From 7c8c4db8ea600e87fae0867b031552a5a8967876 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= Date: Mon, 13 Jun 2022 10:36:38 +0200 Subject: [PATCH] Add rtc::make_ref_counted to api/ This cl adds a forwarding header, a build target, and migrates headers in api/ to use it. Moving actual implementation, will follow, in https://webrtc-review.googlesource.com/c/src/+/265390. Bug: webrtc:12701 Change-Id: Id950725d7d054de8a83b3800b9c9a6437344de86 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/265660 Reviewed-by: Mirko Bonadei Reviewed-by: Tomas Gunnarsson Commit-Queue: Niels Moller Cr-Commit-Position: refs/heads/main@{#37200} --- api/BUILD.gn | 16 ++++++++++-- api/DEPS | 25 +++---------------- api/audio/BUILD.gn | 3 ++- api/audio/echo_detector_creator.cc | 2 +- api/audio_codecs/BUILD.gn | 1 + .../audio_decoder_factory_template.h | 2 +- .../audio_encoder_factory_template.h | 2 +- api/ice_transport_factory.cc | 1 + api/make_ref_counted.h | 18 +++++++++++++ api/rtp_packet_infos.h | 2 +- api/stats_types.cc | 2 +- api/test/fake_frame_decryptor.h | 1 - api/video/BUILD.gn | 4 ++- api/video/encoded_image.cc | 2 -- api/video/i010_buffer.cc | 2 +- api/video/i420_buffer.cc | 2 +- api/video/i422_buffer.cc | 2 +- api/video/i444_buffer.cc | 2 +- api/video/nv12_buffer.cc | 2 +- api/video/recordable_encoded_frame.h | 1 - 20 files changed, 53 insertions(+), 39 deletions(-) create mode 100644 api/make_ref_counted.h diff --git a/api/BUILD.gn b/api/BUILD.gn index 42a9436b30..e1aedd310c 100644 --- a/api/BUILD.gn +++ b/api/BUILD.gn @@ -89,10 +89,10 @@ rtc_library("rtp_packet_info") { ] deps = [ ":array_view", + ":make_ref_counted", ":refcountedbase", ":rtp_headers", ":scoped_refptr", - "../rtc_base:refcount", "../rtc_base/system:rtc_export", "units:timestamp", ] @@ -115,6 +115,7 @@ rtc_library("media_stream_interface") { ] deps = [ ":audio_options_api", + ":make_ref_counted", ":rtp_parameters", ":scoped_refptr", ":sequence_checker", @@ -179,6 +180,7 @@ rtc_library("libjingle_peerconnection_api") { ":field_trials_view", ":frame_transformer_interface", ":libjingle_logging_api", + ":make_ref_counted", ":media_stream_interface", ":network_state_predictor_api", ":packet_socket_factory", @@ -244,6 +246,7 @@ rtc_source_set("frame_transformer_interface") { visibility = [ "*" ] sources = [ "frame_transformer_interface.h" ] deps = [ + ":make_ref_counted", ":scoped_refptr", "../rtc_base:refcount", "video:encoded_frame", @@ -318,6 +321,12 @@ rtc_source_set("scoped_refptr") { sources = [ "scoped_refptr.h" ] } +rtc_source_set("make_ref_counted") { + visibility = [ "*" ] + sources = [ "make_ref_counted.h" ] + deps = [ "../rtc_base:refcount" ] +} + rtc_source_set("video_quality_test_fixture_api") { visibility = [ "*" ] testonly = true @@ -623,6 +632,7 @@ rtc_source_set("rtc_stats_api") { ] deps = [ + ":make_ref_counted", ":scoped_refptr", "../api:refcountedbase", "../rtc_base:checks", @@ -767,6 +777,7 @@ rtc_library("ice_transport_factory") { ] deps = [ ":libjingle_peerconnection_api", + ":make_ref_counted", ":packet_socket_factory", ":scoped_refptr", "../p2p:rtc_p2p", @@ -990,6 +1001,7 @@ if (rtc_include_tests) { deps = [ ":array_view", ":libjingle_peerconnection_api", + ":make_ref_counted", ":rtp_parameters", "../rtc_base:checks", "../rtc_base:refcount", @@ -1007,9 +1019,9 @@ if (rtc_include_tests) { deps = [ ":array_view", ":libjingle_peerconnection_api", + ":make_ref_counted", ":rtp_parameters", "../rtc_base:checks", - "../rtc_base:refcount", "crypto:frame_decryptor_interface", ] } diff --git a/api/DEPS b/api/DEPS index 9db91bef37..69d3a381b1 100644 --- a/api/DEPS +++ b/api/DEPS @@ -143,7 +143,6 @@ specific_include_rules = { "proxy\.h": [ "+rtc_base/event.h", "+rtc_base/message_handler.h", # Inherits from it. - "+rtc_base/ref_counted_object.h", "+rtc_base/thread.h", ], @@ -159,9 +158,6 @@ specific_include_rules = { # For private member and constructor. "+rtc_base/system/file_wrapper.h", ], - "rtp_packet_infos\.h": [ - "+rtc_base/ref_counted_object.h", - ], "rtp_receiver_interface\.h": [ "+rtc_base/ref_count.h", ], @@ -206,10 +202,6 @@ specific_include_rules = { "+rtc_base/ref_count.h", ], - "audio_decoder_factory_template\.h": [ - "+rtc_base/ref_counted_object.h", - ], - "audio_encoder\.h": [ "+rtc_base/buffer.h", ], @@ -218,10 +210,6 @@ specific_include_rules = { "+rtc_base/ref_count.h", ], - "audio_encoder_factory_template\.h": [ - "+rtc_base/ref_counted_object.h", - ], - "frame_decryptor_interface\.h": [ "+rtc_base/ref_count.h", ], @@ -236,7 +224,6 @@ specific_include_rules = { "rtc_stats_report\.h": [ "+rtc_base/ref_count.h", - "+rtc_base/ref_counted_object.h", ], "audioproc_float\.h": [ @@ -247,14 +234,6 @@ specific_include_rules = { "+modules/audio_processing/include/audio_processing.h", ], - "fake_frame_decryptor\.h": [ - "+rtc_base/ref_counted_object.h", - ], - - "fake_frame_encryptor\.h": [ - "+rtc_base/ref_counted_object.h", - ], - "fake_metronome\.h": [ "+rtc_base/synchronization/mutex.h", "+rtc_base/task_queue.h", @@ -262,6 +241,10 @@ specific_include_rules = { "+rtc_base/thread_annotations.h", ], + "make_ref_counted\.h": [ + "+rtc_base/ref_counted_object.h", + ], + "mock.*\.h": [ "+test/gmock.h", ], diff --git a/api/audio/BUILD.gn b/api/audio/BUILD.gn index 7220106d3c..4832751b5f 100644 --- a/api/audio/BUILD.gn +++ b/api/audio/BUILD.gn @@ -37,6 +37,7 @@ rtc_source_set("audio_mixer_api") { deps = [ ":audio_frame_api", + "..:make_ref_counted", "../../rtc_base:refcount", ] } @@ -102,9 +103,9 @@ rtc_source_set("echo_detector_creator") { "echo_detector_creator.h", ] deps = [ + "..:make_ref_counted", "../../api:scoped_refptr", "../../modules/audio_processing:api", "../../modules/audio_processing:residual_echo_detector", - "../../rtc_base:refcount", ] } diff --git a/api/audio/echo_detector_creator.cc b/api/audio/echo_detector_creator.cc index 04215b0deb..15b7c51dca 100644 --- a/api/audio/echo_detector_creator.cc +++ b/api/audio/echo_detector_creator.cc @@ -9,8 +9,8 @@ */ #include "api/audio/echo_detector_creator.h" +#include "api/make_ref_counted.h" #include "modules/audio_processing/residual_echo_detector.h" -#include "rtc_base/ref_counted_object.h" namespace webrtc { diff --git a/api/audio_codecs/BUILD.gn b/api/audio_codecs/BUILD.gn index ec358e12e2..5aa6ea44ad 100644 --- a/api/audio_codecs/BUILD.gn +++ b/api/audio_codecs/BUILD.gn @@ -31,6 +31,7 @@ rtc_library("audio_codecs_api") { deps = [ "..:array_view", "..:bitrate_allocation", + "..:make_ref_counted", "..:scoped_refptr", "../../api:field_trials_view", "../../rtc_base:buffer", diff --git a/api/audio_codecs/audio_decoder_factory_template.h b/api/audio_codecs/audio_decoder_factory_template.h index 4e39365182..7ea0c91372 100644 --- a/api/audio_codecs/audio_decoder_factory_template.h +++ b/api/audio_codecs/audio_decoder_factory_template.h @@ -16,8 +16,8 @@ #include "api/audio_codecs/audio_decoder_factory.h" #include "api/field_trials_view.h" +#include "api/make_ref_counted.h" #include "api/scoped_refptr.h" -#include "rtc_base/ref_counted_object.h" namespace webrtc { diff --git a/api/audio_codecs/audio_encoder_factory_template.h b/api/audio_codecs/audio_encoder_factory_template.h index 8490f46b7d..8a70ba2268 100644 --- a/api/audio_codecs/audio_encoder_factory_template.h +++ b/api/audio_codecs/audio_encoder_factory_template.h @@ -16,8 +16,8 @@ #include "api/audio_codecs/audio_encoder_factory.h" #include "api/field_trials_view.h" +#include "api/make_ref_counted.h" #include "api/scoped_refptr.h" -#include "rtc_base/ref_counted_object.h" namespace webrtc { diff --git a/api/ice_transport_factory.cc b/api/ice_transport_factory.cc index 9e7e629a6f..e88ac183fa 100644 --- a/api/ice_transport_factory.cc +++ b/api/ice_transport_factory.cc @@ -13,6 +13,7 @@ #include #include +#include "api/make_ref_counted.h" #include "p2p/base/ice_transport_internal.h" #include "p2p/base/p2p_constants.h" #include "p2p/base/p2p_transport_channel.h" diff --git a/api/make_ref_counted.h b/api/make_ref_counted.h new file mode 100644 index 0000000000..e6bdf528ce --- /dev/null +++ b/api/make_ref_counted.h @@ -0,0 +1,18 @@ +/* + * Copyright 2022 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 API_MAKE_REF_COUNTED_H_ +#define API_MAKE_REF_COUNTED_H_ + +#include "rtc_base/ref_counted_object.h" + +// TODO(bugs.webrtc.org/12701): Move implementation of make_ref_counted to this +// file. + +#endif // API_MAKE_REF_COUNTED_H_ diff --git a/api/rtp_packet_infos.h b/api/rtp_packet_infos.h index 031e33332e..7445729fbb 100644 --- a/api/rtp_packet_infos.h +++ b/api/rtp_packet_infos.h @@ -15,10 +15,10 @@ #include #include +#include "api/make_ref_counted.h" #include "api/ref_counted_base.h" #include "api/rtp_packet_info.h" #include "api/scoped_refptr.h" -#include "rtc_base/ref_counted_object.h" #include "rtc_base/system/rtc_export.h" namespace webrtc { diff --git a/api/stats_types.cc b/api/stats_types.cc index 8f69e5f876..61a0b8499d 100644 --- a/api/stats_types.cc +++ b/api/stats_types.cc @@ -13,8 +13,8 @@ #include #include "absl/algorithm/container.h" +#include "api/make_ref_counted.h" #include "rtc_base/checks.h" -#include "rtc_base/ref_counted_object.h" #include "rtc_base/string_encode.h" // TODO(tommi): Could we have a static map of value name -> expected type diff --git a/api/test/fake_frame_decryptor.h b/api/test/fake_frame_decryptor.h index cb58dd6c99..783bc805c4 100644 --- a/api/test/fake_frame_decryptor.h +++ b/api/test/fake_frame_decryptor.h @@ -19,7 +19,6 @@ #include "api/array_view.h" #include "api/crypto/frame_decryptor_interface.h" #include "api/media_types.h" -#include "rtc_base/ref_counted_object.h" namespace webrtc { diff --git a/api/video/BUILD.gn b/api/video/BUILD.gn index 6057a7386d..fb7bfc637e 100644 --- a/api/video/BUILD.gn +++ b/api/video/BUILD.gn @@ -65,6 +65,7 @@ rtc_library("video_frame") { deps = [ ":video_rtp_headers", "..:array_view", + "..:make_ref_counted", "..:rtp_packet_info", "..:scoped_refptr", "..:video_track_source_constraints", @@ -93,6 +94,7 @@ rtc_library("video_frame_i010") { deps = [ ":video_frame", ":video_rtp_headers", + "..:make_ref_counted", "..:scoped_refptr", "../../rtc_base", "../../rtc_base:checks", @@ -111,8 +113,8 @@ rtc_source_set("recordable_encoded_frame") { ":video_frame", ":video_rtp_headers", "..:array_view", + "..:make_ref_counted", "..:scoped_refptr", - "../../rtc_base:refcount", "../units:timestamp", ] } diff --git a/api/video/encoded_image.cc b/api/video/encoded_image.cc index fc77b9415b..ff61994dee 100644 --- a/api/video/encoded_image.cc +++ b/api/video/encoded_image.cc @@ -13,8 +13,6 @@ #include #include -#include "rtc_base/ref_counted_object.h" - namespace webrtc { EncodedImageBuffer::EncodedImageBuffer(size_t size) : size_(size) { diff --git a/api/video/i010_buffer.cc b/api/video/i010_buffer.cc index b98e586562..32507febed 100644 --- a/api/video/i010_buffer.cc +++ b/api/video/i010_buffer.cc @@ -11,9 +11,9 @@ #include +#include "api/make_ref_counted.h" #include "api/video/i420_buffer.h" #include "rtc_base/checks.h" -#include "rtc_base/ref_counted_object.h" #include "third_party/libyuv/include/libyuv/convert.h" #include "third_party/libyuv/include/libyuv/scale.h" diff --git a/api/video/i420_buffer.cc b/api/video/i420_buffer.cc index deecf1d71d..bf7fc06ee9 100644 --- a/api/video/i420_buffer.cc +++ b/api/video/i420_buffer.cc @@ -14,8 +14,8 @@ #include #include +#include "api/make_ref_counted.h" #include "rtc_base/checks.h" -#include "rtc_base/ref_counted_object.h" #include "third_party/libyuv/include/libyuv/convert.h" #include "third_party/libyuv/include/libyuv/planar_functions.h" #include "third_party/libyuv/include/libyuv/scale.h" diff --git a/api/video/i422_buffer.cc b/api/video/i422_buffer.cc index d6cf0d6c97..d387a4c4e9 100644 --- a/api/video/i422_buffer.cc +++ b/api/video/i422_buffer.cc @@ -14,9 +14,9 @@ #include #include +#include "api/make_ref_counted.h" #include "api/video/i420_buffer.h" #include "rtc_base/checks.h" -#include "rtc_base/ref_counted_object.h" #include "third_party/libyuv/include/libyuv/convert.h" #include "third_party/libyuv/include/libyuv/planar_functions.h" #include "third_party/libyuv/include/libyuv/scale.h" diff --git a/api/video/i444_buffer.cc b/api/video/i444_buffer.cc index 8bf9f76625..98e892308f 100644 --- a/api/video/i444_buffer.cc +++ b/api/video/i444_buffer.cc @@ -14,9 +14,9 @@ #include #include +#include "api/make_ref_counted.h" #include "api/video/i420_buffer.h" #include "rtc_base/checks.h" -#include "rtc_base/ref_counted_object.h" #include "third_party/libyuv/include/libyuv/convert.h" #include "third_party/libyuv/include/libyuv/planar_functions.h" #include "third_party/libyuv/include/libyuv/scale.h" diff --git a/api/video/nv12_buffer.cc b/api/video/nv12_buffer.cc index 37d688b88b..ca9dcd8677 100644 --- a/api/video/nv12_buffer.cc +++ b/api/video/nv12_buffer.cc @@ -10,9 +10,9 @@ #include "api/video/nv12_buffer.h" +#include "api/make_ref_counted.h" #include "api/video/i420_buffer.h" #include "rtc_base/checks.h" -#include "rtc_base/ref_counted_object.h" #include "third_party/libyuv/include/libyuv/convert.h" #include "third_party/libyuv/include/libyuv/scale.h" diff --git a/api/video/recordable_encoded_frame.h b/api/video/recordable_encoded_frame.h index b4ad83a344..702f4d73e6 100644 --- a/api/video/recordable_encoded_frame.h +++ b/api/video/recordable_encoded_frame.h @@ -17,7 +17,6 @@ #include "api/video/color_space.h" #include "api/video/encoded_image.h" #include "api/video/video_codec_type.h" -#include "rtc_base/ref_count.h" namespace webrtc {