提交 10859cba 编写于 作者: mahuifa's avatar mahuifa

feat:创建所有需要用到的函数

上级 7c5606b3
......@@ -4,3 +4,33 @@ ReadThread::ReadThread(QObject *parent) : QThread(parent)
{
}
ReadThread::~ReadThread()
{
}
void ReadThread::open(const QString &url)
{
}
void ReadThread::pause(bool flag)
{
}
void ReadThread::close()
{
}
const QString &ReadThread::url()
{
}
void ReadThread::run()
{
}
......@@ -10,17 +10,44 @@
#ifndef READTHREAD_H
#define READTHREAD_H
#include <QElapsedTimer>
#include <QThread>
#include <QTime>
class VideoDecode;
class ReadThread : public QThread
{
Q_OBJECT
public:
enum PlayState // 视频播放状态
{
play,
end
};
public:
explicit ReadThread(QObject *parent = nullptr);
~ReadThread() override;
void open(const QString& url = QString()); // 打开视频
void pause(bool flag); // 暂停视频
void close(); // 关闭视频
const QString& url(); // 获取打开的视频地址
protected:
void run() override;
signals:
void updateImage(const QImage& image); // 将读取到的视频图像发送出去
void playState(PlayState state); // 视频播放状态发送改变时触发
public slots:
private:
VideoDecode* m_videoDecode = nullptr; // 视频解码类
QString m_url; // 打开的视频地址
bool m_play = false; // 播放控制
bool m_pause = false; // 暂停控制
QElapsedTimer m_etime1; // 控制视频播放速度(更精确,但不支持视频后退)
QTime m_etime2; // 控制视频播放速度(支持视频后退)
};
#endif // READTHREAD_H
......@@ -4,3 +4,58 @@ VideoDecode::VideoDecode()
{
}
VideoDecode::~VideoDecode()
{
}
bool VideoDecode::open(const QString &url)
{
}
QImage *VideoDecode::read()
{
}
void VideoDecode::close()
{
}
bool VideoDecode::isEnd()
{
}
const qint64 &VideoDecode::pts()
{
}
void VideoDecode::initFFmpeg()
{
}
void VideoDecode::showError(int err)
{
}
qreal VideoDecode::rationalToDouble(AVRational rational)
{
}
void VideoDecode::clear()
{
}
void VideoDecode::free()
{
}
......@@ -10,11 +10,35 @@
#ifndef VIDEODECODE_H
#define VIDEODECODE_H
#include <QString>
struct AVFormatContext;
struct AVCodecContext;
struct AVRational;
struct AVPacket;
struct AVFrame;
struct SwsContext;
struct AVBufferRef;
class QImage;
class VideoDecode
{
public:
VideoDecode();
~VideoDecode();
bool open(const QString& url = QString()); // 打开媒体文件,或者流媒体rtmp、strp、http
QImage *read(); // 读取视频图像
void close(); // 关闭
bool isEnd(); // 是否读取完成
const qint64& pts(); // 获取当前帧显示时间
private:
void initFFmpeg(); // 初始化ffmpeg库(整个程序中只需加载一次)
void showError(int err); // 显示ffmpeg执行错误时的错误信息
qreal rationalToDouble(AVRational rational); // 将AVRational转换为double
void clear(); // 清空读取缓冲
void free(); // 释放
};
#endif // VIDEODECODE_H
......@@ -15,3 +15,23 @@ Widget::~Widget()
delete ui;
}
void Widget::on_but_file_clicked()
{
}
void Widget::on_but_open_clicked()
{
}
void Widget::on_but_pause_clicked()
{
}
void Widget::on_playState(ReadThread::PlayState state)
{
}
......@@ -2,6 +2,7 @@
#define WIDGET_H
#include <QWidget>
#include "readthread.h"
QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
......@@ -15,7 +16,18 @@ public:
Widget(QWidget *parent = nullptr);
~Widget();
private slots:
void on_but_file_clicked();
void on_but_open_clicked();
void on_but_pause_clicked();
void on_playState(ReadThread::PlayState state);
private:
Ui::Widget *ui;
ReadThread* m_readThread = nullptr;
};
#endif // WIDGET_H
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册