调整项目文件结构

This commit is contained in:
rankun 2018-11-07 18:00:05 +08:00
parent 2211fc0c52
commit aca8d23f3e
32 changed files with 491 additions and 776 deletions

View file

@ -29,46 +29,35 @@ DEFINES += QT_DEPRECATED_WARNINGS
SOURCES += \
main.cpp \
dialog.cpp \
adbprocess.cpp \
decoder.cpp \
server.cpp \
convert.cpp \
frames.cpp \
fpscounter.cpp \
qyuvopenglwidget.cpp \
videoform.cpp \
devicesocket.cpp \
tcpserver.cpp \
controlevent.cpp \
controller.cpp
videoform.cpp
HEADERS += \
dialog.h \
adbprocess.h \
decoder.h \
server.h \
convert.h \
frames.h \
fpscounter.h \
qyuvopenglwidget.h \
videoform.h \
devicesocket.h \
tcpserver.h \
qscrcpyevent.h \
controlevent.h \
controller.h
videoform.h
FORMS += \
dialog.ui \
videoform.ui
#子工程
include ($$PWD/common/common.pri)
include ($$PWD/server/server.pri)
include ($$PWD/adb/adb.pri)
include ($$PWD/decoder/decoder.pri)
include ($$PWD/render/render.pri)
include ($$PWD/android/android.pri)
include ($$PWD/inputcontrol/inputcontrol.pri)
# 附加包含路径
INCLUDEPATH += \
$$PWD/ffmpeg/include \
$$PWD/android
$$PWD/common \
$$PWD/server \
$$PWD/adb \
$$PWD/decoder \
$$PWD/render \
$$PWD/android \
$$PWD/inputcontrol
# 依赖库
LIBS += \

View file

@ -1,318 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.6.2, 2018-10-10T18:19:32. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
<value type="QByteArray">{37b22fe7-3e02-43d3-85e3-251a3ebe4093}</value>
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
<value type="int">0</value>
</data>
<data>
<variable>ProjectExplorer.Project.EditorSettings</variable>
<valuemap type="QVariantMap">
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
<value type="QString" key="language">Cpp</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
</valuemap>
</valuemap>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
<value type="QString" key="language">QmlJS</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
</valuemap>
</valuemap>
<value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
<value type="int" key="EditorConfiguration.IndentSize">4</value>
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
<value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
<value type="int" key="EditorConfiguration.TabSize">8</value>
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.PluginSettings</variable>
<valuemap type="QVariantMap"/>
</data>
<data>
<variable>ProjectExplorer.Project.Target.0</variable>
<valuemap type="QVariantMap">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.9.6 MSVC2015 32bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.9.6 MSVC2015 32bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.596.win32_msvc2015_kit</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">G:/mygitcode/QtScrcpy/build-QtScrcpy-Desktop_Qt_5_9_6_MSVC2015_32bit-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">true</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">false</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">G:/mygitcode/QtScrcpy/build-QtScrcpy-Desktop_Qt_5_9_6_MSVC2015_32bit-Release</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">false</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">G:/mygitcode/QtScrcpy/build-QtScrcpy-Desktop_Qt_5_9_6_MSVC2015_32bit-Profile</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">true</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">true</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">false</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Profile</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Profile</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">3</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">部署</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">部署设置</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
<value type="bool" key="Analyzer.QmlProfiler.AggregateTraces">false</value>
<value type="bool" key="Analyzer.QmlProfiler.FlushEnabled">false</value>
<value type="uint" key="Analyzer.QmlProfiler.FlushInterval">1000</value>
<value type="QString" key="Analyzer.QmlProfiler.LastTraceFile"></value>
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
<value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
<value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
<value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
<value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
<value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
<value type="int">0</value>
<value type="int">1</value>
<value type="int">2</value>
<value type="int">3</value>
<value type="int">4</value>
<value type="int">5</value>
<value type="int">6</value>
<value type="int">7</value>
<value type="int">8</value>
<value type="int">9</value>
<value type="int">10</value>
<value type="int">11</value>
<value type="int">12</value>
<value type="int">13</value>
<value type="int">14</value>
</valuelist>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">QtScrcpy</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:G:/mygitcode/QtScrcpy/src/QtScrcpy.pro</value>
<value type="bool" key="QmakeProjectManager.QmakeRunConfiguration.UseLibrarySearchPath">true</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">QtScrcpy.pro</value>
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory.default">G:/mygitcode/QtScrcpy/build-QtScrcpy-Desktop_Qt_5_9_6_MSVC2015_32bit-Debug</value>
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.TargetCount</variable>
<value type="int">1</value>
</data>
<data>
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
<value type="int">18</value>
</data>
<data>
<variable>Version</variable>
<value type="int">18</value>
</data>
</qtcreator>

5
src/adb/adb.pri Normal file
View file

@ -0,0 +1,5 @@
HEADERS += \
$$PWD/adbprocess.h
SOURCES += \
$$PWD/adbprocess.cpp

3
src/android/android.pri Normal file
View file

@ -0,0 +1,3 @@
HEADERS += \
$$PWD/input.h \
$$PWD/keycodes.h

2
src/common/common.pri Normal file
View file

@ -0,0 +1,2 @@
HEADERS += \
$$PWD/qscrcpyevent.h

12
src/decoder/decoder.pri Normal file
View file

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

View file

@ -1,71 +1,71 @@
#include <QTimerEvent>
#include <QDebug>
#include "fpscounter.h"
FpsCounter::FpsCounter(QObject* parent) : QObject(parent)
{
}
FpsCounter::~FpsCounter()
{
}
void FpsCounter::start()
{
resetCounter();
startCounterTimer();
}
void FpsCounter::stop()
{
stopCounterTimer();
resetCounter();
}
bool FpsCounter::isStarted()
{
return m_counterTimer;
}
void FpsCounter::addRenderedFrame()
{
m_rendered++;
}
void FpsCounter::addSkippedFrame()
{
m_skipped++;
}
void FpsCounter::timerEvent(QTimerEvent *event)
{
if (event && m_counterTimer == event->timerId()) {
m_curRendered = m_rendered;
m_curSkipped = m_skipped;
resetCounter();
//qInfo("FPS:%d Discard:%d", m_curRendered, m_skipped);
}
}
void FpsCounter::startCounterTimer()
{
stopCounterTimer();
m_counterTimer = startTimer(1000);
}
void FpsCounter::stopCounterTimer()
{
if (m_counterTimer) {
killTimer(m_counterTimer);
m_counterTimer = 0;
}
}
void FpsCounter::resetCounter()
{
m_rendered = 0;
m_skipped = 0;
}
#include <QTimerEvent>
#include <QDebug>
#include "fpscounter.h"
FpsCounter::FpsCounter(QObject* parent) : QObject(parent)
{
}
FpsCounter::~FpsCounter()
{
}
void FpsCounter::start()
{
resetCounter();
startCounterTimer();
}
void FpsCounter::stop()
{
stopCounterTimer();
resetCounter();
}
bool FpsCounter::isStarted()
{
return m_counterTimer;
}
void FpsCounter::addRenderedFrame()
{
m_rendered++;
}
void FpsCounter::addSkippedFrame()
{
m_skipped++;
}
void FpsCounter::timerEvent(QTimerEvent *event)
{
if (event && m_counterTimer == event->timerId()) {
m_curRendered = m_rendered;
m_curSkipped = m_skipped;
resetCounter();
//qInfo("FPS:%d Discard:%d", m_curRendered, m_skipped);
}
}
void FpsCounter::startCounterTimer()
{
stopCounterTimer();
m_counterTimer = startTimer(1000);
}
void FpsCounter::stopCounterTimer()
{
if (m_counterTimer) {
killTimer(m_counterTimer);
m_counterTimer = 0;
}
}
void FpsCounter::resetCounter()
{
m_rendered = 0;
m_skipped = 0;
}

View file

@ -1,35 +1,35 @@
#ifndef FPSCOUNTER_H
#define FPSCOUNTER_H
#include <QObject>
class FpsCounter : public QObject
{
Q_OBJECT
public:
FpsCounter(QObject* parent = Q_NULLPTR);
virtual ~FpsCounter();
void start();
void stop();
bool isStarted();
void addRenderedFrame();
void addSkippedFrame();
protected:
virtual void timerEvent(QTimerEvent *event);
private:
void startCounterTimer();
void stopCounterTimer();
void resetCounter();
private:
quint32 m_counterTimer = 0;
quint32 m_curRendered = 0;
quint32 m_curSkipped = 0;
quint32 m_rendered = 0;
quint32 m_skipped = 0;
};
#endif // FPSCOUNTER_H
#ifndef FPSCOUNTER_H
#define FPSCOUNTER_H
#include <QObject>
class FpsCounter : public QObject
{
Q_OBJECT
public:
FpsCounter(QObject* parent = Q_NULLPTR);
virtual ~FpsCounter();
void start();
void stop();
bool isStarted();
void addRenderedFrame();
void addSkippedFrame();
protected:
virtual void timerEvent(QTimerEvent *event);
private:
void startCounterTimer();
void stopCounterTimer();
void resetCounter();
private:
quint32 m_counterTimer = 0;
quint32 m_curRendered = 0;
quint32 m_curSkipped = 0;
quint32 m_rendered = 0;
quint32 m_skipped = 0;
};
#endif // FPSCOUNTER_H

View file

@ -0,0 +1,8 @@
HEADERS += \
$$PWD/controlevent.h \
$$PWD/controller.h
SOURCES += \
$$PWD/controlevent.cpp \
$$PWD/controller.cpp

View file

@ -1,241 +1,241 @@
#include <QCoreApplication>
#include <QOpenGLTexture>
#include "qyuvopenglwidget.h"
// 存储顶点坐标和纹理坐标
// 存在一起缓存在vbo
// 使用glVertexAttribPointer指定访问方式即可
static const GLfloat coordinate[] = {
// 顶点坐标存储4个xyz坐标
// 坐标范围为[-1,1],中心点为 0,0
// 二维图像z始终为0
// GL_TRIANGLE_STRIP的绘制方式
// 使用前3个坐标绘制一个三角形使用后三个坐标绘制一个三角形正好为一个矩形
// x y z
-1.0f, -1.0f, 0.0f,
1.0f, -1.0f, 0.0f,
-1.0f, 1.0f, 0.0f,
1.0f, 1.0f, 0.0f,
// 纹理坐标存储4个xy坐标
// 坐标范围为[0,1],左下角为 0,0
// TODO 为什么这个顺序指定四个顶点?顶点坐标和纹理坐标如何映射的?
0.0f, 1.0f,
1.0f, 1.0f,
0.0f, 0.0f,
1.0f, 0.0f
};
// 顶点着色器
static const QString s_vertShader = R"(
attribute vec3 vertexIn; // xyz顶点坐标
attribute vec2 textureIn; // xy纹理坐标
varying vec2 textureOut; // 传递给片段着色器的纹理坐标
void main(void)
{
gl_Position = vec4(vertexIn, 1.0); // 1.0表示vertexIn是一个顶点位置
textureOut = textureIn; // 纹理坐标直接传递给片段着色器
}
)";
// 片段着色器
static QString s_fragShader = R"(
varying vec2 textureOut; // 由顶点着色器传递过来的纹理坐标
uniform sampler2D textureY; // uniform 纹理单元,利用纹理单元可以使用多个纹理
uniform sampler2D textureU; // sampler2D是2D采样器
uniform sampler2D textureV; // 声明yuv三个纹理单元
void main(void)
{
vec3 yuv;
vec3 rgb;
// 根据指定的纹理textureY和坐标textureOut来采样
yuv.x = texture2D(textureY, textureOut).r;
yuv.y = texture2D(textureU, textureOut).r - 0.5;
yuv.z = texture2D(textureV, textureOut).r - 0.5;
// 采样完转为rgb
rgb = mat3(1.0, 1.0, 1.0,
0.0, -0.39465, 2.03211,
1.13983, -0.58060, 0.0) * yuv;
// 输出颜色值
gl_FragColor = vec4(rgb, 1.0);
}
)";
QYUVOpenGLWidget::QYUVOpenGLWidget(QWidget *parent) : QOpenGLWidget(parent)
{
}
QYUVOpenGLWidget::~QYUVOpenGLWidget()
{
makeCurrent();
m_vbo.destroy();
deInitTextures();
doneCurrent();
}
QSize QYUVOpenGLWidget::minimumSizeHint() const
{
return QSize(50, 50);
}
QSize QYUVOpenGLWidget::sizeHint() const
{
return size();
}
void QYUVOpenGLWidget::setFrameSize(const QSize &frameSize)
{
if (m_frameSize != frameSize) {
m_frameSize = frameSize;
m_needUpdate = true;
// inittexture immediately
repaint();
}
}
const QSize& QYUVOpenGLWidget::frameSize()
{
return m_frameSize;
}
void QYUVOpenGLWidget::updateTextures(quint8 *dataY, quint8 *dataU, quint8 *dataV, quint32 linesizeY, quint32 linesizeU, quint32 linesizeV)
{
if (m_textureInited) {
updateTexture(m_texture[0], 0, dataY, linesizeY);
updateTexture(m_texture[1], 1, dataU, linesizeU);
updateTexture(m_texture[2], 2, dataV, linesizeV);
update();
}
}
void QYUVOpenGLWidget::initializeGL()
{
initializeOpenGLFunctions();
glDisable(GL_DEPTH_TEST);
// 顶点缓冲对象初始化
m_vbo.create();
m_vbo.bind();
m_vbo.allocate(coordinate, sizeof(coordinate));
initShader();
// 设置背景清理色为黑色
glClearColor(0.0,0.0,0.0,0.0);
// 清理颜色背景
glClear(GL_COLOR_BUFFER_BIT);
}
void QYUVOpenGLWidget::paintGL()
{
if (m_needUpdate) {
deInitTextures();
initTextures();
m_needUpdate = false;
}
if (m_textureInited) {
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, m_texture[0]);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, m_texture[1]);
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, m_texture[2]);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
}
}
void QYUVOpenGLWidget::resizeGL(int width, int height)
{
glViewport(0, 0, width, height);
repaint();
}
void QYUVOpenGLWidget::initShader()
{
// opengles的float、int等要手动指定精度
if (QCoreApplication::testAttribute(Qt::AA_UseOpenGLES)) {
s_fragShader.prepend(R"(
precision mediump int;
precision mediump float;
)");
}
m_shaderProgram.addShaderFromSourceCode(QOpenGLShader::Vertex, s_vertShader);
m_shaderProgram.addShaderFromSourceCode(QOpenGLShader::Fragment, s_fragShader);
m_shaderProgram.link();
m_shaderProgram.bind();
// 指定顶点坐标在vbo中的访问方式
// 参数解释顶点坐标在shader中的参数名称顶点坐标为float起始偏移为0顶点坐标类型为vec3步幅为3个float
m_shaderProgram.setAttributeBuffer("vertexIn", GL_FLOAT, 0, 3, 3 * sizeof(float));
// 启用顶点属性
m_shaderProgram.enableAttributeArray("vertexIn");
// 指定纹理坐标在vbo中的访问方式
// 参数解释纹理坐标在shader中的参数名称纹理坐标为float起始偏移为12个float跳过前面存储的12个顶点坐标纹理坐标类型为vec2步幅为2个float
m_shaderProgram.setAttributeBuffer("textureIn", GL_FLOAT, 12 * sizeof(float), 2, 2 * sizeof(float));
m_shaderProgram.enableAttributeArray("textureIn");
// 关联片段着色器中的纹理单元和opengl中的纹理单元opengl一般提供16个纹理单元
m_shaderProgram.setUniformValue("textureY", 0);
m_shaderProgram.setUniformValue("textureU", 1);
m_shaderProgram.setUniformValue("textureV", 2);
}
void QYUVOpenGLWidget::initTextures()
{
// 创建纹理
glGenTextures(1, &m_texture[0]);
glBindTexture(GL_TEXTURE_2D, m_texture[0]);
// 设置纹理缩放时的策略
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
// 设置st方向上纹理超出坐标时的显示策略
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, m_frameSize.width(), m_frameSize.height(), 0, GL_RED, GL_UNSIGNED_BYTE, NULL);
glGenTextures(1, &m_texture[1]);
glBindTexture(GL_TEXTURE_2D, m_texture[1]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, m_frameSize.width()/2, m_frameSize.height()/2, 0, GL_RED, GL_UNSIGNED_BYTE, NULL);
glGenTextures(1, &m_texture[2]);
glBindTexture(GL_TEXTURE_2D, m_texture[2]);
// 设置纹理缩放时的策略
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
// 设置st方向上纹理超出坐标时的显示策略
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, m_frameSize.width()/2, m_frameSize.height()/2, 0, GL_RED, GL_UNSIGNED_BYTE, NULL);
m_textureInited = true;
}
void QYUVOpenGLWidget::deInitTextures()
{
glDeleteTextures(3, m_texture);
memset(m_texture, 0, 3);
m_textureInited = false;
}
void QYUVOpenGLWidget::updateTexture(GLuint texture, quint32 textureType, quint8 *pixels, quint32 stride)
{
if (!pixels)
return;
QSize size = 0 == textureType ? m_frameSize : m_frameSize/2;
makeCurrent();
glBindTexture(GL_TEXTURE_2D, texture);
glPixelStorei(GL_UNPACK_ROW_LENGTH, stride);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, size.width(), size.height(), GL_RED, GL_UNSIGNED_BYTE, pixels);
doneCurrent();
}
#include <QCoreApplication>
#include <QOpenGLTexture>
#include "qyuvopenglwidget.h"
// 存储顶点坐标和纹理坐标
// 存在一起缓存在vbo
// 使用glVertexAttribPointer指定访问方式即可
static const GLfloat coordinate[] = {
// 顶点坐标存储4个xyz坐标
// 坐标范围为[-1,1],中心点为 0,0
// 二维图像z始终为0
// GL_TRIANGLE_STRIP的绘制方式
// 使用前3个坐标绘制一个三角形使用后三个坐标绘制一个三角形正好为一个矩形
// x y z
-1.0f, -1.0f, 0.0f,
1.0f, -1.0f, 0.0f,
-1.0f, 1.0f, 0.0f,
1.0f, 1.0f, 0.0f,
// 纹理坐标存储4个xy坐标
// 坐标范围为[0,1],左下角为 0,0
// TODO 为什么这个顺序指定四个顶点?顶点坐标和纹理坐标如何映射的?
0.0f, 1.0f,
1.0f, 1.0f,
0.0f, 0.0f,
1.0f, 0.0f
};
// 顶点着色器
static const QString s_vertShader = R"(
attribute vec3 vertexIn; // xyz顶点坐标
attribute vec2 textureIn; // xy纹理坐标
varying vec2 textureOut; // 传递给片段着色器的纹理坐标
void main(void)
{
gl_Position = vec4(vertexIn, 1.0); // 1.0表示vertexIn是一个顶点位置
textureOut = textureIn; // 纹理坐标直接传递给片段着色器
}
)";
// 片段着色器
static QString s_fragShader = R"(
varying vec2 textureOut; // 由顶点着色器传递过来的纹理坐标
uniform sampler2D textureY; // uniform 纹理单元,利用纹理单元可以使用多个纹理
uniform sampler2D textureU; // sampler2D是2D采样器
uniform sampler2D textureV; // 声明yuv三个纹理单元
void main(void)
{
vec3 yuv;
vec3 rgb;
// 根据指定的纹理textureY和坐标textureOut来采样
yuv.x = texture2D(textureY, textureOut).r;
yuv.y = texture2D(textureU, textureOut).r - 0.5;
yuv.z = texture2D(textureV, textureOut).r - 0.5;
// 采样完转为rgb
rgb = mat3(1.0, 1.0, 1.0,
0.0, -0.39465, 2.03211,
1.13983, -0.58060, 0.0) * yuv;
// 输出颜色值
gl_FragColor = vec4(rgb, 1.0);
}
)";
QYUVOpenGLWidget::QYUVOpenGLWidget(QWidget *parent) : QOpenGLWidget(parent)
{
}
QYUVOpenGLWidget::~QYUVOpenGLWidget()
{
makeCurrent();
m_vbo.destroy();
deInitTextures();
doneCurrent();
}
QSize QYUVOpenGLWidget::minimumSizeHint() const
{
return QSize(50, 50);
}
QSize QYUVOpenGLWidget::sizeHint() const
{
return size();
}
void QYUVOpenGLWidget::setFrameSize(const QSize &frameSize)
{
if (m_frameSize != frameSize) {
m_frameSize = frameSize;
m_needUpdate = true;
// inittexture immediately
repaint();
}
}
const QSize& QYUVOpenGLWidget::frameSize()
{
return m_frameSize;
}
void QYUVOpenGLWidget::updateTextures(quint8 *dataY, quint8 *dataU, quint8 *dataV, quint32 linesizeY, quint32 linesizeU, quint32 linesizeV)
{
if (m_textureInited) {
updateTexture(m_texture[0], 0, dataY, linesizeY);
updateTexture(m_texture[1], 1, dataU, linesizeU);
updateTexture(m_texture[2], 2, dataV, linesizeV);
update();
}
}
void QYUVOpenGLWidget::initializeGL()
{
initializeOpenGLFunctions();
glDisable(GL_DEPTH_TEST);
// 顶点缓冲对象初始化
m_vbo.create();
m_vbo.bind();
m_vbo.allocate(coordinate, sizeof(coordinate));
initShader();
// 设置背景清理色为黑色
glClearColor(0.0,0.0,0.0,0.0);
// 清理颜色背景
glClear(GL_COLOR_BUFFER_BIT);
}
void QYUVOpenGLWidget::paintGL()
{
if (m_needUpdate) {
deInitTextures();
initTextures();
m_needUpdate = false;
}
if (m_textureInited) {
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, m_texture[0]);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, m_texture[1]);
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, m_texture[2]);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
}
}
void QYUVOpenGLWidget::resizeGL(int width, int height)
{
glViewport(0, 0, width, height);
repaint();
}
void QYUVOpenGLWidget::initShader()
{
// opengles的float、int等要手动指定精度
if (QCoreApplication::testAttribute(Qt::AA_UseOpenGLES)) {
s_fragShader.prepend(R"(
precision mediump int;
precision mediump float;
)");
}
m_shaderProgram.addShaderFromSourceCode(QOpenGLShader::Vertex, s_vertShader);
m_shaderProgram.addShaderFromSourceCode(QOpenGLShader::Fragment, s_fragShader);
m_shaderProgram.link();
m_shaderProgram.bind();
// 指定顶点坐标在vbo中的访问方式
// 参数解释顶点坐标在shader中的参数名称顶点坐标为float起始偏移为0顶点坐标类型为vec3步幅为3个float
m_shaderProgram.setAttributeBuffer("vertexIn", GL_FLOAT, 0, 3, 3 * sizeof(float));
// 启用顶点属性
m_shaderProgram.enableAttributeArray("vertexIn");
// 指定纹理坐标在vbo中的访问方式
// 参数解释纹理坐标在shader中的参数名称纹理坐标为float起始偏移为12个float跳过前面存储的12个顶点坐标纹理坐标类型为vec2步幅为2个float
m_shaderProgram.setAttributeBuffer("textureIn", GL_FLOAT, 12 * sizeof(float), 2, 2 * sizeof(float));
m_shaderProgram.enableAttributeArray("textureIn");
// 关联片段着色器中的纹理单元和opengl中的纹理单元opengl一般提供16个纹理单元
m_shaderProgram.setUniformValue("textureY", 0);
m_shaderProgram.setUniformValue("textureU", 1);
m_shaderProgram.setUniformValue("textureV", 2);
}
void QYUVOpenGLWidget::initTextures()
{
// 创建纹理
glGenTextures(1, &m_texture[0]);
glBindTexture(GL_TEXTURE_2D, m_texture[0]);
// 设置纹理缩放时的策略
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
// 设置st方向上纹理超出坐标时的显示策略
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, m_frameSize.width(), m_frameSize.height(), 0, GL_RED, GL_UNSIGNED_BYTE, NULL);
glGenTextures(1, &m_texture[1]);
glBindTexture(GL_TEXTURE_2D, m_texture[1]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, m_frameSize.width()/2, m_frameSize.height()/2, 0, GL_RED, GL_UNSIGNED_BYTE, NULL);
glGenTextures(1, &m_texture[2]);
glBindTexture(GL_TEXTURE_2D, m_texture[2]);
// 设置纹理缩放时的策略
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
// 设置st方向上纹理超出坐标时的显示策略
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, m_frameSize.width()/2, m_frameSize.height()/2, 0, GL_RED, GL_UNSIGNED_BYTE, NULL);
m_textureInited = true;
}
void QYUVOpenGLWidget::deInitTextures()
{
glDeleteTextures(3, m_texture);
memset(m_texture, 0, 3);
m_textureInited = false;
}
void QYUVOpenGLWidget::updateTexture(GLuint texture, quint32 textureType, quint8 *pixels, quint32 stride)
{
if (!pixels)
return;
QSize size = 0 == textureType ? m_frameSize : m_frameSize/2;
makeCurrent();
glBindTexture(GL_TEXTURE_2D, texture);
glPixelStorei(GL_UNPACK_ROW_LENGTH, stride);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, size.width(), size.height(), GL_RED, GL_UNSIGNED_BYTE, pixels);
doneCurrent();
}

View file

@ -1,49 +1,49 @@
#ifndef QYUVOPENGLWIDGET_H
#define QYUVOPENGLWIDGET_H
#include <QOpenGLWidget>
#include <QOpenGLFunctions>
#include <QOpenGLShaderProgram>
#include <QOpenGLBuffer>
class QYUVOpenGLWidget : public QOpenGLWidget, protected QOpenGLFunctions
{
Q_OBJECT
public:
explicit QYUVOpenGLWidget(QWidget *parent = nullptr);
virtual ~QYUVOpenGLWidget();
QSize minimumSizeHint() const override;
QSize sizeHint() const override;
void setFrameSize(const QSize& frameSize);
const QSize& frameSize();
void updateTextures(quint8* dataY, quint8* dataU, quint8* dataV, quint32 linesizeY, quint32 linesizeU, quint32 linesizeV);
protected:
void initializeGL();
void paintGL();
void resizeGL(int width, int height);
private:
void initShader();
void initTextures();
void deInitTextures();
void updateTexture(GLuint texture, quint32 textureType, quint8* pixels, quint32 stride);
private:
// 视频帧尺寸
QSize m_frameSize = {-1, -1};
bool m_needUpdate = false;
bool m_textureInited = false;
// 顶点缓冲对象(Vertex Buffer Objects, VBO)默认即为VertexBuffer(GL_ARRAY_BUFFER)类型
QOpenGLBuffer m_vbo;
// 着色器程序:编译链接着色器
QOpenGLShaderProgram m_shaderProgram;
// YUV纹理用于生成纹理贴图
GLuint m_texture[3] = {0};
};
#endif // QYUVOPENGLWIDGET_H
#ifndef QYUVOPENGLWIDGET_H
#define QYUVOPENGLWIDGET_H
#include <QOpenGLWidget>
#include <QOpenGLFunctions>
#include <QOpenGLShaderProgram>
#include <QOpenGLBuffer>
class QYUVOpenGLWidget : public QOpenGLWidget, protected QOpenGLFunctions
{
Q_OBJECT
public:
explicit QYUVOpenGLWidget(QWidget *parent = nullptr);
virtual ~QYUVOpenGLWidget();
QSize minimumSizeHint() const override;
QSize sizeHint() const override;
void setFrameSize(const QSize& frameSize);
const QSize& frameSize();
void updateTextures(quint8* dataY, quint8* dataU, quint8* dataV, quint32 linesizeY, quint32 linesizeU, quint32 linesizeV);
protected:
void initializeGL();
void paintGL();
void resizeGL(int width, int height);
private:
void initShader();
void initTextures();
void deInitTextures();
void updateTexture(GLuint texture, quint32 textureType, quint8* pixels, quint32 stride);
private:
// 视频帧尺寸
QSize m_frameSize = {-1, -1};
bool m_needUpdate = false;
bool m_textureInited = false;
// 顶点缓冲对象(Vertex Buffer Objects, VBO)默认即为VertexBuffer(GL_ARRAY_BUFFER)类型
QOpenGLBuffer m_vbo;
// 着色器程序:编译链接着色器
QOpenGLShaderProgram m_shaderProgram;
// YUV纹理用于生成纹理贴图
GLuint m_texture[3] = {0};
};
#endif // QYUVOPENGLWIDGET_H

5
src/render/render.pri Normal file
View file

@ -0,0 +1,5 @@
HEADERS += \
$$PWD/qyuvopenglwidget.h
SOURCES += \
$$PWD/qyuvopenglwidget.cpp

9
src/server/server.pri Normal file
View file

@ -0,0 +1,9 @@
HEADERS += \
$$PWD/devicesocket.h \
$$PWD/server.h \
$$PWD/tcpserver.h
SOURCES += \
$$PWD/devicesocket.cpp \
$$PWD/server.cpp \
$$PWD/tcpserver.cpp

View file

@ -1,19 +1,19 @@
#include "tcpserver.h"
#include "devicesocket.h"
TcpServer::TcpServer(QObject *parent) : QTcpServer(parent)
{
}
TcpServer::~TcpServer()
{
}
void TcpServer::incomingConnection(qintptr handle)
{
DeviceSocket *socket = new DeviceSocket();
socket->setSocketDescriptor(handle);
addPendingConnection(socket);
}
#include "tcpserver.h"
#include "devicesocket.h"
TcpServer::TcpServer(QObject *parent) : QTcpServer(parent)
{
}
TcpServer::~TcpServer()
{
}
void TcpServer::incomingConnection(qintptr handle)
{
DeviceSocket *socket = new DeviceSocket();
socket->setSocketDescriptor(handle);
addPendingConnection(socket);
}

View file

@ -1,17 +1,17 @@
#ifndef TCPSERVER_H
#define TCPSERVER_H
#include <QTcpServer>
class TcpServer : public QTcpServer
{
Q_OBJECT
public:
explicit TcpServer(QObject *parent = nullptr);
virtual ~TcpServer();
protected:
virtual void incomingConnection(qintptr handle);
};
#endif // TCPSERVER_H
#ifndef TCPSERVER_H
#define TCPSERVER_H
#include <QTcpServer>
class TcpServer : public QTcpServer
{
Q_OBJECT
public:
explicit TcpServer(QObject *parent = nullptr);
virtual ~TcpServer();
protected:
virtual void incomingConnection(qintptr handle);
};
#endif // TCPSERVER_H