菜单 学习猿地 - LMONKEY

VIP

开通学习猿地VIP

尊享10项VIP特权 持续新增

知识通关挑战

打卡带练!告别无效练习

接私单赚外块

VIP优先接,累计金额超百万

学习猿地私房课免费学

大厂实战课仅对VIP开放

你的一对一导师

每月可免费咨询大牛30次

领取更多软件工程师实用特权

入驻
149
0

实现国标GB28181视频流媒体服务直播点播服务平台EasyGBS通过http请求获取HLS、RTMP和RTSP地址

原创
05/13 14:22
阅读数 29528

近年来,国内视频监控应用发展迅猛,系统接入规模不断扩大,涌现了大量平台提供商,平台提供商的接入协议各不相同,终端制造商需要给每款终端维护提供各种不同平台的软件版本,造成了极大的资源浪费。各地视频大规模建设后,省级、国家级集中调阅,对重特大事件通过视频掌握现场并进行指挥调度的需求逐步涌现,然而不同平台间缺乏统一的互通协议。

在这样的产业背景下,基于终端标准化、平台互联互通的需求,GB/T28181应运而生。GB28181协议不仅包括设备间的级联,也包含系统的级联,在安防领域中越来越通用,已经成为统一各家安防设备和平台的统一标准。EasyGBS视频流媒体直播点播服务平台应运而生。

今天主要为大家介绍下GB/T28181流媒体平台的相关协议,具体如下:

一、通信接口:

视频服务器作为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://121.40.50.44:10000/
    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://121.40.50.44:10000/
    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://121.40.50.44:10000/
    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://121.40.50.44:10000/
    HTTP Method:    GET
        
返回:
    其中errcode为必填项,errcode小于0表示错误,无数据; 如果errcode等于0,那么数据里面的每项都是必填项

        [
            {"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://121.40.50.44:10000/
    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://121.40.50.44:10000/
    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://121.40.50.44:10000/
    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://121.40.50.44:10000/
    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;

发表评论

0/200
149 点赞
0 评论
收藏