Deprecate PeerConnectionFactory::CreatePeerConnection
Applications should use CreatePeerConnectionOrError instead.
Moved fallback implementations of CreatePeerConnection into the
api/peer_connection_interface.h file, so that we do not have to
declare these methods in the proxy.
Bug: webrtc:12238
Change-Id: I70c56336641c2a108b68446ae41f43409277a584
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/217762
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Tommi <tommi@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33964}
diff --git a/api/BUILD.gn b/api/BUILD.gn
index 212e9cd..00542f3 100644
--- a/api/BUILD.gn
+++ b/api/BUILD.gn
@@ -197,6 +197,7 @@
"units:data_rate",
"units:timestamp",
"video:encoded_image",
+ "video:video_bitrate_allocator_factory",
"video:video_frame",
"video:video_rtp_headers",
diff --git a/api/DEPS b/api/DEPS
index 2e46029..1d3d43f 100644
--- a/api/DEPS
+++ b/api/DEPS
@@ -128,13 +128,18 @@
"peer_connection_interface\.h": [
"+media/base/media_config.h",
"+media/base/media_engine.h",
+ "+p2p/base/port.h",
"+p2p/base/port_allocator.h",
+ "+rtc_base/network.h",
+ "+rtc_base/network_constants.h",
"+rtc_base/network_monitor_factory.h",
+ "+rtc_base/ref_count.h",
"+rtc_base/rtc_certificate.h",
"+rtc_base/rtc_certificate_generator.h",
"+rtc_base/socket_address.h",
"+rtc_base/ssl_certificate.h",
"+rtc_base/ssl_stream_adapter.h",
+ "+rtc_base/thread.h",
],
"proxy\.h": [
diff --git a/api/peer_connection_factory_proxy.h b/api/peer_connection_factory_proxy.h
index 0eb2b39..de6250f 100644
--- a/api/peer_connection_factory_proxy.h
+++ b/api/peer_connection_factory_proxy.h
@@ -25,16 +25,6 @@
BEGIN_PROXY_MAP(PeerConnectionFactory)
PROXY_PRIMARY_THREAD_DESTRUCTOR()
PROXY_METHOD1(void, SetOptions, const Options&)
-PROXY_METHOD4(rtc::scoped_refptr<PeerConnectionInterface>,
- CreatePeerConnection,
- const PeerConnectionInterface::RTCConfiguration&,
- std::unique_ptr<cricket::PortAllocator>,
- std::unique_ptr<rtc::RTCCertificateGeneratorInterface>,
- PeerConnectionObserver*)
-PROXY_METHOD2(rtc::scoped_refptr<PeerConnectionInterface>,
- CreatePeerConnection,
- const PeerConnectionInterface::RTCConfiguration&,
- PeerConnectionDependencies)
PROXY_METHOD2(RTCErrorOr<rtc::scoped_refptr<PeerConnectionInterface>>,
CreatePeerConnectionOrError,
const PeerConnectionInterface::RTCConfiguration&,
diff --git a/api/peer_connection_interface.cc b/api/peer_connection_interface.cc
index e1d94dd..230731c 100644
--- a/api/peer_connection_interface.cc
+++ b/api/peer_connection_interface.cc
@@ -10,8 +10,7 @@
#include "api/peer_connection_interface.h"
-#include "api/dtls_transport_interface.h"
-#include "api/sctp_transport_interface.h"
+#include <utility>
namespace webrtc {
@@ -77,14 +76,27 @@
std::unique_ptr<cricket::PortAllocator> allocator,
std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator,
PeerConnectionObserver* observer) {
- return nullptr;
+ PeerConnectionDependencies dependencies(observer);
+ dependencies.allocator = std::move(allocator);
+ dependencies.cert_generator = std::move(cert_generator);
+ auto result =
+ CreatePeerConnectionOrError(configuration, std::move(dependencies));
+ if (!result.ok()) {
+ return nullptr;
+ }
+ return result.MoveValue();
}
rtc::scoped_refptr<PeerConnectionInterface>
PeerConnectionFactoryInterface::CreatePeerConnection(
const PeerConnectionInterface::RTCConfiguration& configuration,
PeerConnectionDependencies dependencies) {
- return nullptr;
+ auto result =
+ CreatePeerConnectionOrError(configuration, std::move(dependencies));
+ if (!result.ok()) {
+ return nullptr;
+ }
+ return result.MoveValue();
}
RTCErrorOr<rtc::scoped_refptr<PeerConnectionInterface>>
diff --git a/api/peer_connection_interface.h b/api/peer_connection_interface.h
index 800f36c..892e84e 100644
--- a/api/peer_connection_interface.h
+++ b/api/peer_connection_interface.h
@@ -67,12 +67,16 @@
#ifndef API_PEER_CONNECTION_INTERFACE_H_
#define API_PEER_CONNECTION_INTERFACE_H_
+#include <stdint.h>
#include <stdio.h>
+#include <functional>
#include <memory>
#include <string>
#include <vector>
+#include "absl/base/attributes.h"
+#include "absl/types/optional.h"
#include "api/adaptation/resource.h"
#include "api/async_dns_resolver.h"
#include "api/async_resolver_factory.h"
@@ -81,6 +85,7 @@
#include "api/audio_codecs/audio_encoder_factory.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/dtls_transport_interface.h"
@@ -88,15 +93,18 @@
#include "api/ice_transport_interface.h"
#include "api/jsep.h"
#include "api/media_stream_interface.h"
+#include "api/media_types.h"
#include "api/neteq/neteq_factory.h"
#include "api/network_state_predictor.h"
#include "api/packet_socket_factory.h"
#include "api/rtc_error.h"
#include "api/rtc_event_log/rtc_event_log_factory_interface.h"
#include "api/rtc_event_log_output.h"
+#include "api/rtp_parameters.h"
#include "api/rtp_receiver_interface.h"
#include "api/rtp_sender_interface.h"
#include "api/rtp_transceiver_interface.h"
+#include "api/scoped_refptr.h"
#include "api/sctp_transport_interface.h"
#include "api/set_local_description_observer_interface.h"
#include "api/set_remote_description_observer_interface.h"
@@ -109,19 +117,25 @@
#include "api/transport/sctp_transport_factory_interface.h"
#include "api/transport/webrtc_key_value_config.h"
#include "api/turn_customizer.h"
+#include "api/video/video_bitrate_allocator_factory.h"
#include "media/base/media_config.h"
#include "media/base/media_engine.h"
// TODO(bugs.webrtc.org/7447): We plan to provide a way to let applications
// inject a PacketSocketFactory and/or NetworkManager, and not expose
-// PortAllocator in the PeerConnection api.
+// PortAllocator in the PeerConnection api. This will let us remove nogncheck.
+#include "p2p/base/port.h" // nogncheck
#include "p2p/base/port_allocator.h" // nogncheck
+#include "rtc_base/network.h"
+#include "rtc_base/network_constants.h"
#include "rtc_base/network_monitor_factory.h"
+#include "rtc_base/ref_count.h"
#include "rtc_base/rtc_certificate.h"
#include "rtc_base/rtc_certificate_generator.h"
#include "rtc_base/socket_address.h"
#include "rtc_base/ssl_certificate.h"
#include "rtc_base/ssl_stream_adapter.h"
#include "rtc_base/system/rtc_export.h"
+#include "rtc_base/thread.h"
namespace rtc {
class Thread;
@@ -1432,6 +1446,7 @@
PeerConnectionDependencies dependencies);
// Deprecated creator - does not return an error code on error.
// TODO(bugs.webrtc.org:12238): Deprecate and remove.
+ ABSL_DEPRECATED("Use CreatePeerConnectionOrError")
virtual rtc::scoped_refptr<PeerConnectionInterface> CreatePeerConnection(
const PeerConnectionInterface::RTCConfiguration& configuration,
PeerConnectionDependencies dependencies);
@@ -1445,6 +1460,7 @@
// responsibility of the caller to delete it. It can be safely deleted after
// Close has been called on the returned PeerConnection, which ensures no
// more observer callbacks will be invoked.
+ ABSL_DEPRECATED("Use CreatePeerConnectionOrError")
virtual rtc::scoped_refptr<PeerConnectionInterface> CreatePeerConnection(
const PeerConnectionInterface::RTCConfiguration& configuration,
std::unique_ptr<cricket::PortAllocator> allocator,