From 75b9ab6751f3f49bbdd0a260fcbcbc8135dd567a Mon Sep 17 00:00:00 2001 From: Harald Alvestrand Date: Wed, 30 Sep 2020 22:17:18 +0000 Subject: [PATCH] Move have_pending_rtp_data_channel_ to sdp_offer_answer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also use accessors for the last few member variable references in PeerConnection. This completes removing the variable accesses from SdpOfferAnswerHandler to PeerConnection. Bug: webrtc:11995 Change-Id: I70c78b43035c15f20559f7a6a5b50c3a613fe907 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/186200 Reviewed-by: Björn Terelius Commit-Queue: Harald Alvestrand Cr-Commit-Position: refs/heads/master@{#32272} --- pc/peer_connection.cc | 2 +- pc/peer_connection.h | 6 ++---- pc/sdp_offer_answer.cc | 21 ++++++++------------- pc/sdp_offer_answer.h | 8 ++++++++ 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/pc/peer_connection.cc b/pc/peer_connection.cc index 41963596a7..cdd529d0d6 100644 --- a/pc/peer_connection.cc +++ b/pc/peer_connection.cc @@ -3925,7 +3925,7 @@ bool PeerConnection::CreateDataChannel(const std::string& mid) { this, &PeerConnection::OnSentPacket_w); data_channel_controller_.rtp_data_channel()->SetRtpTransport( rtp_transport); - have_pending_rtp_data_channel_ = true; + sdp_handler_.SetHavePendingRtpDataChannel(); return true; } return false; diff --git a/pc/peer_connection.h b/pc/peer_connection.h index e5a7ae8345..780ba9440f 100644 --- a/pc/peer_connection.h +++ b/pc/peer_connection.h @@ -683,7 +683,8 @@ class PeerConnection : public PeerConnectionInternal, // to the user. If this is false, Plan B semantics are assumed. // TODO(bugs.webrtc.org/8530): Flip the default to be Unified Plan once // sufficient time has passed. - bool IsUnifiedPlan() const RTC_RUN_ON(signaling_thread()) { + bool IsUnifiedPlan() const { + RTC_DCHECK_RUN_ON(signaling_thread()); return configuration_.sdp_semantics == SdpSemantics::kUnifiedPlan; } @@ -1048,9 +1049,6 @@ class PeerConnection : public PeerConnectionInternal, RTC_GUARDED_BY(signaling_thread()); // A pointer is passed to senders_ rtc::scoped_refptr stats_collector_ RTC_GUARDED_BY(signaling_thread()); - // Used when rolling back RTP data channels. - bool have_pending_rtp_data_channel_ RTC_GUARDED_BY(signaling_thread()) = - false; TransceiverList transceivers_; // MIDs will be generated using this generator which will keep track of diff --git a/pc/sdp_offer_answer.cc b/pc/sdp_offer_answer.cc index b150ce9061..273ba11ea0 100644 --- a/pc/sdp_offer_answer.cc +++ b/pc/sdp_offer_answer.cc @@ -2271,11 +2271,10 @@ RTCError SdpOfferAnswerHandler::UpdateSessionState( ? PeerConnectionInterface::kHaveLocalPrAnswer : PeerConnectionInterface::kHaveRemotePrAnswer); } else { - RTC_DCHECK_RUN_ON(pc_->signaling_thread()); RTC_DCHECK(type == SdpType::kAnswer); ChangeSignalingState(PeerConnectionInterface::kStable); pc_->transceivers_.DiscardStableStates(); - pc_->have_pending_rtp_data_channel_ = false; + have_pending_rtp_data_channel_ = false; } // Update internal objects according to the session description's media @@ -2378,14 +2377,11 @@ RTCError SdpOfferAnswerHandler::Rollback(SdpType desc_type) { transceiver->internal()->set_mline_index(state.mline_index()); } pc_->transport_controller_->RollbackTransports(); - { - RTC_DCHECK_RUN_ON(pc_->signaling_thread()); - if (pc_->have_pending_rtp_data_channel_) { - pc_->DestroyDataChannelTransport(); - pc_->have_pending_rtp_data_channel_ = false; - } - pc_->transceivers_.DiscardStableStates(); + if (have_pending_rtp_data_channel_) { + pc_->DestroyDataChannelTransport(); + have_pending_rtp_data_channel_ = false; } + pc_->transceivers_.DiscardStableStates(); pending_local_description_.reset(); pending_remote_description_.reset(); ChangeSignalingState(PeerConnectionInterface::kStable); @@ -2416,7 +2412,6 @@ RTCError SdpOfferAnswerHandler::Rollback(SdpType desc_type) { } bool SdpOfferAnswerHandler::IsUnifiedPlan() const { - RTC_DCHECK_RUN_ON(pc_->signaling_thread()); return pc_->IsUnifiedPlan(); } @@ -3030,8 +3025,8 @@ RTCError SdpOfferAnswerHandler::UpdateDataChannel( RTC_LOG(LS_INFO) << "Rejected data channel, mid=" << content.mid(); pc_->DestroyDataChannelTransport(); } else { - if (!pc_->data_channel_controller_.rtp_data_channel() && - !pc_->data_channel_controller_.data_channel_transport()) { + if (!pc_->data_channel_controller()->rtp_data_channel() && + !pc_->data_channel_controller()->data_channel_transport()) { RTC_LOG(LS_INFO) << "Creating data channel, mid=" << content.mid(); if (!pc_->CreateDataChannel(content.name)) { LOG_AND_RETURN_ERROR(RTCErrorType::INTERNAL_ERROR, @@ -3041,7 +3036,7 @@ RTCError SdpOfferAnswerHandler::UpdateDataChannel( if (source == cricket::CS_REMOTE) { const MediaContentDescription* data_desc = content.media_description(); if (data_desc && cricket::IsRtpProtocol(data_desc->protocol())) { - pc_->data_channel_controller_.UpdateRemoteRtpDataChannels( + pc_->data_channel_controller()->UpdateRemoteRtpDataChannels( GetActiveStreams(data_desc)); } } diff --git a/pc/sdp_offer_answer.h b/pc/sdp_offer_answer.h index b84c8bd3fe..92ecbdfc3c 100644 --- a/pc/sdp_offer_answer.h +++ b/pc/sdp_offer_answer.h @@ -130,6 +130,10 @@ class SdpOfferAnswerHandler { bool HasNewIceCredentials(); bool IceRestartPending(const std::string& content_name) const; void UpdateNegotiationNeeded(); + void SetHavePendingRtpDataChannel() { + RTC_DCHECK_RUN_ON(signaling_thread()); + have_pending_rtp_data_channel_ = true; + } // Returns the media section in the given session description that is // associated with the RtpTransceiver. Returns null if none found or this @@ -362,6 +366,10 @@ class SdpOfferAnswerHandler { rtc::scoped_refptr missing_msid_default_stream_ RTC_GUARDED_BY(signaling_thread()); + // Used when rolling back RTP data channels. + bool have_pending_rtp_data_channel_ RTC_GUARDED_BY(signaling_thread()) = + false; + rtc::WeakPtrFactory weak_ptr_factory_ RTC_GUARDED_BY(signaling_thread()); };