Skip to content

Profile audio: check some values when setProfile #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 17, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/AvTranscoder/EssenceStream/OutputAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,22 @@ void OutputAudio::setProfile( Profile::ProfileDesc& desc, const AudioFrameDesc&
if( ! desc.count( Profile::avProfileCodec ) ||
! desc.count( Profile::avProfileSampleFormat ) ||
! desc.count( Profile::avProfileSampleRate ) ||
! desc.count( Profile::avProfileChannel ) )
! desc.count( Profile::avProfileChannel ) ||
! desc.count( Profile::avProfileChannelLayout ) )
{
throw std::runtime_error( "The profile " + desc[ Profile::avProfileIdentificatorHuman ] + " is invalid." );
}

// check some values of the profile
if( desc[ Profile::avProfileSampleRate ] == "0" )
throw std::runtime_error( "Profile " + desc[ Profile::avProfileIdentificatorHuman ] + ": bad sample rate." );

if( desc[ Profile::avProfileChannel ] == "0" )
throw std::runtime_error( "Profile " + desc[ Profile::avProfileIdentificatorHuman ] + ": bad audio channel." );

if( desc[ Profile::avProfileChannelLayout ] == "0" )
throw std::runtime_error( "Profile " + desc[ Profile::avProfileIdentificatorHuman ] + ": bad audio channel layout." );

_audioDesc.setAudioCodec( desc[ Profile::avProfileCodec ] );
size_t sample_rate = std::strtoul( desc[ Profile::avProfileSampleRate ].c_str(), NULL, 0 );
size_t channels = std::strtoul( desc[ Profile::avProfileChannel ].c_str(), NULL, 0 );
Expand Down
3 changes: 2 additions & 1 deletion src/AvTranscoder/Profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ const std::string Profile::avProfilePixelFormat( "pix_fmt" );
const std::string Profile::avProfileSampleFormat( "sample_fmt" );
const std::string Profile::avProfileFrameRate( "r" );
const std::string Profile::avProfileSampleRate( "ar" );
const std::string Profile::avProfileChannel( "channel" );
const std::string Profile::avProfileChannel( "ac" );
const std::string Profile::avProfileChannelLayout( "channel_layout" );
const std::string Profile::avProfileWidth( "width" );
const std::string Profile::avProfileHeight( "height" );

Expand Down
1 change: 1 addition & 0 deletions src/AvTranscoder/Profile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class Profile
static const std::string avProfileFrameRate;
static const std::string avProfileSampleRate;
static const std::string avProfileChannel;
static const std::string avProfileChannelLayout;

static const std::string avProfileWidth;
static const std::string avProfileHeight;
Expand Down
2 changes: 2 additions & 0 deletions src/AvTranscoder/Profiles/Wave.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ void loadWave( Profile::ProfilesDesc& profiles )
wave24b48kMono[ Profile::avProfileSampleFormat ] = "s32";
wave24b48kMono[ Profile::avProfileSampleRate ] = "48000";
wave24b48kMono[ Profile::avProfileChannel ] = "1";
wave24b48kMono[ Profile::avProfileChannelLayout ] = "1";

Profile::ProfileDesc wave16b48kMono;

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

profiles.push_back( wave24b48kMono );
profiles.push_back( wave16b48kMono );
Expand Down