我想测试c ++应用程序和浏览器javascript之间的连接。现在,我没有服务器参与,并且我正在通过标准IO自己做信令工作。问题是当我尝试将本机应用程序生成的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
两个本机应用程序之间的连接工作正常,所以我想问题出在javascript代码中。我将不胜感激。
答案 0 :(得分:0)
在最后一行a=sctpmap:5000 webrtc-datachannel 1024
之后添加换行符