项目简介
- GB28181协议设备端SDK,作为下级,支持GB/T28181-2011和GB/T28181-2016版本。支持linux X86平台、海思ARM系列平台等。兼容目前市面绝大部分主流厂商上级平台(如海康、大华、宇视、东方网力等),目前提供linux x86 64位下的库文件及demo(若有兴趣,欢迎通过以下联系方式跟我联系提供其它linux或arm平台下的库及demo)。
- 编译环境:gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.4)
- SDK下载地址:https://gitee.com/liuchen1206/GB28181DeviceSDK
- 欢迎试用交流反馈您的宝贵意见。
联系方式(E-mail:liuchen1206#163.com)。
功能清单
- 库提供C语言风格接口,支持C/C++二次开发
- 设备注册功能
- 心跳保活功能,掉线后自动重注册上线
- 设备目录查询功能
- 实时视频功能,支持UDP和TCP两种方式取流,支持H264、H265、G711A
- 设备云台控制功能
- 历史录像检索功能
- 录像回放功能,支持UDP和TCP两种方式,支持倍速回放、暂停、拖放等
- 录像下载功能
- 手动录像开启/停止
- 报警布防\撤防功能
- 设备信息、设备状态、设备配置等查询功能
- 设备网络校时功能
- 设备远程重启功能
SDK接口
#ifndef __GBSERVERSDK_H__
#define __GBSERVERSDK_H__
#include "GBCommon.h"
#ifdef WIN32
#define strcasecmp stricmp
#define strncasecmp strnicmp
#ifdef GB_SDK_EXPORTS
#define _GB_SDK_EXPORTS __declspec(dllexport)
#else
#define _GB_SDK_EXPORTS __declspec(dllimport)
#endif
#else
#define _GB_SDK_EXPORTS __attribute__ ((visibility("default")))
#endif
_GB_SDK_EXPORTS GB_ERROR GB_SDK_Init(
const GB_SIP_SERVER* pSipServerInfo,
const GB_CHANNEL_ITEM* pGb28181ChannelID,
int nChannelNum,
const GB_CHANNEL_ITEM* pGb28181AlarmID,
int nAlarmNum,
GB_NOTIFY_CB pfnNotifyCB,
void* pUser);
_GB_SDK_EXPORTS GB_ERROR GB_SDK_Start();
_GB_SDK_EXPORTS GB_ERROR GB_SDK_Stop();
_GB_SDK_EXPORTS GB_ERROR GB_SDK_Quit();
_GB_SDK_EXPORTS GB_STATUS GB_SDK_GetStatus();
_GB_SDK_EXPORTS GB_ERROR GB_SDK_InputData(unsigned long lTaskID, const GBFrameInfo* pFrameHead, const char* pData, bool bPlayback);
_GB_SDK_EXPORTS GB_ERROR GB_SDK_InputTalkbackData(unsigned long lTaskID, const GBFrameInfo* pFrameHead, const char* pData);
_GB_SDK_EXPORTS GB_ERROR GB_SDK_UpdateAlarmStatus(int nAlarmID, unsigned short uAlarmType, unsigned short uAlarmStatus);
_GB_SDK_EXPORTS GB_ERROR GB_SDK_SetGpsInterval(bool bEnable, unsigned int uTime);
_GB_SDK_EXPORTS GB_ERROR GB_SDK_SetGpsInfo(const GPS_INFO *pGPSInfo);
_GB_SDK_EXPORTS GB_ERROR GB_SDK_ReportGpsImmediate();
#endif
#ifndef __GB28181_COMMON_DEFINE__H__
#define __GB28181_COMMON_DEFINE__H__
#include
#pragma pack( 4)
#define GB_SHORT_LEN 32
#define GB_LONG_LEN 64
const unsigned int GB_MAX_CAMERA_NUM = 64;
#define INVALID_INDEX(type) (static_cast(~(type)0x0))
enum GB_ERROR
{
GB_ERR_SUCCESS,
GB_ERR_FAILD,
GB_ERR_PERMISSION_DENIED,
GB_ERR_UNAUTHORIZED,
GB_ERR_INVALID_PARAMETER,
GB_ERR_SYSTEM_BUSY,
GB_ERR_PENDING,
GB_ERR_NETWORK_ERROR,
GB_ERR_NOT_EXIST,
GB_ERR_BUFFER_FULL,
GB_ERR_IGNORE,
GB_ERR_NOT_SUPPORTED,
GB_ERR_UNKNOWN_ERROR,
};
typedef struct _gb_device_init_info
{
int nLocalVideoInputNum;
int nNetVideoInputNum;
int nAudioInputNum;
int nSensorInputNum;
int nMaxALarm;
int nMaxAudio;
int nDeviceType;
int nProductType;
int nDevVer;
unsigned int nSoftVer;
unsigned int nBuildTime;
char szDeviceName [20];
}GB_DEV_INIT_INFO;
typedef enum _gb_status
{
STATUS_UNREGISTER = 0,
STATUS_REGISTER = 1,
}GB_STATUS;
typedef struct _gb_sip_server
{
char server_ip[32];
unsigned short server_port;
unsigned int expires;
char server_id[GB_SHORT_LEN];
char user[GB_SHORT_LEN];
char passwd[GB_SHORT_LEN];
char dvr_id[GB_SHORT_LEN];
unsigned short dvr_port;
unsigned int keepaliveInterval;
char devowner[GB_LONG_LEN];
char civilcode[GB_LONG_LEN];
char installaddr[GB_LONG_LEN];
unsigned int defaultStreamType;
}GB_SIP_SERVER;
typedef struct _gb_channel_item
{
int nChannelID;
char gb28181ID[GB_SHORT_LEN];
}GB_CHANNEL_ITEM;
typedef struct _gb_frame_info
{
int nChannelID;
unsigned short streamType;
unsigned char byFrameType;
unsigned char keyFrame;
unsigned int frameIndex;
unsigned int width;
unsigned int height;
unsigned int length;
long long time;
}GBFrameInfo;
#define GBFRAME_LEN sizeof(GBFrameInfo)
typedef enum _frame_type
{
FRAME_TYPE_NONE = 0x00,
FRAME_TYPE_VIDEO = 0x01,
FRAME_TYPE_AUDIO = 0x02,
FRAME_TYPE_TALK_AUDIO = 0x03,
FRAME_TYPE_END = 0x04,
}FRAME_TYPE;
typedef struct _frame_info_ex
{
unsigned long keyFrame;
unsigned long frameType;
unsigned long length;
unsigned long width;
unsigned long height;
unsigned char *pData;
unsigned long channel;
unsigned long frameIndex;
unsigned long streamID;
long long time;
}FRAME_INFO_EX;
typedef struct _ptz_ctrl
{
unsigned long chnn;
unsigned long speed;
unsigned long cmdType;
unsigned long cmdValue;
}PTZ_CTRL;
enum STREAM_TYPE
{
STREAM_NULL = -1,
STREAM_VIDEO = 0,
STREAM_AUDIO,
STREAM_PLAYBACK,
STREAM_TALKBACK,
STREAM_END,
};
typedef enum _replay_method
{
METHOD_PLAY = 0,
METHOD_PAUSE = 1,
METHOD_SEEK = 2,
}REPLAY_METHOD;
typedef struct _gps_info
{
float fLongitude;
float fLatitude;
float fSpeed;
float fDirection;
int nAltiude;
}GPS_INFO;
#define NOTIFY_Play "Play"
#define NOTIFY_Stop "Stop"
#define NOTIFY_Playback "Playback"
#define NOTIFY_PlaybackStop "PlaybackStop"
#define NOTIFY_ManualRecStart "ManualRecStart"
#define NOTIFY_ManualRecStop "ManualRecStop"
#define NOTIFY_SetGuard "SetGuard"
#define NOTIFY_ResetGuard "ResetGuard"
#define NOTIFY_PtzCtl "PtzCtl"
#define NOTIFY_RecordQuery "RecordQuery"
#define NOTIFY_Event "Event"
typedef enum _event_sub_type
{
EVENT_TYPE_UNKNOWN = 0,
EVENT_STREAM_END = 1,
EVENT_STREAM_SEEK = 2,
}EVENT_SUB_TYPE;
typedef GB_ERROR (*GB_NOTIFY_CB) (const char* pNotifyType,const char* pNotifyXml, char* pRespXml, int nRespSize, void* pUser);
#pragma pack()
#endif