Adopt absl::string_view in modules/audio_coding/

Bug: webrtc:13579
Change-Id: Ifec66fb6ba9724d18539de7245a358c2d13c7939
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/268547
Reviewed-by: Ivo Creusen <ivoc@webrtc.org>
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Commit-Queue: Ali Tofigh <alito@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37573}
diff --git a/modules/audio_coding/acm2/acm_send_test.cc b/modules/audio_coding/acm2/acm_send_test.cc
index a84fa7c..3e65f94 100644
--- a/modules/audio_coding/acm2/acm_send_test.cc
+++ b/modules/audio_coding/acm2/acm_send_test.cc
@@ -14,6 +14,7 @@
 #include <string.h>
 
 #include "absl/strings/match.h"
+#include "absl/strings/string_view.h"
 #include "api/audio_codecs/audio_encoder.h"
 #include "api/audio_codecs/builtin_audio_decoder_factory.h"
 #include "api/audio_codecs/builtin_audio_encoder_factory.h"
@@ -57,7 +58,7 @@
 
 AcmSendTestOldApi::~AcmSendTestOldApi() = default;
 
-bool AcmSendTestOldApi::RegisterCodec(const char* payload_name,
+bool AcmSendTestOldApi::RegisterCodec(absl::string_view payload_name,
                                       int clockrate_hz,
                                       int num_channels,
                                       int payload_type,
diff --git a/modules/audio_coding/acm2/acm_send_test.h b/modules/audio_coding/acm2/acm_send_test.h
index b14cb80..0bd2470 100644
--- a/modules/audio_coding/acm2/acm_send_test.h
+++ b/modules/audio_coding/acm2/acm_send_test.h
@@ -14,6 +14,7 @@
 #include <memory>
 #include <vector>
 
+#include "absl/strings/string_view.h"
 #include "api/audio/audio_frame.h"
 #include "modules/audio_coding/include/audio_coding_module.h"
 #include "modules/audio_coding/neteq/tools/packet_source.h"
@@ -38,7 +39,7 @@
   AcmSendTestOldApi& operator=(const AcmSendTestOldApi&) = delete;
 
   // Registers the send codec. Returns true on success, false otherwise.
-  bool RegisterCodec(const char* payload_name,
+  bool RegisterCodec(absl::string_view payload_name,
                      int sampling_freq_hz,
                      int channels,
                      int payload_type,
diff --git a/modules/audio_coding/acm2/audio_coding_module.cc b/modules/audio_coding/acm2/audio_coding_module.cc
index e2081e2..4367ab0 100644
--- a/modules/audio_coding/acm2/audio_coding_module.cc
+++ b/modules/audio_coding/acm2/audio_coding_module.cc
@@ -14,6 +14,7 @@
 #include <cstdint>
 
 #include "absl/strings/match.h"
+#include "absl/strings/string_view.h"
 #include "api/array_view.h"
 #include "modules/audio_coding/acm2/acm_receiver.h"
 #include "modules/audio_coding/acm2/acm_remixing.h"
@@ -112,7 +113,7 @@
   // the value has changed since the last time (and always for the first call).
   class ChangeLogger {
    public:
-    explicit ChangeLogger(const std::string& histogram_name)
+    explicit ChangeLogger(absl::string_view histogram_name)
         : histogram_name_(histogram_name) {}
     // Logs the new value if it is different from the last logged value, or if
     // this is the first call.
@@ -135,7 +136,7 @@
 
   int InitializeReceiverSafe() RTC_EXCLUSIVE_LOCKS_REQUIRED(acm_mutex_);
 
-  bool HaveValidEncoder(const char* caller_name) const
+  bool HaveValidEncoder(absl::string_view caller_name) const
       RTC_EXCLUSIVE_LOCKS_REQUIRED(acm_mutex_);
 
   // Preprocessing of input audio, including resampling and down-mixing if
@@ -589,7 +590,8 @@
   return 0;
 }
 
-bool AudioCodingModuleImpl::HaveValidEncoder(const char* caller_name) const {
+bool AudioCodingModuleImpl::HaveValidEncoder(
+    absl::string_view caller_name) const {
   if (!encoder_stack_) {
     RTC_LOG(LS_ERROR) << caller_name << " failed: No send codec is registered.";
     return false;
diff --git a/modules/audio_coding/acm2/audio_coding_module_unittest.cc b/modules/audio_coding/acm2/audio_coding_module_unittest.cc
index 911bd50..572ebfd 100644
--- a/modules/audio_coding/acm2/audio_coding_module_unittest.cc
+++ b/modules/audio_coding/acm2/audio_coding_module_unittest.cc
@@ -17,6 +17,7 @@
 #include <memory>
 #include <vector>
 
+#include "absl/strings/string_view.h"
 #include "api/audio_codecs/audio_encoder.h"
 #include "api/audio_codecs/builtin_audio_decoder_factory.h"
 #include "api/audio_codecs/builtin_audio_encoder_factory.h"
@@ -860,7 +861,7 @@
 
   // Sets up the test::AcmSendTest object. Returns true on success, otherwise
   // false.
-  bool SetUpSender(std::string input_file_name, int source_rate) {
+  bool SetUpSender(absl::string_view input_file_name, int source_rate) {
     // Note that `audio_source_` will loop forever. The test duration is set
     // explicitly by `kTestDurationMs`.
     audio_source_.reset(new test::InputAudioFile(input_file_name));
@@ -871,7 +872,7 @@
 
   // Registers a send codec in the test::AcmSendTest object. Returns true on
   // success, false on failure.
-  bool RegisterSendCodec(const char* payload_name,
+  bool RegisterSendCodec(absl::string_view payload_name,
                          int sampling_freq_hz,
                          int channels,
                          int payload_type,
@@ -895,8 +896,8 @@
 
   // Runs the test. SetUpSender() and RegisterSendCodec() must have been called
   // before calling this method.
-  void Run(const std::string& audio_checksum_ref,
-           const std::string& payload_checksum_ref,
+  void Run(absl::string_view audio_checksum_ref,
+           absl::string_view payload_checksum_ref,
            int expected_packets,
            test::AcmReceiveTestOldApi::NumOutputChannels expected_channels,
            rtc::scoped_refptr<AudioDecoderFactory> decoder_factory = nullptr) {
@@ -943,12 +944,12 @@
   }
 
   // Helper: result must be one the "|"-separated checksums.
-  void ExpectChecksumEq(std::string ref, std::string result) {
+  void ExpectChecksumEq(absl::string_view ref, absl::string_view result) {
     if (ref.size() == result.size()) {
       // Only one checksum: clearer message.
       EXPECT_EQ(ref, result);
     } else {
-      EXPECT_NE(ref.find(result), std::string::npos)
+      EXPECT_NE(ref.find(result), absl::string_view::npos)
           << result << " must be one of these:\n"
           << ref;
     }
@@ -988,7 +989,7 @@
                               packet->payload_length_bytes());
   }
 
-  void SetUpTest(const char* codec_name,
+  void SetUpTest(absl::string_view codec_name,
                  int codec_sample_rate_hz,
                  int channels,
                  int payload_type,
@@ -1284,7 +1285,7 @@
 
   // Registers a send codec in the test::AcmSendTest object. Returns true on
   // success, false on failure.
-  virtual bool RegisterSendCodec(const char* payload_name,
+  virtual bool RegisterSendCodec(absl::string_view payload_name,
                                  int sampling_freq_hz,
                                  int channels,
                                  int payload_type,
@@ -1310,7 +1311,7 @@
     EXPECT_GE(max_expected_total_bits, nr_bytes * 8);
   }
 
-  void SetUpTest(const char* codec_name,
+  void SetUpTest(absl::string_view codec_name,
                  int codec_sample_rate_hz,
                  int channels,
                  int payload_type,