diff --git a/pc/BUILD.gn b/pc/BUILD.gn index 1ae3715b82..98449a3813 100644 --- a/pc/BUILD.gn +++ b/pc/BUILD.gn @@ -2658,6 +2658,7 @@ if (rtc_include_tests && !build_with_chromium) { deps = [ ":channel", ":channel_interface", + ":channel_manager", ":jitter_buffer_delay", ":libjingle_peerconnection", ":peer_connection_internal", diff --git a/pc/connection_context.cc b/pc/connection_context.cc index acc80f30bb..818283d636 100644 --- a/pc/connection_context.cc +++ b/pc/connection_context.cc @@ -16,6 +16,7 @@ #include "api/transport/field_trial_based_config.h" #include "media/base/media_engine.h" #include "media/sctp/sctp_transport_factory.h" +#include "pc/channel_manager.h" #include "rtc_base/helpers.h" #include "rtc_base/internal/default_socket_server.h" #include "rtc_base/socket_server.h" diff --git a/pc/connection_context.h b/pc/connection_context.h index 5625a79171..43239ffae0 100644 --- a/pc/connection_context.h +++ b/pc/connection_context.h @@ -24,7 +24,6 @@ #include "api/transport/sctp_transport_factory_interface.h" #include "media/base/media_engine.h" #include "p2p/base/basic_packet_socket_factory.h" -#include "pc/channel_manager.h" #include "rtc_base/checks.h" #include "rtc_base/network.h" #include "rtc_base/network_monitor_factory.h" @@ -33,6 +32,10 @@ #include "rtc_base/thread.h" #include "rtc_base/thread_annotations.h" +namespace cricket { +class ChannelManager; +} + namespace rtc { class BasicNetworkManager; class BasicPacketSocketFactory; @@ -116,6 +119,7 @@ class ConnectionContext final std::unique_ptr const trials_; // channel_manager is accessed both on signaling thread and worker thread. + // Const after construction, explicitly cleared in destructor. std::unique_ptr channel_manager_; std::unique_ptr const network_monitor_factory_ RTC_GUARDED_BY(signaling_thread_); diff --git a/pc/peer_connection.cc b/pc/peer_connection.cc index 957c2ec840..19cb1933cc 100644 --- a/pc/peer_connection.cc +++ b/pc/peer_connection.cc @@ -42,6 +42,7 @@ #include "p2p/base/p2p_constants.h" #include "p2p/base/p2p_transport_channel.h" #include "p2p/base/transport_info.h" +#include "pc/channel_manager.h" #include "pc/ice_server_parsing.h" #include "pc/rtp_receiver.h" #include "pc/rtp_receiver_proxy.h" @@ -1676,10 +1677,6 @@ void PeerConnection::AddAdaptationResource( call_->AddAdaptationResource(resource); } -cricket::ChannelManager* PeerConnection::channel_manager() { - return context_->channel_manager(); -} - bool PeerConnection::StartRtcEventLog(std::unique_ptr output, int64_t output_period_ms) { return worker_thread()->Invoke( diff --git a/pc/peer_connection.h b/pc/peer_connection.h index ca43fdf248..52ad382d95 100644 --- a/pc/peer_connection.h +++ b/pc/peer_connection.h @@ -55,7 +55,6 @@ #include "p2p/base/port_allocator.h" #include "p2p/base/transport_description.h" #include "pc/channel_interface.h" -#include "pc/channel_manager.h" #include "pc/connection_context.h" #include "pc/data_channel_controller.h" #include "pc/data_channel_utils.h" @@ -85,6 +84,10 @@ #include "rtc_base/thread_annotations.h" #include "rtc_base/weak_ptr.h" +namespace cricket { +class ChannelManager; +} + namespace webrtc { // PeerConnection is the implementation of the PeerConnection object as defined @@ -340,7 +343,6 @@ class PeerConnection : public PeerConnectionInternal, const RtpTransmissionManager* rtp_manager() const override { return rtp_manager_.get(); } - cricket::ChannelManager* channel_manager(); JsepTransportController* transport_controller_s() override { RTC_DCHECK_RUN_ON(signaling_thread()); @@ -589,6 +591,10 @@ class PeerConnection : public PeerConnectionInternal, int64_t packet_time_us)> InitializeRtcpCallback(); + cricket::ChannelManager* channel_manager() { + return context_->channel_manager(); + } + const rtc::scoped_refptr context_; // Field trials active for this PeerConnection is the first of: // a) Specified in PeerConnectionDependencies (owned). diff --git a/pc/peer_connection_factory.cc b/pc/peer_connection_factory.cc index aa9f328231..6e6a72ced8 100644 --- a/pc/peer_connection_factory.cc +++ b/pc/peer_connection_factory.cc @@ -33,6 +33,7 @@ #include "p2p/base/port_allocator.h" #include "p2p/client/basic_port_allocator.h" #include "pc/audio_track.h" +#include "pc/channel_manager.h" #include "pc/local_audio_source.h" #include "pc/media_stream.h" #include "pc/media_stream_proxy.h" @@ -294,10 +295,6 @@ rtc::scoped_refptr PeerConnectionFactory::CreateAudioTrack( return AudioTrackProxy::Create(signaling_thread(), track); } -cricket::ChannelManager* PeerConnectionFactory::channel_manager() { - return context_->channel_manager(); -} - std::unique_ptr PeerConnectionFactory::CreateRtcEventLog_w() { RTC_DCHECK_RUN_ON(worker_thread()); diff --git a/pc/peer_connection_factory.h b/pc/peer_connection_factory.h index 16695f234a..ff3d515964 100644 --- a/pc/peer_connection_factory.h +++ b/pc/peer_connection_factory.h @@ -40,13 +40,16 @@ #include "call/call.h" #include "call/rtp_transport_controller_send_factory_interface.h" #include "p2p/base/port_allocator.h" -#include "pc/channel_manager.h" #include "pc/connection_context.h" #include "rtc_base/checks.h" #include "rtc_base/rtc_certificate_generator.h" #include "rtc_base/thread.h" #include "rtc_base/thread_annotations.h" +namespace cricket { +class ChannelManager; +} + namespace rtc { class BasicNetworkManager; class BasicPacketSocketFactory; @@ -100,8 +103,6 @@ class PeerConnectionFactory : public PeerConnectionFactoryInterface { return context_->sctp_transport_factory(); } - virtual cricket::ChannelManager* channel_manager(); - rtc::Thread* signaling_thread() const { // This method can be called on a different thread when the factory is // created in CreatePeerConnectionFactory(). @@ -135,6 +136,10 @@ class PeerConnectionFactory : public PeerConnectionFactoryInterface { rtc::Thread* network_thread() const { return context_->network_thread(); } bool IsTrialEnabled(absl::string_view key) const; + + cricket::ChannelManager* channel_manager() { + return context_->channel_manager(); + } const cricket::ChannelManager* channel_manager() const { return context_->channel_manager(); } diff --git a/pc/rtp_transceiver.h b/pc/rtp_transceiver.h index 6549f9952a..b61ca752d1 100644 --- a/pc/rtp_transceiver.h +++ b/pc/rtp_transceiver.h @@ -34,7 +34,6 @@ #include "api/video/video_bitrate_allocator_factory.h" #include "media/base/media_channel.h" #include "pc/channel_interface.h" -#include "pc/channel_manager.h" #include "pc/proxy.h" #include "pc/rtp_receiver.h" #include "pc/rtp_receiver_proxy.h" @@ -46,6 +45,10 @@ #include "rtc_base/third_party/sigslot/sigslot.h" #include "rtc_base/thread_annotations.h" +namespace cricket { +class ChannelManager; +} + namespace webrtc { class PeerConnectionSdpMethods; diff --git a/pc/rtp_transceiver_unittest.cc b/pc/rtp_transceiver_unittest.cc index 12b706590a..ce2eefc974 100644 --- a/pc/rtp_transceiver_unittest.cc +++ b/pc/rtp_transceiver_unittest.cc @@ -20,6 +20,7 @@ #include "api/rtp_parameters.h" #include "media/base/fake_media_engine.h" #include "media/base/media_engine.h" +#include "pc/channel_manager.h" #include "pc/test/mock_channel_interface.h" #include "pc/test/mock_rtp_receiver_internal.h" #include "pc/test/mock_rtp_sender_internal.h" diff --git a/pc/rtp_transmission_manager.cc b/pc/rtp_transmission_manager.cc index 28508234cb..6939a07dec 100644 --- a/pc/rtp_transmission_manager.cc +++ b/pc/rtp_transmission_manager.cc @@ -18,6 +18,7 @@ #include "api/rtp_transceiver_direction.h" #include "pc/audio_rtp_receiver.h" #include "pc/channel_interface.h" +#include "pc/channel_manager.h" #include "pc/stats_collector_interface.h" #include "pc/video_rtp_receiver.h" #include "rtc_base/checks.h" diff --git a/pc/rtp_transmission_manager.h b/pc/rtp_transmission_manager.h index 3496bfa54d..6e25f2d9b7 100644 --- a/pc/rtp_transmission_manager.h +++ b/pc/rtp_transmission_manager.h @@ -27,7 +27,6 @@ #include "api/scoped_refptr.h" #include "api/sequence_checker.h" #include "media/base/media_channel.h" -#include "pc/channel_manager.h" #include "pc/rtp_receiver.h" #include "pc/rtp_receiver_proxy.h" #include "pc/rtp_sender.h" @@ -41,6 +40,10 @@ #include "rtc_base/thread_annotations.h" #include "rtc_base/weak_ptr.h" +namespace cricket { +class ChannelManager; +} + namespace rtc { class Thread; } @@ -255,9 +258,9 @@ class RtpTransmissionManager : public RtpSenderBase::SetStreamsObserver { bool closed_ = false; bool const is_unified_plan_; - rtc::Thread* signaling_thread_; - rtc::Thread* worker_thread_; - cricket::ChannelManager* channel_manager_; + rtc::Thread* const signaling_thread_; + rtc::Thread* const worker_thread_; + cricket::ChannelManager* const channel_manager_; UsagePattern* usage_pattern_; PeerConnectionObserver* observer_; StatsCollectorInterface* const stats_; diff --git a/pc/sdp_offer_answer.cc b/pc/sdp_offer_answer.cc index ff8cf0a870..1d34081bce 100644 --- a/pc/sdp_offer_answer.cc +++ b/pc/sdp_offer_answer.cc @@ -41,6 +41,7 @@ #include "p2p/base/transport_description_factory.h" #include "p2p/base/transport_info.h" #include "pc/channel_interface.h" +#include "pc/channel_manager.h" #include "pc/dtls_transport.h" #include "pc/media_stream.h" #include "pc/media_stream_proxy.h" diff --git a/pc/sdp_offer_answer.h b/pc/sdp_offer_answer.h index 2c0cdd4078..de814ec737 100644 --- a/pc/sdp_offer_answer.h +++ b/pc/sdp_offer_answer.h @@ -41,7 +41,6 @@ #include "media/base/media_channel.h" #include "media/base/stream_params.h" #include "p2p/base/port_allocator.h" -#include "pc/channel_manager.h" #include "pc/connection_context.h" #include "pc/data_channel_controller.h" #include "pc/jsep_transport_controller.h" @@ -65,6 +64,10 @@ #include "rtc_base/unique_id_generator.h" #include "rtc_base/weak_ptr.h" +namespace cricket { +class ChannelManager; +} + namespace webrtc { // SdpOfferAnswerHandler is a component diff --git a/pc/test/fake_peer_connection_for_stats.h b/pc/test/fake_peer_connection_for_stats.h index acf8e283a2..e612f0d10f 100644 --- a/pc/test/fake_peer_connection_for_stats.h +++ b/pc/test/fake_peer_connection_for_stats.h @@ -20,6 +20,7 @@ #include "media/base/fake_media_engine.h" #include "pc/channel.h" +#include "pc/channel_manager.h" #include "pc/stream_collection.h" #include "pc/test/fake_data_channel_provider.h" #include "pc/test/fake_peer_connection_base.h" diff --git a/pc/webrtc_session_description_factory.h b/pc/webrtc_session_description_factory.h index 3f1519082b..20c9100590 100644 --- a/pc/webrtc_session_description_factory.h +++ b/pc/webrtc_session_description_factory.h @@ -23,7 +23,6 @@ #include "api/scoped_refptr.h" #include "p2p/base/transport_description.h" #include "p2p/base/transport_description_factory.h" -#include "pc/channel_manager.h" #include "pc/media_session.h" #include "pc/sdp_state_provider.h" #include "rtc_base/message_handler.h"