SDP 會話描述協議概述

1.概述
SDP也是MMUSIC工作組的一個產品,在MBONE內容中用得很多。其目的就是在媒體會話中,傳遞媒體流信息,允許會話描述的接收者去參與會話。SDP基本上在internet上工作。他定義了會話畫描述的統一格式,但並不定義多播地址的分配和SDP消息的傳輸,也不支持媒體編碼方案的協商,這些功能均由下層傳送協議完成.典型的會話傳送協議包括:SAP(Session Announcement Protocol 會話公告協議),SIP,RTSP,HTTP,和使用MIME的E-Mail.(注意:對SAP只能包含一個會話描述,其它會話傳誦協議的SDP可包含多個繪畫描述)

SDP包括以下一些方面:
1)會話的名稱和目的
2)會話存活時間
3)包含在會話中的媒體信息,包括:
    媒體類型(video, audio, etc)
    傳輸協議(RTP/UDP/IP, H.320, etc)
    媒體格式(H.261 video, MPEG video, etc)
    多播或遠端(單播)地址和端口
4)爲接收媒體而需的信息(addresses, ports, formats and so on)
5)使用的帶寬信息
6)可信賴的接洽信息(Contact information)
7)等。。。

2.協議:
Session description                 //格式及舉例
v=  (protocol version)              //v=0
o=  (owner/creator and session identifier).   
                                                                        //o=<用戶名><會話id><版本><網絡類型><地址類型><地址>
                                                                //o=sname 1234567890 0987654321 I IP4 126.15.64.3
s=  (session name)                  //會話名
i=* (session information)           //會話信息
u=* (URI of description)            //u=http://www.zte.com.cn/staff/sdp.ps
e=* (email address)                 //[email protected](general text如:王生)
                                    //或e=Mr. Wang<[email protected]>
p=* (phone number)                  //p=+86-0755-26773000-7110(wang) or p=+1 617 253 6011
c=* (connection information -如已經包含在所有媒體中則該行不需要)
                                    //c=<網絡類型><地址信息><連接地址>
                                    //多點會議包括TTL
                                    //連接地址: <base multicast address>/<ttl>/<number of addresses>
                                                                        //c=IN IP4 224.2.13.23/127
                                    //c=IN IP4 224.2.1.1/127/3
b=* (bandwidth information)         //b=<修改量(CT Conference Total
                                                                        //IAS Application-specific Max)>:<帶寬值(kb/s)>
                                                                        //b=CT:120

One or more time descriptions (see below)
z=* (time zone adjustments)         //時區調整
k=* (encryption key)                //k=<方法>:<密鑰>或k=<方法>
a=* (zero or more session attribute lines)     
                                                                        //a=<屬性>  或a=<屬性>:<值>
                                                                        
Zero or more media descriptions (see below)     
各行嚴格按順序,其中:
時間描述:
t=  (time the session is active)    //<開始時間><結束時間>,單位秒,十進制NTP
                                                                        //t=2873397468 2873404969
r=* (zero or more repeat times)     //<重複時間><活動持續時間以開始時刻爲參考的偏移列表>單位秒
                                                                        //r=604800 3666 90000 或寫成r=7d 1h 0 25h

媒體描述:
m=  (media name and transport address)    
                                                                        //m=<媒體><端口><傳送><格式列表>
                                    //m=audio 49170 RTP/AVP 0 3
                                    //協議爲RTP,剖面爲AVP
                                    //參考rtp-parameters.txt
i=* (media title)                           //媒體稱呼
c=* (connection information – 如已經包含在會話級描述則爲可選)
b=* (bandwidth information)         //同c
k=* (encryption key)                //會話級爲摸認值,同c
a=* (zero or more media attribute lines)              
                                                                        //兩種形式:(也同c)(見後說明)
                                    //a=<attribute>如:
                                    //     a=recvonly
                                    //a=<attribute>:<value>
注:v,o,s,t,m爲必須的,其他項爲可選。
         如果SDP語法分析器不能識別某一類型(Type),則整個描述丟失;
         如果”a=”的某屬性值不理解,則予以丟失
         整個協議區分大小寫
         “=”兩側不允許有空格
         會話級的描述就是媒體級描述的缺省值
         所有均格式爲<type>=<value>
        An example SDP description is:

        v=0
        o=mhandley 2890844526 2890842807 IN IP4 126.16.64.4
        s=SDP Seminar
        i=A Seminar on the session description protocol
        u=http://www.cs.ucl.ac.uk/staff/M.Handley/sdp.03.ps
        [email protected] (Mark Handley)
        c=IN IP4 224.2.17.12/127
        t=2873397496 2873404696
        a=recvonly
        m=audio 49170 RTP/AVP 0
        m=video 51372 RTP/AVP 31
        m=application 32416 udp wb
        a=orient:portrait
//////////////////////////////////////////////////////////    
Protocol Version
      v=<version>        
//  v=0
      v:該SDP協議的版本號

Origin
   o=<username> <session id> <version> <network type> <address type><address>
// o=mhandley 2890844526 2890842807 IN IP4 126.16.64.4 
   o:標示了該會話的全局唯一性
   <username>:用於登陸創建主機的ID,若該主機不支持側應爲"-",該字段內不能包含空格
   <session id>:用於唯一的標示該會話描述,建議採用Network Time Protocol (NTP)的時間戳來保證唯一性
   <version>:該公告的版本號,用於區別同個會話內的多個公告
   <network type>:網絡類型 IN(Internet)
   <address type>:地址類型 IP4/IP6
   <address>:該會話創建者的地址

Session Name
   s=<session name>
// s=SDP Seminar
   s:會話名,每個會話僅有一個

Session and Media Information
   i=<session description>
// i=A Seminar on the session description protocol
   i:會話信息,每個會話至多有一個,每個媒體至多有一個,常用於標識一個會話內多個同類型的媒體流。
   
URI
   u=<URI>
// u=http://www.cs.ucl.ac.uk/staff/M.Handley/sdp.03.ps
   u:該會話的URI(Universal Resource Identifier)地址

Email Address and Phone Number
   e=<email address>
   p=<phone number>
   e/p:添加會話負責人的私人信息
//   EMAIL地址格式:[email protected] (Mark Handley) or e=Mark Handley <[email protected]>
//   電話號碼的格式:p=+44-171-380-7777 or p=+1 617 253 6011

Connection Data
   c=<network type> <address type> <connection address>
// c=IN IP4 224.2.17.12/127
   c:連接數據,每個會話公告應包含一個連接描述在每個媒體描述中,
   單播的時候通過該IP地址發送,多播時通過TTL與IP地址共同決定那些包將被髮送
   <connection address>:IP addr/TTL[/IP NUMS] example:192.168.1.2/127[/2],單播[多播]
   IP address together with TTL define which muticast pakets will be
   sent in this conference.
   
Bandwidth
   b=<modifier>:<bandwidth-value>
//....
     b:提供此次會話的帶寬
     <modifier>:修改量
     CT Conference Total:固有的最大帶寬值與多播骨幹網的TTL值或一個特指的多播範圍區相關連
     如果某一會話或媒體的帶寬與最大帶寬值不同,則通過該參數提供一個最大的限定值。該參數指定多個媒體總和的值。
     AS Application-Specific Maximum:該參數指定一個特殊應用的帶寬,指定單一媒體的值。
  Extension Mechanism:X-..擴展的帶寬定義

Times, Repeat Times and Time Zones
   t=<start time>  <stop time> 
// t=2873397496 2873404696
     t:描述該會議的開始和結束時間,如果該會議在多個不規則的時間間隔內激活,可以使用多行t:描述
     如果時間間隔爲規則的,可以使用"r="重複定義。
     <start time>:開始時間,以秒錶示的NTP時間,開始結束時間都爲0時被認爲時永久的會議
     <stop time>:結束時間,以秒錶示的NTP時間,結束時間爲0時,該會議直到過了開始時間纔開始
     
     r=<repeat interval> <active duration> <list of offsets from start-time>
     <repeat interval>:重複間隔
     <active duration>:持續時間
     <list of offsets from start-time>:相對開始時間的偏移
     
     z=<adjustment time> <offset> <adjustment time> <offset> ....
// z=2882844526 -1h 2898848070 0
     z:<調整時間> <偏移>

Encryption Keys
   k=<method>
   k=<method>:<encryption key>
   
   k=clear:<encryption key> //<加密密鑰>密鑰沒有變換
   k=base64:<encoded encryption key> //經base64加密的密鑰,因爲它含有SDP禁用的字符
   k=uri:<URI to obtain key> //URI攜帶密鑰
   k=prompt //不採用密碼,SDP沒有提供密鑰但該會話或媒體流是要求加密的。
   
Attributes  //該描述常被用於擴展SDP協議,分成“會話級”和“媒體級”兩種屬性
   a=<attribute>
   a=<attribute>:<value>
// a=recvonly
// a=orient:portrait
   a:媒體描述具備任意個“媒體級”的屬性,用於附加表示媒體流的信息
   屬性也可以被加在第一個媒體域,這些“會話級”屬性用於附帶表示會議的信息
   屬性域一般有兩種格式:
   <attribute>:性質屬性,描述當前會話的性質
   <value>:
   
Media Announcements
   m=<media> <port> <transport> <fmt list>
   每個會話可以包含許多的媒體描述,
   <media>:媒體類型,包括audio/video/application/data/control,
   (音頻/視頻/應用[如:白板信息]/數據[不要向用戶顯示]/控制)
   當有新的媒體類型出項時,這些值將被擴展。
   <port>:端口類型,該值的確定取決於對應的"c="域中指定的網絡
   和在第三個子項中定義的傳輸協議,UDP端口只能在1024-65535之間
   RTP端口可以是任意有效的範圍,RTCP端口定義爲大於對應RTP端口的奇數
   當分級的多個媒體流編碼通過單一的地址發送時,我們必須指定多個端口用於傳輸。
   採用跟"c="域中定義多個IP地址的格式一樣,
   m=<media> <port>/<number of ports> <transport> <fmt list>
   example:  m=video 49170/2 RTP/AVP 31
   定義了兩對的RTP/RTCP端口,49170 19171和49172 49173
   <transport>:傳輸協議類型,該項的值依賴於"c="域中的網絡類型
   IP4 
   如果某個應用採用在UDP上使用單一組合了所
   有媒體格式和傳輸協議的模式傳輸,簡單的方法是將傳輸協議指定爲UDP,
   採用格式列表區別組合的協議,區別傳輸類型和媒體格式是必要的。
   
   <fmt list>:格式列表,對音頻和視頻應用,該值表示媒體的有效負荷類型
   一旦這個格式列表被限定,在這個會話過程中都將使用列表裏面的有效負荷類型
   ,但第一個類型將被作爲默認值。
   如果媒體流的傳輸模式不是RTP/UDP,格式將在附加的文件中進行定義。
   如果通過RTP傳輸,SDP可以提供靜態和動態綁定的兩種RTP編碼有效負荷類型。
   靜態綁定類型的類型值提供確定的有效負荷類型,動態綁定必須通過後續的選項
   來進一步的說明。
   例如:m=video 49232 RTP/AVP 0 //定義負荷類型爲0的媒體流從49232端口發送
                m=video 49232 RTP/AVP 98
         a=rtpmap:98 L16/16000/2 //採用採樣頻率爲16KHZ 16bit的立體聲線性編碼
         
     rtpmap屬性對"m="描述的格式列表的負荷類型進行詳細說明,
     通用的rtpmap屬性的格式爲:
     a=rtpmap:<payload type> <encoding name>/<clock rate>[/<encoding parameters>]
     <payload type> 
     <encoding name>:編碼名,擴展的用X-開始
     <clock rate>:採樣頻率
     <encoding parameters>:對語音編碼來說,該參數表示語音聲道。
     對視頻編碼不提供該參數。
     RTP格式列表沒提供對每個媒體包包括幾個採樣點進行說明,
     如果沒有默認值,需要通過"ptime"說明。
     
     非RTP媒體採用MIME文本類型編碼,如:m=application 32416 udp wb

Suggested Attributes
推薦的屬性
   a=cat:<category>
   cat:描述離散分級的會話類型,使接受者通過該參數過率不想要的會話類型

   a=keywds:<keywords>
   keywds:該參數輔助接收者根據關鍵字過慮會話,鑑別想要會話類型。
   
   a=tool:<name and version of tool>
   tool:該參數提供給SDP創建者名字和版本號。

   a=ptime:<packet time>
   ptime:該參數提供一個以毫秒爲單位的打包長度,媒體級屬性
 
   a=recvonly
   a=sendrecv
   a=sendonly
     發送模式,會話級屬性。
     
   a=orient:<whiteboard orientation>
   該參數指定白板應用中屏幕的方向性,
   允許值爲`portrait',`landscape' and `seascape' (upside down landscape).

   a=type:<conference type>
   該參數指定會議類型,
   允許值爲:`broadcast', `meeting', `moderated', `test' and `H332'.
   broadcast會話默認爲recvonly
   meeting默認sendrecv
   
   a=charset:<character set>
   該參數指定會話名和信息值的字符集
   a=charset:ISO-8859-1
   
   a=sdplang:<language tag>
   描述該會話的描述的語言

   a=lang:<language tag> "session-level" and "media-level"
   SDP描述使用的語言,媒體的語言

   a=framerate:<frame rate>
   該參數描述視頻的最大幀數(frames/sec),允許(整數.小數)格式

   a=quality:<quality>
   該參數用0-10的整數值描述建議的編碼質量,
   對視頻來說爲了在幀速率和持續圖像質量間指定一個非默認的平衡值 
       10 - 最佳圖像質量

       5 - 無質量建議

       0 - 最差圖像質量

   a=fmtp:<format> <format specific parameters>
   該屬性值指定一個SDP不瞭解的特殊格式,該格式是媒體的格式的一種。  
   定義指定格式的附加參數   
3.語法
announcement =        proto-version
                         origin-field
                         session-name-field
                         information-field
                         uri-field
                         email-fields
                         phone-fields
                         connection-field
                         bandwidth-fields
                         time-fields
                         key-field
                         attribute-fields
                         media-descriptions

   proto-version =       "v=" 1*DIGIT CRLF
                         ;this memo describes version 0
   origin-field =        "o=" username space
                         sess-id space sess-version space
                         nettype space addrtype space
                         addr CRLF
   session-name-field =  "s=" text CRLF
   information-field =   ["i=" text CRLF]
   uri-field =           ["u=" uri CRLF]
   email-fields =        *("e=" email-address CRLF)
   phone-fields =        *("p=" phone-number CRLF)
   connection-field =    ["c=" nettype space addrtype space
                         connection-address CRLF]
                         ;a connection field must be present
                         ;in every media description or at the
                         ;session-level
   bandwidth-fields =    *("b=" bwtype ":" bandwidth CRLF)
   time-fields =         1*( "t=" start-time space stop-time
                         *(CRLF repeat-fields) CRLF)
                         [zone-adjustments CRLF]
   repeat-fields =       "r=" repeat-interval space typed-time
                         1*(space typed-time)
   zone-adjustments =    time space ["-"] typed-time
                         *(space time space ["-"] typed-time)
   key-field =           ["k=" key-type CRLF]
   key-type =            "prompt" |
                         "clear:" key-data |
                         "base64:" key-data |
                         "uri:" uri
   key-data =            email-safe | "~" | "
   attribute-fields =    *("a=" attribute CRLF)
   media-descriptions =  *( media-field
                         information-field
                         *(connection-field)
                         bandwidth-fields
                         key-field
                         attribute-fields )
   media-field =         "m=" media space port ["/" integer]
                         space proto 1*(space fmt) CRLF
   media =               1*(alpha-numeric)
                         ;typically "audio", "video", "application"
                         ;or "data"
   fmt =                 1*(alpha-numeric)
                         ;typically an RTP payload type for audio
                         ;and video media
   proto =               1*(alpha-numeric)
                         ;typically "RTP/AVP" or "udp" for IP4
   port =                1*(DIGIT)
                         ;should in the range "1024" to "65535" inclusive
                         ;for UDP based media
   attribute =           (att-field ":" att-value) | att-field
   att-field =           1*(alpha-numeric)
   att-value =           byte-string
   sess-id =             1*(DIGIT)
                         ;should be unique for this originating username/host
   sess-version =        1*(DIGIT)
                         ;0 is a new session
   connection-address =  multicast-address
                         | addr
   multicast-address =   3*(decimal-uchar ".") decimal-uchar "/" ttl
                         [ "/" integer ]
                         ;multicast addresses may be in the range
                         ;224.0.0.0 to 239.255.255.255
   ttl =                 decimal-uchar
   start-time =          time | "0"
   stop-time =           time | "0"
   time =                POS-DIGIT 9*(DIGIT)
                         ;sufficient for 2 more centuries
   repeat-interval =     typed-time
   typed-time =          1*(DIGIT) [fixed-len-time-unit]
   fixed-len-time-unit = "d" | "h" | "m" | "s"
   bwtype =              1*(alpha-numeric)
   bandwidth =           1*(DIGIT)
   username =            safe
                         ;pretty wide definition, but doesn't include space
   email-address =       email | email "(" email-safe ")" |
                         email-safe "<" email ">"
   email =               ;defined in RFC822
   uri=                  ;defined in RFC1630
   phone-number =        phone | phone "(" email-safe ")" |
                         email-safe "<" phone ">"
   phone =               "+" POS-DIGIT 1*(space | "-" | DIGIT)
                         ;there must be a space or hyphen between the
                         ;international code and the rest of the number.
   nettype =             "IN"
                         ;list to be extended
   addrtype =            "IP4" | "IP6"
                         ;list to be extended
   addr =                FQDN | unicast-address
   FQDN =                4*(alpha-numeric|"-"|".")
                         ;fully qualified domain name as specified in RFC1035
   unicast-address =     IP4-address | IP6-address
   IP4-address =         b1 "." decimal-uchar "." decimal-uchar "." b4
   b1 =                  decimal-uchar
                         ;less than "224"; not "0" or "127"
   b4 =                  decimal-uchar
                         ;not "0"
   IP6-address =         ;to be defined
   text =                byte-string
                         ;default is to interpret this as IS0-10646 UTF8
                         ;ISO 8859-1 requires a "a=charset:ISO-8859-1"
                         ;session-level attribute to be used
   byte-string =         1*(0x01..0x09|0x0b|0x0c|0x0e..0xff)
                         ;any byte except NUL, CR or LF
   decimal-uchar =       DIGIT
                         | POS-DIGIT DIGIT
                         | ("1" 2*(DIGIT))
                         | ("2" ("0"|"1"|"2"|"3"|"4") DIGIT)
                         | ("2" "5" ("0"|"1"|"2"|"3"|"4"|"5"))
   integer =             POS-DIGIT *(DIGIT)
   alpha-numeric =       ALPHA | DIGIT
   DIGIT =               "0" | POS-DIGIT
   POS-DIGIT =           "1"|"2"|"3"|"4"|"5"|"6"|"7"|"8"|"9"
   ALPHA =               "a"|"b"|"c"|"d"|"e"|"f"|"g"|"h"|"i"|"j"|"k"|
                         "l"|"m"|"n"|"o "|"p"|"q"|"r"|"s"|"t"|"u"|"v"|
                         "w"|"x"|"y"|"z"|"A"|"B"|"C "|"D"|"E"|"F"|"G"|
                         "H"|"I"|"J"|"K"|"L"|"M"|"N"|"O"|"P"|" Q"|"R"|
                         "S"|"T"|"U"|"V"|"W"|"X"|"Y"|"Z"
   email-safe =          safe | space | tab
   safe =                alpha-numeric |
                         "'" | "'" | "-" | "." | "/" | ":" | "?" | """ |
                         "#" | "$" | "&" | "*" | ";" | "=" | "@" | "[" |
                         "]" | "^" | "_" | "`" | "{" | "|" | "}" | "+" |
                         "~" | "
   space =               %d32
   tab =                 %d9
   CRLF =                %d13.10

 

常見的如下:

a=rtpmap:103 ISAC/16000
a=rtpmap:102 iLBC/8000
a=rtpmap:3 GSM/8000
a=rtpmap:106 telephone-event/8000
a=rtpmap:13 CN/8000
a=rtpmap:117 red/8000
a=rtpmap:18 G729a/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:2 G726-32/8000
a=rtpmap:4 G723/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:96 G726-40/8000
a=rtpmap:97 G726-24/8000
a=rtpmap:98 G726-16/8000
a=rtpmap:100 NSE/8000
a=rtpmap:101 telephone-event/8000
a=rtpmap:0 pcmu/8000
a=rtpmap:8 pcma/8000
a=rtpmap:3 gsm/8000
a=rtpmap:18 G729/8000
a=rtpmap:98 iLBC/8000
a=rtpmap:97 speex/8000
a=rtpmap:101 telephone-event/8000

發佈了41 篇原創文章 · 獲贊 4 · 訪問量 22萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章