W3C home > Mailing lists > Public > public-webrtc-logs@w3.org > September 2018

[webrtc-stats] Replace "stream" stats with RTCMediaHandlerStats.mid

From: Jan-Ivar Bruaroey via GitHub <sysbot+gh@w3.org>
Date: Thu, 06 Sep 2018 22:37:21 +0000
To: public-webrtc-logs@w3.org
Message-ID: <issues.opened-357853376-1536273440-sysbot+gh@w3.org>
jan-ivar has just created a new issue for https://github.com/w3c/webrtc-stats:

== Replace "stream" stats with RTCMediaHandlerStats.mid ==
@karthikbr82 said in https://github.com/w3c/webrtc-stats/issues/361#issuecomment-419095016:
> if we are moving "tracks" [to the] Obsolete stats section then we could do the same for "stream".

👍 I suspect "stream" stats existed to help locate relevant stats from a media starting point. This made sense when `pc.addStream` was the media hand-off API. E.g.
await negotiate();
const stats = await pc.getStats();
const streamStat = [...stats.entries()]
  .find(stat => stat.type == "stream" && stat.streamIdentifier == stream.id);
const [senderStat] = streamStat.trackIds.map(id => stats.get(id));

These days, it's probably more helpful to start from a track:
await negotiate();
const senderStat = [...(await pc.getStats()).entries()]
  .find(stat => stat.type == "sender" && stat.trackIdentifier == track.id);
But the track isn't stable (may be changed with *replaceTrack*); the *transceiver.mid* is. So better: 
const transceiver = pc.addTransceiver(track);
await negotiate();
const senderStat = [...(await pc.getStats()).entries()]
  .find(s => s.type == "sender" && s.mid == transceiver.mid);
Of course `transceiver.sender.getStats()` works, but sometimes we need to navigate the big one. 

Please view or discuss this issue at https://github.com/w3c/webrtc-stats/issues/365 using your GitHub account
Received on Thursday, 6 September 2018 22:37:23 UTC

This archive was generated by hypermail 2.4.0 : Saturday, 6 May 2023 21:19:45 UTC