| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @fileoverview | 6 * @fileoverview |
| 7 * Module to support debug overlay window with connection stats. | 7 * Module to support debug overlay window with connection stats. |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 'use strict'; | 10 'use strict'; |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 videoBandwidth = videoBandwidth / 1048576; | 116 videoBandwidth = videoBandwidth / 1048576; |
| 117 } else { | 117 } else { |
| 118 units = 'GiBps'; | 118 units = 'GiBps'; |
| 119 videoBandwidth = videoBandwidth / 1073741824; | 119 videoBandwidth = videoBandwidth / 1073741824; |
| 120 } | 120 } |
| 121 } | 121 } |
| 122 | 122 |
| 123 /** | 123 /** |
| 124 * @param {number} value | 124 * @param {number} value |
| 125 * @param {string} units | 125 * @param {string} units |
| 126 * @param {number} digits |
| 126 * @return {string} Formatted number. | 127 * @return {string} Formatted number. |
| 127 */ | 128 */ |
| 128 function formatStatNumber(value, units) { | 129 function formatStatNumber(value, units, digits) { |
| 129 if (value != undefined) { | 130 if (value != undefined) { |
| 130 return value.toFixed(2) + ' ' + units; | 131 return value.toFixed(digits) + ' ' + units; |
| 131 } else { | 132 } else { |
| 132 return "n/a"; | 133 return "n/a"; |
| 133 } | 134 } |
| 134 } | 135 } |
| 135 | 136 |
| 137 /** |
| 138 * @param {string} type |
| 139 * @param {number} avg |
| 140 * @param {number} max |
| 141 * @return {string} "type: avg, max; " e.g. "RTT: 8.0, 13; " |
| 142 */ |
| 143 function formatStat(type, avg, max) { |
| 144 return type + ': ' + avg.toFixed(1) + ', ' + max + '; '; |
| 145 } |
| 146 |
| 136 var statistics = document.getElementById('statistics'); | 147 var statistics = document.getElementById('statistics'); |
| 137 this.statsElement_.innerText = ( | 148 this.statsElement_.innerText = ( |
| 138 'Bandwidth: ' + formatStatNumber(videoBandwidth, units) + | 149 '(avg, max in ms) ' + |
| 139 ', Frame Rate: ' + formatStatNumber(stats.videoFrameRate, 'fps') + | 150 formatStat('Capture', stats.captureLatency, stats.maxCaptureLatency) + |
| 140 ', Capture: ' + formatStatNumber(stats.captureLatency, 'ms') + | 151 formatStat('Encode', stats.encodeLatency, stats.maxEncodeLatency) + |
| 141 ', Encode: ' + formatStatNumber(stats.encodeLatency, 'ms') + | 152 formatStat('Decode', stats.decodeLatency, stats.maxDecodeLatency) + |
| 142 ', Decode: ' + formatStatNumber(stats.decodeLatency, 'ms') + | 153 formatStat('Render', stats.renderLatency, stats.maxRenderLatency) + |
| 143 ', Render: ' + formatStatNumber(stats.renderLatency, 'ms') + | 154 formatStat('RTT', stats.roundtripLatency, stats.maxRoundtripLatency) + |
| 144 ', Latency: ' + formatStatNumber(stats.roundtripLatency, 'ms')); | 155 'Bandwidth: ' + formatStatNumber(videoBandwidth, units, 2) + '; ' + |
| 156 'Frame Rate: ' + formatStatNumber(stats.videoFrameRate, 'fps', 1) |
| 157 ); |
| 145 }; | 158 }; |
| OLD | NEW |