我有一个基于 Web 的 WebRTC 客户端,并且具有以下功能:
- 步骤 1. CreateOffer 将音频和视频轨道设置为 sendrecv。
- 步骤 2. 将音频和视频轨道设置为 sendrecv 的接收和应答。点对点 A/V 呼叫在此处建立。
- 步骤 3. 使用“ ”接收重新邀请
a=group:BUNDLE 0 1 video_1
。在这里,我得到了第二个视频轨道(video_1
)a=sendonly
。
重新邀请 SDP 是:
c=IN IP4 xxx.xx.xx.xx
b=AS:4044
t=0 0
a=ice-lite
a=ice-options:trickle
a=group:BUNDLE 0 1 video_1
a=msid-semantic:WMS 43e6158b973b4ca08c2bc5174f58b434
m=audio 49162 UDP/TLS/RTP/SAVP 111 110
b=AS:44
a=tcap:1 RTP/SAVPF
a=pcfg:1 t=1
a=rtpmap:111 opus/48000/2
a=fmtp:111 maxaveragebitrate=6000; maxplaybackrate=16000; sprop-maxcapturerate=16000; sprop-stereo=0; stereo=0; useinbandfec=1
a=rtpmap:110 telephone-event/48000
a=fmtp:110 0-15
a=ptime:20
a=maxptime:120
a=sendrecv
a=rtcp:49163
a=extmap:4 urn:ietf:params:rtp-hdrext:sdes:mid
a=candidate:1 1 UDP 2130706175 xxx.xx.xx.xx 49162 typ host
a=end-of-candidates
a=ice-ufrag:zurp
a=ice-pwd:Zrz0Y1wK3WbD0HSKqgx88C
a=setup:actpass
a=fingerprint:sha-256 5B:A6:08:68:7C:5B:39:BB:C1:EC:C5:72:35:C7:62:3B:A2:BE:BE:0C:29:83:11:CC:51:FE:0C:93:A5:8D:AA:E8
a=rtcp-mux
a=msid:43e6158b973b4ca08c2bc5174f58b434 09c78ac11b0347aa8b6a1a9fdba841c1
a=ssrc:1095164922 cname:K8o0hMe5bXvm
a=mid:0
m=video 57354 UDP/TLS/RTP/SAVPF 96
b=AS:2000
a=rtpmap:96 VP8/90000
a=fmtp:96 max-fr=30; max-fs=3600
a=sendrecv
a=framerate:30
a=extmap:13 urn:3gpp:video-orientation
a=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
a=extmap:4 urn:ietf:params:rtp-hdrext:sdes:mid
a=extmap:5 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id
a=rtcp:57355
a=rtcp-fb:* nack
a=rtcp-fb:* nack pli
a=rtcp-fb:* ccm fir
a=rtcp-fb:* goog-remb
a=rtcp-fb:* ccm tmmbr
a=candidate:1 1 UDP 2130706175 xxx.xx.xx.xx 57354 typ host
a=end-of-candidates
a=ice-ufrag:X9Z+
a=ice-pwd:hcvRaKtCJLdHDRs7MP4KXq
a=setup:actpass
a=fingerprint:sha-256 5B:A6:08:68:7C:5B:39:BB:C1:EC:C5:72:35:C7:62:3B:A2:BE:BE:0C:29:83:11:CC:51:FE:0C:93:A5:8D:AA:E8
a=rtcp-mux
a=msid:43e6158b973b4ca08c2bc5174f58b434 track-1
a=ssrc:2066381390 cname:K8o0hMe5bXvm
a=mid:1
m=video 0 UDP/TLS/RTP/SAVPF 96
b=AS:2000
a=rtpmap:96 VP8/90000
a=fmtp:96 max-fr=30; max-fs=3600
a=sendonly
a=framerate:30
a=extmap:13 urn:3gpp:video-orientation
a=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
a=extmap:4 urn:ietf:params:rtp-hdrext:sdes:mid
a=extmap:5 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id
a=rtcp:57355
a=rtcp-fb:* nack
a=rtcp-fb:* nack pli
a=rtcp-fb:* ccm fir
a=rtcp-fb:* goog-remb
a=rtcp-fb:* ccm tmmbr
a=ice-ufrag:X9Z+
a=ice-pwd:hcvRaKtCJLdHDRs7MP4KXq
a=setup:actpass
a=fingerprint:sha-256 5B:A6:08:68:7C:5B:39:BB:C1:EC:C5:72:35:C7:62:3B:A2:BE:BE:0C:29:83:11:CC:51:FE:0C:93:A5:8D:AA:E8
a=rtcp-mux
a=msid:43e6158b973b4ca08c2bc5174f58b434 track-2
a=ssrc:2776644557 cname:K8o0hMe5bXvm
a=mid:video_1
a=bundle-only
- 第 4 步。作为对上述重新邀请的响应,我的 WebRTC 客户端正在创建一个 SDP,其中两个视频轨道都设置为
a=recvonly
.
以下是作为对上述重新邀请请求的答复而生成的 SDP:
a=group:BUNDLE 0 1 video_1
a=msid-semantic: WMS 03b098fc-d19f-4604-8698-a164f1064222
m=audio 54067 UDP/TLS/RTP/SAVP 111 110
c=IN IP4 192.168.1.107
a=rtcp:9 IN IP4 0.0.0.0
a=candidate:779251937 1 udp 2122260223 192.168.1.107 54067 typ host generation 0 network-id 1 network-cost 10
a=candidate:1626442769 1 tcp 1518280447 192.168.1.107 9 typ host tcptype active generation 0 network-id 1 network-cost 10
a=ice-ufrag:bSuf
a=ice-pwd:gEbxh/ZGJqewM+cb6mLj9vX1
a=ice-options:trickle
a=fingerprint:sha-256 CC:89:23:8E:49:D2:F3:20:70:FB:B6:3B:BB:D9:76:B6:E3:E2:6D:C4:CB:51:0D:55:AB:D7:93:D8:91:63:15:4E
a=setup:active
a=mid:0
a=extmap:4 urn:ietf:params:rtp-hdrext:sdes:mid
a=sendrecv
a=msid:03b098fc-d19f-4604-8698-a164f1064222 bf7a9e2d-c258-419b-9460-6e0c492599eb
a=rtcp-mux
a=rtpmap:111 opus/48000/2
a=fmtp:111 maxaveragebitrate=6000;minptime=10;useinbandfec=1
a=rtpmap:110 telephone-event/48000
a=ssrc:2871826634 cname:NdgoEAIRngdC542j
m=video 9 UDP/TLS/RTP/SAVPF 96
c=IN IP4 0.0.0.0
a=rtcp:9 IN IP4 0.0.0.0
a=ice-ufrag:bSuf
a=ice-pwd:gEbxh/ZGJqewM+cb6mLj9vX1
a=ice-options:trickle
a=fingerprint:sha-256 CC:89:23:8E:49:D2:F3:20:70:FB:B6:3B:BB:D9:76:B6:E3:E2:6D:C4:CB:51:0D:55:AB:D7:93:D8:91:63:15:4E
a=setup:active
a=mid:1
a=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
a=extmap:13 urn:3gpp:video-orientation
a=extmap:4 urn:ietf:params:rtp-hdrext:sdes:mid
a=extmap:5 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id
a=recvonly
a=msid:03b098fc-d19f-4604-8698-a164f1064222 20213716-40ab-4f1c-9b69-9d859de05ca6
a=rtcp-mux
a=rtpmap:96 VP8/90000
a=rtcp-fb:96 goog-remb
a=rtcp-fb:96 ccm fir
a=rtcp-fb:96 nack
a=rtcp-fb:96 nack pli
a=ssrc:3663801913 cname:NdgoEAIRngdC542j
m=video 9 UDP/TLS/RTP/SAVPF 96
c=IN IP4 0.0.0.0
a=rtcp:9 IN IP4 0.0.0.0
a=ice-ufrag:bSuf
a=ice-pwd:gEbxh/ZGJqewM+cb6mLj9vX1
a=ice-options:trickle
a=fingerprint:sha-256 CC:89:23:8E:49:D2:F3:20:70:FB:B6:3B:BB:D9:76:B6:E3:E2:6D:C4:CB:51:0D:55:AB:D7:93:D8:91:63:15:4E
a=setup:active
a=mid:video_1
a=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
a=extmap:13 urn:3gpp:video-orientation
a=extmap:4 urn:ietf:params:rtp-hdrext:sdes:mid
a=extmap:5 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id
a=recvonly
a=rtcp-mux
a=rtpmap:96 VP8/90000
a=rtcp-fb:96 goog-remb
a=rtcp-fb:96 ccm fir
a=rtcp-fb:96 nack
a=rtcp-fb:96 nack pli
我在获取 Re-Invite 时创建了一个新的对等连接,但使用的是我在步骤 1 中创建报价时获取的相同 localstreams 对象。在创建新的对等连接之前清除旧对等连接中的现有本地轨道。
localStream.getTracks().forEach(function(track) {
var sender = call.peerConnection.getSenders().find ? call.peerConnection.getSenders().find(function(s) {
return s.track === track;
}) : null;
if (sender) {
call.peerConnection.removeTrack(sender);
在创建新的 peerConnection 时,添加本地轨道,例如:
newStream.getTracks().forEach(function(track) {
wsclogger.debug("addLocalStream, calling addTrack() --> "+ track.kind);
peerConnection.addTrack(track, newStream);
});
在这里,我从上面的日志中确认音频和视频轨道都被添加到新创建的 peerConnection 对象中。
请指导我这里出了什么问题。
PS:相同的逻辑适用于 Android,其中 Re-invite Response sdp 包含a=sendrecv
track-1 和a=recvonly
track-2。
提前致谢。