Skip to content

Commit bd01298

Browse files
author
Clement Champetier
committed
StreamTranscoder: updated constructor parameters
To get all inputStreamDesc instead of only the array of channel index.
1 parent 8c95f63 commit bd01298

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

src/AvTranscoder/transcoder/StreamTranscoder.cpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
#include "StreamTranscoder.hpp"
32

43
#include <AvTranscoder/stream/InputStream.hpp>
@@ -31,7 +30,7 @@ StreamTranscoder::StreamTranscoder(IInputStream& inputStream, IOutputFile& outpu
3130
, _outputEncoder(NULL)
3231
, _transform(NULL)
3332
, _filterGraph(NULL)
34-
, _channelIndexArray()
33+
, _inputStreamDesc()
3534
, _offset(offset)
3635
, _needToSwitchToGenerator(false)
3736
{
@@ -121,8 +120,8 @@ StreamTranscoder::StreamTranscoder(IInputStream& inputStream, IOutputFile& outpu
121120
setOffset(offset);
122121
}
123122

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)
126125
: _inputStream(&inputStream)
127126
, _outputStream(NULL)
128127
, _sourceBuffer(NULL)
@@ -133,7 +132,7 @@ StreamTranscoder::StreamTranscoder(IInputStream& inputStream, IOutputFile& outpu
133132
, _outputEncoder(NULL)
134133
, _transform(NULL)
135134
, _filterGraph(NULL)
136-
, _channelIndexArray(channelIndexArray)
135+
, _inputStreamDesc(inputStreamDesc)
137136
, _offset(offset)
138137
, _needToSwitchToGenerator(false)
139138
{
@@ -191,17 +190,17 @@ StreamTranscoder::StreamTranscoder(IInputStream& inputStream, IOutputFile& outpu
191190

192191
AudioFrameDesc outputFrameDesc(_inputStream->getAudioCodec().getAudioFrameDesc());
193192
outputFrameDesc.setParameters(profile);
194-
if(!_channelIndexArray.empty())
195-
outputFrameDesc._nbChannels = _channelIndexArray.size();
193+
if(_inputStreamDesc.demultiplexing())
194+
outputFrameDesc._nbChannels = _inputStreamDesc._channelIndexArray.size();
196195
outputAudio->setupAudioEncoder(outputFrameDesc, profile);
197196

198197
// output stream
199198
_outputStream = &outputFile.addAudioStream(outputAudio->getAudioCodec());
200199

201200
// buffers to process
202201
AudioFrameDesc inputFrameDesc(_inputStream->getAudioCodec().getAudioFrameDesc());
203-
if(!_channelIndexArray.empty())
204-
inputFrameDesc._nbChannels = _channelIndexArray.size();
202+
if(_inputStreamDesc.demultiplexing())
203+
inputFrameDesc._nbChannels = _inputStreamDesc._channelIndexArray.size();
205204

206205
_sourceBuffer = new AudioFrame(inputFrameDesc);
207206
_frameBuffer = new AudioFrame(outputAudio->getAudioCodec().getAudioFrameDesc());
@@ -234,7 +233,7 @@ StreamTranscoder::StreamTranscoder(IOutputFile& outputFile, const ProfileLoader:
234233
, _outputEncoder(NULL)
235234
, _transform(NULL)
236235
, _filterGraph(NULL)
237-
, _channelIndexArray()
236+
, _inputStreamDesc()
238237
, _offset(0)
239238
, _needToSwitchToGenerator(false)
240239
{
@@ -466,10 +465,10 @@ bool StreamTranscoder::processTranscode()
466465

467466
LOG_DEBUG("Decode next frame")
468467
bool decodingStatus = false;
469-
if(_channelIndexArray.empty())
470-
decodingStatus = _currentDecoder->decodeNextFrame(*_sourceBuffer);
468+
if(_inputStreamDesc.demultiplexing())
469+
decodingStatus = _currentDecoder->decodeNextFrame(*_sourceBuffer, _inputStreamDesc._channelIndexArray);
471470
else
472-
decodingStatus = _currentDecoder->decodeNextFrame(*_sourceBuffer, _channelIndexArray);
471+
decodingStatus = _currentDecoder->decodeNextFrame(*_sourceBuffer);
473472

474473
CodedData data;
475474
if(decodingStatus)

src/AvTranscoder/transcoder/StreamTranscoder.hpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
#include <AvTranscoder/common.hpp>
55

6+
#include <AvTranscoder/transcoder/InputStreamDesc.hpp>
7+
68
#include <AvTranscoder/stream/IInputStream.hpp>
79
#include <AvTranscoder/stream/IOutputStream.hpp>
810

@@ -33,8 +35,8 @@ class AvExport StreamTranscoder
3335
/**
3436
* @brief Transcode the given stream.
3537
**/
36-
StreamTranscoder(IInputStream& inputStream, IOutputFile& outputFile, const ProfileLoader::Profile& profile,
37-
const std::vector<size_t> channelIndexArray, const float offset = 0);
38+
StreamTranscoder(const InputStreamDesc& inputStreamDesc, IInputStream& inputStream, IOutputFile& outputFile,
39+
const ProfileLoader::Profile& profile, const float offset = 0);
3840

3941
/**
4042
* @brief Encode a generated stream
@@ -135,8 +137,7 @@ class AvExport StreamTranscoder
135137

136138
FilterGraph* _filterGraph; ///< Filter graph (has ownership)
137139

138-
std::vector<size_t>
139-
_channelIndexArray; ///< List of channels that is processed from the input stream (empty if no demultiplexing).
140+
const InputStreamDesc _inputStreamDesc; ///< Description of the data to extract from the input stream.
140141

141142
float _offset; ///< Offset, in seconds, at the beginning of the StreamTranscoder.
142143

src/AvTranscoder/transcoder/Transcoder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ void Transcoder::addTranscodeStream(const InputStreamDesc& inputStreamDesc, cons
242242
case AVMEDIA_TYPE_AUDIO:
243243
{
244244
_streamTranscodersAllocated.push_back(
245-
new StreamTranscoder(inputStream, _outputFile, profile, inputStreamDesc._channelIndexArray, offset));
245+
new StreamTranscoder(inputStreamDesc, inputStream, _outputFile, profile, offset));
246246
_streamTranscoders.push_back(_streamTranscodersAllocated.back());
247247
break;
248248
}

0 commit comments

Comments
 (0)