-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathICodec.hpp
More file actions
77 lines (60 loc) · 1.96 KB
/
Copy pathICodec.hpp
File metadata and controls
77 lines (60 loc) · 1.96 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
#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();
/// Reset the codec context.
void closeCodec();
std::string getCodecName() const;
AVCodecID getCodecId() const;
ECodecType getCodecType() const { return _type; }
int getLatency() const;
OptionArray getOptions(); ///< Get options as array
#ifndef SWIG
OptionMap& getOptionsMap() { return _options; } ///< Get options as map
#endif
Option& getOption(const std::string& optionName) { return _options.at(optionName); }
#ifndef SWIG
AVCodecContext& getAVCodecContext() { return *_avCodecContext; }
const AVCodecContext& getAVCodecContext() const { return *_avCodecContext; }
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)
const AVCodec* _avCodec; ///< Codec abstract description
const bool _isCodecContextAllocated; ///< Is the AVCodecContext allocated by the class
ECodecType _type;
OptionMap _options;
};
}
#endif