I have implemented two webrtc clients (peers) and a simple signaling server. Three elements are in local. Despite the get media, the offer/answer methods between peers and the signaling server seems working, I am only able to display local videos in both peers (both in different browser tabs)
Here is the SDP that the offerer sends to the other peer
v=0
o=- 1118386230690454721 2 IN IP4 127.0.0.1
s=-
t=0 0
a=msid-semantic: WMS
The other peer answers with similar SDP but other session id.
localVideo = document.querySelector('#localVideo');
remoteVideo = document.querySelector('#remoteVideo');
socket = io.connect("http://localhost:3000");
pc = new RTCPeerConnection(null);
var constraints = {video: true, audio: true};
getUserMedia(constraints, handleUserMedia, handleUserMediaError);
pc.onaddstream = handleRemoteStreamAdded;
pc.onremovestream = handleRemoteStreamRemoved;
pc.onicecandidate = handleIceCandidate;
var lspd;
pc.createOffer().then(function(offer) {
lspd = offer;
return pc.setLocalDescription(offer);
}).then(function() {
var offerData = {
sdp: lspd,
customerName: "name",
room: room
}
socket.emit('offer', offerData);
}).catch(function(reason) {
console.log("Error on createOffer: " + reason);
});
socket.on('answering', function (msg){
pc.setRemoteDescription(msg);
});
function handleRemoteStreamAdded(event) {
remoteVideo.src = window.URL.createObjectURL(event.stream);
remoteStream = event.stream;
}
function handleUserMedia(stream) {
localVideo.src = window.URL.createObjectURL(stream);
localStream = stream;
pc.addStream(stream);
}
The onaddstream is never added in both peers and I never can see remote video. Moreover it seems that the SDP is not complete.
Any ideas on what could I try or debug in order to reach communication between peers?
Thanks