rtcpeerconnection
Advanced tools
Comparing version 5.0.2 to 5.1.0
{ | ||
"name": "rtcpeerconnection", | ||
"version": "5.0.2", | ||
"version": "5.1.0", | ||
"description": "A tiny browser module that normalizes and simplifies the API for WebRTC peer connections.", | ||
@@ -5,0 +5,0 @@ "main": "rtcpeerconnection.js", |
@@ -150,2 +150,3 @@ var util = require('util'); | ||
ice: {}, | ||
remoteIce: {}, | ||
sid: '', | ||
@@ -258,20 +259,59 @@ isInitiator: true, | ||
var mid = content.name; | ||
var remoteContent = self.remoteDescription.contents.find(function (c) { | ||
return c.name === content.name; | ||
}); | ||
candidates.forEach( | ||
function (candidate) { | ||
var iceCandidate = SJJ.toCandidateSDP(candidate) + '\r\n'; | ||
self.pc.addIceCandidate( | ||
new RTCIceCandidate({ | ||
candidate: iceCandidate, | ||
sdpMLineIndex: mline, | ||
sdpMid: mid | ||
}), function () { | ||
// well, this success callback is pretty meaningless | ||
}, | ||
function (err) { | ||
self.emit('error', err); | ||
} | ||
); | ||
self._checkRemoteCandidate(iceCandidate); | ||
}); | ||
// process candidates as a callback, in case we need to | ||
// update ufrag and pwd with offer/answer | ||
var processCandidates = function () { | ||
candidates.forEach( | ||
function (candidate) { | ||
var iceCandidate = SJJ.toCandidateSDP(candidate) + '\r\n'; | ||
self.pc.addIceCandidate( | ||
new RTCIceCandidate({ | ||
candidate: iceCandidate, | ||
sdpMLineIndex: mline, | ||
sdpMid: mid | ||
}), function () { | ||
// well, this success callback is pretty meaningless | ||
}, | ||
function (err) { | ||
self.emit('error', err); | ||
} | ||
); | ||
self._checkRemoteCandidate(iceCandidate); | ||
}); | ||
cb(); | ||
}; | ||
if (self.config.remoteIce[content.name] && transport.ufrag && | ||
self.config.remoteIce[content.name].ufrag !== transport.ufrag) { | ||
console.log('ice restart needed', transport); | ||
if (remoteContent) { | ||
remoteContent.transport.ufrag = transport.ufrag; | ||
remoteContent.transport.pwd = transport.pwd; | ||
var offer = { | ||
type: 'offer', | ||
jingle: self.remoteDescription | ||
}; | ||
offer.sdp = SJJ.toSessionSDP(offer.jingle, { | ||
sid: self.config.sdpSessionID, | ||
role: self._role(), | ||
direction: 'incoming' | ||
}); | ||
self.pc.setRemoteDescription(new RTCSessionDescription(offer), | ||
function () { | ||
console.log('ice success updating remote desctipion'); | ||
processCandidates(); | ||
}, | ||
function (err) { | ||
console.error('ice failed to update remote description', err); | ||
} | ||
); | ||
} else { | ||
console.error('ice failed to find matching content'); | ||
} | ||
} else { | ||
processCandidates(); | ||
} | ||
}); | ||
@@ -300,4 +340,4 @@ } else { | ||
self._checkRemoteCandidate(update.candidate.candidate); | ||
cb(); | ||
} | ||
cb(); | ||
}; | ||
@@ -394,2 +434,3 @@ | ||
} | ||
}); | ||
@@ -435,2 +476,12 @@ } | ||
} | ||
// Save ICE credentials | ||
each(offer.jingle.contents, function (content) { | ||
var transport = content.transport || {}; | ||
if (transport.ufrag) { | ||
self.config.remoteIce[content.name] = { | ||
ufrag: transport.ufrag, | ||
pwd: transport.pwd | ||
}; | ||
} | ||
}); | ||
offer.sdp = SJJ.toSessionSDP(offer.jingle, { | ||
@@ -503,2 +554,13 @@ sid: self.config.sdpSessionID, | ||
self.remoteDescription = answer.jingle; | ||
// Save ICE credentials | ||
each(answer.jingle.contents, function (content) { | ||
var transport = content.transport || {}; | ||
if (transport.ufrag) { | ||
self.config.remoteIce[content.name] = { | ||
ufrag: transport.ufrag, | ||
pwd: transport.pwd | ||
}; | ||
} | ||
}); | ||
} | ||
@@ -505,0 +567,0 @@ answer.sdp.split('\r\n').forEach(function (line) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
290205
7931