@@ -188,73 +188,6 @@ export function shimGetSendersWithDtmf(window) {
188
188
}
189
189
}
190
190
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
-
258
191
export function shimSenderReceiverGetStats ( window ) {
259
192
if ( ! ( typeof window === 'object' && window . RTCPeerConnection &&
260
193
window . RTCRtpSender && window . RTCRtpReceiver ) ) {
0 commit comments