diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
commit | 40a355a42d4a9444dc753c04c6608dade2f06a23 (patch) | |
tree | 871fc667d2de662f171103ce5ec067014ef85e61 /third_party/libwebrtc/modules/audio_coding/neteq/decision_logic_unittest.cc | |
parent | Adding upstream version 124.0.1. (diff) | |
download | firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.tar.xz firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.zip |
Adding upstream version 125.0.1.upstream/125.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/libwebrtc/modules/audio_coding/neteq/decision_logic_unittest.cc')
-rw-r--r-- | third_party/libwebrtc/modules/audio_coding/neteq/decision_logic_unittest.cc | 62 |
1 files changed, 24 insertions, 38 deletions
diff --git a/third_party/libwebrtc/modules/audio_coding/neteq/decision_logic_unittest.cc b/third_party/libwebrtc/modules/audio_coding/neteq/decision_logic_unittest.cc index 97e20dd883..9e9902af50 100644 --- a/third_party/libwebrtc/modules/audio_coding/neteq/decision_logic_unittest.cc +++ b/third_party/libwebrtc/modules/audio_coding/neteq/decision_logic_unittest.cc @@ -18,6 +18,7 @@ #include "modules/audio_coding/neteq/delay_manager.h" #include "modules/audio_coding/neteq/mock/mock_buffer_level_filter.h" #include "modules/audio_coding/neteq/mock/mock_delay_manager.h" +#include "modules/audio_coding/neteq/mock/mock_packet_arrival_history.h" #include "test/field_trial.h" #include "test/gtest.h" @@ -47,6 +48,7 @@ NetEqController::NetEqStatus CreateNetEqStatus(NetEq::Mode last_mode, return status; } +using ::testing::_; using ::testing::Return; } // namespace @@ -54,8 +56,6 @@ using ::testing::Return; class DecisionLogicTest : public ::testing::Test { protected: DecisionLogicTest() { - test::ScopedFieldTrials trials( - "WebRTC-Audio-NetEqDecisionLogicConfig/cng_timeout_ms:1000/"); NetEqController::Config config; config.tick_timer = &tick_timer_; config.allow_time_stretching = true; @@ -64,8 +64,11 @@ class DecisionLogicTest : public ::testing::Test { mock_delay_manager_ = delay_manager.get(); auto buffer_level_filter = std::make_unique<MockBufferLevelFilter>(); mock_buffer_level_filter_ = buffer_level_filter.get(); + auto packet_arrival_history = std::make_unique<MockPacketArrivalHistory>(); + mock_packet_arrival_history_ = packet_arrival_history.get(); decision_logic_ = std::make_unique<DecisionLogic>( - config, std::move(delay_manager), std::move(buffer_level_filter)); + config, std::move(delay_manager), std::move(buffer_level_filter), + std::move(packet_arrival_history)); decision_logic_->SetSampleRate(kSampleRate, kOutputSizeSamples); } @@ -73,13 +76,16 @@ class DecisionLogicTest : public ::testing::Test { std::unique_ptr<DecisionLogic> decision_logic_; MockDelayManager* mock_delay_manager_; MockBufferLevelFilter* mock_buffer_level_filter_; + MockPacketArrivalHistory* mock_packet_arrival_history_; }; TEST_F(DecisionLogicTest, NormalOperation) { EXPECT_CALL(*mock_delay_manager_, TargetDelayMs()) .WillRepeatedly(Return(100)); - EXPECT_CALL(*mock_buffer_level_filter_, filtered_current_level()) - .WillRepeatedly(Return(90 * kSamplesPerMs)); + EXPECT_CALL(*mock_packet_arrival_history_, GetDelayMs(_, _)) + .WillRepeatedly(Return(100)); + EXPECT_CALL(*mock_packet_arrival_history_, GetMaxDelayMs()) + .WillRepeatedly(Return(0)); bool reset_decoder = false; tick_timer_.Increment(kMinTimescaleInterval + 1); @@ -92,8 +98,10 @@ TEST_F(DecisionLogicTest, NormalOperation) { TEST_F(DecisionLogicTest, Accelerate) { EXPECT_CALL(*mock_delay_manager_, TargetDelayMs()) .WillRepeatedly(Return(100)); - EXPECT_CALL(*mock_buffer_level_filter_, filtered_current_level()) - .WillRepeatedly(Return(110 * kSamplesPerMs)); + EXPECT_CALL(*mock_packet_arrival_history_, GetDelayMs(_, _)) + .WillRepeatedly(Return(150)); + EXPECT_CALL(*mock_packet_arrival_history_, GetMaxDelayMs()) + .WillRepeatedly(Return(0)); bool reset_decoder = false; tick_timer_.Increment(kMinTimescaleInterval + 1); @@ -106,8 +114,10 @@ TEST_F(DecisionLogicTest, Accelerate) { TEST_F(DecisionLogicTest, FastAccelerate) { EXPECT_CALL(*mock_delay_manager_, TargetDelayMs()) .WillRepeatedly(Return(100)); - EXPECT_CALL(*mock_buffer_level_filter_, filtered_current_level()) - .WillRepeatedly(Return(400 * kSamplesPerMs)); + EXPECT_CALL(*mock_packet_arrival_history_, GetDelayMs(_, _)) + .WillRepeatedly(Return(500)); + EXPECT_CALL(*mock_packet_arrival_history_, GetMaxDelayMs()) + .WillRepeatedly(Return(0)); bool reset_decoder = false; tick_timer_.Increment(kMinTimescaleInterval + 1); @@ -120,8 +130,10 @@ TEST_F(DecisionLogicTest, FastAccelerate) { TEST_F(DecisionLogicTest, PreemptiveExpand) { EXPECT_CALL(*mock_delay_manager_, TargetDelayMs()) .WillRepeatedly(Return(100)); - EXPECT_CALL(*mock_buffer_level_filter_, filtered_current_level()) - .WillRepeatedly(Return(50 * kSamplesPerMs)); + EXPECT_CALL(*mock_packet_arrival_history_, GetDelayMs(_, _)) + .WillRepeatedly(Return(50)); + EXPECT_CALL(*mock_packet_arrival_history_, GetMaxDelayMs()) + .WillRepeatedly(Return(0)); bool reset_decoder = false; tick_timer_.Increment(kMinTimescaleInterval + 1); @@ -131,20 +143,6 @@ TEST_F(DecisionLogicTest, PreemptiveExpand) { EXPECT_FALSE(reset_decoder); } -TEST_F(DecisionLogicTest, DecelerationTargetLevelOffset) { - EXPECT_CALL(*mock_delay_manager_, TargetDelayMs()) - .WillRepeatedly(Return(500)); - EXPECT_CALL(*mock_buffer_level_filter_, filtered_current_level()) - .WillRepeatedly(Return(400 * kSamplesPerMs)); - - bool reset_decoder = false; - tick_timer_.Increment(kMinTimescaleInterval + 1); - EXPECT_EQ(decision_logic_->GetDecision( - CreateNetEqStatus(NetEq::Mode::kNormal, 400), &reset_decoder), - NetEq::Operation::kPreemptiveExpand); - EXPECT_FALSE(reset_decoder); -} - TEST_F(DecisionLogicTest, PostponeDecodeAfterExpand) { EXPECT_CALL(*mock_delay_manager_, TargetDelayMs()) .WillRepeatedly(Return(500)); @@ -170,7 +168,7 @@ TEST_F(DecisionLogicTest, TimeStrechComfortNoise) { { bool reset_decoder = false; // Below target window. - auto status = CreateNetEqStatus(NetEq::Mode::kCodecInternalCng, 400); + auto status = CreateNetEqStatus(NetEq::Mode::kCodecInternalCng, 200); status.generated_noise_samples = 400 * kSamplesPerMs; status.next_packet->timestamp = status.target_timestamp + 400 * kSamplesPerMs; @@ -189,18 +187,6 @@ TEST_F(DecisionLogicTest, TimeStrechComfortNoise) { EXPECT_EQ(decision_logic_->GetDecision(status, &reset_decoder), NetEq::Operation::kNormal); EXPECT_FALSE(reset_decoder); - - // The buffer level filter should be adjusted with the number of samples - // that was skipped. - int timestamp_leap = status.next_packet->timestamp - - status.target_timestamp - - status.generated_noise_samples; - EXPECT_CALL(*mock_buffer_level_filter_, - Update(400 * kSamplesPerMs, timestamp_leap)); - EXPECT_EQ(decision_logic_->GetDecision( - CreateNetEqStatus(NetEq::Mode::kNormal, 400), &reset_decoder), - NetEq::Operation::kNormal); - EXPECT_FALSE(reset_decoder); } } |