Add IceControllerEvent::ICE_CONTROLLER_RECHECK
This patch adds a new enum value in IceControllerEvent::Type, that allows an IceController to request a recheck without any of the predefined event occuring. This patch is a NOP for BasicIceController. BUG=webrtc:10647 Change-Id: Idf1d0946480437109ff272946679fef559ca7beb Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/161047 Reviewed-by: Harald Alvestrand <hta@webrtc.org> Commit-Queue: Jonas Oreland <jonaso@webrtc.org> Cr-Commit-Position: refs/heads/master@{#29976}
This commit is contained in:
parent
464741276f
commit
b5aa0a85f3
@ -462,7 +462,9 @@ BasicIceController::HandleInitialSelectDampening(
|
||||
}
|
||||
|
||||
RTC_LOG(LS_INFO) << "delay initial selection up to " << min_delay << "ms";
|
||||
return {absl::nullopt, min_delay};
|
||||
reason.type = IceControllerEvent::ICE_CONTROLLER_RECHECK;
|
||||
reason.recheck_delay_ms = min_delay;
|
||||
return {absl::nullopt, reason};
|
||||
}
|
||||
|
||||
IceControllerInterface::SwitchResult BasicIceController::ShouldSwitchConnection(
|
||||
@ -492,20 +494,22 @@ IceControllerInterface::SwitchResult BasicIceController::ShouldSwitchConnection(
|
||||
receiving_unchanged_threshold,
|
||||
&missed_receiving_unchanged_threshold);
|
||||
|
||||
absl::optional<int> recheck_delay;
|
||||
absl::optional<IceControllerEvent> recheck_event;
|
||||
if (missed_receiving_unchanged_threshold &&
|
||||
config_.receiving_switching_delay_or_default()) {
|
||||
// If we do not switch to the connection because it missed the receiving
|
||||
// threshold, the new connection is in a better receiving state than the
|
||||
// currently selected connection. So we need to re-check whether it needs
|
||||
// to be switched at a later time.
|
||||
recheck_delay = config_.receiving_switching_delay_or_default();
|
||||
recheck_event = reason;
|
||||
recheck_event->recheck_delay_ms =
|
||||
config_.receiving_switching_delay_or_default();
|
||||
}
|
||||
|
||||
if (cmp < 0) {
|
||||
return {new_connection, absl::nullopt};
|
||||
} else if (cmp > 0) {
|
||||
return {absl::nullopt, recheck_delay};
|
||||
return {absl::nullopt, recheck_event};
|
||||
}
|
||||
|
||||
// If everything else is the same, switch only if rtt has improved by
|
||||
@ -514,7 +518,7 @@ IceControllerInterface::SwitchResult BasicIceController::ShouldSwitchConnection(
|
||||
return {new_connection, absl::nullopt};
|
||||
}
|
||||
|
||||
return {absl::nullopt, recheck_delay};
|
||||
return {absl::nullopt, recheck_event};
|
||||
}
|
||||
|
||||
IceControllerInterface::SwitchResult
|
||||
|
||||
@ -44,10 +44,12 @@ std::string IceControllerEvent::ToString() const {
|
||||
case SELECTED_CONNECTION_DESTROYED:
|
||||
reason = "selected candidate pair destroyed";
|
||||
break;
|
||||
case ICE_CONTROLLER_RECHECK:
|
||||
reason = "ice-controller-request-recheck";
|
||||
break;
|
||||
}
|
||||
if (dampening_delay) {
|
||||
reason += " (after switching dampening interval: " +
|
||||
std::to_string(dampening_delay) + ")";
|
||||
if (recheck_delay_ms) {
|
||||
reason += " (after delay: " + std::to_string(recheck_delay_ms) + ")";
|
||||
}
|
||||
return reason;
|
||||
}
|
||||
|
||||
@ -32,7 +32,11 @@ struct IceControllerEvent {
|
||||
NOMINATION_ON_CONTROLLED_SIDE,
|
||||
DATA_RECEIVED,
|
||||
CONNECT_STATE_CHANGE,
|
||||
SELECTED_CONNECTION_DESTROYED
|
||||
SELECTED_CONNECTION_DESTROYED,
|
||||
// The ICE_CONTROLLER_RECHECK enum value lets an IceController request
|
||||
// P2PTransportChannel to recheck a switch periodically without an event
|
||||
// taking place.
|
||||
ICE_CONTROLLER_RECHECK,
|
||||
};
|
||||
|
||||
IceControllerEvent(const Type& _type) // NOLINT: runtime/explicit
|
||||
@ -40,7 +44,7 @@ struct IceControllerEvent {
|
||||
std::string ToString() const;
|
||||
|
||||
Type type;
|
||||
int dampening_delay = 0;
|
||||
int recheck_delay_ms = 0;
|
||||
};
|
||||
|
||||
// Defines the interface for a module that control
|
||||
@ -65,8 +69,8 @@ class IceControllerInterface {
|
||||
// Connection that we should (optionally) switch to.
|
||||
absl::optional<const Connection*> connection;
|
||||
|
||||
// Delay in milliseconds when we should resort and try switching again.
|
||||
absl::optional<int> recheck_delay_ms;
|
||||
// An optional recheck event for when a Switch() should be attempted again.
|
||||
absl::optional<IceControllerEvent> recheck_event;
|
||||
};
|
||||
|
||||
virtual ~IceControllerInterface() = default;
|
||||
|
||||
@ -234,17 +234,16 @@ bool P2PTransportChannel::MaybeSwitchSelectedConnection(
|
||||
reason);
|
||||
}
|
||||
|
||||
if (result.recheck_delay_ms.has_value()) {
|
||||
if (result.recheck_event.has_value()) {
|
||||
// If we do not switch to the connection because it missed the receiving
|
||||
// threshold, the new connection is in a better receiving state than the
|
||||
// currently selected connection. So we need to re-check whether it needs
|
||||
// to be switched at a later time.
|
||||
reason.dampening_delay = *result.recheck_delay_ms;
|
||||
invoker_.AsyncInvokeDelayed<void>(
|
||||
RTC_FROM_HERE, thread(),
|
||||
rtc::Bind(&P2PTransportChannel::SortConnectionsAndUpdateState, this,
|
||||
reason),
|
||||
reason.dampening_delay);
|
||||
*result.recheck_event),
|
||||
result.recheck_event->recheck_delay_ms);
|
||||
}
|
||||
|
||||
return result.connection.has_value();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user