39 lines
859 B
C++
39 lines
859 B
C++
#pragma once
|
|
#include <memory>
|
|
|
|
struct AVCodecContext;
|
|
struct AVCodecParameters;
|
|
struct AVPacket;
|
|
struct AVFrame;
|
|
|
|
namespace engine::ffmpeg {
|
|
|
|
class CodecContext {
|
|
public:
|
|
CodecContext() = default;
|
|
~CodecContext() = default;
|
|
CodecContext(const CodecContext &) = delete;
|
|
CodecContext &operator=(const CodecContext &) = delete;
|
|
|
|
bool open(const AVCodecParameters *par);
|
|
void close();
|
|
|
|
bool sendPacket(const AVPacket *pkt) const;
|
|
|
|
bool receiveFrame(AVFrame *frame) const;
|
|
|
|
void flush();
|
|
|
|
bool isOpen() const { return m_ctx != nullptr; }
|
|
int sampleRate()const;
|
|
int channels() const;
|
|
|
|
const AVCodecContext *get() const { return m_ctx.get(); }
|
|
|
|
private:
|
|
struct Deleter { void operator()(AVCodecContext *p) const; };
|
|
std::unique_ptr<AVCodecContext, Deleter> m_ctx;
|
|
};
|
|
|
|
} // namespace engine::ffmpeg
|