Reputation: 131
I wanted to test connection between my c++ app and browser javascript. For now i have no server involved and i'm doing signaling stuff on my own by standard IO. The issue is when I try to pass sdp generated by native app to javascript to create answer I get error (generated at setRemoteDescription call):
OperationError: Failed to parse SessionDescription. a=sctpmap:5000 webrtc-datachannel 1024 Invalid SDP line.
Here is javascript code:
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);
}
and sample 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
Connection between two native apps works fine so i guess the issue is somewhere in javascript code. I would appreciate any suggestions.
Upvotes: 3
Views: 5557
Reputation: 1351
Add an line break after the last line a=sctpmap:5000 webrtc-datachannel 1024
Upvotes: 1