From 713188010ba839b94ff50de6babaa0af4ea4445b Mon Sep 17 00:00:00 2001 From: Mirko Bonadei Date: Mon, 18 Feb 2019 18:52:43 +0100 Subject: [PATCH] Don't block the signaling thread during the call. Since WebRTC stats are collected on the signaling thread, this CL moves the wait from the signaling thread to the main thread. Bug: webrtc:10138 Change-Id: I0e554fe82e3a4afe66b45e53032b06d533f54a39 Reviewed-on: https://webrtc-review.googlesource.com/c/123228 Commit-Queue: Mirko Bonadei Reviewed-by: Artem Titov Reviewed-by: Karl Wiberg Cr-Commit-Position: refs/heads/master@{#26746} --- test/pc/e2e/BUILD.gn | 1 + test/pc/e2e/peer_connection_quality_test.cc | 24 +++++++++++++++------ test/pc/e2e/peer_connection_quality_test.h | 3 ++- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/test/pc/e2e/BUILD.gn b/test/pc/e2e/BUILD.gn index 27955a35c4..8cede7029e 100644 --- a/test/pc/e2e/BUILD.gn +++ b/test/pc/e2e/BUILD.gn @@ -216,6 +216,7 @@ if (rtc_include_tests) { "../../../rtc_base:gunit_helpers", "../../../rtc_base:rtc_base", "../../../rtc_base:rtc_base_approved", + "../../../rtc_base:safe_conversions", "../../../system_wrappers:system_wrappers", "../../../test:fileutils", "../../../test:video_test_support", diff --git a/test/pc/e2e/peer_connection_quality_test.cc b/test/pc/e2e/peer_connection_quality_test.cc index 4f293fa42c..7efb8116e3 100644 --- a/test/pc/e2e/peer_connection_quality_test.cc +++ b/test/pc/e2e/peer_connection_quality_test.cc @@ -11,6 +11,7 @@ */ #include "test/pc/e2e/peer_connection_quality_test.h" +#include #include #include @@ -22,6 +23,7 @@ #include "pc/test/mock_peer_connection_observers.h" #include "rtc_base/bind.h" #include "rtc_base/gunit.h" +#include "rtc_base/numerics/safe_conversions.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" @@ -189,8 +191,19 @@ void PeerConnectionE2EQualityTest::Run( video_quality_analyzer_injection_helper_->Start(video_analyzer_threads); signaling_thread->Invoke( RTC_FROM_HERE, - rtc::Bind(&PeerConnectionE2EQualityTest::RunOnSignalingThread, this, - run_params)); + rtc::Bind(&PeerConnectionE2EQualityTest::SetupCallOnSignalingThread, + this)); + + // TODO(bugs.webrtc.org/10138): Implement stats collection and send stats + // reports to analyzers every 1 second. + rtc::Event done; + done.Wait(rtc::checked_cast(run_params.run_duration.ms())); + + signaling_thread->Invoke( + RTC_FROM_HERE, + rtc::Bind(&PeerConnectionE2EQualityTest::TearDownCallOnSignalingThread, + this)); + video_quality_analyzer_injection_helper_->Stop(); // Ensuring that TestPeers have been destroyed in order to correctly close @@ -296,15 +309,14 @@ void PeerConnectionE2EQualityTest::SetupVideoSink( output_video_sinks_.push_back(std::move(video_sink)); } -void PeerConnectionE2EQualityTest::RunOnSignalingThread(RunParams run_params) { +void PeerConnectionE2EQualityTest::SetupCallOnSignalingThread() { alice_video_sources_ = AddMedia(alice_.get()); bob_video_sources_ = AddMedia(bob_.get()); SetupCall(); +} - rtc::Event done; - done.Wait(static_cast(run_params.run_duration.ms())); - +void PeerConnectionE2EQualityTest::TearDownCallOnSignalingThread() { TearDownCall(); } diff --git a/test/pc/e2e/peer_connection_quality_test.h b/test/pc/e2e/peer_connection_quality_test.h index b19a4fe6da..be146f7fa3 100644 --- a/test/pc/e2e/peer_connection_quality_test.h +++ b/test/pc/e2e/peer_connection_quality_test.h @@ -58,7 +58,8 @@ class PeerConnectionE2EQualityTest void SetupVideoSink(rtc::scoped_refptr transceiver, std::vector remote_video_configs); // Have to be run on the signaling thread. - void RunOnSignalingThread(RunParams run_params); + void SetupCallOnSignalingThread(); + void TearDownCallOnSignalingThread(); std::vector> AddMedia(TestPeer* peer); std::vector>