Remove rtc_base/scoped_ref_ptr.h.

The type rtc::scoped_refptr<T> is now part of api/. Please include it from
api/scoped_refptr.h.

More info: See: https://groups.google.com/forum/#!topic/discuss-webrtc/Mme2MSz4z4o.

Bug: webrtc:9887, webrtc:8205
No-Try: True
Change-Id: Ic6c7c81e226e59f12f7933e472f573ae097b55bf
Reviewed-on: https://webrtc-review.googlesource.com/c/119041
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26414}
diff --git a/api/BUILD.gn b/api/BUILD.gn
index 396f63d..4e2077a 100644
--- a/api/BUILD.gn
+++ b/api/BUILD.gn
@@ -46,6 +46,7 @@
     ":callfactory_api",
     ":fec_controller_api",
     ":libjingle_peerconnection_api",
+    ":scoped_refptr",
     "../logging:rtc_event_log_api",
     "../logging:rtc_event_log_impl_base",
     "../media:rtc_audio_video",
@@ -54,7 +55,6 @@
     "../modules/audio_processing:api",
     "../pc:peerconnection",
     "../rtc_base:deprecation",
-    "../rtc_base:ptr_util",
     "../rtc_base:rtc_base",
     "../rtc_base:rtc_base_approved",
     "audio:audio_mixer_api",
@@ -157,6 +157,7 @@
     ":fec_controller_api",
     ":libjingle_logging_api",
     ":rtc_stats_api",
+    ":scoped_refptr",
     "audio:audio_mixer_api",
     "audio_codecs:audio_codecs_api",
     "transport:bitrate_settings",
@@ -244,8 +245,8 @@
     ]
     deps = [
       ":fec_controller_api",
+      ":scoped_refptr",
       ":video_quality_test_fixture_api",
-      "../rtc_base:ptr_util",
       "../video:video_quality_test",
       "//third_party/abseil-cpp/absl/memory",
     ]
@@ -295,6 +296,7 @@
   ]
 
   deps = [
+    ":scoped_refptr",
     "../rtc_base:checks",
     "../rtc_base:rtc_base_approved",
     "../rtc_base/system:rtc_export",
diff --git a/api/DEPS b/api/DEPS
index 37d0e9b..ca0726f 100644
--- a/api/DEPS
+++ b/api/DEPS
@@ -68,7 +68,6 @@
 
   "create_peerconnection_factory\.h": [
     "+rtc_base/deprecation.h",
-    "+rtc_base/scoped_ref_ptr.h",
   ],
 
   "data_channel_interface\.h": [
@@ -103,7 +102,6 @@
   "media_stream_interface\.h": [
     "+modules/audio_processing/include/audio_processing_statistics.h",
     "+rtc_base/ref_count.h",
-    "+rtc_base/scoped_ref_ptr.h",
   ],
 
   "media_transport_interface\.h": [
@@ -137,7 +135,6 @@
     "+rtc_base/message_handler.h",  # Inherits from it.
     "+rtc_base/message_queue.h",    # Inherits from MessageData.
     "+rtc_base/ref_counted_object.h",
-    "+rtc_base/scoped_ref_ptr.h",
     "+rtc_base/thread.h",
   ],
 
@@ -153,17 +150,14 @@
 
   "rtp_receiver_interface\.h": [
     "+rtc_base/ref_count.h",
-    "+rtc_base/scoped_ref_ptr.h",
   ],
 
   "rtp_sender_interface\.h": [
     "+rtc_base/ref_count.h",
-    "+rtc_base/scoped_ref_ptr.h",
   ],
 
   "rtp_transceiver_interface\.h": [
     "+rtc_base/ref_count.h",
-    "+rtc_base/scoped_ref_ptr.h",
   ],
 
   "set_remote_description_observer_interface\.h": [
@@ -173,7 +167,6 @@
   "stats_types\.h": [
     "+rtc_base/constructor_magic.h",
     "+rtc_base/ref_count.h",
-    "+rtc_base/scoped_ref_ptr.h",
     "+rtc_base/string_encode.h",
     "+rtc_base/thread_checker.h",
   ],
@@ -201,7 +194,6 @@
 
   "audio_decoder_factory_template\.h": [
     "+rtc_base/ref_counted_object.h",
-    "+rtc_base/scoped_ref_ptr.h",
   ],
 
   "audio_encoder\.h": [
@@ -215,15 +207,6 @@
 
   "audio_encoder_factory_template\.h": [
     "+rtc_base/ref_counted_object.h",
-    "+rtc_base/scoped_ref_ptr.h",
-  ],
-
-  "builtin_audio_decoder_factory\.h": [
-    "+rtc_base/scoped_ref_ptr.h",
-  ],
-
-  "builtin_audio_encoder_factory\.h": [
-    "+rtc_base/scoped_ref_ptr.h",
   ],
 
   "frame_decryptor_interface\.h": [
@@ -236,13 +219,11 @@
 
   "rtc_stats_collector_callback\.h": [
     "+rtc_base/ref_count.h",
-    "+rtc_base/scoped_ref_ptr.h",
   ],
 
   "rtc_stats_report\.h": [
     "+rtc_base/ref_count.h",
     "+rtc_base/ref_counted_object.h",
-    "+rtc_base/scoped_ref_ptr.h",
   ],
 
   "audioproc_float\.h": [
@@ -281,7 +262,6 @@
 
   "video_encoder_config\.h": [
     "+rtc_base/ref_count.h",
-    "+rtc_base/scoped_ref_ptr.h",
   ],
 
   # .cc files in api/ should not be restricted in what they can #include,
diff --git a/api/audio_codecs/BUILD.gn b/api/audio_codecs/BUILD.gn
index 31fe2be..26c66d1 100644
--- a/api/audio_codecs/BUILD.gn
+++ b/api/audio_codecs/BUILD.gn
@@ -31,6 +31,7 @@
   deps = [
     "..:array_view",
     "..:bitrate_allocation",
+    "..:scoped_refptr",
     "../..:webrtc_common",
     "../../rtc_base:checks",
     "../../rtc_base:deprecation",
@@ -51,6 +52,7 @@
   ]
   deps = [
     ":audio_codecs_api",
+    "..:scoped_refptr",
     "../../rtc_base:rtc_base_approved",
     "L16:audio_decoder_L16",
     "g711:audio_decoder_g711",
@@ -81,6 +83,7 @@
   ]
   deps = [
     ":audio_codecs_api",
+    "..:scoped_refptr",
     "../../rtc_base:rtc_base_approved",
     "L16:audio_encoder_L16",
     "g711:audio_encoder_g711",
diff --git a/api/audio_codecs/audio_decoder_factory_template.h b/api/audio_codecs/audio_decoder_factory_template.h
index e7f1443..f3bc136 100644
--- a/api/audio_codecs/audio_decoder_factory_template.h
+++ b/api/audio_codecs/audio_decoder_factory_template.h
@@ -15,8 +15,8 @@
 #include <vector>
 
 #include "api/audio_codecs/audio_decoder_factory.h"
+#include "api/scoped_refptr.h"
 #include "rtc_base/ref_counted_object.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace webrtc {
 
diff --git a/api/audio_codecs/audio_encoder_factory_template.h b/api/audio_codecs/audio_encoder_factory_template.h
index 01a6a74..74cb053 100644
--- a/api/audio_codecs/audio_encoder_factory_template.h
+++ b/api/audio_codecs/audio_encoder_factory_template.h
@@ -15,8 +15,8 @@
 #include <vector>
 
 #include "api/audio_codecs/audio_encoder_factory.h"
+#include "api/scoped_refptr.h"
 #include "rtc_base/ref_counted_object.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace webrtc {
 
diff --git a/api/audio_codecs/builtin_audio_decoder_factory.h b/api/audio_codecs/builtin_audio_decoder_factory.h
index 3accd4a..8776196 100644
--- a/api/audio_codecs/builtin_audio_decoder_factory.h
+++ b/api/audio_codecs/builtin_audio_decoder_factory.h
@@ -12,7 +12,7 @@
 #define API_AUDIO_CODECS_BUILTIN_AUDIO_DECODER_FACTORY_H_
 
 #include "api/audio_codecs/audio_decoder_factory.h"
-#include "rtc_base/scoped_ref_ptr.h"
+#include "api/scoped_refptr.h"
 
 namespace webrtc {
 
diff --git a/api/audio_codecs/builtin_audio_encoder_factory.h b/api/audio_codecs/builtin_audio_encoder_factory.h
index 3c67dd3..48ebc43 100644
--- a/api/audio_codecs/builtin_audio_encoder_factory.h
+++ b/api/audio_codecs/builtin_audio_encoder_factory.h
@@ -12,7 +12,7 @@
 #define API_AUDIO_CODECS_BUILTIN_AUDIO_ENCODER_FACTORY_H_
 
 #include "api/audio_codecs/audio_encoder_factory.h"
-#include "rtc_base/scoped_ref_ptr.h"
+#include "api/scoped_refptr.h"
 
 namespace webrtc {
 
diff --git a/api/create_peerconnection_factory.cc b/api/create_peerconnection_factory.cc
index cc7541b..0d15e8c 100644
--- a/api/create_peerconnection_factory.cc
+++ b/api/create_peerconnection_factory.cc
@@ -19,6 +19,7 @@
 #include "api/call/call_factory_interface.h"
 #include "api/fec_controller.h"
 #include "api/peer_connection_interface.h"
+#include "api/scoped_refptr.h"
 #include "api/transport/network_control.h"
 #include "api/video_codecs/video_decoder_factory.h"
 #include "api/video_codecs/video_encoder_factory.h"
@@ -28,7 +29,6 @@
 #include "media/engine/webrtc_media_engine.h"
 #include "modules/audio_device/include/audio_device.h"
 #include "modules/audio_processing/include/audio_processing.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/thread.h"
 
 namespace webrtc {
diff --git a/api/create_peerconnection_factory.h b/api/create_peerconnection_factory.h
index 88ecef8..40f1276 100644
--- a/api/create_peerconnection_factory.h
+++ b/api/create_peerconnection_factory.h
@@ -18,9 +18,9 @@
 #include "api/audio_codecs/audio_encoder_factory.h"
 #include "api/fec_controller.h"
 #include "api/peer_connection_interface.h"
+#include "api/scoped_refptr.h"
 #include "api/transport/network_control.h"
 #include "rtc_base/deprecation.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace rtc {
 // TODO(bugs.webrtc.org/9987): Move rtc::Thread to api/ or expose a better
diff --git a/api/media_stream_interface.h b/api/media_stream_interface.h
index af89e9d..b077480 100644
--- a/api/media_stream_interface.h
+++ b/api/media_stream_interface.h
@@ -24,12 +24,12 @@
 
 #include "absl/types/optional.h"
 #include "api/audio_options.h"
+#include "api/scoped_refptr.h"
 #include "api/video/video_frame.h"
 #include "api/video/video_sink_interface.h"
 #include "api/video/video_source_interface.h"
 #include "modules/audio_processing/include/audio_processing_statistics.h"
 #include "rtc_base/ref_count.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace webrtc {
 
diff --git a/api/proxy.h b/api/proxy.h
index b1d9d50..6627aac 100644
--- a/api/proxy.h
+++ b/api/proxy.h
@@ -56,11 +56,11 @@
 #include <string>
 #include <utility>
 
+#include "api/scoped_refptr.h"
 #include "rtc_base/event.h"
 #include "rtc_base/message_handler.h"
 #include "rtc_base/message_queue.h"
 #include "rtc_base/ref_counted_object.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/thread.h"
 
 namespace rtc {
diff --git a/api/rtp_receiver_interface.h b/api/rtp_receiver_interface.h
index e7fa0bf..bc32566 100644
--- a/api/rtp_receiver_interface.h
+++ b/api/rtp_receiver_interface.h
@@ -23,8 +23,8 @@
 #include "api/media_types.h"
 #include "api/proxy.h"
 #include "api/rtp_parameters.h"
+#include "api/scoped_refptr.h"
 #include "rtc_base/ref_count.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace webrtc {
 
diff --git a/api/rtp_sender_interface.h b/api/rtp_sender_interface.h
index 6397938..c04ce69 100644
--- a/api/rtp_sender_interface.h
+++ b/api/rtp_sender_interface.h
@@ -25,8 +25,8 @@
 #include "api/proxy.h"
 #include "api/rtc_error.h"
 #include "api/rtp_parameters.h"
+#include "api/scoped_refptr.h"
 #include "rtc_base/ref_count.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace webrtc {
 
diff --git a/api/rtp_transceiver_interface.h b/api/rtp_transceiver_interface.h
index c62df49..aec0d15 100644
--- a/api/rtp_transceiver_interface.h
+++ b/api/rtp_transceiver_interface.h
@@ -20,8 +20,8 @@
 #include "api/rtp_parameters.h"
 #include "api/rtp_receiver_interface.h"
 #include "api/rtp_sender_interface.h"
+#include "api/scoped_refptr.h"
 #include "rtc_base/ref_count.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace webrtc {
 
diff --git a/api/stats/rtc_stats_collector_callback.h b/api/stats/rtc_stats_collector_callback.h
index 0bc8217..c3e0824 100644
--- a/api/stats/rtc_stats_collector_callback.h
+++ b/api/stats/rtc_stats_collector_callback.h
@@ -11,9 +11,9 @@
 #ifndef API_STATS_RTC_STATS_COLLECTOR_CALLBACK_H_
 #define API_STATS_RTC_STATS_COLLECTOR_CALLBACK_H_
 
+#include "api/scoped_refptr.h"
 #include "api/stats/rtc_stats_report.h"
 #include "rtc_base/ref_count.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace webrtc {
 
diff --git a/api/stats/rtc_stats_report.h b/api/stats/rtc_stats_report.h
index ab4f8f0..2f5b876 100644
--- a/api/stats/rtc_stats_report.h
+++ b/api/stats/rtc_stats_report.h
@@ -18,10 +18,10 @@
 #include <string>
 #include <vector>
 
+#include "api/scoped_refptr.h"
 #include "api/stats/rtc_stats.h"
 #include "rtc_base/ref_count.h"
 #include "rtc_base/ref_counted_object.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/system/rtc_export.h"
 
 namespace webrtc {
diff --git a/api/stats_types.h b/api/stats_types.h
index 7f1160f..0e97eaf 100644
--- a/api/stats_types.h
+++ b/api/stats_types.h
@@ -20,9 +20,9 @@
 #include <string>
 #include <vector>
 
+#include "api/scoped_refptr.h"
 #include "rtc_base/constructor_magic.h"
 #include "rtc_base/ref_count.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/string_encode.h"
 #include "rtc_base/thread_checker.h"
 
diff --git a/api/video/BUILD.gn b/api/video/BUILD.gn
index 27e2096..d5905f5 100644
--- a/api/video/BUILD.gn
+++ b/api/video/BUILD.gn
@@ -33,6 +33,7 @@
 
   deps = [
     "..:array_view",
+    "..:scoped_refptr",
     "../../rtc_base:checks",
     "../../rtc_base:rtc_base_approved",
     "../../rtc_base/system:rtc_export",
@@ -48,6 +49,7 @@
   ]
   deps = [
     ":video_frame",
+    "..:scoped_refptr",
     "../../rtc_base:checks",
     "../../rtc_base:rtc_base",
     "../../rtc_base/memory:aligned_malloc",
@@ -65,6 +67,7 @@
   deps = [
     ":video_frame",
     ":video_frame_i420",
+    "..:scoped_refptr",
     "../../rtc_base:checks",
     "../../rtc_base:rtc_base",
     "../../rtc_base/memory:aligned_malloc",
@@ -211,7 +214,7 @@
   deps = [
     ":video_frame",
     ":video_stream_encoder",
-    "../../rtc_base:ptr_util",
+    "../../api:scoped_refptr",
     "../../video:video_stream_encoder_impl",
     "../video_codecs:video_codecs_api",
     "//third_party/abseil-cpp/absl/memory",
@@ -230,10 +233,10 @@
     ":video_bitrate_allocator",
     ":video_bitrate_allocator_factory",
     "../../:webrtc_common",
+    "../../api:scoped_refptr",
     "../../media:rtc_media_base",
     "../../modules/video_coding:video_coding_utility",
     "../../modules/video_coding:webrtc_vp9_helpers",
-    "../../rtc_base:ptr_util",
     "../../rtc_base/system:fallthrough",
     "../video_codecs:video_codecs_api",
     "//third_party/abseil-cpp/absl/memory",
diff --git a/api/video/DEPS b/api/video/DEPS
index 3dfec07..4bc9a39 100644
--- a/api/video/DEPS
+++ b/api/video/DEPS
@@ -8,21 +8,17 @@
 
   "i010_buffer\.h": [
     "+rtc_base/memory/aligned_malloc.h",
-    "+rtc_base/scoped_ref_ptr.h",
   ],
 
   "i420_buffer\.h": [
     "+rtc_base/memory/aligned_malloc.h",
-    "+rtc_base/scoped_ref_ptr.h",
   ],
 
   "video_frame\.h": [
-    "+rtc_base/scoped_ref_ptr.h",
   ],
 
   "video_frame_buffer\.h": [
     "+rtc_base/ref_count.h",
-    "+rtc_base/scoped_ref_ptr.h",
   ],
 
   "video_stream_decoder_create.cc": [
diff --git a/api/video/i010_buffer.h b/api/video/i010_buffer.h
index 8f354b6..4b35ca3 100644
--- a/api/video/i010_buffer.h
+++ b/api/video/i010_buffer.h
@@ -14,10 +14,10 @@
 #include <stdint.h>
 #include <memory>
 
+#include "api/scoped_refptr.h"
 #include "api/video/video_frame_buffer.h"
 #include "api/video/video_rotation.h"
 #include "rtc_base/memory/aligned_malloc.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace webrtc {
 
diff --git a/api/video/i420_buffer.h b/api/video/i420_buffer.h
index ca290ee..b76a507 100644
--- a/api/video/i420_buffer.h
+++ b/api/video/i420_buffer.h
@@ -14,10 +14,10 @@
 #include <stdint.h>
 #include <memory>
 
+#include "api/scoped_refptr.h"
 #include "api/video/video_frame_buffer.h"
 #include "api/video/video_rotation.h"
 #include "rtc_base/memory/aligned_malloc.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/system/rtc_export.h"
 
 namespace webrtc {
diff --git a/api/video/video_frame.h b/api/video/video_frame.h
index 728d818..de3f0ef 100644
--- a/api/video/video_frame.h
+++ b/api/video/video_frame.h
@@ -14,11 +14,11 @@
 #include <stdint.h>
 
 #include "absl/types/optional.h"
+#include "api/scoped_refptr.h"
 #include "api/video/color_space.h"
 #include "api/video/hdr_metadata.h"
 #include "api/video/video_frame_buffer.h"
 #include "api/video/video_rotation.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/system/rtc_export.h"
 
 namespace webrtc {
diff --git a/api/video/video_frame_buffer.h b/api/video/video_frame_buffer.h
index cdc87ac..7fb603e 100644
--- a/api/video/video_frame_buffer.h
+++ b/api/video/video_frame_buffer.h
@@ -13,8 +13,8 @@
 
 #include <stdint.h>
 
+#include "api/scoped_refptr.h"
 #include "rtc_base/ref_count.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace webrtc {
 
diff --git a/api/video_codecs/BUILD.gn b/api/video_codecs/BUILD.gn
index ad93d40..71cd615 100644
--- a/api/video_codecs/BUILD.gn
+++ b/api/video_codecs/BUILD.gn
@@ -32,6 +32,7 @@
   ]
 
   deps = [
+    "..:scoped_refptr",
     "../..:webrtc_common",
     "../../rtc_base:checks",
     "../../rtc_base:rtc_base_approved",
@@ -59,8 +60,8 @@
 
   deps = [
     ":video_codecs_api",
+    "../../api:scoped_refptr",
     "../../media:rtc_internal_video_codecs",
-    "../../rtc_base:ptr_util",
     "../../rtc_base/system:rtc_export",
     "//third_party/abseil-cpp/absl/memory",
   ]
@@ -79,11 +80,11 @@
 
   deps = [
     ":video_codecs_api",
+    "../../api:scoped_refptr",
     "../../media:rtc_encoder_simulcast_proxy",
     "../../media:rtc_internal_video_codecs",
     "../../media:rtc_media_base",
     "../../rtc_base:checks",
-    "../../rtc_base:ptr_util",
     "../../rtc_base/system:rtc_export",
     "//third_party/abseil-cpp/absl/memory",
     "//third_party/abseil-cpp/absl/strings",
diff --git a/api/video_codecs/test/BUILD.gn b/api/video_codecs/test/BUILD.gn
index acb77cc..b16023c 100644
--- a/api/video_codecs/test/BUILD.gn
+++ b/api/video_codecs/test/BUILD.gn
@@ -23,12 +23,12 @@
       "..:video_codecs_api",
       "../..:mock_video_encoder",
       "../../../:webrtc_common",
+      "../../../api:scoped_refptr",
       "../../../modules:module_api",
       "../../../modules/video_coding:video_codec_interface",
       "../../../modules/video_coding:video_coding_utility",
       "../../../modules/video_coding:webrtc_vp8",
       "../../../rtc_base:checks",
-      "../../../rtc_base:ptr_util",
       "../../../rtc_base:rtc_base_tests_utils",
       "../../../test:field_trial",
       "../../../test:test_support",
diff --git a/api/video_codecs/test/video_encoder_software_fallback_wrapper_unittest.cc b/api/video_codecs/test/video_encoder_software_fallback_wrapper_unittest.cc
index bf08d1c..cdddbeb 100644
--- a/api/video_codecs/test/video_encoder_software_fallback_wrapper_unittest.cc
+++ b/api/video_codecs/test/video_encoder_software_fallback_wrapper_unittest.cc
@@ -16,6 +16,7 @@
 
 #include "absl/memory/memory.h"
 #include "absl/types/optional.h"
+#include "api/scoped_refptr.h"
 #include "api/test/mock_video_encoder.h"
 #include "api/video/encoded_image.h"
 #include "api/video/i420_buffer.h"
@@ -33,7 +34,6 @@
 #include "modules/video_coding/include/video_error_codes.h"
 #include "modules/video_coding/utility/simulcast_rate_allocator.h"
 #include "rtc_base/fake_clock.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "test/field_trial.h"
 #include "test/gmock.h"
 #include "test/gtest.h"
diff --git a/api/video_codecs/video_encoder_config.h b/api/video_codecs/video_encoder_config.h
index 3a35380..78f2db4 100644
--- a/api/video_codecs/video_encoder_config.h
+++ b/api/video_codecs/video_encoder_config.h
@@ -16,10 +16,10 @@
 #include <vector>
 
 #include "absl/types/optional.h"
+#include "api/scoped_refptr.h"
 #include "api/video_codecs/sdp_video_format.h"
 #include "api/video_codecs/video_codec.h"
 #include "rtc_base/ref_count.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace webrtc {
 
diff --git a/audio/BUILD.gn b/audio/BUILD.gn
index 116385e..e4ab39a 100644
--- a/audio/BUILD.gn
+++ b/audio/BUILD.gn
@@ -46,6 +46,7 @@
     "../api:array_view",
     "../api:call_api",
     "../api:libjingle_peerconnection_api",
+    "../api:scoped_refptr",
     "../api:transport_api",
     "../api/audio:aec3_factory",
     "../api/audio:audio_frame_api",
diff --git a/audio/audio_transport_impl.h b/audio/audio_transport_impl.h
index e0aaa5e..4c244a1 100644
--- a/audio/audio_transport_impl.h
+++ b/audio/audio_transport_impl.h
@@ -14,6 +14,7 @@
 #include <vector>
 
 #include "api/audio/audio_mixer.h"
+#include "api/scoped_refptr.h"
 #include "audio/audio_level.h"
 #include "common_audio/resampler/include/push_resampler.h"
 #include "modules/audio_device/include/audio_device.h"
@@ -21,7 +22,6 @@
 #include "modules/audio_processing/typing_detection.h"
 #include "rtc_base/constructor_magic.h"
 #include "rtc_base/critical_section.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/thread_annotations.h"
 
 namespace webrtc {
diff --git a/call/BUILD.gn b/call/BUILD.gn
index 4362fd1..af7f446 100644
--- a/call/BUILD.gn
+++ b/call/BUILD.gn
@@ -33,6 +33,7 @@
     "..:webrtc_common",
     "../api:fec_controller_api",
     "../api:libjingle_peerconnection_api",
+    "../api:scoped_refptr",
     "../api:transport_api",
     "../api/audio:audio_mixer_api",
     "../api/audio_codecs:audio_codecs_api",
diff --git a/call/audio_receive_stream.h b/call/audio_receive_stream.h
index f1aeb88..88a16ed 100644
--- a/call/audio_receive_stream.h
+++ b/call/audio_receive_stream.h
@@ -23,8 +23,8 @@
 #include "api/media_transport_interface.h"
 #include "api/rtp_parameters.h"
 #include "api/rtp_receiver_interface.h"
+#include "api/scoped_refptr.h"
 #include "call/rtp_config.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace webrtc {
 class AudioSinkInterface;
diff --git a/call/audio_send_stream.h b/call/audio_send_stream.h
index 044ec99..08a50c8 100644
--- a/call/audio_send_stream.h
+++ b/call/audio_send_stream.h
@@ -25,9 +25,9 @@
 #include "api/crypto/frame_encryptor_interface.h"
 #include "api/media_transport_interface.h"
 #include "api/rtp_parameters.h"
+#include "api/scoped_refptr.h"
 #include "call/rtp_config.h"
 #include "modules/audio_processing/include/audio_processing_statistics.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace webrtc {
 
diff --git a/call/audio_state.h b/call/audio_state.h
index 967314b..18cbd48 100644
--- a/call/audio_state.h
+++ b/call/audio_state.h
@@ -11,10 +11,10 @@
 #define CALL_AUDIO_STATE_H_
 
 #include "api/audio/audio_mixer.h"
+#include "api/scoped_refptr.h"
 #include "modules/audio_device/include/audio_device.h"
 #include "modules/audio_processing/include/audio_processing.h"
 #include "rtc_base/ref_count.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace webrtc {
 
diff --git a/common_video/BUILD.gn b/common_video/BUILD.gn
index fc36ff8..fbbfd62 100644
--- a/common_video/BUILD.gn
+++ b/common_video/BUILD.gn
@@ -40,6 +40,7 @@
 
   deps = [
     "..:webrtc_common",
+    "../api:scoped_refptr",
     "../api/video:encoded_image",
     "../api/video:video_bitrate_allocation",
     "../api/video:video_bitrate_allocator",
@@ -87,6 +88,7 @@
     deps = [
       ":common_video",
       "../:webrtc_common",
+      "../api:scoped_refptr",
       "../api/units:time_delta",
       "../api/video:video_frame",
       "../api/video:video_frame_i010",
diff --git a/common_video/i420_buffer_pool_unittest.cc b/common_video/i420_buffer_pool_unittest.cc
index 5ebf1bc..debe637 100644
--- a/common_video/i420_buffer_pool_unittest.cc
+++ b/common_video/i420_buffer_pool_unittest.cc
@@ -11,10 +11,10 @@
 #include <stdint.h>
 #include <string.h>
 
+#include "api/scoped_refptr.h"
 #include "api/video/i420_buffer.h"
 #include "api/video/video_frame_buffer.h"
 #include "common_video/include/i420_buffer_pool.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "test/gtest.h"
 
 namespace webrtc {
diff --git a/common_video/include/i420_buffer_pool.h b/common_video/include/i420_buffer_pool.h
index 8b0f08c..0beb3a5 100644
--- a/common_video/include/i420_buffer_pool.h
+++ b/common_video/include/i420_buffer_pool.h
@@ -14,10 +14,10 @@
 #include <stddef.h>
 #include <list>
 
+#include "api/scoped_refptr.h"
 #include "api/video/i420_buffer.h"
 #include "rtc_base/race_checker.h"
 #include "rtc_base/ref_counted_object.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace webrtc {
 
diff --git a/common_video/include/video_frame_buffer.h b/common_video/include/video_frame_buffer.h
index f35f107..bc70f34 100644
--- a/common_video/include/video_frame_buffer.h
+++ b/common_video/include/video_frame_buffer.h
@@ -13,10 +13,10 @@
 
 #include <stdint.h>
 
+#include "api/scoped_refptr.h"
 #include "api/video/video_frame_buffer.h"
 #include "rtc_base/callback.h"
 #include "rtc_base/ref_counted_object.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace webrtc {
 
diff --git a/common_video/libyuv/include/webrtc_libyuv.h b/common_video/libyuv/include/webrtc_libyuv.h
index d324834..340fd3d 100644
--- a/common_video/libyuv/include/webrtc_libyuv.h
+++ b/common_video/libyuv/include/webrtc_libyuv.h
@@ -19,10 +19,10 @@
 #include <stdio.h>
 #include <vector>
 
+#include "api/scoped_refptr.h"
 #include "api/video/video_frame.h"
 #include "api/video/video_frame_buffer.h"
 #include "common_types.h"  // NOLINT(build/include)
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace webrtc {
 
diff --git a/examples/BUILD.gn b/examples/BUILD.gn
index 7676bfa..f5577b6 100644
--- a/examples/BUILD.gn
+++ b/examples/BUILD.gn
@@ -504,6 +504,7 @@
 
       deps = [
         "../api:libjingle_peerconnection_api",
+        "../api:scoped_refptr",
         "../api/audio_codecs:builtin_audio_decoder_factory",
         "../api/audio_codecs:builtin_audio_encoder_factory",
         "../api/video:builtin_video_bitrate_allocator_factory",
@@ -692,6 +693,7 @@
       "../api:audio_options_api",
       "../api:create_peerconnection_factory",
       "../api:libjingle_peerconnection_api",
+      "../api:scoped_refptr",
       "../api/audio:audio_mixer_api",
       "../api/audio_codecs:audio_codecs_api",
       "../api/video:video_frame_i420",
diff --git a/examples/androidnativeapi/BUILD.gn b/examples/androidnativeapi/BUILD.gn
index 22f70c1..4c1abac 100644
--- a/examples/androidnativeapi/BUILD.gn
+++ b/examples/androidnativeapi/BUILD.gn
@@ -48,6 +48,7 @@
 
     deps = [
       ":generated_jni",
+      "../../api:scoped_refptr",
       "//api:libjingle_peerconnection_api",
       "//api/audio_codecs:builtin_audio_decoder_factory",
       "//api/audio_codecs:builtin_audio_encoder_factory",
diff --git a/examples/androidnativeapi/jni/android_call_client.h b/examples/androidnativeapi/jni/android_call_client.h
index 5ab61f4..979df7a 100644
--- a/examples/androidnativeapi/jni/android_call_client.h
+++ b/examples/androidnativeapi/jni/android_call_client.h
@@ -17,8 +17,8 @@
 #include <string>
 
 #include "api/peer_connection_interface.h"
+#include "api/scoped_refptr.h"
 #include "rtc_base/critical_section.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/thread_checker.h"
 #include "sdk/android/native_api/jni/scoped_java_ref.h"
 #include "sdk/android/native_api/video/video_source.h"
diff --git a/examples/objcnativeapi/objc/objc_call_client.h b/examples/objcnativeapi/objc/objc_call_client.h
index 43a48c5..986014f 100644
--- a/examples/objcnativeapi/objc/objc_call_client.h
+++ b/examples/objcnativeapi/objc/objc_call_client.h
@@ -15,8 +15,8 @@
 #include <string>
 
 #include "api/peer_connection_interface.h"
+#include "api/scoped_refptr.h"
 #include "rtc_base/critical_section.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/thread_checker.h"
 
 @class RTCVideoCapturer;
diff --git a/examples/peerconnection/client/linux/main.cc b/examples/peerconnection/client/linux/main.cc
index 74fc17a..7c07314 100644
--- a/examples/peerconnection/client/linux/main.cc
+++ b/examples/peerconnection/client/linux/main.cc
@@ -12,6 +12,7 @@
 #include <gtk/gtk.h>
 #include <stdio.h>
 
+#include "api/scoped_refptr.h"
 #include "examples/peerconnection/client/conductor.h"
 #include "examples/peerconnection/client/flag_defs.h"
 #include "examples/peerconnection/client/linux/main_wnd.h"
@@ -20,7 +21,6 @@
 #include "rtc_base/message_queue.h"
 #include "rtc_base/physical_socket_server.h"
 #include "rtc_base/ref_counted_object.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/ssl_adapter.h"
 #include "rtc_base/thread.h"
 #include "system_wrappers/include/field_trial.h"
diff --git a/examples/peerconnection/client/linux/main_wnd.h b/examples/peerconnection/client/linux/main_wnd.h
index a30ec27..2fd3de5 100644
--- a/examples/peerconnection/client/linux/main_wnd.h
+++ b/examples/peerconnection/client/linux/main_wnd.h
@@ -16,11 +16,11 @@
 #include <string>
 
 #include "api/media_stream_interface.h"
+#include "api/scoped_refptr.h"
 #include "api/video/video_frame.h"
 #include "api/video/video_sink_interface.h"
 #include "examples/peerconnection/client/main_wnd.h"
 #include "examples/peerconnection/client/peer_connection_client.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 // Forward declarations.
 typedef struct _GtkWidget GtkWidget;
diff --git a/logging/BUILD.gn b/logging/BUILD.gn
index ed1a916..0e2bd51 100644
--- a/logging/BUILD.gn
+++ b/logging/BUILD.gn
@@ -39,7 +39,7 @@
 
   deps = [
     "../api:libjingle_logging_api",
-    "../rtc_base:ptr_util",
+    "../api:scoped_refptr",
     "../rtc_base:rtc_base_approved",
     "//third_party/abseil-cpp/absl/memory",
   ]
@@ -65,7 +65,7 @@
 
   deps = [
     ":rtc_event_log_api",
-    "../rtc_base:ptr_util",
+    "../api:scoped_refptr",
     "//third_party/abseil-cpp/absl/memory",
   ]
 }
@@ -85,9 +85,9 @@
   deps = [
     ":rtc_event_log_api",
     ":rtc_stream_config",
+    "../api:scoped_refptr",
     "../modules/audio_coding:audio_network_adaptor_config",
     "../rtc_base:checks",
-    "../rtc_base:ptr_util",
     "//third_party/abseil-cpp/absl/memory",
   ]
 }
@@ -108,8 +108,8 @@
 
   deps = [
     ":rtc_event_log_api",
+    "../api:scoped_refptr",
     "../modules/remote_bitrate_estimator:remote_bitrate_estimator",
-    "../rtc_base:ptr_util",
     "//third_party/abseil-cpp/absl/memory",
   ]
 }
@@ -129,9 +129,9 @@
   deps = [
     ":rtc_event_log_api",
     "../api:array_view",
+    "../api:scoped_refptr",
     "../modules/rtp_rtcp:rtp_rtcp_format",
     "../rtc_base:checks",
-    "../rtc_base:ptr_util",
     "../rtc_base:rtc_base_approved",
     "//third_party/abseil-cpp/absl/memory",
   ]
@@ -148,8 +148,8 @@
   deps = [
     ":rtc_event_log_api",
     ":rtc_stream_config",
+    "../api:scoped_refptr",
     "../rtc_base:checks",
-    "../rtc_base:ptr_util",
     "//third_party/abseil-cpp/absl/memory",
   ]
 }
diff --git a/media/BUILD.gn b/media/BUILD.gn
index 7d2c5f9..4c4a9e1 100644
--- a/media/BUILD.gn
+++ b/media/BUILD.gn
@@ -78,6 +78,7 @@
   deps = [
     "../api:array_view",
     "../api:audio_options_api",
+    "../api:scoped_refptr",
     "../rtc_base:checks",
     "../rtc_base:rtc_base_approved",
     "../rtc_base:rtc_task_queue",
@@ -190,6 +191,7 @@
     "engine/simulcast_encoder_adapter.h",
   ]
   deps = [
+    "../api:scoped_refptr",
     "../api/video:video_codec_constants",
     "../api/video:video_frame",
     "../api/video:video_frame_i420",
@@ -302,6 +304,7 @@
   defines = []
   libs = []
   deps = [
+    "../api:scoped_refptr",
     "../api/video:video_bitrate_allocation",
     "../api/video:video_bitrate_allocator_factory",
     "../modules/audio_processing:api",
@@ -460,6 +463,7 @@
       ":rtc_audio_video",
       ":rtc_simulcast_encoder_adapter",
       "../api:libjingle_peerconnection_api",
+      "../api:scoped_refptr",
       "../api/video:encoded_image",
       "../api/video:video_frame_i420",
       "../call:video_stream_api",
@@ -564,6 +568,7 @@
       ":rtc_constants",
       ":rtc_data",
       "../:webrtc_common",
+      "../api:scoped_refptr",
       "../api/test/video:function_video_factory",
       "../api/units:time_delta",
       "../api/video:video_frame_i420",
diff --git a/media/base/adapted_video_track_source.cc b/media/base/adapted_video_track_source.cc
index 531fa45..4ae0d15 100644
--- a/media/base/adapted_video_track_source.cc
+++ b/media/base/adapted_video_track_source.cc
@@ -10,11 +10,11 @@
 
 #include "media/base/adapted_video_track_source.h"
 
+#include "api/scoped_refptr.h"
 #include "api/video/i420_buffer.h"
 #include "api/video/video_frame_buffer.h"
 #include "api/video/video_rotation.h"
 #include "rtc_base/checks.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/time_utils.h"
 
 namespace rtc {
diff --git a/media/base/fake_frame_source.cc b/media/base/fake_frame_source.cc
index be8f33f..8a05536 100644
--- a/media/base/fake_frame_source.cc
+++ b/media/base/fake_frame_source.cc
@@ -10,10 +10,10 @@
 
 #include "media/base/fake_frame_source.h"
 
+#include "api/scoped_refptr.h"
 #include "api/video/i420_buffer.h"
 #include "api/video/video_frame_buffer.h"
 #include "rtc_base/checks.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/time_utils.h"
 
 namespace cricket {
diff --git a/media/base/fake_video_capturer.cc b/media/base/fake_video_capturer.cc
index 7535b16..84bb032 100644
--- a/media/base/fake_video_capturer.cc
+++ b/media/base/fake_video_capturer.cc
@@ -14,11 +14,11 @@
 #include <cstdint>
 
 #include "absl/memory/memory.h"
+#include "api/scoped_refptr.h"
 #include "api/video/i420_buffer.h"
 #include "api/video/video_frame_buffer.h"
 #include "rtc_base/arraysize.h"
 #include "rtc_base/checks.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/time_utils.h"
 
 namespace cricket {
diff --git a/media/base/fake_video_renderer.h b/media/base/fake_video_renderer.h
index 4ffa91e..171c0e3 100644
--- a/media/base/fake_video_renderer.h
+++ b/media/base/fake_video_renderer.h
@@ -13,12 +13,12 @@
 
 #include <stdint.h>
 
+#include "api/scoped_refptr.h"
 #include "api/video/video_frame.h"
 #include "api/video/video_frame_buffer.h"
 #include "api/video/video_rotation.h"
 #include "api/video/video_sink_interface.h"
 #include "rtc_base/critical_section.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace cricket {
 
diff --git a/media/base/video_broadcaster.h b/media/base/video_broadcaster.h
index a99e044..20111bc 100644
--- a/media/base/video_broadcaster.h
+++ b/media/base/video_broadcaster.h
@@ -11,11 +11,11 @@
 #ifndef MEDIA_BASE_VIDEO_BROADCASTER_H_
 #define MEDIA_BASE_VIDEO_BROADCASTER_H_
 
+#include "api/scoped_refptr.h"
 #include "api/video/video_frame_buffer.h"
 #include "api/video/video_source_interface.h"
 #include "media/base/video_source_base.h"
 #include "rtc_base/critical_section.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/thread_annotations.h"
 #include "rtc_base/thread_checker.h"
 
diff --git a/media/base/video_capturer.cc b/media/base/video_capturer.cc
index 76c0047..b51f4d8 100644
--- a/media/base/video_capturer.cc
+++ b/media/base/video_capturer.cc
@@ -14,13 +14,13 @@
 
 #include <cstdint>
 
+#include "api/scoped_refptr.h"
 #include "api/video/i420_buffer.h"
 #include "api/video/video_frame.h"
 #include "api/video/video_frame_buffer.h"
 #include "api/video/video_rotation.h"
 #include "rtc_base/checks.h"
 #include "rtc_base/logging.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/time_utils.h"
 
 namespace cricket {
diff --git a/media/engine/apm_helpers_unittest.cc b/media/engine/apm_helpers_unittest.cc
index fa5b4d3..5b0ed23 100644
--- a/media/engine/apm_helpers_unittest.cc
+++ b/media/engine/apm_helpers_unittest.cc
@@ -10,8 +10,8 @@
 
 #include "media/engine/apm_helpers.h"
 
+#include "api/scoped_refptr.h"
 #include "modules/audio_processing/include/audio_processing.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "test/gmock.h"
 #include "test/gtest.h"
 
diff --git a/media/engine/simulcast_encoder_adapter.cc b/media/engine/simulcast_encoder_adapter.cc
index 895489c..f6d0f24 100644
--- a/media/engine/simulcast_encoder_adapter.cc
+++ b/media/engine/simulcast_encoder_adapter.cc
@@ -17,6 +17,7 @@
 #include <string>
 #include <utility>
 
+#include "api/scoped_refptr.h"
 #include "api/video/i420_buffer.h"
 #include "api/video/video_codec_constants.h"
 #include "api/video/video_frame_buffer.h"
@@ -26,7 +27,6 @@
 #include "modules/video_coding/utility/simulcast_rate_allocator.h"
 #include "rtc_base/atomic_ops.h"
 #include "rtc_base/checks.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "system_wrappers/include/field_trial.h"
 #include "third_party/libyuv/include/libyuv/scale.h"
 
diff --git a/media/engine/webrtc_voice_engine.h b/media/engine/webrtc_voice_engine.h
index 335c47d..4ee61a1 100644
--- a/media/engine/webrtc_voice_engine.h
+++ b/media/engine/webrtc_voice_engine.h
@@ -18,6 +18,7 @@
 
 #include "api/audio_codecs/audio_encoder_factory.h"
 #include "api/rtp_receiver_interface.h"
+#include "api/scoped_refptr.h"
 #include "call/audio_state.h"
 #include "call/call.h"
 #include "media/base/rtp_utils.h"
@@ -28,7 +29,6 @@
 #include "rtc_base/constructor_magic.h"
 #include "rtc_base/experiments/audio_allocation_settings.h"
 #include "rtc_base/network_route.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/task_queue.h"
 #include "rtc_base/thread_checker.h"
 
diff --git a/media/engine/webrtc_voice_engine_unittest.cc b/media/engine/webrtc_voice_engine_unittest.cc
index 8204010..d05feb5 100644
--- a/media/engine/webrtc_voice_engine_unittest.cc
+++ b/media/engine/webrtc_voice_engine_unittest.cc
@@ -15,6 +15,7 @@
 #include "api/audio_codecs/builtin_audio_decoder_factory.h"
 #include "api/audio_codecs/builtin_audio_encoder_factory.h"
 #include "api/rtp_parameters.h"
+#include "api/scoped_refptr.h"
 #include "call/call.h"
 #include "logging/rtc_event_log/rtc_event_log.h"
 #include "media/base/fake_media_engine.h"
@@ -29,7 +30,6 @@
 #include "rtc_base/arraysize.h"
 #include "rtc_base/byte_order.h"
 #include "rtc_base/numerics/safe_conversions.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "test/field_trial.h"
 #include "test/gtest.h"
 #include "test/mock_audio_decoder_factory.h"
diff --git a/modules/audio_coding/BUILD.gn b/modules/audio_coding/BUILD.gn
index 074ca93..2bc9635 100644
--- a/modules/audio_coding/BUILD.gn
+++ b/modules/audio_coding/BUILD.gn
@@ -391,6 +391,7 @@
   deps = [
     ":isac_bwinfo",
     "../..:webrtc_common",
+    "../../api:scoped_refptr",
     "../../api/audio_codecs:audio_codecs_api",
     "../../rtc_base:checks",
     "../../rtc_base:rtc_base_approved",
@@ -984,6 +985,7 @@
     "../..:webrtc_common",
     "../../api:array_view",
     "../../api:libjingle_peerconnection_api",
+    "../../api:scoped_refptr",
     "../../api/audio:audio_frame_api",
     "../../api/audio_codecs:audio_codecs_api",
     "../../common_audio",
@@ -1364,6 +1366,7 @@
     defines = audio_coding_defines
 
     deps = audio_coding_deps + [
+             "../../api:scoped_refptr",
              "..:module_api",
              ":audio_coding",
              "../../api/audio_codecs:audio_codecs_api",
diff --git a/modules/audio_coding/acm2/acm_receive_test.h b/modules/audio_coding/acm2/acm_receive_test.h
index 23e48a0..fce3d6b 100644
--- a/modules/audio_coding/acm2/acm_receive_test.h
+++ b/modules/audio_coding/acm2/acm_receive_test.h
@@ -16,8 +16,8 @@
 #include <string>
 
 #include "api/audio_codecs/audio_decoder_factory.h"
+#include "api/scoped_refptr.h"
 #include "rtc_base/constructor_magic.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "system_wrappers/include/clock.h"
 
 namespace webrtc {
diff --git a/modules/audio_coding/codecs/isac/audio_decoder_isac_t.h b/modules/audio_coding/codecs/isac/audio_decoder_isac_t.h
index ab9a6ed..7cadd91 100644
--- a/modules/audio_coding/codecs/isac/audio_decoder_isac_t.h
+++ b/modules/audio_coding/codecs/isac/audio_decoder_isac_t.h
@@ -15,9 +15,9 @@
 
 #include "absl/types/optional.h"
 #include "api/audio_codecs/audio_decoder.h"
+#include "api/scoped_refptr.h"
 #include "modules/audio_coding/codecs/isac/locked_bandwidth_info.h"
 #include "rtc_base/constructor_magic.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace webrtc {
 
diff --git a/modules/audio_coding/codecs/isac/audio_encoder_isac_t.h b/modules/audio_coding/codecs/isac/audio_encoder_isac_t.h
index 91eb1fd..c6ef795 100644
--- a/modules/audio_coding/codecs/isac/audio_encoder_isac_t.h
+++ b/modules/audio_coding/codecs/isac/audio_encoder_isac_t.h
@@ -14,9 +14,9 @@
 #include <vector>
 
 #include "api/audio_codecs/audio_encoder.h"
+#include "api/scoped_refptr.h"
 #include "modules/audio_coding/codecs/isac/locked_bandwidth_info.h"
 #include "rtc_base/constructor_magic.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace webrtc {
 
diff --git a/modules/audio_coding/neteq/decoder_database.h b/modules/audio_coding/neteq/decoder_database.h
index 1992272..e0a3fe3 100644
--- a/modules/audio_coding/neteq/decoder_database.h
+++ b/modules/audio_coding/neteq/decoder_database.h
@@ -17,10 +17,10 @@
 
 #include "api/audio_codecs/audio_decoder_factory.h"
 #include "api/audio_codecs/audio_format.h"
+#include "api/scoped_refptr.h"
 #include "modules/audio_coding/codecs/cng/webrtc_cng.h"
 #include "modules/audio_coding/neteq/packet.h"
 #include "rtc_base/constructor_magic.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace webrtc {
 
diff --git a/modules/audio_coding/neteq/include/neteq.h b/modules/audio_coding/neteq/include/neteq.h
index d4e8423..afa52d4 100644
--- a/modules/audio_coding/neteq/include/neteq.h
+++ b/modules/audio_coding/neteq/include/neteq.h
@@ -22,9 +22,9 @@
 #include "api/audio_codecs/audio_decoder.h"
 #include "api/audio_codecs/audio_format.h"
 #include "api/rtp_headers.h"
+#include "api/scoped_refptr.h"
 #include "modules/audio_coding/neteq/defines.h"
 #include "rtc_base/constructor_magic.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace webrtc {
 
diff --git a/modules/audio_device/BUILD.gn b/modules/audio_device/BUILD.gn
index 0f9d995..f982196 100644
--- a/modules/audio_device/BUILD.gn
+++ b/modules/audio_device/BUILD.gn
@@ -98,6 +98,7 @@
     "include/audio_device_defines.h",
   ]
   deps = [
+    "../../api:scoped_refptr",
     "../../rtc_base:checks",
     "../../rtc_base:deprecation",
     "../../rtc_base:rtc_base_approved",
@@ -198,6 +199,7 @@
       ":audio_device_api",
       ":audio_device_buffer",
       ":windows_core_audio_utility",
+      "../../api:scoped_refptr",
       "../../rtc_base:checks",
       "../../rtc_base:rtc_base_approved",
       "//third_party/abseil-cpp/absl/memory",
@@ -216,6 +218,7 @@
     ":audio_device_default",
     ":audio_device_generic",
     "../../api:array_view",
+    "../../api:scoped_refptr",
     "../../common_audio",
     "../../common_audio:common_audio_c",
     "../../rtc_base:checks",
@@ -424,6 +427,7 @@
         ":audio_device_impl",
         ":audio_device_ios_objc",
         ":mock_audio_device",
+        "../../api:scoped_refptr",
         "../../rtc_base:rtc_base_approved",
         "../../sdk:audio_objc",
         "../../system_wrappers",
@@ -451,6 +455,7 @@
       ":audio_device_impl",
       ":mock_audio_device",
       "../../api:array_view",
+      "../../api:scoped_refptr",
       "../../common_audio",
       "../../rtc_base:checks",
       "../../rtc_base:rtc_base_approved",
diff --git a/modules/audio_device/android/audio_device_unittest.cc b/modules/audio_device/android/audio_device_unittest.cc
index 350eae9..6f899ee 100644
--- a/modules/audio_device/android/audio_device_unittest.cc
+++ b/modules/audio_device/android/audio_device_unittest.cc
@@ -16,6 +16,7 @@
 #include <string>
 #include <vector>
 
+#include "api/scoped_refptr.h"
 #include "modules/audio_device/android/audio_common.h"
 #include "modules/audio_device/android/audio_manager.h"
 #include "modules/audio_device/android/build_info.h"
@@ -27,7 +28,6 @@
 #include "rtc_base/critical_section.h"
 #include "rtc_base/event.h"
 #include "rtc_base/format_macros.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/time_utils.h"
 #include "test/gmock.h"
 #include "test/gtest.h"
diff --git a/modules/audio_device/audio_device_impl.cc b/modules/audio_device/audio_device_impl.cc
index e44a62d..8bea256 100644
--- a/modules/audio_device/audio_device_impl.cc
+++ b/modules/audio_device/audio_device_impl.cc
@@ -12,12 +12,12 @@
 
 #include <stddef.h>
 
+#include "api/scoped_refptr.h"
 #include "modules/audio_device/audio_device_config.h"  // IWYU pragma: keep
 #include "modules/audio_device/audio_device_generic.h"
 #include "rtc_base/checks.h"
 #include "rtc_base/logging.h"
 #include "rtc_base/ref_counted_object.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "system_wrappers/include/metrics.h"
 
 #if defined(_WIN32)
diff --git a/modules/audio_device/audio_device_unittest.cc b/modules/audio_device/audio_device_unittest.cc
index f0ede1b..9fcc4d8 100644
--- a/modules/audio_device/audio_device_unittest.cc
+++ b/modules/audio_device/audio_device_unittest.cc
@@ -16,6 +16,7 @@
 #include "absl/memory/memory.h"
 #include "absl/types/optional.h"
 #include "api/array_view.h"
+#include "api/scoped_refptr.h"
 #include "modules/audio_device/audio_device_impl.h"
 #include "modules/audio_device/include/audio_device.h"
 #include "modules/audio_device/include/mock_audio_transport.h"
@@ -25,7 +26,6 @@
 #include "rtc_base/logging.h"
 #include "rtc_base/numerics/safe_conversions.h"
 #include "rtc_base/race_checker.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/thread_annotations.h"
 #include "rtc_base/thread_checker.h"
 #include "rtc_base/time_utils.h"
diff --git a/modules/audio_device/include/audio_device.h b/modules/audio_device/include/audio_device.h
index 1afb4ee..71a1932 100644
--- a/modules/audio_device/include/audio_device.h
+++ b/modules/audio_device/include/audio_device.h
@@ -11,9 +11,9 @@
 #ifndef MODULES_AUDIO_DEVICE_INCLUDE_AUDIO_DEVICE_H_
 #define MODULES_AUDIO_DEVICE_INCLUDE_AUDIO_DEVICE_H_
 
+#include "api/scoped_refptr.h"
 #include "modules/audio_device/include/audio_device_defines.h"
 #include "rtc_base/ref_count.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace webrtc {
 
diff --git a/modules/audio_device/include/audio_device_data_observer.h b/modules/audio_device/include/audio_device_data_observer.h
index 67ef98f..270aea8 100644
--- a/modules/audio_device/include/audio_device_data_observer.h
+++ b/modules/audio_device/include/audio_device_data_observer.h
@@ -14,8 +14,8 @@
 #include <stddef.h>
 #include <stdint.h>
 
+#include "api/scoped_refptr.h"
 #include "modules/audio_device/include/audio_device.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace webrtc {
 
diff --git a/modules/audio_device/include/test_audio_device.h b/modules/audio_device/include/test_audio_device.h
index 6fe1c1a..d12af87 100644
--- a/modules/audio_device/include/test_audio_device.h
+++ b/modules/audio_device/include/test_audio_device.h
@@ -16,12 +16,12 @@
 #include <string>
 
 #include "api/array_view.h"
+#include "api/scoped_refptr.h"
 #include "modules/audio_device/include/audio_device.h"
 #include "modules/audio_device/include/audio_device_defines.h"
 #include "rtc_base/buffer.h"
 #include "rtc_base/event.h"
 #include "rtc_base/platform_file.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace webrtc {
 
diff --git a/modules/audio_device/ios/audio_device_unittest_ios.mm b/modules/audio_device/ios/audio_device_unittest_ios.mm
index c46a853..74cfcc2 100644
--- a/modules/audio_device/ios/audio_device_unittest_ios.mm
+++ b/modules/audio_device/ios/audio_device_unittest_ios.mm
@@ -16,6 +16,7 @@
 #include <string>
 #include <vector>
 
+#include "api/scoped_refptr.h"
 #include "modules/audio_device/audio_device_impl.h"
 #include "modules/audio_device/include/audio_device.h"
 #include "modules/audio_device/include/mock_audio_transport.h"
@@ -25,7 +26,6 @@
 #include "rtc_base/event.h"
 #include "rtc_base/format_macros.h"
 #include "rtc_base/logging.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/time_utils.h"
 #include "test/gmock.h"
 #include "test/gtest.h"
diff --git a/modules/audio_device/win/audio_device_core_win.h b/modules/audio_device/win/audio_device_core_win.h
index 9945552..3bc1b0c 100644
--- a/modules/audio_device/win/audio_device_core_win.h
+++ b/modules/audio_device/win/audio_device_core_win.h
@@ -26,8 +26,8 @@
 #include <mediaobj.h>     // IMediaObject
 #include <mmdeviceapi.h>  // MMDevice
 
+#include "api/scoped_refptr.h"
 #include "rtc_base/critical_section.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 // Use Multimedia Class Scheduler Service (MMCSS) to boost the thread priority
 #pragma comment(lib, "avrt.lib")
diff --git a/modules/audio_device/win/audio_device_module_win.h b/modules/audio_device/win/audio_device_module_win.h
index e4c5e56..112e5cc 100644
--- a/modules/audio_device/win/audio_device_module_win.h
+++ b/modules/audio_device/win/audio_device_module_win.h
@@ -14,8 +14,8 @@
 #include <memory>
 #include <string>
 
+#include "api/scoped_refptr.h"
 #include "modules/audio_device/include/audio_device.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace webrtc {
 
diff --git a/modules/audio_mixer/BUILD.gn b/modules/audio_mixer/BUILD.gn
index f935e83..3979136 100644
--- a/modules/audio_mixer/BUILD.gn
+++ b/modules/audio_mixer/BUILD.gn
@@ -38,6 +38,7 @@
   deps = [
     ":audio_frame_manipulator",
     "../../api:array_view",
+    "../../api:scoped_refptr",
     "../../api/audio:audio_frame_api",
     "../../api/audio:audio_mixer_api",
     "../../audio/utility:audio_frame_operations",
diff --git a/modules/audio_mixer/audio_mixer_impl.h b/modules/audio_mixer/audio_mixer_impl.h
index 94361c7..c38aff2 100644
--- a/modules/audio_mixer/audio_mixer_impl.h
+++ b/modules/audio_mixer/audio_mixer_impl.h
@@ -17,12 +17,12 @@
 
 #include "api/audio/audio_frame.h"
 #include "api/audio/audio_mixer.h"
+#include "api/scoped_refptr.h"
 #include "modules/audio_mixer/frame_combiner.h"
 #include "modules/audio_mixer/output_rate_calculator.h"
 #include "rtc_base/constructor_magic.h"
 #include "rtc_base/critical_section.h"
 #include "rtc_base/race_checker.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/thread_annotations.h"
 
 namespace webrtc {
diff --git a/modules/audio_processing/BUILD.gn b/modules/audio_processing/BUILD.gn
index ab5a704..46869d0 100644
--- a/modules/audio_processing/BUILD.gn
+++ b/modules/audio_processing/BUILD.gn
@@ -50,11 +50,11 @@
     ":audio_processing_statistics",
     ":config",
     ":gain_control_interface",
+    "../../api:scoped_refptr",
     "../../api/audio:aec3_config",
     "../../api/audio:echo_control",
     "../../rtc_base:deprecation",
     "../../rtc_base:macromagic",
-    "../../rtc_base:ptr_util",
     "../../rtc_base:rtc_base_approved",
     "../../rtc_base/system:rtc_export",
     "//third_party/abseil-cpp/absl/types:optional",
@@ -416,6 +416,7 @@
       ":mocks",
       "../..:webrtc_common",
       "../../api:array_view",
+      "../../api:scoped_refptr",
       "../../api/audio:aec3_config",
       "../../api/audio:aec3_factory",
       "../../common_audio:common_audio",
diff --git a/modules/audio_processing/agc2/rnn_vad/BUILD.gn b/modules/audio_processing/agc2/rnn_vad/BUILD.gn
index d1edece..b26aef0 100644
--- a/modules/audio_processing/agc2/rnn_vad/BUILD.gn
+++ b/modules/audio_processing/agc2/rnn_vad/BUILD.gn
@@ -52,8 +52,8 @@
     ]
     deps = [
       "../../../../api:array_view",
+      "../../../../api:scoped_refptr",
       "../../../../rtc_base:checks",
-      "../../../../rtc_base:ptr_util",
       "../../../../test:fileutils",
       "../../../../test:test_support",
       "//third_party/abseil-cpp/absl/memory",
diff --git a/modules/audio_processing/audio_processing_impl_unittest.cc b/modules/audio_processing/audio_processing_impl_unittest.cc
index c511cb3..abceeec 100644
--- a/modules/audio_processing/audio_processing_impl_unittest.cc
+++ b/modules/audio_processing/audio_processing_impl_unittest.cc
@@ -13,12 +13,12 @@
 #include <memory>
 
 #include "absl/memory/memory.h"
+#include "api/scoped_refptr.h"
 #include "modules/audio_processing/include/audio_processing.h"
 #include "modules/audio_processing/test/echo_control_mock.h"
 #include "modules/audio_processing/test/test_utils.h"
 #include "rtc_base/checks.h"
 #include "rtc_base/ref_counted_object.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "test/gmock.h"
 #include "test/gtest.h"
 
diff --git a/modules/audio_processing/include/audio_processing.h b/modules/audio_processing/include/audio_processing.h
index afe5f6c..aba0a13 100644
--- a/modules/audio_processing/include/audio_processing.h
+++ b/modules/audio_processing/include/audio_processing.h
@@ -25,6 +25,7 @@
 #include "absl/types/optional.h"
 #include "api/audio/echo_canceller3_config.h"
 #include "api/audio/echo_control.h"
+#include "api/scoped_refptr.h"
 #include "modules/audio_processing/include/audio_generator.h"
 #include "modules/audio_processing/include/audio_processing_statistics.h"
 #include "modules/audio_processing/include/config.h"
@@ -33,7 +34,6 @@
 #include "rtc_base/deprecation.h"
 #include "rtc_base/platform_file.h"
 #include "rtc_base/ref_count.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/system/rtc_export.h"
 
 namespace webrtc {
diff --git a/modules/congestion_controller/BUILD.gn b/modules/congestion_controller/BUILD.gn
index 7bd049e..7c683d4 100644
--- a/modules/congestion_controller/BUILD.gn
+++ b/modules/congestion_controller/BUILD.gn
@@ -37,6 +37,7 @@
     ":transport_feedback",
     "..:module_api",
     "../..:webrtc_common",
+    "../../api:scoped_refptr",
     "../../api/transport:field_trial_based_config",
     "../../api/transport:network_control",
     "../../api/transport:webrtc_key_value_config",
@@ -44,7 +45,6 @@
     "../../api/units:timestamp",
     "../../rtc_base:checks",
     "../../rtc_base:deprecation",
-    "../../rtc_base:ptr_util",
     "../../rtc_base:rate_limiter",
     "../../rtc_base/experiments:rate_control_settings",
     "../../rtc_base/network:sent_packet",
diff --git a/modules/desktop_capture/BUILD.gn b/modules/desktop_capture/BUILD.gn
index 0677a79..ca13924 100644
--- a/modules/desktop_capture/BUILD.gn
+++ b/modules/desktop_capture/BUILD.gn
@@ -30,6 +30,7 @@
   ]
 
   deps = [
+    "../../api:scoped_refptr",
     "../../rtc_base:checks",
     "../../rtc_base/system:rtc_export",
     "//third_party/abseil-cpp/absl/memory",
@@ -46,6 +47,7 @@
 
     sources = []
     deps = [
+      "../../api:scoped_refptr",
       "../../rtc_base:checks",
       "//third_party/abseil-cpp/absl/memory",
     ]
@@ -131,6 +133,7 @@
 
     deps = [
       ":primitives",
+      "../../api:scoped_refptr",
       "../../rtc_base:checks",
       "../../rtc_base:rtc_base_approved",
       "../../system_wrappers",
@@ -236,6 +239,7 @@
     deps = [
       ":desktop_capture_generic",
       ":primitives",
+      "../../api:scoped_refptr",
       "../../rtc_base:checks",
       "../../rtc_base:rtc_base",
       "../../rtc_base:rtc_base_approved",
@@ -425,6 +429,7 @@
   deps = [
     ":primitives",
     "../../api:refcountedbase",
+    "../../api:scoped_refptr",
     "../../rtc_base:checks",
     "../../rtc_base:rtc_base",  # TODO(kjellander): Cleanup in bugs.webrtc.org/3806.
     "../../rtc_base/synchronization:rw_lock_wrapper",
diff --git a/modules/desktop_capture/desktop_capture_options.h b/modules/desktop_capture/desktop_capture_options.h
index 9d35836..9473547 100644
--- a/modules/desktop_capture/desktop_capture_options.h
+++ b/modules/desktop_capture/desktop_capture_options.h
@@ -10,7 +10,7 @@
 #ifndef MODULES_DESKTOP_CAPTURE_DESKTOP_CAPTURE_OPTIONS_H_
 #define MODULES_DESKTOP_CAPTURE_DESKTOP_CAPTURE_OPTIONS_H_
 
-#include "rtc_base/scoped_ref_ptr.h"
+#include "api/scoped_refptr.h"
 #include "rtc_base/system/rtc_export.h"
 
 #if defined(USE_X11)
diff --git a/modules/desktop_capture/linux/mouse_cursor_monitor_x11.h b/modules/desktop_capture/linux/mouse_cursor_monitor_x11.h
index 9925c53..37c0b87 100644
--- a/modules/desktop_capture/linux/mouse_cursor_monitor_x11.h
+++ b/modules/desktop_capture/linux/mouse_cursor_monitor_x11.h
@@ -14,12 +14,12 @@
 #include <X11/X.h>
 #include <memory>
 
+#include "api/scoped_refptr.h"
 #include "modules/desktop_capture/desktop_capture_options.h"
 #include "modules/desktop_capture/desktop_capture_types.h"
 #include "modules/desktop_capture/linux/shared_x_display.h"
 #include "modules/desktop_capture/mouse_cursor.h"
 #include "modules/desktop_capture/mouse_cursor_monitor.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace webrtc {
 
diff --git a/modules/desktop_capture/linux/shared_x_display.h b/modules/desktop_capture/linux/shared_x_display.h
index 0829e09..8f3bb41 100644
--- a/modules/desktop_capture/linux/shared_x_display.h
+++ b/modules/desktop_capture/linux/shared_x_display.h
@@ -17,8 +17,8 @@
 #include <string>
 
 #include "api/ref_counted_base.h"
+#include "api/scoped_refptr.h"
 #include "rtc_base/constructor_magic.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 // Including Xlib.h will involve evil defines (Bool, Status, True, False), which
 // easily conflict with other headers.
diff --git a/modules/desktop_capture/linux/window_capturer_x11.cc b/modules/desktop_capture/linux/window_capturer_x11.cc
index 68302e1..85a51a6 100644
--- a/modules/desktop_capture/linux/window_capturer_x11.cc
+++ b/modules/desktop_capture/linux/window_capturer_x11.cc
@@ -18,6 +18,7 @@
 #include <string>
 #include <utility>
 
+#include "api/scoped_refptr.h"
 #include "modules/desktop_capture/desktop_capture_types.h"
 #include "modules/desktop_capture/desktop_frame.h"
 #include "modules/desktop_capture/desktop_region.h"
@@ -26,7 +27,6 @@
 #include "modules/desktop_capture/linux/window_list_utils.h"
 #include "rtc_base/checks.h"
 #include "rtc_base/logging.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/trace_event.h"
 
 namespace webrtc {
diff --git a/modules/desktop_capture/linux/window_capturer_x11.h b/modules/desktop_capture/linux/window_capturer_x11.h
index 0f81950..48b2554 100644
--- a/modules/desktop_capture/linux/window_capturer_x11.h
+++ b/modules/desktop_capture/linux/window_capturer_x11.h
@@ -16,6 +16,7 @@
 #include <memory>
 #include <string>
 
+#include "api/scoped_refptr.h"
 #include "modules/desktop_capture/desktop_capture_options.h"
 #include "modules/desktop_capture/desktop_capturer.h"
 #include "modules/desktop_capture/desktop_geometry.h"
@@ -24,7 +25,6 @@
 #include "modules/desktop_capture/linux/x_atom_cache.h"
 #include "modules/desktop_capture/linux/x_server_pixel_buffer.h"
 #include "rtc_base/constructor_magic.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace webrtc {
 
diff --git a/modules/desktop_capture/mouse_cursor_monitor_mac.mm b/modules/desktop_capture/mouse_cursor_monitor_mac.mm
index 814a45a..35ef394 100644
--- a/modules/desktop_capture/mouse_cursor_monitor_mac.mm
+++ b/modules/desktop_capture/mouse_cursor_monitor_mac.mm
@@ -18,6 +18,7 @@
 #include <Cocoa/Cocoa.h>
 #include <CoreFoundation/CoreFoundation.h>
 
+#include "api/scoped_refptr.h"
 #include "modules/desktop_capture/desktop_capture_options.h"
 #include "modules/desktop_capture/desktop_capture_types.h"
 #include "modules/desktop_capture/desktop_frame.h"
@@ -27,7 +28,6 @@
 #include "modules/desktop_capture/mac/window_list_utils.h"
 #include "modules/desktop_capture/mouse_cursor.h"
 #include "rtc_base/mac_utils.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace webrtc {
 
diff --git a/modules/desktop_capture/screen_drawer_linux.cc b/modules/desktop_capture/screen_drawer_linux.cc
index 658554e..bb5b86f 100644
--- a/modules/desktop_capture/screen_drawer_linux.cc
+++ b/modules/desktop_capture/screen_drawer_linux.cc
@@ -14,6 +14,7 @@
 #include <memory>
 
 #include "absl/memory/memory.h"
+#include "api/scoped_refptr.h"
 #include "modules/desktop_capture/desktop_capture_types.h"
 #include "modules/desktop_capture/desktop_geometry.h"
 #include "modules/desktop_capture/linux/shared_x_display.h"
@@ -21,7 +22,6 @@
 #include "modules/desktop_capture/screen_drawer.h"
 #include "modules/desktop_capture/screen_drawer_lock_posix.h"
 #include "rtc_base/checks.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "system_wrappers/include/sleep.h"
 
 namespace webrtc {
diff --git a/modules/desktop_capture/shared_desktop_frame.h b/modules/desktop_capture/shared_desktop_frame.h
index 12671de..fd862d7 100644
--- a/modules/desktop_capture/shared_desktop_frame.h
+++ b/modules/desktop_capture/shared_desktop_frame.h
@@ -13,10 +13,10 @@
 
 #include <memory>
 
+#include "api/scoped_refptr.h"
 #include "modules/desktop_capture/desktop_frame.h"
 #include "rtc_base/constructor_magic.h"
 #include "rtc_base/ref_counted_object.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/system/rtc_export.h"
 
 namespace webrtc {
diff --git a/modules/desktop_capture/win/dxgi_duplicator_controller.h b/modules/desktop_capture/win/dxgi_duplicator_controller.h
index a4f967d..cf0067d 100644
--- a/modules/desktop_capture/win/dxgi_duplicator_controller.h
+++ b/modules/desktop_capture/win/dxgi_duplicator_controller.h
@@ -17,6 +17,7 @@
 #include <string>
 #include <vector>
 
+#include "api/scoped_refptr.h"
 #include "modules/desktop_capture/desktop_geometry.h"
 #include "modules/desktop_capture/shared_desktop_frame.h"
 #include "modules/desktop_capture/win/d3d_device.h"
@@ -25,7 +26,6 @@
 #include "modules/desktop_capture/win/dxgi_context.h"
 #include "modules/desktop_capture/win/dxgi_frame.h"
 #include "rtc_base/critical_section.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace webrtc {
 
diff --git a/modules/desktop_capture/win/screen_capturer_win_directx.h b/modules/desktop_capture/win/screen_capturer_win_directx.h
index 9438bbd..0e3b79c 100644
--- a/modules/desktop_capture/win/screen_capturer_win_directx.h
+++ b/modules/desktop_capture/win/screen_capturer_win_directx.h
@@ -16,13 +16,13 @@
 #include <memory>
 #include <vector>
 
+#include "api/scoped_refptr.h"
 #include "modules/desktop_capture/desktop_capture_options.h"
 #include "modules/desktop_capture/desktop_capturer.h"
 #include "modules/desktop_capture/desktop_region.h"
 #include "modules/desktop_capture/screen_capture_frame_queue.h"
 #include "modules/desktop_capture/win/dxgi_duplicator_controller.h"
 #include "modules/desktop_capture/win/dxgi_frame.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace webrtc {
 
diff --git a/modules/desktop_capture/window_capturer_mac.mm b/modules/desktop_capture/window_capturer_mac.mm
index ae763f1..979b3b8 100644
--- a/modules/desktop_capture/window_capturer_mac.mm
+++ b/modules/desktop_capture/window_capturer_mac.mm
@@ -15,6 +15,7 @@
 
 #include <utility>
 
+#include "api/scoped_refptr.h"
 #include "modules/desktop_capture/desktop_capture_options.h"
 #include "modules/desktop_capture/desktop_capturer.h"
 #include "modules/desktop_capture/desktop_frame.h"
@@ -26,7 +27,6 @@
 #include "rtc_base/constructor_magic.h"
 #include "rtc_base/logging.h"
 #include "rtc_base/mac_utils.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/trace_event.h"
 
 namespace webrtc {
diff --git a/modules/desktop_capture/window_finder.h b/modules/desktop_capture/window_finder.h
index 1a78145..4b88bb8 100644
--- a/modules/desktop_capture/window_finder.h
+++ b/modules/desktop_capture/window_finder.h
@@ -13,9 +13,9 @@
 
 #include <memory>
 
+#include "api/scoped_refptr.h"
 #include "modules/desktop_capture/desktop_capture_types.h"
 #include "modules/desktop_capture/desktop_geometry.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 #if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS)
 #include "modules/desktop_capture/mac/desktop_configuration_monitor.h"
diff --git a/modules/desktop_capture/window_finder_mac.h b/modules/desktop_capture/window_finder_mac.h
index db6e926..988dd49 100644
--- a/modules/desktop_capture/window_finder_mac.h
+++ b/modules/desktop_capture/window_finder_mac.h
@@ -11,8 +11,8 @@
 #ifndef MODULES_DESKTOP_CAPTURE_WINDOW_FINDER_MAC_H_
 #define MODULES_DESKTOP_CAPTURE_WINDOW_FINDER_MAC_H_
 
+#include "api/scoped_refptr.h"
 #include "modules/desktop_capture/window_finder.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace webrtc {
 
diff --git a/modules/desktop_capture/window_finder_unittest.cc b/modules/desktop_capture/window_finder_unittest.cc
index b54b304..4e01628 100644
--- a/modules/desktop_capture/window_finder_unittest.cc
+++ b/modules/desktop_capture/window_finder_unittest.cc
@@ -13,10 +13,10 @@
 #include <stdint.h>
 #include <memory>
 
+#include "api/scoped_refptr.h"
 #include "modules/desktop_capture/desktop_geometry.h"
 #include "modules/desktop_capture/screen_drawer.h"
 #include "rtc_base/logging.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "test/gtest.h"
 
 #if defined(USE_X11)
diff --git a/modules/rtp_rtcp/BUILD.gn b/modules/rtp_rtcp/BUILD.gn
index 80f9e13..69fa724 100644
--- a/modules/rtp_rtcp/BUILD.gn
+++ b/modules/rtp_rtcp/BUILD.gn
@@ -199,6 +199,7 @@
     "../..:webrtc_common",
     "../../api:array_view",
     "../../api:libjingle_peerconnection_api",
+    "../../api:scoped_refptr",
     "../../api:transport_api",
     "../../api/audio_codecs:audio_codecs_api",
     "../../api/video:video_bitrate_allocation",
@@ -427,6 +428,7 @@
       "../..:webrtc_common",
       "../../api:array_view",
       "../../api:libjingle_peerconnection_api",
+      "../../api:scoped_refptr",
       "../../api:transport_api",
       "../../api/video:video_bitrate_allocation",
       "../../api/video:video_bitrate_allocator",
diff --git a/modules/rtp_rtcp/source/flexfec_header_reader_writer.cc b/modules/rtp_rtcp/source/flexfec_header_reader_writer.cc
index b813340..e3cb0e9 100644
--- a/modules/rtp_rtcp/source/flexfec_header_reader_writer.cc
+++ b/modules/rtp_rtcp/source/flexfec_header_reader_writer.cc
@@ -12,11 +12,11 @@
 
 #include <string.h>
 
+#include "api/scoped_refptr.h"
 #include "modules/rtp_rtcp/source/byte_io.h"
 #include "modules/rtp_rtcp/source/forward_error_correction_internal.h"
 #include "rtc_base/checks.h"
 #include "rtc_base/logging.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace webrtc {
 
diff --git a/modules/rtp_rtcp/source/flexfec_header_reader_writer_unittest.cc b/modules/rtp_rtcp/source/flexfec_header_reader_writer_unittest.cc
index 5da378c..3d19eda 100644
--- a/modules/rtp_rtcp/source/flexfec_header_reader_writer_unittest.cc
+++ b/modules/rtp_rtcp/source/flexfec_header_reader_writer_unittest.cc
@@ -13,13 +13,13 @@
 #include <memory>
 #include <utility>
 
+#include "api/scoped_refptr.h"
 #include "modules/rtp_rtcp/source/byte_io.h"
 #include "modules/rtp_rtcp/source/flexfec_header_reader_writer.h"
 #include "modules/rtp_rtcp/source/forward_error_correction.h"
 #include "modules/rtp_rtcp/source/forward_error_correction_internal.h"
 #include "rtc_base/checks.h"
 #include "rtc_base/random.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "test/gmock.h"
 #include "test/gtest.h"
 
diff --git a/modules/rtp_rtcp/source/flexfec_receiver.cc b/modules/rtp_rtcp/source/flexfec_receiver.cc
index 1a62bce..4cf58d1 100644
--- a/modules/rtp_rtcp/source/flexfec_receiver.cc
+++ b/modules/rtp_rtcp/source/flexfec_receiver.cc
@@ -13,9 +13,9 @@
 #include <string.h>
 
 #include "api/array_view.h"
+#include "api/scoped_refptr.h"
 #include "rtc_base/checks.h"
 #include "rtc_base/logging.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace webrtc {
 
diff --git a/modules/rtp_rtcp/source/forward_error_correction.h b/modules/rtp_rtcp/source/forward_error_correction.h
index adb7572..b442273 100644
--- a/modules/rtp_rtcp/source/forward_error_correction.h
+++ b/modules/rtp_rtcp/source/forward_error_correction.h
@@ -17,10 +17,10 @@
 #include <memory>
 #include <vector>
 
+#include "api/scoped_refptr.h"
 #include "modules/include/module_fec_types.h"
 #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
 #include "modules/rtp_rtcp/source/forward_error_correction_internal.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace webrtc {
 
diff --git a/modules/rtp_rtcp/source/ulpfec_header_reader_writer.cc b/modules/rtp_rtcp/source/ulpfec_header_reader_writer.cc
index 22af7e7..7086b13 100644
--- a/modules/rtp_rtcp/source/ulpfec_header_reader_writer.cc
+++ b/modules/rtp_rtcp/source/ulpfec_header_reader_writer.cc
@@ -12,10 +12,10 @@
 
 #include <string.h>
 
+#include "api/scoped_refptr.h"
 #include "modules/rtp_rtcp/source/byte_io.h"
 #include "modules/rtp_rtcp/source/forward_error_correction_internal.h"
 #include "rtc_base/checks.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace webrtc {
 
diff --git a/modules/rtp_rtcp/source/ulpfec_header_reader_writer_unittest.cc b/modules/rtp_rtcp/source/ulpfec_header_reader_writer_unittest.cc
index a1d1bd5..2ad1239 100644
--- a/modules/rtp_rtcp/source/ulpfec_header_reader_writer_unittest.cc
+++ b/modules/rtp_rtcp/source/ulpfec_header_reader_writer_unittest.cc
@@ -13,13 +13,13 @@
 #include <memory>
 #include <utility>
 
+#include "api/scoped_refptr.h"
 #include "modules/rtp_rtcp/source/byte_io.h"
 #include "modules/rtp_rtcp/source/forward_error_correction.h"
 #include "modules/rtp_rtcp/source/forward_error_correction_internal.h"
 #include "modules/rtp_rtcp/source/ulpfec_header_reader_writer.h"
 #include "rtc_base/checks.h"
 #include "rtc_base/random.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "test/gtest.h"
 
 namespace webrtc {
diff --git a/modules/rtp_rtcp/source/ulpfec_receiver_impl.cc b/modules/rtp_rtcp/source/ulpfec_receiver_impl.cc
index 0bb4ad8..614d4aa 100644
--- a/modules/rtp_rtcp/source/ulpfec_receiver_impl.cc
+++ b/modules/rtp_rtcp/source/ulpfec_receiver_impl.cc
@@ -14,9 +14,9 @@
 #include <memory>
 #include <utility>
 
+#include "api/scoped_refptr.h"
 #include "modules/rtp_rtcp/source/byte_io.h"
 #include "rtc_base/logging.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/time_utils.h"
 
 namespace webrtc {
diff --git a/modules/video_capture/BUILD.gn b/modules/video_capture/BUILD.gn
index 6ff80d4..bddba89 100644
--- a/modules/video_capture/BUILD.gn
+++ b/modules/video_capture/BUILD.gn
@@ -30,6 +30,7 @@
     "..:module_api",
     "../..:webrtc_common",
     "../../api:libjingle_peerconnection_api",
+    "../../api:scoped_refptr",
     "../../api/video:video_frame",
     "../../api/video:video_frame_i420",
     "../../common_video",
@@ -52,6 +53,7 @@
 
   deps = [
     ":video_capture_module",
+    "../../api:scoped_refptr",
     "../../rtc_base:rtc_base_approved",
     "../../system_wrappers",
   ]
@@ -74,6 +76,7 @@
 
       deps = [
         ":video_capture_module",
+        "../../api:scoped_refptr",
         "../../rtc_base:rtc_base_approved",
         "../../system_wrappers",
       ]
@@ -96,6 +99,7 @@
   rtc_source_set("video_capture_internal_impl") {
     deps = [
       ":video_capture_module",
+      "../../api:scoped_refptr",
       "../../rtc_base:checks",
       "../../rtc_base:rtc_base_approved",
       "../../system_wrappers",
@@ -186,6 +190,7 @@
       deps = [
         ":video_capture_internal_impl",
         ":video_capture_module",
+        "../../api:scoped_refptr",
         "../../api/video:video_frame",
         "../../api/video:video_frame_i420",
         "../../common_video:common_video",
diff --git a/modules/video_capture/external/video_capture_external.cc b/modules/video_capture/external/video_capture_external.cc
index 1c5a90a..f61e73e 100644
--- a/modules/video_capture/external/video_capture_external.cc
+++ b/modules/video_capture/external/video_capture_external.cc
@@ -8,10 +8,10 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
+#include "api/scoped_refptr.h"
 #include "modules/video_capture/video_capture.h"
 #include "modules/video_capture/video_capture_impl.h"
 #include "rtc_base/ref_counted_object.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace webrtc {
 
diff --git a/modules/video_capture/linux/video_capture_linux.cc b/modules/video_capture/linux/video_capture_linux.cc
index 714a0f9..d890469 100644
--- a/modules/video_capture/linux/video_capture_linux.cc
+++ b/modules/video_capture/linux/video_capture_linux.cc
@@ -23,11 +23,11 @@
 #include <new>
 #include <string>
 
+#include "api/scoped_refptr.h"
 #include "media/base/video_common.h"
 #include "modules/video_capture/video_capture.h"
 #include "rtc_base/logging.h"
 #include "rtc_base/ref_counted_object.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace webrtc {
 namespace videocapturemodule {
diff --git a/modules/video_capture/objc/video_capture.h b/modules/video_capture/objc/video_capture.h
index a85c93e..1dc1fbd 100644
--- a/modules/video_capture/objc/video_capture.h
+++ b/modules/video_capture/objc/video_capture.h
@@ -11,8 +11,8 @@
 #ifndef MODULES_VIDEO_CAPTURE_OBJC_VIDEO_CAPTURE_H_
 #define MODULES_VIDEO_CAPTURE_OBJC_VIDEO_CAPTURE_H_
 
+#include "api/scoped_refptr.h"
 #include "modules/video_capture/video_capture_impl.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 @class RTCVideoCaptureIosObjC;
 
diff --git a/modules/video_capture/objc/video_capture.mm b/modules/video_capture/objc/video_capture.mm
index 1b173f9..9697c28 100644
--- a/modules/video_capture/objc/video_capture.mm
+++ b/modules/video_capture/objc/video_capture.mm
@@ -12,11 +12,11 @@
 #error "This file requires ARC support."
 #endif
 
+#include "api/scoped_refptr.h"
 #include "modules/video_capture/objc/device_info_objc.h"
 #include "modules/video_capture/objc/rtc_video_capture_objc.h"
 #include "rtc_base/ref_count.h"
 #include "rtc_base/ref_counted_object.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 using namespace webrtc;
 using namespace videocapturemodule;
diff --git a/modules/video_capture/test/video_capture_unittest.cc b/modules/video_capture/test/video_capture_unittest.cc
index 63d5018..4bc6866 100644
--- a/modules/video_capture/test/video_capture_unittest.cc
+++ b/modules/video_capture/test/video_capture_unittest.cc
@@ -15,6 +15,7 @@
 #include <sstream>
 
 #include "absl/memory/memory.h"
+#include "api/scoped_refptr.h"
 #include "api/video/i420_buffer.h"
 #include "api/video/video_frame.h"
 #include "common_video/libyuv/include/webrtc_libyuv.h"
@@ -22,7 +23,6 @@
 #include "modules/video_capture/video_capture.h"
 #include "modules/video_capture/video_capture_factory.h"
 #include "rtc_base/critical_section.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/time_utils.h"
 #include "system_wrappers/include/sleep.h"
 #include "test/frame_utils.h"
diff --git a/modules/video_capture/video_capture_factory.h b/modules/video_capture/video_capture_factory.h
index 30fca7d..1901958 100644
--- a/modules/video_capture/video_capture_factory.h
+++ b/modules/video_capture/video_capture_factory.h
@@ -14,9 +14,9 @@
 #ifndef MODULES_VIDEO_CAPTURE_VIDEO_CAPTURE_FACTORY_H_
 #define MODULES_VIDEO_CAPTURE_VIDEO_CAPTURE_FACTORY_H_
 
+#include "api/scoped_refptr.h"
 #include "modules/video_capture/video_capture.h"
 #include "modules/video_capture/video_capture_defines.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace webrtc {
 
diff --git a/modules/video_capture/video_capture_impl.h b/modules/video_capture/video_capture_impl.h
index 2ec3547..516446d 100644
--- a/modules/video_capture/video_capture_impl.h
+++ b/modules/video_capture/video_capture_impl.h
@@ -18,6 +18,7 @@
 #include <stddef.h>
 #include <stdint.h>
 
+#include "api/scoped_refptr.h"
 #include "api/video/video_frame.h"
 #include "api/video/video_rotation.h"
 #include "api/video/video_sink_interface.h"
@@ -25,7 +26,6 @@
 #include "modules/video_capture/video_capture_config.h"
 #include "modules/video_capture/video_capture_defines.h"
 #include "rtc_base/critical_section.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace webrtc {
 
diff --git a/modules/video_capture/windows/video_capture_factory_windows.cc b/modules/video_capture/windows/video_capture_factory_windows.cc
index 9f76902..eacb542 100644
--- a/modules/video_capture/windows/video_capture_factory_windows.cc
+++ b/modules/video_capture/windows/video_capture_factory_windows.cc
@@ -8,11 +8,11 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
+#include "api/scoped_refptr.h"
 #include "modules/video_capture/windows/video_capture_ds.h"
 #include "modules/video_capture/windows/video_capture_mf.h"
 #include "rtc_base/ref_count.h"
 #include "rtc_base/ref_counted_object.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace webrtc {
 namespace videocapturemodule {
diff --git a/modules/video_coding/BUILD.gn b/modules/video_coding/BUILD.gn
index f65715b..0c9db0f 100644
--- a/modules/video_coding/BUILD.gn
+++ b/modules/video_coding/BUILD.gn
@@ -85,6 +85,7 @@
   deps = [
     "..:module_fec_api",
     "../../api:libjingle_peerconnection_api",
+    "../../api:scoped_refptr",
     "../../api/video:encoded_image",
     "../../api/video:video_bitrate_allocation",
     "../../api/video:video_bitrate_allocator_factory",
@@ -379,6 +380,7 @@
     ":video_coding_utility",
     "..:module_api",
     "../..:webrtc_common",
+    "../../api:scoped_refptr",
     "../../api/video:encoded_image",
     "../../api/video:video_frame",
     "../../api/video:video_frame_i420",
@@ -417,6 +419,7 @@
     ":webrtc_vp8_temporal_layers",
     "..:module_api",
     "../..:webrtc_common",
+    "../../api:scoped_refptr",
     "../../api/video:encoded_image",
     "../../api/video:video_frame",
     "../../api/video:video_frame_i420",
@@ -525,6 +528,7 @@
     ":webrtc_vp9_helpers",
     "..:module_api",
     "../..:webrtc_common",
+    "../../api:scoped_refptr",
     "../../api/video:video_frame",
     "../../api/video:video_frame_i010",
     "../../api/video_codecs:video_codecs_api",
@@ -647,6 +651,7 @@
       ":webrtc_vp9_helpers",
       "..:module_api",
       "../..:webrtc_common",
+      "../../api:scoped_refptr",
       "../../api:videocodec_test_fixture_api",
       "../../api/video:builtin_video_bitrate_allocator_factory",
       "../../api/video:encoded_image",
@@ -787,6 +792,7 @@
       "../../api:mock_video_codec_factory",
       "../../api:mock_video_decoder",
       "../../api:mock_video_encoder",
+      "../../api:scoped_refptr",
       "../../api:videocodec_test_fixture_api",
       "../../api/test/video:function_video_factory",
       "../../api/video:encoded_image",
@@ -913,6 +919,7 @@
       "../../api:fec_controller_api",
       "../../api:mock_video_decoder",
       "../../api:mock_video_encoder",
+      "../../api:scoped_refptr",
       "../../api:simulcast_test_fixture_api",
       "../../api:videocodec_test_fixture_api",
       "../../api/test/video:function_video_factory",
diff --git a/modules/video_coding/codecs/multiplex/include/augmented_video_frame_buffer.h b/modules/video_coding/codecs/multiplex/include/augmented_video_frame_buffer.h
index 72c8fb8..c45ab3b 100644
--- a/modules/video_coding/codecs/multiplex/include/augmented_video_frame_buffer.h
+++ b/modules/video_coding/codecs/multiplex/include/augmented_video_frame_buffer.h
@@ -14,8 +14,8 @@
 #include <cstdint>
 #include <memory>
 
+#include "api/scoped_refptr.h"
 #include "api/video/video_frame_buffer.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace webrtc {
 class AugmentedVideoFrameBuffer : public VideoFrameBuffer {
diff --git a/modules/video_coding/codecs/multiplex/test/multiplex_adapter_unittest.cc b/modules/video_coding/codecs/multiplex/test/multiplex_adapter_unittest.cc
index f9444b7..4225a59 100644
--- a/modules/video_coding/codecs/multiplex/test/multiplex_adapter_unittest.cc
+++ b/modules/video_coding/codecs/multiplex/test/multiplex_adapter_unittest.cc
@@ -16,6 +16,7 @@
 
 #include "absl/memory/memory.h"
 #include "absl/types/optional.h"
+#include "api/scoped_refptr.h"
 #include "api/test/mock_video_decoder_factory.h"
 #include "api/test/mock_video_encoder_factory.h"
 #include "api/video/encoded_image.h"
@@ -40,7 +41,6 @@
 #include "modules/video_coding/include/video_error_codes.h"
 #include "rtc_base/keep_ref_until_done.h"
 #include "rtc_base/ref_counted_object.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "test/gmock.h"
 #include "test/gtest.h"
 #include "test/video_codec_settings.h"
diff --git a/modules/video_coding/codecs/test/videoprocessor.cc b/modules/video_coding/codecs/test/videoprocessor.cc
index ea97731..b30c032 100644
--- a/modules/video_coding/codecs/test/videoprocessor.cc
+++ b/modules/video_coding/codecs/test/videoprocessor.cc
@@ -17,6 +17,7 @@
 #include <utility>
 
 #include "absl/memory/memory.h"
+#include "api/scoped_refptr.h"
 #include "api/video/builtin_video_bitrate_allocator_factory.h"
 #include "api/video/i420_buffer.h"
 #include "api/video/video_bitrate_allocator_factory.h"
@@ -30,7 +31,6 @@
 #include "modules/video_coding/codecs/interface/common_constants.h"
 #include "modules/video_coding/include/video_error_codes.h"
 #include "rtc_base/checks.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/time_utils.h"
 #include "test/gtest.h"
 #include "third_party/libyuv/include/libyuv/compare.h"
diff --git a/modules/video_coding/codecs/test/videoprocessor_unittest.cc b/modules/video_coding/codecs/test/videoprocessor_unittest.cc
index 541fc45..c668f41 100644
--- a/modules/video_coding/codecs/test/videoprocessor_unittest.cc
+++ b/modules/video_coding/codecs/test/videoprocessor_unittest.cc
@@ -11,6 +11,7 @@
 #include <memory>
 
 #include "absl/memory/memory.h"
+#include "api/scoped_refptr.h"
 #include "api/test/mock_video_decoder.h"
 #include "api/test/mock_video_encoder.h"
 #include "api/test/videocodec_test_fixture.h"
@@ -18,7 +19,6 @@
 #include "media/base/media_constants.h"
 #include "modules/video_coding/codecs/test/videocodec_test_stats_impl.h"
 #include "modules/video_coding/codecs/test/videoprocessor.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/task_queue_for_test.h"
 #include "test/gmock.h"
 #include "test/gtest.h"
diff --git a/modules/video_coding/codecs/vp8/libvpx_vp8_decoder.cc b/modules/video_coding/codecs/vp8/libvpx_vp8_decoder.cc
index de8538e..000fc3a 100644
--- a/modules/video_coding/codecs/vp8/libvpx_vp8_decoder.cc
+++ b/modules/video_coding/codecs/vp8/libvpx_vp8_decoder.cc
@@ -15,6 +15,7 @@
 
 #include "absl/memory/memory.h"
 #include "absl/types/optional.h"
+#include "api/scoped_refptr.h"
 #include "api/video/i420_buffer.h"
 #include "api/video/video_frame.h"
 #include "api/video/video_frame_buffer.h"
@@ -25,7 +26,6 @@
 #include "modules/video_coding/include/video_error_codes.h"
 #include "rtc_base/checks.h"
 #include "rtc_base/numerics/exp_filter.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/time_utils.h"
 #include "system_wrappers/include/field_trial.h"
 #include "system_wrappers/include/metrics.h"
diff --git a/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc b/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc
index af435a5..7af2b52 100644
--- a/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc
+++ b/modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc
@@ -17,6 +17,7 @@
 #include <vector>
 
 #include "absl/memory/memory.h"
+#include "api/scoped_refptr.h"
 #include "api/video/video_content_type.h"
 #include "api/video/video_frame_buffer.h"
 #include "api/video/video_timing.h"
@@ -32,7 +33,6 @@
 #include "rtc_base/checks.h"
 #include "rtc_base/experiments/field_trial_parser.h"
 #include "rtc_base/experiments/rate_control_settings.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/trace_event.h"
 #include "system_wrappers/include/field_trial.h"
 #include "third_party/libyuv/include/libyuv/scale.h"
diff --git a/modules/video_coding/codecs/vp9/vp9_frame_buffer_pool.h b/modules/video_coding/codecs/vp9/vp9_frame_buffer_pool.h
index fd84b66..df6d451 100644
--- a/modules/video_coding/codecs/vp9/vp9_frame_buffer_pool.h
+++ b/modules/video_coding/codecs/vp9/vp9_frame_buffer_pool.h
@@ -16,10 +16,10 @@
 
 #include <vector>
 
+#include "api/scoped_refptr.h"
 #include "rtc_base/buffer.h"
 #include "rtc_base/critical_section.h"
 #include "rtc_base/ref_count.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 struct vpx_codec_ctx;
 struct vpx_codec_frame_buffer;
diff --git a/modules/video_coding/packet_buffer.h b/modules/video_coding/packet_buffer.h
index 73ffb05..0da504f 100644
--- a/modules/video_coding/packet_buffer.h
+++ b/modules/video_coding/packet_buffer.h
@@ -16,12 +16,12 @@
 #include <set>
 #include <vector>
 
+#include "api/scoped_refptr.h"
 #include "modules/include/module_common_types.h"
 #include "modules/video_coding/packet.h"
 #include "modules/video_coding/rtp_frame_reference_finder.h"
 #include "rtc_base/critical_section.h"
 #include "rtc_base/numerics/sequence_number_util.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/thread_annotations.h"
 
 namespace webrtc {
diff --git a/modules/video_coding/video_codec_initializer.cc b/modules/video_coding/video_codec_initializer.cc
index 311fb86..d67cf52 100644
--- a/modules/video_coding/video_codec_initializer.cc
+++ b/modules/video_coding/video_codec_initializer.cc
@@ -15,6 +15,7 @@
 #include <algorithm>
 
 #include "absl/types/optional.h"
+#include "api/scoped_refptr.h"
 #include "api/video/video_bitrate_allocation.h"
 #include "api/video_codecs/video_encoder.h"
 #include "common_types.h"  // NOLINT(build/include)
@@ -22,7 +23,6 @@
 #include "modules/video_coding/include/video_coding_defines.h"
 #include "rtc_base/checks.h"
 #include "rtc_base/logging.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace webrtc {
 
diff --git a/modules/video_coding/video_codec_initializer_unittest.cc b/modules/video_coding/video_codec_initializer_unittest.cc
index a90b7b7..6734b7e 100644
--- a/modules/video_coding/video_codec_initializer_unittest.cc
+++ b/modules/video_coding/video_codec_initializer_unittest.cc
@@ -15,6 +15,7 @@
 #include <memory>
 
 #include "absl/types/optional.h"
+#include "api/scoped_refptr.h"
 #include "api/video/builtin_video_bitrate_allocator_factory.h"
 #include "api/video/video_bitrate_allocation.h"
 #include "api/video/video_bitrate_allocator.h"
@@ -26,7 +27,6 @@
 #include "modules/video_coding/codecs/vp9/include/vp9_globals.h"
 #include "rtc_base/checks.h"
 #include "rtc_base/ref_counted_object.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "test/gtest.h"
 
 namespace webrtc {
diff --git a/modules/video_coding/video_sender.cc b/modules/video_coding/video_sender.cc
index 78196ab..5b3a657 100644
--- a/modules/video_coding/video_sender.cc
+++ b/modules/video_coding/video_sender.cc
@@ -12,6 +12,7 @@
 #include <stdint.h>
 #include <vector>
 
+#include "api/scoped_refptr.h"
 #include "api/video/video_bitrate_allocation.h"
 #include "api/video/video_bitrate_allocator.h"
 #include "api/video/video_frame.h"
@@ -30,7 +31,6 @@
 #include "rtc_base/checks.h"
 #include "rtc_base/critical_section.h"
 #include "rtc_base/logging.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/sequenced_task_checker.h"
 #include "system_wrappers/include/clock.h"
 #include "system_wrappers/include/field_trial.h"
diff --git a/modules/video_processing/BUILD.gn b/modules/video_processing/BUILD.gn
index 2e2a93f..afcbf7f 100644
--- a/modules/video_processing/BUILD.gn
+++ b/modules/video_processing/BUILD.gn
@@ -27,6 +27,7 @@
   deps = [
     ":denoiser_filter",
     "..:module_api",
+    "../../api:scoped_refptr",
     "../../api/video:video_frame",
     "../../api/video:video_frame_i420",
     "../../common_audio",
@@ -114,10 +115,10 @@
     deps = [
       ":denoiser_filter",
       ":video_processing",
+      "../../api:scoped_refptr",
       "../../api/video:video_frame",
       "../../api/video:video_frame_i420",
       "../../common_video:common_video",
-      "../../rtc_base:ptr_util",
       "../../test:fileutils",
       "../../test:test_support",
       "../../test:video_test_common",
diff --git a/modules/video_processing/test/denoiser_test.cc b/modules/video_processing/test/denoiser_test.cc
index 223e3ae..550e96f 100644
--- a/modules/video_processing/test/denoiser_test.cc
+++ b/modules/video_processing/test/denoiser_test.cc
@@ -14,12 +14,12 @@
 #include <memory>
 #include <string>
 
+#include "api/scoped_refptr.h"
 #include "api/video/i420_buffer.h"
 #include "api/video/video_frame_buffer.h"
 #include "modules/video_processing/util/denoiser_filter.h"
 #include "modules/video_processing/util/skin_detection.h"
 #include "modules/video_processing/video_denoiser.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "test/frame_utils.h"
 #include "test/gtest.h"
 #include "test/testsupport/file_utils.h"
diff --git a/modules/video_processing/video_denoiser.h b/modules/video_processing/video_denoiser.h
index 6e743b5..37d624b 100644
--- a/modules/video_processing/video_denoiser.h
+++ b/modules/video_processing/video_denoiser.h
@@ -13,12 +13,12 @@
 
 #include <memory>
 
+#include "api/scoped_refptr.h"
 #include "api/video/video_frame_buffer.h"
 #include "common_video/include/i420_buffer_pool.h"
 #include "modules/video_processing/util/denoiser_filter.h"
 #include "modules/video_processing/util/noise_estimation.h"
 #include "modules/video_processing/util/skin_detection.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace webrtc {
 
diff --git a/p2p/BUILD.gn b/p2p/BUILD.gn
index dcc7caf..775ebbd 100644
--- a/p2p/BUILD.gn
+++ b/p2p/BUILD.gn
@@ -119,6 +119,7 @@
   deps = [
     "../api:libjingle_peerconnection_api",
     "../api:ortc_api",
+    "../api:scoped_refptr",
     "../api/transport:enums",
     "../logging:ice_log",
     "../logging:rtc_event_log_api",
@@ -221,6 +222,7 @@
       ":rtc_p2p",
       "../api:libjingle_peerconnection_api",
       "../api:ortc_api",
+      "../api:scoped_refptr",
       "../api/units:time_delta",
       "../rtc_base:checks",
       "../rtc_base:gunit_helpers",
diff --git a/p2p/base/dtls_transport_internal.h b/p2p/base/dtls_transport_internal.h
index 3054169..b9c399d 100644
--- a/p2p/base/dtls_transport_internal.h
+++ b/p2p/base/dtls_transport_internal.h
@@ -17,10 +17,10 @@
 #include <string>
 
 #include "api/crypto/crypto_options.h"
+#include "api/scoped_refptr.h"
 #include "p2p/base/ice_transport_internal.h"
 #include "p2p/base/packet_transport_internal.h"
 #include "rtc_base/constructor_magic.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/ssl_certificate.h"
 #include "rtc_base/ssl_fingerprint.h"
 #include "rtc_base/ssl_stream_adapter.h"
diff --git a/p2p/base/regathering_controller_unittest.cc b/p2p/base/regathering_controller_unittest.cc
index c90beb6..db1f1bd 100644
--- a/p2p/base/regathering_controller_unittest.cc
+++ b/p2p/base/regathering_controller_unittest.cc
@@ -13,6 +13,7 @@
 #include <string>
 #include <vector>
 
+#include "api/scoped_refptr.h"
 #include "p2p/base/fake_port_allocator.h"
 #include "p2p/base/mock_ice_transport.h"
 #include "p2p/base/p2p_constants.h"
@@ -21,7 +22,6 @@
 #include "p2p/base/stun_server.h"
 #include "rtc_base/gunit.h"
 #include "rtc_base/ref_counted_object.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/socket_address.h"
 #include "rtc_base/thread.h"
 #include "rtc_base/virtual_socket_server.h"
diff --git a/pc/BUILD.gn b/pc/BUILD.gn
index ce4e6dc..7c16753 100644
--- a/pc/BUILD.gn
+++ b/pc/BUILD.gn
@@ -94,6 +94,7 @@
     "../api:call_api",
     "../api:libjingle_peerconnection_api",
     "../api:ortc_api",
+    "../api:scoped_refptr",
     "../api/video:video_frame",
     "../call:call_interfaces",
     "../call:rtp_interfaces",
@@ -245,6 +246,7 @@
     "../api:fec_controller_api",
     "../api:libjingle_peerconnection_api",
     "../api:rtc_stats_api",
+    "../api:scoped_refptr",
     "../api/video:video_frame",
     "../api/video_codecs:video_codecs_api",
     "../call:call_interfaces",
@@ -366,6 +368,7 @@
       "../api:create_peerconnection_factory",
       "../api:libjingle_peerconnection_api",
       "../api:rtc_stats_api",
+      "../api:scoped_refptr",
       "../api/audio:audio_mixer_api",
       "../api/audio_codecs:audio_codecs_api",
       "../api/audio_codecs:builtin_audio_decoder_factory",
@@ -406,6 +409,7 @@
       ":pc_test_utils",
       "../api:libjingle_peerconnection_api",
       "../api:rtc_stats_api",
+      "../api:scoped_refptr",
       "../pc:peerconnection",
       "../rtc_base:checks",
       "../rtc_base:gunit_helpers",
@@ -473,6 +477,7 @@
       "../api:libjingle_peerconnection_api",
       "../api:libjingle_peerconnection_test_api",
       "../api:rtc_stats_api",
+      "../api:scoped_refptr",
       "../api/audio:audio_mixer_api",
       "../api/audio_codecs:audio_codecs_api",
       "../api/video:video_frame",
@@ -576,6 +581,7 @@
       "../api:libjingle_peerconnection_api",
       "../api:loopback_media_transport",
       "../api:mock_rtp",
+      "../api:scoped_refptr",
       "../api/audio:audio_mixer_api",
       "../api/units:time_delta",
       "../logging:fake_rtc_event_log",
diff --git a/pc/audio_track.h b/pc/audio_track.h
index 6df8693..f89bbcd 100644
--- a/pc/audio_track.h
+++ b/pc/audio_track.h
@@ -14,9 +14,9 @@
 #include <string>
 
 #include "api/media_stream_interface.h"
+#include "api/scoped_refptr.h"
 #include "pc/media_stream_track.h"
 #include "rtc_base/constructor_magic.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/thread_checker.h"
 
 namespace webrtc {
diff --git a/pc/data_channel.h b/pc/data_channel.h
index af8dd93..a07c4fb 100644
--- a/pc/data_channel.h
+++ b/pc/data_channel.h
@@ -18,10 +18,10 @@
 
 #include "api/data_channel_interface.h"
 #include "api/proxy.h"
+#include "api/scoped_refptr.h"
 #include "media/base/media_channel.h"
 #include "pc/channel.h"
 #include "rtc_base/async_invoker.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/third_party/sigslot/sigslot.h"
 
 namespace webrtc {
diff --git a/pc/local_audio_source.h b/pc/local_audio_source.h
index 0223fd4..587ce10 100644
--- a/pc/local_audio_source.h
+++ b/pc/local_audio_source.h
@@ -14,7 +14,7 @@
 #include "api/audio_options.h"
 #include "api/media_stream_interface.h"
 #include "api/notifier.h"
-#include "rtc_base/scoped_ref_ptr.h"
+#include "api/scoped_refptr.h"
 
 // LocalAudioSource implements AudioSourceInterface.
 // This contains settings for switching audio processing on and off.
diff --git a/pc/media_stream.h b/pc/media_stream.h
index e513226..34299f4 100644
--- a/pc/media_stream.h
+++ b/pc/media_stream.h
@@ -17,7 +17,7 @@
 
 #include "api/media_stream_interface.h"
 #include "api/notifier.h"
-#include "rtc_base/scoped_ref_ptr.h"
+#include "api/scoped_refptr.h"
 
 namespace webrtc {
 
diff --git a/pc/media_stream_observer.h b/pc/media_stream_observer.h
index faa6772..890600d 100644
--- a/pc/media_stream_observer.h
+++ b/pc/media_stream_observer.h
@@ -12,7 +12,7 @@
 #define PC_MEDIA_STREAM_OBSERVER_H_
 
 #include "api/media_stream_interface.h"
-#include "rtc_base/scoped_ref_ptr.h"
+#include "api/scoped_refptr.h"
 #include "rtc_base/third_party/sigslot/sigslot.h"
 
 namespace webrtc {
diff --git a/pc/peer_connection_data_channel_unittest.cc b/pc/peer_connection_data_channel_unittest.cc
index c120143..754ee0a 100644
--- a/pc/peer_connection_data_channel_unittest.cc
+++ b/pc/peer_connection_data_channel_unittest.cc
@@ -21,6 +21,7 @@
 #include "api/media_types.h"
 #include "api/peer_connection_interface.h"
 #include "api/peer_connection_proxy.h"
+#include "api/scoped_refptr.h"
 #include "api/test/fake_media_transport.h"
 #include "media/base/codec.h"
 #include "media/base/fake_media_engine.h"
@@ -39,7 +40,6 @@
 #include "rtc_base/checks.h"
 #include "rtc_base/ref_counted_object.h"
 #include "rtc_base/rtc_certificate_generator.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/thread.h"
 #include "test/gtest.h"
 #ifdef WEBRTC_ANDROID
diff --git a/pc/peer_connection_factory.h b/pc/peer_connection_factory.h
index 6b1958c..1303d52 100644
--- a/pc/peer_connection_factory.h
+++ b/pc/peer_connection_factory.h
@@ -18,10 +18,10 @@
 #include "api/media_stream_interface.h"
 #include "api/media_transport_interface.h"
 #include "api/peer_connection_interface.h"
+#include "api/scoped_refptr.h"
 #include "media/sctp/sctp_transport_internal.h"
 #include "pc/channel_manager.h"
 #include "rtc_base/rtc_certificate_generator.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/thread.h"
 
 namespace rtc {
diff --git a/pc/peer_connection_histogram_unittest.cc b/pc/peer_connection_histogram_unittest.cc
index 2bbebdb..596f2f5 100644
--- a/pc/peer_connection_histogram_unittest.cc
+++ b/pc/peer_connection_histogram_unittest.cc
@@ -21,6 +21,7 @@
 #include "api/peer_connection_interface.h"
 #include "api/peer_connection_proxy.h"
 #include "api/rtc_error.h"
+#include "api/scoped_refptr.h"
 #include "media/base/fake_media_engine.h"
 #include "p2p/base/port_allocator.h"
 #include "p2p/client/basic_port_allocator.h"
@@ -34,7 +35,6 @@
 #include "rtc_base/gunit.h"
 #include "rtc_base/ref_counted_object.h"
 #include "rtc_base/rtc_certificate_generator.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/socket_address.h"
 #include "rtc_base/thread.h"
 #include "rtc_base/virtual_socket_server.h"
diff --git a/pc/peer_connection_interface_unittest.cc b/pc/peer_connection_interface_unittest.cc
index d39e072..9180f1d 100644
--- a/pc/peer_connection_interface_unittest.cc
+++ b/pc/peer_connection_interface_unittest.cc
@@ -36,6 +36,7 @@
 #include "api/rtp_receiver_interface.h"
 #include "api/rtp_sender_interface.h"
 #include "api/rtp_transceiver_interface.h"
+#include "api/scoped_refptr.h"
 #include "api/video_codecs/builtin_video_decoder_factory.h"
 #include "api/video_codecs/builtin_video_encoder_factory.h"
 #include "api/video_codecs/video_decoder_factory.h"
@@ -80,7 +81,6 @@
 #include "rtc_base/platform_file.h"
 #include "rtc_base/ref_counted_object.h"
 #include "rtc_base/rtc_certificate_generator.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/socket_address.h"
 #include "rtc_base/string_utils.h"
 #include "rtc_base/thread.h"
diff --git a/pc/peer_connection_rampup_tests.cc b/pc/peer_connection_rampup_tests.cc
index 321affd..93a2724 100644
--- a/pc/peer_connection_rampup_tests.cc
+++ b/pc/peer_connection_rampup_tests.cc
@@ -25,6 +25,7 @@
 #include "api/jsep.h"
 #include "api/media_stream_interface.h"
 #include "api/peer_connection_interface.h"
+#include "api/scoped_refptr.h"
 #include "api/stats/rtc_stats.h"
 #include "api/stats/rtc_stats_report.h"
 #include "api/stats/rtcstats_objects.h"
@@ -50,7 +51,6 @@
 #include "rtc_base/helpers.h"
 #include "rtc_base/location.h"
 #include "rtc_base/ref_counted_object.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/socket_address.h"
 #include "rtc_base/ssl_certificate.h"
 #include "rtc_base/test_certificate_verifier.h"
diff --git a/pc/peer_connection_rtp_unittest.cc b/pc/peer_connection_rtp_unittest.cc
index 0b95d2d..2321ada 100644
--- a/pc/peer_connection_rtp_unittest.cc
+++ b/pc/peer_connection_rtp_unittest.cc
@@ -31,6 +31,7 @@
 #include "api/rtp_receiver_interface.h"
 #include "api/rtp_sender_interface.h"
 #include "api/rtp_transceiver_interface.h"
+#include "api/scoped_refptr.h"
 #include "api/set_remote_description_observer_interface.h"
 #include "api/uma_metrics.h"
 #include "api/video_codecs/builtin_video_decoder_factory.h"
@@ -51,7 +52,6 @@
 #include "rtc_base/gunit.h"
 #include "rtc_base/ref_counted_object.h"
 #include "rtc_base/rtc_certificate_generator.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/thread.h"
 #include "system_wrappers/include/metrics.h"
 #include "test/gmock.h"
diff --git a/pc/peer_connection_wrapper.h b/pc/peer_connection_wrapper.h
index 0acd58f..d7f10b4 100644
--- a/pc/peer_connection_wrapper.h
+++ b/pc/peer_connection_wrapper.h
@@ -23,10 +23,10 @@
 #include "api/rtc_error.h"
 #include "api/rtp_sender_interface.h"
 #include "api/rtp_transceiver_interface.h"
+#include "api/scoped_refptr.h"
 #include "api/stats/rtc_stats_report.h"
 #include "pc/test/mock_peer_connection_observers.h"
 #include "rtc_base/function_view.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace webrtc {
 
diff --git a/pc/remote_audio_source.cc b/pc/remote_audio_source.cc
index ac7604d..c789d45 100644
--- a/pc/remote_audio_source.cc
+++ b/pc/remote_audio_source.cc
@@ -15,11 +15,11 @@
 #include <string>
 
 #include "absl/memory/memory.h"
+#include "api/scoped_refptr.h"
 #include "rtc_base/checks.h"
 #include "rtc_base/constructor_magic.h"
 #include "rtc_base/location.h"
 #include "rtc_base/logging.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/thread.h"
 #include "rtc_base/thread_checker.h"
 
diff --git a/pc/rtc_stats_collector.h b/pc/rtc_stats_collector.h
index e3402df..a3f1593 100644
--- a/pc/rtc_stats_collector.h
+++ b/pc/rtc_stats_collector.h
@@ -18,6 +18,7 @@
 #include <vector>
 
 #include "absl/types/optional.h"
+#include "api/scoped_refptr.h"
 #include "api/stats/rtc_stats_collector_callback.h"
 #include "api/stats/rtc_stats_report.h"
 #include "api/stats/rtcstats_objects.h"
@@ -28,7 +29,6 @@
 #include "pc/track_media_info_map.h"
 #include "rtc_base/async_invoker.h"
 #include "rtc_base/ref_count.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/ssl_identity.h"
 #include "rtc_base/third_party/sigslot/sigslot.h"
 #include "rtc_base/time_utils.h"
diff --git a/pc/rtc_stats_integrationtest.cc b/pc/rtc_stats_integrationtest.cc
index a9ebc80..14fd366 100644
--- a/pc/rtc_stats_integrationtest.cc
+++ b/pc/rtc_stats_integrationtest.cc
@@ -26,6 +26,7 @@
 #include "api/peer_connection_interface.h"
 #include "api/rtp_receiver_interface.h"
 #include "api/rtp_sender_interface.h"
+#include "api/scoped_refptr.h"
 #include "api/stats/rtc_stats.h"
 #include "api/stats/rtc_stats_report.h"
 #include "api/stats/rtcstats_objects.h"
@@ -37,7 +38,6 @@
 #include "rtc_base/event_tracer.h"
 #include "rtc_base/gunit.h"
 #include "rtc_base/ref_counted_object.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/thread.h"
 #include "rtc_base/trace_event.h"
 #include "rtc_base/virtual_socket_server.h"
diff --git a/pc/rtc_stats_traversal.h b/pc/rtc_stats_traversal.h
index f648ec6..062a665 100644
--- a/pc/rtc_stats_traversal.h
+++ b/pc/rtc_stats_traversal.h
@@ -14,9 +14,9 @@
 #include <string>
 #include <vector>
 
+#include "api/scoped_refptr.h"
 #include "api/stats/rtc_stats.h"
 #include "api/stats/rtc_stats_report.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace webrtc {
 
diff --git a/pc/rtp_receiver.h b/pc/rtp_receiver.h
index 86673e8..469502c 100644
--- a/pc/rtp_receiver.h
+++ b/pc/rtp_receiver.h
@@ -25,6 +25,7 @@
 #include "api/media_types.h"
 #include "api/rtp_parameters.h"
 #include "api/rtp_receiver_interface.h"
+#include "api/scoped_refptr.h"
 #include "api/video/video_frame.h"
 #include "api/video/video_sink_interface.h"
 #include "api/video/video_source_interface.h"
@@ -33,7 +34,6 @@
 #include "pc/remote_audio_source.h"
 #include "pc/video_track_source.h"
 #include "rtc_base/ref_counted_object.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/thread.h"
 
 namespace webrtc {
diff --git a/pc/rtp_sender_receiver_unittest.cc b/pc/rtp_sender_receiver_unittest.cc
index 5672a9c..34092fb 100644
--- a/pc/rtp_sender_receiver_unittest.cc
+++ b/pc/rtp_sender_receiver_unittest.cc
@@ -25,6 +25,7 @@
 #include "api/media_stream_interface.h"
 #include "api/rtc_error.h"
 #include "api/rtp_parameters.h"
+#include "api/scoped_refptr.h"
 #include "api/test/fake_frame_decryptor.h"
 #include "api/test/fake_frame_encryptor.h"
 #include "logging/rtc_event_log/rtc_event_log.h"
@@ -53,7 +54,6 @@
 #include "pc/video_track.h"
 #include "rtc_base/checks.h"
 #include "rtc_base/gunit.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/third_party/sigslot/sigslot.h"
 #include "rtc_base/thread.h"
 #include "test/gmock.h"
diff --git a/pc/srtp_session.h b/pc/srtp_session.h
index dd89e43..8bfd6d1 100644
--- a/pc/srtp_session.h
+++ b/pc/srtp_session.h
@@ -13,7 +13,7 @@
 
 #include <vector>
 
-#include "rtc_base/scoped_ref_ptr.h"
+#include "api/scoped_refptr.h"
 #include "rtc_base/thread_checker.h"
 
 // Forward declaration to avoid pulling in libsrtp headers here
diff --git a/pc/stats_collector_unittest.cc b/pc/stats_collector_unittest.cc
index 4fdb8cd2..dc5a47a 100644
--- a/pc/stats_collector_unittest.cc
+++ b/pc/stats_collector_unittest.cc
@@ -17,6 +17,7 @@
 #include "api/audio_codecs/audio_encoder.h"
 #include "api/candidate.h"
 #include "api/data_channel_interface.h"
+#include "api/scoped_refptr.h"
 #include "call/call.h"
 #include "media/base/media_channel.h"
 #include "modules/audio_processing/include/audio_processing_statistics.h"
@@ -33,7 +34,6 @@
 #include "rtc_base/net_helper.h"
 #include "rtc_base/ref_counted_object.h"
 #include "rtc_base/rtc_certificate.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/socket_address.h"
 #include "rtc_base/ssl_identity.h"
 #include "rtc_base/ssl_stream_adapter.h"
diff --git a/pc/test/fake_audio_capture_module.h b/pc/test/fake_audio_capture_module.h
index 495cd01..12eecd9 100644
--- a/pc/test/fake_audio_capture_module.h
+++ b/pc/test/fake_audio_capture_module.h
@@ -22,11 +22,11 @@
 
 #include <memory>
 
+#include "api/scoped_refptr.h"
 #include "common_types.h"  // NOLINT(build/include)
 #include "modules/audio_device/include/audio_device.h"
 #include "rtc_base/critical_section.h"
 #include "rtc_base/message_handler.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace rtc {
 class Thread;
diff --git a/pc/test/fake_audio_capture_module_unittest.cc b/pc/test/fake_audio_capture_module_unittest.cc
index 30a8090..250953f 100644
--- a/pc/test/fake_audio_capture_module_unittest.cc
+++ b/pc/test/fake_audio_capture_module_unittest.cc
@@ -13,9 +13,9 @@
 #include <string.h>
 #include <algorithm>
 
+#include "api/scoped_refptr.h"
 #include "rtc_base/critical_section.h"
 #include "rtc_base/gunit.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "test/gtest.h"
 
 using std::min;
diff --git a/pc/test/peer_connection_test_wrapper.h b/pc/test/peer_connection_test_wrapper.h
index 8bbf42f..67f5673 100644
--- a/pc/test/peer_connection_test_wrapper.h
+++ b/pc/test/peer_connection_test_wrapper.h
@@ -24,10 +24,10 @@
 #include "api/peer_connection_interface.h"
 #include "api/rtc_error.h"
 #include "api/rtp_receiver_interface.h"
+#include "api/scoped_refptr.h"
 #include "api/test/fake_constraints.h"
 #include "pc/test/fake_audio_capture_module.h"
 #include "pc/test/fake_video_track_renderer.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/third_party/sigslot/sigslot.h"
 #include "rtc_base/thread.h"
 #include "rtc_base/thread_checker.h"
diff --git a/pc/video_track.h b/pc/video_track.h
index 0111a66..90e0758 100644
--- a/pc/video_track.h
+++ b/pc/video_track.h
@@ -14,12 +14,12 @@
 #include <string>
 
 #include "api/media_stream_interface.h"
+#include "api/scoped_refptr.h"
 #include "api/video/video_frame.h"
 #include "api/video/video_sink_interface.h"
 #include "api/video/video_source_interface.h"
 #include "media/base/video_source_base.h"
 #include "pc/media_stream_track.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/thread.h"
 #include "rtc_base/thread_annotations.h"
 #include "rtc_base/thread_checker.h"
diff --git a/pc/webrtc_session_description_factory.h b/pc/webrtc_session_description_factory.h
index a1bd0c7..af689a9 100644
--- a/pc/webrtc_session_description_factory.h
+++ b/pc/webrtc_session_description_factory.h
@@ -18,6 +18,7 @@
 
 #include "api/jsep.h"
 #include "api/peer_connection_interface.h"
+#include "api/scoped_refptr.h"
 #include "p2p/base/transport_description.h"
 #include "p2p/base/transport_description_factory.h"
 #include "pc/media_session.h"
@@ -27,7 +28,6 @@
 #include "rtc_base/message_queue.h"
 #include "rtc_base/rtc_certificate.h"
 #include "rtc_base/rtc_certificate_generator.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/third_party/sigslot/sigslot.h"
 #include "rtc_base/thread.h"
 
diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn
index e38da1f..7d25f1f 100644
--- a/rtc_base/BUILD.gn
+++ b/rtc_base/BUILD.gn
@@ -79,6 +79,7 @@
     ":safe_minmax",
     ":type_traits",
     "../api:array_view",
+    "../api:scoped_refptr",
     "../system_wrappers:field_trial",
     "experiments:field_trial_parser",
     "system:arch",
@@ -178,7 +179,6 @@
     ":macromagic",
     ":platform_thread",
     ":platform_thread_types",
-    ":ptr_util",
     ":refcount",
     ":rtc_event",
     ":safe_conversions",
@@ -211,16 +211,6 @@
   ]
 }
 
-rtc_source_set("ptr_util") {
-  visibility = [ "*" ]
-  sources = [
-    "scoped_ref_ptr.h",
-  ]
-  deps = [
-    "../api:scoped_refptr",
-  ]
-}
-
 rtc_source_set("refcount") {
   visibility = [ "*" ]
   sources = [
@@ -533,7 +523,7 @@
   ]
   deps = [
     ":macromagic",
-    ":ptr_util",
+    "../api:scoped_refptr",
     "../api/task_queue",
     "system:rtc_export",
     "//third_party/abseil-cpp/absl/memory",
@@ -555,11 +545,11 @@
       ":macromagic",
       ":platform_thread",
       ":platform_thread_types",
-      ":ptr_util",
       ":refcount",
       ":rtc_task_queue_api",
       ":safe_conversions",
       ":timeutils",
+      "../api:scoped_refptr",
       "system:unused",
     ]
     if (rtc_build_libevent) {
@@ -579,9 +569,9 @@
     deps = [
       ":checks",
       ":logging",
-      ":ptr_util",
       ":refcount",
       ":rtc_task_queue_api",
+      "../api:scoped_refptr",
     ]
   }
 }
@@ -598,12 +588,12 @@
       ":logging",
       ":macromagic",
       ":platform_thread",
-      ":ptr_util",
       ":refcount",
       ":rtc_event",
       ":rtc_task_queue_api",
       ":safe_conversions",
       ":timeutils",
+      "../api:scoped_refptr",
     ]
   }
 }
@@ -619,12 +609,12 @@
     ":logging",
     ":macromagic",
     ":platform_thread",
-    ":ptr_util",
     ":refcount",
     ":rtc_event",
     ":rtc_task_queue_api",
     ":safe_conversions",
     ":timeutils",
+    "../api:scoped_refptr",
   ]
 }
 
@@ -675,9 +665,9 @@
     "weak_ptr.h",
   ]
   deps = [
-    ":ptr_util",
     ":refcount",
     ":sequenced_task_checker",
+    "../api:scoped_refptr",
   ]
 }
 
@@ -867,6 +857,7 @@
     ":stringutils",
     "..:webrtc_common",
     "../api:array_view",
+    "../api:scoped_refptr",
     "network:sent_packet",
     "system:file_wrapper",
     "third_party/base64",
@@ -1398,6 +1389,7 @@
       ":stringutils",
       ":testclient",
       "../api:array_view",
+      "../api:scoped_refptr",
       "../api/units:time_delta",
       "../system_wrappers:system_wrappers",
       "../test:fileutils",
diff --git a/rtc_base/async_invoker.h b/rtc_base/async_invoker.h
index 805768b..f15955d 100644
--- a/rtc_base/async_invoker.h
+++ b/rtc_base/async_invoker.h
@@ -15,12 +15,12 @@
 #include <memory>
 #include <utility>
 
+#include "api/scoped_refptr.h"
 #include "rtc_base/async_invoker_inl.h"
 #include "rtc_base/bind.h"
 #include "rtc_base/constructor_magic.h"
 #include "rtc_base/event.h"
 #include "rtc_base/ref_counted_object.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/third_party/sigslot/sigslot.h"
 #include "rtc_base/thread.h"
 
diff --git a/rtc_base/async_invoker_inl.h b/rtc_base/async_invoker_inl.h
index 50ee638..bd9b0d1 100644
--- a/rtc_base/async_invoker_inl.h
+++ b/rtc_base/async_invoker_inl.h
@@ -11,12 +11,12 @@
 #ifndef RTC_BASE_ASYNC_INVOKER_INL_H_
 #define RTC_BASE_ASYNC_INVOKER_INL_H_
 
+#include "api/scoped_refptr.h"
 #include "rtc_base/bind.h"
 #include "rtc_base/critical_section.h"
 #include "rtc_base/event.h"
 #include "rtc_base/message_handler.h"
 #include "rtc_base/ref_counted_object.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/third_party/sigslot/sigslot.h"
 #include "rtc_base/thread.h"
 #include "rtc_base/thread_annotations.h"
diff --git a/rtc_base/bind.h b/rtc_base/bind.h
index 9f225f1..16ac556 100644
--- a/rtc_base/bind.h
+++ b/rtc_base/bind.h
@@ -64,7 +64,7 @@
 #include <tuple>
 #include <type_traits>
 
-#include "rtc_base/scoped_ref_ptr.h"
+#include "api/scoped_refptr.h"
 #include "rtc_base/template_util.h"
 
 #define NONAME
diff --git a/rtc_base/callback.h b/rtc_base/callback.h
index bead5f4..4751221 100644
--- a/rtc_base/callback.h
+++ b/rtc_base/callback.h
@@ -62,9 +62,9 @@
 #ifndef RTC_BASE_CALLBACK_H_
 #define RTC_BASE_CALLBACK_H_
 
+#include "api/scoped_refptr.h"
 #include "rtc_base/ref_count.h"
 #include "rtc_base/ref_counted_object.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace rtc {
 
diff --git a/rtc_base/callback.h.pump b/rtc_base/callback.h.pump
index a8a3faa..dc5fb3a 100644
--- a/rtc_base/callback.h.pump
+++ b/rtc_base/callback.h.pump
@@ -59,7 +59,7 @@
 
 #include "rtc_base/ref_count.h"
 #include "rtc_base/ref_counted_object.h"
-#include "rtc_base/scoped_ref_ptr.h"
+#include "api/scoped_refptr.h"
 
 namespace rtc {
 
diff --git a/rtc_base/copy_on_write_buffer.h b/rtc_base/copy_on_write_buffer.h
index e055f8d..d0954ad 100644
--- a/rtc_base/copy_on_write_buffer.h
+++ b/rtc_base/copy_on_write_buffer.h
@@ -18,10 +18,10 @@
 #include <type_traits>
 #include <utility>
 
+#include "api/scoped_refptr.h"
 #include "rtc_base/buffer.h"
 #include "rtc_base/checks.h"
 #include "rtc_base/ref_counted_object.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace rtc {
 
diff --git a/rtc_base/keep_ref_until_done.h b/rtc_base/keep_ref_until_done.h
index feb1e90..7bebd82 100644
--- a/rtc_base/keep_ref_until_done.h
+++ b/rtc_base/keep_ref_until_done.h
@@ -11,10 +11,10 @@
 #ifndef RTC_BASE_KEEP_REF_UNTIL_DONE_H_
 #define RTC_BASE_KEEP_REF_UNTIL_DONE_H_
 
+#include "api/scoped_refptr.h"
 #include "rtc_base/bind.h"
 #include "rtc_base/callback.h"
 #include "rtc_base/ref_count.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace rtc {
 
diff --git a/rtc_base/message_queue.h b/rtc_base/message_queue.h
index e484561..5a6bd0a 100644
--- a/rtc_base/message_queue.h
+++ b/rtc_base/message_queue.h
@@ -19,11 +19,11 @@
 #include <queue>
 #include <vector>
 
+#include "api/scoped_refptr.h"
 #include "rtc_base/constructor_magic.h"
 #include "rtc_base/critical_section.h"
 #include "rtc_base/location.h"
 #include "rtc_base/message_handler.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/socket_server.h"
 #include "rtc_base/third_party/sigslot/sigslot.h"
 #include "rtc_base/thread_annotations.h"
diff --git a/rtc_base/ref_counted_object_unittest.cc b/rtc_base/ref_counted_object_unittest.cc
index 9b475e2..00a9295 100644
--- a/rtc_base/ref_counted_object_unittest.cc
+++ b/rtc_base/ref_counted_object_unittest.cc
@@ -12,9 +12,9 @@
 #include <string>
 #include <utility>
 
+#include "api/scoped_refptr.h"
 #include "rtc_base/ref_count.h"
 #include "rtc_base/ref_counted_object.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "test/gtest.h"
 
 namespace rtc {
diff --git a/rtc_base/rtc_certificate.h b/rtc_base/rtc_certificate.h
index a826af4..d98c4ea 100644
--- a/rtc_base/rtc_certificate.h
+++ b/rtc_base/rtc_certificate.h
@@ -15,8 +15,8 @@
 #include <memory>
 #include <string>
 
+#include "api/scoped_refptr.h"
 #include "rtc_base/ref_count.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace rtc {
 
diff --git a/rtc_base/rtc_certificate_generator.h b/rtc_base/rtc_certificate_generator.h
index 75688dd..8cabca4 100644
--- a/rtc_base/rtc_certificate_generator.h
+++ b/rtc_base/rtc_certificate_generator.h
@@ -14,9 +14,9 @@
 #include <stdint.h>
 
 #include "absl/types/optional.h"
+#include "api/scoped_refptr.h"
 #include "rtc_base/ref_count.h"
 #include "rtc_base/rtc_certificate.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/ssl_identity.h"
 #include "rtc_base/thread.h"
 
diff --git a/rtc_base/scoped_ref_ptr.h b/rtc_base/scoped_ref_ptr.h
deleted file mode 100644
index b961ff5..0000000
--- a/rtc_base/scoped_ref_ptr.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- *  Copyright 2011 The WebRTC Project Authors. All rights reserved.
- *
- *  Use of this source code is governed by a BSD-style license
- *  that can be found in the LICENSE file in the root of the source
- *  tree. An additional intellectual property rights grant can be found
- *  in the file PATENTS.  All contributing project authors may
- *  be found in the AUTHORS file in the root of the source tree.
- */
-
-#ifndef RTC_BASE_SCOPED_REF_PTR_H_
-#define RTC_BASE_SCOPED_REF_PTR_H_
-
-// TODO(bugs.webrtc.org/9887): This is a forward header for backwards
-// compatibility. Remove when downstream clients are updated.
-
-#include "api/scoped_refptr.h"
-
-#endif  // RTC_BASE_SCOPED_REF_PTR_H_
diff --git a/rtc_base/task_queue.h b/rtc_base/task_queue.h
index e2b5348..d6198a8 100644
--- a/rtc_base/task_queue.h
+++ b/rtc_base/task_queue.h
@@ -17,10 +17,10 @@
 #include <utility>
 
 #include "absl/memory/memory.h"
+#include "api/scoped_refptr.h"
 #include "api/task_queue/queued_task.h"
 #include "api/task_queue/task_queue_priority.h"
 #include "rtc_base/constructor_magic.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/system/rtc_export.h"
 #include "rtc_base/thread_annotations.h"
 
diff --git a/rtc_base/task_queue_libevent.cc b/rtc_base/task_queue_libevent.cc
index ab97b0c..5ff177c 100644
--- a/rtc_base/task_queue_libevent.cc
+++ b/rtc_base/task_queue_libevent.cc
@@ -22,6 +22,7 @@
 #include <type_traits>
 #include <utility>
 
+#include "api/scoped_refptr.h"
 #include "base/third_party/libevent/event.h"
 #include "rtc_base/checks.h"
 #include "rtc_base/critical_section.h"
@@ -31,7 +32,6 @@
 #include "rtc_base/platform_thread_types.h"
 #include "rtc_base/ref_count.h"
 #include "rtc_base/ref_counted_object.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/system/unused.h"
 #include "rtc_base/task_queue_posix.h"
 #include "rtc_base/thread_annotations.h"
diff --git a/rtc_base/weak_ptr.h b/rtc_base/weak_ptr.h
index daeb671..89969d6 100644
--- a/rtc_base/weak_ptr.h
+++ b/rtc_base/weak_ptr.h
@@ -15,9 +15,9 @@
 
 #include <utility>
 
+#include "api/scoped_refptr.h"
 #include "rtc_base/ref_count.h"
 #include "rtc_base/ref_counted_object.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/sequenced_task_checker.h"
 
 // The implementation is borrowed from chromium except that it does not
diff --git a/rtc_tools/BUILD.gn b/rtc_tools/BUILD.gn
index 4e9e3cf..8ebac7f 100644
--- a/rtc_tools/BUILD.gn
+++ b/rtc_tools/BUILD.gn
@@ -65,6 +65,7 @@
     "video_file_reader.h",
   ]
   deps = [
+    "../api:scoped_refptr",
     "../api/video:video_frame",
     "../api/video:video_frame_i420",
     "../rtc_base:checks",
@@ -81,6 +82,7 @@
   ]
   deps = [
     ":video_file_reader",
+    "../api:scoped_refptr",
     "../api/video:video_frame",
     "../api/video:video_frame_i420",
     "../rtc_base:rtc_base_approved",
@@ -105,6 +107,7 @@
   deps = [
     ":video_file_reader",
     "../api:array_view",
+    "../api:scoped_refptr",
     "../api/video:video_frame",
     "../api/video:video_frame_i420",
     "../common_video",
@@ -127,7 +130,7 @@
     ":video_file_reader",
     ":video_file_writer",
     ":video_quality_analysis",
-    "../rtc_base:ptr_util",
+    "../api:scoped_refptr",
     "../rtc_base:stringutils",
     "../test:perf_test",
     "//third_party/abseil-cpp/absl/strings",
@@ -159,8 +162,8 @@
       ":command_line_parser",
       ":video_file_reader",
       ":video_quality_analysis",
+      "../api:scoped_refptr",
       "../api/video:video_frame",
-      "../rtc_base:ptr_util",
     ]
   }
 
@@ -173,8 +176,8 @@
     deps = [
       ":video_file_reader",
       ":video_quality_analysis",
+      "../api:scoped_refptr",
       "../api/video:video_frame",
-      "../rtc_base:ptr_util",
     ]
   }
 
@@ -382,6 +385,7 @@
       ":video_file_writer",
       ":video_quality_analysis",
       "../:webrtc_common",
+      "../api:scoped_refptr",
       "../api/video:video_frame",
       "../api/video:video_frame_i420",
       "../common_video:common_video",
diff --git a/rtc_tools/frame_analyzer/frame_analyzer.cc b/rtc_tools/frame_analyzer/frame_analyzer.cc
index 770c80e..514a456 100644
--- a/rtc_tools/frame_analyzer/frame_analyzer.cc
+++ b/rtc_tools/frame_analyzer/frame_analyzer.cc
@@ -15,7 +15,7 @@
 #include <vector>
 
 #include "absl/strings/match.h"
-#include "rtc_base/scoped_ref_ptr.h"
+#include "api/scoped_refptr.h"
 #include "rtc_base/strings/string_builder.h"
 #include "rtc_tools/frame_analyzer/video_color_aligner.h"
 #include "rtc_tools/frame_analyzer/video_geometry_aligner.h"
diff --git a/rtc_tools/frame_analyzer/reference_less_video_analysis_lib.h b/rtc_tools/frame_analyzer/reference_less_video_analysis_lib.h
index f2844d2..f5682edd 100644
--- a/rtc_tools/frame_analyzer/reference_less_video_analysis_lib.h
+++ b/rtc_tools/frame_analyzer/reference_less_video_analysis_lib.h
@@ -15,7 +15,7 @@
 #include <string>
 #include <vector>
 
-#include "rtc_base/scoped_ref_ptr.h"
+#include "api/scoped_refptr.h"
 #include "rtc_tools/video_file_reader.h"
 
 // Returns true if the frame is frozen based on psnr and ssim freezing
diff --git a/rtc_tools/frame_analyzer/reference_less_video_analysis_unittest.cc b/rtc_tools/frame_analyzer/reference_less_video_analysis_unittest.cc
index 2c736d1..b98a014 100644
--- a/rtc_tools/frame_analyzer/reference_less_video_analysis_unittest.cc
+++ b/rtc_tools/frame_analyzer/reference_less_video_analysis_unittest.cc
@@ -9,7 +9,7 @@
  */
 #include <vector>
 
-#include "rtc_base/scoped_ref_ptr.h"
+#include "api/scoped_refptr.h"
 #include "rtc_tools/frame_analyzer/reference_less_video_analysis_lib.h"
 #include "rtc_tools/video_file_reader.h"
 #include "test/gtest.h"
diff --git a/rtc_tools/frame_analyzer/video_color_aligner.h b/rtc_tools/frame_analyzer/video_color_aligner.h
index fcb76db..b51e060 100644
--- a/rtc_tools/frame_analyzer/video_color_aligner.h
+++ b/rtc_tools/frame_analyzer/video_color_aligner.h
@@ -13,8 +13,8 @@
 
 #include <array>
 
+#include "api/scoped_refptr.h"
 #include "api/video/video_frame_buffer.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_tools/video_file_reader.h"
 
 namespace webrtc {
diff --git a/rtc_tools/frame_analyzer/video_quality_analysis.h b/rtc_tools/frame_analyzer/video_quality_analysis.h
index ae2a19b..a513a3e 100644
--- a/rtc_tools/frame_analyzer/video_quality_analysis.h
+++ b/rtc_tools/frame_analyzer/video_quality_analysis.h
@@ -15,8 +15,8 @@
 #include <string>
 #include <vector>
 
+#include "api/scoped_refptr.h"
 #include "api/video/video_frame_buffer.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_tools/video_file_reader.h"
 
 namespace webrtc {
diff --git a/rtc_tools/frame_analyzer/video_temporal_aligner.h b/rtc_tools/frame_analyzer/video_temporal_aligner.h
index 31afa1f..9a1bc35 100644
--- a/rtc_tools/frame_analyzer/video_temporal_aligner.h
+++ b/rtc_tools/frame_analyzer/video_temporal_aligner.h
@@ -14,7 +14,7 @@
 #include <stddef.h>
 #include <vector>
 
-#include "rtc_base/scoped_ref_ptr.h"
+#include "api/scoped_refptr.h"
 #include "rtc_tools/video_file_reader.h"
 
 namespace webrtc {
diff --git a/rtc_tools/psnr_ssim_analyzer/psnr_ssim_analyzer.cc b/rtc_tools/psnr_ssim_analyzer/psnr_ssim_analyzer.cc
index 90ab824..ca97161 100644
--- a/rtc_tools/psnr_ssim_analyzer/psnr_ssim_analyzer.cc
+++ b/rtc_tools/psnr_ssim_analyzer/psnr_ssim_analyzer.cc
@@ -13,8 +13,8 @@
 #include <algorithm>
 #include <string>
 
+#include "api/scoped_refptr.h"
 #include "api/video/video_frame_buffer.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_tools/frame_analyzer/video_quality_analysis.h"
 #include "rtc_tools/simple_command_line_parser.h"
 #include "rtc_tools/video_file_reader.h"
diff --git a/rtc_tools/video_file_reader.h b/rtc_tools/video_file_reader.h
index a0315e3..3cdbcff 100644
--- a/rtc_tools/video_file_reader.h
+++ b/rtc_tools/video_file_reader.h
@@ -15,9 +15,9 @@
 #include <iterator>
 #include <string>
 
+#include "api/scoped_refptr.h"
 #include "api/video/video_frame_buffer.h"
 #include "rtc_base/ref_count.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace webrtc {
 namespace test {
diff --git a/rtc_tools/video_file_writer.h b/rtc_tools/video_file_writer.h
index 97b80ea..ab8db81 100644
--- a/rtc_tools/video_file_writer.h
+++ b/rtc_tools/video_file_writer.h
@@ -12,7 +12,7 @@
 
 #include <string>
 
-#include "rtc_base/scoped_ref_ptr.h"
+#include "api/scoped_refptr.h"
 #include "rtc_tools/video_file_reader.h"
 
 namespace webrtc {
diff --git a/sdk/BUILD.gn b/sdk/BUILD.gn
index 8d1ee7e..77d3c43 100644
--- a/sdk/BUILD.gn
+++ b/sdk/BUILD.gn
@@ -894,6 +894,7 @@
         ":videotoolbox_objc",
         "../api:create_peerconnection_factory",
         "../api:libjingle_peerconnection_api",
+        "../api:scoped_refptr",
         "../api/audio_codecs:audio_codecs_api",
         "../api/audio_codecs:builtin_audio_decoder_factory",
         "../api/audio_codecs:builtin_audio_encoder_factory",
@@ -1053,6 +1054,7 @@
             ":videoframebuffer_objc",
             ":videosource_objc",
             ":videotoolbox_objc",
+            "../api:scoped_refptr",
             "../api/video:video_frame_i420",
             "../common_video:common_video",
             "../media:rtc_media_base",
@@ -1531,6 +1533,7 @@
         ":native_video",
         ":videoframebuffer_objc",
         "../api:libjingle_peerconnection_api",
+        "../api:scoped_refptr",
         "../api/video:video_frame",
         "../api/video_codecs:video_codecs_api",
         "../common_video",
diff --git a/sdk/android/BUILD.gn b/sdk/android/BUILD.gn
index c6ffe73..f8977e2 100644
--- a/sdk/android/BUILD.gn
+++ b/sdk/android/BUILD.gn
@@ -557,6 +557,7 @@
       ":internal_jni",
       ":native_api_jni",
       "../../api:libjingle_peerconnection_api",
+      "../../api:scoped_refptr",
       "../../rtc_base:checks",
       "../../rtc_base:rtc_base",
       "../../rtc_base:rtc_base_approved",
@@ -616,6 +617,7 @@
       ":video_jni",
       ":videoframe_jni",
       "../..:webrtc_common",
+      "../../api:scoped_refptr",
       "../../api/video_codecs:video_codecs_api",
       "../../common_video:common_video",
       "../../media:rtc_internal_video_codecs",
@@ -1109,6 +1111,7 @@
       ":base_jni",
       ":generated_video_jni",
       ":native_api_jni",
+      "../../api:scoped_refptr",
       "../../api/video:video_frame",
       "../../common_video:common_video",
       "../../rtc_base:checks",
@@ -1557,6 +1560,7 @@
       ":native_api_video",
       ":opensles_audio_device_module",
       ":video_jni",
+      "../../api:scoped_refptr",
       "../../api/audio_codecs:builtin_audio_decoder_factory",
       "../../api/audio_codecs:builtin_audio_encoder_factory",
       "../../api/video:video_frame",
diff --git a/sdk/android/native_unittests/audio_device/audio_device_unittest.cc b/sdk/android/native_unittests/audio_device/audio_device_unittest.cc
index 6f52880..cacb069 100644
--- a/sdk/android/native_unittests/audio_device/audio_device_unittest.cc
+++ b/sdk/android/native_unittests/audio_device/audio_device_unittest.cc
@@ -11,13 +11,13 @@
 #include <memory>
 #include <numeric>
 
+#include "api/scoped_refptr.h"
 #include "modules/audio_device/include/audio_device.h"
 #include "modules/audio_device/include/mock_audio_transport.h"
 #include "rtc_base/arraysize.h"
 #include "rtc_base/critical_section.h"
 #include "rtc_base/event.h"
 #include "rtc_base/format_macros.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/time_utils.h"
 #include "sdk/android/generated_native_unittests_jni/jni/ApplicationContextProvider_jni.h"
 #include "sdk/android/generated_native_unittests_jni/jni/BuildInfo_jni.h"
diff --git a/sdk/android/src/jni/android_media_decoder.cc b/sdk/android/src/jni/android_media_decoder.cc
index 35f415e..71ba3b7 100644
--- a/sdk/android/src/jni/android_media_decoder.cc
+++ b/sdk/android/src/jni/android_media_decoder.cc
@@ -13,6 +13,7 @@
 #include <memory>
 #include <vector>
 
+#include "api/scoped_refptr.h"
 #include "api/video_codecs/sdp_video_format.h"
 #include "common_video/h264/h264_bitstream_parser.h"
 #include "common_video/include/i420_buffer_pool.h"
@@ -23,7 +24,6 @@
 #include "rtc_base/checks.h"
 #include "rtc_base/logging.h"
 #include "rtc_base/numerics/safe_conversions.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/thread.h"
 #include "rtc_base/time_utils.h"
 #include "sdk/android/generated_video_jni/jni/MediaCodecVideoDecoder_jni.h"
diff --git a/sdk/android/src/jni/pc/audio.h b/sdk/android/src/jni/pc/audio.h
index 49cf069..1e8b3ac 100644
--- a/sdk/android/src/jni/pc/audio.h
+++ b/sdk/android/src/jni/pc/audio.h
@@ -13,10 +13,10 @@
 
 // Adding 'nogncheck' to disable the gn include headers check.
 // We don't want this target depend on audio related targets
-#include "api/audio_codecs/audio_decoder_factory.h"             // nogncheck
-#include "api/audio_codecs/audio_encoder_factory.h"             // nogncheck
+#include "api/audio_codecs/audio_decoder_factory.h"  // nogncheck
+#include "api/audio_codecs/audio_encoder_factory.h"  // nogncheck
+#include "api/scoped_refptr.h"
 #include "modules/audio_processing/include/audio_processing.h"  // nogncheck
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace webrtc {
 namespace jni {
diff --git a/sdk/android/src/jni/pc/media.h b/sdk/android/src/jni/pc/media.h
index 8a0bb52..f701280 100644
--- a/sdk/android/src/jni/pc/media.h
+++ b/sdk/android/src/jni/pc/media.h
@@ -13,7 +13,7 @@
 
 #include <memory>
 
-#include "rtc_base/scoped_ref_ptr.h"
+#include "api/scoped_refptr.h"
 
 namespace webrtc {
 class AudioDeviceModule;
diff --git a/sdk/android/src/jni/pc/video.h b/sdk/android/src/jni/pc/video.h
index 04390ea..32bc640 100644
--- a/sdk/android/src/jni/pc/video.h
+++ b/sdk/android/src/jni/pc/video.h
@@ -13,7 +13,7 @@
 
 #include <jni.h>
 
-#include "rtc_base/scoped_ref_ptr.h"
+#include "api/scoped_refptr.h"
 #include "rtc_base/thread.h"
 #include "sdk/android/native_api/jni/scoped_java_ref.h"
 
diff --git a/sdk/android/src/jni/video_frame.cc b/sdk/android/src/jni/video_frame.cc
index d196b03..0d02527 100644
--- a/sdk/android/src/jni/video_frame.cc
+++ b/sdk/android/src/jni/video_frame.cc
@@ -12,12 +12,12 @@
 
 #include <memory>
 
+#include "api/scoped_refptr.h"
 #include "common_video/include/video_frame_buffer.h"
 #include "rtc_base/bind.h"
 #include "rtc_base/checks.h"
 #include "rtc_base/keep_ref_until_done.h"
 #include "rtc_base/logging.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/time_utils.h"
 #include "sdk/android/generated_video_jni/jni/VideoFrame_jni.h"
 #include "sdk/android/src/jni/jni_helpers.h"
diff --git a/sdk/objc/api/peerconnection/RTCDataChannel+Private.h b/sdk/objc/api/peerconnection/RTCDataChannel+Private.h
index 74d0455..e327fb4 100644
--- a/sdk/objc/api/peerconnection/RTCDataChannel+Private.h
+++ b/sdk/objc/api/peerconnection/RTCDataChannel+Private.h
@@ -11,7 +11,7 @@
 #import "RTCDataChannel.h"
 
 #include "api/data_channel_interface.h"
-#include "rtc_base/scoped_ref_ptr.h"
+#include "api/scoped_refptr.h"
 
 NS_ASSUME_NONNULL_BEGIN
 
diff --git a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory+Native.h b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory+Native.h
index 2752cf4..be68f3f 100644
--- a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory+Native.h
+++ b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory+Native.h
@@ -10,7 +10,7 @@
 
 #import "RTCPeerConnectionFactory.h"
 
-#include "rtc_base/scoped_ref_ptr.h"
+#include "api/scoped_refptr.h"
 
 namespace webrtc {
 
diff --git a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory+Private.h b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory+Private.h
index a82c445..db7829c 100644
--- a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory+Private.h
+++ b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory+Private.h
@@ -11,7 +11,7 @@
 #import "RTCPeerConnectionFactory.h"
 
 #include "api/peer_connection_interface.h"
-#include "rtc_base/scoped_ref_ptr.h"
+#include "api/scoped_refptr.h"
 
 NS_ASSUME_NONNULL_BEGIN
 
diff --git a/sdk/objc/api/peerconnection/RTCPeerConnectionFactoryBuilder.h b/sdk/objc/api/peerconnection/RTCPeerConnectionFactoryBuilder.h
index cca5446..189eb736 100644
--- a/sdk/objc/api/peerconnection/RTCPeerConnectionFactoryBuilder.h
+++ b/sdk/objc/api/peerconnection/RTCPeerConnectionFactoryBuilder.h
@@ -10,7 +10,7 @@
 
 #import "RTCPeerConnectionFactory.h"
 
-#include "rtc_base/scoped_ref_ptr.h"
+#include "api/scoped_refptr.h"
 
 namespace webrtc {
 
diff --git a/sdk/objc/api/peerconnection/RTCRtpReceiver+Native.h b/sdk/objc/api/peerconnection/RTCRtpReceiver+Native.h
index 419a347..e085529 100644
--- a/sdk/objc/api/peerconnection/RTCRtpReceiver+Native.h
+++ b/sdk/objc/api/peerconnection/RTCRtpReceiver+Native.h
@@ -11,7 +11,7 @@
 #import "RTCRtpReceiver.h"
 
 #include "api/crypto/frame_decryptor_interface.h"
-#include "rtc_base/scoped_ref_ptr.h"
+#include "api/scoped_refptr.h"
 
 NS_ASSUME_NONNULL_BEGIN
 
diff --git a/sdk/objc/api/peerconnection/RTCRtpSender+Native.h b/sdk/objc/api/peerconnection/RTCRtpSender+Native.h
index daef7ee..89a691c 100644
--- a/sdk/objc/api/peerconnection/RTCRtpSender+Native.h
+++ b/sdk/objc/api/peerconnection/RTCRtpSender+Native.h
@@ -11,7 +11,7 @@
 #import "RTCRtpSender.h"
 
 #include "api/crypto/frame_encryptor_interface.h"
-#include "rtc_base/scoped_ref_ptr.h"
+#include "api/scoped_refptr.h"
 
 NS_ASSUME_NONNULL_BEGIN
 
diff --git a/sdk/objc/native/api/video_capturer.h b/sdk/objc/native/api/video_capturer.h
index c0a7760..464d148 100644
--- a/sdk/objc/native/api/video_capturer.h
+++ b/sdk/objc/native/api/video_capturer.h
@@ -14,7 +14,7 @@
 #import "base/RTCVideoCapturer.h"
 
 #include "api/media_stream_interface.h"
-#include "rtc_base/scoped_ref_ptr.h"
+#include "api/scoped_refptr.h"
 #include "rtc_base/thread.h"
 
 namespace webrtc {
diff --git a/sdk/objc/native/api/video_frame_buffer.h b/sdk/objc/native/api/video_frame_buffer.h
index 232e00a..54a7375 100644
--- a/sdk/objc/native/api/video_frame_buffer.h
+++ b/sdk/objc/native/api/video_frame_buffer.h
@@ -13,8 +13,8 @@
 
 #import "base/RTCVideoFrameBuffer.h"
 
+#include "api/scoped_refptr.h"
 #include "common_video/include/video_frame_buffer.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace webrtc {
 
diff --git a/sdk/objc/unittests/ObjCVideoTrackSource_xctest.mm b/sdk/objc/unittests/ObjCVideoTrackSource_xctest.mm
index 291c9f0..8c940e4 100644
--- a/sdk/objc/unittests/ObjCVideoTrackSource_xctest.mm
+++ b/sdk/objc/unittests/ObjCVideoTrackSource_xctest.mm
@@ -19,10 +19,10 @@
 #import "components/video_frame_buffer/RTCCVPixelBuffer.h"
 #import "frame_buffer_helpers.h"
 
+#include "api/scoped_refptr.h"
 #include "common_video/libyuv/include/webrtc_libyuv.h"
 #include "media/base/fake_video_renderer.h"
 #include "rtc_base/ref_counted_object.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "sdk/objc/native/api/video_frame.h"
 
 typedef void (^VideoSinkCallback)(RTCVideoFrame *);
diff --git a/sdk/objc/unittests/RTCAudioDeviceModule_xctest.mm b/sdk/objc/unittests/RTCAudioDeviceModule_xctest.mm
index c2b5c6a..094e246 100644
--- a/sdk/objc/unittests/RTCAudioDeviceModule_xctest.mm
+++ b/sdk/objc/unittests/RTCAudioDeviceModule_xctest.mm
@@ -14,7 +14,7 @@
 #import "sdk/objc/native/api/audio_device_module.h"
 #endif
 
-#include "rtc_base/scoped_ref_ptr.h"
+#include "api/scoped_refptr.h"
 
 typedef int32_t(^NeedMorePlayDataBlock)(const size_t nSamples,
                                         const size_t nBytesPerSample,
diff --git a/test/BUILD.gn b/test/BUILD.gn
index fad00e2..6165b95 100644
--- a/test/BUILD.gn
+++ b/test/BUILD.gn
@@ -62,6 +62,7 @@
   deps = [
     "..:webrtc_common",
     "../api:libjingle_peerconnection_api",
+    "../api:scoped_refptr",
     "../api/video:video_frame",
     "../api/video:video_frame_i010",
     "../api/video:video_frame_i420",
@@ -347,6 +348,7 @@
       ":video_test_common",
       ":video_test_support",
       "../api:create_simulcast_test_fixture_api",
+      "../api:scoped_refptr",
       "../api:simulcast_test_fixture_api",
       "../api/test/video:function_video_factory",
       "../api/video:builtin_video_bitrate_allocator_factory",
@@ -628,6 +630,7 @@
   }
   deps = [
     "..:webrtc_common",
+    "../api:scoped_refptr",
     "../api/video:encoded_image",
     "../api/video:video_bitrate_allocation",
     "../api/video:video_frame",
@@ -703,6 +706,7 @@
     ":video_test_common",
     "../:webrtc_common",
     "../api:libjingle_peerconnection_api",
+    "../api:scoped_refptr",
     "../api:simulated_network_api",
     "../api:transport_api",
     "../api/audio_codecs:builtin_audio_decoder_factory",
@@ -803,6 +807,7 @@
   deps = [
     ":test_support",
     "..:webrtc_common",
+    "../api:scoped_refptr",
     "../api/video:video_frame",
     "../common_video",
     "../media:rtc_media_base",
@@ -863,6 +868,7 @@
   deps = [
     ":test_support",
     "../api:array_view",
+    "../api:scoped_refptr",
     "../api/audio_codecs:audio_codecs_api",
     "../api/audio_codecs:builtin_audio_decoder_factory",
     "../rtc_base:checks",
diff --git a/test/encoder_settings.cc b/test/encoder_settings.cc
index e576cc4..cc1994f 100644
--- a/test/encoder_settings.cc
+++ b/test/encoder_settings.cc
@@ -12,11 +12,11 @@
 #include <algorithm>
 #include <string>
 
+#include "api/scoped_refptr.h"
 #include "api/video_codecs/sdp_video_format.h"
 #include "call/rtp_config.h"
 #include "rtc_base/checks.h"
 #include "rtc_base/ref_counted_object.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace webrtc {
 namespace test {
diff --git a/test/fake_decoder.cc b/test/fake_decoder.cc
index 865bca7..70fe085 100644
--- a/test/fake_decoder.cc
+++ b/test/fake_decoder.cc
@@ -12,13 +12,13 @@
 
 #include <string.h>
 
+#include "api/scoped_refptr.h"
 #include "api/video/i420_buffer.h"
 #include "api/video/video_frame.h"
 #include "api/video/video_frame_buffer.h"
 #include "api/video/video_rotation.h"
 #include "modules/video_coding/include/video_error_codes.h"
 #include "rtc_base/checks.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/time_utils.h"
 
 namespace webrtc {
diff --git a/test/fake_vp8_decoder.cc b/test/fake_vp8_decoder.cc
index ae030a71..7a244ca 100644
--- a/test/fake_vp8_decoder.cc
+++ b/test/fake_vp8_decoder.cc
@@ -13,12 +13,12 @@
 #include <stddef.h>
 
 #include "absl/types/optional.h"
+#include "api/scoped_refptr.h"
 #include "api/video/i420_buffer.h"
 #include "api/video/video_frame.h"
 #include "api/video/video_frame_buffer.h"
 #include "api/video/video_rotation.h"
 #include "modules/video_coding/include/video_error_codes.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/time_utils.h"
 
 namespace webrtc {
diff --git a/test/frame_generator.cc b/test/frame_generator.cc
index e37e823..68abede 100644
--- a/test/frame_generator.cc
+++ b/test/frame_generator.cc
@@ -15,6 +15,7 @@
 #include <memory>
 
 #include "absl/memory/memory.h"
+#include "api/scoped_refptr.h"
 #include "api/video/i010_buffer.h"
 #include "api/video/i420_buffer.h"
 #include "api/video/video_frame_buffer.h"
@@ -26,7 +27,6 @@
 #include "rtc_base/checks.h"
 #include "rtc_base/keep_ref_until_done.h"
 #include "rtc_base/random.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "system_wrappers/include/clock.h"
 #include "test/frame_utils.h"
 
diff --git a/test/frame_generator_unittest.cc b/test/frame_generator_unittest.cc
index fa6da9a..599eac9 100644
--- a/test/frame_generator_unittest.cc
+++ b/test/frame_generator_unittest.cc
@@ -15,8 +15,8 @@
 #include <memory>
 #include <string>
 
+#include "api/scoped_refptr.h"
 #include "api/video/video_frame_buffer.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "test/frame_generator.h"
 #include "test/gtest.h"
 #include "test/testsupport/file_utils.h"
diff --git a/test/frame_utils.h b/test/frame_utils.h
index c829311..9351584 100644
--- a/test/frame_utils.h
+++ b/test/frame_utils.h
@@ -12,7 +12,7 @@
 
 #include <stdint.h>
 
-#include "rtc_base/scoped_ref_ptr.h"
+#include "api/scoped_refptr.h"
 
 namespace webrtc {
 class I420Buffer;
diff --git a/test/fuzzers/BUILD.gn b/test/fuzzers/BUILD.gn
index f78669a..797c27d 100644
--- a/test/fuzzers/BUILD.gn
+++ b/test/fuzzers/BUILD.gn
@@ -121,6 +121,7 @@
     "forward_error_correction_fuzzer.cc",
   ]
   deps = [
+    "../../api:scoped_refptr",
     "../../modules/rtp_rtcp",
     "../../modules/rtp_rtcp:rtp_rtcp_format",
     "../../rtc_base:rtc_base_approved",
@@ -132,6 +133,7 @@
     "flexfec_header_reader_fuzzer.cc",
   ]
   deps = [
+    "../../api:scoped_refptr",
     "../../modules/rtp_rtcp",
     "../../modules/rtp_rtcp:rtp_rtcp_format",
     "../../rtc_base:rtc_base_approved",
@@ -154,6 +156,7 @@
     "ulpfec_header_reader_fuzzer.cc",
   ]
   deps = [
+    "../../api:scoped_refptr",
     "../../modules/rtp_rtcp",
     "../../modules/rtp_rtcp:fec_test_helper",
     "../../modules/rtp_rtcp:rtp_rtcp_format",
@@ -482,13 +485,13 @@
   ]
   deps = [
     ":audio_processing_fuzzer_helper",
+    "../../api:scoped_refptr",
     "../../api/audio:aec3_factory",
     "../../modules/audio_processing",
     "../../modules/audio_processing:api",
     "../../modules/audio_processing/aec3",
     "../../modules/audio_processing/aec_dump",
     "../../modules/audio_processing/aec_dump:aec_dump_impl",
-    "../../rtc_base:ptr_util",
     "../../rtc_base:rtc_base_approved",
     "../../rtc_base:rtc_task_queue",
     "../../rtc_base:safe_minmax",
@@ -530,8 +533,8 @@
     "rtp_frame_reference_finder_fuzzer.cc",
   ]
   deps = [
+    "../../api:scoped_refptr",
     "../../modules/video_coding/",
-    "../../rtc_base:ptr_util",
     "../../system_wrappers",
     "//third_party/abseil-cpp/absl/memory",
   ]
diff --git a/test/fuzzers/flexfec_header_reader_fuzzer.cc b/test/fuzzers/flexfec_header_reader_fuzzer.cc
index a5694ea..c887d2e 100644
--- a/test/fuzzers/flexfec_header_reader_fuzzer.cc
+++ b/test/fuzzers/flexfec_header_reader_fuzzer.cc
@@ -10,10 +10,10 @@
 
 #include <algorithm>
 
+#include "api/scoped_refptr.h"
 #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
 #include "modules/rtp_rtcp/source/flexfec_header_reader_writer.h"
 #include "modules/rtp_rtcp/source/forward_error_correction.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace webrtc {
 
diff --git a/test/fuzzers/forward_error_correction_fuzzer.cc b/test/fuzzers/forward_error_correction_fuzzer.cc
index 1385e54..1c37889 100644
--- a/test/fuzzers/forward_error_correction_fuzzer.cc
+++ b/test/fuzzers/forward_error_correction_fuzzer.cc
@@ -10,10 +10,10 @@
 
 #include <memory>
 
+#include "api/scoped_refptr.h"
 #include "modules/rtp_rtcp/source/byte_io.h"
 #include "modules/rtp_rtcp/source/forward_error_correction.h"
 #include "rtc_base/byte_buffer.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace webrtc {
 
diff --git a/test/fuzzers/ulpfec_header_reader_fuzzer.cc b/test/fuzzers/ulpfec_header_reader_fuzzer.cc
index 6a6394f..46fe67b 100644
--- a/test/fuzzers/ulpfec_header_reader_fuzzer.cc
+++ b/test/fuzzers/ulpfec_header_reader_fuzzer.cc
@@ -10,10 +10,10 @@
 
 #include <algorithm>
 
+#include "api/scoped_refptr.h"
 #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
 #include "modules/rtp_rtcp/source/forward_error_correction.h"
 #include "modules/rtp_rtcp/source/ulpfec_header_reader_writer.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace webrtc {
 
diff --git a/test/mock_audio_decoder_factory.h b/test/mock_audio_decoder_factory.h
index b54e109..e38b1d2 100644
--- a/test/mock_audio_decoder_factory.h
+++ b/test/mock_audio_decoder_factory.h
@@ -16,8 +16,8 @@
 
 #include "api/audio_codecs/audio_decoder_factory.h"
 #include "api/audio_codecs/builtin_audio_decoder_factory.h"
+#include "api/scoped_refptr.h"
 #include "rtc_base/ref_counted_object.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "test/gmock.h"
 
 namespace webrtc {
diff --git a/test/mock_audio_encoder_factory.h b/test/mock_audio_encoder_factory.h
index 55fe259..373bbb6 100644
--- a/test/mock_audio_encoder_factory.h
+++ b/test/mock_audio_encoder_factory.h
@@ -15,8 +15,8 @@
 #include <vector>
 
 #include "api/audio_codecs/audio_encoder_factory.h"
+#include "api/scoped_refptr.h"
 #include "rtc_base/ref_counted_object.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "test/gmock.h"
 
 namespace webrtc {
diff --git a/test/test_video_capturer.cc b/test/test_video_capturer.cc
index ef3d858..fa43f9f 100644
--- a/test/test_video_capturer.cc
+++ b/test/test_video_capturer.cc
@@ -12,10 +12,10 @@
 
 #include <algorithm>
 
+#include "api/scoped_refptr.h"
 #include "api/video/i420_buffer.h"
 #include "api/video/video_frame_buffer.h"
 #include "api/video/video_rotation.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace webrtc {
 namespace test {
diff --git a/test/testsupport/frame_reader.h b/test/testsupport/frame_reader.h
index 4c0f206..7f313e8 100644
--- a/test/testsupport/frame_reader.h
+++ b/test/testsupport/frame_reader.h
@@ -15,7 +15,7 @@
 
 #include <string>
 
-#include "rtc_base/scoped_ref_ptr.h"
+#include "api/scoped_refptr.h"
 
 namespace webrtc {
 class I420Buffer;
diff --git a/test/testsupport/y4m_frame_reader.cc b/test/testsupport/y4m_frame_reader.cc
index 00ced05..5e50d86 100644
--- a/test/testsupport/y4m_frame_reader.cc
+++ b/test/testsupport/y4m_frame_reader.cc
@@ -11,8 +11,8 @@
 #include <stdio.h>
 #include <string>
 
+#include "api/scoped_refptr.h"
 #include "api/video/i420_buffer.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "test/testsupport/file_utils.h"
 #include "test/testsupport/frame_reader.h"
 
diff --git a/test/testsupport/y4m_frame_reader_unittest.cc b/test/testsupport/y4m_frame_reader_unittest.cc
index 957b88d..72b421d 100644
--- a/test/testsupport/y4m_frame_reader_unittest.cc
+++ b/test/testsupport/y4m_frame_reader_unittest.cc
@@ -14,9 +14,9 @@
 #include <string>
 
 #include "absl/strings/string_view.h"
+#include "api/scoped_refptr.h"
 #include "api/video/i420_buffer.h"
 #include "api/video/video_frame_buffer.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "test/gtest.h"
 #include "test/testsupport/file_utils.h"
 #include "test/testsupport/frame_reader.h"
diff --git a/test/testsupport/yuv_frame_reader.cc b/test/testsupport/yuv_frame_reader.cc
index c502ee7..2e788b9 100644
--- a/test/testsupport/yuv_frame_reader.cc
+++ b/test/testsupport/yuv_frame_reader.cc
@@ -11,8 +11,8 @@
 #include <stdio.h>
 #include <string>
 
+#include "api/scoped_refptr.h"
 #include "api/video/i420_buffer.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "test/frame_utils.h"
 #include "test/testsupport/file_utils.h"
 #include "test/testsupport/frame_reader.h"
diff --git a/test/testsupport/yuv_frame_reader_unittest.cc b/test/testsupport/yuv_frame_reader_unittest.cc
index cd405f5..9e16307 100644
--- a/test/testsupport/yuv_frame_reader_unittest.cc
+++ b/test/testsupport/yuv_frame_reader_unittest.cc
@@ -13,9 +13,9 @@
 #include <memory>
 #include <string>
 
+#include "api/scoped_refptr.h"
 #include "api/video/i420_buffer.h"
 #include "api/video/video_frame_buffer.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "test/gtest.h"
 #include "test/testsupport/file_utils.h"
 #include "test/testsupport/frame_reader.h"
diff --git a/test/vcm_capturer.h b/test/vcm_capturer.h
index 59000ae..5418dc9 100644
--- a/test/vcm_capturer.h
+++ b/test/vcm_capturer.h
@@ -13,8 +13,8 @@
 #include <memory>
 #include <vector>
 
+#include "api/scoped_refptr.h"
 #include "modules/video_capture/video_capture.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "test/test_video_capturer.h"
 
 namespace webrtc {
diff --git a/test/win/d3d_renderer.h b/test/win/d3d_renderer.h
index a43be44..9e5e23c3 100644
--- a/test/win/d3d_renderer.h
+++ b/test/win/d3d_renderer.h
@@ -14,7 +14,7 @@
 #include <d3d9.h>
 #pragma comment(lib, "d3d9.lib")  // located in DirectX SDK
 
-#include "rtc_base/scoped_ref_ptr.h"
+#include "api/scoped_refptr.h"
 #include "test/video_renderer.h"
 
 namespace webrtc {
diff --git a/video/BUILD.gn b/video/BUILD.gn
index a56e506..d9667c6 100644
--- a/video/BUILD.gn
+++ b/video/BUILD.gn
@@ -59,6 +59,7 @@
     "../api:array_view",
     "../api:fec_controller_api",
     "../api:libjingle_peerconnection_api",
+    "../api:scoped_refptr",
     "../api:transport_api",
     "../api/video:encoded_image",
     "../api/video:video_bitrate_allocation",
@@ -498,6 +499,7 @@
       "../api:fake_frame_encryptor",
       "../api:libjingle_peerconnection_api",
       "../api:mock_frame_decryptor",
+      "../api:scoped_refptr",
       "../api:simulated_network_api",
       "../api/test/video:function_video_factory",
       "../api/video:builtin_video_bitrate_allocator_factory",
diff --git a/video/receive_statistics_proxy_unittest.cc b/video/receive_statistics_proxy_unittest.cc
index 29e4483..43ee080 100644
--- a/video/receive_statistics_proxy_unittest.cc
+++ b/video/receive_statistics_proxy_unittest.cc
@@ -14,11 +14,11 @@
 #include <memory>
 #include <string>
 
+#include "api/scoped_refptr.h"
 #include "api/video/i420_buffer.h"
 #include "api/video/video_frame.h"
 #include "api/video/video_frame_buffer.h"
 #include "api/video/video_rotation.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "system_wrappers/include/metrics.h"
 #include "test/gtest.h"
 
diff --git a/video/video_send_stream_impl.cc b/video/video_send_stream_impl.cc
index 22c485d..2a8e646 100644
--- a/video/video_send_stream_impl.cc
+++ b/video/video_send_stream_impl.cc
@@ -17,6 +17,7 @@
 
 #include "api/crypto/crypto_options.h"
 #include "api/rtp_parameters.h"
+#include "api/scoped_refptr.h"
 #include "api/video_codecs/video_codec.h"
 #include "call/rtp_transport_controller_send_interface.h"
 #include "call/video_send_stream.h"
@@ -28,7 +29,6 @@
 #include "rtc_base/experiments/rate_control_settings.h"
 #include "rtc_base/logging.h"
 #include "rtc_base/numerics/safe_conversions.h"
-#include "rtc_base/scoped_ref_ptr.h"
 #include "rtc_base/sequenced_task_checker.h"
 #include "rtc_base/thread_checker.h"
 #include "rtc_base/time_utils.h"
diff --git a/video/video_stream_decoder.h b/video/video_stream_decoder.h
index 5a62d2c..114c953 100644
--- a/video/video_stream_decoder.h
+++ b/video/video_stream_decoder.h
@@ -16,12 +16,12 @@
 #include <memory>
 #include <vector>
 
+#include "api/scoped_refptr.h"
 #include "api/video/video_sink_interface.h"
 #include "modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h"
 #include "modules/video_coding/include/video_coding_defines.h"
 #include "rtc_base/critical_section.h"
 #include "rtc_base/platform_thread.h"
-#include "rtc_base/scoped_ref_ptr.h"
 
 namespace webrtc {