OLD | NEW |
---|---|
1 /** | 1 /** |
2 * Copyright 2014 The Chromium Authors. All rights reserved. | 2 * Copyright 2014 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 * The one and only peer connection in this page. | 8 * The one and only peer connection in this page. |
9 * @private | 9 * @private |
10 */ | 10 */ |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
282 returnToTest('ok-muted'); | 282 returnToTest('ok-muted'); |
283 } | 283 } |
284 | 284 |
285 /** | 285 /** |
286 * Returns | 286 * Returns |
287 */ | 287 */ |
288 function hasSeenCryptoInSdp() { | 288 function hasSeenCryptoInSdp() { |
289 returnToTest(gHasSeenCryptoInSdp); | 289 returnToTest(gHasSeenCryptoInSdp); |
290 } | 290 } |
291 | 291 |
292 /** | |
293 * Gets and iterates stats. Makes sure at least one report stat is returned. | |
294 * | |
295 * Returns ok on success. | |
296 */ | |
297 function getStats() { | |
298 peerConnection_().getStats( | |
299 function(response) { | |
300 var statsStr = ''; | |
301 var reports = response.result(); | |
302 var numStats = 0; | |
303 for (var i = 0; i < reports.length; i++) { | |
304 var report = reports[i]; | |
305 statsStr += '\nReport #' + i + ': ' + report.id + ' (type: ' + | |
phoglund_chromium
2016/07/27 12:52:10
Maybe call it statsText or result? It appears this
hbos_chromium
2016/07/27 13:50:31
Done.
| |
306 report.type + ', timestamp: ' + report.timestamp + ')'; | |
307 var statNames = report.names(); | |
308 numStats += statNames.length; | |
309 for (var j = 0; j < statNames.length; j++) { | |
310 var statName = statNames[j]; | |
311 var statValue = report.stat(statName); | |
312 statsStr += '\n- ' + statName + ': ' + statValue; | |
313 } | |
314 } | |
315 console.log('getStats:' + statsStr); | |
316 if (numStats === 0) | |
317 throw failTest('No stats was returned by getStats.'); | |
318 returnToTest('ok'); | |
phoglund_chromium
2016/07/27 12:52:10
ok-got-stats perhaps?
hbos_chromium
2016/07/27 13:50:31
Done.
| |
319 }); | |
320 } | |
321 | |
292 // Internals. | 322 // Internals. |
293 | 323 |
294 /** @private */ | 324 /** @private */ |
295 function createPeerConnection_(rtcConfig) { | 325 function createPeerConnection_(rtcConfig) { |
296 try { | 326 try { |
297 peerConnection = new RTCPeerConnection(rtcConfig, {}); | 327 peerConnection = new RTCPeerConnection(rtcConfig, {}); |
298 } catch (exception) { | 328 } catch (exception) { |
299 throw failTest('Failed to create peer connection: ' + exception); | 329 throw failTest('Failed to create peer connection: ' + exception); |
300 } | 330 } |
301 peerConnection.onaddstream = addStreamCallback_; | 331 peerConnection.onaddstream = addStreamCallback_; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
349 function parseJson_(json) { | 379 function parseJson_(json) { |
350 // Escape since the \r\n in the SDP tend to get unescaped. | 380 // Escape since the \r\n in the SDP tend to get unescaped. |
351 jsonWithEscapedLineBreaks = json.replace(/\r\n/g, '\\r\\n'); | 381 jsonWithEscapedLineBreaks = json.replace(/\r\n/g, '\\r\\n'); |
352 try { | 382 try { |
353 return JSON.parse(jsonWithEscapedLineBreaks); | 383 return JSON.parse(jsonWithEscapedLineBreaks); |
354 } catch (exception) { | 384 } catch (exception) { |
355 failTest('Failed to parse JSON: ' + jsonWithEscapedLineBreaks + ', got ' + | 385 failTest('Failed to parse JSON: ' + jsonWithEscapedLineBreaks + ', got ' + |
356 exception); | 386 exception); |
357 } | 387 } |
358 } | 388 } |
OLD | NEW |