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}
This commit is contained in:
Niels Möller 2022-05-30 11:26:40 +02:00 committed by WebRTC LUCI CQ
parent 17a02a31d7
commit c397fc62d8
6 changed files with 14 additions and 10 deletions

View file

@ -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") {

View file

@ -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 @@ class MediaStreamTrack : public Notifier<T> {
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) {

View file

@ -17,12 +17,12 @@ namespace webrtc {
// 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_) {

View file

@ -29,7 +29,7 @@ class AudioTrack : public MediaStreamTrack<AudioTrackInterface>,
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 @@ class AudioTrack : public MediaStreamTrack<AudioTrackInterface>,
public:
static rtc::scoped_refptr<AudioTrack> Create(
const std::string& id,
absl::string_view id,
const rtc::scoped_refptr<AudioSourceInterface>& source);
// MediaStreamTrack implementation.

View file

@ -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 @@ void VideoTrack::OnChanged() {
}
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<

View file

@ -38,7 +38,7 @@ class VideoTrack : public MediaStreamTrack<VideoTrackInterface>,
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 @@ class VideoTrack : public MediaStreamTrack<VideoTrackInterface>,
protected:
VideoTrack(
const std::string& id,
absl::string_view id,
rtc::scoped_refptr<
VideoTrackSourceProxyWithInternal<VideoTrackSourceInterface>> source,
rtc::Thread* worker_thread);