Index: webrtc/modules/video_coding/codecs/vp8/screenshare_layers.cc |
diff --git a/webrtc/modules/video_coding/codecs/vp8/screenshare_layers.cc b/webrtc/modules/video_coding/codecs/vp8/screenshare_layers.cc |
index 2480a502e8e02ed92ce79fbfa1f0c51b86b4a5cb..869657b972d08ca795794d0d4cec7a6e2824bbc9 100644 |
--- a/webrtc/modules/video_coding/codecs/vp8/screenshare_layers.cc |
+++ b/webrtc/modules/video_coding/codecs/vp8/screenshare_layers.cc |
@@ -17,6 +17,8 @@ |
#include "vpx/vpx_encoder.h" |
#include "vpx/vp8cx.h" |
#include "webrtc/modules/video_coding/include/video_codec_interface.h" |
+#include "webrtc/system_wrappers/include/clock.h" |
+#include "webrtc/system_wrappers/include/metrics.h" |
namespace webrtc { |
@@ -46,8 +48,10 @@ const int ScreenshareLayers::kTl1SyncFlags = |
VP8_EFLAG_NO_UPD_LAST; |
ScreenshareLayers::ScreenshareLayers(int num_temporal_layers, |
- uint8_t initial_tl0_pic_idx) |
- : number_of_temporal_layers_(num_temporal_layers), |
+ uint8_t initial_tl0_pic_idx, |
+ Clock* clock) |
+ : clock_(clock), |
+ number_of_temporal_layers_(num_temporal_layers), |
last_base_layer_sync_(false), |
tl0_pic_idx_(initial_tl0_pic_idx), |
active_layer_(-1), |
@@ -61,6 +65,10 @@ ScreenshareLayers::ScreenshareLayers(int num_temporal_layers, |
RTC_CHECK_LE(num_temporal_layers, 2); |
} |
+ScreenshareLayers::~ScreenshareLayers() { |
+ UpdateHistograms(); |
+} |
+ |
int ScreenshareLayers::CurrentLayerId() const { |
// Codec does not use temporal layers for screenshare. |
return 0; |
@@ -72,6 +80,9 @@ int ScreenshareLayers::EncodeFlags(uint32_t timestamp) { |
return 0; |
} |
+ if (stats_.first_frame_time_ms_ == -1) |
+ stats_.first_frame_time_ms_ = clock_->TimeInMilliseconds(); |
+ |
int64_t unwrapped_timestamp = time_wrap_handler_.Unwrap(timestamp); |
int flags = 0; |
@@ -104,6 +115,7 @@ int ScreenshareLayers::EncodeFlags(uint32_t timestamp) { |
break; |
case -1: |
flags = -1; |
+ ++stats_.num_dropped_frames_; |
break; |
default: |
flags = -1; |
@@ -176,6 +188,7 @@ void ScreenshareLayers::FrameEncoded(unsigned int size, |
RTC_DCHECK_NE(-1, active_layer_); |
if (size == 0) { |
layers_[active_layer_].state = TemporalLayer::State::kDropped; |
+ ++stats_.num_overshoots_; |
return; |
} |
@@ -189,8 +202,14 @@ void ScreenshareLayers::FrameEncoded(unsigned int size, |
if (active_layer_ == 0) { |
layers_[0].debt_bytes_ += size; |
layers_[1].debt_bytes_ += size; |
+ ++stats_.num_tl0_frames_; |
+ stats_.tl0_target_bitrate_sum_ += layers_[0].target_rate_kbps_; |
+ stats_.tl0_qp_sum_ += qp; |
} else if (active_layer_ == 1) { |
layers_[1].debt_bytes_ += size; |
+ ++stats_.num_tl1_frames_; |
+ stats_.tl1_target_bitrate_sum_ += layers_[1].target_rate_kbps_; |
+ stats_.tl1_qp_sum_ += qp; |
} |
} |
@@ -283,4 +302,42 @@ void ScreenshareLayers::TemporalLayer::UpdateDebt(int64_t delta_ms) { |
} |
} |
+void ScreenshareLayers::UpdateHistograms() { |
+ if (stats_.first_frame_time_ms_ == -1) |
+ return; |
+ int64_t duration_sec = |
+ (clock_->TimeInMilliseconds() - stats_.first_frame_time_ms_ + 500) / 1000; |
+ if (duration_sec >= metrics::kMinRunTimeInSeconds) { |
+ RTC_HISTOGRAM_COUNTS_10000( |
+ "WebRTC.Video.Screenshare.Layer0.FrameRate", |
+ (stats_.num_tl0_frames_ + (duration_sec / 2)) / duration_sec); |
+ RTC_HISTOGRAM_COUNTS_10000( |
+ "WebRTC.Video.Screenshare.Layer1.FrameRate", |
+ (stats_.num_tl1_frames_ + (duration_sec / 2)) / duration_sec); |
+ int total_frames = stats_.num_tl0_frames_ + stats_.num_tl1_frames_; |
+ RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.Screenshare.FramesPerDrop", |
+ stats_.num_dropped_frames_ == 0 |
+ ? 0 |
+ : total_frames / stats_.num_dropped_frames_); |
+ RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.Screenshare.FramesPerOvershoot", |
+ stats_.num_overshoots_ == 0 |
+ ? 0 |
+ : total_frames / stats_.num_overshoots_); |
+ if (stats_.num_tl0_frames_ > 0) { |
+ RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.Screenshare.Layer0.Qp", |
+ stats_.tl0_qp_sum_ / stats_.num_tl0_frames_); |
+ RTC_HISTOGRAM_COUNTS_10000( |
+ "WebRTC.Video.Screenshare.Layer0.TargetBitrate", |
+ stats_.tl0_target_bitrate_sum_ / stats_.num_tl0_frames_); |
+ } |
+ if (stats_.num_tl1_frames_ > 0) { |
+ RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.Screenshare.Layer1.Qp", |
+ stats_.tl1_qp_sum_ / stats_.num_tl1_frames_); |
+ RTC_HISTOGRAM_COUNTS_10000( |
+ "WebRTC.Video.Screenshare.Layer1.TargetBitrate", |
+ stats_.tl1_target_bitrate_sum_ / stats_.num_tl1_frames_); |
+ } |
+ } |
+} |
+ |
} // namespace webrtc |