diff --git a/pc/BUILD.gn b/pc/BUILD.gn index a318b122a0..2341eb20c7 100644 --- a/pc/BUILD.gn +++ b/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 diff --git a/pc/data_channel_controller.cc b/pc/data_channel_controller.cc index e11647f2ca..adbf303105 100644 --- a/pc/data_channel_controller.cc +++ b/pc/data_channel_controller.cc @@ -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; } diff --git a/pc/data_channel_controller.h b/pc/data_channel_controller.h index af0e06353f..00d38f0c84 100644 --- a/pc/data_channel_controller.h +++ b/pc/data_channel_controller.h @@ -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 weak_factory_{this}; diff --git a/pc/peer_connection.h b/pc/peer_connection.h index 3f3dda601e..653f5f5482 100644 --- a/pc/peer_connection.h +++ b/pc/peer_connection.h @@ -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; diff --git a/pc/peer_connection_internal.h b/pc/peer_connection_internal.h index 3b82dc5271..38a1fd1002 100644 --- a/pc/peer_connection_internal.h +++ b/pc/peer_connection_internal.h @@ -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