Skip to content

Commit

Permalink
Merge pull request #58 from OneHeng/gb28181.md
Browse files Browse the repository at this point in the history
update gb28181.md
  • Loading branch information
ZSC714725 authored Mar 11, 2024
2 parents 117ba69 + eca0475 commit 932e026
Show file tree
Hide file tree
Showing 3 changed files with 209 additions and 9 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ http(s)://127.0.0.1:1290/live/m4s/test110.mp4
http(s)://127.0.0.1:1290/live/hls/test110/index.m3u8

## [GB28181](./document/gb28181.md)
(1) 作为SIP服务器与设备进行SIP交互,打开lalserver的端口接收码流
(1) 作为SIP服务器与设备进行SIP交互,使用单端口收流

(2) 流ID为设备通道编码ID
(2) 提供相关API获取设备信息、播放某通道等功能

(3) 支持H264/H265/AAC

Expand Down
202 changes: 201 additions & 1 deletion document/gb28181.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,206 @@
# GB28181

lalmax的gb28181功能为lalmax扮演lal缺失的SIP服务器角色,lalmax负责SIP交互,调用lal的start_rtp_pub通知lal启动rtp收流,通过SDP告知设备lal的IP和端口,设备与lalmax交互完成后便可推流到lal指定的端口上
lalmax的gb28181功能为单端口监听(TCP/UDP监听端口可以使用tcp_listen_port和udp_listen_port进行配置),根据INVITE消息中的ssrc来区分具体流名,详细的配置见gb28181_config

# GB28181相关HTTP API

目前主要提供的API如下

[/api/gb/device_infos](#apigbdevice_infos)

[/api/gb/update_all_notify](#apigbupdate_all_notify)

[/api/gb/update_notify](#apigbupdate_notify)

[/api/gb/start_play](#apigbstart_play)

[/api/gb/stop_play](#apigbstop_play)


返回信息格式如下
```
{
"code": <int64>, // 状态码
"msg": <string>, // 状态码对应的解释
"data": <any> // 具体返回信息
}
其中code和msg的对应关系如下
1000: success
1001: 请求参数错误
1002: 服务繁忙
1003: 设备暂时未注册
1004: 设备停止播放错误
```

## /api/gb/device_infos
API含义: 获取注册的设备信息

Method: GET

data信息:
```
"data": {
"device_items": [
{
"device_id": <string>, // 设备ID
"channels": [ // 通道信息
{
"channel_id": <string>, // 通道ID
"name": <string>, // 设备名称
"manufacturer": <string>, // 制造厂商
"owner: <string>, // 设备归属
"civilCode": <string>, // 行政区划编码
"address": <string>, // 地址
"status": <string>, // 设备状态,ON/OFF
"longitude": <string>, // 经度
"latitude": <string> // 纬度
}
]
}
]
}
```

示例
```
curl http://127.0.0.1:1290/api/gb/device_infos -X GET
{
"code":1000,
"msg":"success",
"data":{
"device_items":[
{
"device_id":"34020000001320000001",
"channels":[
{
"channel_id":"34020000001320000001",
"name":"Camera 01",
"manufacturer":"Hikvision",
"owner":"Owner",
"civilCode":"3402000000",
"address":"Address",
"status":"ON",
"longitude":"",
"latitude":""
}
]
}
]
}
}
```


## /api/gb/update_all_notify
API含义: 更新全部信息

Method: POST

请求body信息: 无

data信息: 无

示例:
```
curl http://127.0.0.1:1290/api/gb/update_all_notify -X POST
{
"code":1000,
"msg":"success"
}
```

## /api/gb/update_notify
API含义: 更新某个设备信息

Method: POST

请求body信息
```
{
"device_id": <string> // 设备ID
}
```

data信息: 无

示例:
```
curl "http://127.0.0.1:1290/api/gb/update_all_notify" -X POST -d '{"device_id": "34020000001320000001"}'
{
"code":1000,
"msg":"success"
}
```

## /api/gb/start_play
API含义: 播放某通道

Method: POST

请求body信息:
```
{
"device_id": <string>, // 设备ID
"channel_id": <string>, // 通道ID
"network": <string>, // 传输协议类型, tcp/udp
"stream_name": <string> // ssrc对应的流名,不指定的话就使用channel_id
}
```

data信息:
```
{
"stream_name": <string> // 流名
}
```

示例:
```
curl "http://127.0.0.1:1290/api/gb/start_play" -X POST -d '{"device_id": "34020000001320000001", "channel_id": "34020000001320000001", "network": "udp", "stream_name": "test001}'
{
"code":1000,
"msg":"success"
"data": {
"stream_name": "test001"
}
}
```

## /api/gb/stop_play

API含义: 停止播放某通道

Method: POST

请求body信息:
```
{
"device_id": <string>, // 设备ID
"channel_id": <string>, // 通道ID
"stream_name": <string> // ssrc对应的流名,不指定的话就使用channel_id
}
```

data信息: 无

示例:
```
curl "http://127.0.0.1:1290/api/gb/stop_play" -X POST -d '{"device_id": "34020000001320000001", "channel_id": "34020000001320000001", "stream_name": "test001}'
{
"code":1000,
"msg":"success"
"data": {
"stream_name": "test001"
}
}
```

# 海康设备接入

Expand Down
12 changes: 6 additions & 6 deletions gb28181/t_http_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ type DeviceInfos struct {
DeviceItems []*DeviceItem `json:"device_items"`
}
type DeviceItem struct {
DeviceId string `json:"device_id"` //父目录Id
DeviceId string `json:"device_id"` // 设备ID
Channels []*ChannelItem `json:"channels"`
}
type ChannelItem struct {
ChannelId string `json:"channel_id"` // channel id
Name string `json:"name"` //设备名称
Manufacturer string `json:"manufacturer"` //制造厂商
Owner string `json:"owner"` //设备归属
CivilCode string `json:"civilCode"` //行政区划编码
Address string `json:"address"` //地址
Name string `json:"name"` // 设备名称
Manufacturer string `json:"manufacturer"` // 制造厂商
Owner string `json:"owner"` // 设备归属
CivilCode string `json:"civilCode"` // 行政区划编码
Address string `json:"address"` // 地址
Status ChannelStatus `json:"status"` // 状态 on 在线 off离线
Longitude string `json:"longitude"` // 经度
Latitude string `json:"latitude"` // 纬度
Expand Down

0 comments on commit 932e026

Please sign in to comment.