mirror of
https://github.com/barry-ran/QtScrcpy.git
synced 2025-08-03 14:18:45 +00:00
修复卡顿问题(recv接收数据方式不对)
This commit is contained in:
parent
fe79ff1dad
commit
ff10e0e376
4 changed files with 55 additions and 15 deletions
|
@ -23,6 +23,7 @@ DEFINES += QT_DEPRECATED_WARNINGS
|
||||||
# You can also select to disable deprecated APIs only up to a certain version of Qt.
|
# You can also select to disable deprecated APIs only up to a certain version of Qt.
|
||||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||||
|
|
||||||
|
#DEFINES += SKIP_FRAMES
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
main.cpp \
|
main.cpp \
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QTime>
|
||||||
|
|
||||||
#include "decoder.h"
|
#include "decoder.h"
|
||||||
#include "frames.h"
|
#include "frames.h"
|
||||||
|
@ -55,17 +56,16 @@ qint32 Decoder::recvData(quint8* buf, qint32 bufSize)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (m_deviceSocket) {
|
if (m_deviceSocket) {
|
||||||
while (!m_quit && m_deviceSocket->bytesAvailable() < bufSize) {
|
while (!m_quit && m_deviceSocket->bytesAvailable() <= 0) {
|
||||||
if (!m_deviceSocket->waitForReadyRead(300)
|
if (!m_deviceSocket->waitForReadyRead(300)
|
||||||
&& QTcpSocket::SocketTimeoutError != m_deviceSocket->error()) {
|
&& QTcpSocket::SocketTimeoutError != m_deviceSocket->error()) {
|
||||||
|
qDebug() << "waitForReadyRead error " << m_deviceSocket->error();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (QTcpSocket::SocketTimeoutError == m_deviceSocket->error()) {
|
|
||||||
//qDebug() << "QTcpSocket::SocketTimeoutError";
|
|
||||||
}
|
}
|
||||||
}
|
qint64 readSize = qMin(m_deviceSocket->bytesAvailable(), (qint64)bufSize);
|
||||||
qDebug() << "recv data " << bufSize;
|
qDebug() << "ready recv data " << readSize;
|
||||||
return m_deviceSocket->read((char*)buf, bufSize);
|
return m_deviceSocket->read((char*)buf, readSize);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -252,5 +252,6 @@ void Decoder::pushFrame()
|
||||||
// the previous newFrame will consume this frame
|
// the previous newFrame will consume this frame
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
//qDebug() << "------------>" << QTime::currentTime();
|
||||||
emit newFrame();
|
emit newFrame();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
#include <QFile>
|
||||||
|
#include <QTime>
|
||||||
|
|
||||||
#include "dialog.h"
|
#include "dialog.h"
|
||||||
#include "ui_dialog.h"
|
#include "ui_dialog.h"
|
||||||
#include "adbprocess.h"
|
#include "adbprocess.h"
|
||||||
|
@ -5,7 +8,40 @@
|
||||||
#include "glyuvwidget.h"
|
#include "glyuvwidget.h"
|
||||||
#include "yuvglwidget.h"
|
#include "yuvglwidget.h"
|
||||||
|
|
||||||
//#define OPENGL_PLAN2
|
#define OPENGL_PLAN2
|
||||||
|
|
||||||
|
void saveAVFrame_YUV_ToTempFile(const AVFrame *pFrame)
|
||||||
|
{
|
||||||
|
int t_frameWidth = pFrame->width;
|
||||||
|
int t_frameHeight = pFrame->height;
|
||||||
|
int t_yPerRowBytes = pFrame->linesize[0];
|
||||||
|
int t_uPerRowBytes = pFrame->linesize[1];
|
||||||
|
int t_vPerRowBytes = pFrame->linesize[2];
|
||||||
|
qDebug()<<"robin:saveAVFrame_YUV_ToTempFile info:"<<t_frameWidth<<t_frameHeight<<"||"<<t_yPerRowBytes<<t_uPerRowBytes<<t_vPerRowBytes;
|
||||||
|
QFile t_file("E:\\receive_Frame.yuv");
|
||||||
|
t_file.open(QIODevice::WriteOnly | QIODevice::Append);
|
||||||
|
//t_file.write((char *)pFrame->data[0],t_frameWidth * t_frameHeight);
|
||||||
|
//t_file.write((char *)pFrame->data[1],(t_frameWidth/2) * t_frameHeight / 2);
|
||||||
|
//t_file.write((char *)pFrame->data[2],(t_frameWidth/2) * t_frameHeight / 2);
|
||||||
|
|
||||||
|
for(int i = 0;i< t_frameHeight ;i++)
|
||||||
|
{
|
||||||
|
t_file.write((char*)(pFrame->data[0]+i*t_yPerRowBytes),t_frameWidth);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int i = 0;i< t_frameHeight/2 ;i++)
|
||||||
|
{
|
||||||
|
t_file.write((char*)(pFrame->data[1]+i*t_uPerRowBytes),t_frameWidth/2);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int i = 0;i< t_frameHeight/2 ;i++)
|
||||||
|
{
|
||||||
|
t_file.write((char*)(pFrame->data[2]+i*t_vPerRowBytes),t_frameWidth/2);
|
||||||
|
}
|
||||||
|
|
||||||
|
t_file.flush();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
Dialog::Dialog(QWidget *parent) :
|
Dialog::Dialog(QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
|
@ -47,12 +83,14 @@ Dialog::Dialog(QWidget *parent) :
|
||||||
QObject::connect(&decoder, &Decoder::newFrame, this, [this](){
|
QObject::connect(&decoder, &Decoder::newFrame, this, [this](){
|
||||||
frames.lock();
|
frames.lock();
|
||||||
const AVFrame *frame = frames.consumeRenderedFrame();
|
const AVFrame *frame = frames.consumeRenderedFrame();
|
||||||
|
//saveAVFrame_YUV_ToTempFile(frame);
|
||||||
#ifdef OPENGL_PLAN2
|
#ifdef OPENGL_PLAN2
|
||||||
w2->setFrameSize(frame->width, frame->height);
|
w2->setFrameSize(frame->width, frame->height);
|
||||||
w2->setYPixels(frame->data[0], frame->linesize[0]);
|
w2->setYPixels(frame->data[0], frame->linesize[0]);
|
||||||
w2->setUPixels(frame->data[1], frame->linesize[1]);
|
w2->setUPixels(frame->data[1], frame->linesize[1]);
|
||||||
w2->setVPixels(frame->data[2], frame->linesize[2]);
|
w2->setVPixels(frame->data[2], frame->linesize[2]);
|
||||||
w2->update();
|
//w2->update();
|
||||||
|
w2->repaint();
|
||||||
#else
|
#else
|
||||||
w->setVideoSize(frame->width, frame->height);
|
w->setVideoSize(frame->width, frame->height);
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>924</width>
|
<width>1309</width>
|
||||||
<height>365</height>
|
<height>707</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -57,8 +57,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>230</x>
|
<x>230</x>
|
||||||
<y>20</y>
|
<y>20</y>
|
||||||
<width>651</width>
|
<width>1051</width>
|
||||||
<height>301</height>
|
<height>621</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="styleSheet">
|
<property name="styleSheet">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue