Skip to content

Commit 6a62a21

Browse files
author
Clement Champetier
committed
Transcoder: updated how to get profile from a file
* Renamed private method 'getProfileFromFile' to 'getProfileFromInput'. * Removed private method 'addTranscodeStream'.
1 parent 44f62ac commit 6a62a21

File tree

2 files changed

+26
-30
lines changed

2 files changed

+26
-30
lines changed

src/AvTranscoder/transcoder/Transcoder.cpp

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ void Transcoder::addStream(const InputStreamDesc& inputStreamDesc, const std::st
4848
addRewrapStream(inputStreamDesc, offset);
4949
// Transcode (transparent for the user)
5050
else
51-
addTranscodeStream(inputStreamDesc, offset);
51+
{
52+
const ProfileLoader::Profile profile = getProfileFromInput(inputStreamDesc);
53+
addStream(inputStreamDesc, profile, offset);
54+
}
5255
}
5356
// Transcode
5457
else
@@ -203,24 +206,6 @@ void Transcoder::addRewrapStream(const InputStreamDesc& inputStreamDesc, const f
203206
_streamTranscoders.push_back(_streamTranscodersAllocated.back());
204207
}
205208

206-
void Transcoder::addTranscodeStream(const InputStreamDesc& inputStreamDesc, const float offset)
207-
{
208-
// Get profile from input file
209-
InputFile inputFile(inputStreamDesc._filename);
210-
ProfileLoader::Profile profile = getProfileFromFile(inputFile, inputStreamDesc._streamIndex);
211-
212-
// override number of channels parameters to manage demultiplexing
213-
if(inputStreamDesc.demultiplexing())
214-
{
215-
// number of channels
216-
std::stringstream ss;
217-
ss << inputStreamDesc._channelIndexArray.size();
218-
profile[constants::avProfileChannel] = ss.str();
219-
}
220-
221-
addTranscodeStream(inputStreamDesc, profile, offset);
222-
}
223-
224209
void Transcoder::addTranscodeStream(const InputStreamDesc& inputStreamDesc, const ProfileLoader::Profile& profile,
225210
const float offset)
226211
{
@@ -296,12 +281,14 @@ InputFile* Transcoder::addInputFile(const std::string& filename, const int strea
296281
return referenceFile;
297282
}
298283

299-
ProfileLoader::Profile Transcoder::getProfileFromFile(InputFile& inputFile, const size_t streamIndex)
300-
{
301-
const StreamProperties* streamProperties = &inputFile.getProperties().getStreamPropertiesWithIndex(streamIndex);
284+
ProfileLoader::Profile Transcoder::getProfileFromInput(const InputStreamDesc& inputStreamDesc)
285+
{
286+
InputFile inputFile(inputStreamDesc._filename);
287+
288+
const StreamProperties* streamProperties = &inputFile.getProperties().getStreamPropertiesWithIndex(inputStreamDesc._streamIndex);
302289
const VideoProperties* videoProperties = NULL;
303290
const AudioProperties* audioProperties = NULL;
304-
switch(inputFile.getStream(streamIndex).getProperties().getStreamType())
291+
switch(inputFile.getStream(inputStreamDesc._streamIndex).getProperties().getStreamType())
305292
{
306293
case AVMEDIA_TYPE_VIDEO:
307294
{
@@ -343,9 +330,18 @@ ProfileLoader::Profile Transcoder::getProfileFromFile(InputFile& inputFile, cons
343330
std::stringstream ss;
344331
ss << audioProperties->getSampleRate();
345332
profile[constants::avProfileSampleRate] = ss.str();
346-
ss.str("");
347-
ss << audioProperties->getNbChannels();
348-
profile[constants::avProfileChannel] = ss.str();
333+
ss.str("");
334+
// override number of channels parameters to manage demultiplexing
335+
if(inputStreamDesc.demultiplexing())
336+
{
337+
ss << inputStreamDesc._channelIndexArray.size();
338+
profile[constants::avProfileChannel] = ss.str();
339+
}
340+
else
341+
{
342+
ss << audioProperties->getNbChannels();
343+
profile[constants::avProfileChannel] = ss.str();
344+
}
349345
}
350346

351347
return profile;

src/AvTranscoder/transcoder/Transcoder.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,6 @@ class AvExport Transcoder
129129

130130
private:
131131
void addRewrapStream(const InputStreamDesc& inputStreamDesc, const float offset);
132-
133-
void addTranscodeStream(const InputStreamDesc& inputStreamDesc, const float offset);
134132
void addTranscodeStream(const InputStreamDesc& inputStreamDesc, const ProfileLoader::Profile& profile,
135133
const float offset = 0);
136134

@@ -139,8 +137,10 @@ class AvExport Transcoder
139137
*/
140138
InputFile* addInputFile(const std::string& filename, const int streamIndex, const float offset);
141139

142-
ProfileLoader::Profile getProfileFromFile(InputFile& inputFile,
143-
const size_t streamIndex); ///< The function analyses the inputFile
140+
/**
141+
* @return The profile from the given input.
142+
*/
143+
ProfileLoader::Profile getProfileFromInput(const InputStreamDesc& inputStreamDesc);
144144

145145
/**
146146
* @brief Get the duration of the stream, in seconds

0 commit comments

Comments
 (0)