update:frame类重命名为videobuffer类

This commit is contained in:
Barry 2019-06-15 18:25:32 +08:00
parent 7f2509cbed
commit c343052e6c
7 changed files with 40 additions and 40 deletions

View file

@ -3,7 +3,7 @@
#include "compat.h"
#include "decoder.h"
#include "frames.h"
#include "videobuffer.h"
#include "devicesocket.h"
#include "recorder.h"
@ -69,9 +69,9 @@ void Decoder::deInit()
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) {
@ -234,8 +234,8 @@ bool Decoder::startDecode()
void Decoder::stopDecode()
{
m_quit = true;
if (m_frames) {
m_frames->stop();
if (m_vb) {
m_vb->stop();
}
wait();
}
@ -323,7 +323,7 @@ void Decoder::run()
packet.size = 0;
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:
// <http://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=7fc329e2dd6226dfecaa4a1d7adf353bf2773726>
#ifdef QTSCRCPY_LAVF_HAS_NEW_ENCODING_DECODING_API
@ -435,7 +435,7 @@ runQuit:
void Decoder::pushFrame()
{
bool previousFrameConsumed = m_frames->offerDecodedFrame();
bool previousFrameConsumed = m_vb->offerDecodedFrame();
if (!previousFrameConsumed) {
// the previous newFrame will consume this frame
return;

View file

@ -11,7 +11,7 @@ extern "C"
#include "libavformat/avformat.h"
}
class Frames;
class VideoBuffer;
class DeviceSocket;
class Recorder;
class Decoder : public QThread
@ -36,7 +36,7 @@ public:
static bool init();
static void deInit();
void setFrames(Frames* frames);
void setVideoBuffer(VideoBuffer* vb);
void setDeviceSocket(DeviceSocket* deviceSocket);
void setRecoder(Recorder* recorder);
qint32 recvData(quint8* buf, qint32 bufSize);
@ -55,7 +55,7 @@ protected:
private:
QPointer<DeviceSocket> m_deviceSocket;
bool m_quit = false;
Frames* m_frames;
VideoBuffer* m_vb;
// for recorder
Recorder* m_recorder = Q_NULLPTR;

View file

@ -1,12 +1,12 @@
HEADERS += \
$$PWD/decoder.h \
$$PWD/frames.h \
$$PWD/fpscounter.h \
$$PWD/avframeconvert.h
$$PWD/avframeconvert.h \
$$PWD/videobuffer.h
SOURCES += \
$$PWD/decoder.cpp \
$$PWD/frames.cpp \
$$PWD/fpscounter.cpp \
$$PWD/avframeconvert.cpp
$$PWD/avframeconvert.cpp \
$$PWD/videobuffer.cpp

View file

@ -1,21 +1,21 @@
#include "frames.h"
#include "videobuffer.h"
extern "C"
{
#include "libavutil/avutil.h"
#include "libavformat/avformat.h"
}
Frames::Frames()
VideoBuffer::VideoBuffer()
{
}
Frames::~Frames()
VideoBuffer::~VideoBuffer()
{
}
bool Frames::init()
bool VideoBuffer::init()
{
m_decodingFrame = av_frame_alloc();
if (!m_decodingFrame) {
@ -39,7 +39,7 @@ error:
return false;
}
void Frames::deInit()
void VideoBuffer::deInit()
{
if (m_decodingFrame) {
av_frame_free(&m_decodingFrame);
@ -52,22 +52,22 @@ void Frames::deInit()
m_fpsCounter.stop();
}
void Frames::lock()
void VideoBuffer::lock()
{
m_mutex.lock();
}
void Frames::unLock()
void VideoBuffer::unLock()
{
m_mutex.unlock();
}
AVFrame *Frames::decodingFrame()
AVFrame *VideoBuffer::decodingFrame()
{
return m_decodingFrame;
}
bool Frames::offerDecodedFrame()
bool VideoBuffer::offerDecodedFrame()
{
m_mutex.lock();
@ -90,7 +90,7 @@ bool Frames::offerDecodedFrame()
return previousFrameConsumed;
}
const AVFrame *Frames::consumeRenderedFrame()
const AVFrame *VideoBuffer::consumeRenderedFrame()
{
Q_ASSERT(!m_renderingFrameConsumed);
m_renderingFrameConsumed = true;
@ -105,7 +105,7 @@ const AVFrame *Frames::consumeRenderedFrame()
return m_renderingframe;
}
void Frames::stop()
void VideoBuffer::stop()
{
#ifndef SKIP_FRAMES
m_mutex.lock();
@ -116,7 +116,7 @@ void Frames::stop()
#endif
}
void Frames::swap()
void VideoBuffer::swap()
{
AVFrame *tmp = m_decodingFrame;
m_decodingFrame = m_renderingframe;

View file

@ -1,5 +1,5 @@
#ifndef FRAMES_H
#define FRAMES_H
#ifndef VIDEO_BUFFER_H
#define VIDEO_BUFFER_H
#include <QMutex>
#include <QWaitCondition>
@ -9,11 +9,11 @@
// forward declarations
typedef struct AVFrame AVFrame;
class Frames
class VideoBuffer
{
public:
Frames();
virtual ~Frames();
VideoBuffer();
virtual ~VideoBuffer();
bool init();
void deInit();
@ -51,4 +51,4 @@ private:
#endif
};
#endif // FRAMES_H
#endif // VIDEO_BUFFER_H

View file

@ -31,8 +31,8 @@ VideoForm::VideoForm(const QString& serial, quint16 maxSize, quint32 bitRate, co
initUI();
m_server = new Server();
m_frames.init();
m_decoder.setFrames(&m_frames);
m_vb.init();
m_decoder.setVideoBuffer(&m_vb);
if (!fileName.trimmed().isEmpty()) {
m_recorder = new Recorder(fileName.trimmed());
m_decoder.setRecoder(m_recorder);
@ -68,7 +68,7 @@ VideoForm::~VideoForm()
if (m_recorder) {
delete m_recorder;
}
m_frames.deInit();
m_vb.deInit();
delete ui;
}
@ -193,13 +193,13 @@ void VideoForm::initSignals()
}
ui->videoWidget->show();
}
m_frames.lock();
const AVFrame *frame = m_frames.consumeRenderedFrame();
m_vb.lock();
const AVFrame *frame = m_vb.consumeRenderedFrame();
//qDebug() << "widthxheight:" << frame->width << "x" << frame->height;
updateShowSize(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]);
m_frames.unLock();
m_vb.unLock();
},Qt::QueuedConnection);
}

View file

@ -7,7 +7,7 @@
#include "server.h"
#include "decoder.h"
#include "frames.h"
#include "videobuffer.h"
#include "inputconvertnormal.h"
#include "inputconvertgame.h"
#include "filehandler.h"
@ -71,7 +71,7 @@ private:
QSize frameSize;
Server* m_server = Q_NULLPTR;
Decoder m_decoder;
Frames m_frames;
VideoBuffer m_vb;
//InputConvertNormal m_inputConvert;
InputConvertGame m_inputConvert;
FileHandler m_fileHandler;