[webrtc-stats] Reuse of "inbound-rtp" and "outbound-rtp" for RTCP is confusing.

jan-ivar has just created a new issue for https://github.com/w3c/webrtc-stats:

== Reuse of "inbound-rtp" and "outbound-rtp" for RTCP is confusing. ==
The `isRemote` overload of `"inbound-rtp"` and `"outbound-rtp"` is just confusing. It invites surprise and bugs to anyone trying to enumerate stats (scripts end up reading wrong data without knowing it!)

I can't think of a single use-case where enumerating by type alone is not wrong.

It's also false symmetry: both dictionaries have members which existence depend on `isRemote`:
 * [RTCOutboundRTPStreamStats](http://rawgit.com/w3c/webrtc-stats/master/webrtc-stats.html#outboundrtpstats-dict*) has `framesEncoded` (local-only), `remoteTimestamp` (remote-only),
 * [RTCInboundRTPStreamStats](http://rawgit.com/w3c/webrtc-stats/master/webrtc-stats.html#inboundrtpstats-dict*) has `framesDecoded` (local-only), `roundTripTime` (remote-only).

These absences break down easily by type, i.e. *never* appear in subsequent calls where missing.

## Proposal

Remove `isRemote`, and round out the two rtp types with two more for rtcp instead:
 * "outbound-rtp"
 * "inbound-rtp"
 *  **"outbound-rtcp"** (formerly "inbound-rtp" with `isRemote == true`)
 *  **"inbound-rtcp"** (formerly "outbound-rtp" with `isRemote == true`)

Define discrete dictionaries for the four types (in inheritance rather than corrresponding order):
```js
dictionary RTCSentRTPStreamStats : RTCRTPStreamStats {
    unsigned long       packetsSent;
    unsigned long long  bytesSent;
};

dictionary RTCOutboundRTPStreamStats : RTCSentRTPStreamStats {
    double              targetBitrate;
    unsigned long       framesEncoded;
};

dictionary RTCInboundRTCPStreamStats : RTCSentRTPStreamStats {
    DOMHighResTimeStamp remoteTimestamp;
};
```

```js
dictionary RTCReceivedRTPStreamStats : RTCRTPStreamStats {
    unsigned long      packetsReceived;
    unsigned long long bytesReceived;
    unsigned long      packetsLost;
    double             jitter;
    double             fractionLost;
    unsigned long      packetsDiscarded;
    unsigned long      packetsRepaired;
    unsigned long      burstPacketsLost;
    unsigned long      burstPacketsDiscarded;
    unsigned long      burstLossCount;
    unsigned long      burstDiscardCount;
    double             burstLossRate;
    double             burstDiscardRate;
    double             gapLossRate;
    double             gapDiscardRate;
};

dictionary RTCInboundRTPStreamStats : RTCReceivedRTPStreamStats {
    unsigned long      framesDecoded;
};

dictionary RTCOutboundRTCPStreamStats : RTCReceivedRTPStreamStats {
    double             roundTripTime;
};
```
## Benefit:

No need to read prose anymore to see what's where, and it simplifies [usage](https://blog.mozilla.org/webrtc/fiddle-of-the-week-await/) as well:
```js
  let html = "", stats = await pc.getStats();
  for (let stat of stats.values()) {
    // if (stat.isRemote) continue; <--- don't need this line anymore!
    switch (stat.type) {
      case "outbound-rtp": {
        html += dumpOutbound(stat) + "<br>";
        let rtcp = stats.get(stat.remoteId);
        if (rtcp) html += "RTCP " + dumpInbound(rtcp) + "<br>";
        break;
      }
```
Thoughts?

Please view or discuss this issue at https://github.com/w3c/webrtc-stats/issues/189 using your GitHub account

Received on Wednesday, 22 March 2017 20:01:07 UTC