forked from avTranscoder/avTranscoder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStreamProperties.hpp
More file actions
87 lines (70 loc) · 2.65 KB
/
StreamProperties.hpp
File metadata and controls
87 lines (70 loc) · 2.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#ifndef _AV_TRANSCODER_MEDIA_PROPERTY_STREAM_PROPERTIES_HPP
#define _AV_TRANSCODER_MEDIA_PROPERTY_STREAM_PROPERTIES_HPP
#include <AvTranscoder/common.hpp>
#include <AvTranscoder/Option.hpp>
#include <AvTranscoder/properties/util.hpp>
#include <AvTranscoder/file/FormatContext.hpp>
namespace avtranscoder
{
class FileProperties;
/// Virtual based class of properties for all types of stream
class AvExport StreamProperties
{
public:
StreamProperties(const FileProperties& fileProperties, const size_t index);
virtual ~StreamProperties() = 0;
size_t getStreamIndex() const { return _streamIndex; }
size_t getStreamId() const;
Rational getTimeBase() const;
AVMediaType getStreamType() const;
virtual float getDuration() const; ///< in seconds, 0 if not available
size_t getCodecId() const;
std::string getCodecName() const;
std::string getCodecLongName() const;
const PropertyVector& getMetadatas() const { return _metadatas; }
/**
* @return The list of private codec options.
* @see getOptionsMap
* @see getOption
*/
OptionArray getCodecOptions();
#ifndef SWIG
OptionMap& getCodecOptionsMap() { return _options; } ///< Get options as map
#endif
Option& getCodecOption(const std::string& optionName) { return _options.at(optionName); }
#ifndef SWIG
const AVFormatContext& getAVFormatContext() const { return *_formatContext; }
#endif
std::string asJson() const; ///< Return all properties as a json format.
PropertyMap asMap() const; ///< Return all properties as a map (name of property, value)
PropertyVector asVector() const; ///< Same data with a specific order
virtual PropertyVector& fillVector(PropertyVector& data) const; ///< To avoid copy of the vector
private:
#ifndef SWIG
template <typename T>
void addProperty(PropertyVector& dataVector, const std::string& key, T (StreamProperties::*getter)(void) const) const
{
try
{
detail::add(dataVector, key, (this->*getter)());
}
catch(const std::exception& e)
{
detail::add(dataVector, key, detail::propertyValueIfError);
}
}
#endif
protected:
const FileProperties* _fileProperties; ///< Has link (no ownership)
const AVFormatContext* _formatContext; ///< Has link (no ownership)
AVCodecContext* _codecContext; ///< Has link (no ownership)
const AVCodec* _codec; ///< Has link (no ownership)
size_t _streamIndex;
PropertyVector _metadatas;
OptionMap _options;
};
#ifndef SWIG
AvExport std::ostream& operator<<(std::ostream& flux, const StreamProperties& streamProperties);
#endif
}
#endif