4 #include <libavutil/mem.h>
14 : _avCodecContext(NULL)
16 , _isCodecContextAllocated(true)
25 : _avCodecContext(NULL)
27 , _isCodecContextAllocated(true)
36 : _avCodecContext(&avCodecContext)
38 , _isCodecContextAllocated(false)
59 throw std::runtime_error(
"Unable to open a codec without codec context");
64 std::string msg =
"Unable to open codec: ";
80 throw std::runtime_error(msg);
87 const AVCodecDescriptor* desc = avcodec_descriptor_get(
_avCodecContext->codec_id);
89 throw std::runtime_error(
"Codec Descriptor is not available.");
108 std::vector<Option> optionsArray;
111 optionsArray.push_back(it->second);
118 const AVCodecDescriptor* avCodecDescriptor = avcodec_descriptor_get_by_name(codecName.c_str());
119 if(!avCodecDescriptor)
121 std::string msg(
"Unable to find codec ");
123 throw std::runtime_error(msg);
126 setCodec(type, avCodecDescriptor->id);
133 LOG_WARN(
"Unsupported codec with id 0")
138 _avCodec = avcodec_find_encoder(codecId);
140 _avCodec = avcodec_find_decoder(codecId);
151 throw std::runtime_error(
"Unable to allocate the codecContext and set its fields to default values");
void loadOptions(OptionMap &outOptions, void *av_class, int req_flags)
ICodec(const ICodec &iCodec)
std::string getDescriptionFromErrorCode(const int code)
Get the string description corresponding to the error code provided by ffmpeg/libav.
AVCodecContext * _avCodecContext
Full codec instance description (has ownership)
AVCodec * _avCodec
Codec abstract description.
ECodecType
Define if a codec is for encoding or decoding.
AVCodecID getCodecId() const
std::string getCodecName() const
const bool _isCodecContextAllocated
Is the AVCodecContext allocated by the class.
OptionArray getOptions()
Get options as array.
void openCodec()
Initialize the codec context.
void setCodec(const ECodecType type, const std::string &codecName)