mirror of
https://github.com/barry-ran/QtScrcpy.git
synced 2025-08-06 23:48:38 +00:00
update:frame类重命名为videobuffer类
This commit is contained in:
parent
7f2509cbed
commit
c343052e6c
7 changed files with 40 additions and 40 deletions
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include "compat.h"
|
#include "compat.h"
|
||||||
#include "decoder.h"
|
#include "decoder.h"
|
||||||
#include "frames.h"
|
#include "videobuffer.h"
|
||||||
#include "devicesocket.h"
|
#include "devicesocket.h"
|
||||||
#include "recorder.h"
|
#include "recorder.h"
|
||||||
|
|
||||||
|
@ -69,9 +69,9 @@ void Decoder::deInit()
|
||||||
avformat_network_deinit(); // ignore failure
|
avformat_network_deinit(); // ignore failure
|
||||||
}
|
}
|
||||||
|
|
||||||
void Decoder::setFrames(Frames *frames)
|
void Decoder::setVideoBuffer(VideoBuffer* vb)
|
||||||
{
|
{
|
||||||
m_frames = frames;
|
m_vb = vb;
|
||||||
}
|
}
|
||||||
|
|
||||||
static quint32 bufferRead32be(quint8* buf) {
|
static quint32 bufferRead32be(quint8* buf) {
|
||||||
|
@ -234,8 +234,8 @@ bool Decoder::startDecode()
|
||||||
void Decoder::stopDecode()
|
void Decoder::stopDecode()
|
||||||
{
|
{
|
||||||
m_quit = true;
|
m_quit = true;
|
||||||
if (m_frames) {
|
if (m_vb) {
|
||||||
m_frames->stop();
|
m_vb->stop();
|
||||||
}
|
}
|
||||||
wait();
|
wait();
|
||||||
}
|
}
|
||||||
|
@ -323,7 +323,7 @@ void Decoder::run()
|
||||||
packet.size = 0;
|
packet.size = 0;
|
||||||
|
|
||||||
while (!m_quit && !av_read_frame(formatCtx, &packet)) {
|
while (!m_quit && !av_read_frame(formatCtx, &packet)) {
|
||||||
AVFrame* decodingFrame = m_frames->decodingFrame();
|
AVFrame* decodingFrame = m_vb->decodingFrame();
|
||||||
// the new decoding/encoding API has been introduced by:
|
// the new decoding/encoding API has been introduced by:
|
||||||
// <http://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=7fc329e2dd6226dfecaa4a1d7adf353bf2773726>
|
// <http://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=7fc329e2dd6226dfecaa4a1d7adf353bf2773726>
|
||||||
#ifdef QTSCRCPY_LAVF_HAS_NEW_ENCODING_DECODING_API
|
#ifdef QTSCRCPY_LAVF_HAS_NEW_ENCODING_DECODING_API
|
||||||
|
@ -435,7 +435,7 @@ runQuit:
|
||||||
|
|
||||||
void Decoder::pushFrame()
|
void Decoder::pushFrame()
|
||||||
{
|
{
|
||||||
bool previousFrameConsumed = m_frames->offerDecodedFrame();
|
bool previousFrameConsumed = m_vb->offerDecodedFrame();
|
||||||
if (!previousFrameConsumed) {
|
if (!previousFrameConsumed) {
|
||||||
// the previous newFrame will consume this frame
|
// the previous newFrame will consume this frame
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -11,7 +11,7 @@ extern "C"
|
||||||
#include "libavformat/avformat.h"
|
#include "libavformat/avformat.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
class Frames;
|
class VideoBuffer;
|
||||||
class DeviceSocket;
|
class DeviceSocket;
|
||||||
class Recorder;
|
class Recorder;
|
||||||
class Decoder : public QThread
|
class Decoder : public QThread
|
||||||
|
@ -36,7 +36,7 @@ public:
|
||||||
static bool init();
|
static bool init();
|
||||||
static void deInit();
|
static void deInit();
|
||||||
|
|
||||||
void setFrames(Frames* frames);
|
void setVideoBuffer(VideoBuffer* vb);
|
||||||
void setDeviceSocket(DeviceSocket* deviceSocket);
|
void setDeviceSocket(DeviceSocket* deviceSocket);
|
||||||
void setRecoder(Recorder* recorder);
|
void setRecoder(Recorder* recorder);
|
||||||
qint32 recvData(quint8* buf, qint32 bufSize);
|
qint32 recvData(quint8* buf, qint32 bufSize);
|
||||||
|
@ -55,7 +55,7 @@ protected:
|
||||||
private:
|
private:
|
||||||
QPointer<DeviceSocket> m_deviceSocket;
|
QPointer<DeviceSocket> m_deviceSocket;
|
||||||
bool m_quit = false;
|
bool m_quit = false;
|
||||||
Frames* m_frames;
|
VideoBuffer* m_vb;
|
||||||
|
|
||||||
// for recorder
|
// for recorder
|
||||||
Recorder* m_recorder = Q_NULLPTR;
|
Recorder* m_recorder = Q_NULLPTR;
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
$$PWD/decoder.h \
|
$$PWD/decoder.h \
|
||||||
$$PWD/frames.h \
|
|
||||||
$$PWD/fpscounter.h \
|
$$PWD/fpscounter.h \
|
||||||
$$PWD/avframeconvert.h
|
$$PWD/avframeconvert.h \
|
||||||
|
$$PWD/videobuffer.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
$$PWD/decoder.cpp \
|
$$PWD/decoder.cpp \
|
||||||
$$PWD/frames.cpp \
|
|
||||||
$$PWD/fpscounter.cpp \
|
$$PWD/fpscounter.cpp \
|
||||||
$$PWD/avframeconvert.cpp
|
$$PWD/avframeconvert.cpp \
|
||||||
|
$$PWD/videobuffer.cpp
|
||||||
|
|
||||||
|
|
|
@ -1,21 +1,21 @@
|
||||||
#include "frames.h"
|
#include "videobuffer.h"
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
#include "libavutil/avutil.h"
|
#include "libavutil/avutil.h"
|
||||||
#include "libavformat/avformat.h"
|
#include "libavformat/avformat.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
Frames::Frames()
|
VideoBuffer::VideoBuffer()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Frames::~Frames()
|
VideoBuffer::~VideoBuffer()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Frames::init()
|
bool VideoBuffer::init()
|
||||||
{
|
{
|
||||||
m_decodingFrame = av_frame_alloc();
|
m_decodingFrame = av_frame_alloc();
|
||||||
if (!m_decodingFrame) {
|
if (!m_decodingFrame) {
|
||||||
|
@ -39,7 +39,7 @@ error:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Frames::deInit()
|
void VideoBuffer::deInit()
|
||||||
{
|
{
|
||||||
if (m_decodingFrame) {
|
if (m_decodingFrame) {
|
||||||
av_frame_free(&m_decodingFrame);
|
av_frame_free(&m_decodingFrame);
|
||||||
|
@ -52,22 +52,22 @@ void Frames::deInit()
|
||||||
m_fpsCounter.stop();
|
m_fpsCounter.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Frames::lock()
|
void VideoBuffer::lock()
|
||||||
{
|
{
|
||||||
m_mutex.lock();
|
m_mutex.lock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Frames::unLock()
|
void VideoBuffer::unLock()
|
||||||
{
|
{
|
||||||
m_mutex.unlock();
|
m_mutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
AVFrame *Frames::decodingFrame()
|
AVFrame *VideoBuffer::decodingFrame()
|
||||||
{
|
{
|
||||||
return m_decodingFrame;
|
return m_decodingFrame;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Frames::offerDecodedFrame()
|
bool VideoBuffer::offerDecodedFrame()
|
||||||
{
|
{
|
||||||
m_mutex.lock();
|
m_mutex.lock();
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ bool Frames::offerDecodedFrame()
|
||||||
return previousFrameConsumed;
|
return previousFrameConsumed;
|
||||||
}
|
}
|
||||||
|
|
||||||
const AVFrame *Frames::consumeRenderedFrame()
|
const AVFrame *VideoBuffer::consumeRenderedFrame()
|
||||||
{
|
{
|
||||||
Q_ASSERT(!m_renderingFrameConsumed);
|
Q_ASSERT(!m_renderingFrameConsumed);
|
||||||
m_renderingFrameConsumed = true;
|
m_renderingFrameConsumed = true;
|
||||||
|
@ -105,7 +105,7 @@ const AVFrame *Frames::consumeRenderedFrame()
|
||||||
return m_renderingframe;
|
return m_renderingframe;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Frames::stop()
|
void VideoBuffer::stop()
|
||||||
{
|
{
|
||||||
#ifndef SKIP_FRAMES
|
#ifndef SKIP_FRAMES
|
||||||
m_mutex.lock();
|
m_mutex.lock();
|
||||||
|
@ -116,7 +116,7 @@ void Frames::stop()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Frames::swap()
|
void VideoBuffer::swap()
|
||||||
{
|
{
|
||||||
AVFrame *tmp = m_decodingFrame;
|
AVFrame *tmp = m_decodingFrame;
|
||||||
m_decodingFrame = m_renderingframe;
|
m_decodingFrame = m_renderingframe;
|
|
@ -1,5 +1,5 @@
|
||||||
#ifndef FRAMES_H
|
#ifndef VIDEO_BUFFER_H
|
||||||
#define FRAMES_H
|
#define VIDEO_BUFFER_H
|
||||||
|
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
#include <QWaitCondition>
|
#include <QWaitCondition>
|
||||||
|
@ -9,11 +9,11 @@
|
||||||
// forward declarations
|
// forward declarations
|
||||||
typedef struct AVFrame AVFrame;
|
typedef struct AVFrame AVFrame;
|
||||||
|
|
||||||
class Frames
|
class VideoBuffer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Frames();
|
VideoBuffer();
|
||||||
virtual ~Frames();
|
virtual ~VideoBuffer();
|
||||||
|
|
||||||
bool init();
|
bool init();
|
||||||
void deInit();
|
void deInit();
|
||||||
|
@ -51,4 +51,4 @@ private:
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FRAMES_H
|
#endif // VIDEO_BUFFER_H
|
|
@ -31,8 +31,8 @@ VideoForm::VideoForm(const QString& serial, quint16 maxSize, quint32 bitRate, co
|
||||||
initUI();
|
initUI();
|
||||||
|
|
||||||
m_server = new Server();
|
m_server = new Server();
|
||||||
m_frames.init();
|
m_vb.init();
|
||||||
m_decoder.setFrames(&m_frames);
|
m_decoder.setVideoBuffer(&m_vb);
|
||||||
if (!fileName.trimmed().isEmpty()) {
|
if (!fileName.trimmed().isEmpty()) {
|
||||||
m_recorder = new Recorder(fileName.trimmed());
|
m_recorder = new Recorder(fileName.trimmed());
|
||||||
m_decoder.setRecoder(m_recorder);
|
m_decoder.setRecoder(m_recorder);
|
||||||
|
@ -68,7 +68,7 @@ VideoForm::~VideoForm()
|
||||||
if (m_recorder) {
|
if (m_recorder) {
|
||||||
delete m_recorder;
|
delete m_recorder;
|
||||||
}
|
}
|
||||||
m_frames.deInit();
|
m_vb.deInit();
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,13 +193,13 @@ void VideoForm::initSignals()
|
||||||
}
|
}
|
||||||
ui->videoWidget->show();
|
ui->videoWidget->show();
|
||||||
}
|
}
|
||||||
m_frames.lock();
|
m_vb.lock();
|
||||||
const AVFrame *frame = m_frames.consumeRenderedFrame();
|
const AVFrame *frame = m_vb.consumeRenderedFrame();
|
||||||
//qDebug() << "widthxheight:" << frame->width << "x" << frame->height;
|
//qDebug() << "widthxheight:" << frame->width << "x" << frame->height;
|
||||||
updateShowSize(QSize(frame->width, frame->height));
|
updateShowSize(QSize(frame->width, frame->height));
|
||||||
ui->videoWidget->setFrameSize(QSize(frame->width, frame->height));
|
ui->videoWidget->setFrameSize(QSize(frame->width, frame->height));
|
||||||
ui->videoWidget->updateTextures(frame->data[0], frame->data[1], frame->data[2], frame->linesize[0], frame->linesize[1], frame->linesize[2]);
|
ui->videoWidget->updateTextures(frame->data[0], frame->data[1], frame->data[2], frame->linesize[0], frame->linesize[1], frame->linesize[2]);
|
||||||
m_frames.unLock();
|
m_vb.unLock();
|
||||||
},Qt::QueuedConnection);
|
},Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
#include "decoder.h"
|
#include "decoder.h"
|
||||||
#include "frames.h"
|
#include "videobuffer.h"
|
||||||
#include "inputconvertnormal.h"
|
#include "inputconvertnormal.h"
|
||||||
#include "inputconvertgame.h"
|
#include "inputconvertgame.h"
|
||||||
#include "filehandler.h"
|
#include "filehandler.h"
|
||||||
|
@ -71,7 +71,7 @@ private:
|
||||||
QSize frameSize;
|
QSize frameSize;
|
||||||
Server* m_server = Q_NULLPTR;
|
Server* m_server = Q_NULLPTR;
|
||||||
Decoder m_decoder;
|
Decoder m_decoder;
|
||||||
Frames m_frames;
|
VideoBuffer m_vb;
|
||||||
//InputConvertNormal m_inputConvert;
|
//InputConvertNormal m_inputConvert;
|
||||||
InputConvertGame m_inputConvert;
|
InputConvertGame m_inputConvert;
|
||||||
FileHandler m_fileHandler;
|
FileHandler m_fileHandler;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue