Avoiding check on reordering configs in ANA if there is no controller has scoring point.

BUG=webrtc:7729

Review-Url: https://codereview.webrtc.org/2910193002
Cr-Commit-Position: refs/heads/master@{#18331}
This commit is contained in:
minyue
2017-05-30 08:56:08 -07:00
committed by Commit Bot
parent d4d2ecec18
commit 12de077b14
2 changed files with 38 additions and 8 deletions

View File

@ -253,13 +253,20 @@ std::unique_ptr<ControllerManager> ControllerManagerImpl::Create(
controllers.push_back(std::move(controller));
}
RTC_CHECK(controller_manager_config.has_min_reordering_time_ms());
RTC_CHECK(controller_manager_config.has_min_reordering_squared_distance());
return std::unique_ptr<ControllerManagerImpl>(new ControllerManagerImpl(
ControllerManagerImpl::Config(
controller_manager_config.min_reordering_time_ms(),
controller_manager_config.min_reordering_squared_distance()),
std::move(controllers), scoring_points));
if (scoring_points.size() == 0) {
return std::unique_ptr<ControllerManagerImpl>(new ControllerManagerImpl(
ControllerManagerImpl::Config(0, 0), std::move(controllers),
scoring_points));
} else {
RTC_CHECK(controller_manager_config.has_min_reordering_time_ms());
RTC_CHECK(controller_manager_config.has_min_reordering_squared_distance());
return std::unique_ptr<ControllerManagerImpl>(new ControllerManagerImpl(
ControllerManagerImpl::Config(
controller_manager_config.min_reordering_time_ms(),
controller_manager_config.min_reordering_squared_distance()),
std::move(controllers), scoring_points));
}
#else
RTC_NOTREACHED();
return nullptr;
@ -294,11 +301,13 @@ ControllerManagerImpl::~ControllerManagerImpl() = default;
std::vector<Controller*> ControllerManagerImpl::GetSortedControllers(
const Controller::NetworkMetrics& metrics) {
int64_t now_ms = rtc::TimeMillis();
if (controller_scoring_points_.size() == 0)
return default_sorted_controllers_;
if (!metrics.uplink_bandwidth_bps || !metrics.uplink_packet_loss_fraction)
return sorted_controllers_;
const int64_t now_ms = rtc::TimeMillis();
if (last_reordering_time_ms_ &&
now_ms - *last_reordering_time_ms_ < config_.min_reordering_time_ms)
return sorted_controllers_;

View File

@ -359,6 +359,27 @@ TEST(ControllerManagerTest, CreateFromConfigStringAndCheckDefaultOrder) {
ControllerType::FRAME_LENGTH, ControllerType::BIT_RATE});
}
TEST(ControllerManagerTest, CreateCharPointFreeConfigAndCheckDefaultOrder) {
audio_network_adaptor::config::ControllerManager config;
// Following controllers have no characteristic points.
AddChannelControllerConfig(&config);
AddDtxControllerConfig(&config);
AddBitrateControllerConfig(&config);
ProtoString config_string;
config.SerializeToString(&config_string);
auto states = CreateControllerManager(config_string);
Controller::NetworkMetrics metrics;
auto controllers = states.controller_manager->GetSortedControllers(metrics);
CheckControllersOrder(
controllers,
std::vector<ControllerType>{ControllerType::CHANNEL, ControllerType::DTX,
ControllerType::BIT_RATE});
}
TEST(ControllerManagerTest, CreateFromConfigStringAndCheckReordering) {
rtc::ScopedFakeClock fake_clock;
audio_network_adaptor::config::ControllerManager config;