[Stats] Add minimum RTCReceivedRtpStreamStats with jitter and packetsLost

Spec: https://www.w3.org/TR/webrtc-stats/#receivedrtpstats-dict*

    According to the spec, |RTCReceivedRtpStreamStats| is the base class for |RTCInboundRtpStreamStats| and |RTCRemoteInboundRtpStreamStats|. This structure isn't visible in JavaScript but it's important to bring it up to spec for the C++ part. This CL adds the barebone |RTCReceivedRtpStreamStats| with a bunch of TODOs for later migrations.

    This commit makes the minimum |RTCReceivedRtpStreamStats| and rebase |RTCInboundRtpStreamStats| and |RTCRemoteInboundRtpStreamStats| to use the new class as the parent class.

    This commit also moves |jitter| and |packets_lost| to |RTCReceivedRtpStreamStats|, from |RTCInboundRtpStreamStats| and |RTCRemoteInboundRtpStreamStats|. Moving these two first because they are the two that exist in both subclasses for now.

Bug: webrtc:12532
Change-Id: I0ec74fd241f16c1e1a6498b6baa621ca0489f279
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/210340
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33435}
This commit is contained in:
Di Wu
2021-03-09 09:25:28 -08:00
committed by Commit Bot
parent 8639673f0c
commit fd1e9d1af4
3 changed files with 132 additions and 100 deletions

View File

@ -374,34 +374,46 @@ class RTC_EXPORT RTCRTPStreamStats : public RTCStats {
~RTCRTPStreamStats() override;
RTCStatsMember<uint32_t> ssrc;
// TODO(hbos): Remote case not supported by |RTCStatsCollector|.
// crbug.com/657855, 657856
RTCStatsMember<bool> is_remote; // = false
RTCStatsMember<std::string> media_type; // renamed to kind.
RTCStatsMember<std::string> kind;
RTCStatsMember<std::string> track_id;
RTCStatsMember<std::string> transport_id;
RTCStatsMember<std::string> codec_id;
// FIR and PLI counts are only defined for |media_type == "video"|.
RTCStatsMember<uint32_t> fir_count;
RTCStatsMember<uint32_t> pli_count;
// TODO(hbos): NACK count should be collected by |RTCStatsCollector| for both
// audio and video but is only defined in the "video" case. crbug.com/657856
RTCStatsMember<uint32_t> nack_count;
// TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/657854
// SLI count is only defined for |media_type == "video"|.
RTCStatsMember<uint32_t> sli_count;
RTCStatsMember<uint64_t> qp_sum;
// Obsolete
RTCStatsMember<std::string> media_type; // renamed to kind.
protected:
RTCRTPStreamStats(const std::string& id, int64_t timestamp_us);
RTCRTPStreamStats(std::string&& id, int64_t timestamp_us);
};
class RTC_EXPORT RTCReceivedRtpStreamStats : public RTCRTPStreamStats {
public:
WEBRTC_RTCSTATS_DECL();
RTCReceivedRtpStreamStats(const RTCReceivedRtpStreamStats& other);
~RTCReceivedRtpStreamStats() override;
// TODO(hbos) The following fields need to be added and migrated
// both from RTCInboundRtpStreamStats and RTCRemoteInboundRtpStreamStats:
// packetsReceived, packetsDiscarded, packetsRepaired, burstPacketsLost,
// burstPacketDiscarded, burstLossCount, burstDiscardCount, burstLossRate,
// burstDiscardRate, gapLossRate, gapDiscardRate, framesDropped,
// partialFramesLost, fullFramesLost
// crbug.com/webrtc/12532
RTCStatsMember<double> jitter;
RTCStatsMember<int32_t> packets_lost; // Signed per RFC 3550
protected:
RTCReceivedRtpStreamStats(const std::string&& id, int64_t timestamp_us);
RTCReceivedRtpStreamStats(std::string&& id, int64_t timestamp_us);
};
// https://w3c.github.io/webrtc-stats/#inboundrtpstats-dict*
// TODO(hbos): Support the remote case |is_remote = true|.
// https://bugs.webrtc.org/7065
class RTC_EXPORT RTCInboundRTPStreamStats final : public RTCRTPStreamStats {
class RTC_EXPORT RTCInboundRTPStreamStats final
: public RTCReceivedRtpStreamStats {
public:
WEBRTC_RTCSTATS_DECL();
@ -415,9 +427,7 @@ class RTC_EXPORT RTCInboundRTPStreamStats final : public RTCRTPStreamStats {
RTCStatsMember<uint64_t> fec_packets_discarded;
RTCStatsMember<uint64_t> bytes_received;
RTCStatsMember<uint64_t> header_bytes_received;
RTCStatsMember<int32_t> packets_lost; // Signed per RFC 3550
RTCStatsMember<double> last_packet_received_timestamp;
RTCStatsMember<double> jitter;
RTCStatsMember<double> jitter_buffer_delay;
RTCStatsMember<uint64_t> jitter_buffer_emitted_count;
RTCStatsMember<uint64_t> total_samples_received;
@ -469,6 +479,16 @@ class RTC_EXPORT RTCInboundRTPStreamStats final : public RTCRTPStreamStats {
// TODO(hbos): This is only implemented for video; implement it for audio as
// well.
RTCStatsMember<std::string> decoder_implementation;
// FIR and PLI counts are only defined for |media_type == "video"|.
RTCStatsMember<uint32_t> fir_count;
RTCStatsMember<uint32_t> pli_count;
// TODO(hbos): NACK count should be collected by |RTCStatsCollector| for both
// audio and video but is only defined in the "video" case. crbug.com/657856
RTCStatsMember<uint32_t> nack_count;
RTCStatsMember<uint64_t> qp_sum;
// Obsolete
RTCStatsMember<bool> is_remote; // = false
};
// https://w3c.github.io/webrtc-stats/#outboundrtpstats-dict*
@ -517,18 +537,21 @@ class RTC_EXPORT RTCOutboundRTPStreamStats final : public RTCRTPStreamStats {
// TODO(hbos): This is only implemented for video; implement it for audio as
// well.
RTCStatsMember<std::string> encoder_implementation;
// FIR and PLI counts are only defined for |media_type == "video"|.
RTCStatsMember<uint32_t> fir_count;
RTCStatsMember<uint32_t> pli_count;
// TODO(hbos): NACK count should be collected by |RTCStatsCollector| for both
// audio and video but is only defined in the "video" case. crbug.com/657856
RTCStatsMember<uint32_t> nack_count;
RTCStatsMember<uint64_t> qp_sum;
// Obsolete
RTCStatsMember<bool> is_remote; // = false
};
// TODO(https://crbug.com/webrtc/10671): Refactor the stats dictionaries to have
// the same hierarchy as in the spec; implement RTCReceivedRtpStreamStats.
// Several metrics are shared between "outbound-rtp", "remote-inbound-rtp",
// "inbound-rtp" and "remote-outbound-rtp". In the spec there is a hierarchy of
// dictionaries that minimizes defining the same metrics in multiple places.
// From JavaScript this hierarchy is not observable and the spec's hierarchy is
// purely editorial. In C++ non-final classes in the hierarchy could be used to
// refer to different stats objects within the hierarchy.
// https://w3c.github.io/webrtc-stats/#remoteinboundrtpstats-dict*
class RTC_EXPORT RTCRemoteInboundRtpStreamStats final : public RTCStats {
class RTC_EXPORT RTCRemoteInboundRtpStreamStats final
: public RTCReceivedRtpStreamStats {
public:
WEBRTC_RTCSTATS_DECL();
@ -537,17 +560,6 @@ class RTC_EXPORT RTCRemoteInboundRtpStreamStats final : public RTCStats {
RTCRemoteInboundRtpStreamStats(const RTCRemoteInboundRtpStreamStats& other);
~RTCRemoteInboundRtpStreamStats() override;
// In the spec RTCRemoteInboundRtpStreamStats inherits from RTCRtpStreamStats
// and RTCReceivedRtpStreamStats. The members here are listed based on where
// they are defined in the spec.
// RTCRtpStreamStats
RTCStatsMember<uint32_t> ssrc;
RTCStatsMember<std::string> kind;
RTCStatsMember<std::string> transport_id;
RTCStatsMember<std::string> codec_id;
// RTCReceivedRtpStreamStats
RTCStatsMember<int32_t> packets_lost;
RTCStatsMember<double> jitter;
// TODO(hbos): The following RTCReceivedRtpStreamStats metrics should also be
// implemented: packetsReceived, packetsDiscarded, packetsRepaired,
// burstPacketsLost, burstPacketsDiscarded, burstLossCount, burstDiscardCount,