Files
gb28181/GB28181Device/sip/gb28181_msg.h
2024-12-15 20:42:32 +08:00

528 lines
20 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/***************************************************************************************
*
* IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
*
* By downloading, copying, installing or using the software you agree to this license.
* If you do not agree to this license, do not download, install,
* copy or use the software.
*
* Copyright (C) 2014-2022, Happytimesoft Corporation, all rights reserved.
*
* Redistribution and use in binary forms, with or without modification, are permitted.
*
* Unless required by applicable law or agreed to in writing, software distributed
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
****************************************************************************************/
#ifndef GB28181_MSG_H
#define GB28181_MSG_H
#include "sys_inc.h"
#include "sip_inc.h"
#include "xml_node.h"
/***********************************************************************/
typedef enum
{
RESULT_OK,
RESULT_ERROR,
} GB28181_RESULT;
typedef enum
{
STATUS_ON,
STATUS_OFF,
} GB28181_STATUS;
/***********************************************************************/
typedef struct
{
uint32 SN; // 命令序列号(必选)
char DeviceID[64]; // 目录设备/视频监控联网系统/区域编码(必选)
} GB28181_REQ_HDR;
typedef struct
{
uint32 FilePathFlag : 1;
uint32 AddressFlag : 1;
uint32 StartTimeFlag : 1;
uint32 EndTimeFlag : 1;
uint32 TypeFlag : 1;
uint32 RecorderIDFlag : 1;
uint32 FileSizeFlag : 1;
uint32 Reserved : 25;
char DeviceID[100]; // 设备/区域编码(必选)
char Name[100]; // 设备/区域名称(必选)
char FilePath[256]; // 文件路径名 (可选)
char Address[100]; // 录像地址(可选)
time_t StartTime; // 录像开始时间(可选)
time_t EndTime; // 录像结束时间(可选)
int Secrecy; // 保密属性(必选)缺省为0; 0:不涉密, 1:涉密
char Type[16]; // 录像产生类型(可选) time或alarm或manual
char RecorderID[100]; // 录像触发者ID(可选)
int FileSize; // 录像文件大小,单位: Byte(可选)
} GB28181_RECORD_INFO;
typedef struct
{
uint32 PTZTypeFlag : 1;
uint32 PositionTypeFlag : 1;
uint32 RoomTypeFlag : 1;
uint32 UseTypeFlag : 1;
uint32 SupplyLightTypeFlag : 1;
uint32 DirectionTypeFlag : 1;
uint32 ResolutionFlag : 1;
uint32 BusinessGroupIDFlag : 1;
uint32 DownloadSpeedFlag : 1;
uint32 SVCSpaceSupportModeFlag : 1;
uint32 SVCTimeSupportModeFlag : 1;
uint32 Reserved : 21;
int PTZType; // 摄像机类型扩展,标识摄像机类型: 1-球机; 2-半球; 3-固定枪机; 4-遥控枪机。当目录项为摄像机时可选
int PositionType; // 摄像机位置类型扩展。1-省际检查站、 2-党政机关、 3-车站码头、 4-中心广 场、 5-体育场馆、
// 6-商业中心、 7-宗教场所、 8-校园周边、 9-治安复杂区域、 10-交通 干线。当目录项为摄像机时可选
int RoomType; // 摄像机安装位置室外、室内属性。1-室外、 2-室内。当目录项为摄像机时可选,缺省为1
int UseType; // 摄像机用途属性。1 -治安、 2 -交通、 3 -重点。当目录项为摄像机时可选
int SupplyLightType; // 摄像机补光属性。1 -无补光、 2 -红外补光、 3 -白光补光。当目录项为摄像机时可选,缺省为1
int DirectionType; // 摄像机监视方位属性。1 -东、 2 -西、 3 -南、 4 -北、 5 -东南、 6 -东北、 7 -西南、 8 -西北。
// 当目录项为摄像机时且为固定摄像机或设置看守位摄像机时可选
char Resolution[20]; // 摄像机支持的分辨率,可有多个分辨率值,各个取值间以“/”分隔。当目录项为摄像机时可选
// 1———QCIF 2———CIF 3———4CIF 4———D1 5———720P 6———1080P/I
char BusinessGroupID[64];// 虚拟组织所属的业务分组ID,业务分组根据特定的业务需求制定,一个业务分组包含一组特定的虚拟组织
char DownloadSpeed[20]; // 下载倍速范围(可选),各可选参数以“/”分隔,如设备支持1, 2, 4倍速下载则应写为“1/2/4”
int SVCSpaceSupportMode;// 空域编码能力,取值0:不支持; 1: 1级增强( 1个增强层); 2: 2级增强(2个增强层); 3: 3级增强(3个增强层)(可选)
int SVCTimeSupportMode; // 时域编码能力,取值0:不支持; 1: 1级增强; 2: 2级增强; 3: 3级增强(可选)
} GB28181_DEVICE_EX;
typedef struct
{
uint32 BlockFlag : 1;
uint32 SafetyWayFlag : 1;
uint32 CertNumFlag : 1;
uint32 CertifiableFlag : 1;
uint32 ErrCodeFlag : 1;
uint32 EndTimeFlag : 1;
uint32 IPAddressFlag : 1;
uint32 PortFlag : 1;
uint32 PasswordFlag : 1;
uint32 LongitudeFlag : 1;
uint32 LatitudeFlag : 1;
uint32 InfoFlag : 1;
uint32 Reserved : 20;
char DeviceID[100]; // 设备/区域/系统编码(必选)
char Name[128]; // 设备/区域/系统名称(必选)
char Manufacturer[64]; // 当为设备时,设备厂商(必选)
char Model[64]; // 当为设备时,设备型号(必选)
char Owner[64]; // 当为设备时,设备归属(必选)
char CivilCode[64]; // 行政区域(必选)
char Block[64]; // 警区(可选)
char Address[100]; // 当为设备时,安装地址(必选)
int Parental; // 当为设备时,是否有子设备(必选) 1有, 0没有
char ParentID[100]; // 父设备/区域/系统ID(必选)
int SafetyWay; // 信令安全模式(可选)缺省为0;
// 0:不采用;
// 2: S/MIME签名方式;
// 3: S/MIME加密签名同时采用方式;
// 4:数字摘要方式
int RegisterWay; // 注册方式(必选)缺省为1;
// 1:符合IETFRFC3261标准的认证注册模式;
// 2:基于口令的双向认证注册模式;
// 3:基于数字证书的双向认证注册模式
char CertNum[32]; // 证书序列号(有证书的设备必选)
int Certifiable; // 证书有效标识(有证书的设备必选)缺省为0;证书有效标识:0:无效1: 有效
int ErrCode; // 无效原因码(有证书且证书无效的设备必选)
time_t EndTime; // 证书终止有效期(有证书的设备必选)
int Secrecy; // 保密属性(必选)缺省为0; 0:不涉密, 1:涉密
char IPAddress[32]; // 设备/区域/系统IP地址(可选)
int Port; // 设备/区域/系统端口(可选)
char Password[32]; // 设备口令(可选)
GB28181_STATUS Status; // 设备状态(必选)
double Longitude; // 经度(可选)
double Latitude; // 纬度(可选)
GB28181_DEVICE_EX Info; // 扩展信息
} GB28181_DEVICE;
typedef struct
{
uint32 PositionCapabilityFlag : 1;
uint32 LongitudeFlag : 1;
uint32 LatitudeFlag : 1;
uint32 Reserved : 29;
char Name[100]; // 设备名称(必选)
int Expiration; // 注册过期时间(必选)
int HeartBeatInterval; // 心跳间隔时间(必选)
int HeartBeatCount; // 心跳超时次数(必选)
int PositionCapability; // 定位功能支持情况。取值: 0 -不支持; 1 -支持GPS定位; 2 -支持北斗定位(可选, 默认取值为0)
double Longitude; // 经度(可选)
double Latitude; // 纬度(可选)
} GB28181_BASIC_PARAM;
typedef struct
{
uint32 DownloadSpeedFlag : 1;
uint32 ResolutionFlag : 1;
uint32 Reserved : 32;
char DownloadSpeed[20]; // 下载倍速范围(可选),各可选参数以“ /”分隔,如设备支持1, 2, 4倍速下载则应 写为“ 1/2/4”
char Resolution[64]; // 摄像机支持的分辨率(可选),可有多个分辨率值,各个取值间以“ /”分隔;
// 1———QCIF 2———CIF 3———4CIF 4———D1 5———720P 6———1080P/I
} GB28181_VIDEO_PARAM;
typedef struct
{
int AlarmType; // 报警类型。报警方式为2时,不携带AlarmType为默认的报警设备报警,携带AlarmType取值及对应报警类型如下:
// 1 -视频丢失报警; 2 -设备防拆报警; 3 -存储设备磁盘满报警; 4 -设备高温报警; 5 -设备低温报警。
// 报警方式为5时,取值如下: 1-人工视频报警; 2-运动目标检测报警; 3-遗留物检测报警; 4-物体移除检测报警;
// 5-绊线检测报警; 6-入侵检测报警; 7-逆行检测报警; 8-徘徊检测报警; 9-流量统计报警; 10-密度检测报警;
// 11-视频异常检测报警; 12-快速移动报警。
// 报警方式为6时,取值如下: 1-存储设备磁盘故障报警; 2-存储设备风扇故障报警
} GB28181_ALARM_EX;
typedef struct
{
uint32 AlarmDescriptionFlag: 1;
uint32 LongitudeFlag : 1;
uint32 LatitudeFlag : 1;
uint32 InfoFlag : 1;
uint32 Reserved : 28;
char DeviceID[64]; // 报警设备编码或报警中心编码( 10位)(必选)
int AlarmPriority; // 报警级别(必选), 1为一级警情, 2为二级警情, 3为三级警情, 4为四级警情
char AlarmMethod[8]; // 报警方式(必选), 取值1为电话报警, 2为设备报警, 3为短信报警, 4为GPS报警,
// 5为 视频报警, 6为设备故障报警, 7其他报警
time_t AlarmTime; // 报警时间(必选)
char AlarmDescription[100];// 报警内容描述(可选)
double Longitude; // 经度 (可选)
double Latitude; // 纬度 (可选)
GB28181_ALARM_EX Info; // 扩展Info项携带报警类型、报警类型参数字段
} GB28181_ALARM;
typedef struct
{
char PresetID[32]; // 预置位编码(必选)
char PresetName[64]; // 预置位名称(必选)
} GB28181_PRESET;
typedef struct
{
int Length; // 播放窗口长度像素值(必选)
int Width; // 播放窗口宽度像素值(必选)
int MidPointX; // 拉框中心的横轴坐标像素值(必选)
int MidPointY; // 拉框中心的纵轴坐标像素值(必选)
int LengthX; // 拉框长度像素值(必选)
int LengthY; // 拉框宽度像素值(必选)
} GB28181_DRAG_ZOOM;
typedef struct
{
uint32 ResetTimeFlag : 1;
uint32 PresetIndexFlag : 1;
uint32 Reserved : 30;
int Enabled; // 看守位使能1:开启, 0:关闭(必选)
int ResetTime; // 自动归位时间间隔,开启看守位时使用,单位:秒( s)(可选)
int PresetIndex; // 调用预置位编号,开启看守位时使用,取值范围0~255(可选)
} GB28181_HOME_POS;
typedef struct
{
char DeviceID[64]; // 媒体发送设备编码(必选)
char NotifyType[32]; // 通知事件类型(必选),取值“121"表示历史媒体文件发送结束
} GB28181_MEDIA_NOTIFY;
/***********************************************************************/
typedef struct
{
uint32 FilePathFlag : 1;
uint32 AddressFlag : 1;
uint32 SecrecyFlag : 1;
uint32 TypeFlag : 1;
uint32 RecorderIDFlag : 1;
uint32 IndistinctQueryFlag : 1;
uint32 Reserved : 26;
GB28181_REQ_HDR hdr;
time_t StartTime; // 录像起始时间(必选)
time_t EndTime; // 录像终止时间(必选)
char FilePath[256]; // 文件路径名 (可选)
char Address[100]; // 录像地址(可选 支持不完全查询)
int Secrecy; // 保密属性(可选)缺省为0; 0:不涉密, 1:涉密
char Type[16]; // 录像产生类型(可选) time或alarm或manual或all
char RecorderID[100]; // 录像触发者ID(可选)
int IndistinctQuery; // 录像模糊查询属性(可选)缺省为0;
// 0:不进行模糊查询,此时根据SIP消息中To头域 URI中的ID值确定查询录像位置,
// 若ID值为本域系统ID则进行中心历史记录检索,若为前端设备ID则进行前端设备历史记录检索;
// 1:进行模糊查询,此时设备所在域应同时进行中心检索和前端检索并将结果统一返回
} GB28181_RECORD_INFO_REQ;
typedef struct
{
int SumNum; // 查询结果总数(必选)
int Num; // 文件目录项列表, Num表示目录项个数
GB28181_RECORD_INFO * RecordList;
} GB28181_RECORD_INFO_RES;
typedef struct
{
GB28181_REQ_HDR hdr;
} GB28181_DEVICE_STATUS_REQ;
typedef struct
{
uint32 ReasonFlag : 1;
uint32 EncodeFlag : 1;
uint32 RecordFlag : 1;
uint32 DeviceTimeFlag : 1;
uint32 Reserved : 28;
GB28181_RESULT Result; // 查询结果标志(必选)
int Online; // 是否在线(必选)0-不在线1-在线
GB28181_RESULT Status; // 是否正常工作(必选)
char Reason[100]; // 不正常工作原因(可选)
GB28181_STATUS Encode; // 是否编码(可选)
GB28181_STATUS Record; // 是否录像(可选)
time_t DeviceTime; // 设备时间和日期(可选)
} GB28181_DEVICE_STATUS_RES;
typedef struct
{
GB28181_REQ_HDR hdr;
} GB28181_DEVICE_INFO_REQ;
typedef struct
{
uint32 ManufacturerFlag: 1;
uint32 ModelFlag : 1;
uint32 FirmwareFlag : 1;
uint32 ChannelFlag : 1;
uint32 Reserved : 28;
char DeviceName[128]; // 目标设备/区域/系统的名称(可选)
GB28181_RESULT Result; // 查询结果标志(必选)
char Manufacturer[64]; // 设备生产商(可选)
char Model[64]; // 设备型号(可选)
char Firmware[64]; // 设备固件版本(可选)
int Channel; // 视频输入通道数(可选)
} GB28181_DEVICE_INFO_RES;
typedef struct
{
uint32 StartTimeFlag : 1;
uint32 EndTimeFlag : 1;
uint32 Reserved : 30;
GB28181_REQ_HDR hdr;
time_t StartTime; // 增加设备的起始时间(可选)空表示不限
time_t EndTime; // 增加设备的终止时间(可选)空表示到当前时间
} GB28181_CATALOG_REQ;
typedef struct
{
int SumNum; // 查询结果总数(必选)
int Num; // 文件目录项列表, Num表示目录项个数
GB28181_DEVICE * DeviceList;// 设备目录项列表
} GB28181_CATALOG, GB28181_CATALOG_RES;
typedef struct
{
GB28181_REQ_HDR hdr;
char ConfigType[100]; // 查询配置参数类型(必选),可查询的配置类型包括
// 基本参数配置: BasicParam,
// 视频参数范围: VideoParamOpt,
// SVAC编码配置: SVACEncodeConfig,
// SVAC解码配置: SVACDecodeConfig。
// 可同时查询多个配置类型,各类型以“/”分隔,可返回与查询SN值相同的多个响应,每个响应对应一个配置类型
} GB28181_CONFIG_REQ;
typedef struct
{
uint32 BasicParamFlag : 1;
uint32 VideoParamOptFlag : 1;
uint32 Reserved : 30;
GB28181_RESULT Result;
GB28181_BASIC_PARAM BasicParam;
GB28181_VIDEO_PARAM VideoParamOpt;
} GB28181_CONFIG_RES;
typedef struct
{
uint32 StartAlarmPriorityFlag : 1;
uint32 EndAlarmPriorityFlag : 1;
uint32 AlarmMethodFlag : 1;
uint32 AlarmTypeFlag : 1;
uint32 StartAlarmTimeFlag : 1;
uint32 EndAlarmTimeFlag : 1;
uint32 Reserved : 26;
GB28181_REQ_HDR hdr;
int StartAlarmPriority; // 报警起始级别(可选), 0为全部, 1为一级警情, 2为二级警情, 3为三级警情, 4为四级警情
int EndAlarmPriority; // 报警终止级别(可选), 0为全部, 1为一级警情, 2为二级警情, 3为三级警情, 4为四级警情
char AlarmMethod[8]; // 报警方式条件(可选), 取值0为全部, 1为电话报警, 2为设备报警, 3为短信报警, 4为GPS报警,
// 5为视频报警, 6为设备故障报警, 7其他报警;可以为直接组合如12为电话报警或设备报警
char AlarmType[32]; // 报警类型
time_t StartAlarmTime; // 报警发生起止时间(可选)
time_t EndAlarmTime; // 报警发生起止时间(可选)
} GB28181_ALARM_REQ;
typedef struct
{
GB28181_REQ_HDR hdr;
} GB28181_PRESET_REQ;
typedef struct
{
int Num; // 列表项个数,当未配置预置位时取值为0(必选)
GB28181_PRESET * PresetList;// 预置位列表
} GB28181_PRESET_RES;
typedef struct
{
uint32 IntervalFlag : 1;
uint32 Reserved : 31;
GB28181_REQ_HDR hdr;
int Interval; // 移动设备位置信息上报时间间隔单位秒默认5(可选)
} GB28181_MOBILE_POSITION_REQ;
typedef struct
{
uint32 PTZCmdFlag : 1;
uint32 TeleBootFlag : 1;
uint32 RecordCmdFlag : 1;
uint32 GuardCmdFlag : 1;
uint32 AlarmCmdFlag : 1;
uint32 IFameCmdFlag : 1;
uint32 DragZoomInFlag : 1;
uint32 DragZoomOutFlag : 1;
uint32 HomePositionFlag: 1;
uint32 Reserved : 23;
GB28181_REQ_HDR hdr;
char PTZCmd[32]; // 球机/云台控制命令(可选)
char TeleBoot[16]; // 远程启动控制命令(可选)
char RecordCmd[16]; // 录像控制命令(可选)
char GuardCmd[16]; // 报警布防/撤防命令(可选)
char AlarmCmd[16]; // 报警复位命令(可选)
char IFameCmd[16]; // 强制关键帧命令,设备收到此命令应立刻发送一个IDR帧(可选)
GB28181_DRAG_ZOOM DragZoomIn; // 拉框放大控制命令(可选)
GB28181_DRAG_ZOOM DragZoomOut; // 拉框缩小控制命令(可选)
GB28181_HOME_POS HomePosition; // 看守位控制命令(可选)
} GB28181_DEVICE_CONTROL_REQ;
typedef struct
{
GB28181_RESULT Result; // 执行结果标志(必选)
} GB28181_DEVICE_CONTROL_RES;
typedef struct
{
uint32 BasicParamFlag : 1;
uint32 Reserved : 31;
GB28181_REQ_HDR hdr;
struct
{
uint32 NameFlag : 1;
uint32 ExpirationFlag : 1;
uint32 HeartBeatIntervalFlag : 1;
uint32 HeartBeatCountFlag : 1;
uint32 Reserved : 28;
char Name[100]; // 设备名称(可选)
int Expiration; // 注册过期时间(可选)
int HeartBeatInterval; // 心跳间隔时间(可选)
int HeartBeatCount; // 心跳超时次数(可选)
} BasicParam;
} GB28181_DEVICE_CONFIG_REQ;
typedef struct
{
GB28181_RESULT Result; // 执行结果标志(必选)
} GB28181_DEVICE_CONFIG_RES;
typedef struct
{
GB28181_REQ_HDR hdr;
char SourceID[64]; // 语音输入设备的设备编码(必选)
char TargetID[64]; // 语音输出设备的设备编码(必选)
} GB28181_BROADCAST_NOTIFY_REQ;
typedef struct
{
char DeviceID[64]; // 语音输出设备的设备编码(必选)
int Result; // 执行结果标志(必选)
} GB28181_BROADCAST_NOTIFY_RES;
typedef struct
{
uint32 SpeedFlag : 1;
uint32 DirectionFlag : 1;
uint32 AltitudeFlag : 1;
uint32 Reserved : 29;
char TargetID[64]; //
time_t Time; // 产生通知时间(必选)
double Longitude; // 经度(必选)
double Latitude; // 纬度(必选)
double Speed; // 速度,单位:km/小时(可选)
double Direction; // 方向取值为当前摄像头方向与正北方的顺时针夹角取值范围0-360单位度(可选)
int Altitude; // 海拔高度,单位米(可选)
} GB28181_MOBILE_POSITION;
#ifdef __cplusplus
extern "C" {
#endif
BOOL gb28181_msg_rx(HSIP_MSG * rx_msg);
XMLN * gb28181_msg_parse(HSIP_MSG * rx_msg);
void gb28181_alarm_tx(GB28181_ALARM * p_req);
void gb28181_heartbeat_tx(HSIP_USER * p_user);
void gb28181_media_status_tx(HSIP_USER * p_user, GB28181_MEDIA_NOTIFY * p_req);
BOOL gb28181_req_hdr_parse(XMLN * p_root, GB28181_REQ_HDR * p_req);
BOOL gb28181_catalog_req_parse(XMLN * p_root, GB28181_CATALOG_REQ * p_req);
BOOL gb28181_alarm_req_parse(XMLN * p_root, GB28181_ALARM_REQ * p_req);
BOOL gb28181_mobile_position_req_parse(XMLN * p_root, GB28181_MOBILE_POSITION_REQ * p_req);
int gb28181_catalog_notify_xml_build(char * p_xml, int tlen, GB28181_CATALOG * p_req);
int gb28181_alarm_notify_xml_build(char * p_xml, int tlen, GB28181_ALARM * p_req);
int gb28181_media_notify_xml_build(char * p_xml, int tlen, GB28181_MEDIA_NOTIFY * p_req);
int gb28181_mobile_position_notify_xml_build(char * p_xml, int tlen, GB28181_MOBILE_POSITION * p_req);
#ifdef __cplusplus
}
#endif
#endif