56 lines
1006 B
C++
56 lines
1006 B
C++
#ifndef FFCONV_CODEC_H
|
|
#define FFCONV_CODEC_H
|
|
|
|
#include "ffcpp.h"
|
|
#include "Packet.h"
|
|
#include "Frame.h"
|
|
|
|
extern "C" {
|
|
#include <libavformat/avformat.h>
|
|
}
|
|
|
|
namespace ffcpp {
|
|
|
|
enum class CodecType {
|
|
Encoder,
|
|
Decoder
|
|
};
|
|
|
|
class Codec: public non_copyable {
|
|
private:
|
|
AVCodec* _codec;
|
|
AVCodecContext* _codecCtx;
|
|
|
|
public:
|
|
Codec();
|
|
Codec(AVCodecContext* ctx, CodecType type);
|
|
Codec(AVCodecContext* ctx, AVCodec* codec);
|
|
~Codec();
|
|
|
|
operator AVCodecContext*() const;
|
|
|
|
int width() const;
|
|
int height() const;
|
|
AVRational timeBase() const;
|
|
int capabilities() const;
|
|
AVPixelFormat pixelFormat() const;
|
|
AVSampleFormat sampleFormat() const;
|
|
int frameSize() const;
|
|
|
|
void setWidth(int width);
|
|
void setHeight(int height);
|
|
void setPixelFormat(AVPixelFormat pixelFormat);
|
|
|
|
Frame decode(Packet& packet);
|
|
Packet encode(AVFrame* frame);
|
|
Frame createAudioFrame() const;
|
|
|
|
public:
|
|
Codec(Codec&& c) noexcept;
|
|
Codec& operator=(Codec&& c) noexcept;
|
|
};
|
|
|
|
}
|
|
|
|
#endif //FFCONV_CODEC_H
|