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.
82 lines
1.9 KiB
C++
82 lines
1.9 KiB
C++
#ifndef CFFMPEG_DECODE_H
|
|
#define CFFMPEG_DECODE_H
|
|
|
|
#include "ffmpeginclude.h"
|
|
#include <QDateTime>
|
|
#include <QDebug>
|
|
#include <QDir>
|
|
#include <QImage>
|
|
#include <QPaintEvent>
|
|
#include <QPainter>
|
|
#include <QThread>
|
|
#include <QWidget>
|
|
|
|
// class Cffmpeg_decode: public QThread
|
|
class Cffmpeg_decode : public QObject {
|
|
Q_OBJECT
|
|
public:
|
|
// explicit Cffmpeg_decode();
|
|
Cffmpeg_decode(QObject *parent = nullptr);
|
|
~Cffmpeg_decode();
|
|
|
|
public:
|
|
bool open_input_file();
|
|
void stop();
|
|
/**
|
|
* @brief 设置拉流保存文件夹路径
|
|
* @param fileDirPath 文件夹路径
|
|
*/
|
|
void setSaveFileDirPath(QString fileDirPath);
|
|
public slots:
|
|
void run();
|
|
void setUrl(QString url);
|
|
|
|
signals:
|
|
void sendQImage(QImage);
|
|
void sendConnectFail(int);
|
|
void sendInitPushStream_Signal(AVFormatContext *inputFormatCtx);
|
|
void sendStreamData_Signal(AVPacket *pkt, int frm_cnt);
|
|
|
|
public:
|
|
bool IsstopPlay = false;
|
|
bool bPushStreamFlag = false;
|
|
|
|
private:
|
|
AVFormatContext *inputFormatCtx = NULL; //
|
|
|
|
AVCodecContext *decoderCtx = NULL; //
|
|
AVCodecContext *encoderCtx = NULL; //
|
|
|
|
const AVCodec *decoder = NULL; // 解码器
|
|
|
|
AVPacket *inputPacket = NULL; //
|
|
|
|
AVFrame *yuvFrame = NULL;
|
|
AVFrame *rgbFrame = NULL;
|
|
|
|
struct SwsContext *swsCtx = NULL; // 图像转换上下文
|
|
|
|
AVCodecParameters *videoCodecPara = nullptr;
|
|
|
|
unsigned char *out_buffer = nullptr;
|
|
|
|
int videoStreamIndex = -1;
|
|
int numBytes = -1;
|
|
int frm_cnt = 0;
|
|
|
|
QString _url;
|
|
QString saveFileDirPath;
|
|
bool bRecordTime = true;
|
|
long long startTime;
|
|
/******** 保存裸流使用 ******************/
|
|
AVFormatContext *m_formatContextSave = nullptr; // 封装上下文
|
|
QString m_strCodecName; // 编解码器名称
|
|
AVStream *m_videoStreamOut = nullptr; // 输出视频流
|
|
bool m_writeHeader = false; // 是否写入文件头
|
|
private:
|
|
bool openSave();
|
|
void saveDone();
|
|
};
|
|
|
|
#endif // CFFMPEG_DECODE_H
|