SDP格式


抄錄:Webrtc SDP格式解讀-https://blog.csdn.net/m0_37263637/article/details/96355737

SDP組成結構

                                                 +---------------------+
                                                 |        v=           |
                                                 +---------------------+
                 +---------------------+         +---------------------+
         ====    |   Session Metadata  |  =====  |        o=           |
         |       +---------------------+         +----------------------
         |                                       +---------------------+
         |                                       |        t=           |
         |                                       +---------------------+
         |
         |
         |                                       +---------------------+
         |                                       |        c=           |
         |                                       +---------------------+
         |       +---------------------+
         ====    | Network Description |   =====
         |       +---------------------+
         |                                       +---------------------+
         |                                       |    a=candidate      |
         |                                       +---------------------+
         |
         |
         |                                       +---------------------+
         |                                       |        m=           |
         |                                       +---------------------+
         |        +---------------------+        +---------------------+
         ====     | Stream Description  |  ===== |      a=rtpmap       |
         |        +---------------------+        +----------------------
         |                                       +---------------------+
         |                                       |      a=fmtp         |
         |                                       +---------------------+
         |                                       +---------------------+
         |                                       |      a=sendrecv..   |
         |                                       +---------------------+
 +---------------+
 |    SEMANTIC   |
 | COMPONENTS OF |
 |     SDP       |
 +---------------+
         |                                       +---------------------+
         |                                       |      a=crypto       |
         |                                       +---------------------+
         |         +---------------------+       +---------------------+
         ====      |Security Descriptions|  =====|      a=ice-frag     |
         |         +---------------------+       +----------------------
 				 |                               +---------------------+
         |                                       |      a=ice-pwd      |
         |                                       +---------------------+
         |                                       +---------------------+
         |                                       |     a=fingerprint   |
         |                                       +---------------------+
         |
         |
         |
         |                                       +---------------------+
         |                                       |      a=rtcp-fb      |
         |                                       +---------------------+
         |         +---------------------+       +---------------------+
         ====      |   Qos,Grouping      |       |                     |
                   |   Descriptions      |  =====|       a=group       |
                   +---------------------+       +----------------------
                                                 +---------------------+
                                                 |       a=rtcpmux     |
                                                 +---------------------+

參數解讀

//---------------------- Session Metadata -------------------//
// v = 0  “v =”字段給出SDP的版本,默認為0。
v=0

// o = <username> <sess-id> <sess-version> <nettype> <addrtype> <unicast-address> 
// <username> 是用戶在始發主機上的登錄名
// <sess-id> <sess-id>是一個數字字符串,使得<username><sess-id>nettype><addrtype>和<unicast-address>的元組形成會話的全局唯一標識符。
// <sess-version>是此會話描述的版本號 
// <nettype>是一個給出網絡類型的文本字符串。 “IN”被定義為具有“Internet”的含義
// <addrtype>是一個文本字符串,給出了后面的地址類型 定義了“IP4”和“IP6”
// <unicast-address>是創建會話的計算機的地址。   
o=mozilla...THIS_IS_SDPARTA-67.0.4 7082731800936198286 0 IN IP4 0.0.0.0

// s = <會話名稱>  “s =”字段是文本會話名稱.每個會話描述必須有一個且只有一個“s =”字段。“s =”字段不能為空
s=-

//t =<start-time> <stop-time>“t =”行指定會話的開始和停止時間。如果<stop-time>設置為零,則會話不受限制,但在<start-time>之后才會生效。如果<start-time>也為零,則會話被視為永久會話。
t=0 0
//********************* Session Metadata ********************//


//---------------------- Security Descriptions-------------------//
//a = <attribute>:<value> 
//a = <fingerprint> SRIP 所需的DTLS指紋信息
a=fingerprint:sha-256 16:9A:59:1B:25:91:DD:C3:4D:B6:22:AB:36:0E:74:1A:F0:C1:62:0B:7F:7D:D3:08:93:13:83:B0:A9:4D:94:E7

//Negotiating Media Multiplexing Using the Session Description Protocol
//表示需要共用一個傳輸通道傳輸的媒體,通過ssrc進行區分不同的流。如果沒有這一行,音視頻數據就會分別用單獨udp端口來發送.
a=group:BUNDLE 0 1 2

//Trickle ICE:Incremental Provisioning of Candidates for the Interactive Connectivity Establishment (ICE) Protocol
//ICE建立候選時 采用增量設置的方式
a=ice-options:trickle

//WebRTC MediaStream Identification in the Session Description Protocol
//標識SDP中包含MediaStream的標識
a=msid-semantic:WMS *
//********************* Security Descriptions ********************//


//---------------------- Stream Description -------------------//
// m=<media> <port> <proto> <fmt> ...
//<media>是媒體類型 當前定義的媒體 "audio","video", "text", "application", and "message"
//<port>是傳輸媒體流的傳輸端口。在相關的“c =”字段中指定,以及在媒體字段的<proto>子字段中定義的傳輸協議。
//<proto>是傳輸協議。傳輸協議的含義取決於相關“c =”字段中的地址類型字段。
//<fmt>是媒體格式描述(編碼類型)。第四個和任何后續 如果<proto>子字段是“RTP / AVP”或“RTP / SAVP”,則<fmt> 子字段包含RTP有效載荷類型號。
m=audio 9 UDP/TLS/RTP/SAVPF 109 9 0 8 101

// c=<nettype> <addrtype> <connection-address>
// 會話描述必須包含 每個媒體描述中的至少一個“c =”字段或會話級別的單個“c =”字段
// <nettype>   “IN”被定義為具有“Internet”的含義
// <addrtype> 為IP4和IP6時
c=IN IP4 0.0.0.0
//a = sendrecv 這指定應以發送和接收模式啟動工具。對於具有默認為僅接收模式的工具的交互式會議,這是必需的。
a=sendrecv

//   The URI for declaring this header extension in an extmap attribute is "urn:ietf:params:rtp-hdrext:ssrc-audio-level".
a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level
a=extmap:2/recvonly urn:ietf:params:rtp-hdrext:csrc-audio-level
a=extmap:3 urn:ietf:params:rtp-hdrext:sdes:mid

//a=fmtp:<format> <format specific parameters> 用於傳遞特殊參數
// 此屬性允許以SDP不必理解的方式傳達特定於特定格式的參數。格式必須是為媒體指定的格式之一。格式特定參數可以是SDP要求傳達的任何參數集,
a=fmtp:109 maxplaybackrate=48000;stereo=1;useinbandfec=1
a=fmtp:101 0-15

//---------------------- Security Descriptions-------------------//
a=ice-pwd:141cd92cd90d3f5c446004c3404b13c7
a=ice-ufrag:33748035
a=mid:0
a=msid:{15d330d9-3078-4727-b51e-cdc8a2554dd1} {435405e5-84b9-49bb-85a3-9d06b16970f7}
//********************* Security Descriptions ********************//


//"a = rtcp-mux"屬性以指示需要RTP和RTCP多路復用
a=rtcp-mux
//rtpmap:<payload type> <encoding name> / <clock rate> [/ <encoding parameters>]
//<payload type> 此屬性從RTP有效內容類型編號(在 “m =”行中使用)映射到表示要使用的有效載荷格式,編碼類型 采樣率 編碼參數
a=rtpmap:109 opus/48000/2
a=rtpmap:9 G722/8000/1
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000/1

//DTLS 握手方式 "active" / "passive" / "actpass"/ "holdconn"   'actpass': 連接或啟動傳出連接。
a=setup:actpass
//同步源(SSRC)標識符識別SDP,將屬性與這些來源相關聯
//新的SDP媒體級屬性“ssrc”,用於標識特定的屬性RTP會話中的同步源並充當元數據屬性將源級屬性信息映射到這些源
a=ssrc:2040182694 cname:{eee1aa1e-411a-47d5-98ad-b26dc639bc67}


m=video 9 UDP/TLS/RTP/SAVPF 120 121 126 97
c=IN IP4 0.0.0.0
a=sendrecv

a=extmap:3 urn:ietf:params:rtp-hdrext:sdes:mid
a=extmap:4 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
a=extmap:5 urn:ietf:params:rtp-hdrext:toffset

a=fmtp:126 profile-level-id=42e01f;level-asymmetry-allowed=1;packetization-mode=1
a=fmtp:97 profile-level-id=42e01f;level-asymmetry-allowed=1
a=fmtp:120 max-fs=12288;max-fr=60
a=fmtp:121 max-fs=12288;max-fr=60

//---------------------- Security Descriptions-------------------//
a=ice-pwd:141cd92cd90d3f5c446004c3404b13c7
a=ice-ufrag:33748035

a=mid:1
a=msid:{15d330d9-3078-4727-b51e-cdc8a2554dd1} {47004068-3cac-4ee8-87df-2cdf02ae0921}
//---------------------- Security Descriptions-------------------//



//a = rtcp-fb: RTCP-FB-PT SP RTCP-FB-VAL CRLF
//rtcp-fb-pt是有效負載類型
///rtcp-fb-val定義反饋消息的類型 ack,nack,trr-int和rtcp-fb-id
a=rtcp-fb:120 nack
a=rtcp-fb:120 nack pli
a=rtcp-fb:120 ccm fir
a=rtcp-fb:120 goog-remb
a=rtcp-fb:121 nack
a=rtcp-fb:121 nack pli
a=rtcp-fb:121 ccm fir
a=rtcp-fb:121 goog-remb
a=rtcp-fb:126 nack
a=rtcp-fb:126 nack pli
a=rtcp-fb:126 ccm fir
a=rtcp-fb:126 goog-remb
a=rtcp-fb:97 nack
a=rtcp-fb:97 nack pli
a=rtcp-fb:97 ccm fir
a=rtcp-fb:97 goog-remb


a=rtcp-mux
//rtpmap:<payload type> <encoding name> / <clock rate> [/ <encoding parameters>]
//<payload type> 此屬性從RTP有效內容類型編號(在 “m =”行中使用)映射到表示要使用的有效載荷格式,編碼類型 采樣率 編碼參數
//而以下格式的編碼的格式要去相應編碼格式標准文檔中查看 比如H264 就是RFC3984 https://tools.ietf.org/html/rfc3984
a=rtpmap:120 VP8/90000
a=rtpmap:121 VP9/90000
a=rtpmap:126 H264/90000
a=rtpmap:97 H264/90000

a=setup:actpass
a=ssrc:1381656291 cname:{eee1aa1e-411a-47d5-98ad-b26dc639bc67}
//********************* Stream Description ********************//

m=application 9 UDP/DTLS/SCTP webrtc-datachannel
c=IN IP4 0.0.0.0
a=sendrecv
a=ice-pwd:141cd92cd90d3f5c446004c3404b13c7
a=ice-ufrag:33748035
a=mid:2
a=setup:actpass
a=sctp-port:5000
a=max-message-size:1073741823

媒體流信息

m=video 9 UDP/TLS/RTP/SAVPF 120 121 126 97
c=IN IP4 0.0.0.0
a=sendrecv

a=extmap:3 urn:ietf:params:rtp-hdrext:sdes:mid
a=extmap:4 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
a=extmap:5 urn:ietf:params:rtp-hdrext:toffset

a=fmtp:126 profile-level-id=42e01f;level-asymmetry-allowed=1;packetization-mode=1
a=fmtp:97 profile-level-id=42e01f;level-asymmetry-allowed=1
a=fmtp:120 max-fs=12288;max-fr=60
a=fmtp:121 max-fs=12288;max-fr=60

a=ice-pwd:141cd92cd90d3f5c446004c3404b13c7
a=ice-ufrag:33748035
a=mid:1
a=msid:{15d330d9-3078-4727-b51e-cdc8a2554dd1} {47004068-3cac-4ee8-87df-2cdf02ae0921}

//a = rtcp-fb: RTCP-FB-PT SP RTCP-FB-VAL CRLF
//rtcp-fb-pt是有效負載類型
///rtcp-fb-val定義反饋消息的類型 ack,nack,trr-int和rtcp-fb-id
a=rtcp-fb:120 nack
a=rtcp-fb:120 nack pli
a=rtcp-fb:120 ccm fir
a=rtcp-fb:120 goog-remb
a=rtcp-fb:121 nack
a=rtcp-fb:121 nack pli
a=rtcp-fb:121 ccm fir
a=rtcp-fb:121 goog-remb
a=rtcp-fb:126 nack
a=rtcp-fb:126 nack pli
a=rtcp-fb:126 ccm fir
a=rtcp-fb:126 goog-remb
a=rtcp-fb:97 nack
a=rtcp-fb:97 nack pli
a=rtcp-fb:97 ccm fir
a=rtcp-fb:97 goog-remb

a=rtcp-mux
//rtpmap:<payload type> <encoding name> / <clock rate> [/ <encoding parameters>]
//<payload type> 此屬性從RTP有效內容類型編號(在 “m =”行中使用)映射到表示要使用的有效載荷格式,編碼類型 采樣率 編碼參數
//而以下格式的編碼的格式要去相應編碼格式標准文檔中查看 比如H264 就是RFC3984 https://tools.ietf.org/html/rfc3984
a=rtpmap:120 VP8/90000
a=rtpmap:121 VP9/90000
a=rtpmap:126 H264/90000
a=rtpmap:97 H264/90000

a=setup:actpass
a=ssrc:1381656291 cname:{eee1aa1e-411a-47d5-98ad-b26dc639bc67}

以H264為例

// m=<media> <port> <proto> <fmt> ...
//<media>是媒體類型 當前定義的媒體 "audio","video", "text", "application", and "message"
//<port>是傳輸媒體流的傳輸端口。在相關的“c =”字段中指定,以及在媒體字段的<proto>子字段中定義的傳輸協議。
//<proto>是傳輸協議。傳輸協議的含義取決於相關“c =”字段中的地址類型字段。
//<fmt>是媒體格式描述(編碼類型)。第四個和任何后續 如果<proto>子字段是“RTP / AVP”或“RTP / SAVP”,則<fmt> 子字段包含RTP有效載荷類型號。
m=video 9 UDP/TLS/RTP/SAVPF 120 121 126 97

a=fmtp:97 profile-level-id=42e01f;level-asymmetry-allowed=1

a=rtcp-fb:97 nack
a=rtcp-fb:97 nack pli
a=rtcp-fb:97 ccm fir
a=rtcp-fb:97 goog-remb

a=rtpmap:97 H264/90000


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM