From 97a387d7f370de730cf74883d16fb3225f4209c7 Mon Sep 17 00:00:00 2001 From: Tomas Gunnarsson Date: Mon, 29 Mar 2021 21:04:29 +0200 Subject: [PATCH] Make PeerConnection::session_id_ const and readable from any thread. Going forward, we'll need to read this value from other threads than signaling, so I've moved the initialization into the constructor. Bug: none Change-Id: I56b00d38c86788cbab9a2055719074ea48f4750f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/213185 Reviewed-by: Niels Moller Commit-Queue: Tommi Cr-Commit-Position: refs/heads/master@{#33613} --- pc/peer_connection.cc | 11 +++++------ pc/peer_connection.h | 3 +-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/pc/peer_connection.cc b/pc/peer_connection.cc index 2e206bfa11..a571a53645 100644 --- a/pc/peer_connection.cc +++ b/pc/peer_connection.cc @@ -468,6 +468,11 @@ PeerConnection::PeerConnection( tls_cert_verifier_(std::move(dependencies.tls_cert_verifier)), call_(std::move(call)), call_ptr_(call_.get()), + // RFC 3264: The numeric value of the session id and version in the + // o line MUST be representable with a "64 bit signed integer". + // Due to this constraint session id |session_id_| is max limited to + // LLONG_MAX. + session_id_(rtc::ToString(rtc::CreateRandomId64() & LLONG_MAX)), dtls_enabled_(dtls_enabled), data_channel_controller_(this), message_handler_(signaling_thread()), @@ -560,12 +565,6 @@ RTCError PeerConnection::Initialize( NoteUsageEvent(UsageEvent::TURN_SERVER_ADDED); } - // RFC 3264: The numeric value of the session id and version in the - // o line MUST be representable with a "64 bit signed integer". - // Due to this constraint session id |session_id_| is max limited to - // LLONG_MAX. - session_id_ = rtc::ToString(rtc::CreateRandomId64() & LLONG_MAX); - if (configuration.enable_rtp_data_channel) { // Enable creation of RTP data channels if the kEnableRtpDataChannels is // set. It takes precendence over the disable_sctp_data_channels diff --git a/pc/peer_connection.h b/pc/peer_connection.h index 58424dbac0..aa46feb4aa 100644 --- a/pc/peer_connection.h +++ b/pc/peer_connection.h @@ -271,7 +271,6 @@ class PeerConnection : public PeerConnectionInternal, rtc::Thread* worker_thread() const final { return context_->worker_thread(); } std::string session_id() const override { - RTC_DCHECK_RUN_ON(signaling_thread()); return session_id_; } @@ -670,7 +669,7 @@ class PeerConnection : public PeerConnectionInternal, rtc::scoped_refptr stats_collector_ RTC_GUARDED_BY(signaling_thread()); - std::string session_id_ RTC_GUARDED_BY(signaling_thread()); + const std::string session_id_; std::unique_ptr transport_controller_; // TODO(bugs.webrtc.org/9987): Accessed on both