diff options
Diffstat (limited to 'libtransport/src/protocols/rtc/rtc_forwarding_strategy.cc')
-rw-r--r-- | libtransport/src/protocols/rtc/rtc_forwarding_strategy.cc | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/libtransport/src/protocols/rtc/rtc_forwarding_strategy.cc b/libtransport/src/protocols/rtc/rtc_forwarding_strategy.cc index 9503eed3e..c6bc751e6 100644 --- a/libtransport/src/protocols/rtc/rtc_forwarding_strategy.cc +++ b/libtransport/src/protocols/rtc/rtc_forwarding_strategy.cc @@ -35,8 +35,9 @@ RTCForwardingStrategy::RTCForwardingStrategy() RTCForwardingStrategy::~RTCForwardingStrategy() {} -void RTCForwardingStrategy::setCallback(interface::StrategyCallback* callback) { - callback_ = callback; +void RTCForwardingStrategy::setCallback( + interface::StrategyCallback&& callback) { + callback_ = std::move(callback); } void RTCForwardingStrategy::initFwdStrategy( @@ -55,27 +56,24 @@ void RTCForwardingStrategy::initFwdStrategy( } void RTCForwardingStrategy::checkStrategy() { - if (*callback_) { - strategy_t used_strategy = selected_strategy_; - if (used_strategy == BOTH) used_strategy = current_strategy_; - assert(used_strategy == BEST_PATH || used_strategy == REPLICATION || - used_strategy == NONE); - - notification::ForwardingStrategy strategy = - notification::ForwardingStrategy::NONE; - switch (used_strategy) { - case BEST_PATH: - strategy = notification::ForwardingStrategy::BEST_PATH; - break; - case REPLICATION: - strategy = notification::ForwardingStrategy::REPLICATION; - break; - default: - break; - } - - (*callback_)(strategy); + strategy_t used_strategy = selected_strategy_; + if (used_strategy == BOTH) used_strategy = current_strategy_; + assert(used_strategy == BEST_PATH || used_strategy == REPLICATION || + used_strategy == NONE); + + notification::ForwardingStrategy strategy = + notification::ForwardingStrategy::NONE; + switch (used_strategy) { + case BEST_PATH: + strategy = notification::ForwardingStrategy::BEST_PATH; + break; + case REPLICATION: + strategy = notification::ForwardingStrategy::REPLICATION; + break; + default: + break; } + callback_(strategy); if (!init_) return; |