-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathICodec.hpp
More file actions
77 lines (57 loc) · 1.84 KB
/
Copy pathICodec.hpp
File metadata and controls
77 lines (57 loc) · 1.84 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
#ifndef _AV_TRANSCODER_CODEC_ICODEC_HPP_
#define _AV_TRANSCODER_CODEC_ICODEC_HPP_
#include <AvTranscoder/common.hpp>
#include <AvTranscoder/Option.hpp>
extern "C" {
#include <libavcodec/avcodec.h>
}
#include <string>
namespace avtranscoder
{
/**
* @brief Define if a codec is for encoding or decoding.
*/
enum ECodecType
{
eCodecTypeEncoder,
eCodecTypeDecoder
};
class AvExport ICodec
{
private:
ICodec( const ICodec& iCodec );
ICodec& operator=( const ICodec& iCodec );
public:
ICodec( const ECodecType type, const std::string& codecName );
ICodec( const ECodecType type, const AVCodecID codecId );
ICodec( const ECodecType type, AVCodecContext& avCodecContext );
virtual ~ICodec() = 0;
/// Initialize the codec context.
void openCodec();
std::string getCodecName() const;
AVCodecID getCodecId() const;
ECodecType getCodecType() const { return _type; }
int getLatency() const;
OptionArray getOptions(); ///< Get options as array
OptionMap& getOptionsMap() { return _options; } ///< Get options as map
Option& getOption( const std::string& optionName ) { return _options.at(optionName); }
#ifndef SWIG
AVCodecContext& getAVCodecContext() { return *_avCodecContext; }
const AVCodecContext& getAVCodecContext() const { return *_avCodecContext; }
AVCodec& getAVCodec() { return *_avCodec; }
const AVCodec& getAVCodec() const { return *_avCodec; }
#endif
private:
void setCodec( const ECodecType type, const std::string& codecName );
void setCodec( const ECodecType type, const AVCodecID codecId );
void allocateContext();
void loadCodecOptions();
protected:
AVCodecContext* _avCodecContext; ///< Full codec instance description (has ownership)
AVCodec* _avCodec; ///< Codec abstract description
const bool _isCodecContextAllocated; ///< Is the AVCodecContext allocated by the class
ECodecType _type;
OptionMap _options;
};
}
#endif