视频监控安防平台-国标28181(GB28181)平台通过http请求获取HLS、RTMP和RTSP地址(HTTP服务转GB28181)

版权声明:本文为博主原创文章,未经博主允许不得转载。QQ/微信联系:123011785 https://blog.csdn.net/songxiao1988918/article/details/84712841

        视频监控安防平台-国标28181(GB28181)平台通过http请求获取HLS、RTMP和RTSP地址(HTTP服务转GB28181)

  最近抽时间完善了HTTP服务接入GB28181的小平台,支持HLS、RTMP、RTSP码流输出,其中HLS和RTMP只支持实时视频的输出,如果需要demo联系QQ/微信:123011785

下面我把协议列举下:

一、通信接口:
    视频服务器作为httpserver。        
    
1.    请求视频
    字段说明:
    "channelid":  (字符串)   通道20位编号
    "type":       (数字)        国标请求视频类型:1:udp 2:tcp主动 3:tcp被动
    "videourltype":  (字符串)   视频类型:rtsp:返回rtsp地址  rtmp:返回rtmp地址 hls:返回hls地址

    "errcode":    (数字)   返回值,0表示成功,其他见错误码
    "sessionid":  (字符串) 会话返回的sessionid
    "rtspurl":    (字符串) rtsp地址
请求:
    URL:    http://122.114.130.9:8088/vss/open_stream/{channelid}/{type}/{videourltype}
        
    HTTP Method:    GET
        
返回:
    其中errcode为必填项,errcode小于0表示错误,无数据
    {
        "errcode":0,
        "errdesc":"OK",
        "strsessionid":"44030000001320000001",
        "rtspurl":"http://47.92.224.143:8080/video/44030000001320000001.m3u8"
    }

2.    停止视频-通过sessionid停止视频 (包含实时视频、历史视频点播、历史视频下载)
    字段说明:
    "sessionid":  (字符串) 会话返回的sessionid
    
    "errcode":    (数字)   返回状态值,0表示正常状态,其他见错误码
请求:
    URL:    http://122.114.130.9:8088/vss/close_stream/{sessionid}
        
    HTTP Method:    GET
        
返回:
    其中errcode为必填项,errcode小于0表示错误
    {
        "errcode":0,
        "errdesc":"OK"
    }
        
3.    Ptz请求
    字段说明:
    "channelid":  (字符串)   通道20位编号
    "ptztype":   (字符串) 控制类型:上"up",下"down",左"left",右"right",左上"leftup",左下"leftdown",右上"rightup",右下"rightdown",镜头近"zoomin",镜头远"zoomout", 
                            焦距远"focusfar",焦距近"focusnear", 设置预置位"setpos",调预置位"callpos"
    "ptzparam":   (数字)   参数,速度范围为0-255,0为停止
    
请求:
    URL:    http://122.114.130.9:8088/vss/ptz/{ptztype}/{ptzparam}/{channelid}
        
    HTTP Method:    GET
        
返回: 
    其中errcode为必填项,errcode小于0表示错误
    {"errcode":0,"errdesc":"OK"}


4.    录像查询
    字段说明:
    
    "channelid":   (字符串)   通道20位编号
    "begintime":   (字符串) "YYYY-MM-DDTHH:MM:SS":  年月日时分秒; 开始时间,注意不全0
    "endtime":     (字符串) "YYYY-MM-DDTHH:MM:SS":  年月日时分秒; 结束时间,注意不全0
    
    "data":        录像查询信息
    "begintime":   (字符串) "YYYY-MM-DDTHH:MM:SS":  年月日时分秒; 开始时间,注意不全0
    "endtime":     (字符串) "YYYY-MM-DDTHH:MM:SS":  年月日时分秒; 结束时间,注意不全0
    "filename":    (字符串) 文件名,不一定用,如果根据文件回放才用,根据时间回放不用
    "type":      (字符串)录像类型 all,time,alarm,manual

请求:
    URL:    http://122.114.130.9:8088/vss/history_search/{begintime}/{endtime}/{channelid}
        
    HTTP Method:    GET
        
返回: 
    其中errcode为必填项,errcode小于0表示错误,无数据; 如果errcode等于0,那么数据里面的每项都是必填项
    {"errcode":0,"errdesc":"OK","totalsize":3,"onepagesize":3,"totalpage":1,"pageno":1,"count":3,"data":
        [
            {"channelid":11000000001320000001,"begintime":"2017-09-19T15:13:24","endtime":"2017-09-19T15:38:34","filename":"101101001_0","type":"all"},
            {"channelid":11000000001320000001,"begintime":"2017-09-19T15:56:52","endtime":"2017-09-19T16:03:10","filename":"101101001_2","type":"all"},
            {"channelid":11000000001320000001,"begintime":"2017-09-19T16:06:42","endtime":"2017-09-19T17:28:55","filename":"101101001_4","type":"all"}
        ]
    }
    
5.    录像点播/下载
    字段说明:
    "channelid":  (字符串)   通道20位编号
    "opttype":    (字符串) "vod"点播, "download"下载
    "begintime":  (字符串) "YYYY-MM-DDTHH:MM:SS":  年月日 时分秒; 开始时间
    "endtime":    (字符串) "YYYY-MM-DDTHH:MM:SS":  年月日 时分秒; 结束时间
    "type":       (数字)   国标请求视频类型:1:udp 2:tcp主动 3:tcp被动

    返回参数:
    "errcode":    (数字)   返回状态值,0表示正常状态,其他见错误码
    "rtspurl":    (字符串) 点播/下载rtsp地址
    "sessionid":  (字符串) 点播/下载句柄,用于点播控制,关闭(为请求时传入的sessionid)
    "filesize":   (64位数字)   点播/下载的总大小
    
请求:
    URL:    http://122.114.130.9:8088/vss/open_his_stream/{opttype}/{begintime}/{endtime}/{channelid}/{type}
        
    HTTP Method:    GET
        
返回:
    其中errcode为必填项,errcode小于0表示错误,无数据; 如果errcode等于0,那么数据里面的每项都是必填项
    {
        "errccode":0,
        "rtspurl":"rtsp://192.168.12.93:9554/Type=2/DevAor=101101001-2017030031-111",
        "sessionid":"101101001-2017030031-111"
        "filesize":110503259
    }
        
    
6.    点播控制
    字段说明:
    "sessionid":    (字符串) 点播返回的sessionid句柄
    "vodctrltype":  (字符串) "play","pause","stop","jump"
    "vodctrlparam": (字符串)  0(pause,stop) / 0.125,0.25,0.5,1,2,4,8,16(play) (范围:0-32)/ 从开始时间跳转的秒数(jump)
    
请求:
    URL:    http://122.114.130.9:8088/vss/his_stream_ctrl/{sessionid}/{vodctrltype}/{vodctrlparam}
        
    HTTP Method:    GET
        
返回:
    其中errcode为必填项,errcode小于0表示错误
    {"errccode":0,"errdesc":"OK"}

7.     设备控制
    字段说明:
    "channelid":  (字符串)   通道或者设备20位编号
    "devctrltype": (字符串)  "record":录像开启和停止-通道id "guard":布放和撤防-报警通道id "reboot":设备重启-设备id "keyfame":强制关键帧-通道id
    "param":  (字符串) "start"启动,"stop"停止 
    
请求:
    URL:    http://47.92.224.143:8060/vss/device_ctrl/{devctrltype}/{channelid}/{param}
        
    HTTP Method:    GET
        
返回:
    其中errcode为必填项,errcode小于0表示错误
    {"errccode":0,"errdesc":"OK"}
    
    
二、报警通知  
    视频服务器作为httpclient

    方法说明: 
    

    字段说明:
    "channelid":  (字符串)   通道20位编号
    "alarmtype": (数字) 报警类型(后续根据需求定义)
    "alarmtime":  (字符串) "YYYY-MM-DDTHH:MM:SS":  年月日 时分秒; 报警时间
    "alarmdesc":  (字符串) 报警描述
    "longitude":  (字符串) 经度
    "latitude":      (字符串) 纬度
    
请求:
    URL:    http://122.114.130.9:8088/vssalarm

        
    HTTP Method:    POST
        
    Body: 
    所有字段都为必填项
    {"channelid":"11000000001320000001","alarmtype":1,"alarmtime":"2017-09-19T15:13:24","alarmdesc":"fire","longitude":"10.01123","latitude":"20.34221"}    

    
其中MYSQL数据库表结构为:

/* 创建一级设备表 */
create table IF NOT EXISTS VSSDevTbl

ID              int primary key auto_increment comment '自增ID;',  
DevPubID        varchar(32) not null unique comment '一级设备账号;', 
DevNickname     char(128) comment '昵称;',  
UserName         char(64) comment '用户名;', 
Passwd             char(64) comment '密码;', 
CorpID          char(32) comment '设备厂商;',    
IP              char(16) comment 'IP地址 ;', 
Port            smallint unsigned comment '端口;',     
Alive           boolean default 0 comment '注册状态;0-下线;1-上线',
DMarker         int default 1 comment '0-未变化;1-增加;2-删除;3-修改;4-已同步,可删除;',
UpdateTime   TIMESTAMP ON UPDATE CURRENT_TIMESTAMP DEFAULT CURRENT_TIMESTAMP comment '更新时间;' 
);
alter table VSSDevTbl comment '创建一级设备表';
/*alter table VSSDevTbl add index idx_DevID(DevPubID);*/

/* 创建二级设备表 */
create table IF NOT EXISTS VSSChannelTbl

ID             int primary key auto_increment comment '自增ID;',  
DevPubID       varchar(32) not null comment '一级设备账号;', 
Nickname       char(128) comment '昵称;',  
ChanPubID      varchar(32) not null unique comment '二级设备账号;', 
Alive          boolean default 0 comment '注册状态;0-下线;1-上线',
CorpID         char(32) comment '设备厂商;',    
Model           char(32) comment '设备型号;',
Owner           char(32) comment '设备归属;',
CivilCode       char(32) comment '行政区域;',
Address           char(128) comment '安装地址;',
Parental       int default 0 comment  '0-没有设备;1-有子设备',
ParentId       char(64) comment '父设备;',
IP             char(16) comment 'IP地址 ;', 
Port           smallint unsigned comment '端口;', 
Longitude       double default 0 comment  '经度',
Latitude       double default 0 comment  '纬度',
Altitude       double default 0 comment  '海拔',
PTZType           int default 0 comment  '1-球机;2-半球;3-固定枪机;4-遥控枪机;',    
RoomType       int default 0 comment  '1-室外;2-室内',
DirectionType  int default 0 comment  '1-东;2-西;3-南;4-北;5-东南;6-东北;7-西南;8-西北;',
StreamType     int default 0 comment  '0-H264;1-MPEG2;2-MPEG4;3-SVAC;4-3GP;5-H265;',
DMarker        int default 1 comment '0-未变化;1-增加;2-删除;3-修改;4-已同步,可删除;',
UpdateTime   TIMESTAMP ON UPDATE CURRENT_TIMESTAMP DEFAULT CURRENT_TIMESTAMP comment '更新时间;' 
);
alter table VSSChannelTbl comment '创建二级设备表';
alter table VSSChannelTbl add constraint FK_VSSChannelTbl foreign key (DevPubID) references VSSDevTbl (DevPubID) on delete cascade;

create table IF NOT EXISTS SVRTbl  

ID                  int primary key auto_increment comment '自增ID;',  
GBServerID          varchar(20) not null comment '国标服务器ID;',
IP                    varchar(16) comment 'IP;', 
GBServerPort        smallint unsigned comment '国标服务器端口;',  
RtspServerPort      smallint unsigned comment 'rtsp服务器端口;', 
HttpserverPort      smallint unsigned comment 'http服务器端口;', 
HttpclientSvrIp     varchar(16) comment 'http客户端连接服务IP;', 
HttpclientSvrPort   smallint unsigned comment 'http客户端连接服务端口;', 
Active              int default 0 comment '运行状态 1开启 0关闭;',
MaxCameraNum           int default 0 comment '服务器最大摄像头数量;',
CurrentCameraNum    int default 0 comment '服务器当前摄像头数量;',
ServerAlarmNum      int default 0 comment '服务器触发警报警戒值;',                
UpdateTime   TIMESTAMP ON UPDATE CURRENT_TIMESTAMP DEFAULT CURRENT_TIMESTAMP comment '更新时间:',
Remark                    varchar(255) comment'备用字段;' 
);
alter table SVRTbl comment '创建服务器配置表';

/* 创建区域组织结构表 */
create table IF NOT EXISTS VSSDomainUnitTbl

ID              int primary key auto_increment comment '自增ID;',  
DevPubID        varchar(32) not null comment '一级设备账号;', 
DomainPubID     char(32) not null unique comment '域名ID;', 
Name             char(128) comment '名称;',  
BusinessGroupID char(32) comment '业务分组ID;',
ParentId        char(64) comment '父节点ID;',
UpdateTime   TIMESTAMP ON UPDATE CURRENT_TIMESTAMP DEFAULT CURRENT_TIMESTAMP comment '更新时间;' 
);
alter table VSSDomainUnitTbl comment '创建一级设备表';
alter table VSSDomainUnitTbl add constraint FK_VSSDomainUnitTbl foreign key (DevPubID) references VSSDevTbl (DevPubID) on delete cascade;

使用信息和相关信息查看上传的demo!

猜你喜欢

转载自blog.csdn.net/songxiao1988918/article/details/84712841