From 7cca016721571fc77a90f8243fc8a8dc1b50fc04 Mon Sep 17 00:00:00 2001 From: Jakob Ivarsson Date: Wed, 1 Sep 2021 18:19:37 +0200 Subject: [PATCH] Hard code rtx handling option in NetEq. This allows NetEq to adapt to late reordered packets which are common when using retransmissions. Remaining cleanup of the plumbing from WebRTC API will be done in a follow-up cl. Bug: webrtc:10178 Change-Id: Ia9911eaafdabd3b69441dc089116d79e24f1b2b2 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/231002 Reviewed-by: Ivo Creusen Commit-Queue: Jakob Ivarsson Cr-Commit-Position: refs/heads/main@{#34898} --- modules/audio_coding/neteq/neteq_impl.cc | 12 +----------- modules/audio_coding/neteq/neteq_impl.h | 1 - modules/audio_coding/neteq/neteq_impl_unittest.cc | 6 ++---- 3 files changed, 3 insertions(+), 16 deletions(-) diff --git a/modules/audio_coding/neteq/neteq_impl.cc b/modules/audio_coding/neteq/neteq_impl.cc index fce857fb92..624d8d3a48 100644 --- a/modules/audio_coding/neteq/neteq_impl.cc +++ b/modules/audio_coding/neteq/neteq_impl.cc @@ -59,14 +59,12 @@ std::unique_ptr CreateNetEqController( const NetEqControllerFactory& controller_factory, int base_min_delay, int max_packets_in_buffer, - bool enable_rtx_handling, bool allow_time_stretching, TickTimer* tick_timer, webrtc::Clock* clock) { NetEqController::Config config; config.base_min_delay_ms = base_min_delay; config.max_packets_in_buffer = max_packets_in_buffer; - config.enable_rtx_handling = enable_rtx_handling; config.allow_time_stretching = allow_time_stretching; config.tick_timer = tick_timer; config.clock = clock; @@ -111,7 +109,6 @@ NetEqImpl::Dependencies::Dependencies( CreateNetEqController(controller_factory, config.min_delay_ms, config.max_packets_in_buffer, - config.enable_rtx_handling, !config.for_test_no_time_stretching, tick_timer.get(), clock)), @@ -158,7 +155,6 @@ NetEqImpl::NetEqImpl(const NetEq::Config& config, 10, // Report once every 10 s. tick_timer_.get()), no_time_stretching_(config.for_test_no_time_stretching), - enable_rtx_handling_(config.enable_rtx_handling), output_delay_chain_ms_( GetDelayChainLengthMs(config.extra_output_delay_ms)), output_delay_chain_(rtc::CheckedDivExact(output_delay_chain_ms_, 10)) { @@ -825,14 +821,8 @@ int NetEqImpl::InsertPacketInternal(const RTPHeader& rtp_header, info.main_sequence_number = main_sequence_number; info.is_dtx = is_dtx; info.buffer_flush = buffer_flush_occured; - // Only update statistics if incoming packet is not older than last played - // out packet or RTX handling is enabled, and if new codec flag is not - // set. - const bool should_update_stats = - (enable_rtx_handling_ || - static_cast(main_timestamp - timestamp_) >= 0) && - !new_codec_; + const bool should_update_stats = !new_codec_; auto relative_delay = controller_->PacketArrived(fs_hz_, should_update_stats, info); if (relative_delay) { diff --git a/modules/audio_coding/neteq/neteq_impl.h b/modules/audio_coding/neteq/neteq_impl.h index e3d84b3a1d..98bf0e23be 100644 --- a/modules/audio_coding/neteq/neteq_impl.h +++ b/modules/audio_coding/neteq/neteq_impl.h @@ -399,7 +399,6 @@ class NetEqImpl : public webrtc::NetEq { ExpandUmaLogger speech_expand_uma_logger_ RTC_GUARDED_BY(mutex_); bool no_time_stretching_ RTC_GUARDED_BY(mutex_); // Only used for test. rtc::BufferT concealment_audio_ RTC_GUARDED_BY(mutex_); - const bool enable_rtx_handling_ RTC_GUARDED_BY(mutex_); // Data members used for adding extra delay to the output of NetEq. // The delay in ms (which is 10 times the number of elements in // output_delay_chain_). diff --git a/modules/audio_coding/neteq/neteq_impl_unittest.cc b/modules/audio_coding/neteq/neteq_impl_unittest.cc index 154a48ec4c..7010adfa40 100644 --- a/modules/audio_coding/neteq/neteq_impl_unittest.cc +++ b/modules/audio_coding/neteq/neteq_impl_unittest.cc @@ -122,7 +122,6 @@ class NetEqImplTest : public ::testing::Test { NetEqController::Config controller_config; controller_config.tick_timer = tick_timer_; controller_config.base_min_delay_ms = config_.min_delay_ms; - controller_config.enable_rtx_handling = config_.enable_rtx_handling; controller_config.allow_time_stretching = true; controller_config.max_packets_in_buffer = config_.max_packets_in_buffer; controller_config.clock = &clock_; @@ -1603,12 +1602,11 @@ TEST_F(NetEqImplTest, InsertEmptyPacket) { neteq_->InsertEmptyPacket(rtp_header); } -TEST_F(NetEqImplTest, EnableRtxHandling) { +TEST_F(NetEqImplTest, NotifyControllerOfReorderedPacket) { using ::testing::AllOf; using ::testing::Field; UseNoMocks(); use_mock_neteq_controller_ = true; - config_.enable_rtx_handling = true; CreateInstance(); EXPECT_CALL(*mock_neteq_controller_, GetDecision(_, _)) .Times(1) @@ -1638,7 +1636,7 @@ TEST_F(NetEqImplTest, EnableRtxHandling) { *mock_neteq_controller_, PacketArrived( /*fs_hz*/ 8000, - /*should_update_stats*/ _, + /*should_update_stats*/ true, /*info*/ AllOf( Field(&NetEqController::PacketArrivedInfo::packet_length_samples,