You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
PayloadAPP/Src/Video/cffmpeg_decode.h

82 lines
1.6 KiB
C

#ifndef CFFMPEG_DECODE_H
#define CFFMPEG_DECODE_H
#include <QDebug>
#include <QImage>
#include <QPaintEvent>
#include <QPainter>
#include <QThread>
#include <QWidget>
extern "C" {
#include "libavcodec/avcodec.h"
#include <libavutil/channel_layout.h>
#include <libavutil/common.h>
#include <libavutil/frame.h>
#include <libavutil/imgutils.h>
#include <libavutil/mem.h>
#include <libavutil/opt.h>
#include <libavutil/parseutils.h>
#include <libavutil/samplefmt.h>
#include <libswscale/swscale.h>
#include <libavformat/avformat.h>
}
// class Cffmpeg_decode: public QThread
class Cffmpeg_decode : public QObject {
Q_OBJECT
public:
// explicit Cffmpeg_decode();
Cffmpeg_decode(QObject *parent = nullptr);
~Cffmpeg_decode();
public:
void setUrl(QString url);
bool open_input_file();
bool IsstopPlay = false;
void stop();
public slots:
void run();
signals:
void sendQImage(QImage);
void sendConnectFail(int);
private:
AVFormatContext *inputFormatCtx = NULL; //
AVFormatContext *outputFormatCtx = NULL; //
AVCodecContext *decoderCtx = NULL; //
AVCodecContext *encoderCtx = NULL;//
const AVCodec *decoder = NULL; // 解码器
const AVCodec *encoder = NULL; //
AVPacket *inputPacket = NULL; //
AVPacket *outputPacket = NULL; //
AVFrame *yuvFrame = NULL;
AVFrame *rgbFrame = NULL;
struct SwsContext *swsCtx = NULL;
AVCodecParameters *videoCodecPara = nullptr;
AVCodecParameters *videoCodecPara2 = nullptr;
AVStream *outStream;
unsigned char *out_buffer = nullptr;
int videoStreamIndex = -1;
int videoStreamIndexOut = -1;
int numBytes = -1;
QString _url;
};
#endif // CFFMPEG_DECODE_H