Bandwidth stats display in constraints-and-stats.

Also shows off the report type and ID field, and logs less useless info.

BUG=

Review URL: https://webrtc-codereview.appspot.com/1212007

git-svn-id: http://webrtc.googlecode.com/svn/trunk@3706 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
hta@webrtc.org 2013-03-22 08:48:16 +00:00
parent 999e900fb6
commit 3ed599adb5

View File

@ -8,6 +8,8 @@
var mystream;
var pc1;
var pc2;
var bytesPrev = 0;
var timestampPrev = 0;
$ = function(id) {
return document.getElementById(id);
@ -117,12 +119,10 @@ var statCollector = setInterval(function() {
display("No stream");
if (pc2 && pc2.getRemoteStreams()[0]) {
if (pc2.getStats) {
display('No stats callback');
pc2.getStats(function(stats) {
log('Raw stats ' + stats);
var statsString = '';
var results = stats.result();
log('Raw results ' + results);
var bitrateText = 'No bitrate stats';
for (var i = 0; i < results.length; ++i) {
var res = results[i];
statsString += '<h3>Report ';
@ -130,6 +130,20 @@ var statCollector = setInterval(function() {
statsString += '</h3>';
if (!res.local || res.local === res) {
statsString += dumpStats(res);
// The bandwidth info for video is in a type ssrc stats record
// with googFrameHeightReceived defined.
// Should check for mediatype = video, but this is not
// implemented yet.
if (res.type == 'ssrc' && res.stat('googFrameHeightReceived')) {
var bytesNow = res.stat('bytesReceived');
if (timestampPrev > 0) {
var bitRate = Math.round((bytesNow - bytesPrev) * 8 /
(res.timestamp - timestampPrev));
bitrateText = bitRate + ' kbits/sec';
}
timestampPrev = res.timestamp;
bytesPrev = bytesNow;
}
} else {
// Pre-227.0.1445 (188719) browser
if (res.local) {
@ -143,7 +157,7 @@ var statCollector = setInterval(function() {
}
}
$('stats').innerHTML = statsString;
display('No bitrate stats');
display(bitrateText);
});
} else {
display('No stats function. Use at least Chrome 24.0.1285');
@ -169,8 +183,15 @@ var statCollector = setInterval(function() {
function dumpStats(obj) {
var statsString = 'Timestamp:';
statsString += obj.timestamp;
if (obj.id) {
statsString += " id ";
statsString += obj.id;
}
if (obj.type) {
statsString += " type ";
statsString += obj.type;
}
if (obj.names) {
log('Have names function');
names = obj.names();
for (var i = 0; i < names.length; ++i) {
statsString += '<br>';
@ -179,7 +200,6 @@ function dumpStats(obj) {
statsString += obj.stat(names[i]);
}
} else {
log('No names function');
if (obj.stat('audioOutputLevel')) {
statsString += "audioOutputLevel: ";
statsString += obj.stat('audioOutputLevel');