分离 Cpp 和 Go 的分支

This commit is contained in:
kunmeng 2025-01-08 09:32:58 +08:00
parent 41d8da2401
commit 429a9ed8ec
38 changed files with 5 additions and 160680 deletions

View File

@ -1,7 +0,0 @@
/.idea
/.git
/cmake-build-debug-visual-studio
/V6.1.9.45_build20220902_ArmLinux64_ZH_20240802154010_lib.zip
/V6.1.9.48_build20230410_linux64_20240829112751_lib.zip
/V6.1.9.48_build20230410_win64_20240829112623_lib.zip
/build

2
.gitignore vendored
View File

@ -1,8 +1,6 @@
/.idea
/.cache
/.fleet
/cmake-build-debug-visual-studio
/cmake-build-release-visual-studio
*.lib
*.dll
*.so

View File

@ -1,64 +0,0 @@
cmake_minimum_required(VERSION 3.15)
project(HikNetSDKPkg CXX)
set(CMAKE_CXX_STANDARD 11)
set(OS ${CMAKE_HOST_SYSTEM_NAME})
set(Arch ${CMAKE_HOST_SYSTEM_PROCESSOR})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/build)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/build)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/build)
message(STATUS "Target Operating System: ${OS}")
message(STATUS "Target Architecture: ${Arch}")
if(OS STREQUAL "Windows")
set(CMAKE_DEBUG_POSTFIX "_win_amd64_d")
set(CMAKE_RELEASE_POSTFIX "_win_amd64")
elseif (Arch STREQUAL "x86_64" OR Arch STREQUAL "amd64")
set(CMAKE_DEBUG_POSTFIX "_linux_amd64_d")
set(CMAKE_RELEASE_POSTFIX "_linux_amd64")
elseif (Arch STREQUAL "aarch64" OR Arch STREQUAL "arm64")
set(CMAKE_DEBUG_POSTFIX "_linux_arm64_d")
set(CMAKE_RELEASE_POSTFIX "_linux_arm64")
endif ()
add_library(HikNetSDKPkg SHARED
library.cpp
src/HIKBallCamera.cpp
src/HIKBase.cpp
src/HIKNvr.cpp
src/FormatTrans.cpp
)
target_compile_definitions(HikNetSDKPkg PRIVATE Export)
if(Arch STREQUAL "x86_64" OR OS STREQUAL "Windows")
target_include_directories(HikNetSDKPkg PRIVATE "./src/include/Hik/amd64")
elseif (Arch STREQUAL "aarch64")
target_include_directories(HikNetSDKPkg PRIVATE "./src/include/Hik/arm64")
endif ()
if(OS STREQUAL "Windows")
target_link_directories(HikNetSDKPkg PRIVATE "./arm64_windows_lib")
target_link_libraries(HikNetSDKPkg PRIVATE "HCNetSDK.lib")
target_link_libraries(HikNetSDKPkg PRIVATE "HCCore.lib")
target_link_libraries(HikNetSDKPkg PRIVATE "GdiPlus.lib")
elseif (Arch STREQUAL "x86_64" OR Arch STREQUAL "amd64")
target_link_directories(HikNetSDKPkg PRIVATE "./amd64_linux_lib")
target_link_libraries(HikNetSDKPkg PRIVATE "libHCCore.so")
target_link_libraries(HikNetSDKPkg PRIVATE "libhcnetsdk.so")
target_link_libraries(HikNetSDKPkg PRIVATE "libhpr.so")
target_link_libraries(HikNetSDKPkg PRIVATE "libz.so")
elseif (Arch STREQUAL "aarch64")
target_link_directories(HikNetSDKPkg PRIVATE "./arm64_linux_lib")
target_link_libraries(HikNetSDKPkg PRIVATE "libAudioRender.so")
target_link_libraries(HikNetSDKPkg PRIVATE "libcrypto.so")
target_link_libraries(HikNetSDKPkg PRIVATE "libHCCore.so")
target_link_libraries(HikNetSDKPkg PRIVATE "libhcnetsdk.so")
target_link_libraries(HikNetSDKPkg PRIVATE "libhpr.so")
target_link_libraries(HikNetSDKPkg PRIVATE "libPlayCtrl.so")
target_link_libraries(HikNetSDKPkg PRIVATE "libssl.so")
target_link_libraries(HikNetSDKPkg PRIVATE "libSuperRender.so")
target_link_libraries(HikNetSDKPkg PRIVATE "libz.so")
endif ()

View File

@ -1,22 +0,0 @@
FROM r-2.top/alpine:3.19 AS deps
WORKDIR /usr
RUN apk add gcc g++ cmake make acl
FROM r-2.top/alpine:3.19 AS build
WORKDIR /hikbuild
COPY --from=deps /usr /usr
COPY --from=deps /lib /lib
COPY . /hikbuild
RUN cmake . -D Arch=${TARGETARCH} -D CMAKE_BUILD_TYPE=RELEASE && make
FROM r-2.top/alpine:3.19 AS export
WORKDIR /home
COPY --from=build /hikbuild/build /home
#docker buildx build --platform linux/amd64,linux/arm64 --output type=local,dest=/hikbuild/ .

View File

@ -54,12 +54,12 @@ func getSystemLibrary() string {
switch runtime.GOOS {
case "linux":
if runtime.GOARCH == "amd64" || runtime.GOARCH == "386" {
return "libHikNetSDKPkg_linux_amd64.so"
return "./libHikNetSDKPkg_linux_amd64.so"
} else {
return "libHikNetSDKPkg_linux_arm64.so"
return "./libHikNetSDKPkg_linux_arm64.so"
}
case "windows":
return "HikNetSDKPkg_win_amd64.dll"
return "./HikNetSDKPkg_win_amd64.dll"
default:
panic(fmt.Errorf("GOOS=%s is not supported", runtime.GOOS))
}

2
go.mod
View File

@ -2,4 +2,4 @@ module gitea.com/kunmeng/HikNetSDKPkg
go 1.23.1
require github.com/ebitengine/purego v0.8.0
require github.com/ebitengine/purego v0.8.1

3
go.sum
View File

@ -1,2 +1 @@
github.com/ebitengine/purego v0.8.0 h1:JbqvnEzRvPpxhCJzJJ2y0RbiZ8nyjccVUrSM3q+GvvE=
github.com/ebitengine/purego v0.8.0/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ=
github.com/ebitengine/purego v0.8.1/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ=

View File

@ -1,38 +0,0 @@
#ifndef HIKVISION_NETWORK_SDK_PACKAGING_LIBRARY_LIBRARY_H
#define HIKVISION_NETWORK_SDK_PACKAGING_LIBRARY_LIBRARY_H
#ifdef _WIN32
#ifdef Export
#define Omnimatrix __declspec(dllexport)
#else
#define Omnimatrix __declspec(dllimport)
#endif
#else
#define Omnimatrix
#endif
#ifdef __cplusplus
extern "C" {
#endif
Omnimatrix bool DVR_Init();
Omnimatrix void* NewHIKBallCamera();
Omnimatrix bool InitBallCamera(void* PtrHIKBallCamera,const char* ip, const char* port,const char* username,const char* password,const char* BallMachineType);
Omnimatrix bool PtzGotoPut(void* PtrHIKBallCamera,int Action, float P, float T, float Z);
Omnimatrix bool PtzGet(void* PtrHIKBallCamera,void *P, void *T, void *Z);
Omnimatrix bool StopBus(void* PtrHIKBallCamera,int direction);
Omnimatrix bool StartBus(void* PtrHIKBallCamera,int direction,int speed);
Omnimatrix void* NewHIKNvr();
Omnimatrix bool InitNvr(void* PtrHIKNvr,char* ip, char* port, char* username, char* password, int channel);
Omnimatrix char* CheckTimeRegionWithMonth(void* PtrHIKNvr,int year,int month);
Omnimatrix char* CheckTimeRegionWithDay(void* PtrHIKNvr,int year,int month,int day);
Omnimatrix int NvrUTCDiff(void* PtrHIKNvr);
#ifdef __cplusplus
}
#endif
#endif //HIKVISION_NETWORK_SDK_PACKAGING_LIBRARY_LIBRARY_H

View File

@ -1,93 +0,0 @@
#include "include/library.h"
#include "./src/HIKBallCamera.h"
#include "src/HIKNvr.h"
#include <cstring>
bool DVR_Init() {
return HK_DVR_Init();
}
void *NewHIKBallCamera() {
return new HIKBallCamera();
}
bool InitBallCamera(void *PtrHIKBallCamera, const char *ip, const char *port, const char *username, const char *password, const char *BallMachineType) {
auto *HIKBallCameraObj = (HIKBallCamera *)PtrHIKBallCamera;
return HIKBallCameraObj->InitBallCamera(ip, port, username, password, BallMachineType);
}
bool PtzGotoPut(void *PtrHIKBallCamera, int Action, float P, float T, float Z) {
auto *HIKBallCameraObj = (HIKBallCamera *)PtrHIKBallCamera;
return HIKBallCameraObj->PtzGotoPut(Action, P, T, Z);
}
bool PtzGet(void *PtrHIKBallCamera, void *P, void *T, void *Z) {
auto *HIKBallCameraObj = (HIKBallCamera *)PtrHIKBallCamera;
return HIKBallCameraObj->PtzGet((float *)P, (float *)T, (float *)Z);
}
bool StopBus(void *PtrHIKBallCamera, int direction) {
auto *HIKBallCameraObj = (HIKBallCamera *)PtrHIKBallCamera;
return HIKBallCameraObj->StopBus(direction);
}
bool StartBus(void *PtrHIKBallCamera, int direction, int speed) {
auto *HIKBallCameraObj = (HIKBallCamera *)PtrHIKBallCamera;
return HIKBallCameraObj->StartBus(direction, speed);
}
void *NewHIKNvr() {
return new HIKNvr();
}
bool InitNvr(void *PtrHIKNvr, char *ip, char *port, char *username, char *password, int channel) {
auto *HIKNvrObj = (HIKNvr *)PtrHIKNvr;
return HIKNvrObj->InitNvr(ip, port, username, password, channel);
}
char *CheckTimeRegionWithMonth(void *PtrHIKNvr, int year, int month) {
auto *HIKNvrObj = (HIKNvr *)PtrHIKNvr;
DateTime select_time;
select_time.year() = year;
select_time.month() = month;
std::string res;
//check the time region with month
int nRet = 0;
std::vector<int> available_date_vec;
nRet = HIKNvrObj->CheckTimeRegionWithMonth(select_time, available_date_vec);
if (nRet == 0) {
res = HIKNvrObj->TimeToJson(select_time, &available_date_vec).dump();
}else{
res = "";
}
char *cString = new char[res.size() + 1];
std::strcpy(cString, res.c_str());
return cString;
}
char *CheckTimeRegionWithDay(void *PtrHIKNvr, int year, int month, int day) {
auto *HIKNvrObj = (HIKNvr *)PtrHIKNvr;
DateTime select_time;
select_time.year() = year;
select_time.month() = month;
select_time.day() = day;
std::string res;
std::vector<TimeRecord> available_time_vec;
int nRet = HIKNvrObj->CheckTimeRegionWithDay(select_time, available_time_vec);
if (nRet == 0) {
res = HIKNvrObj->TimeToJsonInDay(select_time, &available_time_vec).dump();
}else{
res = "";
}
char *cString = new char[res.size() + 1];
std::strcpy(cString, res.c_str());
return cString;
}
int NvrUTCDiff(void *PtrHIKNvr) {
auto *HIKNvrObj = (HIKNvr *)PtrHIKNvr;
return HIKNvrObj->GetNvrUTCDiff();
}

View File

@ -1,123 +0,0 @@
#pragma once
#include <iostream>
#include <string>
//
class DateTime
{
public:
DateTime(int year, int month, int day, int hour, int minute, int second)
{
SetDateTime(year, month, day, hour, minute, second);
}
DateTime()
{
SetDateTime(0, 0, 0, 0, 0, 0);
}
~DateTime() {}
// Set date and time
void SetDateTime(int year, int month, int day, int hour, int minute, int second)
{
m_year = year;
m_month = month;
m_day = day;
m_hour = hour;
m_minute = minute;
m_second = second;
}
//copy constructor
DateTime(const DateTime& other)
{
m_year = other.m_year;
m_month = other.m_month;
m_day = other.m_day;
m_hour = other.m_hour;
m_minute = other.m_minute;
m_second = other.m_second;
}
DateTime& operator=(const DateTime& other)
{
m_year = other.m_year;
m_month = other.m_month;
m_day = other.m_day;
m_hour = other.m_hour;
m_minute = other.m_minute;
m_second = other.m_second;
return *this;
}
// Get date and time
std::string GetDateTime()
{
return std::to_string(m_year) + "-" + std::to_string(m_month) + "-" + std::to_string(m_day) + " " + std::to_string(m_hour) + ":" + std::to_string(m_minute) + ":" + std::to_string(m_second);
}
// 比较两个对象
int CompareTo(DateTime other)
{
if (m_year != other.m_year)
{
return m_year < other.m_year ? -1 : 1;
}
if (m_month != other.m_month)
{
return m_month < other.m_month ? -1 : 1;
}
if (m_day != other.m_day)
{
return m_day < other.m_day ? -1 : 1;
}
if (m_hour != other.m_hour)
{
return m_hour < other.m_hour ? -1 : 1;
}
if (m_minute != other.m_minute)
{
return m_minute < other.m_minute ? -1 : 1;
}
if (m_second != other.m_second)
{
return m_second < other.m_second ? -1 : 1;
}
return 0;
}
// < Operator overwrite
bool operator<(const DateTime& other)
{
return CompareTo(other) < 0;
}
// > Operator overwrite
bool operator>(const DateTime& other)
{
return CompareTo(other) > 0;
}
// == Operator overwrite
bool operator==(const DateTime& other)
{
return CompareTo(other) == 0;
}
// 访问私有成员
int& year() { return m_year; }
int& month() { return m_month; }
int& day() { return m_day; }
int& hour() { return m_hour; }
int& minute() { return m_minute; }
int& second() { return m_second; }
private:
int m_year;
int m_month;
int m_day;
int m_hour;
int m_minute;
int m_second;
};

View File

@ -1,43 +0,0 @@
#pragma once
#include <thread>
#include <chrono>
#define SLEEP(x) std::this_thread::sleep_for(std::chrono::seconds(x));
#ifdef _WIN32_
#include <windows.h>
#ifdef OmnimatrixExport
#define Omnimatrix __declspec(dllexport)
#else
#define Omnimatrix __declspec(dllimport)
#endif
#define STRCPY(Dst, Len, Src) strcpy_s(Dst, Len, Src)
#define LOCAL_TIME(in, out) localtime_s(in,out);
#define LOCAL_MIN MIN(a,b)
#define LOCAL_MAX MAX(a,b)
#endif
#ifdef _LINUX_
#include "unistd.h"
#include <stdint.h>
#ifdef Omnimatrix
#define Omnimatrix __attribute__((visibility("default")))
#else
#define Omnimatrix __attribute__((visibility("default")))
#endif
#define LOCAL_TIME(in, out) localtime_r(out,in )
#define STRCPY(Dst,Len ,Src ) strcpy(Dst, Src)
#endif

View File

@ -1,178 +0,0 @@
#include <cassert>
#include <sstream>
#include <iomanip>
#include "FormatTrans.h"
float HEX2DEC(WORD Hex)
{
BYTE bai = Hex >> 12;
Hex = Hex - bai * std::pow(16, 3);
BYTE shi = Hex >> 8;
Hex = Hex - shi * pow(16, 2);
BYTE ge = Hex >> 4;
Hex = Hex - ge * pow(16, 1);
BYTE xiao = Hex;
return bai * pow(10, 2) + shi * pow(10, 1) + ge * pow(10, 0) + xiao * pow(10, -1);
}
WORD DEC2HEX(float Dec)
{
BYTE bai = Dec / pow(10, 2);
Dec = Dec - bai * pow(10, 2);
BYTE shi = Dec / pow(10, 1);
Dec = Dec - shi * pow(10, 1);
BYTE ge = Dec / pow(10, 0);
Dec = Dec - ge * pow(10, 0);
BYTE xiao = Dec / pow(10, -1);
return bai * pow(16, 3) + shi * pow(16, 2) + ge * pow(16, 1) + xiao * pow(16, 0);
}
/***********************************
function: IsHexChar
desc: 0-9a-f之间
input char-
Output
return: 8-8a-10
-1
***********************************/
int IsHexChar(char hc)
{
if('0'<=hc && hc<='9')
return (int(hc)-int('0'));
else if('a'<=hc && hc<='f')
return (int(hc)-int('a')+10);
else if('A'<=hc && hc<='F')
return (int(hc)-int('A')+10);
return -1;
}
/**************************************
function: Hex2Char
desc: 16
Input: hex-162
Output:
return: ascii字符
**************************************/
unsigned char Hex2Char(const std::string &hex)
{
assert(hex.length() == 2);
int high = IsHexChar(hex[0]);
int low = IsHexChar(hex[1]);
if(high == -1 || low == -1)
return '\0';
int asc = high*16+low;
// char b = toascii(asc);
return asc;
}
/****************************
function: Hex2String
desc: 16ascii字符串
Input: hex-16
Output:
return: ascii字符串
*****************************/
std::string Hex2String(const std::string &hex)
{
assert(hex.length()%2 == 0);
std::string hstr;
for(int i=0; i<hex.length(); i+=2)
{
std::string tmp = hex.substr(i,2);
hstr.append(1,Hex2Char(tmp));
}
return hstr;
}
/****************************************
functionPrepareHexString
desc: 0x
Input: str普通字符串
Output:
return: 0x的字符串
****************************************/
std::string PrepareHexString(std::string str)
{
//先删除空格
int i=0;
while(i != str.length())
{
i = str.find(' ',i);
if(i == -1)
break;
str = str.erase(i,1);
}
//删除0x
i = 0;
std::string tmp("0x");
while(i != str.length())
{
i = str.find(tmp,i);
if(i == -1)
break;
str = str.erase(i,2);
}
//删除0X
i = 0;
tmp = "0X";
while(i != str.length())
{
i = str.find(tmp,i);
if(i == -1)
break;
str = str.erase(i,2);
}
if(str.length()%2 != 0)
str.append(1,'0');
str = Hex2String(str);
return str;
}
// 十进制转十六进制
std::string decimalToHexadecimal(int decimal) {
std::stringstream ss;
ss << std::hex << decimal;
return ss.str();
}
// 十六进制转十进制
int hexadecimalToDecimal(const std::string& hexadecimal) {
return std::stoi(hexadecimal, nullptr, 16);
}
std::string charToHex(char value) {
int intValue = static_cast<int>(value);
if (intValue < 0) {
intValue = 256 + intValue;
}
std::stringstream ss;
ss << std::setw(2) << std::setfill('0') << std::hex << std::uppercase << intValue;
return ss.str();
}
std::string verify(const std::string& hexStr){
// 准备字符串去掉空格和0x
std::string preparedStr = PrepareHexString(hexStr);
// 计算校验码
int sum = 0;
for (size_t i = 1; i < 6; i += 1) {
int temp = int(static_cast<unsigned char>(preparedStr[i]));
sum += temp;
}
// 取模并转换为16进制
int checksum = sum % 0x100;
std::string hex = decimalToHexadecimal(checksum);
if (hex.length() == 1){
hex = "0" + hex;
}
return hex;
}

View File

@ -1,26 +0,0 @@
// 用于为海康球机PTZ值转换的函数
#pragma once
#include "DecisionPlatform.h"
#include <cmath>
#include <string>
typedef unsigned char BYTE;
typedef unsigned short WORD;
float HEX2DEC(WORD Hex);
WORD DEC2HEX(float Dec);
std::string Hex2String(const std::string &hex);
std::string PrepareHexString(std::string str);
// 十进制转十六进制
std::string decimalToHexadecimal(int decimal);
// 十六进制转十进制
int hexadecimalToDecimal(const std::string& hexadecimal);
std::string charToHex(char value);
std::string verify(const std::string& hexStr);

View File

@ -1,378 +0,0 @@
#include "HIKBallCamera.h"
#include "FormatTrans.h"
#include <vector>
#include <sstream>
HIKBallCamera::HIKBallCamera(){
};
struct PTZ{
float P;
float T;
float Z;
};
PTZ PTZDATA;
std::vector<std::string> velocity = {"0a","14","1e","28","32","3c","ff"};
bool HIKBallCamera::InitBallCamera(std::string ip, std::string port, std::string username, std::string password, std::string BallMachineType)
{
int res = Login(ip, port, username, password);
if (res != 0){
std::cout << "Incorrect Login error code:" << res << std::endl;
return false;
}
m_Channel = DeviceInfo.byStartChan;
this->BallMachineType = BallMachineType;
if (BallMachineType == "BuKongQiu"){
NET_DVR_SERIALSTART_V40 struSerialParam = { 0 };
struSerialParam.dwSize = sizeof(struSerialParam);
struSerialParam.dwSerialType = 2;//1:232串口2:485串口
struSerialParam.bySerialNum = 1;//串口编号设备支持多个RS232串口时有效
lTranHandle = NET_DVR_SerialStart_V40(LoginID, &struSerialParam, sizeof(struSerialParam), g_fSerialDataCallBack, NULL);//设置回调函数获取透传数据
if (lTranHandle < 0)
{
printf("NET_DVR_SerialStart error, %d\n", NET_DVR_GetLastError());
NET_DVR_Logout(LoginID);
NET_DVR_Cleanup();
return false;
}
}
return true;
}
//回调透传数据函数的外部实现
void CALLBACK HIKBallCamera::g_fSerialDataCallBack(LONG lSerialHandle, LONG lChannel, char *pRecvDataBuffer, DWORD dwBufSize, void *pUser)
{
std::string type = charToHex(pRecvDataBuffer[3]);
if (type=="59"){
PTZDATA.P = float(hexadecimalToDecimal(charToHex(pRecvDataBuffer[4])+charToHex(pRecvDataBuffer[5])))/100.0;
}else if (type == "5B"){
PTZDATA.T = float(hexadecimalToDecimal(charToHex(pRecvDataBuffer[4])+charToHex(pRecvDataBuffer[5])))/100.0;
}else if (type == "5D"){
PTZDATA.Z = float(hexadecimalToDecimal(charToHex(pRecvDataBuffer[4])+charToHex(pRecvDataBuffer[5])))/100.0;
}
}
bool HIKBallCamera::PtzControl(int command, int stop, int speed)
{
bool Ret = false;
//use HIK SDK to control the ball camera
Ret = NET_DVR_PTZControlWithSpeed_Other(LoginID,m_Channel, command, stop, speed);
//get the error code
if(!Ret)
{
std::cout << "PTZ control failed! Error code: " << NET_DVR_GetLastError() << std::endl;
return false;
}
return true;
}
bool HIKBallCamera::PtzControlLeft(int speed,int state)
{
if (BallMachineType=="BuKongQiu") {
std::string buf = "ff 01 00 04 "+velocity[speed - 1]+" 00";
buf = buf +" "+ verify(buf);
SerialSend(PrepareHexString(buf));
return true;
}else{
return PtzControl(PAN_LEFT, state, speed);
}
}
bool HIKBallCamera::PtzControlRight(int speed,int state)
{
if (BallMachineType=="BuKongQiu") {
std::string buf = "ff 01 00 02 "+velocity[speed - 1]+" 00";
buf = buf +" "+ verify(buf);
SerialSend(PrepareHexString(buf));
return true;
}else{
return PtzControl(PAN_RIGHT, state, speed);
}
}
bool HIKBallCamera::PtzControlUp(int speed,int state)
{
if (BallMachineType=="BuKongQiu") {
std::string buf = "ff 01 00 08 00 "+velocity[speed - 1];
buf = buf +" "+ verify(buf);
SerialSend(PrepareHexString(buf));
return true;
}else{
return PtzControl(TILT_UP, state, speed);
}
}
bool HIKBallCamera::PtzControlDown(int speed,int state)
{
if (BallMachineType=="BuKongQiu") {
std::string buf = "ff 01 00 10 00 "+velocity[speed - 1];
buf = buf +" "+ verify(buf);
SerialSend(PrepareHexString(buf));
return true;
}else{
return PtzControl(TILT_DOWN, state, speed);
}
}
bool HIKBallCamera::PtzControlZoomIn(int speed,int state)
{
if (BallMachineType=="BuKongQiu") {
SerialSend(PrepareHexString("ff 01 00 20 00 00 21"));
return true;
}else{
return PtzControl(ZOOM_IN, state, speed);
}
}
bool HIKBallCamera::PtzControlZoomOut(int speed,int state)
{
if (BallMachineType=="BuKongQiu") {
SerialSend(PrepareHexString("ff 01 00 40 00 00 41"));
return true;
}else{
return PtzControl(ZOOM_OUT, state, speed);
}
}
bool HIKBallCamera::PtzControlFocusAdd(int speed,int state){
if (BallMachineType=="BuKongQiu") {
std::cout << "ff 01 01 00 00 00 02" << std::endl;
SerialSend(PrepareHexString("ff 01 01 00 00 00 02"));
return true;
}else{
return PtzControl(FOCUS_FAR, state, speed);
}
}
bool HIKBallCamera::PtzControlFocusSub(int speed,int state){
if (BallMachineType=="BuKongQiu") {
std::cout << "ff 01 00 80 00 00 81" << std::endl;
SerialSend(PrepareHexString("ff 01 00 80 00 00 81"));
return true;
}else{
return PtzControl(FOCUS_NEAR, state, speed);
}
}
bool HIKBallCamera::PtzControlStop(){
SerialSend(PrepareHexString("ff 01 00 00 00 00 01"));
return true;
}
bool HIKBallCamera::PtzControlUpLeft(int speed,int state)
{
if (BallMachineType=="BuKongQiu") {
std::string buf = "ff 01 00 0c "+velocity[speed - 1]+" " + velocity[speed - 1];
buf = buf +" "+ verify(buf);
SerialSend(PrepareHexString(buf));
return true;
}else{
return PtzControl(UP_LEFT, state, speed);
}
}
bool HIKBallCamera::PtzControlUpRight(int speed,int state)
{
if (BallMachineType=="BuKongQiu") {
std::string buf = "ff 01 00 0a "+velocity[speed - 1]+" " + velocity[speed - 1];
buf = buf +" "+ verify(buf);
SerialSend(PrepareHexString(buf));
return true;
}else{
return PtzControl(UP_RIGHT, state, speed);
}
}
bool HIKBallCamera::PtzControlDownLeft(int speed,int state)
{
if (BallMachineType=="BuKongQiu") {
std::string buf = "ff 01 00 14 "+velocity[speed - 1]+" " + velocity[speed - 1];
buf = buf +" "+ verify(buf);
SerialSend(PrepareHexString(buf));
return true;
}else{
return PtzControl(DOWN_LEFT, state, speed);
}
}
bool HIKBallCamera::PtzControlDownRight(int speed,int state)
{
if (BallMachineType=="BuKongQiu") {
std::string buf = "ff 01 00 12 "+velocity[speed - 1]+" " + velocity[speed - 1];
buf = buf +" "+ verify(buf);
SerialSend(PrepareHexString(buf));
return true;
}else{
return PtzControl(DOWN_RIGHT, state, speed);
}
}
std::string addSpacesEveryTwoWords(const std::string& hex) {
std::ostringstream result;
int len = hex.length();
// 如果十六进制字符串的长度是奇数,则在前面添加一个 0
std::string paddedHex = (len % 2 == 1) ? "0" + hex : hex;
// 遍历字符串,每两个字符分割一次
for (size_t i = 0; i < paddedHex.length(); i += 2) {
if (i != 0) {
result << " ";
}
result << paddedHex.substr(i, 2);
}
return result.str();
}
std::string padding(const std::string& hex){
if (hex.length()==2){
return "00 "+hex;
} else{
return hex;
}
}
// PTZ 跳转到指定位置
bool HIKBallCamera::PtzGotoPut(int Action, float P, float T, float Z)
{
if (BallMachineType=="BuKongQiu"){
std::string pHex = decimalToHexadecimal(P * 100);
pHex = padding(addSpacesEveryTwoWords(pHex));
std::string tHex = decimalToHexadecimal(T * 100);
tHex = padding(addSpacesEveryTwoWords(tHex));
std::string zHex = decimalToHexadecimal(Z * 100);
zHex = padding(addSpacesEveryTwoWords(zHex));
std::string pBuf = "ff 01 00 4b "+ pHex;
std::string tBuf = "ff 01 00 4d "+ tHex;
std::string zBuf = "ff 01 00 4f "+ zHex;
pBuf = pBuf+" "+verify(pBuf);
tBuf = tBuf+" "+verify(tBuf);
zBuf = zBuf+" "+verify(zBuf);
switch (Action) {
case 1:
SerialSend(PrepareHexString(pBuf)); // 设置 P
SerialSend(PrepareHexString(tBuf)); // 设置 T
SerialSend(PrepareHexString(zBuf)); // 设置 Z
break;
case 2:
SerialSend(PrepareHexString(pBuf)); // 设置 P
break;
case 3:
SerialSend(PrepareHexString(tBuf)); // 设置 T
break;
case 4:
SerialSend(PrepareHexString(zBuf)); // 设置 Z
break;
case 5:
SerialSend(PrepareHexString(pBuf)); // 设置 P
SerialSend(PrepareHexString(tBuf)); // 设置 T
break;
default:
break;
}
return true;
}else{
NET_DVR_PTZPOS ptzPosCurrent;
ptzPosCurrent.wPanPos = DEC2HEX(P);
ptzPosCurrent.wTiltPos = DEC2HEX(T);
ptzPosCurrent.wZoomPos = DEC2HEX(Z);
ptzPosCurrent.wAction = Action;
bool b = NET_DVR_SetDVRConfig(LoginID, NET_DVR_SET_PTZPOS, m_Channel, &ptzPosCurrent, sizeof(NET_DVR_PTZPOS));
return b;
}
}
bool HIKBallCamera::SerialSend(const std::string& hex){
char m_DataBuf[50];
int m_DataLen;
int len = hex.length();
m_DataLen = len<1024 ? len : 1024;
memcpy(m_DataBuf,hex.c_str(),m_DataLen);
return NET_DVR_SerialSend(lTranHandle,1, m_DataBuf, m_DataLen);
}
bool HIKBallCamera::PtzGet(float* posP, float* posT, float* posZ) {
if (BallMachineType=="BuKongQiu"){
SerialSend(PrepareHexString("ff 01 00 51 00 00 52"));
SerialSend(PrepareHexString("ff 01 00 53 00 00 54"));
SerialSend(PrepareHexString("ff 01 00 55 00 00 56"));
SLEEP(1);
*posP = PTZDATA.P;
*posT = PTZDATA.T;
*posZ = PTZDATA.Z;
return true;
}else{
NET_DVR_PTZPOS ptzPosCurrent;
DWORD dwtmp;
bool b = NET_DVR_GetDVRConfig(LoginID, NET_DVR_GET_PTZPOS, m_Channel, &ptzPosCurrent, sizeof(NET_DVR_PTZPOS),&dwtmp);
float P = HEX2DEC(ptzPosCurrent.wPanPos);
float T = HEX2DEC(ptzPosCurrent.wTiltPos);
float Z = HEX2DEC(ptzPosCurrent.wZoomPos);
*posP = P;
*posT = T;
*posZ = Z;
return b;
}
}
bool HIKBallCamera::CmdSwitch(int direction,int speed,int state){
bool Res = false;
switch (direction) {
case PTZ_LEFT:
Res = PtzControlLeft(speed,state);
break;
case PTZ_RIGHT:
Res = PtzControlRight(speed,state);
break;
case PTZ_UP:
Res = PtzControlUp(speed,state);
break;
case PTZ_DOWN:
Res = PtzControlDown(speed,state);
break;
case PTZ_UP_LEFT:
Res = PtzControlUpLeft(speed,state);
break;
case PTZ_UP_RIGHT:
Res = PtzControlUpRight(speed,state);
break;
case PTZ_DOWN_LEFT:
Res = PtzControlDownLeft(speed,state);
break;
case PTZ_DOWN_RIGHT:
Res = PtzControlDownRight(speed,state);
break;
case PTZ_ZOOM_IN:
Res = PtzControlZoomIn(speed,state);
break;
case PTZ_ZOOM_OUT:
Res = PtzControlZoomOut(speed,state);
break;
case PTZ_Focus_Far:
Res = PtzControlFocusSub(speed,state);
break;
case PTZ_Focus_Near:
Res = PtzControlFocusAdd(speed,state);
break;
}
return Res;
}
bool HIKBallCamera::StopBus(int direction) {
if (BallMachineType=="BuKongQiu"){
return PtzControlStop();
}
return CmdSwitch(direction,0,1);
}
bool HIKBallCamera::StartBus(int direction, int speed) {
return CmdSwitch(direction,speed,0);
}

View File

@ -1,65 +0,0 @@
#pragma once
#include "HIKBase.h"
#define PTZ_LEFT 1 // 云台向左
#define PTZ_RIGHT 2 // 云台向右
#define PTZ_UP 3 // 云台向上
#define PTZ_DOWN 4 // 云台向下
#define PTZ_UP_LEFT 5 // 云台左上
#define PTZ_UP_RIGHT 6 // 云台右上
#define PTZ_DOWN_LEFT 7 // 云台左下
#define PTZ_DOWN_RIGHT 8 // 云台右下
#define PTZ_ZOOM_IN 9 // 云台放大
#define PTZ_ZOOM_OUT 10 // 云台缩小
#define PTZ_Focus_Far 11 // 云台聚焦+
#define PTZ_Focus_Near 12 // 云台聚焦-
class HIKBallCamera : public HIKBase
{
public:
HIKBallCamera();
bool InitBallCamera(std::string ip, std::string port, std::string username, std::string password, std::string BallMachineType);
bool PtzGotoPut(int Action, float P, float T, float Z = 0);
bool PtzGet(float *posP, float *posT, float *posZ);
bool StopBus(int direction);
bool StartBus(int direction,int speed);
private:
LONG lTranHandle;
std::string BallMachineType;
int m_Channel;
private:
bool PtzControlUp(int speed,int state);
bool PtzControlDown(int speed,int state);
bool PtzControlLeft(int speed,int state);
bool PtzControlRight(int speed,int state);
bool PtzControlUpLeft(int speed,int state);
bool PtzControlUpRight(int speed,int state);
bool PtzControlDownLeft(int speed,int state);
bool PtzControlDownRight(int speed,int state);
bool PtzControlZoomIn(int speed,int state);
bool PtzControlZoomOut(int speed,int state);
bool PtzControlFocusAdd(int speed,int state);
bool PtzControlFocusSub(int speed,int state);
private:
/**
* @brief 使485
*
* @param hex
**/
bool SerialSend(const std::string& hex);
private:
/**
* @brief PTZ Switch
*
* @param direction PTZ
* @param speed PTZ
* @param state PTZ
**/
bool CmdSwitch(int direction,int speed,int state);
bool PtzControl(int command, int stop, int speed);
bool PtzControlStop();
void static CALLBACK g_fSerialDataCallBack(LONG lSerialHandle, LONG lChannel, char *pRecvDataBuffer, DWORD dwBufSize, void *pUser);
};

View File

@ -1,36 +0,0 @@
#include "HIKBase.h"
#include <memory>
#include <cstring>
#include <chrono>
HIKBase::HIKBase()
{
memset(&DeviceInfo, 0, sizeof(DeviceInfo));
}
HIKBase::~HIKBase() = default;
int HIKBase::Login(std::string ip, std::string port, std::string username, std::string password)
{
Ip = ip;
Port = port;
Username = username;
Password = password;
LoginID = NET_DVR_Login_V30((char *)Ip.c_str(), atoi(Port.c_str()), (char *)Username.c_str(), (char *)Password.c_str(), &DeviceInfo);
return NET_DVR_GetLastError();
}
void HIKBase::Logout()
{
if (LoginID >= 0)
{
NET_DVR_Logout(LoginID);
LoginID = -1;
}
}
bool HK_DVR_Init(){
return NET_DVR_Init();
}

View File

@ -1,33 +0,0 @@
#pragma once
#include <iostream>
#include <HCNetSDK.h>
#include <iostream>
#include <string>
class HIKBase
{
public:
HIKBase();
~HIKBase();
int Login(std::string ip, std::string port, std::string username, std::string password);
void Logout();
protected:
LONG LoginID;
NET_DVR_DEVICEINFO_V30 DeviceInfo;
private:
//Hik login info
std::string Ip;//Hik Device IP
std::string Port;//Hik Device Port
std::string Username;//Hik Device Username
std::string Password;//Hik Device Password
//after login, Hik Device ID
int DeviceID;
};
bool HK_DVR_Init();

View File

@ -1,293 +0,0 @@
#define NOMINMAX
#include "./date/date.h"
#include "HIKNvr.h"
#include <ctime>
#include <iostream>
#include <chrono>
HIKNvr::HIKNvr(){
}
/**
* @brief Initializes the NVR with the given login information and channel.
*
* @param ip The IP address of the NVR.
* @param port The port number of the NVR.
* @param username The username for logging into the NVR.
* @param password The password for logging into the NVR.
* @param channel The channel number to set for the NVR.
*/
bool HIKNvr::InitNvr(std::string ip, std::string port, std::string username, std::string password, int channel)
{
if (Login(ip, port, username, password) == 0){
m_Channel = channel + 32;
return true;
}
return false;
}
int HIKNvr::GetNvrUTCDiff(){
NET_DVR_NETAPPCFG struNAC = {0};
DWORD ZoneSize = 0;
if (NET_DVR_GetDVRConfig(LoginID, NET_DVR_GET_NETAPPCFG, 0, &struNAC, sizeof(NET_DVR_NETAPPCFG), &ZoneSize)){
return 5000;
};
int nDiffHour = struNAC.struNtpClientParam.cTimeDifferenceH;
int nDiffMin = struNAC.struNtpClientParam.cTimeDifferenceM;
nDiffTotalMin = (nDiffHour < 0 ? -1 : 1) * (abs(nDiffHour) * 60 + nDiffMin);
return (nDiffHour < 0 ? -1 : 1) * (abs(nDiffHour) * 60 + nDiffMin);
}
/**
* @brief
*
* @param select_time The selected time.
* @param available_date_vec The available date vector.
* @return true if the time region is found, false otherwise.
*/
int HIKNvr::CheckTimeRegionWithMonth(DateTime select_time,std::vector<int>& available_date_vec)
{
DateTime DateNow(select_time);
// 查当月
NET_DVR_MRD_SEARCH_PARAM struSearchParam = {0};
NET_DVR_MRD_SEARCH_RESULT struSearchResult = {0};
struSearchParam.dwSize = sizeof(NET_DVR_MRD_SEARCH_PARAM);
struSearchParam.wYear = DateNow.year();
struSearchParam.byMonth = DateNow.month();
struSearchParam.struStreamInfo.dwChannel = m_Channel; // channel
struSearchParam.byLocalOrUTC = true; // 0:local time, 1:UTC time (时区)
struSearchParam.byDrawFrame = 0; // 0:不抽帧1:抽帧
struSearchParam.byStreamType = 0;// 0:主码流1:子码流
// 查记录
if (!NET_DVR_GetDeviceConfig(this->LoginID, NET_DVR_GET_MONTHLY_RECORD_DISTRIBUTION, 0, &struSearchParam, sizeof(struSearchParam), NULL, &struSearchResult, sizeof(struSearchResult)))
{
int n = NET_DVR_GetLastError();
return n == NET_DVR_NETWORK_FAIL_CONNECT ? NVR_ERR_CONNECT_7 : NVR_ERR_HIK;
}
for (int i = 0; i < 32; i++)
{
if (struSearchResult.byRecordDistribution[i])
{
available_date_vec.push_back(i + 1);
}
}
return NVR_SUC;
}
/**
* @brief Check if a given time falls within the available time range for the current day.
*
* @param select_time The time to check.
* @param available_time_vec A vector of available time ranges for the current day.
* @return true if the given time falls within the available time range, false otherwise.
*/
int HIKNvr::CheckTimeRegionWithDay(DateTime select_time, std::vector<TimeRecord> &available_time_vec)
{
int nRet = NVR_SUC;
GetNvrUTCDiff();
DateTime DateNow(select_time);
int nYear = DateNow.year();
int nMonth = DateNow.month();
int nDay = DateNow.day();
NET_DVR_FILECOND FileCond;
FileCond.dwFileType = 0xff;// 0xff:所有文件
FileCond.dwIsLocked = 0xff;// 0xff:所有文件
FileCond.dwUseCardNo = 0; //不使用卡号
FileCond.lChannel = m_Channel;//通道号
FileCond.struStartTime.dwYear = DateNow.year();
FileCond.struStartTime.dwMonth = DateNow.month();
FileCond.struStartTime.dwDay = DateNow.day();
FileCond.struStartTime.dwHour = 0;
FileCond.struStartTime.dwMinute = 0;
FileCond.struStartTime.dwSecond = 0;
FileCond.struStopTime.dwYear = DateNow.year();
FileCond.struStopTime.dwMonth = DateNow.month();
FileCond.struStopTime.dwDay = DateNow.day();
FileCond.struStopTime.dwHour = 23;
FileCond.struStopTime.dwMinute = 59;
FileCond.struStopTime.dwSecond = 59;
available_time_vec.clear();
LONG hFindHandle = NET_DVR_FindFile_V30(LoginID, &FileCond);
if (-1 == hFindHandle)
{
nRet = NET_DVR_GetLastError();
return nRet == NET_DVR_NETWORK_FAIL_CONNECT?NVR_ERR_CONNECT_7:NVR_ERR_HIK;
}
else
{
NET_DVR_FINDDATA_V30 FindData; // 查找到的文件信息
nRet = NET_DVR_FindNextFile_V30(hFindHandle, &FindData);
int ItemIndex = 0;
while (nRet > 0)
{
if (NET_DVR_FILE_EXCEPTION == nRet)//查找文件时异常
{
break;
}
else if (NET_DVR_FILE_NOFIND == nRet)//没有文件
{
break;
}
else if (NET_DVR_NOMOREFILE == nRet) // 查找结束
{
break;
}
else if (NET_DVR_ISFINDING == nRet) // 正在查找
{
nRet = NET_DVR_FindNextFile_V30(hFindHandle, &FindData);
//请求过快会出读错误。同时也是参考海康sdk写法。
std::this_thread::sleep_for(std::chrono::milliseconds(5));
}
else if (NET_DVR_FILE_SUCCESS == nRet) // 获取文件信息成功
{
// 保存文件信息
TimeRecord tR;
if (nDay != FindData.struStartTime.dwDay)//起始不在今日
{
tR.TimeStart.SetDateTime(FindData.struStartTime.dwYear, FindData.struStartTime.dwMonth, nDay, 0, 0, 0);
}
else//起始在今日
{
tR.TimeStart.SetDateTime(FindData.struStartTime.dwYear, FindData.struStartTime.dwMonth, FindData.struStartTime.dwDay, FindData.struStartTime.dwHour, FindData.struStartTime.dwMinute, FindData.struStartTime.dwSecond);
}
if (nDay != FindData.struStopTime.dwDay)//结束不在今日
{
tR.TimeEnd.SetDateTime(FindData.struStartTime.dwYear, FindData.struStartTime.dwMonth, FindData.struStartTime.dwDay, 23, 59, 59);
}
else//结束在今日
{
tR.TimeEnd.SetDateTime(FindData.struStopTime.dwYear, FindData.struStopTime.dwMonth, FindData.struStopTime.dwDay,
FindData.struStopTime.dwHour, FindData.struStopTime.dwMinute, FindData.struStopTime.dwSecond);
}
date::sys_days original_date_start{date::year{tR.TimeStart.year()} / date::month{static_cast<unsigned int>(tR.TimeStart.month())} / date::day{static_cast<unsigned int>(tR.TimeStart.day())}};
date::sys_time<std::chrono::seconds> original_time_start{date::sys_days{original_date_start} + std::chrono::hours{tR.TimeStart.hour()} + std::chrono::minutes{tR.TimeStart.minute()} + std::chrono::seconds{tR.TimeStart.minute()}};
date::sys_time<std::chrono::seconds> utc_plus_8_time_start = original_time_start - std::chrono::minutes{nDiffTotalMin};
date::sys_days original_date_end{date::year{tR.TimeEnd.year()} / date::month{static_cast<unsigned int>(tR.TimeEnd.month())} / date::day{static_cast<unsigned int>(tR.TimeEnd.day())}};
date::sys_time<std::chrono::seconds> original_time_end{date::sys_days{original_date_end} + std::chrono::hours{tR.TimeEnd.hour()} + std::chrono::minutes{tR.TimeEnd.minute()} + std::chrono::seconds{tR.TimeEnd.minute()}};
date::sys_time<std::chrono::seconds> utc_plus_8_time_end = original_time_end - std::chrono::minutes{nDiffTotalMin};
// 计算时间点到1970-01-01 00:00:00 UTC的时间间隔即时间戳
std::chrono::seconds timestamp = std::chrono::duration_cast<std::chrono::seconds>(utc_plus_8_time_start.time_since_epoch());
tR.tmTimeStart = timestamp.count();
timestamp = std::chrono::duration_cast<std::chrono::seconds>(utc_plus_8_time_end.time_since_epoch());
tR.tmTimeEnd = timestamp.count();
available_time_vec.emplace_back(tR);
nRet = NET_DVR_FindNextFile_V30(hFindHandle, &FindData);
}
}
// 关闭查找,释放句柄
NET_DVR_FindClose_V30(hFindHandle);
}
return NVR_SUC;
}
/**
* @brief Get the time region based on the selected time and value.
*
* @param SelectTime The selected time.
* @param Value The value used to calculate the time region.
* @param TimeStart The start time of the time region.
* @param TimeEnd The end time of the time region.
* @return true if the time region is found, false otherwise.
*/
bool HIKNvr::GetTimeRegion(DateTime SelectTime, int Value, DateTime &TimeStart, DateTime &TimeEnd)
{
int nYear = SelectTime.year();
int nMonth = SelectTime.month();
int nDay = SelectTime.day();
// 时间格式 转换,找时间区间
int nHour = Value / 3600;
int nMinute = Value / 60 - 60 * nHour;
int nSecond = Value - (nMinute + 60 * nHour) * 60;
TimeStart = SelectTime;
TimeStart.hour() = nHour;
TimeStart.minute() = nMinute;
TimeStart.second() = nSecond;
bool bHave = false;
for (auto it : m_TimeRecords)
{
if (it.IsInRecord(TimeStart))
{
bHave = true;
TimeEnd = it.TimeEnd;
break;
}
}
return bHave;
}
/**
* @brief Turn the time to json.
*
* @param Time The time to be turned to json.
* @param pAvailableDateVec The available date vector.
* @return nlohmann::json& The json object.
*/
nlohmann::json HIKNvr::TimeToJson(DateTime Time, std::vector<int> *pAvailableDateVec)
{
nlohmann::json Message;
//year and month
Message["year"] = Time.year();
Message["month"] = Time.month();
//date
if (pAvailableDateVec != nullptr)
{
nlohmann::json data;
for (auto date : *pAvailableDateVec)
{
data.push_back(date);
}
Message["day"] = data;
}
return Message;
}
/**
* @brief Converts available time slots in a day to JSON format.
*
* @param Time The date and time of the day.
* @param pAvailableTimeVec A pointer to a vector of available time slots.
* @return nlohmann::json& A reference to the JSON object containing the converted time slots.
*/
nlohmann::json HIKNvr::TimeToJsonInDay(DateTime Time, std::vector<TimeRecord> *pAvailableTimeVec)
{
nlohmann::json Message;
if(pAvailableTimeVec != nullptr)
{
for(auto time : *pAvailableTimeVec)
{
nlohmann::json data;
data["begin"] = time.tmTimeStart;
data["end"] = time.tmTimeEnd;
Message.push_back(data);
}
}
return Message;
}

View File

@ -1,59 +0,0 @@
#pragma once
#include "json.hpp"
#include "HIKBase.h"
#include "DecisionPlatform.h"
#include "DataTime.h"
#include <vector>
#define NVR_SUC 0
#define NVR_ERR_HIK 6
#define NVR_ERR_CONNECT_7 7
struct TimeRecord
{
DateTime TimeStart;
DateTime TimeEnd;
long long tmTimeStart;
long long tmTimeEnd;
// 目前是针对每天记录比对所以只比对time即可。
bool IsInRecord(DateTime time_in)
{
if (TimeStart < time_in && TimeEnd > time_in)
{
return true;
}
return false;
}
};
class HIKNvr : public HIKBase
{
public:
HIKNvr();
//初始化 Nvr
bool InitNvr(std::string ip, std::string port, std::string username, std::string password, int channel);
//按月查询
int CheckTimeRegionWithMonth(DateTime select_time, std::vector<int> &available_date_vec);
//按日查询
int CheckTimeRegionWithDay(DateTime select_time, std::vector<TimeRecord> &available_time_vec);
//though input SelectTime get the time region
bool GetTimeRegion(DateTime select_time,int value ,DateTime &time_start,DateTime &time_end);
int GetNvrUTCDiff();
int nDiffTotalMin;
public:
// 将时间转换成json
nlohmann::json TimeToJson(DateTime Time,std::vector<int> *pAvailableDateVec);
nlohmann::json TimeToJsonInDay(DateTime Time,std::vector<TimeRecord> *pAvailableTimeVec);
private:
//record the time in the Nvr
std::vector<TimeRecord> m_TimeRecords;
//Nvr channel
int m_Channel;
};

View File

@ -1,34 +0,0 @@
#ifndef CHRONO_IO_H
#define CHRONO_IO_H
// The MIT License (MIT)
//
// Copyright (c) 2016, 2017 Howard Hinnant
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// Our apologies. When the previous paragraph was written, lowercase had not yet
// been invented (that would involve another several millennia of evolution).
// We did not mean to shout.
// This functionality has moved to "date.h"
#include "date.h"
#endif // CHRONO_IO_H

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,950 +0,0 @@
#ifndef PTZ_H
#define PTZ_H
// The MIT License (MIT)
//
// Copyright (c) 2017 Howard Hinnant
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// This header allows Posix-style time zones as specified for TZ here:
// http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08_03
//
// Posix::time_zone can be constructed with a posix-style string and then used in
// a zoned_time like so:
//
// zoned_time<system_clock::duration, Posix::time_zone> zt{"EST5EDT,M3.2.0,M11.1.0",
// system_clock::now()};
// or:
//
// Posix::time_zone tz{"EST5EDT,M3.2.0,M11.1.0"};
// zoned_time<system_clock::duration, Posix::time_zone> zt{tz, system_clock::now()};
//
// In C++17 CTAD simplifies this to:
//
// Posix::time_zone tz{"EST5EDT,M3.2.0,M11.1.0"};
// zoned_time zt{tz, system_clock::now()};
//
// Extension to the Posix rules to allow a constant daylight saving offset:
//
// If the rule set is missing (everything starting with ','), then
// there must be exactly one abbreviation (std or daylight) with
// length 3 or greater, and that will be used as the constant offset. If
// there are two, the std abbreviation is silently set to "", and the
// result is constant daylight saving. If there are zero abbreviations
// with no rule set, an exception is thrown.
//
// Example:
// "EST5" yields a constant offset of -5h with 0h save and "EST abbreviation.
// "5EDT" yields a constant offset of -4h with 1h save and "EDT" abbreviation.
// "EST5EDT" and "5EDT4" are both equal to "5EDT".
//
// Note, Posix-style time zones are not recommended for all of the reasons described here:
// https://stackoverflow.com/tags/timezone/info
//
// They are provided here as a non-trivial custom time zone example, and if you really
// have to have Posix time zones, you're welcome to use this one.
#include "date/tz.h"
#include <algorithm>
#include <cctype>
#include <ostream>
#include <string>
namespace Posix
{
namespace detail
{
#if HAS_STRING_VIEW
using string_t = std::string_view;
#else // !HAS_STRING_VIEW
using string_t = std::string;
#endif // !HAS_STRING_VIEW
class rule;
void throw_invalid(const string_t& s, unsigned i, const string_t& message);
unsigned read_date(const string_t& s, unsigned i, rule& r);
unsigned read_name(const string_t& s, unsigned i, std::string& name);
unsigned read_signed_time(const string_t& s, unsigned i, std::chrono::seconds& t);
unsigned read_unsigned_time(const string_t& s, unsigned i, std::chrono::seconds& t);
unsigned read_unsigned(const string_t& s, unsigned i, unsigned limit, unsigned& u,
const string_t& message = string_t{});
class rule
{
enum {off, J, M, N};
date::month m_;
date::weekday wd_;
unsigned short n_ : 14;
unsigned short mode_ : 2;
std::chrono::duration<std::int32_t> time_ = std::chrono::hours{2};
public:
rule() : mode_(off) {}
bool ok() const {return mode_ != off;}
date::local_seconds operator()(date::year y) const;
std::string to_string() const;
friend std::ostream& operator<<(std::ostream& os, const rule& r);
friend unsigned read_date(const string_t& s, unsigned i, rule& r);
friend bool operator==(const rule& x, const rule& y);
};
inline
bool
operator==(const rule& x, const rule& y)
{
if (x.mode_ != y.mode_)
return false;
switch (x.mode_)
{
case rule::J:
case rule::N:
return x.n_ == y.n_;
case rule::M:
return x.m_ == y.m_ && x.n_ == y.n_ && x.wd_ == y.wd_;
default:
return true;
}
}
inline
bool
operator!=(const rule& x, const rule& y)
{
return !(x == y);
}
inline
date::local_seconds
rule::operator()(date::year y) const
{
using date::local_days;
using date::January;
using date::days;
using date::last;
using sec = std::chrono::seconds;
date::local_seconds t;
switch (mode_)
{
case J:
t = local_days{y/January/0} + days{n_ + (y.is_leap() && n_ > 59)} + sec{time_};
break;
case M:
t = (n_ == 5 ? local_days{y/m_/wd_[last]} : local_days{y/m_/wd_[n_]}) + sec{time_};
break;
case N:
t = local_days{y/January/1} + days{n_} + sec{time_};
break;
default:
assert(!"rule called with bad mode");
}
return t;
}
inline
std::string
rule::to_string() const
{
using namespace std::chrono;
auto print_offset = [](seconds off)
{
std::string nm;
if (off != hours{2})
{
date::hh_mm_ss<seconds> offset{off};
nm = '/';
nm += std::to_string(offset.hours().count());
if (offset.minutes() != minutes{0} || offset.seconds() != seconds{0})
{
nm += ':';
if (offset.minutes() < minutes{10})
nm += '0';
nm += std::to_string(offset.minutes().count());
if (offset.seconds() != seconds{0})
{
nm += ':';
if (offset.seconds() < seconds{10})
nm += '0';
nm += std::to_string(offset.seconds().count());
}
}
}
return nm;
};
std::string nm;
switch (mode_)
{
case rule::J:
nm = 'J';
nm += std::to_string(n_);
break;
case rule::M:
nm = 'M';
nm += std::to_string(static_cast<unsigned>(m_));
nm += '.';
nm += std::to_string(n_);
nm += '.';
nm += std::to_string(wd_.c_encoding());
break;
case rule::N:
nm = std::to_string(n_);
break;
default:
break;
}
nm += print_offset(time_);
return nm;
}
inline
std::ostream&
operator<<(std::ostream& os, const rule& r)
{
switch (r.mode_)
{
case rule::J:
os << 'J' << r.n_ << date::format(" %T", r.time_);
break;
case rule::M:
if (r.n_ == 5)
os << r.m_/r.wd_[date::last];
else
os << r.m_/r.wd_[r.n_];
os << date::format(" %T", r.time_);
break;
case rule::N:
os << r.n_ << date::format(" %T", r.time_);
break;
default:
break;
}
return os;
}
} // namespace detail
class time_zone
{
std::string std_abbrev_;
std::string dst_abbrev_ = {};
std::chrono::seconds offset_;
std::chrono::seconds save_ = std::chrono::hours{1};
detail::rule start_rule_;
detail::rule end_rule_;
public:
explicit time_zone(const detail::string_t& name);
template <class Duration>
date::sys_info get_info(date::sys_time<Duration> st) const;
template <class Duration>
date::local_info get_info(date::local_time<Duration> tp) const;
template <class Duration>
date::sys_time<typename std::common_type<Duration, std::chrono::seconds>::type>
to_sys(date::local_time<Duration> tp) const;
template <class Duration>
date::sys_time<typename std::common_type<Duration, std::chrono::seconds>::type>
to_sys(date::local_time<Duration> tp, date::choose z) const;
template <class Duration>
date::local_time<typename std::common_type<Duration, std::chrono::seconds>::type>
to_local(date::sys_time<Duration> tp) const;
friend std::ostream& operator<<(std::ostream& os, const time_zone& z);
const time_zone* operator->() const {return this;}
std::string name() const;
friend bool operator==(const time_zone& x, const time_zone& y);
private:
date::sys_seconds get_start(date::year y) const;
date::sys_seconds get_prev_start(date::year y) const;
date::sys_seconds get_next_start(date::year y) const;
date::sys_seconds get_end(date::year y) const;
date::sys_seconds get_prev_end(date::year y) const;
date::sys_seconds get_next_end(date::year y) const;
date::sys_info contant_offset() const;
};
inline
date::sys_seconds
time_zone::get_start(date::year y) const
{
return date::sys_seconds{(start_rule_(y) - offset_).time_since_epoch()};
}
inline
date::sys_seconds
time_zone::get_prev_start(date::year y) const
{
return date::sys_seconds{(start_rule_(--y) - offset_).time_since_epoch()};
}
inline
date::sys_seconds
time_zone::get_next_start(date::year y) const
{
return date::sys_seconds{(start_rule_(++y) - offset_).time_since_epoch()};
}
inline
date::sys_seconds
time_zone::get_end(date::year y) const
{
return date::sys_seconds{(end_rule_(y) - (offset_ + save_)).time_since_epoch()};
}
inline
date::sys_seconds
time_zone::get_prev_end(date::year y) const
{
return date::sys_seconds{(end_rule_(--y) - (offset_ + save_)).time_since_epoch()};
}
inline
date::sys_seconds
time_zone::get_next_end(date::year y) const
{
return date::sys_seconds{(end_rule_(++y) - (offset_ + save_)).time_since_epoch()};
}
inline
date::sys_info
time_zone::contant_offset() const
{
using date::year;
using date::sys_info;
using date::sys_days;
using date::January;
using date::December;
using date::last;
using std::chrono::minutes;
sys_info r;
r.begin = sys_days{year::min()/January/1};
r.end = sys_days{year::max()/December/last};
if (std_abbrev_.size() > 0)
{
r.abbrev = std_abbrev_;
r.offset = offset_;
r.save = {};
}
else
{
r.abbrev = dst_abbrev_;
r.offset = offset_ + save_;
r.save = date::ceil<minutes>(save_);
}
return r;
}
inline
time_zone::time_zone(const detail::string_t& s)
{
using detail::read_name;
using detail::read_signed_time;
using detail::throw_invalid;
auto i = read_name(s, 0, std_abbrev_);
auto std_name_i = i;
auto abbrev_name_i = i;
i = read_signed_time(s, i, offset_);
offset_ = -offset_;
if (i != s.size())
{
i = read_name(s, i, dst_abbrev_);
abbrev_name_i = i;
if (i != s.size())
{
if (s[i] != ',')
{
i = read_signed_time(s, i, save_);
save_ = -save_ - offset_;
}
if (i != s.size())
{
if (s[i] != ',')
throw_invalid(s, i, "Expecting end of string or ',' to start rule");
++i;
i = read_date(s, i, start_rule_);
if (i == s.size() || s[i] != ',')
throw_invalid(s, i, "Expecting ',' and then the ending rule");
++i;
i = read_date(s, i, end_rule_);
if (i != s.size())
throw_invalid(s, i, "Found unexpected trailing characters");
}
}
}
if (start_rule_.ok())
{
if (std_abbrev_.size() < 3)
throw_invalid(s, std_name_i, "Zone with rules must have a std"
" abbreviation of length 3 or greater");
if (dst_abbrev_.size() < 3)
throw_invalid(s, abbrev_name_i, "Zone with rules must have a daylight"
" abbreviation of length 3 or greater");
}
else
{
if (dst_abbrev_.size() >= 3)
{
std_abbrev_.clear();
}
else if (std_abbrev_.size() < 3)
{
throw_invalid(s, std_name_i, "Zone must have at least one abbreviation"
" of length 3 or greater");
}
else
{
dst_abbrev_.clear();
save_ = {};
}
}
}
template <class Duration>
date::sys_info
time_zone::get_info(date::sys_time<Duration> st) const
{
using date::sys_info;
using date::year_month_day;
using date::sys_days;
using date::floor;
using date::ceil;
using date::days;
using date::year;
using date::January;
using date::December;
using date::last;
using std::chrono::minutes;
sys_info r{};
r.offset = offset_;
if (start_rule_.ok())
{
auto y = year_month_day{floor<days>(st)}.year();
if (st >= get_next_start(y))
++y;
else if (st < get_prev_end(y))
--y;
auto start = get_start(y);
auto end = get_end(y);
if (start <= end) // (northern hemisphere)
{
if (start <= st && st < end)
{
r.begin = start;
r.end = end;
r.offset += save_;
r.save = ceil<minutes>(save_);
r.abbrev = dst_abbrev_;
}
else if (st < start)
{
r.begin = get_prev_end(y);
r.end = start;
r.abbrev = std_abbrev_;
}
else // st >= end
{
r.begin = end;
r.end = get_next_start(y);
r.abbrev = std_abbrev_;
}
}
else // end < start (southern hemisphere)
{
if (end <= st && st < start)
{
r.begin = end;
r.end = start;
r.abbrev = std_abbrev_;
}
else if (st < end)
{
r.begin = get_prev_start(y);
r.end = end;
r.offset += save_;
r.save = ceil<minutes>(save_);
r.abbrev = dst_abbrev_;
}
else // st >= start
{
r.begin = start;
r.end = get_next_end(y);
r.offset += save_;
r.save = ceil<minutes>(save_);
r.abbrev = dst_abbrev_;
}
}
}
else
r = contant_offset();
assert(r.begin <= st && st < r.end);
return r;
}
template <class Duration>
date::local_info
time_zone::get_info(date::local_time<Duration> tp) const
{
using date::local_info;
using date::year_month_day;
using date::days;
using date::sys_days;
using date::sys_seconds;
using date::year;
using date::ceil;
using date::January;
using date::December;
using date::last;
using std::chrono::seconds;
using std::chrono::minutes;
local_info r{};
using date::floor;
if (start_rule_.ok())
{
auto y = year_month_day{floor<days>(tp)}.year();
auto start = get_start(y);
auto end = get_end(y);
auto utcs = sys_seconds{floor<seconds>(tp - offset_).time_since_epoch()};
auto utcd = sys_seconds{floor<seconds>(tp - (offset_ + save_)).time_since_epoch()};
auto northern = start <= end;
if ((utcs < start) != (utcd < start))
{
if (northern)
r.first.begin = get_prev_end(y);
else
r.first.begin = end;
r.first.end = start;
r.first.offset = offset_;
r.first.abbrev = std_abbrev_;
r.second.begin = start;
if (northern)
r.second.end = end;
else
r.second.end = get_next_end(y);
r.second.abbrev = dst_abbrev_;
r.second.offset = offset_ + save_;
r.second.save = ceil<minutes>(save_);
r.result = save_ > seconds{0} ? local_info::nonexistent
: local_info::ambiguous;
}
else if ((utcs < end) != (utcd < end))
{
if (northern)
r.first.begin = start;
else
r.first.begin = get_prev_start(y);
r.first.end = end;
r.first.offset = offset_ + save_;
r.first.save = ceil<minutes>(save_);
r.first.abbrev = dst_abbrev_;
r.second.begin = end;
if (northern)
r.second.end = get_next_start(y);
else
r.second.end = start;
r.second.abbrev = std_abbrev_;
r.second.offset = offset_;
r.result = save_ > seconds{0} ? local_info::ambiguous
: local_info::nonexistent;
}
else
r.first = get_info(utcs);
}
else
r.first = contant_offset();
return r;
}
template <class Duration>
date::sys_time<typename std::common_type<Duration, std::chrono::seconds>::type>
time_zone::to_sys(date::local_time<Duration> tp) const
{
using date::local_info;
using date::sys_time;
using date::ambiguous_local_time;
using date::nonexistent_local_time;
auto i = get_info(tp);
if (i.result == local_info::nonexistent)
throw nonexistent_local_time(tp, i);
else if (i.result == local_info::ambiguous)
throw ambiguous_local_time(tp, i);
return sys_time<Duration>{tp.time_since_epoch()} - i.first.offset;
}
template <class Duration>
date::sys_time<typename std::common_type<Duration, std::chrono::seconds>::type>
time_zone::to_sys(date::local_time<Duration> tp, date::choose z) const
{
using date::local_info;
using date::sys_time;
using date::choose;
auto i = get_info(tp);
if (i.result == local_info::nonexistent)
{
return i.first.end;
}
else if (i.result == local_info::ambiguous)
{
if (z == choose::latest)
return sys_time<Duration>{tp.time_since_epoch()} - i.second.offset;
}
return sys_time<Duration>{tp.time_since_epoch()} - i.first.offset;
}
template <class Duration>
date::local_time<typename std::common_type<Duration, std::chrono::seconds>::type>
time_zone::to_local(date::sys_time<Duration> tp) const
{
using date::local_time;
using std::chrono::seconds;
using LT = local_time<typename std::common_type<Duration, seconds>::type>;
auto i = get_info(tp);
return LT{(tp + i.offset).time_since_epoch()};
}
inline
std::ostream&
operator<<(std::ostream& os, const time_zone& z)
{
using date::operator<<;
os << '{';
os << z.std_abbrev_ << ", " << z.dst_abbrev_ << date::format(", %T, ", z.offset_)
<< date::format("%T, [", z.save_) << z.start_rule_ << ", " << z.end_rule_ << ")}";
return os;
}
inline
std::string
time_zone::name() const
{
using namespace date;
using namespace std::chrono;
auto print_abbrev = [](std::string const& nm)
{
if (std::any_of(nm.begin(), nm.end(),
[](char c)
{
return !std::isalpha(c);
}))
{
return '<' + nm + '>';
}
return nm;
};
auto print_offset = [](seconds off)
{
std::string nm;
hh_mm_ss<seconds> offset{-off};
if (offset.is_negative())
nm += '-';
nm += std::to_string(offset.hours().count());
if (offset.minutes() != minutes{0} || offset.seconds() != seconds{0})
{
nm += ':';
if (offset.minutes() < minutes{10})
nm += '0';
nm += std::to_string(offset.minutes().count());
if (offset.seconds() != seconds{0})
{
nm += ':';
if (offset.seconds() < seconds{10})
nm += '0';
nm += std::to_string(offset.seconds().count());
}
}
return nm;
};
auto nm = print_abbrev(std_abbrev_);
nm += print_offset(offset_);
if (!dst_abbrev_.empty())
{
nm += print_abbrev(dst_abbrev_);
if (save_ != hours{1})
nm += print_offset(offset_+save_);
if (start_rule_.ok())
{
nm += ',';
nm += start_rule_.to_string();
nm += ',';
nm += end_rule_.to_string();
}
}
return nm;
}
inline
bool
operator==(const time_zone& x, const time_zone& y)
{
return x.std_abbrev_ == y.std_abbrev_ &&
x.dst_abbrev_ == y. dst_abbrev_ &&
x.offset_ == y.offset_ &&
x.save_ == y.save_ &&
x.start_rule_ == y.start_rule_ &&
x.end_rule_ == y.end_rule_;
}
inline
bool
operator!=(const time_zone& x, const time_zone& y)
{
return !(x == y);
}
namespace detail
{
inline
void
throw_invalid(const string_t& s, unsigned i, const string_t& message)
{
throw std::runtime_error(std::string("Invalid time_zone initializer.\n") +
std::string(message) + ":\n" +
std::string(s) + '\n' +
"\x1b[1;32m" +
std::string(i, '~') + '^' +
std::string(i < s.size() ? s.size()-i-1 : 0, '~') +
"\x1b[0m");
}
inline
unsigned
read_date(const string_t& s, unsigned i, rule& r)
{
using date::month;
using date::weekday;
if (i == s.size())
throw_invalid(s, i, "Expected rule but found end of string");
if (s[i] == 'J')
{
++i;
unsigned n;
i = read_unsigned(s, i, 3, n, "Expected to find the Julian day [1, 365]");
if (!(1 <= n && n <= 365))
throw_invalid(s, i-1, "Expected Julian day to be in the range [1, 365]");
r.mode_ = rule::J;
r.n_ = n;
}
else if (s[i] == 'M')
{
++i;
unsigned m;
i = read_unsigned(s, i, 2, m, "Expected to find month [1, 12]");
if (!(1 <= m && m <= 12))
throw_invalid(s, i-1, "Expected month to be in the range [1, 12]");
if (i == s.size() || s[i] != '.')
throw_invalid(s, i, "Expected '.' after month");
++i;
unsigned n;
i = read_unsigned(s, i, 1, n, "Expected to find week number [1, 5]");
if (!(1 <= n && n <= 5))
throw_invalid(s, i-1, "Expected week number to be in the range [1, 5]");
if (i == s.size() || s[i] != '.')
throw_invalid(s, i, "Expected '.' after weekday index");
++i;
unsigned wd;
i = read_unsigned(s, i, 1, wd, "Expected to find day of week [0, 6]");
if (wd > 6)
throw_invalid(s, i-1, "Expected day of week to be in the range [0, 6]");
r.mode_ = rule::M;
r.m_ = month{m};
r.wd_ = weekday{wd};
r.n_ = n;
}
else if (std::isdigit(s[i]))
{
unsigned n;
i = read_unsigned(s, i, 3, n);
if (n > 365)
throw_invalid(s, i-1, "Expected Julian day to be in the range [0, 365]");
r.mode_ = rule::N;
r.n_ = n;
}
else
throw_invalid(s, i, "Expected 'J', 'M', or a digit to start rule");
if (i != s.size() && s[i] == '/')
{
++i;
std::chrono::seconds t;
i = read_unsigned_time(s, i, t);
r.time_ = t;
}
return i;
}
inline
unsigned
read_name(const string_t& s, unsigned i, std::string& name)
{
if (i == s.size())
throw_invalid(s, i, "Expected a name but found end of string");
if (s[i] == '<')
{
++i;
while (true)
{
if (i == s.size())
throw_invalid(s, i,
"Expected to find closing '>', but found end of string");
if (s[i] == '>')
break;
name.push_back(s[i]);
++i;
}
++i;
}
else
{
while (i != s.size() && std::isalpha(s[i]))
{
name.push_back(s[i]);
++i;
}
}
return i;
}
inline
unsigned
read_signed_time(const string_t& s, unsigned i,
std::chrono::seconds& t)
{
if (i == s.size())
throw_invalid(s, i, "Expected to read signed time, but found end of string");
bool negative = false;
if (s[i] == '-')
{
negative = true;
++i;
}
else if (s[i] == '+')
++i;
i = read_unsigned_time(s, i, t);
if (negative)
t = -t;
return i;
}
inline
unsigned
read_unsigned_time(const string_t& s, unsigned i, std::chrono::seconds& t)
{
using std::chrono::seconds;
using std::chrono::minutes;
using std::chrono::hours;
if (i == s.size())
throw_invalid(s, i, "Expected to read unsigned time, but found end of string");
unsigned x;
i = read_unsigned(s, i, 2, x, "Expected to find hours [0, 24]");
if (x > 24)
throw_invalid(s, i-1, "Expected hours to be in the range [0, 24]");
t = hours{x};
if (i != s.size() && s[i] == ':')
{
++i;
i = read_unsigned(s, i, 2, x, "Expected to find minutes [0, 59]");
if (x > 59)
throw_invalid(s, i-1, "Expected minutes to be in the range [0, 59]");
t += minutes{x};
if (i != s.size() && s[i] == ':')
{
++i;
i = read_unsigned(s, i, 2, x, "Expected to find seconds [0, 59]");
if (x > 59)
throw_invalid(s, i-1, "Expected seconds to be in the range [0, 59]");
t += seconds{x};
}
}
return i;
}
inline
unsigned
read_unsigned(const string_t& s, unsigned i, unsigned limit, unsigned& u,
const string_t& message)
{
if (i == s.size() || !std::isdigit(s[i]))
throw_invalid(s, i, message);
u = static_cast<unsigned>(s[i] - '0');
unsigned count = 1;
for (++i; count < limit && i != s.size() && std::isdigit(s[i]); ++i, ++count)
u = u * 10 + static_cast<unsigned>(s[i] - '0');
return i;
}
} // namespace detail
} // namespace Posix
namespace date
{
template <>
struct zoned_traits<Posix::time_zone>
{
#if HAS_STRING_VIEW
static
Posix::time_zone
locate_zone(std::string_view name)
{
return Posix::time_zone{name};
}
#else // !HAS_STRING_VIEW
static
Posix::time_zone
locate_zone(const std::string& name)
{
return Posix::time_zone{name};
}
static
Posix::time_zone
locate_zone(const char* name)
{
return Posix::time_zone{name};
}
#endif // !HAS_STRING_VIEW
};
} // namespace date
#endif // PTZ_H

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,316 +0,0 @@
#ifndef TZ_PRIVATE_H
#define TZ_PRIVATE_H
// The MIT License (MIT)
//
// Copyright (c) 2015, 2016 Howard Hinnant
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// Our apologies. When the previous paragraph was written, lowercase had not yet
// been invented (that would involve another several millennia of evolution).
// We did not mean to shout.
#if !defined(_MSC_VER) || (_MSC_VER >= 1900)
#include "tz.h"
#else
#include "date.h"
#include <vector>
#endif
namespace date
{
namespace detail
{
#if !USE_OS_TZDB
enum class tz {utc, local, standard};
//forward declare to avoid warnings in gcc 6.2
class MonthDayTime;
std::istream& operator>>(std::istream& is, MonthDayTime& x);
std::ostream& operator<<(std::ostream& os, const MonthDayTime& x);
class MonthDayTime
{
private:
struct pair
{
#if defined(_MSC_VER) && (_MSC_VER < 1900)
pair() : month_day_(date::jan / 1), weekday_(0U) {}
pair(const date::month_day& month_day, const date::weekday& weekday)
: month_day_(month_day), weekday_(weekday) {}
#endif
date::month_day month_day_;
date::weekday weekday_;
};
enum Type {month_day, month_last_dow, lteq, gteq};
Type type_{month_day};
#if !defined(_MSC_VER) || (_MSC_VER >= 1900)
union U
#else
struct U
#endif
{
date::month_day month_day_;
date::month_weekday_last month_weekday_last_;
pair month_day_weekday_;
#if !defined(_MSC_VER) || (_MSC_VER >= 1900)
U() : month_day_{date::jan/1} {}
#else
U() :
month_day_(date::jan/1),
month_weekday_last_(date::month(0U), date::weekday_last(date::weekday(0U)))
{}
#endif // !defined(_MSC_VER) || (_MSC_VER >= 1900)
U& operator=(const date::month_day& x);
U& operator=(const date::month_weekday_last& x);
U& operator=(const pair& x);
} u;
std::chrono::hours h_{0};
std::chrono::minutes m_{0};
std::chrono::seconds s_{0};
tz zone_{tz::local};
public:
MonthDayTime() = default;
MonthDayTime(local_seconds tp, tz timezone);
MonthDayTime(const date::month_day& md, tz timezone);
date::day day() const;
date::month month() const;
tz zone() const {return zone_;}
void canonicalize(date::year y);
sys_seconds
to_sys(date::year y, std::chrono::seconds offset, std::chrono::seconds save) const;
sys_days to_sys_days(date::year y) const;
sys_seconds to_time_point(date::year y) const;
int compare(date::year y, const MonthDayTime& x, date::year yx,
std::chrono::seconds offset, std::chrono::minutes prev_save) const;
friend std::istream& operator>>(std::istream& is, MonthDayTime& x);
friend std::ostream& operator<<(std::ostream& os, const MonthDayTime& x);
};
// A Rule specifies one or more set of datetimes without using an offset.
// Multiple dates are specified with multiple years. The years in effect
// go from starting_year_ to ending_year_, inclusive. starting_year_ <=
// ending_year_. save_ is in effect for times from the specified time
// onward, including the specified time. When the specified time is
// local, it uses the save_ from the chronologically previous Rule, or if
// there is none, 0.
//forward declare to avoid warnings in gcc 6.2
class Rule;
bool operator==(const Rule& x, const Rule& y);
bool operator<(const Rule& x, const Rule& y);
bool operator==(const Rule& x, const date::year& y);
bool operator<(const Rule& x, const date::year& y);
bool operator==(const date::year& x, const Rule& y);
bool operator<(const date::year& x, const Rule& y);
bool operator==(const Rule& x, const std::string& y);
bool operator<(const Rule& x, const std::string& y);
bool operator==(const std::string& x, const Rule& y);
bool operator<(const std::string& x, const Rule& y);
std::ostream& operator<<(std::ostream& os, const Rule& r);
class Rule
{
private:
std::string name_;
date::year starting_year_{0};
date::year ending_year_{0};
MonthDayTime starting_at_;
std::chrono::minutes save_{0};
std::string abbrev_;
public:
Rule() = default;
explicit Rule(const std::string& s);
Rule(const Rule& r, date::year starting_year, date::year ending_year);
const std::string& name() const {return name_;}
const std::string& abbrev() const {return abbrev_;}
const MonthDayTime& mdt() const {return starting_at_;}
const date::year& starting_year() const {return starting_year_;}
const date::year& ending_year() const {return ending_year_;}
const std::chrono::minutes& save() const {return save_;}
static void split_overlaps(std::vector<Rule>& rules);
friend bool operator==(const Rule& x, const Rule& y);
friend bool operator<(const Rule& x, const Rule& y);
friend bool operator==(const Rule& x, const date::year& y);
friend bool operator<(const Rule& x, const date::year& y);
friend bool operator==(const date::year& x, const Rule& y);
friend bool operator<(const date::year& x, const Rule& y);
friend bool operator==(const Rule& x, const std::string& y);
friend bool operator<(const Rule& x, const std::string& y);
friend bool operator==(const std::string& x, const Rule& y);
friend bool operator<(const std::string& x, const Rule& y);
friend std::ostream& operator<<(std::ostream& os, const Rule& r);
private:
date::day day() const;
date::month month() const;
static void split_overlaps(std::vector<Rule>& rules, std::size_t i, std::size_t& e);
static bool overlaps(const Rule& x, const Rule& y);
static void split(std::vector<Rule>& rules, std::size_t i, std::size_t k,
std::size_t& e);
};
inline bool operator!=(const Rule& x, const Rule& y) {return !(x == y);}
inline bool operator> (const Rule& x, const Rule& y) {return y < x;}
inline bool operator<=(const Rule& x, const Rule& y) {return !(y < x);}
inline bool operator>=(const Rule& x, const Rule& y) {return !(x < y);}
inline bool operator!=(const Rule& x, const date::year& y) {return !(x == y);}
inline bool operator> (const Rule& x, const date::year& y) {return y < x;}
inline bool operator<=(const Rule& x, const date::year& y) {return !(y < x);}
inline bool operator>=(const Rule& x, const date::year& y) {return !(x < y);}
inline bool operator!=(const date::year& x, const Rule& y) {return !(x == y);}
inline bool operator> (const date::year& x, const Rule& y) {return y < x;}
inline bool operator<=(const date::year& x, const Rule& y) {return !(y < x);}
inline bool operator>=(const date::year& x, const Rule& y) {return !(x < y);}
inline bool operator!=(const Rule& x, const std::string& y) {return !(x == y);}
inline bool operator> (const Rule& x, const std::string& y) {return y < x;}
inline bool operator<=(const Rule& x, const std::string& y) {return !(y < x);}
inline bool operator>=(const Rule& x, const std::string& y) {return !(x < y);}
inline bool operator!=(const std::string& x, const Rule& y) {return !(x == y);}
inline bool operator> (const std::string& x, const Rule& y) {return y < x;}
inline bool operator<=(const std::string& x, const Rule& y) {return !(y < x);}
inline bool operator>=(const std::string& x, const Rule& y) {return !(x < y);}
struct zonelet
{
enum tag {has_rule, has_save, is_empty};
std::chrono::seconds gmtoff_;
tag tag_ = has_rule;
#if !defined(_MSC_VER) || (_MSC_VER >= 1900)
union U
#else
struct U
#endif
{
std::string rule_;
std::chrono::minutes save_;
~U() {}
U() {}
U(const U&) {}
U& operator=(const U&) = delete;
} u;
std::string format_;
date::year until_year_{0};
MonthDayTime until_date_;
sys_seconds until_utc_;
local_seconds until_std_;
local_seconds until_loc_;
std::chrono::minutes initial_save_{0};
std::string initial_abbrev_;
std::pair<const Rule*, date::year> first_rule_{nullptr, date::year::min()};
std::pair<const Rule*, date::year> last_rule_{nullptr, date::year::max()};
~zonelet();
zonelet();
zonelet(const zonelet& i);
zonelet& operator=(const zonelet&) = delete;
};
#else // USE_OS_TZDB
struct ttinfo
{
std::int32_t tt_gmtoff;
unsigned char tt_isdst;
unsigned char tt_abbrind;
unsigned char pad[2];
};
static_assert(sizeof(ttinfo) == 8, "");
struct expanded_ttinfo
{
std::chrono::seconds offset;
std::string abbrev;
bool is_dst;
};
struct transition
{
sys_seconds timepoint;
const expanded_ttinfo* info;
transition(sys_seconds tp, const expanded_ttinfo* i = nullptr)
: timepoint(tp)
, info(i)
{}
friend
std::ostream&
operator<<(std::ostream& os, const transition& t)
{
using date::operator<<;
os << t.timepoint << "Z ";
if (t.info->offset >= std::chrono::seconds{0})
os << '+';
os << make_time(t.info->offset);
if (t.info->is_dst > 0)
os << " daylight ";
else
os << " standard ";
os << t.info->abbrev;
return os;
}
};
#endif // USE_OS_TZDB
} // namespace detail
} // namespace date
#if defined(_MSC_VER) && (_MSC_VER < 1900)
#include "tz.h"
#endif
#endif // TZ_PRIVATE_H

View File

@ -1,111 +0,0 @@
#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

View File

@ -1,451 +0,0 @@
///////////////////////////////////////////////////////////////////////////
// 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

File diff suppressed because it is too large Load Diff

View File

@ -1,760 +0,0 @@
#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; //P0~3600
DWORD dwT; //T0~3600
DWORD dwZ; //Z0~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_

View File

@ -1,111 +0,0 @@
#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

View File

@ -1,451 +0,0 @@
///////////////////////////////////////////////////////////////////////////
// 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

File diff suppressed because it is too large Load Diff

View File

@ -1,955 +0,0 @@
#ifndef __LINUX_PLAYM4_H__
#define __LINUX_PLAYM4_H__
#ifdef __cplusplus
extern "C"
{
#endif
typedef unsigned int PLAYM4_HWND;
typedef void * PLAYM4_HWNDEX;
typedef void * PLAYM4_HDC;
#define PLAYM4_API
#define __stdcall
#ifndef CALLBACK
#define CALLBACK
#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 or node cout for decoded data
#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
//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 //Display 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加速没有开启
#define PLAYM4_FEC_ERR_PLACETYPE 117 // 安装方式不对.一个播放库port对应一种安装方式
#define PLAYM4_FEC_ERR_CorrectType 118 // 矫正方式错误:如矫正方式已有,则不能开多个比如一个播放库port,设定除了PTZ和鱼眼半球矫正方式外,其他的矫正方式则只能开一路;设置180度矫正不能和ptz矫正一起开半球矫正与其他矫正则无关联性。
#define PLAYM4_FEC_ERR_NULLWND 119 // 鱼眼窗口为空
#define PLAYM4_FEC_ERR_PARA 120 // 鱼眼参数错误
//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和海康H.264都可以用这个定义
#define VIDEO_MPEG2 0x2 // 标准MPEG2
#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
// 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
typedef struct tagSystemTime
{
short wYear;
short wMonth;
short wDayOfWeek;
short wDay;
short wHour;
short wMinute;
short wSecond;
short wMilliseconds;
}SYSTEMTIME;
typedef struct tagHKRect
{
unsigned long left;
unsigned long top;
unsigned long right;
unsigned long bottom;
}HKRECT;
//Frame position
typedef struct
{
long long nFilePos;
int nFrameNum;
int nFrameTime;
int nErrorFrameNum;
SYSTEMTIME *pErrorTime;
int nErrorLostFrameNum;
int nErrorFrameSize;
}FRAME_POS,*PFRAME_POS;
//Frame Info
typedef struct
{
int nWidth;
int nHeight;
int nStamp;
int nType;
int nFrameRate;
unsigned int dwFrameNum;
}FRAME_INFO;
//Frame
typedef struct
{
char *pDataBuf;
int nSize;
int nFrameNum;
int bIsAudio;
int nReserved;
}FRAME_TYPE;
//Watermark Info //add by gb 080119
typedef struct
{
char *pDataBuf;
int nSize;
int nFrameNum;
int bRsaRight;
int nReserved;
}WATERMARK_INFO;
typedef struct SYNCDATA_INFO
{
unsigned int dwDataType; //和码流数据同步的附属信息类型,目前有:智能信息,车载信息
unsigned int dwDataLen; //附属信息数据长度
unsigned char* 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 char flag; //8bit,0x81表示是 smart标记否则为非smart,快速识别intra的方式是 media_version >= 0x0103&& video_fortmat = (H.264 or H.265) && ((flag & 0x02) ==0x2)
unsigned char stream_tag; //8bit,0x81表示码流中含有SDP信息
unsigned char reserved[14]; // 保留
}HIK_MEDIAINFO;
#endif
typedef struct
{
int nPort;
char* pBuf;
int nBufLen;
int nWidth;
int nHeight;
int nStamp;
int nType;
void* nUser;
}DISPLAY_INFO;
typedef struct
{
int nPort;
char *pVideoBuf;
int nVideoBufLen;
char *pPriBuf;
int nPriBufLen;
int nWidth;
int nHeight;
int nStamp;
int nType;
void* nUser;
}DISPLAY_INFOEX;
typedef struct PLAYM4_SYSTEM_TIME //绝对时间
{
unsigned int dwYear; //年
unsigned int dwMon; //月
unsigned int dwDay; //日
unsigned int dwHour; //时
unsigned int dwMin; //分
unsigned int dwSec; //秒
unsigned int dwMs; //毫秒
} PLAYM4_SYSTEM_TIME;
#ifndef CROP_PIC_INFO_TAG
#define CROP_PIC_INFO_TAG
typedef struct
{
unsigned char* pDataBuf; //抓图数据buffer
unsigned int dwPicSize; //实际图片大小
unsigned int dwBufSize; //数据buffer大小
unsigned int dwPicWidth; //截图宽
unsigned int dwPicHeight; //截图高
unsigned int dwReserve; //多加一个reserve字段
HKRECT* pCropRect; //选择区域NULL, 同老的抓图接口
}CROP_PIC_INFO;
#endif
//////////////////////////////////////////////////////////////////////////////
//API
//////////////////////////////////////////////////////////////////////////////
int PlayM4_GetPort(int* nPort);
int PlayM4_FreePort(int nPort);
int PlayM4_OpenFile(int nPort,char * sFileName);
int PlayM4_CloseFile(int nPort);
int PlayM4_SetStreamOpenMode(int nPort,unsigned int nMode);
int PlayM4_GetStreamOpenMode(int nPort);
int PlayM4_OpenStream(int nPort,unsigned char * pFileHeadBuf,unsigned int nSize,unsigned int nBufPoolSize);
int PlayM4_CloseStream(int nPort);
int PlayM4_Play(int nPort, PLAYM4_HWND hWnd);
int PlayM4_PlayEx(int nPort, PLAYM4_HWNDEX hWnd);
int PlayM4_Stop(int nPort);
int PlayM4_Pause(int nPort,unsigned int nPause);
int PlayM4_Fast(int nPort);
int PlayM4_Slow(int nPort);
int PlayM4_RefreshPlay(int nPort);
int PlayM4_InputData(int nPort,unsigned char * pBuf,unsigned int nSize);
int PlayM4_PlaySound(int nPort);
int PlayM4_StopSound();
int PlayM4_PlaySoundShare(int nPort);
int PlayM4_StopSoundShare(int nPort);
int PlayM4_SetVolume(int nPort,unsigned short nVolume);
unsigned short PlayM4_GetVolume(int nPort);
int PlayM4_OneByOne(int nPort);
int PlayM4_OneByOneBack(int nPort);
int PlayM4_SetPlayPos(int nPort,float fRelativePos);
float PlayM4_GetPlayPos(int nPort);
unsigned int PlayM4_GetFileTime(int nPort);
unsigned int PlayM4_GetPlayedTime(int nPort);
unsigned int PlayM4_GetPlayedFrames(int nPort);
unsigned int PlayM4_GetFileTotalFrames(int nPort);
unsigned int PlayM4_GetCurrentFrameRate(int nPort);
unsigned int PlayM4_GetCurrentFrameNum(int nPort);
unsigned int PlayM4_GetSpecialData(int nPort);
unsigned int PlayM4_GetAbsFrameNum(int nPort);
unsigned int PlayM4_GetFileHeadLength();
unsigned int PlayM4_GetSdkVersion();
unsigned int PlayM4_GetLastError(int nPort);
unsigned int PlayM4_GetPlayedTimeEx(int nPort);
int PlayM4_GetSystemTime(int nPort, PLAYM4_SYSTEM_TIME *pstSystemTime);
int PlayM4_GetFileTimeEx(int nPort, unsigned int* pStart, unsigned int* pStop, unsigned int* pRev);
int PlayM4_GetCurrentFrameRateEx(int nPort, float* pfFrameRate);
int PlayM4_GetPictureSize(int nPort,int *pWidth,int *pHeight);
int PlayM4_GetKeyFramePos(int nPort,unsigned int nValue, unsigned int nType, PFRAME_POS pFramePos);
int PlayM4_GetNextKeyFramePos(int nPort,unsigned int nValue, unsigned int nType, PFRAME_POS pFramePos);
int PlayM4_ConvertToBmpFile(char * pBuf,int nSize,int nWidth,int nHeight,int nType,char *sFileName);
int PlayM4_ConvertToJpegFile(char * pBuf,int nSize,int nWidth,int nHeight,int nType,char *sFileName);
int PlayM4_SetJpegQuality(int nQuality);
int PlayM4_GetBMP(int nPort,unsigned char * pBitmap,unsigned int nBufSize,unsigned int* pBmpSize);
int PlayM4_GetJPEG(int nPort,unsigned char * pJpeg,unsigned int nBufSize,unsigned int* pJpegSize);
int PlayM4_SetPlayedTimeEx(int nPort,unsigned int nTime);
int PlayM4_SetCurrentFrameNum(int nPort,unsigned int nFrameNum);
int PlayM4_SetDisplayRegion(int nPort,unsigned int nRegionNum, HKRECT *pSrcRect, PLAYM4_HWND hDestWnd, int bEnable);
int PlayM4_SetDisplayRegionOnWnd(int nPort,unsigned int nRegionNum, HKRECT *pSrcRect, int bEnable);///<多窗口分割接口
int PlayM4_SetDecodeFrameType(int nPort,unsigned int nFrameType);
int PlayM4_SetSecretKey(int nPort, int lKeyType, char *pSecretKey, int lKeyLen);
int PlayM4_SetDecCBStream(int nPort,unsigned int nStream);
int PlayM4_SetDecCallBackMend(int nPort,void (CALLBACK* DecCBFun)(int nPort,char * pBuf,int nSize,FRAME_INFO * pFrameInfo, void* nUser,int nReserved2), void* nUser);
int PlayM4_SetDecCallBackExMend(int nPort, void (CALLBACK* DecCBFun)(int nPort, char* pBuf, int nSize, FRAME_INFO* pFrameInfo, void* nUser, int nReserved2), char* pDest, int nDestSize, void* nUser);
int PlayM4_SetDisplayCallBack(int nPort,void (CALLBACK* DisplayCBFun)(int nPort,char * pBuf,int nSize,int nWidth,int nHeight,int nStamp,int nType,int nReserved));
int PlayM4_SetDisplayCallBackEx(int nPort,void (CALLBACK* DisplayCBFun)(DISPLAY_INFO *pstDisplayInfo), void* nUser);
int PlayM4_SetFileRefCallBack(int nPort, void (CALLBACK *pFileRefDone)(unsigned int nPort,void* nUser),void* nUser);
int PlayM4_SetEncTypeChangeCallBack(int nPort, void(CALLBACK *funEncChange)(int nPort, void* nUser), void* nUser);
int PlayM4_SetCheckWatermarkCallBack(int nPort, void(CALLBACK* funCheckWatermark)(int nPort, WATERMARK_INFO* pWatermarkInfo, void* nUser), void* nUser);
int PlayM4_SetFileEndCallback(int nPort, void(CALLBACK*FileEndCallback)(int nPort, void *pUser), void *pUser);
int PlayM4_ResetSourceBuffer(int nPort);
int PlayM4_SetDisplayBuf(int nPort, unsigned int nNum);
int PlayM4_ResetBuffer(int nPort,unsigned int nBufType);
unsigned int PlayM4_GetSourceBufferRemain(int nPort);
unsigned int PlayM4_GetDisplayBuf(int nPort);
unsigned int PlayM4_GetBufferValue(int nPort,unsigned int nBufType);
int PlayM4_GetRefValue(int nPort,unsigned char *pBuffer, unsigned int *pSize);
int PlayM4_SetRefValue(int nPort,unsigned char *pBuffer, unsigned int nSize);
int PlayM4_GetRefValueEx(int nPort,unsigned char *pBuffer, unsigned int *pSize);///< 增加帧类型回调
int PlayM4_RegisterDrawFun(int nPort,void (CALLBACK* DrawFun)(int nPort,PLAYM4_HDC hDc,void* nUser),void* nUser);
int PlayM4_ThrowBFrameNum(int nPort,unsigned int nNum);
int PlayM4_SkipErrorData(int nPort, int bSkip);
int PlayM4_ReversePlay(int nPort);
#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 int __stdcall PlayM4_OpenStreamAdvanced(int nPort, int nProtocolType, PLAYM4_SESSION_INFO* pstSessionInfo, unsigned int 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 int __stdcall PlayM4_SetRotateAngle(int nPort, unsigned int nRegionNum, unsigned int dwType);
#ifndef PLAYM4_ADDITION_INFO_TAG
#define PLAYM4_ADDITION_INFO_TAG
typedef struct _PLAYM4_ADDITION_INFO_ //交互信息结构
{
unsigned char* pData; //附件数据
unsigned int dwDatalen; //附件数据长度
unsigned int dwDataType; //数据类型
unsigned int dwTimeStamp; //相对时间戳
} PLAYM4_ADDITION_INFO;
#endif
//dwGroupIndex 暂约定取值0~3第一版本取消同步只能同个closestream处理
PLAYM4_API int __stdcall PlayM4_SetSycGroup(int nPort, unsigned int dwGroupIndex);
//暂不实现此函数,同个组设置的起始时间不一致,以最小的时间作为播放起点,同一组可只设一路
PLAYM4_API int __stdcall PlayM4_SetSycStartTime(int 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_NULL = 0x0, // 不矫正(原图)
FEC_CORRECT_PTZ = 0x100, // PTZ
FEC_CORRECT_180 = 0x200, // 180度矫正 对应2P
FEC_CORRECT_360 = 0x300, // 360全景矫正 对应1P
FEC_CORRECT_LAT = 0x400, // 纬度展开
FEC_CORRECT_SEMISPHERE = 0x500, // 3D半球矫正
FEC_CORRECT_CYLINDER = 0x0600, // 鱼眼圆柱显示 - 顶装/底装
FEC_CORRECT_CYLINDER_SPLIT = 0x0700, // 鱼眼切开的圆柱显示 - 顶装/底装
FEC_CORRECT_PLANET = 0x0800, // 鱼眼小行星
FEC_CORRECT_ARCSPHERE_HORIZONTAL = 0x0900, // 鱼眼水平弧面 - 壁装
FEC_CORRECT_ARCSPHERE_VERTICAL = 0x0A00, // 鱼眼垂直弧面 - 壁装
}FECCORRECTTYPE;
typedef enum tagFECCorrectEffect
{
FEC_CORRECT_EFFECT_BACK_FACE_CULLING = 0x100, // 背面剔除非0表示启用为0表示不启用建议设置整数强转浮点数
}FECCORRECTEFFECT;
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;
// PTZ在原始鱼眼图上轮廓的显示模式
typedef enum tagFECShowMode
{
FEC_PTZ_OUTLINE_NULL, // 不显示
FEC_PTZ_OUTLINE_RECT, // 矩形显示
FEC_PTZ_OUTLINE_RANGE, // 真实区域显示
}FECSHOWMODE;
// 更新标记变量定义
#define FEC_UPDATE_RADIUS 0x1
#define FEC_UPDATE_PTZZOOM 0x2
#define FEC_UPDATE_WIDESCANOFFSET 0x4
#define FEC_UPDATE_PTZPARAM 0x8
#define FEC_UPDATT_PTZCOLOR 0x10
// 色彩结构体
typedef struct tagFECColor
{
unsigned char nR; // R分量
unsigned char nG; // G分量
unsigned char nB; // B分量
unsigned char nAlpha; // Alpha分量
}FECCOLOR;
typedef struct tagFECParam
{
unsigned int nUpDateType; // 更新的类型
unsigned int nPlaceAndCorrect; // 安装方式和矫正方式只能用于获取SetParam的时候无效,该值表示安装方式和矫正方式的和
PTZPARAM stPTZParam; // PTZ 校正的参数
CYCLEPARAM stCycleParam; // 鱼眼图像圆心参数
float fZoom; // PTZ 显示的范围参数
float fWideScanOffset; // 180或者360度校正的偏移角度
FECCOLOR stPTZColor; // PTZ颜色
int nResver[15]; // 保留字段
}FISHEYEPARAM;
#define FEC_JPEG 0 // JPEG抓图
#define FEC_BMP 1 // BMP 抓图
///<新的3d鱼眼半球矫正画面的视角变化调节(缩放和旋转)
typedef enum tagPLAYM4HRViewParamType
{
PLAYM4_HR_VPT_ROTATION_X = 0x1, ///<水平旋转
PLAYM4_HR_VPT_ROTATION_Y = 0x2, ///<垂直旋转
PLAYM4_HR_VPT_SCALE = 0x3, ///<缩放(其绝对值为浮点型0值时为黑屏-正常效果)
}PLAYM4HRVIEWPARAMTYPE;
// 鱼眼3D模型参数
typedef enum tagPLAYM4FEC3DModelParam
{
PLAYM4_FEC_3DMP_CYLINDER_HEIGHT = 0x1, ///< 圆柱模型高
PLAYM4_FEC_3DMP_CYLINDER_RADIUS = 0x2, ///< 圆柱模型半径
}PLAYM4FEC3DMODELPARAM;
// 特定视角状态
typedef enum tagPLAYM4FECSpecialViewType
{
PLAYM4_FEC_SVT_EDGE = 0x1 ///<弧面鱼眼模型与窗口贴边视角
}PLAYM4FECSPECIALVIEWTYPE;
#endif
typedef void (__stdcall * FISHEYE_CallBack )( void* pUser , unsigned int nPort , unsigned int nCBType , void * hDC , unsigned int nWidth , unsigned int nHeight);
// 启用鱼眼
PLAYM4_API int __stdcall PlayM4_FEC_Enable(int nPort);
// 关闭鱼眼模块
PLAYM4_API int __stdcall PlayM4_FEC_Disable(int nPort);
// 获取鱼眼矫正处理子端口 [1~31]
PLAYM4_API int __stdcall PlayM4_FEC_GetPort(int nPort , unsigned int* nSubPort , FECPLACETYPE emPlaceType , FECCORRECTTYPE emCorrectType);
// 删除鱼眼矫正处理子端口
PLAYM4_API int __stdcall PlayM4_FEC_DelPort(int nPort , unsigned int nSubPort);
// 设置鱼眼矫正参数
PLAYM4_API int __stdcall PlayM4_FEC_SetParam(int nPort , unsigned int nSubPort , FISHEYEPARAM * pPara);
// 获取鱼眼矫正参数
PLAYM4_API int __stdcall PlayM4_FEC_GetParam(int nPort , unsigned int nSubPort , FISHEYEPARAM * pPara);
// 设置显示窗口,可以随时切换
PLAYM4_API int __stdcall PlayM4_FEC_SetWnd(int nPort , unsigned int nSubPort , void * hWnd);
// 设置鱼眼窗口的绘图回调
PLAYM4_API int __stdcall PlayM4_FEC_SetCallBack(int nPort , unsigned int nSubPort , FISHEYE_CallBack cbFunc , void * pUser);
PLAYM4_API int __stdcall PlayM4_FEC_Capture(int nPort, unsigned int nSubPort , unsigned int nType, char *pFileName);
PLAYM4_API int __stdcall PlayM4_FEC_GetCurrentPTZPort(int nPort, float fPositionX,float fPositionY, unsigned int *pnPort);
PLAYM4_API int __stdcall PlayM4_FEC_SetCurrentPTZPort(int nPort, unsigned int nSubPort);
PLAYM4_API int __stdcall PlayM4_FEC_SetPTZOutLineShowMode(int nPort,FECSHOWMODE nPTZShowMode);
//新的鱼眼半球矫正视角变化(旋转)两个相关接口
//获取半球矫正视角参数(设置前先获取当前的值)
PLAYM4_API int __stdcall PlayM4_FEC_GetViewParam(int nPort, unsigned int nSubPort, PLAYM4HRVIEWPARAMTYPE enViewParamType, float* fValue);
//设置半球矫正视角变化参数(设置的值为获取值加上要偏移值)
PLAYM4_API int __stdcall PlayM4_FEC_SetViewParam(int nPort, unsigned int nSubPort, PLAYM4HRVIEWPARAMTYPE enViewParamType, float fValue);
//鱼眼电子放大 nType = 0
//鱼眼窗口分割 nType = 1
//注意窗口分割时hDestWnd无效请设置为NULL20180813暂不支持
//目前电子放大不支持其他窗口上放大nRegionNum置为0hDestWnd置为NULLbEnable置为0取消电子放大非0为电子放大
//pSrcRect区域归一化乘以1000除以宽或者高其值在0-1000之间
//只推荐原图、180、360、纬度展开不带PTZ显示电子放大再开ptz会导致电子放大失效-3D鱼眼不建议使用此接口(用视角变化接口进行缩放)
PLAYM4_API bool __stdcall PlayM4_FEC_SetDisplayRegion(int nPort, unsigned int nSubPort,unsigned int nType, unsigned int nRegionNum, HKRECT *pSrcRect, PLAYM4_HWND hDestWnd, int bEnable);
//背面剔除非0表示启用为0表示不启用建议设置整数强转浮点数
PLAYM4_API bool __stdcall PlayM4_FEC_SetCorrectEffect(int nPort, unsigned int nSubPort, FECCORRECTEFFECT nCorrectEffect, float fValue);
// 设置3D模型参数-针对3D圆柱展开有效
PLAYM4_API bool __stdcall PlayM4_FEC_Set3DModelParam(int nPort, unsigned int nSubPort, PLAYM4FEC3DMODELPARAM enType, float fValue);
// 获取特定视角参数 - 只适用于弧面跟SetViewParam接口配合使用
PLAYM4_API bool __stdcall PlayM4_FEC_GetSpecialViewParam(int nPort, unsigned int nSubPort, PLAYM4FECSPECIALVIEWTYPE enSVType, PLAYM4HRVIEWPARAMTYPE enVPType, float* pValue);
//图像增强相关-Linux版本不支持
#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
//设置关闭/开启模块 -- NO SUPPORT
//dwModuFlag对应PLAYM4_VIE_MODULES宏,可组合
//先设置模块开启,再设置模块参数;期间采用默认的参数;
//关闭模块后,上次设置的参数清空
//其他接口调用,必须在该接口开启模块后;否则,返回错误
PLAYM4_API int __stdcall PlayM4_VIE_SetModuConfig(int nPort, int nModuFlag, int bEnable);
//设置图像增强区域NULL全图超过全图采用全图最小区域16*16像素 -- NO SUPPORT
//可支持设置区域最多比较说4个第一个版本可以只支持一个。多个区域要求不能重叠有重叠就报错
PLAYM4_API int __stdcall PlayM4_VIE_SetRegion(int nPort, int nRegNum, HKRECT* pRect);
//获取开启模块 -- NO SUPPORT
PLAYM4_API int __stdcall PlayM4_VIE_GetModuConfig(int nPort, int* pdwModuFlag);
//设置参数
//未开启模块的参数设置被忽略 -- NO SUPPORT
PLAYM4_API int __stdcall PlayM4_VIE_SetParaConfig(int nPort, PLAYM4_VIE_PARACONFIG* pParaConfig);
//获取开启模块的参数 -- NO SUPPORT
PLAYM4_API int __stdcall PlayM4_VIE_GetParaConfig(int nPort, PLAYM4_VIE_PARACONFIG* pParaConfig);
// 私有信息模块类型
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_PRIDATA_RENDER;
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;
typedef enum _PLAYM4_TEM_FLAG
{
PLAYM4_TEM_REGION_BOX = 0x00000001, //框测温
PLAYM4_TEM_REGION_LINE = 0x00000002, //线测温
PLAYM4_TEM_REGION_POINT = 0x00000004, //点测温
}PLAYM4_TEM_FLAG;
// 智能信息开关
PLAYM4_API int __stdcall PlayM4_RenderPrivateData(int nPort, int nIntelType, int bTrue);
///<智能信息子开关
PLAYM4_API int __stdcall PlayM4_RenderPrivateDataEx(int nPort, int nIntelType, int nSubType, int bTrue);
//ENCRYPT Info
typedef struct{
long nVideoEncryptType; //视频加密类型
long nAudioEncryptType; //音频加密类型
long nSetSecretKey; //是否设置1表示设置密钥0表示没有设置密钥
}ENCRYPT_INFO;
// 加密码流回调,nType=0表示码流加密标记位发生变化就回调nType=1表示码流有加密位发生回调
PLAYM4_API int __stdcall PlayM4_SetEncryptTypeCallBack(int nPort, unsigned int nType, void (CALLBACK* EncryptTypeCBFun)(int nPort, ENCRYPT_INFO* pEncryptInfo, void* nUser, int nReserved2), void* nUser);
#define PLAYM4_MEDIA_HEAD 1 //系统头数据
#define PLAYM4_VIDEO_DATA 2 //视频流数据
#define PLAYM4_AUDIO_DATA 3 //音频流数据
#define PLAYM4_PRIVT_DATA 4 //私有流数据
//预录像数据信息- NO SUPPORT
typedef struct
{
long nType; // 数据类型,如文件头,视频,音频,私有数据等
long nStamp; // 时间戳
long nFrameNum; // 帧号
long nBufLen; // 数据长度
char* pBuf; // 帧数据,以帧为单位回调
PLAYM4_SYSTEM_TIME stSysTime; // 全局时间
}RECORD_DATA_INFO;
//设置预录像开关bFlag=1开启bFlag=0关闭-- NO SUPPORT
PLAYM4_API int __stdcall PlayM4_SetPreRecordFlag(int nPort, int bFlag);
//预录像数据数据回调- NO SUPPORT
PLAYM4_API int __stdcall PlayM4_SetPreRecordCallBack(int nPort, void (CALLBACK* PreRecordCBfun)(int nPort, RECORD_DATA_INFO* pRecordDataInfo, void* pUser), void* pUser);
typedef struct
{
long lDataType; //私有数据类型
long lDataStrVersion; //数据返回的结构体版本,主要是为了兼容性
long lDataTimeStamp;
long lDataLength;
char* pData;
}AdditionDataInfo;
PLAYM4_API int __stdcall PlayM4_SetAdditionDataCallBack(int nPort, unsigned int nSyncType, void (CALLBACK* AdditionDataCBFun)(int nPort, AdditionDataInfo* pstAddDataInfo, void* pUser), void* pUser);
//lType: 1 表示获取当前显示帧PTZ信息。以特定结构体形式存储在pInfo内plLen返回长度信息;起先传入pInfo = null可以获取出需要分配的内存长度plLen
PLAYM4_API int __stdcall PlayM4_GetStreamAdditionalInfo(int nPort, int lType, unsigned char* pInfo, int* plLen);
#define PLAYM4_SOURCE_MODULE 0 // 数据源模块
#define PLAYM4_DEMUX_MODULE 1 // 解析模块
#define PLAYM4_DECODE_MODULE 2 // 解码模块
#define PLAYM4_RENDER_MODULE 3 // 渲染模块
#define PLAYM4_RTINFO_HARDDECODE_ERROR 0 // 硬解码致命(需要切软解)错误
#define PLAYM4_RTINFO_SOFTDECODE_ERROR 1 // 软解码错误(不支持)
#define PLAYM4_RTINFO_MEDIAHEADER_ERROR 2 // 媒体头错误
#define PLAYM4_RTINFO_SWITCH_SOFT_DEC 3 // 切换至软解
#define PLAYM4_RTINFO_ALLOC_MEMORY_ERROR 4 // 内存分配失败
#define PLAYM4_RTINFO_ENCRYPT_ERROR 5 // 秘钥错误
#define PLAYM4_RTINFO_RENDER_OVER 8 // 渲染一帧结束
#define PLAYM4_RTINFO_ERR_PRESENT 16 // 渲染显示错误[当前渲染引擎渲染失败,上层重新切换引擎]
#define PLAYM4_RTINFO_IDMX_DATA_ERROR 32 // 数据有误,解析失败
#define PLAYM4_RTINFO_DECODE_PARAM_ERROR 64 // 参数有误,解码失败
#define PLAYM4_RTINFO_SOFTDECODE_DATA_ERROR 128 // 软解码数据错误
typedef struct
{
int nRunTimeModule; //当前运行模块暂定2为解码模块后续扩展
int nStrVersion; //数据返回的结构体版本,主要是为了兼容性,第一个版本定义成0x0001
int nFrameTimeStamp; //帧号
int nFrameNum; //时间戳
int nErrorCode; //错误码,0为硬解错误
unsigned char reserved[12]; //保留字节
}RunTimeInfo;
///<实时信息回调接口
PLAYM4_API int __stdcall PlayM4_SetRunTimeInfoCallBackEx(int nPort, int nModule, void (CALLBACK* RunTimeInfoCBFun)(int nPort, RunTimeInfo* pstRunTimeInfo, void* pUser), void* pUser);
// 1、SetRunTimeInfoCallBackEx接口nErrorCode类型6改为类型8以后扩展方式 16、32、64且从8开始消息默认关闭不发送。
// 2、新增消息控制接口控制从8以后的消息支持从8开始后消息拼接模式 8|16|32 这种方式,上层主动选择接受类型。
// 3、nType可以通过或的方式将类型传入nFlag表示清除为0或者进行回调非0
PLAYM4_API int __stdcall PlayM4_SetRunTimeInfoCallbackType(int nPort, int nModule, unsigned int nType, int nFlag);
///<渲染显示相关接口
#ifndef PLAYM4_HIKD3D11_TAG
#define PLAYM4_HIKD3D11_TAG
///<渲染抓图结构体
typedef struct _tagD3D11_PIC_INFO_
{
unsigned int nPicMode; //抓图模式0-按照码流实际分辨率抓图(之前抓图模式)1-按照下面传入的宽高抓图nPicWidth*nPicHeight为显示窗口宽高时效果最佳
unsigned char* pBuf; //抓图数据buffer
unsigned int nBufSize; //缓存buffer大小-如果nPicMode为0则为之前的根据获取到的码流分辨率来进行缓存申请如果nPicMode为1则上层根据设置的分辨率来申请缓存
unsigned int* pPicSize; //实际图片大小
unsigned int nPicWidth; //设置抓图宽-nPicMode为1时有效且宽>=32,nPicWidth*nPicHeight<5000w分辨率。
unsigned int nPicHeight; //设置抓图高-nPicMode为1时有效且高>=32,nPicWidth*nPicHeight<5000w分辨率。
unsigned char chReserve[8]; //reserve保留字段
}D3D_PIC_INFO;
/*渲染图像后处理类型*/
typedef enum tagPLAYM4PostProcType
{
PLAYM4_PPT_BRIGHTNESS = 0x1, ///< 亮度 [-1.0, 1.0]
PLAYM4_PPT_HUE = 0x2, ///< 色度 [0.0, 1.0]----0.166累加为一种颜色变化及0和1为同一种颜色
PLAYM4_PPT_SATURATION = 0x3, ///< 饱和度 [-1.0, 1.0]
PLAYM4_PPT_CONTRAST = 0x4, ///< 对比度 [-1.0, 1.0]
PLAYM4_PPT_SHARPNESS = 0x5, ///< 锐度 [ 0.0, 1.0]
}PLAYM4PostProcType;
#endif
///<渲染库抓图:nType:0-jpeg,1-bmp.
PLAYM4_API int __stdcall PlayM4_GetD3DCapture(int nPort, unsigned int nType, D3D_PIC_INFO* pstPicInfo);
///<渲染后处理-设置参数
PLAYM4_API int __stdcall PlayM4_SetD3DPostProcess(int nPort, PLAYM4PostProcType nPostType, float fValue);
///<渲染后处理-获取参数
PLAYM4_API int __stdcall PlayM4_GetD3DPostProcess(int nPort, PLAYM4PostProcType nPostType, float* fValue);
///<字符叠加的字体库路径(不设置时采用默认字体库)-play前设置
PLAYM4_API int __stdcall PlayM4_SetConfigFontPath(int nPort, char* pFontPath);
// 根据相对时间获取mp4封装在线定位偏移
PLAYM4_API int __stdcall PlayM4_GetMpOffset(int nPort, int nTime, int* nOffset);
///<时区的表示以秒为单位,东区为正,西区为负-同步回放
PLAYM4_API bool __stdcall PlayM4_SetSupplementaryTimeZone(int nPort, int nTimeZone);
///<若已经设置时区则返回设置时区,否则失败-同步回放
PLAYM4_API bool __stdcall PlayM4_GetSupplementaryTimeZone(int nPort, int* pTimeZone);
////////////////////////////////////
///<窗口大小改变通知接口
PLAYM4_API int __stdcall PlayM4_WndResolutionChange(int nPort);//new add
//不建议使用
PLAYM4_API int __stdcall PlayM4_SetRunTimeInfoCallBack(int nPort, void (CALLBACK* RunTimeInfoCBFun)(int nPort, RunTimeInfo* pstRunTimeInfo, void* pUser), void* pUser);
int PlayM4_RigisterDrawFun(int nPort,void (CALLBACK* DrawFun)(int nPort,PLAYM4_HDC hDc,void* nUser),void* nUser);
int PlayM4_SetDecCallBack(int nPort,void (CALLBACK* DecCBFun)(int nPort,char* pBuf,int nSize,FRAME_INFO * pFrameInfo, void* nReserved1,int nReserved2));
int PlayM4_SetDecCallBackEx(int nPort,void (CALLBACK* DecCBFun)(int nPort,char * pBuf,int nSize,FRAME_INFO * pFrameInfo, void* nReserved1,int nReserved2), char* pDest, int nDestSize);
int PlayM4_SetTimerType(int nPort,unsigned int nTimerType,unsigned int nReserved);
int PlayM4_GetTimerType(int nPort,unsigned int *pTimerType,unsigned int *pReserved);
int PlayM4_SetDisplayMode(int nPort, unsigned int dwType);
int PlayM4_SetVideoWindow(int nPort, unsigned int nRegionNum, PLAYM4_HWND hWnd);
/////////////////////////////////////////////////////////////////////////////
////////////////NO SUPPORT///////////////////////////////////////////////////
int PlayM4_InitDDraw(PLAYM4_HWND hWnd);
int PlayM4_RealeseDDraw();
#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/";
int PlayM4_InitDDrawDevice();
void PlayM4_ReleaseDDrawDevice();
int PlayM4_SetDDrawDevice(int nPort, unsigned int nDeviceNum);
int PlayM4_SetDDrawDeviceEx(int nPort,unsigned int nRegionNum,unsigned int nDeviceNum);
int PlayM4_GetDDrawDeviceInfo(unsigned int nDeviceNum, char* lpDriverDescription, unsigned int nDespLen, char* lpDriverName, unsigned int nNameLen, HMONITOR* hhMonitor);
int PlayM4_GetCapsEx(unsigned int nDDrawDeviceNum);
unsigned int PlayM4_GetDDrawDeviceTotalNums();
#endif
int PlayM4_GetCaps();
int PlayM4_OpenStreamEx(int nPort, unsigned char* pFileHeadBuf, unsigned int nSize, unsigned int nBufPoolSize);
int PlayM4_CloseStreamEx(int nPort);
int PlayM4_InputVideoData(int nPort, unsigned char* pBuf, unsigned int nSize);
int PlayM4_InputAudioData(int nPort, unsigned char* pBuf, unsigned int nSize);
int PlayM4_GetFileSpecialAttr(int nPort, unsigned int* pTimeStamp, unsigned int* pFileNum, unsigned int* pReserved);
//int PlayM4_SetOverlayMode(int nPort, int bOverlay, COLORREF colorKey);
int PlayM4_GetOverlayMode(int nPort);
int PlayM4_SetOverlayFlipMode(int nPort, int bTrue);
//COLORREF PlayM4_GetColorKey(int nPort);
int PlayM4_SetPicQuality(int nPort, int bHighQuality);
int PlayM4_GetPictureQuality(int nPort, int* bHighQuality);
int PlayM4_ResetSourceBufFlag(int nPort);
int PlayM4_SetDisplayType(int nPort, int nType);
int PlayM4_GetDisplayType(int nPort);
int PlayM4_SyncToAudio(int nPort, int bSyncToAudio);
int PlayM4_RefreshPlayEx(int nPort, unsigned int nRegionNum);
int PlayM4_AdjustWaveAudio(int nPort, int nCoefficient);
int PlayM4_SetPlayMode(int nPort, int bNormal);
int PlayM4_SetColor(int nPort, unsigned int nRegionNum, int nBrightness, int nContrast, int nSaturation, int nHue);
int PlayM4_GetColor(int nPort, unsigned int nRegionNum, int* pBrightness, int* pContrast, int* pSaturation, int* pHue);
int PlayM4_SetImageSharpen(int nPort, unsigned int nLevel);
int PlayM4_SetDeflash(int nPort, int bDefalsh);
int PlayM4_CheckDiscontinuousFrameNum(int nPort, int bCheck);
int PlayM4_SetFileEndMsg(int nPort, PLAYM4_HWND hWnd, unsigned int nMsg);
int PlayM4_SetVerifyCallBack(int nPort, unsigned int nBeginTime, unsigned int nEndTime, void (__stdcall* funVerify)(int nPort, FRAME_POS* pFilePos, unsigned int bIsVideo, unsigned int nUser), unsigned int nUser);
int PlayM4_SetEncChangeMsg(int nPort, PLAYM4_HWND hWnd, unsigned int nMsg);
int PlayM4_SetGetUserDataCallBack(int nPort, void(CALLBACK* funGetUserData)(int nPort, unsigned char* pUserBuf, unsigned int nBufLen, unsigned int nUser), unsigned int nUser);
int PlayM4_SetSourceBufCallBack(int nPort, unsigned int nThreShold, void (CALLBACK* SourceBufCallBack)(int nPort, unsigned int nBufSize, unsigned int dwUser, void* pResvered), unsigned int dwUser, void* pReserved);
int PlayM4_GetOriginalFrameCallBack(int nPort, int bIsChange, int bNormalSpeed, int nStartFrameNum, int nStartStamp, int nFileHeader, void(CALLBACK *funGetOrignalFrame)(int nPort, FRAME_TYPE* frameType, int nUser), int nUser);
int PlayM4_GetThrowBFrameCallBack(int nPort, void(CALLBACK* funThrowBFrame)(int nPort, unsigned int nBFrame, unsigned int nUser), unsigned int nUser);
int PlayM4_SetAudioCallBack(int nPort, void (__stdcall* funAudio)(int nPort, char* pAudioBuf, int nSize, int nStamp, int nType, int nUser), int nUser);
//motionflow
PLAYM4_API int __stdcall PlayM4_MotionFlow(int nPort, unsigned int dwAdjustType);
////////////////////////////////////////////////////////////////////////////////
#ifdef __cplusplus
}
#endif
#endif //_PLAYM4_H_

23761
src/json.hpp

File diff suppressed because it is too large Load Diff