Adopt absl::string_view in modules/audio_processing/
Bug: webrtc:13579
Change-Id: Idb05a64cfd16aed68d40cd427a6b516caa5e2077
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/269387
Reviewed-by: Ivo Creusen <ivoc@webrtc.org>
Commit-Queue: Ali Tofigh <alito@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37800}
diff --git a/modules/audio_processing/BUILD.gn b/modules/audio_processing/BUILD.gn
index ca55fec..24c66b1 100644
--- a/modules/audio_processing/BUILD.gn
+++ b/modules/audio_processing/BUILD.gn
@@ -311,7 +311,10 @@
"../../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 @@
"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 @@
"../../test:perf_test",
"../../test:test_support",
]
+ absl_deps = [ "//third_party/abseil-cpp/absl/strings" ]
}
rtc_library("analog_mic_simulation") {
@@ -648,5 +655,8 @@
"../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 4de2d00..679ce48 100644
--- a/modules/audio_processing/aec3/BUILD.gn
+++ b/modules/audio_processing/aec3/BUILD.gn
@@ -157,7 +157,10 @@
"../../../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 @@
"../../../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 7597709..34c06f4 100644
--- a/modules/audio_processing/aec3/adaptive_fir_filter.h
+++ b/modules/audio_processing/aec3/adaptive_fir_filter.h
@@ -16,6 +16,7 @@
#include <array>
#include <vector>
+#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 @@
// 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 1404a99..e8e2175 100644
--- a/modules/audio_processing/aec3/echo_canceller3.cc
+++ b/modules/audio_processing/aec3/echo_canceller3.cc
@@ -12,6 +12,7 @@
#include <algorithm>
#include <utility>
+#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 @@
// 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(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 38dac71..38d8776 100644
--- a/modules/audio_processing/aec_dump/BUILD.gn
+++ b/modules/audio_processing/aec_dump/BUILD.gn
@@ -17,6 +17,7 @@
"../../../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 @@
"../../../rtc_base/system:file_wrapper",
"../../../system_wrappers",
]
+ absl_deps = [ "//third_party/abseil-cpp/absl/strings" ]
deps += [ "../:audioproc_debug_proto" ]
}
@@ -106,4 +108,5 @@
":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 b0ec839..20718c3 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 <memory>
-#include <string>
+#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 @@
static std::unique_ptr<AecDump> Create(webrtc::FileWrapper file,
int64_t max_log_size_bytes,
rtc::TaskQueue* worker_queue);
- static std::unique_ptr<AecDump> Create(std::string file_name,
+ static std::unique_ptr<AecDump> Create(absl::string_view file_name,
int64_t max_log_size_bytes,
rtc::TaskQueue* worker_queue);
static std::unique_ptr<AecDump> 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 32f214b..94c2404 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 <memory>
#include <utility>
+#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 @@
worker_queue);
}
-std::unique_ptr<AecDump> AecDumpFactory::Create(std::string file_name,
+std::unique_ptr<AecDump> 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 126adeb..9bd9745 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 @@
return nullptr;
}
-std::unique_ptr<AecDump> AecDumpFactory::Create(std::string file_name,
+std::unique_ptr<AecDump> 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 1142f36..70190cf 100644
--- a/modules/audio_processing/agc/BUILD.gn
+++ b/modules/audio_processing/agc/BUILD.gn
@@ -185,6 +185,9 @@
"../../../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 af193ee..bbc0a7e 100644
--- a/modules/audio_processing/agc/loudness_histogram_unittest.cc
+++ b/modules/audio_processing/agc/loudness_histogram_unittest.cc
@@ -17,7 +17,9 @@
#include <algorithm>
#include <cmath>
#include <memory>
+#include <string>
+#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 @@
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::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 4e40736..64a7b38 100644
--- a/modules/audio_processing/agc2/BUILD.gn
+++ b/modules/audio_processing/agc2/BUILD.gn
@@ -101,8 +101,10 @@
"../../../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 b522ec3..bb6e038 100644
--- a/modules/audio_processing/agc2/interpolated_gain_curve.cc
+++ b/modules/audio_processing/agc2/interpolated_gain_curve.cc
@@ -13,9 +13,11 @@
#include <algorithm>
#include <iterator>
+#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 @@
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::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 b1a5cf4..8dd3e48 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 <array>
-#include <string>
+#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 @@
};
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 @@
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 5758092..7a1e220 100644
--- a/modules/audio_processing/agc2/limiter.cc
+++ b/modules/audio_processing/agc2/limiter.cc
@@ -14,6 +14,7 @@
#include <array>
#include <cmath>
+#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 @@
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 669e202..d4d5563 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 <string>
#include <vector>
+#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 @@
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 9d62e2f..9093a68 100644
--- a/modules/audio_processing/agc2/rnn_vad/BUILD.gn
+++ b/modules/audio_processing/agc2/rnn_vad/BUILD.gn
@@ -230,6 +230,7 @@
"../../../../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 b8ca9c3..857a9f2 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 <algorithm>
#include <fstream>
#include <memory>
+#include <string>
#include <type_traits>
#include <vector>
+#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 @@
class FloatFileReader : public FileReader {
public:
static_assert(std::is_arithmetic<T>::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 e366e18..e64b7b7 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 <memory>
#include <string>
+#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 @@
// 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 762980b..57d51a2 100644
--- a/modules/audio_processing/audio_processing_impl.cc
+++ b/modules/audio_processing/audio_processing_impl.cc
@@ -1654,8 +1654,8 @@
bool AudioProcessingImpl::CreateAndAttachAecDump(absl::string_view file_name,
int64_t max_log_size_bytes,
rtc::TaskQueue* worker_queue) {
- std::unique_ptr<AecDump> aec_dump = AecDumpFactory::Create(
- std::string(file_name), max_log_size_bytes, worker_queue);
+ std::unique_ptr<AecDump> 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 49e435f..51d1962 100644
--- a/modules/audio_processing/audio_processing_performance_unittest.cc
+++ b/modules/audio_processing/audio_processing_performance_unittest.cc
@@ -14,6 +14,7 @@
#include <memory>
#include <vector>
+#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 @@
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 5c93433..a051474 100644
--- a/modules/audio_processing/audio_processing_unittest.cc
+++ b/modules/audio_processing/audio_processing_unittest.cc
@@ -18,8 +18,10 @@
#include <memory>
#include <numeric>
#include <queue>
+#include <string>
#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 @@
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<int32_t>(msg.ByteSizeLong());
@@ -218,7 +220,7 @@
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 @@
// have competing filenames.
std::map<std::string, std::string> 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 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 @@
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 @@
}
#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 @@
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<AudioProcessing> ap =
diff --git a/modules/audio_processing/logging/apm_data_dumper.cc b/modules/audio_processing/logging/apm_data_dumper.cc
index 445248b..65d2167 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 = '/';
#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 @@
absl::optional<int> 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 @@
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 9c2ac3b..4ab6baa 100644
--- a/modules/audio_processing/logging/apm_data_dumper.h
+++ b/modules/audio_processing/logging/apm_data_dumper.h
@@ -13,19 +13,20 @@
#include <stdint.h>
#include <stdio.h>
-#include <string.h>
-#include <string>
#if WEBRTC_APM_DEBUG_DUMP == 1
#include <memory>
+#include <string>
#include <unordered_map>
#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 @@
}
// 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 @@
// 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 @@
#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 @@
#endif
}
- void DumpRaw(const char* name,
+ void DumpRaw(absl::string_view name,
rtc::ArrayView<const double> v,
int dump_set = kDefaultDumpSet) {
#if WEBRTC_APM_DEBUG_DUMP == 1
@@ -144,7 +147,9 @@
#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 @@
#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 @@
#endif
}
- void DumpRaw(const char* name,
+ void DumpRaw(absl::string_view name,
rtc::ArrayView<const float> v,
int dump_set = kDefaultDumpSet) {
#if WEBRTC_APM_DEBUG_DUMP == 1
@@ -184,7 +189,7 @@
#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 @@
#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 @@
#endif
}
- void DumpRaw(const char* name,
+ void DumpRaw(absl::string_view name,
rtc::ArrayView<const bool> v,
int dump_set = kDefaultDumpSet) {
#if WEBRTC_APM_DEBUG_DUMP == 1
@@ -226,7 +231,9 @@
#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 @@
#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 @@
#endif
}
- void DumpRaw(const char* name,
+ void DumpRaw(absl::string_view name,
rtc::ArrayView<const int16_t> v,
int dump_set = kDefaultDumpSet) {
#if WEBRTC_APM_DEBUG_DUMP == 1
@@ -266,7 +273,9 @@
#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 @@
#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 @@
#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 @@
#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 @@
#endif
}
- void DumpRaw(const char* name,
+ void DumpRaw(absl::string_view name,
rtc::ArrayView<const int32_t> v,
int dump_set = kDefaultDumpSet) {
#if WEBRTC_APM_DEBUG_DUMP == 1
@@ -333,7 +344,7 @@
#endif
}
- void DumpRaw(const char* name,
+ void DumpRaw(absl::string_view name,
rtc::ArrayView<const size_t> v,
int dump_set = kDefaultDumpSet) {
#if WEBRTC_APM_DEBUG_DUMP == 1
@@ -344,7 +355,7 @@
#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 @@
#endif
}
- void DumpWav(const char* name,
+ void DumpWav(absl::string_view name,
rtc::ArrayView<const float> v,
int sample_rate_hz,
int num_channels,
@@ -389,8 +400,8 @@
raw_files_;
std::unordered_map<std::string, std::unique_ptr<WavWriter>> 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 736b77b..ee8a308 100644
--- a/modules/audio_processing/test/api_call_statistics.cc
+++ b/modules/audio_processing/test/api_call_statistics.cc
@@ -15,7 +15,9 @@
#include <iostream>
#include <limits>
#include <memory>
+#include <string>
+#include "absl/strings/string_view.h"
#include "rtc_base/time_utils.h"
namespace webrtc {
@@ -72,9 +74,9 @@
<< " 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<std::ofstream> out =
- std::make_unique<std::ofstream>(filename);
+ std::make_unique<std::ofstream>(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 6a78d36..8fced10 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 <string>
#include <vector>
+#include "absl/strings/string_view.h"
+
namespace webrtc {
namespace test {
@@ -29,7 +30,7 @@
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 5923fc3..b29027c 100644
--- a/modules/audio_processing/test/audio_processing_simulator.cc
+++ b/modules/audio_processing/test/audio_processing_simulator.cc
@@ -18,6 +18,7 @@
#include <utility>
#include <vector>
+#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 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 @@
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 @@
// 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 dc38172..dd9fc70 100644
--- a/modules/audio_processing/test/audioproc_float_impl.cc
+++ b/modules/audio_processing/test/audioproc_float_impl.cc
@@ -334,10 +334,10 @@
"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<std::string>* parameter) {
if (value.compare("") != 0) {
- *parameter = value;
+ *parameter = std::string(value);
}
}
@@ -521,7 +521,7 @@
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 @@
"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 4408b5b..2c36780 100644
--- a/modules/audio_processing/test/conversational_speech/BUILD.gn
+++ b/modules/audio_processing/test/conversational_speech/BUILD.gn
@@ -74,5 +74,8 @@
"../../../../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 f219a65..5a847e0 100644
--- a/modules/audio_processing/test/conversational_speech/config.h
+++ b/modules/audio_processing/test/conversational_speech/config.h
@@ -13,14 +13,16 @@
#include <string>
+#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 c7a459c..1771444 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 <memory>
#include <vector>
+#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 @@
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 @@
}
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 @@
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 96b5894..a377cce 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() = default;
std::unique_ptr<WavReaderInterface> 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 c2db85f..bcc7f30 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 <memory>
#include <string>
+#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 @@
MOCK_METHOD(std::unique_ptr<WavReaderInterface>,
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<WavReaderInterface> CreateMock(const std::string& filepath);
+ std::unique_ptr<WavReaderInterface> CreateMock(absl::string_view filepath);
const Params& default_params_;
std::map<std::string, const Params> 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 2ae33d7..952114a 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 <algorithm>
#include <iterator>
+#include "absl/strings/string_view.h"
#include "rtc_base/logging.h"
#include "test/testsupport/file_utils.h"
@@ -22,7 +23,7 @@
MultiEndCall::MultiEndCall(
rtc::ArrayView<const Turn> timing,
- const std::string& audiotracks_path,
+ absl::string_view audiotracks_path,
std::unique_ptr<WavReaderAbstractFactory> 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 693f00e..6328346 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 <utility>
#include <vector>
+#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 @@
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 @@
MultiEndCall(
rtc::ArrayView<const Turn> timing,
- const std::string& audiotracks_path,
+ absl::string_view audiotracks_path,
std::unique_ptr<WavReaderAbstractFactory> wavreader_abstract_factory);
~MultiEndCall();
@@ -85,7 +86,7 @@
bool CheckTiming();
rtc::ArrayView<const Turn> timing_;
- const std::string& audiotracks_path_;
+ std::string audiotracks_path_;
std::unique_ptr<WavReaderAbstractFactory> wavreader_abstract_factory_;
std::set<std::string> speaker_names_;
std::map<std::string, std::unique_ptr<WavReaderInterface>>
diff --git a/modules/audio_processing/test/conversational_speech/simulator.cc b/modules/audio_processing/test/conversational_speech/simulator.cc
index c0fb589..89bcd48 100644
--- a/modules/audio_processing/test/conversational_speech/simulator.cc
+++ b/modules/audio_processing/test/conversational_speech/simulator.cc
@@ -18,6 +18,7 @@
#include <utility>
#include <vector>
+#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 @@
// the near-end and far=end audio tracks.
std::unique_ptr<std::map<std::string, SpeakerOutputFilePaths>>
InitSpeakerOutputFilePaths(const std::set<std::string>& speaker_names,
- const std::string& output_path) {
+ absl::string_view output_path) {
// Create map.
auto speaker_output_file_paths_map =
std::make_unique<std::map<std::string, SpeakerOutputFilePaths>>();
@@ -174,7 +175,7 @@
std::unique_ptr<std::map<std::string, SpeakerOutputFilePaths>> 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 2584782..2f311e1 100644
--- a/modules/audio_processing/test/conversational_speech/simulator.h
+++ b/modules/audio_processing/test/conversational_speech/simulator.h
@@ -16,6 +16,7 @@
#include <string>
#include <utility>
+#include "absl/strings/string_view.h"
#include "modules/audio_processing/test/conversational_speech/multiend_call.h"
namespace webrtc {
@@ -23,8 +24,8 @@
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 @@
// Generates the near-end and far-end audio track pairs for each speaker.
std::unique_ptr<std::map<std::string, SpeakerOutputFilePaths>> 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 8ff011c..95ec9f5 100644
--- a/modules/audio_processing/test/conversational_speech/timing.cc
+++ b/modules/audio_processing/test/conversational_speech/timing.cc
@@ -12,7 +12,9 @@
#include <fstream>
#include <iostream>
+#include <string>
+#include "absl/strings/string_view.h"
#include "rtc_base/string_encode.h"
namespace webrtc {
@@ -25,9 +27,9 @@
b.gain == gain;
}
-std::vector<Turn> LoadTiming(const std::string& timing_filepath) {
+std::vector<Turn> LoadTiming(absl::string_view timing_filepath) {
// Line parser.
- auto parse_line = [](const std::string& line) {
+ auto parse_line = [](absl::string_view line) {
std::vector<absl::string_view> fields = rtc::split(line, ' ');
RTC_CHECK_GE(fields.size(), 3);
RTC_CHECK_LE(fields.size(), 4);
@@ -44,7 +46,7 @@
// 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 @@
return timing;
}
-void SaveTiming(const std::string& timing_filepath,
+void SaveTiming(absl::string_view timing_filepath,
rtc::ArrayView<const Turn> 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 2a0d640..9314f6f 100644
--- a/modules/audio_processing/test/conversational_speech/timing.h
+++ b/modules/audio_processing/test/conversational_speech/timing.h
@@ -38,10 +38,10 @@
};
// Loads a list of turns from a file.
-std::vector<Turn> LoadTiming(const std::string& timing_filepath);
+std::vector<Turn> 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<const Turn> 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 83fda0d..14ddfc7 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 <memory>
-#include <string>
+#include "absl/strings/string_view.h"
#include "modules/audio_processing/test/conversational_speech/wavreader_interface.h"
namespace webrtc {
@@ -24,7 +24,7 @@
public:
virtual ~WavReaderAbstractFactory() = default;
virtual std::unique_ptr<WavReaderInterface> 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 01e3c94..99b1686 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 <cstddef>
+#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 @@
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;
std::unique_ptr<WavReaderInterface> WavReaderFactory::Create(
- const std::string& filepath) const {
+ absl::string_view filepath) const {
return std::unique_ptr<WavReaderAdaptor>(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 2f86bf5..f2e5b61 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 <memory>
-#include <string>
+#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 @@
WavReaderFactory();
~WavReaderFactory() override;
std::unique_ptr<WavReaderInterface> 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 cab6966..2419313 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 <string>
+
+#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 @@
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 e514d1d..be21c68 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 <memory>
-#include <string>
+#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 @@
~DebugDumpReplayer();
// Set dump file
- bool SetDumpFile(const std::string& filename);
+ bool SetDumpFile(absl::string_view filename);
// Return next event.
absl::optional<audioproc::Event> GetNextEvent() const;
diff --git a/modules/audio_processing/test/debug_dump_test.cc b/modules/audio_processing/test/debug_dump_test.cc
index b735160..d69d3a4 100644
--- a/modules/audio_processing/test/debug_dump_test.cc
+++ b/modules/audio_processing/test/debug_dump_test.cc
@@ -14,6 +14,7 @@
#include <string>
#include <vector>
+#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 @@
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 @@
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 @@
// 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<audioproc::Event> event =
diff --git a/modules/audio_processing/test/py_quality_assessment/BUILD.gn b/modules/audio_processing/test/py_quality_assessment/BUILD.gn
index 581fe95..e53a829 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 @@
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 bae652e..6f3b2d1 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 <fstream>
#include <iostream>
+#include <string>
+#include "absl/strings/string_view.h"
#include "rtc_base/checks.h"
namespace webrtc {
@@ -21,9 +23,9 @@
// 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 dda2c3b..9aeebe5 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 <string>
#include <utility>
+#include "absl/strings/string_view.h"
#include "rtc_base/checks.h"
#include "rtc_base/system/arch.h"
@@ -68,10 +70,11 @@
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 063ce87..bf82f9d 100644
--- a/modules/audio_processing/test/test_utils.h
+++ b/modules/audio_processing/test/test_utils.h
@@ -20,6 +20,7 @@
#include <string>
#include <vector>
+#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 @@
};
// 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 @@
// Returns a vector<T> parsed from whitespace delimited values in to_parse,
// or an empty vector if the string could not be parsed.
template <typename T>
-std::vector<T> ParseList(const std::string& to_parse) {
+std::vector<T> ParseList(absl::string_view to_parse) {
std::vector<T> values;
- std::istringstream str(to_parse);
+ std::istringstream str( // no-presubmit-check TODO(webrtc:8982)
+ std::string{to_parse});
std::copy(
std::istream_iterator<T>(str), // no-presubmit-check TODO(webrtc:8982)
std::istream_iterator<T>(), // 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 d8f6b59..ee87f9e 100644
--- a/modules/audio_processing/test/wav_based_simulator.cc
+++ b/modules/audio_processing/test/wav_based_simulator.cc
@@ -14,6 +14,7 @@
#include <iostream>
+#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 test {
std::vector<WavBasedSimulator::SimulationEventType>
-WavBasedSimulator::GetCustomEventChain(const std::string& filename) {
+WavBasedSimulator::GetCustomEventChain(absl::string_view filename) {
std::vector<WavBasedSimulator::SimulationEventType> 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 ff88fd5..44e9ee2 100644
--- a/modules/audio_processing/test/wav_based_simulator.h
+++ b/modules/audio_processing/test/wav_based_simulator.h
@@ -13,6 +13,7 @@
#include <vector>
+#include "absl/strings/string_view.h"
#include "modules/audio_processing/test/audio_processing_simulator.h"
namespace webrtc {
@@ -51,7 +52,7 @@
void PrepareReverseProcessStreamCall();
static std::vector<SimulationEventType> GetDefaultEventChain();
static std::vector<SimulationEventType> GetCustomEventChain(
- const std::string& filename);
+ absl::string_view filename);
std::vector<SimulationEventType> call_chain_;
};
diff --git a/modules/audio_processing/transient/BUILD.gn b/modules/audio_processing/transient/BUILD.gn
index 9be0da2..41aeab0 100644
--- a/modules/audio_processing/transient/BUILD.gn
+++ b/modules/audio_processing/transient/BUILD.gn
@@ -125,6 +125,9 @@
"../../../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 c32df6c..a9dddb1 100644
--- a/modules/audio_processing/transient/file_utils_unittest.cc
+++ b/modules/audio_processing/transient/file_utils_unittest.cc
@@ -16,6 +16,7 @@
#include <string>
#include <vector>
+#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 @@
~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;