diff --git a/webrtc/modules/audio_coding/audio_network_adaptor/frame_length_controller.cc b/webrtc/modules/audio_coding/audio_network_adaptor/frame_length_controller.cc index 49b1d4deb3..4dd6088829 100644 --- a/webrtc/modules/audio_coding/audio_network_adaptor/frame_length_controller.cc +++ b/webrtc/modules/audio_coding/audio_network_adaptor/frame_length_controller.cc @@ -98,9 +98,7 @@ bool FrameLengthController::FrameLengthIncreasingDecision( // current overhead rate OR all the following: // 2. longer frame length is available AND // 3. |uplink_bandwidth_bps| is known to be smaller than a threshold AND - // 4. |uplink_packet_loss_fraction| is known to be smaller than a threshold - // AND - // 5. FEC is not decided or is OFF. + // 4. |uplink_packet_loss_fraction| is known to be smaller than a threshold. auto longer_frame_length_ms = std::next(frame_length_ms_); if (longer_frame_length_ms == config_.encoder_frame_lengths_ms.end()) @@ -123,8 +121,7 @@ bool FrameLengthController::FrameLengthIncreasingDecision( *uplink_bandwidth_bps_ <= increase_threshold->second) && (uplink_packet_loss_fraction_ && *uplink_packet_loss_fraction_ <= - config_.fl_increasing_packet_loss_fraction) && - !config.enable_fec.value_or(false); + config_.fl_increasing_packet_loss_fraction); } bool FrameLengthController::FrameLengthDecreasingDecision( @@ -137,7 +134,6 @@ bool FrameLengthController::FrameLengthDecreasingDecision( // one or more of the followings: // 3. |uplink_bandwidth_bps| is known to be larger than a threshold, // 4. |uplink_packet_loss_fraction| is known to be larger than a threshold, - // 5. FEC is decided ON. if (frame_length_ms_ == config_.encoder_frame_lengths_ms.begin()) return false; @@ -160,8 +156,7 @@ bool FrameLengthController::FrameLengthDecreasingDecision( *uplink_bandwidth_bps_ >= decrease_threshold->second) || (uplink_packet_loss_fraction_ && *uplink_packet_loss_fraction_ >= - config_.fl_decreasing_packet_loss_fraction) || - config.enable_fec.value_or(false); + config_.fl_decreasing_packet_loss_fraction); } } // namespace webrtc diff --git a/webrtc/modules/audio_coding/audio_network_adaptor/frame_length_controller_unittest.cc b/webrtc/modules/audio_coding/audio_network_adaptor/frame_length_controller_unittest.cc index beff4edefe..d2b535cd64 100644 --- a/webrtc/modules/audio_coding/audio_network_adaptor/frame_length_controller_unittest.cc +++ b/webrtc/modules/audio_coding/audio_network_adaptor/frame_length_controller_unittest.cc @@ -99,10 +99,8 @@ void UpdateNetworkMetrics( } void CheckDecision(FrameLengthController* controller, - const rtc::Optional& enable_fec, int expected_frame_length_ms) { AudioEncoderRuntimeConfig config; - config.enable_fec = enable_fec; controller->MakeDecision(&config); EXPECT_EQ(rtc::Optional(expected_frame_length_ms), config.frame_length_ms); @@ -116,7 +114,7 @@ TEST(FrameLengthControllerTest, DecreaseTo20MsOnHighUplinkBandwidth) { UpdateNetworkMetrics( controller.get(), rtc::Optional(kFl60msTo20msBandwidthBps), rtc::Optional(), rtc::Optional(kOverheadBytesPerPacket)); - CheckDecision(controller.get(), rtc::Optional(), 20); + CheckDecision(controller.get(), 20); } TEST(FrameLengthControllerTest, DecreaseTo20MsOnHighUplinkPacketLossFraction) { @@ -125,13 +123,7 @@ TEST(FrameLengthControllerTest, DecreaseTo20MsOnHighUplinkPacketLossFraction) { UpdateNetworkMetrics(controller.get(), rtc::Optional(), rtc::Optional(kFlDecreasingPacketLossFraction), rtc::Optional(kOverheadBytesPerPacket)); - CheckDecision(controller.get(), rtc::Optional(), 20); -} - -TEST(FrameLengthControllerTest, DecreaseTo20MsWhenFecIsOn) { - auto controller = - CreateController(CreateChangeCriteriaFor20msAnd60ms(), {20, 60}, 60); - CheckDecision(controller.get(), rtc::Optional(true), 20); + CheckDecision(controller.get(), 20); } TEST(FrameLengthControllerTest, @@ -140,7 +132,7 @@ TEST(FrameLengthControllerTest, CreateController(CreateChangeCriteriaFor20msAnd60ms(), {60}, 60); // Set FEC on that would cause frame length to decrease if receiver frame // length range included 20ms. - CheckDecision(controller.get(), rtc::Optional(true), 60); + CheckDecision(controller.get(), 60); } TEST(FrameLengthControllerTest, Maintain60MsOnMultipleConditions) { @@ -154,7 +146,7 @@ TEST(FrameLengthControllerTest, Maintain60MsOnMultipleConditions) { rtc::Optional(kMediumBandwidthBps), rtc::Optional(kMediumPacketLossFraction), rtc::Optional(kOverheadBytesPerPacket)); - CheckDecision(controller.get(), rtc::Optional(), 60); + CheckDecision(controller.get(), 60); } TEST(FrameLengthControllerTest, IncreaseTo60MsOnMultipleConditions) { @@ -169,31 +161,31 @@ TEST(FrameLengthControllerTest, IncreaseTo60MsOnMultipleConditions) { rtc::Optional(kFl20msTo60msBandwidthBps), rtc::Optional(kFlIncreasingPacketLossFraction), rtc::Optional(kOverheadBytesPerPacket)); - CheckDecision(controller.get(), rtc::Optional(), 60); + CheckDecision(controller.get(), 60); } TEST(FrameLengthControllerTest, IncreaseTo60MsOnVeryLowUplinkBandwidth) { auto controller = CreateController(CreateChangeCriteriaFor20msAnd60ms(), {20, 60}, 20); - // We set packet loss fraction to kFlDecreasingPacketLossFraction, and FEC on, - // both of which should have prevented frame length to increase, if the uplink - // bandwidth was not this low. + // We set packet loss fraction to kFlDecreasingPacketLossFraction, which + // should have prevented frame length to increase, if the uplink bandwidth + // was not this low. UpdateNetworkMetrics(controller.get(), rtc::Optional(VeryLowBitrate(20)), rtc::Optional(kFlIncreasingPacketLossFraction), rtc::Optional(kOverheadBytesPerPacket)); - CheckDecision(controller.get(), rtc::Optional(true), 60); + CheckDecision(controller.get(), 60); } TEST(FrameLengthControllerTest, Maintain60MsOnVeryLowUplinkBandwidth) { auto controller = CreateController(CreateChangeCriteriaFor20msAnd60ms(), {20, 60}, 60); - // We set packet loss fraction to FlDecreasingPacketLossFraction, and FEC on, - // both of which should have caused the frame length to decrease, if the - // uplink bandwidth was not this low. + // We set packet loss fraction to FlDecreasingPacketLossFraction, which should + // have caused the frame length to decrease, if the uplink bandwidth was not + // this low. UpdateNetworkMetrics(controller.get(), rtc::Optional(VeryLowBitrate(20)), rtc::Optional(kFlIncreasingPacketLossFraction), rtc::Optional(kOverheadBytesPerPacket)); - CheckDecision(controller.get(), rtc::Optional(true), 60); + CheckDecision(controller.get(), 60); } TEST(FrameLengthControllerTest, UpdateMultipleNetworkMetricsAtOnce) { @@ -212,7 +204,7 @@ TEST(FrameLengthControllerTest, UpdateMultipleNetworkMetricsAtOnce) { network_metrics.uplink_packet_loss_fraction = rtc::Optional(kFlIncreasingPacketLossFraction); controller->UpdateNetworkMetrics(network_metrics); - CheckDecision(controller.get(), rtc::Optional(), 60); + CheckDecision(controller.get(), 60); } TEST(FrameLengthControllerTest, @@ -225,7 +217,7 @@ TEST(FrameLengthControllerTest, rtc::Optional(kFl20msTo60msBandwidthBps), rtc::Optional(kFlIncreasingPacketLossFraction), rtc::Optional(kOverheadBytesPerPacket)); - CheckDecision(controller.get(), rtc::Optional(), 20); + CheckDecision(controller.get(), 20); } TEST(FrameLengthControllerTest, Maintain20MsOnMediumUplinkBandwidth) { @@ -235,7 +227,7 @@ TEST(FrameLengthControllerTest, Maintain20MsOnMediumUplinkBandwidth) { rtc::Optional(kMediumBandwidthBps), rtc::Optional(kFlIncreasingPacketLossFraction), rtc::Optional(kOverheadBytesPerPacket)); - CheckDecision(controller.get(), rtc::Optional(), 20); + CheckDecision(controller.get(), 20); } TEST(FrameLengthControllerTest, Maintain20MsOnMediumUplinkPacketLossFraction) { @@ -247,19 +239,7 @@ TEST(FrameLengthControllerTest, Maintain20MsOnMediumUplinkPacketLossFraction) { rtc::Optional(kFl20msTo60msBandwidthBps), rtc::Optional(kMediumPacketLossFraction), rtc::Optional(kOverheadBytesPerPacket)); - CheckDecision(controller.get(), rtc::Optional(), 20); -} - -TEST(FrameLengthControllerTest, Maintain20MsWhenFecIsOn) { - auto controller = - CreateController(CreateChangeCriteriaFor20msAnd60ms(), {20, 60}, 20); - // Use a low uplink bandwidth and a low uplink packet loss fraction that would - // cause frame length to increase if FEC was not ON. - UpdateNetworkMetrics(controller.get(), - rtc::Optional(kFl20msTo60msBandwidthBps), - rtc::Optional(kMediumPacketLossFraction), - rtc::Optional(kOverheadBytesPerPacket)); - CheckDecision(controller.get(), rtc::Optional(true), 20); + CheckDecision(controller.get(), 20); } TEST(FrameLengthControllerTest, Maintain60MsWhenNo120msCriteriaIsSet) { @@ -269,7 +249,7 @@ TEST(FrameLengthControllerTest, Maintain60MsWhenNo120msCriteriaIsSet) { rtc::Optional(kFl60msTo120msBandwidthBps), rtc::Optional(kFlIncreasingPacketLossFraction), rtc::Optional(kOverheadBytesPerPacket)); - CheckDecision(controller.get(), rtc::Optional(), 60); + CheckDecision(controller.get(), 60); } TEST(FrameLengthControllerTest, From120MsTo20MsOnHighUplinkBandwidth) { @@ -279,12 +259,12 @@ TEST(FrameLengthControllerTest, From120MsTo20MsOnHighUplinkBandwidth) { UpdateNetworkMetrics( controller.get(), rtc::Optional(kFl60msTo20msBandwidthBps), rtc::Optional(), rtc::Optional(kOverheadBytesPerPacket)); - CheckDecision(controller.get(), rtc::Optional(), 60); + CheckDecision(controller.get(), 60); UpdateNetworkMetrics( controller.get(), rtc::Optional(kFl60msTo20msBandwidthBps), rtc::Optional(), rtc::Optional(kOverheadBytesPerPacket)); - CheckDecision(controller.get(), rtc::Optional(), 20); + CheckDecision(controller.get(), 20); } TEST(FrameLengthControllerTest, From120MsTo20MsOnHighUplinkPacketLossFraction) { @@ -294,52 +274,42 @@ TEST(FrameLengthControllerTest, From120MsTo20MsOnHighUplinkPacketLossFraction) { UpdateNetworkMetrics(controller.get(), rtc::Optional(), rtc::Optional(kFlDecreasingPacketLossFraction), rtc::Optional(kOverheadBytesPerPacket)); - CheckDecision(controller.get(), rtc::Optional(), 60); + CheckDecision(controller.get(), 60); UpdateNetworkMetrics(controller.get(), rtc::Optional(), rtc::Optional(kFlDecreasingPacketLossFraction), rtc::Optional(kOverheadBytesPerPacket)); - CheckDecision(controller.get(), rtc::Optional(), 20); -} - -TEST(FrameLengthControllerTest, From120MsTo20MsWhenFecIsOn) { - auto controller = CreateController(CreateChangeCriteriaFor20ms60msAnd120ms(), - {20, 60, 120}, 120); - // It takes two steps for frame length to go from 120ms to 20ms. - CheckDecision(controller.get(), rtc::Optional(true), 60); - CheckDecision(controller.get(), rtc::Optional(true), 20); + CheckDecision(controller.get(), 20); } TEST(FrameLengthControllerTest, Maintain120MsOnVeryLowUplinkBandwidth) { auto controller = CreateController(CreateChangeCriteriaFor20ms60msAnd120ms(), {20, 60, 120}, 120); - // We set packet loss fraction to FlDecreasingPacketLossFraction, and FEC on, - // both of which should have caused the frame length to decrease, if the - // uplink bandwidth was not this low. + // We set packet loss fraction to FlDecreasingPacketLossFraction, which should + // have caused the frame length to decrease, if the uplink bandwidth was not + // this low. UpdateNetworkMetrics(controller.get(), rtc::Optional(VeryLowBitrate(60)), rtc::Optional(kFlDecreasingPacketLossFraction), rtc::Optional(kOverheadBytesPerPacket)); - CheckDecision(controller.get(), rtc::Optional(true), 120); + CheckDecision(controller.get(), 120); } TEST(FrameLengthControllerTest, From60MsTo120MsOnVeryLowUplinkBandwidth) { auto controller = CreateController(CreateChangeCriteriaFor20ms60msAnd120ms(), {20, 60, 120}, 60); - // We set packet loss fraction to FlDecreasingPacketLossFraction, and FEC on, - // both of which should have prevented frame length to increase, if the uplink - // bandwidth was not this low. + // We set packet loss fraction to FlDecreasingPacketLossFraction, which should + // have prevented frame length to increase, if the uplink bandwidth was not + // this low. UpdateNetworkMetrics(controller.get(), rtc::Optional(VeryLowBitrate(60)), rtc::Optional(kFlDecreasingPacketLossFraction), rtc::Optional(kOverheadBytesPerPacket)); - CheckDecision(controller.get(), rtc::Optional(true), 120); + CheckDecision(controller.get(), 120); } TEST(FrameLengthControllerTest, From20MsTo120MsOnMultipleConditions) { // Increase to 120ms frame length if // 1. |uplink_bandwidth_bps| is known to be smaller than a threshold AND - // 2. |uplink_packet_loss_fraction| is known to be smaller than a threshold - // AND - // 3. FEC is not decided or OFF. + // 2. |uplink_packet_loss_fraction| is known to be smaller than a threshold. auto controller = CreateController(CreateChangeCriteriaFor20ms60msAnd120ms(), {20, 60, 120}, 20); // It takes two steps for frame length to go from 20ms to 120ms. @@ -347,12 +317,12 @@ TEST(FrameLengthControllerTest, From20MsTo120MsOnMultipleConditions) { rtc::Optional(kFl60msTo120msBandwidthBps), rtc::Optional(kFlIncreasingPacketLossFraction), rtc::Optional(kOverheadBytesPerPacket)); - CheckDecision(controller.get(), rtc::Optional(), 60); + CheckDecision(controller.get(), 60); UpdateNetworkMetrics(controller.get(), rtc::Optional(kFl60msTo120msBandwidthBps), rtc::Optional(kFlIncreasingPacketLossFraction), rtc::Optional(kOverheadBytesPerPacket)); - CheckDecision(controller.get(), rtc::Optional(), 120); + CheckDecision(controller.get(), 120); } TEST(FrameLengthControllerTest, Stall60MsIf120MsNotInReceiverFrameLengthRange) { @@ -362,12 +332,12 @@ TEST(FrameLengthControllerTest, Stall60MsIf120MsNotInReceiverFrameLengthRange) { rtc::Optional(kFl60msTo120msBandwidthBps), rtc::Optional(kFlIncreasingPacketLossFraction), rtc::Optional(kOverheadBytesPerPacket)); - CheckDecision(controller.get(), rtc::Optional(), 60); + CheckDecision(controller.get(), 60); UpdateNetworkMetrics(controller.get(), rtc::Optional(kFl60msTo120msBandwidthBps), rtc::Optional(kFlIncreasingPacketLossFraction), rtc::Optional(kOverheadBytesPerPacket)); - CheckDecision(controller.get(), rtc::Optional(), 60); + CheckDecision(controller.get(), 60); } TEST(FrameLengthControllerTest, CheckBehaviorOnChangingNetworkMetrics) { @@ -377,37 +347,37 @@ TEST(FrameLengthControllerTest, CheckBehaviorOnChangingNetworkMetrics) { rtc::Optional(kMediumBandwidthBps), rtc::Optional(kFlIncreasingPacketLossFraction), rtc::Optional(kOverheadBytesPerPacket)); - CheckDecision(controller.get(), rtc::Optional(), 20); + CheckDecision(controller.get(), 20); UpdateNetworkMetrics(controller.get(), rtc::Optional(kFl20msTo60msBandwidthBps), rtc::Optional(kFlIncreasingPacketLossFraction), rtc::Optional(kOverheadBytesPerPacket)); - CheckDecision(controller.get(), rtc::Optional(), 60); + CheckDecision(controller.get(), 60); UpdateNetworkMetrics(controller.get(), rtc::Optional(kFl60msTo120msBandwidthBps), rtc::Optional(kMediumPacketLossFraction), rtc::Optional(kOverheadBytesPerPacket)); - CheckDecision(controller.get(), rtc::Optional(), 60); + CheckDecision(controller.get(), 60); UpdateNetworkMetrics(controller.get(), rtc::Optional(kFl60msTo120msBandwidthBps), rtc::Optional(kFlIncreasingPacketLossFraction), rtc::Optional(kOverheadBytesPerPacket)); - CheckDecision(controller.get(), rtc::Optional(), 120); + CheckDecision(controller.get(), 120); UpdateNetworkMetrics(controller.get(), rtc::Optional(kFl120msTo60msBandwidthBps), rtc::Optional(kFlIncreasingPacketLossFraction), rtc::Optional(kOverheadBytesPerPacket)); - CheckDecision(controller.get(), rtc::Optional(), 60); + CheckDecision(controller.get(), 60); UpdateNetworkMetrics(controller.get(), rtc::Optional(kMediumBandwidthBps), rtc::Optional(kFlDecreasingPacketLossFraction), rtc::Optional(kOverheadBytesPerPacket)); - CheckDecision(controller.get(), rtc::Optional(), 20); + CheckDecision(controller.get(), 20); } } // namespace webrtc