mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-13 05:40:42 +01:00
Replace std::string::find() == 0 with absl::StartsWith (part 2).
This CL has been generated using clang-tidy [1] except for changes to BUILD.gn files. [1] - https://clang.llvm.org/extra/clang-tidy/checks/abseil-string-find-startswith.html Bug: None Change-Id: Ibf75601065a53bde28623b8eef57bec067235640 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/172586 Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#30984}
This commit is contained in:
parent
55c991cc81
commit
06d3559b79
19 changed files with 52 additions and 35 deletions
|
@ -149,6 +149,7 @@ rtc_library("rtc_software_fallback_wrappers") {
|
|||
"../video:video_frame",
|
||||
"../video:video_rtp_headers",
|
||||
"//third_party/abseil-cpp/absl/base:core_headers",
|
||||
"//third_party/abseil-cpp/absl/strings",
|
||||
"//third_party/abseil-cpp/absl/types:optional",
|
||||
]
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/strings/match.h"
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/fec_controller_override.h"
|
||||
#include "api/video/i420_buffer.h"
|
||||
|
@ -71,7 +72,7 @@ absl::optional<ForcedFallbackParams> ParseFallbackParamsFromFieldTrials(
|
|||
const VideoEncoder& main_encoder) {
|
||||
const std::string field_trial =
|
||||
webrtc::field_trial::FindFullName(kVp8ForceFallbackEncoderFieldTrial);
|
||||
if (field_trial.find("Enabled") != 0) {
|
||||
if (!absl::StartsWith(field_trial, "Enabled")) {
|
||||
return absl::nullopt;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/strings/match.h"
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/transport/goog_cc_factory.h"
|
||||
#include "api/transport/network_types.h"
|
||||
|
@ -60,7 +61,7 @@ TargetRateConstraints ConvertConstraints(const BitrateConstraints& contraints,
|
|||
|
||||
bool IsEnabled(const WebRtcKeyValueConfig* trials, absl::string_view key) {
|
||||
RTC_DCHECK(trials != nullptr);
|
||||
return trials->Lookup(key).find("Enabled") == 0;
|
||||
return absl::StartsWith(trials->Lookup(key), "Enabled");
|
||||
}
|
||||
|
||||
bool IsRelayed(const rtc::NetworkRoute& route) {
|
||||
|
|
|
@ -58,6 +58,7 @@ rtc_library("pacing") {
|
|||
"../rtp_rtcp:rtp_rtcp_format",
|
||||
"../utility",
|
||||
"//third_party/abseil-cpp/absl/memory",
|
||||
"//third_party/abseil-cpp/absl/strings",
|
||||
"//third_party/abseil-cpp/absl/types:optional",
|
||||
]
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include <vector>
|
||||
|
||||
#include "absl/memory/memory.h"
|
||||
#include "absl/strings/match.h"
|
||||
#include "api/rtc_event_log/rtc_event_log.h"
|
||||
#include "modules/utility/include/process_thread.h"
|
||||
#include "rtc_base/checks.h"
|
||||
|
@ -27,21 +28,19 @@ namespace webrtc {
|
|||
const int64_t PacedSender::kMaxQueueLengthMs = 2000;
|
||||
const float PacedSender::kDefaultPaceMultiplier = 2.5f;
|
||||
|
||||
PacedSender::PacedSender(Clock* clock,
|
||||
PacketRouter* packet_router,
|
||||
PacedSender::PacedSender(Clock* clock, PacketRouter* packet_router,
|
||||
RtcEventLog* event_log,
|
||||
const WebRtcKeyValueConfig* field_trials,
|
||||
ProcessThread* process_thread)
|
||||
: process_mode_((field_trials != nullptr &&
|
||||
field_trials->Lookup("WebRTC-Pacer-DynamicProcess")
|
||||
.find("Enabled") == 0)
|
||||
: process_mode_(
|
||||
(field_trials != nullptr &&
|
||||
absl::StartsWith(field_trials->Lookup("WebRTC-Pacer-DynamicProcess"),
|
||||
"Enabled"))
|
||||
? PacingController::ProcessMode::kDynamic
|
||||
: PacingController::ProcessMode::kPeriodic),
|
||||
pacing_controller_(clock,
|
||||
static_cast<PacingController::PacketSender*>(this),
|
||||
event_log,
|
||||
field_trials,
|
||||
process_mode_),
|
||||
event_log, field_trials, process_mode_),
|
||||
clock_(clock),
|
||||
packet_router_(packet_router),
|
||||
process_thread_(process_thread) {
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/strings/match.h"
|
||||
#include "modules/pacing/bitrate_prober.h"
|
||||
#include "modules/pacing/interval_budget.h"
|
||||
#include "modules/utility/include/process_thread.h"
|
||||
|
@ -42,12 +43,12 @@ constexpr int kFirstPriority = 0;
|
|||
|
||||
bool IsDisabled(const WebRtcKeyValueConfig& field_trials,
|
||||
absl::string_view key) {
|
||||
return field_trials.Lookup(key).find("Disabled") == 0;
|
||||
return absl::StartsWith(field_trials.Lookup(key), "Disabled");
|
||||
}
|
||||
|
||||
bool IsEnabled(const WebRtcKeyValueConfig& field_trials,
|
||||
absl::string_view key) {
|
||||
return field_trials.Lookup(key).find("Enabled") == 0;
|
||||
return absl::StartsWith(field_trials.Lookup(key), "Enabled");
|
||||
}
|
||||
|
||||
int GetPriorityForType(RtpPacketMediaType type) {
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <cstdint>
|
||||
#include <utility>
|
||||
|
||||
#include "absl/strings/match.h"
|
||||
#include "rtc_base/checks.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
@ -105,7 +106,7 @@ bool IsEnabled(const WebRtcKeyValueConfig* field_trials, const char* name) {
|
|||
if (!field_trials) {
|
||||
return false;
|
||||
}
|
||||
return field_trials->Lookup(name).find("Enabled") == 0;
|
||||
return absl::StartsWith(field_trials->Lookup(name), "Enabled");
|
||||
}
|
||||
|
||||
RoundRobinPacketQueue::RoundRobinPacketQueue(
|
||||
|
|
|
@ -59,6 +59,7 @@ rtc_library("remote_bitrate_estimator") {
|
|||
"../../system_wrappers",
|
||||
"../../system_wrappers:field_trial",
|
||||
"../../system_wrappers:metrics",
|
||||
"//third_party/abseil-cpp/absl/strings",
|
||||
"//third_party/abseil-cpp/absl/types:optional",
|
||||
]
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include <cstdio>
|
||||
#include <string>
|
||||
|
||||
#include "absl/strings/match.h"
|
||||
#include "api/transport/network_types.h"
|
||||
#include "api/units/data_rate.h"
|
||||
#include "modules/remote_bitrate_estimator/include/bwe_defines.h"
|
||||
|
@ -37,12 +38,12 @@ constexpr char kBweBackOffFactorExperiment[] = "WebRTC-BweBackOffFactor";
|
|||
|
||||
bool IsEnabled(const WebRtcKeyValueConfig& field_trials,
|
||||
absl::string_view key) {
|
||||
return field_trials.Lookup(key).find("Enabled") == 0;
|
||||
return absl::StartsWith(field_trials.Lookup(key), "Enabled");
|
||||
}
|
||||
|
||||
bool IsNotDisabled(const WebRtcKeyValueConfig& field_trials,
|
||||
absl::string_view key) {
|
||||
return field_trials.Lookup(key).find("Disabled") != 0;
|
||||
return !absl::StartsWith(field_trials.Lookup(key), "Disabled");
|
||||
}
|
||||
|
||||
double ReadBackoffFactor(const WebRtcKeyValueConfig& key_value_config) {
|
||||
|
|
|
@ -148,20 +148,19 @@ RTPSenderVideo::RTPSenderVideo(const Config& config)
|
|||
packetization_overhead_bitrate_(1000, RateStatistics::kBpsScale),
|
||||
frame_encryptor_(config.frame_encryptor),
|
||||
require_frame_encryption_(config.require_frame_encryption),
|
||||
generic_descriptor_auth_experiment_(
|
||||
config.field_trials->Lookup("WebRTC-GenericDescriptorAuth")
|
||||
.find("Disabled") != 0),
|
||||
exclude_transport_sequence_number_from_fec_experiment_(
|
||||
config.field_trials
|
||||
->Lookup(kExcludeTransportSequenceNumberFromFecFieldTrial)
|
||||
.find("Enabled") == 0),
|
||||
generic_descriptor_auth_experiment_(!absl::StartsWith(
|
||||
config.field_trials->Lookup("WebRTC-GenericDescriptorAuth"),
|
||||
"Disabled")),
|
||||
exclude_transport_sequence_number_from_fec_experiment_(absl::StartsWith(
|
||||
config.field_trials->Lookup(
|
||||
kExcludeTransportSequenceNumberFromFecFieldTrial),
|
||||
"Enabled")),
|
||||
absolute_capture_time_sender_(config.clock),
|
||||
frame_transformer_delegate_(
|
||||
config.frame_transformer
|
||||
? new rtc::RefCountedObject<
|
||||
RTPSenderVideoFrameTransformerDelegate>(
|
||||
this,
|
||||
std::move(config.frame_transformer))
|
||||
this, std::move(config.frame_transformer))
|
||||
: nullptr) {
|
||||
if (frame_transformer_delegate_)
|
||||
frame_transformer_delegate_->Init();
|
||||
|
|
|
@ -164,6 +164,7 @@ rtc_library("rate_control_settings") {
|
|||
"../../api/units:data_size",
|
||||
"../../api/video_codecs:video_codecs_api",
|
||||
"../../system_wrappers:field_trial",
|
||||
"//third_party/abseil-cpp/absl/strings",
|
||||
"//third_party/abseil-cpp/absl/types:optional",
|
||||
]
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
#include "absl/strings/match.h"
|
||||
#include "api/transport/field_trial_based_config.h"
|
||||
#include "rtc_base/logging.h"
|
||||
#include "rtc_base/numerics/safe_conversions.h"
|
||||
|
@ -42,7 +43,7 @@ const char* kScreenshareHysteresisFieldTrialname =
|
|||
|
||||
bool IsEnabled(const WebRtcKeyValueConfig* const key_value_config,
|
||||
absl::string_view key) {
|
||||
return key_value_config->Lookup(key).find("Enabled") == 0;
|
||||
return absl::StartsWith(key_value_config->Lookup(key), "Enabled");
|
||||
}
|
||||
|
||||
void ParseHysteresisFactor(const WebRtcKeyValueConfig* const key_value_config,
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/strings/match.h"
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/net_helpers.h"
|
||||
#include "rtc_base/network_monitor.h"
|
||||
|
@ -47,10 +48,10 @@ class FakeNetworkMonitor : public NetworkMonitorBase {
|
|||
AdapterType GetAdapterType(const std::string& if_name) override {
|
||||
// Note that the name matching rules are different from the
|
||||
// GetAdapterTypeFromName in NetworkManager.
|
||||
if (if_name.find("wifi") == 0) {
|
||||
if (absl::StartsWith(if_name, "wifi")) {
|
||||
return ADAPTER_TYPE_WIFI;
|
||||
}
|
||||
if (if_name.find("cellular") == 0) {
|
||||
if (absl::StartsWith(if_name, "cellular")) {
|
||||
return ADAPTER_TYPE_CELLULAR;
|
||||
}
|
||||
return ADAPTER_TYPE_UNKNOWN;
|
||||
|
|
|
@ -128,6 +128,7 @@ rtc_library("video_test_common") {
|
|||
"../rtc_base:timeutils",
|
||||
"../rtc_base/task_utils:repeating_task",
|
||||
"../system_wrappers",
|
||||
"//third_party/abseil-cpp/absl/strings",
|
||||
]
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/strings/match.h"
|
||||
#include "api/test/create_frame_generator.h"
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/critical_section.h"
|
||||
|
@ -34,7 +35,7 @@ std::string TransformFilePath(std::string path) {
|
|||
int ext_pos = path.rfind(".");
|
||||
if (ext_pos < 0) {
|
||||
return test::ResourcePath(path, "yuv");
|
||||
} else if (path.find(resource_prefix) == 0) {
|
||||
} else if (absl::StartsWith(path, resource_prefix)) {
|
||||
std::string name = path.substr(resource_prefix.length(), ext_pos);
|
||||
std::string ext = path.substr(ext_pos, path.size());
|
||||
return test::ResourcePath(name, ext);
|
||||
|
|
|
@ -144,6 +144,7 @@ if (rtc_include_tests) {
|
|||
"//third_party/abseil-cpp/absl/flags:flag",
|
||||
"//third_party/abseil-cpp/absl/flags:parse",
|
||||
"//third_party/abseil-cpp/absl/memory",
|
||||
"//third_party/abseil-cpp/absl/strings",
|
||||
"//third_party/abseil-cpp/absl/types:optional",
|
||||
]
|
||||
if (is_android) {
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include "absl/strings/match.h"
|
||||
#include "api/test/create_frame_generator.h"
|
||||
#include "api/test/frame_generator_interface.h"
|
||||
#include "api/test/video/function_video_encoder_factory.h"
|
||||
|
@ -112,7 +113,7 @@ std::string TransformFilePath(std::string path) {
|
|||
int ext_pos = path.rfind(".");
|
||||
if (ext_pos < 0) {
|
||||
return test::ResourcePath(path, "yuv");
|
||||
} else if (path.find(resource_prefix) == 0) {
|
||||
} else if (absl::StartsWith(path, resource_prefix)) {
|
||||
std::string name = path.substr(resource_prefix.length(), ext_pos);
|
||||
std::string ext = path.substr(ext_pos, path.size());
|
||||
return test::ResourcePath(name, ext);
|
||||
|
|
|
@ -124,6 +124,7 @@ rtc_library("video") {
|
|||
"//third_party/abseil-cpp/absl/algorithm:container",
|
||||
"//third_party/abseil-cpp/absl/base:core_headers",
|
||||
"//third_party/abseil-cpp/absl/memory",
|
||||
"//third_party/abseil-cpp/absl/strings",
|
||||
"//third_party/abseil-cpp/absl/types:optional",
|
||||
]
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include <limits>
|
||||
#include <utility>
|
||||
|
||||
#include "absl/strings/match.h"
|
||||
#include "api/video/video_codec_constants.h"
|
||||
#include "api/video/video_codec_type.h"
|
||||
#include "api/video_codecs/video_codec.h"
|
||||
|
@ -112,14 +113,16 @@ absl::optional<int> GetFallbackMaxPixels(const std::string& group) {
|
|||
absl::optional<int> GetFallbackMaxPixelsIfFieldTrialEnabled() {
|
||||
std::string group =
|
||||
webrtc::field_trial::FindFullName(kVp8ForcedFallbackEncoderFieldTrial);
|
||||
return (group.find("Enabled") == 0) ? GetFallbackMaxPixels(group.substr(7))
|
||||
return (absl::StartsWith(group, "Enabled"))
|
||||
? GetFallbackMaxPixels(group.substr(7))
|
||||
: absl::optional<int>();
|
||||
}
|
||||
|
||||
absl::optional<int> GetFallbackMaxPixelsIfFieldTrialDisabled() {
|
||||
std::string group =
|
||||
webrtc::field_trial::FindFullName(kVp8ForcedFallbackEncoderFieldTrial);
|
||||
return (group.find("Disabled") == 0) ? GetFallbackMaxPixels(group.substr(8))
|
||||
return (absl::StartsWith(group, "Disabled"))
|
||||
? GetFallbackMaxPixels(group.substr(8))
|
||||
: absl::optional<int>();
|
||||
}
|
||||
} // namespace
|
||||
|
|
Loading…
Reference in a new issue