javascript - Session error description: Couldn't set up DTLS-SRTP on RTP channel -
i facing error of not being able set remote sdp there error in session description - couldn't set dtls-srtp on rtp channel
also there occurs 2 round of offer/answer round in peer peer(which shouldn't) onnegotiationneeded fires twice. occurs during video conference setup in multi peer connectivity, otherwise datachannel set in multiple peer connection(used stream external video) works fine. code below initiates peer connection -
// initiating peer connection host function initiatepeerconnection(currentpeer, callback){ peerconnection[currentpeer] = new rtcpeerconnection(serverconfig); // initiation of rtc connection of peers other host console.log(peerconnection[currentpeer]); console.log(currentpeer); peerconnection[currentpeer].onicecandidate = function(evt){ console.log("ice candidate"); console.log(peerid); signalserver.send(json.stringify({"candidate": evt.candidate, "peerid": peerid, "senderid": senderid, "sendto": currentpeer})); }; peerconnection[currentpeer].onnegotiationneeded = function(){ console.log("negotiation initiated"+currentpeer.tostring()); peerconnection[currentpeer].createoffer() .then(function(offer){ peerconnection[currentpeer].setlocaldescription(offer) }) .then(function(){ console.log("offer sent "+currentpeer.tostring()); console.log(peerid); console.log(peerconnection[currentpeer].localdescription); signalserver.send(json.stringify({"sessiondescriptionprotocol": peerconnection[currentpeer].localdescription, "peerid": peerid, "senderid": senderid, "sendto": currentpeer})); console.log("done negotiation"); }) .catch(logerror) }; // console.log(localstream); // peerconnection[currentpeer].addstream(localstream); // peerconnection[currentpeer].ontrack = gotremotestream; navigator.getusermedia(constraints, function(stream){ localstream = stream; console.log(localstream); gotlocalstream(localstream, currentpeer); }, fallbackusermedia); peerconnection[currentpeer].ontrack = function(e){ console.log("on track"); gotremotestream(e); }; callback(currentpeer, setupchannel); // callback createdatachannel. calling callback setupchannel } the code below answers offer/message received server -
if(message.sessiondescriptionprotocol) { console.log(message.sessiondescriptionprotocol.type) if(message.sessiondescriptionprotocol.type == 'offer') { peerconnection[currentpeer].setremotedescription(message.sessiondescriptionprotocol) .then(function(){ return peerconnection[currentpeer].createanswer(); }) .then(function(answer){ createlocaldescription(answer); }) .catch(logerror) }else{ console.log(currentpeer); peerconnection[currentpeer].setremotedescription(message.sessiondescriptionprotocol) .catch(logerror); } // }); } else if(message.candidate) { console.log("adding"); peerconnection[currentpeer].addicecandidate(message.candidate); console.log("added"); } function createlocaldescription(answer){ peerconnection[currentpeer].setlocaldescription(answer) .then(function(){ console.log("answer sent "+currentpeer.tostring()); console.log(peerid); console.log(peerconnection[currentpeer].localdescription); signalserver.send(json.stringify({"sessiondescriptionprotocol": peerconnection[currentpeer].localdescription, "peerid": peerid, "senderid": senderid, "sendto": currentpeer})); console.log("done"); }) } here link repository if needed
thanks in advance :d
Comments
Post a Comment