Remove accessor_lock_ in jsep_transport
Make access to rtcp_transport_ limited to network thread.
Bug: none
Change-Id: Id5c2834f758da595724079596d839e528c92e977
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/205982
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Tommi <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33180}
diff --git a/pc/jsep_transport.cc b/pc/jsep_transport.cc
index c385fd1..1bdcafd 100644
--- a/pc/jsep_transport.cc
+++ b/pc/jsep_transport.cc
@@ -207,7 +207,6 @@
ice_parameters);
{
- webrtc::MutexLock lock(&accessor_lock_);
if (rtcp_dtls_transport_) {
RTC_DCHECK(rtcp_dtls_transport_->internal());
rtcp_dtls_transport_->internal()->ice_transport()->SetIceParameters(
@@ -353,7 +352,6 @@
bool ret = GetTransportStats(rtp_dtls_transport_->internal(),
ICE_CANDIDATE_COMPONENT_RTP, stats);
- webrtc::MutexLock lock(&accessor_lock_);
if (rtcp_dtls_transport_) {
RTC_DCHECK(rtcp_dtls_transport_->internal());
ret &= GetTransportStats(rtcp_dtls_transport_->internal(),
@@ -466,8 +464,6 @@
}
void JsepTransport::ActivateRtcpMux() {
- RTC_DCHECK_RUN_ON(network_thread_);
-
if (unencrypted_rtp_transport_) {
RTC_DCHECK(!sdes_transport_);
RTC_DCHECK(!dtls_srtp_transport_);
@@ -483,10 +479,7 @@
dtls_srtp_transport_->SetDtlsTransports(rtp_dtls_transport(),
/*rtcp_dtls_transport=*/nullptr);
}
- {
- webrtc::MutexLock lock(&accessor_lock_);
- rtcp_dtls_transport_ = nullptr; // Destroy this reference.
- }
+ rtcp_dtls_transport_ = nullptr; // Destroy this reference.
// Notify the JsepTransportController to update the aggregate states.
SignalRtcpMuxActive();
}
diff --git a/pc/jsep_transport.h b/pc/jsep_transport.h
index 56fc2d9..5a6ef8a 100644
--- a/pc/jsep_transport.h
+++ b/pc/jsep_transport.h
@@ -46,7 +46,6 @@
#include "rtc_base/rtc_certificate.h"
#include "rtc_base/ssl_fingerprint.h"
#include "rtc_base/ssl_stream_adapter.h"
-#include "rtc_base/synchronization/mutex.h"
#include "rtc_base/synchronization/sequence_checker.h"
#include "rtc_base/third_party/sigslot/sigslot.h"
#include "rtc_base/thread.h"
@@ -125,7 +124,7 @@
webrtc::RTCError SetLocalJsepTransportDescription(
const JsepTransportDescription& jsep_description,
- webrtc::SdpType type) RTC_LOCKS_EXCLUDED(accessor_lock_);
+ webrtc::SdpType type);
// Set the remote TransportDescription to be used by DTLS and ICE channels
// that are part of this Transport.
@@ -154,7 +153,7 @@
absl::optional<rtc::SSLRole> GetDtlsRole() const;
// TODO(deadbeef): Make this const. See comment in transportcontroller.h.
- bool GetStats(TransportStats* stats) RTC_LOCKS_EXCLUDED(accessor_lock_);
+ bool GetStats(TransportStats* stats);
const JsepTransportDescription* local_description() const {
RTC_DCHECK_RUN_ON(network_thread_);
@@ -194,18 +193,16 @@
return nullptr;
}
- const DtlsTransportInternal* rtcp_dtls_transport() const
- RTC_LOCKS_EXCLUDED(accessor_lock_) {
- webrtc::MutexLock lock(&accessor_lock_);
+ const DtlsTransportInternal* rtcp_dtls_transport() const {
+ RTC_DCHECK_RUN_ON(network_thread_);
if (rtcp_dtls_transport_) {
return rtcp_dtls_transport_->internal();
}
return nullptr;
}
- DtlsTransportInternal* rtcp_dtls_transport()
- RTC_LOCKS_EXCLUDED(accessor_lock_) {
- webrtc::MutexLock lock(&accessor_lock_);
+ DtlsTransportInternal* rtcp_dtls_transport() {
+ RTC_DCHECK_RUN_ON(network_thread_);
if (rtcp_dtls_transport_) {
return rtcp_dtls_transport_->internal();
}
@@ -249,7 +246,7 @@
private:
bool SetRtcpMux(bool enable, webrtc::SdpType type, ContentSource source);
- void ActivateRtcpMux() RTC_LOCKS_EXCLUDED(accessor_lock_);
+ void ActivateRtcpMux() RTC_RUN_ON(network_thread_);
bool SetSdes(const std::vector<CryptoParams>& cryptos,
const std::vector<int>& encrypted_extension_ids,
@@ -289,10 +286,6 @@
// Owning thread, for safety checks
const rtc::Thread* const network_thread_;
- // Critical scope for fields accessed off-thread. Mutable, since it is used by
- // getter methods.
- // TODO(https://bugs.webrtc.org/10300): Stop doing this.
- mutable webrtc::Mutex accessor_lock_;
const std::string mid_;
// needs-ice-restart bit as described in JSEP.
bool needs_ice_restart_ RTC_GUARDED_BY(network_thread_) = false;
@@ -315,10 +308,10 @@
const std::unique_ptr<webrtc::DtlsSrtpTransport> dtls_srtp_transport_;
const rtc::scoped_refptr<webrtc::DtlsTransport> rtp_dtls_transport_;
- // TODO(tommi): Restrict use to network thread, or make const. And delete the
- // `accessor_lock_`.
+ // The RTCP transport is const for all usages, except that it is cleared
+ // when RTCP multiplexing is turned on; this happens on the network thread.
rtc::scoped_refptr<webrtc::DtlsTransport> rtcp_dtls_transport_
- RTC_GUARDED_BY(accessor_lock_);
+ RTC_GUARDED_BY(network_thread_);
const std::unique_ptr<webrtc::DataChannelTransportInterface>
sctp_data_channel_transport_;