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 <chxg@google.com>
Commit-Queue: Tommi <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32071}
This commit is contained in:
Tomas Gunnarsson 2020-09-10 13:04:50 +02:00 committed by Commit Bot
parent 8750c16f46
commit fc83cdc819
9 changed files with 14 additions and 15 deletions

View file

@ -22,7 +22,7 @@ namespace webrtc {
// are called on is an implementation detail. // are called on is an implementation detail.
BEGIN_SIGNALING_PROXY_MAP(MediaStream) BEGIN_SIGNALING_PROXY_MAP(MediaStream)
PROXY_SIGNALING_THREAD_DESTRUCTOR() PROXY_SIGNALING_THREAD_DESTRUCTOR()
PROXY_CONSTMETHOD0(std::string, id) BYPASS_PROXY_CONSTMETHOD0(std::string, id)
PROXY_METHOD0(AudioTrackVector, GetAudioTracks) PROXY_METHOD0(AudioTrackVector, GetAudioTracks)
PROXY_METHOD0(VideoTrackVector, GetVideoTracks) PROXY_METHOD0(VideoTrackVector, GetVideoTracks)
PROXY_METHOD1(rtc::scoped_refptr<AudioTrackInterface>, PROXY_METHOD1(rtc::scoped_refptr<AudioTrackInterface>,

View file

@ -26,8 +26,8 @@ namespace webrtc {
BEGIN_SIGNALING_PROXY_MAP(AudioTrack) BEGIN_SIGNALING_PROXY_MAP(AudioTrack)
PROXY_SIGNALING_THREAD_DESTRUCTOR() PROXY_SIGNALING_THREAD_DESTRUCTOR()
PROXY_CONSTMETHOD0(std::string, kind) BYPASS_PROXY_CONSTMETHOD0(std::string, kind)
PROXY_CONSTMETHOD0(std::string, id) BYPASS_PROXY_CONSTMETHOD0(std::string, id)
PROXY_CONSTMETHOD0(TrackState, state) PROXY_CONSTMETHOD0(TrackState, state)
PROXY_CONSTMETHOD0(bool, enabled) PROXY_CONSTMETHOD0(bool, enabled)
PROXY_CONSTMETHOD0(AudioSourceInterface*, GetSource) PROXY_CONSTMETHOD0(AudioSourceInterface*, GetSource)
@ -42,8 +42,8 @@ END_PROXY_MAP()
BEGIN_PROXY_MAP(VideoTrack) BEGIN_PROXY_MAP(VideoTrack)
PROXY_SIGNALING_THREAD_DESTRUCTOR() PROXY_SIGNALING_THREAD_DESTRUCTOR()
PROXY_CONSTMETHOD0(std::string, kind) BYPASS_PROXY_CONSTMETHOD0(std::string, kind)
PROXY_CONSTMETHOD0(std::string, id) BYPASS_PROXY_CONSTMETHOD0(std::string, id)
PROXY_CONSTMETHOD0(TrackState, state) PROXY_CONSTMETHOD0(TrackState, state)
PROXY_CONSTMETHOD0(bool, enabled) PROXY_CONSTMETHOD0(bool, enabled)
PROXY_METHOD1(bool, set_enabled, bool) PROXY_METHOD1(bool, set_enabled, bool)

View file

@ -128,8 +128,8 @@ PROXY_CONSTMETHOD0(rtc::scoped_refptr<DtlsTransportInterface>, dtls_transport)
PROXY_CONSTMETHOD0(std::vector<std::string>, stream_ids) PROXY_CONSTMETHOD0(std::vector<std::string>, stream_ids)
PROXY_CONSTMETHOD0(std::vector<rtc::scoped_refptr<MediaStreamInterface>>, PROXY_CONSTMETHOD0(std::vector<rtc::scoped_refptr<MediaStreamInterface>>,
streams) streams)
PROXY_CONSTMETHOD0(cricket::MediaType, media_type) BYPASS_PROXY_CONSTMETHOD0(cricket::MediaType, media_type)
PROXY_CONSTMETHOD0(std::string, id) BYPASS_PROXY_CONSTMETHOD0(std::string, id)
PROXY_CONSTMETHOD0(RtpParameters, GetParameters) PROXY_CONSTMETHOD0(RtpParameters, GetParameters)
PROXY_METHOD1(void, SetObserver, RtpReceiverObserverInterface*) PROXY_METHOD1(void, SetObserver, RtpReceiverObserverInterface*)
PROXY_METHOD1(void, SetJitterBufferMinimumDelay, absl::optional<double>) PROXY_METHOD1(void, SetJitterBufferMinimumDelay, absl::optional<double>)

View file

@ -110,8 +110,8 @@ PROXY_METHOD1(bool, SetTrack, MediaStreamTrackInterface*)
PROXY_CONSTMETHOD0(rtc::scoped_refptr<MediaStreamTrackInterface>, track) PROXY_CONSTMETHOD0(rtc::scoped_refptr<MediaStreamTrackInterface>, track)
PROXY_CONSTMETHOD0(rtc::scoped_refptr<DtlsTransportInterface>, dtls_transport) PROXY_CONSTMETHOD0(rtc::scoped_refptr<DtlsTransportInterface>, dtls_transport)
PROXY_CONSTMETHOD0(uint32_t, ssrc) PROXY_CONSTMETHOD0(uint32_t, ssrc)
PROXY_CONSTMETHOD0(cricket::MediaType, media_type) BYPASS_PROXY_CONSTMETHOD0(cricket::MediaType, media_type)
PROXY_CONSTMETHOD0(std::string, id) BYPASS_PROXY_CONSTMETHOD0(std::string, id)
PROXY_CONSTMETHOD0(std::vector<std::string>, stream_ids) PROXY_CONSTMETHOD0(std::vector<std::string>, stream_ids)
PROXY_CONSTMETHOD0(std::vector<RtpEncodingParameters>, init_send_encodings) PROXY_CONSTMETHOD0(std::vector<RtpEncodingParameters>, init_send_encodings)
PROXY_CONSTMETHOD0(RtpParameters, GetParameters) PROXY_CONSTMETHOD0(RtpParameters, GetParameters)

View file

@ -23,8 +23,8 @@ namespace webrtc {
BEGIN_PROXY_MAP(VideoTrackSource) BEGIN_PROXY_MAP(VideoTrackSource)
PROXY_SIGNALING_THREAD_DESTRUCTOR() PROXY_SIGNALING_THREAD_DESTRUCTOR()
PROXY_CONSTMETHOD0(SourceState, state) PROXY_CONSTMETHOD0(SourceState, state)
PROXY_CONSTMETHOD0(bool, remote) BYPASS_PROXY_CONSTMETHOD0(bool, remote)
PROXY_CONSTMETHOD0(bool, is_screencast) BYPASS_PROXY_CONSTMETHOD0(bool, is_screencast)
PROXY_CONSTMETHOD0(absl::optional<bool>, needs_denoising) PROXY_CONSTMETHOD0(absl::optional<bool>, needs_denoising)
PROXY_METHOD1(bool, GetStats, Stats*) PROXY_METHOD1(bool, GetStats, Stats*)
PROXY_WORKER_METHOD2(void, PROXY_WORKER_METHOD2(void,

View file

@ -39,7 +39,6 @@ AudioTrack::~AudioTrack() {
} }
std::string AudioTrack::kind() const { std::string AudioTrack::kind() const {
RTC_DCHECK(thread_checker_.IsCurrent());
return kAudioKind; return kAudioKind;
} }

View file

@ -48,7 +48,7 @@ class MediaStream : public Notifier<MediaStreamInterface> {
template <typename TrackVector> template <typename TrackVector>
bool RemoveTrack(TrackVector* Tracks, MediaStreamTrackInterface* track); bool RemoveTrack(TrackVector* Tracks, MediaStreamTrackInterface* track);
std::string id_; const std::string id_;
AudioTrackVector audio_tracks_; AudioTrackVector audio_tracks_;
VideoTrackVector video_tracks_; VideoTrackVector video_tracks_;
}; };

View file

@ -53,7 +53,7 @@ class MediaStreamTrack : public Notifier<T> {
private: private:
bool enabled_; bool enabled_;
std::string id_; const std::string id_;
MediaStreamTrackInterface::TrackState state_; MediaStreamTrackInterface::TrackState state_;
}; };

View file

@ -244,7 +244,7 @@ class RtpTransceiver final
BEGIN_SIGNALING_PROXY_MAP(RtpTransceiver) BEGIN_SIGNALING_PROXY_MAP(RtpTransceiver)
PROXY_SIGNALING_THREAD_DESTRUCTOR() PROXY_SIGNALING_THREAD_DESTRUCTOR()
PROXY_CONSTMETHOD0(cricket::MediaType, media_type) BYPASS_PROXY_CONSTMETHOD0(cricket::MediaType, media_type)
PROXY_CONSTMETHOD0(absl::optional<std::string>, mid) PROXY_CONSTMETHOD0(absl::optional<std::string>, mid)
PROXY_CONSTMETHOD0(rtc::scoped_refptr<RtpSenderInterface>, sender) PROXY_CONSTMETHOD0(rtc::scoped_refptr<RtpSenderInterface>, sender)
PROXY_CONSTMETHOD0(rtc::scoped_refptr<RtpReceiverInterface>, receiver) PROXY_CONSTMETHOD0(rtc::scoped_refptr<RtpReceiverInterface>, receiver)