How to use stats

Given the API that we decided to go with, here is code that will
produce one line (to console) for each RTP stream that includes a
timestamp and the ssrc for those streams.

function statsCallback(allStats) {
  var stats = getStatsByType(allStats, 'RTPStreamStats');
  stats.forEach(function(v) {
    console.log(v.timestamp + ' ' + v.id + ' ' + v.ssrc);
  });
}

function getStatsByType(allStats, type) {
  return Object.keys(allStats).filter(function(id) {
    return allStats[id].type === allStats;
  }).map(function(id) {
    return allStats[id];
  });
}

Question: do we set type for an RTCStatsObject based on the most
specific type?  That would invalidate the filtering I'm doing here.

Received on Thursday, 7 February 2013 16:57:34 UTC