mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-12 21:30:45 +01:00
Replace rtc::Optional with absl::optional in rtc_base
This is a no-op change because rtc::Optional is an alias to absl::optional This CL generated by running script with parameter 'rtc_base' Then manually fix where Optional was used without rtc prefix (patchset#3) find $@ -type f \( -name \*.h -o -name \*.cc \) \ -exec sed -i 's|rtc::Optional|absl::optional|g' {} \+ \ -exec sed -i 's|rtc::nullopt|absl::nullopt|g' {} \+ \ -exec sed -i 's|#include "api/optional.h"|#include "absl/types/optional.h"|' {} \+ find $@ -type f -name BUILD.gn \ -exec sed -r -i 's|"[\./api]*:optional"|"//third_party/abseil-cpp/absl/types:optional"|' {} \+; git cl format Bug: webrtc:9078 Change-Id: I825f80cc8089747876ba6316d9e7c30e05716974 Reviewed-on: https://webrtc-review.googlesource.com/84585 Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Cr-Commit-Position: refs/heads/master@{#23700}
This commit is contained in:
parent
c806c1d337
commit
0a1d189e50
32 changed files with 170 additions and 171 deletions
|
@ -88,10 +88,10 @@ class FakePacketTransport : public PacketTransportInternal {
|
|||
|
||||
const CopyOnWriteBuffer* last_sent_packet() { return &last_sent_packet_; }
|
||||
|
||||
Optional<NetworkRoute> network_route() const override {
|
||||
absl::optional<NetworkRoute> network_route() const override {
|
||||
return network_route_;
|
||||
}
|
||||
void SetNetworkRoute(Optional<NetworkRoute> network_route) {
|
||||
void SetNetworkRoute(absl::optional<NetworkRoute> network_route) {
|
||||
network_route_ = network_route;
|
||||
}
|
||||
|
||||
|
@ -132,7 +132,7 @@ class FakePacketTransport : public PacketTransportInternal {
|
|||
bool writable_ = false;
|
||||
bool receiving_ = false;
|
||||
|
||||
Optional<NetworkRoute> network_route_;
|
||||
absl::optional<NetworkRoute> network_route_;
|
||||
};
|
||||
|
||||
} // namespace rtc
|
||||
|
|
|
@ -446,7 +446,7 @@ rtc_source_set("rtc_base_approved_generic") {
|
|||
deps += [
|
||||
"..:webrtc_common",
|
||||
"../api:array_view",
|
||||
"../api:optional",
|
||||
"//third_party/abseil-cpp/absl/types:optional",
|
||||
]
|
||||
|
||||
if (is_android) {
|
||||
|
@ -661,7 +661,7 @@ rtc_static_library("rtc_numerics") {
|
|||
":checks",
|
||||
":rtc_base_approved",
|
||||
":safe_compare",
|
||||
"../api:optional",
|
||||
"//third_party/abseil-cpp/absl/types:optional",
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -728,7 +728,7 @@ rtc_static_library("rtc_base_generic") {
|
|||
":stringutils",
|
||||
"..:webrtc_common",
|
||||
"../api:array_view",
|
||||
"../api:optional",
|
||||
"//third_party/abseil-cpp/absl/types:optional",
|
||||
]
|
||||
public_deps = [
|
||||
":rtc_base_approved",
|
||||
|
@ -1304,9 +1304,9 @@ if (rtc_include_tests) {
|
|||
":rtc_base_tests_utils",
|
||||
":stringutils",
|
||||
"../api:array_view",
|
||||
"../api:optional",
|
||||
"../test:fileutils",
|
||||
"../test:test_support",
|
||||
"//third_party/abseil-cpp/absl/types:optional",
|
||||
]
|
||||
public_deps = [
|
||||
":rtc_base",
|
||||
|
|
|
@ -15,8 +15,8 @@ rtc_static_library("alr_experiment") {
|
|||
]
|
||||
deps = [
|
||||
"../:rtc_base_approved",
|
||||
"../../api:optional",
|
||||
"../../system_wrappers:field_trial_api",
|
||||
"//third_party/abseil-cpp/absl/types:optional",
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -29,11 +29,11 @@ rtc_static_library("field_trial_parser") {
|
|||
]
|
||||
deps = [
|
||||
"../:rtc_base_approved",
|
||||
"../../api:optional",
|
||||
"../../api/units:data_rate",
|
||||
"../../api/units:data_size",
|
||||
"../../api/units:time_delta",
|
||||
"../../system_wrappers:field_trial_api",
|
||||
"//third_party/abseil-cpp/absl/types:optional",
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -44,8 +44,8 @@ rtc_static_library("congestion_controller_experiment") {
|
|||
]
|
||||
deps = [
|
||||
"../:rtc_base_approved",
|
||||
"../../api:optional",
|
||||
"../../system_wrappers:field_trial_api",
|
||||
"//third_party/abseil-cpp/absl/types:optional",
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -57,9 +57,9 @@ rtc_static_library("quality_scaling_experiment") {
|
|||
deps = [
|
||||
"../:rtc_base_approved",
|
||||
"../..:webrtc_common",
|
||||
"../../api:optional",
|
||||
"../../api/video_codecs:video_codecs_api",
|
||||
"../../system_wrappers:field_trial_api",
|
||||
"//third_party/abseil-cpp/absl/types:optional",
|
||||
]
|
||||
}
|
||||
|
||||
|
|
|
@ -31,9 +31,9 @@ bool AlrExperimentSettings::MaxOneFieldTrialEnabled() {
|
|||
.empty();
|
||||
}
|
||||
|
||||
rtc::Optional<AlrExperimentSettings>
|
||||
absl::optional<AlrExperimentSettings>
|
||||
AlrExperimentSettings::CreateFromFieldTrial(const char* experiment_name) {
|
||||
rtc::Optional<AlrExperimentSettings> ret;
|
||||
absl::optional<AlrExperimentSettings> ret;
|
||||
std::string group_name = field_trial::FindFullName(experiment_name);
|
||||
|
||||
const std::string kIgnoredSuffix = "_Dogfood";
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#ifndef RTC_BASE_EXPERIMENTS_ALR_EXPERIMENT_H_
|
||||
#define RTC_BASE_EXPERIMENTS_ALR_EXPERIMENT_H_
|
||||
|
||||
#include "api/optional.h"
|
||||
#include "absl/types/optional.h"
|
||||
|
||||
namespace webrtc {
|
||||
struct AlrExperimentSettings {
|
||||
|
@ -28,7 +28,7 @@ struct AlrExperimentSettings {
|
|||
|
||||
static const char kScreenshareProbingBweExperimentName[];
|
||||
static const char kStrictPacingAndProbingExperimentName[];
|
||||
static rtc::Optional<AlrExperimentSettings> CreateFromFieldTrial(
|
||||
static absl::optional<AlrExperimentSettings> CreateFromFieldTrial(
|
||||
const char* experiment_name);
|
||||
static bool MaxOneFieldTrialEnabled();
|
||||
|
||||
|
|
|
@ -31,10 +31,10 @@ bool CongestionControllerExperiment::InjectedControllerEnabled() {
|
|||
return trial_string.find("Enabled,Injected") == 0;
|
||||
}
|
||||
|
||||
rtc::Optional<CongestionControllerExperiment::BbrExperimentConfig>
|
||||
absl::optional<CongestionControllerExperiment::BbrExperimentConfig>
|
||||
CongestionControllerExperiment::GetBbrExperimentConfig() {
|
||||
if (!BbrControllerEnabled())
|
||||
return rtc::nullopt;
|
||||
return absl::nullopt;
|
||||
std::string trial_string =
|
||||
webrtc::field_trial::FindFullName(kControllerExperiment);
|
||||
BbrExperimentConfig config;
|
||||
|
@ -56,7 +56,7 @@ CongestionControllerExperiment::GetBbrExperimentConfig() {
|
|||
&config.probe_rtt_congestion_window_gain) == 17) {
|
||||
return config;
|
||||
} else {
|
||||
return rtc::nullopt;
|
||||
return absl::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ class CongestionControllerExperiment {
|
|||
};
|
||||
static bool BbrControllerEnabled();
|
||||
static bool InjectedControllerEnabled();
|
||||
static rtc::Optional<BbrExperimentConfig> GetBbrExperimentConfig();
|
||||
static absl::optional<BbrExperimentConfig> GetBbrExperimentConfig();
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
|
|
@ -47,7 +47,7 @@ void ParseFieldTrial(
|
|||
int key_end = std::min(val_end, colon_pos);
|
||||
int val_begin = key_end + 1;
|
||||
std::string key = trial_string.substr(i, key_end - i);
|
||||
rtc::Optional<std::string> opt_value;
|
||||
absl::optional<std::string> opt_value;
|
||||
if (val_end >= val_begin)
|
||||
opt_value = trial_string.substr(val_begin, val_end - val_begin);
|
||||
i = val_end + 1;
|
||||
|
@ -65,37 +65,37 @@ void ParseFieldTrial(
|
|||
}
|
||||
|
||||
template <>
|
||||
rtc::Optional<bool> ParseTypedParameter<bool>(std::string str) {
|
||||
absl::optional<bool> ParseTypedParameter<bool>(std::string str) {
|
||||
if (str == "true" || str == "1") {
|
||||
return true;
|
||||
} else if (str == "false" || str == "0") {
|
||||
return false;
|
||||
}
|
||||
return rtc::nullopt;
|
||||
return absl::nullopt;
|
||||
}
|
||||
|
||||
template <>
|
||||
rtc::Optional<double> ParseTypedParameter<double>(std::string str) {
|
||||
absl::optional<double> ParseTypedParameter<double>(std::string str) {
|
||||
double value;
|
||||
if (sscanf(str.c_str(), "%lf", &value) == 1) {
|
||||
return value;
|
||||
} else {
|
||||
return rtc::nullopt;
|
||||
return absl::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
template <>
|
||||
rtc::Optional<int> ParseTypedParameter<int>(std::string str) {
|
||||
absl::optional<int> ParseTypedParameter<int>(std::string str) {
|
||||
int value;
|
||||
if (sscanf(str.c_str(), "%i", &value) == 1) {
|
||||
return value;
|
||||
} else {
|
||||
return rtc::nullopt;
|
||||
return absl::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
template <>
|
||||
rtc::Optional<std::string> ParseTypedParameter<std::string>(std::string str) {
|
||||
absl::optional<std::string> ParseTypedParameter<std::string>(std::string str) {
|
||||
return std::move(str);
|
||||
}
|
||||
|
||||
|
@ -108,10 +108,10 @@ bool FieldTrialFlag::Get() const {
|
|||
return value_;
|
||||
}
|
||||
|
||||
bool FieldTrialFlag::Parse(rtc::Optional<std::string> str_value) {
|
||||
bool FieldTrialFlag::Parse(absl::optional<std::string> str_value) {
|
||||
// Only set the flag if there is no argument provided.
|
||||
if (str_value) {
|
||||
rtc::Optional<bool> opt_value = ParseTypedParameter<bool>(*str_value);
|
||||
absl::optional<bool> opt_value = ParseTypedParameter<bool>(*str_value);
|
||||
if (!opt_value)
|
||||
return false;
|
||||
value_ = *opt_value;
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include <stdint.h>
|
||||
#include <initializer_list>
|
||||
#include <string>
|
||||
#include "api/optional.h"
|
||||
#include "absl/types/optional.h"
|
||||
|
||||
// Field trial parser functionality. Provides funcitonality to parse field trial
|
||||
// argument strings in key:value format. Each parameter is described using
|
||||
|
@ -39,7 +39,7 @@ class FieldTrialParameterInterface {
|
|||
friend void ParseFieldTrial(
|
||||
std::initializer_list<FieldTrialParameterInterface*> fields,
|
||||
std::string raw_string);
|
||||
virtual bool Parse(rtc::Optional<std::string> str_value) = 0;
|
||||
virtual bool Parse(absl::optional<std::string> str_value) = 0;
|
||||
std::string Key() const;
|
||||
|
||||
private:
|
||||
|
@ -52,10 +52,10 @@ void ParseFieldTrial(
|
|||
std::initializer_list<FieldTrialParameterInterface*> fields,
|
||||
std::string raw_string);
|
||||
|
||||
// Specialize this in code file for custom types. Should return rtc::nullopt if
|
||||
// Specialize this in code file for custom types. Should return absl::nullopt if
|
||||
// the given string cannot be properly parsed.
|
||||
template <typename T>
|
||||
rtc::Optional<T> ParseTypedParameter(std::string);
|
||||
absl::optional<T> ParseTypedParameter(std::string);
|
||||
|
||||
// This class uses the ParseTypedParameter function to implement a parameter
|
||||
// implementation with an enforced default value.
|
||||
|
@ -68,9 +68,9 @@ class FieldTrialParameter : public FieldTrialParameterInterface {
|
|||
operator T() const { return Get(); }
|
||||
|
||||
protected:
|
||||
bool Parse(rtc::Optional<std::string> str_value) override {
|
||||
bool Parse(absl::optional<std::string> str_value) override {
|
||||
if (str_value) {
|
||||
rtc::Optional<T> value = ParseTypedParameter<T>(*str_value);
|
||||
absl::optional<T> value = ParseTypedParameter<T>(*str_value);
|
||||
if (value.has_value()) {
|
||||
value_ = value.value();
|
||||
return true;
|
||||
|
@ -84,31 +84,31 @@ class FieldTrialParameter : public FieldTrialParameterInterface {
|
|||
};
|
||||
|
||||
// This class uses the ParseTypedParameter function to implement an optional
|
||||
// parameter implementation that can default to rtc::nullopt.
|
||||
// parameter implementation that can default to absl::nullopt.
|
||||
template <typename T>
|
||||
class FieldTrialOptional : public FieldTrialParameterInterface {
|
||||
public:
|
||||
explicit FieldTrialOptional(std::string key)
|
||||
: FieldTrialParameterInterface(key) {}
|
||||
FieldTrialOptional(std::string key, rtc::Optional<T> default_value)
|
||||
FieldTrialOptional(std::string key, absl::optional<T> default_value)
|
||||
: FieldTrialParameterInterface(key), value_(default_value) {}
|
||||
rtc::Optional<T> Get() const { return value_; }
|
||||
absl::optional<T> Get() const { return value_; }
|
||||
|
||||
protected:
|
||||
bool Parse(rtc::Optional<std::string> str_value) override {
|
||||
bool Parse(absl::optional<std::string> str_value) override {
|
||||
if (str_value) {
|
||||
rtc::Optional<T> value = ParseTypedParameter<T>(*str_value);
|
||||
absl::optional<T> value = ParseTypedParameter<T>(*str_value);
|
||||
if (!value.has_value())
|
||||
return false;
|
||||
value_ = value.value();
|
||||
} else {
|
||||
value_ = rtc::nullopt;
|
||||
value_ = absl::nullopt;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
rtc::Optional<T> value_;
|
||||
absl::optional<T> value_;
|
||||
};
|
||||
|
||||
// Equivalent to a FieldTrialParameter<bool> in the case that both key and value
|
||||
|
@ -121,7 +121,7 @@ class FieldTrialFlag : public FieldTrialParameterInterface {
|
|||
bool Get() const;
|
||||
|
||||
protected:
|
||||
bool Parse(rtc::Optional<std::string> str_value) override;
|
||||
bool Parse(absl::optional<std::string> str_value) override;
|
||||
|
||||
private:
|
||||
bool value_;
|
||||
|
|
|
@ -43,14 +43,14 @@ enum class CustomEnum {
|
|||
// Providing a custom parser for an enum can make the trial string easier to
|
||||
// read, but also adds more code and makes the string more verbose.
|
||||
template <>
|
||||
rtc::Optional<CustomEnum> ParseTypedParameter<CustomEnum>(std::string str) {
|
||||
absl::optional<CustomEnum> ParseTypedParameter<CustomEnum>(std::string str) {
|
||||
if (str == "default")
|
||||
return CustomEnum::kDefault;
|
||||
else if (str == "red")
|
||||
return CustomEnum::kRed;
|
||||
else if (str == "blue")
|
||||
return CustomEnum::kBlue;
|
||||
return rtc::nullopt;
|
||||
return absl::nullopt;
|
||||
}
|
||||
|
||||
TEST(FieldTrialParserTest, ParsesValidParameters) {
|
||||
|
@ -104,7 +104,7 @@ TEST(FieldTrialParserTest, IgnoresInvalid) {
|
|||
EXPECT_EQ(exp.hash.Get(), "a80");
|
||||
}
|
||||
TEST(FieldTrialParserTest, ParsesOptionalParameters) {
|
||||
FieldTrialOptional<int> max_count("c", rtc::nullopt);
|
||||
FieldTrialOptional<int> max_count("c", absl::nullopt);
|
||||
ParseFieldTrial({&max_count}, "");
|
||||
EXPECT_FALSE(max_count.Get().has_value());
|
||||
ParseFieldTrial({&max_count}, "c:10");
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include <limits>
|
||||
#include <string>
|
||||
|
||||
#include "api/optional.h"
|
||||
#include "absl/types/optional.h"
|
||||
|
||||
// Large enough to fit "seconds", the longest supported unit name.
|
||||
#define RTC_TRIAL_UNIT_LENGTH_STR "7"
|
||||
|
@ -26,7 +26,7 @@ struct ValueWithUnit {
|
|||
std::string unit;
|
||||
};
|
||||
|
||||
rtc::Optional<ValueWithUnit> ParseValueWithUnit(std::string str) {
|
||||
absl::optional<ValueWithUnit> ParseValueWithUnit(std::string str) {
|
||||
if (str == "inf") {
|
||||
return ValueWithUnit{std::numeric_limits<double>::infinity(), ""};
|
||||
} else if (str == "-inf") {
|
||||
|
@ -40,13 +40,13 @@ rtc::Optional<ValueWithUnit> ParseValueWithUnit(std::string str) {
|
|||
return ValueWithUnit{double_val, unit_char};
|
||||
}
|
||||
}
|
||||
return rtc::nullopt;
|
||||
return absl::nullopt;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
template <>
|
||||
rtc::Optional<DataRate> ParseTypedParameter<DataRate>(std::string str) {
|
||||
rtc::Optional<ValueWithUnit> result = ParseValueWithUnit(str);
|
||||
absl::optional<DataRate> ParseTypedParameter<DataRate>(std::string str) {
|
||||
absl::optional<ValueWithUnit> result = ParseValueWithUnit(str);
|
||||
if (result) {
|
||||
if (result->unit.empty() || result->unit == "kbps") {
|
||||
return DataRate::kbps(result->value);
|
||||
|
@ -54,22 +54,22 @@ rtc::Optional<DataRate> ParseTypedParameter<DataRate>(std::string str) {
|
|||
return DataRate::bps(result->value);
|
||||
}
|
||||
}
|
||||
return rtc::nullopt;
|
||||
return absl::nullopt;
|
||||
}
|
||||
|
||||
template <>
|
||||
rtc::Optional<DataSize> ParseTypedParameter<DataSize>(std::string str) {
|
||||
rtc::Optional<ValueWithUnit> result = ParseValueWithUnit(str);
|
||||
absl::optional<DataSize> ParseTypedParameter<DataSize>(std::string str) {
|
||||
absl::optional<ValueWithUnit> result = ParseValueWithUnit(str);
|
||||
if (result) {
|
||||
if (result->unit.empty() || result->unit == "bytes")
|
||||
return DataSize::bytes(result->value);
|
||||
}
|
||||
return rtc::nullopt;
|
||||
return absl::nullopt;
|
||||
}
|
||||
|
||||
template <>
|
||||
rtc::Optional<TimeDelta> ParseTypedParameter<TimeDelta>(std::string str) {
|
||||
rtc::Optional<ValueWithUnit> result = ParseValueWithUnit(str);
|
||||
absl::optional<TimeDelta> ParseTypedParameter<TimeDelta>(std::string str) {
|
||||
absl::optional<ValueWithUnit> result = ParseValueWithUnit(str);
|
||||
if (result) {
|
||||
if (result->unit == "s" || result->unit == "seconds") {
|
||||
return TimeDelta::seconds(result->value);
|
||||
|
@ -79,7 +79,7 @@ rtc::Optional<TimeDelta> ParseTypedParameter<TimeDelta>(std::string str) {
|
|||
return TimeDelta::ms(result->value);
|
||||
}
|
||||
}
|
||||
return rtc::nullopt;
|
||||
return absl::nullopt;
|
||||
}
|
||||
|
||||
template class FieldTrialParameter<DataRate>;
|
||||
|
|
|
@ -21,7 +21,7 @@ struct DummyExperiment {
|
|||
FieldTrialParameter<TimeDelta> period =
|
||||
FieldTrialParameter<TimeDelta>("p", TimeDelta::ms(100));
|
||||
FieldTrialOptional<DataSize> max_buffer =
|
||||
FieldTrialOptional<DataSize>("b", rtc::nullopt);
|
||||
FieldTrialOptional<DataSize>("b", absl::nullopt);
|
||||
|
||||
explicit DummyExperiment(std::string field_trial) {
|
||||
ParseFieldTrial({&target_rate, &max_buffer, &period}, field_trial);
|
||||
|
|
|
@ -23,14 +23,14 @@ constexpr int kMaxVp9Qp = 255;
|
|||
constexpr int kMaxH264Qp = 51;
|
||||
constexpr int kMaxGenericQp = 255;
|
||||
|
||||
rtc::Optional<VideoEncoder::QpThresholds> GetThresholds(int low,
|
||||
int high,
|
||||
int max) {
|
||||
absl::optional<VideoEncoder::QpThresholds> GetThresholds(int low,
|
||||
int high,
|
||||
int max) {
|
||||
if (low < kMinQp || high > max || high < low)
|
||||
return rtc::nullopt;
|
||||
return absl::nullopt;
|
||||
|
||||
RTC_LOG(LS_INFO) << "QP thresholds: low: " << low << ", high: " << high;
|
||||
return rtc::Optional<VideoEncoder::QpThresholds>(
|
||||
return absl::optional<VideoEncoder::QpThresholds>(
|
||||
VideoEncoder::QpThresholds(low, high));
|
||||
}
|
||||
} // namespace
|
||||
|
@ -39,11 +39,11 @@ bool QualityScalingExperiment::Enabled() {
|
|||
return webrtc::field_trial::IsEnabled(kFieldTrial);
|
||||
}
|
||||
|
||||
rtc::Optional<QualityScalingExperiment::Settings>
|
||||
absl::optional<QualityScalingExperiment::Settings>
|
||||
QualityScalingExperiment::ParseSettings() {
|
||||
const std::string group = webrtc::field_trial::FindFullName(kFieldTrial);
|
||||
if (group.empty())
|
||||
return rtc::nullopt;
|
||||
return absl::nullopt;
|
||||
|
||||
Settings s;
|
||||
if (sscanf(group.c_str(), "Enabled-%d,%d,%d,%d,%d,%d,%d,%d,%f,%f,%d",
|
||||
|
@ -51,16 +51,16 @@ QualityScalingExperiment::ParseSettings() {
|
|||
&s.h264_high, &s.generic_low, &s.generic_high, &s.alpha_high,
|
||||
&s.alpha_low, &s.drop) != 11) {
|
||||
RTC_LOG(LS_WARNING) << "Invalid number of parameters provided.";
|
||||
return rtc::nullopt;
|
||||
return absl::nullopt;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
rtc::Optional<VideoEncoder::QpThresholds>
|
||||
absl::optional<VideoEncoder::QpThresholds>
|
||||
QualityScalingExperiment::GetQpThresholds(VideoCodecType codec_type) {
|
||||
const auto settings = ParseSettings();
|
||||
if (!settings)
|
||||
return rtc::nullopt;
|
||||
return absl::nullopt;
|
||||
|
||||
switch (codec_type) {
|
||||
case kVideoCodecVP8:
|
||||
|
@ -73,7 +73,7 @@ QualityScalingExperiment::GetQpThresholds(VideoCodecType codec_type) {
|
|||
return GetThresholds(settings->generic_low, settings->generic_high,
|
||||
kMaxGenericQp);
|
||||
default:
|
||||
return rtc::nullopt;
|
||||
return absl::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#ifndef RTC_BASE_EXPERIMENTS_QUALITY_SCALING_EXPERIMENT_H_
|
||||
#define RTC_BASE_EXPERIMENTS_QUALITY_SCALING_EXPERIMENT_H_
|
||||
|
||||
#include "api/optional.h"
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/video_codecs/video_encoder.h"
|
||||
#include "common_types.h" // NOLINT(build/include)
|
||||
|
||||
|
@ -44,10 +44,10 @@ class QualityScalingExperiment {
|
|||
static bool Enabled();
|
||||
|
||||
// Returns settings from field trial.
|
||||
static rtc::Optional<Settings> ParseSettings();
|
||||
static absl::optional<Settings> ParseSettings();
|
||||
|
||||
// Returns QpThresholds for the |codec_type|.
|
||||
static rtc::Optional<VideoEncoder::QpThresholds> GetQpThresholds(
|
||||
static absl::optional<VideoEncoder::QpThresholds> GetQpThresholds(
|
||||
VideoCodecType codec_type);
|
||||
|
||||
// Returns parsed values. If the parsing fails, default values are returned.
|
||||
|
|
|
@ -48,12 +48,12 @@ void HistogramPercentileCounter::Add(uint32_t value) {
|
|||
Add(value, 1);
|
||||
}
|
||||
|
||||
rtc::Optional<uint32_t> HistogramPercentileCounter::GetPercentile(
|
||||
absl::optional<uint32_t> HistogramPercentileCounter::GetPercentile(
|
||||
float fraction) {
|
||||
RTC_CHECK_LE(fraction, 1.0);
|
||||
RTC_CHECK_GE(fraction, 0.0);
|
||||
if (total_elements_ == 0)
|
||||
return rtc::nullopt;
|
||||
return absl::nullopt;
|
||||
size_t elements_to_skip = static_cast<size_t>(
|
||||
std::max(0.0f, std::ceil(total_elements_ * fraction) - 1));
|
||||
if (elements_to_skip >= total_elements_)
|
||||
|
@ -73,7 +73,7 @@ rtc::Optional<uint32_t> HistogramPercentileCounter::GetPercentile(
|
|||
}
|
||||
}
|
||||
RTC_NOTREACHED();
|
||||
return rtc::nullopt;
|
||||
return absl::nullopt;
|
||||
}
|
||||
|
||||
} // namespace rtc
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#include "api/optional.h"
|
||||
#include "absl/types/optional.h"
|
||||
|
||||
namespace rtc {
|
||||
// Calculates percentiles on the stream of data. Use |Add| methods to add new
|
||||
|
@ -30,7 +30,7 @@ class HistogramPercentileCounter {
|
|||
void Add(uint32_t value, size_t count);
|
||||
void Add(const HistogramPercentileCounter& other);
|
||||
// Argument should be from 0 to 1.
|
||||
rtc::Optional<uint32_t> GetPercentile(float fraction);
|
||||
absl::optional<uint32_t> GetPercentile(float fraction);
|
||||
|
||||
private:
|
||||
std::vector<size_t> histogram_low_;
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include <limits>
|
||||
#include <utility>
|
||||
|
||||
#include "api/optional.h"
|
||||
#include "absl/types/optional.h"
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/constructormagic.h"
|
||||
|
||||
|
@ -40,7 +40,7 @@ class MovingMaxCounter {
|
|||
// Advances the current time, and returns the maximum sample in the time
|
||||
// window ending at the current time. The new current time must be at least as
|
||||
// large as the old current time.
|
||||
rtc::Optional<T> Max(int64_t current_time_ms);
|
||||
absl::optional<T> Max(int64_t current_time_ms);
|
||||
void Reset();
|
||||
|
||||
private:
|
||||
|
@ -83,9 +83,9 @@ void MovingMaxCounter<T>::Add(const T& sample, int64_t current_time_ms) {
|
|||
}
|
||||
|
||||
template <class T>
|
||||
rtc::Optional<T> MovingMaxCounter<T>::Max(int64_t current_time_ms) {
|
||||
absl::optional<T> MovingMaxCounter<T>::Max(int64_t current_time_ms) {
|
||||
RollWindow(current_time_ms);
|
||||
rtc::Optional<T> res;
|
||||
absl::optional<T> res;
|
||||
if (!samples_.empty()) {
|
||||
res.emplace(samples_.front().second);
|
||||
}
|
||||
|
|
|
@ -54,24 +54,24 @@ void SampleCounter::Add(const SampleCounter& other) {
|
|||
max_ = other.max_;
|
||||
}
|
||||
|
||||
rtc::Optional<int> SampleCounter::Avg(int64_t min_required_samples) const {
|
||||
absl::optional<int> SampleCounter::Avg(int64_t min_required_samples) const {
|
||||
RTC_DCHECK_GT(min_required_samples, 0);
|
||||
if (num_samples_ < min_required_samples)
|
||||
return rtc::nullopt;
|
||||
return absl::nullopt;
|
||||
return rtc::dchecked_cast<int>(sum_ / num_samples_);
|
||||
}
|
||||
|
||||
rtc::Optional<int64_t> SampleCounter::Variance(
|
||||
absl::optional<int64_t> SampleCounter::Variance(
|
||||
int64_t min_required_samples) const {
|
||||
RTC_DCHECK_GT(min_required_samples, 0);
|
||||
if (num_samples_ < min_required_samples)
|
||||
return rtc::nullopt;
|
||||
return absl::nullopt;
|
||||
// E[(x-mean)^2] = E[x^2] - mean^2
|
||||
int64_t mean = sum_ / num_samples_;
|
||||
return sum_squared_ / num_samples_ - mean * mean;
|
||||
}
|
||||
|
||||
rtc::Optional<int> SampleCounter::Max() const {
|
||||
absl::optional<int> SampleCounter::Max() const {
|
||||
return max_;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#ifndef RTC_BASE_NUMERICS_SAMPLE_COUNTER_H_
|
||||
#define RTC_BASE_NUMERICS_SAMPLE_COUNTER_H_
|
||||
|
||||
#include "api/optional.h"
|
||||
#include "absl/types/optional.h"
|
||||
|
||||
namespace rtc {
|
||||
|
||||
|
@ -22,9 +22,9 @@ class SampleCounter {
|
|||
SampleCounter();
|
||||
~SampleCounter();
|
||||
void Add(int sample);
|
||||
rtc::Optional<int> Avg(int64_t min_required_samples) const;
|
||||
rtc::Optional<int64_t> Variance(int64_t min_required_samples) const;
|
||||
rtc::Optional<int> Max() const;
|
||||
absl::optional<int> Avg(int64_t min_required_samples) const;
|
||||
absl::optional<int64_t> Variance(int64_t min_required_samples) const;
|
||||
absl::optional<int> Max() const;
|
||||
void Reset();
|
||||
// Adds all the samples from the |other| SampleCounter as if they were all
|
||||
// individually added using |Add(int)| method.
|
||||
|
@ -34,7 +34,7 @@ class SampleCounter {
|
|||
int64_t sum_ = 0;
|
||||
int64_t sum_squared_ = 0;
|
||||
int64_t num_samples_ = 0;
|
||||
rtc::Optional<int> max_;
|
||||
absl::optional<int> max_;
|
||||
};
|
||||
|
||||
} // namespace rtc
|
||||
|
|
|
@ -23,9 +23,9 @@ namespace rtc {
|
|||
TEST(SampleCounterTest, ProcessesNoSamples) {
|
||||
constexpr int kMinSamples = 1;
|
||||
SampleCounter counter;
|
||||
EXPECT_THAT(counter.Avg(kMinSamples), Eq(rtc::nullopt));
|
||||
EXPECT_THAT(counter.Avg(kMinSamples), Eq(rtc::nullopt));
|
||||
EXPECT_THAT(counter.Max(), Eq(rtc::nullopt));
|
||||
EXPECT_THAT(counter.Avg(kMinSamples), Eq(absl::nullopt));
|
||||
EXPECT_THAT(counter.Avg(kMinSamples), Eq(absl::nullopt));
|
||||
EXPECT_THAT(counter.Max(), Eq(absl::nullopt));
|
||||
}
|
||||
|
||||
TEST(SampleCounterTest, NotEnoughSamples) {
|
||||
|
@ -34,8 +34,8 @@ TEST(SampleCounterTest, NotEnoughSamples) {
|
|||
for (int value : {1, 2, 3, 4, 5}) {
|
||||
counter.Add(value);
|
||||
}
|
||||
EXPECT_THAT(counter.Avg(kMinSamples), Eq(rtc::nullopt));
|
||||
EXPECT_THAT(counter.Avg(kMinSamples), Eq(rtc::nullopt));
|
||||
EXPECT_THAT(counter.Avg(kMinSamples), Eq(absl::nullopt));
|
||||
EXPECT_THAT(counter.Avg(kMinSamples), Eq(absl::nullopt));
|
||||
EXPECT_THAT(counter.Max(), Eq(5));
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include <limits>
|
||||
#include <type_traits>
|
||||
|
||||
#include "api/optional.h"
|
||||
#include "absl/types/optional.h"
|
||||
#include "rtc_base/numerics/mod_ops.h"
|
||||
#include "rtc_base/numerics/safe_compare.h"
|
||||
|
||||
|
@ -120,7 +120,7 @@ class SeqNumUnwrapper {
|
|||
|
||||
private:
|
||||
uint64_t last_unwrapped_;
|
||||
rtc::Optional<T> last_value_;
|
||||
absl::optional<T> last_value_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
|
|
@ -29,7 +29,7 @@ RateLimiter::~RateLimiter() {}
|
|||
bool RateLimiter::TryUseRate(size_t packet_size_bytes) {
|
||||
rtc::CritScope cs(&lock_);
|
||||
int64_t now_ms = clock_->TimeInMilliseconds();
|
||||
rtc::Optional<uint32_t> current_rate = current_rate_.Rate(now_ms);
|
||||
absl::optional<uint32_t> current_rate = current_rate_.Rate(now_ms);
|
||||
if (current_rate) {
|
||||
// If there is a current rate, check if adding bytes would cause maximum
|
||||
// bitrate target to be exceeded. If there is NOT a valid current rate,
|
||||
|
|
|
@ -61,7 +61,7 @@ void RateStatistics::Update(size_t count, int64_t now_ms) {
|
|||
++num_samples_;
|
||||
}
|
||||
|
||||
rtc::Optional<uint32_t> RateStatistics::Rate(int64_t now_ms) const {
|
||||
absl::optional<uint32_t> RateStatistics::Rate(int64_t now_ms) const {
|
||||
// Yeah, this const_cast ain't pretty, but the alternative is to declare most
|
||||
// of the members as mutable...
|
||||
const_cast<RateStatistics*>(this)->EraseOld(now_ms);
|
||||
|
@ -71,7 +71,7 @@ rtc::Optional<uint32_t> RateStatistics::Rate(int64_t now_ms) const {
|
|||
int64_t active_window_size = now_ms - oldest_time_ + 1;
|
||||
if (num_samples_ == 0 || active_window_size <= 1 ||
|
||||
(num_samples_ <= 1 && active_window_size < current_window_size_ms_)) {
|
||||
return rtc::nullopt;
|
||||
return absl::nullopt;
|
||||
}
|
||||
|
||||
float scale = scale_ / active_window_size;
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
#include <memory>
|
||||
|
||||
#include "api/optional.h"
|
||||
#include "absl/types/optional.h"
|
||||
#include "typedefs.h" // NOLINT(build/include)
|
||||
|
||||
namespace webrtc {
|
||||
|
@ -42,7 +42,7 @@ class RateStatistics {
|
|||
// from a monotonic clock. Ie, it doesn't matter if this call moves the
|
||||
// window, since any subsequent call to Update or Rate would still have moved
|
||||
// the window as much or more.
|
||||
rtc::Optional<uint32_t> Rate(int64_t now_ms) const;
|
||||
absl::optional<uint32_t> Rate(int64_t now_ms) const;
|
||||
|
||||
// Update the size of the averaging window. The maximum allowed value for
|
||||
// window_size_ms is max_window_size_ms as supplied in the constructor.
|
||||
|
|
|
@ -53,7 +53,7 @@ TEST_F(RateStatisticsTest, TestStrictMode) {
|
|||
// Approximately 1200 kbps expected. Not exact since when packets
|
||||
// are removed we will jump 10 ms to the next packet.
|
||||
if (i > kInterval) {
|
||||
rtc::Optional<uint32_t> rate = stats_.Rate(now_ms);
|
||||
absl::optional<uint32_t> rate = stats_.Rate(now_ms);
|
||||
EXPECT_TRUE(static_cast<bool>(rate));
|
||||
uint32_t samples = i / kInterval + 1;
|
||||
uint64_t total_bits = samples * kPacketSize * 8;
|
||||
|
@ -78,7 +78,7 @@ TEST_F(RateStatisticsTest, IncreasingThenDecreasingBitrate) {
|
|||
const uint32_t kExpectedBitrate = 8000000;
|
||||
// 1000 bytes per millisecond until plateau is reached.
|
||||
int prev_error = kExpectedBitrate;
|
||||
rtc::Optional<uint32_t> bitrate;
|
||||
absl::optional<uint32_t> bitrate;
|
||||
while (++now_ms < 10000) {
|
||||
stats_.Update(1000, now_ms);
|
||||
bitrate = stats_.Rate(now_ms);
|
||||
|
@ -102,7 +102,7 @@ TEST_F(RateStatisticsTest, IncreasingThenDecreasingBitrate) {
|
|||
// Zero bytes per millisecond until 0 is reached.
|
||||
while (++now_ms < 20000) {
|
||||
stats_.Update(0, now_ms);
|
||||
rtc::Optional<uint32_t> new_bitrate = stats_.Rate(now_ms);
|
||||
absl::optional<uint32_t> new_bitrate = stats_.Rate(now_ms);
|
||||
if (static_cast<bool>(new_bitrate) && *new_bitrate != *bitrate) {
|
||||
// New bitrate must be lower than previous one.
|
||||
EXPECT_LT(*new_bitrate, *bitrate);
|
||||
|
@ -130,7 +130,7 @@ TEST_F(RateStatisticsTest, ResetAfterSilence) {
|
|||
const uint32_t kExpectedBitrate = 8000000;
|
||||
// 1000 bytes per millisecond until the window has been filled.
|
||||
int prev_error = kExpectedBitrate;
|
||||
rtc::Optional<uint32_t> bitrate;
|
||||
absl::optional<uint32_t> bitrate;
|
||||
while (++now_ms < 10000) {
|
||||
stats_.Update(1000, now_ms);
|
||||
bitrate = stats_.Rate(now_ms);
|
||||
|
@ -213,7 +213,7 @@ TEST_F(RateStatisticsTest, RespectsWindowSizeEdges) {
|
|||
|
||||
// Window size should be full, and the single data point should be accepted.
|
||||
++now_ms;
|
||||
rtc::Optional<uint32_t> bitrate = stats_.Rate(now_ms);
|
||||
absl::optional<uint32_t> bitrate = stats_.Rate(now_ms);
|
||||
EXPECT_TRUE(static_cast<bool>(bitrate));
|
||||
EXPECT_EQ(1000 * 8u, *bitrate);
|
||||
|
||||
|
@ -239,7 +239,7 @@ TEST_F(RateStatisticsTest, HandlesZeroCounts) {
|
|||
stats_.Update(kWindowMs, now_ms);
|
||||
now_ms += kWindowMs - 1;
|
||||
stats_.Update(0, now_ms);
|
||||
rtc::Optional<uint32_t> bitrate = stats_.Rate(now_ms);
|
||||
absl::optional<uint32_t> bitrate = stats_.Rate(now_ms);
|
||||
EXPECT_TRUE(static_cast<bool>(bitrate));
|
||||
EXPECT_EQ(1000 * 8u, *bitrate);
|
||||
|
||||
|
@ -262,7 +262,7 @@ TEST_F(RateStatisticsTest, HandlesQuietPeriods) {
|
|||
|
||||
stats_.Update(0, now_ms);
|
||||
now_ms += kWindowMs - 1;
|
||||
rtc::Optional<uint32_t> bitrate = stats_.Rate(now_ms);
|
||||
absl::optional<uint32_t> bitrate = stats_.Rate(now_ms);
|
||||
EXPECT_TRUE(static_cast<bool>(bitrate));
|
||||
EXPECT_EQ(0u, *bitrate);
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ class RTCCertificateGenerationTask : public RefCountInterface,
|
|||
Thread* signaling_thread,
|
||||
Thread* worker_thread,
|
||||
const KeyParams& key_params,
|
||||
const Optional<uint64_t>& expires_ms,
|
||||
const absl::optional<uint64_t>& expires_ms,
|
||||
const scoped_refptr<RTCCertificateGeneratorCallback>& callback)
|
||||
: signaling_thread_(signaling_thread),
|
||||
worker_thread_(worker_thread),
|
||||
|
@ -94,7 +94,7 @@ class RTCCertificateGenerationTask : public RefCountInterface,
|
|||
Thread* const signaling_thread_;
|
||||
Thread* const worker_thread_;
|
||||
const KeyParams key_params_;
|
||||
const Optional<uint64_t> expires_ms_;
|
||||
const absl::optional<uint64_t> expires_ms_;
|
||||
const scoped_refptr<RTCCertificateGeneratorCallback> callback_;
|
||||
scoped_refptr<RTCCertificate> certificate_;
|
||||
};
|
||||
|
@ -104,7 +104,7 @@ class RTCCertificateGenerationTask : public RefCountInterface,
|
|||
// static
|
||||
scoped_refptr<RTCCertificate> RTCCertificateGenerator::GenerateCertificate(
|
||||
const KeyParams& key_params,
|
||||
const Optional<uint64_t>& expires_ms) {
|
||||
const absl::optional<uint64_t>& expires_ms) {
|
||||
if (!key_params.IsValid())
|
||||
return nullptr;
|
||||
SSLIdentity* identity;
|
||||
|
@ -139,7 +139,7 @@ RTCCertificateGenerator::RTCCertificateGenerator(Thread* signaling_thread,
|
|||
|
||||
void RTCCertificateGenerator::GenerateCertificateAsync(
|
||||
const KeyParams& key_params,
|
||||
const Optional<uint64_t>& expires_ms,
|
||||
const absl::optional<uint64_t>& expires_ms,
|
||||
const scoped_refptr<RTCCertificateGeneratorCallback>& callback) {
|
||||
RTC_DCHECK(signaling_thread_->IsCurrent());
|
||||
RTC_DCHECK(callback);
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#ifndef RTC_BASE_RTCCERTIFICATEGENERATOR_H_
|
||||
#define RTC_BASE_RTCCERTIFICATEGENERATOR_H_
|
||||
|
||||
#include "api/optional.h"
|
||||
#include "absl/types/optional.h"
|
||||
#include "rtc_base/refcount.h"
|
||||
#include "rtc_base/rtccertificate.h"
|
||||
#include "rtc_base/scoped_ref_ptr.h"
|
||||
|
@ -43,7 +43,7 @@ class RTCCertificateGeneratorInterface {
|
|||
// its own restrictions on the expiration time.
|
||||
virtual void GenerateCertificateAsync(
|
||||
const KeyParams& key_params,
|
||||
const Optional<uint64_t>& expires_ms,
|
||||
const absl::optional<uint64_t>& expires_ms,
|
||||
const scoped_refptr<RTCCertificateGeneratorCallback>& callback) = 0;
|
||||
};
|
||||
|
||||
|
@ -60,7 +60,7 @@ class RTCCertificateGenerator : public RTCCertificateGeneratorInterface {
|
|||
// specified, a default expiration time is used.
|
||||
static scoped_refptr<RTCCertificate> GenerateCertificate(
|
||||
const KeyParams& key_params,
|
||||
const Optional<uint64_t>& expires_ms);
|
||||
const absl::optional<uint64_t>& expires_ms);
|
||||
|
||||
RTCCertificateGenerator(Thread* signaling_thread, Thread* worker_thread);
|
||||
~RTCCertificateGenerator() override {}
|
||||
|
@ -72,7 +72,7 @@ class RTCCertificateGenerator : public RTCCertificateGeneratorInterface {
|
|||
// specified, a default expiration time is used.
|
||||
void GenerateCertificateAsync(
|
||||
const KeyParams& key_params,
|
||||
const Optional<uint64_t>& expires_ms,
|
||||
const absl::optional<uint64_t>& expires_ms,
|
||||
const scoped_refptr<RTCCertificateGeneratorCallback>& callback) override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
#include <memory>
|
||||
|
||||
#include "api/optional.h"
|
||||
#include "absl/types/optional.h"
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/gunit.h"
|
||||
#include "rtc_base/logging.h"
|
||||
|
@ -79,19 +79,19 @@ class RTCCertificateGeneratorTest : public testing::Test {
|
|||
};
|
||||
|
||||
TEST_F(RTCCertificateGeneratorTest, GenerateECDSA) {
|
||||
EXPECT_TRUE(RTCCertificateGenerator::GenerateCertificate(
|
||||
KeyParams::ECDSA(), Optional<uint64_t>()));
|
||||
EXPECT_TRUE(RTCCertificateGenerator::GenerateCertificate(KeyParams::ECDSA(),
|
||||
absl::nullopt));
|
||||
}
|
||||
|
||||
TEST_F(RTCCertificateGeneratorTest, GenerateRSA) {
|
||||
EXPECT_TRUE(RTCCertificateGenerator::GenerateCertificate(
|
||||
KeyParams::RSA(), Optional<uint64_t>()));
|
||||
EXPECT_TRUE(RTCCertificateGenerator::GenerateCertificate(KeyParams::RSA(),
|
||||
absl::nullopt));
|
||||
}
|
||||
|
||||
TEST_F(RTCCertificateGeneratorTest, GenerateAsyncECDSA) {
|
||||
EXPECT_FALSE(fixture_->certificate());
|
||||
fixture_->generator()->GenerateCertificateAsync(
|
||||
KeyParams::ECDSA(), Optional<uint64_t>(), fixture_);
|
||||
fixture_->generator()->GenerateCertificateAsync(KeyParams::ECDSA(),
|
||||
absl::nullopt, fixture_);
|
||||
// Until generation has completed, the certificate is null. Since this is an
|
||||
// async call, generation must not have completed until we process messages
|
||||
// posted to this thread (which is done by |EXPECT_TRUE_WAIT|).
|
||||
|
@ -110,15 +110,14 @@ TEST_F(RTCCertificateGeneratorTest, GenerateWithExpires) {
|
|||
|
||||
// Generate a certificate that expires immediately.
|
||||
scoped_refptr<RTCCertificate> cert_a =
|
||||
RTCCertificateGenerator::GenerateCertificate(KeyParams::ECDSA(),
|
||||
Optional<uint64_t>(0));
|
||||
RTCCertificateGenerator::GenerateCertificate(KeyParams::ECDSA(), 0);
|
||||
EXPECT_TRUE(cert_a);
|
||||
|
||||
// Generate a certificate that expires in one minute.
|
||||
const uint64_t kExpiresMs = 60000;
|
||||
scoped_refptr<RTCCertificate> cert_b =
|
||||
RTCCertificateGenerator::GenerateCertificate(
|
||||
KeyParams::ECDSA(), Optional<uint64_t>(kExpiresMs));
|
||||
RTCCertificateGenerator::GenerateCertificate(KeyParams::ECDSA(),
|
||||
kExpiresMs);
|
||||
EXPECT_TRUE(cert_b);
|
||||
|
||||
// Verify that |cert_b| expires approximately |kExpiresMs| after |cert_a|
|
||||
|
@ -133,11 +132,11 @@ TEST_F(RTCCertificateGeneratorTest, GenerateWithInvalidParamsShouldFail) {
|
|||
KeyParams invalid_params = KeyParams::RSA(0, 0);
|
||||
EXPECT_FALSE(invalid_params.IsValid());
|
||||
|
||||
EXPECT_FALSE(RTCCertificateGenerator::GenerateCertificate(
|
||||
invalid_params, Optional<uint64_t>()));
|
||||
EXPECT_FALSE(RTCCertificateGenerator::GenerateCertificate(invalid_params,
|
||||
absl::nullopt));
|
||||
|
||||
fixture_->generator()->GenerateCertificateAsync(
|
||||
invalid_params, Optional<uint64_t>(), fixture_);
|
||||
fixture_->generator()->GenerateCertificateAsync(invalid_params, absl::nullopt,
|
||||
fixture_);
|
||||
EXPECT_TRUE_WAIT(fixture_->GenerateAsyncCompleted(), kGenerationTimeoutMs);
|
||||
EXPECT_FALSE(fixture_->certificate());
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#include "rtc_base/win32.h"
|
||||
#endif
|
||||
|
||||
#include "api/optional.h"
|
||||
#include "absl/types/optional.h"
|
||||
#include "rtc_base/constructormagic.h"
|
||||
#include "rtc_base/socketaddress.h"
|
||||
|
||||
|
@ -147,8 +147,8 @@ struct PacketInfo {
|
|||
|
||||
PacketType packet_type = PacketType::kUnknown;
|
||||
PacketInfoProtocolType protocol = PacketInfoProtocolType::kUnknown;
|
||||
// A unique id assigned by the network manager, and rtc::nullopt if not set.
|
||||
rtc::Optional<uint16_t> network_id;
|
||||
// A unique id assigned by the network manager, and absl::nullopt if not set.
|
||||
absl::optional<uint16_t> network_id;
|
||||
size_t packet_size_bytes = 0;
|
||||
size_t turn_overhead_bytes = 0;
|
||||
SocketAddress local_socket_address;
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
namespace rtc {
|
||||
namespace string_to_number_internal {
|
||||
|
||||
rtc::Optional<signed_type> ParseSigned(const char* str, int base) {
|
||||
absl::optional<signed_type> ParseSigned(const char* str, int base) {
|
||||
RTC_DCHECK(str);
|
||||
if (isdigit(str[0]) || str[0] == '-') {
|
||||
char* end = nullptr;
|
||||
|
@ -28,10 +28,10 @@ rtc::Optional<signed_type> ParseSigned(const char* str, int base) {
|
|||
return value;
|
||||
}
|
||||
}
|
||||
return rtc::nullopt;
|
||||
return absl::nullopt;
|
||||
}
|
||||
|
||||
rtc::Optional<unsigned_type> ParseUnsigned(const char* str, int base) {
|
||||
absl::optional<unsigned_type> ParseUnsigned(const char* str, int base) {
|
||||
RTC_DCHECK(str);
|
||||
if (isdigit(str[0]) || str[0] == '-') {
|
||||
// Explicitly discard negative values. std::strtoull parsing causes unsigned
|
||||
|
@ -45,7 +45,7 @@ rtc::Optional<unsigned_type> ParseUnsigned(const char* str, int base) {
|
|||
return value;
|
||||
}
|
||||
}
|
||||
return rtc::nullopt;
|
||||
return absl::nullopt;
|
||||
}
|
||||
|
||||
} // namespace string_to_number_internal
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include <limits>
|
||||
#include <string>
|
||||
|
||||
#include "api/optional.h"
|
||||
#include "absl/types/optional.h"
|
||||
|
||||
namespace rtc {
|
||||
|
||||
|
@ -25,8 +25,8 @@ namespace rtc {
|
|||
// are disabled in WebRTC.
|
||||
//
|
||||
// Integers are parsed using one of the following functions:
|
||||
// rtc::Optional<int-type> StringToNumber(const char* str, int base = 10);
|
||||
// rtc::Optional<int-type> StringToNumber(const std::string& str,
|
||||
// absl::optional<int-type> StringToNumber(const char* str, int base = 10);
|
||||
// absl::optional<int-type> StringToNumber(const std::string& str,
|
||||
// int base = 10);
|
||||
//
|
||||
// These functions parse a value from the beginning of a string into one of the
|
||||
|
@ -46,13 +46,13 @@ namespace string_to_number_internal {
|
|||
using unsigned_type = unsigned long long; // NOLINT(runtime/int)
|
||||
using signed_type = long long; // NOLINT(runtime/int)
|
||||
|
||||
rtc::Optional<signed_type> ParseSigned(const char* str, int base);
|
||||
rtc::Optional<unsigned_type> ParseUnsigned(const char* str, int base);
|
||||
absl::optional<signed_type> ParseSigned(const char* str, int base);
|
||||
absl::optional<unsigned_type> ParseUnsigned(const char* str, int base);
|
||||
} // namespace string_to_number_internal
|
||||
|
||||
template <typename T>
|
||||
typename std::enable_if<std::is_integral<T>::value && std::is_signed<T>::value,
|
||||
rtc::Optional<T>>::type
|
||||
absl::optional<T>>::type
|
||||
StringToNumber(const char* str, int base = 10) {
|
||||
using string_to_number_internal::signed_type;
|
||||
static_assert(
|
||||
|
@ -61,31 +61,31 @@ StringToNumber(const char* str, int base = 10) {
|
|||
std::numeric_limits<T>::lowest() >=
|
||||
std::numeric_limits<signed_type>::lowest(),
|
||||
"StringToNumber only supports signed integers as large as long long int");
|
||||
rtc::Optional<signed_type> value =
|
||||
absl::optional<signed_type> value =
|
||||
string_to_number_internal::ParseSigned(str, base);
|
||||
if (value && *value >= std::numeric_limits<T>::lowest() &&
|
||||
*value <= std::numeric_limits<T>::max()) {
|
||||
return static_cast<T>(*value);
|
||||
}
|
||||
return rtc::nullopt;
|
||||
return absl::nullopt;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
typename std::enable_if<std::is_integral<T>::value &&
|
||||
std::is_unsigned<T>::value,
|
||||
rtc::Optional<T>>::type
|
||||
absl::optional<T>>::type
|
||||
StringToNumber(const char* str, int base = 10) {
|
||||
using string_to_number_internal::unsigned_type;
|
||||
static_assert(std::numeric_limits<T>::max() <=
|
||||
std::numeric_limits<unsigned_type>::max(),
|
||||
"StringToNumber only supports unsigned integers as large as "
|
||||
"unsigned long long int");
|
||||
rtc::Optional<unsigned_type> value =
|
||||
absl::optional<unsigned_type> value =
|
||||
string_to_number_internal::ParseUnsigned(str, base);
|
||||
if (value && *value <= std::numeric_limits<T>::max()) {
|
||||
return static_cast<T>(*value);
|
||||
}
|
||||
return rtc::nullopt;
|
||||
return absl::nullopt;
|
||||
}
|
||||
|
||||
// The std::string overloads only exists if there is a matching const char*
|
||||
|
|
|
@ -68,10 +68,10 @@ TYPED_TEST_P(BasicNumberTest, TestInvalidNumbers) {
|
|||
(min_value == 0) ? "-2" : (std::to_string(min_value) + "1");
|
||||
// Make the large value approximately ten times larger than the maximum.
|
||||
const std::string too_large_string = std::to_string(max_value) + "1";
|
||||
EXPECT_EQ(rtc::nullopt, StringToNumber<T>(too_low_string));
|
||||
EXPECT_EQ(rtc::nullopt, StringToNumber<T>(too_low_string.c_str()));
|
||||
EXPECT_EQ(rtc::nullopt, StringToNumber<T>(too_large_string));
|
||||
EXPECT_EQ(rtc::nullopt, StringToNumber<T>(too_large_string.c_str()));
|
||||
EXPECT_EQ(absl::nullopt, StringToNumber<T>(too_low_string));
|
||||
EXPECT_EQ(absl::nullopt, StringToNumber<T>(too_low_string.c_str()));
|
||||
EXPECT_EQ(absl::nullopt, StringToNumber<T>(too_large_string));
|
||||
EXPECT_EQ(absl::nullopt, StringToNumber<T>(too_large_string.c_str()));
|
||||
}
|
||||
|
||||
TYPED_TEST_P(BasicNumberTest, TestInvalidInputs) {
|
||||
|
@ -79,18 +79,18 @@ TYPED_TEST_P(BasicNumberTest, TestInvalidInputs) {
|
|||
const char kInvalidCharArray[] = "Invalid string containing 47";
|
||||
const char kPlusMinusCharArray[] = "+-100";
|
||||
const char kNumberFollowedByCruft[] = "640x480";
|
||||
EXPECT_EQ(rtc::nullopt, StringToNumber<T>(kInvalidCharArray));
|
||||
EXPECT_EQ(rtc::nullopt, StringToNumber<T>(std::string(kInvalidCharArray)));
|
||||
EXPECT_EQ(rtc::nullopt, StringToNumber<T>(kPlusMinusCharArray));
|
||||
EXPECT_EQ(rtc::nullopt, StringToNumber<T>(std::string(kPlusMinusCharArray)));
|
||||
EXPECT_EQ(rtc::nullopt, StringToNumber<T>(kNumberFollowedByCruft));
|
||||
EXPECT_EQ(rtc::nullopt,
|
||||
EXPECT_EQ(absl::nullopt, StringToNumber<T>(kInvalidCharArray));
|
||||
EXPECT_EQ(absl::nullopt, StringToNumber<T>(std::string(kInvalidCharArray)));
|
||||
EXPECT_EQ(absl::nullopt, StringToNumber<T>(kPlusMinusCharArray));
|
||||
EXPECT_EQ(absl::nullopt, StringToNumber<T>(std::string(kPlusMinusCharArray)));
|
||||
EXPECT_EQ(absl::nullopt, StringToNumber<T>(kNumberFollowedByCruft));
|
||||
EXPECT_EQ(absl::nullopt,
|
||||
StringToNumber<T>(std::string(kNumberFollowedByCruft)));
|
||||
EXPECT_EQ(rtc::nullopt, StringToNumber<T>(" 5"));
|
||||
EXPECT_EQ(rtc::nullopt, StringToNumber<T>(" - 5"));
|
||||
EXPECT_EQ(rtc::nullopt, StringToNumber<T>("- 5"));
|
||||
EXPECT_EQ(rtc::nullopt, StringToNumber<T>(" -5"));
|
||||
EXPECT_EQ(rtc::nullopt, StringToNumber<T>("5 "));
|
||||
EXPECT_EQ(absl::nullopt, StringToNumber<T>(" 5"));
|
||||
EXPECT_EQ(absl::nullopt, StringToNumber<T>(" - 5"));
|
||||
EXPECT_EQ(absl::nullopt, StringToNumber<T>("- 5"));
|
||||
EXPECT_EQ(absl::nullopt, StringToNumber<T>(" -5"));
|
||||
EXPECT_EQ(absl::nullopt, StringToNumber<T>("5 "));
|
||||
}
|
||||
|
||||
REGISTER_TYPED_TEST_CASE_P(BasicNumberTest,
|
||||
|
@ -105,10 +105,10 @@ INSTANTIATE_TYPED_TEST_CASE_P(StringToNumberTest_Integers,
|
|||
IntegerTypes);
|
||||
|
||||
TEST(StringToNumberTest, TestSpecificValues) {
|
||||
EXPECT_EQ(rtc::nullopt, StringToNumber<uint8_t>("256"));
|
||||
EXPECT_EQ(rtc::nullopt, StringToNumber<uint8_t>("-256"));
|
||||
EXPECT_EQ(rtc::nullopt, StringToNumber<int8_t>("256"));
|
||||
EXPECT_EQ(rtc::nullopt, StringToNumber<int8_t>("-256"));
|
||||
EXPECT_EQ(absl::nullopt, StringToNumber<uint8_t>("256"));
|
||||
EXPECT_EQ(absl::nullopt, StringToNumber<uint8_t>("-256"));
|
||||
EXPECT_EQ(absl::nullopt, StringToNumber<int8_t>("256"));
|
||||
EXPECT_EQ(absl::nullopt, StringToNumber<int8_t>("-256"));
|
||||
}
|
||||
|
||||
} // namespace rtc
|
||||
|
|
Loading…
Reference in a new issue