webrtc-adapter
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -25,2 +25,20 @@ /*jslint node:true*/ | ||
var fixChromeStatsResponse = function(response) { | ||
var standardReport = {}; | ||
var reports = response.result(); | ||
reports.forEach(function(report) { | ||
var standardStats = { | ||
id: report.id, | ||
timestamp: report.timestamp, | ||
type: report.type | ||
}; | ||
report.names().forEach(function(name) { | ||
standardStats[name] = report.stat(name); | ||
}); | ||
standardReport[standardStats.id] = standardStats; | ||
}); | ||
return standardReport; | ||
}; | ||
// Unify PeerConnection Object. | ||
@@ -35,3 +53,15 @@ if (typeof RTCPeerConnection !== 'undefined') { | ||
} else if (typeof webkitRTCPeerConnection !== 'undefined') { | ||
myRTCPeerConnection = webkitRTCPeerConnection; | ||
// Chrome returns a nonstandard, non-JSON-ifiable response from getStats. | ||
myRTCPeerConnection = function(configuration, constraints) { | ||
var pc = new webkitRTCPeerConnection(configuration, constraints); | ||
var boundGetStats = pc.getStats.bind(pc); | ||
pc.getStats = function(selector, successCallback, failureCallback) { | ||
var successCallbackWrapper = function(chromeStatsResponse) { | ||
successCallback(fixChromeStatsResponse(chromeStatsResponse)); | ||
}; | ||
// Chrome also takes its arguments in the wrong order. | ||
boundGetStats(successCallbackWrapper, failureCallback, selector); | ||
}; | ||
return pc; | ||
}; | ||
} | ||
@@ -38,0 +68,0 @@ |
{ | ||
"name": "webrtc-adapter", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"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
15696
6
89