1 Star 8 Fork 9

我不写名字 / GB28181-Service

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

GB28181-Service

CMake on Ubuntu MSBuild

依赖ZLMediaKit实现的一个简单的GB28181服务器。

因eXosip2使用epoll,Windows下SipService只支持UDP,Linux下支持TCP和UDP。SipClinet,用于模拟一个GB28181设备。

实现功能

  • 国标摄像头注册接入、目录查询、推流。

  • 云台控制、预置位调用,参考Http接口部分。

  • 实现部分zlm的webhook接口,以实现按需推流功能。客户端拉流时推送视频,无人观看时,自动关闭。

  • sqlite数据保存。

  • 设置设备和通道的Nickname,修改设备收流IP。

  • 录像文件查询和回放。

  • 单端口模式收流和多端口模式收流适配。单端口模式下,流地址是SSRC信息,所以这里对每个Channel初始化时就设置一个固定的SSRC(通过defaultStreamID获取ssrc对应的streamID)。多端口模式下,使用device_id和channel_id组合作为streamID。

    如设备ID: 34020000002000000001,通道ID: 34020000002000000012,系统初始化SSRC: 0200000000。单端口模式下,可以用rtsp://127.0.0.1:554/rtp/0BEBC200地址播放,其中0BEBC200则为SSRC的16进制标识。多端口模式下,则使用rtsp://127.0.0.1:554/rtp/34020000002000000001_34020000002000000012。当然也可用ZLMediaKit支持的其他各种协议格式。

    具体内容可以参考GB28181怎么用设备ID作为流ID · ZLMediaKit/ZLMediaKit Wiki (github.com)

按需推流大致流程

待实现

  • 语音对讲

  • ...

编译安装

参考 Install.md

依赖库:

WebHook接口

端口为配置文件中Http端口。

配置文件说明

<?xml version="1.0" encoding="utf-8" ?>
<Config>
	<SipServer>
		<!-- SIP监听端口 -->
		<Port>5060</Port>
		<Password>12345678</Password>
		<!-- SIP服务ID -->
		<ID>34020000002000000001</ID>
		<!-- 这个参数暂时没用 -->
		<IP>0.0.0.0</IP>
		<!-- 收流IP -->
		<ExternIP>192.168.116.125</ExternIP>
	</SipServer>
	<MediaServer>
		<!-- ZLM服务地址 -->
		<IP>127.0.0.1</IP>
		<!-- ZLM服务Http端口 -->
		<Port>10070</Port>
		<!-- ZLM RTP接收端口 -->
		<RtpPort>10000</RtpPort>
		<!-- ZLM是否使用单端口模式 -->
		<SinglePortMode>true</SinglePortMode>
		<Secret>035c73f7-bb6b-4889-a715-d9eb2d1925cc</Secret>
	</MediaServer>
	<Http>
		<!-- Http服务端口 -->
		<Port>8000</Port>
	</Http>
</Config>

接口列表

1、/v1/device/list

{
    "code": 0,
    "data": [
        {
            "channel_count": 1,
            "id": "34020000001320000100",
            "ip": "192.168.116.200",
            "last_time": "2023-06-26 15:24:04",
            "manufacturer": "Hikvision",
            "name": "IP DOME",
            "nickname": "IP DOME",
            "port": "5060",
            "protocol": "UDP",
            "regist_time": "2023-06-26 15:23:59",
            "status": 1,
            "stream_ip": "192.168.116.125"
        }
    ],
    "msg": "ok"
}

2、/v1/device

{
    "code": 0,
    "data": {
        "channel_count": 1,
        "id": "34020000001320000100",
        "ip": "192.168.116.200",
        "last_time": "2023-06-26 15:28:39",
        "manufacturer": "Hikvision",
        "name": "IP DOME",
        "nickname": "IP DOME",
        "port": "5060",
        "protocol": "UDP",
        "regist_time": "2023-06-26 15:23:59",
        "status": 1,
        "stream_ip": "192.168.116.125"
    },
    "msg": "ok"
}

3、/v1/channel/list

{
    "code": 0,
    "data": [
        {
            "id": "34020000001320000100",
            "manufacturer": "Hikvision",
            "model": "IP Camera",
            "name": "IPdome",
            "nickname": "IPdome",
            "ptz_type": "",
            "ssrc": "0200000000",
            "status": "ON",
            "stream_id": "0BEBC200",
            "sub_channel_count": 0
        }
    ],
    "msg": "ok"
}

4、/v1/channel

{
    "code": 0,
    "data": [
        {
            "id": "34020000001320000100",
            "manufacturer": "Hikvision",
            "model": "IP Camera",
            "name": "IPdome",
            "nickname": "IPdome",
            "ptz_type": "",
            "ssrc": "0200000000",
            "status": "ON",
            "stream_id": "0BEBC200",
            "sub_channel_count": 0
        }
    ],
    "msg": "ok"
}

5、/v1/play/start

如果超时会返回

{
    "code": 400,
    "data": "",
    "msg": "timeout"
}

正常则会返回

{
    "code": 0,
    "data": {
        "ssrc": "0200000001"
    },
    "msg": "ok"
}

6、/v1/play/stop

{
    "code": 0,
    "data": "",
    "msg": "ok"
}

7、/v1/play/stopall

{
    "code": 0,
    "data": "",
    "msg": "ok"
}

8、/v1/set/device/streamip

{
    "code": 0,
    "data": "",
    "msg": "ok"
}

9、/v1/set/device/nickname

{
    "code": 0,
    "data": "",
    "msg": "ok"
}

10、/v1/set/channel/nickname

{
    "code": 0,
    "data": "",
    "msg": "ok"
}

11、/v1/defaultStreamID

{
    "code": 0,
    "data": {
        "ssrc": "0200000001"
    },
    "msg": "ok"
}

12、/v1/preset

{
    "code": 0,
    "data": "",
    "msg": "ok"
}

13、/v1/preset/query

{
    "code": 0,
    "data": [
        {
            "id": "1",
            "name": "预置点 1"
        },
        {
            "id": "2",
            "name": "预置点 2"
        },
        {
            "id": "3",
            "name": "预置点 3"
        }
    ],
    "msg": "ok"
}

14、/v1/ptz

15、/v1/record/query

16、/v1/record/play/start

17、/v1/record/play/stop

MIT License Copyright (c) 2023 The project authors. All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

依赖ZLMediaKit实现的一个简单的GB28181服务器,并提供了一个Client用于测试。支持Windows、Linux。 展开 收起
C++ 等 6 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
C++
1
https://gitee.com/yszs/sip-service.git
git@gitee.com:yszs/sip-service.git
yszs
sip-service
GB28181-Service
master

搜索帮助