From 641a1b11b68f3b8eadee2d138bdf61dce78c8c66 Mon Sep 17 00:00:00 2001 From: Ali Tofigh Date: Tue, 17 May 2022 11:48:46 +0200 Subject: [PATCH] Adopt absl::string_view in call/ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: webrtc:13579 Change-Id: Ib616eb3372da341fafb55c23038182751b9da5a2 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/262780 Reviewed-by: Erik Språng Commit-Queue: Ali Tofigh Cr-Commit-Position: refs/heads/main@{#36910} --- call/BUILD.gn | 9 +++++++- call/adaptation/BUILD.gn | 6 ++++- .../adaptation/broadcast_resource_listener.cc | 3 ++- .../resource_adaptation_processor.cc | 6 +++-- .../resource_adaptation_processor.h | 4 +++- .../test/fake_adaptation_constraint.cc | 6 +++-- .../test/fake_adaptation_constraint.h | 3 ++- call/adaptation/test/fake_resource.cc | 7 +++--- call/adaptation/test/fake_resource.h | 5 ++-- call/bitrate_allocator_unittest.cc | 3 ++- call/bitrate_estimator_tests.cc | 6 ++--- call/call.cc | 13 ++++++----- call/call.h | 3 ++- call/call_perf_tests.cc | 13 ++++++----- call/call_unittest.cc | 5 ++-- call/degraded_call.cc | 3 ++- call/degraded_call.h | 3 ++- call/rampup_tests.cc | 9 ++++---- call/rampup_tests.h | 9 ++++---- call/rtp_demuxer.cc | 18 +++++++-------- call/rtp_demuxer.h | 10 ++++---- call/rtp_demuxer_unittest.cc | 23 ++++++++++--------- call/rtp_transport_controller_send.cc | 3 ++- call/rtp_transport_controller_send.h | 3 ++- .../rtp_transport_controller_send_interface.h | 3 ++- call/rtp_video_sender.cc | 6 +++-- .../test/mock_rtp_transport_controller_send.h | 3 ++- media/engine/fake_webrtc_call.cc | 3 ++- media/engine/fake_webrtc_call.h | 7 +++--- 29 files changed, 117 insertions(+), 78 deletions(-) diff --git a/call/BUILD.gn b/call/BUILD.gn index ba0da32bca..6b92d28c2a 100644 --- a/call/BUILD.gn +++ b/call/BUILD.gn @@ -78,6 +78,7 @@ rtc_library("call_interfaces") { ] absl_deps = [ "//third_party/abseil-cpp/absl/functional:bind_front", + "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/types:optional", ] } @@ -127,6 +128,7 @@ rtc_library("rtp_interfaces") { ] absl_deps = [ "//third_party/abseil-cpp/absl/algorithm:container", + "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/types:optional", ] } @@ -339,6 +341,7 @@ rtc_library("call") { ] absl_deps = [ "//third_party/abseil-cpp/absl/functional:bind_front", + "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/types:optional", ] } @@ -591,7 +594,10 @@ if (rtc_include_tests) { "../video", "//testing/gtest", ] - absl_deps = [ "//third_party/abseil-cpp/absl/flags:flag" ] + absl_deps = [ + "//third_party/abseil-cpp/absl/flags:flag", + "//third_party/abseil-cpp/absl/strings", + ] } } @@ -616,6 +622,7 @@ if (rtc_include_tests) { "../rtc_base/network:sent_packet", "../test:test_support", ] + absl_deps = [ "//third_party/abseil-cpp/absl/strings" ] } rtc_source_set("mock_bitrate_allocator") { testonly = true diff --git a/call/adaptation/BUILD.gn b/call/adaptation/BUILD.gn index 2cb8093860..336dd233f9 100644 --- a/call/adaptation/BUILD.gn +++ b/call/adaptation/BUILD.gn @@ -57,6 +57,7 @@ rtc_library("resource_adaptation") { ] absl_deps = [ "//third_party/abseil-cpp/absl/algorithm:container", + "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/types:optional", "//third_party/abseil-cpp/absl/types:variant", ] @@ -123,6 +124,9 @@ if (rtc_include_tests) { "../../rtc_base/task_utils:to_queued_task", "../../test:test_support", ] - absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ] + absl_deps = [ + "//third_party/abseil-cpp/absl/strings", + "//third_party/abseil-cpp/absl/types:optional", + ] } } diff --git a/call/adaptation/broadcast_resource_listener.cc b/call/adaptation/broadcast_resource_listener.cc index 5a1250ae80..9d0a849279 100644 --- a/call/adaptation/broadcast_resource_listener.cc +++ b/call/adaptation/broadcast_resource_listener.cc @@ -14,6 +14,7 @@ #include #include +#include "absl/strings/string_view.h" #include "rtc_base/checks.h" #include "rtc_base/ref_counted_object.h" #include "rtc_base/synchronization/mutex.h" @@ -24,7 +25,7 @@ namespace webrtc { // a single ResourceListener. class BroadcastResourceListener::AdapterResource : public Resource { public: - explicit AdapterResource(std::string name) : name_(std::move(name)) {} + explicit AdapterResource(absl::string_view name) : name_(std::move(name)) {} ~AdapterResource() override { RTC_DCHECK(!listener_); } // The parent is letting us know we have a usage neasurement. diff --git a/call/adaptation/resource_adaptation_processor.cc b/call/adaptation/resource_adaptation_processor.cc index a89d64b412..44fe472ff0 100644 --- a/call/adaptation/resource_adaptation_processor.cc +++ b/call/adaptation/resource_adaptation_processor.cc @@ -15,6 +15,7 @@ #include #include "absl/algorithm/container.h" +#include "absl/strings/string_view.h" #include "api/sequence_checker.h" #include "api/video/video_adaptation_counters.h" #include "call/adaptation/video_stream_adapter.h" @@ -59,8 +60,9 @@ ResourceAdaptationProcessor::MitigationResultAndLogMessage:: : result(MitigationResult::kAdaptationApplied), message() {} ResourceAdaptationProcessor::MitigationResultAndLogMessage:: - MitigationResultAndLogMessage(MitigationResult result, std::string message) - : result(result), message(std::move(message)) {} + MitigationResultAndLogMessage(MitigationResult result, + absl::string_view message) + : result(result), message(message) {} ResourceAdaptationProcessor::ResourceAdaptationProcessor( VideoStreamAdapter* stream_adapter) diff --git a/call/adaptation/resource_adaptation_processor.h b/call/adaptation/resource_adaptation_processor.h index ca2fec08c3..6ad0ef82ea 100644 --- a/call/adaptation/resource_adaptation_processor.h +++ b/call/adaptation/resource_adaptation_processor.h @@ -17,6 +17,7 @@ #include #include +#include "absl/strings/string_view.h" #include "absl/types/optional.h" #include "api/adaptation/resource.h" #include "api/rtp_parameters.h" @@ -108,7 +109,8 @@ class ResourceAdaptationProcessor : public ResourceAdaptationProcessorInterface, struct MitigationResultAndLogMessage { MitigationResultAndLogMessage(); - MitigationResultAndLogMessage(MitigationResult result, std::string message); + MitigationResultAndLogMessage(MitigationResult result, + absl::string_view message); MitigationResult result; std::string message; }; diff --git a/call/adaptation/test/fake_adaptation_constraint.cc b/call/adaptation/test/fake_adaptation_constraint.cc index 18b8e8b696..dbb31f0d3b 100644 --- a/call/adaptation/test/fake_adaptation_constraint.cc +++ b/call/adaptation/test/fake_adaptation_constraint.cc @@ -12,10 +12,12 @@ #include +#include "absl/strings/string_view.h" + namespace webrtc { -FakeAdaptationConstraint::FakeAdaptationConstraint(std::string name) - : name_(std::move(name)), is_adaptation_up_allowed_(true) {} +FakeAdaptationConstraint::FakeAdaptationConstraint(absl::string_view name) + : name_(name), is_adaptation_up_allowed_(true) {} FakeAdaptationConstraint::~FakeAdaptationConstraint() = default; diff --git a/call/adaptation/test/fake_adaptation_constraint.h b/call/adaptation/test/fake_adaptation_constraint.h index 021e46a501..5c684335f2 100644 --- a/call/adaptation/test/fake_adaptation_constraint.h +++ b/call/adaptation/test/fake_adaptation_constraint.h @@ -13,13 +13,14 @@ #include +#include "absl/strings/string_view.h" #include "call/adaptation/adaptation_constraint.h" namespace webrtc { class FakeAdaptationConstraint : public AdaptationConstraint { public: - explicit FakeAdaptationConstraint(std::string name); + explicit FakeAdaptationConstraint(absl::string_view name); ~FakeAdaptationConstraint() override; void set_is_adaptation_up_allowed(bool is_adaptation_up_allowed); diff --git a/call/adaptation/test/fake_resource.cc b/call/adaptation/test/fake_resource.cc index 70df058a70..4515b0ab72 100644 --- a/call/adaptation/test/fake_resource.cc +++ b/call/adaptation/test/fake_resource.cc @@ -13,17 +13,18 @@ #include #include +#include "absl/strings/string_view.h" #include "rtc_base/ref_counted_object.h" namespace webrtc { // static -rtc::scoped_refptr FakeResource::Create(std::string name) { +rtc::scoped_refptr FakeResource::Create(absl::string_view name) { return rtc::make_ref_counted(name); } -FakeResource::FakeResource(std::string name) - : Resource(), name_(std::move(name)), listener_(nullptr) {} +FakeResource::FakeResource(absl::string_view name) + : Resource(), name_(name), listener_(nullptr) {} FakeResource::~FakeResource() {} diff --git a/call/adaptation/test/fake_resource.h b/call/adaptation/test/fake_resource.h index e88d97db7a..1119a9614f 100644 --- a/call/adaptation/test/fake_resource.h +++ b/call/adaptation/test/fake_resource.h @@ -14,6 +14,7 @@ #include #include +#include "absl/strings/string_view.h" #include "absl/types/optional.h" #include "api/adaptation/resource.h" #include "api/scoped_refptr.h" @@ -23,9 +24,9 @@ namespace webrtc { // Fake resource used for testing. class FakeResource : public Resource { public: - static rtc::scoped_refptr Create(std::string name); + static rtc::scoped_refptr Create(absl::string_view name); - explicit FakeResource(std::string name); + explicit FakeResource(absl::string_view name); ~FakeResource() override; void SetUsageState(ResourceUsageState usage_state); diff --git a/call/bitrate_allocator_unittest.cc b/call/bitrate_allocator_unittest.cc index e4f0566827..69bdd83397 100644 --- a/call/bitrate_allocator_unittest.cc +++ b/call/bitrate_allocator_unittest.cc @@ -14,6 +14,7 @@ #include #include +#include "absl/strings/string_view.h" #include "system_wrappers/include/clock.h" #include "test/gmock.h" #include "test/gtest.h" @@ -306,7 +307,7 @@ class BitrateAllocatorTestNoEnforceMin : public ::testing::Test { uint32_t max_bitrate_bps, uint32_t pad_up_bitrate_bps, bool enforce_min_bitrate, - std::string track_id, + absl::string_view track_id, double bitrate_priority) { allocator_->AddObserver( observer, {min_bitrate_bps, max_bitrate_bps, pad_up_bitrate_bps, 0, diff --git a/call/bitrate_estimator_tests.cc b/call/bitrate_estimator_tests.cc index 424cf0b038..e18bc2475f 100644 --- a/call/bitrate_estimator_tests.cc +++ b/call/bitrate_estimator_tests.cc @@ -41,7 +41,7 @@ class LogObserver { ~LogObserver() { rtc::LogMessage::RemoveLogToStream(&callback_); } - void PushExpectedLogLine(const std::string& expected_log_line) { + void PushExpectedLogLine(absl::string_view expected_log_line) { callback_.PushExpectedLogLine(expected_log_line); } @@ -83,9 +83,9 @@ class LogObserver { bool Wait() { return done_.Wait(test::CallTest::kDefaultTimeoutMs); } - void PushExpectedLogLine(const std::string& expected_log_line) { + void PushExpectedLogLine(absl::string_view expected_log_line) { MutexLock lock(&mutex_); - expected_log_lines_.push_back(expected_log_line); + expected_log_lines_.emplace_back(expected_log_line); } private: diff --git a/call/call.cc b/call/call.cc index 1582bd2341..f96bda5702 100644 --- a/call/call.cc +++ b/call/call.cc @@ -21,6 +21,7 @@ #include #include "absl/functional/bind_front.h" +#include "absl/strings/string_view.h" #include "absl/types/optional.h" #include "api/rtc_event_log/rtc_event_log.h" #include "api/sequence_checker.h" @@ -272,7 +273,7 @@ class Call final : public webrtc::Call, uint32_t local_ssrc) override; void OnUpdateSyncGroup(webrtc::AudioReceiveStream& stream, - const std::string& sync_group) override; + absl::string_view sync_group) override; void OnSentPacket(const rtc::SentPacket& sent_packet) override; @@ -349,9 +350,9 @@ class Call final : public webrtc::Call, rtc::CopyOnWriteBuffer packet, int64_t packet_time_us) RTC_RUN_ON(worker_thread_); - AudioReceiveStream* FindAudioStreamForSyncGroup(const std::string& sync_group) + AudioReceiveStream* FindAudioStreamForSyncGroup(absl::string_view sync_group) RTC_RUN_ON(worker_thread_); - void ConfigureSync(const std::string& sync_group) RTC_RUN_ON(worker_thread_); + void ConfigureSync(absl::string_view sync_group) RTC_RUN_ON(worker_thread_); void NotifyBweOfReceivedPacket(const RtpPacketReceived& packet, MediaType media_type, @@ -1403,7 +1404,7 @@ void Call::OnLocalSsrcUpdated(FlexfecReceiveStream& stream, } void Call::OnUpdateSyncGroup(webrtc::AudioReceiveStream& stream, - const std::string& sync_group) { + absl::string_view sync_group) { RTC_DCHECK_RUN_ON(worker_thread_); webrtc::internal::AudioReceiveStream& receive_stream = static_cast(stream); @@ -1476,7 +1477,7 @@ void Call::OnAllocationLimitsChanged(BitrateAllocationLimits limits) { // RTC_RUN_ON(worker_thread_) AudioReceiveStream* Call::FindAudioStreamForSyncGroup( - const std::string& sync_group) { + absl::string_view sync_group) { RTC_DCHECK_RUN_ON(&receive_11993_checker_); if (!sync_group.empty()) { for (AudioReceiveStream* stream : audio_receive_streams_) { @@ -1490,7 +1491,7 @@ AudioReceiveStream* Call::FindAudioStreamForSyncGroup( // TODO(bugs.webrtc.org/11993): Expect to be called on the network thread. // RTC_RUN_ON(worker_thread_) -void Call::ConfigureSync(const std::string& sync_group) { +void Call::ConfigureSync(absl::string_view sync_group) { // `audio_stream` may be nullptr when clearing the audio stream for a group. AudioReceiveStream* audio_stream = FindAudioStreamForSyncGroup(sync_group); diff --git a/call/call.h b/call/call.h index 65bd5f2f23..d98616ca2c 100644 --- a/call/call.h +++ b/call/call.h @@ -15,6 +15,7 @@ #include #include +#include "absl/strings/string_view.h" #include "api/adaptation/resource.h" #include "api/media_types.h" #include "api/task_queue/task_queue_base.h" @@ -171,7 +172,7 @@ class Call { uint32_t local_ssrc) = 0; virtual void OnUpdateSyncGroup(AudioReceiveStream& stream, - const std::string& sync_group) = 0; + absl::string_view sync_group) = 0; virtual void OnSentPacket(const rtc::SentPacket& sent_packet) = 0; diff --git a/call/call_perf_tests.cc b/call/call_perf_tests.cc index 6acebf2bb7..16ecf103e4 100644 --- a/call/call_perf_tests.cc +++ b/call/call_perf_tests.cc @@ -13,6 +13,7 @@ #include #include +#include "absl/strings/string_view.h" #include "api/audio_codecs/builtin_audio_encoder_factory.h" #include "api/rtc_event_log/rtc_event_log.h" #include "api/task_queue/task_queue_base.h" @@ -76,7 +77,7 @@ class CallPerfTest : public test::CallTest { float video_ntp_speed, float video_rtp_speed, float audio_rtp_speed, - const std::string& test_label); + absl::string_view test_label); void TestMinTransmitBitrate(bool pad_to_min_bitrate); @@ -91,7 +92,7 @@ class CallPerfTest : public test::CallTest { int start_bwe, int max_bwe); void TestEncodeFramerate(VideoEncoderFactory* encoder_factory, - const std::string& payload_name, + absl::string_view payload_name, const std::vector& max_framerates); }; @@ -104,7 +105,7 @@ class VideoRtcpAndSyncObserver : public test::RtpRtcpObserver, public: explicit VideoRtcpAndSyncObserver(TaskQueueBase* task_queue, Clock* clock, - const std::string& test_label) + absl::string_view test_label) : test::RtpRtcpObserver(CallPerfTest::kLongTimeoutMs), clock_(clock), test_label_(test_label), @@ -169,7 +170,7 @@ void CallPerfTest::TestAudioVideoSync(FecMode fec, float video_ntp_speed, float video_rtp_speed, float audio_rtp_speed, - const std::string& test_label) { + absl::string_view test_label) { const char* kSyncGroup = "av_sync"; const uint32_t kAudioSendSsrc = 1234; const uint32_t kAudioRecvSsrc = 5678; @@ -1055,7 +1056,7 @@ TEST_F(CallPerfTest, MAYBE_Min_Bitrate_VideoAndAudio) { } void CallPerfTest::TestEncodeFramerate(VideoEncoderFactory* encoder_factory, - const std::string& payload_name, + absl::string_view payload_name, const std::vector& max_framerates) { static constexpr double kAllowedFpsDiff = 1.5; static constexpr TimeDelta kMinGetStatsInterval = TimeDelta::Millis(400); @@ -1067,7 +1068,7 @@ void CallPerfTest::TestEncodeFramerate(VideoEncoderFactory* encoder_factory, public test::FrameGeneratorCapturer::SinkWantsObserver { public: FramerateObserver(VideoEncoderFactory* encoder_factory, - const std::string& payload_name, + absl::string_view payload_name, const std::vector& max_framerates, TaskQueueBase* task_queue) : EndToEndTest(kDefaultTimeoutMs), diff --git a/call/call_unittest.cc b/call/call_unittest.cc index c84cc51951..e07e447a0f 100644 --- a/call/call_unittest.cc +++ b/call/call_unittest.cc @@ -16,6 +16,7 @@ #include #include "absl/memory/memory.h" +#include "absl/strings/string_view.h" #include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/rtc_event_log/rtc_event_log.h" #include "api/task_queue/default_task_queue_factory.h" @@ -82,9 +83,9 @@ namespace { rtc::scoped_refptr FindResourceWhoseNameContains( const std::vector>& resources, - const std::string& name_contains) { + absl::string_view name_contains) { for (const auto& resource : resources) { - if (resource->Name().find(name_contains) != std::string::npos) + if (resource->Name().find(std::string(name_contains)) != std::string::npos) return resource; } return nullptr; diff --git a/call/degraded_call.cc b/call/degraded_call.cc index e6dd3618e2..82f5a5a9e5 100644 --- a/call/degraded_call.cc +++ b/call/degraded_call.cc @@ -13,6 +13,7 @@ #include #include +#include "absl/strings/string_view.h" #include "rtc_base/location.h" namespace webrtc { @@ -315,7 +316,7 @@ void DegradedCall::OnLocalSsrcUpdated(FlexfecReceiveStream& stream, } void DegradedCall::OnUpdateSyncGroup(AudioReceiveStream& stream, - const std::string& sync_group) { + absl::string_view sync_group) { call_->OnUpdateSyncGroup(stream, sync_group); } diff --git a/call/degraded_call.h b/call/degraded_call.h index 586bb91701..434d377c01 100644 --- a/call/degraded_call.h +++ b/call/degraded_call.h @@ -19,6 +19,7 @@ #include #include +#include "absl/strings/string_view.h" #include "absl/types/optional.h" #include "api/call/transport.h" #include "api/fec_controller.h" @@ -105,7 +106,7 @@ class DegradedCall : public Call, private PacketReceiver { void OnLocalSsrcUpdated(FlexfecReceiveStream& stream, uint32_t local_ssrc) override; void OnUpdateSyncGroup(AudioReceiveStream& stream, - const std::string& sync_group) override; + absl::string_view sync_group) override; void OnSentPacket(const rtc::SentPacket& sent_packet) override; protected: diff --git a/call/rampup_tests.cc b/call/rampup_tests.cc index 999bb50815..ae2b0a7fed 100644 --- a/call/rampup_tests.cc +++ b/call/rampup_tests.cc @@ -13,6 +13,7 @@ #include #include "absl/flags/flag.h" +#include "absl/strings/string_view.h" #include "api/rtc_event_log/rtc_event_log_factory.h" #include "api/rtc_event_log_output_file.h" #include "api/task_queue/default_task_queue_factory.h" @@ -58,7 +59,7 @@ RampUpTester::RampUpTester(size_t num_video_streams, size_t num_flexfec_streams, unsigned int start_bitrate_bps, int64_t min_run_time_ms, - const std::string& extension_type, + absl::string_view extension_type, bool rtx, bool red, bool report_perf_stats, @@ -329,9 +330,9 @@ void RampUpTester::PollStats() { } void RampUpTester::ReportResult( - const std::string& measurement, + absl::string_view measurement, size_t value, - const std::string& units, + absl::string_view units, test::ImproveDirection improve_direction) const { webrtc::test::PrintResult( measurement, "", @@ -420,7 +421,7 @@ RampUpDownUpTester::RampUpDownUpTester(size_t num_video_streams, size_t num_audio_streams, size_t num_flexfec_streams, unsigned int start_bitrate_bps, - const std::string& extension_type, + absl::string_view extension_type, bool rtx, bool red, const std::vector& loss_rates, diff --git a/call/rampup_tests.h b/call/rampup_tests.h index 0432e662ba..aadbca818e 100644 --- a/call/rampup_tests.h +++ b/call/rampup_tests.h @@ -17,6 +17,7 @@ #include #include +#include "absl/strings/string_view.h" #include "api/rtc_event_log/rtc_event_log.h" #include "api/task_queue/task_queue_base.h" #include "api/test/simulated_network.h" @@ -43,7 +44,7 @@ class RampUpTester : public test::EndToEndTest { size_t num_flexfec_streams, unsigned int start_bitrate_bps, int64_t min_run_time_ms, - const std::string& extension_type, + absl::string_view extension_type, bool rtx, bool red, bool report_perf_stats, @@ -65,9 +66,9 @@ class RampUpTester : public test::EndToEndTest { size_t* padding_sent, size_t* media_sent) const; - void ReportResult(const std::string& measurement, + void ReportResult(absl::string_view measurement, size_t value, - const std::string& units, + absl::string_view units, test::ImproveDirection improve_direction) const; void TriggerTestDone(); @@ -128,7 +129,7 @@ class RampUpDownUpTester : public RampUpTester { size_t num_audio_streams, size_t num_flexfec_streams, unsigned int start_bitrate_bps, - const std::string& extension_type, + absl::string_view extension_type, bool rtx, bool red, const std::vector& loss_rates, diff --git a/call/rtp_demuxer.cc b/call/rtp_demuxer.cc index 3924f84df4..0b74f2ac0a 100644 --- a/call/rtp_demuxer.cc +++ b/call/rtp_demuxer.cc @@ -10,6 +10,7 @@ #include "call/rtp_demuxer.h" +#include "absl/strings/string_view.h" #include "call/rtp_packet_sink_interface.h" #include "modules/rtp_rtcp/source/rtp_header_extensions.h" #include "modules/rtp_rtcp/source/rtp_packet_received.h" @@ -238,8 +239,7 @@ bool RtpDemuxer::AddSink(uint32_t ssrc, RtpPacketSinkInterface* sink) { return AddSink(criteria, sink); } -void RtpDemuxer::AddSink(const std::string& rsid, - RtpPacketSinkInterface* sink) { +void RtpDemuxer::AddSink(absl::string_view rsid, RtpPacketSinkInterface* sink) { RtpDemuxerCriteria criteria(absl::string_view() /* mid */, rsid); AddSink(criteria, sink); } @@ -363,7 +363,7 @@ RtpPacketSinkInterface* RtpDemuxer::ResolveSink( return ResolveSinkByPayloadType(packet.PayloadType(), ssrc); } -RtpPacketSinkInterface* RtpDemuxer::ResolveSinkByMid(const std::string& mid, +RtpPacketSinkInterface* RtpDemuxer::ResolveSinkByMid(absl::string_view mid, uint32_t ssrc) { const auto it = sink_by_mid_.find(mid); if (it != sink_by_mid_.end()) { @@ -374,11 +374,11 @@ RtpPacketSinkInterface* RtpDemuxer::ResolveSinkByMid(const std::string& mid, return nullptr; } -RtpPacketSinkInterface* RtpDemuxer::ResolveSinkByMidRsid( - const std::string& mid, - const std::string& rsid, - uint32_t ssrc) { - const auto it = sink_by_mid_and_rsid_.find(std::make_pair(mid, rsid)); +RtpPacketSinkInterface* RtpDemuxer::ResolveSinkByMidRsid(absl::string_view mid, + absl::string_view rsid, + uint32_t ssrc) { + const auto it = sink_by_mid_and_rsid_.find( + std::make_pair(std::string(mid), std::string(rsid))); if (it != sink_by_mid_and_rsid_.end()) { RtpPacketSinkInterface* sink = it->second; AddSsrcSinkBinding(ssrc, sink); @@ -387,7 +387,7 @@ RtpPacketSinkInterface* RtpDemuxer::ResolveSinkByMidRsid( return nullptr; } -RtpPacketSinkInterface* RtpDemuxer::ResolveSinkByRsid(const std::string& rsid, +RtpPacketSinkInterface* RtpDemuxer::ResolveSinkByRsid(absl::string_view rsid, uint32_t ssrc) { const auto it = sink_by_rsid_.find(rsid); if (it != sink_by_rsid_.end()) { diff --git a/call/rtp_demuxer.h b/call/rtp_demuxer.h index 5fd37b4613..53eeb0b6b6 100644 --- a/call/rtp_demuxer.h +++ b/call/rtp_demuxer.h @@ -145,7 +145,7 @@ class RtpDemuxer { // Registers a sink's association to an RSID. Only one sink may be associated // with a given RSID. Null pointer is not allowed. - void AddSink(const std::string& rsid, RtpPacketSinkInterface* sink); + void AddSink(absl::string_view rsid, RtpPacketSinkInterface* sink); // Removes a sink. Return value reports if anything was actually removed. // Null pointer is not allowed. @@ -167,12 +167,12 @@ class RtpDemuxer { RtpPacketSinkInterface* ResolveSink(const RtpPacketReceived& packet); // Used by the ResolveSink algorithm. - RtpPacketSinkInterface* ResolveSinkByMid(const std::string& mid, + RtpPacketSinkInterface* ResolveSinkByMid(absl::string_view mid, uint32_t ssrc); - RtpPacketSinkInterface* ResolveSinkByMidRsid(const std::string& mid, - const std::string& rsid, + RtpPacketSinkInterface* ResolveSinkByMidRsid(absl::string_view mid, + absl::string_view rsid, uint32_t ssrc); - RtpPacketSinkInterface* ResolveSinkByRsid(const std::string& rsid, + RtpPacketSinkInterface* ResolveSinkByRsid(absl::string_view rsid, uint32_t ssrc); RtpPacketSinkInterface* ResolveSinkByPayloadType(uint8_t payload_type, uint32_t ssrc); diff --git a/call/rtp_demuxer_unittest.cc b/call/rtp_demuxer_unittest.cc index 4dbee91785..2b394d3bff 100644 --- a/call/rtp_demuxer_unittest.cc +++ b/call/rtp_demuxer_unittest.cc @@ -14,6 +14,7 @@ #include #include +#include "absl/strings/string_view.h" #include "call/test/mock_rtp_packet_sink_interface.h" #include "modules/rtp_rtcp/include/rtp_header_extension_map.h" #include "modules/rtp_rtcp/source/rtp_header_extensions.h" @@ -60,18 +61,18 @@ class RtpDemuxerTest : public ::testing::Test { return AddSink(criteria, sink); } - bool AddSinkOnlyRsid(const std::string& rsid, RtpPacketSinkInterface* sink) { + bool AddSinkOnlyRsid(absl::string_view rsid, RtpPacketSinkInterface* sink) { RtpDemuxerCriteria criteria(absl::string_view(), rsid); return AddSink(criteria, sink); } - bool AddSinkOnlyMid(const std::string& mid, RtpPacketSinkInterface* sink) { + bool AddSinkOnlyMid(absl::string_view mid, RtpPacketSinkInterface* sink) { RtpDemuxerCriteria criteria(mid); return AddSink(criteria, sink); } - bool AddSinkBothMidRsid(const std::string& mid, - const std::string& rsid, + bool AddSinkBothMidRsid(absl::string_view mid, + absl::string_view rsid, RtpPacketSinkInterface* sink) { RtpDemuxerCriteria criteria(mid, rsid); return AddSink(criteria, sink); @@ -110,7 +111,7 @@ class RtpDemuxerTest : public ::testing::Test { std::unique_ptr CreatePacketWithSsrcMid( uint32_t ssrc, - const std::string& mid) { + absl::string_view mid) { RtpPacketReceived::ExtensionManager extension_manager; extension_manager.Register(11); @@ -121,7 +122,7 @@ class RtpDemuxerTest : public ::testing::Test { std::unique_ptr CreatePacketWithSsrcRsid( uint32_t ssrc, - const std::string& rsid) { + absl::string_view rsid) { RtpPacketReceived::ExtensionManager extension_manager; extension_manager.Register(6); @@ -132,7 +133,7 @@ class RtpDemuxerTest : public ::testing::Test { std::unique_ptr CreatePacketWithSsrcRrid( uint32_t ssrc, - const std::string& rrid) { + absl::string_view rrid) { RtpPacketReceived::ExtensionManager extension_manager; extension_manager.Register(7); @@ -143,8 +144,8 @@ class RtpDemuxerTest : public ::testing::Test { std::unique_ptr CreatePacketWithSsrcMidRsid( uint32_t ssrc, - const std::string& mid, - const std::string& rsid) { + absl::string_view mid, + absl::string_view rsid) { RtpPacketReceived::ExtensionManager extension_manager; extension_manager.Register(11); extension_manager.Register(6); @@ -157,8 +158,8 @@ class RtpDemuxerTest : public ::testing::Test { std::unique_ptr CreatePacketWithSsrcRsidRrid( uint32_t ssrc, - const std::string& rsid, - const std::string& rrid) { + absl::string_view rsid, + absl::string_view rrid) { RtpPacketReceived::ExtensionManager extension_manager; extension_manager.Register(6); extension_manager.Register(7); diff --git a/call/rtp_transport_controller_send.cc b/call/rtp_transport_controller_send.cc index cc469cf93d..393acc44d0 100644 --- a/call/rtp_transport_controller_send.cc +++ b/call/rtp_transport_controller_send.cc @@ -14,6 +14,7 @@ #include #include "absl/strings/match.h" +#include "absl/strings/string_view.h" #include "absl/types/optional.h" #include "api/transport/goog_cc_factory.h" #include "api/transport/network_types.h" @@ -270,7 +271,7 @@ bool RtpTransportControllerSend::IsRelevantRouteChange( } void RtpTransportControllerSend::OnNetworkRouteChanged( - const std::string& transport_name, + absl::string_view transport_name, const rtc::NetworkRoute& network_route) { // Check if the network route is connected. diff --git a/call/rtp_transport_controller_send.h b/call/rtp_transport_controller_send.h index e982a07a8e..abe13eef36 100644 --- a/call/rtp_transport_controller_send.h +++ b/call/rtp_transport_controller_send.h @@ -17,6 +17,7 @@ #include #include +#include "absl/strings/string_view.h" #include "api/network_state_predictor.h" #include "api/sequence_checker.h" #include "api/transport/network_control.h" @@ -94,7 +95,7 @@ class RtpTransportControllerSend final StreamFeedbackProvider* GetStreamFeedbackProvider() override; void RegisterTargetTransferRateObserver( TargetTransferRateObserver* observer) override; - void OnNetworkRouteChanged(const std::string& transport_name, + void OnNetworkRouteChanged(absl::string_view transport_name, const rtc::NetworkRoute& network_route) override; void OnNetworkAvailability(bool network_available) override; RtcpBandwidthObserver* GetBandwidthObserver() override; diff --git a/call/rtp_transport_controller_send_interface.h b/call/rtp_transport_controller_send_interface.h index f68c4bf3dd..adf983c7b5 100644 --- a/call/rtp_transport_controller_send_interface.h +++ b/call/rtp_transport_controller_send_interface.h @@ -18,6 +18,7 @@ #include #include +#include "absl/strings/string_view.h" #include "absl/types/optional.h" #include "api/crypto/crypto_options.h" #include "api/fec_controller.h" @@ -127,7 +128,7 @@ class RtpTransportControllerSendInterface { virtual void RegisterTargetTransferRateObserver( TargetTransferRateObserver* observer) = 0; virtual void OnNetworkRouteChanged( - const std::string& transport_name, + absl::string_view transport_name, const rtc::NetworkRoute& network_route) = 0; virtual void OnNetworkAvailability(bool network_available) = 0; virtual RtcpBandwidthObserver* GetBandwidthObserver() = 0; diff --git a/call/rtp_video_sender.cc b/call/rtp_video_sender.cc index 116c878559..2a87b1b6f8 100644 --- a/call/rtp_video_sender.cc +++ b/call/rtp_video_sender.cc @@ -17,6 +17,7 @@ #include "absl/algorithm/container.h" #include "absl/strings/match.h" +#include "absl/strings/string_view.h" #include "api/array_view.h" #include "api/transport/field_trial_based_config.h" #include "api/video_codecs/video_codec.h" @@ -55,9 +56,10 @@ static const size_t kPathMTU = 1500; using webrtc_internal_rtp_video_sender::RtpStreamSender; -bool PayloadTypeSupportsSkippingFecPackets(const std::string& payload_name, +bool PayloadTypeSupportsSkippingFecPackets(absl::string_view payload_name, const FieldTrialsView& trials) { - const VideoCodecType codecType = PayloadStringToCodecType(payload_name); + const VideoCodecType codecType = + PayloadStringToCodecType(std::string(payload_name)); if (codecType == kVideoCodecVP8 || codecType == kVideoCodecVP9) { return true; } diff --git a/call/test/mock_rtp_transport_controller_send.h b/call/test/mock_rtp_transport_controller_send.h index 8d637a3b5c..1887cb0d1a 100644 --- a/call/test/mock_rtp_transport_controller_send.h +++ b/call/test/mock_rtp_transport_controller_send.h @@ -16,6 +16,7 @@ #include #include +#include "absl/strings/string_view.h" #include "api/crypto/crypto_options.h" #include "api/crypto/frame_encryptor_interface.h" #include "api/frame_transformer_interface.h" @@ -76,7 +77,7 @@ class MockRtpTransportControllerSend (override)); MOCK_METHOD(void, OnNetworkRouteChanged, - (const std::string&, const rtc::NetworkRoute&), + (absl::string_view, const rtc::NetworkRoute&), (override)); MOCK_METHOD(void, OnNetworkAvailability, (bool), (override)); MOCK_METHOD(RtcpBandwidthObserver*, GetBandwidthObserver, (), (override)); diff --git a/media/engine/fake_webrtc_call.cc b/media/engine/fake_webrtc_call.cc index 0cbbf7cf42..9375103c31 100644 --- a/media/engine/fake_webrtc_call.cc +++ b/media/engine/fake_webrtc_call.cc @@ -13,6 +13,7 @@ #include #include "absl/algorithm/container.h" +#include "absl/strings/string_view.h" #include "api/call/audio_sink.h" #include "modules/rtp_rtcp/source/rtp_util.h" #include "rtc_base/checks.h" @@ -728,7 +729,7 @@ void FakeCall::OnLocalSsrcUpdated(webrtc::FlexfecReceiveStream& stream, } void FakeCall::OnUpdateSyncGroup(webrtc::AudioReceiveStream& stream, - const std::string& sync_group) { + absl::string_view sync_group) { auto& fake_stream = static_cast(stream); fake_stream.SetSyncGroup(sync_group); } diff --git a/media/engine/fake_webrtc_call.h b/media/engine/fake_webrtc_call.h index 8a3e22614f..28302c79fc 100644 --- a/media/engine/fake_webrtc_call.h +++ b/media/engine/fake_webrtc_call.h @@ -25,6 +25,7 @@ #include #include +#include "absl/strings/string_view.h" #include "api/transport/field_trial_based_config.h" #include "api/video/video_frame.h" #include "call/audio_receive_stream.h" @@ -105,8 +106,8 @@ class FakeAudioReceiveStream final : public webrtc::AudioReceiveStream { config_.rtp.local_ssrc = local_ssrc; } - void SetSyncGroup(const std::string& sync_group) { - config_.sync_group = sync_group; + void SetSyncGroup(absl::string_view sync_group) { + config_.sync_group = std::string(sync_group); } private: @@ -424,7 +425,7 @@ class FakeCall final : public webrtc::Call, public webrtc::PacketReceiver { void OnLocalSsrcUpdated(webrtc::FlexfecReceiveStream& stream, uint32_t local_ssrc) override; void OnUpdateSyncGroup(webrtc::AudioReceiveStream& stream, - const std::string& sync_group) override; + absl::string_view sync_group) override; void OnSentPacket(const rtc::SentPacket& sent_packet) override; webrtc::TaskQueueBase* const network_thread_;