Update VideoTrack::Create to use rtc::scoped_refptr.

Bug: webrtc:13464
Change-Id: I6508fbede2f447f8c0c9b37556d37e7fc2ccb744
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/252441
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36277}
diff --git a/pc/peer_connection_factory.cc b/pc/peer_connection_factory.cc
index 262ca90..c598440 100644
--- a/pc/peer_connection_factory.cc
+++ b/pc/peer_connection_factory.cc
@@ -276,8 +276,9 @@
     const std::string& id,
     VideoTrackSourceInterface* source) {
   RTC_DCHECK(signaling_thread()->IsCurrent());
-  rtc::scoped_refptr<VideoTrackInterface> track(
-      VideoTrack::Create(id, source, worker_thread()));
+  rtc::scoped_refptr<VideoTrackInterface> track = VideoTrack::Create(
+      id, rtc::scoped_refptr<VideoTrackSourceInterface>(source),
+      worker_thread());
   return VideoTrackProxy::Create(signaling_thread(), worker_thread(), track);
 }
 
@@ -285,8 +286,8 @@
     const std::string& id,
     AudioSourceInterface* source) {
   RTC_DCHECK(signaling_thread()->IsCurrent());
-  rtc::scoped_refptr<AudioTrackInterface> track(
-      AudioTrack::Create(id, rtc::scoped_refptr<AudioSourceInterface>(source)));
+  rtc::scoped_refptr<AudioTrackInterface> track =
+      AudioTrack::Create(id, rtc::scoped_refptr<AudioSourceInterface>(source));
   return AudioTrackProxy::Create(signaling_thread(), track);
 }
 
diff --git a/pc/video_track.cc b/pc/video_track.cc
index aa8e0df..95e27a3 100644
--- a/pc/video_track.cc
+++ b/pc/video_track.cc
@@ -132,13 +132,12 @@
 
 rtc::scoped_refptr<VideoTrack> VideoTrack::Create(
     const std::string& id,
-    VideoTrackSourceInterface* source,
+    rtc::scoped_refptr<VideoTrackSourceInterface> source,
     rtc::Thread* worker_thread) {
   rtc::scoped_refptr<
       VideoTrackSourceProxyWithInternal<VideoTrackSourceInterface>>
       source_proxy = VideoTrackSourceProxy::Create(
-          rtc::Thread::Current(), worker_thread,
-          rtc::scoped_refptr<VideoTrackSourceInterface>(source));
+          rtc::Thread::Current(), worker_thread, std::move(source));
 
   return rtc::make_ref_counted<VideoTrack>(id, std::move(source_proxy),
                                            worker_thread);
diff --git a/pc/video_track.h b/pc/video_track.h
index f938b33..8934e96 100644
--- a/pc/video_track.h
+++ b/pc/video_track.h
@@ -39,7 +39,7 @@
  public:
   static rtc::scoped_refptr<VideoTrack> Create(
       const std::string& label,
-      VideoTrackSourceInterface* source,
+      rtc::scoped_refptr<VideoTrackSourceInterface> source,
       rtc::Thread* worker_thread);
 
   void AddOrUpdateSink(rtc::VideoSinkInterface<VideoFrame>* sink,