Revert "Move injection of PacketSocketFactory from PC to PCF"
This reverts commit 905c3a6c73d293882ef11942066ccda52a9e14d1.
Reason for revert: New test fails internal tests, with a similar problem as the failed android test: No networks are detected on the test bot.
Original change's description:
> Move injection of PacketSocketFactory from PC to PCF
>
> Injection via PeerConnectionDependecies was broken, in not accepting
> ownership of the injected object.
>
> Bug: webrtc:7447, webrtc:14204
> Change-Id: Ic53f05d51928b006fc1e46d502633d88471eb518
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/266140
> Reviewed-by: Harald Alvestrand <hta@webrtc.org>
> Commit-Queue: Niels Moller <nisse@webrtc.org>
> Cr-Commit-Position: refs/heads/main@{#37270}
Bug: webrtc:7447, webrtc:14204
Change-Id: Ib412d09699a48d8f5db27e2960e365b536ab3aa8
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/266146
Owners-Override: Niels Moller <nisse@webrtc.org>
Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37273}
diff --git a/api/BUILD.gn b/api/BUILD.gn
index cd1c104..5f6bc49 100644
--- a/api/BUILD.gn
+++ b/api/BUILD.gn
@@ -1100,17 +1100,6 @@
]
}
- rtc_source_set("mock_packet_socket_factory") {
- visibility = [ "*" ]
- testonly = true
- sources = [ "test/mock_packet_socket_factory.h" ]
-
- deps = [
- ":packet_socket_factory",
- "../test:test_support",
- ]
- }
-
rtc_source_set("mock_peerconnectioninterface") {
visibility = [ "*" ]
testonly = true
@@ -1333,7 +1322,6 @@
":mock_frame_decryptor",
":mock_frame_encryptor",
":mock_media_stream_interface",
- ":mock_packet_socket_factory",
":mock_peer_connection_factory_interface",
":mock_peerconnectioninterface",
":mock_rtp",
diff --git a/api/peer_connection_interface.h b/api/peer_connection_interface.h
index bd2f46f..e5bbd9c 100644
--- a/api/peer_connection_interface.h
+++ b/api/peer_connection_interface.h
@@ -1379,9 +1379,10 @@
PeerConnectionObserver* observer = nullptr;
// Optional dependencies
// TODO(bugs.webrtc.org/7447): remove port allocator once downstream is
- // updated. The recommended way to inject networking components is to pass a
- // PacketSocketFactory when creating the PeerConnectionFactory.
+ // updated. For now, you can only set one of allocator and
+ // packet_socket_factory, not both.
std::unique_ptr<cricket::PortAllocator> allocator;
+ std::unique_ptr<rtc::PacketSocketFactory> packet_socket_factory;
// Factory for creating resolvers that look up hostnames in DNS
std::unique_ptr<webrtc::AsyncDnsResolverFactoryInterface>
async_dns_resolver_factory;
@@ -1421,7 +1422,6 @@
rtc::Thread* worker_thread = nullptr;
rtc::Thread* signaling_thread = nullptr;
rtc::SocketFactory* socket_factory = nullptr;
- std::unique_ptr<rtc::PacketSocketFactory> packet_socket_factory;
std::unique_ptr<TaskQueueFactory> task_queue_factory;
std::unique_ptr<cricket::MediaEngineInterface> media_engine;
std::unique_ptr<CallFactoryInterface> call_factory;
diff --git a/api/test/mock_packet_socket_factory.h b/api/test/mock_packet_socket_factory.h
deleted file mode 100644
index 7e59556..0000000
--- a/api/test/mock_packet_socket_factory.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2022 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.
- */
-
-#ifndef API_TEST_MOCK_PACKET_SOCKET_FACTORY_H_
-#define API_TEST_MOCK_PACKET_SOCKET_FACTORY_H_
-
-#include <memory>
-#include <string>
-
-#include "api/packet_socket_factory.h"
-#include "test/gmock.h"
-
-namespace rtc {
-class MockPacketSocketFactory : public PacketSocketFactory {
- public:
- MOCK_METHOD(AsyncPacketSocket*,
- CreateUdpSocket,
- (const SocketAddress&, uint16_t, uint16_t),
- (override));
- MOCK_METHOD(AsyncListenSocket*,
- CreateServerTcpSocket,
- (const SocketAddress&, uint16_t, uint16_t, int opts),
- (override));
- MOCK_METHOD(AsyncPacketSocket*,
- CreateClientTcpSocket,
- (const SocketAddress& local_address,
- const SocketAddress&,
- const ProxyInfo&,
- const std::string&,
- const PacketSocketTcpOptions&),
- (override));
- MOCK_METHOD(std::unique_ptr<webrtc::AsyncDnsResolverInterface>,
- CreateAsyncDnsResolver,
- (),
- (override));
-};
-
-static_assert(!std::is_abstract_v<MockPacketSocketFactory>, "");
-
-} // namespace rtc
-
-#endif // API_TEST_MOCK_PACKET_SOCKET_FACTORY_H_