[PCLF] Introduce API to safely mutate ConfigurableParams in TestPeer
Bug: b/213863770 Change-Id: I90b7b5cd55ac5a8ebee5d790205a4fa6700dfff4 No-Try: True Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/260117 Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Commit-Queue: Artem Titov <titovartem@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36668}
This commit is contained in:
committed by
WebRTC LUCI CQ
parent
24eb595587
commit
a92d051e0f
@ -233,10 +233,10 @@ class PeerConnectionE2EQualityTestFixture {
|
||||
stream_label(std::move(stream_label)) {}
|
||||
|
||||
// Video stream width.
|
||||
const size_t width;
|
||||
size_t width;
|
||||
// Video stream height.
|
||||
const size_t height;
|
||||
const int32_t fps;
|
||||
size_t height;
|
||||
int32_t fps;
|
||||
VideoResolution GetResolution() const {
|
||||
return VideoResolution(width, height, fps);
|
||||
}
|
||||
|
||||
@ -235,9 +235,11 @@ if (!build_with_chromium) {
|
||||
"../../../pc:peerconnection_wrapper",
|
||||
"../../../rtc_base:logging",
|
||||
"../../../rtc_base:refcount",
|
||||
"../../../rtc_base/synchronization:mutex",
|
||||
]
|
||||
absl_deps = [
|
||||
"//third_party/abseil-cpp/absl/memory",
|
||||
"//third_party/abseil-cpp/absl/strings",
|
||||
"//third_party/abseil-cpp/absl/types:variant",
|
||||
]
|
||||
}
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
#include <utility>
|
||||
|
||||
#include "absl/memory/memory.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "api/scoped_refptr.h"
|
||||
#include "modules/audio_processing/include/audio_processing.h"
|
||||
|
||||
@ -20,6 +21,11 @@ namespace webrtc {
|
||||
namespace webrtc_pc_e2e {
|
||||
namespace {
|
||||
|
||||
using VideoSubscription = ::webrtc::webrtc_pc_e2e::
|
||||
PeerConnectionE2EQualityTestFixture::VideoSubscription;
|
||||
using VideoConfig =
|
||||
::webrtc::webrtc_pc_e2e::PeerConnectionE2EQualityTestFixture::VideoConfig;
|
||||
|
||||
class SetRemoteDescriptionCallback
|
||||
: public webrtc::SetRemoteDescriptionObserverInterface {
|
||||
public:
|
||||
@ -39,6 +45,36 @@ class SetRemoteDescriptionCallback
|
||||
|
||||
} // namespace
|
||||
|
||||
ConfigurableParams TestPeer::configurable_params() const {
|
||||
MutexLock lock(&mutex_);
|
||||
return configurable_params_;
|
||||
}
|
||||
|
||||
void TestPeer::AddVideoConfig(VideoConfig config) {
|
||||
MutexLock lock(&mutex_);
|
||||
configurable_params_.video_configs.push_back(std::move(config));
|
||||
}
|
||||
|
||||
void TestPeer::RemoveVideoConfig(absl::string_view stream_label) {
|
||||
MutexLock lock(&mutex_);
|
||||
bool config_removed = false;
|
||||
for (auto it = configurable_params_.video_configs.begin();
|
||||
it != configurable_params_.video_configs.end(); ++it) {
|
||||
if (*it->stream_label == stream_label) {
|
||||
configurable_params_.video_configs.erase(it);
|
||||
config_removed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
RTC_CHECK(config_removed) << *params_.name << ": No video config with label ["
|
||||
<< stream_label << "] was found";
|
||||
}
|
||||
|
||||
void TestPeer::SetVideoSubscription(VideoSubscription subscription) {
|
||||
MutexLock lock(&mutex_);
|
||||
configurable_params_.video_subscription = std::move(subscription);
|
||||
}
|
||||
|
||||
bool TestPeer::SetRemoteDescription(
|
||||
std::unique_ptr<SessionDescriptionInterface> desc,
|
||||
std::string* error_out) {
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "absl/memory/memory.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "api/function_view.h"
|
||||
#include "api/scoped_refptr.h"
|
||||
#include "api/sequence_checker.h"
|
||||
@ -24,6 +25,7 @@
|
||||
#include "pc/peer_connection_wrapper.h"
|
||||
#include "rtc_base/logging.h"
|
||||
#include "rtc_base/ref_counted_object.h"
|
||||
#include "rtc_base/synchronization/mutex.h"
|
||||
#include "test/pc/e2e/peer_configurer.h"
|
||||
#include "test/pc/e2e/peer_connection_quality_test_params.h"
|
||||
|
||||
@ -34,9 +36,14 @@ namespace webrtc_pc_e2e {
|
||||
class TestPeer final {
|
||||
public:
|
||||
const Params& params() const { return params_; }
|
||||
ConfigurableParams configurable_params() const {
|
||||
return configurable_params_;
|
||||
}
|
||||
|
||||
ConfigurableParams configurable_params() const;
|
||||
void AddVideoConfig(PeerConnectionE2EQualityTestFixture::VideoConfig config);
|
||||
// Removes video config with specified name. Crashes if the config with
|
||||
// specified name isn't found.
|
||||
void RemoveVideoConfig(absl::string_view stream_label);
|
||||
void SetVideoSubscription(
|
||||
PeerConnectionE2EQualityTestFixture::VideoSubscription subscription);
|
||||
|
||||
PeerConfigurerImpl::VideoSource ReleaseVideoSource(size_t i) {
|
||||
RTC_CHECK(wrapper_) << "TestPeer is already closed";
|
||||
@ -150,8 +157,11 @@ class TestPeer final {
|
||||
std::unique_ptr<rtc::Thread> worker_thread);
|
||||
|
||||
private:
|
||||
Params params_;
|
||||
ConfigurableParams configurable_params_;
|
||||
const Params params_;
|
||||
|
||||
mutable Mutex mutex_;
|
||||
ConfigurableParams configurable_params_ RTC_GUARDED_BY(mutex_);
|
||||
|
||||
// Keeps ownership of worker thread. It has to be destroyed after `wrapper_`.
|
||||
std::unique_ptr<rtc::Thread> worker_thread_;
|
||||
std::unique_ptr<PeerConnectionWrapper> wrapper_;
|
||||
|
||||
Reference in New Issue
Block a user