Index: webrtc/modules/video_coding/frame_buffer2.cc |
diff --git a/webrtc/modules/video_coding/frame_buffer2.cc b/webrtc/modules/video_coding/frame_buffer2.cc |
index e02e5b6071c14bcb72567d0a43600ae6959b68c3..bf1760ec279052482152c602ec3b6e0d21db7653 100644 |
--- a/webrtc/modules/video_coding/frame_buffer2.cc |
+++ b/webrtc/modules/video_coding/frame_buffer2.cc |
@@ -19,6 +19,7 @@ |
#include "webrtc/modules/video_coding/jitter_estimator.h" |
#include "webrtc/modules/video_coding/timing.h" |
#include "webrtc/system_wrappers/include/clock.h" |
+#include "webrtc/system_wrappers/include/metrics.h" |
namespace webrtc { |
namespace video_coding { |
@@ -44,7 +45,13 @@ FrameBuffer::FrameBuffer(Clock* clock, |
num_frames_history_(0), |
num_frames_buffered_(0), |
stopped_(false), |
- protection_mode_(kProtectionNack) {} |
+ protection_mode_(kProtectionNack), |
+ num_total_frames_(0), |
+ num_key_frames_(0) {} |
+ |
+FrameBuffer::~FrameBuffer() { |
+ UpdateHistograms(); |
+} |
FrameBuffer::ReturnReason FrameBuffer::NextFrame( |
int64_t max_wait_time_ms, |
@@ -155,6 +162,10 @@ int FrameBuffer::InsertFrame(std::unique_ptr<FrameObject> frame) { |
rtc::CritScope lock(&crit_); |
RTC_DCHECK(frame); |
+ ++num_total_frames_; |
+ if (frame->num_references == 0) |
+ ++num_key_frames_; |
+ |
FrameKey key(frame->picture_id, frame->spatial_layer); |
int last_continuous_picture_id = |
last_continuous_frame_it_ == frames_.end() |
@@ -353,5 +364,16 @@ bool FrameBuffer::UpdateFrameInfoWithIncomingFrame(const FrameObject& frame, |
return true; |
} |
+void FrameBuffer::UpdateHistograms() const { |
+ rtc::CritScope lock(&crit_); |
+ if (num_total_frames_ > 0) { |
+ int key_frames_permille = (static_cast<float>(num_key_frames_) * 1000.0f / |
+ static_cast<float>(num_total_frames_) + |
+ 0.5f); |
+ RTC_HISTOGRAM_COUNTS_1000("WebRTC.Video.KeyFramesReceivedInPermille", |
+ key_frames_permille); |
+ } |
+} |
+ |
} // namespace video_coding |
} // namespace webrtc |