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

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.
```js
pc.addStream(stream);
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:
```js
pc.addTransceiver(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: 
```js
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