From da1c65fb53c3925dbd1e7118a322637a00a894b9 Mon Sep 17 00:00:00 2001 From: Artem Titov Date: Wed, 12 Jun 2019 13:17:01 +0200 Subject: [PATCH] Change reporting of time_between_freezes. Report time_between_freezes as test duration when there were no freezes in the call. Bug: webrtc:10138 Change-Id: I3d99be4b714f1b1d13e7b8b7055b368a20859490 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/141665 Reviewed-by: Ilya Nikolaevskiy Commit-Queue: Artem Titov Cr-Commit-Position: refs/heads/master@{#28248} --- .../video/default_video_quality_analyzer.cc | 20 +++++++++++++++---- .../video/default_video_quality_analyzer.h | 1 + 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/test/pc/e2e/analyzer/video/default_video_quality_analyzer.cc b/test/pc/e2e/analyzer/video/default_video_quality_analyzer.cc index 49cdb1899b..ce285338e3 100644 --- a/test/pc/e2e/analyzer/video/default_video_quality_analyzer.cc +++ b/test/pc/e2e/analyzer/video/default_video_quality_analyzer.cc @@ -81,7 +81,10 @@ void DefaultVideoQualityAnalyzer::Start(std::string test_case_name, } { rtc::CritScope crit(&lock_); + RTC_CHECK(start_time_.IsMinusInfinity()); + state_ = State::kActive; + start_time_ = Now(); } } @@ -90,6 +93,13 @@ uint16_t DefaultVideoQualityAnalyzer::OnFrameCaptured( const webrtc::VideoFrame& frame) { // |next_frame_id| is atomic, so we needn't lock here. uint16_t frame_id = next_frame_id_++; + Timestamp start_time = Timestamp::MinusInfinity(); + { + rtc::CritScope crit(&lock_); + // Create a local copy of start_time_ to access it under |comparison_lock_| + // without holding a |lock_| + start_time = start_time_; + } { // Ensure stats for this stream exists. rtc::CritScope crit(&comparison_lock_); @@ -98,7 +108,7 @@ uint16_t DefaultVideoQualityAnalyzer::OnFrameCaptured( // Assume that the first freeze was before first stream frame captured. // This way time before the first freeze would be counted as time between // freezes. - stream_last_freeze_end_time_.insert({stream_label, Now()}); + stream_last_freeze_end_time_.insert({stream_label, start_time}); } } { @@ -298,10 +308,12 @@ void DefaultVideoQualityAnalyzer::Stop() { rtc::CritScope crit1(&lock_); rtc::CritScope crit2(&comparison_lock_); for (auto& item : stream_stats_) { - if (item.second.freeze_time_ms.IsEmpty()) { - continue; - } const StreamState& state = stream_states_[item.first]; + // If there are no freezes in the call we have to report + // time_between_freezes_ms as call duration and in such case + // |stream_last_freeze_end_time_| for this stream will be |start_time_|. + // If there is freeze, then we need add time from last rendered frame + // to last freeze end as time between freezes. if (state.last_rendered_frame_time) { item.second.time_between_freezes_ms.AddSample( (state.last_rendered_frame_time.value() - diff --git a/test/pc/e2e/analyzer/video/default_video_quality_analyzer.h b/test/pc/e2e/analyzer/video/default_video_quality_analyzer.h index caac7648d0..e7be2b5af9 100644 --- a/test/pc/e2e/analyzer/video/default_video_quality_analyzer.h +++ b/test/pc/e2e/analyzer/video/default_video_quality_analyzer.h @@ -263,6 +263,7 @@ class DefaultVideoQualityAnalyzer : public VideoQualityAnalyzerInterface { rtc::CriticalSection lock_; State state_ RTC_GUARDED_BY(lock_) = State::kNew; + Timestamp start_time_ RTC_GUARDED_BY(lock_) = Timestamp::MinusInfinity(); // Frames that were captured by all streams and still aren't rendered by any // stream or deemed dropped. std::map captured_frames_in_flight_