Use string_view to pass track ids to constructors

Bug: webrtc:13579
Change-Id: Icbd08d5fba9d150295675d730b7261d23992488c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/264441
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37035}
diff --git a/api/BUILD.gn b/api/BUILD.gn
index 5691480..b0e878e 100644
--- a/api/BUILD.gn
+++ b/api/BUILD.gn
@@ -127,7 +127,10 @@
     "video:recordable_encoded_frame",
     "video:video_frame",
   ]
-  absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ]
+  absl_deps = [
+    "//third_party/abseil-cpp/absl/strings",
+    "//third_party/abseil-cpp/absl/types:optional",
+  ]
 }
 
 rtc_library("libjingle_peerconnection_api") {
diff --git a/api/media_stream_track.h b/api/media_stream_track.h
index 738f034..316dd78 100644
--- a/api/media_stream_track.h
+++ b/api/media_stream_track.h
@@ -13,6 +13,7 @@
 
 #include <string>
 
+#include "absl/strings/string_view.h"
 #include "api/media_stream_interface.h"
 #include "api/notifier.h"
 
@@ -41,7 +42,7 @@
   void set_ended() { set_state(MediaStreamTrackInterface::TrackState::kEnded); }
 
  protected:
-  explicit MediaStreamTrack(const std::string& id)
+  explicit MediaStreamTrack(absl::string_view id)
       : enabled_(true), id_(id), state_(MediaStreamTrackInterface::kLive) {}
 
   bool set_state(MediaStreamTrackInterface::TrackState new_state) {
diff --git a/pc/audio_track.cc b/pc/audio_track.cc
index ae8914d..aa4d473 100644
--- a/pc/audio_track.cc
+++ b/pc/audio_track.cc
@@ -17,12 +17,12 @@
 
 // static
 rtc::scoped_refptr<AudioTrack> AudioTrack::Create(
-    const std::string& id,
+    absl::string_view id,
     const rtc::scoped_refptr<AudioSourceInterface>& source) {
   return rtc::make_ref_counted<AudioTrack>(id, source);
 }
 
-AudioTrack::AudioTrack(const std::string& label,
+AudioTrack::AudioTrack(absl::string_view label,
                        const rtc::scoped_refptr<AudioSourceInterface>& source)
     : MediaStreamTrack<AudioTrackInterface>(label), audio_source_(source) {
   if (audio_source_) {
diff --git a/pc/audio_track.h b/pc/audio_track.h
index 920bb94..ae326b3 100644
--- a/pc/audio_track.h
+++ b/pc/audio_track.h
@@ -29,7 +29,7 @@
                    public ObserverInterface {
  protected:
   // Protected ctor to force use of factory method.
-  AudioTrack(const std::string& label,
+  AudioTrack(absl::string_view label,
              const rtc::scoped_refptr<AudioSourceInterface>& source);
 
   AudioTrack() = delete;
@@ -40,7 +40,7 @@
 
  public:
   static rtc::scoped_refptr<AudioTrack> Create(
-      const std::string& id,
+      absl::string_view id,
       const rtc::scoped_refptr<AudioSourceInterface>& source);
 
   // MediaStreamTrack implementation.
diff --git a/pc/video_track.cc b/pc/video_track.cc
index 95e27a3..571e498 100644
--- a/pc/video_track.cc
+++ b/pc/video_track.cc
@@ -22,7 +22,7 @@
 namespace webrtc {
 
 VideoTrack::VideoTrack(
-    const std::string& label,
+    absl::string_view label,
     rtc::scoped_refptr<
         VideoTrackSourceProxyWithInternal<VideoTrackSourceInterface>> source,
     rtc::Thread* worker_thread)
@@ -131,7 +131,7 @@
 }
 
 rtc::scoped_refptr<VideoTrack> VideoTrack::Create(
-    const std::string& id,
+    absl::string_view id,
     rtc::scoped_refptr<VideoTrackSourceInterface> source,
     rtc::Thread* worker_thread) {
   rtc::scoped_refptr<
diff --git a/pc/video_track.h b/pc/video_track.h
index 8934e96..13a51c4 100644
--- a/pc/video_track.h
+++ b/pc/video_track.h
@@ -38,7 +38,7 @@
                    public ObserverInterface {
  public:
   static rtc::scoped_refptr<VideoTrack> Create(
-      const std::string& label,
+      absl::string_view label,
       rtc::scoped_refptr<VideoTrackSourceInterface> source,
       rtc::Thread* worker_thread);
 
@@ -60,7 +60,7 @@
 
  protected:
   VideoTrack(
-      const std::string& id,
+      absl::string_view id,
       rtc::scoped_refptr<
           VideoTrackSourceProxyWithInternal<VideoTrackSourceInterface>> source,
       rtc::Thread* worker_thread);