diff options
author | Florent Castelli <orphis@webrtc.org> | 2021-06-01 18:39:49 +0200 |
---|---|---|
committer | WebRTC LUCI CQ <webrtc-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2021-06-18 09:59:40 +0000 |
commit | 6a11c844fde7253136d42bf50510510532ecd349 (patch) | |
tree | 28668efef473909fad7f4ce5b22b873b5f2084b9 | |
parent | c20f1563b672da0cb777141357c678562865cc5b (diff) | |
download | webrtc-6a11c844fde7253136d42bf50510510532ecd349.tar.gz |
dcsctp: Add DcSctpSocketFactory
The factory allows us to isolate the implementation from users who only
need to depend directly on the public folder now.
Bug: webrtc:12614
Change-Id: Ied09cf772ed427eaf17a7b5705f587da57405640
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/220939
Commit-Queue: Florent Castelli <orphis@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34330}
-rw-r--r-- | media/BUILD.gn | 2 | ||||
-rw-r--r-- | media/sctp/dcsctp_transport.cc | 7 | ||||
-rw-r--r-- | net/dcsctp/public/BUILD.gn | 13 | ||||
-rw-r--r-- | net/dcsctp/public/dcsctp_socket_factory.cc | 31 | ||||
-rw-r--r-- | net/dcsctp/public/dcsctp_socket_factory.h | 31 |
5 files changed, 80 insertions, 4 deletions
diff --git a/media/BUILD.gn b/media/BUILD.gn index 9c57a1d16b..30f642a25d 100644 --- a/media/BUILD.gn +++ b/media/BUILD.gn @@ -402,9 +402,9 @@ if (rtc_build_dcsctp) { ":rtc_data_sctp_transport_internal", "../api:array_view", "../media:rtc_media_base", + "../net/dcsctp/public:factory", "../net/dcsctp/public:socket", "../net/dcsctp/public:types", - "../net/dcsctp/socket:dcsctp_socket", "../net/dcsctp/timer:task_queue_timeout", "../p2p:rtc_p2p", "../rtc_base:checks", diff --git a/media/sctp/dcsctp_transport.cc b/media/sctp/dcsctp_transport.cc index c77bcda74d..90fb0e8aca 100644 --- a/media/sctp/dcsctp_transport.cc +++ b/media/sctp/dcsctp_transport.cc @@ -19,9 +19,9 @@ #include "absl/types/optional.h" #include "api/array_view.h" #include "media/base/media_channel.h" +#include "net/dcsctp/public/dcsctp_socket_factory.h" #include "net/dcsctp/public/packet_observer.h" #include "net/dcsctp/public/types.h" -#include "net/dcsctp/socket/dcsctp_socket.h" #include "p2p/base/packet_transport_internal.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" @@ -177,8 +177,9 @@ bool DcSctpTransport::Start(int local_sctp_port, packet_observer = std::make_unique<TextPcapPacketObserver>(debug_name_); } - socket_ = std::make_unique<dcsctp::DcSctpSocket>( - debug_name_, *this, std::move(packet_observer), options); + dcsctp::DcSctpSocketFactory factory; + socket_ = + factory.Create(debug_name_, *this, std::move(packet_observer), options); } else { if (local_sctp_port != socket_->options().local_port || remote_sctp_port != socket_->options().remote_port) { diff --git a/net/dcsctp/public/BUILD.gn b/net/dcsctp/public/BUILD.gn index 85cf529c2f..4a924cae9b 100644 --- a/net/dcsctp/public/BUILD.gn +++ b/net/dcsctp/public/BUILD.gn @@ -43,6 +43,19 @@ rtc_source_set("socket") { ] } +rtc_source_set("factory") { + deps = [ + ":socket", + ":types", + "../socket:dcsctp_socket", + ] + sources = [ + "dcsctp_socket_factory.cc", + "dcsctp_socket_factory.h", + ] + absl_deps = [ "//third_party/abseil-cpp/absl/strings" ] +} + if (rtc_include_tests) { rtc_library("dcsctp_public_unittests") { testonly = true diff --git a/net/dcsctp/public/dcsctp_socket_factory.cc b/net/dcsctp/public/dcsctp_socket_factory.cc new file mode 100644 index 0000000000..338d143424 --- /dev/null +++ b/net/dcsctp/public/dcsctp_socket_factory.cc @@ -0,0 +1,31 @@ +/* + * Copyright 2021 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 "net/dcsctp/public/dcsctp_socket_factory.h" + +#include <memory> +#include <utility> + +#include "absl/strings/string_view.h" +#include "net/dcsctp/public/dcsctp_options.h" +#include "net/dcsctp/public/dcsctp_socket.h" +#include "net/dcsctp/public/packet_observer.h" +#include "net/dcsctp/socket/dcsctp_socket.h" + +namespace dcsctp { +std::unique_ptr<DcSctpSocketInterface> DcSctpSocketFactory::Create( + absl::string_view log_prefix, + DcSctpSocketCallbacks& callbacks, + std::unique_ptr<PacketObserver> packet_observer, + const DcSctpOptions& options) { + return std::make_unique<DcSctpSocket>(log_prefix, callbacks, + std::move(packet_observer), options); +} +} // namespace dcsctp diff --git a/net/dcsctp/public/dcsctp_socket_factory.h b/net/dcsctp/public/dcsctp_socket_factory.h new file mode 100644 index 0000000000..dcc68d9b54 --- /dev/null +++ b/net/dcsctp/public/dcsctp_socket_factory.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2021 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 NET_DCSCTP_PUBLIC_DCSCTP_SOCKET_FACTORY_H_ +#define NET_DCSCTP_PUBLIC_DCSCTP_SOCKET_FACTORY_H_ + +#include <memory> + +#include "absl/strings/string_view.h" +#include "net/dcsctp/public/dcsctp_options.h" +#include "net/dcsctp/public/dcsctp_socket.h" +#include "net/dcsctp/public/packet_observer.h" + +namespace dcsctp { +class DcSctpSocketFactory { + public: + std::unique_ptr<DcSctpSocketInterface> Create( + absl::string_view log_prefix, + DcSctpSocketCallbacks& callbacks, + std::unique_ptr<PacketObserver> packet_observer, + const DcSctpOptions& options); +}; +} // namespace dcsctp + +#endif // NET_DCSCTP_PUBLIC_DCSCTP_SOCKET_FACTORY_H_ |