使用 vanilla webRTC 客户端回答 SDP 错误 Kurento NodeJS 服务器

Answer SDP Error Kurento NodeJS server with vanilla webRTC client

我一直在开发一个应用程序来使用 Kurento 媒体服务器从浏览器记录会话。我已经使用 kurento-client 库设置了后端,并在前端使用了 vanilla WebRTC API。

报价在客户端生成,答案从服务器返回。

问题出现在客户端的 setRemoteDescription 方法中。

我收到如下所示的错误

Uncaught (in promise) TypeError: Failed to execute 'setRemoteDescription' on 'RTCPeerConnection': The provided value is not of type 'RTCSessionDescriptionInit'.

控制台记录接收到的 SDP 会产生以下值。

v=0
o=- 3858259838 3858259838 IN IP4 0.0.0.0
s=Kurento Media Server
c=IN IP4 0.0.0.0
t=0 0
a=extmap-allow-mixed:
a=msid-semantic: WMS EkyCjRfgsyNQMlKh9vmRFVBIlCgbgNt51tst
a=group:BUNDLE 0 1
m=audio 1 UDP/TLS/RTP/SAVPF 111 0
a=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
a=sendrecv
a=mid:0
a=rtcp:9 IN IP4 0.0.0.0
a=rtpmap:111 opus/48000/2
a=rtpmap:0 PCMU/8000
a=setup:active
a=rtcp-mux
a=fmtp:111 minptime=10;useinbandfec=1
a=ssrc:2441312662 cname:user4258135824@host-a3760c98
a=ice-ufrag:u7MJ
a=ice-pwd:uAgK+b4b5eK2333Z+qQZnP
a=fingerprint:sha-256 BD:6C:C8:40:7C:30:60:30:76:63:CC:28:20:D3:81:5F:EE:5A:6D:B0:C4:AA:09:37:70:8E:13:55:51:81:4B:37
m=video 1 UDP/TLS/RTP/SAVPF 96 127 125 108 124 123 35
a=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
a=sendrecv
a=mid:1
a=rtcp:9 IN IP4 0.0.0.0
a=rtpmap:96 VP8/90000
a=rtpmap:127 H264/90000
a=rtpmap:125 H264/90000
a=rtpmap:108 H264/90000
a=rtpmap:124 H264/90000
a=rtpmap:123 H264/90000
a=rtpmap:35 H264/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=rtcp-fb:127 goog-remb
a=rtcp-fb:127 ccm fir
a=rtcp-fb:127 nack
a=rtcp-fb:127 nack pli
a=rtcp-fb:125 goog-remb
a=rtcp-fb:125 ccm fir
a=rtcp-fb:125 nack
a=rtcp-fb:125 nack pli
a=rtcp-fb:108 goog-remb
a=rtcp-fb:108 ccm fir
a=rtcp-fb:108 nack
a=rtcp-fb:108 nack pli
a=rtcp-fb:124 goog-remb
a=rtcp-fb:124 ccm fir
a=rtcp-fb:124 nack
a=rtcp-fb:124 nack pli
a=rtcp-fb:123 goog-remb
a=rtcp-fb:123 ccm fir
a=rtcp-fb:123 nack
a=rtcp-fb:123 nack pli
a=rtcp-fb:35 goog-remb
a=rtcp-fb:35 ccm fir
a=rtcp-fb:35 nack
a=rtcp-fb:35 nack pli
a=setup:active
a=rtcp-mux
a=fmtp:127 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42001f
a=fmtp:125 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42001f
a=fmtp:108 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f
a=fmtp:124 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42e01f
a=fmtp:123 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=4d001f
a=fmtp:35 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=4d001f
a=ssrc:3201711112 cname:user4258135824@host-a3760c98
a=ice-ufrag:u7MJ
a=ice-pwd:uAgK+b4b5eK2333Z+qQZnP
a=fingerprint:sha-256 BD:6C:C8:40:7C:30:60:30:76:63:CC:28:20:D3:81:5F:EE:5A:6D:B0:C4:AA:09:37:70:8E:13:55:51:81:4B:37

我在下方提供了引发错误的代码段。

socket.on("credentials", async({ sdp, ice} ) => {
    try {
        if(sdp) {
            console.log(sdp)
            await pc.setRemoteDescription(sdp)
            console.log('set')
        }
        else if(ice) {
            await pc.addIceCandidate(ice)
            console.log('ice set')
        }
    }
    catch(error) {
        console.log(error)
    }
})

这不是答案 SDP 的正确格式吗?非常感谢您提供解决此问题的帮助。

您的术语有问题。 SDP本身就是以v=...开头的字符串。 但是,setRemoteDescription call expects a RTCSessionDescriptionInit 参数,即具有 {type, sdp}.

的对象

该类型(offeranswer 通常)也应该来自您的信号。