diff --git a/index.d.ts b/index.d.ts index 22e2f042..95f0d0ee 100644 --- a/index.d.ts +++ b/index.d.ts @@ -17,7 +17,6 @@ declare module "webrtc-adapter" { shimMediaStream(window: Window): void; shimOnTrack(window: Window): void; shimGetSendersWithDtmf(window: Window): void; - shimGetStats(window: Window): void; shimSenderReceiverGetStats(window: Window): void; shimAddTrackRemoveTrackWithNative(window: Window): void; shimAddTrackRemoveTrack(window: Window): void; diff --git a/src/js/adapter_factory.js b/src/js/adapter_factory.js index 54bdda28..8687c34a 100644 --- a/src/js/adapter_factory.js +++ b/src/js/adapter_factory.js @@ -60,7 +60,6 @@ export function adapterFactory({window} = {}, options = { chromeShim.shimOnTrack(window, browserDetails); chromeShim.shimAddTrackRemoveTrack(window, browserDetails); chromeShim.shimGetSendersWithDtmf(window, browserDetails); - chromeShim.shimGetStats(window, browserDetails); chromeShim.shimSenderReceiverGetStats(window, browserDetails); chromeShim.fixNegotiationNeeded(window, browserDetails); diff --git a/src/js/chrome/chrome_shim.js b/src/js/chrome/chrome_shim.js index 46aee7e2..4a036ea2 100644 --- a/src/js/chrome/chrome_shim.js +++ b/src/js/chrome/chrome_shim.js @@ -188,73 +188,6 @@ export function shimGetSendersWithDtmf(window) { } } -export function shimGetStats(window) { - if (!window.RTCPeerConnection) { - return; - } - - const origGetStats = window.RTCPeerConnection.prototype.getStats; - window.RTCPeerConnection.prototype.getStats = function getStats() { - const [selector, onSucc, onErr] = arguments; - - // If selector is a function then we are in the old style stats so just - // pass back the original getStats format to avoid breaking old users. - if (arguments.length > 0 && typeof selector === 'function') { - return origGetStats.apply(this, arguments); - } - - // When spec-style getStats is supported, return those when called with - // either no arguments or the selector argument is null. - if (origGetStats.length === 0 && (arguments.length === 0 || - typeof selector !== 'function')) { - return origGetStats.apply(this, []); - } - - const fixChromeStats_ = function(response) { - const standardReport = {}; - const reports = response.result(); - reports.forEach(report => { - const standardStats = { - id: report.id, - timestamp: report.timestamp, - type: { - localcandidate: 'local-candidate', - remotecandidate: 'remote-candidate' - }[report.type] || report.type - }; - report.names().forEach(name => { - standardStats[name] = report.stat(name); - }); - standardReport[standardStats.id] = standardStats; - }); - - return standardReport; - }; - - // shim getStats with maplike support - const makeMapStats = function(stats) { - return new Map(Object.keys(stats).map(key => [key, stats[key]])); - }; - - if (arguments.length >= 2) { - const successCallbackWrapper_ = function(response) { - onSucc(makeMapStats(fixChromeStats_(response))); - }; - - return origGetStats.apply(this, [successCallbackWrapper_, - selector]); - } - - // promise-support - return new Promise((resolve, reject) => { - origGetStats.apply(this, [ - function(response) { - resolve(makeMapStats(fixChromeStats_(response))); - }, reject]); - }).then(onSucc, onErr); - }; -} - export function shimSenderReceiverGetStats(window) { if (!(typeof window === 'object' && window.RTCPeerConnection && window.RTCRtpSender && window.RTCRtpReceiver)) {