From fc83cdc8198b0609f8986313ef48e565b558e8a7 Mon Sep 17 00:00:00 2001 From: Tomas Gunnarsson Date: Thu, 10 Sep 2020 13:04:50 +0200 Subject: [PATCH] Avoid proxy thread hops for reading const properties. This bypasses the proxy for the following properties: * MediaStream::id() * AudioTrack::kind() and AudioTrack::id() * VideoTrack::kind() and VideoTrack::id() * RtpReceiver::media_type() and RtpReceiver::id() * RtpSender::media_type() and RtpSender::id() * VideoTrackSource::remote() and VideoTrackSource::is_screencast() * RtpTransceiver::media_type() Bug: webrtc:11923 Change-Id: If7edea1781f778af3775515fc4af9a9e151c8103 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/183767 Reviewed-by: Chen Xing Commit-Queue: Tommi Cr-Commit-Position: refs/heads/master@{#32071} --- api/media_stream_proxy.h | 2 +- api/media_stream_track_proxy.h | 8 ++++---- api/rtp_receiver_interface.h | 4 ++-- api/rtp_sender_interface.h | 4 ++-- api/video_track_source_proxy.h | 4 ++-- pc/audio_track.cc | 1 - pc/media_stream.h | 2 +- pc/media_stream_track.h | 2 +- pc/rtp_transceiver.h | 2 +- 9 files changed, 14 insertions(+), 15 deletions(-) diff --git a/api/media_stream_proxy.h b/api/media_stream_proxy.h index 516967998f..8ee33ca0ee 100644 --- a/api/media_stream_proxy.h +++ b/api/media_stream_proxy.h @@ -22,7 +22,7 @@ namespace webrtc { // are called on is an implementation detail. BEGIN_SIGNALING_PROXY_MAP(MediaStream) PROXY_SIGNALING_THREAD_DESTRUCTOR() -PROXY_CONSTMETHOD0(std::string, id) +BYPASS_PROXY_CONSTMETHOD0(std::string, id) PROXY_METHOD0(AudioTrackVector, GetAudioTracks) PROXY_METHOD0(VideoTrackVector, GetVideoTracks) PROXY_METHOD1(rtc::scoped_refptr, diff --git a/api/media_stream_track_proxy.h b/api/media_stream_track_proxy.h index d3dc25504b..59dcb77244 100644 --- a/api/media_stream_track_proxy.h +++ b/api/media_stream_track_proxy.h @@ -26,8 +26,8 @@ namespace webrtc { BEGIN_SIGNALING_PROXY_MAP(AudioTrack) PROXY_SIGNALING_THREAD_DESTRUCTOR() -PROXY_CONSTMETHOD0(std::string, kind) -PROXY_CONSTMETHOD0(std::string, id) +BYPASS_PROXY_CONSTMETHOD0(std::string, kind) +BYPASS_PROXY_CONSTMETHOD0(std::string, id) PROXY_CONSTMETHOD0(TrackState, state) PROXY_CONSTMETHOD0(bool, enabled) PROXY_CONSTMETHOD0(AudioSourceInterface*, GetSource) @@ -42,8 +42,8 @@ END_PROXY_MAP() BEGIN_PROXY_MAP(VideoTrack) PROXY_SIGNALING_THREAD_DESTRUCTOR() -PROXY_CONSTMETHOD0(std::string, kind) -PROXY_CONSTMETHOD0(std::string, id) +BYPASS_PROXY_CONSTMETHOD0(std::string, kind) +BYPASS_PROXY_CONSTMETHOD0(std::string, id) PROXY_CONSTMETHOD0(TrackState, state) PROXY_CONSTMETHOD0(bool, enabled) PROXY_METHOD1(bool, set_enabled, bool) diff --git a/api/rtp_receiver_interface.h b/api/rtp_receiver_interface.h index a15864e34a..786ea3aceb 100644 --- a/api/rtp_receiver_interface.h +++ b/api/rtp_receiver_interface.h @@ -128,8 +128,8 @@ PROXY_CONSTMETHOD0(rtc::scoped_refptr, dtls_transport) PROXY_CONSTMETHOD0(std::vector, stream_ids) PROXY_CONSTMETHOD0(std::vector>, streams) -PROXY_CONSTMETHOD0(cricket::MediaType, media_type) -PROXY_CONSTMETHOD0(std::string, id) +BYPASS_PROXY_CONSTMETHOD0(cricket::MediaType, media_type) +BYPASS_PROXY_CONSTMETHOD0(std::string, id) PROXY_CONSTMETHOD0(RtpParameters, GetParameters) PROXY_METHOD1(void, SetObserver, RtpReceiverObserverInterface*) PROXY_METHOD1(void, SetJitterBufferMinimumDelay, absl::optional) diff --git a/api/rtp_sender_interface.h b/api/rtp_sender_interface.h index bdbd6dc645..a33b80042e 100644 --- a/api/rtp_sender_interface.h +++ b/api/rtp_sender_interface.h @@ -110,8 +110,8 @@ PROXY_METHOD1(bool, SetTrack, MediaStreamTrackInterface*) PROXY_CONSTMETHOD0(rtc::scoped_refptr, track) PROXY_CONSTMETHOD0(rtc::scoped_refptr, dtls_transport) PROXY_CONSTMETHOD0(uint32_t, ssrc) -PROXY_CONSTMETHOD0(cricket::MediaType, media_type) -PROXY_CONSTMETHOD0(std::string, id) +BYPASS_PROXY_CONSTMETHOD0(cricket::MediaType, media_type) +BYPASS_PROXY_CONSTMETHOD0(std::string, id) PROXY_CONSTMETHOD0(std::vector, stream_ids) PROXY_CONSTMETHOD0(std::vector, init_send_encodings) PROXY_CONSTMETHOD0(RtpParameters, GetParameters) diff --git a/api/video_track_source_proxy.h b/api/video_track_source_proxy.h index 528b7cf701..692ff6493f 100644 --- a/api/video_track_source_proxy.h +++ b/api/video_track_source_proxy.h @@ -23,8 +23,8 @@ namespace webrtc { BEGIN_PROXY_MAP(VideoTrackSource) PROXY_SIGNALING_THREAD_DESTRUCTOR() PROXY_CONSTMETHOD0(SourceState, state) -PROXY_CONSTMETHOD0(bool, remote) -PROXY_CONSTMETHOD0(bool, is_screencast) +BYPASS_PROXY_CONSTMETHOD0(bool, remote) +BYPASS_PROXY_CONSTMETHOD0(bool, is_screencast) PROXY_CONSTMETHOD0(absl::optional, needs_denoising) PROXY_METHOD1(bool, GetStats, Stats*) PROXY_WORKER_METHOD2(void, diff --git a/pc/audio_track.cc b/pc/audio_track.cc index ff680652c9..4f4c6b4757 100644 --- a/pc/audio_track.cc +++ b/pc/audio_track.cc @@ -39,7 +39,6 @@ AudioTrack::~AudioTrack() { } std::string AudioTrack::kind() const { - RTC_DCHECK(thread_checker_.IsCurrent()); return kAudioKind; } diff --git a/pc/media_stream.h b/pc/media_stream.h index 34299f46e3..6f16bea1d9 100644 --- a/pc/media_stream.h +++ b/pc/media_stream.h @@ -48,7 +48,7 @@ class MediaStream : public Notifier { template bool RemoveTrack(TrackVector* Tracks, MediaStreamTrackInterface* track); - std::string id_; + const std::string id_; AudioTrackVector audio_tracks_; VideoTrackVector video_tracks_; }; diff --git a/pc/media_stream_track.h b/pc/media_stream_track.h index 358d89a25b..25c3663c0a 100644 --- a/pc/media_stream_track.h +++ b/pc/media_stream_track.h @@ -53,7 +53,7 @@ class MediaStreamTrack : public Notifier { private: bool enabled_; - std::string id_; + const std::string id_; MediaStreamTrackInterface::TrackState state_; }; diff --git a/pc/rtp_transceiver.h b/pc/rtp_transceiver.h index 9c048adc06..97e60a50d1 100644 --- a/pc/rtp_transceiver.h +++ b/pc/rtp_transceiver.h @@ -244,7 +244,7 @@ class RtpTransceiver final BEGIN_SIGNALING_PROXY_MAP(RtpTransceiver) PROXY_SIGNALING_THREAD_DESTRUCTOR() -PROXY_CONSTMETHOD0(cricket::MediaType, media_type) +BYPASS_PROXY_CONSTMETHOD0(cricket::MediaType, media_type) PROXY_CONSTMETHOD0(absl::optional, mid) PROXY_CONSTMETHOD0(rtc::scoped_refptr, sender) PROXY_CONSTMETHOD0(rtc::scoped_refptr, receiver)