Skip to content

Commit 7a6b02d

Browse files
Merge pull request #22 from cchampet/master
Profile audio: check some values when setProfile
2 parents 2f9f4a2 + 24da5e0 commit 7a6b02d

File tree

4 files changed

+17
-2
lines changed

4 files changed

+17
-2
lines changed

src/AvTranscoder/EssenceStream/OutputAudio.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,22 @@ void OutputAudio::setProfile( Profile::ProfileDesc& desc, const AudioFrameDesc&
174174
if( ! desc.count( Profile::avProfileCodec ) ||
175175
! desc.count( Profile::avProfileSampleFormat ) ||
176176
! desc.count( Profile::avProfileSampleRate ) ||
177-
! desc.count( Profile::avProfileChannel ) )
177+
! desc.count( Profile::avProfileChannel ) ||
178+
! desc.count( Profile::avProfileChannelLayout ) )
178179
{
179180
throw std::runtime_error( "The profile " + desc[ Profile::avProfileIdentificatorHuman ] + " is invalid." );
180181
}
181182

183+
// check some values of the profile
184+
if( desc[ Profile::avProfileSampleRate ] == "0" )
185+
throw std::runtime_error( "Profile " + desc[ Profile::avProfileIdentificatorHuman ] + ": bad sample rate." );
186+
187+
if( desc[ Profile::avProfileChannel ] == "0" )
188+
throw std::runtime_error( "Profile " + desc[ Profile::avProfileIdentificatorHuman ] + ": bad audio channel." );
189+
190+
if( desc[ Profile::avProfileChannelLayout ] == "0" )
191+
throw std::runtime_error( "Profile " + desc[ Profile::avProfileIdentificatorHuman ] + ": bad audio channel layout." );
192+
182193
_audioDesc.setAudioCodec( desc[ Profile::avProfileCodec ] );
183194
size_t sample_rate = std::strtoul( desc[ Profile::avProfileSampleRate ].c_str(), NULL, 0 );
184195
size_t channels = std::strtoul( desc[ Profile::avProfileChannel ].c_str(), NULL, 0 );

src/AvTranscoder/Profile.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ const std::string Profile::avProfilePixelFormat( "pix_fmt" );
2424
const std::string Profile::avProfileSampleFormat( "sample_fmt" );
2525
const std::string Profile::avProfileFrameRate( "r" );
2626
const std::string Profile::avProfileSampleRate( "ar" );
27-
const std::string Profile::avProfileChannel( "channel" );
27+
const std::string Profile::avProfileChannel( "ac" );
28+
const std::string Profile::avProfileChannelLayout( "channel_layout" );
2829
const std::string Profile::avProfileWidth( "width" );
2930
const std::string Profile::avProfileHeight( "height" );
3031

src/AvTranscoder/Profile.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class Profile
2525
static const std::string avProfileFrameRate;
2626
static const std::string avProfileSampleRate;
2727
static const std::string avProfileChannel;
28+
static const std::string avProfileChannelLayout;
2829

2930
static const std::string avProfileWidth;
3031
static const std::string avProfileHeight;

src/AvTranscoder/Profiles/Wave.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ void loadWave( Profile::ProfilesDesc& profiles )
1616
wave24b48kMono[ Profile::avProfileSampleFormat ] = "s32";
1717
wave24b48kMono[ Profile::avProfileSampleRate ] = "48000";
1818
wave24b48kMono[ Profile::avProfileChannel ] = "1";
19+
wave24b48kMono[ Profile::avProfileChannelLayout ] = "1";
1920

2021
Profile::ProfileDesc wave16b48kMono;
2122

@@ -27,6 +28,7 @@ void loadWave( Profile::ProfilesDesc& profiles )
2728
wave16b48kMono[ Profile::avProfileSampleFormat ] = "s16";
2829
wave16b48kMono[ Profile::avProfileSampleRate ] = "48000";
2930
wave16b48kMono[ Profile::avProfileChannel ] = "1";
31+
wave16b48kMono[ Profile::avProfileChannelLayout ] = "1";
3032

3133
profiles.push_back( wave24b48kMono );
3234
profiles.push_back( wave16b48kMono );

0 commit comments

Comments
 (0)