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}
This commit is contained in:
Ali Tofigh
2022-07-20 12:53:07 +02:00
committed by WebRTC LUCI CQ
parent 761072f68e
commit 714e3cbb48
63 changed files with 234 additions and 152 deletions

View File

@ -10,6 +10,7 @@
#include "modules/audio_coding/neteq/test/neteq_decoding_test.h"
#include "absl/strings/string_view.h"
#include "api/audio_codecs/builtin_audio_decoder_factory.h"
#include "api/rtp_headers.h"
#include "modules/audio_coding/neteq/default_neteq_factory.h"
@ -93,7 +94,7 @@ void NetEqDecodingTest::SetUp() {
void NetEqDecodingTest::TearDown() {}
void NetEqDecodingTest::OpenInputFile(const std::string& rtp_file) {
void NetEqDecodingTest::OpenInputFile(absl::string_view rtp_file) {
rtp_source_.reset(test::RtpFileSource::Create(rtp_file));
}
@ -131,9 +132,9 @@ void NetEqDecodingTest::Process() {
}
void NetEqDecodingTest::DecodeAndCompare(
const std::string& rtp_file,
const std::string& output_checksum,
const std::string& network_stats_checksum,
absl::string_view rtp_file,
absl::string_view output_checksum,
absl::string_view network_stats_checksum,
bool gen_ref) {
OpenInputFile(rtp_file);

View File

@ -15,6 +15,7 @@
#include <set>
#include <string>
#include "absl/strings/string_view.h"
#include "api/audio/audio_frame.h"
#include "api/neteq/neteq.h"
#include "api/rtp_headers.h"
@ -39,12 +40,12 @@ class NetEqDecodingTest : public ::testing::Test {
NetEqDecodingTest();
virtual void SetUp();
virtual void TearDown();
void OpenInputFile(const std::string& rtp_file);
void OpenInputFile(absl::string_view rtp_file);
void Process();
void DecodeAndCompare(const std::string& rtp_file,
const std::string& output_checksum,
const std::string& network_stats_checksum,
void DecodeAndCompare(absl::string_view rtp_file,
absl::string_view output_checksum,
absl::string_view network_stats_checksum,
bool gen_ref);
static void PopulateRtpInfo(int frame_index,

View File

@ -106,8 +106,8 @@ NetEqOpusQualityTest::NetEqOpusQualityTest()
// Redefine decoder type if input is stereo.
if (channels_ > 1) {
audio_format_ = SdpAudioFormat(
"opus", 48000, 2, std::map<std::string, std::string>{{"stereo", "1"}});
audio_format_ = SdpAudioFormat("opus", 48000, 2,
SdpAudioFormat::Parameters{{"stereo", "1"}});
}
application_ = absl::GetFlag(FLAGS_application);
}

View File

@ -50,7 +50,7 @@ void Convert(const webrtc::NetEqNetworkStatistics& stats_raw,
void AddMessage(FILE* file,
rtc::MessageDigest* digest,
const std::string& message) {
absl::string_view message) {
int32_t size = message.length();
if (file)
ASSERT_EQ(1u, fwrite(&size, sizeof(size), 1, file));
@ -64,11 +64,11 @@ void AddMessage(FILE* file,
#endif // WEBRTC_NETEQ_UNITTEST_BITEXACT
ResultSink::ResultSink(const std::string& output_file)
ResultSink::ResultSink(absl::string_view output_file)
: output_fp_(nullptr),
digest_(rtc::MessageDigestFactory::Create(rtc::DIGEST_SHA_1)) {
if (!output_file.empty()) {
output_fp_ = fopen(output_file.c_str(), "wb");
output_fp_ = fopen(std::string(output_file).c_str(), "wb");
EXPECT_TRUE(output_fp_ != NULL);
}
}
@ -91,7 +91,7 @@ void ResultSink::AddResult(const NetEqNetworkStatistics& stats_raw) {
#endif // WEBRTC_NETEQ_UNITTEST_BITEXACT
}
void ResultSink::VerifyChecksum(const std::string& checksum) {
void ResultSink::VerifyChecksum(absl::string_view checksum) {
std::string buffer;
buffer.resize(digest_->Size());
digest_->Finish(buffer.data(), buffer.size());
@ -100,7 +100,7 @@ void ResultSink::VerifyChecksum(const std::string& checksum) {
EXPECT_EQ(checksum, result);
} else {
// Check result is one the '|'-separated checksums.
EXPECT_NE(checksum.find(result), std::string::npos)
EXPECT_NE(checksum.find(result), absl::string_view::npos)
<< result << " should be one of these:\n"
<< checksum;
}

View File

@ -15,6 +15,7 @@
#include <memory>
#include <string>
#include "absl/strings/string_view.h"
#include "api/neteq/neteq.h"
#include "rtc_base/message_digest.h"
@ -22,7 +23,7 @@ namespace webrtc {
class ResultSink {
public:
explicit ResultSink(const std::string& output_file);
explicit ResultSink(absl::string_view output_file);
~ResultSink();
template <typename T>
@ -30,7 +31,7 @@ class ResultSink {
void AddResult(const NetEqNetworkStatistics& stats);
void VerifyChecksum(const std::string& ref_check_sum);
void VerifyChecksum(absl::string_view ref_check_sum);
private:
FILE* output_fp_;