74 lines
1.6 KiB
C++
74 lines
1.6 KiB
C++
#ifndef FFCONV_CODEC_H
|
|
#define FFCONV_CODEC_H
|
|
|
|
#include "ffcpp.h"
|
|
#include "Packet.h"
|
|
#include "Frame.h"
|
|
|
|
extern "C" {
|
|
#include <libavformat/avformat.h>
|
|
}
|
|
|
|
#include <memory>
|
|
|
|
namespace ffcpp {
|
|
|
|
enum class CodecType {
|
|
Encoder,
|
|
Decoder
|
|
};
|
|
|
|
typedef std::shared_ptr<class Codec> CodecPtr;
|
|
|
|
class Codec {
|
|
private:
|
|
AVCodec* _codec;
|
|
AVCodecContext* _codecCtx;
|
|
mutable FramePtr _tmpFrame;
|
|
mutable PacketPtr _tmpPacket;
|
|
|
|
public:
|
|
Codec();
|
|
Codec(AVCodecID codecId, CodecType type, AVCodecParameters* params = nullptr);
|
|
Codec(AVCodecContext* ctx, AVCodec* codec);
|
|
~Codec();
|
|
|
|
operator AVCodecContext*() const;
|
|
|
|
const AVCodec* nativeCodecPtr() const;
|
|
|
|
int width() const;
|
|
int height() const;
|
|
AVRational timeBase() const;
|
|
int capabilities() const;
|
|
AVPixelFormat pixelFormat() const;
|
|
AVSampleFormat sampleFormat() const;
|
|
int frameSize() const;
|
|
int channels() const;
|
|
int sampleRate() const;
|
|
int channelLayout() const;
|
|
|
|
void setWidth(int width);
|
|
void setHeight(int height);
|
|
void setPixelFormat(AVPixelFormat pixelFormat);
|
|
void setTimeBase(AVRational timeBase);
|
|
void setSampleFormat(AVSampleFormat sampleFormat);
|
|
void setGlobalQuality(int quality);
|
|
void setChannelCount(int channels);
|
|
void setChannelLayout(uint64_t layout);
|
|
void setSampleRate(int sampleRate);
|
|
void setStdCompliance(int compliance);
|
|
|
|
std::tuple<FramePtr, bool> decode(PacketPtr packet);
|
|
Packet encode(FramePtr frame);
|
|
FramePtr createAudioFrame() const;
|
|
|
|
public:
|
|
Codec(Codec&& c) noexcept;
|
|
Codec& operator=(Codec&& c) noexcept;
|
|
};
|
|
|
|
}
|
|
|
|
#endif //FFCONV_CODEC_H
|