SDP 消息格式
在 SIP 协议详解 中提到过一种Sip body消息体格式message/sdp
,这一节来了解一下SDP消息格式。
- SDP(Session Description Protocol)是一种会话描述的数据格式
在 RFC4566 中有这样一断描述:SDP is purely a format for session description -- it does not incorporate a transport protocol, and it is intended to use different transport protocols as appropriate, including the SAP(Session Announcement Protocol) ,SIP(Session Initiation Protocol) , RTSP(Real Time Streaming Protocol) ,electronic mail using the MIME extensions, and the Hypertext Transport Protocol.
翻译过来大概是:SDP(Session Description Protocol)是一种纯粹的会话描述的格式。 SDP不是传输协议,信息传输上,其适当使用不用协议完成,包括:SAP,SIP,RTSP,HTTP,MIME协议扩展。
- SDP 通常用在会话初始化过程中,用来传送会话参与者的能力列表,以协调会话双方的各项参数。例如:媒体的种类为 audio 或 video ;媒体的编码方式(H.261 video、MPEG video 等) 。
SDP举例:
Session description
v=0
o=jdoe 2890844526 2890842807 IN IP4 10.47.16.5
s=SDP Seminar
i=A Seminar on the session description protocol
u=http://www.example.com/seminars/sdp.pdf
e=j.doe@example.com (Jane Doe)
c=IN IP4 224.2.17.12/127
t=2873397496 2873404696
a=recvonly
m=audio 49170 RTP/AVP 0
m=video 51372 RTP/AVP 99
a=rtpmap:99 h263-1998/90000
Time description
t=3034423619 3042462419
r=604800 3600 0 90000
Media description
m=video 49170/2 RTP/AVP 31
SDP协议的结构如下:
Session description
v= (protocol version)
o= (originator and session identifier)
s= (session name)
i=* (session information)
u=* (URI of description)
e=* (email address)
p=* (phone number)
c=* (connection information -- not required if included in
all media)
b=* (zero or more bandwidth information lines)
One or more time descriptions ("t=" and "r=" lines; see below)
z=* (time zone adjustments)
k=* (encryption key)
a=* (zero or more session attribute lines)
Zero or more media descriptions
Time description
t= (time the session is active)
r=* (zero or more repeat times)
Media description, if present
m= (media name and transport address)
i=* (media title)
c=* (connection information -- optional if included at
session level)
b=* (zero or more bandwidth information lines)
k=* (encryption key)
a=* (zero or more media attribute lines)
Session description
Type | 含义 | 解释 | 举例 |
---|---|---|---|
v | protocol version | SDP的版本号 | v=0 |
o | origion | 会话发起者的描述 | o={用户名}{session id} {会话版本} {网络类型}{地址类型}{地址} |
s | Session Name | 会话名,在整个会话中有且只有一个”s=” | s=SDP Seminar |
i | session information | 会话的文本描述信息 | i=A Seminar on the session description protocol |
u | URI | The URI should be a pointer to additional information about the session. | u=http://www.example.com/seminars/sdp.pdf |
e | Email Address and Phone Number | specify contact information for the person responsible for the conference | e=j.doe@example.com (Jane Doe) |
c | Connection Data | the connection type and address | c=IN IP4 224.2.17.12/127 |
b | Bandwidth | the proposed bandwidth to be used by thesession or media | c=IN IP4 224.2.17.12/127 |
Time description
Type | 含义 | 解释 | 举例 |
---|---|---|---|
t | Timing | specify the start and stop times for a session | t={开始时间} {结束时间} |
r | Repeat Times | specify repeat times for a session | r={重复间隔}{活动时长}{启动时间偏移} |
Media description
Type | 含义 | 解释 | 举例 |
---|---|---|---|
m | media name and transport address | m={media}{port}{proto}{fmt} | m=video 49170/2 RTP/AVP 31 |
参考
RFC4566:https://tools.ietf.org/html/rfc4566
SDP协议介绍:https://www.cnblogs.com/idignew/p/7249056.html