WebRtc11:SDP详解
SDP规范
- 会话层(全局)
- 媒体层(局部)
会话层
- 会话的名称和目的
- 会话的存活时间
- 会话中包含多个媒体信息
SDP媒体信息
- 媒体格式
- 传输协议
- 传输IP和端口
- 媒体负载类型
SDP格式
- 由多个< type >= < value > 组成
- 一个会话级描述
- 多个媒体级描述
SDP结构
- Session Description
- Time Description
- Media Description
Session Description(了解即可)
Time Description(了解即可)
Media Description(重点)
字段含义
重要
对rtpmap进一步说明用fmtp
WebRTC中的SDP
WebRTC Offer/Answer SDP
SDP例子
v=0
o=- 5037468894663793939 2 IN IP4 127.0.0.1
s=-
t=0 0
a=group:BUNDLE 0
a=extmap-allow-mixed
a=msid-semantic: WMS 21eda7d7-c9fe-4709-998c-eab3b22382df
m=video 9 UDP/TLS/RTP/SAVPF 96 97 103 104 107 108 109 114 115 116 117 118 39 40 45 46 98 99 100 101 119 120 123 124 125
c=IN IP4 0.0.0.0
a=rtcp:9 IN IP4 0.0.0.0
a=ice-ufrag:6s1+
a=ice-pwd:4BJx+10HhljTHZbDCl9jOtbH
a=ice-options:trickle
a=fingerprint:sha-256 32:E0:78:07:CB:4D:CD:18:2C:85:24:B5:4F:68:26:5C:09:52:DF:59:E1:EA:3D:21:01:84:A4:26:15:AB:29:17
a=setup:actpass
a=mid:0
a=extmap:1 urn:ietf:params:rtp-hdrext:toffset
a=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
a=extmap:3 urn:3gpp:video-orientation
a=extmap:4 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01
a=extmap:5 http://www.webrtc.org/experiments/rtp-hdrext/playout-delay
a=extmap:6 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:9 urn:ietf:params:rtp-hdrext:sdes:mid
a=extmap:10 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id
a=extmap:11 urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id
a=sendrecv
a=msid:21eda7d7-c9fe-4709-998c-eab3b22382df ca66d0ef-610d-4d67-b6a7-c148ee76adfa
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:103 H264/90000
a=rtcp-fb:103 goog-remb
a=rtcp-fb:103 transport-cc
a=rtcp-fb:103 ccm fir
a=rtcp-fb:103 nack
a=rtcp-fb:103 nack pli
a=fmtp:103 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42001f
a=rtpmap:104 rtx/90000
a=fmtp:104 apt=103
a=rtpmap:107 H264/90000
a=rtcp-fb:107 goog-remb
a=rtcp-fb:107 transport-cc
a=rtcp-fb:107 ccm fir
a=rtcp-fb:107 nack
a=rtcp-fb:107 nack pli
a=fmtp:107 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42001f
a=rtpmap:108 rtx/90000
a=fmtp:108 apt=107
a=rtpmap:109 H264/90000
a=rtcp-fb:109 goog-remb
a=rtcp-fb:109 transport-cc
a=rtcp-fb:109 ccm fir
a=rtcp-fb:109 nack
a=rtcp-fb:109 nack pli
a=fmtp:109 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f
a=rtpmap:114 rtx/90000
a=fmtp:114 apt=109
a=rtpmap:115 H264/90000
a=rtcp-fb:115 goog-remb
a=rtcp-fb:115 transport-cc
a=rtcp-fb:115 ccm fir
a=rtcp-fb:115 nack
a=rtcp-fb:115 nack pli
a=fmtp:115 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42e01f
a=rtpmap:116 rtx/90000
a=fmtp:116 apt=115
a=rtpmap:117 H264/90000
a=rtcp-fb:117 goog-remb
a=rtcp-fb:117 transport-cc
a=rtcp-fb:117 ccm fir
a=rtcp-fb:117 nack
a=rtcp-fb:117 nack pli
a=fmtp:117 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=4d001f
a=rtpmap:118 rtx/90000
a=fmtp:118 apt=117
a=rtpmap:39 H264/90000
a=rtcp-fb:39 goog-remb
a=rtcp-fb:39 transport-cc
a=rtcp-fb:39 ccm fir
a=rtcp-fb:39 nack
a=rtcp-fb:39 nack pli
a=fmtp:39 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=4d001f
a=rtpmap:40 rtx/90000
a=fmtp:40 apt=39
a=rtpmap:45 AV1/90000
a=rtcp-fb:45 goog-remb
a=rtcp-fb:45 transport-cc
a=rtcp-fb:45 ccm fir
a=rtcp-fb:45 nack
a=rtcp-fb:45 nack pli
a=fmtp:45 level-idx=5;profile=0;tier=0
a=rtpmap:46 rtx/90000
a=fmtp:46 apt=45
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:119 H264/90000
a=rtcp-fb:119 goog-remb
a=rtcp-fb:119 transport-cc
a=rtcp-fb:119 ccm fir
a=rtcp-fb:119 nack
a=rtcp-fb:119 nack pli
a=fmtp:119 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=64001f
a=rtpmap:120 rtx/90000
a=fmtp:120 apt=119
a=rtpmap:123 red/90000
a=rtpmap:124 rtx/90000
a=fmtp:124 apt=123
a=rtpmap:125 ulpfec/90000
a=ssrc-group:FID 1758617498 1760089180
a=ssrc:1758617498 cname:AzhxWgpFGztb1IZ6
a=ssrc:1758617498 msid:21eda7d7-c9fe-4709-998c-eab3b22382df ca66d0ef-610d-4d67-b6a7-c148ee76adfa
a=ssrc:1760089180 cname:AzhxWgpFGztb1IZ6
a=ssrc:1760089180 msid:21eda7d7-c9fe-4709-998c-eab3b22382df ca66d0ef-610d-4d67-b6a7-c148ee76adfa
对应的解释
v=0
SDP协议版本号,固定为0,表示遵循RFC 4566标准 o=- 5037468894663793939 2 IN IP4 127.0.0.1
会话发起者信息:-:无用户名;
5037468894663793939:唯一会话ID;
2:会话版本号;
IN IP4 127.0.0.1:IPv4本地地址 s=-
会话名称,此处为空 t=0 0
会话时间范围,0 0表示会话无固定时间限制 a=group:BUNDLE 0
所有媒体流(此处仅视频流mid:0)复用同一传输通道(BUNDLE策略) a=extmap-allow-mixed
允许混合使用标准和非标准RTP头部扩展 a=msid-semantic: WMS 21eda7d7-c9fe-4709-998c-eab3b22382df
定义媒体流标识符,WMS为WebRTC媒体流语义标识 视频媒体描述(Media Level)
m=video 9 UDP/TLS/RTP/SAVPF 96 97 103 ... 125
视频媒体参数:9:占位端口(实际由ICE协商确定);
UDP/TLS/RTP/SAVPF:加密传输协议(DTLS-SRTP);
96 97 ...:支持的Payload类型列表 c=IN IP4 0.0.0.0
连接地址占位符,实际由ICE候选地址覆盖 a=rtcp:9 IN IP4 0.0.0.0
RTCP端口配置(与RTP复用同一端口) a=ice-ufrag:6s1+ / a=ice-pwd:4BJx+...
ICE连接凭证,用于身份验证和连接建立 a=ice-options:trickle
支持Trickle ICE模式(逐步收集候选地址) a=fingerprint:sha-256 32:E0:78:07:...
DTLS证书指纹,用于安全握手验证 a=setup:actpass
DTLS角色协商策略,表示本端可主动或被动发起握手 a=mid:0
媒体标识符,对应BUNDLE分组中的视频流 RTP扩展头(a=extmap)1 urn:ietf:...toffset:时间偏移扩展;
2 abs-send-time:发送时间戳(用于拥塞控制);
3 video-orientation:视频方向元数据;
4 transport-wide-cc:传输层带宽反馈;
5 playout-delay:播放延迟控制;
6 video-content-type:视频内容类型(如屏幕共享);
7 video-timing:视频帧时间戳;
8 color-space:色彩空间信息;
9-11:流标识与修复流关联 a=sendrecv
媒体流方向为双向传输(支持发送与接收) a=msid:21eda7d7... ca66d0ef...
媒体流ID(WebRTC MediaStream ID与Track ID) a=rtcp-mux / a=rtcp-rsize
RTP/RTCP复用端口与精简RTCP包大小 编解码器与反馈机制
VP8编解码器a=rtpmap:96 VP8/90000:VP8编码,时钟频率90kHz;
a=rtcp-fb:96 goog-remb:支持REMB带宽反馈;
a=rtcp-fb:96 transport-cc:传输层拥塞控制;
a=rtcp-fb:96 nack pli:支持丢包重传(NACK)与关键帧请求(PLI) H.264编解码器(多配置)a=rtpmap:103 H264/90000:Baseline 3.1配置(profile-level-id=42001f);
packetization-mode=1:分片模式(支持非交错帧);
level-asymmetry-allowed=1:允许编解码器级别不对称 AV1与VP9编解码器a=rtpmap:45 AV1/90000:AV1编码(level-idx=5);
a=rtpmap:98 VP9/90000:VP9编码(profile-id=0) 重传流(RTX)a=rtpmap:97 rtx/90000:VP8重传流(apt=96关联主编码);
a=fmtp:97 apt=96:指定主编码Payload类型 冗余与纠错(RED/ULP FEC)a=rtpmap:123 red/90000:冗余编码(RED);
a=rtpmap:125 ulpfec/90000:前向纠错(ULP FEC) 流标识与同步源(SSRC)
a=ssrc-group:FID 1758617498 1760089180
主媒体流(SSRC:1758617498)与重传流(SSRC:1760089180)关联 a=ssrc:1758617498 cname:AzhxWgpFGztb1IZ6
同步源(SSRC)的规范名称(CNAME),用于跨设备流同步