Move have_pending_rtp_data_channel_ to sdp_offer_answer

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 <terelius@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32272}
This commit is contained in:
Harald Alvestrand
2020-09-30 22:17:18 +00:00
committed by Commit Bot
parent c06e374a55
commit 75b9ab6751
4 changed files with 19 additions and 18 deletions

View File

@ -3925,7 +3925,7 @@ bool PeerConnection::CreateDataChannel(const std::string& mid) {
this, &PeerConnection::OnSentPacket_w); this, &PeerConnection::OnSentPacket_w);
data_channel_controller_.rtp_data_channel()->SetRtpTransport( data_channel_controller_.rtp_data_channel()->SetRtpTransport(
rtp_transport); rtp_transport);
have_pending_rtp_data_channel_ = true; sdp_handler_.SetHavePendingRtpDataChannel();
return true; return true;
} }
return false; return false;

View File

@ -683,7 +683,8 @@ class PeerConnection : public PeerConnectionInternal,
// to the user. If this is false, Plan B semantics are assumed. // 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 // TODO(bugs.webrtc.org/8530): Flip the default to be Unified Plan once
// sufficient time has passed. // 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; 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_GUARDED_BY(signaling_thread()); // A pointer is passed to senders_
rtc::scoped_refptr<RTCStatsCollector> stats_collector_ rtc::scoped_refptr<RTCStatsCollector> stats_collector_
RTC_GUARDED_BY(signaling_thread()); 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_; TransceiverList transceivers_;
// MIDs will be generated using this generator which will keep track of // MIDs will be generated using this generator which will keep track of

View File

@ -2271,11 +2271,10 @@ RTCError SdpOfferAnswerHandler::UpdateSessionState(
? PeerConnectionInterface::kHaveLocalPrAnswer ? PeerConnectionInterface::kHaveLocalPrAnswer
: PeerConnectionInterface::kHaveRemotePrAnswer); : PeerConnectionInterface::kHaveRemotePrAnswer);
} else { } else {
RTC_DCHECK_RUN_ON(pc_->signaling_thread());
RTC_DCHECK(type == SdpType::kAnswer); RTC_DCHECK(type == SdpType::kAnswer);
ChangeSignalingState(PeerConnectionInterface::kStable); ChangeSignalingState(PeerConnectionInterface::kStable);
pc_->transceivers_.DiscardStableStates(); 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 // 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()); transceiver->internal()->set_mline_index(state.mline_index());
} }
pc_->transport_controller_->RollbackTransports(); pc_->transport_controller_->RollbackTransports();
{ if (have_pending_rtp_data_channel_) {
RTC_DCHECK_RUN_ON(pc_->signaling_thread()); pc_->DestroyDataChannelTransport();
if (pc_->have_pending_rtp_data_channel_) { have_pending_rtp_data_channel_ = false;
pc_->DestroyDataChannelTransport();
pc_->have_pending_rtp_data_channel_ = false;
}
pc_->transceivers_.DiscardStableStates();
} }
pc_->transceivers_.DiscardStableStates();
pending_local_description_.reset(); pending_local_description_.reset();
pending_remote_description_.reset(); pending_remote_description_.reset();
ChangeSignalingState(PeerConnectionInterface::kStable); ChangeSignalingState(PeerConnectionInterface::kStable);
@ -2416,7 +2412,6 @@ RTCError SdpOfferAnswerHandler::Rollback(SdpType desc_type) {
} }
bool SdpOfferAnswerHandler::IsUnifiedPlan() const { bool SdpOfferAnswerHandler::IsUnifiedPlan() const {
RTC_DCHECK_RUN_ON(pc_->signaling_thread());
return pc_->IsUnifiedPlan(); return pc_->IsUnifiedPlan();
} }
@ -3030,8 +3025,8 @@ RTCError SdpOfferAnswerHandler::UpdateDataChannel(
RTC_LOG(LS_INFO) << "Rejected data channel, mid=" << content.mid(); RTC_LOG(LS_INFO) << "Rejected data channel, mid=" << content.mid();
pc_->DestroyDataChannelTransport(); pc_->DestroyDataChannelTransport();
} else { } else {
if (!pc_->data_channel_controller_.rtp_data_channel() && if (!pc_->data_channel_controller()->rtp_data_channel() &&
!pc_->data_channel_controller_.data_channel_transport()) { !pc_->data_channel_controller()->data_channel_transport()) {
RTC_LOG(LS_INFO) << "Creating data channel, mid=" << content.mid(); RTC_LOG(LS_INFO) << "Creating data channel, mid=" << content.mid();
if (!pc_->CreateDataChannel(content.name)) { if (!pc_->CreateDataChannel(content.name)) {
LOG_AND_RETURN_ERROR(RTCErrorType::INTERNAL_ERROR, LOG_AND_RETURN_ERROR(RTCErrorType::INTERNAL_ERROR,
@ -3041,7 +3036,7 @@ RTCError SdpOfferAnswerHandler::UpdateDataChannel(
if (source == cricket::CS_REMOTE) { if (source == cricket::CS_REMOTE) {
const MediaContentDescription* data_desc = content.media_description(); const MediaContentDescription* data_desc = content.media_description();
if (data_desc && cricket::IsRtpProtocol(data_desc->protocol())) { if (data_desc && cricket::IsRtpProtocol(data_desc->protocol())) {
pc_->data_channel_controller_.UpdateRemoteRtpDataChannels( pc_->data_channel_controller()->UpdateRemoteRtpDataChannels(
GetActiveStreams(data_desc)); GetActiveStreams(data_desc));
} }
} }

View File

@ -130,6 +130,10 @@ class SdpOfferAnswerHandler {
bool HasNewIceCredentials(); bool HasNewIceCredentials();
bool IceRestartPending(const std::string& content_name) const; bool IceRestartPending(const std::string& content_name) const;
void UpdateNegotiationNeeded(); 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 // Returns the media section in the given session description that is
// associated with the RtpTransceiver. Returns null if none found or this // associated with the RtpTransceiver. Returns null if none found or this
@ -362,6 +366,10 @@ class SdpOfferAnswerHandler {
rtc::scoped_refptr<MediaStreamInterface> missing_msid_default_stream_ rtc::scoped_refptr<MediaStreamInterface> missing_msid_default_stream_
RTC_GUARDED_BY(signaling_thread()); 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<SdpOfferAnswerHandler> weak_ptr_factory_ rtc::WeakPtrFactory<SdpOfferAnswerHandler> weak_ptr_factory_
RTC_GUARDED_BY(signaling_thread()); RTC_GUARDED_BY(signaling_thread());
}; };