新增U盘获取图语License功能
This commit is contained in:
parent
f0b1152cad
commit
1f7bc017ca
|
@ -27,6 +27,7 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="SourceCode\HotPlugListener.cpp" />
|
<ClCompile Include="SourceCode\HotPlugListener.cpp" />
|
||||||
<ClCompile Include="SourceCode\Json\readJsonFile.cpp" />
|
<ClCompile Include="SourceCode\Json\readJsonFile.cpp" />
|
||||||
|
<ClCompile Include="SourceCode\LicenseGenerate\LicenseGenerate.cpp" />
|
||||||
<ClCompile Include="SourceCode\main.cpp" />
|
<ClCompile Include="SourceCode\main.cpp" />
|
||||||
<ClCompile Include="SourceCode\Media\Media.cpp" />
|
<ClCompile Include="SourceCode\Media\Media.cpp" />
|
||||||
<ClCompile Include="SourceCode\Media\VideoDecoder\FFmpegDecoder.cpp">
|
<ClCompile Include="SourceCode\Media\VideoDecoder\FFmpegDecoder.cpp">
|
||||||
|
@ -61,6 +62,7 @@
|
||||||
<None Include="SourceCode\Json\JsonFile\backBoardTest.json" />
|
<None Include="SourceCode\Json\JsonFile\backBoardTest.json" />
|
||||||
<None Include="SourceCode\Json\JsonFile\backDevInfo.json" />
|
<None Include="SourceCode\Json\JsonFile\backDevInfo.json" />
|
||||||
<None Include="SourceCode\Json\JsonFile\frontBoardFuncConfig.json" />
|
<None Include="SourceCode\Json\JsonFile\frontBoardFuncConfig.json" />
|
||||||
|
<None Include="SourceCode\Json\JsonFile\frontBoardLicense.json" />
|
||||||
<None Include="SourceCode\Json\JsonFile\frontBoardOneClickTest.json" />
|
<None Include="SourceCode\Json\JsonFile\frontBoardOneClickTest.json" />
|
||||||
<None Include="SourceCode\Json\JsonFile\frontBoardTest.json" />
|
<None Include="SourceCode\Json\JsonFile\frontBoardTest.json" />
|
||||||
<None Include="SourceCode\Json\JsonFile\frontDevInfo.json" />
|
<None Include="SourceCode\Json\JsonFile\frontDevInfo.json" />
|
||||||
|
@ -80,7 +82,11 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="SourceCode\Json\readJsonFile.h" />
|
<ClInclude Include="SourceCode\Json\readJsonFile.h" />
|
||||||
|
<ClInclude Include="SourceCode\LicenseGenerate\LicenseGenerate.h" />
|
||||||
|
<ClInclude Include="SourceCode\LicenseGenerate\p_code.h" />
|
||||||
<ClInclude Include="SourceCode\Media\Media.h" />
|
<ClInclude Include="SourceCode\Media\Media.h" />
|
||||||
|
<QtMoc Include="SourceCode\Network\LicenseConfirmWindow.h" />
|
||||||
|
<ClInclude Include="SourceCode\RecvDataHandler\MsgTpye.h" />
|
||||||
<QtMoc Include="SourceCode\Widget\FocusWindow.h" />
|
<QtMoc Include="SourceCode\Widget\FocusWindow.h" />
|
||||||
<QtMoc Include="SourceCode\Media\VideoDecoder\FFmpegDecoder.h" />
|
<QtMoc Include="SourceCode\Media\VideoDecoder\FFmpegDecoder.h" />
|
||||||
<ClInclude Include="SourceCode\Media\VideoDecoder\RingBuffer.h" />
|
<ClInclude Include="SourceCode\Media\VideoDecoder\RingBuffer.h" />
|
||||||
|
@ -95,6 +101,7 @@
|
||||||
<WindowsTargetPlatformVersion Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">10.0.20348.0</WindowsTargetPlatformVersion>
|
<WindowsTargetPlatformVersion Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">10.0.20348.0</WindowsTargetPlatformVersion>
|
||||||
<QtMsBuild Condition="'$(QtMsBuild)'=='' OR !Exists('$(QtMsBuild)\qt.targets')">$(MSBuildProjectDirectory)\QtMsBuild</QtMsBuild>
|
<QtMsBuild Condition="'$(QtMsBuild)'=='' OR !Exists('$(QtMsBuild)\qt.targets')">$(MSBuildProjectDirectory)\QtMsBuild</QtMsBuild>
|
||||||
<ProjectName>FactoryTestTool</ProjectName>
|
<ProjectName>FactoryTestTool</ProjectName>
|
||||||
|
<WindowsTargetPlatformVersion>7.0</WindowsTargetPlatformVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|Win32'" Label="Configuration">
|
||||||
|
@ -174,40 +181,42 @@
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<AdditionalOptions>/utf-8</AdditionalOptions>
|
<AdditionalOptions>/utf-8</AdditionalOptions>
|
||||||
|
<AdditionalIncludeDirectories>D:\QT\qt\5.15.2\msvc2019_64\include\QtNetwork;D:\QT\qt\5.15.2\msvc2019_64\include\QtGui;D:\QT\qt\5.15.2\msvc2019_64\include\QtCore;D:\QT\qt\5.15.2\msvc2019_64\include\QtWidgets;D:\QT\qt\5.15.2\msvc2019_64\include</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<AdditionalDependencies>libYTDoorLockAuthTool.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>libYTDoorLockAuthTool.lib;Qt5Core.lib;Qt5Widgets.lib;Qt5Gui.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<AdditionalLibraryDirectories>.\ThirdParty\youtu_auth_tool\libs\windowsx64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>D:\QT\qt\5.15.2\msvc2019_64\lib;.\ThirdParty\youtu_auth_tool\libs\windowsx64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<AdditionalOptions>/utf-8</AdditionalOptions>
|
<AdditionalOptions>/utf-8</AdditionalOptions>
|
||||||
<PreprocessorDefinitions>DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<AdditionalIncludeDirectories>D:\QT\qt\5.15.2\msvc2019_64\include\QtNetwork;D:\QT\qt\5.15.2\msvc2019_64\include\QtGui;D:\QT\qt\5.15.2\msvc2019_64\include\QtCore;D:\QT\qt\5.15.2\msvc2019_64\include\QtWidgets;D:\QT\qt\5.15.2\msvc2019_64\include</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<AdditionalDependencies>libYTDoorLockAuthTool.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>libYTDoorLockAuthTool.lib;Qt5Core.lib;Qt5Widgets.lib;Qt5Gui.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<AdditionalLibraryDirectories>.\ThirdParty\youtu_auth_tool\libs\windowsx64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>D:\QT\qt\5.15.2\msvc2019_64\lib;.\ThirdParty\youtu_auth_tool\libs\windowsx64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<AdditionalOptions>/utf-8</AdditionalOptions>
|
<AdditionalOptions>/utf-8</AdditionalOptions>
|
||||||
<PreprocessorDefinitions>DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<AdditionalIncludeDirectories>E:\facttest\new_factest\FactoryTestTool\ThirdParty\ffmpeg-master-latest-win64-gpl-shared\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>D:\QT\qt\5.15.2\msvc2019_64\include;E:\facttest\new_factest\FactoryTestTool\ThirdParty\ffmpeg-master-latest-win64-gpl-shared\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<AdditionalLibraryDirectories>E:\facttest\new_factest\FactoryTestTool\ThirdParty\ffmpeg-master-latest-win64-gpl-shared\lib;.\ThirdParty\youtu_auth_tool\libs\windowsx32;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>D:\QT\qt\5.15.2\msvc2019_64\lib;E:\facttest\new_factest\FactoryTestTool\ThirdParty\ffmpeg-master-latest-win64-gpl-shared\lib;.\ThirdParty\youtu_auth_tool\libs\windowsx32;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
<AdditionalDependencies>libYTDoorLockAuthTool.lib;avcodec.lib;avdevice.lib;avfilter.lib;avformat.lib;avutil.lib;postproc.lib;swresample.lib;swscale.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>libYTDoorLockAuthTool.lib;avcodec.lib;avdevice.lib;avfilter.lib;avformat.lib;avutil.lib;postproc.lib;swresample.lib;swscale.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<AdditionalOptions>/utf-8</AdditionalOptions>
|
<AdditionalOptions>/utf-8</AdditionalOptions>
|
||||||
<AdditionalIncludeDirectories>E:\facttest\new_factest\FactoryTestTool\ThirdParty\ffmpeg-master-latest-win64-gpl-shared\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>D:\QT\qt\5.15.2\msvc2019_64\include;E:\facttest\new_factest\FactoryTestTool\ThirdParty\ffmpeg-master-latest-win64-gpl-shared\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<AdditionalLibraryDirectories>E:\facttest\new_factest\FactoryTestTool\ThirdParty\ffmpeg-master-latest-win64-gpl-shared\lib;.\ThirdParty\youtu_auth_tool\libs\windowsx32;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
<AdditionalLibraryDirectories>D:\QT\qt\5.15.2\msvc2019_64\lib;E:\facttest\new_factest\FactoryTestTool\ThirdParty\ffmpeg-master-latest-win64-gpl-shared\lib;.\ThirdParty\youtu_auth_tool\libs\windowsx32;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
<AdditionalDependencies>libYTDoorLockAuthTool.lib;avcodec.lib;avdevice.lib;avfilter.lib;avformat.lib;avutil.lib;postproc.lib;swresample.lib;swscale.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>libYTDoorLockAuthTool.lib;avcodec.lib;avdevice.lib;avfilter.lib;avformat.lib;avutil.lib;postproc.lib;swresample.lib;swscale.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
|
|
|
@ -29,6 +29,9 @@
|
||||||
<ClCompile Include="SourceCode\Media\VideoDecoder\RingBuffer.cpp">
|
<ClCompile Include="SourceCode\Media\VideoDecoder\RingBuffer.cpp">
|
||||||
<Filter>Media\VideoDecoder</Filter>
|
<Filter>Media\VideoDecoder</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="SourceCode\LicenseGenerate\LicenseGenerate.cpp">
|
||||||
|
<Filter>LicenseGenerate</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<QtMoc Include="SourceCode\HotPlugListener.h">
|
<QtMoc Include="SourceCode\HotPlugListener.h">
|
||||||
|
@ -52,6 +55,9 @@
|
||||||
<QtMoc Include="SourceCode\Network\DelUserWindows.h">
|
<QtMoc Include="SourceCode\Network\DelUserWindows.h">
|
||||||
<Filter>Network</Filter>
|
<Filter>Network</Filter>
|
||||||
</QtMoc>
|
</QtMoc>
|
||||||
|
<QtMoc Include="SourceCode\Network\LicenseConfirmWindow.h">
|
||||||
|
<Filter>Network</Filter>
|
||||||
|
</QtMoc>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include=".editorconfig" />
|
<None Include=".editorconfig" />
|
||||||
|
@ -94,6 +100,9 @@
|
||||||
<None Include="SourceCode\Json\JsonFile\backDevInfo.json">
|
<None Include="SourceCode\Json\JsonFile\backDevInfo.json">
|
||||||
<Filter>Json\JsonFile</Filter>
|
<Filter>Json\JsonFile</Filter>
|
||||||
</None>
|
</None>
|
||||||
|
<None Include="SourceCode\Json\JsonFile\frontBoardLicense.json">
|
||||||
|
<Filter>Json\JsonFile</Filter>
|
||||||
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Filter Include="Widget">
|
<Filter Include="Widget">
|
||||||
|
@ -105,9 +114,6 @@
|
||||||
<Filter Include="Network">
|
<Filter Include="Network">
|
||||||
<UniqueIdentifier>{8f2d3c5e-4c9e-45a5-b3fa-6e3e5d18311c}</UniqueIdentifier>
|
<UniqueIdentifier>{8f2d3c5e-4c9e-45a5-b3fa-6e3e5d18311c}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter Include="Widget\ItemWidget">
|
|
||||||
<UniqueIdentifier>{06e02411-f304-43f0-9f87-cfad902da874}</UniqueIdentifier>
|
|
||||||
</Filter>
|
|
||||||
<Filter Include="Media">
|
<Filter Include="Media">
|
||||||
<UniqueIdentifier>{418fba92-36fe-46e4-88ae-ec0b9c7cfea8}</UniqueIdentifier>
|
<UniqueIdentifier>{418fba92-36fe-46e4-88ae-ec0b9c7cfea8}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
@ -126,6 +132,9 @@
|
||||||
<Filter Include="Media\VideoDecoder">
|
<Filter Include="Media\VideoDecoder">
|
||||||
<UniqueIdentifier>{fee8fd4c-8ed1-42b8-98d1-6d5cb4b01abf}</UniqueIdentifier>
|
<UniqueIdentifier>{fee8fd4c-8ed1-42b8-98d1-6d5cb4b01abf}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
<Filter Include="LicenseGenerate">
|
||||||
|
<UniqueIdentifier>{463f4c83-c88f-4815-b160-19430dd30eda}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="SourceCode\Media\Media.h">
|
<ClInclude Include="SourceCode\Media\Media.h">
|
||||||
|
@ -143,5 +152,14 @@
|
||||||
<ClInclude Include="SourceCode\Media\VideoDecoder\RingBuffer.h">
|
<ClInclude Include="SourceCode\Media\VideoDecoder\RingBuffer.h">
|
||||||
<Filter>Media\VideoDecoder</Filter>
|
<Filter>Media\VideoDecoder</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="SourceCode\RecvDataHandler\MsgTpye.h">
|
||||||
|
<Filter>RecvDataHandler</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="SourceCode\LicenseGenerate\p_code.h">
|
||||||
|
<Filter>LicenseGenerate</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="SourceCode\LicenseGenerate\LicenseGenerate.h">
|
||||||
|
<Filter>LicenseGenerate</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -2,25 +2,31 @@
|
||||||
{
|
{
|
||||||
"cmd": "GET_BACK_SW_VERSION",
|
"cmd": "GET_BACK_SW_VERSION",
|
||||||
"val": 0,
|
"val": 0,
|
||||||
"lable": "后板软件版本",
|
"lable": "后板V851版本:",
|
||||||
|
"timeout": 2000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cmd": "GET_BACK_SW_VERSION",
|
||||||
|
"val": 0,
|
||||||
|
"lable": "后板806版本:",
|
||||||
"timeout": 2000
|
"timeout": 2000
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cmd": "GET_BACK_HW_VERSION",
|
"cmd": "GET_BACK_HW_VERSION",
|
||||||
"val": 0,
|
"val": 0,
|
||||||
"lable": "后板硬件版本",
|
"lable": "后板硬件版本:",
|
||||||
"timeout": 2000
|
"timeout": 2000
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cmd": "GET_BACK_SN",
|
"cmd": "GET_BACK_SN",
|
||||||
"val": 0,
|
"val": 0,
|
||||||
"lable": "后板SN号",
|
"lable": "SN号:",
|
||||||
"timeout": 2000
|
"timeout": 2000
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cmd": "GET_BACK_UID",
|
"cmd": "GET_BACK_UID",
|
||||||
"val": 0,
|
"val": 0,
|
||||||
"lable": "后板UID",
|
"lable": "UID:",
|
||||||
"timeout": 2000
|
"timeout": 2000
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"cmd": "GET_FRONT_HW_INFO",
|
||||||
|
"val": 0,
|
||||||
|
"lable": "get_hw_info",
|
||||||
|
"timeout": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cmd": "GET_FRONT_LICENSE",
|
||||||
|
"val": 0,
|
||||||
|
"lable": "get_license",
|
||||||
|
"timeout": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cmd": "WRITE_FRONT_LICENSE",
|
||||||
|
"val": 0,
|
||||||
|
"lable": "write_license",
|
||||||
|
"timeout": 0
|
||||||
|
}
|
||||||
|
]
|
|
@ -2,25 +2,31 @@
|
||||||
{
|
{
|
||||||
"cmd": "GET_FRONT_V851_VERSION",
|
"cmd": "GET_FRONT_V851_VERSION",
|
||||||
"val": 0,
|
"val": 0,
|
||||||
"lable": "前板V851版本",
|
"lable": "前板V851版本:",
|
||||||
"timeout": 2000
|
"timeout": 2000
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cmd": "GET_FRONT_MCU_VERSION",
|
"cmd": "GET_FRONT_MCU_VERSION",
|
||||||
"val": 0,
|
"val": 0,
|
||||||
"lable": "前板MCU版本",
|
"lable": "前板MCU版本:",
|
||||||
"timeout": 2000
|
"timeout": 2000
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cmd": "GET_FRONT_HW_VERSION",
|
"cmd": "GET_FRONT_HW_VERSION",
|
||||||
"val": 0,
|
"val": 0,
|
||||||
"lable": "前板硬件版本",
|
"lable": "前板硬件版本:",
|
||||||
"timeout": 2000
|
"timeout": 2000
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cmd": "GET_FRONT_ALGO_VERSION",
|
"cmd": "GET_FRONT_ALGO_VERSION",
|
||||||
"val": 0,
|
"val": 0,
|
||||||
"lable": "算法版本",
|
"lable": "算法版本:",
|
||||||
|
"timeout": 2000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cmd": "GET_FRONT_SN",
|
||||||
|
"val": 0,
|
||||||
|
"lable": "SN号:",
|
||||||
"timeout": 2000
|
"timeout": 2000
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,305 +1,64 @@
|
||||||
#include "readJsonFile.h"
|
#include "readJsonFile.h"
|
||||||
|
|
||||||
QJsonArray readJson_testConfig()
|
QJsonArray readJsonArrayFromFile(const QString& filePath)
|
||||||
{
|
{
|
||||||
/*QDir dir(JsonDir);
|
QJsonArray jsonArray;
|
||||||
QString filePath = dir.absoluteFilePath("testConfig.json");*/
|
QFile file(filePath);
|
||||||
QJsonArray testJsonConfig;
|
|
||||||
//QFile file(filePath);
|
|
||||||
QFile file("./SourceCode/Json/JsonFile/testConfig.json");
|
|
||||||
//QFile file("funcConfig.json");
|
|
||||||
if (file.open(QIODevice::ReadOnly)) {
|
if (file.open(QIODevice::ReadOnly)) {
|
||||||
qDebug() << "success to open testConfig.json";
|
qDebug() << "Successfully opened" << filePath;
|
||||||
QByteArray data = file.readAll();
|
QByteArray data = file.readAll();
|
||||||
// 输出文件内容,检查是否正确读取
|
|
||||||
//qDebug() << "File content:" << data;
|
|
||||||
QJsonDocument doc = QJsonDocument::fromJson(data);
|
QJsonDocument doc = QJsonDocument::fromJson(data);
|
||||||
if (!doc.isNull()) {
|
if (!doc.isNull() && doc.isArray()) {
|
||||||
if (doc.isArray()) {
|
jsonArray = doc.array();
|
||||||
testJsonConfig = doc.array();
|
qDebug() << filePath << "JSON array size:" << jsonArray.size();
|
||||||
qDebug() << "JSON array size:" << testJsonConfig.size();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
qDebug() << "JSON document is not an array!";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
qDebug() << "Failed to parse JSON document!";
|
qDebug() << "Failed to parse JSON document from" << filePath;
|
||||||
}
|
}
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
qDebug() << "Failed to open testConfig.json";
|
qDebug() << "Failed to open" << filePath;
|
||||||
}
|
}
|
||||||
return testJsonConfig;
|
return jsonArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonArray readJson_funcConfig()
|
QJsonArray readJson_testConfig() {
|
||||||
{
|
return readJsonArrayFromFile("./SourceCode/Json/JsonFile/testConfig.json");
|
||||||
QJsonArray funcJsonConfig;
|
|
||||||
QFile funcConfig_file("./SourceCode/Json/JsonFile/funcConfig.json");
|
|
||||||
if (funcConfig_file.open(QIODevice::ReadOnly)) {
|
|
||||||
qDebug() << "success to open funcConfig.json";
|
|
||||||
QByteArray data = funcConfig_file.readAll();
|
|
||||||
// 输出文件内容,检查是否正确读取
|
|
||||||
//qDebug() << "funcConfig_file content:" << data;
|
|
||||||
QJsonDocument doc = QJsonDocument::fromJson(data);
|
|
||||||
if (!doc.isNull()) {
|
|
||||||
if (doc.isArray()) {
|
|
||||||
funcJsonConfig = doc.array();
|
|
||||||
qDebug() << "funcJsonConfig JSON array size:" << funcJsonConfig.size();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
qDebug() << "funcJsonConfig JSON document is not an array!";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
qDebug() << "Failed to parse funcJsonConfig JSON document!";
|
|
||||||
}
|
|
||||||
funcConfig_file.close();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
qDebug() << "Failed to open funcConfig.json";
|
|
||||||
}
|
|
||||||
return funcJsonConfig;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonArray readJson_frontBoardOneClickTest()
|
QJsonArray readJson_funcConfig() {
|
||||||
{
|
return readJsonArrayFromFile("./SourceCode/Json/JsonFile/funcConfig.json");
|
||||||
QJsonArray frontBoardOneClickTest;
|
|
||||||
QFile frontBoardOneClickTest_file("./SourceCode/Json/JsonFile/frontBoardOneClickTest.json");
|
|
||||||
if (frontBoardOneClickTest_file.open(QIODevice::ReadOnly)) {
|
|
||||||
qDebug() << "success to open frontBoardOneClickTest.json";
|
|
||||||
QByteArray data = frontBoardOneClickTest_file.readAll();
|
|
||||||
// 输出文件内容,检查是否正确读取
|
|
||||||
//qDebug() << "frontBoardOneClickTest_file content:" << data;
|
|
||||||
QJsonDocument doc = QJsonDocument::fromJson(data);
|
|
||||||
if (!doc.isNull()) {
|
|
||||||
if (doc.isArray()) {
|
|
||||||
frontBoardOneClickTest = doc.array();
|
|
||||||
qDebug() << "frontBoardOneClickTest JSON array size:" << frontBoardOneClickTest.size();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
qDebug() << "frontBoardOneClickTest JSON document is not an array!";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
qDebug() << "Failed to parse frontBoardOneClickTest JSON document!";
|
|
||||||
}
|
|
||||||
frontBoardOneClickTest_file.close();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
qDebug() << "Failed to open frontBoardOneClickTest.json";
|
|
||||||
}
|
|
||||||
return frontBoardOneClickTest;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonArray readJson_frontBoardTest()
|
QJsonArray readJson_frontBoardOneClickTest() {
|
||||||
{
|
return readJsonArrayFromFile("./SourceCode/Json/JsonFile/frontBoardOneClickTest.json");
|
||||||
QJsonArray frontBoardTest;
|
|
||||||
QFile frontBoardTest_file("./SourceCode/Json/JsonFile/frontBoardTest.json");
|
|
||||||
if (frontBoardTest_file.open(QIODevice::ReadOnly)) {
|
|
||||||
qDebug() << "success to open frontBoardTest.json";
|
|
||||||
QByteArray data = frontBoardTest_file.readAll();
|
|
||||||
// 输出文件内容,检查是否正确读取
|
|
||||||
//qDebug() << "frontBoardTest_file content:" << data;
|
|
||||||
QJsonDocument doc = QJsonDocument::fromJson(data);
|
|
||||||
if (!doc.isNull()) {
|
|
||||||
if (doc.isArray()) {
|
|
||||||
frontBoardTest = doc.array();
|
|
||||||
qDebug() << "frontBoardTest JSON array size:" << frontBoardTest.size();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
qDebug() << "frontBoardTest JSON document is not an array!";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
qDebug() << "Failed to parse frontBoardTest JSON document!";
|
|
||||||
}
|
|
||||||
frontBoardTest_file.close();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
qDebug() << "Failed to open frontBoardTest.json";
|
|
||||||
}
|
|
||||||
return frontBoardTest;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonArray readJson_frontBoardFuncConfig()
|
QJsonArray readJson_frontBoardTest() {
|
||||||
{
|
return readJsonArrayFromFile("./SourceCode/Json/JsonFile/frontBoardTest.json");
|
||||||
QJsonArray frontBoardFuncConfig;
|
|
||||||
QFile frontBoardFuncConfig_file("./SourceCode/Json/JsonFile/frontBoardFuncConfig.json");
|
|
||||||
if (frontBoardFuncConfig_file.open(QIODevice::ReadOnly)) {
|
|
||||||
qDebug() << "success to open frontBoardFuncConfig.json";
|
|
||||||
QByteArray data = frontBoardFuncConfig_file.readAll();
|
|
||||||
// 输出文件内容,检查是否正确读取
|
|
||||||
//qDebug() << "frontBoardFuncConfig_file content:" << data;
|
|
||||||
QJsonDocument doc = QJsonDocument::fromJson(data);
|
|
||||||
if (!doc.isNull()) {
|
|
||||||
if (doc.isArray()) {
|
|
||||||
frontBoardFuncConfig = doc.array();
|
|
||||||
qDebug() << "frontBoardFuncConfig JSON array size:" << frontBoardFuncConfig.size();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
qDebug() << "frontBoardFuncConfig JSON document is not an array!";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
qDebug() << "Failed to parse frontBoardFuncConfig JSON document!";
|
|
||||||
}
|
|
||||||
frontBoardFuncConfig_file.close();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
qDebug() << "Failed to open frontBoardFuncConfig.json";
|
|
||||||
}
|
|
||||||
return frontBoardFuncConfig;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//QJsonArray readJson_funcConfig()
|
QJsonArray readJson_frontBoardFuncConfig() {
|
||||||
//{
|
return readJsonArrayFromFile("./SourceCode/Json/JsonFile/frontBoardFuncConfig.json");
|
||||||
// QJsonArray funcJsonConfig;
|
|
||||||
// QFile funcConfig_file("./SourceCode/Json/JsonFile/funcConfig.json");
|
|
||||||
// if (funcConfig_file.open(QIODevice::ReadOnly)) {
|
|
||||||
// qDebug() << "success to open funcConfig.json";
|
|
||||||
// QByteArray data = funcConfig_file.readAll();
|
|
||||||
// // 输出文件内容,检查是否正确读取
|
|
||||||
// //qDebug() << "funcConfig_file content:" << data;
|
|
||||||
// QJsonDocument doc = QJsonDocument::fromJson(data);
|
|
||||||
// if (!doc.isNull()) {
|
|
||||||
// if (doc.isArray()) {
|
|
||||||
// funcJsonConfig = doc.array();
|
|
||||||
// qDebug() << "funcJsonConfig JSON array size:" << funcJsonConfig.size();
|
|
||||||
// }
|
|
||||||
// else {
|
|
||||||
// qDebug() << "funcJsonConfig JSON document is not an array!";
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// else {
|
|
||||||
// qDebug() << "Failed to parse funcJsonConfig JSON document!";
|
|
||||||
// }
|
|
||||||
// funcConfig_file.close();
|
|
||||||
// }
|
|
||||||
// else {
|
|
||||||
// qDebug() << "Failed to open funcConfig.json";
|
|
||||||
// }
|
|
||||||
// return funcJsonConfig;
|
|
||||||
//}
|
|
||||||
|
|
||||||
QJsonArray readJson_frontDevInfo()
|
|
||||||
{
|
|
||||||
QJsonArray frontDevInfo;
|
|
||||||
QFile frontDevInfo_file("./SourceCode/Json/JsonFile/frontDevInfo.json");
|
|
||||||
if (frontDevInfo_file.open(QIODevice::ReadOnly)) {
|
|
||||||
qDebug() << "success to open frontDevInfo.json";
|
|
||||||
QByteArray data = frontDevInfo_file.readAll();
|
|
||||||
// 输出文件内容,检查是否正确读取
|
|
||||||
//qDebug() << "funcConfig_file content:" << data;
|
|
||||||
QJsonDocument doc = QJsonDocument::fromJson(data);
|
|
||||||
if (!doc.isNull()) {
|
|
||||||
if (doc.isArray()) {
|
|
||||||
frontDevInfo = doc.array();
|
|
||||||
qDebug() << "frontDevInfo JSON array size:" << frontDevInfo.size();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
qDebug() << "frontDevInfo JSON document is not an array!";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
qDebug() << "Failed to parse frontDevInfo JSON document!";
|
|
||||||
}
|
|
||||||
frontDevInfo_file.close();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
qDebug() << "Failed to open frontDevInfo.json";
|
|
||||||
}
|
|
||||||
return frontDevInfo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonArray readJson_backDevInfo()
|
QJsonArray readJson_frontDevInfo() {
|
||||||
{
|
return readJsonArrayFromFile("./SourceCode/Json/JsonFile/frontDevInfo.json");
|
||||||
QJsonArray backDevInfo;
|
|
||||||
QFile backDevInfo_file("./SourceCode/Json/JsonFile/backDevInfo.json");
|
|
||||||
if (backDevInfo_file.open(QIODevice::ReadOnly)) {
|
|
||||||
qDebug() << "success to open backDevInfo.json";
|
|
||||||
QByteArray data = backDevInfo_file.readAll();
|
|
||||||
// 输出文件内容,检查是否正确读取
|
|
||||||
//qDebug() << "funcConfig_file content:" << data;
|
|
||||||
QJsonDocument doc = QJsonDocument::fromJson(data);
|
|
||||||
if (!doc.isNull()) {
|
|
||||||
if (doc.isArray()) {
|
|
||||||
backDevInfo = doc.array();
|
|
||||||
qDebug() << "backDevInfo JSON array size:" << backDevInfo.size();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
qDebug() << "backDevInfo JSON document is not an array!";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
qDebug() << "Failed to parse backDevInfo JSON document!";
|
|
||||||
}
|
|
||||||
backDevInfo_file.close();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
qDebug() << "Failed to open backDevInfo.json";
|
|
||||||
}
|
|
||||||
return backDevInfo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonArray readJson_getPic()
|
QJsonArray readJson_frontLicense() {
|
||||||
{
|
return readJsonArrayFromFile("./SourceCode/Json/JsonFile/frontBoardLicense.json");
|
||||||
QJsonArray getPicJson;
|
|
||||||
QFile getPic_file("./SourceCode/Json/JsonFile/getPic.json");
|
|
||||||
if (getPic_file.open(QIODevice::ReadOnly)) {
|
|
||||||
qDebug() << "success to open getPic.json";
|
|
||||||
QByteArray data = getPic_file.readAll();
|
|
||||||
// 输出文件内容,检查是否正确读取
|
|
||||||
//qDebug() << "funcConfig_file content:" << data;
|
|
||||||
QJsonDocument doc = QJsonDocument::fromJson(data);
|
|
||||||
if (!doc.isNull()) {
|
|
||||||
if (doc.isArray()) {
|
|
||||||
getPicJson = doc.array();
|
|
||||||
qDebug() << "getPic JSON array size:" << getPicJson.size();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
qDebug() << "getPic JSON document is not an array!";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
qDebug() << "Failed to parse getPic JSON document!";
|
|
||||||
}
|
|
||||||
getPic_file.close();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
qDebug() << "Failed to open getPic.json";
|
|
||||||
}
|
|
||||||
return getPicJson;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonArray readJson_getVideo()
|
QJsonArray readJson_backDevInfo() {
|
||||||
{
|
return readJsonArrayFromFile("./SourceCode/Json/JsonFile/backDevInfo.json");
|
||||||
QJsonArray getVideoJson;
|
}
|
||||||
QFile getVideo_file("./SourceCode/Json/JsonFile/getVideo.json");
|
|
||||||
if (getVideo_file.open(QIODevice::ReadOnly)) {
|
QJsonArray readJson_getPic() {
|
||||||
qDebug() << "success to open getVideo.json";
|
return readJsonArrayFromFile("./SourceCode/Json/JsonFile/getPic.json");
|
||||||
QByteArray data = getVideo_file.readAll();
|
}
|
||||||
// 输出文件内容,检查是否正确读取
|
|
||||||
//qDebug() << "funcConfig_file content:" << data;
|
QJsonArray readJson_getVideo() {
|
||||||
QJsonDocument doc = QJsonDocument::fromJson(data);
|
return readJsonArrayFromFile("./SourceCode/Json/JsonFile/getVideo.json");
|
||||||
if (!doc.isNull()) {
|
|
||||||
if (doc.isArray()) {
|
|
||||||
getVideoJson = doc.array();
|
|
||||||
qDebug() << "getVideo JSON array size:" << getVideoJson.size();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
qDebug() << "getVideo JSON document is not an array!";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
qDebug() << "Failed to parse getVideo JSON document!";
|
|
||||||
}
|
|
||||||
getVideo_file.close();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
qDebug() << "Failed to open getVideo.json";
|
|
||||||
}
|
|
||||||
return getVideoJson;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ QJsonArray readJson_frontBoardOneClickTest();
|
||||||
QJsonArray readJson_frontBoardTest();
|
QJsonArray readJson_frontBoardTest();
|
||||||
QJsonArray readJson_frontBoardFuncConfig();
|
QJsonArray readJson_frontBoardFuncConfig();
|
||||||
QJsonArray readJson_frontDevInfo();
|
QJsonArray readJson_frontDevInfo();
|
||||||
|
QJsonArray readJson_frontLicense();
|
||||||
QJsonArray readJson_backDevInfo();
|
QJsonArray readJson_backDevInfo();
|
||||||
|
|
||||||
QJsonArray readJson_testConfig();
|
QJsonArray readJson_testConfig();
|
||||||
|
|
|
@ -0,0 +1,68 @@
|
||||||
|
// LicenseGenerate.cpp
|
||||||
|
#include "LicenseGenerate.h"
|
||||||
|
|
||||||
|
#define PIX_HARDWARE_INFO_BYTES 32
|
||||||
|
#define PIX_LICENCE_BYTES 128
|
||||||
|
|
||||||
|
typedef const char* (*pix_license_generate_version_func)();
|
||||||
|
typedef int (*pix_license_generate_func)(const unsigned char*, int, unsigned char*, int);
|
||||||
|
|
||||||
|
void licenseGenerate()
|
||||||
|
{
|
||||||
|
unsigned char hardware_info[PIX_HARDWARE_INFO_BYTES] = { };
|
||||||
|
unsigned char license_info[PIX_LICENCE_BYTES] = { 0 };
|
||||||
|
|
||||||
|
// 获取当前路径
|
||||||
|
wchar_t currentPath[MAX_PATH];
|
||||||
|
GetCurrentDirectoryW(MAX_PATH, currentPath);
|
||||||
|
std::wcout << L"Current Directory: " << currentPath << std::endl;
|
||||||
|
|
||||||
|
// 打印 DLL 的完整路径
|
||||||
|
std::wstring dllPath = std::wstring(currentPath) + L"\\ThirdParty\\LicenseGenerate\\pix_license.dll";
|
||||||
|
std::wcout << L"DLL Path: " << dllPath << std::endl;
|
||||||
|
|
||||||
|
// 加载 DLL 文件
|
||||||
|
HINSTANCE hDLL = LoadLibraryW(dllPath.c_str());
|
||||||
|
if (hDLL == NULL) {
|
||||||
|
std::cerr << "Failed to load DLL. Error code: " << GetLastError() << std::endl;
|
||||||
|
FreeLibrary(hDLL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
pix_license_generate_version_func pix_license_generate_version =
|
||||||
|
(pix_license_generate_version_func)GetProcAddress(hDLL, "pix_license_generate_version");
|
||||||
|
pix_license_generate_func pix_license_generate =
|
||||||
|
(pix_license_generate_func)GetProcAddress(hDLL, "pix_license_generate");
|
||||||
|
if (pix_license_generate_version == NULL || pix_license_generate == NULL) {
|
||||||
|
std::cerr << "Failed to find one or more functions." << std::endl;
|
||||||
|
FreeLibrary(hDLL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
printf("pix_license_generate_version is %s\n",
|
||||||
|
pix_license_generate_version());
|
||||||
|
|
||||||
|
printf("Hardware info:");
|
||||||
|
for (int j = 0; j < PIX_HARDWARE_INFO_BYTES; ++j) {
|
||||||
|
hardware_info[j] = j;
|
||||||
|
printf("0x%02x, ", hardware_info[j]);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
// return 限制不调用 pix_license_generate, 防止减少license个数
|
||||||
|
return;
|
||||||
|
int ret = pix_license_generate(hardware_info, PIX_HARDWARE_INFO_BYTES,
|
||||||
|
license_info, PIX_LICENCE_BYTES);
|
||||||
|
if (ret != SDK_CODE_OK) {
|
||||||
|
printf("Fail to generate license with %d\n", ret);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printf("License is\n");
|
||||||
|
for (int j = 0; j < PIX_LICENCE_BYTES; ++j) {
|
||||||
|
printf("0x%02x, ", license_info[j]);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
FreeLibrary(hDLL);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
#ifndef LICENSEGENERATE_H
|
||||||
|
#define LICENSEGENERATE_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QTcpServer>
|
||||||
|
#include <QJsonArray>
|
||||||
|
#include <windows.h>
|
||||||
|
#include <iostream>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "p_code.h"
|
||||||
|
|
||||||
|
void licenseGenerate();
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,41 @@
|
||||||
|
#ifndef FACEKITASM_P_CODE_H
|
||||||
|
#define FACEKITASM_P_CODE_H
|
||||||
|
|
||||||
|
#define SDK_CODE_OK 0
|
||||||
|
#define SDK_CODE_INVALID_ARG -4
|
||||||
|
#define SDK_CODE_MODEL_NOT_INIT -44
|
||||||
|
#define SDK_CODE_REID_MODEL_NOT_INIT -550
|
||||||
|
#define SDK_CODE_INNER_ERROR -444
|
||||||
|
#define SDK_CODE_MODEL_NOT_FOUND -404
|
||||||
|
#define SDK_CODE_LICENCE_NOT_FOUND -405
|
||||||
|
#define SDK_CODE_INVALID_LICENCE -406
|
||||||
|
#define SDK_CODE_BROKEN_MODEL_FILE -407
|
||||||
|
#define SDK_CODE_MODEL_FILE_VERSION_MISMATCH -408
|
||||||
|
#define SDK_CODE_INVALID_LICENCE_STATUS -501
|
||||||
|
#define SDK_CODE_INVALID_HW_LICENCE_STATUS -505
|
||||||
|
#define SDK_CODE_INVALID_STATUS -600
|
||||||
|
#define SDK_CODE_DECODE_ERROR -1001
|
||||||
|
#define SDK_CODE_DETECT_ERROR -1002
|
||||||
|
#define SDK_CODE_SHIELDING -1010
|
||||||
|
#define SDK_CODE_MATCH_ERROR -2010
|
||||||
|
#define SDK_CODE_EXTRACT_POINT_ERROR -2011
|
||||||
|
#define SDK_CODE_FILE_NOT_EXIST -3010
|
||||||
|
|
||||||
|
#define SDK_CODE_SYS_TIME_ERROR -5001
|
||||||
|
#define SDK_CODE_IMAGE_NOT_EXIST -5002
|
||||||
|
#define SDK_CODE_IMAGE_DECODE_FAIL -5003
|
||||||
|
#define SDK_CODE_FLOOD_SPECKLE_IMAGE_SIZE_ERROR -5004
|
||||||
|
#define SDK_CODE_SPECKLE_IMAGE_TOO_LESS_POINT -5005
|
||||||
|
#define SDK_CODE_CALI_TOO_LESS_POINT_MATCH -5006
|
||||||
|
#define SDK_CODE_FAILED_TO_FIND_CHECKER -5007
|
||||||
|
#define SDK_CODE_REF_IMAGE_LOSS_POINT -5008
|
||||||
|
#define SDK_CODE_CALIBRATION_ERROR -5009
|
||||||
|
#define SDK_CODE_GET_DEPTH_ERROR -5010
|
||||||
|
|
||||||
|
#define SDK_CODE_NOT_IMPLEMENT -6868
|
||||||
|
|
||||||
|
#define SDK_CODE_AUTH_ERROR -8888
|
||||||
|
|
||||||
|
//#define TRIVAL_VERSION 1
|
||||||
|
|
||||||
|
#endif //FACEKITASM_P_CODE_HPP
|
Binary file not shown.
|
@ -1,3 +1,255 @@
|
||||||
|
// FFmpegDecoder.cpp
|
||||||
|
//#include "FFmpegDecoder.h"
|
||||||
|
//
|
||||||
|
//FFmpegDecoder::FFmpegDecoder(QObject* parent) :
|
||||||
|
// QThread(parent),
|
||||||
|
// videoLabel(nullptr),
|
||||||
|
// abort(false),
|
||||||
|
// restart(false),
|
||||||
|
// formatContext(nullptr),
|
||||||
|
// codecContext(nullptr),
|
||||||
|
// frame(nullptr),
|
||||||
|
// packet(nullptr),
|
||||||
|
// swsContext(nullptr),
|
||||||
|
// videoStreamIndex(-1) // 初始化成员变量
|
||||||
|
//{
|
||||||
|
// av_log_set_level(AV_LOG_QUIET); // 设置日志级别为安静模式
|
||||||
|
// avformat_network_init(); // 初始化网络
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//FFmpegDecoder::~FFmpegDecoder()
|
||||||
|
//{
|
||||||
|
// mutex.lock();
|
||||||
|
// abort = true;
|
||||||
|
// condition.wakeOne();
|
||||||
|
// mutex.unlock();
|
||||||
|
// wait();
|
||||||
|
// if (codecContext) {
|
||||||
|
// avcodec_free_context(&codecContext);
|
||||||
|
// }
|
||||||
|
// if (frame) {
|
||||||
|
// av_frame_free(&frame);
|
||||||
|
// }
|
||||||
|
// if (packet) {
|
||||||
|
// av_packet_free(&packet);
|
||||||
|
// }
|
||||||
|
// if (swsContext) {
|
||||||
|
// sws_freeContext(swsContext);
|
||||||
|
// }
|
||||||
|
// if (formatContext) {
|
||||||
|
// avformat_close_input(&formatContext);
|
||||||
|
// }
|
||||||
|
// avformat_network_deinit(); // 反初始化网络
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//void FFmpegDecoder::initialize()
|
||||||
|
//{
|
||||||
|
// // 初始化FFmpeg库
|
||||||
|
// avformat_network_init();
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//void FFmpegDecoder::decodeFile(const QString& filePath, QLabel* videoLabel)
|
||||||
|
//{
|
||||||
|
// QMutexLocker locker(&mutex);
|
||||||
|
// this->filePath = filePath;
|
||||||
|
// this->videoLabel = videoLabel;
|
||||||
|
// if (!isRunning()) {
|
||||||
|
// //start(LowPriority);
|
||||||
|
// start(NormalPriority);
|
||||||
|
// }
|
||||||
|
// restart = true;
|
||||||
|
// condition.wakeOne();
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//void FFmpegDecoder::run()
|
||||||
|
//{
|
||||||
|
// QFile file(filePath);
|
||||||
|
// qint64 fileSize = 0;
|
||||||
|
//
|
||||||
|
// for (;;) {
|
||||||
|
// mutex.lock();
|
||||||
|
// while (!restart && !abort) {
|
||||||
|
// condition.wait(&mutex);
|
||||||
|
// }
|
||||||
|
// if (abort) {
|
||||||
|
// mutex.unlock();
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// restart = false;
|
||||||
|
// QLabel* currentVideoLabel = videoLabel;
|
||||||
|
// QSize labelSize = currentVideoLabel->size();
|
||||||
|
// mutex.unlock();
|
||||||
|
// qDebug() << "Video label size: Width =" << labelSize.width() << ", Height =" << labelSize.height();
|
||||||
|
//
|
||||||
|
// if (!file.open(QIODevice::ReadOnly)) {
|
||||||
|
// qWarning() << "Failed to open file:" << filePath;
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
// // 从上次处理的位置开始读取
|
||||||
|
// file.seek(fileSize);
|
||||||
|
//
|
||||||
|
// formatContext = nullptr;
|
||||||
|
// codecContext = nullptr;
|
||||||
|
// frame = nullptr;
|
||||||
|
// packet = nullptr;
|
||||||
|
//
|
||||||
|
// // 通过 FFmpeg 初始化格式上下文和解码器
|
||||||
|
// if (avformat_open_input(&formatContext, filePath.toStdString().c_str(), nullptr, nullptr) != 0) {
|
||||||
|
// qWarning() << "Failed to open file with FFmpeg:" << filePath;
|
||||||
|
// file.close();
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (avformat_find_stream_info(formatContext, nullptr) < 0) {
|
||||||
|
// qWarning() << "Failed to retrieve stream info";
|
||||||
|
// avformat_close_input(&formatContext);
|
||||||
|
// file.close();
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// videoStreamIndex = -1;
|
||||||
|
// for (unsigned int i = 0; i < formatContext->nb_streams; ++i) {
|
||||||
|
// if (formatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
|
||||||
|
// videoStreamIndex = i;
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// if (videoStreamIndex == -1) {
|
||||||
|
// qWarning() << "No video stream found";
|
||||||
|
// avformat_close_input(&formatContext);
|
||||||
|
// file.close();
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// AVCodecParameters* codecParameters = formatContext->streams[videoStreamIndex]->codecpar;
|
||||||
|
// const AVCodec* codec = avcodec_find_decoder(codecParameters->codec_id);
|
||||||
|
// if (!codec) {
|
||||||
|
// qWarning() << "Unsupported codec";
|
||||||
|
// avformat_close_input(&formatContext);
|
||||||
|
// file.close();
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// codecContext = avcodec_alloc_context3(codec);
|
||||||
|
// if (!codecContext) {
|
||||||
|
// qWarning() << "Failed to allocate codec context";
|
||||||
|
// avformat_close_input(&formatContext);
|
||||||
|
// file.close();
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (avcodec_parameters_to_context(codecContext, codecParameters) < 0) {
|
||||||
|
// qWarning() << "Failed to copy codec parameters to context";
|
||||||
|
// avcodec_free_context(&codecContext);
|
||||||
|
// avformat_close_input(&formatContext);
|
||||||
|
// file.close();
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (avcodec_open2(codecContext, codec, nullptr) < 0) {
|
||||||
|
// qWarning() << "Failed to open codec";
|
||||||
|
// avcodec_free_context(&codecContext);
|
||||||
|
// avformat_close_input(&formatContext);
|
||||||
|
// file.close();
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// frame = av_frame_alloc();
|
||||||
|
// packet = av_packet_alloc();
|
||||||
|
//
|
||||||
|
// // 主解码循环
|
||||||
|
// while (!abort) {
|
||||||
|
// qint64 currentFileSize = file.size();
|
||||||
|
// if (currentFileSize > fileSize) {
|
||||||
|
// fileSize = currentFileSize;
|
||||||
|
// file.seek(fileSize); // 设置文件读取位置到末尾
|
||||||
|
//
|
||||||
|
// // 读取并处理数据包
|
||||||
|
// while (av_read_frame(formatContext, packet) >= 0) {
|
||||||
|
// if (packet->stream_index == videoStreamIndex) {
|
||||||
|
// int ret = avcodec_send_packet(codecContext, packet);
|
||||||
|
// if (ret < 0) {
|
||||||
|
// qWarning() << "Error sending packet for decoding";
|
||||||
|
// av_packet_unref(packet);
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
// while (ret >= 0) {
|
||||||
|
// ret = avcodec_receive_frame(codecContext, frame);
|
||||||
|
// if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {
|
||||||
|
// qWarning() << "----------- break";
|
||||||
|
// av_packet_unref(packet);
|
||||||
|
// continue;
|
||||||
|
// //break;
|
||||||
|
// }
|
||||||
|
// else if (ret < 0) {
|
||||||
|
// qWarning() << "Error during decoding";
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /*mutex.lock();
|
||||||
|
// QSize labelSize = currentVideoLabel->size();
|
||||||
|
// mutex.unlock();*/
|
||||||
|
// //qDebug() << "Video label size: Width =" << labelSize.width() << ", Height =" << labelSize.height();
|
||||||
|
// QImage img = avFrameToQImage(frame);
|
||||||
|
// QImage scaledImage = img.scaled(labelSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||||
|
// currentVideoLabel->setPixmap(QPixmap::fromImage(scaledImage));
|
||||||
|
// //currentVideoLabel->setPixmap(QPixmap::fromImage(img));
|
||||||
|
// QThread::msleep(10); // Simulate 25 FPS frame rate
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// av_packet_unref(packet);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// mutex.lock();
|
||||||
|
// if (restart) {
|
||||||
|
// restart = false;
|
||||||
|
// mutex.unlock();
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// mutex.unlock();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// avcodec_free_context(&codecContext);
|
||||||
|
// avformat_close_input(&formatContext);
|
||||||
|
// av_frame_free(&frame);
|
||||||
|
// av_packet_free(&packet);
|
||||||
|
// file.close();
|
||||||
|
// sws_freeContext(swsContext);
|
||||||
|
//
|
||||||
|
// mutex.lock();
|
||||||
|
// if (!restart) {
|
||||||
|
// condition.wait(&mutex);
|
||||||
|
// }
|
||||||
|
// mutex.unlock();
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//QImage FFmpegDecoder::avFrameToQImage(AVFrame* frame)
|
||||||
|
//{
|
||||||
|
// int width = frame->width;
|
||||||
|
// int height = frame->height;
|
||||||
|
// AVPixelFormat pixFmt = (AVPixelFormat)frame->format;
|
||||||
|
//
|
||||||
|
// SwsContext* swsCtx = sws_getContext(width, height, pixFmt, width, height, AV_PIX_FMT_RGB24, SWS_BILINEAR, nullptr, nullptr, nullptr);
|
||||||
|
// if (!swsCtx) {
|
||||||
|
// qWarning() << "Failed to initialize the conversion context";
|
||||||
|
// return QImage();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// QImage img(width, height, QImage::Format_RGB888);
|
||||||
|
// uint8_t* dest[4] = { img.bits(), nullptr, nullptr, nullptr };
|
||||||
|
// int destLinesize[4] = { img.bytesPerLine(), 0, 0, 0 };
|
||||||
|
//
|
||||||
|
// sws_scale(swsCtx, frame->data, frame->linesize, 0, height, dest, destLinesize);
|
||||||
|
// sws_freeContext(swsCtx);
|
||||||
|
//
|
||||||
|
// return img;
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
// FFmpegDecoder.cpp
|
// FFmpegDecoder.cpp
|
||||||
#include "FFmpegDecoder.h"
|
#include "FFmpegDecoder.h"
|
||||||
|
|
||||||
|
@ -15,35 +267,25 @@ FFmpegDecoder::FFmpegDecoder(QObject* parent) :
|
||||||
{
|
{
|
||||||
av_log_set_level(AV_LOG_QUIET); // 设置日志级别为安静模式
|
av_log_set_level(AV_LOG_QUIET); // 设置日志级别为安静模式
|
||||||
avformat_network_init(); // 初始化网络
|
avformat_network_init(); // 初始化网络
|
||||||
|
qDebug() << "FFmpegDecoder created";
|
||||||
}
|
}
|
||||||
|
|
||||||
FFmpegDecoder::~FFmpegDecoder()
|
FFmpegDecoder::~FFmpegDecoder()
|
||||||
{
|
{
|
||||||
|
qDebug() << "Destroying FFmpegDecoder";
|
||||||
mutex.lock();
|
mutex.lock();
|
||||||
abort = true;
|
abort = true;
|
||||||
condition.wakeOne();
|
condition.wakeOne();
|
||||||
mutex.unlock();
|
mutex.unlock();
|
||||||
wait();
|
wait();
|
||||||
if (codecContext) {
|
cleanup();
|
||||||
avcodec_free_context(&codecContext);
|
|
||||||
}
|
|
||||||
if (frame) {
|
|
||||||
av_frame_free(&frame);
|
|
||||||
}
|
|
||||||
if (packet) {
|
|
||||||
av_packet_free(&packet);
|
|
||||||
}
|
|
||||||
if (swsContext) {
|
|
||||||
sws_freeContext(swsContext);
|
|
||||||
}
|
|
||||||
if (formatContext) {
|
|
||||||
avformat_close_input(&formatContext);
|
|
||||||
}
|
|
||||||
avformat_network_deinit(); // 反初始化网络
|
avformat_network_deinit(); // 反初始化网络
|
||||||
|
qDebug() << "FFmpegDecoder destroyed";
|
||||||
}
|
}
|
||||||
|
|
||||||
void FFmpegDecoder::initialize()
|
void FFmpegDecoder::initialize()
|
||||||
{
|
{
|
||||||
|
qDebug() << "Initializing FFmpeg library";
|
||||||
// 初始化FFmpeg库
|
// 初始化FFmpeg库
|
||||||
avformat_network_init();
|
avformat_network_init();
|
||||||
}
|
}
|
||||||
|
@ -54,7 +296,7 @@ void FFmpegDecoder::decodeFile(const QString& filePath, QLabel* videoLabel)
|
||||||
this->filePath = filePath;
|
this->filePath = filePath;
|
||||||
this->videoLabel = videoLabel;
|
this->videoLabel = videoLabel;
|
||||||
if (!isRunning()) {
|
if (!isRunning()) {
|
||||||
//start(LowPriority);
|
qDebug() << "Starting decoder thread";
|
||||||
start(NormalPriority);
|
start(NormalPriority);
|
||||||
}
|
}
|
||||||
restart = true;
|
restart = true;
|
||||||
|
@ -66,13 +308,14 @@ void FFmpegDecoder::run()
|
||||||
QFile file(filePath);
|
QFile file(filePath);
|
||||||
qint64 fileSize = 0;
|
qint64 fileSize = 0;
|
||||||
|
|
||||||
for (;;) {
|
while (true) {
|
||||||
mutex.lock();
|
mutex.lock();
|
||||||
while (!restart && !abort) {
|
while (!restart && !abort) {
|
||||||
condition.wait(&mutex);
|
condition.wait(&mutex);
|
||||||
}
|
}
|
||||||
if (abort) {
|
if (abort) {
|
||||||
mutex.unlock();
|
mutex.unlock();
|
||||||
|
qDebug() << "Decoder thread aborting";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
restart = false;
|
restart = false;
|
||||||
|
@ -85,78 +328,14 @@ void FFmpegDecoder::run()
|
||||||
qWarning() << "Failed to open file:" << filePath;
|
qWarning() << "Failed to open file:" << filePath;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// 从上次处理的位置开始读取
|
|
||||||
file.seek(fileSize);
|
|
||||||
|
|
||||||
formatContext = nullptr;
|
if (!initializeFFmpeg(filePath)) {
|
||||||
codecContext = nullptr;
|
qDebug() << "Failed to initialize FFmpeg for file:" << filePath;
|
||||||
frame = nullptr;
|
cleanup();
|
||||||
packet = nullptr;
|
|
||||||
|
|
||||||
// 通过 FFmpeg 初始化格式上下文和解码器
|
|
||||||
if (avformat_open_input(&formatContext, filePath.toStdString().c_str(), nullptr, nullptr) != 0) {
|
|
||||||
qWarning() << "Failed to open file with FFmpeg:" << filePath;
|
|
||||||
file.close();
|
file.close();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (avformat_find_stream_info(formatContext, nullptr) < 0) {
|
|
||||||
qWarning() << "Failed to retrieve stream info";
|
|
||||||
avformat_close_input(&formatContext);
|
|
||||||
file.close();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
videoStreamIndex = -1;
|
|
||||||
for (unsigned int i = 0; i < formatContext->nb_streams; ++i) {
|
|
||||||
if (formatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
|
|
||||||
videoStreamIndex = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (videoStreamIndex == -1) {
|
|
||||||
qWarning() << "No video stream found";
|
|
||||||
avformat_close_input(&formatContext);
|
|
||||||
file.close();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
AVCodecParameters* codecParameters = formatContext->streams[videoStreamIndex]->codecpar;
|
|
||||||
const AVCodec* codec = avcodec_find_decoder(codecParameters->codec_id);
|
|
||||||
if (!codec) {
|
|
||||||
qWarning() << "Unsupported codec";
|
|
||||||
avformat_close_input(&formatContext);
|
|
||||||
file.close();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
codecContext = avcodec_alloc_context3(codec);
|
|
||||||
if (!codecContext) {
|
|
||||||
qWarning() << "Failed to allocate codec context";
|
|
||||||
avformat_close_input(&formatContext);
|
|
||||||
file.close();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (avcodec_parameters_to_context(codecContext, codecParameters) < 0) {
|
|
||||||
qWarning() << "Failed to copy codec parameters to context";
|
|
||||||
avcodec_free_context(&codecContext);
|
|
||||||
avformat_close_input(&formatContext);
|
|
||||||
file.close();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (avcodec_open2(codecContext, codec, nullptr) < 0) {
|
|
||||||
qWarning() << "Failed to open codec";
|
|
||||||
avcodec_free_context(&codecContext);
|
|
||||||
avformat_close_input(&formatContext);
|
|
||||||
file.close();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
frame = av_frame_alloc();
|
|
||||||
packet = av_packet_alloc();
|
|
||||||
|
|
||||||
// 主解码循环
|
// 主解码循环
|
||||||
while (!abort) {
|
while (!abort) {
|
||||||
qint64 currentFileSize = file.size();
|
qint64 currentFileSize = file.size();
|
||||||
|
@ -176,24 +355,17 @@ void FFmpegDecoder::run()
|
||||||
while (ret >= 0) {
|
while (ret >= 0) {
|
||||||
ret = avcodec_receive_frame(codecContext, frame);
|
ret = avcodec_receive_frame(codecContext, frame);
|
||||||
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {
|
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {
|
||||||
qWarning() << "----------- break";
|
|
||||||
av_packet_unref(packet);
|
av_packet_unref(packet);
|
||||||
continue;
|
continue;
|
||||||
//break;
|
|
||||||
}
|
}
|
||||||
else if (ret < 0) {
|
else if (ret < 0) {
|
||||||
qWarning() << "Error during decoding";
|
qWarning() << "Error during decoding";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*mutex.lock();
|
|
||||||
QSize labelSize = currentVideoLabel->size();
|
|
||||||
mutex.unlock();*/
|
|
||||||
//qDebug() << "Video label size: Width =" << labelSize.width() << ", Height =" << labelSize.height();
|
|
||||||
QImage img = avFrameToQImage(frame);
|
QImage img = avFrameToQImage(frame);
|
||||||
QImage scaledImage = img.scaled(labelSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
QImage scaledImage = img.scaled(labelSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||||
currentVideoLabel->setPixmap(QPixmap::fromImage(scaledImage));
|
currentVideoLabel->setPixmap(QPixmap::fromImage(scaledImage));
|
||||||
//currentVideoLabel->setPixmap(QPixmap::fromImage(img));
|
|
||||||
QThread::msleep(10); // Simulate 25 FPS frame rate
|
QThread::msleep(10); // Simulate 25 FPS frame rate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -210,12 +382,8 @@ void FFmpegDecoder::run()
|
||||||
mutex.unlock();
|
mutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
avcodec_free_context(&codecContext);
|
cleanup();
|
||||||
avformat_close_input(&formatContext);
|
|
||||||
av_frame_free(&frame);
|
|
||||||
av_packet_free(&packet);
|
|
||||||
file.close();
|
file.close();
|
||||||
sws_freeContext(swsContext);
|
|
||||||
|
|
||||||
mutex.lock();
|
mutex.lock();
|
||||||
if (!restart) {
|
if (!restart) {
|
||||||
|
@ -225,25 +393,102 @@ void FFmpegDecoder::run()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FFmpegDecoder::initializeFFmpeg(const QString& filePath)
|
||||||
|
{
|
||||||
|
if (avformat_open_input(&formatContext, filePath.toStdString().c_str(), nullptr, nullptr) != 0) {
|
||||||
|
qWarning() << "Failed to open file with FFmpeg:" << filePath;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (avformat_find_stream_info(formatContext, nullptr) < 0) {
|
||||||
|
qWarning() << "Failed to retrieve stream info";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
videoStreamIndex = -1;
|
||||||
|
for (unsigned int i = 0; i < formatContext->nb_streams; ++i) {
|
||||||
|
if (formatContext->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
|
||||||
|
videoStreamIndex = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (videoStreamIndex == -1) {
|
||||||
|
qWarning() << "No video stream found";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
AVCodecParameters* codecParameters = formatContext->streams[videoStreamIndex]->codecpar;
|
||||||
|
const AVCodec* codec = avcodec_find_decoder(codecParameters->codec_id);
|
||||||
|
if (!codec) {
|
||||||
|
qWarning() << "Unsupported codec";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
codecContext = avcodec_alloc_context3(codec);
|
||||||
|
if (!codecContext) {
|
||||||
|
qWarning() << "Failed to allocate codec context";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (avcodec_parameters_to_context(codecContext, codecParameters) < 0) {
|
||||||
|
qWarning() << "Failed to copy codec parameters to context";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (avcodec_open2(codecContext, codec, nullptr) < 0) {
|
||||||
|
qWarning() << "Failed to open codec";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
frame = av_frame_alloc();
|
||||||
|
packet = av_packet_alloc();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FFmpegDecoder::cleanup()
|
||||||
|
{
|
||||||
|
if (codecContext) {
|
||||||
|
avcodec_free_context(&codecContext);
|
||||||
|
codecContext = nullptr;
|
||||||
|
}
|
||||||
|
if (frame) {
|
||||||
|
av_frame_free(&frame);
|
||||||
|
frame = nullptr;
|
||||||
|
}
|
||||||
|
if (packet) {
|
||||||
|
av_packet_free(&packet);
|
||||||
|
packet = nullptr;
|
||||||
|
}
|
||||||
|
if (swsContext) {
|
||||||
|
sws_freeContext(swsContext);
|
||||||
|
swsContext = nullptr;
|
||||||
|
}
|
||||||
|
if (formatContext) {
|
||||||
|
avformat_close_input(&formatContext);
|
||||||
|
formatContext = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QImage FFmpegDecoder::avFrameToQImage(AVFrame* frame)
|
QImage FFmpegDecoder::avFrameToQImage(AVFrame* frame)
|
||||||
{
|
{
|
||||||
int width = frame->width;
|
int width = frame->width;
|
||||||
int height = frame->height;
|
int height = frame->height;
|
||||||
AVPixelFormat pixFmt = (AVPixelFormat)frame->format;
|
AVPixelFormat pixFmt = (AVPixelFormat)frame->format;
|
||||||
|
|
||||||
SwsContext* swsCtx = sws_getContext(width, height, pixFmt, width, height, AV_PIX_FMT_RGB24, SWS_BILINEAR, nullptr, nullptr, nullptr);
|
if (!swsContext) {
|
||||||
if (!swsCtx) {
|
swsContext = sws_getContext(width, height, pixFmt, width, height, AV_PIX_FMT_RGB24, SWS_BILINEAR, nullptr, nullptr, nullptr);
|
||||||
qWarning() << "Failed to initialize the conversion context";
|
if (!swsContext) {
|
||||||
return QImage();
|
qWarning() << "Failed to initialize the conversion context";
|
||||||
|
return QImage();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QImage img(width, height, QImage::Format_RGB888);
|
QImage img(width, height, QImage::Format_RGB888);
|
||||||
uint8_t* dest[4] = { img.bits(), nullptr, nullptr, nullptr };
|
uint8_t* dest[4] = { img.bits(), nullptr, nullptr, nullptr };
|
||||||
int destLinesize[4] = { img.bytesPerLine(), 0, 0, 0 };
|
int destLinesize[4] = { img.bytesPerLine(), 0, 0, 0 };
|
||||||
|
|
||||||
sws_scale(swsCtx, frame->data, frame->linesize, 0, height, dest, destLinesize);
|
sws_scale(swsContext, frame->data, frame->linesize, 0, height, dest, destLinesize);
|
||||||
sws_freeContext(swsCtx);
|
|
||||||
|
|
||||||
return img;
|
return img;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,9 @@ public:
|
||||||
void decodeFile(const QString& filePath, QLabel* videoLabel);
|
void decodeFile(const QString& filePath, QLabel* videoLabel);
|
||||||
void decodeSingleFrame(const QByteArray& data, QLabel* videoLabel); // 添加 videoLabel 参数
|
void decodeSingleFrame(const QByteArray& data, QLabel* videoLabel); // 添加 videoLabel 参数
|
||||||
|
|
||||||
|
bool initializeFFmpeg(const QString& filePath);
|
||||||
|
void cleanup();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void run() override;
|
void run() override;
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,21 @@
|
||||||
// ClientHandler.cpp
|
// ClientHandler.cpp
|
||||||
#include "ClientHandler.h"
|
#include "ClientHandler.h"
|
||||||
|
#include "LicenseConfirmWindow.h"
|
||||||
|
|
||||||
ClientHandler::ClientHandler(QTcpSocket* socket, QJsonArray frontBoardOneClickTest, QJsonArray frontBoardTest, QJsonArray frontBoardFuncConfig, QJsonArray getDevInfoJson,
|
ClientHandler::ClientHandler(QTcpSocket* socket, QJsonArray frontBoardOneClickTest, QJsonArray frontBoardTest, QJsonArray frontBoardFuncConfig,
|
||||||
QJsonArray getPicJson, QJsonArray getVideoJson, int clientId, QObject* parent)
|
QJsonArray frontBoardDevInfoJson, QJsonArray frontBoardLicenseJson, QJsonArray backBoardDevInfoJson,
|
||||||
: QObject(parent), socket(socket), frontBoardOneClickTest(frontBoardOneClickTest), frontBoardTest(frontBoardTest), frontBoardFuncConfig(frontBoardFuncConfig), getDevInfoJson(getDevInfoJson),
|
QJsonArray getPicJson, QJsonArray getVideoJson, int clientId, QObject* parent)
|
||||||
getPicJson(getPicJson), getVideoJson(getVideoJson), currentItemIndex(0), clientId(clientId),
|
: QObject(parent), socket(socket),
|
||||||
isManualSend(false), isSingleSend(false), isClickedSend(false), size(0), isFirstDataReceived(true), processDataFunction(nullptr),
|
frontBoardOneClickTest(frontBoardOneClickTest), frontBoardTest(frontBoardTest),
|
||||||
isDataStuck(false), dataProcessingActive(false), isRecvVideoData(false)
|
frontBoardFuncConfig(frontBoardFuncConfig), frontBoardDevInfoJson(frontBoardDevInfoJson),
|
||||||
|
frontBoardLicenseJson(frontBoardLicenseJson),
|
||||||
|
backBoardDevInfoJson(backBoardDevInfoJson), getPicJson(getPicJson),
|
||||||
|
getVideoJson(getVideoJson), currentItemIndex(0), clientId(clientId),
|
||||||
|
isManualSend(false), isSingleSend(false), isClickedSend(false), size(0),
|
||||||
|
isFirstDataReceived(true), processDataFunction(nullptr),
|
||||||
|
isDataStuck(false), dataProcessingActive(false), isRecvVideoData(false),
|
||||||
|
currentFrontBoardIndex(0), // 初始化为0
|
||||||
|
currentBackBoardIndex(0)
|
||||||
{
|
{
|
||||||
connect(socket, &QTcpSocket::readyRead, this, &ClientHandler::onDataReceived);
|
connect(socket, &QTcpSocket::readyRead, this, &ClientHandler::onDataReceived);
|
||||||
connect(socket, &QTcpSocket::disconnected, this, &ClientHandler::onDisconnected);
|
connect(socket, &QTcpSocket::disconnected, this, &ClientHandler::onDisconnected);
|
||||||
|
@ -179,6 +188,30 @@ void ClientHandler::sendGetVideoItem(int itemIndex, int video_flag)
|
||||||
sendJsonItem(getVideoJson, itemIndex, "", "getVideo");
|
sendJsonItem(getVideoJson, itemIndex, "", "getVideo");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 发送License处理按键
|
||||||
|
void ClientHandler::sendLicenseItem(int itemIndex)
|
||||||
|
{
|
||||||
|
if (itemIndex < 0 || itemIndex >= frontBoardLicenseJson.size()) {
|
||||||
|
qDebug() << "Invalid itemIndex";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QJsonObject item = frontBoardLicenseJson[itemIndex].toObject();
|
||||||
|
QString label = item["lable"].toString();
|
||||||
|
|
||||||
|
if (label == "write_license" || label == "get_license") {
|
||||||
|
LicenseConfirmWindow dialog("你确定要发送此授权项吗?");
|
||||||
|
int result = dialog.exec();
|
||||||
|
|
||||||
|
if (result == QDialog::Accepted) {
|
||||||
|
sendJsonItem(frontBoardLicenseJson, itemIndex, "", "License");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sendJsonItem(frontBoardLicenseJson, itemIndex, "", "License");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 发送单独一个功能配置 JSON 项目
|
// 发送单独一个功能配置 JSON 项目
|
||||||
void ClientHandler::sendFuncItem(int itemIndex, const QString text)
|
void ClientHandler::sendFuncItem(int itemIndex, const QString text)
|
||||||
{
|
{
|
||||||
|
@ -192,6 +225,50 @@ void ClientHandler::sendItem(int itemIndex)
|
||||||
sendJsonItem(frontBoardTest, itemIndex, "", "test");
|
sendJsonItem(frontBoardTest, itemIndex, "", "test");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ClientHandler::sendDevInfoJsonItem(const QJsonObject& jsonItem, int itemIndex)
|
||||||
|
{
|
||||||
|
QMutexLocker locker(&mutex);
|
||||||
|
isPowerOnSend = true;
|
||||||
|
qDebug() << "itemIndex:" << itemIndex;
|
||||||
|
qDebug() << "jsonItem.size():" << jsonItem.size();
|
||||||
|
|
||||||
|
QString itemData = QJsonDocument(jsonItem).toJson();
|
||||||
|
emit sendData(itemData.toUtf8());
|
||||||
|
|
||||||
|
if (jsonItem.contains("timeout")) {
|
||||||
|
int timeout = jsonItem.value("timeout").toInt();
|
||||||
|
if (timeout > 0) {
|
||||||
|
emit startTimeout(timeout);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// 如果没有 timeout 字段,则不设置超时处理,一直等待数据接收
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClientHandler::sendDevInfoItem()
|
||||||
|
{
|
||||||
|
// 前板
|
||||||
|
if (1) {
|
||||||
|
qDebug() << "frontBoardDevInfoJson.size():" << frontBoardDevInfoJson.size();
|
||||||
|
if (currentFrontBoardIndex < frontBoardDevInfoJson.size()) {
|
||||||
|
sendDevInfoJsonItem(frontBoardDevInfoJson[currentFrontBoardIndex].toObject(), 1);
|
||||||
|
currentFrontBoardIndex ++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
isPowerOnSend = false;
|
||||||
|
}
|
||||||
|
// 后板
|
||||||
|
else {
|
||||||
|
if (currentBackBoardIndex < backBoardDevInfoJson.size()) {
|
||||||
|
sendDevInfoJsonItem(backBoardDevInfoJson[currentBackBoardIndex ++].toObject(), 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
isPowerOnSend = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 发送下一个 JSON 项目
|
// 发送下一个 JSON 项目
|
||||||
void ClientHandler::sendNextItem()
|
void ClientHandler::sendNextItem()
|
||||||
{
|
{
|
||||||
|
@ -330,11 +407,11 @@ void ClientHandler::onDataReceived()
|
||||||
{
|
{
|
||||||
// 接收其他数据 添加区分 视频与其他数据 的标志位
|
// 接收其他数据 添加区分 视频与其他数据 的标志位
|
||||||
if (!isRecvVideoData &&
|
if (!isRecvVideoData &&
|
||||||
(isClickedSend || (isSingleSend && (currentItemIndex < frontBoardTest.size())))) {
|
(isPowerOnSend || isClickedSend || (isSingleSend && (currentItemIndex < frontBoardTest.size())))) {
|
||||||
QByteArray allData;
|
QByteArray allData;
|
||||||
while (socket->bytesAvailable() > 0) {
|
while (socket->bytesAvailable() > 0) {
|
||||||
qint64 bytesAvailableBefore = socket->bytesAvailable();
|
qint64 bytesAvailableBefore = socket->bytesAvailable();
|
||||||
qDebug() << "Bytes available before read:" << bytesAvailableBefore << "clientId:" << clientId;
|
//qDebug() << "Bytes available before read:" << bytesAvailableBefore << "clientId:" << clientId;
|
||||||
QByteArray buffer;
|
QByteArray buffer;
|
||||||
buffer.resize(qMin(bytesAvailableBefore, qint64(5 * 1024))); // 每次读取最多 5KB
|
buffer.resize(qMin(bytesAvailableBefore, qint64(5 * 1024))); // 每次读取最多 5KB
|
||||||
qint64 bytesRead = socket->read(buffer.data(), buffer.size());
|
qint64 bytesRead = socket->read(buffer.data(), buffer.size());
|
||||||
|
@ -349,7 +426,7 @@ void ClientHandler::onDataReceived()
|
||||||
}
|
}
|
||||||
if (!allData.isEmpty()) {
|
if (!allData.isEmpty()) {
|
||||||
emit dataReceived(getClientAddress(), allData, 0xFF, currentItemIndex, currentFuncItemIndex, "", "");
|
emit dataReceived(getClientAddress(), allData, 0xFF, currentItemIndex, currentFuncItemIndex, "", "");
|
||||||
if (!isSingleSend) {
|
if (!isSingleSend && !isPowerOnSend) {
|
||||||
currentItemIndex ++;
|
currentItemIndex ++;
|
||||||
itemsProcessedCount ++;
|
itemsProcessedCount ++;
|
||||||
}
|
}
|
||||||
|
@ -360,17 +437,25 @@ void ClientHandler::onDataReceived()
|
||||||
isSingleSend = false; // 重置标志
|
isSingleSend = false; // 重置标志
|
||||||
isClickedSend = false;
|
isClickedSend = false;
|
||||||
}
|
}
|
||||||
else if (currentItemIndex < frontBoardOneClickTest.size()) {
|
else if (isPowerOnSend && currentFrontBoardIndex < frontBoardDevInfoJson.size()) {
|
||||||
|
sendDevInfoItem();
|
||||||
|
}
|
||||||
|
/*else if (isPowerOnSend) {
|
||||||
|
qDebug() << "All items processed in onDataReceived.";
|
||||||
|
emit allItemsProcessed(getClientAddress(), currentFrontBoardIndex);
|
||||||
|
isPowerOnSend = false;
|
||||||
|
}*/
|
||||||
|
else if (isClickedSend && (currentItemIndex < frontBoardOneClickTest.size())) {
|
||||||
//qDebug() << "-------- start sendNextItem";
|
//qDebug() << "-------- start sendNextItem";
|
||||||
sendNextItem();
|
sendNextItem();
|
||||||
}
|
}
|
||||||
else {
|
else if(isClickedSend) {
|
||||||
qDebug() << "All items processed in onDataReceived.";
|
//qDebug() << "All items processed in onDataReceived.";
|
||||||
emit allItemsProcessed(getClientAddress(), itemsProcessedCount);
|
emit allItemsProcessed(getClientAddress(), itemsProcessedCount);
|
||||||
isClickedSend = false;
|
isClickedSend = false;
|
||||||
//resetCurrentItemIndex();
|
//resetCurrentItemIndex();
|
||||||
}
|
}
|
||||||
qDebug() << "" << __FUNCTION__ << "------> itemsProcessedCount :" << itemsProcessedCount;
|
//qDebug() << "" << __FUNCTION__ << "------> itemsProcessedCount :" << itemsProcessedCount;
|
||||||
}
|
}
|
||||||
// 接收视频流数据 isRecvVideoData 置 0
|
// 接收视频流数据 isRecvVideoData 置 0
|
||||||
else if (!dataProcessingActive) {
|
else if (!dataProcessingActive) {
|
||||||
|
@ -387,7 +472,7 @@ void ClientHandler::processPendingData()
|
||||||
QByteArray allData;
|
QByteArray allData;
|
||||||
while (socket->bytesAvailable() > 0 && maxIterations-- > 0) {
|
while (socket->bytesAvailable() > 0 && maxIterations-- > 0) {
|
||||||
qint64 bytesAvailableBefore = socket->bytesAvailable();
|
qint64 bytesAvailableBefore = socket->bytesAvailable();
|
||||||
qDebug() << "Bytes available before read:" << bytesAvailableBefore << "clientId:" << clientId;
|
//qDebug() << "Bytes available before read:" << bytesAvailableBefore << "clientId:" << clientId;
|
||||||
RETRY:
|
RETRY:
|
||||||
// 分块读取数据,避免一次性读取过多数据
|
// 分块读取数据,避免一次性读取过多数据
|
||||||
QByteArray buffer;
|
QByteArray buffer;
|
||||||
|
@ -398,9 +483,9 @@ void ClientHandler::processPendingData()
|
||||||
buffer.resize(bytesRead);
|
buffer.resize(bytesRead);
|
||||||
allData.append(buffer);
|
allData.append(buffer);
|
||||||
qint64 bytesAvailableAfter = socket->bytesAvailable();
|
qint64 bytesAvailableAfter = socket->bytesAvailable();
|
||||||
qDebug() << "--1--Received data size:" << buffer.size() << "clientId:" << clientId
|
/*qDebug() << "--1--Received data size:" << buffer.size() << "clientId:" << clientId
|
||||||
<< "at" << QDateTime::currentDateTime().toString(Qt::ISODate)
|
<< "at" << QDateTime::currentDateTime().toString(Qt::ISODate)
|
||||||
<< "bytesAvailable after read:" << bytesAvailableAfter;
|
<< "bytesAvailable after read:" << bytesAvailableAfter; */
|
||||||
|
|
||||||
if (isFirstDataReceived) {
|
if (isFirstDataReceived) {
|
||||||
RNDISFirstData(buffer);
|
RNDISFirstData(buffer);
|
||||||
|
@ -474,23 +559,31 @@ void ClientHandler::onTimeout()
|
||||||
//emit statusUpdated(socket->peerAddress().toString(), currentItemIndex, false, itemData);
|
//emit statusUpdated(socket->peerAddress().toString(), currentItemIndex, false, itemData);
|
||||||
emit statusUpdated(getClientAddress(), currentItemIndex + 1, currentFuncItemIndex + 1,
|
emit statusUpdated(getClientAddress(), currentItemIndex + 1, currentFuncItemIndex + 1,
|
||||||
false, getCurrentItemLable(), getCurrentFuncItemLable());
|
false, getCurrentItemLable(), getCurrentFuncItemLable());
|
||||||
if (isSingleSend == false) {
|
if (!isSingleSend && !isPowerOnSend) {
|
||||||
currentItemIndex ++;
|
currentItemIndex ++;
|
||||||
itemsProcessedCount ++;
|
itemsProcessedCount ++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isSingleSend) {
|
if (isSingleSend) {
|
||||||
isSingleSend = false; // 重置标志
|
isSingleSend = false;
|
||||||
}
|
}
|
||||||
else if (currentItemIndex < frontBoardOneClickTest.size()) {
|
else if (isPowerOnSend && currentFrontBoardIndex < frontBoardDevInfoJson.size()) {
|
||||||
|
sendDevInfoItem();
|
||||||
|
}
|
||||||
|
else if (isClickedSend && (currentItemIndex < frontBoardOneClickTest.size())) {
|
||||||
//qDebug() << "------> onTimeout";
|
//qDebug() << "------> onTimeout";
|
||||||
sendNextItem();
|
sendNextItem();
|
||||||
}
|
}
|
||||||
else {
|
else if(isClickedSend) {
|
||||||
qDebug() << "All items processed in onTimeout.";
|
qDebug() << "All items processed in onTimeout.";
|
||||||
emit allItemsProcessed(getClientAddress(), itemsProcessedCount);
|
emit allItemsProcessed(getClientAddress(), itemsProcessedCount);
|
||||||
//resetCurrentItemIndex();
|
//resetCurrentItemIndex();
|
||||||
}
|
}
|
||||||
|
else if (isPowerOnSend) {
|
||||||
|
qDebug() << "All items processed in onTimeout.";
|
||||||
|
emit allItemsProcessed(getClientAddress(), currentFrontBoardIndex);
|
||||||
|
//resetCurrentItemIndex();
|
||||||
|
}
|
||||||
//qDebug() << "------> end mutex :" << __FUNCTION__;
|
//qDebug() << "------> end mutex :" << __FUNCTION__;
|
||||||
qDebug() << "" << __FUNCTION__ << "------> itemsProcessedCount :" << itemsProcessedCount;
|
qDebug() << "" << __FUNCTION__ << "------> itemsProcessedCount :" << itemsProcessedCount;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QElapsedTimer>
|
#include <QElapsedTimer>
|
||||||
#include <QStorageInfo>
|
#include <QStorageInfo>
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
#include "DelUserWindows.h"
|
#include "DelUserWindows.h"
|
||||||
|
|
||||||
|
@ -28,11 +29,15 @@ class ClientHandler : public QObject, public QRunnable
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ClientHandler(QTcpSocket* socket, QJsonArray frontBoardOneClickTest, QJsonArray frontBoardTest, QJsonArray frontBoardFuncConfig, QJsonArray getDevInfoJson,
|
explicit ClientHandler(QTcpSocket* socket, QJsonArray frontBoardOneClickTest, QJsonArray frontBoardTest,
|
||||||
QJsonArray getPicJson, QJsonArray getVideoJson, int clientId, QObject* parent = nullptr);
|
QJsonArray frontBoardFuncConfig, QJsonArray frontBoardDevInfoJson, QJsonArray frontBoardLicenseJson,
|
||||||
|
QJsonArray backBoardDevInfoJson, QJsonArray getPicJson, QJsonArray getVideoJson,
|
||||||
|
int clientId, QObject* parent = nullptr);
|
||||||
|
|
||||||
~ClientHandler();
|
~ClientHandler();
|
||||||
|
|
||||||
|
void sendDevInfoItem();
|
||||||
|
|
||||||
bool isData_Stuck() const;
|
bool isData_Stuck() const;
|
||||||
//static int pre_H264_clientId; // 预览H264的客户端ID
|
//static int pre_H264_clientId; // 预览H264的客户端ID
|
||||||
QTcpSocket* getSocket() const { return socket; }
|
QTcpSocket* getSocket() const { return socket; }
|
||||||
|
@ -48,6 +53,8 @@ public:
|
||||||
void sendGetPicItem(int itemIndex);
|
void sendGetPicItem(int itemIndex);
|
||||||
// 发送拉视频流按键
|
// 发送拉视频流按键
|
||||||
void sendGetVideoItem(int itemIndex, int video_flag);
|
void sendGetVideoItem(int itemIndex, int video_flag);
|
||||||
|
// 发送License处理按键
|
||||||
|
void sendLicenseItem(int itemIndex);
|
||||||
// 发送下一个功能配置 JSON 项目
|
// 发送下一个功能配置 JSON 项目
|
||||||
void sendFuncItem(int itemIndex, QString text);
|
void sendFuncItem(int itemIndex, QString text);
|
||||||
// 发送下一个 JSON 项目
|
// 发送下一个 JSON 项目
|
||||||
|
@ -110,7 +117,10 @@ private:
|
||||||
QTcpSocket* socket; // 客户端 socket
|
QTcpSocket* socket; // 客户端 socket
|
||||||
QJsonArray frontBoardOneClickTest; // 前板一键功能测试 JSON
|
QJsonArray frontBoardOneClickTest; // 前板一键功能测试 JSON
|
||||||
QJsonArray frontBoardTest; // 前板单项测试 JSON
|
QJsonArray frontBoardTest; // 前板单项测试 JSON
|
||||||
QJsonArray frontBoardFuncConfig; // 前板功能配置参数 JSON
|
QJsonArray frontBoardFuncConfig; // 前板功能配置参数 JSON
|
||||||
|
QJsonArray frontBoardDevInfoJson; // 前板设备信息参数 JSON
|
||||||
|
QJsonArray frontBoardLicenseJson; // 前板license信息 JSON
|
||||||
|
QJsonArray backBoardDevInfoJson; // 后板设备信息参数 JSON
|
||||||
QJsonArray jsonConfig; // 测试区 JSON 配置
|
QJsonArray jsonConfig; // 测试区 JSON 配置
|
||||||
QJsonArray funcJsonConfig; // 功能区 JSON 配置
|
QJsonArray funcJsonConfig; // 功能区 JSON 配置
|
||||||
QJsonArray getDevInfoJson; // 获取设备信息 JSON 配置
|
QJsonArray getDevInfoJson; // 获取设备信息 JSON 配置
|
||||||
|
@ -127,9 +137,12 @@ private:
|
||||||
bool isSingleSend; // 单独点击按键发送的标志
|
bool isSingleSend; // 单独点击按键发送的标志
|
||||||
bool isClickedSend; // 点击按键发送的标志,没有点击不接收数据
|
bool isClickedSend; // 点击按键发送的标志,没有点击不接收数据
|
||||||
bool isRecvVideoData;
|
bool isRecvVideoData;
|
||||||
|
bool isPowerOnSend = false; // 上电发送设备信息
|
||||||
//QTimer* timeoutTimer; // 超时定时器
|
//QTimer* timeoutTimer; // 超时定时器
|
||||||
|
|
||||||
int size;
|
int size;
|
||||||
|
int currentFrontBoardIndex; // 当前发送的前板设备信息项的索引
|
||||||
|
int currentBackBoardIndex; // 当前发送的后板设备信息项的索引
|
||||||
|
|
||||||
void checkThreadStatus();
|
void checkThreadStatus();
|
||||||
bool isFirstDataReceived;
|
bool isFirstDataReceived;
|
||||||
|
@ -141,6 +154,9 @@ private:
|
||||||
void RNDISClient3Data(QByteArray& data);
|
void RNDISClient3Data(QByteArray& data);
|
||||||
void RNDISClient4Data(QByteArray& data);
|
void RNDISClient4Data(QByteArray& data);
|
||||||
|
|
||||||
|
void sendDevInfoJsonItem(const QJsonObject& jsonItem, int itemIndex);
|
||||||
|
//void sendDevInfoItem();
|
||||||
|
|
||||||
QTimer* readTimer;
|
QTimer* readTimer;
|
||||||
QTimer* threadStatusTimer;
|
QTimer* threadStatusTimer;
|
||||||
QTimer* connectionCheckTimer;
|
QTimer* connectionCheckTimer;
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
#ifndef LICENSECONFIRMWINDOW_H
|
||||||
|
#define LICENSECONFIRMWINDOW_H
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <QLabel>
|
||||||
|
|
||||||
|
class LicenseConfirmWindow : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit LicenseConfirmWindow(const QString& message, QWidget* parent = nullptr)
|
||||||
|
{
|
||||||
|
messageLabel = new QLabel(message, this);
|
||||||
|
confirmButton = new QPushButton("确认", this);
|
||||||
|
cancelButton = new QPushButton("取消", this);
|
||||||
|
|
||||||
|
QVBoxLayout* layout = new QVBoxLayout;
|
||||||
|
layout->addWidget(messageLabel);
|
||||||
|
QHBoxLayout* buttonLayout = new QHBoxLayout;
|
||||||
|
buttonLayout->addWidget(confirmButton);
|
||||||
|
buttonLayout->addWidget(cancelButton);
|
||||||
|
layout->addLayout(buttonLayout);
|
||||||
|
|
||||||
|
setLayout(layout);
|
||||||
|
setWindowTitle("获取License");
|
||||||
|
resize(260, 100); // 设置对话框的大小
|
||||||
|
|
||||||
|
connect(confirmButton, &QPushButton::clicked, this, &LicenseConfirmWindow::onConfirmClicked);
|
||||||
|
connect(cancelButton, &QPushButton::clicked, this, &LicenseConfirmWindow::onCancelClicked);
|
||||||
|
}
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void onConfirmClicked()
|
||||||
|
{
|
||||||
|
accept();
|
||||||
|
}
|
||||||
|
|
||||||
|
void onCancelClicked()
|
||||||
|
{
|
||||||
|
reject();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
QLabel* messageLabel;
|
||||||
|
QPushButton* confirmButton;
|
||||||
|
QPushButton* cancelButton;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // LICENSECONFIRMWINDOW_H
|
|
@ -0,0 +1,61 @@
|
||||||
|
#ifndef MSGTYPE_H
|
||||||
|
#define MSGTYPE_H
|
||||||
|
|
||||||
|
// 前板测试项
|
||||||
|
#define FACE_ENROLL_SINGLE 0x0200
|
||||||
|
#define FACE_ENROLL 0x0201
|
||||||
|
#define HAND_ENROLL 0x0202
|
||||||
|
#define FACE_VERIFY 0x0203
|
||||||
|
#define HAND_VERIFY 0x0204
|
||||||
|
#define DEL_USER 0x0205
|
||||||
|
#define DEL_ALLUSER 0x0206
|
||||||
|
#define GET_USER 0x0207
|
||||||
|
#define GET_ALLUSER 0x0208
|
||||||
|
#define PASSWD_ENROLL 0x0209
|
||||||
|
#define IMG_ENROLL 0x020A
|
||||||
|
|
||||||
|
#define GET_IMG 0x0220
|
||||||
|
#define START_VIDEO 0x0221
|
||||||
|
#define STOP_VIDEO 0x0222
|
||||||
|
|
||||||
|
#define TOUCH_TEST 0x0240
|
||||||
|
#define MIC_TEST 0x0241
|
||||||
|
#define SPK_TEST 0x0242
|
||||||
|
#define RADAR_TEST 0x0243
|
||||||
|
#define NFC_TEST 0x0244
|
||||||
|
#define PR_SWITCH 0x0245
|
||||||
|
#define PS_TEST 0x0246
|
||||||
|
#define BACKLIGHT 0x0247
|
||||||
|
#define IR_LED 0x0248
|
||||||
|
#define UART_TEST 0x0249
|
||||||
|
#define PIR_TEST 0x024A
|
||||||
|
|
||||||
|
// 前板配置
|
||||||
|
#define FACE_VERIFY_THRES 0x0300
|
||||||
|
#define FACE_THRES_LEVEL 0x0301
|
||||||
|
#define FACE_LIVE_THRES 0x0302
|
||||||
|
#define FACE_ACC_THRES 0x0303
|
||||||
|
#define FACE_ACC_LEVEL 0x0304
|
||||||
|
#define FACE_DIS_RANGE 0x0305
|
||||||
|
#define FACE_ANGLE_RANGE 0x0306
|
||||||
|
#define HAND_VERIFY_THRES 0x0307
|
||||||
|
#define HANS_THRES_LEVEL 0x0308
|
||||||
|
#define HAND_LIVE_THRES 0x0309
|
||||||
|
#define USER_MAX_NUM 0x030A
|
||||||
|
#define ADMI_USER_MAX_NUM 0x030B
|
||||||
|
#define FACE_REPEAT 0x030C
|
||||||
|
#define HAND_REPEAT 0x030D
|
||||||
|
|
||||||
|
#define SET_IP 0x0320
|
||||||
|
#define SET_PORT 0x0321
|
||||||
|
|
||||||
|
#define SET_VOLUME 0x0340
|
||||||
|
#define SET_BACKLIGHT 0x0341
|
||||||
|
#define SET_RADAR_DIS 0x0342
|
||||||
|
#define SET_UART_BARTRATE 0x0343
|
||||||
|
|
||||||
|
#define SET_LOG_LEVEL 0x0360
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
|
@ -16,8 +16,14 @@ DataHandler::DataHandler(QLabel* leftLens_imageLabel, QLabel* rightLens_imageLab
|
||||||
|
|
||||||
DataHandler::~DataHandler()
|
DataHandler::~DataHandler()
|
||||||
{
|
{
|
||||||
delete ffmpegDecoder; // 释放解码器
|
if (ffmpegDecoder) {
|
||||||
delete buffer;
|
ffmpegDecoder->requestInterruption();
|
||||||
|
ffmpegDecoder->wait(); // 等待解码器线程完成
|
||||||
|
delete ffmpegDecoder;
|
||||||
|
ffmpegDecoder = nullptr;
|
||||||
|
}
|
||||||
|
delete buffer;
|
||||||
|
buffer = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 将十六进制字符串转换为 QByteArray
|
// 将十六进制字符串转换为 QByteArray
|
||||||
|
@ -47,14 +53,10 @@ void DataHandler::showVideo(const QString& client, const QByteArray& valData)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//qDebug() << "==========valData.size:" << valData.size();
|
|
||||||
if (!valData.isEmpty()) {
|
if (!valData.isEmpty()) {
|
||||||
file.write(valData);
|
file.write(valData);
|
||||||
file.flush(); // 刷新文件缓冲区,以确保数据写入磁盘
|
file.flush(); // 刷新文件缓冲区
|
||||||
qWarning() << " ------------ write ------------" ;
|
|
||||||
}
|
}
|
||||||
//qint64 elapsed = timer.elapsed(); // 获取经过的时间(毫秒)
|
|
||||||
//qDebug() << "Time spent writing file:" << elapsed << "ms";
|
|
||||||
|
|
||||||
if (!start_run) {
|
if (!start_run) {
|
||||||
start_run = 1;
|
start_run = 1;
|
||||||
|
@ -69,29 +71,8 @@ void DataHandler::clearAllRecvData() {
|
||||||
dataLen = 0;
|
dataLen = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataHandler::handleCmd(unsigned char msg_id, const QString& client, QByteArray actual_data)
|
|
||||||
{
|
|
||||||
switch (msg_id) {
|
|
||||||
case 0x19:
|
|
||||||
{
|
|
||||||
showPic(leftLens_m_imageLabel, rightLens_m_imageLabel, client, actual_data);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 0x11:
|
|
||||||
{
|
|
||||||
showVideo(client, actual_data);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
{}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 处理接收到的数据
|
// 处理接收到的数据
|
||||||
void DataHandler::handleData(const QString& client, const QByteArray& recvData, unsigned char msg_id,
|
void DataHandler::handleData(const QString& client, const QByteArray& recvData, int msg_id,
|
||||||
int currentRecvItemIndex, int currentRecvFuncItemIndex,
|
int currentRecvItemIndex, int currentRecvFuncItemIndex,
|
||||||
const QString& itemData, const QString& funcItemData)
|
const QString& itemData, const QString& funcItemData)
|
||||||
{
|
{
|
||||||
|
@ -111,7 +92,7 @@ void DataHandler::handleData(const QString& client, const QByteArray& recvData,
|
||||||
qDebug() << "read file data size:" << recvdata.size();
|
qDebug() << "read file data size:" << recvdata.size();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
qDebug() << "---Received data size:" << recvData.size();
|
//qDebug() << "---Received data size:" << recvData.size();
|
||||||
|
|
||||||
// 将接收到的数据追加到buffer
|
// 将接收到的数据追加到buffer
|
||||||
buffer->append(recvData);
|
buffer->append(recvData);
|
||||||
|
@ -119,7 +100,8 @@ void DataHandler::handleData(const QString& client, const QByteArray& recvData,
|
||||||
while (buffer->size() >= 11) { // 至少需要11个字节来解析数据头
|
while (buffer->size() >= 11) { // 至少需要11个字节来解析数据头
|
||||||
// 检查数据头
|
// 检查数据头
|
||||||
if (buffer->mid(0, 4) == QByteArray::fromHex("aa55aa55")) {
|
if (buffer->mid(0, 4) == QByteArray::fromHex("aa55aa55")) {
|
||||||
msg_id = static_cast<unsigned char>(buffer->at(4));
|
msg_id = (static_cast<unsigned char>(buffer->at(5)) << 8) |
|
||||||
|
(static_cast<unsigned char>(buffer->at(4)));
|
||||||
int dataSize = (static_cast<unsigned char>(buffer->at(9)) << 24) |
|
int dataSize = (static_cast<unsigned char>(buffer->at(9)) << 24) |
|
||||||
(static_cast<unsigned char>(buffer->at(8)) << 16) |
|
(static_cast<unsigned char>(buffer->at(8)) << 16) |
|
||||||
(static_cast<unsigned char>(buffer->at(7)) << 8) |
|
(static_cast<unsigned char>(buffer->at(7)) << 8) |
|
||||||
|
@ -138,8 +120,8 @@ void DataHandler::handleData(const QString& client, const QByteArray& recvData,
|
||||||
buffer->remove(0, totalSize); // 移除已处理的数据
|
buffer->remove(0, totalSize); // 移除已处理的数据
|
||||||
// 暂时设置 NG
|
// 暂时设置 NG
|
||||||
// 同一个client仅当 msg_id 不连续为 0x11/0x21 或第一次处理时才执行 emit statusUpdated
|
// 同一个client仅当 msg_id 不连续为 0x11/0x21 或第一次处理时才执行 emit statusUpdated
|
||||||
if ((msg_id != 0x11 || clientLastMsgId.value(client, 0) != 0x11) &&
|
if ((msg_id != 0x0011 || clientLastMsgId.value(client, 0) != 0x0011) &&
|
||||||
(msg_id != 0x21 || clientLastMsgId.value(client, 0) != 0x21)){
|
(msg_id != 0x0021 || clientLastMsgId.value(client, 0) != 0x0021)){
|
||||||
qDebug() << "Emitting statusUpdated for client:" << client << "with msg_id:" << msg_id;
|
qDebug() << "Emitting statusUpdated for client:" << client << "with msg_id:" << msg_id;
|
||||||
emit statusUpdated(client, currentRecvItemIndex + 1, currentRecvFuncItemIndex + 1,
|
emit statusUpdated(client, currentRecvItemIndex + 1, currentRecvFuncItemIndex + 1,
|
||||||
true, itemData, funcItemData);
|
true, itemData, funcItemData);
|
||||||
|
@ -156,3 +138,269 @@ void DataHandler::handleData(const QString& client, const QByteArray& recvData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DataHandler::handleFrontCmd(int msg_id, const QString& client, QByteArray actual_data)
|
||||||
|
{
|
||||||
|
switch (msg_id) {
|
||||||
|
case 0x0019:
|
||||||
|
{
|
||||||
|
showPic(leftLens_m_imageLabel, rightLens_m_imageLabel, client, actual_data);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 0x0011:
|
||||||
|
{
|
||||||
|
showVideo(client, actual_data);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 0x0021:
|
||||||
|
{
|
||||||
|
//showVideo(client, actual_data);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case FACE_ENROLL_SINGLE:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case FACE_ENROLL:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case HAND_ENROLL:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case FACE_VERIFY:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case HAND_VERIFY:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case DEL_USER:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case DEL_ALLUSER:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case GET_USER:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case GET_ALLUSER:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case PASSWD_ENROLL:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case IMG_ENROLL:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case GET_IMG:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case START_VIDEO:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case STOP_VIDEO:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case TOUCH_TEST:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MIC_TEST:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SPK_TEST:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case RADAR_TEST:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case NFC_TEST:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case PR_SWITCH:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case PS_TEST:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case BACKLIGHT:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case IR_LED:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case UART_TEST:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case PIR_TEST:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case FACE_VERIFY_THRES:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case FACE_THRES_LEVEL:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case FACE_LIVE_THRES:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case FACE_ACC_THRES:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case FACE_ACC_LEVEL:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case FACE_DIS_RANGE:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case FACE_ANGLE_RANGE:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case HAND_VERIFY_THRES:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case HANS_THRES_LEVEL:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case HAND_LIVE_THRES:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case USER_MAX_NUM:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ADMI_USER_MAX_NUM:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case FACE_REPEAT:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case HAND_REPEAT:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SET_IP:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SET_PORT:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SET_VOLUME:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SET_BACKLIGHT:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SET_RADAR_DIS:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SET_UART_BARTRATE:
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
{}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DataHandler::handleBackCmd(int msg_id, const QString& client, QByteArray actual_data)
|
||||||
|
{
|
||||||
|
switch (msg_id) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DataHandler::handleCmd(int msg_id, const QString& client, QByteArray actual_data)
|
||||||
|
{
|
||||||
|
if (msg_id < 0x0400) {
|
||||||
|
handleFrontCmd(msg_id, client, actual_data);
|
||||||
|
}
|
||||||
|
else if (msg_id < 0x0800) {
|
||||||
|
handleBackCmd(msg_id, client, actual_data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include "../Media/Media.h"
|
#include "../Media/Media.h"
|
||||||
#include "../ParseDataHandler/msgID.h"
|
#include "../ParseDataHandler/msgID.h"
|
||||||
#include "../Media/VideoDecoder/FFmpegDecoder.h"
|
#include "../Media/VideoDecoder/FFmpegDecoder.h"
|
||||||
|
#include "MsgTpye.h"
|
||||||
|
|
||||||
#define YUV420 1
|
#define YUV420 1
|
||||||
#define YUV422 2
|
#define YUV422 2
|
||||||
|
@ -33,7 +34,7 @@ public:
|
||||||
~DataHandler();
|
~DataHandler();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void handleData(const QString& client, const QByteArray& data, unsigned char msg_id, int currentRecvItemIndex,
|
void handleData(const QString& client, const QByteArray& data, int msg_id, int currentRecvItemIndex,
|
||||||
int currentRecvFuncItemIndex, const QString& itemData, const QString& funcItemData);
|
int currentRecvFuncItemIndex, const QString& itemData, const QString& funcItemData);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
@ -56,7 +57,9 @@ private:
|
||||||
QByteArray hexStringToByteArray(const QString& hexString);
|
QByteArray hexStringToByteArray(const QString& hexString);
|
||||||
void showVideo(const QString& client, const QByteArray& valData);
|
void showVideo(const QString& client, const QByteArray& valData);
|
||||||
void clearAllRecvData();
|
void clearAllRecvData();
|
||||||
void handleCmd(unsigned char msg_id, const QString& client, QByteArray actual_data);
|
void handleCmd(int msg_id, const QString& client, QByteArray actual_data);
|
||||||
|
void handleFrontCmd(int msg_id, const QString& client, QByteArray actual_data);
|
||||||
|
void handleBackCmd(int msg_id, const QString& client, QByteArray actual_data);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DATAHANDLER_H
|
#endif // DATAHANDLER_H
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include "MainWidget.h"
|
#include "MainWidget.h"
|
||||||
#include "../RecvDataHandler/RecvDataHandler.h"
|
#include "../RecvDataHandler/RecvDataHandler.h"
|
||||||
#include "../Json/readJsonFile.h"
|
#include "../Json/readJsonFile.h"
|
||||||
|
#include "../LicenseGenerate/LicenseGenerate.h"
|
||||||
|
|
||||||
void onThreadFinished(QThread* thread, ClientHandler* handler)
|
void onThreadFinished(QThread* thread, ClientHandler* handler)
|
||||||
{
|
{
|
||||||
|
@ -10,7 +11,7 @@ void onThreadFinished(QThread* thread, ClientHandler* handler)
|
||||||
thread->deleteLater();
|
thread->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 构造函数,初始化 UI 组件和服务器
|
// 初始化 UI 组件和服务器
|
||||||
MainWidget::MainWidget(QWidget* parent) :
|
MainWidget::MainWidget(QWidget* parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
nextClientId(1),
|
nextClientId(1),
|
||||||
|
@ -61,12 +62,9 @@ MainWidget::MainWidget(QWidget* parent) :
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// 每连接一个新客户端创建一个新的线程
|
|
||||||
QThread* thread = new QThread(this);
|
QThread* thread = new QThread(this);
|
||||||
|
ClientHandler* handler = new ClientHandler(socket, frontBoardOneClickTest, frontBoardTest, frontBoardFuncConfig,
|
||||||
/*ClientHandler* handler = new ClientHandler(socket, testJsonConfig, funcJsonConfig, getDevInfoJson,
|
frontBoardDevInfoJson, frontBoardLicenseJson, backBoardDevInfoJson,
|
||||||
getPicJson, getVideoJson, clientId, nullptr);*/
|
|
||||||
ClientHandler* handler = new ClientHandler(socket, frontBoardOneClickTest, frontBoardTest, frontBoardFuncConfig, getDevInfoJson,
|
|
||||||
getPicJson, getVideoJson, clientId, nullptr);
|
getPicJson, getVideoJson, clientId, nullptr);
|
||||||
|
|
||||||
// 将 ClientHandler 移动到线程池中的线程
|
// 将 ClientHandler 移动到线程池中的线程
|
||||||
|
@ -101,7 +99,6 @@ MainWidget::MainWidget(QWidget* parent) :
|
||||||
connect(handler, &ClientHandler::selectClientDisconnected, this, &MainWidget::onDisconnectClient);
|
connect(handler, &ClientHandler::selectClientDisconnected, this, &MainWidget::onDisconnectClient);
|
||||||
|
|
||||||
// 创建 DataHandler 对象并连接信号
|
// 创建 DataHandler 对象并连接信号
|
||||||
//QLabel* imageDisplayLabel = new QLabel;
|
|
||||||
DataHandler* dataHandler = new DataHandler(leftLens_imageLabel, rightLens_imageLabel, videoLabel, this);
|
DataHandler* dataHandler = new DataHandler(leftLens_imageLabel, rightLens_imageLabel, videoLabel, this);
|
||||||
connect(handler, &ClientHandler::dataReceived, dataHandler, &DataHandler::handleData);
|
connect(handler, &ClientHandler::dataReceived, dataHandler, &DataHandler::handleData);
|
||||||
connect(dataHandler, &DataHandler::statusUpdated, this, &MainWidget::onStatusUpdated);
|
connect(dataHandler, &DataHandler::statusUpdated, this, &MainWidget::onStatusUpdated);
|
||||||
|
@ -137,6 +134,28 @@ MainWidget::~MainWidget() {
|
||||||
handler->deleteLater();
|
handler->deleteLater();
|
||||||
}
|
}
|
||||||
server->close();
|
server->close();
|
||||||
|
|
||||||
|
for (auto thread : clientThreads) {
|
||||||
|
thread->quit();
|
||||||
|
thread->wait();
|
||||||
|
delete thread;
|
||||||
|
}
|
||||||
|
clientThreads.clear();
|
||||||
|
|
||||||
|
for (auto handler : clients_1) {
|
||||||
|
handler->deleteLater();
|
||||||
|
}
|
||||||
|
clients_1.clear();
|
||||||
|
|
||||||
|
for (auto timer : clientTimers) {
|
||||||
|
timer->stop();
|
||||||
|
delete timer;
|
||||||
|
}
|
||||||
|
clientTimers.clear();
|
||||||
|
|
||||||
|
if (server->isListening()) {
|
||||||
|
server->close();
|
||||||
|
}
|
||||||
qDebug() << "MainWidget destroyed";
|
qDebug() << "MainWidget destroyed";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,7 +247,8 @@ void MainWidget::setupUI()
|
||||||
sendAllButton->setEnabled(false);
|
sendAllButton->setEnabled(false);
|
||||||
|
|
||||||
statusListWidget = new QListWidget(this);
|
statusListWidget = new QListWidget(this);
|
||||||
statusListWidget->setMinimumSize(350, 880);
|
//statusListWidget->setMinimumSize(350, 880);
|
||||||
|
statusListWidget->setMinimumSize(350, 680);
|
||||||
statusListWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); // 设置大小策略为扩展
|
statusListWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); // 设置大小策略为扩展
|
||||||
|
|
||||||
QHBoxLayout* buttonLayout = new QHBoxLayout;
|
QHBoxLayout* buttonLayout = new QHBoxLayout;
|
||||||
|
@ -240,7 +260,7 @@ void MainWidget::setupUI()
|
||||||
leftLayout->addLayout(buttonLayout);
|
leftLayout->addLayout(buttonLayout);
|
||||||
leftLayout->setStretch(0, 1);
|
leftLayout->setStretch(0, 1);
|
||||||
leftLayout->addWidget(statusListWidget);
|
leftLayout->addWidget(statusListWidget);
|
||||||
leftLayout->setStretch(1, 20);
|
leftLayout->setStretch(1, 200);
|
||||||
|
|
||||||
saveCheckBox = new QCheckBox("", this);
|
saveCheckBox = new QCheckBox("", this);
|
||||||
selectFileButton = new QPushButton("Save", this);
|
selectFileButton = new QPushButton("Save", this);
|
||||||
|
@ -260,31 +280,78 @@ void MainWidget::setupUI()
|
||||||
leftLayout->addLayout(fileLayout);
|
leftLayout->addLayout(fileLayout);
|
||||||
leftLayout->setStretch(2, 1);
|
leftLayout->setStretch(2, 1);
|
||||||
|
|
||||||
|
// 读取 JSON 配置文件
|
||||||
|
readJsonConfig();
|
||||||
|
|
||||||
|
QGroupBox* groupBox = new QGroupBox("算法 license", this);
|
||||||
|
QHBoxLayout* buttonRowLayout = new QHBoxLayout;
|
||||||
|
for (int i = 0; i < frontBoardLicenseJson.size(); ++i) {
|
||||||
|
QJsonObject item = frontBoardLicenseJson[i].toObject();
|
||||||
|
QString buttonText = item["lable"].toString();
|
||||||
|
QPushButton* button = new QPushButton(buttonText, this);
|
||||||
|
button->setProperty("licenseIndex", i);
|
||||||
|
buttonRowLayout->addWidget(button);
|
||||||
|
connect(button, &QPushButton::clicked, this, &MainWidget::onLicenseButtonClicked);
|
||||||
|
}
|
||||||
|
QLineEdit* readOnlyLineEdit = new QLineEdit(this);
|
||||||
|
readOnlyLineEdit->setReadOnly(true);
|
||||||
|
readOnlyLineEdit->setText("This is a read-only text");
|
||||||
|
readOnlyLineEdit->setFixedHeight(80);
|
||||||
|
|
||||||
|
QVBoxLayout* groupBoxLayout_license = new QVBoxLayout;
|
||||||
|
groupBoxLayout_license->addLayout(buttonRowLayout);
|
||||||
|
groupBoxLayout_license->addWidget(readOnlyLineEdit);
|
||||||
|
groupBox->setLayout(groupBoxLayout_license);
|
||||||
|
|
||||||
|
leftLayout->addWidget(groupBox);
|
||||||
|
leftLayout->setStretch(3, 1);
|
||||||
|
|
||||||
QWidget* leftContainer = new QWidget(this);
|
QWidget* leftContainer = new QWidget(this);
|
||||||
leftContainer->setLayout(leftLayout);
|
leftContainer->setLayout(leftLayout);
|
||||||
leftContainer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
leftContainer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
|
|
||||||
// 读取 JSON 配置文件
|
|
||||||
readJsonConfig();
|
|
||||||
|
|
||||||
QTabWidget* tabWidget = new QTabWidget(this);
|
QTabWidget* tabWidget = new QTabWidget(this);
|
||||||
tabWidget->setFixedSize(900, 315); // 设置 QTabWidget 的固定大小
|
tabWidget->setFixedSize(900, 315); // 设置 QTabWidget 的固定大小
|
||||||
|
|
||||||
QGroupBox* frontDeviceInfoGroupBox = new QGroupBox("前板设备信息", this);
|
QGroupBox* frontDeviceInfoGroupBox = new QGroupBox("前板设备信息", this);
|
||||||
QVBoxLayout* frontDeviceInfoLayout = new QVBoxLayout(frontDeviceInfoGroupBox);
|
QVBoxLayout* frontDeviceInfoLayout = new QVBoxLayout(frontDeviceInfoGroupBox);
|
||||||
|
|
||||||
QHBoxLayout* frontDeviceButtonsLayout = new QHBoxLayout;
|
QVBoxLayout* frontDeviceLabelsLayout = new QVBoxLayout;
|
||||||
for (int i = 0; i < 2; ++i) {
|
for (const QJsonValue& value : frontBoardDevInfoJson) {
|
||||||
QPushButton* button = new QPushButton(QString("Device %1").arg(i + 1), this);
|
QJsonObject item = value.toObject();
|
||||||
button->setProperty("deviceInfoIndex", i);
|
QString label = item["lable"].toString();
|
||||||
frontDeviceButtonsLayout->addWidget(button);
|
QLabel* itemLabel = new QLabel(label, this);
|
||||||
connect(button, &QPushButton::clicked, this, &MainWidget::onSendGetDevInfoClicked);
|
QLineEdit* itemLineEdit = new QLineEdit(this);
|
||||||
|
itemLineEdit->setReadOnly(true);
|
||||||
|
|
||||||
|
QHBoxLayout* itemLayout = new QHBoxLayout;
|
||||||
|
itemLayout->addWidget(itemLabel);
|
||||||
|
itemLayout->addWidget(itemLineEdit);
|
||||||
|
|
||||||
|
frontDeviceLabelsLayout->addLayout(itemLayout);
|
||||||
}
|
}
|
||||||
frontDeviceInfoLayout->addLayout(frontDeviceButtonsLayout);
|
frontDeviceInfoLayout->addLayout(frontDeviceLabelsLayout);
|
||||||
frontDeviceInfoLayout->addStretch();
|
frontDeviceInfoLayout->addStretch();
|
||||||
|
|
||||||
QGroupBox* backDeviceInfoGroupBox = new QGroupBox("后板设备信息", this);
|
QGroupBox* backDeviceInfoGroupBox = new QGroupBox("后板设备信息", this);
|
||||||
QVBoxLayout* backDeviceInfoLayout = new QVBoxLayout(backDeviceInfoGroupBox);
|
QVBoxLayout* backDeviceInfoLayout = new QVBoxLayout(backDeviceInfoGroupBox);
|
||||||
|
|
||||||
|
QVBoxLayout* backDeviceLabelsLayout = new QVBoxLayout;
|
||||||
|
for (const QJsonValue& value : backBoardDevInfoJson) {
|
||||||
|
QJsonObject item = value.toObject();
|
||||||
|
QString label = item["lable"].toString();
|
||||||
|
QLabel* itemLabel = new QLabel(label, this);
|
||||||
|
QLineEdit* itemLineEdit = new QLineEdit(this);
|
||||||
|
itemLineEdit->setReadOnly(true);
|
||||||
|
|
||||||
|
QHBoxLayout* itemLayout = new QHBoxLayout;
|
||||||
|
itemLayout->addWidget(itemLabel);
|
||||||
|
itemLayout->addWidget(itemLineEdit);
|
||||||
|
|
||||||
|
backDeviceLabelsLayout->addLayout(itemLayout);
|
||||||
|
}
|
||||||
|
backDeviceInfoLayout->addLayout(backDeviceLabelsLayout);
|
||||||
|
backDeviceInfoLayout->addStretch();
|
||||||
|
|
||||||
QHBoxLayout* groupBoxLayout = new QHBoxLayout;
|
QHBoxLayout* groupBoxLayout = new QHBoxLayout;
|
||||||
groupBoxLayout->addWidget(frontDeviceInfoGroupBox, 1);
|
groupBoxLayout->addWidget(frontDeviceInfoGroupBox, 1);
|
||||||
|
@ -568,6 +635,7 @@ void MainWidget::readJsonConfig()
|
||||||
frontBoardTest = readJson_frontBoardTest();
|
frontBoardTest = readJson_frontBoardTest();
|
||||||
frontBoardFuncConfig = readJson_frontBoardFuncConfig();
|
frontBoardFuncConfig = readJson_frontBoardFuncConfig();
|
||||||
frontBoardDevInfoJson = readJson_frontDevInfo();
|
frontBoardDevInfoJson = readJson_frontDevInfo();
|
||||||
|
frontBoardLicenseJson = readJson_frontLicense();
|
||||||
backBoardDevInfoJson = readJson_backDevInfo();
|
backBoardDevInfoJson = readJson_backDevInfo();
|
||||||
testJsonConfig = readJson_testConfig();
|
testJsonConfig = readJson_testConfig();
|
||||||
funcJsonConfig = readJson_funcConfig();
|
funcJsonConfig = readJson_funcConfig();
|
||||||
|
@ -640,6 +708,29 @@ void MainWidget::updateServerButtonText()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 处理 License 按键点击事件
|
||||||
|
void MainWidget::onLicenseButtonClicked()
|
||||||
|
{
|
||||||
|
if (connectedClientsCount) {
|
||||||
|
QPushButton* button = qobject_cast<QPushButton*>(sender());
|
||||||
|
if (button) {
|
||||||
|
int index = button->property("licenseIndex").toInt();
|
||||||
|
if (index >= 0 && index < frontBoardLicenseJson.size()) {
|
||||||
|
QJsonObject jsonObject = frontBoardLicenseJson[index].toObject();
|
||||||
|
QString jsonString = QJsonDocument(jsonObject).toJson(QJsonDocument::Compact);
|
||||||
|
//qDebug() << "license Button clicked, sending JSON:" << jsonString;
|
||||||
|
for (ClientHandler* handler : clients) {
|
||||||
|
handler->sendLicenseItem(index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
QListWidgetItem* listItem = new QListWidgetItem(QString("No device is connected !!!"), statusListWidget);
|
||||||
|
listItem->setBackground(Qt::red);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 处理开始服务器按键点击事件
|
// 处理开始服务器按键点击事件
|
||||||
void MainWidget::onStartServerClicked()
|
void MainWidget::onStartServerClicked()
|
||||||
{
|
{
|
||||||
|
@ -792,6 +883,11 @@ void MainWidget::onOpenFocusWindowClicked()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//void MainWidget::onPowerOnSend()
|
||||||
|
//{
|
||||||
|
//
|
||||||
|
//}
|
||||||
|
|
||||||
// 处理一键发送按键点击事件
|
// 处理一键发送按键点击事件
|
||||||
void MainWidget::onSendAllClicked()
|
void MainWidget::onSendAllClicked()
|
||||||
{
|
{
|
||||||
|
@ -805,8 +901,9 @@ void MainWidget::onSendAllClicked()
|
||||||
for (ClientHandler* handler : clients) {
|
for (ClientHandler* handler : clients) {
|
||||||
// 重置索引
|
// 重置索引
|
||||||
handler->resetCurrentItemIndex();
|
handler->resetCurrentItemIndex();
|
||||||
qDebug() << "------> handler->sendNextItem()";
|
//handler->sendNextItem();
|
||||||
handler->sendNextItem();
|
handler->sendDevInfoItem();
|
||||||
|
//licenseGenerate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -48,6 +48,7 @@ private slots:
|
||||||
void onSendGetPicClicked();
|
void onSendGetPicClicked();
|
||||||
// 处理发送拉视频流按键点击事件
|
// 处理发送拉视频流按键点击事件
|
||||||
void onSendGetVideoClicked();
|
void onSendGetVideoClicked();
|
||||||
|
void onLicenseButtonClicked();
|
||||||
// 处理一键发送按钮点击事件
|
// 处理一键发送按钮点击事件
|
||||||
void onSendAllClicked();
|
void onSendAllClicked();
|
||||||
// 处理单独发送项按钮点击事件
|
// 处理单独发送项按钮点击事件
|
||||||
|
@ -81,6 +82,7 @@ private slots:
|
||||||
void startClientReadTimer(int clientId);
|
void startClientReadTimer(int clientId);
|
||||||
void stopClientReadTimer(int clientId);
|
void stopClientReadTimer(int clientId);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// 读取 test JSON 配置文件
|
// 读取 test JSON 配置文件
|
||||||
void readJsonConfig();
|
void readJsonConfig();
|
||||||
|
@ -99,6 +101,7 @@ private:
|
||||||
QJsonArray frontBoardTest; // 前板单项测试 JSON
|
QJsonArray frontBoardTest; // 前板单项测试 JSON
|
||||||
QJsonArray frontBoardFuncConfig; // 前板功能配置参数 JSON
|
QJsonArray frontBoardFuncConfig; // 前板功能配置参数 JSON
|
||||||
QJsonArray frontBoardDevInfoJson; // 前板设备信息参数 JSON
|
QJsonArray frontBoardDevInfoJson; // 前板设备信息参数 JSON
|
||||||
|
QJsonArray frontBoardLicenseJson; // 前板License JSON
|
||||||
QJsonArray backBoardDevInfoJson; // 后板设备信息参数 JSON
|
QJsonArray backBoardDevInfoJson; // 后板设备信息参数 JSON
|
||||||
QJsonArray testJsonConfig; // 功能测试区 JSON 配置
|
QJsonArray testJsonConfig; // 功能测试区 JSON 配置
|
||||||
QJsonArray funcJsonConfig; // 功能配置区 JSON 配置
|
QJsonArray funcJsonConfig; // 功能配置区 JSON 配置
|
||||||
|
|
|
@ -1,9 +1,16 @@
|
||||||
#include "./Widget/MainWidget.h"
|
#include "./Widget/MainWidget.h"
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
#include <windows.h>
|
||||||
|
#include <iostream>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
QApplication a(argc, argv);
|
QApplication app(argc, argv);
|
||||||
|
|
||||||
|
QIcon appIcon("./app_icon.ico");
|
||||||
|
app.setWindowIcon(appIcon);
|
||||||
|
|
||||||
MainWidget w;
|
MainWidget w;
|
||||||
w.show();
|
w.show();
|
||||||
return a.exec();
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 118 KiB |
|
@ -0,0 +1,73 @@
|
||||||
|
// LicenseGenerate.cpp
|
||||||
|
#include "LicenseGenerate.h"
|
||||||
|
|
||||||
|
#define PIX_HARDWARE_INFO_BYTES 32
|
||||||
|
#define PIX_LICENCE_BYTES 128
|
||||||
|
|
||||||
|
//const char* pix_license_generate_version();
|
||||||
|
//int pix_license_generate(const unsigned char* hardware_info_ptr, int hardware_info_bytes,
|
||||||
|
// unsigned char* license_ptr, int license_bytes);
|
||||||
|
|
||||||
|
|
||||||
|
typedef const char* (*pix_license_generate_version_func)();
|
||||||
|
typedef int (*pix_license_generate_func)(const unsigned char*, int, unsigned char*, int);
|
||||||
|
|
||||||
|
|
||||||
|
void licenseGenerate()
|
||||||
|
{
|
||||||
|
unsigned char hardware_info[PIX_HARDWARE_INFO_BYTES] = { };
|
||||||
|
unsigned char license_info[PIX_LICENCE_BYTES] = { 0 };
|
||||||
|
|
||||||
|
// 获取并打印当前工作目录
|
||||||
|
wchar_t currentPath[MAX_PATH];
|
||||||
|
GetCurrentDirectoryW(MAX_PATH, currentPath);
|
||||||
|
std::wcout << L"Current Directory: " << currentPath << std::endl;
|
||||||
|
|
||||||
|
// 打印 DLL 的完整路径
|
||||||
|
std::wstring dllPath = std::wstring(currentPath) + L"\\ThirdParty\\LicenseGenerate\\pix_license.dll";
|
||||||
|
std::wcout << L"DLL Path: " << dllPath << std::endl;
|
||||||
|
|
||||||
|
// 加载 DLL 文件
|
||||||
|
HINSTANCE hDLL = LoadLibraryW(dllPath.c_str()); // 使用 LoadLibraryW 加载宽字符路径
|
||||||
|
if (hDLL == NULL) {
|
||||||
|
std::cerr << "Failed to load DLL. Error code: " << GetLastError() << std::endl;
|
||||||
|
FreeLibrary(hDLL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
pix_license_generate_version_func pix_license_generate_version =
|
||||||
|
(pix_license_generate_version_func)GetProcAddress(hDLL, "pix_license_generate_version");
|
||||||
|
pix_license_generate_func pix_license_generate =
|
||||||
|
(pix_license_generate_func)GetProcAddress(hDLL, "pix_license_generate");
|
||||||
|
if (pix_license_generate_version == NULL || pix_license_generate == NULL) {
|
||||||
|
std::cerr << "Failed to find one or more functions." << std::endl;
|
||||||
|
FreeLibrary(hDLL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
printf("pix_license_generate_version is %s\n",
|
||||||
|
pix_license_generate_version());
|
||||||
|
|
||||||
|
printf("Hardware info:");
|
||||||
|
for (int j = 0; j < PIX_HARDWARE_INFO_BYTES; ++j) {
|
||||||
|
hardware_info[j] = j;
|
||||||
|
printf("0x%02x, ", hardware_info[j]);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
return;
|
||||||
|
int ret = pix_license_generate(hardware_info, PIX_HARDWARE_INFO_BYTES,
|
||||||
|
license_info, PIX_LICENCE_BYTES);
|
||||||
|
if (ret != SDK_CODE_OK) {
|
||||||
|
printf("Fail to generate license with %d\n", ret);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printf("License is\n");
|
||||||
|
for (int j = 0; j < PIX_LICENCE_BYTES; ++j) {
|
||||||
|
printf("0x%02x, ", license_info[j]);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
// 释放 DLL
|
||||||
|
FreeLibrary(hDLL);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue