diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:14:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:14:29 +0000 |
commit | fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8 (patch) | |
tree | 4c1ccaf5486d4f2009f9a338a98a83e886e29c97 /third_party/libwebrtc/test/network | |
parent | Releasing progress-linux version 124.0.1-1~progress7.99u1. (diff) | |
download | firefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.tar.xz firefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.zip |
Merging upstream version 125.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/libwebrtc/test/network')
4 files changed, 61 insertions, 61 deletions
diff --git a/third_party/libwebrtc/test/network/BUILD.gn b/third_party/libwebrtc/test/network/BUILD.gn index 5a6cb31f4b..b8255d35fd 100644 --- a/third_party/libwebrtc/test/network/BUILD.gn +++ b/third_party/libwebrtc/test/network/BUILD.gn @@ -76,6 +76,7 @@ rtc_library("emulated_network") { "../../rtc_base:task_queue_for_test", "../../rtc_base:threading", "../../rtc_base/memory:always_valid_pointer", + "../../rtc_base/network:received_packet", "../../rtc_base/synchronization:mutex", "../../rtc_base/system:no_unique_address", "../../rtc_base/task_utils:repeating_task", @@ -117,6 +118,7 @@ if (rtc_include_tests && !build_with_chromium) { ":emulated_network", "../:test_support", "../../api:callfactory_api", + "../../api:enable_media_with_defaults", "../../api:libjingle_peerconnection_api", "../../api:scoped_refptr", "../../api:simulated_network_api", @@ -125,7 +127,6 @@ if (rtc_include_tests && !build_with_chromium) { "../../api/transport:field_trial_based_config", "../../call:simulated_network", "../../media:rtc_audio_video", - "../../media:rtc_media_engine_defaults", "../../modules/audio_device:test_audio_device_module", "../../p2p:rtc_p2p", "../../pc:pc_test_utils", diff --git a/third_party/libwebrtc/test/network/emulated_turn_server.cc b/third_party/libwebrtc/test/network/emulated_turn_server.cc index 0bc7ec6e2a..93724ca8a3 100644 --- a/third_party/libwebrtc/test/network/emulated_turn_server.cc +++ b/third_party/libwebrtc/test/network/emulated_turn_server.cc @@ -14,6 +14,7 @@ #include <utility> #include "api/packet_socket_factory.h" +#include "rtc_base/network/received_packet.h" #include "rtc_base/strings/string_builder.h" #include "rtc_base/task_queue_for_test.h" @@ -22,10 +23,56 @@ namespace { static const char kTestRealm[] = "example.org"; static const char kTestSoftware[] = "TestTurnServer"; +// A wrapper class for cricket::TurnServer to allocate sockets. +class PacketSocketFactoryWrapper : public rtc::PacketSocketFactory { + public: + explicit PacketSocketFactoryWrapper( + webrtc::test::EmulatedTURNServer* turn_server) + : turn_server_(turn_server) {} + ~PacketSocketFactoryWrapper() override {} + + // This method is called from TurnServer when making a TURN ALLOCATION. + // It will create a socket on the `peer_` endpoint. + rtc::AsyncPacketSocket* CreateUdpSocket(const rtc::SocketAddress& address, + uint16_t min_port, + uint16_t max_port) override { + return turn_server_->CreatePeerSocket(); + } + + rtc::AsyncListenSocket* CreateServerTcpSocket( + const rtc::SocketAddress& local_address, + uint16_t min_port, + uint16_t max_port, + int opts) override { + return nullptr; + } + rtc::AsyncPacketSocket* CreateClientTcpSocket( + const rtc::SocketAddress& local_address, + const rtc::SocketAddress& remote_address, + const rtc::ProxyInfo& proxy_info, + const std::string& user_agent, + const rtc::PacketSocketTcpOptions& tcp_options) override { + return nullptr; + } + std::unique_ptr<webrtc::AsyncDnsResolverInterface> CreateAsyncDnsResolver() + override { + return nullptr; + } + + private: + webrtc::test::EmulatedTURNServer* turn_server_; +}; + +} // namespace + +namespace webrtc { +namespace test { + // A wrapper class for copying data between an AsyncPacketSocket and a // EmulatedEndpoint. This is used by the cricket::TurnServer when // sending data back into the emulated network. -class AsyncPacketSocketWrapper : public rtc::AsyncPacketSocket { +class EmulatedTURNServer::AsyncPacketSocketWrapper + : public rtc::AsyncPacketSocket { public: AsyncPacketSocketWrapper(webrtc::test::EmulatedTURNServer* turn_server, webrtc::EmulatedEndpoint* endpoint, @@ -56,6 +103,9 @@ class AsyncPacketSocketWrapper : public rtc::AsyncPacketSocket { return cb; } int Close() override { return 0; } + void NotifyPacketReceived(const rtc::ReceivedPacket& packet) { + rtc::AsyncPacketSocket::NotifyPacketReceived(packet); + } rtc::AsyncPacketSocket::State GetState() const override { return rtc::AsyncPacketSocket::STATE_BOUND; @@ -71,51 +121,6 @@ class AsyncPacketSocketWrapper : public rtc::AsyncPacketSocket { const rtc::SocketAddress local_address_; }; -// A wrapper class for cricket::TurnServer to allocate sockets. -class PacketSocketFactoryWrapper : public rtc::PacketSocketFactory { - public: - explicit PacketSocketFactoryWrapper( - webrtc::test::EmulatedTURNServer* turn_server) - : turn_server_(turn_server) {} - ~PacketSocketFactoryWrapper() override {} - - // This method is called from TurnServer when making a TURN ALLOCATION. - // It will create a socket on the `peer_` endpoint. - rtc::AsyncPacketSocket* CreateUdpSocket(const rtc::SocketAddress& address, - uint16_t min_port, - uint16_t max_port) override { - return turn_server_->CreatePeerSocket(); - } - - rtc::AsyncListenSocket* CreateServerTcpSocket( - const rtc::SocketAddress& local_address, - uint16_t min_port, - uint16_t max_port, - int opts) override { - return nullptr; - } - rtc::AsyncPacketSocket* CreateClientTcpSocket( - const rtc::SocketAddress& local_address, - const rtc::SocketAddress& remote_address, - const rtc::ProxyInfo& proxy_info, - const std::string& user_agent, - const rtc::PacketSocketTcpOptions& tcp_options) override { - return nullptr; - } - std::unique_ptr<webrtc::AsyncDnsResolverInterface> CreateAsyncDnsResolver() - override { - return nullptr; - } - - private: - webrtc::test::EmulatedTURNServer* turn_server_; -}; - -} // namespace - -namespace webrtc { -namespace test { - EmulatedTURNServer::EmulatedTURNServer(std::unique_ptr<rtc::Thread> thread, EmulatedEndpoint* client, EmulatedEndpoint* peer) @@ -170,9 +175,8 @@ void EmulatedTURNServer::OnPacketReceived(webrtc::EmulatedIpPacket packet) { RTC_DCHECK_RUN_ON(thread_.get()); auto it = sockets_.find(packet.to); if (it != sockets_.end()) { - it->second->SignalReadPacket( - it->second, reinterpret_cast<const char*>(packet.cdata()), - packet.size(), packet.from, packet.arrival_time.ms()); + it->second->NotifyPacketReceived( + rtc::ReceivedPacket(packet.data, packet.from, packet.arrival_time)); } }); } diff --git a/third_party/libwebrtc/test/network/emulated_turn_server.h b/third_party/libwebrtc/test/network/emulated_turn_server.h index 9cb0ceabf6..de5d266897 100644 --- a/third_party/libwebrtc/test/network/emulated_turn_server.h +++ b/third_party/libwebrtc/test/network/emulated_turn_server.h @@ -84,7 +84,8 @@ class EmulatedTURNServer : public EmulatedTURNServerInterface, EmulatedEndpoint* const client_; EmulatedEndpoint* const peer_; std::unique_ptr<cricket::TurnServer> turn_server_ RTC_GUARDED_BY(&thread_); - std::map<rtc::SocketAddress, rtc::AsyncPacketSocket*> sockets_ + class AsyncPacketSocketWrapper; + std::map<rtc::SocketAddress, AsyncPacketSocketWrapper*> sockets_ RTC_GUARDED_BY(&thread_); // Wraps a EmulatedEndpoint in a AsyncPacketSocket to bridge interaction diff --git a/third_party/libwebrtc/test/network/network_emulation_pc_unittest.cc b/third_party/libwebrtc/test/network/network_emulation_pc_unittest.cc index 51a45a8234..09d3946747 100644 --- a/third_party/libwebrtc/test/network/network_emulation_pc_unittest.cc +++ b/third_party/libwebrtc/test/network/network_emulation_pc_unittest.cc @@ -11,7 +11,7 @@ #include <cstdint> #include <memory> -#include "api/call/call_factory_interface.h" +#include "api/enable_media_with_defaults.h" #include "api/peer_connection_interface.h" #include "api/rtc_event_log/rtc_event_log_factory.h" #include "api/scoped_refptr.h" @@ -19,7 +19,6 @@ #include "api/transport/field_trial_based_config.h" #include "call/simulated_network.h" #include "media/engine/webrtc_media_engine.h" -#include "media/engine/webrtc_media_engine_defaults.h" #include "modules/audio_device/include/test_audio_device.h" #include "p2p/base/basic_packet_socket_factory.h" #include "p2p/client/basic_port_allocator.h" @@ -57,23 +56,18 @@ rtc::scoped_refptr<PeerConnectionFactoryInterface> CreatePeerConnectionFactory( rtc::Thread* network_thread) { PeerConnectionFactoryDependencies pcf_deps; pcf_deps.task_queue_factory = CreateDefaultTaskQueueFactory(); - pcf_deps.call_factory = CreateCallFactory(); pcf_deps.event_log_factory = std::make_unique<RtcEventLogFactory>(pcf_deps.task_queue_factory.get()); pcf_deps.network_thread = network_thread; pcf_deps.signaling_thread = signaling_thread; pcf_deps.trials = std::make_unique<FieldTrialBasedConfig>(); - cricket::MediaEngineDependencies media_deps; - media_deps.task_queue_factory = pcf_deps.task_queue_factory.get(); - media_deps.adm = TestAudioDeviceModule::Create( - media_deps.task_queue_factory, + pcf_deps.adm = TestAudioDeviceModule::Create( + pcf_deps.task_queue_factory.get(), TestAudioDeviceModule::CreatePulsedNoiseCapturer(kMaxAptitude, kSamplingFrequency), TestAudioDeviceModule::CreateDiscardRenderer(kSamplingFrequency), /*speed=*/1.f); - media_deps.trials = pcf_deps.trials.get(); - SetMediaEngineDefaults(&media_deps); - pcf_deps.media_engine = cricket::CreateMediaEngine(std::move(media_deps)); + EnableMediaWithDefaults(pcf_deps); return CreateModularPeerConnectionFactory(std::move(pcf_deps)); } |