Chromium Code Reviews| 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..4d750e0a2fce0895ae4d1a1a1adfd18b8d5d2674 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_) / |
|
brandtr
2016/11/21 16:46:45
Are you missing a factor 1000 here?
philipel
2016/11/22 14:56:23
Done.
|
| + static_cast<float>(num_total_frames_) + |
| + 0.5f); |
| + RTC_HISTOGRAM_COUNTS_1000("WebRTC.Video.KeyFramesReceivedInPermille", |
| + key_frames_permille); |
| + } |
| +} |
| + |
| } // namespace video_coding |
| } // namespace webrtc |