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}
This commit is contained in:
parent
c20f1563b6
commit
6a11c844fd
@ -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",
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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
|
||||
|
||||
31
net/dcsctp/public/dcsctp_socket_factory.cc
Normal file
31
net/dcsctp/public/dcsctp_socket_factory.cc
Normal file
@ -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
|
||||
31
net/dcsctp/public/dcsctp_socket_factory.h
Normal file
31
net/dcsctp/public/dcsctp_socket_factory.h
Normal file
@ -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_
|
||||
Loading…
x
Reference in New Issue
Block a user