变更
This commit is contained in:
commit
005ce8cb29
196
.clang-format
Normal file
196
.clang-format
Normal file
@ -0,0 +1,196 @@
|
||||
---
|
||||
# 语言: None, Cpp, Java, JavaScript, ObjC, Proto, TableGen, TextProto
|
||||
Language: Cpp
|
||||
# BasedOnStyle: LLVM
|
||||
# 访问说明符(public、private等)的偏移
|
||||
AccessModifierOffset: -4
|
||||
# 开括号(开圆括号、开尖括号、开方括号)后的对齐: Align, DontAlign, AlwaysBreak(总是在开括号后换行)
|
||||
AlignAfterOpenBracket: Align
|
||||
# 连续赋值时,对齐所有等号
|
||||
AlignConsecutiveAssignments: true
|
||||
# 连续声明时,对齐所有声明的变量名
|
||||
AlignConsecutiveDeclarations: true
|
||||
|
||||
AlignEscapedNewlines: Right
|
||||
|
||||
# 左对齐逃脱换行(使用反斜杠换行)的反斜杠
|
||||
# AlignEscapedNewlinesLeft: true
|
||||
# 水平对齐二元和三元表达式的操作数
|
||||
AlignOperands: true
|
||||
# 对齐连续的尾随的注释
|
||||
AlignTrailingComments: true
|
||||
|
||||
# 允许函数声明的所有参数在放在下一行
|
||||
AllowAllParametersOfDeclarationOnNextLine: false
|
||||
# 允许短的块放在同一行
|
||||
AllowShortBlocksOnASingleLine: true
|
||||
# 允许短的case标签放在同一行
|
||||
AllowShortCaseLabelsOnASingleLine: true
|
||||
# 允许短的函数放在同一行: None, InlineOnly(定义在类中), Empty(空函数), Inline(定义在类中,空函数), All
|
||||
AllowShortFunctionsOnASingleLine: Empty
|
||||
# 允许短的if语句保持在同一行
|
||||
AllowShortIfStatementsOnASingleLine: false
|
||||
# 允许短的循环保持在同一行
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
|
||||
# 总是在定义返回类型后换行(deprecated)
|
||||
AlwaysBreakAfterDefinitionReturnType: None
|
||||
# 总是在返回类型后换行: None, All, TopLevel(顶级函数,不包括在类中的函数),
|
||||
# AllDefinitions(所有的定义,不包括声明), TopLevelDefinitions(所有的顶级函数的定义)
|
||||
AlwaysBreakAfterReturnType: None
|
||||
# 总是在多行string字面量前换行
|
||||
AlwaysBreakBeforeMultilineStrings: false
|
||||
# 总是在template声明后换行
|
||||
AlwaysBreakTemplateDeclarations: true
|
||||
# false表示函数实参要么都在同一行,要么都各自一行
|
||||
BinPackArguments: true
|
||||
# false表示所有形参要么都在同一行,要么都各自一行
|
||||
BinPackParameters: false
|
||||
# 大括号换行,只有当BreakBeforeBraces设置为Custom时才有效
|
||||
BraceWrapping:
|
||||
# class定义后面
|
||||
AfterClass: true
|
||||
# 控制语句后面
|
||||
AfterControlStatement: true
|
||||
# enum定义后面
|
||||
AfterEnum: false
|
||||
# 函数定义后面
|
||||
AfterFunction: true
|
||||
# 命名空间定义后面
|
||||
AfterNamespace: true
|
||||
# ObjC定义后面
|
||||
AfterObjCDeclaration: true
|
||||
# struct定义后面
|
||||
AfterStruct: true
|
||||
# union定义后面
|
||||
AfterUnion: true
|
||||
|
||||
AfterExternBlock: false
|
||||
# catch之前
|
||||
BeforeCatch: true
|
||||
# else之前
|
||||
BeforeElse: true
|
||||
# 缩进大括号
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: true
|
||||
SplitEmptyRecord: true
|
||||
SplitEmptyNamespace: true
|
||||
|
||||
# 在二元运算符前换行: None(在操作符后换行), NonAssignment(在非赋值的操作符前换行), All(在操作符前换行)
|
||||
BreakBeforeBinaryOperators: None
|
||||
# 在大括号前换行: Attach(始终将大括号附加到周围的上下文), Linux(除函数、命名空间和类定义,与Attach类似),
|
||||
# Mozilla(除枚举、函数、记录定义,与Attach类似), Stroustrup(除函数定义、catch、else,与Attach类似),
|
||||
# Allman(总是在大括号前换行), GNU(总是在大括号前换行,并对于控制语句的大括号增加额外的缩进), WebKit(在函数前换行), Custom
|
||||
# 注:这里认为语句块也属于函数
|
||||
BreakBeforeBraces: Attach
|
||||
# 在三元运算符前换行
|
||||
BreakBeforeTernaryOperators: false
|
||||
|
||||
# 在构造函数的初始化列表的逗号前换行
|
||||
BreakConstructorInitializersBeforeComma: false
|
||||
BreakConstructorInitializers: BeforeColon
|
||||
# 每行字符的限制,0表示没有限制
|
||||
ColumnLimit: 100
|
||||
# 描述具有特殊意义的注释的正则表达式,它不应该被分割为多行或以其它方式改变
|
||||
CommentPragmas: '^ IWYU pragma:'
|
||||
CompactNamespaces: false
|
||||
# 构造函数的初始化列表要么都在同一行,要么都各自一行
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
||||
# 构造函数的初始化列表的缩进宽度
|
||||
ConstructorInitializerIndentWidth: 4
|
||||
# 延续的行的缩进宽度
|
||||
ContinuationIndentWidth: 4
|
||||
# 去除C++11的列表初始化的大括号{后和}前的空格
|
||||
Cpp11BracedListStyle: true
|
||||
# 继承最常用的指针和引用的对齐方式
|
||||
DerivePointerAlignment: false
|
||||
# 关闭格式化
|
||||
DisableFormat: false
|
||||
# 自动检测函数的调用和定义是否被格式为每行一个参数(Experimental)
|
||||
ExperimentalAutoDetectBinPacking: false
|
||||
# 需要被解读为foreach循环而不是函数调用的宏
|
||||
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
|
||||
# 对#include进行排序,匹配了某正则表达式的#include拥有对应的优先级,匹配不到的则默认优先级为INT_MAX(优先级越小排序越靠前),
|
||||
# 可以定义负数优先级从而保证某些#include永远在最前面
|
||||
IncludeCategories:
|
||||
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
|
||||
Priority: 2
|
||||
- Regex: '^(<|"(gtest|isl|json)/)'
|
||||
Priority: 3
|
||||
- Regex: '.*'
|
||||
Priority: 1
|
||||
# 缩进case标签
|
||||
IndentCaseLabels: true
|
||||
|
||||
IndentPPDirectives: AfterHash
|
||||
# 缩进宽度
|
||||
IndentWidth: 4
|
||||
# 函数返回类型换行时,缩进函数声明或函数定义的函数名
|
||||
IndentWrappedFunctionNames: false
|
||||
# 保留在块开始处的空行
|
||||
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||
# 开始一个块的宏的正则表达式
|
||||
MacroBlockBegin: ''
|
||||
# 结束一个块的宏的正则表达式
|
||||
MacroBlockEnd: ''
|
||||
# 连续空行的最大数量
|
||||
MaxEmptyLinesToKeep: 1
|
||||
# 命名空间的缩进: None, Inner(缩进嵌套的命名空间中的内容), All
|
||||
NamespaceIndentation: Inner
|
||||
# 使用ObjC块时缩进宽度
|
||||
ObjCBlockIndentWidth: 4
|
||||
# 在ObjC的@property后添加一个空格
|
||||
ObjCSpaceAfterProperty: false
|
||||
# 在ObjC的protocol列表前添加一个空格
|
||||
ObjCSpaceBeforeProtocolList: true
|
||||
|
||||
|
||||
# 在call(后对函数调用换行的penalty
|
||||
PenaltyBreakBeforeFirstCallParameter: 30
|
||||
# 在一个注释中引入换行的penalty
|
||||
PenaltyBreakComment: 300
|
||||
# 第一次在<<前换行的penalty
|
||||
PenaltyBreakFirstLessLess: 120
|
||||
# 在一个字符串字面量中引入换行的penalty
|
||||
PenaltyBreakString: 1000
|
||||
# 对于每个在行字符数限制之外的字符的penalty
|
||||
PenaltyExcessCharacter: 1000000
|
||||
# 将函数的返回类型放到它自己的行的penalty
|
||||
PenaltyReturnTypeOnItsOwnLine: 90
|
||||
|
||||
# 指针和引用的对齐: Left, Right, Middle
|
||||
PointerAlignment: Right
|
||||
# 允许重新排版注释
|
||||
ReflowComments: true
|
||||
# 允许排序#include
|
||||
SortIncludes: true
|
||||
|
||||
# 在C风格类型转换后添加空格
|
||||
SpaceAfterCStyleCast: false
|
||||
|
||||
SpaceAfterTemplateKeyword: true
|
||||
|
||||
# 在赋值运算符之前添加空格
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
# 开圆括号之前添加一个空格: Never, ControlStatements, Always
|
||||
SpaceBeforeParens: ControlStatements
|
||||
# 在空的圆括号中添加空格
|
||||
SpaceInEmptyParentheses: false
|
||||
# 在尾随的评论前添加的空格数(只适用于//)
|
||||
SpacesBeforeTrailingComments: 2
|
||||
# 在尖括号的<后和>前添加空格
|
||||
SpacesInAngles: false
|
||||
# 在容器(ObjC和JavaScript的数组和字典等)字面量中添加空格
|
||||
SpacesInContainerLiterals: false
|
||||
# 在C风格类型转换的括号中添加空格
|
||||
SpacesInCStyleCastParentheses: false
|
||||
# 在圆括号的(后和)前添加空格
|
||||
SpacesInParentheses: false
|
||||
# 在方括号的[后和]前添加空格,lamda表达式和未指明大小的数组的声明不受影响
|
||||
SpacesInSquareBrackets: false
|
||||
# 标准: Cpp03, Cpp11, Auto
|
||||
Standard: Cpp11
|
||||
# tab宽度
|
||||
TabWidth: 4
|
||||
# 使用tab字符: Never, ForIndentation, ForContinuationAndIndentation, Always
|
||||
UseTab: Never
|
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
cmake-*/
|
||||
.idea/
|
37
CMakeLists.txt
Normal file
37
CMakeLists.txt
Normal file
@ -0,0 +1,37 @@
|
||||
cmake_minimum_required(VERSION 3.23)
|
||||
project(CommonCamera)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
|
||||
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/CommonCamera/lib)
|
||||
|
||||
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/CommonCamera/include)
|
||||
# 海康威视
|
||||
file(GLOB HK_LIBS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CommonCamera/lib/hikvision/*.so
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CommonCamera/lib/hikvision/*.so.*)
|
||||
# 大华
|
||||
file(GLOB DH_LIBS ${CMAKE_CURRENT_SOURCE_DIR}/CommonCamera/lib/dahua/*.so)
|
||||
|
||||
|
||||
add_library(HikVisionImpl SHARED ${CMAKE_CURRENT_SOURCE_DIR}/CommonCamera/src/HikVisionImpl.cpp)
|
||||
target_link_libraries(HikVisionImpl PUBLIC ${HK_LIBS})
|
||||
|
||||
|
||||
add_library(DaHuaImpl SHARED ${CMAKE_CURRENT_SOURCE_DIR}/CommonCamera/src/DaHuaImpl.cpp)
|
||||
target_link_libraries(DaHuaImpl PUBLIC ${DH_LIBS})
|
||||
|
||||
add_executable(CommonCamera tests/main.cpp)
|
||||
target_link_libraries(CommonCamera PUBLIC HikVisionImpl DaHuaImpl)
|
||||
|
||||
|
||||
install(TARGETS HikVisionImpl DaHuaImpl
|
||||
LIBRARY DESTINATION /usr/local/lib)
|
||||
install(FILES ${HK_LIBS}
|
||||
DESTINATION /usr/local/lib)
|
||||
install(FILES ${DH_LIBS}
|
||||
DESTINATION /usr/local/lib)
|
||||
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/CommonCamera/include/
|
||||
DESTINATION /usr/include/CommonCamera)
|
||||
|
269
CommonCamera/include/Camera.h
Normal file
269
CommonCamera/include/Camera.h
Normal file
@ -0,0 +1,269 @@
|
||||
//
|
||||
// Created by 张宇衡 on 2023/4/13.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
#include "Struct.h"
|
||||
#include <string>
|
||||
#include <future>
|
||||
|
||||
namespace CC {
|
||||
|
||||
class Camera {
|
||||
public:
|
||||
typedef std::shared_ptr<Camera> Ptr;
|
||||
|
||||
Camera() = default;
|
||||
|
||||
virtual ~Camera() = default;
|
||||
|
||||
// --------------------------------- 以下函数为纯虚函数 ---------------------------------
|
||||
|
||||
public: // ---------------- ptz控制 ----------------
|
||||
public:
|
||||
/*!
|
||||
* @brief 获取当前摄像头的ptz范围
|
||||
* @return 仅ptz范围 如果失败则返回nullptr
|
||||
*/
|
||||
virtual PTZ_INFO::Ptr get_ptz_range() = 0;
|
||||
|
||||
/*!
|
||||
* @brief 获取当前摄像头的ptz
|
||||
* @return 仅当前ptz 不包含范围 如果失败则返回nullptr
|
||||
*/
|
||||
virtual PTZ_INFO::Ptr get_ptz() = 0;
|
||||
|
||||
/*!
|
||||
* @brief 绝对移动
|
||||
* @param pan 水平角度
|
||||
* @param tilt 垂直角度
|
||||
* @param zoom 缩放比例
|
||||
*/
|
||||
virtual void absolute_move(double pan, double tilt, double zoom) = 0;
|
||||
|
||||
/*!
|
||||
* @brief 相对移动
|
||||
* @param pan 水平角度
|
||||
* @param tilt 垂直角度
|
||||
*/
|
||||
virtual void relative_move(double pan, double tilt) = 0;
|
||||
|
||||
/*!
|
||||
* @brief 指定速度上移
|
||||
* @param speed 速度 0-1
|
||||
*/
|
||||
virtual void move_up(float speed) = 0;
|
||||
|
||||
/*!
|
||||
* @brief 上移
|
||||
*/
|
||||
virtual void move_up() = 0;
|
||||
|
||||
/*!
|
||||
* @brief 指定速度下移
|
||||
* @param speed 速度 0-1
|
||||
*/
|
||||
virtual void move_down(float speed) = 0;
|
||||
|
||||
/*!
|
||||
* @brief 下移
|
||||
*/
|
||||
virtual void move_down() = 0;
|
||||
|
||||
/*!
|
||||
* @brief 指定速度左移
|
||||
* @param speed 速度 0-1
|
||||
*/
|
||||
virtual void move_left(float speed) = 0;
|
||||
|
||||
/*!
|
||||
* @brief 左移
|
||||
*/
|
||||
virtual void move_left() = 0;
|
||||
|
||||
/*!
|
||||
* @brief 指定速度右移
|
||||
* @param speed 速度 0-1
|
||||
*/
|
||||
virtual void move_right(float speed) = 0;
|
||||
|
||||
/*!
|
||||
* @brief 右移
|
||||
*/
|
||||
virtual void move_right() = 0;
|
||||
|
||||
/*!
|
||||
* @brief 指定速度上左移
|
||||
* @param speed 速度 0-1
|
||||
*/
|
||||
virtual void move_up_left(float speed) = 0;
|
||||
|
||||
/*!
|
||||
* @brief 上左移
|
||||
*/
|
||||
virtual void move_up_left() = 0;
|
||||
|
||||
/*!
|
||||
* @brief 指定速度上右移
|
||||
* @param speed 速度 0-1
|
||||
*/
|
||||
virtual void move_up_right(float speed) = 0;
|
||||
|
||||
/*!
|
||||
* @brief 上右移
|
||||
*/
|
||||
virtual void move_up_right() = 0;
|
||||
|
||||
/*!
|
||||
* @brief 指定速度下左移
|
||||
* @param speed 速度 0-1
|
||||
*/
|
||||
virtual void move_down_left(float speed) = 0;
|
||||
|
||||
/*!
|
||||
* @brief 下左移
|
||||
*/
|
||||
virtual void move_down_left() = 0;
|
||||
|
||||
/*!
|
||||
* @brief 指定速度下右移
|
||||
* @param speed 速度 0-1
|
||||
*/
|
||||
virtual void move_down_right(float speed) = 0;
|
||||
|
||||
/*!
|
||||
* @brief 下右移
|
||||
*/
|
||||
virtual void move_down_right() = 0;
|
||||
|
||||
/*!
|
||||
* @brief 指定速度变焦 缩进
|
||||
* @param speed 速度 0-1
|
||||
*/
|
||||
virtual void zoom_in(float speed) = 0;
|
||||
|
||||
/*!
|
||||
* @brief 变焦 缩进
|
||||
*/
|
||||
virtual void zoom_in() = 0;
|
||||
|
||||
/*!
|
||||
* @brief 指定速度变焦 放大
|
||||
* @param speed 速度 0-1
|
||||
*/
|
||||
virtual void zoom_out(float speed) = 0;
|
||||
|
||||
/*!
|
||||
* @brief 变焦 放大
|
||||
*/
|
||||
virtual void zoom_out() = 0;
|
||||
|
||||
/*!
|
||||
* @brief 相对变焦
|
||||
* @param zoom 增加或减少的值
|
||||
*/
|
||||
virtual void zoom(double zoom) = 0;
|
||||
|
||||
/*!
|
||||
* @brief 停止移动
|
||||
*/
|
||||
virtual void stop_move() = 0;
|
||||
|
||||
/*!
|
||||
* @brief 自动对焦
|
||||
*/
|
||||
virtual void auto_focus() = 0;
|
||||
|
||||
/*!
|
||||
* @brief 云台复位
|
||||
*/
|
||||
virtual void ptz_reset() = 0;
|
||||
|
||||
public: // ---------------- fov ----------------
|
||||
public:
|
||||
/*!
|
||||
* @brief 获取当前摄像头的fov范围
|
||||
* @return 仅fov范围 如果失败则返回nullptr
|
||||
*/
|
||||
virtual FOV_INFO::Ptr get_fov_range() = 0;
|
||||
|
||||
/*!
|
||||
* @brief 获取当前摄像头的fov
|
||||
* @return 仅当前fov 不包含范围 如果失败则返回nullptr
|
||||
*/
|
||||
virtual FOV_INFO::Ptr get_fov() = 0;
|
||||
|
||||
public: // ---------------- 基本功能 ----------------
|
||||
public:
|
||||
/*!
|
||||
* @brief 验证摄像头是否可用
|
||||
* @return true 可用 false 不可用
|
||||
*/
|
||||
virtual bool usable() = 0;
|
||||
|
||||
/*!
|
||||
* @brief 获取当前摄像头的rtsp流地址
|
||||
* @return rtsp流地址
|
||||
*/
|
||||
virtual std::string get_stream_url() = 0;
|
||||
|
||||
/*!
|
||||
* @brief 获取截图
|
||||
* @param data 截图数据
|
||||
* @param size 截图数据大小
|
||||
*/
|
||||
virtual bool snapshot(char **data, unsigned int &size) = 0;
|
||||
|
||||
/*!
|
||||
* @brief 获取截图
|
||||
* @param path 截图保存路径
|
||||
*/
|
||||
virtual bool snapshot(const std::string &path) = 0;
|
||||
|
||||
// --------------------------------- 以下函数为非虚函数 ---------------------------------
|
||||
public:
|
||||
/*!
|
||||
* @brief 获取当前摄像头的ptz
|
||||
* @return 摄像头的ptz信息 包含范围与当前值
|
||||
*/
|
||||
PTZ_INFO::Ptr get_ptz_info() {
|
||||
PTZ_INFO::Ptr ptz_info = PTZ_INFO::make();
|
||||
PTZ_INFO::Ptr range = get_ptz_range();
|
||||
PTZ_INFO::Ptr ptz = get_ptz();
|
||||
if (range) {
|
||||
ptz_info->pan = range->pan;
|
||||
ptz_info->tilt = range->tilt;
|
||||
ptz_info->zoom = range->zoom;
|
||||
}
|
||||
if (ptz) {
|
||||
ptz_info->pan->data = ptz->pan->data;
|
||||
ptz_info->tilt->data = ptz->tilt->data;
|
||||
ptz_info->zoom->data = ptz->zoom->data;
|
||||
ptz_info->moving = ptz->moving;
|
||||
}
|
||||
return ptz_info;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief 获取当前摄像头的fov
|
||||
* @return 摄像头的fov信息 包含范围与当前值
|
||||
*/
|
||||
FOV_INFO::Ptr get_fov_info() {
|
||||
FOV_INFO::Ptr fov_info = FOV_INFO::make();
|
||||
FOV_INFO::Ptr range = get_fov_range();
|
||||
FOV_INFO::Ptr fov = get_fov();
|
||||
if (range) {
|
||||
fov_info->horizontal = range->horizontal;
|
||||
fov_info->vertical = range->vertical;
|
||||
fov_info->diagonal = range->diagonal;
|
||||
}
|
||||
if (fov) {
|
||||
fov_info->horizontal->data = fov->horizontal->data;
|
||||
fov_info->vertical->data = fov->vertical->data;
|
||||
fov_info->diagonal->data = fov->diagonal->data;
|
||||
}
|
||||
return fov_info;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace CC
|
35
CommonCamera/include/CommonCamera.h
Normal file
35
CommonCamera/include/CommonCamera.h
Normal file
@ -0,0 +1,35 @@
|
||||
//
|
||||
// Created by 张宇衡 on 2023/4/13.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
#include "DaHua.h"
|
||||
#include "HikVision.h"
|
||||
#include "YuShi.h"
|
||||
#include "None.h"
|
||||
#include <string>
|
||||
|
||||
namespace CC {
|
||||
|
||||
static Camera::Ptr make_hikvision_camera(const std::string &ip,
|
||||
const std::string &username,
|
||||
const std::string &password) {
|
||||
HikVision::Ptr camera = HikVision::make(ip, username, password);
|
||||
return std::static_pointer_cast<Camera>(camera);
|
||||
}
|
||||
|
||||
static Camera::Ptr make_dahua_camera(const std::string &ip,
|
||||
const std::string &username,
|
||||
const std::string &password) {
|
||||
DaHua::Ptr camera = DaHua::make(ip, username, password);
|
||||
return std::static_pointer_cast<Camera>(camera);
|
||||
}
|
||||
|
||||
static Camera::Ptr make_yushi_camera(const std::string &ip,
|
||||
const std::string &username,
|
||||
const std::string &password) {
|
||||
YuShi::Ptr camera = YuShi::make(ip, username, password);
|
||||
return std::static_pointer_cast<Camera>(camera);
|
||||
}
|
||||
|
||||
} // namespace CC
|
120
CommonCamera/include/DaHua.h
Normal file
120
CommonCamera/include/DaHua.h
Normal file
@ -0,0 +1,120 @@
|
||||
//
|
||||
// Created by 张宇衡 on 2023/4/13.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
#include <utility>
|
||||
|
||||
#include "Camera.h"
|
||||
#include "dahua/dhnetsdk.h"
|
||||
|
||||
#define DH_CHANNEL 0
|
||||
|
||||
namespace CC {
|
||||
|
||||
class DaHua : public Camera {
|
||||
private:
|
||||
std::string ip_;
|
||||
std::string username_;
|
||||
std::string password_;
|
||||
|
||||
long login_handle_ = -1;
|
||||
|
||||
std::mutex usable_mutex_;
|
||||
std::mutex operate_mutex_;
|
||||
|
||||
public:
|
||||
typedef std::shared_ptr<DaHua> Ptr;
|
||||
|
||||
static Ptr make(const std::string &ip,
|
||||
const std::string &username,
|
||||
const std::string &password) {
|
||||
return std::make_shared<DaHua>(ip, username, password);
|
||||
}
|
||||
|
||||
DaHua() = delete;
|
||||
|
||||
DaHua(std::string ip, std::string username, std::string password);
|
||||
|
||||
~DaHua() override;
|
||||
|
||||
public:
|
||||
PTZ_INFO::Ptr get_ptz_range() override;
|
||||
|
||||
PTZ_INFO::Ptr get_ptz() override;
|
||||
|
||||
FOV_INFO::Ptr get_fov_range() override;
|
||||
|
||||
FOV_INFO::Ptr get_fov() override;
|
||||
|
||||
bool usable() override;
|
||||
|
||||
void absolute_move(double pan, double tilt, double zoom) override;
|
||||
|
||||
void relative_move(double pan, double tilt) override;
|
||||
|
||||
void move_up(float speed) override;
|
||||
|
||||
void move_up() override;
|
||||
|
||||
void move_down(float speed) override;
|
||||
|
||||
void move_down() override;
|
||||
|
||||
void move_left(float speed) override;
|
||||
|
||||
void move_left() override;
|
||||
|
||||
void move_right(float speed) override;
|
||||
|
||||
void move_right() override;
|
||||
|
||||
void move_up_left(float speed) override;
|
||||
|
||||
void move_up_left() override;
|
||||
|
||||
void move_up_right(float speed) override;
|
||||
|
||||
void move_up_right() override;
|
||||
|
||||
void move_down_left(float speed) override;
|
||||
|
||||
void move_down_left() override;
|
||||
|
||||
void move_down_right(float speed) override;
|
||||
|
||||
void move_down_right() override;
|
||||
|
||||
void zoom_in(float speed) override;
|
||||
|
||||
void zoom_in() override;
|
||||
|
||||
void zoom_out(float speed) override;
|
||||
|
||||
void zoom_out() override;
|
||||
|
||||
void zoom(double zoom) override;
|
||||
|
||||
void stop_move() override;
|
||||
|
||||
void auto_focus() override {}
|
||||
|
||||
bool snapshot(char **data, unsigned int &size) override;
|
||||
|
||||
std::string get_stream_url() override {
|
||||
return "";
|
||||
}
|
||||
|
||||
void ptz_reset() override;
|
||||
|
||||
bool snapshot(const std::string &path) override;
|
||||
|
||||
private:
|
||||
void login();
|
||||
|
||||
void logout();
|
||||
|
||||
fDisConnect dis_connect_callback_ = nullptr;
|
||||
};
|
||||
|
||||
} // namespace CC
|
125
CommonCamera/include/HikVision.h
Normal file
125
CommonCamera/include/HikVision.h
Normal file
@ -0,0 +1,125 @@
|
||||
//
|
||||
// Created by 张宇衡 on 2023/4/13.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
#include <utility>
|
||||
|
||||
#include "Camera.h"
|
||||
#include "hikvision/HCNetSDK.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
|
||||
#define HK_CHANNEL 1
|
||||
|
||||
namespace CC {
|
||||
|
||||
class HikVision : public Camera {
|
||||
private:
|
||||
std::string ip_;
|
||||
std::string username_;
|
||||
std::string password_;
|
||||
|
||||
int user_id_ = -1;
|
||||
|
||||
std::mutex usable_mutex_;
|
||||
std::mutex operate_mutex_;
|
||||
|
||||
public:
|
||||
typedef std::shared_ptr<HikVision> Ptr;
|
||||
|
||||
static Ptr make(const std::string &ip,
|
||||
const std::string &username,
|
||||
const std::string &password) {
|
||||
return std::make_shared<HikVision>(ip, username, password);
|
||||
}
|
||||
|
||||
HikVision() = delete;
|
||||
|
||||
HikVision(std::string ip, std::string username, std::string password);
|
||||
|
||||
~HikVision() override;
|
||||
|
||||
public:
|
||||
PTZ_INFO::Ptr get_ptz_range() override;
|
||||
|
||||
PTZ_INFO::Ptr get_ptz() override;
|
||||
|
||||
FOV_INFO::Ptr get_fov_range() override;
|
||||
|
||||
FOV_INFO::Ptr get_fov() override;
|
||||
|
||||
bool usable() override;
|
||||
|
||||
void absolute_move(double pan, double tilt, double zoom) override;
|
||||
|
||||
void relative_move(double pan, double tilt) override;
|
||||
|
||||
void move_up(float speed) override;
|
||||
|
||||
void move_up() override;
|
||||
|
||||
void move_down(float speed) override;
|
||||
|
||||
void move_down() override;
|
||||
|
||||
void move_left(float speed) override;
|
||||
|
||||
void move_left() override;
|
||||
|
||||
void move_right(float speed) override;
|
||||
|
||||
void move_right() override;
|
||||
|
||||
void move_up_left(float speed) override;
|
||||
|
||||
void move_up_left() override;
|
||||
|
||||
void move_up_right(float speed) override;
|
||||
|
||||
void move_up_right() override;
|
||||
|
||||
void move_down_left(float speed) override;
|
||||
|
||||
void move_down_left() override;
|
||||
|
||||
void move_down_right(float speed) override;
|
||||
|
||||
void move_down_right() override;
|
||||
|
||||
void zoom_in(float speed) override;
|
||||
|
||||
void zoom_in() override;
|
||||
|
||||
void zoom_out(float speed) override;
|
||||
|
||||
void zoom_out() override;
|
||||
|
||||
void zoom(double zoom) override;
|
||||
|
||||
void stop_move() override;
|
||||
|
||||
void auto_focus() override;
|
||||
|
||||
std::string get_stream_url() override;
|
||||
|
||||
void ptz_reset() override;
|
||||
|
||||
bool snapshot(char **data, unsigned int &size) override;
|
||||
|
||||
bool snapshot(const std::string &path) override;
|
||||
|
||||
private:
|
||||
void login();
|
||||
|
||||
void logout();
|
||||
|
||||
private:
|
||||
// 0x3500 -> 350.0
|
||||
static double convert_hex_to_double(int hex_num);
|
||||
// 350.0 -> 0x3500
|
||||
static int convert_double_to_hex(double double_num);
|
||||
};
|
||||
|
||||
} // namespace CC
|
121
CommonCamera/include/None.h
Normal file
121
CommonCamera/include/None.h
Normal file
@ -0,0 +1,121 @@
|
||||
//
|
||||
// Created by 张宇衡 on 2023/4/13.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
#include <utility>
|
||||
|
||||
#include "Camera.h"
|
||||
|
||||
namespace CC {
|
||||
|
||||
class None : public Camera {
|
||||
private:
|
||||
std::string ip_;
|
||||
std::string username_;
|
||||
std::string password_;
|
||||
|
||||
public:
|
||||
typedef std::shared_ptr<None> Ptr;
|
||||
|
||||
static Ptr make(const std::string &ip,
|
||||
const std::string &username,
|
||||
const std::string &password) {
|
||||
return std::make_shared<None>(ip, username, password);
|
||||
}
|
||||
|
||||
None() = delete;
|
||||
|
||||
None(std::string ip, std::string username, std::string password)
|
||||
: ip_(std::move(ip)), username_(std::move(username)), password_(std::move(password)) {}
|
||||
|
||||
~None() override = default;
|
||||
|
||||
public:
|
||||
|
||||
PTZ_INFO::Ptr get_ptz_range() override {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PTZ_INFO::Ptr get_ptz() override {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
FOV_INFO::Ptr get_fov_range() override {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
FOV_INFO::Ptr get_fov() override {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool usable() override {
|
||||
return false;
|
||||
}
|
||||
|
||||
void absolute_move(double pan, double tilt, double zoom) override {}
|
||||
|
||||
void relative_move(double pan, double tilt) override {}
|
||||
|
||||
void move_up(float speed) override {}
|
||||
|
||||
void move_up() override {}
|
||||
|
||||
void move_down(float speed) override {}
|
||||
|
||||
void move_down() override {}
|
||||
|
||||
void move_left(float speed) override {}
|
||||
|
||||
void move_left() override {}
|
||||
|
||||
void move_right(float speed) override {}
|
||||
|
||||
void move_right() override {}
|
||||
|
||||
void move_up_left(float speed) override {}
|
||||
|
||||
void move_up_left() override {}
|
||||
|
||||
void move_up_right(float speed) override {}
|
||||
|
||||
void move_up_right() override {}
|
||||
|
||||
void move_down_left(float speed) override {}
|
||||
|
||||
void move_down_left() override {}
|
||||
|
||||
void move_down_right(float speed) override {}
|
||||
|
||||
void move_down_right() override {}
|
||||
|
||||
void zoom_in(float speed) override {}
|
||||
|
||||
void zoom_in() override {}
|
||||
|
||||
void zoom_out(float speed) override {}
|
||||
|
||||
void zoom_out() override {}
|
||||
|
||||
void zoom(double zoom) override {}
|
||||
|
||||
void stop_move() override {}
|
||||
|
||||
void auto_focus() override {}
|
||||
|
||||
std::string get_stream_url() override {
|
||||
return "";
|
||||
}
|
||||
|
||||
bool snapshot(char **data, unsigned int &size) override {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool snapshot(const std::string &path) override {
|
||||
return false;
|
||||
}
|
||||
|
||||
void ptz_reset() override {}
|
||||
};
|
||||
|
||||
} // namespace CC
|
74
CommonCamera/include/Struct.h
Normal file
74
CommonCamera/include/Struct.h
Normal file
@ -0,0 +1,74 @@
|
||||
//
|
||||
// Created by 张宇衡 on 2023/4/13.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <cstring>
|
||||
|
||||
namespace CC {
|
||||
|
||||
class RangeData {
|
||||
public:
|
||||
typedef std::shared_ptr<RangeData> Ptr;
|
||||
|
||||
static Ptr make() {
|
||||
return std::make_shared<RangeData>();
|
||||
}
|
||||
double data = 0.0;
|
||||
double max = 0.0;
|
||||
double min = 0.0;
|
||||
};
|
||||
|
||||
class PTZ_INFO {
|
||||
public:
|
||||
typedef std::shared_ptr<PTZ_INFO> Ptr;
|
||||
|
||||
static Ptr make() {
|
||||
return std::make_shared<PTZ_INFO>();
|
||||
}
|
||||
|
||||
RangeData::Ptr pan = RangeData::make();
|
||||
RangeData::Ptr tilt = RangeData::make();
|
||||
RangeData::Ptr zoom = RangeData::make();
|
||||
bool moving = false;
|
||||
|
||||
std::string str() const {
|
||||
std::stringstream ss;
|
||||
ss << "pan : \t" << pan->data << "\t max: \t" << pan->max << "\t min: \t" << pan->min
|
||||
<< std::endl;
|
||||
ss << "tilt : \t" << tilt->data << "\t max: \t" << tilt->max << "\t min: \t" << tilt->min
|
||||
<< std::endl;
|
||||
ss << "zoom : \t" << zoom->data << "\t max: \t" << zoom->max << "\t min: \t" << zoom->min
|
||||
<< std::endl;
|
||||
return ss.str();
|
||||
}
|
||||
};
|
||||
|
||||
class FOV_INFO {
|
||||
public:
|
||||
typedef std::shared_ptr<FOV_INFO> Ptr;
|
||||
|
||||
static Ptr make() {
|
||||
return std::make_shared<FOV_INFO>();
|
||||
}
|
||||
|
||||
RangeData::Ptr horizontal = RangeData::make();
|
||||
RangeData::Ptr vertical = RangeData::make();
|
||||
RangeData::Ptr diagonal = RangeData::make();
|
||||
|
||||
std::string str() const {
|
||||
std::stringstream ss;
|
||||
ss << "horizontal : \t" << horizontal->data << "\t max: \t" << horizontal->max
|
||||
<< "\t min: \t" << horizontal->min << std::endl;
|
||||
ss << "vertical : \t" << vertical->data << "\t max: \t" << vertical->max << "\t min: \t"
|
||||
<< vertical->min << std::endl;
|
||||
ss << "diagonal : \t" << diagonal->data << "\t max: \t" << diagonal->max << "\t min: \t"
|
||||
<< diagonal->min << std::endl;
|
||||
return ss.str();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace CC
|
121
CommonCamera/include/YuShi.h
Normal file
121
CommonCamera/include/YuShi.h
Normal file
@ -0,0 +1,121 @@
|
||||
//
|
||||
// Created by 张宇衡 on 2023/4/13.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
#include <utility>
|
||||
|
||||
#include "Camera.h"
|
||||
|
||||
namespace CC {
|
||||
|
||||
class YuShi : public Camera {
|
||||
private:
|
||||
std::string ip_;
|
||||
std::string username_;
|
||||
std::string password_;
|
||||
|
||||
public:
|
||||
typedef std::shared_ptr<YuShi> Ptr;
|
||||
|
||||
static Ptr make(const std::string &ip,
|
||||
const std::string &username,
|
||||
const std::string &password) {
|
||||
return std::make_shared<YuShi>(ip, username, password);
|
||||
}
|
||||
|
||||
YuShi() = delete;
|
||||
|
||||
YuShi(std::string ip, std::string username, std::string password)
|
||||
: ip_(std::move(ip)), username_(std::move(username)), password_(std::move(password)) {}
|
||||
|
||||
~YuShi() override = default;
|
||||
|
||||
public:
|
||||
|
||||
PTZ_INFO::Ptr get_ptz_range() override {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PTZ_INFO::Ptr get_ptz() override {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
FOV_INFO::Ptr get_fov_range() override {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
FOV_INFO::Ptr get_fov() override {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool usable() override {
|
||||
return false;
|
||||
}
|
||||
|
||||
void absolute_move(double pan, double tilt, double zoom) override {}
|
||||
|
||||
void relative_move(double pan, double tilt) override {}
|
||||
|
||||
void move_up(float speed) override {}
|
||||
|
||||
void move_up() override {}
|
||||
|
||||
void move_down(float speed) override {}
|
||||
|
||||
void move_down() override {}
|
||||
|
||||
void move_left(float speed) override {}
|
||||
|
||||
void move_left() override {}
|
||||
|
||||
void move_right(float speed) override {}
|
||||
|
||||
void move_right() override {}
|
||||
|
||||
void move_up_left(float speed) override {}
|
||||
|
||||
void move_up_left() override {}
|
||||
|
||||
void move_up_right(float speed) override {}
|
||||
|
||||
void move_up_right() override {}
|
||||
|
||||
void move_down_left(float speed) override {}
|
||||
|
||||
void move_down_left() override {}
|
||||
|
||||
void move_down_right(float speed) override {}
|
||||
|
||||
void move_down_right() override {}
|
||||
|
||||
void zoom_in(float speed) override {}
|
||||
|
||||
void zoom_in() override {}
|
||||
|
||||
void zoom_out(float speed) override {}
|
||||
|
||||
void zoom_out() override {}
|
||||
|
||||
void zoom(double zoom) override {}
|
||||
|
||||
void stop_move() override {}
|
||||
|
||||
void auto_focus() override {}
|
||||
|
||||
std::string get_stream_url() override {
|
||||
return "";
|
||||
}
|
||||
|
||||
bool snapshot(char **data, unsigned int &size) override {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool snapshot(const std::string &path) override {
|
||||
return false;
|
||||
}
|
||||
|
||||
void ptz_reset() override {}
|
||||
};
|
||||
|
||||
} // namespace CC
|
28
CommonCamera/include/dahua/avglobal.h
Normal file
28
CommonCamera/include/dahua/avglobal.h
Normal file
@ -0,0 +1,28 @@
|
||||
|
||||
#ifndef AVGLOBAL_H
|
||||
#define AVGLOBAL_H
|
||||
|
||||
typedef int AV_int32;
|
||||
typedef unsigned int AV_uint32;
|
||||
|
||||
#ifndef __OBJC__
|
||||
typedef int AV_BOOL;
|
||||
#else
|
||||
typedef BOOL AV_BOOL;
|
||||
#endif
|
||||
|
||||
typedef void* AV_HANDLE;
|
||||
typedef unsigned char AV_BYTE;
|
||||
typedef float AV_float;
|
||||
|
||||
#ifdef WIN32
|
||||
typedef __int64 AV_int64;
|
||||
typedef unsigned __int64 AV_uint64;
|
||||
#else
|
||||
typedef long long AV_int64;
|
||||
typedef unsigned long long AV_uint64;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
18174
CommonCamera/include/dahua/dhconfigsdk.h
Normal file
18174
CommonCamera/include/dahua/dhconfigsdk.h
Normal file
File diff suppressed because it is too large
Load Diff
110220
CommonCamera/include/dahua/dhnetsdk.h
Normal file
110220
CommonCamera/include/dahua/dhnetsdk.h
Normal file
File diff suppressed because it is too large
Load Diff
111
CommonCamera/include/hikvision/DataType.h
Normal file
111
CommonCamera/include/hikvision/DataType.h
Normal file
@ -0,0 +1,111 @@
|
||||
#ifndef DATA_TYPE_H
|
||||
#define DATA_TYPE_H
|
||||
#define FRAME_HEAD_MAGIC 0x03211546
|
||||
#define SYSTEM_SYNC_ID 2
|
||||
|
||||
#ifdef __LINUX__
|
||||
typedef unsigned char UCHAR;
|
||||
typedef unsigned char* PBYTE;
|
||||
typedef char* LPTSTR;
|
||||
typedef unsigned short USHORT;
|
||||
typedef int HANDLE;
|
||||
typedef unsigned long ULONG;
|
||||
typedef unsigned long DWORD;
|
||||
#endif //#ifdef __LINUX__
|
||||
|
||||
typedef struct tagFrameInfo{
|
||||
ULONG SyncId; /* 00000000000000000000000000010b */
|
||||
ULONG Magic;
|
||||
USHORT FrameType; /* I frames , P frames or BBP frames Audio frames or dsp status etc */
|
||||
ULONG Length; /*lenth include this header */
|
||||
ULONG FrameNumber; /* serial number of this frame */
|
||||
UCHAR Breakable; /* indicate if stream breakable, you could restart new file(with PktSysHeader) if true */
|
||||
/*ULONG Ack;*/
|
||||
ULONG PTS; /* system clock when this frames is processed */
|
||||
}TMFRAME_HEADER, *PTMFRAME_HEADER;
|
||||
|
||||
typedef enum {
|
||||
StandardNone = 0x80000000,
|
||||
StandardNTSC = 0x00000001,
|
||||
StandardPAL = 0x00000002,
|
||||
StandardSECAM = 0x00000004,
|
||||
} VideoStandard_t;
|
||||
|
||||
|
||||
typedef enum {
|
||||
PktError = 0,
|
||||
PktIFrames = 0x0001,
|
||||
PktPFrames = 0x0002,
|
||||
PktBBPFrames = 0x0004,
|
||||
PktAudioFrames = 0x0008,
|
||||
PktMotionDetection = 0x00010,
|
||||
PktDspStatus = 0x00020,
|
||||
PktOrigImage = 0x00040,
|
||||
PktSysHeader = 0x00080,
|
||||
PktBPFrames = 0x00100,
|
||||
PktSFrames = 0x00200,
|
||||
PktSubIFrames = 0x00400,
|
||||
PktSubPFrames = 0x00800,
|
||||
PktSubBBPFrames = 0x01000,
|
||||
PktSubSysHeader = 0x02000
|
||||
}FrameType_t;
|
||||
|
||||
typedef struct tagVersion{
|
||||
ULONG DspVersion, DspBuildNum;
|
||||
ULONG DriverVersion, DriverBuildNum;
|
||||
ULONG SDKVersion, SDKBuildNum;
|
||||
}VERSION_INFO, *PVERSION_INFO;
|
||||
|
||||
typedef enum {
|
||||
ENC_CIF_FORMAT = 0,
|
||||
ENC_QCIF_FORMAT = 1,
|
||||
ENC_2CIF_FORMAT = 2,
|
||||
ENC_4CIF_FORMAT = 3,
|
||||
ENC_QQCIF_FORMAT = 4,
|
||||
ENC_CIFQCIF_FORMAT =5,
|
||||
ENC_CIFQQCIF_FORMAT =6,
|
||||
ENC_DCIF_FORMAT =7,
|
||||
ENC_VGA_FORMAT=8
|
||||
}PictureFormat_t;
|
||||
|
||||
typedef struct tagMotionData{
|
||||
PictureFormat_t PicFormat;
|
||||
ULONG HorizeBlocks;
|
||||
ULONG VerticalBlocks;
|
||||
ULONG BlockSize;
|
||||
}MOTION_DATA_HEADER, *PMOTION_DATA_HEADER;
|
||||
|
||||
|
||||
#define _OSD_BASE 0x9000 /*base address of special character*/
|
||||
#define _OSD_YEAR4 (_OSD_BASE+0) /*show year time by length of 4 , for example: 2005*/
|
||||
#define _OSD_YEAR2 (_OSD_BASE+1) /*show year time by length of 2, for example: 05 */
|
||||
#define _OSD_MONTH3 (_OSD_BASE+2) /*show month time in English, for example: Jan*/
|
||||
#define _OSD_MONTH2 (_OSD_BASE+3) /*show month time by two Arabic numerals, for example: 07*/
|
||||
#define _OSD_DAY (_OSD_BASE+4) /*show day time by two Arabic numerals, for example: 31*/
|
||||
#define _OSD_WEEK3 (_OSD_BASE+5) /*show week time in English: MON¡«SUN*/
|
||||
#define _OSD_CWEEK1 (_OSD_BASE+6) /*show week time in Chinese GB code*/
|
||||
#define _OSD_HOUR24 (_OSD_BASE+7) /*show 24 hours clock: 00¡«23 */
|
||||
#define _OSD_HOUR12 (_OSD_BASE+8) /*show 12 hours clock: 00¡«12*/
|
||||
#define _OSD_MINUTE (_OSD_BASE+9) /*show minute time by length of 2: 00¡«59*/
|
||||
#define _OSD_SECOND (_OSD_BASE+10) /*show second time by length of 2: 00¡«59*/
|
||||
#define _OSD_MILISECOND (_OSD_BASE+11) /*show millisecond time by length of 3: 000~999*/
|
||||
#define _OSD_APM (_OSD_BASE+14) /*show a.m. or p.m. by length of 2 bit, AM or PM*/
|
||||
|
||||
//For new added APIs to set OSD: SetEncoderOsdDisplayMode, SetDecoderOsdDisplayMode and SetDisplayOsdDisplayMode in v6.0 SDK, we use new basic address of special character.
|
||||
#define _OSD_BASE_EX 0x90000 /*base address of special character*/
|
||||
#define _OSD_YEAR4_EX (_OSD_BASE_EX+0) /*the same as _OSD_YEAR4*/
|
||||
#define _OSD_YEAR2_EX (_OSD_BASE_EX+1) /*the same as _OSD_YEAR2*/
|
||||
#define _OSD_MONTH3_EX (_OSD_BASE_EX+2) /*the same as _OSD_MONTH3*/
|
||||
#define _OSD_MONTH2_EX (_OSD_BASE_EX+3) /*the same as _OSD_MONTH2*/
|
||||
#define _OSD_DAY_EX (_OSD_BASE_EX+4) /*the same as _OSD_DAY*/
|
||||
#define _OSD_WEEK3_EX (_OSD_BASE_EX+5) /*the same as _OSD_WEEK3*/
|
||||
#define _OSD_CWEEK1_EX (_OSD_BASE_EX+6) /*the same as _OSD_CWEEK1*/
|
||||
#define _OSD_HOUR24_EX (_OSD_BASE_EX+7) /*the same as _OSD_HOUR24*/
|
||||
#define _OSD_HOUR12_EX (_OSD_BASE_EX+8) /*the same as _OSD_HOUR12*/
|
||||
#define _OSD_MINUTE_EX (_OSD_BASE_EX+9) /*the same as _OSD_MINUTE*/
|
||||
#define _OSD_SECOND_EX (_OSD_BASE_EX+10) /*the same as _OSD_SECOND*/
|
||||
#define _OSD_MILISECOND_EX (_OSD_BASE_EX+11) /*the same as _OSD_MILISECOND*/
|
||||
#define _OSD_APM_EX (_OSD_BASE_EX+14) /*the same as _OSD_APM*/
|
||||
|
||||
|
||||
#endif
|
451
CommonCamera/include/hikvision/DecodeCardSdk.h
Normal file
451
CommonCamera/include/hikvision/DecodeCardSdk.h
Normal file
@ -0,0 +1,451 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// DS-40xxHC/HF BOARD SYSTEM SDK //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef DECODECARD_SDK_H
|
||||
#define DECODECARD_SDK_H
|
||||
|
||||
#include "datatype.h"
|
||||
|
||||
#define DLLEXPORT_API extern "C" __declspec(dllexport)
|
||||
#define ERR_WAIT_TIMEOUT 0xc0000001
|
||||
#define ERR_INVALID_HANDLE 0xc0000002
|
||||
#define ERR_INVALID_ARGUMENT 0xc0000003
|
||||
#define ERR_DDRAW_CREATE_FAILED 0xc0000004
|
||||
#define ERR_DDRAW_CAPS_FAULT 0xc0000005
|
||||
#define ERR_SET_COOPERATIVELEVEL_FAILED 0xc0000006
|
||||
#define ERR_PRIMARY_SURFACE_CREATE_FAILED 0xc0000007
|
||||
#define ERR_GET_OVERLAY_ADDRESS_FAILED 0xc0000008
|
||||
#define ERR_OVERLAY_SURFACE_CREATE_FAILED 0xc0000009
|
||||
#define ERR_OVERLAY_UPDATE_FAILED 0xc000000a
|
||||
#define ERR_TMMAN_FAILURE 0xc000000b
|
||||
#define ERR_CHANNELMAGIC_MISMATCH 0xc000000c
|
||||
#define ERR_CALLBACK_REGISTERED 0xc000000d
|
||||
#define ERR_QUEUE_OVERFLOW 0xc000000e
|
||||
#define ERR_STREAM_THREAD_FAILURE 0xc000000f
|
||||
#define ERR_THREAD_STOP_ERROR 0xc0000010
|
||||
#define ERR_NOT_SUPPORT 0xc0000011
|
||||
#define ERR_OUTOF_MEMORY 0xc0000012
|
||||
#define ERR_DSP_BUSY 0xc0000013
|
||||
#define ERR_DATA_ERROR 0xc0000014
|
||||
#define ERR_KERNEL 0xc0000016
|
||||
#define ERR_OFFSCREEN_CREATE_FAILED 0xc0000017
|
||||
#define ERR_MULTICLOCK_FAILURE 0xc0000018
|
||||
#define ERR_INVALID_DEVICE 0xc0000019
|
||||
#define ERR_INVALID_DRIVER 0xc000001a
|
||||
//error code for MD card
|
||||
#define HWERR_SUCCESS 0
|
||||
#define HWERR_ALLOCATE_MEMORY 0xc1000001
|
||||
#define HWERR_INVALID_HANDLE 0xc1000002
|
||||
#define HWERR_DDRAW_CREATE_FAILED 0xc1000003
|
||||
#define HWERR_DDRAW_CAPS_FAULT 0xc1000004
|
||||
#define HWERR_SET_COOPERATIVELEVEL_FAILED 0xc1000005
|
||||
#define HWERR_PRIMARY_SURFACE_CREATE_FAILED 0xc1000006
|
||||
#define HWERR_OVERLAY_CREATE_FAILED 0xc1000007
|
||||
#define HWERR_GET_OVERLAY_ADDRESS_FAILED 0xc1000008
|
||||
#define HWERR_OVERLAY_UPDATE_FAILED 0xc1000009
|
||||
#define HWERR_SURFACE_NULL 0xc100000a
|
||||
#define HWERR_FILEHEADER_UNKNOWN 0xc100000b
|
||||
#define HWERR_CREATE_FILE_FAILED 0xc100000c
|
||||
#define HWERR_FILE_SIZE_ZERO 0xc100000d
|
||||
#define HWERR_FILE_SIZE_INVALID 0xc100000d
|
||||
#define HWERR_CREATE_OBJ_FAILED 0xc100000e
|
||||
#define HWERR_CHANNELMAGIC_MISMATCH 0xc100000f
|
||||
#define HWERR_PARA_OVER 0xc1000010
|
||||
#define HWERR_ORDER 0xc1000011
|
||||
#define HWERR_COMMAND 0xc1000012
|
||||
#define HWERR_UNSUPPORTED 0xc1000013
|
||||
#define HWERR_DSPOPEN 0xc1000014
|
||||
#define HWERR_DSPLOAD 0xc1000015
|
||||
#define HWERR_ALLOCATE_DSPMEMORY 0xc1000016
|
||||
#define HWERR_DSPCHECHER 0xc1000017
|
||||
#define HWERR_IMGFILE_UNKNOWN 0xc1000018
|
||||
#define HWERR_INVALID_FILE 0xc1000019
|
||||
//standart
|
||||
#define HW_PAL 2
|
||||
#define HW_NTSC 1
|
||||
//jump direction
|
||||
#define HW_JUMP_FORWARD 309
|
||||
#define HW_JUMP_BACKWARD 310
|
||||
|
||||
|
||||
typedef enum tagTypeVideoFormat
|
||||
{
|
||||
vdfRGB8A_233 = 0x00000001,
|
||||
vdfRGB8R_332 = 0x00000002,
|
||||
vdfRGB15Alpha = 0x00000004,
|
||||
vdfRGB16 = 0x00000008,
|
||||
vdfRGB24 = 0x00000010,
|
||||
vdfRGB24Alpha = 0x00000020,
|
||||
|
||||
vdfYUV420Planar = 0x00000040,
|
||||
vdfYUV422Planar = 0x00000080,
|
||||
vdfYUV411Planar = 0x00000100,
|
||||
vdfYUV420Interspersed = 0x00000200,
|
||||
vdfYUV422Interspersed = 0x00000400,
|
||||
vdfYUV411Interspersed = 0x00000800,
|
||||
vdfYUV422Sequence = 0x00001000, /* U0, Y0, V0, Y1: For VO overlay */
|
||||
vdfYUV422SequenceAlpha = 0x00002000,
|
||||
/* U0, Y0, V0, Y1: For VO overlay, with low bit for alpha blending */
|
||||
vdfMono = 0x00004000, /* 8 bit monochrome */
|
||||
|
||||
vdfYUV444Planar = 0x00008000,
|
||||
}TypeVideoFormat;
|
||||
|
||||
|
||||
typedef enum _BitrateControlType_t
|
||||
{
|
||||
brCBR = 0,
|
||||
brVBR = 1,
|
||||
}BitrateControlType_t;
|
||||
|
||||
typedef enum _BOARD_TYPE_DS
|
||||
{
|
||||
DS400XM =0,
|
||||
DS400XH =1,
|
||||
DS4004HC =2,
|
||||
DS4008HC =3,
|
||||
DS4016HC =4,
|
||||
DS4001HF =5,
|
||||
DS4004HF =6,
|
||||
DS4002MD =7,
|
||||
DS4004MD =8, //4004MD
|
||||
DS4016HCS =9, //4016HCS
|
||||
DS4002HT =10, //4002HT
|
||||
DS4004HT =11, //4004HT
|
||||
DS4008HT =12, //4008HT
|
||||
DS4004HC_PLUS =13, //4004HC+
|
||||
DS4008HC_PLUS =14, //4008HC+
|
||||
DS4016HC_PLUS =15, //4016HC+
|
||||
DS4008HF =16, //4008HF
|
||||
DS4008MD =17, //4008MD
|
||||
DS4008HS =18, //4008HS
|
||||
DS4016HS =19, //4016HS
|
||||
INVALID_BOARD_TYPE =0xffffffff,
|
||||
}BOARD_TYPE_DS;
|
||||
|
||||
#define STREAM_TYPE_VIDEO 1
|
||||
#define STREAM_TYPE_AUDIO 2
|
||||
#define STREAM_TYPE_AVSYNC 3
|
||||
#define DRAWFUN(x) void (CALLBACK* x)(long nPort,HDC hDc,LONG nUser)
|
||||
|
||||
|
||||
typedef void (*LOGRECORD_CALLBACK)(char *str, void *context);
|
||||
typedef int (*STREAM_READ_CALLBACK)(ULONG channelNumber, void *context);
|
||||
typedef int (*STREAM_DIRECT_READ_CALLBACK)(ULONG channelNumber,void *DataBuf,DWORD Length,int FrameType,void *context);
|
||||
|
||||
typedef struct tagChannelCapability{
|
||||
UCHAR bAudioPreview;
|
||||
UCHAR bAlarmIO;
|
||||
UCHAR bWatchDog;
|
||||
}CHANNEL_CAPABILITY, *PCHANNEL_CAPABILITY;
|
||||
|
||||
typedef struct tagFramsStatistics{
|
||||
ULONG VideoFrames;
|
||||
ULONG AudioFrames;
|
||||
ULONG FramesLost;
|
||||
ULONG QueueOverflow;
|
||||
ULONG CurBps;
|
||||
}FRAMES_STATISTICS, *PFRAMES_STATISTICS;
|
||||
|
||||
DLLEXPORT_API int __stdcall InitDSPs();
|
||||
DLLEXPORT_API int __stdcall DeInitDSPs();
|
||||
DLLEXPORT_API HANDLE __stdcall ChannelOpen(int ChannelNum);
|
||||
DLLEXPORT_API int __stdcall ChannelClose(HANDLE hChannelHandle);
|
||||
DLLEXPORT_API int __stdcall GetTotalChannels();
|
||||
DLLEXPORT_API int __stdcall GetTotalDSPs();
|
||||
DLLEXPORT_API int __stdcall StartVideoPreview(HANDLE hChannelHandle,HWND WndHandle, RECT *rect, BOOLEAN bOverlay, int VideoFormat, int FrameRate);
|
||||
DLLEXPORT_API int __stdcall StopVideoPreview(HANDLE hChannelHandle);
|
||||
DLLEXPORT_API int __stdcall SetVideoPara(HANDLE hChannelHandle, int Brightness, int Contrast, int Saturation, int Hue);
|
||||
DLLEXPORT_API int __stdcall GetVideoPara(HANDLE hChannelHandle, VideoStandard_t *VideoStandard, int *Brightness, int *Contrast, int *Saturation, int *Hue);
|
||||
DLLEXPORT_API int __stdcall GetVideoSignal(HANDLE hChannelHandle);
|
||||
DLLEXPORT_API int __stdcall GetSDKVersion(PVERSION_INFO VersionInfo);
|
||||
DLLEXPORT_API int __stdcall GetCapability(HANDLE hChannelHandle, CHANNEL_CAPABILITY *Capability);
|
||||
DLLEXPORT_API int __stdcall GetLastErrorNum(HANDLE hChannelHandle, ULONG *DspError, ULONG *SdkError);
|
||||
DLLEXPORT_API int __stdcall SetStreamType(HANDLE hChannelHandle, USHORT Type);
|
||||
DLLEXPORT_API int __stdcall GetStreamType(HANDLE hChannelHandle, USHORT *StreamType);
|
||||
DLLEXPORT_API int __stdcall GetFramesStatistics(HANDLE hChannelHandle, PFRAMES_STATISTICS framesStatistics);
|
||||
DLLEXPORT_API int __stdcall StartMotionDetection(HANDLE hChannelHandle);
|
||||
DLLEXPORT_API int __stdcall GetBoardInfo(HANDLE hChannelHandle, ULONG *BoardType, UCHAR *SerialNo);
|
||||
DLLEXPORT_API int __stdcall StopMotionDetection(HANDLE hChannelHandle);
|
||||
DLLEXPORT_API int __stdcall GetOriginalImage(HANDLE hChannelHandle, UCHAR *ImageBuf, ULONG *Size);
|
||||
DLLEXPORT_API int __stdcall RegisterLogRecordCallback(LOGRECORD_CALLBACK LogRecordFunc, void *Context);
|
||||
DLLEXPORT_API int __stdcall SetAudioPreview(HANDLE hChannelHandle, BOOL bEnable);
|
||||
DLLEXPORT_API int __stdcall ReadStreamData(HANDLE hChannelHandle, void *DataBuf, DWORD *Length, int *FrameType);
|
||||
DLLEXPORT_API int __stdcall RegisterMessageNotifyHandle(HWND hWnd, UINT MessageId);
|
||||
DLLEXPORT_API int __stdcall StartVideoCapture(HANDLE hChannelHandle);
|
||||
DLLEXPORT_API int __stdcall StopVideoCapture(HANDLE hChannelHandle);
|
||||
DLLEXPORT_API int __stdcall SetIBPMode(HANDLE hChannelHandle, int KeyFrameIntervals, int BFrames, int PFrames, int FrameRate);
|
||||
DLLEXPORT_API int __stdcall SetDefaultQuant(HANDLE hChannelHandle, int IQuantVal, int PQuantVal, int BQuantVal);
|
||||
DLLEXPORT_API int __stdcall SetOsd(HANDLE hChannelHandle, BOOL Enable);
|
||||
|
||||
DLLEXPORT_API int __stdcall SetLogo(HANDLE hChannelHandle, int x, int y, int w, int h, unsigned char *yuv);
|
||||
DLLEXPORT_API int __stdcall StopLogo(HANDLE hChannelHandle);
|
||||
DLLEXPORT_API int __stdcall SetupMotionDetection(HANDLE hChannelHandle, RECT *RectList, int iAreas);
|
||||
DLLEXPORT_API int __stdcall MotionAnalyzer(HANDLE hChannelHandle, char *MotionData, int iThreshold, int *iResult);
|
||||
DLLEXPORT_API int __stdcall LoadYUVFromBmpFile(char *FileName, unsigned char *yuv, int BufLen, int *Width, int *Height);
|
||||
DLLEXPORT_API int __stdcall SaveYUVToBmpFile(char *FileName, unsigned char *yuv, int Width, int Height);
|
||||
DLLEXPORT_API int __stdcall CaptureIFrame(HANDLE hChannelHandle);
|
||||
DLLEXPORT_API int __stdcall RegisterStreamReadCallback(STREAM_READ_CALLBACK StreamReadCallback, void *Context);
|
||||
DLLEXPORT_API int __stdcall AdjustMotionDetectPrecision(HANDLE hChannelHandle,
|
||||
int iGrade, int iFastMotionDetectFps,
|
||||
int iSlowMotionDetectFps);
|
||||
DLLEXPORT_API int __stdcall SetupBitrateControl(HANDLE hChannelHandle, ULONG MaxBps);
|
||||
DLLEXPORT_API int __stdcall SetOverlayColorKey(COLORREF DestColorKey);
|
||||
DLLEXPORT_API int __stdcall SetOsdDisplayMode(HANDLE hChannelHandle, int Brightness, BOOL Translucent, int parameter, USHORT *Format1, USHORT *Format2);
|
||||
DLLEXPORT_API int __stdcall SetLogoDisplayMode(HANDLE hChannelHandle, COLORREF ColorKey, BOOL Translucent, int TwinkleInterval);
|
||||
DLLEXPORT_API int __stdcall SetEncoderPictureFormat(HANDLE hChannelHandle, PictureFormat_t PictureFormat);
|
||||
DLLEXPORT_API int __stdcall SetVideoStandard(HANDLE hChannelHandle, VideoStandard_t VideoStandard);
|
||||
DLLEXPORT_API int __stdcall RestoreOverlay();
|
||||
DLLEXPORT_API int __stdcall ResetDSP(int DspNumber);
|
||||
DLLEXPORT_API int __stdcall GetSoundLevel(HANDLE hChannelHandle);
|
||||
|
||||
|
||||
DLLEXPORT_API int __stdcall SetBitrateControlMode(HANDLE hChannelHandle, BitrateControlType_t brc);
|
||||
DLLEXPORT_API int __stdcall SetupNotifyThreshold(HANDLE hChannelHandle, int iFramesThreshold);
|
||||
|
||||
DLLEXPORT_API int __stdcall SetupSubChannel(HANDLE hChannelHandle, int iSubChannel);
|
||||
DLLEXPORT_API int __stdcall GetSubChannelStreamType(void *DataBuf, int FrameType);
|
||||
//add for HC/HF
|
||||
DLLEXPORT_API int __stdcall RegisterStreamDirectReadCallback(STREAM_DIRECT_READ_CALLBACK StreamDirectReadCallback,void *Context);
|
||||
DLLEXPORT_API int __stdcall RegisterDrawFun(DWORD nport, DRAWFUN(DrawFun),LONG nUser);
|
||||
DLLEXPORT_API int __stdcall SetupMask(HANDLE hChannelHandle, RECT *rectList, int iAreas);
|
||||
DLLEXPORT_API int __stdcall StopMask(HANDLE hChannelHandle);
|
||||
DLLEXPORT_API int __stdcall SetSubEncoderPictureFormat(HANDLE hChannelHandle, PictureFormat_t PictureFormat);
|
||||
DLLEXPORT_API int __stdcall StartSubVideoCapture(HANDLE hChannelHandle);
|
||||
DLLEXPORT_API int __stdcall StopSubVideoCapture(HANDLE hChannelHandle);
|
||||
DLLEXPORT_API int __stdcall SetupDateTime(HANDLE hChannelHandle, SYSTEMTIME *now);
|
||||
/*
|
||||
以下为1.7版本新增的功能。
|
||||
以后可能会根据用户的反馈进行修改和完善。
|
||||
*/
|
||||
//原始图像流设置
|
||||
typedef void (*IMAGE_STREAM_CALLBACK)(UINT channelNumber,void *context );
|
||||
DLLEXPORT_API int __stdcall SetImageStream(HANDLE hChannel,BOOL bStart,UINT fps,UINT width,UINT height,unsigned char *imageBuffer);
|
||||
DLLEXPORT_API int __stdcall RegisterImageStreamCallback(IMAGE_STREAM_CALLBACK,void *context);
|
||||
/*
|
||||
设置视频输入位置:
|
||||
(x,y)为系统所处理图像的左上角在摄像机输入的原始图像中的坐标。
|
||||
x必须为2的整数倍。
|
||||
(x,y)坐标的参数范围和摄像机的型号有关,如果指定的值和摄像机的输入不匹配,
|
||||
可能会导致图像静止或水平、垂直方向滚动。
|
||||
*/
|
||||
DLLEXPORT_API int __stdcall SetInputVideoPosition(HANDLE hChannel,UINT x,UINT y);
|
||||
DLLEXPORT_API int __stdcall StopRegisterDrawFun(DWORD nport);
|
||||
|
||||
/*
|
||||
3.0
|
||||
*/
|
||||
#define SERIAL_NUMBER_LENGTH 12 //板卡序列号长度
|
||||
typedef struct tagDS_BOARD_DETAIL
|
||||
{
|
||||
BOARD_TYPE_DS type; //板卡类型
|
||||
BYTE sn[16]; //序列号
|
||||
UINT dspCount; //板卡包含的DSP个数
|
||||
UINT firstDspIndex; //板卡上第一个DSP的索引
|
||||
UINT encodeChannelCount; //板卡包含的编码通道个数
|
||||
UINT firstEncodeChannelIndex; //板卡上第一个编码通道的索引
|
||||
UINT decodeChannelCount; //板卡包含的解码通道个数
|
||||
UINT firstDecodeChannelIndex; //板卡上第一个解码通道的索引
|
||||
UINT displayChannelCount; //板卡包含的视频输出通道个数
|
||||
UINT firstDisplayChannelIndex; //板卡上第一个视频输出通道的索引
|
||||
UINT reserved1;
|
||||
UINT reserved2;
|
||||
UINT reserved3;
|
||||
UINT reserved4;
|
||||
}DS_BOARD_DETAIL;
|
||||
typedef struct tagDSP_DETAIL
|
||||
{
|
||||
UINT encodeChannelCount; //板卡包含的编码通道个数
|
||||
UINT firstEncodeChannelIndex; //板卡上第一个编码通道的索引
|
||||
UINT decodeChannelCount; //板卡包含的解码通道个数
|
||||
UINT firstDecodeChannelIndex; //板卡上第一个解码通道的索引
|
||||
UINT displayChannelCount; //板卡包含的视频输出通道个数
|
||||
UINT firstDisplayChannelIndex; //板卡上第一个视频输出通道的索引
|
||||
UINT reserved1;
|
||||
UINT reserved2;
|
||||
UINT reserved3;
|
||||
UINT reserved4;
|
||||
}DSP_DETAIL;
|
||||
DLLEXPORT_API unsigned int __stdcall GetBoardCount();
|
||||
DLLEXPORT_API int __stdcall GetBoardDetail(UINT boardNum,DS_BOARD_DETAIL *pBoardDetail);
|
||||
DLLEXPORT_API unsigned int __stdcall GetDspCount();
|
||||
DLLEXPORT_API int __stdcall GetDspDetail(UINT dspNum,DSP_DETAIL *pDspDetail);
|
||||
DLLEXPORT_API unsigned int __stdcall GetEncodeChannelCount();
|
||||
DLLEXPORT_API unsigned int __stdcall GetDecodeChannelCount();
|
||||
DLLEXPORT_API unsigned int __stdcall GetDisplayChannelCount();
|
||||
DLLEXPORT_API int __stdcall SetDefaultVideoStandard(VideoStandard_t VideoStandard);
|
||||
DLLEXPORT_API int __stdcall SetVideoDetectPrecision(HANDLE hChannel,unsigned int value);
|
||||
DLLEXPORT_API int __stdcall SetSubStreamType(HANDLE hChannelHandle, USHORT Type);
|
||||
DLLEXPORT_API int __stdcall GetSubStreamType(HANDLE hChannelHandle, USHORT *StreamType);
|
||||
|
||||
#define MAX_DISPLAY_REGION 16
|
||||
typedef struct tagREGION_PARAM
|
||||
{
|
||||
UINT left;
|
||||
UINT top;
|
||||
UINT width;
|
||||
UINT height;
|
||||
COLORREF color;
|
||||
UINT param;
|
||||
}REGION_PARAM;
|
||||
DLLEXPORT_API int __stdcall SetDisplayStandard(UINT nDisplayChannel,VideoStandard_t VideoStandard);
|
||||
DLLEXPORT_API int __stdcall SetDisplayRegion(UINT nDisplayChannel,UINT nRegionCount,REGION_PARAM *pParam,UINT nReserved);
|
||||
DLLEXPORT_API int __stdcall ClearDisplayRegion(UINT nDisplayChannel,UINT nRegionFlag);
|
||||
DLLEXPORT_API int __stdcall SetDisplayRegionPosition(UINT nDisplayChannel,UINT nRegion,UINT nLeft,UINT nTop);
|
||||
DLLEXPORT_API int __stdcall FillDisplayRegion(UINT nDisplayChannel,UINT nRegion,unsigned char *pImage);
|
||||
DLLEXPORT_API int __stdcall SetEncoderVideoExtOutput(UINT nEncodeChannel,UINT nPort,BOOL bOpen,UINT nDisplayChannel,UINT nDisplayRegion,UINT nReserved);
|
||||
DLLEXPORT_API int __stdcall SetDecoderVideoExtOutput(UINT nDecodeChannel,UINT nPort,BOOL bOpen,UINT nDisplayChannel,UINT nDisplayRegion,UINT nReserved);
|
||||
DLLEXPORT_API int __stdcall SetDecoderVideoOutput(UINT nDecodeChannel,UINT nPort,BOOL bOpen,UINT nDisplayChannel,UINT nDisplayRegion,UINT nReserved);
|
||||
DLLEXPORT_API int __stdcall SetDecoderAudioOutput(UINT nDecodeChannel,BOOL bOpen,UINT nOutputChannel);
|
||||
//3.1
|
||||
DLLEXPORT_API int __stdcall SetDeInterlace(HANDLE hChannelHandle,UINT mode,UINT level);
|
||||
DLLEXPORT_API int __stdcall SetPreviewOverlayMode(BOOL bTrue);
|
||||
|
||||
//DECODE functions for DS4002MD
|
||||
#if defined( _WINDLL)
|
||||
#define PLAYER_API extern "C"__declspec(dllexport)
|
||||
#else
|
||||
#define PLAYER_API extern "C" __declspec(dllimport)
|
||||
#endif
|
||||
typedef struct tagDISPLAY_PARA
|
||||
{
|
||||
long bToScreen;
|
||||
long bToVideoOut;
|
||||
long nLeft;
|
||||
long nTop;
|
||||
long nWidth;
|
||||
long nHeight;
|
||||
long nReserved;
|
||||
}DISPLAY_PARA,*PDISPLAY_PARA;
|
||||
//Version info
|
||||
typedef struct tagVERSION{
|
||||
ULONG DspVersion, DspBuildNum;
|
||||
ULONG DriverVersion, DriverBuildNum;
|
||||
ULONG SDKVersion, SDKBuildNum;
|
||||
}HW_VERSION, *PHW_VERSION;
|
||||
|
||||
//init part
|
||||
PLAYER_API int __stdcall HW_InitDirectDraw(HWND hParent,COLORREF colorKey);
|
||||
PLAYER_API int __stdcall HW_ReleaseDirectDraw();
|
||||
PLAYER_API int __stdcall HW_InitDecDevice(long *pDeviceTotal);
|
||||
PLAYER_API int __stdcall HW_ReleaseDecDevice();
|
||||
PLAYER_API int __stdcall HW_ChannelOpen(long nChannelNum,HANDLE* phChannel);
|
||||
PLAYER_API int __stdcall HW_ChannelClose(HANDLE hChannel);
|
||||
//open part
|
||||
|
||||
PLAYER_API int __stdcall HW_OpenStream(HANDLE hChannel,PBYTE pFileHeadBuf,DWORD nSize);
|
||||
DLLEXPORT_API int __stdcall HW_ResetStream(HANDLE hChannel);
|
||||
PLAYER_API int __stdcall HW_CloseStream(HANDLE hChannel);
|
||||
PLAYER_API int __stdcall HW_InputData(HANDLE hChannel,PBYTE pBuf,DWORD nSize);
|
||||
PLAYER_API int __stdcall HW_OpenFile(HANDLE hChannel,LPTSTR sFileName);
|
||||
PLAYER_API int __stdcall HW_CloseFile(HANDLE hChannel);
|
||||
|
||||
//play part
|
||||
PLAYER_API int __stdcall HW_SetDisplayPara(HANDLE hChannel,DISPLAY_PARA *pPara);
|
||||
PLAYER_API int __stdcall HW_Play(HANDLE hChannel);
|
||||
PLAYER_API int __stdcall HW_Stop(HANDLE hChannel);
|
||||
PLAYER_API int __stdcall HW_Pause(HANDLE hChannel,ULONG bPause);
|
||||
|
||||
//sound part
|
||||
PLAYER_API int __stdcall HW_PlaySound(HANDLE hChannel);
|
||||
PLAYER_API int __stdcall HW_StopSound(HANDLE hChannel);
|
||||
PLAYER_API int __stdcall HW_SetVolume(HANDLE hChannel,ULONG nVolume);
|
||||
//overlay part
|
||||
PLAYER_API int __stdcall HW_RefreshSurface();
|
||||
PLAYER_API int __stdcall HW_RestoreSurface();
|
||||
PLAYER_API int __stdcall HW_ClearSurface();
|
||||
PLAYER_API int __stdcall HW_ZoomOverlay(RECT* pSrcClientRect, RECT* pDecScreenRect);
|
||||
//cut file
|
||||
PLAYER_API int __stdcall HW_StartCapFile(HANDLE hChannel,LPTSTR sFileName);
|
||||
PLAYER_API int __stdcall HW_StopCapFile(HANDLE hChannel);
|
||||
//capture picture
|
||||
PLAYER_API int __stdcall HW_GetYV12Image(HANDLE hChannel, PBYTE pBuffer, ULONG nSize);
|
||||
PLAYER_API int __stdcall HW_GetPictureSize(HANDLE hChannel,ULONG* pWidth, ULONG* pHeight);
|
||||
PLAYER_API int __stdcall HW_ConvertToBmpFile(BYTE * pBuf,ULONG nSize,ULONG nWidth,ULONG nHeight,char *sFileName,ULONG nReserved);
|
||||
//setting and getting part
|
||||
PLAYER_API int __stdcall HW_Jump(HANDLE hChannel,ULONG nDirection);
|
||||
PLAYER_API int __stdcall HW_SetJumpInterval(HANDLE hChannel,ULONG nSecond);
|
||||
PLAYER_API int __stdcall HW_GetSpeed(HANDLE hChannel,long *pSpeed);
|
||||
PLAYER_API int __stdcall HW_SetSpeed(HANDLE hChannel,long nSpeed);
|
||||
PLAYER_API int __stdcall HW_SetPlayPos(HANDLE hChannel,ULONG nPos);
|
||||
PLAYER_API int __stdcall HW_GetPlayPos(HANDLE hChannel,ULONG* pPos);
|
||||
PLAYER_API int __stdcall HW_GetVersion(PHW_VERSION pVersion);
|
||||
PLAYER_API int __stdcall HW_GetCurrentFrameRate(HANDLE hChannel,ULONG* pFrameRate);
|
||||
PLAYER_API int __stdcall HW_GetCurrentFrameNum(HANDLE hChannel,ULONG* pFrameNum);
|
||||
PLAYER_API int __stdcall HW_GetFileTotalFrames(HANDLE hChannel,ULONG* pTotalFrames);
|
||||
PLAYER_API int __stdcall HW_GetFileTime(HANDLE hChannel, ULONG* pFileTime);
|
||||
PLAYER_API int __stdcall HW_GetCurrentFrameTime(HANDLE hChannel,ULONG* pFrameTime);
|
||||
PLAYER_API int __stdcall HW_GetPlayedFrames(HANDLE hChannel,ULONG *pDecVFrames);
|
||||
PLAYER_API int __stdcall HW_GetDeviceSerialNo(HANDLE hChannel,ULONG *pDeviceSerialNo);
|
||||
PLAYER_API int __stdcall HW_SetFileEndMsg(HANDLE hChannel,HWND hWnd,UINT nMsg);
|
||||
PLAYER_API int __stdcall HW_SetStreamOpenMode(HANDLE hChannel,ULONG nMode);
|
||||
PLAYER_API int __stdcall HW_GetStreamOpenMode(HANDLE hChannel,ULONG *pMode);
|
||||
PLAYER_API int __stdcall HW_SetVideoOutStandard(HANDLE hChannel,ULONG nStandard);
|
||||
PLAYER_API int __stdcall HW_SetDspDeadlockMsg(HWND hWnd,UINT nMsg);
|
||||
PLAYER_API int __stdcall HW_GetChannelNum(long nDspNum,long *pChannelNum,ULONG nNumsToGet,ULONG * pNumsGotten);
|
||||
PLAYER_API int __stdcall HW_ResetDsp(long nDspNum);
|
||||
PLAYER_API int __stdcall HW_SetAudioPreview(HANDLE hChannel, BOOL bEnable);
|
||||
//////////////////////////////////////////////
|
||||
|
||||
PLAYER_API int __stdcall HW_OpenStreamEx(HANDLE hChannel,PBYTE pFileHeadBuf,DWORD nSize);
|
||||
PLAYER_API int __stdcall HW_CloseStreamEx(HANDLE hChannel);
|
||||
PLAYER_API int __stdcall HW_InputVideoData(HANDLE hChannel,PBYTE pBuf,DWORD nSize);
|
||||
PLAYER_API int __stdcall HW_InputAudioData(HANDLE hChannel,PBYTE pBuf,DWORD nSize);
|
||||
|
||||
//4.0
|
||||
PLAYER_API int __stdcall SetOsdDisplayModeEx(HANDLE hChannelHandle,int color,BOOL Translucent,int param,int nLineCount,USHORT **Format);
|
||||
typedef void (*MOTION_DETECTION_CALLBACK)(ULONG channelNumber,BOOL bMotionDetected,void *context);
|
||||
PLAYER_API int __stdcall SetupMotionDetectionEx(HANDLE hChannelHandle,int iGrade,int iFastMotionDetectFps,
|
||||
int iSlowMotionDetectFps,UINT delay,RECT *RectList, int iAreas,
|
||||
MOTION_DETECTION_CALLBACK MotionDetectionCallback,int reserved);
|
||||
PLAYER_API int __stdcall GetJpegImage(HANDLE hChannelHandle,UCHAR *ImageBuf,ULONG *Size,UINT nQuality);
|
||||
//WatchDog
|
||||
PLAYER_API int __stdcall SetWatchDog(UINT boardNumber,BOOL bEnable);
|
||||
//4.1
|
||||
typedef void (*FILE_REF_DONE_CALLBACK)(UINT nChannel,UINT nSize);
|
||||
PLAYER_API int __stdcall HW_SetFileRef(HANDLE hChannel,BOOL bEnable,FILE_REF_DONE_CALLBACK FileRefDoneCallback);
|
||||
PLAYER_API int __stdcall HW_LocateByAbsoluteTime(HANDLE hChannel,SYSTEMTIME time);
|
||||
PLAYER_API int __stdcall HW_LocateByFrameNumber(HANDLE hChannel,UINT frmNum);
|
||||
PLAYER_API int __stdcall HW_GetCurrentAbsoluteTime(HANDLE hChannel,SYSTEMTIME *pTime);
|
||||
PLAYER_API int __stdcall HW_GetFileAbsoluteTime(HANDLE hChannel,SYSTEMTIME *pStartTime,SYSTEMTIME *pEndTime);
|
||||
//4.2
|
||||
DLLEXPORT_API int __stdcall HW_ImportFileRef(HANDLE hChannel,char *pBuffer,UINT nSize);
|
||||
DLLEXPORT_API int __stdcall HW_ExportFileRef(HANDLE hChannel,char *pBuffer,UINT nSize);
|
||||
DLLEXPORT_API int __stdcall SetDisplayVideoCapture(UINT nDisplayChannel,BOOL bStart,UINT fps,UINT width,UINT height,unsigned char *imageBuffer);
|
||||
DLLEXPORT_API int __stdcall RegisterDisplayVideoCaptureCallback(IMAGE_STREAM_CALLBACK DisplayVideoCaptureCallback,void *context);
|
||||
DLLEXPORT_API int __stdcall SetDisplayVideoBrightness(UINT chan,int Brightness);
|
||||
DLLEXPORT_API int __stdcall SetChannelStreamCRC(HANDLE hChannel,BOOL bEnable);
|
||||
DLLEXPORT_API int __stdcall SetSubChannelStreamCRC(HANDLE hChannel,BOOL bEnable);
|
||||
DLLEXPORT_API int __stdcall HW_SetDecoderPostProcess(HANDLE hChannel,UINT param);
|
||||
//
|
||||
typedef void (*DECODER_VIDEO_CAPTURE_CALLBACK)(UINT nChannelNumber,void *DataBuf,UINT width,UINT height,UINT nFrameNum,UINT nFrameTime,SYSTEMTIME *pFrameAbsoluteTime,void *context);
|
||||
DLLEXPORT_API int __stdcall RegisterDecoderVideoCaptureCallback(DECODER_VIDEO_CAPTURE_CALLBACK DecoderVideoCaptureCallback,void *context);
|
||||
DLLEXPORT_API int __stdcall HW_SetDecoderVideoCapture(HANDLE hChannel,BOOL bStart,UINT param);
|
||||
DLLEXPORT_API int __stdcall HW_InputDataByFrame(HANDLE hChannel,PBYTE pBuf,DWORD nSize);
|
||||
/*
|
||||
人脸检测接口:仅供测试、评估,以后可能会做修改。
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
short x,y,width,height;
|
||||
}FACE_AREA_DEMO;
|
||||
typedef struct
|
||||
{
|
||||
FACE_AREA_DEMO faceArea;
|
||||
FACE_AREA_DEMO leftEyeArea;
|
||||
FACE_AREA_DEMO rightEyeArea;
|
||||
FACE_AREA_DEMO leftPupilArea;
|
||||
FACE_AREA_DEMO rightPupilArea;
|
||||
FACE_AREA_DEMO noseArea;
|
||||
FACE_AREA_DEMO mouthArea;
|
||||
}FACE_INFO_DEMO;
|
||||
typedef void (*FACE_DETECTION_DEMO_CALLBACK)(UINT nChannel,UINT nFaceCount,FACE_INFO_DEMO *pFaceInfo,
|
||||
char *pData,UINT nDataSize,UINT nImageWidth,UINT nImageHeight);
|
||||
|
||||
DLLEXPORT_API int __stdcall SetFaceDetectionDemo(HANDLE hChannelHandle,BOOL bEnable,
|
||||
UINT nFrameInterval,FACE_DETECTION_DEMO_CALLBACK pFunc,
|
||||
BOOL bCompress,UINT nCompressQuality,BOOL bLocateEyePos);
|
||||
|
||||
#endif
|
||||
|
52625
CommonCamera/include/hikvision/HCNetSDK.h
Normal file
52625
CommonCamera/include/hikvision/HCNetSDK.h
Normal file
File diff suppressed because it is too large
Load Diff
760
CommonCamera/include/hikvision/plaympeg4.h
Normal file
760
CommonCamera/include/hikvision/plaympeg4.h
Normal file
@ -0,0 +1,760 @@
|
||||
#ifndef _PLAYM4_H_
|
||||
#define _PLAYM4_H_
|
||||
|
||||
#if defined( _WINDLL)
|
||||
#define PLAYM4_API extern "C" __declspec(dllexport)
|
||||
#else
|
||||
#define PLAYM4_API extern "C" __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
//Max channel numbers
|
||||
#define PLAYM4_MAX_SUPPORTS 500
|
||||
//Wave coef range;
|
||||
#define MIN_WAVE_COEF -100
|
||||
#define MAX_WAVE_COEF 100
|
||||
|
||||
//Timer type
|
||||
#define TIMER_1 1 //Only 16 timers for every process.Default TIMER;
|
||||
#define TIMER_2 2 //Not limit;But the precision less than TIMER_1;
|
||||
|
||||
//BUFFER AND DATA TYPE
|
||||
#define BUF_VIDEO_SRC (1) //mixed input,total src buffer size;splited input,video src buffer size
|
||||
#define BUF_AUDIO_SRC (2) //mixed input,not defined;splited input,audio src buffer size
|
||||
#define BUF_VIDEO_RENDER (3) //video render node count
|
||||
#define BUF_AUDIO_RENDER (4) //audio render node count
|
||||
#define BUF_VIDEO_DECODED (5) //video decoded node count to render
|
||||
#define BUF_AUDIO_DECODED (6) //audio decoded node count to render
|
||||
#define BUF_DISPLAY_NODE (7) //display node
|
||||
|
||||
//Error code
|
||||
#define PLAYM4_NOERROR 0 //no error
|
||||
#define PLAYM4_PARA_OVER 1 //input parameter is invalid;
|
||||
#define PLAYM4_ORDER_ERROR 2 //The order of the function to be called is error.
|
||||
#define PLAYM4_TIMER_ERROR 3 //Create multimedia clock failed;
|
||||
#define PLAYM4_DEC_VIDEO_ERROR 4 //Decode video data failed.
|
||||
#define PLAYM4_DEC_AUDIO_ERROR 5 //Decode audio data failed.
|
||||
#define PLAYM4_ALLOC_MEMORY_ERROR 6 //Allocate memory failed.
|
||||
#define PLAYM4_OPEN_FILE_ERROR 7 //Open the file failed.
|
||||
#define PLAYM4_CREATE_OBJ_ERROR 8 //Create thread or event failed
|
||||
#define PLAYM4_CREATE_DDRAW_ERROR 9 //Create DirectDraw object failed.
|
||||
#define PLAYM4_CREATE_OFFSCREEN_ERROR 10 //failed when creating off-screen surface.
|
||||
#define PLAYM4_BUF_OVER 11 //buffer is overflow
|
||||
#define PLAYM4_CREATE_SOUND_ERROR 12 //failed when creating audio device.
|
||||
#define PLAYM4_SET_VOLUME_ERROR 13 //Set volume failed
|
||||
#define PLAYM4_SUPPORT_FILE_ONLY 14 //The function only support play file.
|
||||
#define PLAYM4_SUPPORT_STREAM_ONLY 15 //The function only support play stream.
|
||||
#define PLAYM4_SYS_NOT_SUPPORT 16 //System not support.
|
||||
#define PLAYM4_FILEHEADER_UNKNOWN 17 //No file header.
|
||||
#define PLAYM4_VERSION_INCORRECT 18 //The version of decoder and encoder is not adapted.
|
||||
#define PLAYM4_INIT_DECODER_ERROR 19 //Initialize decoder failed.
|
||||
#define PLAYM4_CHECK_FILE_ERROR 20 //The file data is unknown.
|
||||
#define PLAYM4_INIT_TIMER_ERROR 21 //Initialize multimedia clock failed.
|
||||
#define PLAYM4_BLT_ERROR 22 //Blt failed.
|
||||
#define PLAYM4_UPDATE_ERROR 23 //Update failed.
|
||||
#define PLAYM4_OPEN_FILE_ERROR_MULTI 24 //openfile error, streamtype is multi
|
||||
#define PLAYM4_OPEN_FILE_ERROR_VIDEO 25 //openfile error, streamtype is video
|
||||
#define PLAYM4_JPEG_COMPRESS_ERROR 26 //JPEG compress error
|
||||
#define PLAYM4_EXTRACT_NOT_SUPPORT 27 //Don't support the version of this file.
|
||||
#define PLAYM4_EXTRACT_DATA_ERROR 28 //extract video data failed.
|
||||
#define PLAYM4_SECRET_KEY_ERROR 29 //Secret key is error //add 20071218
|
||||
#define PLAYM4_DECODE_KEYFRAME_ERROR 30 //add by hy 20090318
|
||||
#define PLAYM4_NEED_MORE_DATA 31 //add by hy 20100617
|
||||
#define PLAYM4_INVALID_PORT 32 //add by cj 20100913
|
||||
#define PLAYM4_NOT_FIND 33 //add by cj 20110428
|
||||
#define PLAYM4_NEED_LARGER_BUFFER 34 //add by pzj 20130528
|
||||
#define PLAYM4_FAIL_UNKNOWN 99 //Fail, but the reason is unknown;
|
||||
|
||||
//鱼眼功能错误码
|
||||
#define PLAYM4_FEC_ERR_ENABLEFAIL 100 // 鱼眼模块加载失败
|
||||
#define PLAYM4_FEC_ERR_NOTENABLE 101 // 鱼眼模块没有加载
|
||||
#define PLAYM4_FEC_ERR_NOSUBPORT 102 // 子端口没有分配
|
||||
#define PLAYM4_FEC_ERR_PARAMNOTINIT 103 // 没有初始化对应端口的参数
|
||||
#define PLAYM4_FEC_ERR_SUBPORTOVER 104 // 子端口已经用完
|
||||
#define PLAYM4_FEC_ERR_EFFECTNOTSUPPORT 105 // 该安装方式下这种效果不支持
|
||||
#define PLAYM4_FEC_ERR_INVALIDWND 106 // 非法的窗口
|
||||
#define PLAYM4_FEC_ERR_PTZOVERFLOW 107 // PTZ位置越界
|
||||
#define PLAYM4_FEC_ERR_RADIUSINVALID 108 // 圆心参数非法
|
||||
#define PLAYM4_FEC_ERR_UPDATENOTSUPPORT 109 // 指定的安装方式和矫正效果,该参数更新不支持
|
||||
#define PLAYM4_FEC_ERR_NOPLAYPORT 110 // 播放库端口没有启用
|
||||
#define PLAYM4_FEC_ERR_PARAMVALID 111 // 参数为空
|
||||
#define PLAYM4_FEC_ERR_INVALIDPORT 112 // 非法子端口
|
||||
#define PLAYM4_FEC_ERR_PTZZOOMOVER 113 // PTZ矫正范围越界
|
||||
#define PLAYM4_FEC_ERR_OVERMAXPORT 114 // 矫正通道饱和,最大支持的矫正通道为四个
|
||||
#define PLAYM4_FEC_ERR_ENABLED 115 //该端口已经启用了鱼眼模块
|
||||
#define PLAYM4_FEC_ERR_D3DACCENOTENABLE 116 // D3D加速没有开启
|
||||
|
||||
|
||||
//Max display regions.
|
||||
#define MAX_DISPLAY_WND 4
|
||||
|
||||
//Display type
|
||||
#define DISPLAY_NORMAL 0x00000001
|
||||
#define DISPLAY_QUARTER 0x00000002
|
||||
#define DISPLAY_YC_SCALE 0x00000004 //add by gb 20091116
|
||||
#define DISPLAY_NOTEARING 0x00000008
|
||||
//Display buffers
|
||||
#define MAX_DIS_FRAMES 50
|
||||
#define MIN_DIS_FRAMES 1
|
||||
|
||||
//Locate by
|
||||
#define BY_FRAMENUM 1
|
||||
#define BY_FRAMETIME 2
|
||||
|
||||
//Source buffer
|
||||
#define SOURCE_BUF_MAX 1024*100000
|
||||
#define SOURCE_BUF_MIN 1024*50
|
||||
|
||||
//Stream type
|
||||
#define STREAME_REALTIME 0
|
||||
#define STREAME_FILE 1
|
||||
|
||||
//frame type
|
||||
#define T_AUDIO16 101
|
||||
#define T_AUDIO8 100
|
||||
#define T_UYVY 1
|
||||
#define T_YV12 3
|
||||
#define T_RGB32 7
|
||||
|
||||
//capability
|
||||
#define SUPPORT_DDRAW 1
|
||||
#define SUPPORT_BLT 2
|
||||
#define SUPPORT_BLTFOURCC 4
|
||||
#define SUPPORT_BLTSHRINKX 8
|
||||
#define SUPPORT_BLTSHRINKY 16
|
||||
#define SUPPORT_BLTSTRETCHX 32
|
||||
#define SUPPORT_BLTSTRETCHY 64
|
||||
#define SUPPORT_SSE 128
|
||||
#define SUPPORT_MMX 256
|
||||
|
||||
// 以下宏定义用于HIK_MEDIAINFO结构
|
||||
#define FOURCC_HKMI 0x484B4D49 // "HKMI" HIK_MEDIAINFO结构标记
|
||||
// 系统封装格式
|
||||
#define SYSTEM_NULL 0x0 // 没有系统层,纯音频流或视频流
|
||||
#define SYSTEM_HIK 0x1 // 海康文件层
|
||||
#define SYSTEM_MPEG2_PS 0x2 // PS封装
|
||||
#define SYSTEM_MPEG2_TS 0x3 // TS封装
|
||||
#define SYSTEM_RTP 0x4 // rtp封装
|
||||
#define SYSTEM_RTPHIK 0x401 // rtp封装
|
||||
|
||||
// 视频编码类型
|
||||
#define VIDEO_NULL 0x0 // 没有视频
|
||||
#define VIDEO_H264 0x1 // 海康H.264
|
||||
#define VIDEO_MPEG4 0x3 // 标准MPEG4
|
||||
#define VIDEO_MJPEG 0x4
|
||||
#define VIDEO_AVC264 0x0100
|
||||
|
||||
// 音频编码类型
|
||||
#define AUDIO_NULL 0x0000 // 没有音频
|
||||
#define AUDIO_ADPCM 0x1000 // ADPCM
|
||||
#define AUDIO_MPEG 0x2000 // MPEG 系列音频,解码器能自适应各种MPEG音频
|
||||
#define AUDIO_AAC 0X2001 // AAC 编码
|
||||
// G系列音频
|
||||
#define AUDIO_RAW_DATA8 0x7000 //采样率为8k的原始数据
|
||||
#define AUDIO_RAW_UDATA16 0x7001 //采样率为16k的原始数据,即L16
|
||||
#define AUDIO_G711_U 0x7110
|
||||
#define AUDIO_G711_A 0x7111
|
||||
#define AUDIO_G722_1 0x7221
|
||||
#define AUDIO_G723_1 0x7231
|
||||
#define AUDIO_G726_U 0x7260
|
||||
#define AUDIO_G726_A 0x7261
|
||||
#define AUDIO_G726_16 0x7262
|
||||
#define AUDIO_G729 0x7290
|
||||
#define AUDIO_AMR_NB 0x3000
|
||||
|
||||
#define SYNCDATA_VEH 1 //同步数据:车载信息
|
||||
#define SYNCDATA_IVS 2 //同步数据:智能信息
|
||||
|
||||
//motion flow type
|
||||
#define MOTION_FLOW_NONE 0
|
||||
#define MOTION_FLOW_CPU 1
|
||||
#define MOTION_FLOW_GPU 2
|
||||
|
||||
//音视频加密类型
|
||||
#define ENCRYPT_AES_3R_VIDEO 1
|
||||
#define ENCRYPT_AES_10R_VIDEO 2
|
||||
#define ENCRYPT_AES_3R_AUDIO 1
|
||||
#define ENCRYPT_AES_10R_AUDIO 2
|
||||
|
||||
//Frame position
|
||||
typedef struct{
|
||||
long nFilePos;
|
||||
long nFrameNum;
|
||||
long nFrameTime;
|
||||
long nErrorFrameNum;
|
||||
SYSTEMTIME *pErrorTime;
|
||||
long nErrorLostFrameNum;
|
||||
long nErrorFrameSize;
|
||||
}FRAME_POS,*PFRAME_POS;
|
||||
|
||||
//Frame Info
|
||||
typedef struct{
|
||||
long nWidth;
|
||||
long nHeight;
|
||||
long nStamp;
|
||||
long nType;
|
||||
long nFrameRate;
|
||||
DWORD dwFrameNum;
|
||||
}FRAME_INFO;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
long nPort; //通道号
|
||||
char *pBuf; //返回的第一路图像数据指针
|
||||
unsigned int nBufLen; //返回的第一路图像数据大小
|
||||
char *pBuf1; //返回的第二路图像数据指针
|
||||
unsigned int nBufLen1; //返回的第二路图像数据大小
|
||||
char *pBuf2; //返回的第三路图像数据指针
|
||||
unsigned int nBufLen2; //返回的第三路图像数据大小
|
||||
unsigned int nWidth; //画面宽
|
||||
unsigned int nHeight; //画面高
|
||||
unsigned int nStamp; //时标信息,单位毫秒
|
||||
unsigned int nType; //数据类型
|
||||
void *pUser; //用户数据
|
||||
unsigned int reserved[4]; //保留
|
||||
}DISPLAY_INFO_YUV;
|
||||
|
||||
//Frame
|
||||
typedef struct{
|
||||
char *pDataBuf;
|
||||
long nSize;
|
||||
long nFrameNum;
|
||||
BOOL bIsAudio;
|
||||
long nReserved;
|
||||
}FRAME_TYPE;
|
||||
|
||||
//Watermark Info //add by gb 080119
|
||||
typedef struct{
|
||||
char *pDataBuf;
|
||||
long nSize;
|
||||
long nFrameNum;
|
||||
BOOL bRsaRight;
|
||||
long nReserved;
|
||||
}WATERMARK_INFO;
|
||||
|
||||
typedef struct SYNCDATA_INFO
|
||||
{
|
||||
DWORD dwDataType; //和码流数据同步的附属信息类型,目前有:智能信息,车载信息
|
||||
DWORD dwDataLen; //附属信息数据长度
|
||||
BYTE* pData; //指向附属信息数据结构的指针,比如IVS_INFO结构
|
||||
} SYNCDATA_INFO;
|
||||
|
||||
#ifndef _HIK_MEDIAINFO_FLAG_
|
||||
#define _HIK_MEDIAINFO_FLAG_
|
||||
typedef struct _HIK_MEDIAINFO_ // modified by gb 080425
|
||||
{
|
||||
unsigned int media_fourcc; // "HKMI": 0x484B4D49 Hikvision Media Information
|
||||
unsigned short media_version; // 版本号:指本信息结构版本号,目前为0x0101,即1.01版本,01:主版本号;01:子版本号。
|
||||
unsigned short device_id; // 设备ID,便于跟踪/分析
|
||||
|
||||
unsigned short system_format; // 系统封装层
|
||||
unsigned short video_format; // 视频编码类型
|
||||
|
||||
unsigned short audio_format; // 音频编码类型
|
||||
unsigned char audio_channels; // 通道数
|
||||
unsigned char audio_bits_per_sample; // 样位率
|
||||
unsigned int audio_samplesrate; // 采样率
|
||||
unsigned int audio_bitrate; // 压缩音频码率,单位:bit
|
||||
|
||||
unsigned int reserved[4]; // 保留
|
||||
}HIK_MEDIAINFO;
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
long nPort;
|
||||
char * pBuf;
|
||||
long nBufLen;
|
||||
long nWidth;
|
||||
long nHeight;
|
||||
long nStamp;
|
||||
long nType;
|
||||
long nUser;
|
||||
}DISPLAY_INFO;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
long nPort;
|
||||
char *pVideoBuf;
|
||||
long nVideoBufLen;
|
||||
char *pPriBuf;
|
||||
long nPriBufLen;
|
||||
long nWidth;
|
||||
long nHeight;
|
||||
long nStamp;
|
||||
long nType;
|
||||
long nUser;
|
||||
}DISPLAY_INFOEX;
|
||||
|
||||
typedef struct PLAYM4_SYSTEM_TIME //绝对时间
|
||||
{
|
||||
DWORD dwYear; //年
|
||||
DWORD dwMon; //月
|
||||
DWORD dwDay; //日
|
||||
DWORD dwHour; //时
|
||||
DWORD dwMin; //分
|
||||
DWORD dwSec; //秒
|
||||
DWORD dwMs; //毫秒
|
||||
} PLAYM4_SYSTEM_TIME;
|
||||
|
||||
//ENCRYPT Info
|
||||
typedef struct{
|
||||
long nVideoEncryptType; //视频加密类型
|
||||
long nAudioEncryptType; //音频加密类型
|
||||
long nSetSecretKey; //是否设置,1表示设置密钥,0表示没有设置密钥
|
||||
}ENCRYPT_INFO;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//API
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////ver 1.0///////////////////////////////////////
|
||||
//Initialize DirecDraw.Now invalid.
|
||||
PLAYM4_API BOOL __stdcall PlayM4_InitDDraw(HWND hWnd);
|
||||
//Release directDraw; Now invalid.
|
||||
PLAYM4_API BOOL __stdcall PlayM4_RealeseDDraw();
|
||||
PLAYM4_API BOOL __stdcall PlayM4_OpenFile(LONG nPort,LPSTR sFileName);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_CloseFile(LONG nPort);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_Play(LONG nPort, HWND hWnd);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_Stop(LONG nPort);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_Pause(LONG nPort,DWORD nPause);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_Fast(LONG nPort);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_Slow(LONG nPort);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_OneByOne(LONG nPort);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_SetPlayPos(LONG nPort,float fRelativePos);
|
||||
PLAYM4_API float __stdcall PlayM4_GetPlayPos(LONG nPort);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_SetFileEndMsg(LONG nPort,HWND hWnd,UINT nMsg);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_SetVolume(LONG nPort,WORD nVolume);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_StopSound();
|
||||
PLAYM4_API BOOL __stdcall PlayM4_PlaySound(LONG nPort);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_OpenStream(LONG nPort,PBYTE pFileHeadBuf,DWORD nSize,DWORD nBufPoolSize);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_InputData(LONG nPort,PBYTE pBuf,DWORD nSize);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_CloseStream(LONG nPort);
|
||||
PLAYM4_API int __stdcall PlayM4_GetCaps();
|
||||
PLAYM4_API DWORD __stdcall PlayM4_GetFileTime(LONG nPort);
|
||||
PLAYM4_API DWORD __stdcall PlayM4_GetPlayedTime(LONG nPort);
|
||||
PLAYM4_API DWORD __stdcall PlayM4_GetPlayedFrames(LONG nPort);
|
||||
|
||||
//23
|
||||
////////////////ver 2.0 added///////////////////////////////////////
|
||||
PLAYM4_API BOOL __stdcall PlayM4_SetDecCallBack(LONG nPort,void (CALLBACK* DecCBFun)(long nPort,char * pBuf,long nSize,FRAME_INFO * pFrameInfo, long nReserved1,long nReserved2));
|
||||
PLAYM4_API BOOL __stdcall PlayM4_SetDisplayCallBackYUV(LONG nPort, void (CALLBACK* DisplayCBFun)(DISPLAY_INFO_YUV *pstDisplayInfo), BOOL bTrue, void* pUser);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_SetDisplayCallBack(LONG nPort,void (CALLBACK* DisplayCBFun)(long nPort,char * pBuf,long nSize,long nWidth,long nHeight,long nStamp,long nType,long nReserved));
|
||||
PLAYM4_API BOOL __stdcall PlayM4_ConvertToBmpFile(char * pBuf,long nSize,long nWidth,long nHeight,long nType,char *sFileName);
|
||||
PLAYM4_API DWORD __stdcall PlayM4_GetFileTotalFrames(LONG nPort);
|
||||
PLAYM4_API DWORD __stdcall PlayM4_GetCurrentFrameRate(LONG nPort);
|
||||
PLAYM4_API DWORD __stdcall PlayM4_GetPlayedTimeEx(LONG nPort);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_SetPlayedTimeEx(LONG nPort,DWORD nTime);
|
||||
PLAYM4_API DWORD __stdcall PlayM4_GetCurrentFrameNum(LONG nPort);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_SetStreamOpenMode(LONG nPort,DWORD nMode);
|
||||
PLAYM4_API DWORD __stdcall PlayM4_GetFileHeadLength();
|
||||
PLAYM4_API DWORD __stdcall PlayM4_GetSdkVersion();
|
||||
//11
|
||||
////////////////ver 2.2 added///////////////////////////////////////
|
||||
PLAYM4_API DWORD __stdcall PlayM4_GetLastError(LONG nPort);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_RefreshPlay(LONG nPort);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_SetOverlayMode(LONG nPort,BOOL bOverlay,COLORREF colorKey);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_GetPictureSize(LONG nPort,LONG *pWidth,LONG *pHeight);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_SetPicQuality(LONG nPort,BOOL bHighQuality);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_PlaySoundShare(LONG nPort);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_StopSoundShare(LONG nPort);
|
||||
//7
|
||||
////////////////ver 2.4 added///////////////////////////////////////
|
||||
PLAYM4_API LONG __stdcall PlayM4_GetStreamOpenMode(LONG nPort);
|
||||
PLAYM4_API LONG __stdcall PlayM4_GetOverlayMode(LONG nPort);
|
||||
PLAYM4_API COLORREF __stdcall PlayM4_GetColorKey(LONG nPort);
|
||||
PLAYM4_API WORD __stdcall PlayM4_GetVolume(LONG nPort);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_GetPictureQuality(LONG nPort,BOOL *bHighQuality);
|
||||
PLAYM4_API DWORD __stdcall PlayM4_GetSourceBufferRemain(LONG nPort);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_ResetSourceBuffer(LONG nPort);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_SetSourceBufCallBack(LONG nPort,DWORD nThreShold,void (CALLBACK * SourceBufCallBack)(long nPort,DWORD nBufSize,DWORD dwUser,void*pResvered),DWORD dwUser,void *pReserved);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_ResetSourceBufFlag(LONG nPort);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_SetDisplayBuf(LONG nPort,DWORD nNum);
|
||||
PLAYM4_API DWORD __stdcall PlayM4_GetDisplayBuf(LONG nPort);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_OneByOneBack(LONG nPort);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_SetFileRefCallBack(LONG nPort, void (__stdcall *pFileRefDone)(DWORD nPort,DWORD nUser),DWORD nUser);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_SetCurrentFrameNum(LONG nPort,DWORD nFrameNum);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_GetKeyFramePos(LONG nPort,DWORD nValue, DWORD nType, PFRAME_POS pFramePos);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_GetNextKeyFramePos(LONG nPort,DWORD nValue, DWORD nType, PFRAME_POS pFramePos);
|
||||
#if (WINVER >= 0x0400)
|
||||
//Note: These funtion must be builded under win2000 or above with Microsoft Platform sdk.
|
||||
// You can download the sdk from "http://www.microsoft.com/msdownload/platformsdk/sdkupdate/";
|
||||
PLAYM4_API BOOL __stdcall PlayM4_InitDDrawDevice();
|
||||
PLAYM4_API void __stdcall PlayM4_ReleaseDDrawDevice();
|
||||
PLAYM4_API DWORD __stdcall PlayM4_GetDDrawDeviceTotalNums();
|
||||
PLAYM4_API BOOL __stdcall PlayM4_SetDDrawDevice(LONG nPort,DWORD nDeviceNum);
|
||||
//PLAYM4_API BOOL __stdcall PlayM4_GetDDrawDeviceInfo(DWORD nDeviceNum,LPSTR lpDriverDescription,DWORD nDespLen,LPSTR lpDriverName ,DWORD nNameLen,HMONITOR *hhMonitor);
|
||||
PLAYM4_API int __stdcall PlayM4_GetCapsEx(DWORD nDDrawDeviceNum);
|
||||
#endif
|
||||
PLAYM4_API BOOL __stdcall PlayM4_ThrowBFrameNum(LONG nPort,DWORD nNum);
|
||||
//23
|
||||
////////////////ver 2.5 added///////////////////////////////////////
|
||||
PLAYM4_API BOOL __stdcall PlayM4_SetDisplayType(LONG nPort,LONG nType);
|
||||
PLAYM4_API long __stdcall PlayM4_GetDisplayType(LONG nPort);
|
||||
//2
|
||||
////////////////ver 3.0 added///////////////////////////////////////
|
||||
PLAYM4_API BOOL __stdcall PlayM4_SetDecCBStream(LONG nPort,DWORD nStream);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_SetDisplayRegion(LONG nPort,DWORD nRegionNum, RECT *pSrcRect, HWND hDestWnd, BOOL bEnable);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_RefreshPlayEx(LONG nPort,DWORD nRegionNum);
|
||||
#if (WINVER >= 0x0400)
|
||||
//Note: The funtion must be builded under win2000 or above with Microsoft Platform sdk.
|
||||
// You can download the sdk from http://www.microsoft.com/msdownload/platformsdk/sdkupdate/;
|
||||
PLAYM4_API BOOL __stdcall PlayM4_SetDDrawDeviceEx(LONG nPort,DWORD nRegionNum,DWORD nDeviceNum);
|
||||
#endif
|
||||
//4
|
||||
/////////////////v3.2 added/////////////////////////////////////////
|
||||
|
||||
PLAYM4_API BOOL __stdcall PlayM4_GetRefValue(LONG nPort,BYTE *pBuffer, DWORD *pSize);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_SetRefValue(LONG nPort,BYTE *pBuffer, DWORD nSize);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_OpenStreamEx(LONG nPort,PBYTE pFileHeadBuf,DWORD nSize,DWORD nBufPoolSize);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_CloseStreamEx(LONG nPort);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_InputVideoData(LONG nPort,PBYTE pBuf,DWORD nSize);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_InputAudioData(LONG nPort,PBYTE pBuf,DWORD nSize);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_RegisterDrawFun(LONG nPort,void (CALLBACK* DrawFun)(long nPort,HDC hDc,LONG nUser),LONG nUser);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_RigisterDrawFun(LONG nPort,void (CALLBACK* DrawFun)(long nPort,HDC hDc,LONG nUser),LONG nUser);
|
||||
//8
|
||||
//////////////////v3.4/////////////////////////////////////////////////////
|
||||
PLAYM4_API BOOL __stdcall PlayM4_SetTimerType(LONG nPort,DWORD nTimerType,DWORD nReserved);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_GetTimerType(LONG nPort,DWORD *pTimerType,DWORD *pReserved);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_ResetBuffer(LONG nPort,DWORD nBufType);
|
||||
PLAYM4_API DWORD __stdcall PlayM4_GetBufferValue(LONG nPort,DWORD nBufType);
|
||||
|
||||
//////////////////V3.6/////////////////////////////////////////////////////////
|
||||
PLAYM4_API BOOL __stdcall PlayM4_AdjustWaveAudio(LONG nPort,LONG nCoefficient);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_SetVerifyCallBack(LONG nPort, DWORD nBeginTime, DWORD nEndTime, void (__stdcall * funVerify)(long nPort, FRAME_POS * pFilePos, DWORD bIsVideo, DWORD nUser), DWORD nUser);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_SetAudioCallBack(LONG nPort, void (__stdcall * funAudio)(long nPort, char * pAudioBuf, long nSize, long nStamp, long nType, long nUser), long nUser);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_SetEncTypeChangeCallBack(LONG nPort,void(CALLBACK *funEncChange)(long nPort,long nUser),long nUser);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_SetColor(LONG nPort, DWORD nRegionNum, int nBrightness, int nContrast, int nSaturation, int nHue);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_GetColor(LONG nPort, DWORD nRegionNum, int *pBrightness, int *pContrast, int *pSaturation, int *pHue);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_SetEncChangeMsg(LONG nPort,HWND hWnd,UINT nMsg);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_GetOriginalFrameCallBack(LONG nPort, BOOL bIsChange,BOOL bNormalSpeed,long nStartFrameNum,long nStartStamp,long nFileHeader,void(CALLBACK *funGetOrignalFrame)(long nPort,FRAME_TYPE *frameType, long nUser),long nUser);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_GetFileSpecialAttr(LONG nPort, DWORD *pTimeStamp,DWORD *pFileNum ,DWORD *pReserved);
|
||||
PLAYM4_API DWORD __stdcall PlayM4_GetSpecialData(LONG nPort);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_SetCheckWatermarkCallBack(LONG nPort,void(CALLBACK* funCheckWatermark)(long nPort,WATERMARK_INFO* pWatermarkInfo,DWORD nUser),DWORD nUser);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_SetImageSharpen(LONG nPort,DWORD nLevel);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_SetDecodeFrameType(LONG nPort,DWORD nFrameType);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_SetPlayMode(LONG nPort,BOOL bNormal);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_SetOverlayFlipMode(LONG nPort,BOOL bTrue);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_SetOverlayPriInfoFlag(LONG nPort, DWORD nIntelType, BOOL bTrue,const char *pFontPath);
|
||||
|
||||
//PLAYM4_API DWORD __stdcall PlayM4_GetAbsFrameNum(LONG nPort);
|
||||
|
||||
//////////////////V4.7.0.0//////////////////////////////////////////////////////
|
||||
////convert yuv to jpeg
|
||||
PLAYM4_API BOOL __stdcall PlayM4_ConvertToJpegFile(char * pBuf,long nSize,long nWidth,long nHeight,long nType,char *sFileName);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_SetJpegQuality(long nQuality);
|
||||
//set deflash
|
||||
PLAYM4_API BOOL __stdcall PlayM4_SetDeflash(LONG nPort,BOOL bDefalsh);
|
||||
//PLAYM4_API BOOL __stdcall PlayM4_SetDecCallBackEx(LONG nPort,void (CALLBACK* DecCBFun)(long nPort,char * pBuf,long nSize,FRAME_INFO * pFrameInfo, long nReserved1,long nReserved2), char* pDest, long nDestSize);
|
||||
//////////////////V4.8.0.0/////////////////////////////////////////////////////////
|
||||
//check discontinuous frame number as error data?
|
||||
PLAYM4_API BOOL __stdcall PlayM4_CheckDiscontinuousFrameNum(LONG nPort, BOOL bCheck);
|
||||
//get bmp or jpeg
|
||||
PLAYM4_API BOOL __stdcall PlayM4_GetBMP(LONG nPort,PBYTE pBitmap,DWORD nBufSize,DWORD* pBmpSize);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_GetJPEG(LONG nPort,PBYTE pJpeg,DWORD nBufSize,DWORD* pJpegSize);
|
||||
//dec call back mend
|
||||
PLAYM4_API BOOL __stdcall PlayM4_SetDecCallBackMend(LONG nPort,void (CALLBACK* DecCBFun)(long nPort,char * pBuf,long nSize,FRAME_INFO * pFrameInfo, long nUser,long nReserved2), long nUser);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_SetSecretKey(LONG nPort, LONG lKeyType, char *pSecretKey, LONG lKeyLen);
|
||||
|
||||
// add by gb 2007-12-23
|
||||
PLAYM4_API BOOL __stdcall PlayM4_SetFileEndCallback(LONG nPort, void(CALLBACK*FileEndCallback)(long nPort, void *pUser), void *pUser);
|
||||
|
||||
// add by gb 080131 version 4.9.0.1
|
||||
PLAYM4_API BOOL __stdcall PlayM4_GetPort(LONG* nPort);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_FreePort(LONG nPort);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_SetDisplayCallBackEx(LONG nPort,void (CALLBACK* DisplayCBFun)(DISPLAY_INFO *pstDisplayInfo), long nUser);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_SkipErrorData(LONG nPort, BOOL bSkip);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_SetDecCallBackExMend(LONG nPort, void (CALLBACK* DecCBFun)(long nPort, char* pBuf, long nSize, FRAME_INFO* pFrameInfo,
|
||||
long nUser, long nReserved2), char* pDest, long nDestSize, long nUser);
|
||||
//reverse play add by chenjie 110609
|
||||
PLAYM4_API BOOL __stdcall PlayM4_ReversePlay(LONG nPort);
|
||||
PLAYM4_API BOOL __stdcall PlayM4_GetSystemTime(LONG nPort, PLAYM4_SYSTEM_TIME *pstSystemTime);
|
||||
|
||||
//PLAYM4_API BOOL __stdcall PlayM4_SetDecodeERC(long nPort, unsigned int nLevel);
|
||||
|
||||
#ifndef PLAYM4_SESSION_INFO_TAG
|
||||
#define PLAYM4_SESSION_INFO_TAG
|
||||
//nProtocolType
|
||||
#define PLAYM4_PROTOCOL_RTSP 1
|
||||
//nSessionInfoType
|
||||
#define PLAYM4_SESSION_INFO_SDP 1
|
||||
|
||||
typedef struct _PLAYM4_SESSION_INFO_ //交互信息结构
|
||||
{
|
||||
int nSessionInfoType; //交互信息类型,比如SDP,比如海康私有信息头
|
||||
int nSessionInfoLen; //交互信息长度
|
||||
unsigned char* pSessionInfoData; //交互信息数据
|
||||
|
||||
} PLAYM4_SESSION_INFO;
|
||||
#endif
|
||||
|
||||
PLAYM4_API BOOL __stdcall PlayM4_OpenStreamAdvanced(LONG nPort, int nProtocolType, PLAYM4_SESSION_INFO* pstSessionInfo, DWORD nBufPoolSize);
|
||||
|
||||
#define R_ANGLE_0 -1 //不旋转
|
||||
#define R_ANGLE_L90 0 //向左旋转90度
|
||||
#define R_ANGLE_R90 1 //向右旋转90度
|
||||
#define R_ANGLE_180 2 //旋转180度
|
||||
|
||||
PLAYM4_API BOOL __stdcall PlayM4_SetRotateAngle(LONG nPort, DWORD nRegionNum, DWORD dwType);
|
||||
|
||||
#ifndef PLAYM4_ADDITION_INFO_TAG
|
||||
#define PLAYM4_ADDITION_INFO_TAG
|
||||
typedef struct _PLAYM4_ADDITION_INFO_ //交互信息结构
|
||||
{
|
||||
BYTE* pData; //附件数据
|
||||
DWORD dwDatalen; //附件数据长度
|
||||
DWORD dwDataType; //数据类型
|
||||
DWORD dwTimeStamp; //相对时间戳
|
||||
} PLAYM4_ADDITION_INFO;
|
||||
#endif
|
||||
|
||||
//dwGroupIndex 暂约定取值0~3,第一版本取消同步只能同个closestream处理
|
||||
PLAYM4_API BOOL __stdcall PlayM4_SetSycGroup(LONG nPort, DWORD dwGroupIndex);
|
||||
//暂不实现此函数,同个组设置的起始时间不一致,以最小的时间作为播放起点,同一组可只设一路
|
||||
PLAYM4_API BOOL __stdcall PlayM4_SetSycStartTime(LONG nPort, PLAYM4_SYSTEM_TIME *pstSystemTime);
|
||||
|
||||
|
||||
// 以下实现鱼眼相关的接口
|
||||
#ifndef FISH_EYE_TAG
|
||||
#define FISH_EYE_TAG
|
||||
|
||||
// 安装类型
|
||||
typedef enum tagFECPlaceType
|
||||
{
|
||||
FEC_PLACE_WALL = 0x1, // 壁装方式 (法线水平)
|
||||
FEC_PLACE_FLOOR = 0x2, // 地面安装 (法线向上)
|
||||
FEC_PLACE_CEILING = 0x3, // 顶装方式 (法线向下)
|
||||
|
||||
}FECPLACETYPE;
|
||||
|
||||
typedef enum tagFECCorrectType
|
||||
{
|
||||
FEC_CORRECT_PTZ = 0x100, // PTZ
|
||||
FEC_CORRECT_180 = 0x200, // 180度矫正 (对应2P)
|
||||
FEC_CORRECT_360 = 0x300, // 360全景矫正 (对应1P)
|
||||
FEC_CORRECT_LAT = 0x400 //纬度展开
|
||||
|
||||
}FECCORRECTTYPE;
|
||||
|
||||
typedef struct tagCycleParam
|
||||
{
|
||||
float fRadiusLeft; // 圆的最左边X坐标
|
||||
float fRadiusRight; // 圆的最右边X坐标
|
||||
float fRadiusTop; // 圆的最上边Y坐标
|
||||
float fRadiusBottom; // 圆的最下边Y坐标
|
||||
|
||||
}CYCLEPARAM;
|
||||
|
||||
typedef struct tagPTZParam
|
||||
{
|
||||
float fPTZPositionX; // PTZ 显示的中心位置 X坐标
|
||||
float fPTZPositionY; // PTZ 显示的中心位置 Y坐标
|
||||
|
||||
}PTZPARAM;
|
||||
|
||||
|
||||
// 错误码
|
||||
/*********************************************
|
||||
|
||||
|
||||
********************************************/
|
||||
|
||||
|
||||
// 更新标记变量定义
|
||||
|
||||
|
||||
#define FEC_UPDATE_RADIUS 0x1
|
||||
#define FEC_UPDATE_PTZZOOM 0x2
|
||||
#define FEC_UPDATE_WIDESCANOFFSET 0x4
|
||||
#define FEC_UPDATE_PTZPARAM 0x8
|
||||
|
||||
|
||||
typedef struct tagFECParam
|
||||
{
|
||||
|
||||
|
||||
unsigned int nUpDateType; // 更新的类型
|
||||
|
||||
unsigned int nPlaceAndCorrect; // 安装方式和矫正方式,只能用于获取,SetParam的时候无效,该值表示安装方式和矫正方式的和
|
||||
|
||||
PTZPARAM stPTZParam; // PTZ 校正的参数
|
||||
|
||||
CYCLEPARAM stCycleParam; // 鱼眼图像圆心参数
|
||||
|
||||
float fZoom; // PTZ 显示的范围参数
|
||||
|
||||
float fWideScanOffset; // 180或者360度校正的偏移角度
|
||||
|
||||
int nResver[16]; // 保留字段
|
||||
|
||||
}FISHEYEPARAM;
|
||||
|
||||
typedef void (__stdcall * FISHEYE_CallBack )( void* pUser , unsigned int nSubPort , unsigned int nCBType , void * hDC , unsigned int nWidth , unsigned int nHeight);
|
||||
|
||||
#endif
|
||||
// 启用鱼眼
|
||||
PLAYM4_API BOOL __stdcall PlayM4_FEC_Enable(LONG nPort);
|
||||
|
||||
// 关闭鱼眼模块
|
||||
PLAYM4_API BOOL __stdcall PlayM4_FEC_Disable(LONG nPort);
|
||||
|
||||
// 获取鱼眼矫正处理子端口 [1~31]
|
||||
PLAYM4_API BOOL __stdcall PlayM4_FEC_GetPort(LONG nPort, unsigned int* nSubPort,FECPLACETYPE emPlaceType,FECCORRECTTYPE emCorrectType);
|
||||
|
||||
// 删除鱼眼矫正处理子端口
|
||||
PLAYM4_API BOOL __stdcall PlayM4_FEC_DelPort(LONG nPort , unsigned int nSubPort);
|
||||
|
||||
// 设置鱼眼矫正参数
|
||||
PLAYM4_API BOOL __stdcall PlayM4_FEC_SetParam(LONG nPort , unsigned int nSubPort , FISHEYEPARAM * pPara);
|
||||
|
||||
// 获取鱼眼矫正参数
|
||||
PLAYM4_API BOOL __stdcall PlayM4_FEC_GetParam(LONG nPort , unsigned int nSubPort , FISHEYEPARAM * pPara);
|
||||
|
||||
// 设置显示窗口,可以随时切换
|
||||
PLAYM4_API BOOL __stdcall PlayM4_FEC_SetWnd(LONG nPort , unsigned int nSubPort , void * hWnd);
|
||||
|
||||
// 设置鱼眼窗口的绘图回调
|
||||
PLAYM4_API BOOL __stdcall PlayM4_FEC_SetCallBack(LONG nPort , unsigned int nSubPort , FISHEYE_CallBack cbFunc , void * pUser);
|
||||
|
||||
//motionflow
|
||||
PLAYM4_API BOOL __stdcall PlayM4_MotionFlow(LONG nPort, DWORD dwAdjustType);
|
||||
|
||||
|
||||
//图像增强相关
|
||||
#ifndef PLAYM4_HIKVIE_TAG
|
||||
#define PLAYM4_HIKVIE_TAG
|
||||
|
||||
typedef struct _PLAYM4_VIE_DYNPARAM_
|
||||
{
|
||||
int moduFlag; //启用的算法处理模块,在PLAYM4_VIE_MODULES中定义
|
||||
//如 PLAYM4_VIE_MODU_ADJ | PLAYM4_VIE_MODU_EHAN
|
||||
//模块启用后,必须设置相应的参数;
|
||||
//PLAYM4_VIE_MODU_ADJ
|
||||
int brightVal; //亮度调节值,[-255, 255]
|
||||
int contrastVal; //对比度调节值,[-256, 255]
|
||||
int colorVal; //饱和度调节值,[-256, 255]
|
||||
//PLAYM4_VIE_MODU_EHAN
|
||||
int toneScale; //滤波范围,[0, 100]
|
||||
int toneGain; //对比度调节,全局对比度增益值,[-256, 255]
|
||||
int toneOffset; //亮度调节,亮度平均值偏移,[-255, 255]
|
||||
int toneColor; //颜色调节,颜色保真值,[-256, 255]
|
||||
//PLAYM4_VIE_MODU_DEHAZE
|
||||
int dehazeLevel; //去雾强度,[0, 255]
|
||||
int dehazeTrans; //透射值,[0, 255]
|
||||
int dehazeBright; //亮度补偿,[0, 255]
|
||||
//PLAYM4_VIE_MODU_DENOISE
|
||||
int denoiseLevel; //去噪强度,[0, 255]
|
||||
//PLAYM4_VIE_MODU_SHARPEN
|
||||
int usmAmount; //锐化强度,[0, 255]
|
||||
int usmRadius; //锐化半径,[1, 15]
|
||||
int usmThreshold; //锐化阈值,[0, 255]
|
||||
//PLAYM4_VIE_MODU_DEBLOCK
|
||||
int deblockLevel; //去块强度,[0, 100]
|
||||
//PLAYM4_VIE_MODU_LENS
|
||||
int lensWarp; //畸变量,[-256, 255]
|
||||
int lensZoom; //缩放量,[-256, 255]
|
||||
//PLAYM4_VIE_MODU_CRB
|
||||
//无响应参数
|
||||
} PLAYM4_VIE_PARACONFIG;
|
||||
|
||||
typedef enum _PLAYM4_VIE_MODULES
|
||||
{
|
||||
PLAYM4_VIE_MODU_ADJ = 0x00000001, //图像基本调节
|
||||
PLAYM4_VIE_MODU_EHAN = 0x00000002, //局部增强模块
|
||||
PLAYM4_VIE_MODU_DEHAZE = 0x00000004, //去雾模块
|
||||
PLAYM4_VIE_MODU_DENOISE = 0x00000008, //去噪模块
|
||||
PLAYM4_VIE_MODU_SHARPEN = 0x00000010, //锐化模块
|
||||
PLAYM4_VIE_MODU_DEBLOCK = 0x00000020, //去块滤波模块
|
||||
PLAYM4_VIE_MODU_CRB = 0x00000040, //色彩平衡模块
|
||||
PLAYM4_VIE_MODU_LENS = 0x00000080, //镜头畸变矫正模块
|
||||
}PLAYM4_VIE_MODULES;
|
||||
#endif
|
||||
|
||||
//设置关闭/开启模块
|
||||
//dwModuFlag对应PLAYM4_VIE_MODULES宏,可组合
|
||||
//先设置模块开启,再设置模块参数;期间采用默认的参数;
|
||||
//关闭模块后,上次设置的参数清空
|
||||
//其他接口调用,必须在该接口开启模块后;否则,返回错误
|
||||
PLAYM4_API BOOL __stdcall PlayM4_VIE_SetModuConfig(LONG lPort,int nModuFlag,BOOL bEnable);
|
||||
|
||||
//设置图像增强区域,NULL全图;超过全图,采用全图;最小区域16*16像素
|
||||
//可支持设置区域,最多比较说4个,第一个版本可以只支持一个。多个区域要求不能重叠,有重叠就报错
|
||||
PLAYM4_API BOOL __stdcall PlayM4_VIE_SetRegion(LONG lPort,LONG lRegNum,RECT* pRect);
|
||||
|
||||
//获取开启模块
|
||||
PLAYM4_API BOOL __stdcall PlayM4_VIE_GetModuConfig(LONG lPort,int* pdwModuFlag);
|
||||
|
||||
//设置参数
|
||||
//未开启模块的参数设置被忽略
|
||||
PLAYM4_API BOOL __stdcall PlayM4_VIE_SetParaConfig(LONG lPort,PLAYM4_VIE_PARACONFIG* pParaConfig);
|
||||
|
||||
//获取开启模块的参数
|
||||
PLAYM4_API BOOL __stdcall PlayM4_VIE_GetParaConfig(LONG lPort,PLAYM4_VIE_PARACONFIG* pParaConfig);
|
||||
|
||||
//音视频同步接口
|
||||
PLAYM4_API BOOL __stdcall PlayM4_SyncToAudio(LONG nPort, BOOL bSyncToAudio);
|
||||
|
||||
// 私有信息模块类型
|
||||
typedef enum _PLAYM4_PRIDATA_RENDER
|
||||
{
|
||||
PLAYM4_RENDER_ANA_INTEL_DATA = 0x00000001, //智能分析
|
||||
PLAYM4_RENDER_MD = 0x00000002, //移动侦测
|
||||
PLAYM4_RENDER_ADD_POS = 0x00000004, //POS信息后叠加
|
||||
PLAYM4_RENDER_ADD_PIC = 0x00000008, //图片叠加
|
||||
PLAYM4_RENDER_FIRE_DETCET = 0x00000010, //热成像信息
|
||||
PLAYM4_RENDER_TEM = 0x00000020, //温度信息
|
||||
PLAYM4_RENDER_TRACK_TEM = 0x00000040, //轨迹信息
|
||||
PLAYM4_RENDER_THERMAL = 0x00000080 //废气检测和烟火屏蔽信息
|
||||
}PLAYM4_PRIDATA_RENDER;
|
||||
|
||||
typedef enum _PLAYM4_THERMAL_FLAG
|
||||
{
|
||||
PLAYM4_THERMAL_FIREMASK = 0x00000001, //烟火屏蔽
|
||||
PLAYM4_THERMAL_RULEGAS = 0x00000002, //规则废气检测
|
||||
PLAYM4_THERMAL_TARGETGAS = 0x00000004 //目标废气检测
|
||||
}PLAYM4_THERMAL_FLAG;
|
||||
|
||||
typedef enum _PLAYM4_FIRE_ALARM{
|
||||
PLAYM4_FIRE_FRAME_DIS = 0x00000001, //火点框显示
|
||||
PLAYM4_FIRE_MAX_TEMP = 0x00000002, //最高温度
|
||||
PLAYM4_FIRE_MAX_TEMP_POSITION = 0x00000004, //最高温度位置显示
|
||||
PLAYM4_FIRE_DISTANCE = 0x00000008, //最高温度距离}PLAYM4_FIRE_ALARM
|
||||
}PLAYM4_FIRE_ALARM;
|
||||
|
||||
typedef enum _PLAYM4_TEM_FLAG{
|
||||
PLAYM4_TEM_REGION_BOX = 0x00000001, //框测温
|
||||
PLAYM4_TEM_REGION_LINE = 0x00000002, //线测温
|
||||
PLAYM4_TEM_REGION_POINT = 0x00000004, //点测温}PLAYM4_TEM_FLAG
|
||||
}PLAYM4_TEM_FLAG;
|
||||
|
||||
typedef enum _PLAYM4_TRACK_FLAG
|
||||
{
|
||||
PLAYM4_TRACK_PEOPLE = 0x00000001, //人轨迹
|
||||
PLAYM4_TRACK_VEHICLE = 0x00000002, //车轨迹
|
||||
}PLAYM4_TRACK_FLAG;
|
||||
|
||||
typedef struct TI_PTZ_INFO_
|
||||
{
|
||||
unsigned short dwDefVer; //结构体版本
|
||||
unsigned short dwLength; //PTZ_info长度,以8字节为单位
|
||||
DWORD dwP; //P(0~3600)
|
||||
DWORD dwT; //T(0~3600)
|
||||
DWORD dwZ; //Z(0~3600)
|
||||
BYTE chFSMState; //跟踪状态
|
||||
BYTE bClearFocusState; //聚焦清晰状态(0,1)
|
||||
BYTE reserved[6]; //6个字节保留
|
||||
}PTZ_INFO;
|
||||
|
||||
|
||||
// 智能信息开关
|
||||
PLAYM4_API BOOL __stdcall PlayM4_RenderPrivateData(LONG nPort, int nIntelType, BOOL bTrue);
|
||||
|
||||
PLAYM4_API BOOL __stdcall PlayM4_RenderPrivateDataEx(LONG nPort, int nIntelType, int nSubType, BOOL bTrue);
|
||||
|
||||
// 加密码流回调,nType=0表示码流加密标记位发生变化就回调,nType=1表示码流有加密位发生回调
|
||||
PLAYM4_API BOOL __stdcall PlayM4_SetEncryptTypeCallBack(LONG nPort, DWORD nType,
|
||||
void (CALLBACK* EncryptTypeCBFun)(long nPort, ENCRYPT_INFO* pEncryptInfo, long nUser, long nReserved2), long nUser);
|
||||
//lType: 1 表示获取当前显示帧PTZ信息。以特定结构体形式存储在pInfo内,plLen返回长度信息
|
||||
PLAYM4_API BOOL __stdcall PlayM4_GetStreamAdditionalInfo(LONG nPort, LONG lType, BYTE* pInfo, LONG* plLen);
|
||||
|
||||
|
||||
#endif //_PLAYM4_H_
|
BIN
CommonCamera/lib/dahua/libStreamConvertor.so
Normal file
BIN
CommonCamera/lib/dahua/libStreamConvertor.so
Normal file
Binary file not shown.
BIN
CommonCamera/lib/dahua/libavnetsdk.so
Normal file
BIN
CommonCamera/lib/dahua/libavnetsdk.so
Normal file
Binary file not shown.
BIN
CommonCamera/lib/dahua/libdhconfigsdk.so
Normal file
BIN
CommonCamera/lib/dahua/libdhconfigsdk.so
Normal file
Binary file not shown.
BIN
CommonCamera/lib/dahua/libdhnetsdk.so
Normal file
BIN
CommonCamera/lib/dahua/libdhnetsdk.so
Normal file
Binary file not shown.
12
CommonCamera/lib/hikvision/HCNetSDK_Log_Switch.xml
Normal file
12
CommonCamera/lib/hikvision/HCNetSDK_Log_Switch.xml
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="GB2312"?>
|
||||
<SdkLocal>
|
||||
<SdkLog>
|
||||
<logLevel>3</logLevel><!--req, 1-ERROR, 2-DEBUG, 3-INFO-->
|
||||
<logDirectory>./SDKLOG/</logDirectory><!--the end of the string must be '/'-->
|
||||
<autoDelete>true</autoDelete><!--true: There are less than 10 files in the directory, it will be auto deleted by sdk when the files are more than 10; false: No upper limit to the number of log files-->
|
||||
</SdkLog>
|
||||
<HeartbeatCfg>
|
||||
<Interval>120</Interval> <!-- 心跳时间间隔,单位秒,等于0,使用默认值120s,取值范围为[30, 120] 小于30s,间隔为30s,大于120s,间隔为120s-->
|
||||
<Count>1</Count> <!-- 触发异常回调需要心跳交互异常的次数,等于0,使用默认值1次-->
|
||||
</HeartbeatCfg>
|
||||
</SdkLocal>
|
BIN
CommonCamera/lib/hikvision/libAudioIntercom.so
Normal file
BIN
CommonCamera/lib/hikvision/libAudioIntercom.so
Normal file
Binary file not shown.
BIN
CommonCamera/lib/hikvision/libAudioRender.so
Normal file
BIN
CommonCamera/lib/hikvision/libAudioRender.so
Normal file
Binary file not shown.
BIN
CommonCamera/lib/hikvision/libHCAlarm.so
Normal file
BIN
CommonCamera/lib/hikvision/libHCAlarm.so
Normal file
Binary file not shown.
BIN
CommonCamera/lib/hikvision/libHCCore.so
Normal file
BIN
CommonCamera/lib/hikvision/libHCCore.so
Normal file
Binary file not shown.
BIN
CommonCamera/lib/hikvision/libHCCoreDevCfg.so
Normal file
BIN
CommonCamera/lib/hikvision/libHCCoreDevCfg.so
Normal file
Binary file not shown.
BIN
CommonCamera/lib/hikvision/libHCDisplay.so
Normal file
BIN
CommonCamera/lib/hikvision/libHCDisplay.so
Normal file
Binary file not shown.
BIN
CommonCamera/lib/hikvision/libHCGeneralCfgMgr.so
Normal file
BIN
CommonCamera/lib/hikvision/libHCGeneralCfgMgr.so
Normal file
Binary file not shown.
BIN
CommonCamera/lib/hikvision/libHCIndustry.so
Normal file
BIN
CommonCamera/lib/hikvision/libHCIndustry.so
Normal file
Binary file not shown.
BIN
CommonCamera/lib/hikvision/libHCPlayBack.so
Normal file
BIN
CommonCamera/lib/hikvision/libHCPlayBack.so
Normal file
Binary file not shown.
BIN
CommonCamera/lib/hikvision/libHCPreview.so
Normal file
BIN
CommonCamera/lib/hikvision/libHCPreview.so
Normal file
Binary file not shown.
BIN
CommonCamera/lib/hikvision/libHCVoiceTalk.so
Normal file
BIN
CommonCamera/lib/hikvision/libHCVoiceTalk.so
Normal file
Binary file not shown.
BIN
CommonCamera/lib/hikvision/libNPQos.so
Normal file
BIN
CommonCamera/lib/hikvision/libNPQos.so
Normal file
Binary file not shown.
BIN
CommonCamera/lib/hikvision/libStreamTransClient.so
Normal file
BIN
CommonCamera/lib/hikvision/libStreamTransClient.so
Normal file
Binary file not shown.
BIN
CommonCamera/lib/hikvision/libSystemTransform.so
Normal file
BIN
CommonCamera/lib/hikvision/libSystemTransform.so
Normal file
Binary file not shown.
BIN
CommonCamera/lib/hikvision/libanalyzedata.so
Normal file
BIN
CommonCamera/lib/hikvision/libanalyzedata.so
Normal file
Binary file not shown.
BIN
CommonCamera/lib/hikvision/libcrypto.so.1.1
Normal file
BIN
CommonCamera/lib/hikvision/libcrypto.so.1.1
Normal file
Binary file not shown.
BIN
CommonCamera/lib/hikvision/libhcnetsdk.so
Normal file
BIN
CommonCamera/lib/hikvision/libhcnetsdk.so
Normal file
Binary file not shown.
BIN
CommonCamera/lib/hikvision/libhpr.so
Normal file
BIN
CommonCamera/lib/hikvision/libhpr.so
Normal file
Binary file not shown.
BIN
CommonCamera/lib/hikvision/libiconv.so.2
Normal file
BIN
CommonCamera/lib/hikvision/libiconv.so.2
Normal file
Binary file not shown.
1
CommonCamera/lib/hikvision/libiconv2.so
Symbolic link
1
CommonCamera/lib/hikvision/libiconv2.so
Symbolic link
@ -0,0 +1 @@
|
||||
libiconv.so.2
|
BIN
CommonCamera/lib/hikvision/libopenal.so.1
Normal file
BIN
CommonCamera/lib/hikvision/libopenal.so.1
Normal file
Binary file not shown.
BIN
CommonCamera/lib/hikvision/libssl.so.1.1
Normal file
BIN
CommonCamera/lib/hikvision/libssl.so.1.1
Normal file
Binary file not shown.
BIN
CommonCamera/lib/hikvision/libz.so
Normal file
BIN
CommonCamera/lib/hikvision/libz.so
Normal file
Binary file not shown.
BIN
CommonCamera/lib/libDaHuaImpl.so
Executable file
BIN
CommonCamera/lib/libDaHuaImpl.so
Executable file
Binary file not shown.
BIN
CommonCamera/lib/libHikVisionImpl.so
Executable file
BIN
CommonCamera/lib/libHikVisionImpl.so
Executable file
Binary file not shown.
424
CommonCamera/src/DaHuaImpl.cpp
Normal file
424
CommonCamera/src/DaHuaImpl.cpp
Normal file
@ -0,0 +1,424 @@
|
||||
//
|
||||
// Created by 张宇衡 on 2023/4/14.
|
||||
//
|
||||
|
||||
#include "DaHua.h"
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
|
||||
namespace CC {
|
||||
|
||||
void CALLBACK snap_callback(LLONG lLoginID,
|
||||
BYTE *pBuf,
|
||||
UINT RevLen,
|
||||
UINT EncodeType,
|
||||
DWORD CmdSerial,
|
||||
LDWORD dwUser) {
|
||||
if (pBuf == nullptr) {
|
||||
return;
|
||||
}
|
||||
std::string filename = std::to_string(lLoginID) + ".jpg";
|
||||
std::FILE *fp = std::fopen(filename.c_str(), "wb");
|
||||
std::fwrite(pBuf, 1, RevLen, fp);
|
||||
std::fclose(fp);
|
||||
}
|
||||
|
||||
bool DaHua::snapshot(const std::string &path) {
|
||||
std::unique_lock<std::mutex> lock(operate_mutex_);
|
||||
if (!usable()) {
|
||||
return false;
|
||||
}
|
||||
CLIENT_SetSnapRevCallBack(&snap_callback, 0);
|
||||
|
||||
SNAP_PARAMS snap_params = {0};
|
||||
snap_params.Channel = DH_CHANNEL;
|
||||
snap_params.Quality = 4;
|
||||
snap_params.mode = 0;
|
||||
snap_params.CmdSerial = 0;
|
||||
if (CLIENT_SnapPictureEx(login_handle_, &snap_params)) {
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
std::FILE *fp = std::fopen(path.c_str(), "wb");
|
||||
std::string temp_filename = std::to_string(login_handle_) + ".jpg";
|
||||
std::FILE *fp2 = std::fopen(temp_filename.c_str(), "rb");
|
||||
if (fp == nullptr || fp2 == nullptr) {
|
||||
return false;
|
||||
}
|
||||
// fp2 转移到 fp
|
||||
std::fseek(fp2, 0, SEEK_END);
|
||||
unsigned int snap_buffer_size_ = std::ftell(fp2);
|
||||
std::fseek(fp2, 0, SEEK_SET);
|
||||
char *snap_buffer_ = new char[snap_buffer_size_];
|
||||
std::fread(snap_buffer_, 1, snap_buffer_size_, fp2);
|
||||
std::fwrite(snap_buffer_, 1, snap_buffer_size_, fp);
|
||||
std::fclose(fp);
|
||||
std::fclose(fp2);
|
||||
std::remove(temp_filename.c_str());
|
||||
return true;
|
||||
} else {
|
||||
int code = CLIENT_GetLastError() & 0x7fffffff;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
DaHua::DaHua(std::string ip, std::string username, std::string password)
|
||||
: ip_(std::move(ip)), username_(std::move(username)), password_(std::move(password)) {
|
||||
CLIENT_Init(dis_connect_callback_, (LDWORD)this);
|
||||
login();
|
||||
}
|
||||
|
||||
void DaHua::login() {
|
||||
NET_IN_LOGIN_WITH_HIGHLEVEL_SECURITY in_param = {0};
|
||||
in_param.dwSize = sizeof(in_param);
|
||||
strncpy(in_param.szIP, ip_.c_str(), ip_.size());
|
||||
strncpy(in_param.szPassword, password_.c_str(), password_.size());
|
||||
strncpy(in_param.szUserName, username_.c_str(), username_.size());
|
||||
in_param.nPort = 80;
|
||||
in_param.emSpecCap = EM_LOGIN_SPEC_CAP_TCP;
|
||||
|
||||
NET_OUT_LOGIN_WITH_HIGHLEVEL_SECURITY out_param = {0};
|
||||
out_param.dwSize = sizeof(out_param);
|
||||
|
||||
login_handle_ = CLIENT_LoginWithHighLevelSecurity(&in_param, &out_param);
|
||||
}
|
||||
|
||||
void DaHua::move_up(float speed) {
|
||||
std::unique_lock<std::mutex> lock(operate_mutex_);
|
||||
if (!usable()) {
|
||||
return;
|
||||
}
|
||||
CLIENT_DHPTZControlEx(login_handle_, DH_CHANNEL, DH_PTZ_UP_CONTROL, 0, int(speed * 100) / 14, 0,
|
||||
false);
|
||||
}
|
||||
|
||||
void DaHua::absolute_move(double pan, double tilt, double zoom) {
|
||||
std::unique_lock<std::mutex> lock(operate_mutex_);
|
||||
if (!usable()) {
|
||||
return;
|
||||
}
|
||||
if (pan < 0) {
|
||||
pan = 0;
|
||||
}
|
||||
if (pan > 360) {
|
||||
pan = 360;
|
||||
}
|
||||
if (tilt < 0) {
|
||||
tilt = 0;
|
||||
}
|
||||
if (tilt > 360) {
|
||||
tilt = 360;
|
||||
}
|
||||
if (zoom < 1) {
|
||||
zoom = 1;
|
||||
}
|
||||
if (zoom > 128) {
|
||||
zoom = 128;
|
||||
}
|
||||
CLIENT_DHPTZControlEx(login_handle_, DH_CHANNEL, DH_EXTPTZ_EXACTGOTO, int(pan * 10),
|
||||
int(tilt * 10), int(zoom), false);
|
||||
}
|
||||
|
||||
void DaHua::relative_move(double pan, double tilt) {
|
||||
if (!usable()) {
|
||||
return;
|
||||
}
|
||||
PTZ_INFO::Ptr ptz_info = get_ptz();
|
||||
if (ptz_info == nullptr) {
|
||||
return;
|
||||
}
|
||||
double new_pan = ptz_info->pan->data + pan;
|
||||
double new_tilt = ptz_info->tilt->data + tilt;
|
||||
absolute_move(new_pan, new_tilt, ptz_info->zoom->data);
|
||||
}
|
||||
|
||||
void DaHua::move_up() {
|
||||
std::unique_lock<std::mutex> lock(operate_mutex_);
|
||||
if (!usable()) {
|
||||
return;
|
||||
}
|
||||
CLIENT_DHPTZControlEx(login_handle_, DH_CHANNEL, DH_PTZ_UP_CONTROL, 0, 4, 0, false);
|
||||
}
|
||||
|
||||
bool DaHua::usable() {
|
||||
std::unique_lock<std::mutex> lock(usable_mutex_);
|
||||
if (login_handle_ > 0) {
|
||||
// 如果已经是登录过的重新尝试登录避免因为超时导致的操作失败
|
||||
logout();
|
||||
login();
|
||||
}
|
||||
if (login_handle_ <= 0) {
|
||||
login();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
PTZ_INFO::Ptr DaHua::get_ptz_range() {
|
||||
std::unique_lock<std::mutex> lock(operate_mutex_);
|
||||
if (!usable()) {
|
||||
return nullptr;
|
||||
}
|
||||
PTZ_INFO::Ptr ptz_info = PTZ_INFO::make();
|
||||
ptz_info->pan->min = 0;
|
||||
ptz_info->pan->max = 360;
|
||||
ptz_info->tilt->min = 0;
|
||||
ptz_info->tilt->max = 90;
|
||||
ptz_info->zoom->min = 1;
|
||||
ptz_info->zoom->max = 128;
|
||||
return ptz_info;
|
||||
}
|
||||
|
||||
PTZ_INFO::Ptr DaHua::get_ptz() {
|
||||
std::unique_lock<std::mutex> lock(operate_mutex_);
|
||||
if (!usable()) {
|
||||
return nullptr;
|
||||
}
|
||||
PTZ_INFO::Ptr ptz_info = PTZ_INFO::make();
|
||||
DH_PTZ_LOCATION_INFO ptz_location = {0};
|
||||
int out_len;
|
||||
CLIENT_QueryRemotDevState(login_handle_, DH_DEVSTATE_PTZ_LOCATION, DH_CHANNEL,
|
||||
(char *)&ptz_location, sizeof(ptz_location), &out_len);
|
||||
ptz_info->pan->data = ptz_location.nPTZPan / 10.0;
|
||||
ptz_info->tilt->data = ptz_location.nPTZTilt / 10.0;
|
||||
ptz_info->zoom->data = ptz_location.nPTZZoom;
|
||||
return ptz_info;
|
||||
}
|
||||
|
||||
FOV_INFO::Ptr DaHua::get_fov_range() {
|
||||
std::unique_lock<std::mutex> lock(operate_mutex_);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
FOV_INFO::Ptr DaHua::get_fov() {
|
||||
std::unique_lock<std::mutex> lock(operate_mutex_);
|
||||
if (!usable()) {
|
||||
return nullptr;
|
||||
}
|
||||
FOV_INFO::Ptr fov_info = FOV_INFO::make();
|
||||
DH_OUT_PTZ_VIEW_RANGE_STATUS ptz_view_range = {0};
|
||||
ptz_view_range.dwSize = sizeof(ptz_view_range);
|
||||
int out_len;
|
||||
CLIENT_QueryRemotDevState(login_handle_, DH_DEVSTATE_PTZ_VIEW_RANGE, DH_CHANNEL,
|
||||
(char *)&ptz_view_range, sizeof(ptz_view_range), &out_len);
|
||||
fov_info->horizontal->data = ptz_view_range.nAngelH / 10.0;
|
||||
fov_info->vertical->data = ptz_view_range.nAngelV / 10.0;
|
||||
fov_info->diagonal->data =
|
||||
sqrt(pow(fov_info->horizontal->data, 2) + pow(fov_info->vertical->data, 2));
|
||||
return fov_info;
|
||||
}
|
||||
|
||||
void DaHua::move_down(float speed) {
|
||||
std::unique_lock<std::mutex> lock(operate_mutex_);
|
||||
if (!usable()) {
|
||||
return;
|
||||
}
|
||||
CLIENT_DHPTZControlEx(login_handle_, DH_CHANNEL, DH_PTZ_DOWN_CONTROL, 0, int(speed * 100) / 14,
|
||||
0, false);
|
||||
}
|
||||
|
||||
void DaHua::stop_move() {
|
||||
std::unique_lock<std::mutex> lock(operate_mutex_);
|
||||
if (!usable()) {
|
||||
return;
|
||||
}
|
||||
CLIENT_DHPTZControlEx(login_handle_, DH_CHANNEL, DH_PTZ_UP_CONTROL, 0, 0, 0, false);
|
||||
CLIENT_DHPTZControlEx(login_handle_, DH_CHANNEL, DH_PTZ_DOWN_CONTROL, 0, 0, 0, false);
|
||||
CLIENT_DHPTZControlEx(login_handle_, DH_CHANNEL, DH_PTZ_LEFT_CONTROL, 0, 0, 0, false);
|
||||
CLIENT_DHPTZControlEx(login_handle_, DH_CHANNEL, DH_PTZ_RIGHT_CONTROL, 0, 0, 0, false);
|
||||
CLIENT_DHPTZControlEx(login_handle_, DH_CHANNEL, DH_EXTPTZ_LEFTTOP, 0, 0, 0, false);
|
||||
CLIENT_DHPTZControlEx(login_handle_, DH_CHANNEL, DH_EXTPTZ_RIGHTTOP, 0, 0, 0, false);
|
||||
CLIENT_DHPTZControlEx(login_handle_, DH_CHANNEL, DH_EXTPTZ_LEFTDOWN, 0, 0, 0, false);
|
||||
CLIENT_DHPTZControlEx(login_handle_, DH_CHANNEL, DH_EXTPTZ_RIGHTDOWN, 0, 0, 0, false);
|
||||
}
|
||||
|
||||
void DaHua::logout() {
|
||||
CLIENT_Logout(login_handle_);
|
||||
login_handle_ = -1;
|
||||
}
|
||||
|
||||
DaHua::~DaHua() {
|
||||
logout();
|
||||
CLIENT_Cleanup();
|
||||
}
|
||||
|
||||
void DaHua::move_down() {
|
||||
std::unique_lock<std::mutex> lock(operate_mutex_);
|
||||
if (!usable()) {
|
||||
return;
|
||||
}
|
||||
CLIENT_DHPTZControlEx(login_handle_, DH_CHANNEL, DH_PTZ_DOWN_CONTROL, 0, 4, 0, false);
|
||||
}
|
||||
|
||||
void DaHua::move_left(float speed) {
|
||||
std::unique_lock<std::mutex> lock(operate_mutex_);
|
||||
if (!usable()) {
|
||||
return;
|
||||
}
|
||||
CLIENT_DHPTZControlEx(login_handle_, DH_CHANNEL, DH_PTZ_LEFT_CONTROL, 0, int(speed * 100) / 14,
|
||||
0, false);
|
||||
}
|
||||
|
||||
void DaHua::move_left() {
|
||||
std::unique_lock<std::mutex> lock(operate_mutex_);
|
||||
if (!usable()) {
|
||||
return;
|
||||
}
|
||||
CLIENT_DHPTZControlEx(login_handle_, DH_CHANNEL, DH_PTZ_LEFT_CONTROL, 0, 4, 0, false);
|
||||
}
|
||||
|
||||
void DaHua::move_right(float speed) {
|
||||
std::unique_lock<std::mutex> lock(operate_mutex_);
|
||||
if (!usable()) {
|
||||
return;
|
||||
}
|
||||
CLIENT_DHPTZControlEx(login_handle_, DH_CHANNEL, DH_PTZ_RIGHT_CONTROL, 0, int(speed * 100) / 14,
|
||||
0, false);
|
||||
}
|
||||
|
||||
void DaHua::move_right() {
|
||||
std::unique_lock<std::mutex> lock(operate_mutex_);
|
||||
if (!usable()) {
|
||||
return;
|
||||
}
|
||||
CLIENT_DHPTZControlEx(login_handle_, DH_CHANNEL, DH_PTZ_RIGHT_CONTROL, 0, 4, 0, false);
|
||||
}
|
||||
|
||||
void DaHua::move_up_left(float speed) {
|
||||
std::unique_lock<std::mutex> lock(operate_mutex_);
|
||||
if (!usable()) {
|
||||
return;
|
||||
}
|
||||
CLIENT_DHPTZControlEx(login_handle_, DH_CHANNEL, DH_EXTPTZ_LEFTTOP, int(speed * 100) / 14,
|
||||
int(speed * 100) / 14, 0, false);
|
||||
}
|
||||
|
||||
void DaHua::move_up_left() {
|
||||
std::unique_lock<std::mutex> lock(operate_mutex_);
|
||||
if (!usable()) {
|
||||
return;
|
||||
}
|
||||
CLIENT_DHPTZControlEx(login_handle_, DH_CHANNEL, DH_EXTPTZ_LEFTTOP, 4, 4, 0, false);
|
||||
}
|
||||
|
||||
void DaHua::move_up_right(float speed) {
|
||||
std::unique_lock<std::mutex> lock(operate_mutex_);
|
||||
if (!usable()) {
|
||||
return;
|
||||
}
|
||||
CLIENT_DHPTZControlEx(login_handle_, DH_CHANNEL, DH_EXTPTZ_RIGHTTOP, int(speed * 100) / 14,
|
||||
int(speed * 100) / 14, 0, false);
|
||||
}
|
||||
|
||||
void DaHua::move_up_right() {
|
||||
std::unique_lock<std::mutex> lock(operate_mutex_);
|
||||
if (!usable()) {
|
||||
return;
|
||||
}
|
||||
CLIENT_DHPTZControlEx(login_handle_, DH_CHANNEL, DH_EXTPTZ_RIGHTTOP, 4, 4, 0, false);
|
||||
}
|
||||
|
||||
void DaHua::move_down_left(float speed) {
|
||||
std::unique_lock<std::mutex> lock(operate_mutex_);
|
||||
if (!usable()) {
|
||||
return;
|
||||
}
|
||||
CLIENT_DHPTZControlEx(login_handle_, DH_CHANNEL, DH_EXTPTZ_LEFTDOWN, int(speed * 100) / 14,
|
||||
int(speed * 100) / 14, 0, false);
|
||||
}
|
||||
|
||||
void DaHua::move_down_left() {
|
||||
std::unique_lock<std::mutex> lock(operate_mutex_);
|
||||
if (!usable()) {
|
||||
return;
|
||||
}
|
||||
CLIENT_DHPTZControlEx(login_handle_, DH_CHANNEL, DH_EXTPTZ_LEFTDOWN, 4, 4, 0, false);
|
||||
}
|
||||
|
||||
void DaHua::move_down_right(float speed) {
|
||||
std::unique_lock<std::mutex> lock(operate_mutex_);
|
||||
if (!usable()) {
|
||||
return;
|
||||
}
|
||||
CLIENT_DHPTZControlEx(login_handle_, DH_CHANNEL, DH_EXTPTZ_RIGHTDOWN, int(speed * 100) / 14,
|
||||
int(speed * 100) / 14, 0, false);
|
||||
}
|
||||
|
||||
void DaHua::move_down_right() {
|
||||
std::unique_lock<std::mutex> lock(operate_mutex_);
|
||||
if (!usable()) {
|
||||
return;
|
||||
}
|
||||
CLIENT_DHPTZControlEx(login_handle_, DH_CHANNEL, DH_EXTPTZ_RIGHTDOWN, 4, 4, 0, false);
|
||||
}
|
||||
|
||||
void DaHua::zoom_in(float speed) {
|
||||
std::unique_lock<std::mutex> lock(operate_mutex_);
|
||||
if (!usable()) {
|
||||
return;
|
||||
}
|
||||
CLIENT_DHPTZControlEx(login_handle_, DH_CHANNEL, DH_PTZ_ZOOM_ADD_CONTROL, int(speed * 100) / 14,
|
||||
int(speed * 100) / 14, 0, false);
|
||||
}
|
||||
|
||||
void DaHua::zoom_in() {
|
||||
std::unique_lock<std::mutex> lock(operate_mutex_);
|
||||
if (!usable()) {
|
||||
return;
|
||||
}
|
||||
CLIENT_DHPTZControlEx(login_handle_, DH_CHANNEL, DH_PTZ_ZOOM_ADD_CONTROL, 4, 4, 0, false);
|
||||
}
|
||||
|
||||
void DaHua::zoom_out(float speed) {
|
||||
std::unique_lock<std::mutex> lock(operate_mutex_);
|
||||
if (!usable()) {
|
||||
return;
|
||||
}
|
||||
CLIENT_DHPTZControlEx(login_handle_, DH_CHANNEL, DH_PTZ_ZOOM_DEC_CONTROL, int(speed * 100) / 14,
|
||||
int(speed * 100) / 14, 0, false);
|
||||
}
|
||||
|
||||
void DaHua::zoom_out() {
|
||||
std::unique_lock<std::mutex> lock(operate_mutex_);
|
||||
if (!usable()) {
|
||||
return;
|
||||
}
|
||||
CLIENT_DHPTZControlEx(login_handle_, DH_CHANNEL, DH_PTZ_ZOOM_DEC_CONTROL, 4, 4, 0, false);
|
||||
}
|
||||
|
||||
bool DaHua::snapshot(char **data, unsigned int &size) {
|
||||
std::unique_lock<std::mutex> lock(operate_mutex_);
|
||||
std::string temp_file = std::to_string(time(nullptr)) + ".jpg";
|
||||
snapshot(temp_file);
|
||||
std::FILE *fp = std::fopen(temp_file.c_str(), "rb");
|
||||
if (fp == nullptr) {
|
||||
return false;
|
||||
}
|
||||
std::fseek(fp, 0, SEEK_END);
|
||||
size = std::ftell(fp);
|
||||
*data = new char[size];
|
||||
std::fseek(fp, 0, SEEK_SET);
|
||||
std::fread(*data, 1, size, fp);
|
||||
std::fclose(fp);
|
||||
std::remove(temp_file.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
void DaHua::zoom(double zoom) {
|
||||
if (!usable()) {
|
||||
return;
|
||||
}
|
||||
PTZ_INFO::Ptr ptz_info = PTZ_INFO::make();
|
||||
ptz_info = get_ptz();
|
||||
absolute_move(ptz_info->pan->data, ptz_info->tilt->data, ptz_info->zoom->data + zoom);
|
||||
}
|
||||
|
||||
void DaHua::ptz_reset() {
|
||||
std::unique_lock<std::mutex> lock(operate_mutex_);
|
||||
if (!usable()) {
|
||||
return;
|
||||
}
|
||||
// 这不是复位,而是将当前位置设置为0
|
||||
// CLIENT_DHPTZControlEx(login_handle_, DH_CHANNEL, DH_EXTPTZ_RESETZERO, 0, 0, 0, false);
|
||||
}
|
||||
|
||||
} // namespace CC
|
433
CommonCamera/src/HikVisionImpl.cpp
Normal file
433
CommonCamera/src/HikVisionImpl.cpp
Normal file
@ -0,0 +1,433 @@
|
||||
//
|
||||
// Created by 张宇衡 on 2023/4/14.
|
||||
//
|
||||
|
||||
|
||||
#include "HikVision.h"
|
||||
|
||||
namespace CC {
|
||||
|
||||
HikVision::HikVision(std::string ip, std::string username, std::string password)
|
||||
: ip_(std::move(ip)), username_(std::move(username)), password_(std::move(password)) {
|
||||
NET_DVR_Init();
|
||||
login();
|
||||
}
|
||||
|
||||
HikVision::~HikVision() {
|
||||
logout();
|
||||
NET_DVR_Cleanup();
|
||||
}
|
||||
|
||||
PTZ_INFO::Ptr HikVision::get_ptz_range() {
|
||||
std::unique_lock<std::mutex> lock(operate_mutex_);
|
||||
if (!usable()) {
|
||||
return nullptr;
|
||||
}
|
||||
PTZ_INFO::Ptr ptz = PTZ_INFO::make();
|
||||
NET_DVR_PTZSCOPE struct_ptz_scope = {0};
|
||||
DWORD out_size;
|
||||
if (!NET_DVR_GetDVRConfig(user_id_, NET_DVR_GET_PTZSCOPE, HK_CHANNEL, &struct_ptz_scope,
|
||||
sizeof(struct_ptz_scope), &out_size)) {
|
||||
return nullptr;
|
||||
}
|
||||
ptz->pan->min = convert_hex_to_double(struct_ptz_scope.wPanPosMin);
|
||||
ptz->pan->max = convert_hex_to_double(struct_ptz_scope.wPanPosMax);
|
||||
ptz->tilt->min = convert_hex_to_double(struct_ptz_scope.wTiltPosMin);
|
||||
ptz->tilt->max = convert_hex_to_double(struct_ptz_scope.wTiltPosMax);
|
||||
ptz->zoom->min = convert_hex_to_double(struct_ptz_scope.wZoomPosMin);
|
||||
ptz->zoom->max = convert_hex_to_double(struct_ptz_scope.wZoomPosMax);
|
||||
return ptz;
|
||||
}
|
||||
|
||||
PTZ_INFO::Ptr HikVision::get_ptz() {
|
||||
std::unique_lock<std::mutex> lock(operate_mutex_);
|
||||
if (!usable()) {
|
||||
return nullptr;
|
||||
}
|
||||
PTZ_INFO::Ptr ptz = PTZ_INFO::make();
|
||||
NET_DVR_PTZPOS struct_ptz_pos = {0};
|
||||
DWORD re;
|
||||
if (!NET_DVR_GetDVRConfig(user_id_, NET_DVR_GET_PTZPOS, HK_CHANNEL, &struct_ptz_pos,
|
||||
sizeof(struct_ptz_pos), &re)) {
|
||||
return nullptr;
|
||||
}
|
||||
ptz->pan->data = convert_hex_to_double(struct_ptz_pos.wPanPos);
|
||||
ptz->tilt->data = convert_hex_to_double(struct_ptz_pos.wTiltPos);
|
||||
ptz->zoom->data = convert_hex_to_double(struct_ptz_pos.wZoomPos);
|
||||
return ptz;
|
||||
}
|
||||
|
||||
FOV_INFO::Ptr HikVision::get_fov_range() {
|
||||
std::unique_lock<std::mutex> lock(operate_mutex_);
|
||||
if (!usable()) {
|
||||
return nullptr;
|
||||
}
|
||||
FOV_INFO::Ptr fov = FOV_INFO::make();
|
||||
NET_DVR_STD_CONFIG struct_cfg = {nullptr};
|
||||
NET_DVR_GIS_INFO struct_gis_info = {0};
|
||||
int channel = HK_CHANNEL;
|
||||
struct_cfg.lpInBuffer = nullptr;
|
||||
struct_cfg.dwInSize = 0;
|
||||
struct_cfg.lpCondBuffer = &channel;
|
||||
struct_cfg.dwCondSize = 4;
|
||||
struct_cfg.lpOutBuffer = &struct_gis_info;
|
||||
struct_cfg.dwOutSize = sizeof(struct_gis_info);
|
||||
if (!NET_DVR_GetSTDConfig(user_id_, NET_DVR_GET_GISINFO, &struct_cfg)) {
|
||||
return nullptr;
|
||||
}
|
||||
fov->horizontal->min = struct_gis_info.fMinHorizontalValue;
|
||||
fov->horizontal->max = struct_gis_info.fMaxHorizontalValue;
|
||||
fov->vertical->min = struct_gis_info.fMinVerticalValue;
|
||||
fov->vertical->max = struct_gis_info.fMaxVerticalValue;
|
||||
fov->diagonal->min = sqrt(pow(struct_gis_info.fMinHorizontalValue, 2) +
|
||||
pow(struct_gis_info.fMinVerticalValue, 2));
|
||||
fov->diagonal->max = sqrt(pow(struct_gis_info.fMaxHorizontalValue, 2) +
|
||||
pow(struct_gis_info.fMaxVerticalValue, 2));
|
||||
return fov;
|
||||
}
|
||||
|
||||
FOV_INFO::Ptr HikVision::get_fov() {
|
||||
std::unique_lock<std::mutex> lock(operate_mutex_);
|
||||
if (!usable())
|
||||
return nullptr;
|
||||
FOV_INFO::Ptr fov = FOV_INFO::make();
|
||||
NET_DVR_STD_CONFIG struct_cfg = {nullptr};
|
||||
NET_DVR_GIS_INFO struct_gis_info = {0};
|
||||
int channel = HK_CHANNEL;
|
||||
struct_cfg.lpInBuffer = nullptr;
|
||||
struct_cfg.dwInSize = 0;
|
||||
struct_cfg.lpCondBuffer = &channel;
|
||||
struct_cfg.dwCondSize = 4;
|
||||
struct_cfg.lpOutBuffer = &struct_gis_info;
|
||||
struct_cfg.dwOutSize = sizeof(struct_gis_info);
|
||||
if (!NET_DVR_GetSTDConfig(user_id_, NET_DVR_GET_GISINFO, &struct_cfg)) {
|
||||
return nullptr;
|
||||
}
|
||||
fov->horizontal->data = struct_gis_info.fHorizontalValue;
|
||||
fov->vertical->data = struct_gis_info.fVerticalValue;
|
||||
fov->diagonal->data =
|
||||
sqrt(pow(struct_gis_info.fHorizontalValue, 2) + pow(struct_gis_info.fVerticalValue, 2));
|
||||
return fov;
|
||||
}
|
||||
|
||||
bool HikVision::usable() {
|
||||
std::unique_lock<std::mutex> lock(usable_mutex_);
|
||||
if (user_id_ >= 0) {
|
||||
// 如果已经是登录过的重新尝试登录避免因为超时导致的操作失败
|
||||
logout();
|
||||
login();
|
||||
}
|
||||
if (user_id_ < 0) {
|
||||
login();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void HikVision::absolute_move(double pan, double tilt, double zoom) {
|
||||
std::unique_lock<std::mutex> lock(operate_mutex_);
|
||||
if (!usable()) {
|
||||
return;
|
||||
}
|
||||
NET_DVR_PTZPOS struct_ptz_pos = {0};
|
||||
struct_ptz_pos.wPanPos = convert_double_to_hex(pan);
|
||||
struct_ptz_pos.wTiltPos = convert_double_to_hex(tilt);
|
||||
struct_ptz_pos.wZoomPos = convert_double_to_hex(zoom);
|
||||
struct_ptz_pos.wAction = 1;
|
||||
NET_DVR_SetDVRConfig(user_id_, NET_DVR_SET_PTZPOS, HK_CHANNEL, &struct_ptz_pos,
|
||||
sizeof(struct_ptz_pos));
|
||||
}
|
||||
|
||||
void HikVision::relative_move(double pan, double tilt) {
|
||||
if (!usable()) {
|
||||
return;
|
||||
}
|
||||
PTZ_INFO::Ptr current = get_ptz();
|
||||
if (current == nullptr) {
|
||||
return;
|
||||
}
|
||||
PTZ_INFO::Ptr absolute = PTZ_INFO::make();
|
||||
absolute->pan->data = current->pan->data + pan;
|
||||
absolute->tilt->data = current->tilt->data + tilt;
|
||||
absolute_move(absolute->pan->data, absolute->tilt->data, current->zoom->data);
|
||||
}
|
||||
|
||||
void HikVision::move_up(float speed) {
|
||||
std::unique_lock<std::mutex> lock(operate_mutex_);
|
||||
if (!usable()) {
|
||||
return;
|
||||
}
|
||||
NET_DVR_PTZControlWithSpeed_Other(user_id_, HK_CHANNEL, TILT_UP, 0, int(speed * 100) / 14);
|
||||
}
|
||||
|
||||
void HikVision::move_up() {
|
||||
std::unique_lock<std::mutex> lock(operate_mutex_);
|
||||
if (!usable()) {
|
||||
return;
|
||||
}
|
||||
NET_DVR_PTZControl_Other(user_id_, HK_CHANNEL, TILT_UP, 0);
|
||||
}
|
||||
|
||||
void HikVision::move_down(float speed) {
|
||||
std::unique_lock<std::mutex> lock(operate_mutex_);
|
||||
if (!usable()) {
|
||||
return;
|
||||
}
|
||||
NET_DVR_PTZControlWithSpeed_Other(user_id_, HK_CHANNEL, TILT_DOWN, 0,
|
||||
int(speed * 100) / 14);
|
||||
}
|
||||
|
||||
void HikVision::move_down() {
|
||||
std::unique_lock<std::mutex> lock(operate_mutex_);
|
||||
if (!usable()) {
|
||||
return;
|
||||
}
|
||||
NET_DVR_PTZControl_Other(user_id_, HK_CHANNEL, TILT_DOWN, 0);
|
||||
}
|
||||
|
||||
void HikVision::move_left(float speed) {
|
||||
std::unique_lock<std::mutex> lock(operate_mutex_);
|
||||
if (!usable()) {
|
||||
return;
|
||||
}
|
||||
NET_DVR_PTZControlWithSpeed_Other(user_id_, HK_CHANNEL, PAN_LEFT, 0, int(speed * 100) / 14);
|
||||
}
|
||||
|
||||
void HikVision::move_left() {
|
||||
std::unique_lock<std::mutex> lock(operate_mutex_);
|
||||
if (!usable()) {
|
||||
return;
|
||||
}
|
||||
NET_DVR_PTZControl_Other(user_id_, HK_CHANNEL, PAN_LEFT, 0);
|
||||
}
|
||||
|
||||
void HikVision::move_right(float speed) {
|
||||
std::unique_lock<std::mutex> lock(operate_mutex_);
|
||||
if (!usable()) {
|
||||
return;
|
||||
}
|
||||
NET_DVR_PTZControlWithSpeed_Other(user_id_, HK_CHANNEL, PAN_RIGHT, 0,
|
||||
int(speed * 100) / 14);
|
||||
}
|
||||
|
||||
void HikVision::move_right() {
|
||||
std::unique_lock<std::mutex> lock(operate_mutex_);
|
||||
if (!usable()) {
|
||||
return;
|
||||
}
|
||||
NET_DVR_PTZControl_Other(user_id_, HK_CHANNEL, PAN_RIGHT, 0);
|
||||
}
|
||||
|
||||
void HikVision::move_up_left(float speed) {
|
||||
std::unique_lock<std::mutex> lock(operate_mutex_);
|
||||
if (!usable()) {
|
||||
return;
|
||||
}
|
||||
NET_DVR_PTZControlWithSpeed_Other(user_id_, HK_CHANNEL, UP_LEFT, 0, int(speed * 100) / 14);
|
||||
}
|
||||
|
||||
void HikVision::move_up_left() {
|
||||
std::unique_lock<std::mutex> lock(operate_mutex_);
|
||||
if (!usable()) {
|
||||
return;
|
||||
}
|
||||
NET_DVR_PTZControl_Other(user_id_, HK_CHANNEL, UP_LEFT, 0);
|
||||
}
|
||||
|
||||
void HikVision::move_up_right(float speed) {
|
||||
std::unique_lock<std::mutex> lock(operate_mutex_);
|
||||
if (!usable()) {
|
||||
return;
|
||||
}
|
||||
NET_DVR_PTZControlWithSpeed_Other(user_id_, HK_CHANNEL, UP_RIGHT, 0, int(speed * 100) / 14);
|
||||
}
|
||||
|
||||
void HikVision::move_up_right() {
|
||||
std::unique_lock<std::mutex> lock(operate_mutex_);
|
||||
if (!usable()) {
|
||||
return;
|
||||
}
|
||||
NET_DVR_PTZControl_Other(user_id_, HK_CHANNEL, UP_RIGHT, 0);
|
||||
}
|
||||
|
||||
void HikVision::move_down_left(float speed) {
|
||||
std::unique_lock<std::mutex> lock(operate_mutex_);
|
||||
if (!usable()) {
|
||||
return;
|
||||
}
|
||||
NET_DVR_PTZControlWithSpeed_Other(user_id_, HK_CHANNEL, DOWN_LEFT, 0,
|
||||
int(speed * 100) / 14);
|
||||
}
|
||||
|
||||
void HikVision::move_down_left() {
|
||||
std::unique_lock<std::mutex> lock(operate_mutex_);
|
||||
if (!usable()) {
|
||||
return;
|
||||
}
|
||||
NET_DVR_PTZControl_Other(user_id_, HK_CHANNEL, DOWN_LEFT, 0);
|
||||
}
|
||||
|
||||
void HikVision::move_down_right(float speed) {
|
||||
std::unique_lock<std::mutex> lock(operate_mutex_);
|
||||
if (!usable()) {
|
||||
return;
|
||||
}
|
||||
NET_DVR_PTZControlWithSpeed_Other(user_id_, HK_CHANNEL, DOWN_RIGHT, 0,
|
||||
int(speed * 100) / 14);
|
||||
}
|
||||
|
||||
void HikVision::move_down_right() {
|
||||
std::unique_lock<std::mutex> lock(operate_mutex_);
|
||||
if (!usable()) {
|
||||
return;
|
||||
}
|
||||
NET_DVR_PTZControl_Other(user_id_, HK_CHANNEL, DOWN_RIGHT, 0);
|
||||
}
|
||||
|
||||
void HikVision::zoom_in(float speed) {
|
||||
std::unique_lock<std::mutex> lock(operate_mutex_);
|
||||
if (!usable()) {
|
||||
return;
|
||||
}
|
||||
NET_DVR_PTZControlWithSpeed_Other(user_id_, HK_CHANNEL, ZOOM_IN, 0, int(speed * 100) / 14);
|
||||
}
|
||||
|
||||
void HikVision::zoom_in() {
|
||||
std::unique_lock<std::mutex> lock(operate_mutex_);
|
||||
if (!usable()) {
|
||||
return;
|
||||
}
|
||||
NET_DVR_PTZControl_Other(user_id_, HK_CHANNEL, ZOOM_IN, 0);
|
||||
}
|
||||
|
||||
void HikVision::zoom_out(float speed) {
|
||||
std::unique_lock<std::mutex> lock(operate_mutex_);
|
||||
if (!usable()) {
|
||||
return;
|
||||
}
|
||||
NET_DVR_PTZControlWithSpeed_Other(user_id_, HK_CHANNEL, ZOOM_OUT, 0, int(speed * 100) / 14);
|
||||
}
|
||||
|
||||
void HikVision::zoom_out() {
|
||||
std::unique_lock<std::mutex> lock(operate_mutex_);
|
||||
if (!usable()) {
|
||||
return;
|
||||
}
|
||||
NET_DVR_PTZControl_Other(user_id_, HK_CHANNEL, ZOOM_OUT, 0);
|
||||
}
|
||||
|
||||
void HikVision::stop_move() {
|
||||
std::unique_lock<std::mutex> lock(operate_mutex_);
|
||||
if (!usable()) {
|
||||
return;
|
||||
}
|
||||
NET_DVR_PTZControl_Other(user_id_, HK_CHANNEL, PAN_RIGHT, 1);
|
||||
NET_DVR_PTZControl_Other(user_id_, HK_CHANNEL, PAN_LEFT, 1);
|
||||
NET_DVR_PTZControl_Other(user_id_, HK_CHANNEL, TILT_UP, 1);
|
||||
NET_DVR_PTZControl_Other(user_id_, HK_CHANNEL, TILT_DOWN, 1);
|
||||
NET_DVR_PTZControl_Other(user_id_, HK_CHANNEL, UP_LEFT, 1);
|
||||
NET_DVR_PTZControl_Other(user_id_, HK_CHANNEL, UP_RIGHT, 1);
|
||||
NET_DVR_PTZControl_Other(user_id_, HK_CHANNEL, DOWN_LEFT, 1);
|
||||
NET_DVR_PTZControl_Other(user_id_, HK_CHANNEL, DOWN_RIGHT, 1);
|
||||
NET_DVR_PTZControl_Other(user_id_, HK_CHANNEL, ZOOM_IN, 1);
|
||||
NET_DVR_PTZControl_Other(user_id_, HK_CHANNEL, ZOOM_OUT, 1);
|
||||
}
|
||||
|
||||
void HikVision::zoom(double zoom) {
|
||||
if (!usable()) {
|
||||
return;
|
||||
}
|
||||
PTZ_INFO::Ptr current = get_ptz();
|
||||
if (current == nullptr) {
|
||||
return;
|
||||
}
|
||||
PTZ_INFO::Ptr absolute = PTZ_INFO::make();
|
||||
absolute->zoom->data = current->zoom->data + zoom;
|
||||
absolute_move(absolute->pan->data, absolute->tilt->data, current->zoom->data);
|
||||
}
|
||||
|
||||
void HikVision::auto_focus() {
|
||||
std::unique_lock<std::mutex> lock(operate_mutex_);
|
||||
if (!usable()) {
|
||||
return;
|
||||
}
|
||||
NET_DVR_FocusOnePush(user_id_, HK_CHANNEL);
|
||||
}
|
||||
|
||||
std::string HikVision::get_stream_url() {
|
||||
return "";
|
||||
}
|
||||
|
||||
void HikVision::ptz_reset() {
|
||||
std::unique_lock<std::mutex> lock(operate_mutex_);
|
||||
if (!usable()) {
|
||||
return;
|
||||
}
|
||||
NET_DVR_ResetLens(user_id_, HK_CHANNEL);
|
||||
}
|
||||
|
||||
bool HikVision::snapshot(char **data, unsigned int &size) {
|
||||
std::unique_lock<std::mutex> lock(operate_mutex_);
|
||||
if (!usable()) {
|
||||
return false;
|
||||
}
|
||||
NET_DVR_JPEGPARA struct_jpeg_picture = {0};
|
||||
struct_jpeg_picture.wPicSize = 0xff;
|
||||
struct_jpeg_picture.wPicQuality = 1;
|
||||
*data = (char *)malloc(1024 * 1024 * 2);
|
||||
if (!NET_DVR_CaptureJPEGPicture_NEW(user_id_, HK_CHANNEL, &struct_jpeg_picture, *data,
|
||||
1024 * 1024 * 2, &size)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void HikVision::login() {
|
||||
NET_DVR_USER_LOGIN_INFO struct_login_info = {0};
|
||||
NET_DVR_DEVICEINFO_V40 struct_device_info_V40 = {0};
|
||||
struct_login_info.bUseAsynLogin = false;
|
||||
struct_login_info.wPort = 8000;
|
||||
memcpy(struct_login_info.sDeviceAddress, ip_.c_str(), NET_DVR_DEV_ADDRESS_MAX_LEN);
|
||||
memcpy(struct_login_info.sUserName, username_.c_str(), NAME_LEN);
|
||||
memcpy(struct_login_info.sPassword, password_.c_str(), NAME_LEN);
|
||||
user_id_ = NET_DVR_Login_V40(&struct_login_info, &struct_device_info_V40);
|
||||
}
|
||||
|
||||
void HikVision::logout() {
|
||||
NET_DVR_Logout_V30(user_id_);
|
||||
user_id_ = -1;
|
||||
}
|
||||
|
||||
double HikVision::convert_hex_to_double(int hex_num) {
|
||||
std::stringstream ss;
|
||||
ss << std::hex << hex_num; // 将16进制数转换为字符串
|
||||
std::string hex_str = ss.str(); // 获取字符串
|
||||
return std::stoi(hex_str) / 10.0;
|
||||
}
|
||||
|
||||
int HikVision::convert_double_to_hex(double double_num) {
|
||||
std::stringstream ss;
|
||||
ss << "0x" << int(double_num * 10);
|
||||
int hex_num;
|
||||
ss >> std::hex >> hex_num;
|
||||
return hex_num;
|
||||
}
|
||||
|
||||
bool HikVision::snapshot(const std::string &path) {
|
||||
std::unique_lock<std::mutex> lock(operate_mutex_);
|
||||
char *data;
|
||||
unsigned int size;
|
||||
if (!snapshot(&data, size)) {
|
||||
return false;
|
||||
}
|
||||
// 写入文件
|
||||
std::FILE *fp = std::fopen(path.c_str(), "wb");
|
||||
if (fp == nullptr) {
|
||||
return false;
|
||||
}
|
||||
std::fwrite(data, size, 1, fp);
|
||||
std::fclose(fp);
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace CC
|
36
README.md
Normal file
36
README.md
Normal file
@ -0,0 +1,36 @@
|
||||
# CommonCamera 通用相机SDK
|
||||
|
||||
## 介绍
|
||||
|
||||
对相机不同相机厂商的SDK进行封装,提供统一的接口,方便项目开发使用。
|
||||
|
||||
## 使用方法
|
||||
|
||||
1. 将 CommonCamera 目录复制到项目依赖下;
|
||||
2. Cmake 中添加依赖;
|
||||
```cmake
|
||||
include_directories(your/proj/path/CommonCamera/include)
|
||||
file(GLOB_RECURSE COMMON_CAMERA_LIBS your/proj/path/CommonCamera/lib/*.so)
|
||||
|
||||
target_link_libraries(your_target ${COMMON_CAMERA_LIBS})
|
||||
```
|
||||
3. 在代码中使用
|
||||
```c++
|
||||
#include <CommonCamera.h>
|
||||
|
||||
// 所有相机都被封装成 CC::Camera 抽象类便于统一操作
|
||||
std::vector<CC::Camera::Ptr> cameras;
|
||||
|
||||
// 创建一个大华相机
|
||||
cameras.push_back(CC::make_dahua_camera("192.168.1.12", "username", "pass"));
|
||||
// 创建一个海康相机
|
||||
cameras.push_back(CC::make_hikvision_camera("192.168.1.12", "username", "pass"));
|
||||
```
|
||||
|
||||
## 目前支持的相机厂商
|
||||
|
||||
- 大华 `Camera::Ptr make_hikvision_camera(const std::string &ip, const std::string &username, const std::string &password);`
|
||||
- 海康 `Camera::Ptr make_dahua_camera(const std::string &ip, const std::string &username, const std::string &password);`
|
||||
|
||||
## 目前支持的相机功能
|
||||
|
13
tests/main.cpp
Normal file
13
tests/main.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
#include <CommonCamera.h>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
|
||||
int main() {
|
||||
auto cam = CC::make_dahua_camera("192.168.163.4", "admin", "eccom123");
|
||||
std::cout<<cam->get_ptz_info()->str()<<std::endl;
|
||||
cam->zoom(50);
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds (10000));
|
||||
std::cout<<cam->get_ptz_info()->str()<<std::endl;
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user