Skip to content

Commit 5df34b5

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 5df34b5

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

src/AvTranscoder/properties/StreamProperties.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,23 @@ 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+
avcodec_open2(_codecContext, _codec, NULL);
40+
loadOptions(_options, _codecContext->priv_data);
41+
}
42+
}
3343
}
3444

3545
StreamProperties::~StreamProperties()
3646
{
47+
avcodec_close(_codecContext);
3748
}
3849

3950
size_t StreamProperties::getStreamId() const
@@ -98,6 +109,16 @@ std::string StreamProperties::getCodecLongName() const
98109
return std::string(_codec->long_name);
99110
}
100111

112+
std::vector<Option> StreamProperties::getCodecOptions()
113+
{
114+
std::vector<Option> optionsArray;
115+
for(OptionMap::iterator it = _options.begin(); it != _options.end(); ++it)
116+
{
117+
optionsArray.push_back(it->second);
118+
}
119+
return optionsArray;
120+
}
121+
101122
PropertyVector StreamProperties::asVector() const
102123
{
103124
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)