GB28181学习(十五)——流传输方式

前言

基于GB/T28181-2022版本,实时流的传输方式包括3种:

  • UDP
  • TCP被动
  • TCP主动

UDP

流程

注意:

  • m字段指定传输方式为RTP/AVP;

抓包

  • SIP服务器发送INVITE请求;
bash 复制代码
INVITE sip:xxx@192.168.0.111:5060 SIP/2.0
Via: SIP/2.0/UDP 192.168.0.107:5060;rport;branch=xxx
Max-Forwards: 70
From: sip:xxx@192.168.0.107:5060;tag=xxx
To: sip:xxx@192.168.0.111:5060
Contact: <sip:xxx@192.168.0.107:5060>
Call-ID: xxx
CSeq: 18467 INVITE
Allow: INVITE, ACK, BYE, CANCEL, UPDATE, PRACK
Supported: 100rel
Subject: xxx:xx,xxx:xx
Content-Type: application/sdp
Content-Length:   211

v=0
o=xxx 0 0 IN IP4 192.168.0.107
s=Play
c=IN IP4 192.168.0.107
t=0 0
m=video 36000 RTP/AVP 96 98 97   # 36000为SIP服务数据接收端口
a=recvonly
a=rtpmap:96 PS/90000
a=rtpmap:98 H264/90000
a=rtpmap:97 MPEG4/90000
y=0100000001
  • 设备返回200 OK;
bash 复制代码
SIP/2.0 200 OK
Call-ID: xxx
Contact: <sip:sss@192.168.0.111:5060>
Content-Length: 226
Content-Type: application/sdp
CSeq: 18467 INVITE
From: <sip:xxx@192.168.0.107:5060>;tag=xxx
To: <sip:xxx@192.168.0.111:5060>;tag=xxx
User-Agent: SIP UAS V.2016.xxxx
Via: SIP/2.0/UDP 192.168.0.107:5060;rport=5060;branch=xxx

v=0
o=34020000001310000002 0 0 IN IP4 192.168.0.111
s=Play
i=VCam Live Video
c=IN IP4 192.168.0.111
t=0 0
m=video 9712 RTP/AVP 96     # 9712为设备端数据发送端口
a=sendonly
a=rtpmap:96 PS/90000
a=streamprofile:0
y=0100000001
f=v/0/0/0/0/0a/0/0/0
  • SIP服务器返回ACK
bash 复制代码
ACK sip:xxx@192.168.0.111:5060 SIP/2.0
Via: SIP/2.0/UDP 192.168.0.107:5060;rport;branch=xxx
Max-Forwards: 70
From: sip:xxx@192.168.0.107:5060;tag=xxx
To: sip:xxx@192.168.0.111:5060;tag=xxx
Call-ID: xxx
CSeq: 18467 ACK
Content-Length:  0

TCP被动

流程

注意:

  • m字段指定传输方式为TCP/RTP/AVP;
  • sdp信息中增加"a=setup:passive";
  • SIP服务器启动端口监听,设备发起tcp连接请求;

抓包

  • SIP服务器发送INVITE请求;
bash 复制代码
INVITE sip:xxx@192.168.0.111:5060 SIP/2.0
Via: SIP/2.0/UDP 192.168.0.107:5060;rport;branch=xxx
Max-Forwards: 70
From: sip:xxx@192.168.0.107:5060;tag=xxx
To: sip:xxx@192.168.0.111:5060
Contact: <sip:xxx@192.168.0.107:5060>
Call-ID: xxx
CSeq: 18480 INVITE
Allow: INVITE, ACK, BYE, CANCEL, UPDATE, PRACK
Supported: 100rel
Subject: xxx:xx,xxx:xx
Content-Type: application/sdp
Content-Length:   211

v=0
o=xxx 0 0 IN IP4 192.168.0.107
s=Play
c=IN IP4 192.168.0.107
t=0 0
m=video 36000 TCP/RTP/AVP 96 98 97 
a=recvonly
a=rtpmap:96 PS/90000
a=rtpmap:98 H264/90000
a=rtpmap:97 MPEG4/90000
a=setup:passive
y=0100000001
  • 设备返回200 OK
bash 复制代码
SIP/2.0 200 OK
Call-ID: xxx
Contact: <sip:xxx@192.168.0.111:5060>
Content-Length: 264
Content-Type: application/sdp
CSeq: 18480 INVITE
From: <sip:xxx@192.168.0.107>;tag=xxx
To: <sip:xxx@192.168.0.111>;tag=xxx
User-Agent: SIP UAS V.2016.xxxx
Via: SIP/2.0/UDP 192.168.0.107:5060;rport=5060;branch=xxx

v=0
o=xxx 0 0 IN IP4 192.168.0.111
s=Play
i=VCam Live Video
c=IN IP4 192.168.0.111
t=0 0
m=video 9724 TCP/RTP/AVP 96    # 9724为设备端数据发送端口
a=sendonly
a=rtpmap:96 PS/90000           # 流数据为PS封装
a=streamprofile:0
a=setup:active                 # 设备为主动发送方
a=connection:new
y=0100000001
f=v/0/0/0/0/0a/0/0/0
  • SIP服务器返回ACK
bash 复制代码
ACK sip:xxx@192.168.0.111:5060 SIP/2.0
Via: SIP/2.0/UDP 192.168.0.107:5060;rport;branch=xxx
Max-Forwards: 70
From: sip:xxx@192.168.0.107:5060;tag=xxx
To: sip:xxx@192.168.0.111:5060;tag=xxx
Call-ID: xxx
CSeq: 18480 ACK
Content-Length:  0

TCP主动

流程

注意:

  • m字段指定传输方式为TCP/RTP/AVP;
  • sdp信息中增加"a=setup:active";
  • 设备返回200 OK,报文的SDP信息中包含tcp监听端口;
  • SIP服务器根据设备监听端口发起TCP连接请求;

抓包

  • SIP服务器发送INVITE请求;
bash 复制代码
INVITE sip:xxx@192.168.0.111:5060 SIP/2.0
Via: SIP/2.0/UDP 192.168.0.107:5060;rport;branch=xxx
Max-Forwards: 70
From: sip:xxx@192.168.0.107:5060;tag=xxx
To: sip:xxx@192.168.0.111:5060
Contact: <sip:xxx@192.168.0.107:5060>
Call-ID: xxx
CSeq: 19100 INVITE
Allow: INVITE, ACK, BYE, CANCEL, UPDATE, PRACK
Supported: 100rel
Subject: xxx:xx,xxx:xx
Content-Type: application/sdp
Content-Length:   211

v=0
o=xxx 0 0 IN IP4 192.168.0.107
s=Play
c=IN IP4 192.168.0.107
t=0 0
m=video 38000 TCP/RTP/AVP 96 98 97 
a=recvonly
a=rtpmap:96 PS/90000
a=rtpmap:98 H264/90000
a=rtpmap:97 MPEG4/90000
a=setup:active
y=0100000001
  • 设备返回200 OK
bash 复制代码
SIP/2.0 200 OK
Call-ID: xxx
Contact: <sip:xxx@192.168.0.111:5060>
Content-Length: 264
Content-Type: application/sdp
CSeq: 19100 INVITE
From: <sip:xxx@192.168.0.107>;tag=xxx
To: <sip:xxx@192.168.0.111>;tag=xxx
User-Agent: SIP UAS V.2016.xxxx
Via: SIP/2.0/UDP 192.168.0.107:5060;rport=5060;branch=xxx

v=0
o=xxx 0 0 IN IP4 192.168.0.111
s=Play
i=VCam Live Video
c=IN IP4 192.168.0.111
t=0 0
m=video 9704 TCP/RTP/AVP 96    # 9704为设备端监听
a=sendonly
a=rtpmap:96 PS/90000           # 流数据为PS封装
a=streamprofile:0
a=setup:passive                # 设备为被动接收方
a=connection:new
y=0100000001
f=v/0/0/0/0/0a/0/0/0
  • SIP服务器返回ACK
bash 复制代码
ACK sip:xxx@192.168.0.111:5060 SIP/2.0
Via: SIP/2.0/UDP 192.168.0.107:5060;rport;branch=xxx
Max-Forwards: 70
From: sip:xxx@192.168.0.107:5060;tag=xxx
To: sip:xxx@192.168.0.111:5060;tag=xxx
Call-ID: xxx
CSeq: 19100 ACK
Content-Length:  0
  • SIP服务器主动发起tcp连接
相关推荐
止观止10 分钟前
实战演练:用现代 C++ 重构一个“老项目”
c++·实战·raii·代码重构·现代c++
草莓熊Lotso3 小时前
unordered_map/unordered_set 使用指南:差异、性能与场景选择
java·开发语言·c++·人工智能·经验分享·python·网络协议
咔咔咔的5 小时前
1930. 长度为 3 的不同回文子序列
c++
Cinema KI10 小时前
吃透C++继承:不止是代码复用,更是面向对象设计的底层思维
c++
Dream it possible!12 小时前
LeetCode 面试经典 150_二叉搜索树_二叉搜索树中第 K 小的元素(86_230_C++_中等)
c++·leetcode·面试
Bona Sun14 小时前
单片机手搓掌上游戏机(十四)—pico运行fc模拟器之电路连接
c语言·c++·单片机·游戏机
oioihoii14 小时前
性能提升11.4%!C++ Vector的reserve()方法让我大吃一惊
开发语言·c++
小狗爱吃黄桃罐头15 小时前
《C++ Primer Plus》模板类 Template 课本实验
c++
码力码力我爱你17 小时前
Harmony OS C++实战
开发语言·c++
Vect__17 小时前
别再只懂 C++98!C++11 这7个核心特性,直接拉开你与普通开发者的差距
c++