Technology decoding | GB28181/SIP/SDP protocol--EasyGBS national standard GB28181 platform national standard video technology SDP analysis

EasyGBS replaced its new kernel last year. The platform performance of the new kernel version is more stable. We are also constantly optimizing and upgrading the platform's functions to maintain the technological advancement of the EasyGBS platform in the security video surveillance market. EasyGBS has functions such as live video broadcast, video storage, retrieval and playback, PTZ control, alarm reporting, voice intercom, platform cascading, etc., and has a wide range of application scenarios, such as bright kitchens and stoves, beautiful countryside, snowy projects, etc.

SDP (Session Description Protocol) is a protocol used to describe multimedia sessions. It provides a standardized format for describing a session's media type, network transmission parameters, and other relevant information. SDP is typically used with the SIP protocol as part of the SIP message to transport session-related information.

SDP is mainly used in the following areas:

Media description: SDP can describe the type of media used in the session, such as audio, video, real-time text, etc. It can specify information such as the media's codec, transmission protocol, transmission address and port.

Session description: SDP can provide description information about the session, such as the name of the session, owner, participants, session start and end time, etc.

Media attributes: SDP can define media-related attributes, such as bandwidth requirements, media format support, etc.

SDP messages are in plain text format and are organized in lines. Each line contains a field and its corresponding value, separated by a colon (:).

The protocol format of SDP (Session Description Protocol) consists of multiple lines. Each line has a field and a corresponding value, separated by colons (:). The following is the basic format of the SDP protocol:

v=0
o=<username> <session_id> <session_version> <network_type> <address_type> <address>
s=<session_name>
t=<start_time> <end_time>
m=<media_type> <port> <transport_protocol> <format_list>
a=<attribute>
...

Among them, the meaning of each field is as follows:

  • v: protocol version number. Usually 0.
  • o: The owner and session identifier of the session. Including user name, session ID, session version number, network type, address type and address, etc.
  • s: The name of the session.
  • t: Time description of the session. Include the session's start time and end time.
  • m: description of the media. Including media type (such as audio, video), transmission port, transmission protocol and format list, etc.
  • a: Media-related attributes. Can include bandwidth requirements, media format support, etc.

SDP messages can contain multiple media descriptions (line m) and attributes (line a). Each media description is used to describe a media stream (such as an audio stream or a video stream), and each attribute is used to provide additional information related to a specific media stream.

SDP instance

# 请求视频流
INVITE sip:[email protected]:7100 SIP/2.0
Via: SIP/2.0/UDP 192.168.40.55:7100;rport;branch=z9hG4bK2480933505
From: <sip:[email protected]:7100>;tag=2249831759
To: <sip:[email protected]:7100>
Call-ID: 821763613                // Call-ID:使用该字段标识一路视频
CSeq: 20 INVITE
Contact: <sip:[email protected]:7100>
Content-Type: Application/SDP
Max-Forwards: 70
User-Agent: NCG V2.6.0.299938
Subject: 00000000001310018021:0,120105110228023020:0
Content-Length:   239

v=0
o=00000000001310018021 0 0 IN IP4 192.168.40.55
s=Play                        //Play标识为点播请求   Playback标识回播请求
c=IN IP4 192.168.40.55            //192.168.40.55:音视频流目的地址
t=0 0                        //t行第一参数为视频开始时间  第二个参数为结束时间    t = 0 0表示实时视音频点播
m=video 5552 RTP/AVP 96 97 98   //video:表示请求音视频流  audio:表示请求音频流  5522:音视频流目的端口  RTP/AVP:视频流使用协议 96 97 98:客户端支持码流格式
a=rtpmap:96 PS/90000
a=rtpmap:97 MPEG4/90000
a=rtpmap:98 H264/90000
a=recvonly
a=streamMode:MAIN
y=0999999999

# 返回100 trying
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 192.168.40.55:7100;rport=7100;branch=z9hG4bK2480933505
From: <sip:[email protected]:7100>;tag=2249831759
To: <sip:[email protected]:7100>
Call-ID: 821763613
CSeq: 20 INVITE
User-Agent: NCG V2.6.0.299938
Content-Length: 0

# 携带sdp返回 200
SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.40.55:7100;rport=7100;branch=z9hG4bK2480933505
From: <sip:[email protected]:7100>;tag=2249831759
To: <sip:[email protected]:7100>;tag=2885333649
Call-ID: 821763613
CSeq: 20 INVITE
Contact: <sip:[email protected]:7100>
Content-Type: Application/SDP
User-Agent: NCG V2.6.0.299938
Content-Length:   165

v=0
o=00000000001310018021 0 0 IN IP4 192.168.40.55
s=Play                
c=IN IP4 192.168.40.66    //192.168.40.66:音视频流源地址      注:视音频源与目的地址不局限于级联服务器本身
t=0 0
m=video 5268 RTP/AVP 96     // video:表示请求视频流  audio:表示请求音频流  5268:音视频流源端口  RTP/AVP:视频流使用协议 96:服务端所选择的码流格式   音视频所使用端口统一使用偶数端口   port+1为rtcp端口
a=rtpmap:96 PS/90000
a=sendonly
y=0100005268

SDP字段说明:

v字段:协议版本
o字段:-
a字段:a=rtpmap:<payload type> <encoding name>/<clock rate>  [/<encoding parameters>] 中的<encoding name>,利用该属性携带编码器厂商名称。该属性表明该流为某厂商编码器编码且是不符合gb28181规定的媒体流,符合国标的媒体流不需要该属性。
例如:a=rtpmap:96 DAHUA/90000
    a=rtpmap:96 HIKVISION/90000
a字段有下列格式:
a字段可携带倍数参数,用于文件下载时控制下载速度。格式: a=downloadspeed:下载倍数(整型)
a字段可携带文件大小参数,用于文件下载时的进度计算。格式: a=filesize:文件大小 (单位:Byte)
a字段可携带setup、connection作为TCP连接协商参数。 a=setup:TCP连接方式(表示本SDP发送者在建立RTP over TCP连接时是主动还是被动发起TCP连接,“active”为主动,“passive”为被动)
a字段可携带SVC参数,用于视频传输时的分辨率或者帧频控制。a=svcspace:空域编码方式 【取值整型。 0:不使用  1:1级增强  2:2级增强  3:3级增强 】  a = svctime:时域编码方式

s字段:表示请求媒体流的操作类型,“Play”标识为点播请求   “Playback”标识回播请求   “Download”表示文件下载  “Talk”表示语音对讲;
u字段:u行应填写视音频文件的URL。该URL的取值有两种:简捷方式和普通方式。简捷方式直接采用产生该历史媒体的媒体源(如某个摄像头)的设备ID以及相关参数,参数用“:”分隔;普通方式采样http://储存设备ID[/文件夹]*/文件名;
m字段:描述媒体的媒体类型、端口、传输层协议、负载类型等内容。媒体类型采样“video”标识视频或者视音频混合内容,采样“audio”标识传输音频内容;传输方式采用“RTP/AVP”标识传输层协议为 RTP over UDP,采用“TCP/RTP/AVP”标识传输层协议为RTP over TCP;
t字段:当回放或者下载时,t行值为开始时间,结束时间,采样“ ”分隔;
y字段:十进制整数字符串,标识SSRC值。其中第一位为历史或者实时媒体流的标识位,0为实时,1为历史;第2位到第6位取20位SIP监控域ID之中的4-8位作为域标识;第7-10位作为域内媒体流标识,是一个与当前域内产生的媒体流SSRC值后4位不充分的四位十进制整数;
f字段:f=v/编码格式/分辨率/帧率/码率类型/码率大小  a/编码格式/码率大小/采样率    其中v表示video   a表示audio

EasyGBS national standard video cloud service is a video capability platform based on the national standard GB/T28181 protocol. The video functions that can be realized include: real-time monitoring of live broadcast, recording, retrieval and playback, voice intercom, cloud storage, alarm, platform cascading and other functions. The platform is simple to deploy and highly scalable, and supports the distribution of accessed video streams to all terminals and all platforms. The distributed video streams include RTSP, RTMP, FLV, HLS, WebRTC and other formats.

Guess you like

Origin blog.csdn.net/EasyNTS/article/details/132813805