Giter VIP home page Giter VIP logo

plugin-gb28181's Introduction

Introduction

Monibuca is a highly scalable high-performance streaming server development framework developed purely for Go

Usage

package main

import (
	"context"

	"m7s.live/m7s/v5"
	_ "m7s.live/m7s/v5/plugin/debug"
	_ "m7s.live/m7s/v5/plugin/hdl"
	_ "m7s.live/m7s/v5/plugin/rtmp"
)

func main() {
	m7s.Run(context.Background(), "config.yaml")
}

More Example

see example directory

Create Plugin

import (
	"m7s.live/m7s/v5"
)

type MyPlugin struct {
	m7s.Plugin
}

var _ = m7s.InstallPlugin[MyPlugin]()

plugin-gb28181's People

Contributors

bosscheng avatar charlestamz avatar duiniuluantanqin avatar dwdcth avatar geekchengz avatar hongri8488 avatar huhusen avatar kingecg avatar langhuihui avatar ogofly avatar pggiroro avatar sshwsfc avatar yangchao2015 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

plugin-gb28181's Issues

求助

GB28181互联网视频传输,丢帧乱码,怎么解决。

GB28181 Not supported CmdType: MediaStatus

在预览播放历史录像文件时出现的该问题。

摄像头品牌是海康,Monibuca 使用的是 Linux 平台, docker 部署,GB28181的版本号为 "v4.4.5-0.20240521112210-a207352fe6e4,使用的配置是在默认配置的基础上,只修改了 invitemode 属性值为 0

操作流程:

  1. 使用 /gb28181/api/records API接口查询到了录像文件,返回有36条记录
  2. 使用 /gb28181/api/invite API 加上 startTimeendTime 进行拉流
  3. 使用 /preview/ 进行在线预览播放录像文件,typewebrtc

一开始播放很正常,直到连续播放到大约第20个录像文件的中途时,画面不动了,通过海康摄像头管理后台查看录像文件列表如下图所示:
图片

查看 Monibuca 容器日志输出大致如下:

15:05:31.658+0800       INFO    GB28181 OnRegister      {"isUnregister": false, "id": "34020000001320000001", "source": "192.168.50.203:5060", "destination": "[::]:5060"}
15:05:31.658+0800       INFO    GB28181 StoreDevice     {"id": "34020000001320000001", "deviceIp": "192.168.50.203:5060", "servIp": "3402000000", "sipIP": "192.168.50.66", "mediaIp": "192.168.50.66"}
15:05:36.674+0800       INFO    GB28181 QueryDeviceInfo {"id": "34020000001320000001", "status code": 200}
15:06:34.950+0800       INFO    GB28181 invite response {"id": "34020000001320000001", "channel": "34020000001320000001", "status code": 200}
15:06:34.950+0800       INFO    created {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 1}
15:06:34.950+0800       INFO    publish {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 1, "type": "PSPublisher", "ptr": "0xc000f70a08"}
15:06:34.951+0800       INFO    ⌛->🟡  {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 1, "action": "publish"}
15:06:34.951+0800       INFO    tcp listen 1 at :58200
15:06:34.956+0800       INFO    start receive ps stream from    {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 1, "type": "PSPublisher", "tcp": "192.168.50.66:58200"}
15:06:35.265+0800       INFO    attach video track      {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 1, "type": "PSPublisher", "track": "h264", "width": 1280, "height": 720}
15:06:35.265+0800       INFO    video track attached    {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 1, "type": "PSPublisher", "track": "h264", "width": 1280, "height": 720}
15:06:35.265+0800       INFO    🟡->🟢  {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 1, "action": "track available"}
15:06:35.265+0800       INFO    audio track attached    {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 1, "type": "PSPublisher", "track": "pcma", "sample rate": 8000}
15:06:40.187+0800       INFO    subscribe       {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 1, "type": "WebRTCSubscriber", "ID": "824652794112"}
15:06:40.187+0800       INFO    suber +1        {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 1, "type": "WebRTCSubscriber", "ID": "824652794112", "remains": 1}
15:06:40.187+0800       INFO    track+1 {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 1, "type": "WebRTCSubscriber", "ID": "824652794112", "name": "h264"}
15:06:40.188+0800       INFO    track+1 {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 1, "type": "WebRTCSubscriber", "ID": "824652794112", "name": "pcma"}
15:06:40.188+0800       INFO    Connection State has changed:connecting {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 1, "type": "WebRTCSubscriber", "ID": "824652794112"}
15:06:40.190+0800       INFO    candidate:2111806186 1 tcp 1671430143 192.168.50.66 9000 typ host tcptype passive       {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 1, "type": "WebRTCSubscriber", "ID": "824652794112"}
15:06:40.190+0800       INFO    candidate:2027898665 1 tcp 1671430143 172.19.0.1 9000 typ host tcptype passive  {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 1, "type": "WebRTCSubscriber", "ID": "824652794112"}
15:06:40.191+0800       INFO    candidate:2954730683 1 tcp 1671430143 172.17.0.1 9000 typ host tcptype passive  {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 1, "type": "WebRTCSubscriber", "ID": "824652794112"}
15:06:40.191+0800       INFO    candidate:1873040234 1 tcp 1671430143 172.18.0.1 9000 typ host tcptype passive  {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 1, "type": "WebRTCSubscriber", "ID": "824652794112"}
15:06:40.204+0800       INFO    Connection State has changed:connected  {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 1, "type": "WebRTCSubscriber", "ID": "824652794112"}
15:06:40.204+0800       INFO    playblock       {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 1, "type": "WebRTCSubscriber", "ID": "824652794112", "subType": 1}
15:06:40.204+0800       INFO    start read      {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 1, "type": "WebRTCSubscriber", "ID": "824652794112", "track": "h264", "mode": 0}
15:06:40.204+0800       INFO    first frame read        {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 1, "type": "WebRTCSubscriber", "ID": "824652794112", "track": "h264", "firstTs": "4.507672861s", "firstSeq": 102}
15:06:40.245+0800       INFO    start read      {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 1, "type": "WebRTCSubscriber", "ID": "824652794112", "track": "pcma", "mode": 0}
15:06:40.245+0800       INFO    first frame read        {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 1, "type": "WebRTCSubscriber", "ID": "824652794112", "track": "pcma", "firstTs": "4.507672861s", "firstSeq": 101}
15:06:41.334+0800       INFO    jump    {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 1, "type": "WebRTCSubscriber", "ID": "824652794112", "track": "h264", "skipSeq": 49, "skipTs": "5.415672861s"}
15:06:41.455+0800       INFO    jump    {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 1, "type": "WebRTCSubscriber", "ID": "824652794112", "track": "pcma", "skipSeq": 49, "skipTs": "5.377672861s"}
15:07:15.892+0800       WARN    track dts reset {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 1, "type": "PSPublisher", "track": "h264", "delta1": 1983870, "delta2": 1983870}
15:07:15.892+0800       WARN    track dts reset {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 1, "type": "PSPublisher", "track": "pcma", "delta1": 1980000, "delta2": 1980000}
15:07:39.508+0800       WARN    track dts reset {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 1, "type": "PSPublisher", "track": "h264", "delta1": 5577930, "delta2": 7561800}
15:07:39.509+0800       WARN    track dts reset {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 1, "type": "PSPublisher", "track": "pcma", "delta1": 5580000, "delta2": 7560000}
15:08:30.118+0800       WARN    track dts reset {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 1, "type": "PSPublisher", "track": "h264", "delta1": 1983870, "delta2": 9545670}
15:08:30.118+0800       WARN    track dts reset {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 1, "type": "PSPublisher", "track": "pcma", "delta1": 1983600, "delta2": 9543600}
15:08:49.452+0800       WARN    track dts reset {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 1, "type": "PSPublisher", "track": "h264", "delta1": 1265130, "delta2": 10810800}
15:08:49.453+0800       WARN    track dts reset {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 1, "type": "PSPublisher", "track": "pcma", "delta1": 1263600, "delta2": 10807200}
15:10:23.508+0800       WARN    track dts reset {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 1, "type": "PSPublisher", "track": "h264", "delta1": 7507890, "delta2": 18318690}
15:10:23.508+0800       WARN    track dts reset {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 1, "type": "PSPublisher", "track": "pcma", "delta1": 7509600, "delta2": 18316800}
15:12:43.758+0800       WARN    track dts reset {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 1, "type": "PSPublisher", "track": "pcma", "delta1": 1443600, "delta2": 19760400}
15:12:43.759+0800       WARN    track dts reset {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 1, "type": "PSPublisher", "track": "h264", "delta1": 1444770, "delta2": 19763460}
15:13:28.707+0800       WARN    track dts reset {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 1, "type": "PSPublisher", "track": "h264", "delta1": 3421530, "delta2": 23184990}
15:13:28.707+0800       WARN    track dts reset {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 1, "type": "PSPublisher", "track": "pcma", "delta1": 3420000, "delta2": 23180400}
15:13:53.546+0800       WARN    track dts reset {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 1, "type": "PSPublisher", "track": "h264", "delta1": 32533020, "delta2": 55718010}
15:13:53.546+0800       WARN    track dts reset {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 1, "type": "PSPublisher", "track": "pcma", "delta1": 32533200, "delta2": 55713600}
15:14:07.817+0800       WARN    track dts reset {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 1, "type": "PSPublisher", "track": "h264", "delta1": 2163510, "delta2": 57881520}
15:14:07.817+0800       WARN    track dts reset {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 1, "type": "PSPublisher", "track": "pcma", "delta1": 2163600, "delta2": 57877200}
15:14:23.626+0800       WARN    track dts reset {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 1, "type": "PSPublisher", "track": "h264", "delta1": 13125330, "delta2": 71006850}
15:14:23.626+0800       WARN    track dts reset {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 1, "type": "PSPublisher", "track": "pcma", "delta1": 13125600, "delta2": 71002800}
15:14:44.369+0800       WARN    track dts reset {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 1, "type": "PSPublisher", "track": "h264", "delta1": 70866630, "delta2": 141873480}
15:14:44.369+0800       WARN    track dts reset {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 1, "type": "PSPublisher", "track": "pcma", "delta1": 70866000, "delta2": 141868800}
15:16:17.894+0800       ERROR   gb28181 decode rtp error:       {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 1, "type": "PSPublisher", "error": "size 56 < 219824: RTP header size insufficient for extension"}
15:16:17.894+0800       INFO    stop receive ps stream from     {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 1, "type": "PSPublisher", "tcp": "192.168.50.66:58200"}
15:16:17.894+0800       INFO    close   {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 1, "type": "PSPublisher"}
15:16:17.898+0800       WARN    GB28181 Not supported CmdType   {"id": "34020000001320000001", "CmdType": "MediaStatus", "body": "<?xml version=\"1.0\" encoding=\"GB2312\"?>\n<Notify>\n<CmdType>MediaStatus</CmdType>\n<SN>244</SN>\n<DeviceID>34020000001320000001</DeviceID>\n<NotifyType>121</NotifyType>\n</Notify>\n"}
15:16:20.435+0800       WARN    publish is closed       {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 1, "error": "stop", "ptr": "0xc000e42820"}
15:16:20.435+0800       INFO    🟢->⌛  {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 1, "action": "timeout"}
15:16:30.435+0800       INFO    ⌛->🔴  {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 1, "action": "timeout"}
15:16:30.435+0800       INFO    close   {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 1, "type": "WebRTCSubscriber", "ID": "824652794112", "event": "close"}
15:16:30.435+0800       WARN    rtcp read error {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 1, "type": "WebRTCSubscriber", "ID": "824652794112", "error": "EOF"}
15:16:30.436+0800       INFO    Connection State has changed:closed     {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 1, "type": "WebRTCSubscriber", "ID": "824652794112"}
15:17:28.450+0800       INFO    created {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 2}
15:17:28.450+0800       INFO    subscribe       {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 2, "type": "HDLSubscriber", "ID": "192.168.50.207:50377"}
15:17:28.450+0800       INFO    suber +1        {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 2, "type": "HDLSubscriber", "ID": "192.168.50.207:50377", "remains": 1}
15:17:38.451+0800       INFO    ⌛->🔴  {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 2, "action": "timeout"}
15:17:43.276+0800       INFO    created {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 3}
15:17:43.276+0800       INFO    subscribe       {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 3, "type": "WebRTCSubscriber", "ID": "824652791808"}
15:17:43.277+0800       INFO    suber +1        {"stream": "34020000001320000001/34020000001320000001/1717689600-1717776000", "id": 3, "type": "WebRTCSubscriber", "ID": "824652791808", "remains": 1}

以上日志中存在1个 ERROR 等级错误,请作者帮忙查看一下

大华多摄像头无法同时使用

场景描述
server端使用docker方式进行部署

docker run --name monibuca -v /etc/localtime:/etc/localtime:ro   -id -p 1935:1935 -p 8080:8080 -p 8443:8443 -p 554:554 -p 58200:58200 -p 5060:5060/udp -p 8000:8000/udp -p 9000:9000 langhuihui/monibuca:latest

server端配置有进行过更改(默认配置也试过问题一样)

cat config.yaml
# 支持零配置启动,即无需填写配置默认启用所有的插件。
# 只需要填写需要修改的配置项即可。不需要将所有的配置都填写进来!!。
# 全局配置参考 https://m7s.live/guide/config.html
# 插件配置参考各个插件的文档
# 插件都有一个enable配置,如果为false则不启用该插件,默认为true即不需要配置。

gb28181:
  invitemode:     1
  position:
    autosubposition: false
    expires: 3600s
    interval: 6s
  udpcachesize:   0
  serial:         "34020000002000000001"
  realm:          "3402000000"
  password:       "123456"

  registervalidity:  60s

  port:
    sip: udp:5060
    media: tcp:58200-59200

  removebaninterval: 1m
  loglevel:         info

摄像头端只有设备编号不同,其余完全一致(密码有配置123456)
设备编号分别为
34020000001320000001、34020000001320000002
image

故障描述
两个大华品牌摄像头,启用单个摄像头都可以正常,但是如果同时启用两个摄像头,只有最先注册的摄像头能够正常使用,第二个注册的摄像头总是处于publish--->close
image

18:05:53.500+0800	INFO	GB28181	invite response	{"id": "34020000001320000002", "channel": "34020000001310000001", "status code": 200}
18:05:53.500+0800	INFO	created	{"stream": "34020000001320000002/34020000001310000001", "id": 54}
18:05:53.500+0800	INFO	publish	{"stream": "34020000001320000002/34020000001310000001", "id": 54, "type": "PSPublisher", "ptr": "0xc000cec508"}
18:05:53.500+0800	INFO	⌛->🟡	{"stream": "34020000001320000002/34020000001310000001", "id": 54, "action": "publish"}
18:05:53.501+0800	INFO	tcp listen 1 at :58207
18:05:53.501+0800	INFO	subscribe	{"stream": "34020000001320000002/34020000001310000001", "id": 54, "type": "MonitorSuber", "ID": "824634671744"}
18:05:53.501+0800	INFO	innersuber +1	{"stream": "34020000001320000002/34020000001310000001", "id": 54, "type": "MonitorSuber", "ID": "824634671744", "remains": 1}
18:05:58.501+0800	WARN	no tracks	{"stream": "34020000001320000002/34020000001310000001", "id": 54}
18:05:58.501+0800	INFO	🟡->🟢	{"stream": "34020000001320000002/34020000001310000001", "id": 54, "action": "track available"}
18:06:03.502+0800	WARN	no tracks	{"stream": "34020000001320000002/34020000001310000001", "id": 54}
18:06:03.502+0800	INFO	🟢->🔴	{"stream": "34020000001320000002/34020000001310000001", "id": 54, "action": "close"}
18:06:03.502+0800	INFO	close	{"stream": "34020000001320000002/34020000001310000001", "id": 54, "type": "PSPublisher", "event": "close"}
18:06:50.477+0800	INFO	GB28181	invite response	{"id": "34020000001320000002", "channel": "34020000001310000001", "status code": 200}
18:06:50.477+0800	INFO	created	{"stream": "34020000001320000002/34020000001310000001", "id": 55}
18:06:50.477+0800	INFO	publish	{"stream": "34020000001320000002/34020000001310000001", "id": 55, "type": "PSPublisher", "ptr": "0xc001533908"}
18:06:50.477+0800	INFO	⌛->🟡	{"stream": "34020000001320000002/34020000001310000001", "id": 55, "action": "publish"}
18:06:50.477+0800	INFO	tcp listen 1 at :58208
18:06:50.477+0800	INFO	subscribe	{"stream": "34020000001320000002/34020000001310000001", "id": 55, "type": "MonitorSuber", "ID": "824637162112"}
18:06:50.478+0800	INFO	innersuber +1	{"stream": "34020000001320000002/34020000001310000001", "id": 55, "type": "MonitorSuber", "ID": "824637162112", "remains": 1}
18:06:55.477+0800	WARN	no tracks	{"stream": "34020000001320000002/34020000001310000001", "id": 55}
18:06:55.477+0800	INFO	🟡->🟢	{"stream": "34020000001320000002/34020000001310000001", "id": 55, "action": "track available"}
18:07:00.478+0800	WARN	no tracks	{"stream": "34020000001320000002/34020000001310000001", "id": 55}
18:07:00.478+0800	INFO	🟢->🔴	{"stream": "34020000001320000002/34020000001310000001", "id": 55, "action": "close"}
18:07:00.478+0800	INFO	close	{"stream": "34020000001320000002/34020000001310000001", "id": 55, "type": "PSPublisher", "event": "close"}

使用GB28181功能插件运行不起来

错误日志:

../../../go/pkg/mod/m7s.live/plugin/gb28181/[email protected]/handle.go:12:2: "m7s.live/engine/v4" imported and not used
../../../go/pkg/mod/m7s.live/plugin/gb28181/[email protected]/handle.go:283:3: undefined: EmitEvent
../../../go/pkg/mod/m7s.live/plugin/gb28181/[email protected]/handle.go:346:3: undefined: EmitEvent

go的版本是:go1.20.14 linux/amd64

代码main.go
package main

import (
"context"
_ "m7s.live/plugin/gb28181/v4"
//"m7s.live/engine/v4"
//_ "m7s.live/plugin/rtmp/v4"
)

func main() {
engine.Run(context.Background(), "config.yml")
}
请教下,是main.go哪里写的不对吗?
谢谢!!!

没有GPS定位

设备上线后,好像没有订阅GPS定位消息,导致接收不到定位数据

关于设备注册的问题

按照GB28181附录J或者SIP协议,设备在SIP服务器注册成功,服务器返回的200相应中应该是有Contact这一头部字段的,但是目前版本插件是没有的,导致注册成功服务器返回给设备的报文是200 OK (0bingdings),而正常的应该是200OK (1bingdings),所以希望插件在返回的报文里添加Contact这一头部字段,这样就返回正确了

time.After mem++

	sse.WriteJSON(list)
	select {
	case <-time.After(time.Second * 5):
	case <-sse.Done():
		return
	}

restful的这里建议NewTimer,确保超时内存能及时释放
sse.WriteJSON(list)
timeOut := time.NewTimer(time.Second * 5)
defer timeOut.Stop()
select {
case <-timeOut.C:
case <-sse.Done():
return
}
同样的server.go建议增加
t := time.NewTicker(time.Duration(config.RemoveBanInterval) * time.Second)
defer t.Stop() //新增

panic错误

panic: runtime error: slice bounds out of range [:9] with length 0

goroutine 1616 [running]:
m7s.live/plugin/gb28181/v4.(*Channel).CreateRequst(0xc0013ae1c0, {0xe6cbab, 0x6})
	/go/pkg/mod/m7s.live/plugin/gb28181/[email protected]/channel.go:100 +0x725
m7s.live/plugin/gb28181/v4.(*Channel).Invite(0xc0013ae1c0, {0x0, 0x0, {0x0, 0x0}, {0xc000804b50, 0xa}, 0xbebd2f1, 0xe358})
	/go/pkg/mod/m7s.live/plugin/gb28181/[email protected]/channel.go:358 +0xbbc
created by m7s.live/plugin/gb28181/v4.(*Device).UpdateChannels
	/go/pkg/mod/m7s.live/plugin/gb28181/[email protected]/device.go:245 +0x9b6

使用GB28181协议在订阅后流被断开该如何解决

使用设备为海康摄像头,配置如下:
image
config.yaml配置如下

llhls:
  enable: false
hls:
  enable: false
monitor:
  enable: false

global:
  pulseinterval: 5s # 心跳事件间隔时间

gb28181:
  invitemode:     1 #0、手动invite 1、表示自动发起invite,当Server(SIP)接收到设备信息时,立即向设备发送invite命令获取流,2、按需拉流,既等待订阅者触发
  position:
    autosubposition: false #是否自动订阅定位
    expires: 3600s #订阅周期(单位:秒),默认3600
    interval: 61s #订阅间隔(单位:秒),默认6
  sipip:          "" #sip服务器地址 默认 自动适配设备网段
  serial:         "34020000001110000001"
  realm:          "3402000000"
  username:       "34020000001110000001"
  password:       "12345678"
  registervalidity:  80s #注册有效期
  mediaip:          "" #媒体服务器地址 默认 自动适配设备网段
  port:
    sip: udp:5060 #sip服务器端口
    media: tcp:58200-59200 #媒体服务器端口,用于接收设备的流

  removebaninterval: 10m #定时移除注册失败的设备黑名单,单位秒,默认10分钟(600秒)
  loglevel:         debug

启用monibuca进程,查看8080/gb28181/api/list API接口返回如下:

[
  {
    "Channels": [
      {
        "Address": "192.168.254.3",
        "CivilCode": "CivilCode",
        "DeviceID": "34020000001310000001",
        "GpsTime": "0001-01-01T00:00:00Z",
        "Latitude": "",
        "LiveStatus": 0,
        "LiveSubSP": "",
        "Longitude": "",
        "Manufacturer": "Manufacturer",
        "Model": "Camera",
        "Name": "优曼测试",
        "Owner": "Owner",
        "ParentID": "",
        "Parental": 0,
        "Port": 0,
        "RegisterWay": 1,
        "SafetyWay": 0,
        "Secrecy": 0,
        "Status": "ON"
      },
      {
        "Address": "192.168.254.19",
        "CivilCode": "CivilCode",
        "DeviceID": "34020000001310000002",
        "GpsTime": "0001-01-01T00:00:00Z",
        "Latitude": "",
        "LiveStatus": 0,
        "LiveSubSP": "",
        "Longitude": "",
        "Manufacturer": "Manufacturer",
        "Model": "Camera",
        "Name": "Camera 01",
        "Owner": "Owner",
        "ParentID": "",
        "Parental": 0,
        "Port": 0,
        "RegisterWay": 1,
        "SafetyWay": 0,
        "Secrecy": 0,
        "Status": "OFF"
      }
    ],
    "ID": "34020000001110000001",
    "Name": "Network Video Recorder",
    "Manufacturer": "HIKVISION",
    "Model": "DS-7816N-R2/16P",
    "Owner": "",
    "RegisterTime": "2024-01-21T14:54:08.084150099+08:00",
    "UpdateTime": "2024-01-21T15:06:18.120260297+08:00",
    "LastKeepaliveAt": "2024-01-21T15:06:18.120381176+08:00",
    "Status": "ONLINE",
    "SN": 3,
    "SipIP": "172.18.156.34",
    "MediaIP": "172.18.156.34",
    "NetAddr": "171.106.18.191:62977",
    "GpsTime": "0001-01-01T00:00:00Z",
    "Longitude": "",
    "Latitude": ""
  }
]

访问:8080/preview/34020000001110000001/34020000001310000001播放视频流失败,STD输出如下:

15:13:57        DEBUG   Preview visit   {"path": "/preview/34020000001110000001/decoder-pro-hard.js", "remote": "222.71.242.202:56737"}
15:13:57        DEBUG   Preview visit   {"path": "/preview/34020000001110000001/decoder-pro-audio.wasm", "remote": "222.71.242.202:56737"}
15:13:58        DEBUG   HDL     visit   {"path": "/hdl/34020000001110000001/34020000001310000001.flv", "remote": "222.71.242.202:56737"}
15:13:58        INFO    已创建  {"流": "34020000001110000001/34020000001310000001", "id": 1}
15:13:58        DEBUG   warp context    {"流": "34020000001110000001/34020000001310000001", "id": 1, "类型": "HDLSubscriber", "ID": "222.71.242.202:56737"}
15:13:58        INFO    订阅    {"流": "34020000001110000001/34020000001310000001", "id": 1, "类型": "HDLSubscriber", "ID": "222.71.242.202:56737"}
15:13:58        DEBUG   GB28181 TryAutoInvite   {"id": "34020000001110000001", "channel": "34020000001310000001", "opt": "t=0 0", "condition": true}
15:13:58        INFO    订阅者+1        {"流": "34020000001110000001/34020000001310000001", "id": 1, "类型": "HDLSubscriber", "ID": "222.71.242.202:56737", "remains": 1}
15:13:58        INFO    GB28181 invite response {"id": "34020000001110000001", "channel": "34020000001310000001", "status code": 200}
15:13:58        DEBUG   GB28181 Device support tcp      {"id": "34020000001110000001", "channel": "34020000001310000001"}
15:13:58        DEBUG   found   {"流": "34020000001110000001/34020000001310000001", "id": 1}
15:13:58        DEBUG   create context  {"流": "34020000001110000001/34020000001310000001", "id": 1, "类型": "PSPublisher"}
15:13:58        INFO    发布    {"流": "34020000001110000001/34020000001310000001", "id": 1, "类型": "PSPublisher", "ptr": "0xc000c135e0"}
15:13:58        INFO    ⌛->🟡    {"流": "34020000001110000001/34020000001310000001", "id": 1, "动作": "publish"}
15:13:58        INFO    tcp listen 1 at :58200
15:14:03        WARN    no tracks       {"流": "34020000001110000001/34020000001310000001", "id": 1}
15:14:03        INFO    🟡->🔴    {"流": "34020000001110000001/34020000001310000001", "id": 1, "动作": "timeout"}
15:14:03        INFO    close   {"流": "34020000001110000001/34020000001310000001", "id": 1, "类型": "HDLSubscriber", "ID": "222.71.242.202:56737", "event": "close"}
15:14:03        INFO    close   {"流": "34020000001110000001/34020000001310000001", "id": 1, "类型": "PSPublisher", "event": "close"}

观察到的现象:
当播放失败后,8080/gb28181/api/list这个API的返回对象就会变为[]空数组
目前看起来连接是建立了,从报错内容来看是没有收到推流数据,想请教一下该如何排查问题。
服务器上的端口已经全部开放(1-60999)

【bug】两个tplink的摄像头,但是只能播放一个

image

image

image

不知道为啥就timeout了

15:27:50	INFO	tcp listen 1 at :58201
15:28:00	WARN	no tracks	{"stream": "34020000001320000001/34020000001320000001"}
15:28:00	INFO	🟢->⌛	{"stream": "34020000001320000001/34020000001320000001", "action": "publish lost"}
15:28:00	DEBUG	wait publisher	{"stream": "34020000001320000001/34020000001320000001", "wait timeout": "10ms"}
15:28:00	DEBUG	timeout	{"stream": "34020000001320000001/34020000001320000001", "state": "⌛"}
15:28:00	INFO->🔴	{"stream": "34020000001320000001/34020000001320000001", "action": "timeout"}

image

image

感觉并发有问题

image

V4没有AutoCloseAfter配置?

AutoCloseAfter 如果设置大于等于0,则当某个流最后一个订阅者取消订阅时会延迟N秒,会自动发送bye,节省流量。如果为了响应及时,可以设置成-1,保持流的连接

对讲支持

您好,
准备在利用该插件实现语音推送(摄像头播放).实现流程如下:
1)前端页面向sip服务发送HTTP请求(摄像头ID作为参数)。
2)sip服务接收到前端页面请求后根据ID查询到对应的摄像头设备,发送SIP广播通知,并接收摄像头的广播应答。应答中包含摄像头的IP地址,端口号,音频编码信息。
3)sip服务向流媒体服务发送HTTP请求,携带要发送的摄像头RTP相关信息。流媒体服务发送前端音频流。
4)前端页面接收到步骤1的HTTP返回后,进行拾音操作,将PCM格式的音频流发送给流媒体服务。
5)流媒体服务将接收到的PCM音频流转码为PCMA格式。
6)流媒体服务将PCMA音频数据进行RTP封装,以UDP的方式发送到对应的摄像头。
这个插件内置的sip server, sip通信都没有问题. 有个问题是: 步骤3 是插件同monibuca之间通信吗?这个该如何实现?
谢谢

GB28181接入常见问题

这里记录一下GB28181接入的常见问题

SIP/2.0 400 Bad request

国标编码不一致,在nvr或者摄像头的国标配置页;外域编码需要配置和Monibuca一致

SIP/2.0 487 Request Terminated

国标编码问题,nvr的本机的11-13位国标编码需要为200,并修改摄像机11-13位的为131,Monibuca编码为120
还有可能是nvr配置Monibuca的国标编码和国标域反了

海康摄像机使用gb28181报错

panic: runtime error: slice bounds out of range [:-1]

goroutine 120 [running]:
m7s.live/plugin/gb28181/v4.(*GB28181Config).StoreDevice(0x1937440, {0xc000757645, 0x14}, {0x1235158, 0xc000c286e0}, 0xc00074d8e0)
/home/runner/go/pkg/mod/m7s.live/plugin/gb28181/[email protected]/device.go:88 +0x705
m7s.live/plugin/gb28181/v4.(*GB28181Config).OnRegister(0x1937440, {0x1235158?, 0xc000c286e0}, {0x7f635cf23318, 0xc000c07b80})
/home/runner/go/pkg/mod/m7s.live/plugin/gb28181/[email protected]/handle.go:95 +0x3f2
created by github.com/ghettovoice/gosip.(*server).handleRequest
/home/runner/go/pkg/mod/github.com/ghettovoice/[email protected]/server.go:270 +0x28a

Invite请求中SipRequestForResponse报错之后,使用的端口没有回收

return http.StatusInternalServerError, err

在发送Invite请求之前需要从PortManager中拿一个端口,但是发送Invite请求不成功时,不能走Bye中的recycle逻辑。久而久之PortManager.Range()会越来越少直至耗尽

inviteRes, err := d.SipRequestForResponse(invite)
if err != nil {
  channel.Error("invite", zap.Error(err), zap.String("msg", invite.String()))
  return http.StatusInternalServerError, err
}

求助 使用教程

直接在main。go 引用就行吗?我试了 运行不起来,请问有详细的教程吗 新手不懂怎么操作,有 demo 提供吗

TP-Link的无线摄像头与国标28181插件通信,无法autoinvite

局域网下可以成功通信,但是插件发送的invite消息出现可稳定复现的超时,只有极小的概率成功。
发送的消息如下
writing SIP message to UDP 192.168.0.108:5061 {"plugin": "GB28181", "prefix": "transport.Protocol", "connection_key": ""udp:0.0.0.0:5060"", "sip_server_ptr": ""0xc00021de00"", "protocol_ptr": ""0xc00024aa00"", "connection_ptr": ""0xc000314380"", "request_id": ""779f96d4-370d-4e54-a3af-83294d32a154"", "transport": ""UDP"", "source": ""192.168.0.106:5060"", "destination": ""192.168.0.108:5061"", "transport_layer_ptr": ""0xc00021dea0"", "transaction_ptr": ""0xc000244240"", "transaction_key": ""z9hG4bK.Dmv5akDdDsm8aLOsmeB8fT7mbnQgcUVf__INVITE""}

得到的报错如下(master分支暂时没有打印报错log,这个是自己改的)
do SipRequestForResponse faild transaction.TxTimeoutError<transaction_key=z9hG4bK.Dmv5akDdDsm8aLOsmeB8fT7mbnQgcUVf__INVITE transaction_ptr=0xc000244240>: transaction timed out

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.