clang-tidy: apply modernize-use-designated-initializer call/ p2p/ rtc_base/
split from https://webrtc-review.googlesource.com/c/src/+/404061 see there for full history and manual changes Bug: webrtc:424706384 Change-Id: Ic0af7ad0ca739c1ea1e869bc0aa696cc1eea7086 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/405041 Reviewed-by: Harald Alvestrand <hta@webrtc.org> Commit-Queue: Philipp Hancke <phancke@meta.com> Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Cr-Commit-Position: refs/heads/main@{#45397}
This commit is contained in:
parent
af0c2ac84b
commit
9bc8059df5
@ -326,7 +326,8 @@ std::pair<std::vector<scoped_refptr<Resource>>,
|
||||
ResourceAdaptationProcessor::FindMostLimitedResources() const {
|
||||
std::vector<scoped_refptr<Resource>> most_limited_resources;
|
||||
VideoStreamAdapter::RestrictionsWithCounters most_limited_restrictions{
|
||||
VideoSourceRestrictions(), VideoAdaptationCounters()};
|
||||
.restrictions = VideoSourceRestrictions(),
|
||||
.counters = VideoAdaptationCounters()};
|
||||
|
||||
for (const auto& resource_and_adaptation_limit_ :
|
||||
adaptation_limits_by_resources_) {
|
||||
@ -355,7 +356,7 @@ void ResourceAdaptationProcessor::UpdateResourceLimitations(
|
||||
adaptation_limits.counters == counters) {
|
||||
return;
|
||||
}
|
||||
adaptation_limits = {restrictions, counters};
|
||||
adaptation_limits = {.restrictions = restrictions, .counters = counters};
|
||||
|
||||
std::map<scoped_refptr<Resource>, VideoAdaptationCounters> limitations;
|
||||
for (const auto& p : adaptation_limits_by_resources_) {
|
||||
|
||||
@ -246,8 +246,8 @@ void VideoStreamAdapter::ClearRestrictions() {
|
||||
// Invalidate any previously returned Adaptation.
|
||||
RTC_LOG(LS_INFO) << "Resetting restrictions";
|
||||
++adaptation_validation_id_;
|
||||
current_restrictions_ = {VideoSourceRestrictions(),
|
||||
VideoAdaptationCounters()};
|
||||
current_restrictions_ = {.restrictions = VideoSourceRestrictions(),
|
||||
.counters = VideoAdaptationCounters()};
|
||||
awaiting_frame_size_change_ = std::nullopt;
|
||||
BroadcastVideoRestrictionsUpdate(input_state_provider_->InputState(),
|
||||
nullptr);
|
||||
@ -327,9 +327,10 @@ Adaptation VideoStreamAdapter::RestrictionsOrStateToAdaptation(
|
||||
VideoStreamAdapter::RestrictionsOrState step_or_state,
|
||||
const VideoStreamInputState& input_state) const {
|
||||
RTC_DCHECK(!step_or_state.valueless_by_exception());
|
||||
return std::visit(
|
||||
RestrictionsOrStateVisitor{adaptation_validation_id_, input_state},
|
||||
step_or_state);
|
||||
return std::visit(RestrictionsOrStateVisitor{.adaptation_validation_id =
|
||||
adaptation_validation_id_,
|
||||
.input_state = input_state},
|
||||
step_or_state);
|
||||
}
|
||||
|
||||
Adaptation VideoStreamAdapter::GetAdaptationUp(
|
||||
@ -676,7 +677,8 @@ void VideoStreamAdapter::ApplyAdaptation(const Adaptation& adaptation,
|
||||
} else {
|
||||
awaiting_frame_size_change_ = std::nullopt;
|
||||
}
|
||||
current_restrictions_ = {adaptation.restrictions(), adaptation.counters()};
|
||||
current_restrictions_ = {.restrictions = adaptation.restrictions(),
|
||||
.counters = adaptation.counters()};
|
||||
BroadcastVideoRestrictionsUpdate(adaptation.input_state(), resource);
|
||||
}
|
||||
|
||||
|
||||
@ -143,9 +143,9 @@ void DistributeBitrateRelatively(
|
||||
std::vector<PriorityRateObserverConfig> priority_rate_observers;
|
||||
for (const auto& observer_config : allocatable_tracks) {
|
||||
priority_rate_observers.push_back(PriorityRateObserverConfig{
|
||||
observer_config.observer,
|
||||
observers_capacities.at(observer_config.observer),
|
||||
observer_config.config.bitrate_priority});
|
||||
.allocation_key = observer_config.observer,
|
||||
.capacity_bps = observers_capacities.at(observer_config.observer),
|
||||
.bitrate_priority = observer_config.config.bitrate_priority});
|
||||
bitrate_priority_sum += observer_config.config.bitrate_priority;
|
||||
}
|
||||
|
||||
|
||||
@ -135,10 +135,14 @@ class BitrateAllocatorTest : public ::testing::Test {
|
||||
bool enforce_min_bitrate,
|
||||
double bitrate_priority,
|
||||
std::optional<TrackRateElasticity> rate_elasticity = std::nullopt) {
|
||||
allocator_->AddObserver(
|
||||
observer, {min_bitrate_bps, max_bitrate_bps, pad_up_bitrate_bps,
|
||||
/* priority_bitrate */ 0, enforce_min_bitrate,
|
||||
bitrate_priority, rate_elasticity});
|
||||
allocator_->AddObserver(observer,
|
||||
{.min_bitrate_bps = min_bitrate_bps,
|
||||
.max_bitrate_bps = max_bitrate_bps,
|
||||
.pad_up_bitrate_bps = pad_up_bitrate_bps,
|
||||
.priority_bitrate_bps = 0,
|
||||
.enforce_min_bitrate = enforce_min_bitrate,
|
||||
.bitrate_priority = bitrate_priority,
|
||||
.rate_elasticity = rate_elasticity});
|
||||
}
|
||||
MediaStreamAllocationConfig DefaultConfig() const {
|
||||
MediaStreamAllocationConfig default_config;
|
||||
@ -334,9 +338,13 @@ class BitrateAllocatorTestNoEnforceMin : public ::testing::Test {
|
||||
bool enforce_min_bitrate,
|
||||
absl::string_view /* track_id */,
|
||||
double bitrate_priority) {
|
||||
allocator_->AddObserver(
|
||||
observer, {min_bitrate_bps, max_bitrate_bps, pad_up_bitrate_bps, 0,
|
||||
enforce_min_bitrate, bitrate_priority});
|
||||
allocator_->AddObserver(observer,
|
||||
{.min_bitrate_bps = min_bitrate_bps,
|
||||
.max_bitrate_bps = max_bitrate_bps,
|
||||
.pad_up_bitrate_bps = pad_up_bitrate_bps,
|
||||
.priority_bitrate_bps = 0,
|
||||
.enforce_min_bitrate = enforce_min_bitrate,
|
||||
.bitrate_priority = bitrate_priority});
|
||||
}
|
||||
NiceMock<MockLimitObserver> limit_observer_;
|
||||
std::unique_ptr<BitrateAllocator> allocator_;
|
||||
|
||||
@ -138,18 +138,18 @@ PayloadTypePicker::PayloadTypePicker() {
|
||||
// Default audio codecs. Duplicates media/engine/payload_type_mapper.cc
|
||||
const MapTableEntry default_audio_mappings[] = {
|
||||
// Static payload type assignments according to RFC 3551.
|
||||
{{kPcmuCodecName, 8000, 1}, 0},
|
||||
{{"GSM", 8000, 1}, 3},
|
||||
{{"G723", 8000, 1}, 4},
|
||||
{{"DVI4", 8000, 1}, 5},
|
||||
{{"DVI4", 16000, 1}, 6},
|
||||
{{"LPC", 8000, 1}, 7},
|
||||
{{kPcmaCodecName, 8000, 1}, 8},
|
||||
{{kG722CodecName, 8000, 1}, 9},
|
||||
{{kL16CodecName, 44100, 2}, 10},
|
||||
{{kL16CodecName, 44100, 1}, 11},
|
||||
{{"QCELP", 8000, 1}, 12},
|
||||
{{kCnCodecName, 8000, 1}, 13},
|
||||
{.format = {kPcmuCodecName, 8000, 1}, .payload_type = 0},
|
||||
{.format = {"GSM", 8000, 1}, .payload_type = 3},
|
||||
{.format = {"G723", 8000, 1}, .payload_type = 4},
|
||||
{.format = {"DVI4", 8000, 1}, .payload_type = 5},
|
||||
{.format = {"DVI4", 16000, 1}, .payload_type = 6},
|
||||
{.format = {"LPC", 8000, 1}, .payload_type = 7},
|
||||
{.format = {kPcmaCodecName, 8000, 1}, .payload_type = 8},
|
||||
{.format = {kG722CodecName, 8000, 1}, .payload_type = 9},
|
||||
{.format = {kL16CodecName, 44100, 2}, .payload_type = 10},
|
||||
{.format = {kL16CodecName, 44100, 1}, .payload_type = 11},
|
||||
{.format = {"QCELP", 8000, 1}, .payload_type = 12},
|
||||
{.format = {kCnCodecName, 8000, 1}, .payload_type = 13},
|
||||
// RFC 4566 is a bit ambiguous on the contents of the "encoding
|
||||
// parameters" field, which, for audio, encodes the number of
|
||||
// channels. It is "optional and may be omitted if the number of
|
||||
@ -158,39 +158,39 @@ PayloadTypePicker::PayloadTypePicker() {
|
||||
// specify a value for this parameter for MPA, I've included both 0
|
||||
// and 1 here, to increase the chances it will be correctly used if
|
||||
// someone implements an MPEG audio encoder/decoder.
|
||||
{{"MPA", 90000, 0}, 14},
|
||||
{{"MPA", 90000, 1}, 14},
|
||||
{{"G728", 8000, 1}, 15},
|
||||
{{"DVI4", 11025, 1}, 16},
|
||||
{{"DVI4", 22050, 1}, 17},
|
||||
{{"G729", 8000, 1}, 18},
|
||||
{.format = {"MPA", 90000, 0}, .payload_type = 14},
|
||||
{.format = {"MPA", 90000, 1}, .payload_type = 14},
|
||||
{.format = {"G728", 8000, 1}, .payload_type = 15},
|
||||
{.format = {"DVI4", 11025, 1}, .payload_type = 16},
|
||||
{.format = {"DVI4", 22050, 1}, .payload_type = 17},
|
||||
{.format = {"G729", 8000, 1}, .payload_type = 18},
|
||||
|
||||
// Payload type assignments currently used by WebRTC.
|
||||
// Includes data to reduce collisions (and thus reassignments)
|
||||
// TODO(bugs.webrtc.org/400630582): Delete this, it's only for test
|
||||
// stability.
|
||||
{{"reserved-do-not-use", 1, 0}, 102},
|
||||
{{kCnCodecName, 16000, 1}, 105},
|
||||
{{kCnCodecName, 32000, 1}, 106},
|
||||
{{kOpusCodecName,
|
||||
48000,
|
||||
2,
|
||||
{{kCodecParamMinPTime, "10"},
|
||||
{kCodecParamUseInbandFec, kParamValueTrue}}},
|
||||
111},
|
||||
{.format = {"reserved-do-not-use", 1, 0}, .payload_type = 102},
|
||||
{.format = {kCnCodecName, 16000, 1}, .payload_type = 105},
|
||||
{.format = {kCnCodecName, 32000, 1}, .payload_type = 106},
|
||||
{.format = {kOpusCodecName,
|
||||
48000,
|
||||
2,
|
||||
{{kCodecParamMinPTime, "10"},
|
||||
{kCodecParamUseInbandFec, kParamValueTrue}}},
|
||||
.payload_type = 111},
|
||||
// RED for opus is assigned in the lower range, starting at the top.
|
||||
// Note that the FMTP refers to the opus payload type.
|
||||
{{kRedCodecName,
|
||||
48000,
|
||||
2,
|
||||
{{kCodecParamNotInNameValueFormat, "111/111"}}},
|
||||
63},
|
||||
{.format = {kRedCodecName,
|
||||
48000,
|
||||
2,
|
||||
{{kCodecParamNotInNameValueFormat, "111/111"}}},
|
||||
.payload_type = 63},
|
||||
// TODO(solenberg): Remove the hard coded 16k,32k,48k DTMF once we
|
||||
// assign payload types dynamically for send side as well.
|
||||
{{kDtmfCodecName, 48000, 1}, 110},
|
||||
{{kDtmfCodecName, 32000, 1}, 112},
|
||||
{{kDtmfCodecName, 16000, 1}, 113},
|
||||
{{kDtmfCodecName, 8000, 1}, 126}};
|
||||
{.format = {kDtmfCodecName, 48000, 1}, .payload_type = 110},
|
||||
{.format = {kDtmfCodecName, 32000, 1}, .payload_type = 112},
|
||||
{.format = {kDtmfCodecName, 16000, 1}, .payload_type = 113},
|
||||
{.format = {kDtmfCodecName, 8000, 1}, .payload_type = 126}};
|
||||
for (const MapTableEntry& entry : default_audio_mappings) {
|
||||
AddMapping(PayloadType(entry.payload_type), CreateAudioCodec(entry.format));
|
||||
}
|
||||
|
||||
@ -449,7 +449,7 @@ BasicIceController::HandleInitialSelectDampening(
|
||||
if (!field_trials_->initial_select_dampening.has_value() &&
|
||||
!field_trials_->initial_select_dampening_ping_received.has_value()) {
|
||||
// experiment not enabled => select connection.
|
||||
return {new_connection, std::nullopt};
|
||||
return {.connection = new_connection};
|
||||
}
|
||||
|
||||
int64_t now = TimeMillis();
|
||||
@ -470,7 +470,7 @@ BasicIceController::HandleInitialSelectDampening(
|
||||
<< initial_select_timestamp_ms_
|
||||
<< " selection delayed by: " << (now - start_wait) << "ms";
|
||||
initial_select_timestamp_ms_ = 0;
|
||||
return {new_connection, std::nullopt};
|
||||
return {.connection = new_connection};
|
||||
}
|
||||
|
||||
// We are not yet ready to select first connection...
|
||||
@ -493,8 +493,7 @@ BasicIceController::HandleInitialSelectDampening(
|
||||
}
|
||||
|
||||
RTC_LOG(LS_INFO) << "delay initial selection up to " << min_delay << "ms";
|
||||
return {.connection = std::nullopt,
|
||||
.recheck_event = IceRecheckEvent(
|
||||
return {.recheck_event = IceRecheckEvent(
|
||||
IceSwitchReason::ICE_CONTROLLER_RECHECK, min_delay)};
|
||||
}
|
||||
|
||||
@ -502,7 +501,7 @@ IceControllerInterface::SwitchResult BasicIceController::ShouldSwitchConnection(
|
||||
IceSwitchReason reason,
|
||||
const Connection* new_connection) {
|
||||
if (!ReadyToSend(new_connection) || selected_connection_ == new_connection) {
|
||||
return {std::nullopt, std::nullopt};
|
||||
return {};
|
||||
}
|
||||
|
||||
if (selected_connection_ == nullptr) {
|
||||
@ -515,7 +514,7 @@ IceControllerInterface::SwitchResult BasicIceController::ShouldSwitchConnection(
|
||||
int compare_a_b_by_networks = CompareCandidatePairNetworks(
|
||||
new_connection, selected_connection_, config_.network_preference);
|
||||
if (compare_a_b_by_networks == b_is_better && !new_connection->receiving()) {
|
||||
return {std::nullopt, std::nullopt};
|
||||
return {};
|
||||
}
|
||||
|
||||
bool missed_receiving_unchanged_threshold = false;
|
||||
@ -537,18 +536,18 @@ IceControllerInterface::SwitchResult BasicIceController::ShouldSwitchConnection(
|
||||
}
|
||||
|
||||
if (cmp < 0) {
|
||||
return {new_connection, std::nullopt};
|
||||
return {.connection = new_connection};
|
||||
} else if (cmp > 0) {
|
||||
return {std::nullopt, recheck_event};
|
||||
return {.recheck_event = recheck_event};
|
||||
}
|
||||
|
||||
// If everything else is the same, switch only if rtt has improved by
|
||||
// a margin.
|
||||
if (new_connection->rtt() <= selected_connection_->rtt() - kMinImprovement) {
|
||||
return {new_connection, std::nullopt};
|
||||
return {.connection = new_connection};
|
||||
}
|
||||
|
||||
return {std::nullopt, recheck_event};
|
||||
return {.recheck_event = recheck_event};
|
||||
}
|
||||
|
||||
IceControllerInterface::SwitchResult
|
||||
|
||||
@ -219,18 +219,21 @@ P2PTransportChannel::P2PTransportChannel(
|
||||
ParseFieldTrials(field_trials);
|
||||
|
||||
IceControllerFactoryArgs args{
|
||||
[this] { return GetState(); }, [this] { return GetIceRole(); },
|
||||
[this](const Connection* connection) {
|
||||
return IsPortPruned(connection->port()) ||
|
||||
IsRemoteCandidatePruned(connection->remote_candidate());
|
||||
},
|
||||
&ice_field_trials_,
|
||||
field_trials ? field_trials->Lookup("WebRTC-IceControllerFieldTrials")
|
||||
: ""};
|
||||
.ice_transport_state_func = [this] { return GetState(); },
|
||||
.ice_role_func = [this] { return GetIceRole(); },
|
||||
.is_connection_pruned_func =
|
||||
[this](const Connection* connection) {
|
||||
return IsPortPruned(connection->port()) ||
|
||||
IsRemoteCandidatePruned(connection->remote_candidate());
|
||||
},
|
||||
.ice_field_trials = &ice_field_trials_,
|
||||
.ice_controller_field_trials =
|
||||
field_trials ? field_trials->Lookup("WebRTC-IceControllerFieldTrials")
|
||||
: ""};
|
||||
|
||||
if (active_ice_controller_factory) {
|
||||
ActiveIceControllerFactoryArgs active_args{args,
|
||||
/* ice_agent= */ this};
|
||||
ActiveIceControllerFactoryArgs active_args{.legacy_args = args,
|
||||
.ice_agent = this};
|
||||
ice_controller_ = active_ice_controller_factory->Create(active_args);
|
||||
} else {
|
||||
ice_controller_ = std::make_unique<WrappingActiveIceController>(
|
||||
|
||||
@ -760,10 +760,10 @@ TEST_P(StunPortIPAddressTypeMetricsTest, TestIPAddressTypeMetrics) {
|
||||
}
|
||||
|
||||
const IPAddressTypeTestConfig kAllIPAddressTypeTestConfigs[] = {
|
||||
{"127.0.0.1", webrtc::IPAddressType::kLoopback},
|
||||
{"localhost", webrtc::IPAddressType::kLoopback},
|
||||
{"10.0.0.3", webrtc::IPAddressType::kPrivate},
|
||||
{"1.1.1.1", webrtc::IPAddressType::kPublic},
|
||||
{.address = "127.0.0.1", .address_type = webrtc::IPAddressType::kLoopback},
|
||||
{.address = "localhost", .address_type = webrtc::IPAddressType::kLoopback},
|
||||
{.address = "10.0.0.3", .address_type = webrtc::IPAddressType::kPrivate},
|
||||
{.address = "1.1.1.1", .address_type = webrtc::IPAddressType::kPublic},
|
||||
};
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(All,
|
||||
@ -1019,9 +1019,11 @@ TEST_P(StunIPv6PortIPAddressTypeMetricsTest, TestIPAddressTypeMetrics) {
|
||||
}
|
||||
|
||||
const IPAddressTypeTestConfig kAllIPv6AddressTypeTestConfigs[] = {
|
||||
{"::1", webrtc::IPAddressType::kLoopback},
|
||||
{"fd00:4860:4860::8844", webrtc::IPAddressType::kPrivate},
|
||||
{"2001:4860:4860::8888", webrtc::IPAddressType::kPublic},
|
||||
{.address = "::1", .address_type = webrtc::IPAddressType::kLoopback},
|
||||
{.address = "fd00:4860:4860::8844",
|
||||
.address_type = webrtc::IPAddressType::kPrivate},
|
||||
{.address = "2001:4860:4860::8888",
|
||||
.address_type = webrtc::IPAddressType::kPublic},
|
||||
};
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(All,
|
||||
|
||||
@ -2183,13 +2183,14 @@ static struct IPAddressTypeTestConfig {
|
||||
absl::string_view address;
|
||||
IPAddressType address_type;
|
||||
} kAllIPAddressTypeTestConfigs[] = {
|
||||
{"127.0.0.1", IPAddressType::kLoopback},
|
||||
{"localhost", IPAddressType::kLoopback},
|
||||
{"::1", IPAddressType::kLoopback},
|
||||
{"10.0.0.3", IPAddressType::kPrivate},
|
||||
{"fd00:4860:4860::8844", IPAddressType::kPrivate},
|
||||
{"1.1.1.1", IPAddressType::kPublic},
|
||||
{"2001:4860:4860::8888", IPAddressType::kPublic},
|
||||
{.address = "127.0.0.1", .address_type = IPAddressType::kLoopback},
|
||||
{.address = "localhost", .address_type = IPAddressType::kLoopback},
|
||||
{.address = "::1", .address_type = IPAddressType::kLoopback},
|
||||
{.address = "10.0.0.3", .address_type = IPAddressType::kPrivate},
|
||||
{.address = "fd00:4860:4860::8844",
|
||||
.address_type = IPAddressType::kPrivate},
|
||||
{.address = "1.1.1.1", .address_type = IPAddressType::kPublic},
|
||||
{.address = "2001:4860:4860::8888", .address_type = IPAddressType::kPublic},
|
||||
};
|
||||
|
||||
// Used by the test framework to print the param value for parameterized tests.
|
||||
|
||||
@ -128,10 +128,10 @@ TEST(WrappingActiveIceControllerTest, HandlesImmediateSwitchRequest) {
|
||||
std::vector<const Connection*> conns_to_forget{kConnectionTwo};
|
||||
int recheck_delay_ms = 10;
|
||||
IceControllerInterface::SwitchResult switch_result{
|
||||
kConnection,
|
||||
IceRecheckEvent(IceSwitchReason::ICE_CONTROLLER_RECHECK,
|
||||
recheck_delay_ms),
|
||||
conns_to_forget};
|
||||
.connection = kConnection,
|
||||
.recheck_event = IceRecheckEvent(IceSwitchReason::ICE_CONTROLLER_RECHECK,
|
||||
recheck_delay_ms),
|
||||
.connections_to_forget_state_on = conns_to_forget};
|
||||
|
||||
// ICE controller should switch to given connection immediately.
|
||||
Sequence check_then_switch;
|
||||
@ -174,10 +174,10 @@ TEST(WrappingActiveIceControllerTest, HandlesImmediateSortAndSwitchRequest) {
|
||||
std::vector<const Connection*> conns_to_prune{kConnectionThree};
|
||||
int recheck_delay_ms = 10;
|
||||
IceControllerInterface::SwitchResult switch_result{
|
||||
kConnection,
|
||||
IceRecheckEvent(IceSwitchReason::ICE_CONTROLLER_RECHECK,
|
||||
recheck_delay_ms),
|
||||
conns_to_forget};
|
||||
.connection = kConnection,
|
||||
.recheck_event = IceRecheckEvent(IceSwitchReason::ICE_CONTROLLER_RECHECK,
|
||||
recheck_delay_ms),
|
||||
.connections_to_forget_state_on = conns_to_forget};
|
||||
|
||||
Sequence sort_and_switch;
|
||||
EXPECT_CALL(agent, UpdateConnectionStates()).InSequence(sort_and_switch);
|
||||
@ -239,10 +239,10 @@ TEST(WrappingActiveIceControllerTest, HandlesSortAndSwitchRequest) {
|
||||
std::vector<const Connection*> conns_to_forget{kConnectionTwo};
|
||||
int recheck_delay_ms = 10;
|
||||
IceControllerInterface::SwitchResult switch_result{
|
||||
kConnection,
|
||||
IceRecheckEvent(IceSwitchReason::ICE_CONTROLLER_RECHECK,
|
||||
recheck_delay_ms),
|
||||
conns_to_forget};
|
||||
.connection = kConnection,
|
||||
.recheck_event = IceRecheckEvent(IceSwitchReason::ICE_CONTROLLER_RECHECK,
|
||||
recheck_delay_ms),
|
||||
.connections_to_forget_state_on = conns_to_forget};
|
||||
|
||||
// Sort and switch should take place as the subsequent task.
|
||||
Sequence sort_and_switch;
|
||||
|
||||
@ -731,8 +731,8 @@ static const struct {
|
||||
int version_bytes;
|
||||
const std::vector<HandshakeTestEvent>& events;
|
||||
} kEventsPerVersion[] = {
|
||||
{kDtls12VersionBytes, dtls_12_handshake_events},
|
||||
{kDtls13VersionBytes, dtls_13_handshake_events},
|
||||
{.version_bytes = kDtls12VersionBytes, .events = dtls_12_handshake_events},
|
||||
{.version_bytes = kDtls13VersionBytes, .events = dtls_13_handshake_events},
|
||||
};
|
||||
|
||||
struct EndpointConfig {
|
||||
|
||||
@ -128,7 +128,8 @@ void TurnServer::AddInternalServerSocket(
|
||||
|
||||
RTC_DCHECK(server_listen_sockets_.end() ==
|
||||
server_listen_sockets_.find(socket));
|
||||
server_listen_sockets_[socket] = {proto, std::move(ssl_adapter_factory)};
|
||||
server_listen_sockets_[socket] = {
|
||||
.proto = proto, .ssl_adapter_factory = std::move(ssl_adapter_factory)};
|
||||
socket->SignalReadEvent.connect(this, &TurnServer::OnNewInternalConnection);
|
||||
}
|
||||
|
||||
|
||||
@ -48,8 +48,7 @@ int ResolveHostname(absl::string_view hostname,
|
||||
std::vector<IPAddress>& addresses) {
|
||||
addresses.clear();
|
||||
struct addrinfo* result = nullptr;
|
||||
struct addrinfo hints = {0};
|
||||
hints.ai_family = family;
|
||||
struct addrinfo hints = {.ai_flags = AI_ADDRCONFIG, .ai_family = family};
|
||||
// `family` here will almost always be AF_UNSPEC, because `family` comes from
|
||||
// AsyncResolver::addr_.family(), which comes from a SocketAddress constructed
|
||||
// with a hostname. When a SocketAddress is constructed with a hostname, its
|
||||
@ -67,7 +66,6 @@ int ResolveHostname(absl::string_view hostname,
|
||||
// Android (source code, not documentation):
|
||||
// https://android.googlesource.com/platform/bionic/+/
|
||||
// 7e0bfb511e85834d7c6cb9631206b62f82701d60/libc/netbsd/net/getaddrinfo.c#1657
|
||||
hints.ai_flags = AI_ADDRCONFIG;
|
||||
int ret =
|
||||
getaddrinfo(std::string(hostname).c_str(), nullptr, &hints, &result);
|
||||
if (ret != 0) {
|
||||
|
||||
@ -66,11 +66,11 @@ struct Base64DecodeTestCase {
|
||||
};
|
||||
|
||||
const Base64DecodeTestCase kBase64DecodeTestCases[] = {
|
||||
{"InvalidCharacters", "invalid;;;", std::nullopt},
|
||||
{"InvalidLength", "abcde", std::nullopt},
|
||||
{"ValidInput", "abcd", "i\xB7\x1D"},
|
||||
{"ValidInputPadding", "abc=", "i\xB7"},
|
||||
{"EmptyInput", "", ""},
|
||||
{.name = "InvalidCharacters", .data = "invalid;;;", .result = std::nullopt},
|
||||
{.name = "InvalidLength", .data = "abcde", .result = std::nullopt},
|
||||
{.name = "ValidInput", .data = "abcd", .result = "i\xB7\x1D"},
|
||||
{.name = "ValidInputPadding", .data = "abc=", .result = "i\xB7"},
|
||||
{.name = "EmptyInput", .data = "", .result = ""},
|
||||
};
|
||||
|
||||
using Base64DecodeTest = TestWithParam<Base64DecodeTestCase>;
|
||||
@ -93,31 +93,35 @@ TEST_P(Base64DecodeTest, TestDecodeForgiving) {
|
||||
|
||||
const Base64DecodeTestCase kBase64DecodeForgivingTestCases[] = {
|
||||
{
|
||||
"ForgivingPadding",
|
||||
"abc",
|
||||
"i\xB7",
|
||||
.name = "ForgivingPadding",
|
||||
.data = "abc",
|
||||
.result = "i\xB7",
|
||||
},
|
||||
{
|
||||
"WhitespaceForgivenTab",
|
||||
"ab\tcd",
|
||||
"i\xB7\x1D",
|
||||
.name = "WhitespaceForgivenTab",
|
||||
.data = "ab\tcd",
|
||||
.result = "i\xB7\x1D",
|
||||
},
|
||||
{
|
||||
"WhitespaceForgivenSpace",
|
||||
"a bc d",
|
||||
"i\xB7\x1D",
|
||||
.name = "WhitespaceForgivenSpace",
|
||||
.data = "a bc d",
|
||||
.result = "i\xB7\x1D",
|
||||
},
|
||||
{
|
||||
"WhitespaceForgivenNewline",
|
||||
"a\nbc\nd",
|
||||
"i\xB7\x1D",
|
||||
.name = "WhitespaceForgivenNewline",
|
||||
.data = "a\nbc\nd",
|
||||
.result = "i\xB7\x1D",
|
||||
},
|
||||
{
|
||||
"WhitespaceForgivenCarriageReturn",
|
||||
"a\r\nbc\rd",
|
||||
"i\xB7\x1D",
|
||||
.name = "WhitespaceForgivenCarriageReturn",
|
||||
.data = "a\r\nbc\rd",
|
||||
.result = "i\xB7\x1D",
|
||||
},
|
||||
{
|
||||
.name = "WhitespaceForgivenLineFeed",
|
||||
.data = "a\fbcd",
|
||||
.result = "i\xB7\x1D",
|
||||
},
|
||||
{"WhitespaceForgivenLineFeed", "a\fbcd", "i\xB7\x1D"},
|
||||
};
|
||||
|
||||
using Base64DecodeForgivingTest = TestWithParam<Base64DecodeTestCase>;
|
||||
|
||||
@ -34,16 +34,18 @@ struct ValueWithUnit {
|
||||
|
||||
std::optional<ValueWithUnit> ParseValueWithUnit(absl::string_view str) {
|
||||
if (str == "inf") {
|
||||
return ValueWithUnit{std::numeric_limits<double>::infinity(), ""};
|
||||
return ValueWithUnit{.value = std::numeric_limits<double>::infinity(),
|
||||
.unit = ""};
|
||||
} else if (str == "-inf") {
|
||||
return ValueWithUnit{-std::numeric_limits<double>::infinity(), ""};
|
||||
return ValueWithUnit{.value = -std::numeric_limits<double>::infinity(),
|
||||
.unit = ""};
|
||||
} else {
|
||||
double double_val;
|
||||
char unit_char[RTC_TRIAL_UNIT_SIZE];
|
||||
unit_char[0] = 0;
|
||||
if (sscanf(std::string(str).c_str(), "%lf%" RTC_TRIAL_UNIT_LENGTH_STR "s",
|
||||
&double_val, unit_char) >= 1) {
|
||||
return ValueWithUnit{double_val, unit_char};
|
||||
return ValueWithUnit{.value = double_val, .unit = unit_char};
|
||||
}
|
||||
}
|
||||
return std::nullopt;
|
||||
|
||||
@ -58,8 +58,17 @@ TEST(QualityScalingExperimentTest, EnabledWithFieldTrial) {
|
||||
}
|
||||
|
||||
TEST(QualityScalingExperimentTest, ParseSettings) {
|
||||
const QualityScalingExperiment::Settings kExpected = {1, 2, 3, 4, 5, 6,
|
||||
7, 8, 0.9f, 0.99f, 1};
|
||||
const QualityScalingExperiment::Settings kExpected = {.vp8_low = 1,
|
||||
.vp8_high = 2,
|
||||
.vp9_low = 3,
|
||||
.vp9_high = 4,
|
||||
.h264_low = 5,
|
||||
.h264_high = 6,
|
||||
.generic_low = 7,
|
||||
.generic_high = 8,
|
||||
.alpha_high = 0.9f,
|
||||
.alpha_low = 0.99f,
|
||||
.drop = 1};
|
||||
FieldTrials field_trials(
|
||||
"WebRTC-Video-QualityScaling/Enabled-1,2,3,4,5,6,7,8,0.9,0.99,1/");
|
||||
const auto settings = QualityScalingExperiment::ParseSettings(field_trials);
|
||||
|
||||
@ -460,7 +460,8 @@ void Log(const LogArgType* fmt, ...) {
|
||||
const char* tag = nullptr;
|
||||
switch (*fmt) {
|
||||
case LogArgType::kLogMetadata: {
|
||||
meta = {va_arg(args, LogMetadata), ERRCTX_NONE, 0};
|
||||
meta = {
|
||||
.meta = va_arg(args, LogMetadata), .err_ctx = ERRCTX_NONE, .err = 0};
|
||||
break;
|
||||
}
|
||||
case LogArgType::kLogMetadataErr: {
|
||||
|
||||
@ -82,10 +82,10 @@ struct SrtpCipherMapEntry {
|
||||
|
||||
// This isn't elegant, but it's better than an external reference
|
||||
constexpr SrtpCipherMapEntry kSrtpCipherMap[] = {
|
||||
{"SRTP_AES128_CM_SHA1_80", kSrtpAes128CmSha1_80},
|
||||
{"SRTP_AES128_CM_SHA1_32", kSrtpAes128CmSha1_32},
|
||||
{"SRTP_AEAD_AES_128_GCM", kSrtpAeadAes128Gcm},
|
||||
{"SRTP_AEAD_AES_256_GCM", kSrtpAeadAes256Gcm}};
|
||||
{.internal_name = "SRTP_AES128_CM_SHA1_80", .id = kSrtpAes128CmSha1_80},
|
||||
{.internal_name = "SRTP_AES128_CM_SHA1_32", .id = kSrtpAes128CmSha1_32},
|
||||
{.internal_name = "SRTP_AEAD_AES_128_GCM", .id = kSrtpAeadAes128Gcm},
|
||||
{.internal_name = "SRTP_AEAD_AES_256_GCM", .id = kSrtpAeadAes256Gcm}};
|
||||
|
||||
#ifdef OPENSSL_IS_BORINGSSL
|
||||
// Enabled by EnableTimeCallbackForTesting. Should never be set in production
|
||||
@ -1271,16 +1271,17 @@ static const cipher_list OK_ECDSA_ciphers[] = {
|
||||
|
||||
static const cipher_list OK_DTLS13_ciphers[] = {
|
||||
#ifdef TLS1_3_CK_AES_128_GCM_SHA256 // BoringSSL TLS 1.3
|
||||
{static_cast<uint16_t>(TLS1_3_CK_AES_128_GCM_SHA256 & 0xffff),
|
||||
"TLS_AES_128_GCM_SHA256"},
|
||||
{.cipher = static_cast<uint16_t>(TLS1_3_CK_AES_128_GCM_SHA256 & 0xffff),
|
||||
.cipher_str = "TLS_AES_128_GCM_SHA256"},
|
||||
#endif
|
||||
#ifdef TLS1_3_CK_AES_256_GCM_SHA256 // BoringSSL TLS 1.3
|
||||
{static_cast<uint16_t>(TLS1_3_CK_AES_256_GCM_SHA256 & 0xffff),
|
||||
"TLS_AES_256_GCM_SHA256"},
|
||||
#endif
|
||||
#ifdef TLS1_3_CK_CHACHA20_POLY1305_SHA256 // BoringSSL TLS 1.3
|
||||
{static_cast<uint16_t>(TLS1_3_CK_CHACHA20_POLY1305_SHA256 & 0xffff),
|
||||
"TLS_CHACHA20_POLY1305_SHA256"},
|
||||
{.cipher =
|
||||
static_cast<uint16_t>(TLS1_3_CK_CHACHA20_POLY1305_SHA256 & 0xffff),
|
||||
.cipher_str = "TLS_CHACHA20_POLY1305_SHA256"},
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
@ -1631,7 +1631,7 @@ void PhysicalSocketServer::AddEpoll(Dispatcher* pdispatcher, uint64_t key) {
|
||||
return;
|
||||
}
|
||||
|
||||
struct epoll_event event = {0};
|
||||
struct epoll_event event = {};
|
||||
event.events = GetEpollEvents(pdispatcher->GetRequestedEvents());
|
||||
if (event.events == 0u) {
|
||||
// Don't add at all if we don't have any requested events. Could indicate a
|
||||
@ -1654,7 +1654,7 @@ void PhysicalSocketServer::RemoveEpoll(Dispatcher* pdispatcher) {
|
||||
return;
|
||||
}
|
||||
|
||||
struct epoll_event event = {0};
|
||||
struct epoll_event event = {};
|
||||
int err = epoll_ctl(epoll_fd_, EPOLL_CTL_DEL, fd, &event);
|
||||
RTC_DCHECK(err == 0 || errno == ENOENT);
|
||||
// Ignore ENOENT, which could occur if this descriptor wasn't added due to
|
||||
@ -1672,7 +1672,7 @@ void PhysicalSocketServer::UpdateEpoll(Dispatcher* pdispatcher, uint64_t key) {
|
||||
return;
|
||||
}
|
||||
|
||||
struct epoll_event event = {0};
|
||||
struct epoll_event event = {};
|
||||
event.events = GetEpollEvents(pdispatcher->GetRequestedEvents());
|
||||
event.data.u64 = key;
|
||||
// Remove if we don't have any requested events. Could indicate a closed
|
||||
|
||||
@ -514,58 +514,63 @@ class SSLIdentityExpirationTest : public ::testing::Test {
|
||||
int64_t want;
|
||||
} static const data[] = {
|
||||
// clang-format off
|
||||
// clang formatting breaks this nice alignment
|
||||
// clang formatting breaks this nice alignment
|
||||
|
||||
// Valid examples.
|
||||
{"19700101000000Z", true, 0},
|
||||
{"700101000000Z", false, 0},
|
||||
{"19700101000001Z", true, 1},
|
||||
{"700101000001Z", false, 1},
|
||||
{"19700101000100Z", true, 60},
|
||||
{"19700101000101Z", true, 61},
|
||||
{"19700101010000Z", true, 3600},
|
||||
{"19700101010001Z", true, 3601},
|
||||
{"19700101010100Z", true, 3660},
|
||||
{"19700101010101Z", true, 3661},
|
||||
{"710911012345Z", false, 53400225},
|
||||
{"20000101000000Z", true, 946684800},
|
||||
{"20000101000000Z", true, 946684800},
|
||||
{"20151130140156Z", true, 1448892116},
|
||||
{"151130140156Z", false, 1448892116},
|
||||
{"20491231235959Z", true, 2524607999},
|
||||
{"491231235959Z", false, 2524607999},
|
||||
{"20500101000000Z", true, 2524607999+1},
|
||||
{"20700101000000Z", true, 3155760000},
|
||||
{"21000101000000Z", true, 4102444800},
|
||||
{"24000101000000Z", true, 13569465600},
|
||||
{.string="19700101000000Z", .long_format=true, .want=0},
|
||||
{.string="700101000000Z", .long_format=false, .want=0},
|
||||
{.string="19700101000001Z", .long_format=true, .want=1},
|
||||
{.string="700101000001Z", .long_format=false, .want=1},
|
||||
{.string="19700101000100Z", .long_format=true, .want=60},
|
||||
{.string="19700101000101Z", .long_format=true, .want=61},
|
||||
{.string="19700101010000Z", .long_format=true, .want=3600},
|
||||
{.string="19700101010001Z", .long_format=true, .want=3601},
|
||||
{.string="19700101010100Z", .long_format=true, .want=3660},
|
||||
{.string="19700101010101Z", .long_format=true, .want=3661},
|
||||
{.string="710911012345Z", .long_format=false, .want=53400225},
|
||||
{.string="20000101000000Z", .long_format=true, .want=946684800},
|
||||
{.string="20000101000000Z", .long_format=true, .want=946684800},
|
||||
{.string="20151130140156Z", .long_format=true, .want=1448892116},
|
||||
{.string="151130140156Z", .long_format=false, .want=1448892116},
|
||||
{.string="20491231235959Z", .long_format=true, .want=2524607999},
|
||||
{.string="491231235959Z", .long_format=false, .want=2524607999},
|
||||
{.string="20500101000000Z", .long_format=true, .want=2524607999+1},
|
||||
{.string="20700101000000Z", .long_format=true, .want=3155760000},
|
||||
{.string="21000101000000Z", .long_format=true, .want=4102444800},
|
||||
{.string="24000101000000Z", .long_format=true, .want=13569465600},
|
||||
|
||||
// Invalid examples.
|
||||
{"19700101000000", true, -1}, // missing Z long format
|
||||
{"19700101000000X", true, -1}, // X instead of Z long format
|
||||
{"197001010000000", true, -1}, // 0 instead of Z long format
|
||||
{"1970010100000000Z", true, -1}, // excess digits long format
|
||||
{"700101000000", false, -1}, // missing Z short format
|
||||
{"700101000000X", false, -1}, // X instead of Z short format
|
||||
{"7001010000000", false, -1}, // 0 instead of Z short format
|
||||
{"70010100000000Z", false, -1}, // excess digits short format
|
||||
{":9700101000000Z", true, -1}, // invalid character
|
||||
{"1:700101000001Z", true, -1}, // invalid character
|
||||
{"19:00101000100Z", true, -1}, // invalid character
|
||||
{"197:0101000101Z", true, -1}, // invalid character
|
||||
{"1970:101010000Z", true, -1}, // invalid character
|
||||
{"19700:01010001Z", true, -1}, // invalid character
|
||||
{"197001:1010100Z", true, -1}, // invalid character
|
||||
{"1970010:010101Z", true, -1}, // invalid character
|
||||
{"70010100:000Z", false, -1}, // invalid character
|
||||
{"700101000:01Z", false, -1}, // invalid character
|
||||
{"2000010100:000Z", true, -1}, // invalid character
|
||||
{"21000101000:00Z", true, -1}, // invalid character
|
||||
{"240001010000:0Z", true, -1}, // invalid character
|
||||
{"500101000000Z", false, -1}, // but too old for epoch
|
||||
{"691231235959Z", false, -1}, // too old for epoch
|
||||
{"19611118043000Z", false, -1}, // way too old for epoch
|
||||
|
||||
// clang-format off
|
||||
// Long format: missing Z, X instead of Z, 0 instead of Z,
|
||||
// excess digits.
|
||||
{.string="19700101000000", .long_format=true, .want=-1},
|
||||
{.string="19700101000000X", .long_format=true, .want=-1},
|
||||
{.string="197001010000000", .long_format=true, .want=-1},
|
||||
{.string="1970010100000000Z", .long_format=true, .want=-1},
|
||||
// Short format: missing Z, X instead of Z, 0 instead of Z,
|
||||
// excess digits.
|
||||
{.string="700101000000", .long_format=false, .want=-1},
|
||||
{.string="700101000000X", .long_format=false, .want=-1},
|
||||
{.string="7001010000000", .long_format=false, .want=-1},
|
||||
{.string="70010100000000Z", .long_format=false, .want=-1},
|
||||
// Invalid character.
|
||||
{.string=":9700101000000Z", .long_format=true, .want=-1},
|
||||
{.string="1:700101000001Z", .long_format=true, .want=-1},
|
||||
{.string="19:00101000100Z", .long_format=true, .want=-1},
|
||||
{.string="197:0101000101Z", .long_format=true, .want=-1},
|
||||
{.string="1970:101010000Z", .long_format=true, .want=-1},
|
||||
{.string="19700:01010001Z", .long_format=true, .want=-1},
|
||||
{.string="197001:1010100Z", .long_format=true, .want=-1},
|
||||
{.string="1970010:010101Z", .long_format=true, .want=-1},
|
||||
{.string="70010100:000Z", .long_format=false, .want=-1},
|
||||
{.string="700101000:01Z", .long_format=false, .want=-1},
|
||||
{.string="2000010100:000Z", .long_format=true, .want=-1},
|
||||
{.string="21000101000:00Z", .long_format=true, .want=-1},
|
||||
{.string="240001010000:0Z", .long_format=true, .want=-1},
|
||||
// Dates prior to unix epoch (January 1st, 1970).
|
||||
{.string="500101000000Z", .long_format=false, .want=-1},
|
||||
{.string="691231235959Z", .long_format=false, .want=-1},
|
||||
{.string="19611118043000Z", .long_format=false, .want=-1},
|
||||
// clang-format off
|
||||
};
|
||||
|
||||
unsigned char buf[EVP_MAX_MD_SIZE];
|
||||
|
||||
@ -29,7 +29,7 @@ void YieldCurrentThread() {
|
||||
!RTC_USE_NATIVE_MUTEX_ON_MAC
|
||||
sched_yield();
|
||||
#else
|
||||
static const struct timespec ts_null = {0};
|
||||
static const struct timespec ts_null = {.tv_sec = 0, .tv_nsec = 0};
|
||||
nanosleep(&ts_null, nullptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user