File indexing completed on 2025-01-19 03:57:03

0001 /*********************************************************
0002  * Copyright (C) 2020, Val Doroshchuk <valbok@gmail.com> *
0003  *                                                       *
0004  * This file is part of QtAVPlayer.                      *
0005  * Free Qt Media Player based on FFmpeg.                 *
0006  *********************************************************/
0007 
0008 #ifndef QAVCODEC_P_H
0009 #define QAVCODEC_P_H
0010 
0011 //
0012 //  W A R N I N G
0013 //  -------------
0014 //
0015 // This file is not part of the Qt API. It exists purely as an
0016 // implementation detail. This header file may change from version to
0017 // version without notice, or even be removed.
0018 //
0019 // We mean it.
0020 //
0021 
0022 #include "qavpacket_p.h"
0023 #include "qavframe.h"
0024 #include <QtAVPlayer/qtavplayerglobal.h>
0025 #include <memory>
0026 
0027 QT_BEGIN_NAMESPACE
0028 
0029 struct AVCodec;
0030 struct AVCodecContext;
0031 struct AVStream;
0032 class QAVCodecPrivate;
0033 class QAVCodec
0034 {
0035 public:
0036     virtual ~QAVCodec();
0037 
0038     bool open(AVStream *stream);
0039     AVCodecContext *avctx() const;
0040     void setCodec(const AVCodec *c);
0041     const AVCodec *codec() const;
0042 
0043     void flushBuffers();
0044 
0045     // Sends a packet
0046     virtual int write(const QAVPacket &pkt) = 0;
0047     // Receives a frame
0048     // NOTE: There could be multiple frames
0049     virtual int read(QAVStreamFrame &frame) = 0;
0050 
0051 protected:
0052     QAVCodec();
0053     QAVCodec(QAVCodecPrivate &d);
0054     std::unique_ptr<QAVCodecPrivate> d_ptr;
0055     Q_DECLARE_PRIVATE(QAVCodec)
0056 private:
0057     Q_DISABLE_COPY(QAVCodec)
0058 };
0059 
0060 QT_END_NAMESPACE
0061 
0062 #endif