Rasmus Brandt 621cb2943d Fix video version of RTCInboundRtpStreamStats.jitterBufferDelay to obey spec.
Prior to this CL, the video `jitterBufferDelay` stat was the accumulated current delay, which is a smoothened version of the target delay. This is not correct according to the spec [1]. Rather, the stat should be the accumulated time spent in the jitter buffer, for all emitted frames. This CL fixes this spec compliance problem.

Expect changes to test metrics and product monitoring as this CL rolls out.

[1]: https://www.w3.org/TR/webrtc-stats/#dom-rtcinboundrtpstreamstats-jitterbufferdelay

Tested:
1. Go to https://jsfiddle.net/jib1/0L6duga2/show
2. Apply 2.0 seconds of video delay.
3. Notice that "Video jitter buffer delay" is slightly less than 1990ms. (2000ms playoutdelayhint - 10ms render delay - Xms decode delay).

Bug: webrtc:15085
Change-Id: I42805faafd7dd3bcdcf3ad08e751e08d6de38906
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/304521
Reviewed-by: Åsa Persson <asapersson@webrtc.org>
Commit-Queue: Rasmus Brandt <brandtr@webrtc.org>
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#40138}
2023-05-25 07:33:39 +00:00

16 KiB

Video stats

Overview of collected statistics for VideoSendStream and VideoReceiveStream.

VideoSendStream

VideoSendStream::Stats for a sending stream can be gathered via VideoSendStream::GetStats().

Some statistics are collected per RTP stream (see StreamStats) and can be of StreamType: kMedia, kRtx, kFlexfec.

Multiple StreamStats objects are for example present if simulcast is used (multiple kMedia objects) or if RTX or FlexFEC is negotiated.

SendStatisticsProxy

VideoSendStream owns a SendStatisticsProxy which implements VideoStreamEncoderObserver, RtcpStatisticsCallback, ReportBlockDataObserver, RtcpPacketTypeCounterObserver, StreamDataCountersCallback, BitrateStatisticsObserver, FrameCountObserver, SendSideDelayObserver and holds a VideoSendStream::Stats object.

SendStatisticsProxy is called via these interfaces by different components (e.g. RtpRtcp module) to update stats.

StreamStats

  • type - kMedia, kRtx or kFlexfec.
  • referenced_media_ssrc - only present for type kRtx/kFlexfec. The SSRC for the kMedia stream that retransmissions or FEC is performed for.

Updated when a frame has been encoded, VideoStreamEncoder::OnEncodedImage.

Updated when a RTP packet is transmitted to the network, RtpSenderEgress::SendPacket.

  • rtp_stats - total number of sent bytes/packets.
  • total_bitrate_bps - total bitrate sent in bits per second (over a one second window).
  • retransmit_bitrate_bps - total retransmit bitrate sent in bits per second (over a one second window).
  • avg_delay_ms - average capture-to-send delay for sent packets (over a one second window).
  • max_delay_ms - maximum capture-to-send delay for sent packets (over a one second window).
  • total_packet_send_delay_ms - total capture-to-send delay for sent packets [rtcoutboundrtpstreamstats-totalpacketsenddelay].

Updated when an incoming RTCP packet is parsed, RTCPReceiver::ParseCompoundPacket.

  • rtcp_packet_type_counts - total number of received NACK/FIR/PLI packets [rtcoutboundrtpstreamstats-nackcount, fircount, plicount].

Updated when a RTCP report block packet is received, RTCPReceiver::TriggerCallbacksFromRtcpPacket.

  • rtcp_stats - RTCP report block data.
  • report_block_data - RTCP report block data.

Stats

  • std::map<uint32_t, StreamStats> substreams - StreamStats mapped per SSRC.

Updated when a frame is received from the source, VideoStreamEncoder::OnFrame.

  • frames - total number of frames fed to VideoStreamEncoder.
  • input_frame_rate - number of frames fed to VideoStreamEncoder during the last second.
  • frames_dropped_by_congestion_window - total number of dropped frames due to congestion window pushback.
  • frames_dropped_by_encoder_queue - total number of dropped frames due to that the encoder is blocked.

Updated if a frame from the source is dropped, VideoStreamEncoder::OnDiscardedFrame.

  • frames_dropped_by_capturer - total number dropped frames by the source.

Updated if a frame is dropped by FrameDropper, VideoStreamEncoder::MaybeEncodeVideoFrame.

  • frames_dropped_by_rate_limiter - total number of dropped frames to avoid bitrate overuse.

Updated (if changed) before a frame is passed to the encoder, VideoStreamEncoder::EncodeVideoFrame.

Updated after a frame has been encoded, VideoStreamEncoder::OnEncodedImage.

Adaptation stats.

  • bw_limited_resolution - shows if resolution is limited due to restricted bandwidth.
  • cpu_limited_resolution - shows if resolution is limited due to cpu.
  • bw_limited_framerate - shows if framerate is limited due to restricted bandwidth.
  • cpu_limited_framerate - shows if framerate is limited due to cpu.
  • quality_limitation_reason - current reason for limiting resolution and/or framerate [rtcoutboundrtpstreamstats-qualitylimitationreason].
  • quality_limitation_durations_ms - total time spent in quality limitation state [rtcoutboundrtpstreamstats-qualitylimitationdurations].
  • quality_limitation_resolution_changes - total number of times that resolution has changed due to quality limitation [rtcoutboundrtpstreamstats-qualitylimitationresolutionchanges].
  • number_of_cpu_adapt_changes - total number of times resolution/framerate has changed due to cpu limitation.
  • number_of_quality_adapt_changes - total number of times resolution/framerate has changed due to quality limitation.

Updated when the encoder is configured, VideoStreamEncoder::ReconfigureEncoder.

  • content_type - configured content type (UNSPECIFIED/SCREENSHARE).

Updated when the available bitrate changes, VideoSendStreamImpl::OnBitrateUpdated.

  • target_media_bitrate_bps - the bitrate the encoder is configured to use.
  • suspended - shows if video is suspended due to zero target bitrate.

VideoReceiveStream

VideoReceiveStream::Stats for a receiving stream can be gathered via VideoReceiveStream::GetStats().

ReceiveStatisticsProxy

VideoReceiveStream owns a ReceiveStatisticsProxy which implements VideoStreamBufferControllerStatsObserver, RtcpCnameCallback, RtcpPacketTypeCounterObserver, CallStatsObserver and holds a VideoReceiveStream::Stats object.

ReceiveStatisticsProxy is called via these interfaces by different components (e.g. RtpRtcp module) to update stats.

Stats

  • current_payload_type - current payload type.
  • ssrc - configured SSRC for the received stream.

Updated when a complete frame is received, FrameBuffer::InsertFrame.

Updated when a frame is ready for decoding, FrameBuffer::GetNextFrame. From VCMTiming:

  • jitter_buffer_ms - jitter delay in ms: this is the delay added to handle network jitter
  • max_decode_ms - the 95th percentile observed decode time within a time window (10 sec).
  • render_delay_ms - render delay in ms.
  • min_playout_delay_ms - minimum playout delay in ms.
  • target_delay_ms - target playout delay in ms. Max(min_playout_delay_ms, jitter_delay_ms + max_decode_ms + render_delay_ms).
  • current_delay_ms - actual playout delay in ms.
  • jitter_buffer_delay_seconds - total jitter buffer delay in seconds: this is the time spent waiting in the jitter buffer [rtcinboundrtpstreamstats-jitterbufferdelay].
  • jitter_buffer_emitted_count - total number of frames that have come out from the jitter buffer [rtcinboundrtpstreamstats-jitterbufferemittedcount].

Updated (if changed) after a frame is passed to the decoder, VCMGenericDecoder::Decode.

Updated when a frame is ready for decoding, FrameBuffer::GetNextFrame.

  • timing_frame_info - timestamps for a full lifetime of a frame.
  • first_frame_received_to_decoded_ms - initial decoding latency between the first arrived frame and the first decoded frame.
  • frames_dropped - total number of dropped frames prior to decoding or if the system is too slow [rtcreceivedrtpstreamstats-framesdropped].

Updated after a frame has been decoded, VCMDecodedFrameCallback::Decoded.

Updated before a frame is sent to the renderer, VideoReceiveStream2::OnFrame.

ReceiveStatisticsImpl::OnRtpPacket is updated for received RTP packets. From ReceiveStatistics:

  • total_bitrate_bps - incoming bitrate in bps.
  • rtp_stats - RTP statistics for the received stream.

Updated when a RTCP packet is sent, RTCPSender::ComputeCompoundRTCPPacket.

  • rtcp_packet_type_counts - total number of sent NACK/FIR/PLI packets [rtcinboundrtpstreamstats-nackcount, fircount, plicount].