一、SDP協(xié)議介紹
SDP是會話描述協(xié)議的縮寫,是描述流媒體初始化參數(shù)的格式,由IETF作為RFC 4566頒布。流媒體是指在傳輸過程中看到或聽到的內(nèi)容,SDP包通常包括以下信息:
(1)會話信息
· 會話名和目的。
· 會話活動時間。
由于參與會話的資源是受限制的,因此包括以下附加信息是非常有用的。
· 會話使用的帶寬信息。
· 會話負責人的聯(lián)系信息。
(2)媒體信息
· 媒體類型,例如視頻和音頻。
· 傳輸協(xié)議,例如RTP/UDP/IP和H.320。
· 媒體格式,例如H.261視頻和MPEG視頻。
· 多播地址和媒體傳輸端口(IP多播會話)。
· 用于聯(lián)系地址的媒體和傳輸端口的遠端地址(IP單播會話)。
SDP描述由許多文本行組成,文本行的格式為<類型>=<值>,<類型>是一個字母,<值>是結(jié)構(gòu)化的文本串,其格式依<類型>而定。
二、SDP協(xié)議格式
SDP格式:
Session description
v= (protocol version)
o= (owner/creator 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)
以上帶"*"號的是可選的,其余的是必須的。一般順序也按照上面的順序來排列。
a=*是sdp協(xié)議擴展屬性定義,除上面以外的,分解時其它的都可以扔掉。
a=charset屬性指定協(xié)議使用的字符集。一般的是ISO-10646。
示例:
v=<username> <sess-id> <sess-version> <nettype> <addrtype> <unicast-address>
其中:nettype是IN,代表internet,addrtype是IP4或IP6。unicast-address任務(wù)創(chuàng)建計算機的地址。
整個這個屬性,是唯一表示一個任務(wù)。
e=123@126.com 或 p=+1 616 555-6011
對于一個任務(wù)只能兩者之中的一個,表示會議控制者的聯(lián)系方式。郵件地址可以是[email]j.doe@example.com[/email] (Jane Doe)形式,括號里面的是描述聯(lián)系人的名稱,或者Jane Doe <[email]j.doe@example.com[/email]>,前面的是聯(lián)系人的名稱。
c=<nettype> <addrtype> <connection-address>
這個連接數(shù)據(jù),可以是傳話級別的連接數(shù)據(jù),或者是單獨一個媒體數(shù)據(jù)的連接數(shù)據(jù)。在是多播時,connection-address就該是一個多播組地址, 當是單播時,connection-address就該是一個單播地址。對于addrtype是IP4的情況下,connection-address不 僅包含IP地址,并且還要包含a time to live value(TTL 0-255),如:c=IN IP4 224.2.36.42/128,IP6沒有這個TTL值。還允許象這樣的<base multicast address>[/<ttl>]/<number of addresses>格式的connection-address。如:c=IN IP4 224.2.1.1/127/3等同于包含c=IN IP4 224.2.1.1/127, c=IN IP4 224.2.1.2/127, c=IN IP4 224.2.1.3/127三行內(nèi)容。
b=<bwtype>:<bandwidth> bwtype可以是CT或AS,CT方式是設(shè)置整個會議的帶寬,AS是設(shè)置單個會話的帶寬。缺省帶寬是千比特每秒。
t=<start-time> <stop-time>,這個可以有行,指定多個不規(guī)則時間段,如果是規(guī)則的時間段,則r=屬性可以使用。start-time和stop- time都遵從NTP(Network Time Protocol),是以秒為單位,自從1900以來的時間。要轉(zhuǎn)換為UNIX時間,減去2208988800。如果stop-time設(shè)置為0,則會話 沒有時間限制。如果start-time也設(shè)置為0,則會話被認為是永久的。
r=<repeat-interval> <active duration> <offsets from start-time>重復(fù)次數(shù)在時間表示里面可以如下表示:
d - days (86400 seconds)
h - hours (3600 seconds)
m - minutes (60 seconds)
s - seconds (allowed for completeness)
z=<adjustment time> <offset> <adjustment time> <offset> ....
k=<method>
k=<method>:<encryption key>
a=<attribute>
a=<attribute>:<value>
m=<media> <port> <proto> <fmt> ...
m=<media> <port>/<number of ports> <proto> <fmt> ...
其中:<media>可以是,"audio","video", "text", "application" and "message"。<port>是媒體傳送的端口號,它依賴于c=和<proto>。<proto> 可以是,udp,RTP/AVP和RTP/SAVP。
a=cat:<category>分類,根據(jù)分類接收者隔離相應(yīng)的會話
a=keywds:<keywords>關(guān)鍵字,根據(jù)關(guān)鍵字隔離相應(yīng)的會話
a=tool:<name and version of tool>創(chuàng)建任務(wù)描述的工具的名稱及版本號
a=ptime:<packet time>在一個包里面的以毫秒為單位的媒體長度
a=maxptime:<maximum packet time>以毫秒為單位,能夠壓縮進一個包的媒體量。
a=rtpmap:<payload type> <encoding name>/<clock rate> [/<encoding parameters>]
a=recvonly
a=sendrecv
a=sendonly
a=inactive,
a=orient:<orientation>其可能的值,"portrait", "landscape" and "seascape" 。
a=type:<conference type>,建議值是,"broadcast", "meeting", "moderated", "test" and "H332"。
a=charset:<character set>
a=sdplang:<language tag>指定會話或者是媒體級別使用的語言
a=framerate:<frame rate>設(shè)置最大視頻幀速率
a=quality:<quality>值是0-10
a=fmtp:<format> <format specific parameters>
在SIP協(xié)議的包含的內(nèi)容是SDP時,應(yīng)該把Content-Type設(shè)置成application/sdp。