Skip to content

Commit 6daa64c

Browse files
Merge pull request #126 from cchampet/dev_demux_rewrap
Manage "rewrap" of stream in case of demultiplexing
2 parents 1dd2f6e + e9f206a commit 6daa64c

File tree

10 files changed

+182
-103
lines changed

10 files changed

+182
-103
lines changed

src/AvTranscoder/ProfileLoader.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,17 @@ void ProfileLoader::loadProfiles( const std::string& avProfilesPath )
8585

8686
void ProfileLoader::update( const Profile& profile )
8787
{
88-
std::string profileId( profile.find( constants::avProfileIdentificator )->second );
88+
Profile::const_iterator profileIt = profile.find( constants::avProfileIdentificator );
89+
if( profileIt == profile.end() )
90+
throw std::runtime_error( "Invalid profile: can't get identificator" );
91+
92+
std::string profileId( profileIt->second );
8993
size_t profileIndex = 0;
9094
for( Profiles::iterator it = _profiles.begin(); it != _profiles.end(); ++it )
9195
{
96+
// profile already exists
9297
if( (*it).find( constants::avProfileIdentificator )->second == profileId )
93-
{
94-
_profiles.at( profileIndex ) = profile;
9598
return;
96-
}
9799
++profileIndex;
98100
}
99101
// profile not found: add the new profile

src/AvTranscoder/mediaProperty/AudioStreamProperty.hpp

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,22 +43,25 @@ avtranscoder::AudioProperties audioStreamInfo( const AVFormatContext* formatCont
4343
if( channelDescription )
4444
ap.channelDescription = std::string( channelDescription );
4545
#endif
46-
46+
const char* fmtName = av_get_sample_fmt_name( codec_context->sample_fmt );
47+
if( fmtName )
48+
ap.sampleFormatName = std::string( fmtName );
49+
4750
std::string sampleFormat = "";
4851
switch( codec_context->sample_fmt )
4952
{
50-
case AV_SAMPLE_FMT_NONE : ap.sampleFormat = "none"; break;
51-
case AV_SAMPLE_FMT_U8 : ap.sampleFormat = "unsigned 8 bits"; break;
52-
case AV_SAMPLE_FMT_S16 : ap.sampleFormat = "signed 16 bits"; break;
53-
case AV_SAMPLE_FMT_S32 : ap.sampleFormat = "signed 32 bits"; break;
54-
case AV_SAMPLE_FMT_FLT : ap.sampleFormat = "float"; break;
55-
case AV_SAMPLE_FMT_DBL : ap.sampleFormat = "double"; break;
56-
case AV_SAMPLE_FMT_U8P : ap.sampleFormat = "unsigned 8 bits, planar"; break;
57-
case AV_SAMPLE_FMT_S16P : ap.sampleFormat = "signed 16 bits, planar"; break;
58-
case AV_SAMPLE_FMT_S32P : ap.sampleFormat = "signed 32 bits, planar"; break;
59-
case AV_SAMPLE_FMT_FLTP : ap.sampleFormat = "float, planar"; break;
60-
case AV_SAMPLE_FMT_DBLP : ap.sampleFormat = "double, planar"; break;
61-
case AV_SAMPLE_FMT_NB : ap.sampleFormat = "Number of sample formats."; break;
53+
case AV_SAMPLE_FMT_NONE : ap.sampleFormatLongName = "none"; break;
54+
case AV_SAMPLE_FMT_U8 : ap.sampleFormatLongName = "unsigned 8 bits"; break;
55+
case AV_SAMPLE_FMT_S16 : ap.sampleFormatLongName = "signed 16 bits"; break;
56+
case AV_SAMPLE_FMT_S32 : ap.sampleFormatLongName = "signed 32 bits"; break;
57+
case AV_SAMPLE_FMT_FLT : ap.sampleFormatLongName = "float"; break;
58+
case AV_SAMPLE_FMT_DBL : ap.sampleFormatLongName = "double"; break;
59+
case AV_SAMPLE_FMT_U8P : ap.sampleFormatLongName = "unsigned 8 bits, planar"; break;
60+
case AV_SAMPLE_FMT_S16P : ap.sampleFormatLongName = "signed 16 bits, planar"; break;
61+
case AV_SAMPLE_FMT_S32P : ap.sampleFormatLongName = "signed 32 bits, planar"; break;
62+
case AV_SAMPLE_FMT_FLTP : ap.sampleFormatLongName = "float, planar"; break;
63+
case AV_SAMPLE_FMT_DBLP : ap.sampleFormatLongName = "double, planar"; break;
64+
case AV_SAMPLE_FMT_NB : ap.sampleFormatLongName = "Number of sample formats."; break;
6265
}
6366

6467
return ap;

src/AvTranscoder/mediaProperty/mediaProperty.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ MetadatasMap AudioProperties::getDataMap() const
114114
detail::add( dataMap, "codec id", codecId );
115115
detail::add( dataMap, "codec name", codecName );
116116
detail::add( dataMap, "codec long name", codecLongName );
117-
detail::add( dataMap, "sample format", sampleFormat );
117+
detail::add( dataMap, "sample format name", sampleFormatName );
118+
detail::add( dataMap, "sample format long name", sampleFormatLongName );
118119
detail::add( dataMap, "sample rate", sampleRate );
119120
detail::add( dataMap, "bit rate", bit_rate );
120121
detail::add( dataMap, "channels", channels );

src/AvTranscoder/mediaProperty/mediaProperty.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ struct AvExport AudioProperties
106106
{
107107
std::string codecName;
108108
std::string codecLongName;
109-
std::string sampleFormat;
109+
std::string sampleFormatName;
110+
std::string sampleFormatLongName;
110111
std::string channelLayout;
111112
std::string channelName;
112113
std::string channelDescription;

src/AvTranscoder/transcoder/StreamTranscoder.cpp

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -283,11 +283,7 @@ bool StreamTranscoder::processFrame()
283283

284284
if( ! _inputEssence )
285285
{
286-
if( _subStreamIndex < 0 )
287-
{
288-
return processRewrap();
289-
}
290-
return processRewrap( _subStreamIndex );
286+
return processRewrap();
291287
}
292288

293289
if( _subStreamIndex < 0 )
@@ -311,20 +307,6 @@ bool StreamTranscoder::processRewrap()
311307
return true;
312308
}
313309

314-
bool StreamTranscoder::processRewrap( const int subStreamIndex )
315-
{
316-
assert( _inputStream != NULL );
317-
assert( _outputStream != NULL );
318-
319-
CodedData data;
320-
321-
if( ! _inputStream->readNextPacket( data ) )
322-
return false;
323-
_outputStream->wrap( data );
324-
325-
return true;
326-
}
327-
328310
bool StreamTranscoder::processTranscode()
329311
{
330312
assert( _inputEssence != NULL );

src/AvTranscoder/transcoder/StreamTranscoder.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ class AvExport StreamTranscoder
7171

7272
private:
7373
bool processRewrap();
74-
bool processRewrap( const int subStreamIndex );
7574
bool processTranscode();
7675
bool processTranscode( const int subStreamIndex );
7776

0 commit comments

Comments
 (0)