From c397fc62d84f4aa13a7b2a963811a72af376e1b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= Date: Mon, 30 May 2022 11:26:40 +0200 Subject: [PATCH] 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 Commit-Queue: Niels Moller Cr-Commit-Position: refs/heads/main@{#37035} --- api/BUILD.gn | 5 ++++- api/media_stream_track.h | 3 ++- pc/audio_track.cc | 4 ++-- pc/audio_track.h | 4 ++-- pc/video_track.cc | 4 ++-- pc/video_track.h | 4 ++-- 6 files changed, 14 insertions(+), 10 deletions(-) diff --git a/api/BUILD.gn b/api/BUILD.gn index 569148065e..b0e878ee4d 100644 --- a/api/BUILD.gn +++ b/api/BUILD.gn @@ -127,7 +127,10 @@ rtc_library("media_stream_interface") { "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 738f034143..316dd788ef 100644 --- a/api/media_stream_track.h +++ b/api/media_stream_track.h @@ -13,6 +13,7 @@ #include +#include "absl/strings/string_view.h" #include "api/media_stream_interface.h" #include "api/notifier.h" @@ -41,7 +42,7 @@ class MediaStreamTrack : public Notifier { 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 ae8914d634..aa4d4730a0 100644 --- a/pc/audio_track.cc +++ b/pc/audio_track.cc @@ -17,12 +17,12 @@ namespace webrtc { // static rtc::scoped_refptr AudioTrack::Create( - const std::string& id, + absl::string_view id, const rtc::scoped_refptr& source) { return rtc::make_ref_counted(id, source); } -AudioTrack::AudioTrack(const std::string& label, +AudioTrack::AudioTrack(absl::string_view label, const rtc::scoped_refptr& source) : MediaStreamTrack(label), audio_source_(source) { if (audio_source_) { diff --git a/pc/audio_track.h b/pc/audio_track.h index 920bb948ba..ae326b304b 100644 --- a/pc/audio_track.h +++ b/pc/audio_track.h @@ -29,7 +29,7 @@ class AudioTrack : public MediaStreamTrack, 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& source); AudioTrack() = delete; @@ -40,7 +40,7 @@ class AudioTrack : public MediaStreamTrack, public: static rtc::scoped_refptr Create( - const std::string& id, + absl::string_view id, const rtc::scoped_refptr& source); // MediaStreamTrack implementation. diff --git a/pc/video_track.cc b/pc/video_track.cc index 95e27a3c96..571e49807c 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> source, rtc::Thread* worker_thread) @@ -131,7 +131,7 @@ void VideoTrack::OnChanged() { } rtc::scoped_refptr VideoTrack::Create( - const std::string& id, + absl::string_view id, rtc::scoped_refptr source, rtc::Thread* worker_thread) { rtc::scoped_refptr< diff --git a/pc/video_track.h b/pc/video_track.h index 8934e96592..13a51c454b 100644 --- a/pc/video_track.h +++ b/pc/video_track.h @@ -38,7 +38,7 @@ class VideoTrack : public MediaStreamTrack, public ObserverInterface { public: static rtc::scoped_refptr Create( - const std::string& label, + absl::string_view label, rtc::scoped_refptr source, rtc::Thread* worker_thread); @@ -60,7 +60,7 @@ class VideoTrack : public MediaStreamTrack, protected: VideoTrack( - const std::string& id, + absl::string_view id, rtc::scoped_refptr< VideoTrackSourceProxyWithInternal> source, rtc::Thread* worker_thread);