In the 2016 edition of GB28181, active tcp and passive tcp are added to the original UDP transmission for media streaming.
1. Transmission of UDP
This is a common transmission mode. When sending invite, the service terminal of GB28181 contains the port for receiving media in the SDP it carries. After receiving invite, the device terminal (called terminal) parses the port and sends the media stream to the port through UDP.
2.TCP passive
When sending invite, the service end of GB28181 contains the port for receiving media in the SDP it carries and listens for the media data of the port. After receiving invite, the device end (called end) parses the port and sends the media stream to the port through TCP.
3.TCP active
The device end (called end) tells the server its own media stream tcp port, and the server takes the initiative to connect the port of the device end (called end) to obtain data.
Based on the new 2016 version of GB28181 protocol, in addition to the traditional udp traffic, we also need to consider two ways of tcp active and tcp passive in the development of the device side. In the implementation of the code, we distinguish by the sdp carried by the invite of the server side. The code is as follows:
enum SYMediaProtocol { SYUdp = 0, //UDP transmission SYTcpActive, //tcp initiative SYTcpPassive //tcp passive }; SYMediaProtocol CGbtDeviceAgent::getMediaProtocol(const sstd::string szProtocol ) { SYMediaProtocol protocol = kUdp; if (szProtocol == MediaMedium::RTP_AVP_TCP || szProtocol == MediaMedium::TCP_RTP_AVP) { if (medium.setup == MediaMedium::active) { protocol = SYTcpActive; } else { protocol = SYTcpPassive; } } return protocol; }
We can judge the specific media streaming protocol after analyzing the sdp information. The following is the GB28181 message of the server and the device in the tcp active call. In order to highlight the key point and limit the space, only invite and 200OK messages are intercepted:
INVITE sip:53000000441329000515@120.229.43.100:14940 SIP/2.0 Via: SIP/2.0/UDP 106.58.169.248:5066;branch=z9hG4bK-524287-1---96235649734f9450;rport Max-Forwards: 70 Contact: <sip:11010200082006180524@106.58.169.248:5066> To: <sip:53000000441329000515@120.229.43.100:14940> From: <sip:11010200082006180524@106.58.169.248:5066>;tag=4452781c Call-ID: TReMwjEl4tWDd-O-uEJ9vw.. CSeq: 1 INVITE Subject: 53000000441329000515:0,11010200082006180524:0 Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, NOTIFY, SUBSCRIBE, INFO, MESSAGE, ACK, CANCEL, OPTIONS, MESSAGE, SUBSCRIBE, INVITE, REGISTER Content-Type: application/sdp Supported: timer, outbound, path, path, 100rel Content-Length: 190 v=0 o=53000000441329000515 0 0 IN IP4 106.58.169.248 s=Play c=IN IP4 106.58.169.248 t=0 0 m=video 20000 TCP/RTP/AVP 96 a=rtpmap:96 PS/90000 a=recvonly y=0999999999 a=setup:passive SIP/2.0 100 Trying Via: SIP/2.0/UDP 106.58.169.248:5066;branch=z9hG4bK-524287-1---96235649734f9450;rport=5066 From: <sip:11010200082006180524@106.58.169.248:5066>;tag=4452781c To: <sip:53000000441329000515@120.229.43.100:14940> Call-ID: TReMwjEl4tWDd-O-uEJ9vw.. CSeq: 1 INVITE User-Agent: GbtDeviceKit Content-Length: 0 SIP/2.0 200 OK Via: SIP/2.0/UDP 106.58.169.248:5066;branch=z9hG4bK-524287-1---96235649734f9450;rport=5066 From: <sip:11010200082006180524@106.58.169.248:5066>;tag=4452781c To: <sip:53000000441329000515@120.229.43.100:14940>;tag=1591516984 Call-ID: TReMwjEl4tWDd-O-uEJ9vw.. CSeq: 1 INVITE Contact: <sip:53000000441329000515@120.229.43.100:14940> Content-Type: Application/SDP User-Agent: GbtDeviceKit Content-Length: 216 v=0 o=53000000441319000515 0 0 IN IP4 192.168.137.180 s=Play c=IN IP4 192.168.137.180 t=0 0 a=setup:active m=video 12006 TCP/RTP/AVP 96 a=sendonly a=rtpmap:96 PS/90000 y=0999999999 f=v/2/15/2/524288/a/1/8 ACK sip:53000000441329000515@120.229.43.100:14940 SIP/2.0 Via: SIP/2.0/UDP 106.58.169.248:5066;branch=z9hG4bK-524287-1---38246b00e73cc219;rport Max-Forwards: 70 Contact: <sip:11010200082006180524@106.58.169.248:5066> To: <sip:53000000441329000515@120.229.43.100:14940>;tag=1591516984 From: <sip:11010200082006180524@106.58.169.248:5066>;tag=4452781c Call-ID: TReMwjEl4tWDd-O-uEJ9vw.. CSeq: 1 ACK Content-Length: 0
As can be seen from the above figure, TCP/RTP/AVP indicates that tcp is requested to transmit streaming media, and a=setup:active indicates active tcp. According to the content of sdp, you can clearly understand the three transmission modes of GB28181 media.
More information
e-mail: yujesoft@163.com
tel: 13971177602
web: www.founu.com