From a76487ffd25a663f45cf0b5540821a332e4efeb0 Mon Sep 17 00:00:00 2001
From: Danil Chapovalov <danilchap@webrtc.org>
Date: Thu, 2 Mar 2023 15:57:47 +0100
Subject: [PATCH] Relax string parameters in pclf api to absl::string_view
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Bug: webrtc:13579
Change-Id: I53c133bcbba6a074f3be6b996a3991a71190b1fc
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/295865
Reviewed-by: Artem Titov <titovartem@webrtc.org>
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Auto-Submit: Danil Chapovalov <danilchap@webrtc.org>
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#39459}
---
 api/test/pclf/media_configuration.cc | 22 ++++++++++------------
 api/test/pclf/media_configuration.h  |  8 ++++----
 api/test/pclf/peer_configurer.cc     |  8 ++++----
 api/test/pclf/peer_configurer.h      |  4 ++--
 pc/test/svc_e2e_tests.cc             |  2 +-
 5 files changed, 21 insertions(+), 23 deletions(-)

diff --git a/api/test/pclf/media_configuration.cc b/api/test/pclf/media_configuration.cc
index 56b9e52e01..4446e11400 100644
--- a/api/test/pclf/media_configuration.cc
+++ b/api/test/pclf/media_configuration.cc
@@ -27,7 +27,7 @@ namespace webrtc {
 namespace webrtc_pc_e2e {
 namespace {
 
-std::string SpecToString(VideoResolution::Spec spec) {
+absl::string_view SpecToString(VideoResolution::Spec spec) {
   switch (spec) {
     case VideoResolution::Spec::kNone:
       return "None";
@@ -207,24 +207,22 @@ VideoConfig::VideoConfig(const VideoResolution& resolution)
 }
 VideoConfig::VideoConfig(size_t width, size_t height, int32_t fps)
     : width(width), height(height), fps(fps) {}
-VideoConfig::VideoConfig(std::string stream_label,
+VideoConfig::VideoConfig(absl::string_view stream_label,
                          size_t width,
                          size_t height,
                          int32_t fps)
-    : width(width),
-      height(height),
-      fps(fps),
-      stream_label(std::move(stream_label)) {}
+    : width(width), height(height), fps(fps), stream_label(stream_label) {}
 
-AudioConfig::AudioConfig(std::string stream_label)
-    : stream_label(std::move(stream_label)) {}
+AudioConfig::AudioConfig(absl::string_view stream_label)
+    : stream_label(stream_label) {}
+
+VideoCodecConfig::VideoCodecConfig(absl::string_view name)
+    : name(name), required_params() {}
 
-VideoCodecConfig::VideoCodecConfig(std::string name)
-    : name(std::move(name)), required_params() {}
 VideoCodecConfig::VideoCodecConfig(
-    std::string name,
+    absl::string_view name,
     std::map<std::string, std::string> required_params)
-    : name(std::move(name)), required_params(std::move(required_params)) {}
+    : name(name), required_params(std::move(required_params)) {}
 
 absl::optional<VideoResolution> VideoSubscription::GetMaxResolution(
     rtc::ArrayView<const VideoConfig> video_configs) {
diff --git a/api/test/pclf/media_configuration.h b/api/test/pclf/media_configuration.h
index 8e841a265b..718a7b1723 100644
--- a/api/test/pclf/media_configuration.h
+++ b/api/test/pclf/media_configuration.h
@@ -306,7 +306,7 @@ class VideoDumpOptions {
 struct VideoConfig {
   explicit VideoConfig(const VideoResolution& resolution);
   VideoConfig(size_t width, size_t height, int32_t fps);
-  VideoConfig(std::string stream_label,
+  VideoConfig(absl::string_view stream_label,
               size_t width,
               size_t height,
               int32_t fps);
@@ -381,7 +381,7 @@ struct AudioConfig {
   };
 
   AudioConfig() = default;
-  explicit AudioConfig(std::string stream_label);
+  explicit AudioConfig(absl::string_view stream_label);
 
   // Have to be unique among all specified configs for all peers in the call.
   // Will be auto generated if omitted.
@@ -405,8 +405,8 @@ struct AudioConfig {
 };
 
 struct VideoCodecConfig {
-  explicit VideoCodecConfig(std::string name);
-  VideoCodecConfig(std::string name,
+  explicit VideoCodecConfig(absl::string_view name);
+  VideoCodecConfig(absl::string_view name,
                    std::map<std::string, std::string> required_params);
   // Next two fields are used to specify concrete video codec, that should be
   // used in the test. Video code will be negotiated in SDP during offer/
diff --git a/api/test/pclf/peer_configurer.cc b/api/test/pclf/peer_configurer.cc
index de7600efc1..7acaddadda 100644
--- a/api/test/pclf/peer_configurer.cc
+++ b/api/test/pclf/peer_configurer.cc
@@ -181,12 +181,12 @@ PeerConfigurer* PeerConfigurer::SetUseNetworkThreadAsWorkerThread() {
   return this;
 }
 
-PeerConfigurer* PeerConfigurer::SetRtcEventLogPath(std::string path) {
-  params_->rtc_event_log_path = std::move(path);
+PeerConfigurer* PeerConfigurer::SetRtcEventLogPath(absl::string_view path) {
+  params_->rtc_event_log_path = std::string(path);
   return this;
 }
-PeerConfigurer* PeerConfigurer::SetAecDumpPath(std::string path) {
-  params_->aec_dump_path = std::move(path);
+PeerConfigurer* PeerConfigurer::SetAecDumpPath(absl::string_view path) {
+  params_->aec_dump_path = std::string(path);
   return this;
 }
 PeerConfigurer* PeerConfigurer::SetRTCConfiguration(
diff --git a/api/test/pclf/peer_configurer.h b/api/test/pclf/peer_configurer.h
index 10f37a1eec..3596bb67ab 100644
--- a/api/test/pclf/peer_configurer.h
+++ b/api/test/pclf/peer_configurer.h
@@ -152,10 +152,10 @@ class PeerConfigurer {
 
   // If is set, an RTCEventLog will be saved in that location and it will be
   // available for further analysis.
-  PeerConfigurer* SetRtcEventLogPath(std::string path);
+  PeerConfigurer* SetRtcEventLogPath(absl::string_view path);
   // If is set, an AEC dump will be saved in that location and it will be
   // available for further analysis.
-  PeerConfigurer* SetAecDumpPath(std::string path);
+  PeerConfigurer* SetAecDumpPath(absl::string_view path);
   PeerConfigurer* SetRTCConfiguration(
       PeerConnectionInterface::RTCConfiguration configuration);
   PeerConfigurer* SetRTCOfferAnswerOptions(
diff --git a/pc/test/svc_e2e_tests.cc b/pc/test/svc_e2e_tests.cc
index dea0763758..9e911a9dba 100644
--- a/pc/test/svc_e2e_tests.cc
+++ b/pc/test/svc_e2e_tests.cc
@@ -128,7 +128,7 @@ class SvcTest : public testing::TestWithParam<
           {{kVP9FmtpProfileId, VP9ProfileToString(VP9Profile::kProfile0)}});
     }
 
-    return VideoCodecConfig(std::string(codec));
+    return VideoCodecConfig(codec);
   }
 
   const SvcTestParameters& SvcTestParameters() const {