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 <nisse@webrtc.org>
Commit-Queue: Tommi <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33613}
diff --git a/pc/peer_connection.cc b/pc/peer_connection.cc
index 2e206bf..a571a53 100644
--- a/pc/peer_connection.cc
+++ b/pc/peer_connection.cc
@@ -468,6 +468,11 @@
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 @@
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 58424db..aa46feb 100644
--- a/pc/peer_connection.h
+++ b/pc/peer_connection.h
@@ -271,7 +271,6 @@
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 @@
rtc::scoped_refptr<RTCStatsCollector> stats_collector_
RTC_GUARDED_BY(signaling_thread());
- std::string session_id_ RTC_GUARDED_BY(signaling_thread());
+ const std::string session_id_;
std::unique_ptr<JsepTransportController>
transport_controller_; // TODO(bugs.webrtc.org/9987): Accessed on both