webrtc-adapter
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -43,2 +43,16 @@ /*jslint node:true*/ | ||
var sessionHasData = function(desc) { | ||
if (!desc) { | ||
return false; | ||
} | ||
var hasData = false; | ||
var prefix = 'm=application'; | ||
desc.sdp.split('\n').forEach(function(line) { | ||
if (line.slice(0, prefix.length) === prefix) { | ||
hasData = true; | ||
} | ||
}); | ||
return hasData; | ||
}; | ||
// Unify PeerConnection Object. | ||
@@ -48,5 +62,25 @@ if (typeof RTCPeerConnection !== 'undefined') { | ||
} else if (typeof mozRTCPeerConnection !== 'undefined') { | ||
// Firefox uses 'url' rather than 'urls' for RTCIceServer.urls | ||
myRTCPeerConnection = function (configuration, constraints) { | ||
return new mozRTCPeerConnection(renameIceURLs(configuration), constraints); | ||
// Firefox uses 'url' rather than 'urls' for RTCIceServer.urls | ||
var pc = new mozRTCPeerConnection(renameIceURLs(configuration), constraints); | ||
// Firefox doesn't fire 'onnegotiationneeded' when a data channel is created | ||
// https://bugzilla.mozilla.org/show_bug.cgi?id=840728 | ||
var dataEnabled = false; | ||
var boundCreateDataChannel = pc.createDataChannel.bind(pc); | ||
pc.createDataChannel = function(label, dataChannelDict) { | ||
var dc = boundCreateDataChannel(label, dataChannelDict); | ||
if (!dataEnabled) { | ||
dataEnabled = true; | ||
if (pc.onnegotiationneeded && | ||
!sessionHasData(pc.localDescription) && | ||
!sessionHasData(pc.remoteDescription)) { | ||
var event = new Event('negotiationneeded'); | ||
pc.onnegotiationneeded(event); | ||
} | ||
} | ||
return dc; | ||
}; | ||
return pc; | ||
}; | ||
@@ -53,0 +87,0 @@ } else if (typeof webkitRTCPeerConnection !== 'undefined') { |
{ | ||
"name": "webrtc-adapter", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "Commonjs adapter.js browser compatibility shim for webRTC", | ||
@@ -5,0 +5,0 @@ "main": "adapter.js", |
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
16694
120