ossrs / srs-gb28181

GB28181 server based on SRS
https://ossrs.net
MIT License
83 stars 41 forks source link

GB28181: GB28181-2016协议接入大华摄像头失败 #2240 #26

Open winlinvip opened 2 years ago

winlinvip commented 2 years ago

描述(Description)

描述你遇到了什么问题(Please description your issue here) 摄像头使用GB28181-2016协议连接srs服务失败

  1. SRS版本(Version): 4.0.85
  2. SRS的日志如下(Log):
    
    [root@centos7 trunk]# ./objs/srs -c conf/push.gb28181.conf
    [2021-03-15 17:36:37.315][Trace][26144][5xfqp5be] XCORE-SRS/4.0.85(Leo)
    [2021-03-15 17:36:37.315][Trace][26144][5xfqp5be] config parse complete
    [2021-03-15 17:36:37.315][Trace][26144][5xfqp5be] write log to console
    [2021-03-15 17:36:37.315][Trace][26144][5xfqp5be][MAIN] SRS/4.0.85(Leo), MIT
    [2021-03-15 17:36:37.315][Trace][26144][5xfqp5be] authors: Winlin,Wenjie,Runner365,John,B.P.Y,Lixin
    [2021-03-15 17:36:37.315][Trace][26144][5xfqp5be] contributors: winlin<winlin@vip.126.com> wenjie.zhao<740936897@qq.com> xiangcheng.liu<liuxc0116@foxmail.com> naijia.liu<youngcow@youngcow.net> alcoholyi<alcoholyi@qq.com> byteman<wangchen2011@gmail.com> chad.wang<chad.wang.cn@gmail.com> suhetao<suhetao@gmail.com> Johnny<fengjihu@163.com> karthikeyan<keyanmca@gmail.com> StevenLiu<lq@chinaffmpeg.org> zhengfl<zhengfl_1989@126.com> tufang14<breadbean1449@gmail.com> allspace<allspace@gmail.com> niesongsong<nie950@gmail.com> rudeb0t<nimrod@themanxgroup.tw> CallMeNP<np.liamg@gmail.com> synote<synote@qq.com> lovecat<littlefawn@163.com> panda1986<542638787@qq.com> YueHonghui<hongf.yue@hotmail.com> ThomasDreibholz<dreibh@simula.no> JuntaoLiu<juntliu@gmail.com> RocFang<fangpeng1986@gmail.com> MakarovYaroslav<yaroslav.makarov.97@mail.ru> MirkoVelic<mvelic@inoxx.net> HuiZhang(huzhang2)<huzhang2@cisco.com> OtterWa<simpleotter23@gmail.com> walkermi<172192667@qq.com> haofz<fuzhuang.hao@vhall.com> ME_Kun_Han<hanvskun@hotmail.com> ljx0305<ljx0305@gmail.com> cenxinwei<censhanhe@163.com> StarBrilliant<m13253@hotmail.com> xubin<xubin@chnvideo.com> intliang<yintiliang@gmail.com> flowerwrong<sysuyangkang@gmail.com> YLX<568414379@qq.com> J<guotaojiang@qq.com> Harlan<hailiang@gvrcraft.com> hankun<hankun@bravovcloud.com> JonathanBarratt<jonathan.barratt@gmail.com> KeeganH<keeganwharris@gmail.com> StevenLiu<lingjiujianke@gmail.com> liuxc0116<liuxc0116@gmail.com> ChengdongZhang<lmajzcd@sina.com> lovacat<lovecat@china.sina.com> qiang.li<qiang.li@verycdn.com.cn> HungMingWu<u9089000@gmail.com> Himer<xishizhaohua@qq.com> xialixin<xlx0625@163.com> alphonsetai<tyh_123@163.com> Michael.Ma<wnpllr@gmail.com> lam2003<linmin3@yy.com> runner365<shi.weibd@hotmail.com> XiaofengWang<wasphin@gmail.com> XiaLixin<xialx@yuntongxun.com> xiaozhihong<xiaozhihong8@gmail.com> HuyaJohn<xiaozhihong@huya.com> yanghuiwen<cainiaodj@qq.com> Bepartofyou<309554135@qq.com> l<22312935+lam2003@github> xfalcon<x-falcon@github> cgh<jinxue.cgh@alibaba-inc.com> LiPeng<mozhan.lp@alibaba-inc.com> xiaozhihong<hondaxiao@tencent.com> yajun18<yajun18@staff.sina.com.cn> liulichuan<liulichuan@kuaishou.com> yapingcat<caoyapingneu@163.com> chenchengbin<chenchengbin@yy.com> chenhaibo<chenhaibo@RD-CHB-0476-01> jasongwq<jasongwq@gmail.com> xialixin<xialixin@kanzhun.com> yinjiaoyuan<yinjiaoyuan@163.com> PieerePi<pihuibin@hotmail.com> JesseXi<jesse.jinjin@wo.cn> PieerePi<40780488+PieerePi@github> ghostsf<ghost_sf@163.com> xbpeng121<53243357+xbpeng121@github> johzzy<hellojinqiang@gmail.com> 
    [2021-03-15 17:36:37.315][Trace][26144][5xfqp5be] cwd=/root/srs/trunk, work_dir=./, build: 2021-03-15 15:18:56, configure: --x86-x64 --with-gb28181, uname: Linux centos7 3.10.0-1160.el7.x86_64 #1 SMP Mon Oct 19 16:18:59 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux, osx: 0
    [2021-03-15 17:36:37.315][Trace][26144][5xfqp5be] configure detail: --prefix=/usr/local/srs --hls=on --hds=off --dvr=on --ssl=on --https=on --ssl-1-0=off --ssl-local=off --sys-ssl=off --transcode=on --ingest=on --stat=on --http-callback=on --http-server=on --stream-caster=on --http-api=on --utest=off --cherrypy=on --srt=off --rtc=on --simulator=off --gb28181=on --cxx11=off --cxx14=off --ffmpeg-fit=on --nasm=on --srtp-nasm=on --clean=on --gperf=off --gmc=off --gmd=off --gmp=off --gcp=off --gprof=off --static=off --use-shared-st=off --use-shared-srt=off --log-verbose=off --log-info=off --log-trace=on --gcov=off --debug=off --debug-stats=off --cc=gcc --cxx=g++ --ar=ar --ld=ld --randlib=randlib
    [2021-03-15 17:36:37.315][Trace][26144][5xfqp5be] srs checking config...
    [2021-03-15 17:36:37.316][Trace][26144][5xfqp5be] ips, iface[0] enp0s8 ipv4 0x11043 172.16.1.12, iface[1] enp0s8 ipv6 0x11043 fe80::e2b1:52e0:91fc:ac32.009788e-316np0s8
    [2021-03-15 17:36:37.316][Trace][26144][5xfqp5be] devices, intranet enp0s8 172.16.1.12, intranet enp0s8 fe80::e2b1:52e0:91fc:ac32.009788e-316np0s8
    [2021-03-15 17:36:37.316][Warn][26144][5xfqp5be][0] stats network use index=0, ip=172.16.1.12, ifname=enp0s8
    [2021-03-15 17:36:37.316][Warn][26144][5xfqp5be][0] stats disk not configed, disk iops disabled.
    [2021-03-15 17:36:37.316][Trace][26144][5xfqp5be] write log to console
    [2021-03-15 17:36:37.316][Trace][26144][5xfqp5be] features, rch:on, dash:on, hls:on, hds:off, srt:off, hc:on, ha:on, hs:on, hp:on, dvr:on, trans:on, inge:on, stat:on, sc:on
    [2021-03-15 17:36:37.316][Trace][26144][5xfqp5be] SRS on  amd64 x86_64, conf:conf/push.gb28181.conf, limit:1000, writev:1024, encoding:little-endian, HZ:100
    [2021-03-15 17:36:37.316][Trace][26144][5xfqp5be] mw sleep:350ms. mr enabled:on, default:0, sleep:350ms
    [2021-03-15 17:36:37.316][Trace][26144][5xfqp5be] gc:on, pq:30000ms, cscc:[0,16), csa:on, tn:on(may hurts performance), ss:auto(guess by merged write)
    [2021-03-15 17:36:37.316][Trace][26144][5xfqp5be] system default latency(ms): mw(0-350) + mr(0-350) + play-queue(0-30000)
    [2021-03-15 17:36:37.316][Warn][26144][5xfqp5be][0] SRS/4.0.85 is not stable
    [2021-03-15 17:36:37.318][Trace][26144][5xfqp5be] st_init success, use epoll
    [2021-03-15 17:36:37.323][Trace][26144][5xfqp5be] fingerprint=C5:4C:66:B9:A7:94:E4:1D:26:6A:4E:9B:97:70:AA:71:E2:88:BF:50:E7:BA:26:91:75:E2:86:70:F7:78:4F:BD
    [2021-03-15 17:36:37.323][Trace][26144][5xfqp5be] RTC: Object cache init, rtp-cache=(enabled:1,pkt:64m-31w,payload:16m-69w-41w), msg-cache=(enabled:1,obj:16m-41w,buf:512m-34w)
    [2021-03-15 17:36:37.323][Trace][26144][5xfqp5be] http flv live stream, vhost=__defaultVhost__, mount=[vhost]/[app]/[stream].flv
    [2021-03-15 17:36:37.323][Trace][26144][5xfqp5be] http: root mount to ./objs/nginx/html
    [2021-03-15 17:36:37.323][Trace][26144][5xfqp5be] server main cid=5xfqp5be, pid=26144, ppid=1553, asprocess=0
    [2021-03-15 17:36:37.323][Trace][26144][5xfqp5be] write pid=26144 to ./objs/srs.pid success!
    [2021-03-15 17:36:37.324][Trace][26144][5xfqp5be] RTMP listen at tcp://0.0.0.0:1935, fd=7
    [2021-03-15 17:36:37.324][Trace][26144][5xfqp5be] HTTP-API listen at tcp://0.0.0.0:1985, fd=8
    [2021-03-15 17:36:37.324][Trace][26144][5xfqp5be] HTTP-Server listen at tcp://0.0.0.0:8080, fd=9
    [2021-03-15 17:36:37.325][Trace][26144][5xfqp5be] UDP #10 LISTEN at 0.0.0.0:5060, SO_SNDBUF(default=212992, expect=10485760, actual=425984, r0=0), SO_RCVBUF(default=212992, expect=10485760, actual=425984, r0=0)
    [2021-03-15 17:36:37.325][Trace][26144][5xfqp5be] GB28181-SIP over UDP listen at udp://0.0.0.0:5060, fd=10
    [2021-03-15 17:36:37.325][Trace][26144][5xfqp5be] UDP #11 LISTEN at 0.0.0.0:9000, SO_SNDBUF(default=212992, expect=10485760, actual=425984, r0=0), SO_RCVBUF(default=212992, expect=10485760, actual=425984, r0=0)
    [2021-03-15 17:36:37.325][Trace][26144][5xfqp5be] GB28181-Stream over RTP listen at udp://0.0.0.0:9000, fd=11
    [2021-03-15 17:36:37.325][Trace][26144][5xfqp5be] signal installed, reload=1, reopen=10, fast_quit=15, grace_quit=3
    [2021-03-15 17:36:37.326][Trace][26144][5xfqp5be] http: api mount /console to ./objs/nginx/html/console
    [2021-03-15 17:36:37.326][Trace][26144][5xfqp5be] rtc listen at udp://0.0.0.0:8000, fd=12
    [2021-03-15 17:36:37.326][Trace][26144][5xfqp5be] Hybrid cpu=0.00%,0MB
    [2021-03-15 17:36:37.326][Trace][26144][005946v6] GB28181: connection manager run, conns=0
    [2021-03-15 17:36:37.326][Trace][26144][04h6j6fl] TCP: connection manager run, conns=0
    [2021-03-15 17:36:37.326][Trace][26144][736010r3] UDP #12 LISTEN at 0.0.0.0:8000, SO_SNDBUF(default=212992, expect=10485760, actual=425984, r0=0), SO_RCVBUF(default=212992, expect=10485760, actual=425984, r0=0)
    [2021-03-15 17:36:37.326][Trace][26144][20k5657q] RTC: connection manager run, conns=0
    [2021-03-15 17:36:41.354][Trace][26144][5xfqp5be] sip: unkonw message head Priv-Version: content=100
    [2021-03-15 17:36:41.354][Trace][26144][5xfqp5be] sip: unkonw message head Priv-EventCap: content=2
    [2021-03-15 17:36:41.355][Trace][26144][5xfqp5be] gb28181: request client id=34020000001320000008 peer(172.16.1.99, 5160)
    [2021-03-15 17:36:41.355][Trace][26144][5xfqp5be] gb28181: request method=REGISTER, uri=sip:34020000002000000001@172.16.1.12:5060, version=SIP/2.0 expires=60
    [2021-03-15 17:36:41.713][Trace][26144][5xfqp5be] sip: unkonw message head Priv-Version: content=100
    [2021-03-15 17:36:41.713][Trace][26144][5xfqp5be] sip: unkonw message head Priv-EventCap: content=2
    [2021-03-15 17:36:41.713][Trace][26144][5xfqp5be] gb28181: request client id=34020000001320000008 peer(172.16.1.99, 5160)
    [2021-03-15 17:36:41.713][Trace][26144][5xfqp5be] gb28181: request method=REGISTER, uri=sip:34020000002000000001@172.16.1.12:5060, version=SIP/2.0 expires=0
    [2021-03-15 17:36:42.063][Trace][26144][5xfqp5be] sip: unkonw message head Priv-Version: content=100
    [2021-03-15 17:36:42.063][Trace][26144][5xfqp5be] sip: unkonw message head Priv-EventCap: content=2
    [2021-03-15 17:36:42.063][Trace][26144][5xfqp5be] gb28181: request client id=34020000001320000008 peer(172.16.1.99, 5160)
    [2021-03-15 17:36:42.063][Trace][26144][5xfqp5be] gb28181: request method=REGISTER, uri=sip:34020000002000000001@172.16.1.12:5060, version=SIP/2.0 expires=60
    [2021-03-15 17:36:42.515][Trace][26144][n4m39904] gb28181: sip session=34020000001320000008 peer(172.16.1.99, 5160) status(RegisterOk,AliveOk) duration(0,0)
    [2021-03-15 17:36:42.546][Trace][26144][5xfqp5be] sip: unkonw message head Route: content=<sip:34020000002000000001@172.16.1.12:5060>;tag=SrsGbF38745380
    [2021-03-15 17:36:59.319][Trace][26144][5xfqp5be] Hybrid cpu=0.00%,10MB, cid=1,1, timer=14,0,0, clock=0,2,1,1,1,1,2,1,2
    [2021-03-15 17:37:04.624][Trace][26144][5xfqp5be] Hybrid cpu=0.33%,10MB, cid=1,1, timer=14,0,0, clock=0,2,1,1,1,1,2,1,2
    [2021-03-15 17:37:12.479][Trace][26144][n4m39904] gb28181: sip session=34020000001320000008 peer(172.16.1.99, 5160) status(RegisterOk,AliveOk) duration(30,0)
    [2021-03-15 17:37:12.509][Trace][26144][5xfqp5be] sip: unkonw message head Route: content=<sip:34020000002000000001@172.16.1.12:5060>;tag=SrsGbF37681769
    [2021-03-15 17:37:19.753][Trace][26144][5xfqp5be] Hybrid cpu=0.27%,10MB, cid=1,0, timer=27,0,0, clock=0,13,3,1,1,1,2,1,1
    [2021-03-15 17:37:22.529][Trace][26144][5xfqp5be] sip: unkonw message head Priv-Version: content=100
    [2021-03-15 17:37:22.529][Trace][26144][5xfqp5be] sip: unkonw message head Priv-EventCap: content=2
    [2021-03-15 17:37:22.529][Trace][26144][5xfqp5be] gb28181: request client id=34020000001320000008 peer(172.16.1.99, 5160)
    [2021-03-15 17:37:22.529][Trace][26144][5xfqp5be] gb28181: request method=REGISTER, uri=sip:34020000002000000001@172.16.1.12:5060, version=SIP/2.0 expires=60
1. SRS的配置如下(Config):

[root@centos7 trunk]# cat conf/push.gb28181.conf

push gb28181 stream to SRS.

listen 1935; max_connections 1000; daemon off; srs_log_tank console;

http_api { enabled on; listen 1985; }

http_server { enabled on; listen 8080; dir ./objs/nginx/html; }

stats { network 0; }

stream_caster { enabled on; caster gb28181;

# 转发流到rtmp服务器地址与端口
# TODO: https://github.com/ossrs/srs/pull/1679/files#r400875104
# [stream] is VideoChannelCodecID(视频通道编码ID) for sip
# 自动创建的道通[stream] 是‘chid[ssrc]’ [ssrc]是rtp的ssrc
# [ssrc] rtp中的ssrc
output              rtmp://172.16.1.12:1935/live/[stream];

# 接收设备端rtp流的多路复用端口
listen              9000;
# 多路复用端口类型,on为tcp,off为udp
# 默认:off
tcp_enable            off;

# rtp接收监听端口范围,最小值
rtp_port_min        58200;
# rtp接收监听端口范围,最大值
rtp_port_max        58300;

# 是否等待关键帧之后,再转发,
# off:不需等待,直接转发
# on:等第一个关键帧后,再转发
wait_keyframe       on;

# rtp包空闲等待时间,如果指定时间没有收到任何包
# rtp监听连接自动停止,发送BYE命令
rtp_idle_timeout    30;

# 是否转发音频流
# 目前只支持aac格式,所以需要设备支持aac格式
# on:转发音频
# off:不转发音频,只有视频
# *注意*!!!:flv 只支持11025  22050  44100 三种
# 如果设备端没有三种中任何一个,转发时为自动选择一种格式
# 同时也会将adts的头封装在flv aac raw数据中
# 这样的话播放器为自动通过adts头自动选择采样频率
# 像ffplay, vlc都可以,但是flash是没有声音,
# 因为flash,只支持11025 22050 44100
audio_enable        off;

# 是否开启rtp缓冲
# 开启之后能有效解决rtp乱序等问题
jitterbuffer_enable  on;

# 服务器主机号,可以域名或ip地址
# 也就是设备端将媒体发送的地址,如果是服务器是内外网
# 需要写外网地址,
# 调用api创建stream session时返回ip地址也是host
# $CANDIDATE 是系统环境变量,从环境变量获取地址,如果没有配置,用*
# *代表指定stats network 的网卡号地址,如果没有配置network,默认则是第0号网卡地址
# TODO: https://github.com/ossrs/srs/pull/1679/files#r400917594
host       172.16.1.12;

#根据收到ps rtp包自带创建rtmp媒体通道,不需要api接口创建
#rtmp地址参数[stream] 就是通道id  格式chid[ssrc]
auto_create_channel   on;

sip {
    # 是否启用srs内部sip信令
    # 为on信令走srs, off 只转发ps流
    enabled on;

    # sip监听udp端口
    listen              5060;

    # SIP server ID(SIP服务器ID).
    # 设备端配置编号需要与该值一致,否则无法注册
    serial              34020000002000000001;

    # SIP server domain(SIP服务器域)
    realm               3402000000;

    # 服务端发送ack后,接收回应的超时时间,单位为秒
    # 如果指定时间没有回应,认为失败
    ack_timeout         30;

    # 设备心跳维持时间,如果指定时间内(秒)没有接收一个心跳
    # 认为设备离线
    keepalive_timeout   120;

    # 注册之后是否自动给设备端发送invite
    # on: 是  off 不是,需要通过api控制
    auto_play           on;
    # 设备将流发送的端口,是否固定
    # on 发送流到多路复用端口 如9000
    # off 自动从rtp_mix_port - rtp_max_port 之间的值中
    # 选一个可以用的端口
    invite_port_fixed     on;

    # 向设备或下级域查询设备列表的间隔,单位(秒)
    # 默认60秒
    query_catalog_interval  30;
}

}

rtc_server { enabled on;

Listen at udp://8000

listen          8000;
#
# The $CANDIDATE means fetch from env, if not configed, use * as default.
#
# The * means retrieving server IP automatically, from all network interfaces,
# @see https://github.com/ossrs/srs/issues/307#issuecomment-599028124
candidate       $CANDIDATE;

}

vhost defaultVhost { rtc { enabled on; bframe discard; }

http_remux {
    enabled     on;
    mount       [vhost]/[app]/[stream].flv;
}

}



**重现(Replay)**

> 重现Bug的步骤(How to replay bug?)

1. `启动srs`
2. `启动摄像头`

**期望行为(Expect)**

> 描述你期望发生的事情(Please describe your expectation)
能够正常接入摄像头,并可观看rtmp流