From 1f6e4308ab071d1386a25ca5d833f89a1de58a3f Mon Sep 17 00:00:00 2001 From: Sergey Silkin Date: Mon, 21 Feb 2022 09:42:45 +0000 Subject: [PATCH] Revert "Move VideoTrackSourceProxy creation into VideoTrack." This reverts commit 4bc7223cf0775737a615c677b82c78e49a6a8a2c. Reason for revert: Regressions in PC tests https://crbug.com/webrtc/13697 Original change's description: > Move VideoTrackSourceProxy creation into VideoTrack. > > This CL contains a part of a previously reviewed, landed, reverted, > relanded and re-reverted CL: > https://webrtc-review.googlesource.com/c/src/+/250180 > > Bug: webrtc:13540 > Change-Id: Id6df8da5ff61e3ec90d0b3f3d828e8f670d4931b > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251860 > Reviewed-by: Harald Alvestrand > Auto-Submit: Tomas Gunnarsson > Commit-Queue: Tomas Gunnarsson > Cr-Commit-Position: refs/heads/main@{#36025} Bug: webrtc:13540 Change-Id: Ibae8c1d39fa4d71aafd9666b66e6abc8eb8fddb2 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251980 Bot-Commit: rubber-stamper@appspot.gserviceaccount.com Reviewed-by: Harald Alvestrand Reviewed-by: Tomas Gunnarsson Commit-Queue: Tomas Gunnarsson Cr-Commit-Position: refs/heads/main@{#36039} --- pc/BUILD.gn | 1 - pc/audio_track.h | 4 ---- pc/video_rtp_receiver.cc | 6 +++++- pc/video_track.cc | 18 +++++------------- pc/video_track.h | 17 ++++------------- 5 files changed, 14 insertions(+), 32 deletions(-) diff --git a/pc/BUILD.gn b/pc/BUILD.gn index e7b7cc0102..277657e6a0 100644 --- a/pc/BUILD.gn +++ b/pc/BUILD.gn @@ -1272,7 +1272,6 @@ rtc_library("video_track") { "video_track.h", ] deps = [ - ":rtc_pc_base", "../api:media_stream_interface", "../api:scoped_refptr", "../api:sequence_checker", diff --git a/pc/audio_track.h b/pc/audio_track.h index 920bb948ba..f357391987 100644 --- a/pc/audio_track.h +++ b/pc/audio_track.h @@ -21,10 +21,6 @@ namespace webrtc { -// TODO(tommi): Instead of inheriting from `MediaStreamTrack<>`, implement the -// properties directly in this class. `MediaStreamTrack` doesn't guard against -// conflicting access, so we'd need to override those methods anyway in this -// class in order to make sure things are correctly checked. class AudioTrack : public MediaStreamTrack, public ObserverInterface { protected: diff --git a/pc/video_rtp_receiver.cc b/pc/video_rtp_receiver.cc index d1f8fb0d96..c5ead9e773 100644 --- a/pc/video_rtp_receiver.cc +++ b/pc/video_rtp_receiver.cc @@ -41,7 +41,11 @@ VideoRtpReceiver::VideoRtpReceiver( track_(VideoTrackProxyWithInternal::Create( rtc::Thread::Current(), worker_thread, - VideoTrack::Create(receiver_id, source_, worker_thread))), + VideoTrack::Create(receiver_id, + CreateVideoTrackSourceProxy(rtc::Thread::Current(), + worker_thread, + source_), + worker_thread))), attachment_id_(GenerateUniqueId()) { RTC_DCHECK(worker_thread_); SetStreams(streams); diff --git a/pc/video_track.cc b/pc/video_track.cc index 27274dc095..6e749b0526 100644 --- a/pc/video_track.cc +++ b/pc/video_track.cc @@ -23,14 +23,12 @@ namespace webrtc { -VideoTrack::VideoTrack( - const std::string& label, - rtc::scoped_refptr< - VideoTrackSourceProxyWithInternal> source, - rtc::Thread* worker_thread) +VideoTrack::VideoTrack(const std::string& label, + VideoTrackSourceInterface* video_source, + rtc::Thread* worker_thread) : MediaStreamTrack(label), worker_thread_(worker_thread), - video_source_(std::move(source)), + video_source_(video_source), content_hint_(ContentHint::kNone) { RTC_DCHECK_RUN_ON(&signaling_thread_); // Detach the thread checker for VideoSourceBaseGuarded since we'll make calls @@ -132,13 +130,7 @@ rtc::scoped_refptr VideoTrack::Create( const std::string& id, VideoTrackSourceInterface* source, rtc::Thread* worker_thread) { - rtc::scoped_refptr< - VideoTrackSourceProxyWithInternal> - source_proxy = VideoTrackSourceProxy::Create(rtc::Thread::Current(), - worker_thread, source); - - return rtc::make_ref_counted(id, std::move(source_proxy), - worker_thread); + return rtc::make_ref_counted(id, source, worker_thread); } } // namespace webrtc diff --git a/pc/video_track.h b/pc/video_track.h index 2bf7f31741..bf433b5f5a 100644 --- a/pc/video_track.h +++ b/pc/video_track.h @@ -22,16 +22,11 @@ #include "api/video/video_source_interface.h" #include "media/base/video_source_base.h" #include "rtc_base/system/no_unique_address.h" -#include "pc/video_track_source_proxy.h" #include "rtc_base/thread.h" #include "rtc_base/thread_annotations.h" namespace webrtc { -// TODO(tommi): Instead of inheriting from `MediaStreamTrack<>`, implement the -// properties directly in this class. `MediaStreamTrack` doesn't guard against -// conflicting access, so we'd need to override those methods anyway in this -// class in order to make sure things are correctly checked. class VideoTrack : public MediaStreamTrack, public rtc::VideoSourceBaseGuarded, public ObserverInterface { @@ -55,11 +50,9 @@ class VideoTrack : public MediaStreamTrack, std::string kind() const override; protected: - VideoTrack( - const std::string& id, - rtc::scoped_refptr< - VideoTrackSourceProxyWithInternal> source, - rtc::Thread* worker_thread); + VideoTrack(const std::string& id, + VideoTrackSourceInterface* video_source, + rtc::Thread* worker_thread); ~VideoTrack(); private: @@ -68,9 +61,7 @@ class VideoTrack : public MediaStreamTrack, RTC_NO_UNIQUE_ADDRESS webrtc::SequenceChecker signaling_thread_; rtc::Thread* const worker_thread_; - const rtc::scoped_refptr< - VideoTrackSourceProxyWithInternal> - video_source_; + const rtc::scoped_refptr video_source_; ContentHint content_hint_ RTC_GUARDED_BY(&signaling_thread_); // Cached `enabled` state for the worker thread. This is kept in sync with // the state maintained on the signaling thread via set_enabled() but can