Refactor PC tests to use non-global field trials

In particular that avoids lifetime issues with the field trials passed into peerconnection, as now PC takes field trials object by unique_ptr and thus fully manages its lifetime.

Bug: webrtc:42220378
Change-Id: Ia863e9703b5c76ae1866d0ff995b83286c0b947e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/371480
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Per Kjellander <perkj@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#43576}
This commit is contained in:
Danil Chapovalov 2024-12-16 11:37:36 +01:00 committed by WebRTC LUCI CQ
parent 108cde271b
commit acf26ce00a
16 changed files with 86 additions and 126 deletions

View File

@ -2308,6 +2308,7 @@ if (rtc_include_tests && !build_with_chromium) {
"../api:enable_media_with_defaults", "../api:enable_media_with_defaults",
"../api:fake_frame_decryptor", "../api:fake_frame_decryptor",
"../api:fake_frame_encryptor", "../api:fake_frame_encryptor",
"../api:field_trials",
"../api:field_trials_view", "../api:field_trials_view",
"../api:function_view", "../api:function_view",
"../api:ice_transport_interface", "../api:ice_transport_interface",
@ -2416,10 +2417,8 @@ if (rtc_include_tests && !build_with_chromium) {
"../rtc_base/third_party/base64", "../rtc_base/third_party/base64",
"../rtc_base/third_party/sigslot", "../rtc_base/third_party/sigslot",
"../system_wrappers:metrics", "../system_wrappers:metrics",
"../test:field_trial",
"../test:rtc_expect_death", "../test:rtc_expect_death",
"../test:run_loop", "../test:run_loop",
"../test:scoped_key_value_config",
"../test:wait_until", "../test:wait_until",
"../test/pc/sctp:fake_sctp_transport", "../test/pc/sctp:fake_sctp_transport",
"//testing/gtest", "//testing/gtest",
@ -2550,6 +2549,7 @@ if (rtc_include_tests && !build_with_chromium) {
"../api:enable_media_with_defaults", "../api:enable_media_with_defaults",
"../api:fake_frame_decryptor", "../api:fake_frame_decryptor",
"../api:fake_frame_encryptor", "../api:fake_frame_encryptor",
"../api:field_trials",
"../api:field_trials_view", "../api:field_trials_view",
"../api:function_view", "../api:function_view",
"../api:ice_transport_interface", "../api:ice_transport_interface",
@ -2580,7 +2580,6 @@ if (rtc_include_tests && !build_with_chromium) {
"../api/task_queue", "../api/task_queue",
"../api/task_queue:default_task_queue_factory", "../api/task_queue:default_task_queue_factory",
"../api/task_queue:pending_task_safety_flag", "../api/task_queue:pending_task_safety_flag",
"../api/transport:field_trial_based_config",
"../api/transport/rtp:rtp_source", "../api/transport/rtp:rtp_source",
"../api/units:time_delta", "../api/units:time_delta",
"../api/video:builtin_video_bitrate_allocator_factory", "../api/video:builtin_video_bitrate_allocator_factory",

View File

@ -17,7 +17,6 @@
#include "api/peer_connection_interface.h" #include "api/peer_connection_interface.h"
#include "pc/test/integration_test_helpers.h" #include "pc/test/integration_test_helpers.h"
#include "rtc_base/gunit.h" #include "rtc_base/gunit.h"
#include "test/field_trial.h"
#include "test/gmock.h" #include "test/gmock.h"
#include "test/gtest.h" #include "test/gtest.h"
@ -35,21 +34,16 @@ class PeerConnectionCongestionControlTest
}; };
TEST_F(PeerConnectionCongestionControlTest, OfferContainsCcfbIfEnabled) { TEST_F(PeerConnectionCongestionControlTest, OfferContainsCcfbIfEnabled) {
test::ScopedFieldTrials trials( SetFieldTrials("WebRTC-RFC8888CongestionControlFeedback/Enabled/");
"WebRTC-RFC8888CongestionControlFeedback/Enabled/");
ASSERT_TRUE(CreatePeerConnectionWrappers()); ASSERT_TRUE(CreatePeerConnectionWrappers());
caller()->AddAudioVideoTracks(); caller()->AddAudioVideoTracks();
auto offer = caller()->CreateOfferAndWait(); auto offer = caller()->CreateOfferAndWait();
std::string offer_str = absl::StrCat(*offer); std::string offer_str = absl::StrCat(*offer);
EXPECT_THAT(offer_str, HasSubstr("a=rtcp-fb:* ack ccfb\r\n")); EXPECT_THAT(offer_str, HasSubstr("a=rtcp-fb:* ack ccfb\r\n"));
// Closing peer connections before ScopedFieldTrials gets out of scope to
// avoid a race condition.
ClosePeerConnections();
} }
TEST_F(PeerConnectionCongestionControlTest, ReceiveOfferSetsCcfbFlag) { TEST_F(PeerConnectionCongestionControlTest, ReceiveOfferSetsCcfbFlag) {
test::ScopedFieldTrials trials( SetFieldTrials("WebRTC-RFC8888CongestionControlFeedback/Enabled/");
"WebRTC-RFC8888CongestionControlFeedback/Enabled/");
ASSERT_TRUE(CreatePeerConnectionWrappers()); ASSERT_TRUE(CreatePeerConnectionWrappers());
ConnectFakeSignalingForSdpOnly(); ConnectFakeSignalingForSdpOnly();
caller()->AddAudioVideoTracks(); caller()->AddAudioVideoTracks();
@ -72,14 +66,10 @@ TEST_F(PeerConnectionCongestionControlTest, ReceiveOfferSetsCcfbFlag) {
// Check that the answer does not contain transport-cc // Check that the answer does not contain transport-cc
std::string answer_str = absl::StrCat(*caller()->pc()->remote_description()); std::string answer_str = absl::StrCat(*caller()->pc()->remote_description());
EXPECT_THAT(answer_str, Not(HasSubstr("transport-cc"))); EXPECT_THAT(answer_str, Not(HasSubstr("transport-cc")));
// Closing peer connections before ScopedFieldTrials gets out of scope to
// avoid a race condition.
ClosePeerConnections();
} }
TEST_F(PeerConnectionCongestionControlTest, CcfbGetsUsed) { TEST_F(PeerConnectionCongestionControlTest, CcfbGetsUsed) {
test::ScopedFieldTrials trials( SetFieldTrials("WebRTC-RFC8888CongestionControlFeedback/Enabled/");
"WebRTC-RFC8888CongestionControlFeedback/Enabled/");
ASSERT_TRUE(CreatePeerConnectionWrappers()); ASSERT_TRUE(CreatePeerConnectionWrappers());
ConnectFakeSignaling(); ConnectFakeSignaling();
caller()->AddAudioVideoTracks(); caller()->AddAudioVideoTracks();
@ -95,14 +85,10 @@ TEST_F(PeerConnectionCongestionControlTest, CcfbGetsUsed) {
// There should be no transport-cc generated. // There should be no transport-cc generated.
EXPECT_THAT(pc_internal->FeedbackAccordingToTransportCcCountForTesting(), EXPECT_THAT(pc_internal->FeedbackAccordingToTransportCcCountForTesting(),
Eq(0)); Eq(0));
// Closing peer connections before ScopedFieldTrials gets out of scope to
// avoid a race condition.
ClosePeerConnections();
} }
TEST_F(PeerConnectionCongestionControlTest, TransportCcGetsUsed) { TEST_F(PeerConnectionCongestionControlTest, TransportCcGetsUsed) {
test::ScopedFieldTrials trials( SetFieldTrials("WebRTC-RFC8888CongestionControlFeedback/Disabled/");
"WebRTC-RFC8888CongestionControlFeedback/Disabled/");
ASSERT_TRUE(CreatePeerConnectionWrappers()); ASSERT_TRUE(CreatePeerConnectionWrappers());
ConnectFakeSignaling(); ConnectFakeSignaling();
caller()->AddAudioVideoTracks(); caller()->AddAudioVideoTracks();
@ -118,9 +104,6 @@ TEST_F(PeerConnectionCongestionControlTest, TransportCcGetsUsed) {
kDefaultTimeout); kDefaultTimeout);
// Test that RFC 8888 feedback is NOT generated when field trial disabled. // Test that RFC 8888 feedback is NOT generated when field trial disabled.
EXPECT_THAT(pc_internal->FeedbackAccordingToRfc8888CountForTesting(), Eq(0)); EXPECT_THAT(pc_internal->FeedbackAccordingToRfc8888CountForTesting(), Eq(0));
// Closing peer connections before ScopedFieldTrials gets out of scope to
// avoid a race condition.
ClosePeerConnections();
} }
} // namespace webrtc } // namespace webrtc

View File

@ -26,6 +26,7 @@
#include "api/audio_codecs/builtin_audio_encoder_factory.h" #include "api/audio_codecs/builtin_audio_encoder_factory.h"
#include "api/create_peerconnection_factory.h" #include "api/create_peerconnection_factory.h"
#include "api/crypto/crypto_options.h" #include "api/crypto/crypto_options.h"
#include "api/field_trials.h"
#include "api/jsep.h" #include "api/jsep.h"
#include "api/peer_connection_interface.h" #include "api/peer_connection_interface.h"
#include "api/scoped_refptr.h" #include "api/scoped_refptr.h"
@ -56,7 +57,6 @@
#include "rtc_base/thread.h" #include "rtc_base/thread.h"
#include "test/gmock.h" #include "test/gmock.h"
#include "test/gtest.h" #include "test/gtest.h"
#include "test/scoped_key_value_config.h"
#ifdef WEBRTC_ANDROID #ifdef WEBRTC_ANDROID
#include "pc/test/android_test_initializer.h" #include "pc/test/android_test_initializer.h"
#endif #endif
@ -113,7 +113,7 @@ class PeerConnectionCryptoBaseTest : public ::testing::Test {
auto fake_port_allocator = std::make_unique<cricket::FakePortAllocator>( auto fake_port_allocator = std::make_unique<cricket::FakePortAllocator>(
rtc::Thread::Current(), rtc::Thread::Current(),
std::make_unique<rtc::BasicPacketSocketFactory>(vss_.get()), std::make_unique<rtc::BasicPacketSocketFactory>(vss_.get()),
&field_trials_); field_trials_.get());
auto observer = std::make_unique<MockPeerConnectionObserver>(); auto observer = std::make_unique<MockPeerConnectionObserver>();
RTCConfiguration modified_config = config; RTCConfiguration modified_config = config;
modified_config.sdp_semantics = sdp_semantics_; modified_config.sdp_semantics = sdp_semantics_;
@ -163,7 +163,7 @@ class PeerConnectionCryptoBaseTest : public ::testing::Test {
return transport_info->description.connection_role; return transport_info->description.connection_role;
} }
test::ScopedKeyValueConfig field_trials_; std::unique_ptr<FieldTrials> field_trials_ = FieldTrials::CreateNoGlobal("");
std::unique_ptr<rtc::VirtualSocketServer> vss_; std::unique_ptr<rtc::VirtualSocketServer> vss_;
rtc::AutoSocketServerThread main_; rtc::AutoSocketServerThread main_;
rtc::scoped_refptr<PeerConnectionFactoryInterface> pc_factory_; rtc::scoped_refptr<PeerConnectionFactoryInterface> pc_factory_;

View File

@ -25,6 +25,7 @@
#include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/audio_codecs/builtin_audio_decoder_factory.h"
#include "api/audio_codecs/builtin_audio_encoder_factory.h" #include "api/audio_codecs/builtin_audio_encoder_factory.h"
#include "api/audio_options.h" #include "api/audio_options.h"
#include "api/field_trials.h"
#include "api/field_trials_view.h" #include "api/field_trials_view.h"
#include "api/jsep.h" #include "api/jsep.h"
#include "api/make_ref_counted.h" #include "api/make_ref_counted.h"
@ -55,7 +56,6 @@
#include "rtc_base/thread.h" #include "rtc_base/thread.h"
#include "test/gmock.h" #include "test/gmock.h"
#include "test/gtest.h" #include "test/gtest.h"
#include "test/scoped_key_value_config.h"
#include "test/wait_until.h" #include "test/wait_until.h"
using ::testing::AllOf; using ::testing::AllOf;
@ -143,12 +143,13 @@ class PeerConnectionEncodingsIntegrationTest : public ::testing::Test {
RTC_CHECK(background_thread_->Start()); RTC_CHECK(background_thread_->Start());
} }
rtc::scoped_refptr<PeerConnectionTestWrapper> CreatePc() { scoped_refptr<PeerConnectionTestWrapper> CreatePc(
auto pc_wrapper = rtc::make_ref_counted<PeerConnectionTestWrapper>( std::unique_ptr<FieldTrialsView> field_trials = nullptr) {
"pc", &pss_, background_thread_.get(), background_thread_.get(), auto pc_wrapper = make_ref_counted<PeerConnectionTestWrapper>(
field_trials_); "pc", &pss_, background_thread_.get(), background_thread_.get());
pc_wrapper->CreatePc({}, CreateBuiltinAudioEncoderFactory(), pc_wrapper->CreatePc({}, CreateBuiltinAudioEncoderFactory(),
CreateBuiltinAudioDecoderFactory()); CreateBuiltinAudioDecoderFactory(),
std::move(field_trials));
return pc_wrapper; return pc_wrapper;
} }
@ -505,7 +506,6 @@ class PeerConnectionEncodingsIntegrationTest : public ::testing::Test {
return true; return true;
} }
test::ScopedKeyValueConfig field_trials_;
rtc::PhysicalSocketServer pss_; rtc::PhysicalSocketServer pss_;
std::unique_ptr<rtc::Thread> background_thread_; std::unique_ptr<rtc::Thread> background_thread_;
}; };
@ -2220,10 +2220,11 @@ TEST_F(PeerConnectionEncodingsIntegrationTest,
TEST_F(PeerConnectionEncodingsIntegrationTest, TEST_F(PeerConnectionEncodingsIntegrationTest,
AddTransceiverAcceptsMixedCodecSimulcast) { AddTransceiverAcceptsMixedCodecSimulcast) {
// Enable WIP mixed codec simulcast support // Enable WIP mixed codec simulcast support
test::ScopedKeyValueConfig field_trials( std::string field_trials = "WebRTC-MixedCodecSimulcast/Enabled/";
field_trials_, "WebRTC-MixedCodecSimulcast/Enabled/"); scoped_refptr<PeerConnectionTestWrapper> local_pc_wrapper =
rtc::scoped_refptr<PeerConnectionTestWrapper> local_pc_wrapper = CreatePc(); CreatePc(FieldTrials::CreateNoGlobal(field_trials));
rtc::scoped_refptr<PeerConnectionTestWrapper> remote_pc_wrapper = CreatePc(); scoped_refptr<PeerConnectionTestWrapper> remote_pc_wrapper =
CreatePc(FieldTrials::CreateNoGlobal(field_trials));
ExchangeIceCandidates(local_pc_wrapper, remote_pc_wrapper); ExchangeIceCandidates(local_pc_wrapper, remote_pc_wrapper);
std::optional<RtpCodecCapability> vp8 = std::optional<RtpCodecCapability> vp8 =

View File

@ -25,6 +25,7 @@
#include "api/enable_media.h" #include "api/enable_media.h"
#include "api/enable_media_with_defaults.h" #include "api/enable_media_with_defaults.h"
#include "api/environment/environment_factory.h" #include "api/environment/environment_factory.h"
#include "api/field_trials.h"
#include "api/jsep.h" #include "api/jsep.h"
#include "api/make_ref_counted.h" #include "api/make_ref_counted.h"
#include "api/media_stream_interface.h" #include "api/media_stream_interface.h"
@ -56,7 +57,6 @@
#include "rtc_base/time_utils.h" #include "rtc_base/time_utils.h"
#include "test/gmock.h" #include "test/gmock.h"
#include "test/gtest.h" #include "test/gtest.h"
#include "test/scoped_key_value_config.h"
#ifdef WEBRTC_ANDROID #ifdef WEBRTC_ANDROID
#include "pc/test/android_test_initializer.h" #include "pc/test/android_test_initializer.h"
@ -158,7 +158,8 @@ class PeerConnectionFactoryTest : public ::testing::Test {
packet_socket_factory_.reset( packet_socket_factory_.reset(
new rtc::BasicPacketSocketFactory(socket_server_.get())); new rtc::BasicPacketSocketFactory(socket_server_.get()));
port_allocator_.reset(new cricket::FakePortAllocator( port_allocator_.reset(new cricket::FakePortAllocator(
rtc::Thread::Current(), packet_socket_factory_.get(), &field_trials_)); rtc::Thread::Current(), packet_socket_factory_.get(),
field_trials_.get()));
raw_port_allocator_ = port_allocator_.get(); raw_port_allocator_ = port_allocator_.get();
} }
@ -253,7 +254,7 @@ class PeerConnectionFactoryTest : public ::testing::Test {
} }
} }
test::ScopedKeyValueConfig field_trials_; std::unique_ptr<FieldTrials> field_trials_ = FieldTrials::CreateNoGlobal("");
std::unique_ptr<rtc::SocketServer> socket_server_; std::unique_ptr<rtc::SocketServer> socket_server_;
rtc::AutoSocketServerThread main_thread_; rtc::AutoSocketServerThread main_thread_;
rtc::scoped_refptr<PeerConnectionFactoryInterface> factory_; rtc::scoped_refptr<PeerConnectionFactoryInterface> factory_;

View File

@ -11,12 +11,15 @@
// This file contains tests that verify that field trials do what they're // This file contains tests that verify that field trials do what they're
// supposed to do. // supposed to do.
#include <memory>
#include <set> #include <set>
#include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/audio_codecs/builtin_audio_decoder_factory.h"
#include "api/audio_codecs/builtin_audio_encoder_factory.h" #include "api/audio_codecs/builtin_audio_encoder_factory.h"
#include "api/create_peerconnection_factory.h" #include "api/create_peerconnection_factory.h"
#include "api/enable_media_with_defaults.h" #include "api/enable_media_with_defaults.h"
#include "api/field_trials.h"
#include "api/field_trials_view.h"
#include "api/peer_connection_interface.h" #include "api/peer_connection_interface.h"
#include "api/stats/rtcstats_objects.h" #include "api/stats/rtcstats_objects.h"
#include "api/task_queue/default_task_queue_factory.h" #include "api/task_queue/default_task_queue_factory.h"
@ -33,7 +36,6 @@
#include "rtc_base/physical_socket_server.h" #include "rtc_base/physical_socket_server.h"
#include "rtc_base/thread.h" #include "rtc_base/thread.h"
#include "test/gtest.h" #include "test/gtest.h"
#include "test/scoped_key_value_config.h"
#ifdef WEBRTC_ANDROID #ifdef WEBRTC_ANDROID
#include "pc/test/android_test_initializer.h" #include "pc/test/android_test_initializer.h"
@ -100,10 +102,8 @@ class PeerConnectionFieldTrialTest : public ::testing::Test {
// Tests for the dependency descriptor field trial. The dependency descriptor // Tests for the dependency descriptor field trial. The dependency descriptor
// field trial is implemented in media/engine/webrtc_video_engine.cc. // field trial is implemented in media/engine/webrtc_video_engine.cc.
TEST_F(PeerConnectionFieldTrialTest, EnableDependencyDescriptorAdvertised) { TEST_F(PeerConnectionFieldTrialTest, EnableDependencyDescriptorAdvertised) {
std::unique_ptr<test::ScopedKeyValueConfig> field_trials = CreatePCFactory(FieldTrials::CreateNoGlobal(
std::make_unique<test::ScopedKeyValueConfig>( "WebRTC-DependencyDescriptorAdvertised/Enabled/"));
"WebRTC-DependencyDescriptorAdvertised/Enabled/");
CreatePCFactory(std::move(field_trials));
WrapperPtr caller = CreatePeerConnection(); WrapperPtr caller = CreatePeerConnection();
caller->AddTransceiver(cricket::MEDIA_TYPE_VIDEO); caller->AddTransceiver(cricket::MEDIA_TYPE_VIDEO);
@ -135,10 +135,8 @@ TEST_F(PeerConnectionFieldTrialTest, EnableDependencyDescriptorAdvertised) {
#define MAYBE_InjectDependencyDescriptor InjectDependencyDescriptor #define MAYBE_InjectDependencyDescriptor InjectDependencyDescriptor
#endif #endif
TEST_F(PeerConnectionFieldTrialTest, MAYBE_InjectDependencyDescriptor) { TEST_F(PeerConnectionFieldTrialTest, MAYBE_InjectDependencyDescriptor) {
std::unique_ptr<test::ScopedKeyValueConfig> field_trials = CreatePCFactory(FieldTrials::CreateNoGlobal(
std::make_unique<test::ScopedKeyValueConfig>( "WebRTC-DependencyDescriptorAdvertised/Disabled/"));
"WebRTC-DependencyDescriptorAdvertised/Disabled/");
CreatePCFactory(std::move(field_trials));
WrapperPtr caller = CreatePeerConnection(); WrapperPtr caller = CreatePeerConnection();
WrapperPtr callee = CreatePeerConnection(); WrapperPtr callee = CreatePeerConnection();

View File

@ -16,6 +16,7 @@
#include <vector> #include <vector>
#include "absl/strings/string_view.h" #include "absl/strings/string_view.h"
#include "api/field_trials.h"
#include "api/jsep.h" #include "api/jsep.h"
#include "api/media_types.h" #include "api/media_types.h"
#include "api/peer_connection_interface.h" #include "api/peer_connection_interface.h"
@ -42,7 +43,6 @@
#include "rtc_base/thread.h" #include "rtc_base/thread.h"
#include "test/gmock.h" #include "test/gmock.h"
#include "test/gtest.h" #include "test/gtest.h"
#include "test/scoped_key_value_config.h"
namespace webrtc { namespace webrtc {
@ -98,7 +98,7 @@ class PeerConnectionHeaderExtensionTest
auto fake_port_allocator = std::make_unique<cricket::FakePortAllocator>( auto fake_port_allocator = std::make_unique<cricket::FakePortAllocator>(
rtc::Thread::Current(), rtc::Thread::Current(),
std::make_unique<rtc::BasicPacketSocketFactory>(socket_server_.get()), std::make_unique<rtc::BasicPacketSocketFactory>(socket_server_.get()),
&field_trials_); field_trials_.get());
auto observer = std::make_unique<MockPeerConnectionObserver>(); auto observer = std::make_unique<MockPeerConnectionObserver>();
PeerConnectionInterface::RTCConfiguration config; PeerConnectionInterface::RTCConfiguration config;
if (semantics) if (semantics)
@ -113,7 +113,7 @@ class PeerConnectionHeaderExtensionTest
pc_factory, result.MoveValue(), std::move(observer)); pc_factory, result.MoveValue(), std::move(observer));
} }
test::ScopedKeyValueConfig field_trials_; std::unique_ptr<FieldTrials> field_trials_ = FieldTrials::CreateNoGlobal("");
std::unique_ptr<rtc::SocketServer> socket_server_; std::unique_ptr<rtc::SocketServer> socket_server_;
rtc::AutoSocketServerThread main_thread_; rtc::AutoSocketServerThread main_thread_;
std::vector<RtpHeaderExtensionCapability> extensions_; std::vector<RtpHeaderExtensionCapability> extensions_;

View File

@ -23,6 +23,7 @@
#include "api/audio/audio_mixer.h" #include "api/audio/audio_mixer.h"
#include "api/audio/audio_processing.h" #include "api/audio/audio_processing.h"
#include "api/candidate.h" #include "api/candidate.h"
#include "api/field_trials.h"
#include "api/ice_transport_interface.h" #include "api/ice_transport_interface.h"
#include "api/jsep.h" #include "api/jsep.h"
#include "api/media_types.h" #include "api/media_types.h"
@ -54,7 +55,6 @@
#include "rtc_base/socket_address.h" #include "rtc_base/socket_address.h"
#include "rtc_base/thread.h" #include "rtc_base/thread.h"
#include "test/gtest.h" #include "test/gtest.h"
#include "test/scoped_key_value_config.h"
#ifdef WEBRTC_ANDROID #ifdef WEBRTC_ANDROID
#include "pc/test/android_test_initializer.h" #include "pc/test/android_test_initializer.h"
#endif #endif
@ -1445,7 +1445,7 @@ class PeerConnectionIceConfigTest : public ::testing::Test {
std::unique_ptr<cricket::FakePortAllocator> port_allocator( std::unique_ptr<cricket::FakePortAllocator> port_allocator(
new cricket::FakePortAllocator(rtc::Thread::Current(), new cricket::FakePortAllocator(rtc::Thread::Current(),
packet_socket_factory_.get(), packet_socket_factory_.get(),
&field_trials_)); field_trials_.get()));
port_allocator_ = port_allocator.get(); port_allocator_ = port_allocator.get();
PeerConnectionDependencies pc_dependencies(&observer_); PeerConnectionDependencies pc_dependencies(&observer_);
pc_dependencies.allocator = std::move(port_allocator); pc_dependencies.allocator = std::move(port_allocator);
@ -1455,7 +1455,7 @@ class PeerConnectionIceConfigTest : public ::testing::Test {
pc_ = result.MoveValue(); pc_ = result.MoveValue();
} }
test::ScopedKeyValueConfig field_trials_; std::unique_ptr<FieldTrials> field_trials_ = FieldTrials::CreateNoGlobal("");
std::unique_ptr<rtc::SocketServer> socket_server_; std::unique_ptr<rtc::SocketServer> socket_server_;
rtc::AutoSocketServerThread main_thread_; rtc::AutoSocketServerThread main_thread_;
rtc::scoped_refptr<PeerConnectionFactoryInterface> pc_factory_ = nullptr; rtc::scoped_refptr<PeerConnectionFactoryInterface> pc_factory_ = nullptr;

View File

@ -27,6 +27,7 @@
#include "api/create_peerconnection_factory.h" #include "api/create_peerconnection_factory.h"
#include "api/data_channel_interface.h" #include "api/data_channel_interface.h"
#include "api/enable_media_with_defaults.h" #include "api/enable_media_with_defaults.h"
#include "api/field_trials.h"
#include "api/jsep.h" #include "api/jsep.h"
#include "api/media_stream_interface.h" #include "api/media_stream_interface.h"
#include "api/media_types.h" #include "api/media_types.h"
@ -85,7 +86,6 @@
#include "rtc_base/virtual_socket_server.h" #include "rtc_base/virtual_socket_server.h"
#include "test/gmock.h" #include "test/gmock.h"
#include "test/gtest.h" #include "test/gtest.h"
#include "test/scoped_key_value_config.h"
#ifdef WEBRTC_ANDROID #ifdef WEBRTC_ANDROID
#include "pc/test/android_test_initializer.h" #include "pc/test/android_test_initializer.h"
@ -708,7 +708,7 @@ class PeerConnectionInterfaceBaseTest : public ::testing::Test {
new cricket::FakePortAllocator( new cricket::FakePortAllocator(
rtc::Thread::Current(), rtc::Thread::Current(),
std::make_unique<rtc::BasicPacketSocketFactory>(vss_.get()), std::make_unique<rtc::BasicPacketSocketFactory>(vss_.get()),
&field_trials_)); field_trials_.get()));
port_allocator_ = port_allocator.get(); port_allocator_ = port_allocator.get();
// Create certificate generator unless DTLS constraint is explicitly set to // Create certificate generator unless DTLS constraint is explicitly set to
@ -1227,7 +1227,7 @@ class PeerConnectionInterfaceBaseTest : public ::testing::Test {
rtc::SocketServer* socket_server() const { return vss_.get(); } rtc::SocketServer* socket_server() const { return vss_.get(); }
test::ScopedKeyValueConfig field_trials_; std::unique_ptr<FieldTrials> field_trials_ = FieldTrials::CreateNoGlobal("");
std::unique_ptr<rtc::VirtualSocketServer> vss_; std::unique_ptr<rtc::VirtualSocketServer> vss_;
rtc::AutoSocketServerThread main_; rtc::AutoSocketServerThread main_;
rtc::scoped_refptr<FakeAudioCaptureModule> fake_audio_capture_module_; rtc::scoped_refptr<FakeAudioCaptureModule> fake_audio_capture_module_;
@ -1336,8 +1336,9 @@ TEST_P(PeerConnectionInterfaceTest,
std::unique_ptr<rtc::PacketSocketFactory> packet_socket_factory( std::unique_ptr<rtc::PacketSocketFactory> packet_socket_factory(
new rtc::BasicPacketSocketFactory(socket_server())); new rtc::BasicPacketSocketFactory(socket_server()));
std::unique_ptr<cricket::FakePortAllocator> port_allocator( std::unique_ptr<cricket::FakePortAllocator> port_allocator(
new cricket::FakePortAllocator( new cricket::FakePortAllocator(rtc::Thread::Current(),
rtc::Thread::Current(), packet_socket_factory.get(), &field_trials_)); packet_socket_factory.get(),
field_trials_.get()));
cricket::FakePortAllocator* raw_port_allocator = port_allocator.get(); cricket::FakePortAllocator* raw_port_allocator = port_allocator.get();
// Create RTCConfiguration with some network-related fields relevant to // Create RTCConfiguration with some network-related fields relevant to

View File

@ -62,7 +62,6 @@
#include "rtc_base/rtc_certificate_generator.h" #include "rtc_base/rtc_certificate_generator.h"
#include "rtc_base/thread.h" #include "rtc_base/thread.h"
#include "test/gtest.h" #include "test/gtest.h"
#include "test/scoped_key_value_config.h"
#ifdef WEBRTC_ANDROID #ifdef WEBRTC_ANDROID
#include "pc/test/android_test_initializer.h" #include "pc/test/android_test_initializer.h"
#endif #endif
@ -176,7 +175,6 @@ class PeerConnectionMediaBaseTest : public ::testing::Test {
EnableFakeMedia(factory_dependencies, std::move(media_engine)); EnableFakeMedia(factory_dependencies, std::move(media_engine));
factory_dependencies.event_log_factory = factory_dependencies.event_log_factory =
std::make_unique<RtcEventLogFactory>(); std::make_unique<RtcEventLogFactory>();
factory_dependencies.trials = std::move(field_trials_);
auto pc_factory = auto pc_factory =
CreateModularPeerConnectionFactory(std::move(factory_dependencies)); CreateModularPeerConnectionFactory(std::move(factory_dependencies));
@ -253,7 +251,6 @@ class PeerConnectionMediaBaseTest : public ::testing::Test {
return sdp_semantics_ == SdpSemantics::kUnifiedPlan; return sdp_semantics_ == SdpSemantics::kUnifiedPlan;
} }
std::unique_ptr<test::ScopedKeyValueConfig> field_trials_;
std::unique_ptr<rtc::VirtualSocketServer> vss_; std::unique_ptr<rtc::VirtualSocketServer> vss_;
rtc::AutoSocketServerThread main_; rtc::AutoSocketServerThread main_;
const SdpSemantics sdp_semantics_; const SdpSemantics sdp_semantics_;

View File

@ -67,7 +67,6 @@
#include "test/gmock.h" #include "test/gmock.h"
#include "test/gtest.h" #include "test/gtest.h"
#include "test/run_loop.h" #include "test/run_loop.h"
#include "test/scoped_key_value_config.h"
using ::testing::_; using ::testing::_;
using ::testing::ContainerEq; using ::testing::ContainerEq;
@ -111,7 +110,7 @@ class RtpSenderReceiverTest
// Create fake media engine/etc. so we can create channels to use to // Create fake media engine/etc. so we can create channels to use to
// test RtpSenders/RtpReceivers. // test RtpSenders/RtpReceivers.
media_engine_(std::make_unique<cricket::FakeMediaEngine>()), media_engine_(std::make_unique<cricket::FakeMediaEngine>()),
fake_call_(CreateEnvironment(), worker_thread_, network_thread_), fake_call_(env_, worker_thread_, network_thread_),
local_stream_(MediaStream::Create(kStreamId1)) { local_stream_(MediaStream::Create(kStreamId1)) {
rtp_dtls_transport_ = std::make_unique<cricket::FakeDtlsTransport>( rtp_dtls_transport_ = std::make_unique<cricket::FakeDtlsTransport>(
"fake_dtls_transport", cricket::ICE_CANDIDATE_COMPONENT_RTP); "fake_dtls_transport", cricket::ICE_CANDIDATE_COMPONENT_RTP);
@ -166,7 +165,7 @@ class RtpSenderReceiverTest
std::unique_ptr<RtpTransportInternal> CreateDtlsSrtpTransport() { std::unique_ptr<RtpTransportInternal> CreateDtlsSrtpTransport() {
auto dtls_srtp_transport = std::make_unique<DtlsSrtpTransport>( auto dtls_srtp_transport = std::make_unique<DtlsSrtpTransport>(
/*rtcp_mux_required=*/true, field_trials_); /*rtcp_mux_required=*/true, env_.field_trials());
dtls_srtp_transport->SetDtlsTransports(rtp_dtls_transport_.get(), dtls_srtp_transport->SetDtlsTransports(rtp_dtls_transport_.get(),
/*rtcp_dtls_transport=*/nullptr); /*rtcp_dtls_transport=*/nullptr);
return dtls_srtp_transport; return dtls_srtp_transport;
@ -519,7 +518,7 @@ class RtpSenderReceiverTest
test::RunLoop run_loop_; test::RunLoop run_loop_;
rtc::Thread* const network_thread_; rtc::Thread* const network_thread_;
rtc::Thread* const worker_thread_; rtc::Thread* const worker_thread_;
RtcEventLogNull event_log_; const Environment env_ = CreateEnvironment();
// The `rtp_dtls_transport_` and `rtp_transport_` should be destroyed after // The `rtp_dtls_transport_` and `rtp_transport_` should be destroyed after
// the `channel_manager`. // the `channel_manager`.
std::unique_ptr<cricket::DtlsTransportInternal> rtp_dtls_transport_; std::unique_ptr<cricket::DtlsTransportInternal> rtp_dtls_transport_;
@ -544,7 +543,6 @@ class RtpSenderReceiverTest
rtc::scoped_refptr<MediaStreamInterface> local_stream_; rtc::scoped_refptr<MediaStreamInterface> local_stream_;
rtc::scoped_refptr<VideoTrackInterface> video_track_; rtc::scoped_refptr<VideoTrackInterface> video_track_;
rtc::scoped_refptr<AudioTrackInterface> audio_track_; rtc::scoped_refptr<AudioTrackInterface> audio_track_;
test::ScopedKeyValueConfig field_trials_;
}; };
// Test that `voice_channel_` is updated when an audio track is associated // Test that `voice_channel_` is updated when an audio track is associated

View File

@ -21,6 +21,8 @@
#include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/audio_codecs/builtin_audio_decoder_factory.h"
#include "api/audio_codecs/builtin_audio_encoder_factory.h" #include "api/audio_codecs/builtin_audio_encoder_factory.h"
#include "api/create_peerconnection_factory.h" #include "api/create_peerconnection_factory.h"
#include "api/field_trials.h"
#include "api/field_trials_view.h"
#include "api/jsep.h" #include "api/jsep.h"
#include "api/media_types.h" #include "api/media_types.h"
#include "api/peer_connection_interface.h" #include "api/peer_connection_interface.h"
@ -51,7 +53,6 @@
#include "system_wrappers/include/metrics.h" #include "system_wrappers/include/metrics.h"
#include "test/gmock.h" #include "test/gmock.h"
#include "test/gtest.h" #include "test/gtest.h"
#include "test/scoped_key_value_config.h"
// This file contains unit tests that relate to the behavior of the // This file contains unit tests that relate to the behavior of the
// SdpOfferAnswer module. // SdpOfferAnswer module.
@ -98,22 +99,25 @@ class SdpOfferAnswerTest : public ::testing::Test {
Dav1dDecoderTemplateAdapter>>(), Dav1dDecoderTemplateAdapter>>(),
nullptr /* audio_mixer */, nullptr /* audio_mixer */,
nullptr /* audio_processing */, nullptr /* audio_processing */,
nullptr /* audio_frame_processor */, nullptr /* audio_frame_processor */)) {
std::make_unique<test::ScopedKeyValueConfig>(field_trials_, ""))) {
metrics::Reset(); metrics::Reset();
} }
std::unique_ptr<PeerConnectionWrapper> CreatePeerConnection() { std::unique_ptr<PeerConnectionWrapper> CreatePeerConnection(
std::unique_ptr<FieldTrialsView> field_trials = nullptr) {
RTCConfiguration config; RTCConfiguration config;
config.sdp_semantics = SdpSemantics::kUnifiedPlan; config.sdp_semantics = SdpSemantics::kUnifiedPlan;
return CreatePeerConnection(config); return CreatePeerConnection(config, std::move(field_trials));
} }
std::unique_ptr<PeerConnectionWrapper> CreatePeerConnection( std::unique_ptr<PeerConnectionWrapper> CreatePeerConnection(
const RTCConfiguration& config) { const RTCConfiguration& config,
std::unique_ptr<FieldTrialsView> field_trials) {
auto observer = std::make_unique<MockPeerConnectionObserver>(); auto observer = std::make_unique<MockPeerConnectionObserver>();
auto result = pc_factory_->CreatePeerConnectionOrError( PeerConnectionDependencies pc_deps(observer.get());
config, PeerConnectionDependencies(observer.get())); pc_deps.trials = std::move(field_trials);
auto result =
pc_factory_->CreatePeerConnectionOrError(config, std::move(pc_deps));
EXPECT_TRUE(result.ok()); EXPECT_TRUE(result.ok());
observer->SetPeerConnectionInterface(result.value().get()); observer->SetPeerConnectionInterface(result.value().get());
return std::make_unique<PeerConnectionWrapper>( return std::make_unique<PeerConnectionWrapper>(
@ -134,7 +138,6 @@ class SdpOfferAnswerTest : public ::testing::Test {
} }
protected: protected:
test::ScopedKeyValueConfig field_trials_;
std::unique_ptr<rtc::Thread> signaling_thread_; std::unique_ptr<rtc::Thread> signaling_thread_;
rtc::scoped_refptr<PeerConnectionFactoryInterface> pc_factory_; rtc::scoped_refptr<PeerConnectionFactoryInterface> pc_factory_;
@ -637,10 +640,8 @@ TEST_F(SdpOfferAnswerTest, SimulcastAnswerWithNoRidsIsRejected) {
} }
TEST_F(SdpOfferAnswerTest, SimulcastOfferWithMixedCodec) { TEST_F(SdpOfferAnswerTest, SimulcastOfferWithMixedCodec) {
test::ScopedKeyValueConfig field_trials( auto pc = CreatePeerConnection(
field_trials_, "WebRTC-MixedCodecSimulcast/Enabled/"); FieldTrials::CreateNoGlobal("WebRTC-MixedCodecSimulcast/Enabled/"));
auto pc = CreatePeerConnection();
std::optional<RtpCodecCapability> vp8_codec = FindFirstSendCodecWithName( std::optional<RtpCodecCapability> vp8_codec = FindFirstSendCodecWithName(
cricket::MEDIA_TYPE_VIDEO, cricket::kVp8CodecName); cricket::MEDIA_TYPE_VIDEO, cricket::kVp8CodecName);
@ -691,10 +692,8 @@ TEST_F(SdpOfferAnswerTest, SimulcastOfferWithMixedCodec) {
} }
TEST_F(SdpOfferAnswerTest, SimulcastAnswerWithPayloadType) { TEST_F(SdpOfferAnswerTest, SimulcastAnswerWithPayloadType) {
test::ScopedKeyValueConfig field_trials( auto pc = CreatePeerConnection(
field_trials_, "WebRTC-MixedCodecSimulcast/Enabled/"); FieldTrials::CreateNoGlobal("WebRTC-MixedCodecSimulcast/Enabled/"));
auto pc = CreatePeerConnection();
// A SDP offer with recv simulcast with payload type // A SDP offer with recv simulcast with payload type
std::string sdp = std::string sdp =

View File

@ -28,7 +28,6 @@
#include "api/task_queue/default_task_queue_factory.h" #include "api/task_queue/default_task_queue_factory.h"
#include "api/task_queue/pending_task_safety_flag.h" #include "api/task_queue/pending_task_safety_flag.h"
#include "api/task_queue/task_queue_base.h" #include "api/task_queue/task_queue_base.h"
#include "api/transport/field_trial_based_config.h"
#include "api/units/time_delta.h" #include "api/units/time_delta.h"
#include "logging/rtc_event_log/fake_rtc_event_log_factory.h" #include "logging/rtc_event_log/fake_rtc_event_log_factory.h"
#include "p2p/base/basic_packet_socket_factory.h" #include "p2p/base/basic_packet_socket_factory.h"
@ -223,6 +222,7 @@ bool PeerConnectionIntegrationWrapper::Init(
rtc::SocketServer* socket_server, rtc::SocketServer* socket_server,
rtc::Thread* network_thread, rtc::Thread* network_thread,
rtc::Thread* worker_thread, rtc::Thread* worker_thread,
std::unique_ptr<FieldTrialsView> field_trials,
std::unique_ptr<FakeRtcEventLogFactory> event_log_factory, std::unique_ptr<FakeRtcEventLogFactory> event_log_factory,
bool reset_encoder_factory, bool reset_encoder_factory,
bool reset_decoder_factory, bool reset_decoder_factory,
@ -251,7 +251,7 @@ bool PeerConnectionIntegrationWrapper::Init(
pc_factory_dependencies.worker_thread = worker_thread; pc_factory_dependencies.worker_thread = worker_thread;
pc_factory_dependencies.signaling_thread = signaling_thread; pc_factory_dependencies.signaling_thread = signaling_thread;
pc_factory_dependencies.task_queue_factory = CreateDefaultTaskQueueFactory(); pc_factory_dependencies.task_queue_factory = CreateDefaultTaskQueueFactory();
pc_factory_dependencies.trials = std::make_unique<FieldTrialBasedConfig>(); pc_factory_dependencies.trials = std::move(field_trials);
pc_factory_dependencies.decode_metronome = pc_factory_dependencies.decode_metronome =
std::make_unique<TaskQueueMetronome>(TimeDelta::Millis(8)); std::make_unique<TaskQueueMetronome>(TimeDelta::Millis(8));

View File

@ -33,6 +33,7 @@
#include "api/candidate.h" #include "api/candidate.h"
#include "api/crypto/crypto_options.h" #include "api/crypto/crypto_options.h"
#include "api/data_channel_interface.h" #include "api/data_channel_interface.h"
#include "api/field_trials.h"
#include "api/field_trials_view.h" #include "api/field_trials_view.h"
#include "api/ice_transport_interface.h" #include "api/ice_transport_interface.h"
#include "api/jsep.h" #include "api/jsep.h"
@ -94,7 +95,6 @@
#include "system_wrappers/include/metrics.h" #include "system_wrappers/include/metrics.h"
#include "test/gmock.h" #include "test/gmock.h"
#include "test/gtest.h" #include "test/gtest.h"
#include "test/scoped_key_value_config.h"
namespace webrtc { namespace webrtc {
@ -741,6 +741,7 @@ class PeerConnectionIntegrationWrapper : public PeerConnectionObserver,
rtc::SocketServer* socket_server, rtc::SocketServer* socket_server,
rtc::Thread* network_thread, rtc::Thread* network_thread,
rtc::Thread* worker_thread, rtc::Thread* worker_thread,
std::unique_ptr<FieldTrialsView> field_trials,
std::unique_ptr<FakeRtcEventLogFactory> event_log_factory, std::unique_ptr<FakeRtcEventLogFactory> event_log_factory,
bool reset_encoder_factory, bool reset_encoder_factory,
bool reset_decoder_factory, bool reset_decoder_factory,
@ -1322,17 +1323,12 @@ class MockIceTransportFactory : public IceTransportFactory {
// of everything else (including "PeerConnectionFactory"s). // of everything else (including "PeerConnectionFactory"s).
class PeerConnectionIntegrationBaseTest : public ::testing::Test { class PeerConnectionIntegrationBaseTest : public ::testing::Test {
public: public:
PeerConnectionIntegrationBaseTest( explicit PeerConnectionIntegrationBaseTest(SdpSemantics sdp_semantics)
SdpSemantics sdp_semantics,
std::optional<std::string> field_trials = std::nullopt)
: sdp_semantics_(sdp_semantics), : sdp_semantics_(sdp_semantics),
ss_(new rtc::VirtualSocketServer()), ss_(new rtc::VirtualSocketServer()),
fss_(new rtc::FirewallSocketServer(ss_.get())), fss_(new rtc::FirewallSocketServer(ss_.get())),
network_thread_(new rtc::Thread(fss_.get())), network_thread_(new rtc::Thread(fss_.get())),
worker_thread_(rtc::Thread::Create()), worker_thread_(rtc::Thread::Create()) {
// TODO(bugs.webrtc.org/10335): Pass optional ScopedKeyValueConfig.
field_trials_(new test::ScopedKeyValueConfig(
field_trials.has_value() ? *field_trials : "")) {
network_thread_->SetName("PCNetworkThread", this); network_thread_->SetName("PCNetworkThread", this);
worker_thread_->SetName("PCWorkerThread", this); worker_thread_->SetName("PCWorkerThread", this);
RTC_CHECK(network_thread_->Start()); RTC_CHECK(network_thread_->Start());
@ -1383,6 +1379,14 @@ class PeerConnectionIntegrationBaseTest : public ::testing::Test {
PeerConnectionInterface::kIceConnectionCompleted); PeerConnectionInterface::kIceConnectionCompleted);
} }
// Sets field trials to pass to created PeerConnectionWrapper.
// Must be called before PeerConnectionWrappers are created.
void SetFieldTrials(absl::string_view field_trials) {
RTC_CHECK(caller_ == nullptr);
RTC_CHECK(callee_ == nullptr);
field_trials_ = std::string(field_trials);
}
// When `event_log_factory` is null, the default implementation of the event // When `event_log_factory` is null, the default implementation of the event
// log factory will be used. // log factory will be used.
std::unique_ptr<PeerConnectionIntegrationWrapper> CreatePeerConnectionWrapper( std::unique_ptr<PeerConnectionIntegrationWrapper> CreatePeerConnectionWrapper(
@ -1408,6 +1412,7 @@ class PeerConnectionIntegrationBaseTest : public ::testing::Test {
if (!client->Init(options, &modified_config, std::move(dependencies), if (!client->Init(options, &modified_config, std::move(dependencies),
fss_.get(), network_thread_.get(), worker_thread_.get(), fss_.get(), network_thread_.get(), worker_thread_.get(),
FieldTrials::CreateNoGlobal(field_trials_),
std::move(event_log_factory), reset_encoder_factory, std::move(event_log_factory), reset_encoder_factory,
reset_decoder_factory, create_media_engine)) { reset_decoder_factory, create_media_engine)) {
return nullptr; return nullptr;
@ -1837,8 +1842,6 @@ class PeerConnectionIntegrationBaseTest : public ::testing::Test {
expected_cipher_suite); expected_cipher_suite);
} }
const FieldTrialsView& trials() const { return *field_trials_.get(); }
protected: protected:
SdpSemantics sdp_semantics_; SdpSemantics sdp_semantics_;
@ -1859,7 +1862,7 @@ class PeerConnectionIntegrationBaseTest : public ::testing::Test {
std::vector<std::unique_ptr<cricket::TestTurnCustomizer>> turn_customizers_; std::vector<std::unique_ptr<cricket::TestTurnCustomizer>> turn_customizers_;
std::unique_ptr<PeerConnectionIntegrationWrapper> caller_; std::unique_ptr<PeerConnectionIntegrationWrapper> caller_;
std::unique_ptr<PeerConnectionIntegrationWrapper> callee_; std::unique_ptr<PeerConnectionIntegrationWrapper> callee_;
std::unique_ptr<FieldTrialsView> field_trials_; std::string field_trials_;
}; };
} // namespace webrtc } // namespace webrtc

View File

@ -51,12 +51,12 @@
#include "rtc_base/string_encode.h" #include "rtc_base/string_encode.h"
#include "rtc_base/time_utils.h" #include "rtc_base/time_utils.h"
#include "test/gtest.h" #include "test/gtest.h"
#include "test/scoped_key_value_config.h"
namespace { namespace {
using ::webrtc::Environment; using ::webrtc::Environment;
using ::webrtc::FakeVideoTrackRenderer; using ::webrtc::FakeVideoTrackRenderer;
using ::webrtc::FieldTrialsView;
using ::webrtc::IceCandidateInterface; using ::webrtc::IceCandidateInterface;
using ::webrtc::MediaStreamInterface; using ::webrtc::MediaStreamInterface;
using ::webrtc::MediaStreamTrackInterface; using ::webrtc::MediaStreamTrackInterface;
@ -134,21 +134,6 @@ PeerConnectionTestWrapper::PeerConnectionTestWrapper(
pc_thread_checker_.Detach(); pc_thread_checker_.Detach();
} }
PeerConnectionTestWrapper::PeerConnectionTestWrapper(
const std::string& name,
rtc::SocketServer* socket_server,
rtc::Thread* network_thread,
rtc::Thread* worker_thread,
webrtc::test::ScopedKeyValueConfig& field_trials)
: field_trials_(field_trials, ""),
name_(name),
socket_server_(socket_server),
network_thread_(network_thread),
worker_thread_(worker_thread),
pending_negotiation_(false) {
pc_thread_checker_.Detach();
}
PeerConnectionTestWrapper::~PeerConnectionTestWrapper() { PeerConnectionTestWrapper::~PeerConnectionTestWrapper() {
RTC_DCHECK_RUN_ON(&pc_thread_checker_); RTC_DCHECK_RUN_ON(&pc_thread_checker_);
// To avoid flaky bot failures, make sure fake sources are stopped prior to // To avoid flaky bot failures, make sure fake sources are stopped prior to
@ -166,12 +151,13 @@ PeerConnectionTestWrapper::~PeerConnectionTestWrapper() {
bool PeerConnectionTestWrapper::CreatePc( bool PeerConnectionTestWrapper::CreatePc(
const webrtc::PeerConnectionInterface::RTCConfiguration& config, const webrtc::PeerConnectionInterface::RTCConfiguration& config,
rtc::scoped_refptr<webrtc::AudioEncoderFactory> audio_encoder_factory, rtc::scoped_refptr<webrtc::AudioEncoderFactory> audio_encoder_factory,
rtc::scoped_refptr<webrtc::AudioDecoderFactory> audio_decoder_factory) { rtc::scoped_refptr<webrtc::AudioDecoderFactory> audio_decoder_factory,
std::unique_ptr<webrtc::FieldTrialsView> field_trials) {
std::unique_ptr<cricket::PortAllocator> port_allocator( std::unique_ptr<cricket::PortAllocator> port_allocator(
new cricket::FakePortAllocator( new cricket::FakePortAllocator(
network_thread_, network_thread_,
std::make_unique<rtc::BasicPacketSocketFactory>(socket_server_), std::make_unique<rtc::BasicPacketSocketFactory>(socket_server_),
&field_trials_)); field_trials.get()));
RTC_DCHECK_RUN_ON(&pc_thread_checker_); RTC_DCHECK_RUN_ON(&pc_thread_checker_);
@ -191,7 +177,7 @@ bool PeerConnectionTestWrapper::CreatePc(
webrtc::OpenH264DecoderTemplateAdapter, webrtc::OpenH264DecoderTemplateAdapter,
webrtc::Dav1dDecoderTemplateAdapter>>(), webrtc::Dav1dDecoderTemplateAdapter>>(),
nullptr /* audio_mixer */, nullptr /* audio_processing */, nullptr, nullptr /* audio_mixer */, nullptr /* audio_processing */, nullptr,
std::make_unique<webrtc::test::ScopedKeyValueConfig>(field_trials_, "")); std::move(field_trials));
if (!peer_connection_factory_) { if (!peer_connection_factory_) {
return false; return false;
} }

View File

@ -35,7 +35,6 @@
#include "pc/test/fake_video_track_renderer.h" #include "pc/test/fake_video_track_renderer.h"
#include "rtc_base/third_party/sigslot/sigslot.h" #include "rtc_base/third_party/sigslot/sigslot.h"
#include "rtc_base/thread.h" #include "rtc_base/thread.h"
#include "test/scoped_key_value_config.h"
class PeerConnectionTestWrapper class PeerConnectionTestWrapper
: public webrtc::PeerConnectionObserver, : public webrtc::PeerConnectionObserver,
@ -49,17 +48,13 @@ class PeerConnectionTestWrapper
rtc::SocketServer* socket_server, rtc::SocketServer* socket_server,
rtc::Thread* network_thread, rtc::Thread* network_thread,
rtc::Thread* worker_thread); rtc::Thread* worker_thread);
PeerConnectionTestWrapper(const std::string& name,
rtc::SocketServer* socket_server,
rtc::Thread* network_thread,
rtc::Thread* worker_thread,
webrtc::test::ScopedKeyValueConfig& field_trials);
virtual ~PeerConnectionTestWrapper(); virtual ~PeerConnectionTestWrapper();
bool CreatePc( bool CreatePc(
const webrtc::PeerConnectionInterface::RTCConfiguration& config, const webrtc::PeerConnectionInterface::RTCConfiguration& config,
rtc::scoped_refptr<webrtc::AudioEncoderFactory> audio_encoder_factory, rtc::scoped_refptr<webrtc::AudioEncoderFactory> audio_encoder_factory,
rtc::scoped_refptr<webrtc::AudioDecoderFactory> audio_decoder_factory); rtc::scoped_refptr<webrtc::AudioDecoderFactory> audio_decoder_factory,
std::unique_ptr<webrtc::FieldTrialsView> field_trials = nullptr);
rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> pc_factory() rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> pc_factory()
const { const {
@ -136,7 +131,6 @@ class PeerConnectionTestWrapper
bool CheckForAudio(); bool CheckForAudio();
bool CheckForVideo(); bool CheckForVideo();
webrtc::test::ScopedKeyValueConfig field_trials_;
std::string name_; std::string name_;
rtc::SocketServer* const socket_server_; rtc::SocketServer* const socket_server_;
rtc::Thread* const network_thread_; rtc::Thread* const network_thread_;