gpt4 book ai didi

javascript - WebRTC setRemoteDescription 错误

转载 作者:行者123 更新时间:2023-11-30 06:50:39 24 4
gpt4 key购买 nike

我想测试我的 C++ 应用程序和浏览器 JavaScript 之间的连接。现在我没有涉及服务器,我正在通过标准 IO 自己做信号处理。问题是当我尝试将 native 应用程序生成的 sdp 传递给 javascript 以创建答案时,我收到错误消息(在 setRemoteDescription 调用时生成):

OperationError: Failed to parse SessionDescription. a=sctpmap:5000 webrtc-datachannel 1024 Invalid SDP line.

这是javascript代码:

function input() {
var stdin = document.getElementById('stdin');
var input = stdin.value;
stdin.value = '';
return input;
}
function answer() {
peerConnection = new RTCPeerConnection(pcConfig);
peerConnection.onicecandidate = onIceCandidate;
peerConnection.ondatachannel = onDataChannel;
peerConnection.oniceconnectionstatechange = onIceConnectionStateChange;
var buff = input();
var sdpOffer = {
type: "offer",
sdp: buff
}
peerConnection.setRemoteDescription(sdpOffer).then(() => onSetRemoteSuccess(peerConnection), onSetSessionDescriptionError);
peerConnection.createAnswer().then(onCreateAnswerSuccess, onCreateSessionDescriptionError);
}

和示例 sdp:

v=0
o=- 8612289788290620730 2 IN IP4 127.0.0.1
s=-
t=0 0
a=group:BUNDLE data
a=msid-semantic: WMS
m=application 49168 DTLS/SCTP 5000
c=IN IP4 77.114.92.160
a=candidate:1774547698 1 udp 2113937151 77.114.92.160 49168 typ host generation 0 network-cost 50
a=ice-ufrag:yzpQ
a=ice-pwd:UDjI4/ifwEV4mbZnfjbJrRW1
a=ice-options:trickle
a=fingerprint:sha-256 3C:60:34:BA:24:44:36:72:10:DF:E4:8C:00:0B:C1:3D:87:12:65:4D:AC:FF:09:F2:DD:22:BD:A8:3C:90:F1:F8
a=setup:actpass
a=mid:data
a=sctpmap:5000 webrtc-datachannel 1024

两个 native 应用程序之间的连接工作正常,所以我猜问题出在 javascript 代码中。如果有任何建议,我将不胜感激。

最佳答案

在最后一行后添加一个换行符a=sctpmap:5000 webrtc-datachannel 1024

关于javascript - WebRTC setRemoteDescription 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51659635/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com