| OLD | NEW |
| 1 /** | 1 /** |
| 2 * Copyright 2016 The Chromium Authors. All rights reserved. | 2 * Copyright 2016 The Chromium Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Maps "RTCStats.type" values to descriptions of whitelisted (allowed to be | 8 * Maps "RTCStats.type" values to descriptions of whitelisted (allowed to be |
| 9 * exposed to the web) RTCStats-derived dictionaries described below. | 9 * exposed to the web) RTCStats-derived dictionaries described below. |
| 10 * @private | 10 * @private |
| 11 */ | 11 */ |
| 12 var gStatsWhitelist = new Map(); | 12 var gStatsWhitelist = new Map(); |
| 13 | 13 |
| 14 /** | 14 /** |
| 15 * RTCRTPStreamStats | 15 * RTCRTPStreamStats |
| 16 * https://w3c.github.io/webrtc-stats/#streamstats-dict* | 16 * https://w3c.github.io/webrtc-stats/#streamstats-dict* |
| 17 * @private | 17 * @private |
| 18 */ | 18 */ |
| 19 var kRTCRTPStreamStats = new RTCStats_(null, { | 19 var kRTCRTPStreamStats = new RTCStats_(null, { |
| 20 ssrc: 'string', | 20 // TODO(hbos): As soon as |ssrc| has changed into a number, change to |
| 21 // 'number'. https://bugs.chromium.org/p/webrtc/issues/detail?id=7065, 7066 |
| 22 ssrc: 'any', |
| 21 associateStatsId: 'string', | 23 associateStatsId: 'string', |
| 22 isRemote: 'boolean', | 24 isRemote: 'boolean', |
| 23 mediaType: 'string', | 25 mediaType: 'string', |
| 24 trackId: 'string', | 26 trackId: 'string', |
| 25 // TODO(hbos): As soon as |mediaTrackId| has been renamed to |trackId|, remove | |
| 26 // this line. crbug.com/657854 | |
| 27 mediaTrackId: 'string', | |
| 28 transportId: 'string', | 27 transportId: 'string', |
| 29 codecId: 'string', | 28 codecId: 'string', |
| 30 firCount: 'number', | 29 firCount: 'number', |
| 31 pliCount: 'number', | 30 pliCount: 'number', |
| 32 nackCount: 'number', | 31 nackCount: 'number', |
| 33 sliCount: 'number', | 32 sliCount: 'number', |
| 34 qpSum: 'number', | 33 qpSum: 'number', |
| 35 }); | 34 }); |
| 36 | 35 |
| 37 /* | 36 /* |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 * RTCMediaStreamTrackStats | 115 * RTCMediaStreamTrackStats |
| 117 * https://w3c.github.io/webrtc-stats/#mststats-dict* | 116 * https://w3c.github.io/webrtc-stats/#mststats-dict* |
| 118 * @private | 117 * @private |
| 119 */ | 118 */ |
| 120 var kRTCMediaStreamTrackStats = new RTCStats_(null, { | 119 var kRTCMediaStreamTrackStats = new RTCStats_(null, { |
| 121 trackIdentifier: 'string', | 120 trackIdentifier: 'string', |
| 122 remoteSource: 'boolean', | 121 remoteSource: 'boolean', |
| 123 ended: 'boolean', | 122 ended: 'boolean', |
| 124 detached: 'boolean', | 123 detached: 'boolean', |
| 125 kind: 'string', | 124 kind: 'string', |
| 126 // TODO(hbos): As soon as |ssrcIds| has been removed, remove this line. | |
| 127 // crbug.com/659137 | |
| 128 ssrcIds: 'sequence_string', | |
| 129 frameWidth: 'number', | 125 frameWidth: 'number', |
| 130 frameHeight: 'number', | 126 frameHeight: 'number', |
| 131 framesPerSecond: 'number', | 127 framesPerSecond: 'number', |
| 132 framesSent: 'number', | 128 framesSent: 'number', |
| 133 framesReceived: 'number', | 129 framesReceived: 'number', |
| 134 framesDecoded: 'number', | 130 framesDecoded: 'number', |
| 135 framesDropped: 'number', | 131 framesDropped: 'number', |
| 136 framesCorrupted: 'number', | 132 framesCorrupted: 'number', |
| 137 partialFramesLost: 'number', | 133 partialFramesLost: 'number', |
| 138 fullFramesLost: 'number', | 134 fullFramesLost: 'number', |
| (...skipping 23 matching lines...) Expand all Loading... |
| 162 /* | 158 /* |
| 163 * RTCTransportStats | 159 * RTCTransportStats |
| 164 * https://w3c.github.io/webrtc-stats/#transportstats-dict* | 160 * https://w3c.github.io/webrtc-stats/#transportstats-dict* |
| 165 * @private | 161 * @private |
| 166 */ | 162 */ |
| 167 var kRTCTransportStats = new RTCStats_(null, { | 163 var kRTCTransportStats = new RTCStats_(null, { |
| 168 bytesSent: 'number', | 164 bytesSent: 'number', |
| 169 bytesReceived: 'number', | 165 bytesReceived: 'number', |
| 170 rtcpTransportStatsId: 'string', | 166 rtcpTransportStatsId: 'string', |
| 171 dtlsState: 'string', | 167 dtlsState: 'string', |
| 172 // TODO(hbos): As soon as |activeConnection| has been replaced by |dtlsState|, | |
| 173 // remove this line. crbug.com/653873 | |
| 174 activeConnection: 'boolean', | |
| 175 selectedCandidatePairId: 'string', | 168 selectedCandidatePairId: 'string', |
| 176 localCertificateId: 'string', | 169 localCertificateId: 'string', |
| 177 remoteCertificateId: 'string', | 170 remoteCertificateId: 'string', |
| 178 }); | 171 }); |
| 179 gStatsWhitelist.set('transport', kRTCTransportStats); | 172 gStatsWhitelist.set('transport', kRTCTransportStats); |
| 180 | 173 |
| 181 /* | 174 /* |
| 182 * RTCIceCandidateStats | 175 * RTCIceCandidateStats |
| 183 * https://w3c.github.io/webrtc-stats/#icecandidate-dict* | 176 * https://w3c.github.io/webrtc-stats/#icecandidate-dict* |
| 184 * @private | 177 * @private |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 throw failTest('stats.type is not a whitelisted type: ' + stats.type); | 366 throw failTest('stats.type is not a whitelisted type: ' + stats.type); |
| 374 for (let propertyName in stats) { | 367 for (let propertyName in stats) { |
| 375 if (propertyName === 'id' || propertyName === 'timestamp' || | 368 if (propertyName === 'id' || propertyName === 'timestamp' || |
| 376 propertyName === 'type') { | 369 propertyName === 'type') { |
| 377 continue; | 370 continue; |
| 378 } | 371 } |
| 379 if (!whitelistedStats.hasOwnProperty(propertyName)) { | 372 if (!whitelistedStats.hasOwnProperty(propertyName)) { |
| 380 throw failTest('stats.' + propertyName + ' is not a whitelisted ' + | 373 throw failTest('stats.' + propertyName + ' is not a whitelisted ' + |
| 381 'member: ' + stats[propertyName]); | 374 'member: ' + stats[propertyName]); |
| 382 } | 375 } |
| 376 if (whitelistedStats[propertyName] === 'any') |
| 377 continue; |
| 383 if (!whitelistedStats[propertyName].startsWith('sequence_')) { | 378 if (!whitelistedStats[propertyName].startsWith('sequence_')) { |
| 384 if (typeof(stats[propertyName]) !== whitelistedStats[propertyName]) { | 379 if (typeof(stats[propertyName]) !== whitelistedStats[propertyName]) { |
| 385 throw failTest('stats.' + propertyName + ' should have a different ' + | 380 throw failTest('stats.' + propertyName + ' should have a different ' + |
| 386 'type according to the whitelist: ' + stats[propertyName] + ' vs ' + | 381 'type according to the whitelist: ' + stats[propertyName] + ' vs ' + |
| 387 whitelistedStats[propertyName]); | 382 whitelistedStats[propertyName]); |
| 388 } | 383 } |
| 389 } else { | 384 } else { |
| 390 if (!Array.isArray(stats[propertyName])) { | 385 if (!Array.isArray(stats[propertyName])) { |
| 391 throw failTest('stats.' + propertyName + ' should have a different ' + | 386 throw failTest('stats.' + propertyName + ' should have a different ' + |
| 392 'type according to the whitelist (should be an array): ' + | 387 'type according to the whitelist (should be an array): ' + |
| 393 JSON.stringify(stats[propertyName]) + ' vs ' + | 388 JSON.stringify(stats[propertyName]) + ' vs ' + |
| 394 whitelistedStats[propertyName]); | 389 whitelistedStats[propertyName]); |
| 395 } | 390 } |
| 396 let elementType = whitelistedStats[propertyName].substring(9); | 391 let elementType = whitelistedStats[propertyName].substring(9); |
| 397 for (let element in stats[propertyName]) { | 392 for (let element in stats[propertyName]) { |
| 398 if (typeof(element) !== elementType) { | 393 if (typeof(element) !== elementType) { |
| 399 throw failTest('stats.' + propertyName + ' should have a different ' + | 394 throw failTest('stats.' + propertyName + ' should have a different ' + |
| 400 'type according to the whitelist (an element of the array has ' + | 395 'type according to the whitelist (an element of the array has ' + |
| 401 'the incorrect type): ' + JSON.stringify(stats[propertyName]) + | 396 'the incorrect type): ' + JSON.stringify(stats[propertyName]) + |
| 402 ' vs ' + whitelistedStats[propertyName]); | 397 ' vs ' + whitelistedStats[propertyName]); |
| 403 } | 398 } |
| 404 } | 399 } |
| 405 } | 400 } |
| 406 } | 401 } |
| 407 } | 402 } |
| OLD | NEW |