Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / third_party / webrtc / modules / audio_coding / neteq4 / neteq_unittest.cc
index bf5ca7b..47e9e85 100644 (file)
@@ -219,6 +219,8 @@ class NetEqDecodingTest : public ::testing::Test {
                 const std::set<uint16_t>& 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_;
@@ -515,43 +517,44 @@ void NetEqDecodingTest::CheckBgnOff(int sampling_rate_hz,
 #endif
 
 TEST_F(NetEqDecodingTest, DISABLED_ON_ANDROID(MAYBE_TestBitExactness)) {
-  const std::string kInputRtpFile = webrtc::test::ProjectRootPath() +
+  const std::string input_rtp_file = webrtc::test::ProjectRootPath() +
       "resources/audio_coding/neteq_universal_new.rtp";
 #if defined(_MSC_VER) && (_MSC_VER >= 1700)
   // For Visual Studio 2012 and later, we will have to use the generic reference
   // file, rather than the windows-specific one.
-  const std::string kInputRefFile = webrtc::test::ProjectRootPath() +
+  const std::string input_ref_file = webrtc::test::ProjectRootPath() +
       "resources/audio_coding/neteq4_universal_ref.pcm";
 #else
-  const std::string kInputRefFile =
+  const std::string input_ref_file =
       webrtc::test::ResourcePath("audio_coding/neteq4_universal_ref", "pcm");
 #endif
 
   if (FLAGS_gen_ref) {
-    DecodeAndCompare(kInputRtpFile, "");
+    DecodeAndCompare(input_rtp_file, "");
   } else {
-    DecodeAndCompare(kInputRtpFile, kInputRefFile);
+    DecodeAndCompare(input_rtp_file, input_ref_file);
   }
 }
 
 TEST_F(NetEqDecodingTest, DISABLED_ON_ANDROID(TestNetworkStatistics)) {
-  const std::string kInputRtpFile = webrtc::test::ProjectRootPath() +
+  const std::string input_rtp_file = webrtc::test::ProjectRootPath() +
       "resources/audio_coding/neteq_universal_new.rtp";
 #if defined(_MSC_VER) && (_MSC_VER >= 1700)
   // For Visual Studio 2012 and later, we will have to use the generic reference
   // file, rather than the windows-specific one.
-  const std::string kNetworkStatRefFile = webrtc::test::ProjectRootPath() +
+  const std::string network_stat_ref_file = webrtc::test::ProjectRootPath() +
       "resources/audio_coding/neteq4_network_stats.dat";
 #else
-  const std::string kNetworkStatRefFile =
+  const std::string network_stat_ref_file =
       webrtc::test::ResourcePath("audio_coding/neteq4_network_stats", "dat");
 #endif
-  const std::string kRtcpStatRefFile =
+  const std::string rtcp_stat_ref_file =
       webrtc::test::ResourcePath("audio_coding/neteq4_rtcp_stats", "dat");
   if (FLAGS_gen_ref) {
-    DecodeAndCheckStats(kInputRtpFile, "", "");
+    DecodeAndCheckStats(input_rtp_file, "", "");
   } else {
-    DecodeAndCheckStats(kInputRtpFile, kNetworkStatRefFile, kRtcpStatRefFile);
+    DecodeAndCheckStats(input_rtp_file, network_stat_ref_file,
+                        rtcp_stat_ref_file);
   }
 }
 
@@ -694,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;
@@ -718,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<double>(kFrameSizeMs) * kDriftFactor;
+      next_input_time_ms += static_cast<double>(kFrameSizeMs) * drift_factor;
     }
     // Pull out data once.
     int out_len;
@@ -746,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<double>(kCngPeriodMs) * kDriftFactor;
+      next_input_time_ms += static_cast<double>(kCngPeriodMs) * drift_factor;
     }
     // Pull out data once.
     int out_len;
@@ -769,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<double>(kFrameSizeMs) * kDriftFactor;
+      next_input_time_ms += static_cast<double>(kFrameSizeMs) * drift_factor;
     }
     // Pull out data once.
     int out_len;
@@ -787,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};