Add dropped frames metric on the receive side
Reported to UMA and logged for at the end of the call.
Bug: webrtc:8355
Change-Id: I4ef31bf9e55feaba9cf28be5cb4fcfae929c7179
Reviewed-on: https://webrtc-review.googlesource.com/53760
Reviewed-by: Philip Eliasson <philipel@webrtc.org>
Reviewed-by: Erik Språng <sprang@webrtc.org>
Commit-Queue: Ilya Nikolaevskiy <ilnik@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22132}
diff --git a/modules/video_coding/packet_buffer.h b/modules/video_coding/packet_buffer.h
index c1ca7b8..869a81c 100644
--- a/modules/video_coding/packet_buffer.h
+++ b/modules/video_coding/packet_buffer.h
@@ -12,6 +12,7 @@
#define MODULES_VIDEO_CODING_PACKET_BUFFER_H_
#include <memory>
+#include <queue>
#include <set>
#include <vector>
@@ -61,6 +62,9 @@
rtc::Optional<int64_t> LastReceivedPacketMs() const;
rtc::Optional<int64_t> LastReceivedKeyframePacketMs() const;
+ // Returns number of different frames seen in the packet buffer
+ int GetUniqueFramesSeen() const;
+
int AddRef() const;
int Release() const;
@@ -126,6 +130,10 @@
void UpdateMissingPackets(uint16_t seq_num)
RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_);
+ // Counts unique received timestamps and updates |unique_frames_seen_|.
+ void OnTimestampReceived(uint32_t rtp_timestamp)
+ RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_);
+
rtc::CriticalSection crit_;
// Buffer size_ and max_size_ must always be a power of two.
@@ -156,6 +164,8 @@
rtc::Optional<int64_t> last_received_keyframe_packet_ms_
RTC_GUARDED_BY(crit_);
+ int unique_frames_seen_ RTC_GUARDED_BY(crit_);
+
rtc::Optional<uint16_t> newest_inserted_seq_num_ RTC_GUARDED_BY(crit_);
std::set<uint16_t, DescendingSeqNumComp<uint16_t>> missing_packets_
RTC_GUARDED_BY(crit_);
@@ -164,6 +174,11 @@
// RTP timestamp to treat the corresponding frame as a keyframe.
const bool sps_pps_idr_is_h264_keyframe_;
+ // Stores several last seen unique timestamps for quick search.
+ std::set<uint32_t> rtp_timestamps_history_set_ RTC_GUARDED_BY(crit_);
+ // Stores the same unique timestamps in the order of insertion.
+ std::queue<uint32_t> rtp_timestamps_history_queue_ RTC_GUARDED_BY(crit_);
+
mutable volatile int ref_count_ = 0;
};