Compare commits

...

2 Commits

Author SHA1 Message Date
kingecg 43273652a0 fix include path error 2023-04-02 10:44:21 +08:00
kingecg c844a143fc fix build error. And add json lib in project. 2023-04-02 10:34:59 +08:00
15 changed files with 25094 additions and 147 deletions

83
.autotools Normal file
View File

@ -0,0 +1,83 @@
<?xml version="1.0" encoding="UTF-8"?>
<configurations>
<configuration id="org.eclipse.linuxtools.cdt.autotools.core.configuration.build.2059603666">
<option id="configure" value="configure"/>
<option id="configdir" value=""/>
<option id="cache-file" value=""/>
<option id="help" value="false"/>
<option id="no-create" value="false"/>
<option id="quiet" value="false"/>
<option id="version" value="false"/>
<option id="host" value=""/>
<option id="build" value=""/>
<option id="target" value=""/>
<option id="prefix" value=""/>
<option id="exec-prefix" value=""/>
<option id="libdir" value=""/>
<option id="bindir" value=""/>
<option id="sbindir" value=""/>
<option id="includedir" value=""/>
<option id="datadir" value=""/>
<option id="sysconfdir" value=""/>
<option id="infodir" value=""/>
<option id="mandir" value=""/>
<option id="srcdir" value=""/>
<option id="localstatedir" value=""/>
<option id="sharedstatedir" value=""/>
<option id="libexecdir" value=""/>
<option id="oldincludedir" value=""/>
<option id="program-prefix" value=""/>
<option id="program-suffix" value=""/>
<option id="program-transform-name" value=""/>
<option id="env_vars" value=""/>
<option id="enable-maintainer-mode" value="false"/>
<flag id="CFLAGS" value="CFLAGS|CXXFLAGS">
<flagvalue id="cflags-debug" value="false"/>
<flagvalue id="cflags-gprof" value="false"/>
<flagvalue id="cflags-gcov" value="false"/>
</flag>
<option id="user" value=""/>
<option id="autogen" value="autogen.sh"/>
<option id="autogenOpts" value=""/>
</configuration>
<configuration id="org.eclipse.linuxtools.cdt.autotools.core.configuration.build.debug.1203119608">
<option id="configure" value="configure"/>
<option id="configdir" value=""/>
<option id="cache-file" value=""/>
<option id="help" value="false"/>
<option id="no-create" value="false"/>
<option id="quiet" value="false"/>
<option id="version" value="false"/>
<option id="host" value=""/>
<option id="build" value=""/>
<option id="target" value=""/>
<option id="prefix" value=""/>
<option id="exec-prefix" value=""/>
<option id="libdir" value=""/>
<option id="bindir" value=""/>
<option id="sbindir" value=""/>
<option id="includedir" value=""/>
<option id="datadir" value=""/>
<option id="sysconfdir" value=""/>
<option id="infodir" value=""/>
<option id="mandir" value=""/>
<option id="srcdir" value=""/>
<option id="localstatedir" value=""/>
<option id="sharedstatedir" value=""/>
<option id="libexecdir" value=""/>
<option id="oldincludedir" value=""/>
<option id="program-prefix" value=""/>
<option id="program-suffix" value=""/>
<option id="program-transform-name" value=""/>
<option id="env_vars" value=""/>
<option id="enable-maintainer-mode" value="false"/>
<flag id="CFLAGS" value="CFLAGS|CXXFLAGS">
<flagvalue id="cflags-debug" value="false"/>
<flagvalue id="cflags-gprof" value="false"/>
<flagvalue id="cflags-gcov" value="false"/>
</flag>
<option id="user" value="CFLAGS=&apos;-g -O0&apos; CXXFLAGS=&apos;-g -O0&apos;"/>
<option id="autogen" value="autogen.sh"/>
<option id="autogenOpts" value=""/>
</configuration>
</configurations>

86
.cproject Normal file
View File

@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<storageModule moduleId="org.eclipse.cdt.core.settings">
<cconfiguration id="org.eclipse.linuxtools.cdt.autotools.core.configuration.build.2059603666">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="org.eclipse.linuxtools.cdt.autotools.core.configuration.build.2059603666" moduleId="org.eclipse.cdt.core.settings" name="Build (GNU)">
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.MachO64" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.PE64" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.Cygwin_PE64" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GNU_ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.linuxtools.cdt.autotools.core.buildArtefactType.autotools" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.linuxtools.cdt.autotools.core.buildArtefactType.autotools,org.eclipse.cdt.build.core.buildType=org.eclipse.linuxtools.cdt.autotools.core.buildType.default" cleanCommand="rm -rf" description="" errorParsers="org.eclipse.cdt.core.CWDLocator;org.eclipse.cdt.core.GmakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser" id="org.eclipse.linuxtools.cdt.autotools.core.configuration.build.2059603666" name="Build (GNU)" optionalBuildProperties="" parent="org.eclipse.linuxtools.cdt.autotools.core.configuration.build">
<folderInfo id="org.eclipse.linuxtools.cdt.autotools.core.configuration.build.2059603666." name="/" resourcePath="">
<toolChain id="org.eclipse.linuxtools.cdt.autotools.core.toolChain.1637857018" name="GNU Autotools Toolchain" superClass="org.eclipse.linuxtools.cdt.autotools.core.toolChain">
<targetPlatform id="org.eclipse.linuxtools.cdt.autotools.core.toolchain.targetPlatform.1604197845" isAbstract="false" name="GNU Autotools Target Platform" superClass="org.eclipse.linuxtools.cdt.autotools.core.toolchain.targetPlatform"/>
<builder id="org.eclipse.linuxtools.cdt.autotools.core.toolchain.builder.1755320658" name="Autotools Makefile Generator.Build (GNU)" superClass="org.eclipse.linuxtools.cdt.autotools.core.toolchain.builder"/>
<tool id="org.eclipse.linuxtools.cdt.autotools.core.gnu.toolchain.tool.configure.1210949871" name="configure" superClass="org.eclipse.linuxtools.cdt.autotools.core.gnu.toolchain.tool.configure"/>
<tool id="org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.autogen.1422244975" name="autogen.sh" superClass="org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.autogen"/>
<tool id="org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.gcc.1403832341" name="GCC C Compiler" superClass="org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.gcc">
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.264612411" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
</tool>
<tool id="org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.gpp.1819745396" name="GCC C++ Compiler" superClass="org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.gpp">
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1084130285" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
</tool>
</toolChain>
</folderInfo>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
<cconfiguration id="org.eclipse.linuxtools.cdt.autotools.core.configuration.build.debug.1203119608">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="org.eclipse.linuxtools.cdt.autotools.core.configuration.build.debug.1203119608" moduleId="org.eclipse.cdt.core.settings" name="Debug (GNU)">
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.MachO64" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.PE64" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.Cygwin_PE64" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GNU_ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.linuxtools.cdt.autotools.core.buildArtefactType.autotools" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.linuxtools.cdt.autotools.core.buildArtefactType.autotools,org.eclipse.cdt.build.core.buildType=org.eclipse.linuxtools.cdt.autotools.core.buildType.debug" cleanCommand="rm -rf" description="" errorParsers="org.eclipse.cdt.core.CWDLocator;org.eclipse.cdt.core.GmakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser" id="org.eclipse.linuxtools.cdt.autotools.core.configuration.build.debug.1203119608" name="Debug (GNU)" parent="org.eclipse.linuxtools.cdt.autotools.core.configuration.build.debug">
<folderInfo id="org.eclipse.linuxtools.cdt.autotools.core.configuration.build.debug.1203119608." name="/" resourcePath="">
<toolChain id="org.eclipse.linuxtools.cdt.autotools.core.toolChain.debug.1409425059" name="GNU Autotools Toolchain" superClass="org.eclipse.linuxtools.cdt.autotools.core.toolChain.debug">
<targetPlatform id="org.eclipse.linuxtools.cdt.autotools.core.toolchain.targetPlatform.debug.967598552" isAbstract="false" name="GNU Autotools Target Platform" superClass="org.eclipse.linuxtools.cdt.autotools.core.toolchain.targetPlatform.debug"/>
<builder id="org.eclipse.linuxtools.cdt.autotools.core.toolchain.builder.debug.418649973" name="Autotools Makefile Generator.Debug (GNU)" superClass="org.eclipse.linuxtools.cdt.autotools.core.toolchain.builder.debug"/>
<tool id="org.eclipse.linuxtools.cdt.autotools.core.gnu.toolchain.tool.configure.debug.1330225368" name="configure" superClass="org.eclipse.linuxtools.cdt.autotools.core.gnu.toolchain.tool.configure.debug">
<option defaultValue="CFLAGS=-g -O0" id="org.eclipse.linuxtools.cdt.autotools.core.option.configure.user.439996527" superClass="org.eclipse.linuxtools.cdt.autotools.core.option.configure.user" valueType="string"/>
</tool>
<tool id="org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.autogen.debug.1139873207" name="autogen.sh" superClass="org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.autogen.debug"/>
<tool id="org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.gcc.debug.1267951181" name="GCC C Compiler" superClass="org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.gcc.debug">
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1990325660" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
</tool>
<tool id="org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.gpp.debug.939588245" name="GCC C++ Compiler" superClass="org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.gpp.debug">
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.170502241" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
</tool>
</toolChain>
</folderInfo>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<project id="hkstreamer.org.eclipse.linuxtools.cdt.autotools.core.projectType.577587361" name="GNU Autotools" projectType="org.eclipse.linuxtools.cdt.autotools.core.projectType"/>
</storageModule>
<storageModule moduleId="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
</cproject>

33
.project Normal file
View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>hkstreamer</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.autotools.core.genmakebuilderV2</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.core.ccnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
<nature>org.eclipse.cdt.autotools.core.autotoolsNatureV2</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project>
<configuration id="org.eclipse.linuxtools.cdt.autotools.core.configuration.build.2059603666" name="Build (GNU)">
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider copy-of="extension" id="org.eclipse.cdt.autotools.core.LibtoolGCCBuildCommandParser"/>
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="1507469777615362914" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
</extension>
</configuration>
<configuration id="org.eclipse.linuxtools.cdt.autotools.core.configuration.build.debug.1203119608" name="Debug (GNU)">
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider copy-of="extension" id="org.eclipse.cdt.autotools.core.LibtoolGCCBuildCommandParser"/>
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="1507469777615362914" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
</extension>
</configuration>
</project>

View File

@ -12,7 +12,8 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
include_directories(
include
include,
nlohmann
)
link_directories(
@ -27,6 +28,9 @@ set (SRCS
include/HkStreamer.h
include/plaympeg4.h
include/cmdlineparser.h
include/convert.h
nlohmann/json.hpp
src/convert.cpp
src/HkStreamer.cpp
src/main.cpp
src/cmdlineparser.cpp

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 10.0.0, 2023-03-30T23:17:14. -->
<!-- Written by QtCreator 10.0.0, 2023-04-01T19:15:04. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
@ -90,7 +90,7 @@
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">桌面</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">桌面</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{976a26f7-9753-41c3-a002-83e83b921ad8}</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveBuildConfiguration">1</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
@ -392,12 +392,13 @@
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">hkstreamer</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeRunConfiguration.hkstreamer</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">hkstreamer</value>
<value type="QString" key="RunConfiguration.Arguments">--cmd test -U user -P passwd --channel 1</value>
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default">/home/kingecg/code/build-hkstreamer-unknown-Release</value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default">/home/kingecg/code/build-hkstreamer-unknown-Debug</value>
</valuemap>
<value type="qlonglong" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>

View File

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 10.0.0, 2023-03-31T18:22:20. -->
<!-- Written by QtCreator 10.0.0, 2023-04-01T12:13:17. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
<value type="QByteArray">{b1d6c31c-e354-4f9b-a89f-0f02a67ed6d1}</value>
<value type="QByteArray">{e8c938e2-c8fa-4354-a6d6-5cb042d4a566}</value>
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
@ -87,14 +87,14 @@
<variable>ProjectExplorer.Project.Target.0</variable>
<valuemap type="QVariantMap">
<value type="QString" key="DeviceType">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop (x86-darwin-generic-mach_o-32bit)</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop (x86-darwin-generic-mach_o-32bit)</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{ea69aa4c-9f65-4091-af6f-c8dca7313cfe}</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">桌面</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">桌面</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{976a26f7-9753-41c3-a002-83e83b921ad8}</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/Users/chengguang/code/hkstreamer</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/kingecg/code/hkstreamer</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<valuelist type="QVariantList" key="GenericProjectManager.GenericMakeStep.BuildTargets">

View File

@ -20,13 +20,14 @@ public:
void regOpt(string name,int shorName, int needParam, string desc);
string getOpt(string key);
void parseArgs(int argc, char *argv[]);
void help();
private:
string appName;
string appDesc;
map<int, OptDefine> optMap;
map<string, string> paraMap;
bool hasOptSet(string key);
void help();
};
#endif // CMDLINEPARSER_H

View File

@ -1,7 +1,7 @@
#ifndef CONVERT_H
#define CONVERT_H
#include <string>
#include <HCNetSDK.h>
#include "HCNetSDK.h"
using namespace std;
void convert_str_chararr(string src, char *dst, int dstlen);
void convert_isotimestr_time(string timestr, int timezone, LPNET_DVR_TIME time);

24596
nlohmann/json.hpp Normal file

File diff suppressed because it is too large Load Diff

175
nlohmann/json_fwd.hpp Normal file
View File

@ -0,0 +1,175 @@
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
// | | |__ | | | | | | version 3.11.2
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
// SPDX-License-Identifier: MIT
#ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_
#define INCLUDE_NLOHMANN_JSON_FWD_HPP_
#include <cstdint> // int64_t, uint64_t
#include <map> // map
#include <memory> // allocator
#include <string> // string
#include <vector> // vector
// #include <nlohmann/detail/abi_macros.hpp>
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
// | | |__ | | | | | | version 3.11.2
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
// SPDX-License-Identifier: MIT
// This file contains all macro definitions affecting or depending on the ABI
#ifndef JSON_SKIP_LIBRARY_VERSION_CHECK
#if defined(NLOHMANN_JSON_VERSION_MAJOR) && defined(NLOHMANN_JSON_VERSION_MINOR) && defined(NLOHMANN_JSON_VERSION_PATCH)
#if NLOHMANN_JSON_VERSION_MAJOR != 3 || NLOHMANN_JSON_VERSION_MINOR != 11 || NLOHMANN_JSON_VERSION_PATCH != 2
#warning "Already included a different version of the library!"
#endif
#endif
#endif
#define NLOHMANN_JSON_VERSION_MAJOR 3 // NOLINT(modernize-macro-to-enum)
#define NLOHMANN_JSON_VERSION_MINOR 11 // NOLINT(modernize-macro-to-enum)
#define NLOHMANN_JSON_VERSION_PATCH 2 // NOLINT(modernize-macro-to-enum)
#ifndef JSON_DIAGNOSTICS
#define JSON_DIAGNOSTICS 0
#endif
#ifndef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
#define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON 0
#endif
#if JSON_DIAGNOSTICS
#define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS _diag
#else
#define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS
#endif
#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
#define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON _ldvcmp
#else
#define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON
#endif
#ifndef NLOHMANN_JSON_NAMESPACE_NO_VERSION
#define NLOHMANN_JSON_NAMESPACE_NO_VERSION 0
#endif
// Construct the namespace ABI tags component
#define NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b) json_abi ## a ## b
#define NLOHMANN_JSON_ABI_TAGS_CONCAT(a, b) \
NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b)
#define NLOHMANN_JSON_ABI_TAGS \
NLOHMANN_JSON_ABI_TAGS_CONCAT( \
NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS, \
NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON)
// Construct the namespace version component
#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) \
_v ## major ## _ ## minor ## _ ## patch
#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(major, minor, patch) \
NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch)
#if NLOHMANN_JSON_NAMESPACE_NO_VERSION
#define NLOHMANN_JSON_NAMESPACE_VERSION
#else
#define NLOHMANN_JSON_NAMESPACE_VERSION \
NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(NLOHMANN_JSON_VERSION_MAJOR, \
NLOHMANN_JSON_VERSION_MINOR, \
NLOHMANN_JSON_VERSION_PATCH)
#endif
// Combine namespace components
#define NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b) a ## b
#define NLOHMANN_JSON_NAMESPACE_CONCAT(a, b) \
NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b)
#ifndef NLOHMANN_JSON_NAMESPACE
#define NLOHMANN_JSON_NAMESPACE \
nlohmann::NLOHMANN_JSON_NAMESPACE_CONCAT( \
NLOHMANN_JSON_ABI_TAGS, \
NLOHMANN_JSON_NAMESPACE_VERSION)
#endif
#ifndef NLOHMANN_JSON_NAMESPACE_BEGIN
#define NLOHMANN_JSON_NAMESPACE_BEGIN \
namespace nlohmann \
{ \
inline namespace NLOHMANN_JSON_NAMESPACE_CONCAT( \
NLOHMANN_JSON_ABI_TAGS, \
NLOHMANN_JSON_NAMESPACE_VERSION) \
{
#endif
#ifndef NLOHMANN_JSON_NAMESPACE_END
#define NLOHMANN_JSON_NAMESPACE_END \
} /* namespace (inline namespace) NOLINT(readability/namespace) */ \
} // namespace nlohmann
#endif
/*!
@brief namespace for Niels Lohmann
@see https://github.com/nlohmann
@since version 1.0.0
*/
NLOHMANN_JSON_NAMESPACE_BEGIN
/*!
@brief default JSONSerializer template argument
This serializer ignores the template arguments and uses ADL
([argument-dependent lookup](https://en.cppreference.com/w/cpp/language/adl))
for serialization.
*/
template<typename T = void, typename SFINAE = void>
struct adl_serializer;
/// a class to store JSON values
/// @sa https://json.nlohmann.me/api/basic_json/
template<template<typename U, typename V, typename... Args> class ObjectType =
std::map,
template<typename U, typename... Args> class ArrayType = std::vector,
class StringType = std::string, class BooleanType = bool,
class NumberIntegerType = std::int64_t,
class NumberUnsignedType = std::uint64_t,
class NumberFloatType = double,
template<typename U> class AllocatorType = std::allocator,
template<typename T, typename SFINAE = void> class JSONSerializer =
adl_serializer,
class BinaryType = std::vector<std::uint8_t>>
class basic_json;
/// @brief JSON Pointer defines a string syntax for identifying a specific value within a JSON document
/// @sa https://json.nlohmann.me/api/json_pointer/
template<typename RefStringType>
class json_pointer;
/*!
@brief default specialization
@sa https://json.nlohmann.me/api/json/
*/
using json = basic_json<>;
/// @brief a minimal map-like container that preserves insertion order
/// @sa https://json.nlohmann.me/api/ordered_map/
template<class Key, class T, class IgnoredLess, class Allocator>
struct ordered_map;
/// @brief specialization that maintains the insertion order of object keys
/// @sa https://json.nlohmann.me/api/ordered_json/
using ordered_json = basic_json<nlohmann::ordered_map>;
NLOHMANN_JSON_NAMESPACE_END
#endif // INCLUDE_NLOHMANN_JSON_FWD_HPP_

View File

@ -3,13 +3,12 @@
#include <bitset>
#include <unistd.h>
#include <time.h>
#include "HCNetSDK.h"
#include "HkStreamer.h"
#include "convert.h"
#include "../include/HCNetSDK.h"
#include "../include/HkStreamer.h"
#include "../include/convert.h"
using namespace std;
const int outcache_size=1024;
void CALLBACK fPlayDataCallBack(LONG lPlayHandle, DWORD dwDataType, BYTE *pBuffer, DWORD dwBufSize, void* dwUser)
{
void CALLBACK fPlayDataCallBack(LONG lPlayHandle, DWORD dwDataType, BYTE *pBuffer, DWORD dwBufSize, void* dwUser){
DWORD remained = dwBufSize;
char cache[outcache_size]={0};
BYTE *cp; // cp head point
@ -48,22 +47,15 @@ int login(LPLoginInfo loginInfo)
struLoginInfo.bUseAsynLogin = false;
struLoginInfo.wPort = 8000;
memcpy(struLoginInfo.sDeviceAddress, loginInfo->sDeviceAddress, NET_DVR_DEV_ADDRESS_MAX_LEN);
memcpy(struLoginInfo.sUserName, loginInfo->sUserName, NAME_LEN);
memcpy(struLoginInfo.sPassword, loginInfo->sPassword, NAME_LEN);
memcpy(struLoginInfo.sDeviceAddress, loginInfo->sDeviceAddress.c_str(), NET_DVR_DEV_ADDRESS_MAX_LEN);
memcpy(struLoginInfo.sUserName, loginInfo->sUserName.c_str(), NAME_LEN);
memcpy(struLoginInfo.sPassword, loginInfo->sPassword.c_str(), NAME_LEN);
std::cerr << struLoginInfo.sDeviceAddress << " " << struLoginInfo.sUserName << " " << struLoginInfo.sPassword << std::endl;
lUserID = NET_DVR_Login_V40(&struLoginInfo, &struDeviceInfoV40);
return lUserID;
}
{
nvrTime->dwYear = date.dwYear;
nvrTime->dwMonth = date.dwMonth;
nvrTime->dwDay = date.dwDay;
nvrTime->dwHour = date.dwHour;
nvrTime->dwMinute = date.dwMinute;
nvrTime->dwSecond = date.dwSecond;
}
int getCfg(LPLoginInfo loginInfo)
{
@ -154,6 +146,7 @@ int _readChannelConfig(long lUserID,LPStream stream){
stream->lChannel = ipcfg.dwStartDChan + stream->lChannel -1;
stream->bitrate = 2048; // controll speed for download, TODO: get bitrate from device;
return 0;
}
int playback(LPLoginInfo loginInfo, LPStream stream)

View File

@ -1,5 +1,7 @@
#include "cmdlineparser.h"
#include "../include/cmdlineparser.h"
#include <iostream>
#include "string.h"
using namespace std;
template<typename T>
bool mapHasKey(map<int, T> *pMap, int key){
@ -38,25 +40,29 @@ string CmdLineParser::getOpt(string key)
void CmdLineParser::parseArgs(int argc, char *argv[])
{
size_t s=optMap.size();
struct option *longOption = new option[s]();
struct option *longOption =new struct option[s+1]();
int index=0;
string shortArgs;
for (auto i = optMap.begin(); i != optMap.end(); ++i){
struct option logopt={0};
for (auto i = optMap.begin(); i != optMap.end(); i++){
struct option *logopt= &(longOption[index]);
OptDefine od = i->second;
logopt.name = od.name.c_str();
logopt.flag = NULL;
logopt.has_arg = od.needParam;
logopt.val = od.shortName;
if(logopt.val>=65 && logopt.val<=90){
logopt->name = i->second.name.c_str();
logopt->flag = NULL;
logopt->has_arg = od.needParam;
logopt->val = od.shortName;
if(logopt->val>=65 && logopt->val<=90){
// this is a short name
shortArgs.append(1,char(logopt.val));
if(logopt.has_arg != no_argument){
shortArgs.append(1,char(logopt->val));
if(logopt->has_arg != no_argument){
shortArgs.append(1,':');
}
}
index++;
logopt = NULL;
}
// struct option nullOption = {nullptr,0,0,0};
longOption[7] = {nullptr, 0, nullptr, 0};
int optIndex=0;
int opt;
while ((opt=getopt_long(argc, argv, shortArgs.c_str(), longOption, &optIndex))!=-1) {
@ -73,7 +79,6 @@ void CmdLineParser::parseArgs(int argc, char *argv[])
}
}
//释放动态构造的option数组
delete[]longOption;
}

View File

@ -1,8 +1,8 @@
#include "convert.h"
#include "../include/convert.h"
#include <string>
#include <HCNetSDK.h>
#include <cstring>
#include "../include/HCNetSDK.h"
#include "time.h"
using namespace std;
void convert_str_chararr(string src, char *dst, int dstlen)
@ -14,7 +14,7 @@ void convert_str_chararr(string src, char *dst, int dstlen)
} else {
cplen = dstlen;
}
strlcpy(dst, src.c_str(), cplen);
strncpy(dst, src.c_str(), cplen);
}

View File

@ -1,117 +1,60 @@
#include "HkStreamer.h"
#include "../include/HkStreamer.h"
#include <iostream>
#include <cstring>
#include <map>
#include <getopt.h>
#include <time.h>
#include "../include/cmdlineparser.h"
using namespace std;
bool check_key(std::map<std::string, std::string> *m, string key)
{
// Key is not present
if (m->find(key) == m->end())
return false;
return true;
}
void parseTime(string timeStr,struct tm *timeOut){
strptime(timeStr.c_str(), "%Y%m%dT%H%M%S",timeOut);
}
void parseArgs(int argc, char *argv[], std::map<std::string, std::string> *paramMap)
{
static struct option long_options[] = {
{"cnd", required_argument, NULL, 'c'},
{"url", required_argument, NULL, 'i'},
{"user", required_argument, NULL, 'u'},
{"passwd", required_argument, NULL, 'p'},
{"device", required_argument, NULL, 'd'},
{"channel", required_argument, NULL, 'c'},
{"start", required_argument, NULL, 's'},
{"end", required_argument, NULL, 'e'},
};
int c;
while (1)
{
int opt_index = 0;
c = getopt_long(argc, argv, "c:u:p:", long_options, &opt_index);
if (c == -1)
{
break;
}
std::string paraName(1, char(c));
std::cout << "paraName:" << paraName << std::endl;
std::string paraValue = optarg;
(*paramMap)[paraName] = paraValue;
}
}
void error(string msg)
{
cerr << msg << endl;
exit(1);
}
int main(int argc, char *argv[])
{
std::map<std::string, std::string> pMap;
parseArgs(argc, argv, &pMap);
std::string cmd = pMap.at("cmd");
if (!check_key(&pMap, "u"))
{
error("Must set user");
}
if (!check_key(&pMap, "d"))
{
error("Must set device address");
}
LoginInfo loginInfo = {0};
strcpy(loginInfo.sDeviceAddress, pMap.at("d").c_str());
strcpy(loginInfo.sUserName, pMap.at("u").c_str());
strcpy(loginInfo.sPassword, pMap.at("p").c_str());
if (cmd == "playback")
{
if (!check_key(&pMap, "c"))
{
error("Muset set channel");
}
if (!check_key(&pMap, "s"))
{
error("Must set start time");
}
if (!check_key(&pMap, "e"))
{
error("Must set end time");
}
StreamCon stream = {0};
stream.lChannel = stol(pMap.at("c"));
string startStr = pMap.at("s");
struct tm start;
parseTime(startStr, &start);
stream.start.dwYear = start.tm_year;
stream.start.dwMonth = start.tm_mon;
stream.start.dwDay = start.tm_mday;
stream.start.dwHour = start.tm_hour;
stream.start.dwMinute = start.tm_min;
stream.start.dwSecond = start.tm_sec;
string endStr = pMap.at("e");
struct tm end;
parseTime(endStr, &end);
stream.end.dwYear = end.tm_year;
stream.end.dwMonth = end.tm_mon;
stream.end.dwDay = end.tm_mday;
stream.end.dwHour = end.tm_hour;
stream.end.dwMinute = end.tm_min;
stream.end.dwSecond = end.tm_sec;
playback(&loginInfo, &stream);
int call_playback(CmdLineParser *parser){
string user = parser->getOpt("user");
string password = parser->getOpt("password");
string device = parser->getOpt("device");
string channelStr = parser->getOpt("channel");
unsigned long channel = stol(channelStr);
string start = parser->getOpt("start");
string end = parser->getOpt("end");
LoginInfo loginInfo = {device, user, password};
StreamCon stream = {channel, 2048, start, end};
return playback(&loginInfo, &stream);
}
// getCfg(&loginInfo);
int call_test(CmdLineParser *parser){
cout<<"Cmd:"<<parser->getOpt("cmd")<<endl;
cout<<"User:"<<parser->getOpt("user")<<endl;
cout<<"Password:"<<parser->getOpt("password")<<endl;
cout<<"Channel:"<<parser->getOpt("channel")<<endl;
return 0;
}
int main(int argc, char *argv[])
{
CmdLineParser *cmdParser = new CmdLineParser("hkstreamer", "config and streaming for hk nvr");
cmdParser->regOpt("cmd",120, required_argument, "sub command, current support: playback");
cmdParser->regOpt("user",'U', required_argument, "device user");
cmdParser->regOpt("password", 'P', required_argument, "user password");
cmdParser->regOpt("device",'D', required_argument, "hk nvr ip");
cmdParser->regOpt("channel", 'C', required_argument, "channel to retrive video");
cmdParser->regOpt("start",'S',required_argument, "playback start, iso date str as format YYYY-mm-ddTHH:MM:SSZ");
cmdParser->regOpt("end",'E', required_argument, "playback end");
cmdParser->parseArgs(argc, argv);
string cmd = cmdParser->getOpt("cmd");
if(cmd == ""){
error("must give cmd opt");
}
if(cmd == "playback"){
call_playback(cmdParser);
} else if(cmd == "test"){
return call_test(cmdParser);
} else {
cmdParser->help();
}
return 0;
}