Skip to content

Commit 1d2d87f

Browse files
committed
Remove legacy getStats polyfill
which provides a way to turn legacy stats into a maplike object. Legacy getStats have since been removed from Chrome. Fixes webrtcHacks#1137
1 parent 3d2ea98 commit 1d2d87f

File tree

3 files changed

+0
-69
lines changed

3 files changed

+0
-69
lines changed

index.d.ts

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ declare module "webrtc-adapter" {
1717
shimMediaStream(window: Window): void;
1818
shimOnTrack(window: Window): void;
1919
shimGetSendersWithDtmf(window: Window): void;
20-
shimGetStats(window: Window): void;
2120
shimSenderReceiverGetStats(window: Window): void;
2221
shimAddTrackRemoveTrackWithNative(window: Window): void;
2322
shimAddTrackRemoveTrack(window: Window): void;

src/js/adapter_factory.js

-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ export function adapterFactory({window} = {}, options = {
6060
chromeShim.shimOnTrack(window, browserDetails);
6161
chromeShim.shimAddTrackRemoveTrack(window, browserDetails);
6262
chromeShim.shimGetSendersWithDtmf(window, browserDetails);
63-
chromeShim.shimGetStats(window, browserDetails);
6463
chromeShim.shimSenderReceiverGetStats(window, browserDetails);
6564
chromeShim.fixNegotiationNeeded(window, browserDetails);
6665

src/js/chrome/chrome_shim.js

-67
Original file line numberDiff line numberDiff line change
@@ -188,73 +188,6 @@ export function shimGetSendersWithDtmf(window) {
188188
}
189189
}
190190

191-
export function shimGetStats(window) {
192-
if (!window.RTCPeerConnection) {
193-
return;
194-
}
195-
196-
const origGetStats = window.RTCPeerConnection.prototype.getStats;
197-
window.RTCPeerConnection.prototype.getStats = function getStats() {
198-
const [selector, onSucc, onErr] = arguments;
199-
200-
// If selector is a function then we are in the old style stats so just
201-
// pass back the original getStats format to avoid breaking old users.
202-
if (arguments.length > 0 && typeof selector === 'function') {
203-
return origGetStats.apply(this, arguments);
204-
}
205-
206-
// When spec-style getStats is supported, return those when called with
207-
// either no arguments or the selector argument is null.
208-
if (origGetStats.length === 0 && (arguments.length === 0 ||
209-
typeof selector !== 'function')) {
210-
return origGetStats.apply(this, []);
211-
}
212-
213-
const fixChromeStats_ = function(response) {
214-
const standardReport = {};
215-
const reports = response.result();
216-
reports.forEach(report => {
217-
const standardStats = {
218-
id: report.id,
219-
timestamp: report.timestamp,
220-
type: {
221-
localcandidate: 'local-candidate',
222-
remotecandidate: 'remote-candidate'
223-
}[report.type] || report.type
224-
};
225-
report.names().forEach(name => {
226-
standardStats[name] = report.stat(name);
227-
});
228-
standardReport[standardStats.id] = standardStats;
229-
});
230-
231-
return standardReport;
232-
};
233-
234-
// shim getStats with maplike support
235-
const makeMapStats = function(stats) {
236-
return new Map(Object.keys(stats).map(key => [key, stats[key]]));
237-
};
238-
239-
if (arguments.length >= 2) {
240-
const successCallbackWrapper_ = function(response) {
241-
onSucc(makeMapStats(fixChromeStats_(response)));
242-
};
243-
244-
return origGetStats.apply(this, [successCallbackWrapper_,
245-
selector]);
246-
}
247-
248-
// promise-support
249-
return new Promise((resolve, reject) => {
250-
origGetStats.apply(this, [
251-
function(response) {
252-
resolve(makeMapStats(fixChromeStats_(response)));
253-
}, reject]);
254-
}).then(onSucc, onErr);
255-
};
256-
}
257-
258191
export function shimSenderReceiverGetStats(window) {
259192
if (!(typeof window === 'object' && window.RTCPeerConnection &&
260193
window.RTCRtpSender && window.RTCRtpReceiver)) {

0 commit comments

Comments
 (0)