WebRTC 之 SDP

SDP 即 Session Description Protocol 会话描述协议, 它描述了所传输的媒体信息。

之所以需要在多媒体通信之前交换 SDP, 就在于

  • 接收方需要知道传输的是什么媒体类型,什么编码格式,以便正确的回放,
  • 发送方需要知道接收方能接受什么媒体格式,网络连接地址是多少,从而知道如何编码,向哪里传输。

SDP 内容简介

SDP 所描述的会话信息主要有

1. Session Metadata 会话基本信息

  • v= 版本信息
  • o= 发起者信息
  • s= 会话信息
  • t= 时长信息

2. Network Description 网络信息描述

  • c= 连接信息, IN 表示Internet
  • a= 属性信息

3. Stream Description 媒体流信息描述

  • m= 媒体信息
  • a=rtpmap 媒体映射(payload type对应的媒体类型)
  • a=fmtp 媒体格式参数 format parameter
  • a=sendrecv 媒体传输方向,包括 recvonly,sendrecv,sendonly 和 inactive
    等等

4. security descriptions 安全信息描述

  • a=crypto 描述密码套件,密钥参数和会话参数
  • a=ice-frag 用于 ICE 的用户名
  • a=ice-pwd 用于 ICE 的密码
  • a=fingerprint 用于SRTP 的 DTLS 证书指纹

5. QoS, Grouping description 质量控制和分组信息描述

  • a=rtcp-fb 应用 RTCP 反馈消息
  • a=group 应用媒体组
  • a=rtcpmux 应用 rtcp 的多路复用

画一张思维导图以概括所有的 SDP 属性

SDP
SDP 属性

SDP 的 Offer/Answer 交换过程

WebRTC 在对等连接建立之前,需要进行提议/应答( Offer/Answer)过程以交换SDP

  • 首先,发起方通过调用 createOffer()API 创建 Offer。
  • 然后,应用程序使用该 Offer 通过 setLocalDescription()API来设置其本地配置。
  • offer 最终通过其首选的信令机制(例如WebSockets)发送到远端;
  • 接收方收到该 offer 后,将使用 setRemoteDescription() API进行设置。
  • 为了完成 Offer/Answer 交换,接收方使用 createAnswer() API生成适当的 answer,使用 setLocalDescription()API应用该`answer,并将 answer 通过信令通道发送回发起方。
  • 发起方获得该answer后,它将使用 setRemoteDescription()API进行设置,并且初始设置已完成。可以重复此过程以进行其他 Offer/Answer 交换。
signal state machine

WebRTC 扩展中SDP的支持

  • 用于多路复用 bundle 绑定在一个组中的媒体行共用一个传输通道 (a=group:BUNDLE 0 1)
    这里的传输通道是指复用相同的五元组(source IP, source port, destination IP, destination port, protocol)
  • 用于 SRTP的DTLS 指纹 (a=fingerprint) , 即 DTLS 协商时使用的证书的sha-254的哈希值此
  • RTP/RTCP多路复用 (a=rtcp-mux) , 即 RTP 和 RTCP 共同一个传输通道
  • RTCP 反馈支持 (a=rtcp-fb)
  • 主机和服务器反射候选地址 (a=candidate)
  • SRTP 创建框架参数 (a=setup)
  • RTCP 属性 (a=rtcp)
  • RTP 扩展(a=extmap)
    比如用于指示从客户机到混音服务器的音量的扩展RTP头 (a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level)

WebRTC SDP 实例

SDP 的实例和解释在 https://tools.ietf.org/html/rfc8829 JSEP 协议和 https://tools.ietf.org/html/draft-nandakumar-rtcweb-sdp-08 这篇文档中有很详尽的解释,摘录两例如下:

例一

Alice 想给 Bob 发送三路视频流,作为三层 SVC


Alice                                             Bob
  |                                                 |
  |                                                 |
  |      Alice offers 3 sendonly video streams      |
  |      as 3 layers of SVC and bundle-only         |
  |               for video streams.                |
  |                                                 |
  |            Offer(Video:H.264 SVC)               |
  |------------------------------------------------>|
  |                                                 |
  |                                                 |Bob accepts Alice's
  |                                                 |offered Codec
  |                                                 |operation points
  |                                                 |
  |             Answer(Video:H.264)                 |
  |<------------------------------------------------|
  |                                                 |
  |One-Way  H.264 SVC video streams                 |
  |.................................................|
  |                                                 |
  |                                                 |

提议 offer

SDP Contents RFC#/Notes
v=0 [RFC4566]
o=- 20519 0 IN IP4 0.0.0.0 [RFC4566]
s=- [RFC4566]
t=0 0 [RFC4566]
a=msid-semantic:WMS ma [I-D.ietf-mmusic-msid]
a=group:BUNDLE m0 m1 [I-D.ietf-mmusic-sdp-bundle-ne
gotiation] Alice supports
grouping of m=lines under
BUNDLE semantics
a=ice-options:trickle [I-D.ietf-mmusic-trickle-ice]
m=audio 54609 UDP/TLS/RTP/SAVPF [RFC4566]
109
c=IN IP4 24.23.204.141 [RFC4566]
a=msid:ma ta Identifies RTCMediaStream ID
(ma) and RTCMediaStreamTrack
ID (ta)
a=rtcp:64678 IN IP4 [RFC3605]
24.23.204.141
a=mid:m0 [RFC5888] Audio m=line part of
BUNDLE group with a unique
port number
a=rtpmap:109 opus/48000/2 [I-D.ietf-payload-rtp-opus]
a=extmap:1 urn:ietf:params:rtp- [RFC6464]
hdrext:ssrc-audio-level
a=ptime:20 [I-D.ietf-payload-rtp-opus]
a=sendonly [RFC3264]
a=rtcp-fb:109 nack [RFC5104]
a=setup:actpass [RFC4145]
a=rtcp-mux [RFC5761]
a=ice-ufrag:074c6550 [RFC5245]
a=ice-pwd:a28a397a4c3f31747d1ee3 [RFC5245]
474af08a068
a=fingerprint:sha-1 99:41:49:83: [RFC5245]
4a:97:0e:1f:ef:6d:f7:c9:c7:70:
9d:1f:66:79:a8:07
a=candidate:0 1 UDP 2113667327 [RFC5245]
192.168.1.4 54609 typ host
a=candidate:1 1 UDP 694302207 [RFC5245]
24.23.204.141 54609 typ srflx
raddr 192.168.1.4 rport 54609
a=candidate:0 2 UDP 2113667326 [RFC5245]
192.168.1.4 64678 typ host
a=candidate:1 2 UDP 1694302206 [RFC5245]
24.23.204.141 64678 typ srflx
raddr 192.168.1.4 rport 64678
a=ssrc:67890 [RFC5576]
cname:axzo1278npDlAzM73
a=rtcp-rsize [RFC5506]
m=video 0 UDP/TLS/RTP/SAVPF 96 bundle-only video line with
97 100 port number set to zero
c=IN IP4 24.23.204.141 [RFC4566]
a=msid:ma tb Identifies RTCMediaStream ID
(ma) and RTCMediaStreamTrack
ID (tc)
a=rtcp:64678 IN IP4 [RFC3605]
24.23.204.141
a=mid:m1 [RFC5888] Audio m=line part of
BUNDLE group
a=msid:ma tb
a=rtpmap:96 H264/90000 [RFC3984]
a=fmtp:96 profile-level- [RFC3984]H.264 Layer 1
id=4d0028; packetization-mode=1
;max-fr=30;max-fs=8040
a=rtpmap:97 H264/90000 [RFC3984]
a=fmtp:97 profile-level- [RFC3984] H.264 Layer 2
id=4d0028;packetization-mode=1;
max-fr=15;max-fs=1200
a=rtpmap:100 H264-SVC/90000 [RFC3984]
a=fmtp:100 profile-level- [RFC3984]
id=4d0028;packetization-mode=1;
max-fr=30;max-fs=8040
a=depend:100 lay m1:96,97; [RFC5583]Layer 3 dependent on
layers 1 and 2
a=sendonly [RFC3264] - Send only video
stream
a=rtcp-mux [RFC5761]
a=bundle-only [UNIFIED-PLAN]
a=ssrc:1732846380 [RFC5576]
cname:axzo1278npDlAzM73
a=ssrc:1732846381 [RFC5576]
cname:axzo1278npDlAzM73
a=ssrc:1732846382 [RFC5576]
cname:axzo1278npDlAzM73
a=rtcp-fb:* nack [RFC5104]
a=rtcp-fb:* nack pli [RFC5104]
a=rtcp-fb:* ccm fir [RFC5104]
a=rtcp-rsize [RFC5506]

答复 Answer

SDP Contents RFC#/Notes
v=0 [RFC4566]
o=- 20519 0 IN IP4 0.0.0.0 [RFC4566]
s=- [RFC4566]
t=0 0 [RFC4566]
a=msid-semantic:WMS ma [I-D.ietf-mmusic-msid]
a=group:BUNDLE m0 m1 [I-D.ietf-mmusic-sdp-bundle-ne
gotiation]
a=ice-options:trickle [I-D.ietf-mmusic-trickle-ice]
m=audio 49203 UDP/TLS/RTP/SAVPF [RFC4566]
109
c=IN IP4 98.248.92.77 [RFC4566]
a=msid:ma ta Identifies RTCMediaStream ID
(ma) and RTCMediaStreamTrack
ID (ta)
a=rtcp:60065 IN IP4 98.248.92.77 [RFC3605]
a=mid:m0 [RFC5888]
a=rtpmap:109 opus/48000/2 [I-D.ietf-payload-rtp-opus]
a=extmap:1 urn:ietf:params:rtp- [RFC6464]
hdrext:ssrc-audio-level
a=ptime:20 [I-D.ietf-payload-rtp-opus]
a=rtcp-fb:109 nack [RFC5104]
a=recvonly [RFC3264]
a=setup:active [RFC4145]
a=rtcp-mux [RFC5761]
a=ice-ufrag:074c6550 [RFC5245]
a=ice-pwd:a28a397a4c3f31747d1ee3 [RFC5245]
474af08a068
a=fingerprint:sha-1 99:41:49:83: [RFC5245]
4a:97:0e:1f:ef:6d:f7:c9:c7:70:
9d:1f:66:79:a8:07
a=candidate:0 2 UDP 2113667326 [RFC5245]
192.168.1.7 60065 typ host
a=candidate:1 2 UDP 1694302206 [RFC5245]
98.248.92.77 60065 typ srflx
raddr 192.168.1.5 rport 60065
a=rtcp-rsize [RFC5506]
m=video 54609 UDP/TLS/RTP/SAVPF BUNDLE accepted Bundle address
96 100 same as audio m=line.
c=IN IP4 98.248.92.77 [RFC4566]
a=msid:ma tb Identifies RTCMediaStream ID
(ma) and RTCMediaStreamTrack
ID (tb)
a=rtcp:56503 IN IP4 98.248.92.77 [RFC3605]
a=mid:m1 [RFC5888] Video m=line part of
BUNDLE group
a=rtpmap:96 H264/90000 [RFC3984]
a=fmtp:96 profile-level- [RFC3984]H.264 Layer 1
id=4d0028;packetization-mode=1;
max-fr=30;max-fs=8040
a=rtpmap:100 H264-SVC/90000 [RFC3984]
a=fmtp:100 profile-level- [RFC3984]
id=4d0028;packetization-mode=1;
max-fr=30;max-fs=8040
a=depend:100 lay m1:96; [RFC5583] Bob chooses 2 Codec
Operation points
a=ice-ufrag:074c6550 [RFC5245]
a=ice-pwd:a28a397a4c3f31747d1ee3 [RFC5245]
474af08a068
a=fingerprint:sha-1 99:41:49:83: [RFC5245]
4a:97:0e:1f:ef:6d:f7:c9:c7:70:
9d:1f:66:79:a8:07
a=candidate:0 2 UDP 2113667326 [RFC5245]
192.168.1.5 64678 typ host
a=candidate:1 2 UDP 1694302206 [RFC5245]
24.23.204.142 64678 typ srflx
raddr 192.168.1.5 rport 64678
a=recvonly [RFC3264] - Receive only video
stream
a=setup:active [RFC4145]
a=rtcp-mux [RFC5761]
a=bundle-only [UNIFIED-PLAN]
a=ssrc:4638117328 [RFC5576]
cname:axzo1278npDlAzM73
a=rtcp-rsize [RFC5506]

例二

大家可以自己尝试一下这个示例, 看看 createOffer 自动生成的SDP
https://www.fanyamin.com/webrtc/examples/local_peer_connection.html

提议 offer

v=0
o=- 8239869955140945002 2 IN IP4 127.0.0.1
s=-
t=0 0
a=group:BUNDLE 0 1
a=msid-semantic: WMS GoWYMdoRaYVhM48hMwrLvUvXSxbJg14puaW1
m=audio 9 UDP/TLS/RTP/SAVPF 111 103 104 9 0 8 106 105 13 110 112 113 126
c=IN IP4 0.0.0.0
a=rtcp:9 IN IP4 0.0.0.0
a=ice-ufrag:/dWy
a=ice-pwd:p42BXxT7MhHl+m3bpPP2Y/Q5
a=ice-options:trickle
a=fingerprint:sha-256 60:67:45:E8:D6:F6:41:C0:6D:D7:0A:B0:BC:10:37:D8:A4:3F:9F:46:1C:F0:94:10:B8:EE:33:04:EF:50:BB:EC
a=setup:actpass
a=mid:0
a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level
a=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
a=extmap:3 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01
a=extmap:4 urn:ietf:params:rtp-hdrext:sdes:mid
a=extmap:5 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id
a=extmap:6 urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id
a=sendrecv
a=msid:GoWYMdoRaYVhM48hMwrLvUvXSxbJg14puaW1 4599d225-4f4f-4108-a6f2-654a980a34e5
a=rtcp-mux
a=rtpmap:111 opus/48000/2
a=rtcp-fb:111 transport-cc
a=fmtp:111 minptime=10;useinbandfec=1
a=rtpmap:103 ISAC/16000
a=rtpmap:104 ISAC/32000
a=rtpmap:9 G722/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:106 CN/32000
a=rtpmap:105 CN/16000
a=rtpmap:13 CN/8000
a=rtpmap:110 telephone-event/48000
a=rtpmap:112 telephone-event/32000
a=rtpmap:113 telephone-event/16000
a=rtpmap:126 telephone-event/8000
a=ssrc:2145710159 cname:hvdv5R/8+RclR7OU
a=ssrc:2145710159 msid:GoWYMdoRaYVhM48hMwrLvUvXSxbJg14puaW1 4599d225-4f4f-4108-a6f2-654a980a34e5
a=ssrc:2145710159 mslabel:GoWYMdoRaYVhM48hMwrLvUvXSxbJg14puaW1
a=ssrc:2145710159 label:4599d225-4f4f-4108-a6f2-654a980a34e5
m=video 9 UDP/TLS/RTP/SAVPF 96 97 98 99 100 101 102 121 127 120 125 107 108 109 124 119 123 118 114 115 116
c=IN IP4 0.0.0.0
a=rtcp:9 IN IP4 0.0.0.0
a=ice-ufrag:/dWy
a=ice-pwd:p42BXxT7MhHl+m3bpPP2Y/Q5
a=ice-options:trickle
a=fingerprint:sha-256 60:67:45:E8:D6:F6:41:C0:6D:D7:0A:B0:BC:10:37:D8:A4:3F:9F:46:1C:F0:94:10:B8:EE:33:04:EF:50:BB:EC
a=setup:actpass
a=mid:1
a=extmap:14 urn:ietf:params:rtp-hdrext:toffset
a=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
a=extmap:13 urn:3gpp:video-orientation
a=extmap:3 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01
a=extmap:12 http://www.webrtc.org/experiments/rtp-hdrext/playout-delay
a=extmap:11 http://www.webrtc.org/experiments/rtp-hdrext/video-content-type
a=extmap:7 http://www.webrtc.org/experiments/rtp-hdrext/video-timing
a=extmap:8 http://www.webrtc.org/experiments/rtp-hdrext/color-space
a=extmap:4 urn:ietf:params:rtp-hdrext:sdes:mid
a=extmap:5 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id
a=extmap:6 urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id
a=sendrecv
a=msid:GoWYMdoRaYVhM48hMwrLvUvXSxbJg14puaW1 7f813904-12c1-4e89-ad8d-ac6b36189298
a=rtcp-mux
a=rtcp-rsize
a=rtpmap:96 VP8/90000
a=rtcp-fb:96 goog-remb
a=rtcp-fb:96 transport-cc
a=rtcp-fb:96 ccm fir
a=rtcp-fb:96 nack
a=rtcp-fb:96 nack pli
a=rtpmap:97 rtx/90000
a=fmtp:97 apt=96
a=rtpmap:98 VP9/90000
a=rtcp-fb:98 goog-remb
a=rtcp-fb:98 transport-cc
a=rtcp-fb:98 ccm fir
a=rtcp-fb:98 nack
a=rtcp-fb:98 nack pli
a=fmtp:98 profile-id=0
a=rtpmap:99 rtx/90000
a=fmtp:99 apt=98
a=rtpmap:100 VP9/90000
a=rtcp-fb:100 goog-remb
a=rtcp-fb:100 transport-cc
a=rtcp-fb:100 ccm fir
a=rtcp-fb:100 nack
a=rtcp-fb:100 nack pli
a=fmtp:100 profile-id=2
a=rtpmap:101 rtx/90000
a=fmtp:101 apt=100
a=rtpmap:102 H264/90000
a=rtcp-fb:102 goog-remb
a=rtcp-fb:102 transport-cc
a=rtcp-fb:102 ccm fir
a=rtcp-fb:102 nack
a=rtcp-fb:102 nack pli
a=fmtp:102 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42001f
a=rtpmap:121 rtx/90000
a=fmtp:121 apt=102
a=rtpmap:127 H264/90000
a=rtcp-fb:127 goog-remb
a=rtcp-fb:127 transport-cc
a=rtcp-fb:127 ccm fir
a=rtcp-fb:127 nack
a=rtcp-fb:127 nack pli
a=fmtp:127 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42001f
a=rtpmap:120 rtx/90000
a=fmtp:120 apt=127
a=rtpmap:125 H264/90000
a=rtcp-fb:125 goog-remb
a=rtcp-fb:125 transport-cc
a=rtcp-fb:125 ccm fir
a=rtcp-fb:125 nack
a=rtcp-fb:125 nack pli
a=fmtp:125 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f
a=rtpmap:107 rtx/90000
a=fmtp:107 apt=125
a=rtpmap:108 H264/90000
a=rtcp-fb:108 goog-remb
a=rtcp-fb:108 transport-cc
a=rtcp-fb:108 ccm fir
a=rtcp-fb:108 nack
a=rtcp-fb:108 nack pli
a=fmtp:108 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42e01f
a=rtpmap:109 rtx/90000
a=fmtp:109 apt=108
a=rtpmap:124 H264/90000
a=rtcp-fb:124 goog-remb
a=rtcp-fb:124 transport-cc
a=rtcp-fb:124 ccm fir
a=rtcp-fb:124 nack
a=rtcp-fb:124 nack pli
a=fmtp:124 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=4d001f
a=rtpmap:119 rtx/90000
a=fmtp:119 apt=124
a=rtpmap:123 H264/90000
a=rtcp-fb:123 goog-remb
a=rtcp-fb:123 transport-cc
a=rtcp-fb:123 ccm fir
a=rtcp-fb:123 nack
a=rtcp-fb:123 nack pli
a=fmtp:123 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=64001f
a=rtpmap:118 rtx/90000
a=fmtp:118 apt=123
a=rtpmap:114 red/90000
a=rtpmap:115 rtx/90000
a=fmtp:115 apt=114
a=rtpmap:116 ulpfec/90000
a=ssrc-group:FID 381754597 4156246619
a=ssrc:381754597 cname:hvdv5R/8+RclR7OU
a=ssrc:381754597 msid:GoWYMdoRaYVhM48hMwrLvUvXSxbJg14puaW1 7f813904-12c1-4e89-ad8d-ac6b36189298
a=ssrc:381754597 mslabel:GoWYMdoRaYVhM48hMwrLvUvXSxbJg14puaW1
a=ssrc:381754597 label:7f813904-12c1-4e89-ad8d-ac6b36189298
a=ssrc:4156246619 cname:hvdv5R/8+RclR7OU
a=ssrc:4156246619 msid:GoWYMdoRaYVhM48hMwrLvUvXSxbJg14puaW1 7f813904-12c1-4e89-ad8d-ac6b36189298
a=ssrc:4156246619 mslabel:GoWYMdoRaYVhM48hMwrLvUvXSxbJg14puaW1
a=ssrc:4156246619 label:7f813904-12c1-4e89-ad8d-ac6b36189298

答复 Answer

v=0
o=- 8886170094146334558 2 IN IP4 127.0.0.1
s=-
t=0 0
a=group:BUNDLE 0 1
a=msid-semantic: WMS
m=audio 9 UDP/TLS/RTP/SAVPF 111 103 104 9 0 8 106 105 13 110 112 113 126
c=IN IP4 0.0.0.0
a=rtcp:9 IN IP4 0.0.0.0
a=ice-ufrag:aR2X
a=ice-pwd:fXNkKEedNmHopY1Jzl8OBuLx
a=ice-options:trickle
a=fingerprint:sha-256 CB:7F:E6:38:B8:B5:58:BD:7E:E3:5C:A9:D2:1C:88:36:64:DD:2C:CE:2F:81:C0:EE:6D:DA:56:92:CF:1B:79:90
a=setup:active
a=mid:0
a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level
a=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
a=extmap:3 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01
a=extmap:4 urn:ietf:params:rtp-hdrext:sdes:mid
a=extmap:5 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id
a=extmap:6 urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id
a=recvonly
a=rtcp-mux
a=rtpmap:111 opus/48000/2
a=rtcp-fb:111 transport-cc
a=fmtp:111 minptime=10;useinbandfec=1
a=rtpmap:103 ISAC/16000
a=rtpmap:104 ISAC/32000
a=rtpmap:9 G722/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:106 CN/32000
a=rtpmap:105 CN/16000
a=rtpmap:13 CN/8000
a=rtpmap:110 telephone-event/48000
a=rtpmap:112 telephone-event/32000
a=rtpmap:113 telephone-event/16000
a=rtpmap:126 telephone-event/8000
m=video 9 UDP/TLS/RTP/SAVPF 96 97 98 99 100 101 102 121 127 120 125 107 108 109 124 119 123 118 114 115 116
c=IN IP4 0.0.0.0
a=rtcp:9 IN IP4 0.0.0.0
a=ice-ufrag:aR2X
a=ice-pwd:fXNkKEedNmHopY1Jzl8OBuLx
a=ice-options:trickle
a=fingerprint:sha-256 CB:7F:E6:38:B8:B5:58:BD:7E:E3:5C:A9:D2:1C:88:36:64:DD:2C:CE:2F:81:C0:EE:6D:DA:56:92:CF:1B:79:90
a=setup:active
a=mid:1
a=extmap:14 urn:ietf:params:rtp-hdrext:toffset
a=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
a=extmap:13 urn:3gpp:video-orientation
a=extmap:3 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01
a=extmap:12 http://www.webrtc.org/experiments/rtp-hdrext/playout-delay
a=extmap:11 http://www.webrtc.org/experiments/rtp-hdrext/video-content-type
a=extmap:7 http://www.webrtc.org/experiments/rtp-hdrext/video-timing
a=extmap:8 http://www.webrtc.org/experiments/rtp-hdrext/color-space
a=extmap:4 urn:ietf:params:rtp-hdrext:sdes:mid
a=extmap:5 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id
a=extmap:6 urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id
a=recvonly
a=rtcp-mux
a=rtcp-rsize
a=rtpmap:96 VP8/90000
a=rtcp-fb:96 goog-remb
a=rtcp-fb:96 transport-cc
a=rtcp-fb:96 ccm fir
a=rtcp-fb:96 nack
a=rtcp-fb:96 nack pli
a=rtpmap:97 rtx/90000
a=fmtp:97 apt=96
a=rtpmap:98 VP9/90000
a=rtcp-fb:98 goog-remb
a=rtcp-fb:98 transport-cc
a=rtcp-fb:98 ccm fir
a=rtcp-fb:98 nack
a=rtcp-fb:98 nack pli
a=fmtp:98 profile-id=0
a=rtpmap:99 rtx/90000
a=fmtp:99 apt=98
a=rtpmap:100 VP9/90000
a=rtcp-fb:100 goog-remb
a=rtcp-fb:100 transport-cc
a=rtcp-fb:100 ccm fir
a=rtcp-fb:100 nack
a=rtcp-fb:100 nack pli
a=fmtp:100 profile-id=2
a=rtpmap:101 rtx/90000
a=fmtp:101 apt=100
a=rtpmap:102 H264/90000
a=rtcp-fb:102 goog-remb
a=rtcp-fb:102 transport-cc
a=rtcp-fb:102 ccm fir
a=rtcp-fb:102 nack
a=rtcp-fb:102 nack pli
a=fmtp:102 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42001f
a=rtpmap:121 rtx/90000
a=fmtp:121 apt=102
a=rtpmap:127 H264/90000
a=rtcp-fb:127 goog-remb
a=rtcp-fb:127 transport-cc
a=rtcp-fb:127 ccm fir
a=rtcp-fb:127 nack
a=rtcp-fb:127 nack pli
a=fmtp:127 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42001f
a=rtpmap:120 rtx/90000
a=fmtp:120 apt=127
a=rtpmap:125 H264/90000
a=rtcp-fb:125 goog-remb
a=rtcp-fb:125 transport-cc
a=rtcp-fb:125 ccm fir
a=rtcp-fb:125 nack
a=rtcp-fb:125 nack pli
a=fmtp:125 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f
a=rtpmap:107 rtx/90000
a=fmtp:107 apt=125
a=rtpmap:108 H264/90000
a=rtcp-fb:108 goog-remb
a=rtcp-fb:108 transport-cc
a=rtcp-fb:108 ccm fir
a=rtcp-fb:108 nack
a=rtcp-fb:108 nack pli
a=fmtp:108 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42e01f
a=rtpmap:109 rtx/90000
a=fmtp:109 apt=108
a=rtpmap:124 H264/90000
a=rtcp-fb:124 goog-remb
a=rtcp-fb:124 transport-cc
a=rtcp-fb:124 ccm fir
a=rtcp-fb:124 nack
a=rtcp-fb:124 nack pli
a=fmtp:124 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=4d0015
a=rtpmap:119 rtx/90000
a=fmtp:119 apt=124
a=rtpmap:123 H264/90000
a=rtcp-fb:123 goog-remb
a=rtcp-fb:123 transport-cc
a=rtcp-fb:123 ccm fir
a=rtcp-fb:123 nack
a=rtcp-fb:123 nack pli
a=fmtp:123 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=640015
a=rtpmap:118 rtx/90000
a=fmtp:118 apt=123
a=rtpmap:114 red/90000
a=rtpmap:115 rtx/90000
a=fmtp:115 apt=114
a=rtpmap:116 ulpfec/90000

备注

  • a=rtcp-fb:* nack pli 其中 “rtcp-fb” 表示 RTP Control Protocol (RTCP) - 反馈消息的支持,NACK 即 Negative Acknowledgement 表示对一个或多个RTP包丢失的消息,PLI 即图像丢失指示 Picture Loss Indication

  • a=rtcp-fb:* ccm tmmbr 其中 “rtcp-fb” 表示 RTP Control Protocol (RTCP) - 反馈消息的支持,“ccm” 表示对编码控制反馈消息的支持(Codec Control Message), "tmmbr" 表示对临时最大媒体比特率的请求和通知消息的支持

以下都是H.264 的编码参数

  • profile-level-id=428016 profile-level-id 描述了此端点所支持的最小功能集

    • profile-level-id 由6个十六进制数字组成。前4个十六进制数字定义profile-id,而其他2个十六进制数字定义 level。在上例中,profile-id 是4280,而 level 是16。profile-level-id必须对称于呼叫双方

    • profile-id 描述了端点支持的编码工具的子集。profile-id 4280表示基线概要 baseline profile(BP,66),其支持诸如灵活宏块排序、任意切片排序、冗余切片等编码特性。

    • profile level 描述端点可以支持的分辨率、帧速率和比特率。十六进制中的16级(十进制中的22级)表示2.2级=352 x 480像素@每秒30帧。

  • packetization-mode=1 打包模式,取值可以是 0,1 或 2

    • 0 = a single NALU packet sent in an RTP packet, no fragments
    • 1= multiple NALUs can be sent in decoding order. Fragments allowed
    • 2= multiple NALUs can be sent out of decoding order. Fragments allowed
      这个协商的打包模式对呼叫双方必须是对称的
  • max-mbps=245000: 最大解码速率 Max Decoding speed = Max Macroblocks/sec = 245000 (Baseline profile level 2.2 value = 20250)

  • max-fs=9000: 最大帧大小 Max Frame Size = 9000 Macroblocks (Baseline profile level 2.2 value = 1620)

  • max-cpb=200: 最大编码图像缓冲尺寸 Max Coded Picture Buffer size = 200 kbits (Baseline profile level 2.2 value = 4 kbits)

  • max-br=5000: 最大视频比特率 Max video bit rate = 5000 kbps, Baseline profile level 2.2 value = 4000 kbps

  • max-rcmd-nalu-size=3456000: 最大NAL 单元数据包的大小 Max NALU packet size (bytes) that the receiver can handle

  • max-smbps=245000: 最大静态宏块处理速率 Max Static Macroblock processing rate – macroblocks/second

  • max-fps=6000: 最大帧率 Max Frames Per Second in 1/100s of a frame/second = 60 fps (Baseline profile level 2.2 value = 30 fps)

参考资料

  • RFC4566 - SDP: Session Description Protocol (旧版本)
  • RFC8866 - SDP: Session Description Protocol (新版本)
  • RFC3264 - An Offer/Answer Model with the Session Description Protocol (SDP)
  • RFC3551 - RTP Profile for Audio and Video Conferences with Minimal Control
  • RFC8829 - JavaScript Session Establishment Protocol (JSEP)
  • RFC4568 - Security Descriptions for Media Streams
  • SDP Offer/Answer Procedures for ICE
  • SDP for the WebRTC
  • RFC6184 - RTP Payload Format for H.264 Video

你可能感兴趣的:(WebRTC 之 SDP)