diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:33 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:33 +0000 |
commit | 086c044dc34dfc0f74fbe41f4ecb402b2cd34884 (patch) | |
tree | a4f824bd33cb075dd5aa3eb5a0a94af221bbe83a /third_party/libwebrtc/pc/test | |
parent | Adding debian version 124.0.1-1. (diff) | |
download | firefox-086c044dc34dfc0f74fbe41f4ecb402b2cd34884.tar.xz firefox-086c044dc34dfc0f74fbe41f4ecb402b2cd34884.zip |
Merging upstream version 125.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/libwebrtc/pc/test')
11 files changed, 297 insertions, 198 deletions
diff --git a/third_party/libwebrtc/pc/test/android_test_initializer.cc b/third_party/libwebrtc/pc/test/android_test_initializer.cc index 963544cb4b..88b4587789 100644 --- a/third_party/libwebrtc/pc/test/android_test_initializer.cc +++ b/third_party/libwebrtc/pc/test/android_test_initializer.cc @@ -39,7 +39,7 @@ void EnsureInitializedOnce() { RTC_CHECK(rtc::InitializeSSL()) << "Failed to InitializeSSL()"; - webrtc::JVM::Initialize(jvm); + JVM::Initialize(jvm); } } // anonymous namespace diff --git a/third_party/libwebrtc/pc/test/enable_fake_media.cc b/third_party/libwebrtc/pc/test/enable_fake_media.cc new file mode 100644 index 0000000000..5497c60724 --- /dev/null +++ b/third_party/libwebrtc/pc/test/enable_fake_media.cc @@ -0,0 +1,63 @@ +/* + * Copyright 2023 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#include "pc/test/enable_fake_media.h" + +#include <memory> +#include <utility> + +#include "absl/base/nullability.h" +#include "api/environment/environment.h" +#include "api/peer_connection_interface.h" +#include "call/call.h" +#include "call/call_config.h" +#include "media/base/fake_media_engine.h" +#include "pc/media_factory.h" +#include "rtc_base/checks.h" + +namespace webrtc { + +using ::cricket::FakeMediaEngine; +using ::cricket::MediaEngineInterface; + +void EnableFakeMedia( + PeerConnectionFactoryDependencies& deps, + absl::Nonnull<std::unique_ptr<FakeMediaEngine>> fake_media_engine) { + class FakeMediaFactory : public MediaFactory { + public: + explicit FakeMediaFactory( + absl::Nonnull<std::unique_ptr<FakeMediaEngine>> fake) + : fake_(std::move(fake)) {} + + std::unique_ptr<Call> CreateCall(const CallConfig& config) override { + return Call::Create(config); + } + + std::unique_ptr<MediaEngineInterface> CreateMediaEngine( + const Environment& /*env*/, + PeerConnectionFactoryDependencies& /*dependencies*/) { + RTC_CHECK(fake_ != nullptr) + << "CreateMediaEngine can be called at most once."; + return std::move(fake_); + } + + private: + absl::Nullable<std::unique_ptr<FakeMediaEngine>> fake_; + }; + + deps.media_factory = + std::make_unique<FakeMediaFactory>(std::move(fake_media_engine)); +} + +void EnableFakeMedia(PeerConnectionFactoryDependencies& deps) { + EnableFakeMedia(deps, std::make_unique<cricket::FakeMediaEngine>()); +} + +} // namespace webrtc diff --git a/third_party/libwebrtc/pc/test/enable_fake_media.h b/third_party/libwebrtc/pc/test/enable_fake_media.h new file mode 100644 index 0000000000..82c55ad08b --- /dev/null +++ b/third_party/libwebrtc/pc/test/enable_fake_media.h @@ -0,0 +1,38 @@ +/* + * Copyright 2023 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +// Enables fake media support for PeerConnnectionFactory created from `deps` for +// testing purposes. Such fake media support ignores media dependencies in the +// `PeerConnectionFactoryDependencies`. Allows to test PeerConnection and +// PeerConnectionFactory in the presence of the media, but doesn't test media +// support itself. + +#ifndef PC_TEST_ENABLE_FAKE_MEDIA_H_ +#define PC_TEST_ENABLE_FAKE_MEDIA_H_ + +#include <memory> + +#include "absl/base/nullability.h" +#include "api/peer_connection_interface.h" +#include "media/base/fake_media_engine.h" + +namespace webrtc { + +// Enables media support backed by the 'fake_media_engine'. +void EnableFakeMedia( + PeerConnectionFactoryDependencies& deps, + absl::Nonnull<std::unique_ptr<cricket::FakeMediaEngine>> fake_media_engine); + +// Enables media support backed by unspecified lightweight fake implementation. +void EnableFakeMedia(PeerConnectionFactoryDependencies& deps); + +} // namespace webrtc + +#endif // PC_TEST_ENABLE_FAKE_MEDIA_H_ diff --git a/third_party/libwebrtc/pc/test/fake_peer_connection_base.h b/third_party/libwebrtc/pc/test/fake_peer_connection_base.h index a1c8dca12e..1615088e99 100644 --- a/third_party/libwebrtc/pc/test/fake_peer_connection_base.h +++ b/third_party/libwebrtc/pc/test/fake_peer_connection_base.h @@ -363,7 +363,7 @@ class FakePeerConnectionBase : public PeerConnectionInternal { const FieldTrialsView& trials() const override { return field_trials_; } protected: - webrtc::test::ScopedKeyValueConfig field_trials_; + test::ScopedKeyValueConfig field_trials_; }; } // namespace webrtc diff --git a/third_party/libwebrtc/pc/test/fake_peer_connection_for_stats.h b/third_party/libwebrtc/pc/test/fake_peer_connection_for_stats.h index 7302182912..2883c86b58 100644 --- a/third_party/libwebrtc/pc/test/fake_peer_connection_for_stats.h +++ b/third_party/libwebrtc/pc/test/fake_peer_connection_for_stats.h @@ -18,10 +18,11 @@ #include <utility> #include <vector> -#include "media/base/fake_media_engine.h" +#include "api/environment/environment_factory.h" #include "media/base/media_channel.h" #include "pc/channel.h" #include "pc/stream_collection.h" +#include "pc/test/enable_fake_media.h" #include "pc/test/fake_data_channel_controller.h" #include "pc/test/fake_peer_connection_base.h" @@ -150,7 +151,7 @@ class VoiceChannelForTesting : public cricket::VoiceChannel { receive_channel, const std::string& content_name, bool srtp_required, - webrtc::CryptoOptions crypto_options, + CryptoOptions crypto_options, rtc::UniqueRandomIdGenerator* ssrc_generator, std::string transport_name) : VoiceChannel(worker_thread, @@ -183,7 +184,7 @@ class VideoChannelForTesting : public cricket::VideoChannel { receive_channel, const std::string& content_name, bool srtp_required, - webrtc::CryptoOptions crypto_options, + CryptoOptions crypto_options, rtc::UniqueRandomIdGenerator* ssrc_generator, std::string transport_name) : VideoChannel(worker_thread, @@ -219,7 +220,8 @@ class FakePeerConnectionForStats : public FakePeerConnectionBase { signaling_thread_(rtc::Thread::Current()), // TODO(hta): remove separate thread variables and use context. dependencies_(MakeDependencies()), - context_(ConnectionContext::Create(&dependencies_)), + context_( + ConnectionContext::Create(CreateEnvironment(), &dependencies_)), local_streams_(StreamCollection::Create()), remote_streams_(StreamCollection::Create()), data_channel_controller_(network_thread_) {} @@ -235,7 +237,7 @@ class FakePeerConnectionForStats : public FakePeerConnectionBase { dependencies.network_thread = rtc::Thread::Current(); dependencies.worker_thread = rtc::Thread::Current(); dependencies.signaling_thread = rtc::Thread::Current(); - dependencies.media_engine = std::make_unique<cricket::FakeMediaEngine>(); + EnableFakeMedia(dependencies); return dependencies; } @@ -298,7 +300,7 @@ class FakePeerConnectionForStats : public FakePeerConnectionBase { worker_thread_, network_thread_, signaling_thread_, std::move(voice_media_send_channel), std::move(voice_media_receive_channel), mid, kDefaultSrtpRequired, - webrtc::CryptoOptions(), context_->ssrc_generator(), transport_name); + CryptoOptions(), context_->ssrc_generator(), transport_name); auto transceiver = GetOrCreateFirstTransceiverOfType(cricket::MEDIA_TYPE_AUDIO) ->internal(); @@ -332,7 +334,7 @@ class FakePeerConnectionForStats : public FakePeerConnectionBase { worker_thread_, network_thread_, signaling_thread_, std::move(video_media_send_channel), std::move(video_media_receive_channel), mid, kDefaultSrtpRequired, - webrtc::CryptoOptions(), context_->ssrc_generator(), transport_name); + CryptoOptions(), context_->ssrc_generator(), transport_name); auto transceiver = GetOrCreateFirstTransceiverOfType(cricket::MEDIA_TYPE_VIDEO) ->internal(); diff --git a/third_party/libwebrtc/pc/test/fake_periodic_video_source.h b/third_party/libwebrtc/pc/test/fake_periodic_video_source.h index 452a8f6c30..65652bdf0d 100644 --- a/third_party/libwebrtc/pc/test/fake_periodic_video_source.h +++ b/third_party/libwebrtc/pc/test/fake_periodic_video_source.h @@ -65,12 +65,12 @@ class FakePeriodicVideoSource final return wants_; } - void RemoveSink(rtc::VideoSinkInterface<webrtc::VideoFrame>* sink) override { + void RemoveSink(rtc::VideoSinkInterface<VideoFrame>* sink) override { RTC_DCHECK(thread_checker_.IsCurrent()); broadcaster_.RemoveSink(sink); } - void AddOrUpdateSink(rtc::VideoSinkInterface<webrtc::VideoFrame>* sink, + void AddOrUpdateSink(rtc::VideoSinkInterface<VideoFrame>* sink, const rtc::VideoSinkWants& wants) override { RTC_DCHECK(thread_checker_.IsCurrent()); { diff --git a/third_party/libwebrtc/pc/test/integration_test_helpers.cc b/third_party/libwebrtc/pc/test/integration_test_helpers.cc index ede159d744..64d8debc09 100644 --- a/third_party/libwebrtc/pc/test/integration_test_helpers.cc +++ b/third_party/libwebrtc/pc/test/integration_test_helpers.cc @@ -46,7 +46,7 @@ void RemoveSsrcsAndKeepMsids(cricket::SessionDescription* desc) { int FindFirstMediaStatsIndexByKind( const std::string& kind, - const std::vector<const webrtc::RTCInboundRtpStreamStats*>& inbound_rtps) { + const std::vector<const RTCInboundRtpStreamStats*>& inbound_rtps) { for (size_t i = 0; i < inbound_rtps.size(); i++) { if (*inbound_rtps[i]->kind == kind) { return i; diff --git a/third_party/libwebrtc/pc/test/integration_test_helpers.h b/third_party/libwebrtc/pc/test/integration_test_helpers.h index 36b2111324..fb719e7ddd 100644 --- a/third_party/libwebrtc/pc/test/integration_test_helpers.h +++ b/third_party/libwebrtc/pc/test/integration_test_helpers.h @@ -31,10 +31,10 @@ #include "absl/strings/string_view.h" #include "absl/types/optional.h" #include "api/audio_options.h" -#include "api/call/call_factory_interface.h" #include "api/candidate.h" #include "api/crypto/crypto_options.h" #include "api/data_channel_interface.h" +#include "api/enable_media_with_defaults.h" #include "api/field_trials_view.h" #include "api/ice_transport_interface.h" #include "api/jsep.h" @@ -68,14 +68,11 @@ #include "media/base/media_engine.h" #include "media/base/stream_params.h" #include "media/engine/fake_webrtc_video_engine.h" -#include "media/engine/webrtc_media_engine.h" -#include "media/engine/webrtc_media_engine_defaults.h" #include "modules/audio_device/include/audio_device.h" #include "modules/audio_processing/include/audio_processing.h" #include "modules/audio_processing/test/audio_processing_builder_for_testing.h" #include "p2p/base/fake_ice_transport.h" #include "p2p/base/ice_transport_internal.h" -#include "p2p/base/mock_async_resolver.h" #include "p2p/base/p2p_constants.h" #include "p2p/base/port.h" #include "p2p/base/port_allocator.h" @@ -179,14 +176,14 @@ void ReplaceFirstSsrc(StreamParams& stream, uint32_t ssrc); int FindFirstMediaStatsIndexByKind( const std::string& kind, - const std::vector<const webrtc::RTCInboundRtpStreamStats*>& inbound_rtps); + const std::vector<const RTCInboundRtpStreamStats*>& inbound_rtps); -class TaskQueueMetronome : public webrtc::Metronome { +class TaskQueueMetronome : public Metronome { public: explicit TaskQueueMetronome(TimeDelta tick_period); ~TaskQueueMetronome() override; - // webrtc::Metronome implementation. + // Metronome implementation. void RequestCallOnNextTick(absl::AnyInvocable<void() &&> callback) override; TimeDelta TickPeriod() const override; @@ -209,7 +206,7 @@ class SignalingMessageReceiver { virtual ~SignalingMessageReceiver() {} }; -class MockRtpReceiverObserver : public webrtc::RtpReceiverObserverInterface { +class MockRtpReceiverObserver : public RtpReceiverObserverInterface { public: explicit MockRtpReceiverObserver(cricket::MediaType media_type) : expected_media_type_(media_type) {} @@ -236,14 +233,14 @@ class MockRtpReceiverObserver : public webrtc::RtpReceiverObserverInterface { // advertise support of any codecs. // TODO(steveanton): See how this could become a subclass of // PeerConnectionWrapper defined in peerconnectionwrapper.h. -class PeerConnectionIntegrationWrapper : public webrtc::PeerConnectionObserver, +class PeerConnectionIntegrationWrapper : public PeerConnectionObserver, public SignalingMessageReceiver { public: - webrtc::PeerConnectionFactoryInterface* pc_factory() const { + PeerConnectionFactoryInterface* pc_factory() const { return peer_connection_factory_.get(); } - webrtc::PeerConnectionInterface* pc() const { return peer_connection_.get(); } + PeerConnectionInterface* pc() const { return peer_connection_.get(); } // If a signaling message receiver is set (via ConnectFakeSignaling), this // will set the whole offer/answer exchange in motion. Just need to wait for @@ -341,11 +338,11 @@ class PeerConnectionIntegrationWrapper : public webrtc::PeerConnectionObserver, return AddTrack(CreateLocalVideoTrack()); } - rtc::scoped_refptr<webrtc::AudioTrackInterface> CreateLocalAudioTrack() { + rtc::scoped_refptr<AudioTrackInterface> CreateLocalAudioTrack() { cricket::AudioOptions options; // Disable highpass filter so that we can get all the test audio frames. options.highpass_filter = false; - rtc::scoped_refptr<webrtc::AudioSourceInterface> source = + rtc::scoped_refptr<AudioSourceInterface> source = peer_connection_factory_->CreateAudioSource(options); // TODO(perkj): Test audio source when it is implemented. Currently audio // always use the default input. @@ -353,21 +350,20 @@ class PeerConnectionIntegrationWrapper : public webrtc::PeerConnectionObserver, source.get()); } - rtc::scoped_refptr<webrtc::VideoTrackInterface> CreateLocalVideoTrack() { - webrtc::FakePeriodicVideoSource::Config config; + rtc::scoped_refptr<VideoTrackInterface> CreateLocalVideoTrack() { + FakePeriodicVideoSource::Config config; config.timestamp_offset_ms = rtc::TimeMillis(); return CreateLocalVideoTrackInternal(config); } - rtc::scoped_refptr<webrtc::VideoTrackInterface> - CreateLocalVideoTrackWithConfig( - webrtc::FakePeriodicVideoSource::Config config) { + rtc::scoped_refptr<VideoTrackInterface> CreateLocalVideoTrackWithConfig( + FakePeriodicVideoSource::Config config) { return CreateLocalVideoTrackInternal(config); } - rtc::scoped_refptr<webrtc::VideoTrackInterface> - CreateLocalVideoTrackWithRotation(webrtc::VideoRotation rotation) { - webrtc::FakePeriodicVideoSource::Config config; + rtc::scoped_refptr<VideoTrackInterface> CreateLocalVideoTrackWithRotation( + VideoRotation rotation) { + FakePeriodicVideoSource::Config config; config.rotation = rotation; config.timestamp_offset_ms = rtc::TimeMillis(); return CreateLocalVideoTrackInternal(config); @@ -411,22 +407,22 @@ class PeerConnectionIntegrationWrapper : public webrtc::PeerConnectionObserver, } bool SignalingStateStable() { - return pc()->signaling_state() == webrtc::PeerConnectionInterface::kStable; + return pc()->signaling_state() == PeerConnectionInterface::kStable; } bool IceGatheringStateComplete() { return pc()->ice_gathering_state() == - webrtc::PeerConnectionInterface::kIceGatheringComplete; + PeerConnectionInterface::kIceGatheringComplete; } void CreateDataChannel() { CreateDataChannel(nullptr); } - void CreateDataChannel(const webrtc::DataChannelInit* init) { + void CreateDataChannel(const DataChannelInit* init) { CreateDataChannel(kDataChannelLabel, init); } void CreateDataChannel(const std::string& label, - const webrtc::DataChannelInit* init) { + const DataChannelInit* init) { auto data_channel_or_error = pc()->CreateDataChannelOrError(label, init); ASSERT_TRUE(data_channel_or_error.ok()); data_channels_.push_back(data_channel_or_error.MoveValue()); @@ -484,7 +480,7 @@ class PeerConnectionIntegrationWrapper : public webrtc::PeerConnectionObserver, // Returns a MockStatsObserver in a state after stats gathering finished, // which can be used to access the gathered stats. rtc::scoped_refptr<MockStatsObserver> OldGetStatsForTrack( - webrtc::MediaStreamTrackInterface* track) { + MediaStreamTrackInterface* track) { auto observer = rtc::make_ref_counted<MockStatsObserver>(); EXPECT_TRUE(peer_connection_->GetStats( observer.get(), nullptr, @@ -500,9 +496,8 @@ class PeerConnectionIntegrationWrapper : public webrtc::PeerConnectionObserver, // Synchronously gets stats and returns them. If it times out, fails the test // and returns null. - rtc::scoped_refptr<const webrtc::RTCStatsReport> NewGetStats() { - auto callback = - rtc::make_ref_counted<webrtc::MockRTCStatsCollectorCallback>(); + rtc::scoped_refptr<const RTCStatsReport> NewGetStats() { + auto callback = rtc::make_ref_counted<MockRTCStatsCollectorCallback>(); peer_connection_->GetStats(callback.get()); EXPECT_TRUE_WAIT(callback->called(), kDefaultTimeout); return callback->report(); @@ -529,10 +524,10 @@ class PeerConnectionIntegrationWrapper : public webrtc::PeerConnectionObserver, return static_cast<double>(rendered_width()) / rendered_height(); } - webrtc::VideoRotation rendered_rotation() { + VideoRotation rendered_rotation() { EXPECT_FALSE(fake_video_renderers_.empty()); return fake_video_renderers_.empty() - ? webrtc::kVideoRotation_0 + ? kVideoRotation_0 : fake_video_renderers_.begin()->second->rotation(); } @@ -575,20 +570,20 @@ class PeerConnectionIntegrationWrapper : public webrtc::PeerConnectionObserver, return pc()->local_streams().get(); } - webrtc::PeerConnectionInterface::SignalingState signaling_state() { + PeerConnectionInterface::SignalingState signaling_state() { return pc()->signaling_state(); } - webrtc::PeerConnectionInterface::IceConnectionState ice_connection_state() { + PeerConnectionInterface::IceConnectionState ice_connection_state() { return pc()->ice_connection_state(); } - webrtc::PeerConnectionInterface::IceConnectionState + PeerConnectionInterface::IceConnectionState standardized_ice_connection_state() { return pc()->standardized_ice_connection_state(); } - webrtc::PeerConnectionInterface::IceGatheringState ice_gathering_state() { + PeerConnectionInterface::IceGatheringState ice_gathering_state() { return pc()->ice_gathering_state(); } @@ -617,7 +612,7 @@ class PeerConnectionIntegrationWrapper : public webrtc::PeerConnectionObserver, } cricket::PortAllocator* port_allocator() const { return port_allocator_; } - webrtc::FakeRtcEventLogFactory* event_log_factory() const { + FakeRtcEventLogFactory* event_log_factory() const { return event_log_factory_; } @@ -630,8 +625,7 @@ class PeerConnectionIntegrationWrapper : public webrtc::PeerConnectionObserver, // Sets the mDNS responder for the owned fake network manager and keeps a // reference to the responder. - void SetMdnsResponder( - std::unique_ptr<webrtc::FakeMdnsResponder> mdns_responder) { + void SetMdnsResponder(std::unique_ptr<FakeMdnsResponder> mdns_responder) { RTC_DCHECK(mdns_responder != nullptr); mdns_responder_ = mdns_responder.get(); network_manager()->set_mdns_responder(std::move(mdns_responder)); @@ -646,7 +640,7 @@ class PeerConnectionIntegrationWrapper : public webrtc::PeerConnectionObserver, } bool Rollback() { return SetRemoteDescription( - webrtc::CreateSessionDescription(SdpType::kRollback, "")); + CreateSessionDescription(SdpType::kRollback, "")); } // Functions for querying stats. @@ -654,7 +648,7 @@ class PeerConnectionIntegrationWrapper : public webrtc::PeerConnectionObserver, // Get the baseline numbers for audio_packets and audio_delay. auto received_stats = NewGetStats(); auto rtp_stats = - received_stats->GetStatsOfType<webrtc::RTCInboundRtpStreamStats>()[0]; + received_stats->GetStatsOfType<RTCInboundRtpStreamStats>()[0]; ASSERT_TRUE(rtp_stats->relative_packet_arrival_delay.is_defined()); ASSERT_TRUE(rtp_stats->packets_received.is_defined()); rtp_stats_id_ = rtp_stats->id(); @@ -666,8 +660,7 @@ class PeerConnectionIntegrationWrapper : public webrtc::PeerConnectionObserver, void UpdateDelayStats(std::string tag, int desc_size) { auto report = NewGetStats(); - auto rtp_stats = - report->GetAs<webrtc::RTCInboundRtpStreamStats>(rtp_stats_id_); + auto rtp_stats = report->GetAs<RTCInboundRtpStreamStats>(rtp_stats_id_); ASSERT_TRUE(rtp_stats); auto delta_packets = *rtp_stats->packets_received - audio_packets_stat_; auto delta_rpad = @@ -746,11 +739,11 @@ class PeerConnectionIntegrationWrapper : public webrtc::PeerConnectionObserver, bool Init(const PeerConnectionFactory::Options* options, const PeerConnectionInterface::RTCConfiguration* config, - webrtc::PeerConnectionDependencies dependencies, + PeerConnectionDependencies dependencies, rtc::SocketServer* socket_server, rtc::Thread* network_thread, rtc::Thread* worker_thread, - std::unique_ptr<webrtc::FakeRtcEventLogFactory> event_log_factory, + std::unique_ptr<FakeRtcEventLogFactory> event_log_factory, bool reset_encoder_factory, bool reset_decoder_factory, bool create_media_engine) { @@ -773,51 +766,45 @@ class PeerConnectionIntegrationWrapper : public webrtc::PeerConnectionObserver, } rtc::Thread* const signaling_thread = rtc::Thread::Current(); - webrtc::PeerConnectionFactoryDependencies pc_factory_dependencies; + PeerConnectionFactoryDependencies pc_factory_dependencies; pc_factory_dependencies.network_thread = network_thread; pc_factory_dependencies.worker_thread = worker_thread; pc_factory_dependencies.signaling_thread = signaling_thread; pc_factory_dependencies.task_queue_factory = - webrtc::CreateDefaultTaskQueueFactory(); + CreateDefaultTaskQueueFactory(); pc_factory_dependencies.trials = std::make_unique<FieldTrialBasedConfig>(); pc_factory_dependencies.metronome = std::make_unique<TaskQueueMetronome>(TimeDelta::Millis(8)); - cricket::MediaEngineDependencies media_deps; - media_deps.task_queue_factory = - pc_factory_dependencies.task_queue_factory.get(); - media_deps.adm = fake_audio_capture_module_; - webrtc::SetMediaEngineDefaults(&media_deps); + + pc_factory_dependencies.adm = fake_audio_capture_module_; + if (create_media_engine) { + EnableMediaWithDefaults(pc_factory_dependencies); + } if (reset_encoder_factory) { - media_deps.video_encoder_factory.reset(); + pc_factory_dependencies.video_encoder_factory.reset(); } if (reset_decoder_factory) { - media_deps.video_decoder_factory.reset(); + pc_factory_dependencies.video_decoder_factory.reset(); } - if (!media_deps.audio_processing) { + if (!pc_factory_dependencies.audio_processing) { // If the standard Creation method for APM returns a null pointer, instead // use the builder for testing to create an APM object. - media_deps.audio_processing = AudioProcessingBuilderForTesting().Create(); + pc_factory_dependencies.audio_processing = + AudioProcessingBuilderForTesting().Create(); } - media_deps.trials = pc_factory_dependencies.trials.get(); - - if (create_media_engine) { - pc_factory_dependencies.media_engine = - cricket::CreateMediaEngine(std::move(media_deps)); - } - pc_factory_dependencies.call_factory = webrtc::CreateCallFactory(); if (event_log_factory) { event_log_factory_ = event_log_factory.get(); pc_factory_dependencies.event_log_factory = std::move(event_log_factory); } else { pc_factory_dependencies.event_log_factory = - std::make_unique<webrtc::RtcEventLogFactory>( + std::make_unique<RtcEventLogFactory>( pc_factory_dependencies.task_queue_factory.get()); } - peer_connection_factory_ = webrtc::CreateModularPeerConnectionFactory( - std::move(pc_factory_dependencies)); + peer_connection_factory_ = + CreateModularPeerConnectionFactory(std::move(pc_factory_dependencies)); if (!peer_connection_factory_) { return false; @@ -834,9 +821,9 @@ class PeerConnectionIntegrationWrapper : public webrtc::PeerConnectionObserver, return peer_connection_.get() != nullptr; } - rtc::scoped_refptr<webrtc::PeerConnectionInterface> CreatePeerConnection( + rtc::scoped_refptr<PeerConnectionInterface> CreatePeerConnection( const PeerConnectionInterface::RTCConfiguration* config, - webrtc::PeerConnectionDependencies dependencies) { + PeerConnectionDependencies dependencies) { PeerConnectionInterface::RTCConfiguration modified_config; modified_config.sdp_semantics = sdp_semantics_; // If `config` is null, this will result in a default configuration being @@ -869,21 +856,20 @@ class PeerConnectionIntegrationWrapper : public webrtc::PeerConnectionObserver, signal_ice_candidates_ = signal; } - rtc::scoped_refptr<webrtc::VideoTrackInterface> CreateLocalVideoTrackInternal( - webrtc::FakePeriodicVideoSource::Config config) { + rtc::scoped_refptr<VideoTrackInterface> CreateLocalVideoTrackInternal( + FakePeriodicVideoSource::Config config) { // Set max frame rate to 10fps to reduce the risk of test flakiness. // TODO(deadbeef): Do something more robust. config.frame_interval_ms = 100; video_track_sources_.emplace_back( - rtc::make_ref_counted<webrtc::FakePeriodicVideoTrackSource>( + rtc::make_ref_counted<FakePeriodicVideoTrackSource>( config, false /* remote */)); - rtc::scoped_refptr<webrtc::VideoTrackInterface> track = + rtc::scoped_refptr<VideoTrackInterface> track = peer_connection_factory_->CreateVideoTrack(video_track_sources_.back(), rtc::CreateRandomUuid()); if (!local_video_renderer_) { - local_video_renderer_.reset( - new webrtc::FakeVideoTrackRenderer(track.get())); + local_video_renderer_.reset(new FakeVideoTrackRenderer(track.get())); } return track; } @@ -891,7 +877,7 @@ class PeerConnectionIntegrationWrapper : public webrtc::PeerConnectionObserver, void HandleIncomingOffer(const std::string& msg) { RTC_LOG(LS_INFO) << debug_name_ << ": HandleIncomingOffer"; std::unique_ptr<SessionDescriptionInterface> desc = - webrtc::CreateSessionDescription(SdpType::kOffer, msg); + CreateSessionDescription(SdpType::kOffer, msg); if (received_sdp_munger_) { received_sdp_munger_(desc->description()); } @@ -911,7 +897,7 @@ class PeerConnectionIntegrationWrapper : public webrtc::PeerConnectionObserver, void HandleIncomingAnswer(const std::string& msg) { RTC_LOG(LS_INFO) << debug_name_ << ": HandleIncomingAnswer"; std::unique_ptr<SessionDescriptionInterface> desc = - webrtc::CreateSessionDescription(SdpType::kAnswer, msg); + CreateSessionDescription(SdpType::kAnswer, msg); if (received_sdp_munger_) { received_sdp_munger_(desc->description()); } @@ -1062,7 +1048,7 @@ class PeerConnectionIntegrationWrapper : public webrtc::PeerConnectionObserver, const std::string& msg) override { RTC_LOG(LS_INFO) << debug_name_ << ": ReceiveIceMessage"; absl::optional<RTCError> result; - pc()->AddIceCandidate(absl::WrapUnique(webrtc::CreateIceCandidate( + pc()->AddIceCandidate(absl::WrapUnique(CreateIceCandidate( sdp_mid, sdp_mline_index, msg, nullptr)), [&result](RTCError r) { result = r; }); EXPECT_TRUE_WAIT(result.has_value(), kDefaultTimeout); @@ -1071,7 +1057,7 @@ class PeerConnectionIntegrationWrapper : public webrtc::PeerConnectionObserver, // PeerConnectionObserver callbacks. void OnSignalingChange( - webrtc::PeerConnectionInterface::SignalingState new_state) override { + PeerConnectionInterface::SignalingState new_state) override { EXPECT_EQ(pc()->signaling_state(), new_state); peer_connection_signaling_state_history_.push_back(new_state); } @@ -1100,21 +1086,21 @@ class PeerConnectionIntegrationWrapper : public webrtc::PeerConnectionObserver, } void OnRenegotiationNeeded() override {} void OnIceConnectionChange( - webrtc::PeerConnectionInterface::IceConnectionState new_state) override { + PeerConnectionInterface::IceConnectionState new_state) override { EXPECT_EQ(pc()->ice_connection_state(), new_state); ice_connection_state_history_.push_back(new_state); } void OnStandardizedIceConnectionChange( - webrtc::PeerConnectionInterface::IceConnectionState new_state) override { + PeerConnectionInterface::IceConnectionState new_state) override { standardized_ice_connection_state_history_.push_back(new_state); } void OnConnectionChange( - webrtc::PeerConnectionInterface::PeerConnectionState new_state) override { + PeerConnectionInterface::PeerConnectionState new_state) override { peer_connection_state_history_.push_back(new_state); } void OnIceGatheringChange( - webrtc::PeerConnectionInterface::IceGatheringState new_state) override { + PeerConnectionInterface::IceGatheringState new_state) override { EXPECT_EQ(pc()->ice_gathering_state(), new_state); ice_gathering_state_history_.push_back(new_state); } @@ -1124,7 +1110,7 @@ class PeerConnectionIntegrationWrapper : public webrtc::PeerConnectionObserver, ice_candidate_pair_change_history_.push_back(event); } - void OnIceCandidate(const webrtc::IceCandidateInterface* candidate) override { + void OnIceCandidate(const IceCandidateInterface* candidate) override { RTC_LOG(LS_INFO) << debug_name_ << ": OnIceCandidate"; if (remote_async_dns_resolver_) { @@ -1180,20 +1166,19 @@ class PeerConnectionIntegrationWrapper : public webrtc::PeerConnectionObserver, std::unique_ptr<rtc::FakeNetworkManager> fake_network_manager_; std::unique_ptr<rtc::BasicPacketSocketFactory> socket_factory_; // Reference to the mDNS responder owned by `fake_network_manager_` after set. - webrtc::FakeMdnsResponder* mdns_responder_ = nullptr; + FakeMdnsResponder* mdns_responder_ = nullptr; - rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection_; - rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> - peer_connection_factory_; + rtc::scoped_refptr<PeerConnectionInterface> peer_connection_; + rtc::scoped_refptr<PeerConnectionFactoryInterface> peer_connection_factory_; cricket::PortAllocator* port_allocator_; // Needed to keep track of number of frames sent. rtc::scoped_refptr<FakeAudioCaptureModule> fake_audio_capture_module_; // Needed to keep track of number of frames received. - std::map<std::string, std::unique_ptr<webrtc::FakeVideoTrackRenderer>> + std::map<std::string, std::unique_ptr<FakeVideoTrackRenderer>> fake_video_renderers_; // Needed to ensure frames aren't received for removed tracks. - std::vector<std::unique_ptr<webrtc::FakeVideoTrackRenderer>> + std::vector<std::unique_ptr<FakeVideoTrackRenderer>> removed_fake_video_renderers_; // For remote peer communication. @@ -1205,10 +1190,9 @@ class PeerConnectionIntegrationWrapper : public webrtc::PeerConnectionObserver, // Store references to the video sources we've created, so that we can stop // them, if required. - std::vector<rtc::scoped_refptr<webrtc::VideoTrackSource>> - video_track_sources_; + std::vector<rtc::scoped_refptr<VideoTrackSource>> video_track_sources_; // `local_video_renderer_` attached to the first created local video track. - std::unique_ptr<webrtc::FakeVideoTrackRenderer> local_video_renderer_; + std::unique_ptr<FakeVideoTrackRenderer> local_video_renderer_; SdpSemantics sdp_semantics_; PeerConnectionInterface::RTCOfferAnswerOptions offer_answer_options_; @@ -1238,7 +1222,7 @@ class PeerConnectionIntegrationWrapper : public webrtc::PeerConnectionObserver, ice_candidate_pair_change_history_; std::vector<PeerConnectionInterface::SignalingState> peer_connection_signaling_state_history_; - webrtc::FakeRtcEventLogFactory* event_log_factory_; + FakeRtcEventLogFactory* event_log_factory_; // Number of ICE candidates expected. The default is no limit. int candidates_expected_ = std::numeric_limits<int>::max(); @@ -1255,7 +1239,7 @@ class PeerConnectionIntegrationWrapper : public webrtc::PeerConnectionObserver, friend class PeerConnectionIntegrationBaseTest; }; -class MockRtcEventLogOutput : public webrtc::RtcEventLogOutput { +class MockRtcEventLogOutput : public RtcEventLogOutput { public: virtual ~MockRtcEventLogOutput() = default; MOCK_METHOD(bool, IsActive, (), (const, override)); @@ -1367,7 +1351,7 @@ class MediaExpectations { int callee_video_frames_expected_ = 0; }; -class MockIceTransport : public webrtc::IceTransportInterface { +class MockIceTransport : public IceTransportInterface { public: MockIceTransport(const std::string& name, int component) : internal_(std::make_unique<cricket::FakeIceTransport>( @@ -1415,7 +1399,7 @@ class PeerConnectionIntegrationBaseTest : public ::testing::Test { worker_thread_->SetName("PCWorkerThread", this); RTC_CHECK(network_thread_->Start()); RTC_CHECK(worker_thread_->Start()); - webrtc::metrics::Reset(); + metrics::Reset(); } ~PeerConnectionIntegrationBaseTest() { @@ -1452,13 +1436,13 @@ class PeerConnectionIntegrationBaseTest : public ::testing::Test { // are connected. This is an important distinction. Once we have separate // ICE and DTLS state, this check needs to use the DTLS state. return (callee()->ice_connection_state() == - webrtc::PeerConnectionInterface::kIceConnectionConnected || + PeerConnectionInterface::kIceConnectionConnected || callee()->ice_connection_state() == - webrtc::PeerConnectionInterface::kIceConnectionCompleted) && + PeerConnectionInterface::kIceConnectionCompleted) && (caller()->ice_connection_state() == - webrtc::PeerConnectionInterface::kIceConnectionConnected || + PeerConnectionInterface::kIceConnectionConnected || caller()->ice_connection_state() == - webrtc::PeerConnectionInterface::kIceConnectionCompleted); + PeerConnectionInterface::kIceConnectionCompleted); } // When `event_log_factory` is null, the default implementation of the event @@ -1467,8 +1451,8 @@ class PeerConnectionIntegrationBaseTest : public ::testing::Test { const std::string& debug_name, const PeerConnectionFactory::Options* options, const RTCConfiguration* config, - webrtc::PeerConnectionDependencies dependencies, - std::unique_ptr<webrtc::FakeRtcEventLogFactory> event_log_factory, + PeerConnectionDependencies dependencies, + std::unique_ptr<FakeRtcEventLogFactory> event_log_factory, bool reset_encoder_factory, bool reset_decoder_factory, bool create_media_engine = true) { @@ -1498,10 +1482,10 @@ class PeerConnectionIntegrationBaseTest : public ::testing::Test { const std::string& debug_name, const PeerConnectionFactory::Options* options, const RTCConfiguration* config, - webrtc::PeerConnectionDependencies dependencies) { + PeerConnectionDependencies dependencies) { return CreatePeerConnectionWrapper( debug_name, options, config, std::move(dependencies), - std::make_unique<webrtc::FakeRtcEventLogFactory>(), + std::make_unique<FakeRtcEventLogFactory>(), /*reset_encoder_factory=*/false, /*reset_decoder_factory=*/false); } @@ -1522,17 +1506,17 @@ class PeerConnectionIntegrationBaseTest : public ::testing::Test { // callee PeerConnections. SdpSemantics original_semantics = sdp_semantics_; sdp_semantics_ = caller_semantics; - caller_ = CreatePeerConnectionWrapper( - "Caller", nullptr, nullptr, webrtc::PeerConnectionDependencies(nullptr), - nullptr, - /*reset_encoder_factory=*/false, - /*reset_decoder_factory=*/false); + caller_ = CreatePeerConnectionWrapper("Caller", nullptr, nullptr, + PeerConnectionDependencies(nullptr), + nullptr, + /*reset_encoder_factory=*/false, + /*reset_decoder_factory=*/false); sdp_semantics_ = callee_semantics; - callee_ = CreatePeerConnectionWrapper( - "Callee", nullptr, nullptr, webrtc::PeerConnectionDependencies(nullptr), - nullptr, - /*reset_encoder_factory=*/false, - /*reset_decoder_factory=*/false); + callee_ = CreatePeerConnectionWrapper("Callee", nullptr, nullptr, + PeerConnectionDependencies(nullptr), + nullptr, + /*reset_encoder_factory=*/false, + /*reset_decoder_factory=*/false); sdp_semantics_ = original_semantics; return caller_ && callee_; } @@ -1540,24 +1524,24 @@ class PeerConnectionIntegrationBaseTest : public ::testing::Test { bool CreatePeerConnectionWrappersWithConfig( const PeerConnectionInterface::RTCConfiguration& caller_config, const PeerConnectionInterface::RTCConfiguration& callee_config) { - caller_ = CreatePeerConnectionWrapper( - "Caller", nullptr, &caller_config, - webrtc::PeerConnectionDependencies(nullptr), nullptr, - /*reset_encoder_factory=*/false, - /*reset_decoder_factory=*/false); - callee_ = CreatePeerConnectionWrapper( - "Callee", nullptr, &callee_config, - webrtc::PeerConnectionDependencies(nullptr), nullptr, - /*reset_encoder_factory=*/false, - /*reset_decoder_factory=*/false); + caller_ = CreatePeerConnectionWrapper("Caller", nullptr, &caller_config, + PeerConnectionDependencies(nullptr), + nullptr, + /*reset_encoder_factory=*/false, + /*reset_decoder_factory=*/false); + callee_ = CreatePeerConnectionWrapper("Callee", nullptr, &callee_config, + PeerConnectionDependencies(nullptr), + nullptr, + /*reset_encoder_factory=*/false, + /*reset_decoder_factory=*/false); return caller_ && callee_; } bool CreatePeerConnectionWrappersWithConfigAndDeps( const PeerConnectionInterface::RTCConfiguration& caller_config, - webrtc::PeerConnectionDependencies caller_dependencies, + PeerConnectionDependencies caller_dependencies, const PeerConnectionInterface::RTCConfiguration& callee_config, - webrtc::PeerConnectionDependencies callee_dependencies) { + PeerConnectionDependencies callee_dependencies) { caller_ = CreatePeerConnectionWrapper("Caller", nullptr, &caller_config, std::move(caller_dependencies), nullptr, @@ -1574,16 +1558,16 @@ class PeerConnectionIntegrationBaseTest : public ::testing::Test { bool CreatePeerConnectionWrappersWithOptions( const PeerConnectionFactory::Options& caller_options, const PeerConnectionFactory::Options& callee_options) { - caller_ = CreatePeerConnectionWrapper( - "Caller", &caller_options, nullptr, - webrtc::PeerConnectionDependencies(nullptr), nullptr, - /*reset_encoder_factory=*/false, - /*reset_decoder_factory=*/false); - callee_ = CreatePeerConnectionWrapper( - "Callee", &callee_options, nullptr, - webrtc::PeerConnectionDependencies(nullptr), nullptr, - /*reset_encoder_factory=*/false, - /*reset_decoder_factory=*/false); + caller_ = CreatePeerConnectionWrapper("Caller", &caller_options, nullptr, + PeerConnectionDependencies(nullptr), + nullptr, + /*reset_encoder_factory=*/false, + /*reset_decoder_factory=*/false); + callee_ = CreatePeerConnectionWrapper("Callee", &callee_options, nullptr, + PeerConnectionDependencies(nullptr), + nullptr, + /*reset_encoder_factory=*/false, + /*reset_decoder_factory=*/false); return caller_ && callee_; } @@ -1591,10 +1575,10 @@ class PeerConnectionIntegrationBaseTest : public ::testing::Test { PeerConnectionInterface::RTCConfiguration default_config; caller_ = CreatePeerConnectionWrapperWithFakeRtcEventLog( "Caller", nullptr, &default_config, - webrtc::PeerConnectionDependencies(nullptr)); + PeerConnectionDependencies(nullptr)); callee_ = CreatePeerConnectionWrapperWithFakeRtcEventLog( "Callee", nullptr, &default_config, - webrtc::PeerConnectionDependencies(nullptr)); + PeerConnectionDependencies(nullptr)); return caller_ && callee_; } @@ -1604,7 +1588,7 @@ class PeerConnectionIntegrationBaseTest : public ::testing::Test { new FakeRTCCertificateGenerator()); cert_generator->use_alternate_key(); - webrtc::PeerConnectionDependencies dependencies(nullptr); + PeerConnectionDependencies dependencies(nullptr); dependencies.cert_generator = std::move(cert_generator); return CreatePeerConnectionWrapper("New Peer", nullptr, nullptr, std::move(dependencies), nullptr, @@ -1614,12 +1598,12 @@ class PeerConnectionIntegrationBaseTest : public ::testing::Test { bool CreateOneDirectionalPeerConnectionWrappers(bool caller_to_callee) { caller_ = CreatePeerConnectionWrapper( - "Caller", nullptr, nullptr, webrtc::PeerConnectionDependencies(nullptr), + "Caller", nullptr, nullptr, PeerConnectionDependencies(nullptr), nullptr, /*reset_encoder_factory=*/!caller_to_callee, /*reset_decoder_factory=*/caller_to_callee); callee_ = CreatePeerConnectionWrapper( - "Callee", nullptr, nullptr, webrtc::PeerConnectionDependencies(nullptr), + "Callee", nullptr, nullptr, PeerConnectionDependencies(nullptr), nullptr, /*reset_encoder_factory=*/caller_to_callee, /*reset_decoder_factory=*/!caller_to_callee); @@ -1627,18 +1611,18 @@ class PeerConnectionIntegrationBaseTest : public ::testing::Test { } bool CreatePeerConnectionWrappersWithoutMediaEngine() { - caller_ = CreatePeerConnectionWrapper( - "Caller", nullptr, nullptr, webrtc::PeerConnectionDependencies(nullptr), - nullptr, - /*reset_encoder_factory=*/false, - /*reset_decoder_factory=*/false, - /*create_media_engine=*/false); - callee_ = CreatePeerConnectionWrapper( - "Callee", nullptr, nullptr, webrtc::PeerConnectionDependencies(nullptr), - nullptr, - /*reset_encoder_factory=*/false, - /*reset_decoder_factory=*/false, - /*create_media_engine=*/false); + caller_ = CreatePeerConnectionWrapper("Caller", nullptr, nullptr, + PeerConnectionDependencies(nullptr), + nullptr, + /*reset_encoder_factory=*/false, + /*reset_decoder_factory=*/false, + /*create_media_engine=*/false); + callee_ = CreatePeerConnectionWrapper("Callee", nullptr, nullptr, + PeerConnectionDependencies(nullptr), + nullptr, + /*reset_encoder_factory=*/false, + /*reset_decoder_factory=*/false, + /*create_media_engine=*/false); return caller_ && callee_; } @@ -1708,7 +1692,7 @@ class PeerConnectionIntegrationBaseTest : public ::testing::Test { // Messages may get lost on the unreliable DataChannel, so we send multiple // times to avoid test flakiness. - void SendRtpDataWithRetries(webrtc::DataChannelInterface* dc, + void SendRtpDataWithRetries(DataChannelInterface* dc, const std::string& data, int retries) { for (int i = 0; i < retries; ++i) { diff --git a/third_party/libwebrtc/pc/test/mock_peer_connection_observers.h b/third_party/libwebrtc/pc/test/mock_peer_connection_observers.h index e9d97a97f6..6222ef7719 100644 --- a/third_party/libwebrtc/pc/test/mock_peer_connection_observers.h +++ b/third_party/libwebrtc/pc/test/mock_peer_connection_observers.h @@ -254,7 +254,7 @@ class MockPeerConnectionObserver : public PeerConnectionObserver { }; class MockCreateSessionDescriptionObserver - : public webrtc::CreateSessionDescriptionObserver { + : public CreateSessionDescriptionObserver { public: MockCreateSessionDescriptionObserver() : called_(false), @@ -266,7 +266,7 @@ class MockCreateSessionDescriptionObserver error_ = ""; desc_.reset(desc); } - void OnFailure(webrtc::RTCError error) override { + void OnFailure(RTCError error) override { MutexLock lock(&mutex_); called_ = true; error_ = error.message(); @@ -295,8 +295,7 @@ class MockCreateSessionDescriptionObserver std::unique_ptr<SessionDescriptionInterface> desc_ RTC_GUARDED_BY(mutex_); }; -class MockSetSessionDescriptionObserver - : public webrtc::SetSessionDescriptionObserver { +class MockSetSessionDescriptionObserver : public SetSessionDescriptionObserver { public: static rtc::scoped_refptr<MockSetSessionDescriptionObserver> Create() { return rtc::make_ref_counted<MockSetSessionDescriptionObserver>(); @@ -312,7 +311,7 @@ class MockSetSessionDescriptionObserver called_ = true; error_ = ""; } - void OnFailure(webrtc::RTCError error) override { + void OnFailure(RTCError error) override { MutexLock lock(&mutex_); called_ = true; error_ = error.message(); @@ -375,14 +374,14 @@ class FakeSetRemoteDescriptionObserver absl::optional<RTCError> error_; }; -class MockDataChannelObserver : public webrtc::DataChannelObserver { +class MockDataChannelObserver : public DataChannelObserver { public: struct Message { std::string data; bool binary; }; - explicit MockDataChannelObserver(webrtc::DataChannelInterface* channel) + explicit MockDataChannelObserver(DataChannelInterface* channel) : channel_(channel) { channel_->RegisterObserver(this); states_.push_back(channel_->state()); @@ -419,12 +418,12 @@ class MockDataChannelObserver : public webrtc::DataChannelObserver { } private: - rtc::scoped_refptr<webrtc::DataChannelInterface> channel_; + rtc::scoped_refptr<DataChannelInterface> channel_; std::vector<DataChannelInterface::DataState> states_; std::vector<Message> messages_; }; -class MockStatsObserver : public webrtc::StatsObserver { +class MockStatsObserver : public StatsObserver { public: MockStatsObserver() : called_(false), stats_() {} virtual ~MockStatsObserver() {} @@ -576,7 +575,7 @@ class MockStatsObserver : public webrtc::StatsObserver { }; // Helper class that just stores the report from the callback. -class MockRTCStatsCollectorCallback : public webrtc::RTCStatsCollectorCallback { +class MockRTCStatsCollectorCallback : public RTCStatsCollectorCallback { public: rtc::scoped_refptr<const RTCStatsReport> report() { return report_; } diff --git a/third_party/libwebrtc/pc/test/rtp_transport_test_util.h b/third_party/libwebrtc/pc/test/rtp_transport_test_util.h index 593ee002c9..563014f94a 100644 --- a/third_party/libwebrtc/pc/test/rtp_transport_test_util.h +++ b/third_party/libwebrtc/pc/test/rtp_transport_test_util.h @@ -33,9 +33,14 @@ class TransportObserver : public RtpPacketSinkInterface { rtp_transport->SubscribeReadyToSend( this, [this](bool arg) { OnReadyToSend(arg); }); rtp_transport->SetUnDemuxableRtpPacketReceivedHandler( - [this](webrtc::RtpPacketReceived& packet) { - OnUndemuxableRtpPacket(packet); - }); + [this](RtpPacketReceived& packet) { OnUndemuxableRtpPacket(packet); }); + rtp_transport->SubscribeSentPacket(this, + [this](const rtc::SentPacket& packet) { + sent_packet_count_++; + if (action_on_sent_packet_) { + action_on_sent_packet_(); + } + }); } // RtpPacketInterface override. @@ -57,6 +62,7 @@ class TransportObserver : public RtpPacketSinkInterface { int rtp_count() const { return rtp_count_; } int un_demuxable_rtp_count() const { return un_demuxable_rtp_count_; } int rtcp_count() const { return rtcp_count_; } + int sent_packet_count() const { return sent_packet_count_; } rtc::CopyOnWriteBuffer last_recv_rtp_packet() { return last_recv_rtp_packet_; @@ -81,16 +87,21 @@ class TransportObserver : public RtpPacketSinkInterface { void SetActionOnReadyToSend(absl::AnyInvocable<void(bool)> action) { action_on_ready_to_send_ = std::move(action); } + void SetActionOnSentPacket(absl::AnyInvocable<void()> action) { + action_on_sent_packet_ = std::move(action); + } private: bool ready_to_send_ = false; int rtp_count_ = 0; int un_demuxable_rtp_count_ = 0; int rtcp_count_ = 0; + int sent_packet_count_ = 0; int ready_to_send_signal_count_ = 0; rtc::CopyOnWriteBuffer last_recv_rtp_packet_; rtc::CopyOnWriteBuffer last_recv_rtcp_packet_; absl::AnyInvocable<void(bool)> action_on_ready_to_send_; + absl::AnyInvocable<void()> action_on_sent_packet_; }; } // namespace webrtc diff --git a/third_party/libwebrtc/pc/test/svc_e2e_tests.cc b/third_party/libwebrtc/pc/test/svc_e2e_tests.cc index ae35c7f676..3fde5a44e0 100644 --- a/third_party/libwebrtc/pc/test/svc_e2e_tests.cc +++ b/third_party/libwebrtc/pc/test/svc_e2e_tests.cc @@ -160,10 +160,9 @@ std::string SvcTestNameGenerator( // encoder and decoder level. class SvcVideoQualityAnalyzer : public DefaultVideoQualityAnalyzer { public: - using SpatialTemporalLayerCounts = - webrtc::flat_map<int, webrtc::flat_map<int, int>>; + using SpatialTemporalLayerCounts = flat_map<int, flat_map<int, int>>; - explicit SvcVideoQualityAnalyzer(webrtc::Clock* clock) + explicit SvcVideoQualityAnalyzer(Clock* clock) : DefaultVideoQualityAnalyzer(clock, test::GetGlobalMetricsLogger(), DefaultVideoQualityAnalyzerOptions{ @@ -315,9 +314,9 @@ TEST_P(SvcTest, ScalabilityModeSupported) { if (UseDependencyDescriptor()) { trials += "WebRTC-DependencyDescriptorAdvertised/Enabled/"; } - webrtc::test::ScopedFieldTrials override_trials(AppendFieldTrials(trials)); + test::ScopedFieldTrials override_trials(AppendFieldTrials(trials)); std::unique_ptr<NetworkEmulationManager> network_emulation_manager = - CreateNetworkEmulationManager(webrtc::TimeMode::kSimulated); + CreateNetworkEmulationManager(TimeMode::kSimulated); auto analyzer = std::make_unique<SvcVideoQualityAnalyzer>( network_emulation_manager->time_controller()->GetClock()); SvcVideoQualityAnalyzer* analyzer_ptr = analyzer.get(); @@ -475,16 +474,17 @@ INSTANTIATE_TEST_SUITE_P( SvcTestParameters::Create(kAv1CodecName, "L2T3h"), SvcTestParameters::Create(kAv1CodecName, "L2T3_KEY"), // SvcTestParameters::Create(kAv1CodecName, "L2T3_KEY_SHIFT"), - SvcTestParameters::Create(kAv1CodecName, "L3T1"), - SvcTestParameters::Create(kAv1CodecName, "L3T1h"), - SvcTestParameters::Create(kAv1CodecName, "L3T1_KEY"), - SvcTestParameters::Create(kAv1CodecName, "L3T2"), - SvcTestParameters::Create(kAv1CodecName, "L3T2h"), - SvcTestParameters::Create(kAv1CodecName, "L3T2_KEY"), + // TODO(bugs.webrtc.org/15666): Investigate and reenable AV1 + // L3 tests. SvcTestParameters::Create(kAv1CodecName, "L3T1"), + // SvcTestParameters::Create(kAv1CodecName, "L3T1h"), + // SvcTestParameters::Create(kAv1CodecName, "L3T1_KEY"), + // SvcTestParameters::Create(kAv1CodecName, "L3T2"), + // SvcTestParameters::Create(kAv1CodecName, "L3T2h"), + // SvcTestParameters::Create(kAv1CodecName, "L3T2_KEY"), // SvcTestParameters::Create(kAv1CodecName, "L3T2_KEY_SHIFT"), - SvcTestParameters::Create(kAv1CodecName, "L3T3"), - SvcTestParameters::Create(kAv1CodecName, "L3T3h"), - SvcTestParameters::Create(kAv1CodecName, "L3T3_KEY"), + // SvcTestParameters::Create(kAv1CodecName, "L3T3"), + // SvcTestParameters::Create(kAv1CodecName, "L3T3h"), + // SvcTestParameters::Create(kAv1CodecName, "L3T3_KEY"), // SvcTestParameters::Create(kAv1CodecName, "L3T3_KEY_SHIFT"), SvcTestParameters::Create(kAv1CodecName, "S2T1"), SvcTestParameters::Create(kAv1CodecName, "S2T1h"), @@ -492,12 +492,14 @@ INSTANTIATE_TEST_SUITE_P( SvcTestParameters::Create(kAv1CodecName, "S2T2h"), SvcTestParameters::Create(kAv1CodecName, "S2T3"), SvcTestParameters::Create(kAv1CodecName, "S2T3h"), - SvcTestParameters::Create(kAv1CodecName, "S3T1"), - SvcTestParameters::Create(kAv1CodecName, "S3T1h"), - SvcTestParameters::Create(kAv1CodecName, "S3T2"), - SvcTestParameters::Create(kAv1CodecName, "S3T2h"), - SvcTestParameters::Create(kAv1CodecName, "S3T3"), - SvcTestParameters::Create(kAv1CodecName, "S3T3h"), + // TODO(bugs.webrtc.org/15666): Investigate and reenable AV1 + // S3 tests. + // SvcTestParameters::Create(kAv1CodecName, "S3T1"), + // SvcTestParameters::Create(kAv1CodecName, "S3T1h"), + // SvcTestParameters::Create(kAv1CodecName, "S3T2"), + // SvcTestParameters::Create(kAv1CodecName, "S3T2h"), + // SvcTestParameters::Create(kAv1CodecName, "S3T3"), + // SvcTestParameters::Create(kAv1CodecName, "S3T3h"), }), Values(UseDependencyDescriptor::Enabled)), SvcTestNameGenerator); |