From 79f82c1a5767f765e83c19927a517f5d1c43ad45 Mon Sep 17 00:00:00 2001 From: Artem Titov Date: Fri, 3 Sep 2021 22:05:15 +0200 Subject: [PATCH] [PCLF] introduce a Peer class which later will be used to perform in-call actions Bug: b/198796179 Change-Id: Ic4ea2b8d03cbc524334d72ef5c8b3ad1ecd39359 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/231182 Commit-Queue: Artem Titov Reviewed-by: Mirko Bonadei Cr-Commit-Position: refs/heads/main@{#34920} --- api/test/peerconnection_quality_test_fixture.h | 15 ++++++++++++++- test/pc/e2e/peer_connection_quality_test.cc | 12 +++++++++++- test/pc/e2e/peer_connection_quality_test.h | 10 ++++++++++ 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/api/test/peerconnection_quality_test_fixture.h b/api/test/peerconnection_quality_test_fixture.h index 4f691d7449..d9eb9d6ed4 100644 --- a/api/test/peerconnection_quality_test_fixture.h +++ b/api/test/peerconnection_quality_test_fixture.h @@ -465,6 +465,13 @@ class PeerConnectionE2EQualityTestFixture { virtual void StopAndReportResults() = 0; }; + // Represents single participant in call and can be used to perform different + // in-call actions. Might be extended in future. + class PeerHandle { + public: + virtual ~PeerHandle() = default; + }; + virtual ~PeerConnectionE2EQualityTestFixture() = default; // Add activity that will be executed on the best effort at least after @@ -493,7 +500,13 @@ class PeerConnectionE2EQualityTestFixture { // `configurer` function will be used to configure peer in the call. virtual void AddPeer(rtc::Thread* network_thread, rtc::NetworkManager* network_manager, - rtc::FunctionView configurer) = 0; + rtc::FunctionView configurer) {} + virtual PeerHandle* AddAndReturnPeer( + rtc::Thread* network_thread, + rtc::NetworkManager* network_manager, + rtc::FunctionView configurer) { + return nullptr; + } // Runs the media quality test, which includes setting up the call with // configured participants, running it according to provided `run_params` and // terminating it properly at the end. During call duration media quality diff --git a/test/pc/e2e/peer_connection_quality_test.cc b/test/pc/e2e/peer_connection_quality_test.cc index e4c7cf061f..f85d08c6af 100644 --- a/test/pc/e2e/peer_connection_quality_test.cc +++ b/test/pc/e2e/peer_connection_quality_test.cc @@ -154,13 +154,23 @@ void PeerConnectionE2EQualityTest::AddQualityMetricsReporter( quality_metrics_reporters_.push_back(std::move(quality_metrics_reporter)); } -void PeerConnectionE2EQualityTest::AddPeer( +PeerConnectionE2EQualityTest::PeerHandle* +PeerConnectionE2EQualityTest::AddAndReturnPeer( rtc::Thread* network_thread, rtc::NetworkManager* network_manager, rtc::FunctionView configurer) { peer_configurations_.push_back( std::make_unique(network_thread, network_manager)); configurer(peer_configurations_.back().get()); + peer_handles_.push_back(PeerHandleImpl()); + return &peer_handles_.back(); +} + +void PeerConnectionE2EQualityTest::AddPeer( + rtc::Thread* network_thread, + rtc::NetworkManager* network_manager, + rtc::FunctionView configurer) { + AddAndReturnPeer(network_thread, network_manager, configurer); } void PeerConnectionE2EQualityTest::Run(RunParams run_params) { diff --git a/test/pc/e2e/peer_connection_quality_test.h b/test/pc/e2e/peer_connection_quality_test.h index d0932fd884..69c92401a5 100644 --- a/test/pc/e2e/peer_connection_quality_test.h +++ b/test/pc/e2e/peer_connection_quality_test.h @@ -71,6 +71,10 @@ class PeerConnectionE2EQualityTest void AddPeer(rtc::Thread* network_thread, rtc::NetworkManager* network_manager, rtc::FunctionView configurer) override; + PeerHandle* AddAndReturnPeer( + rtc::Thread* network_thread, + rtc::NetworkManager* network_manager, + rtc::FunctionView configurer) override; void Run(RunParams run_params) override; TimeDelta GetRealTestDuration() const override { @@ -80,6 +84,11 @@ class PeerConnectionE2EQualityTest } private: + class PeerHandleImpl : public PeerHandle { + public: + ~PeerHandleImpl() override = default; + }; + // For some functionality some field trials have to be enabled, they will be // enabled in Run(). std::string GetFieldTrials(const RunParams& run_params); @@ -114,6 +123,7 @@ class PeerConnectionE2EQualityTest std::unique_ptr executor_; std::vector> peer_configurations_; + std::vector peer_handles_; std::unique_ptr alice_; std::unique_ptr bob_;