diff --git a/modules/audio_processing/BUILD.gn b/modules/audio_processing/BUILD.gn index ca55fec181..24c66b1a23 100644 --- a/modules/audio_processing/BUILD.gn +++ b/modules/audio_processing/BUILD.gn @@ -311,7 +311,10 @@ rtc_library("apm_logging") { "../../rtc_base:checks", "../../rtc_base:stringutils", ] - absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ] + absl_deps = [ + "//third_party/abseil-cpp/absl/strings", + "//third_party/abseil-cpp/absl/types:optional", + ] defines = [] } @@ -425,7 +428,10 @@ if (rtc_include_tests) { "vad:vad_unittests", "//testing/gtest", ] - absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ] + absl_deps = [ + "//third_party/abseil-cpp/absl/strings", + "//third_party/abseil-cpp/absl/types:optional", + ] defines = [] @@ -498,6 +504,7 @@ if (rtc_include_tests) { "../../test:perf_test", "../../test:test_support", ] + absl_deps = [ "//third_party/abseil-cpp/absl/strings" ] } rtc_library("analog_mic_simulation") { @@ -648,5 +655,8 @@ rtc_library("audioproc_test_utils") { "../audio_coding:neteq_input_audio_tools", "//testing/gtest", ] - absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ] + absl_deps = [ + "//third_party/abseil-cpp/absl/strings", + "//third_party/abseil-cpp/absl/types:optional", + ] } diff --git a/modules/audio_processing/aec3/BUILD.gn b/modules/audio_processing/aec3/BUILD.gn index 4de2d00f3e..679ce48747 100644 --- a/modules/audio_processing/aec3/BUILD.gn +++ b/modules/audio_processing/aec3/BUILD.gn @@ -157,7 +157,10 @@ rtc_library("aec3") { "../../../system_wrappers:metrics", "../utility:cascaded_biquad_filter", ] - absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ] + absl_deps = [ + "//third_party/abseil-cpp/absl/strings", + "//third_party/abseil-cpp/absl/types:optional", + ] if (current_cpu == "x86" || current_cpu == "x64") { deps += [ ":aec3_avx2" ] @@ -208,6 +211,7 @@ rtc_source_set("adaptive_fir_filter") { "../../../api:array_view", "../../../rtc_base/system:arch", ] + absl_deps = [ "//third_party/abseil-cpp/absl/strings" ] } rtc_source_set("adaptive_fir_filter_erl") { diff --git a/modules/audio_processing/aec3/adaptive_fir_filter.h b/modules/audio_processing/aec3/adaptive_fir_filter.h index 7597709460..34c06f4367 100644 --- a/modules/audio_processing/aec3/adaptive_fir_filter.h +++ b/modules/audio_processing/aec3/adaptive_fir_filter.h @@ -16,6 +16,7 @@ #include #include +#include "absl/strings/string_view.h" #include "api/array_view.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/aec3/aec3_fft.h" @@ -141,7 +142,7 @@ class AdaptiveFirFilter { // Returns the maximum number of partitions for the filter. size_t max_filter_size_partitions() const { return max_size_partitions_; } - void DumpFilter(const char* name_frequency_domain) { + void DumpFilter(absl::string_view name_frequency_domain) { for (size_t p = 0; p < max_size_partitions_; ++p) { data_dumper_->DumpRaw(name_frequency_domain, H_[p][0].re); data_dumper_->DumpRaw(name_frequency_domain, H_[p][0].im); diff --git a/modules/audio_processing/aec3/echo_canceller3.cc b/modules/audio_processing/aec3/echo_canceller3.cc index 1404a9987d..e8e2175994 100644 --- a/modules/audio_processing/aec3/echo_canceller3.cc +++ b/modules/audio_processing/aec3/echo_canceller3.cc @@ -12,6 +12,7 @@ #include #include +#include "absl/strings/string_view.h" #include "modules/audio_processing/aec3/aec3_common.h" #include "modules/audio_processing/high_pass_filter.h" #include "modules/audio_processing/logging/apm_data_dumper.h" @@ -37,7 +38,7 @@ bool DetectSaturation(rtc::ArrayView y) { // Retrieves a value from a field trial if it is available. If no value is // present, the default value is returned. If the retrieved value is beyond the // specified limits, the default value is returned instead. -void RetrieveFieldTrialValue(const char* trial_name, +void RetrieveFieldTrialValue(absl::string_view trial_name, float min, float max, float* value_to_update) { @@ -57,7 +58,7 @@ void RetrieveFieldTrialValue(const char* trial_name, } } -void RetrieveFieldTrialValue(const char* trial_name, +void RetrieveFieldTrialValue(absl::string_view trial_name, int min, int max, int* value_to_update) { diff --git a/modules/audio_processing/aec_dump/BUILD.gn b/modules/audio_processing/aec_dump/BUILD.gn index 38dac711cb..38d8776258 100644 --- a/modules/audio_processing/aec_dump/BUILD.gn +++ b/modules/audio_processing/aec_dump/BUILD.gn @@ -17,6 +17,7 @@ rtc_source_set("aec_dump") { "../../../rtc_base/system:file_wrapper", "../../../rtc_base/system:rtc_export", ] + absl_deps = [ "//third_party/abseil-cpp/absl/strings" ] } if (rtc_include_tests) { @@ -75,6 +76,7 @@ if (rtc_enable_protobuf) { "../../../rtc_base/system:file_wrapper", "../../../system_wrappers", ] + absl_deps = [ "//third_party/abseil-cpp/absl/strings" ] deps += [ "../:audioproc_debug_proto" ] } @@ -106,4 +108,5 @@ rtc_library("null_aec_dump_factory") { ":aec_dump", "..:aec_dump_interface", ] + absl_deps = [ "//third_party/abseil-cpp/absl/strings" ] } diff --git a/modules/audio_processing/aec_dump/aec_dump_factory.h b/modules/audio_processing/aec_dump/aec_dump_factory.h index b0ec839214..20718c3d7f 100644 --- a/modules/audio_processing/aec_dump/aec_dump_factory.h +++ b/modules/audio_processing/aec_dump/aec_dump_factory.h @@ -12,8 +12,8 @@ #define MODULES_AUDIO_PROCESSING_AEC_DUMP_AEC_DUMP_FACTORY_H_ #include -#include +#include "absl/strings/string_view.h" #include "modules/audio_processing/include/aec_dump.h" #include "rtc_base/system/file_wrapper.h" #include "rtc_base/system/rtc_export.h" @@ -35,7 +35,7 @@ class RTC_EXPORT AecDumpFactory { static std::unique_ptr Create(webrtc::FileWrapper file, int64_t max_log_size_bytes, rtc::TaskQueue* worker_queue); - static std::unique_ptr Create(std::string file_name, + static std::unique_ptr Create(absl::string_view file_name, int64_t max_log_size_bytes, rtc::TaskQueue* worker_queue); static std::unique_ptr Create(FILE* handle, diff --git a/modules/audio_processing/aec_dump/aec_dump_impl.cc b/modules/audio_processing/aec_dump/aec_dump_impl.cc index 32f214be38..94c24048e0 100644 --- a/modules/audio_processing/aec_dump/aec_dump_impl.cc +++ b/modules/audio_processing/aec_dump/aec_dump_impl.cc @@ -13,6 +13,7 @@ #include #include +#include "absl/strings/string_view.h" #include "modules/audio_processing/aec_dump/aec_dump_factory.h" #include "rtc_base/checks.h" #include "rtc_base/event.h" @@ -264,7 +265,7 @@ std::unique_ptr AecDumpFactory::Create(webrtc::FileWrapper file, worker_queue); } -std::unique_ptr AecDumpFactory::Create(std::string file_name, +std::unique_ptr AecDumpFactory::Create(absl::string_view file_name, int64_t max_log_size_bytes, rtc::TaskQueue* worker_queue) { return Create(FileWrapper::OpenWriteOnly(file_name), max_log_size_bytes, diff --git a/modules/audio_processing/aec_dump/null_aec_dump_factory.cc b/modules/audio_processing/aec_dump/null_aec_dump_factory.cc index 126adeb4eb..9bd9745069 100644 --- a/modules/audio_processing/aec_dump/null_aec_dump_factory.cc +++ b/modules/audio_processing/aec_dump/null_aec_dump_factory.cc @@ -8,6 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include "absl/strings/string_view.h" #include "modules/audio_processing/aec_dump/aec_dump_factory.h" #include "modules/audio_processing/include/aec_dump.h" @@ -19,7 +20,7 @@ std::unique_ptr AecDumpFactory::Create(webrtc::FileWrapper file, return nullptr; } -std::unique_ptr AecDumpFactory::Create(std::string file_name, +std::unique_ptr AecDumpFactory::Create(absl::string_view file_name, int64_t max_log_size_bytes, rtc::TaskQueue* worker_queue) { return nullptr; diff --git a/modules/audio_processing/agc/BUILD.gn b/modules/audio_processing/agc/BUILD.gn index 1142f36d35..70190cf818 100644 --- a/modules/audio_processing/agc/BUILD.gn +++ b/modules/audio_processing/agc/BUILD.gn @@ -185,6 +185,9 @@ if (rtc_include_tests) { "../../../test:test_support", "//testing/gtest", ] - absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ] + absl_deps = [ + "//third_party/abseil-cpp/absl/strings", + "//third_party/abseil-cpp/absl/types:optional", + ] } } diff --git a/modules/audio_processing/agc/loudness_histogram_unittest.cc b/modules/audio_processing/agc/loudness_histogram_unittest.cc index af193ee8f1..bbc0a7ee92 100644 --- a/modules/audio_processing/agc/loudness_histogram_unittest.cc +++ b/modules/audio_processing/agc/loudness_histogram_unittest.cc @@ -17,7 +17,9 @@ #include #include #include +#include +#include "absl/strings/string_view.h" #include "modules/audio_processing/agc/utility.h" #include "test/gtest.h" #include "test/testsupport/file_utils.h" @@ -35,7 +37,7 @@ const double kRelativeErrTol = 1e-10; class LoudnessHistogramTest : public ::testing::Test { protected: - void RunTest(bool enable_circular_buff, const char* filename); + void RunTest(bool enable_circular_buff, absl::string_view filename); private: void TestClean(); @@ -49,8 +51,8 @@ void LoudnessHistogramTest::TestClean() { } void LoudnessHistogramTest::RunTest(bool enable_circular_buff, - const char* filename) { - FILE* in_file = fopen(filename, "rb"); + absl::string_view filename) { + FILE* in_file = fopen(std::string(filename).c_str(), "rb"); ASSERT_TRUE(in_file != NULL); if (enable_circular_buff) { int buffer_size; diff --git a/modules/audio_processing/agc2/BUILD.gn b/modules/audio_processing/agc2/BUILD.gn index 4e40736d52..64a7b38c02 100644 --- a/modules/audio_processing/agc2/BUILD.gn +++ b/modules/audio_processing/agc2/BUILD.gn @@ -101,8 +101,10 @@ rtc_library("fixed_digital") { "../../../rtc_base:gtest_prod", "../../../rtc_base:safe_conversions", "../../../rtc_base:safe_minmax", + "../../../rtc_base:stringutils", "../../../system_wrappers:metrics", ] + absl_deps = [ "//third_party/abseil-cpp/absl/strings" ] } rtc_library("gain_applier") { diff --git a/modules/audio_processing/agc2/interpolated_gain_curve.cc b/modules/audio_processing/agc2/interpolated_gain_curve.cc index b522ec372c..bb6e038514 100644 --- a/modules/audio_processing/agc2/interpolated_gain_curve.cc +++ b/modules/audio_processing/agc2/interpolated_gain_curve.cc @@ -13,9 +13,11 @@ #include #include +#include "absl/strings/string_view.h" #include "modules/audio_processing/agc2/agc2_common.h" #include "modules/audio_processing/logging/apm_data_dumper.h" #include "rtc_base/checks.h" +#include "rtc_base/strings/string_builder.h" namespace webrtc { @@ -30,15 +32,21 @@ constexpr std::array InterpolatedGainCurve::InterpolatedGainCurve( ApmDataDumper* apm_data_dumper, - const std::string& histogram_name_prefix) - : region_logger_("WebRTC.Audio." + histogram_name_prefix + - ".FixedDigitalGainCurveRegion.Identity", - "WebRTC.Audio." + histogram_name_prefix + - ".FixedDigitalGainCurveRegion.Knee", - "WebRTC.Audio." + histogram_name_prefix + - ".FixedDigitalGainCurveRegion.Limiter", - "WebRTC.Audio." + histogram_name_prefix + - ".FixedDigitalGainCurveRegion.Saturation"), + absl::string_view histogram_name_prefix) + : region_logger_( + (rtc::StringBuilder("WebRTC.Audio.") + << histogram_name_prefix << ".FixedDigitalGainCurveRegion.Identity") + .str(), + (rtc::StringBuilder("WebRTC.Audio.") + << histogram_name_prefix << ".FixedDigitalGainCurveRegion.Knee") + .str(), + (rtc::StringBuilder("WebRTC.Audio.") + << histogram_name_prefix << ".FixedDigitalGainCurveRegion.Limiter") + .str(), + (rtc::StringBuilder("WebRTC.Audio.") + << histogram_name_prefix + << ".FixedDigitalGainCurveRegion.Saturation") + .str()), apm_data_dumper_(apm_data_dumper) {} InterpolatedGainCurve::~InterpolatedGainCurve() { @@ -57,10 +65,10 @@ InterpolatedGainCurve::~InterpolatedGainCurve() { } InterpolatedGainCurve::RegionLogger::RegionLogger( - const std::string& identity_histogram_name, - const std::string& knee_histogram_name, - const std::string& limiter_histogram_name, - const std::string& saturation_histogram_name) + absl::string_view identity_histogram_name, + absl::string_view knee_histogram_name, + absl::string_view limiter_histogram_name, + absl::string_view saturation_histogram_name) : identity_histogram( metrics::HistogramFactoryGetCounts(identity_histogram_name, 1, diff --git a/modules/audio_processing/agc2/interpolated_gain_curve.h b/modules/audio_processing/agc2/interpolated_gain_curve.h index b1a5cf473b..8dd3e48f21 100644 --- a/modules/audio_processing/agc2/interpolated_gain_curve.h +++ b/modules/audio_processing/agc2/interpolated_gain_curve.h @@ -12,8 +12,8 @@ #define MODULES_AUDIO_PROCESSING_AGC2_INTERPOLATED_GAIN_CURVE_H_ #include -#include +#include "absl/strings/string_view.h" #include "modules/audio_processing/agc2/agc2_common.h" #include "rtc_base/gtest_prod_util.h" #include "system_wrappers/include/metrics.h" @@ -60,7 +60,7 @@ class InterpolatedGainCurve { }; InterpolatedGainCurve(ApmDataDumper* apm_data_dumper, - const std::string& histogram_name_prefix); + absl::string_view histogram_name_prefix); ~InterpolatedGainCurve(); InterpolatedGainCurve(const InterpolatedGainCurve&) = delete; @@ -86,10 +86,10 @@ class InterpolatedGainCurve { metrics::Histogram* limiter_histogram; metrics::Histogram* saturation_histogram; - RegionLogger(const std::string& identity_histogram_name, - const std::string& knee_histogram_name, - const std::string& limiter_histogram_name, - const std::string& saturation_histogram_name); + RegionLogger(absl::string_view identity_histogram_name, + absl::string_view knee_histogram_name, + absl::string_view limiter_histogram_name, + absl::string_view saturation_histogram_name); ~RegionLogger(); diff --git a/modules/audio_processing/agc2/limiter.cc b/modules/audio_processing/agc2/limiter.cc index 57580924dc..7a1e2202be 100644 --- a/modules/audio_processing/agc2/limiter.cc +++ b/modules/audio_processing/agc2/limiter.cc @@ -14,6 +14,7 @@ #include #include +#include "absl/strings/string_view.h" #include "api/array_view.h" #include "modules/audio_processing/agc2/agc2_common.h" #include "modules/audio_processing/logging/apm_data_dumper.h" @@ -95,7 +96,7 @@ void CheckLimiterSampleRate(int sample_rate_hz) { Limiter::Limiter(int sample_rate_hz, ApmDataDumper* apm_data_dumper, - const std::string& histogram_name) + absl::string_view histogram_name) : interp_gain_curve_(apm_data_dumper, histogram_name), level_estimator_(sample_rate_hz, apm_data_dumper), apm_data_dumper_(apm_data_dumper) { diff --git a/modules/audio_processing/agc2/limiter.h b/modules/audio_processing/agc2/limiter.h index 669e202c20..d4d556349c 100644 --- a/modules/audio_processing/agc2/limiter.h +++ b/modules/audio_processing/agc2/limiter.h @@ -11,9 +11,9 @@ #ifndef MODULES_AUDIO_PROCESSING_AGC2_LIMITER_H_ #define MODULES_AUDIO_PROCESSING_AGC2_LIMITER_H_ -#include #include +#include "absl/strings/string_view.h" #include "modules/audio_processing/agc2/fixed_digital_level_estimator.h" #include "modules/audio_processing/agc2/interpolated_gain_curve.h" #include "modules/audio_processing/include/audio_frame_view.h" @@ -25,7 +25,7 @@ class Limiter { public: Limiter(int sample_rate_hz, ApmDataDumper* apm_data_dumper, - const std::string& histogram_name_prefix); + absl::string_view histogram_name_prefix); Limiter(const Limiter& limiter) = delete; Limiter& operator=(const Limiter& limiter) = delete; ~Limiter(); diff --git a/modules/audio_processing/agc2/rnn_vad/BUILD.gn b/modules/audio_processing/agc2/rnn_vad/BUILD.gn index 9d62e2ff51..9093a68cf3 100644 --- a/modules/audio_processing/agc2/rnn_vad/BUILD.gn +++ b/modules/audio_processing/agc2/rnn_vad/BUILD.gn @@ -230,6 +230,7 @@ if (rtc_include_tests) { "../../../../test:fileutils", "../../../../test:test_support", ] + absl_deps = [ "//third_party/abseil-cpp/absl/strings" ] } unittest_resources = [ diff --git a/modules/audio_processing/agc2/rnn_vad/test_utils.cc b/modules/audio_processing/agc2/rnn_vad/test_utils.cc index b8ca9c3669..857a9f2706 100644 --- a/modules/audio_processing/agc2/rnn_vad/test_utils.cc +++ b/modules/audio_processing/agc2/rnn_vad/test_utils.cc @@ -13,9 +13,11 @@ #include #include #include +#include #include #include +#include "absl/strings/string_view.h" #include "rtc_base/checks.h" #include "rtc_base/numerics/safe_compare.h" #include "test/gtest.h" @@ -31,8 +33,8 @@ template class FloatFileReader : public FileReader { public: static_assert(std::is_arithmetic::value, ""); - FloatFileReader(const std::string& filename) - : is_(filename, std::ios::binary | std::ios::ate), + explicit FloatFileReader(absl::string_view filename) + : is_(std::string(filename), std::ios::binary | std::ios::ate), size_(is_.tellg() / sizeof(T)) { RTC_CHECK(is_); SeekBeginning(); diff --git a/modules/audio_processing/agc2/rnn_vad/test_utils.h b/modules/audio_processing/agc2/rnn_vad/test_utils.h index e366e1837e..e64b7b7ecd 100644 --- a/modules/audio_processing/agc2/rnn_vad/test_utils.h +++ b/modules/audio_processing/agc2/rnn_vad/test_utils.h @@ -16,6 +16,7 @@ #include #include +#include "absl/strings/string_view.h" #include "api/array_view.h" #include "modules/audio_processing/agc2/rnn_vad/common.h" #include "rtc_base/checks.h" @@ -109,8 +110,8 @@ class PitchTestData { // Writer for binary files. class FileWriter { public: - explicit FileWriter(const std::string& file_path) - : os_(file_path, std::ios::binary) {} + explicit FileWriter(absl::string_view file_path) + : os_(std::string(file_path), std::ios::binary) {} FileWriter(const FileWriter&) = delete; FileWriter& operator=(const FileWriter&) = delete; ~FileWriter() = default; diff --git a/modules/audio_processing/audio_processing_impl.cc b/modules/audio_processing/audio_processing_impl.cc index 762980bd46..57d51a2a65 100644 --- a/modules/audio_processing/audio_processing_impl.cc +++ b/modules/audio_processing/audio_processing_impl.cc @@ -1654,8 +1654,8 @@ int AudioProcessingImpl::recommended_stream_analog_level_locked() const { bool AudioProcessingImpl::CreateAndAttachAecDump(absl::string_view file_name, int64_t max_log_size_bytes, rtc::TaskQueue* worker_queue) { - std::unique_ptr aec_dump = AecDumpFactory::Create( - std::string(file_name), max_log_size_bytes, worker_queue); + std::unique_ptr aec_dump = + AecDumpFactory::Create(file_name, max_log_size_bytes, worker_queue); if (!aec_dump) { return false; } diff --git a/modules/audio_processing/audio_processing_performance_unittest.cc b/modules/audio_processing/audio_processing_performance_unittest.cc index 49e435f6f8..51d1962875 100644 --- a/modules/audio_processing/audio_processing_performance_unittest.cc +++ b/modules/audio_processing/audio_processing_performance_unittest.cc @@ -14,6 +14,7 @@ #include #include +#include "absl/strings/string_view.h" #include "api/array_view.h" #include "modules/audio_processing/audio_processing_impl.h" #include "modules/audio_processing/test/audio_processing_builder_for_testing.h" @@ -212,7 +213,7 @@ class TimedThreadApiProcessor { bool Process(); // Method for printing out the simulation statistics. - void print_processor_statistics(const std::string& processor_name) const { + void print_processor_statistics(absl::string_view processor_name) const { const std::string modifier = "_api_call_duration"; const std::string sample_rate_name = diff --git a/modules/audio_processing/audio_processing_unittest.cc b/modules/audio_processing/audio_processing_unittest.cc index 5c934338ff..a0514744c4 100644 --- a/modules/audio_processing/audio_processing_unittest.cc +++ b/modules/audio_processing/audio_processing_unittest.cc @@ -18,8 +18,10 @@ #include #include #include +#include #include "absl/flags/flag.h" +#include "absl/strings/string_view.h" #include "api/audio/echo_detector_creator.h" #include "api/make_ref_counted.h" #include "common_audio/include/audio_util.h" @@ -202,9 +204,9 @@ int16_t MaxAudioFrame(const Int16FrameData& frame) { return max_data; } -void OpenFileAndWriteMessage(const std::string& filename, +void OpenFileAndWriteMessage(absl::string_view filename, const MessageLite& msg) { - FILE* file = fopen(filename.c_str(), "wb"); + FILE* file = fopen(std::string(filename).c_str(), "wb"); ASSERT_TRUE(file != NULL); int32_t size = rtc::checked_cast(msg.ByteSizeLong()); @@ -218,7 +220,7 @@ void OpenFileAndWriteMessage(const std::string& filename, fclose(file); } -std::string ResourceFilePath(const std::string& name, int sample_rate_hz) { +std::string ResourceFilePath(absl::string_view name, int sample_rate_hz) { rtc::StringBuilder ss; // Resource files are all stereo. ss << name << sample_rate_hz / 1000 << "_stereo"; @@ -230,7 +232,7 @@ std::string ResourceFilePath(const std::string& name, int sample_rate_hz) { // have competing filenames. std::map temp_filenames; -std::string OutputFilePath(const std::string& name, +std::string OutputFilePath(absl::string_view name, int input_rate, int output_rate, int reverse_input_rate, @@ -285,8 +287,8 @@ void ClearTempOutFiles() { } } -void OpenFileAndReadMessage(const std::string& filename, MessageLite* msg) { - FILE* file = fopen(filename.c_str(), "rb"); +void OpenFileAndReadMessage(absl::string_view filename, MessageLite* msg) { + FILE* file = fopen(std::string(filename).c_str(), "rb"); ASSERT_TRUE(file != NULL); ReadMessageFromFile(file, msg); fclose(file); @@ -447,8 +449,8 @@ class ApmTest : public ::testing::Test { void StreamParametersTest(Format format); int ProcessStreamChooser(Format format); int AnalyzeReverseStreamChooser(Format format); - void ProcessDebugDump(const std::string& in_filename, - const std::string& out_filename, + void ProcessDebugDump(absl::string_view in_filename, + absl::string_view out_filename, Format format, int max_size_bytes); void VerifyDebugDumpTest(Format format); @@ -1457,12 +1459,12 @@ TEST_F(ApmTest, SplittingFilter) { } #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP -void ApmTest::ProcessDebugDump(const std::string& in_filename, - const std::string& out_filename, +void ApmTest::ProcessDebugDump(absl::string_view in_filename, + absl::string_view out_filename, Format format, int max_size_bytes) { TaskQueueForTest worker_queue("ApmTest_worker_queue"); - FILE* in_file = fopen(in_filename.c_str(), "rb"); + FILE* in_file = fopen(std::string(in_filename).c_str(), "rb"); ASSERT_TRUE(in_file != NULL); audioproc::Event event_msg; bool first_init = true; @@ -1990,7 +1992,7 @@ class AudioProcessingTest size_t num_output_channels, size_t num_reverse_input_channels, size_t num_reverse_output_channels, - const std::string& output_file_prefix) { + absl::string_view output_file_prefix) { AudioProcessing::Config apm_config; apm_config.gain_controller1.analog_gain_controller.enabled = false; rtc::scoped_refptr ap = diff --git a/modules/audio_processing/logging/apm_data_dumper.cc b/modules/audio_processing/logging/apm_data_dumper.cc index 445248b0bf..65d2167d37 100644 --- a/modules/audio_processing/logging/apm_data_dumper.cc +++ b/modules/audio_processing/logging/apm_data_dumper.cc @@ -10,6 +10,7 @@ #include "modules/audio_processing/logging/apm_data_dumper.h" +#include "absl/strings/string_view.h" #include "rtc_base/strings/string_builder.h" // Check to verify that the define is properly set. @@ -29,17 +30,16 @@ constexpr char kPathDelimiter = '\\'; constexpr char kPathDelimiter = '/'; #endif -std::string FormFileName(const char* output_dir, - const char* name, +std::string FormFileName(absl::string_view output_dir, + absl::string_view name, int instance_index, int reinit_index, - const std::string& suffix) { + absl::string_view suffix) { char buf[1024]; rtc::SimpleStringBuilder ss(buf); - const size_t output_dir_size = strlen(output_dir); - if (output_dir_size > 0) { + if (!output_dir.empty()) { ss << output_dir; - if (output_dir[output_dir_size - 1] != kPathDelimiter) { + if (output_dir.back() != kPathDelimiter) { ss << kPathDelimiter; } } @@ -64,7 +64,7 @@ bool ApmDataDumper::recording_activated_ = false; absl::optional ApmDataDumper::dump_set_to_use_; char ApmDataDumper::output_dir_[] = ""; -FILE* ApmDataDumper::GetRawFile(const char* name) { +FILE* ApmDataDumper::GetRawFile(absl::string_view name) { std::string filename = FormFileName(output_dir_, name, instance_index_, recording_set_index_, ".dat"); auto& f = raw_files_[filename]; @@ -75,7 +75,7 @@ FILE* ApmDataDumper::GetRawFile(const char* name) { return f.get(); } -WavWriter* ApmDataDumper::GetWavFile(const char* name, +WavWriter* ApmDataDumper::GetWavFile(absl::string_view name, int sample_rate_hz, int num_channels, WavFile::SampleFormat format) { diff --git a/modules/audio_processing/logging/apm_data_dumper.h b/modules/audio_processing/logging/apm_data_dumper.h index 9c2ac3be5d..4ab6baad83 100644 --- a/modules/audio_processing/logging/apm_data_dumper.h +++ b/modules/audio_processing/logging/apm_data_dumper.h @@ -13,19 +13,20 @@ #include #include -#include -#include #if WEBRTC_APM_DEBUG_DUMP == 1 #include +#include #include #endif +#include "absl/strings/string_view.h" #include "absl/types/optional.h" #include "api/array_view.h" #if WEBRTC_APM_DEBUG_DUMP == 1 #include "common_audio/wav_file.h" #include "rtc_base/checks.h" +#include "rtc_base/string_utils.h" #endif // Check to verify that the define is properly set. @@ -87,10 +88,10 @@ class ApmDataDumper { } // Set an optional output directory. - static void SetOutputDirectory(const std::string& output_dir) { + static void SetOutputDirectory(absl::string_view output_dir) { #if WEBRTC_APM_DEBUG_DUMP == 1 RTC_CHECK_LT(output_dir.size(), kOutputDirMaxLength); - strncpy(output_dir_, output_dir.c_str(), output_dir.size()); + rtc::strcpyn(output_dir_, output_dir.size(), output_dir); #endif } @@ -104,7 +105,9 @@ class ApmDataDumper { // Methods for performing dumping of data of various types into // various formats. - void DumpRaw(const char* name, double v, int dump_set = kDefaultDumpSet) { + void DumpRaw(absl::string_view name, + double v, + int dump_set = kDefaultDumpSet) { #if WEBRTC_APM_DEBUG_DUMP == 1 if (dump_set_to_use_ && *dump_set_to_use_ != dump_set) return; @@ -116,7 +119,7 @@ class ApmDataDumper { #endif } - void DumpRaw(const char* name, + void DumpRaw(absl::string_view name, size_t v_length, const double* v, int dump_set = kDefaultDumpSet) { @@ -131,7 +134,7 @@ class ApmDataDumper { #endif } - void DumpRaw(const char* name, + void DumpRaw(absl::string_view name, rtc::ArrayView v, int dump_set = kDefaultDumpSet) { #if WEBRTC_APM_DEBUG_DUMP == 1 @@ -144,7 +147,9 @@ class ApmDataDumper { #endif } - void DumpRaw(const char* name, float v, int dump_set = kDefaultDumpSet) { + void DumpRaw(absl::string_view name, + float v, + int dump_set = kDefaultDumpSet) { #if WEBRTC_APM_DEBUG_DUMP == 1 if (dump_set_to_use_ && *dump_set_to_use_ != dump_set) return; @@ -156,7 +161,7 @@ class ApmDataDumper { #endif } - void DumpRaw(const char* name, + void DumpRaw(absl::string_view name, size_t v_length, const float* v, int dump_set = kDefaultDumpSet) { @@ -171,7 +176,7 @@ class ApmDataDumper { #endif } - void DumpRaw(const char* name, + void DumpRaw(absl::string_view name, rtc::ArrayView v, int dump_set = kDefaultDumpSet) { #if WEBRTC_APM_DEBUG_DUMP == 1 @@ -184,7 +189,7 @@ class ApmDataDumper { #endif } - void DumpRaw(const char* name, bool v, int dump_set = kDefaultDumpSet) { + void DumpRaw(absl::string_view name, bool v, int dump_set = kDefaultDumpSet) { #if WEBRTC_APM_DEBUG_DUMP == 1 if (dump_set_to_use_ && *dump_set_to_use_ != dump_set) return; @@ -195,7 +200,7 @@ class ApmDataDumper { #endif } - void DumpRaw(const char* name, + void DumpRaw(absl::string_view name, size_t v_length, const bool* v, int dump_set = kDefaultDumpSet) { @@ -213,7 +218,7 @@ class ApmDataDumper { #endif } - void DumpRaw(const char* name, + void DumpRaw(absl::string_view name, rtc::ArrayView v, int dump_set = kDefaultDumpSet) { #if WEBRTC_APM_DEBUG_DUMP == 1 @@ -226,7 +231,9 @@ class ApmDataDumper { #endif } - void DumpRaw(const char* name, int16_t v, int dump_set = kDefaultDumpSet) { + void DumpRaw(absl::string_view name, + int16_t v, + int dump_set = kDefaultDumpSet) { #if WEBRTC_APM_DEBUG_DUMP == 1 if (dump_set_to_use_ && *dump_set_to_use_ != dump_set) return; @@ -238,7 +245,7 @@ class ApmDataDumper { #endif } - void DumpRaw(const char* name, + void DumpRaw(absl::string_view name, size_t v_length, const int16_t* v, int dump_set = kDefaultDumpSet) { @@ -253,7 +260,7 @@ class ApmDataDumper { #endif } - void DumpRaw(const char* name, + void DumpRaw(absl::string_view name, rtc::ArrayView v, int dump_set = kDefaultDumpSet) { #if WEBRTC_APM_DEBUG_DUMP == 1 @@ -266,7 +273,9 @@ class ApmDataDumper { #endif } - void DumpRaw(const char* name, int32_t v, int dump_set = kDefaultDumpSet) { + void DumpRaw(absl::string_view name, + int32_t v, + int dump_set = kDefaultDumpSet) { #if WEBRTC_APM_DEBUG_DUMP == 1 if (dump_set_to_use_ && *dump_set_to_use_ != dump_set) return; @@ -278,7 +287,7 @@ class ApmDataDumper { #endif } - void DumpRaw(const char* name, + void DumpRaw(absl::string_view name, size_t v_length, const int32_t* v, int dump_set = kDefaultDumpSet) { @@ -293,7 +302,9 @@ class ApmDataDumper { #endif } - void DumpRaw(const char* name, size_t v, int dump_set = kDefaultDumpSet) { + void DumpRaw(absl::string_view name, + size_t v, + int dump_set = kDefaultDumpSet) { #if WEBRTC_APM_DEBUG_DUMP == 1 if (dump_set_to_use_ && *dump_set_to_use_ != dump_set) return; @@ -305,7 +316,7 @@ class ApmDataDumper { #endif } - void DumpRaw(const char* name, + void DumpRaw(absl::string_view name, size_t v_length, const size_t* v, int dump_set = kDefaultDumpSet) { @@ -320,7 +331,7 @@ class ApmDataDumper { #endif } - void DumpRaw(const char* name, + void DumpRaw(absl::string_view name, rtc::ArrayView v, int dump_set = kDefaultDumpSet) { #if WEBRTC_APM_DEBUG_DUMP == 1 @@ -333,7 +344,7 @@ class ApmDataDumper { #endif } - void DumpRaw(const char* name, + void DumpRaw(absl::string_view name, rtc::ArrayView v, int dump_set = kDefaultDumpSet) { #if WEBRTC_APM_DEBUG_DUMP == 1 @@ -344,7 +355,7 @@ class ApmDataDumper { #endif } - void DumpWav(const char* name, + void DumpWav(absl::string_view name, size_t v_length, const float* v, int sample_rate_hz, @@ -362,7 +373,7 @@ class ApmDataDumper { #endif } - void DumpWav(const char* name, + void DumpWav(absl::string_view name, rtc::ArrayView v, int sample_rate_hz, int num_channels, @@ -389,8 +400,8 @@ class ApmDataDumper { raw_files_; std::unordered_map> wav_files_; - FILE* GetRawFile(const char* name); - WavWriter* GetWavFile(const char* name, + FILE* GetRawFile(absl::string_view name); + WavWriter* GetWavFile(absl::string_view name, int sample_rate_hz, int num_channels, WavFile::SampleFormat format); diff --git a/modules/audio_processing/test/api_call_statistics.cc b/modules/audio_processing/test/api_call_statistics.cc index 736b77b7cf..ee8a308596 100644 --- a/modules/audio_processing/test/api_call_statistics.cc +++ b/modules/audio_processing/test/api_call_statistics.cc @@ -15,7 +15,9 @@ #include #include #include +#include +#include "absl/strings/string_view.h" #include "rtc_base/time_utils.h" namespace webrtc { @@ -72,9 +74,9 @@ void ApiCallStatistics::PrintReport() const { << " avg: " << avg_capture << " us" << std::endl; } -void ApiCallStatistics::WriteReportToFile(const std::string& filename) const { +void ApiCallStatistics::WriteReportToFile(absl::string_view filename) const { std::unique_ptr out = - std::make_unique(filename); + std::make_unique(std::string(filename)); for (auto v : calls_) { if (v.call_type == CallType::kRender) { *out << "render, "; diff --git a/modules/audio_processing/test/api_call_statistics.h b/modules/audio_processing/test/api_call_statistics.h index 6a78d3616a..8fced104f9 100644 --- a/modules/audio_processing/test/api_call_statistics.h +++ b/modules/audio_processing/test/api_call_statistics.h @@ -11,9 +11,10 @@ #ifndef MODULES_AUDIO_PROCESSING_TEST_API_CALL_STATISTICS_H_ #define MODULES_AUDIO_PROCESSING_TEST_API_CALL_STATISTICS_H_ -#include #include +#include "absl/strings/string_view.h" + namespace webrtc { namespace test { @@ -29,7 +30,7 @@ class ApiCallStatistics { void PrintReport() const; // Writes the call information to a file. - void WriteReportToFile(const std::string& filename) const; + void WriteReportToFile(absl::string_view filename) const; private: struct CallData { diff --git a/modules/audio_processing/test/audio_processing_simulator.cc b/modules/audio_processing/test/audio_processing_simulator.cc index 5923fc34f6..b29027c35e 100644 --- a/modules/audio_processing/test/audio_processing_simulator.cc +++ b/modules/audio_processing/test/audio_processing_simulator.cc @@ -18,6 +18,7 @@ #include #include +#include "absl/strings/string_view.h" #include "api/audio/echo_canceller3_config_json.h" #include "api/audio/echo_canceller3_factory.h" #include "api/audio/echo_detector_creator.h" @@ -35,10 +36,10 @@ namespace webrtc { namespace test { namespace { // Helper for reading JSON from a file and parsing it to an AEC3 configuration. -EchoCanceller3Config ReadAec3ConfigFromJsonFile(const std::string& filename) { +EchoCanceller3Config ReadAec3ConfigFromJsonFile(absl::string_view filename) { std::string json_string; std::string s; - std::ifstream f(filename.c_str()); + std::ifstream f(std::string(filename).c_str()); if (f.fail()) { std::cout << "Failed to open the file " << filename << std::endl; RTC_CHECK_NOTREACHED(); @@ -60,7 +61,7 @@ EchoCanceller3Config ReadAec3ConfigFromJsonFile(const std::string& filename) { return cfg; } -std::string GetIndexedOutputWavFilename(const std::string& wav_name, +std::string GetIndexedOutputWavFilename(absl::string_view wav_name, int counter) { rtc::StringBuilder ss; ss << wav_name.substr(0, wav_name.size() - 4) << "_" << counter @@ -89,11 +90,11 @@ void WriteEchoLikelihoodGraphFileFooter(std::ofstream* output_file) { // leaving the enclosing scope. class ScopedTimer { public: - ScopedTimer(ApiCallStatistics* api_call_statistics_, + ScopedTimer(ApiCallStatistics* api_call_statistics, ApiCallStatistics::CallType call_type) : start_time_(rtc::TimeNanos()), call_type_(call_type), - api_call_statistics_(api_call_statistics_) {} + api_call_statistics_(api_call_statistics) {} ~ScopedTimer() { api_call_statistics_->Add(rtc::TimeNanos() - start_time_, call_type_); diff --git a/modules/audio_processing/test/audioproc_float_impl.cc b/modules/audio_processing/test/audioproc_float_impl.cc index dc38172666..dd9fc70734 100644 --- a/modules/audio_processing/test/audioproc_float_impl.cc +++ b/modules/audio_processing/test/audioproc_float_impl.cc @@ -334,10 +334,10 @@ const char kUsageDescription[] = "processing module, either based on wav files or " "protobuf debug dump recordings.\n"; -void SetSettingIfSpecified(const std::string& value, +void SetSettingIfSpecified(absl::string_view value, absl::optional* parameter) { if (value.compare("") != 0) { - *parameter = value; + *parameter = std::string(value); } } @@ -521,7 +521,7 @@ SimulationSettings CreateSettings() { return settings; } -void ReportConditionalErrorAndExit(bool condition, const std::string& message) { +void ReportConditionalErrorAndExit(bool condition, absl::string_view message) { if (condition) { std::cerr << message << std::endl; exit(1); @@ -640,7 +640,7 @@ void PerformBasicParameterSanityChecks( "Error: --simulated_mic_kind must be specified when mic simulation is " "enabled\n"); - auto valid_wav_name = [](const std::string& wav_file_name) { + auto valid_wav_name = [](absl::string_view wav_file_name) { if (wav_file_name.size() < 5) { return false; } diff --git a/modules/audio_processing/test/conversational_speech/BUILD.gn b/modules/audio_processing/test/conversational_speech/BUILD.gn index 4408b5bea5..2c3678092e 100644 --- a/modules/audio_processing/test/conversational_speech/BUILD.gn +++ b/modules/audio_processing/test/conversational_speech/BUILD.gn @@ -74,5 +74,8 @@ rtc_library("unittest") { "../../../../test:test_support", "//testing/gtest", ] - absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ] + absl_deps = [ + "//third_party/abseil-cpp/absl/strings", + "//third_party/abseil-cpp/absl/types:optional", + ] } diff --git a/modules/audio_processing/test/conversational_speech/config.h b/modules/audio_processing/test/conversational_speech/config.h index f219a65f60..5a847e06a2 100644 --- a/modules/audio_processing/test/conversational_speech/config.h +++ b/modules/audio_processing/test/conversational_speech/config.h @@ -13,14 +13,16 @@ #include +#include "absl/strings/string_view.h" + namespace webrtc { namespace test { namespace conversational_speech { struct Config { - Config(const std::string& audiotracks_path, - const std::string& timing_filepath, - const std::string& output_path) + Config(absl::string_view audiotracks_path, + absl::string_view timing_filepath, + absl::string_view output_path) : audiotracks_path_(audiotracks_path), timing_filepath_(timing_filepath), output_path_(output_path) {} diff --git a/modules/audio_processing/test/conversational_speech/generator_unittest.cc b/modules/audio_processing/test/conversational_speech/generator_unittest.cc index c7a459cb4a..17714440d4 100644 --- a/modules/audio_processing/test/conversational_speech/generator_unittest.cc +++ b/modules/audio_processing/test/conversational_speech/generator_unittest.cc @@ -43,6 +43,7 @@ #include #include +#include "absl/strings/string_view.h" #include "absl/types/optional.h" #include "common_audio/wav_file.h" #include "modules/audio_processing/test/conversational_speech/config.h" @@ -98,7 +99,7 @@ std::unique_ptr CreateMockWavReaderFactory() { kDefaultMockWavReaderFactoryParamsMap)); } -void CreateSineWavFile(const std::string& filepath, +void CreateSineWavFile(absl::string_view filepath, const MockWavReaderFactory::Params& params, float frequency = 440.0f) { // Create samples. @@ -139,7 +140,7 @@ std::string CreateTemporarySineAudioTracks( } void CheckAudioTrackParams(const WavReaderFactory& wav_reader_factory, - const std::string& filepath, + absl::string_view filepath, const MockWavReaderFactory::Params& expeted_params) { auto wav_reader = wav_reader_factory.Create(filepath); EXPECT_EQ(expeted_params.sample_rate, wav_reader->SampleRate()); @@ -147,7 +148,7 @@ void CheckAudioTrackParams(const WavReaderFactory& wav_reader_factory, EXPECT_EQ(expeted_params.num_samples, wav_reader->NumSamples()); } -void DeleteFolderAndContents(const std::string& dir) { +void DeleteFolderAndContents(absl::string_view dir) { if (!DirExists(dir)) { return; } diff --git a/modules/audio_processing/test/conversational_speech/mock_wavreader_factory.cc b/modules/audio_processing/test/conversational_speech/mock_wavreader_factory.cc index 96b5894dd0..a377cce7e3 100644 --- a/modules/audio_processing/test/conversational_speech/mock_wavreader_factory.cc +++ b/modules/audio_processing/test/conversational_speech/mock_wavreader_factory.cc @@ -10,6 +10,7 @@ #include "modules/audio_processing/test/conversational_speech/mock_wavreader_factory.h" +#include "absl/strings/string_view.h" #include "modules/audio_processing/test/conversational_speech/mock_wavreader.h" #include "rtc_base/logging.h" #include "test/gmock.h" @@ -36,11 +37,11 @@ MockWavReaderFactory::MockWavReaderFactory(const Params& default_params) MockWavReaderFactory::~MockWavReaderFactory() = default; std::unique_ptr MockWavReaderFactory::CreateMock( - const std::string& filepath) { + absl::string_view filepath) { // Search the parameters corresponding to filepath. size_t delimiter = filepath.find_last_of("/\\"); // Either windows or posix - std::string filename = - filepath.substr(delimiter == std::string::npos ? 0 : delimiter + 1); + std::string filename(filepath.substr( + delimiter == absl::string_view::npos ? 0 : delimiter + 1)); const auto it = audiotrack_names_params_.find(filename); // If not found, use default parameters. diff --git a/modules/audio_processing/test/conversational_speech/mock_wavreader_factory.h b/modules/audio_processing/test/conversational_speech/mock_wavreader_factory.h index c2db85f6f6..bcc7f3069b 100644 --- a/modules/audio_processing/test/conversational_speech/mock_wavreader_factory.h +++ b/modules/audio_processing/test/conversational_speech/mock_wavreader_factory.h @@ -15,6 +15,7 @@ #include #include +#include "absl/strings/string_view.h" #include "modules/audio_processing/test/conversational_speech/wavreader_abstract_factory.h" #include "modules/audio_processing/test/conversational_speech/wavreader_interface.h" #include "test/gmock.h" @@ -38,14 +39,14 @@ class MockWavReaderFactory : public WavReaderAbstractFactory { MOCK_METHOD(std::unique_ptr, Create, - (const std::string&), + (absl::string_view), (const, override)); private: // Creates a MockWavReader instance using the parameters in // audiotrack_names_params_ if the entry corresponding to filepath exists, // otherwise creates a MockWavReader instance using the default parameters. - std::unique_ptr CreateMock(const std::string& filepath); + std::unique_ptr CreateMock(absl::string_view filepath); const Params& default_params_; std::map audiotrack_names_params_; diff --git a/modules/audio_processing/test/conversational_speech/multiend_call.cc b/modules/audio_processing/test/conversational_speech/multiend_call.cc index 2ae33d7137..952114a78b 100644 --- a/modules/audio_processing/test/conversational_speech/multiend_call.cc +++ b/modules/audio_processing/test/conversational_speech/multiend_call.cc @@ -13,6 +13,7 @@ #include #include +#include "absl/strings/string_view.h" #include "rtc_base/logging.h" #include "test/testsupport/file_utils.h" @@ -22,7 +23,7 @@ namespace conversational_speech { MultiEndCall::MultiEndCall( rtc::ArrayView timing, - const std::string& audiotracks_path, + absl::string_view audiotracks_path, std::unique_ptr wavreader_abstract_factory) : timing_(timing), audiotracks_path_(audiotracks_path), diff --git a/modules/audio_processing/test/conversational_speech/multiend_call.h b/modules/audio_processing/test/conversational_speech/multiend_call.h index 693f00edd9..63283465fa 100644 --- a/modules/audio_processing/test/conversational_speech/multiend_call.h +++ b/modules/audio_processing/test/conversational_speech/multiend_call.h @@ -20,6 +20,7 @@ #include #include +#include "absl/strings/string_view.h" #include "api/array_view.h" #include "modules/audio_processing/test/conversational_speech/timing.h" #include "modules/audio_processing/test/conversational_speech/wavreader_abstract_factory.h" @@ -33,13 +34,13 @@ class MultiEndCall { public: struct SpeakingTurn { // Constructor required in order to use std::vector::emplace_back(). - SpeakingTurn(std::string new_speaker_name, - std::string new_audiotrack_file_name, + SpeakingTurn(absl::string_view new_speaker_name, + absl::string_view new_audiotrack_file_name, size_t new_begin, size_t new_end, int gain) - : speaker_name(std::move(new_speaker_name)), - audiotrack_file_name(std::move(new_audiotrack_file_name)), + : speaker_name(new_speaker_name), + audiotrack_file_name(new_audiotrack_file_name), begin(new_begin), end(new_end), gain(gain) {} @@ -52,7 +53,7 @@ class MultiEndCall { MultiEndCall( rtc::ArrayView timing, - const std::string& audiotracks_path, + absl::string_view audiotracks_path, std::unique_ptr wavreader_abstract_factory); ~MultiEndCall(); @@ -85,7 +86,7 @@ class MultiEndCall { bool CheckTiming(); rtc::ArrayView timing_; - const std::string& audiotracks_path_; + std::string audiotracks_path_; std::unique_ptr wavreader_abstract_factory_; std::set speaker_names_; std::map> diff --git a/modules/audio_processing/test/conversational_speech/simulator.cc b/modules/audio_processing/test/conversational_speech/simulator.cc index c0fb589852..89bcd48d84 100644 --- a/modules/audio_processing/test/conversational_speech/simulator.cc +++ b/modules/audio_processing/test/conversational_speech/simulator.cc @@ -18,6 +18,7 @@ #include #include +#include "absl/strings/string_view.h" #include "api/array_view.h" #include "common_audio/include/audio_util.h" #include "common_audio/wav_file.h" @@ -38,7 +39,7 @@ using conversational_speech::WavReaderInterface; // the near-end and far=end audio tracks. std::unique_ptr> InitSpeakerOutputFilePaths(const std::set& speaker_names, - const std::string& output_path) { + absl::string_view output_path) { // Create map. auto speaker_output_file_paths_map = std::make_unique>(); @@ -174,7 +175,7 @@ namespace conversational_speech { std::unique_ptr> Simulate( const MultiEndCall& multiend_call, - const std::string& output_path) { + absl::string_view output_path) { // Set output file paths and initialize wav writers. const auto& speaker_names = multiend_call.speaker_names(); auto speaker_output_file_paths = diff --git a/modules/audio_processing/test/conversational_speech/simulator.h b/modules/audio_processing/test/conversational_speech/simulator.h index 2584782c22..2f311e16b3 100644 --- a/modules/audio_processing/test/conversational_speech/simulator.h +++ b/modules/audio_processing/test/conversational_speech/simulator.h @@ -16,6 +16,7 @@ #include #include +#include "absl/strings/string_view.h" #include "modules/audio_processing/test/conversational_speech/multiend_call.h" namespace webrtc { @@ -23,8 +24,8 @@ namespace test { namespace conversational_speech { struct SpeakerOutputFilePaths { - SpeakerOutputFilePaths(const std::string& new_near_end, - const std::string& new_far_end) + SpeakerOutputFilePaths(absl::string_view new_near_end, + absl::string_view new_far_end) : near_end(new_near_end), far_end(new_far_end) {} // Paths to the near-end and far-end audio track files. const std::string near_end; @@ -34,7 +35,7 @@ struct SpeakerOutputFilePaths { // Generates the near-end and far-end audio track pairs for each speaker. std::unique_ptr> Simulate( const MultiEndCall& multiend_call, - const std::string& output_path); + absl::string_view output_path); } // namespace conversational_speech } // namespace test diff --git a/modules/audio_processing/test/conversational_speech/timing.cc b/modules/audio_processing/test/conversational_speech/timing.cc index 8ff011c89b..95ec9f542e 100644 --- a/modules/audio_processing/test/conversational_speech/timing.cc +++ b/modules/audio_processing/test/conversational_speech/timing.cc @@ -12,7 +12,9 @@ #include #include +#include +#include "absl/strings/string_view.h" #include "rtc_base/string_encode.h" namespace webrtc { @@ -25,9 +27,9 @@ bool Turn::operator==(const Turn& b) const { b.gain == gain; } -std::vector LoadTiming(const std::string& timing_filepath) { +std::vector LoadTiming(absl::string_view timing_filepath) { // Line parser. - auto parse_line = [](const std::string& line) { + auto parse_line = [](absl::string_view line) { std::vector fields = rtc::split(line, ' '); RTC_CHECK_GE(fields.size(), 3); RTC_CHECK_LE(fields.size(), 4); @@ -44,7 +46,7 @@ std::vector LoadTiming(const std::string& timing_filepath) { // Parse lines. std::string line; - std::ifstream infile(timing_filepath); + std::ifstream infile(std::string{timing_filepath}); while (std::getline(infile, line)) { if (line.empty()) continue; @@ -55,9 +57,9 @@ std::vector LoadTiming(const std::string& timing_filepath) { return timing; } -void SaveTiming(const std::string& timing_filepath, +void SaveTiming(absl::string_view timing_filepath, rtc::ArrayView timing) { - std::ofstream outfile(timing_filepath); + std::ofstream outfile(std::string{timing_filepath}); RTC_CHECK(outfile.is_open()); for (const Turn& turn : timing) { outfile << turn.speaker_name << " " << turn.audiotrack_file_name << " " diff --git a/modules/audio_processing/test/conversational_speech/timing.h b/modules/audio_processing/test/conversational_speech/timing.h index 2a0d6405de..9314f6fc43 100644 --- a/modules/audio_processing/test/conversational_speech/timing.h +++ b/modules/audio_processing/test/conversational_speech/timing.h @@ -38,10 +38,10 @@ struct Turn { }; // Loads a list of turns from a file. -std::vector LoadTiming(const std::string& timing_filepath); +std::vector LoadTiming(absl::string_view timing_filepath); // Writes a list of turns into a file. -void SaveTiming(const std::string& timing_filepath, +void SaveTiming(absl::string_view timing_filepath, rtc::ArrayView timing); } // namespace conversational_speech diff --git a/modules/audio_processing/test/conversational_speech/wavreader_abstract_factory.h b/modules/audio_processing/test/conversational_speech/wavreader_abstract_factory.h index 83fda0d45c..14ddfc7539 100644 --- a/modules/audio_processing/test/conversational_speech/wavreader_abstract_factory.h +++ b/modules/audio_processing/test/conversational_speech/wavreader_abstract_factory.h @@ -12,8 +12,8 @@ #define MODULES_AUDIO_PROCESSING_TEST_CONVERSATIONAL_SPEECH_WAVREADER_ABSTRACT_FACTORY_H_ #include -#include +#include "absl/strings/string_view.h" #include "modules/audio_processing/test/conversational_speech/wavreader_interface.h" namespace webrtc { @@ -24,7 +24,7 @@ class WavReaderAbstractFactory { public: virtual ~WavReaderAbstractFactory() = default; virtual std::unique_ptr Create( - const std::string& filepath) const = 0; + absl::string_view filepath) const = 0; }; } // namespace conversational_speech diff --git a/modules/audio_processing/test/conversational_speech/wavreader_factory.cc b/modules/audio_processing/test/conversational_speech/wavreader_factory.cc index 01e3c9412f..99b1686484 100644 --- a/modules/audio_processing/test/conversational_speech/wavreader_factory.cc +++ b/modules/audio_processing/test/conversational_speech/wavreader_factory.cc @@ -12,6 +12,7 @@ #include +#include "absl/strings/string_view.h" #include "api/array_view.h" #include "common_audio/wav_file.h" #include "rtc_base/checks.h" @@ -24,7 +25,7 @@ using conversational_speech::WavReaderInterface; class WavReaderAdaptor final : public WavReaderInterface { public: - explicit WavReaderAdaptor(const std::string& filepath) + explicit WavReaderAdaptor(absl::string_view filepath) : wav_reader_(filepath) {} ~WavReaderAdaptor() override = default; @@ -55,7 +56,7 @@ WavReaderFactory::WavReaderFactory() = default; WavReaderFactory::~WavReaderFactory() = default; std::unique_ptr WavReaderFactory::Create( - const std::string& filepath) const { + absl::string_view filepath) const { return std::unique_ptr(new WavReaderAdaptor(filepath)); } diff --git a/modules/audio_processing/test/conversational_speech/wavreader_factory.h b/modules/audio_processing/test/conversational_speech/wavreader_factory.h index 2f86bf5ae0..f2e5b61055 100644 --- a/modules/audio_processing/test/conversational_speech/wavreader_factory.h +++ b/modules/audio_processing/test/conversational_speech/wavreader_factory.h @@ -12,8 +12,8 @@ #define MODULES_AUDIO_PROCESSING_TEST_CONVERSATIONAL_SPEECH_WAVREADER_FACTORY_H_ #include -#include +#include "absl/strings/string_view.h" #include "modules/audio_processing/test/conversational_speech/wavreader_abstract_factory.h" #include "modules/audio_processing/test/conversational_speech/wavreader_interface.h" @@ -26,7 +26,7 @@ class WavReaderFactory : public WavReaderAbstractFactory { WavReaderFactory(); ~WavReaderFactory() override; std::unique_ptr Create( - const std::string& filepath) const override; + absl::string_view filepath) const override; }; } // namespace conversational_speech diff --git a/modules/audio_processing/test/debug_dump_replayer.cc b/modules/audio_processing/test/debug_dump_replayer.cc index cab6966765..2419313e9d 100644 --- a/modules/audio_processing/test/debug_dump_replayer.cc +++ b/modules/audio_processing/test/debug_dump_replayer.cc @@ -10,6 +10,9 @@ #include "modules/audio_processing/test/debug_dump_replayer.h" +#include + +#include "absl/strings/string_view.h" #include "modules/audio_processing/test/audio_processing_builder_for_testing.h" #include "modules/audio_processing/test/protobuf_utils.h" #include "modules/audio_processing/test/runtime_setting_util.h" @@ -44,8 +47,8 @@ DebugDumpReplayer::~DebugDumpReplayer() { fclose(debug_file_); } -bool DebugDumpReplayer::SetDumpFile(const std::string& filename) { - debug_file_ = fopen(filename.c_str(), "rb"); +bool DebugDumpReplayer::SetDumpFile(absl::string_view filename) { + debug_file_ = fopen(std::string(filename).c_str(), "rb"); LoadNextMessage(); return debug_file_; } diff --git a/modules/audio_processing/test/debug_dump_replayer.h b/modules/audio_processing/test/debug_dump_replayer.h index e514d1d94f..be21c68663 100644 --- a/modules/audio_processing/test/debug_dump_replayer.h +++ b/modules/audio_processing/test/debug_dump_replayer.h @@ -12,8 +12,8 @@ #define MODULES_AUDIO_PROCESSING_TEST_DEBUG_DUMP_REPLAYER_H_ #include -#include +#include "absl/strings/string_view.h" #include "common_audio/channel_buffer.h" #include "modules/audio_processing/include/audio_processing.h" #include "rtc_base/ignore_wundef.h" @@ -31,7 +31,7 @@ class DebugDumpReplayer { ~DebugDumpReplayer(); // Set dump file - bool SetDumpFile(const std::string& filename); + bool SetDumpFile(absl::string_view filename); // Return next event. absl::optional GetNextEvent() const; diff --git a/modules/audio_processing/test/debug_dump_test.cc b/modules/audio_processing/test/debug_dump_test.cc index b7351609ec..d69d3a4eea 100644 --- a/modules/audio_processing/test/debug_dump_test.cc +++ b/modules/audio_processing/test/debug_dump_test.cc @@ -14,6 +14,7 @@ #include #include +#include "absl/strings/string_view.h" #include "api/audio/echo_canceller3_factory.h" #include "modules/audio_coding/neteq/tools/resample_input_audio_file.h" #include "modules/audio_processing/aec_dump/aec_dump_factory.h" @@ -41,13 +42,13 @@ void MaybeResetBuffer(std::unique_ptr>* buffer, class DebugDumpGenerator { public: - DebugDumpGenerator(const std::string& input_file_name, + DebugDumpGenerator(absl::string_view input_file_name, int input_rate_hz, int input_channels, - const std::string& reverse_file_name, + absl::string_view reverse_file_name, int reverse_rate_hz, int reverse_channels, - const std::string& dump_file_name, + absl::string_view dump_file_name, bool enable_pre_amplifier); // Constructor that uses default input files. @@ -115,13 +116,13 @@ class DebugDumpGenerator { const std::string dump_file_name_; }; -DebugDumpGenerator::DebugDumpGenerator(const std::string& input_file_name, +DebugDumpGenerator::DebugDumpGenerator(absl::string_view input_file_name, int input_rate_hz, int input_channels, - const std::string& reverse_file_name, + absl::string_view reverse_file_name, int reverse_rate_hz, int reverse_channels, - const std::string& dump_file_name, + absl::string_view dump_file_name, bool enable_pre_amplifier) : input_config_(input_rate_hz, input_channels), reverse_config_(reverse_rate_hz, reverse_channels), @@ -254,13 +255,13 @@ class DebugDumpTest : public ::testing::Test { // VerifyDebugDump replays a debug dump using APM and verifies that the result // is bit-exact-identical to the output channel in the dump. This is only // guaranteed if the debug dump is started on the first frame. - void VerifyDebugDump(const std::string& in_filename); + void VerifyDebugDump(absl::string_view in_filename); private: DebugDumpReplayer debug_dump_replayer_; }; -void DebugDumpTest::VerifyDebugDump(const std::string& in_filename) { +void DebugDumpTest::VerifyDebugDump(absl::string_view in_filename) { ASSERT_TRUE(debug_dump_replayer_.SetDumpFile(in_filename)); while (const absl::optional event = diff --git a/modules/audio_processing/test/py_quality_assessment/BUILD.gn b/modules/audio_processing/test/py_quality_assessment/BUILD.gn index 581fe95bb3..e53a829623 100644 --- a/modules/audio_processing/test/py_quality_assessment/BUILD.gn +++ b/modules/audio_processing/test/py_quality_assessment/BUILD.gn @@ -105,6 +105,7 @@ if (!build_with_chromium) { output_dir = "${root_out_dir}/py_quality_assessment/quality_assessment" deps = [ "../../../../rtc_base:checks", + "//third_party/abseil-cpp/absl/strings", ] } diff --git a/modules/audio_processing/test/py_quality_assessment/quality_assessment/fake_polqa.cc b/modules/audio_processing/test/py_quality_assessment/quality_assessment/fake_polqa.cc index bae652e283..6f3b2d1dd7 100644 --- a/modules/audio_processing/test/py_quality_assessment/quality_assessment/fake_polqa.cc +++ b/modules/audio_processing/test/py_quality_assessment/quality_assessment/fake_polqa.cc @@ -10,7 +10,9 @@ #include #include +#include +#include "absl/strings/string_view.h" #include "rtc_base/checks.h" namespace webrtc { @@ -21,9 +23,9 @@ const char* const kErrorMessage = "-Out /path/to/output/file is mandatory"; // Writes fake output intended to be parsed by // quality_assessment.eval_scores.PolqaScore. -void WriteOutputFile(const std::string& output_file_path) { +void WriteOutputFile(absl::string_view output_file_path) { RTC_CHECK_NE(output_file_path, ""); - std::ofstream out(output_file_path); + std::ofstream out(std::string{output_file_path}); RTC_CHECK(!out.bad()); out << "* Fake Polqa output" << std::endl; out << "FakeField1\tPolqaScore\tFakeField2" << std::endl; diff --git a/modules/audio_processing/test/test_utils.cc b/modules/audio_processing/test/test_utils.cc index dda2c3b8db..9aeebe5155 100644 --- a/modules/audio_processing/test/test_utils.cc +++ b/modules/audio_processing/test/test_utils.cc @@ -10,8 +10,10 @@ #include "modules/audio_processing/test/test_utils.h" +#include #include +#include "absl/strings/string_view.h" #include "rtc_base/checks.h" #include "rtc_base/system/arch.h" @@ -68,10 +70,11 @@ void ChannelBufferVectorWriter::Write(const ChannelBuffer& buffer) { output_->data() + old_size); } -FILE* OpenFile(const std::string& filename, const char* mode) { - FILE* file = fopen(filename.c_str(), mode); +FILE* OpenFile(absl::string_view filename, absl::string_view mode) { + std::string filename_str(filename); + FILE* file = fopen(filename_str.c_str(), std::string(mode).c_str()); if (!file) { - printf("Unable to open file %s\n", filename.c_str()); + printf("Unable to open file %s\n", filename_str.c_str()); exit(1); } return file; diff --git a/modules/audio_processing/test/test_utils.h b/modules/audio_processing/test/test_utils.h index 063ce87438..bf82f9d66d 100644 --- a/modules/audio_processing/test/test_utils.h +++ b/modules/audio_processing/test/test_utils.h @@ -20,6 +20,7 @@ #include #include +#include "absl/strings/string_view.h" #include "common_audio/channel_buffer.h" #include "common_audio/wav_file.h" #include "modules/audio_processing/include/audio_processing.h" @@ -112,7 +113,7 @@ class ChannelBufferVectorWriter final { }; // Exits on failure; do not use in unit tests. -FILE* OpenFile(const std::string& filename, const char* mode); +FILE* OpenFile(absl::string_view filename, absl::string_view mode); void SetFrameSampleRate(Int16FrameData* frame, int sample_rate_hz); @@ -151,10 +152,11 @@ float ComputeSNR(const T* ref, const T* test, size_t length, float* variance) { // Returns a vector parsed from whitespace delimited values in to_parse, // or an empty vector if the string could not be parsed. template -std::vector ParseList(const std::string& to_parse) { +std::vector ParseList(absl::string_view to_parse) { std::vector values; - std::istringstream str(to_parse); + std::istringstream str( // no-presubmit-check TODO(webrtc:8982) + std::string{to_parse}); std::copy( std::istream_iterator(str), // no-presubmit-check TODO(webrtc:8982) std::istream_iterator(), // no-presubmit-check TODO(webrtc:8982) diff --git a/modules/audio_processing/test/wav_based_simulator.cc b/modules/audio_processing/test/wav_based_simulator.cc index d8f6b594ac..ee87f9e1a8 100644 --- a/modules/audio_processing/test/wav_based_simulator.cc +++ b/modules/audio_processing/test/wav_based_simulator.cc @@ -14,6 +14,7 @@ #include +#include "absl/strings/string_view.h" #include "modules/audio_processing/logging/apm_data_dumper.h" #include "modules/audio_processing/test/test_utils.h" #include "rtc_base/checks.h" @@ -23,7 +24,7 @@ namespace webrtc { namespace test { std::vector -WavBasedSimulator::GetCustomEventChain(const std::string& filename) { +WavBasedSimulator::GetCustomEventChain(absl::string_view filename) { std::vector call_chain; FileWrapper file_wrapper = FileWrapper::OpenReadOnly(filename); diff --git a/modules/audio_processing/test/wav_based_simulator.h b/modules/audio_processing/test/wav_based_simulator.h index ff88fd5535..44e9ee2b7f 100644 --- a/modules/audio_processing/test/wav_based_simulator.h +++ b/modules/audio_processing/test/wav_based_simulator.h @@ -13,6 +13,7 @@ #include +#include "absl/strings/string_view.h" #include "modules/audio_processing/test/audio_processing_simulator.h" namespace webrtc { @@ -51,7 +52,7 @@ class WavBasedSimulator final : public AudioProcessingSimulator { void PrepareReverseProcessStreamCall(); static std::vector GetDefaultEventChain(); static std::vector GetCustomEventChain( - const std::string& filename); + absl::string_view filename); std::vector call_chain_; }; diff --git a/modules/audio_processing/transient/BUILD.gn b/modules/audio_processing/transient/BUILD.gn index 9be0da2113..41aeab0abe 100644 --- a/modules/audio_processing/transient/BUILD.gn +++ b/modules/audio_processing/transient/BUILD.gn @@ -125,6 +125,9 @@ if (rtc_include_tests) { "../../../test:test_support", "//testing/gtest", ] - absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ] + absl_deps = [ + "//third_party/abseil-cpp/absl/strings", + "//third_party/abseil-cpp/absl/types:optional", + ] } } diff --git a/modules/audio_processing/transient/file_utils_unittest.cc b/modules/audio_processing/transient/file_utils_unittest.cc index c32df6c81f..a9dddb1eda 100644 --- a/modules/audio_processing/transient/file_utils_unittest.cc +++ b/modules/audio_processing/transient/file_utils_unittest.cc @@ -16,6 +16,7 @@ #include #include +#include "absl/strings/string_view.h" #include "rtc_base/system/file_wrapper.h" #include "test/gtest.h" #include "test/testsupport/file_utils.h" @@ -49,8 +50,8 @@ class TransientFileUtilsTest : public ::testing::Test { ~TransientFileUtilsTest() override { CleanupTempFiles(); } - std::string CreateTempFilename(const std::string& dir, - const std::string& prefix) { + std::string CreateTempFilename(absl::string_view dir, + absl::string_view prefix) { std::string filename = test::TempFilename(dir, prefix); temp_filenames_.push_back(filename); return filename;