Skip to content

Commit 77212f4

Browse files
author
Clement Champetier
committed
StreamProperties: added list of private codec options
Do not print them with other properties, since: * they are very specific options. * not all of them can be printed. * we can access them with getter methods (getCodecOptions).
1 parent 4574951 commit 77212f4

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

src/AvTranscoder/properties/StreamProperties.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,21 @@ StreamProperties::StreamProperties(const FormatContext& formatContext, const siz
2828
_codecContext = _formatContext->streams[_streamIndex]->codec;
2929
}
3030

31+
// find the decoder
3132
if(_formatContext && _codecContext)
33+
{
3234
_codec = avcodec_find_decoder(_codecContext->codec_id);
35+
36+
if(_codec)
37+
{
38+
// load specific options of the codec
39+
if(avcodec_open2(_codecContext, _codec, NULL) == 0)
40+
{
41+
loadOptions(_options, _codecContext);
42+
avcodec_close(_codecContext);
43+
}
44+
}
45+
}
3346
}
3447

3548
StreamProperties::~StreamProperties()
@@ -98,6 +111,16 @@ std::string StreamProperties::getCodecLongName() const
98111
return std::string(_codec->long_name);
99112
}
100113

114+
std::vector<Option> StreamProperties::getCodecOptions()
115+
{
116+
std::vector<Option> optionsArray;
117+
for(OptionMap::iterator it = _options.begin(); it != _options.end(); ++it)
118+
{
119+
optionsArray.push_back(it->second);
120+
}
121+
return optionsArray;
122+
}
123+
101124
PropertyVector StreamProperties::asVector() const
102125
{
103126
PropertyVector propertyVector;

src/AvTranscoder/properties/StreamProperties.hpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define _AV_TRANSCODER_MEDIA_PROPERTY_STREAM_PROPERTIES_HPP
33

44
#include <AvTranscoder/common.hpp>
5+
#include <AvTranscoder/Option.hpp>
56
#include <AvTranscoder/properties/util.hpp>
67
#include <AvTranscoder/file/FormatContext.hpp>
78

@@ -27,6 +28,17 @@ class AvExport StreamProperties
2728

2829
const PropertyVector& getMetadatas() const { return _metadatas; }
2930

31+
/**
32+
* @return The list of private codec options.
33+
* @see getOptionsMap
34+
* @see getOption
35+
*/
36+
OptionArray getCodecOptions();
37+
#ifndef SWIG
38+
OptionMap& getCodecOptionsMap() { return _options; } ///< Get options as map
39+
#endif
40+
Option& getCodecOption(const std::string& optionName) { return _options.at(optionName); }
41+
3042
#ifndef SWIG
3143
const AVFormatContext& getAVFormatContext() const { return *_formatContext; }
3244
#endif
@@ -59,6 +71,8 @@ class AvExport StreamProperties
5971

6072
size_t _streamIndex;
6173
PropertyVector _metadatas;
74+
75+
OptionMap _options;
6276
};
6377

6478
#ifndef SWIG

0 commit comments

Comments
 (0)