W3C home > Mailing lists > Public > public-webrtc@w3.org > February 2013

How to use stats

From: Martin Thomson <martin.thomson@gmail.com>
Date: Thu, 7 Feb 2013 11:56:57 -0500
Message-ID: <CABkgnnVhzX38ZBaZTHqC=Cbm2Zohab0RN-A518gw1GJwLJ0s+w@mail.gmail.com>
To: "public-webrtc@w3.org" <public-webrtc@w3.org>
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

This archive was generated by hypermail 2.3.1 : Monday, 23 October 2017 15:19:32 UTC