From 9f97c9a528c0d815ce8854a44552142bb450689c Mon Sep 17 00:00:00 2001 From: Artem Titov Date: Fri, 8 Feb 2019 00:35:13 +0100 Subject: [PATCH] Add starting of VideoQualityAnalyzer in the e2e peer connection level test Bug: webrtc:10138 Change-Id: Ic762543e21a5b55c7f15856fe752534b910dec8f Reviewed-on: https://webrtc-review.googlesource.com/c/121941 Commit-Queue: Artem Titov Reviewed-by: Peter Slatala Cr-Commit-Position: refs/heads/master@{#26599} --- ...video_quality_analyzer_injection_helper.cc | 4 ++++ .../video_quality_analyzer_injection_helper.h | 2 ++ test/pc/e2e/peer_connection_quality_test.cc | 23 ++++++++++++++++++- 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/test/pc/e2e/analyzer/video/video_quality_analyzer_injection_helper.cc b/test/pc/e2e/analyzer/video/video_quality_analyzer_injection_helper.cc index fab8849281..815505c810 100644 --- a/test/pc/e2e/analyzer/video/video_quality_analyzer_injection_helper.cc +++ b/test/pc/e2e/analyzer/video/video_quality_analyzer_injection_helper.cc @@ -131,6 +131,10 @@ VideoQualityAnalyzerInjectionHelper::CreateVideoSink( return absl::make_unique(analyzer_.get(), writer); } +void VideoQualityAnalyzerInjectionHelper::Start(int max_threads_count) { + analyzer_->Start(max_threads_count); +} + void VideoQualityAnalyzerInjectionHelper::Stop() { analyzer_->Stop(); } diff --git a/test/pc/e2e/analyzer/video/video_quality_analyzer_injection_helper.h b/test/pc/e2e/analyzer/video/video_quality_analyzer_injection_helper.h index 40a381d73a..880723f88f 100644 --- a/test/pc/e2e/analyzer/video/video_quality_analyzer_injection_helper.h +++ b/test/pc/e2e/analyzer/video/video_quality_analyzer_injection_helper.h @@ -59,6 +59,8 @@ class VideoQualityAnalyzerInjectionHelper { std::unique_ptr> CreateVideoSink( VideoFrameWriter* writer) const; + void Start(int max_threads_count); + // Stops VideoQualityAnalyzerInterface to populate final data and metrics. void Stop(); diff --git a/test/pc/e2e/peer_connection_quality_test.cc b/test/pc/e2e/peer_connection_quality_test.cc index e356e59deb..174a20cbcc 100644 --- a/test/pc/e2e/peer_connection_quality_test.cc +++ b/test/pc/e2e/peer_connection_quality_test.cc @@ -18,6 +18,7 @@ #include "api/units/time_delta.h" #include "rtc_base/bind.h" #include "rtc_base/gunit.h" +#include "system_wrappers/include/cpu_info.h" #include "test/pc/e2e/analyzer/video/example_video_quality_analyzer.h" #include "test/pc/e2e/api/video_quality_analyzer_interface.h" #include "test/testsupport/file_utils.h" @@ -30,6 +31,12 @@ using VideoConfig = PeerConnectionE2EQualityTestFixture::VideoConfig; constexpr int kDefaultTimeoutMs = 10000; constexpr char kSignalThreadName[] = "signaling_thread"; +// 1 signaling, 2 network, 2 worker and 2 extra for codecs etc. +constexpr int kPeerConnectionUsedThreads = 7; +// Framework has extra thread for network layer and extra thread for peer +// connection stats polling. +constexpr int kFrameworkUsedThreads = 2; +constexpr int kMaxVideoAnalyzerThreads = 8; std::string VideoConfigSourcePresenceToString(const VideoConfig& video_config) { char buf[1024]; @@ -115,10 +122,25 @@ PeerConnectionE2EQualityTest::PeerConnectionE2EQualityTest( void PeerConnectionE2EQualityTest::Run(RunParams run_params) { SetMissedVideoStreamLabels({alice_->params(), bob_->params()}); ValidateParams({alice_->params(), bob_->params()}); + + int num_cores = CpuInfo::DetectNumberOfCores(); + RTC_DCHECK_GE(num_cores, 1); + + int video_analyzer_threads = + num_cores - kPeerConnectionUsedThreads - kFrameworkUsedThreads; + if (video_analyzer_threads <= 0) { + video_analyzer_threads = 1; + } + video_analyzer_threads = + std::min(video_analyzer_threads, kMaxVideoAnalyzerThreads); + RTC_LOG(INFO) << "video_analyzer_threads=" << video_analyzer_threads; + + video_quality_analyzer_injection_helper_->Start(video_analyzer_threads); signaling_thread_->Invoke( RTC_FROM_HERE, rtc::Bind(&PeerConnectionE2EQualityTest::RunOnSignalingThread, this, run_params)); + video_quality_analyzer_injection_helper_->Stop(); } void PeerConnectionE2EQualityTest::SetMissedVideoStreamLabels( @@ -192,7 +214,6 @@ void PeerConnectionE2EQualityTest::RunOnSignalingThread(RunParams run_params) { done.Wait(static_cast(run_params.run_duration.ms())); TearDownCall(); - video_quality_analyzer_injection_helper_->Stop(); } void PeerConnectionE2EQualityTest::AddMedia(TestPeer* peer) {