diff --git a/pc/jsep_transport_controller.cc b/pc/jsep_transport_controller.cc index b7ab279862..9b14dc0342 100644 --- a/pc/jsep_transport_controller.cc +++ b/pc/jsep_transport_controller.cc @@ -92,8 +92,10 @@ JsepTransportController::JsepTransportController( JsepTransportController::~JsepTransportController() { // Channel destructors may try to send packets, so this needs to happen on // the network thread. - network_thread_->Invoke(RTC_FROM_HERE, - [this] { DestroyAllJsepTransports_n(); }); + network_thread_->Invoke(RTC_FROM_HERE, [this] { + RTC_DCHECK_RUN_ON(network_thread_); + DestroyAllJsepTransports_n(); + }); } RTCError JsepTransportController::SetLocalDescription( @@ -104,6 +106,7 @@ RTCError JsepTransportController::SetLocalDescription( RTC_FROM_HERE, [=] { return SetLocalDescription(type, description); }); } + RTC_DCHECK_RUN_ON(network_thread_); if (!initial_offerer_.has_value()) { initial_offerer_.emplace(type == SdpType::kOffer); if (*initial_offerer_) { @@ -123,6 +126,7 @@ RTCError JsepTransportController::SetRemoteDescription( RTC_FROM_HERE, [=] { return SetRemoteDescription(type, description); }); } + RTC_DCHECK_RUN_ON(network_thread_); return ApplyDescription_n(/*local=*/false, type, description); } @@ -558,7 +562,6 @@ RTCError JsepTransportController::ApplyDescription_n( bool local, SdpType type, const cricket::SessionDescription* description) { - RTC_DCHECK_RUN_ON(network_thread_); RTC_DCHECK(description); if (local) { @@ -955,7 +958,6 @@ RTCError JsepTransportController::MaybeCreateJsepTransport( bool local, const cricket::ContentInfo& content_info, const cricket::SessionDescription& description) { - RTC_DCHECK(network_thread_->IsCurrent()); cricket::JsepTransport* transport = GetJsepTransportByName(content_info.name); if (transport) { return RTCError::OK(); diff --git a/pc/jsep_transport_controller.h b/pc/jsep_transport_controller.h index f0adeedf26..64a599088e 100644 --- a/pc/jsep_transport_controller.h +++ b/pc/jsep_transport_controller.h @@ -229,7 +229,8 @@ class JsepTransportController : public sigslot::has_slots<> { private: RTCError ApplyDescription_n(bool local, SdpType type, - const cricket::SessionDescription* description); + const cricket::SessionDescription* description) + RTC_RUN_ON(network_thread_); RTCError ValidateAndMaybeUpdateBundleGroup( bool local, SdpType type, @@ -237,8 +238,10 @@ class JsepTransportController : public sigslot::has_slots<> { RTCError ValidateContent(const cricket::ContentInfo& content_info); void HandleRejectedContent(const cricket::ContentInfo& content_info, - const cricket::SessionDescription* description); - bool HandleBundledContent(const cricket::ContentInfo& content_info); + const cricket::SessionDescription* description) + RTC_RUN_ON(network_thread_); + bool HandleBundledContent(const cricket::ContentInfo& content_info) + RTC_RUN_ON(network_thread_); bool SetTransportForMid(const std::string& mid, cricket::JsepTransport* jsep_transport); @@ -295,12 +298,14 @@ class JsepTransportController : public sigslot::has_slots<> { RTCError MaybeCreateJsepTransport( bool local, const cricket::ContentInfo& content_info, - const cricket::SessionDescription& description); + const cricket::SessionDescription& description) + RTC_RUN_ON(network_thread_); - void MaybeDestroyJsepTransport(const std::string& mid); - void DestroyAllJsepTransports_n(); + void MaybeDestroyJsepTransport(const std::string& mid) + RTC_RUN_ON(network_thread_); + void DestroyAllJsepTransports_n() RTC_RUN_ON(network_thread_); - void SetIceRole_n(cricket::IceRole ice_role); + void SetIceRole_n(cricket::IceRole ice_role) RTC_RUN_ON(network_thread_); cricket::IceRole DetermineIceRole( cricket::JsepTransport* jsep_transport, @@ -334,24 +339,33 @@ class JsepTransportController : public sigslot::has_slots<> { std::vector GetDtlsTransports(); // Handlers for signals from Transport. - void OnTransportWritableState_n(rtc::PacketTransportInternal* transport); - void OnTransportReceivingState_n(rtc::PacketTransportInternal* transport); - void OnTransportGatheringState_n(cricket::IceTransportInternal* transport); + void OnTransportWritableState_n(rtc::PacketTransportInternal* transport) + RTC_RUN_ON(network_thread_); + void OnTransportReceivingState_n(rtc::PacketTransportInternal* transport) + RTC_RUN_ON(network_thread_); + void OnTransportGatheringState_n(cricket::IceTransportInternal* transport) + RTC_RUN_ON(network_thread_); void OnTransportCandidateGathered_n(cricket::IceTransportInternal* transport, - const cricket::Candidate& candidate); - void OnTransportCandidateError_n( - cricket::IceTransportInternal* transport, - const cricket::IceCandidateErrorEvent& event); + const cricket::Candidate& candidate) + RTC_RUN_ON(network_thread_); + void OnTransportCandidateError_n(cricket::IceTransportInternal* transport, + const cricket::IceCandidateErrorEvent& event) + RTC_RUN_ON(network_thread_); void OnTransportCandidatesRemoved_n(cricket::IceTransportInternal* transport, - const cricket::Candidates& candidates); - void OnTransportRoleConflict_n(cricket::IceTransportInternal* transport); - void OnTransportStateChanged_n(cricket::IceTransportInternal* transport); + const cricket::Candidates& candidates) + RTC_RUN_ON(network_thread_); + void OnTransportRoleConflict_n(cricket::IceTransportInternal* transport) + RTC_RUN_ON(network_thread_); + void OnTransportStateChanged_n(cricket::IceTransportInternal* transport) + RTC_RUN_ON(network_thread_); void OnTransportCandidatePairChanged_n( - const cricket::CandidatePairChangeEvent& event); - void UpdateAggregateStates_n(); + const cricket::CandidatePairChangeEvent& event) + RTC_RUN_ON(network_thread_); + void UpdateAggregateStates_n() RTC_RUN_ON(network_thread_); void OnRtcpPacketReceived_n(rtc::CopyOnWriteBuffer* packet, - int64_t packet_time_us); + int64_t packet_time_us) + RTC_RUN_ON(network_thread_); void OnDtlsHandshakeError(rtc::SSLHandshakeError error);