Break out data_channel_controller from peerconnection target
Bug: webrtc:11943 Change-Id: I80c6b1be770f4e99cc7e21ef0e30977198166f88 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251323 Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Commit-Queue: Harald Alvestrand <hta@webrtc.org> Cr-Commit-Position: refs/heads/main@{#35949}
This commit is contained in:

committed by
WebRTC LUCI CQ

parent
a7fc765d3d
commit
5b84f386fc
31
pc/BUILD.gn
31
pc/BUILD.gn
@ -238,8 +238,6 @@ rtc_library("peerconnection") {
|
||||
visibility = [ "*" ]
|
||||
cflags = []
|
||||
sources = [
|
||||
"data_channel_controller.cc",
|
||||
"data_channel_controller.h",
|
||||
"peer_connection.cc",
|
||||
"peer_connection.h",
|
||||
"peer_connection_factory.cc",
|
||||
@ -462,6 +460,35 @@ rtc_library("connection_context") {
|
||||
# TODO(bugs.webrtc.org/13634): Fill these targets with files.
|
||||
rtc_source_set("data_channel_controller") {
|
||||
visibility = [ ":*" ]
|
||||
sources = [
|
||||
"data_channel_controller.cc",
|
||||
"data_channel_controller.h",
|
||||
]
|
||||
deps = [
|
||||
":data_channel_utils",
|
||||
":peer_connection_internal",
|
||||
":rtc_pc_base",
|
||||
":sctp_data_channel",
|
||||
"../api:libjingle_peerconnection_api",
|
||||
"../api:rtc_error",
|
||||
"../api:scoped_refptr",
|
||||
"../api:sequence_checker",
|
||||
"../api/transport:datagram_transport_interface",
|
||||
"../media:rtc_media_base",
|
||||
"../rtc_base:checks",
|
||||
"../rtc_base:logging",
|
||||
"../rtc_base:macromagic",
|
||||
"../rtc_base:rtc_base",
|
||||
"../rtc_base:rtc_base_approved",
|
||||
"../rtc_base:threading",
|
||||
"../rtc_base:weak_ptr",
|
||||
"../rtc_base/task_utils:to_queued_task",
|
||||
"../rtc_base/third_party/sigslot:sigslot",
|
||||
]
|
||||
absl_deps = [
|
||||
"//third_party/abseil-cpp/absl/algorithm:container",
|
||||
"//third_party/abseil-cpp/absl/types:optional",
|
||||
]
|
||||
}
|
||||
rtc_source_set("peer_connection_factory") {
|
||||
visibility = [ "*" ] # Known to be used externally
|
||||
|
@ -17,7 +17,7 @@
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/peer_connection_interface.h"
|
||||
#include "api/rtc_error.h"
|
||||
#include "pc/peer_connection.h"
|
||||
#include "pc/peer_connection_internal.h"
|
||||
#include "pc/sctp_utils.h"
|
||||
#include "rtc_base/location.h"
|
||||
#include "rtc_base/logging.h"
|
||||
@ -298,7 +298,8 @@ DataChannelController::InternalCreateSctpDataChannel(
|
||||
return nullptr;
|
||||
}
|
||||
sctp_data_channels_.push_back(channel);
|
||||
channel->SignalClosed.connect(pc_, &PeerConnection::OnSctpDataChannelClosed);
|
||||
channel->SignalClosed.connect(
|
||||
pc_, &PeerConnectionInternal::OnSctpDataChannelClosed);
|
||||
SignalSctpDataChannelCreated_(channel.get());
|
||||
return channel;
|
||||
}
|
||||
|
@ -38,12 +38,12 @@
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class PeerConnection;
|
||||
class PeerConnectionInternal;
|
||||
|
||||
class DataChannelController : public SctpDataChannelProviderInterface,
|
||||
public DataChannelSink {
|
||||
public:
|
||||
explicit DataChannelController(PeerConnection* pc) : pc_(pc) {}
|
||||
explicit DataChannelController(PeerConnectionInternal* pc) : pc_(pc) {}
|
||||
|
||||
// Not copyable or movable.
|
||||
DataChannelController(DataChannelController&) = delete;
|
||||
@ -180,7 +180,7 @@ class DataChannelController : public SctpDataChannelProviderInterface,
|
||||
RTC_GUARDED_BY(signaling_thread());
|
||||
|
||||
// Owning PeerConnection.
|
||||
PeerConnection* const pc_;
|
||||
PeerConnectionInternal* const pc_;
|
||||
// The weak pointers must be dereferenced and invalidated on the signalling
|
||||
// thread only.
|
||||
rtc::WeakPtrFactory<DataChannelController> weak_factory_{this};
|
||||
|
@ -117,8 +117,7 @@ namespace webrtc {
|
||||
// - The ICE state machine.
|
||||
// - Generating stats.
|
||||
class PeerConnection : public PeerConnectionInternal,
|
||||
public JsepTransportController::Observer,
|
||||
public sigslot::has_slots<> {
|
||||
public JsepTransportController::Observer {
|
||||
public:
|
||||
// Creates a PeerConnection and initializes it with the given values.
|
||||
// If the initialization fails, the function releases the PeerConnection
|
||||
@ -314,7 +313,7 @@ class PeerConnection : public PeerConnectionInternal,
|
||||
bool GetSslRole(const std::string& content_name, rtc::SSLRole* role) override;
|
||||
|
||||
// Functions needed by DataChannelController
|
||||
void NoteDataAddedEvent() { NoteUsageEvent(UsageEvent::DATA_ADDED); }
|
||||
void NoteDataAddedEvent() override { NoteUsageEvent(UsageEvent::DATA_ADDED); }
|
||||
// Returns the observer. Will crash on CHECK if the observer is removed.
|
||||
PeerConnectionObserver* Observer() const override;
|
||||
bool IsClosed() const override {
|
||||
@ -325,7 +324,7 @@ class PeerConnection : public PeerConnectionInternal,
|
||||
// Get current SSL role used by SCTP's underlying transport.
|
||||
bool GetSctpSslRole(rtc::SSLRole* role) override;
|
||||
// Handler for the "channel closed" signal
|
||||
void OnSctpDataChannelClosed(DataChannelInterface* channel);
|
||||
void OnSctpDataChannelClosed(DataChannelInterface* channel) override;
|
||||
|
||||
bool ShouldFireNegotiationNeededEvent(uint32_t event_id) override;
|
||||
|
||||
|
@ -127,7 +127,8 @@ class PeerConnectionSdpMethods {
|
||||
// Functions defined in this class are called by other objects,
|
||||
// but not by SdpOfferAnswerHandler.
|
||||
class PeerConnectionInternal : public PeerConnectionInterface,
|
||||
public PeerConnectionSdpMethods {
|
||||
public PeerConnectionSdpMethods,
|
||||
public sigslot::has_slots<> {
|
||||
public:
|
||||
virtual rtc::Thread* network_thread() const = 0;
|
||||
virtual rtc::Thread* worker_thread() const = 0;
|
||||
@ -172,6 +173,10 @@ class PeerConnectionInternal : public PeerConnectionInterface,
|
||||
// Get SSL role for an arbitrary m= section (handles bundling correctly).
|
||||
virtual bool GetSslRole(const std::string& content_name,
|
||||
rtc::SSLRole* role) = 0;
|
||||
// Functions needed by DataChannelController
|
||||
virtual void NoteDataAddedEvent() {}
|
||||
// Handler for the "channel closed" signal
|
||||
virtual void OnSctpDataChannelClosed(DataChannelInterface* channel) {}
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
Reference in New Issue
Block a user