diff --git a/modules/congestion_controller/goog_cc/BUILD.gn b/modules/congestion_controller/goog_cc/BUILD.gn index 7ec13afc17..90af511451 100644 --- a/modules/congestion_controller/goog_cc/BUILD.gn +++ b/modules/congestion_controller/goog_cc/BUILD.gn @@ -51,6 +51,7 @@ rtc_library("goog_cc") { "../../../rtc_base/experiments:rate_control_settings", "../../../system_wrappers", "../../remote_bitrate_estimator", + "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/types:optional", ] } @@ -78,6 +79,7 @@ rtc_library("pushback_controller") { "../../../api/units:data_size", "../../../rtc_base:checks", "../../../rtc_base/experiments:rate_control_settings", + "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/types:optional", ] } @@ -137,6 +139,7 @@ rtc_library("estimators") { "../../../rtc_base:safe_minmax", "../../../rtc_base/experiments:field_trial_parser", "../../remote_bitrate_estimator", + "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/types:optional", ] } @@ -162,6 +165,7 @@ rtc_library("loss_based_controller") { "../../../system_wrappers:field_trial", "../../../system_wrappers:metrics", "../../remote_bitrate_estimator", + "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/types:optional", ] } @@ -187,6 +191,7 @@ rtc_library("delay_based_bwe") { "../../../system_wrappers:metrics", "../../pacing", "../../remote_bitrate_estimator", + "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/types:optional", ] } @@ -213,6 +218,7 @@ rtc_library("probe_controller") { "../../../rtc_base/experiments:field_trial_parser", "../../../rtc_base/system:unused", "../../../system_wrappers:metrics", + "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/types:optional", ] } diff --git a/modules/congestion_controller/goog_cc/congestion_window_pushback_controller.cc b/modules/congestion_controller/goog_cc/congestion_window_pushback_controller.cc index 479fefc565..ec642823df 100644 --- a/modules/congestion_controller/goog_cc/congestion_window_pushback_controller.cc +++ b/modules/congestion_controller/goog_cc/congestion_window_pushback_controller.cc @@ -16,6 +16,7 @@ #include #include +#include "absl/strings/match.h" #include "rtc_base/checks.h" #include "rtc_base/experiments/rate_control_settings.h" @@ -24,8 +25,9 @@ namespace webrtc { CongestionWindowPushbackController::CongestionWindowPushbackController( const WebRtcKeyValueConfig* key_value_config) : add_pacing_( - key_value_config->Lookup("WebRTC-AddPacingToCongestionWindowPushback") - .find("Enabled") == 0), + absl::StartsWith(key_value_config->Lookup( + "WebRTC-AddPacingToCongestionWindowPushback"), + "Enabled")), min_pushback_target_bitrate_bps_( RateControlSettings::ParseFromKeyValueConfig(key_value_config) .CongestionWindowMinPushbackTargetBitrateBps()), diff --git a/modules/congestion_controller/goog_cc/delay_based_bwe.cc b/modules/congestion_controller/goog_cc/delay_based_bwe.cc index 33995ff2b5..1c02301284 100644 --- a/modules/congestion_controller/goog_cc/delay_based_bwe.cc +++ b/modules/congestion_controller/goog_cc/delay_based_bwe.cc @@ -17,6 +17,7 @@ #include #include +#include "absl/strings/match.h" #include "api/rtc_event_log/rtc_event.h" #include "api/rtc_event_log/rtc_event_log.h" #include "logging/rtc_event_log/events/rtc_event_bwe_update_delay_based.h" @@ -113,9 +114,9 @@ DelayBasedBwe::DelayBasedBwe(const WebRtcKeyValueConfig* key_value_config, prev_bitrate_(DataRate::Zero()), has_once_detected_overuse_(false), prev_state_(BandwidthUsage::kBwNormal), - alr_limited_backoff_enabled_( - key_value_config->Lookup("WebRTC-Bwe-AlrLimitedBackoff") - .find("Enabled") == 0) { + alr_limited_backoff_enabled_(absl::StartsWith( + key_value_config->Lookup("WebRTC-Bwe-AlrLimitedBackoff"), + "Enabled")) { RTC_LOG(LS_INFO) << "Initialized DelayBasedBwe with small packet filtering " << ignore_small_.Parser()->Encode() << ", separate audio overuse detection" diff --git a/modules/congestion_controller/goog_cc/goog_cc_network_control.cc b/modules/congestion_controller/goog_cc/goog_cc_network_control.cc index 10e775b254..e29a6704ba 100644 --- a/modules/congestion_controller/goog_cc/goog_cc_network_control.cc +++ b/modules/congestion_controller/goog_cc/goog_cc_network_control.cc @@ -21,6 +21,7 @@ #include #include +#include "absl/strings/match.h" #include "api/units/time_delta.h" #include "logging/rtc_event_log/events/rtc_event_remote_estimate.h" #include "modules/congestion_controller/goog_cc/alr_detector.h" @@ -53,11 +54,11 @@ int64_t GetBpsOrDefault(const absl::optional& rate, } bool IsEnabled(const WebRtcKeyValueConfig* config, absl::string_view key) { - return config->Lookup(key).find("Enabled") == 0; + return absl::StartsWith(config->Lookup(key), "Enabled"); } bool IsNotDisabled(const WebRtcKeyValueConfig* config, absl::string_view key) { - return config->Lookup(key).find("Disabled") != 0; + return !absl::StartsWith(config->Lookup(key), "Disabled"); } } // namespace diff --git a/modules/congestion_controller/goog_cc/probe_controller.cc b/modules/congestion_controller/goog_cc/probe_controller.cc index c921bd9001..29b472a873 100644 --- a/modules/congestion_controller/goog_cc/probe_controller.cc +++ b/modules/congestion_controller/goog_cc/probe_controller.cc @@ -15,6 +15,7 @@ #include #include +#include "absl/strings/match.h" #include "api/units/data_rate.h" #include "api/units/time_delta.h" #include "api/units/timestamp.h" @@ -129,12 +130,12 @@ ProbeControllerConfig::~ProbeControllerConfig() = default; ProbeController::ProbeController(const WebRtcKeyValueConfig* key_value_config, RtcEventLog* event_log) : enable_periodic_alr_probing_(false), - in_rapid_recovery_experiment_( - key_value_config->Lookup(kBweRapidRecoveryExperiment) - .find("Enabled") == 0), - limit_probes_with_allocateable_rate_( - key_value_config->Lookup(kCappedProbingFieldTrialName) - .find("Disabled") != 0), + in_rapid_recovery_experiment_(absl::StartsWith( + key_value_config->Lookup(kBweRapidRecoveryExperiment), + "Enabled")), + limit_probes_with_allocateable_rate_(!absl::StartsWith( + key_value_config->Lookup(kCappedProbingFieldTrialName), + "Disabled")), event_log_(event_log), config_(ProbeControllerConfig(key_value_config)) { Reset(0); diff --git a/modules/congestion_controller/goog_cc/send_side_bandwidth_estimation.cc b/modules/congestion_controller/goog_cc/send_side_bandwidth_estimation.cc index 7ebef6c73a..d2ae528404 100644 --- a/modules/congestion_controller/goog_cc/send_side_bandwidth_estimation.cc +++ b/modules/congestion_controller/goog_cc/send_side_bandwidth_estimation.cc @@ -16,6 +16,7 @@ #include #include +#include "absl/strings/match.h" #include "api/rtc_event_log/rtc_event.h" #include "api/rtc_event_log/rtc_event_log.h" #include "logging/rtc_event_log/events/rtc_event_bwe_update_loss_based.h" @@ -60,7 +61,7 @@ bool BweLossExperimentIsEnabled() { std::string experiment_string = webrtc::field_trial::FindFullName(kBweLosExperiment); // The experiment is enabled iff the field trial string begins with "Enabled". - return experiment_string.find("Enabled") == 0; + return absl::StartsWith(experiment_string, "Enabled"); } bool ReadBweLossExperimentParameters(float* low_loss_threshold, diff --git a/modules/congestion_controller/goog_cc/trendline_estimator.cc b/modules/congestion_controller/goog_cc/trendline_estimator.cc index 6675a3b0e9..c04db7351d 100644 --- a/modules/congestion_controller/goog_cc/trendline_estimator.cc +++ b/modules/congestion_controller/goog_cc/trendline_estimator.cc @@ -15,6 +15,7 @@ #include #include +#include "absl/strings/match.h" #include "absl/types/optional.h" #include "modules/remote_bitrate_estimator/include/bwe_defines.h" #include "modules/remote_bitrate_estimator/test/bwe_test_logging.h" @@ -115,8 +116,9 @@ constexpr char TrendlineEstimatorSettings::kKey[]; TrendlineEstimatorSettings::TrendlineEstimatorSettings( const WebRtcKeyValueConfig* key_value_config) { - if (key_value_config->Lookup(kBweWindowSizeInPacketsExperiment) - .find("Enabled") == 0) { + if (absl::StartsWith( + key_value_config->Lookup(kBweWindowSizeInPacketsExperiment), + "Enabled")) { window_size = ReadTrendlineFilterWindowSize(key_value_config); } Parser()->Parse(key_value_config->Lookup(TrendlineEstimatorSettings::kKey)); diff --git a/pc/BUILD.gn b/pc/BUILD.gn index 4341ce1492..576685c29c 100644 --- a/pc/BUILD.gn +++ b/pc/BUILD.gn @@ -360,6 +360,7 @@ if (rtc_include_tests) { "../test:test_support", "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/memory", + "//third_party/abseil-cpp/absl/strings", ] if (rtc_build_libsrtp) { diff --git a/pc/media_session_unittest.cc b/pc/media_session_unittest.cc index ffc4a6f430..1a4b507c2b 100644 --- a/pc/media_session_unittest.cc +++ b/pc/media_session_unittest.cc @@ -18,6 +18,7 @@ #include "absl/algorithm/container.h" #include "absl/memory/memory.h" +#include "absl/strings/match.h" #include "media/base/codec.h" #include "media/base/test_utils.h" #include "media/sctp/sctp_transport_internal.h" @@ -3061,7 +3062,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, RtxWithoutApt) { VideoContentDescription* desc = media_desc->as_video(); std::vector codecs = desc->codecs(); for (VideoCodec& codec : codecs) { - if (codec.name.find(cricket::kRtxCodecName) == 0) { + if (absl::StartsWith(codec.name, cricket::kRtxCodecName)) { codec.params.clear(); } } diff --git a/pc/peer_connection.cc b/pc/peer_connection.cc index 27cbedfe22..14281eb243 100644 --- a/pc/peer_connection.cc +++ b/pc/peer_connection.cc @@ -5820,8 +5820,9 @@ PeerConnection::InitializePortAllocator_n( // by experiment. if (configuration.disable_ipv6) { port_allocator_flags &= ~(cricket::PORTALLOCATOR_ENABLE_IPV6); - } else if (webrtc::field_trial::FindFullName("WebRTC-IPv6Default") - .find("Disabled") == 0) { + } else if (absl::StartsWith( + webrtc::field_trial::FindFullName("WebRTC-IPv6Default"), + "Disabled")) { port_allocator_flags &= ~(cricket::PORTALLOCATOR_ENABLE_IPV6); } diff --git a/pc/peer_connection_factory.cc b/pc/peer_connection_factory.cc index cfb871824b..9a758bea2d 100644 --- a/pc/peer_connection_factory.cc +++ b/pc/peer_connection_factory.cc @@ -14,6 +14,7 @@ #include #include +#include "absl/strings/match.h" #include "api/fec_controller.h" #include "api/media_stream_proxy.h" #include "api/media_stream_track_proxy.h" @@ -397,7 +398,7 @@ std::unique_ptr PeerConnectionFactory::CreateCall_w( bool PeerConnectionFactory::IsTrialEnabled(absl::string_view key) const { RTC_DCHECK(trials_); - return trials_->Lookup(key).find("Enabled") == 0; + return absl::StartsWith(trials_->Lookup(key), "Enabled"); } } // namespace webrtc diff --git a/pc/srtp_filter.cc b/pc/srtp_filter.cc index d4ad3bb063..bd48eac83d 100644 --- a/pc/srtp_filter.cc +++ b/pc/srtp_filter.cc @@ -14,6 +14,7 @@ #include +#include "absl/strings/match.h" #include "rtc_base/logging.h" #include "rtc_base/ssl_stream_adapter.h" #include "rtc_base/third_party/base64/base64.h" @@ -257,7 +258,7 @@ bool SrtpFilter::ParseKeyParams(const std::string& key_params, // example key_params: "inline:YUJDZGVmZ2hpSktMbW9QUXJzVHVWd3l6MTIzNDU2" // Fail if key-method is wrong. - if (key_params.find("inline:") != 0) { + if (!absl::StartsWith(key_params, "inline:")) { return false; } diff --git a/pc/srtp_transport.cc b/pc/srtp_transport.cc index 6306d5006b..71a58d0850 100644 --- a/pc/srtp_transport.cc +++ b/pc/srtp_transport.cc @@ -17,6 +17,7 @@ #include #include +#include "absl/strings/match.h" #include "media/base/rtp_utils.h" #include "pc/rtp_transport.h" #include "pc/srtp_session.h" @@ -493,7 +494,7 @@ bool SrtpTransport::ParseKeyParams(const std::string& key_params, // example key_params: "inline:YUJDZGVmZ2hpSktMbW9QUXJzVHVWd3l6MTIzNDU2" // Fail if key-method is wrong. - if (key_params.find("inline:") != 0) { + if (!absl::StartsWith(key_params, "inline:")) { return false; }