javascript - 使用 native WebRTC 代码设置远程 SDP 的问题

标签 javascript c++ webrtc sdp

我有一个流程如下的 P2P 应用程序:

第一个 peer - 浏览器,当前使用 Chromium 78.0.3904.70,64 位
二等同行——原生webrtc代码(基于:WebRTC M62分支),环境:Linux Ubuntu 18.04

在浏览器端,我正在创建一个有限制的报价:

const constraints = {
   offerToReceiveVideo: true,
   offerToReceiveAudio: true
}

生成的 SDP:

sdp":"v=0\r\no=- 439044357473030896 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE 0 1\r\na=msid-semantic: WMS\r\nm=audio 9 UDP/TLS/RTP/SAVPF 111 103 104 9 0 8 106 105 13 110 112 113 126\r\nc=IN IP4 0.0.0.0\r\na=rtcp:9 IN IP4 0.0.0.0\r\na=ice-ufrag:hbv/\r\na=ice-pwd:+kts4bqldeYdmy89dZp7Wv+B\r\na=ice-options:trickle\r\na=fingerprint:sha-256 5B:D0:4F:CF:FD:80:3D:A1:58:01:C1:AA:90:E8:1F:FA:38:02:B6:58:8A:F2:3C:E7:80:9F:12:0D:B6:5F:CB:81\r\na=setup:actpass\r\na=mid:0\r\na=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level\r\na=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time\r\na=extmap:3 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01\r\na=extmap:4 urn:ietf:params:rtp-hdrext:sdes:mid\r\na=extmap:5 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id\r\na=extmap:6 urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id\r\na=recvonly\r\na=rtcp-mux\r\na=rtpmap:111 opus/48000/2\r\na=rtcp-fb:111 transport-cc\r\na=fmtp:111 minptime=10;useinbandfec=1\r\na=rtpmap:103 ISAC/16000\r\na=rtpmap:104 ISAC/32000\r\na=rtpmap:9 G722/8000\r\na=rtpmap:0 PCMU/8000\r\na=rtpmap:8 PCMA/8000\r\na=rtpmap:106 CN/32000\r\na=rtpmap:105 CN/16000\r\na=rtpmap:13 CN/8000\r\na=rtpmap:110 telephone-event/48000\r\na=rtpmap:112 telephone-event/32000\r\na=rtpmap:113 telephone-event/16000\r\na=rtpmap:126 telephone-event/8000\r\nm=video 9 UDP/TLS/RTP/SAVPF 96 97 98 99 100 101 102 122 127 121 125 107 108 109 124 120 123\r\nc=IN IP4 0.0.0.0\r\na=rtcp:9 IN IP4 0.0.0.0\r\na=ice-ufrag:hbv/\r\na=ice-pwd:+kts4bqldeYdmy89dZp7Wv+B\r\na=ice-options:trickle\r\na=fingerprint:sha-256 5B:D0:4F:CF:FD:80:3D:A1:58:01:C1:AA:90:E8:1F:FA:38:02:B6:58:8A:F2:3C:E7:80:9F:12:0D:B6:5F:CB:81\r\na=setup:actpass\r\na=mid:1\r\na=extmap:14 urn:ietf:params:rtp-hdrext:toffset\r\na=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time\r\na=extmap:13 urn:3gpp:video-orientation\r\na=extmap:3 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01\r\na=extmap:12 http://www.webrtc.org/experiments/rtp-hdrext/playout-delay\r\na=extmap:11 http://www.webrtc.org/experiments/rtp-hdrext/video-content-type\r\na=extmap:7 http://www.webrtc.org/experiments/rtp-hdrext/video-timing\r\na=extmap:8 http://tools.ietf.org/html/draft-ietf-avtext-framemarking-07\r\na=extmap:9 http://www.webrtc.org/experiments/rtp-hdrext/color-space\r\na=extmap:4 urn:ietf:params:rtp-hdrext:sdes:mid\r\na=extmap:5 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id\r\na=extmap:6 urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id\r\na=recvonly\r\na=rtcp-mux\r\na=rtcp-rsize\r\na=rtpmap:96 VP8/90000\r\na=rtcp-fb:96 goog-remb\r\na=rtcp-fb:96 transport-cc\r\na=rtcp-fb:96 ccm fir\r\na=rtcp-fb:96 nack\r\na=rtcp-fb:96 nack pli\r\na=rtpmap:97 rtx/90000\r\na=fmtp:97 apt=96\r\na=rtpmap:98 VP9/90000\r\na=rtcp-fb:98 goog-remb\r\na=rtcp-fb:98 transport-cc\r\na=rtcp-fb:98 ccm fir\r\na=rtcp-fb:98 nack\r\na=rtcp-fb:98 nack pli\r\na=fmtp:98 profile-id=0\r\na=rtpmap:99 rtx/90000\r\na=fmtp:99 apt=98\r\na=rtpmap:100 VP9/90000\r\na=rtcp-fb:100 goog-remb\r\na=rtcp-fb:100 transport-cc\r\na=rtcp-fb:100 ccm fir\r\na=rtcp-fb:100 nack\r\na=rtcp-fb:100 nack pli\r\na=fmtp:100 profile-id=2\r\na=rtpmap:101 rtx/90000\r\na=fmtp:101 apt=100\r\na=rtpmap:102 H264/90000\r\na=rtcp-fb:102 goog-remb\r\na=rtcp-fb:102 transport-cc\r\na=rtcp-fb:102 ccm fir\r\na=rtcp-fb:102 nack\r\na=rtcp-fb:102 nack pli\r\na=fmtp:102 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42001f\r\na=rtpmap:122 rtx/90000\r\na=fmtp:122 apt=102\r\na=rtpmap:127 H264/90000\r\na=rtcp-fb:127 goog-remb\r\na=rtcp-fb:127 transport-cc\r\na=rtcp-fb:127 ccm fir\r\na=rtcp-fb:127 nack\r\na=rtcp-fb:127 nack pli\r\na=fmtp:127 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42001f\r\na=rtpmap:121 rtx/90000\r\na=fmtp:121 apt=127\r\na=rtpmap:125 H264/90000\r\na=rtcp-fb:125 goog-remb\r\na=rtcp-fb:125 transport-cc\r\na=rtcp-fb:125 ccm fir\r\na=rtcp-fb:125 nack\r\na=rtcp-fb:125 nack pli\r\na=fmtp:125 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f\r\na=rtpmap:107 rtx/90000\r\na=fmtp:107 apt=125\r\na=rtpmap:108 H264/90000\r\na=rtcp-fb:108 goog-remb\r\na=rtcp-fb:108 transport-cc\r\na=rtcp-fb:108 ccm fir\r\na=rtcp-fb:108 nack\r\na=rtcp-fb:108 nack pli\r\na=fmtp:108 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42e01f\r\na=rtpmap:109 rtx/90000\r\na=fmtp:109 apt=108\r\na=rtpmap:124 red/90000\r\na=rtpmap:120 rtx/90000\r\na=fmtp:120 apt=124\r\na=rtpmap:123 ulpfec/90000\r\n

在 native 代码方面,我有对等连接工厂:

factory_ = webrtc::CreatePeerConnectionFactory(nullptr,
                                                    threads_.worker.get(),
                                                        threads_.signaling.get(),
                                                            nullptr,
                                                                webrtc::CreateBuiltinAudioEncoderFactory(),
                                                                    webrtc::CreateBuiltinAudioDecoderFactory(),
                                                                        new cricket::InternalEncoderFactory(),
                                                                            new cricket::InternalDecoderFactory());

问题出现在设置远程SDP时。
一些 WebRTC 日志:

[000:788] [23544] (channel.cc:2105): Setting remote video description
[000:788] [23544] (webrtcvideoengine.cc:609): SetSendParameters: {codecs: [VideoCodec[108:H264]], extensions: [{uri: urn:ietf:params:rtp-hdrext:toffset, id: 14}, {uri: http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time, id: 2}, {uri: urn:3gpp:video-orientation, id: 13}, {uri: http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01, id: 3}, {uri: http://www.webrtc.org/experiments/rtp-hdrext/playout-delay, id: 12}, {uri: http://www.webrtc.org/experiments/rtp-hdrext/video-content-type, id: 11}, {uri: http://www.webrtc.org/experiments/rtp-hdrext/video-timing, id: 7}, {uri: http://tools.ietf.org/html/draft-ietf-avtext-framemarking-07, id: 8}, {uri: http://www.webrtc.org/experiments/rtp-hdrext/color-space, id: 9}, {uri: urn:ietf:params:rtp-hdrext:sdes:mid, id: 4}, {uri: urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id, id: 5}, {uri: urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id, id: 6}], max_bandwidth_bps: -1, }
[000:788] [23544] (webrtcvideoengine.cc:446): Internally supported codecs: {VideoCodec[0:VP8], VideoCodec[0:red], VideoCodec[0:ulpfec]}
[000:788] [23544] (webrtcvideoengine.cc:456): Codecs supported by the external encoder factory: {VideoCodec[0:VP8], VideoCodec[0:red], VideoCodec[0:ulpfec]}
[000:788] [23544] (webrtcvideoengine.cc:553): No video codecs supported.
[000:788] [23543] (channel.cc:853): Failure in SetRemoteContent with action 0
[000:788] [23543] (webrtcsession.cc:345): Failed to set remote offer sdp: Session error code: ERROR_CONTENT. Session error description: Failed to set remote video description send parameters..

有什么想法可能有问题吗?

最佳答案

看起来您已经编译了不支持 H264 的 native WebRTC 库, 并且浏览器在 SDP 中有 H264,因此它被选为视频编解码器,但您的 native WebRTC 不支持它。

关于javascript - 使用 native WebRTC 代码设置远程 SDP 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58623143/

相关文章:

javascript - 如何在滚动时修复导航栏中的按钮

c++ - int (*p)[3] 和 int *p[3] 有什么区别?

c++ - 在同一行上使用 malloc 创建两个数组

firefox - 使用 MediaRecorder 指定编解码器

ios - 如何将视频渲染器添加到本地视频轨道

javascript - 将音频和视频轨道组合到新的 MediaStream 中

javascript - while 循环使用谷歌图表

javascript - axios如何类似jQuery ajax方法设置表单数据?

javascript - 在嵌入式 map /谷歌地图 API 上使用标准谷歌地图接口(interface)

C++ 编译器不喜欢 "using INLINE = extern inline"