1
-
2
1
#include " StreamTranscoder.hpp"
3
2
4
3
#include < AvTranscoder/stream/InputStream.hpp>
@@ -31,7 +30,7 @@ StreamTranscoder::StreamTranscoder(IInputStream& inputStream, IOutputFile& outpu
31
30
, _outputEncoder(NULL )
32
31
, _transform(NULL )
33
32
, _filterGraph(NULL )
34
- , _channelIndexArray ()
33
+ , _inputStreamDesc ()
35
34
, _offset(offset)
36
35
, _needToSwitchToGenerator(false )
37
36
{
@@ -121,8 +120,8 @@ StreamTranscoder::StreamTranscoder(IInputStream& inputStream, IOutputFile& outpu
121
120
setOffset (offset);
122
121
}
123
122
124
- StreamTranscoder::StreamTranscoder (IInputStream& inputStream, IOutputFile& outputFile, const ProfileLoader::Profile& profile ,
125
- const std::vector< size_t > channelIndexArray , const float offset)
123
+ StreamTranscoder::StreamTranscoder (const InputStreamDesc& inputStreamDesc, IInputStream& inputStream, IOutputFile& outputFile ,
124
+ const ProfileLoader::Profile& profile , const float offset)
126
125
: _inputStream(&inputStream)
127
126
, _outputStream(NULL )
128
127
, _sourceBuffer(NULL )
@@ -133,7 +132,7 @@ StreamTranscoder::StreamTranscoder(IInputStream& inputStream, IOutputFile& outpu
133
132
, _outputEncoder(NULL )
134
133
, _transform(NULL )
135
134
, _filterGraph(NULL )
136
- , _channelIndexArray(channelIndexArray )
135
+ , _inputStreamDesc(inputStreamDesc )
137
136
, _offset(offset)
138
137
, _needToSwitchToGenerator(false )
139
138
{
@@ -191,17 +190,17 @@ StreamTranscoder::StreamTranscoder(IInputStream& inputStream, IOutputFile& outpu
191
190
192
191
AudioFrameDesc outputFrameDesc (_inputStream->getAudioCodec ().getAudioFrameDesc ());
193
192
outputFrameDesc.setParameters (profile);
194
- if (!_channelIndexArray. empty ())
195
- outputFrameDesc._nbChannels = _channelIndexArray.size ();
193
+ if (_inputStreamDesc. demultiplexing ())
194
+ outputFrameDesc._nbChannels = _inputStreamDesc. _channelIndexArray .size ();
196
195
outputAudio->setupAudioEncoder (outputFrameDesc, profile);
197
196
198
197
// output stream
199
198
_outputStream = &outputFile.addAudioStream (outputAudio->getAudioCodec ());
200
199
201
200
// buffers to process
202
201
AudioFrameDesc inputFrameDesc (_inputStream->getAudioCodec ().getAudioFrameDesc ());
203
- if (!_channelIndexArray. empty ())
204
- inputFrameDesc._nbChannels = _channelIndexArray.size ();
202
+ if (_inputStreamDesc. demultiplexing ())
203
+ inputFrameDesc._nbChannels = _inputStreamDesc. _channelIndexArray .size ();
205
204
206
205
_sourceBuffer = new AudioFrame (inputFrameDesc);
207
206
_frameBuffer = new AudioFrame (outputAudio->getAudioCodec ().getAudioFrameDesc ());
@@ -234,7 +233,7 @@ StreamTranscoder::StreamTranscoder(IOutputFile& outputFile, const ProfileLoader:
234
233
, _outputEncoder(NULL )
235
234
, _transform(NULL )
236
235
, _filterGraph(NULL )
237
- , _channelIndexArray ()
236
+ , _inputStreamDesc ()
238
237
, _offset(0 )
239
238
, _needToSwitchToGenerator(false )
240
239
{
@@ -466,10 +465,10 @@ bool StreamTranscoder::processTranscode()
466
465
467
466
LOG_DEBUG (" Decode next frame" )
468
467
bool decodingStatus = false ;
469
- if (_channelIndexArray. empty ())
470
- decodingStatus = _currentDecoder->decodeNextFrame (*_sourceBuffer);
468
+ if (_inputStreamDesc. demultiplexing ())
469
+ decodingStatus = _currentDecoder->decodeNextFrame (*_sourceBuffer, _inputStreamDesc. _channelIndexArray );
471
470
else
472
- decodingStatus = _currentDecoder->decodeNextFrame (*_sourceBuffer, _channelIndexArray );
471
+ decodingStatus = _currentDecoder->decodeNextFrame (*_sourceBuffer);
473
472
474
473
CodedData data;
475
474
if (decodingStatus)
0 commit comments