From fcfc6a990e639788bbe607e07ce72da689403525 Mon Sep 17 00:00:00 2001 From: "henrik.lundin@webrtc.org" Date: Thu, 13 Feb 2014 11:42:28 +0000 Subject: [PATCH] Small refactoring of NetEq unittest for CNG with clock drift Converting the test to a method within the test fixture, and setting up two tests that call this method. One for positive and one for negative clock drift. The one with positive clock drift is disabled for now since it does not pass, but will be re-enabled shortly. This change is only made for NetEq4. R=tlegrand@google.com Review URL: https://webrtc-codereview.appspot.com/8599004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@5541 4adac7df-926f-26a2-2b94-8c16560cd09d --- .../audio_coding/neteq4/neteq_unittest.cc | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/webrtc/modules/audio_coding/neteq4/neteq_unittest.cc b/webrtc/modules/audio_coding/neteq4/neteq_unittest.cc index 40d52f5f2c..47e9e855e2 100644 --- a/webrtc/modules/audio_coding/neteq4/neteq_unittest.cc +++ b/webrtc/modules/audio_coding/neteq4/neteq_unittest.cc @@ -219,6 +219,8 @@ class NetEqDecodingTest : public ::testing::Test { const std::set& drop_seq_numbers, bool expect_seq_no_wrap, bool expect_timestamp_wrap); + void LongCngWithClockDrift(double drift_factor); + NetEq* neteq_; FILE* rtp_fp_; unsigned int sim_clock_; @@ -695,14 +697,12 @@ TEST_F(NetEqDecodingTest, EXPECT_EQ(110946, network_stats.clockdrift_ppm); } -TEST_F(NetEqDecodingTest, DISABLED_ON_ANDROID(LongCngWithClockDrift)) { +void NetEqDecodingTest::LongCngWithClockDrift(double drift_factor) { uint16_t seq_no = 0; uint32_t timestamp = 0; const int kFrameSizeMs = 30; const int kSamples = kFrameSizeMs * 16; const int kPayloadBytes = kSamples * 2; - // Apply a clock drift of -25 ms / s (sender faster than receiver). - const double kDriftFactor = 1000.0 / (1000.0 + 25.0); double next_input_time_ms = 0.0; double t_ms; NetEqOutputType type; @@ -719,7 +719,7 @@ TEST_F(NetEqDecodingTest, DISABLED_ON_ANDROID(LongCngWithClockDrift)) { ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, kPayloadBytes, 0)); ++seq_no; timestamp += kSamples; - next_input_time_ms += static_cast(kFrameSizeMs) * kDriftFactor; + next_input_time_ms += static_cast(kFrameSizeMs) * drift_factor; } // Pull out data once. int out_len; @@ -747,7 +747,7 @@ TEST_F(NetEqDecodingTest, DISABLED_ON_ANDROID(LongCngWithClockDrift)) { ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, payload_len, 0)); ++seq_no; timestamp += kCngPeriodSamples; - next_input_time_ms += static_cast(kCngPeriodMs) * kDriftFactor; + next_input_time_ms += static_cast(kCngPeriodMs) * drift_factor; } // Pull out data once. int out_len; @@ -770,7 +770,7 @@ TEST_F(NetEqDecodingTest, DISABLED_ON_ANDROID(LongCngWithClockDrift)) { ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, kPayloadBytes, 0)); ++seq_no; timestamp += kSamples; - next_input_time_ms += static_cast(kFrameSizeMs) * kDriftFactor; + next_input_time_ms += static_cast(kFrameSizeMs) * drift_factor; } // Pull out data once. int out_len; @@ -788,6 +788,20 @@ TEST_F(NetEqDecodingTest, DISABLED_ON_ANDROID(LongCngWithClockDrift)) { EXPECT_GE(delay_after, delay_before - 20 * 16); } +TEST_F(NetEqDecodingTest, DISABLED_ON_ANDROID(LongCngWithClockNegativeDrift)) { + // Apply a clock drift of -25 ms / s (sender faster than receiver). + const double kDriftFactor = 1000.0 / (1000.0 + 25.0); + LongCngWithClockDrift(kDriftFactor); +} + +// TODO(hlundin): Re-enable this test and fix the issues to make it pass. +TEST_F(NetEqDecodingTest, + DISABLED_ON_ANDROID(DISABLED_LongCngWithClockPositiveDrift)) { + // Apply a clock drift of +25 ms / s (sender slower than receiver). + const double kDriftFactor = 1000.0 / (1000.0 - 25.0); + LongCngWithClockDrift(kDriftFactor); +} + TEST_F(NetEqDecodingTest, DISABLED_ON_ANDROID(UnknownPayloadType)) { const int kPayloadBytes = 100; uint8_t payload[kPayloadBytes] = {0};