Remove WebRtcACMEncodingType

The parameter was not needed; it was sufficient with a bool indicating
speech or not speech. This change propagates to the InFrameType
callback function. Some tests are updated too.

COAUTHOR=kwiberg@webrtc.org
R=minyue@webrtc.org
TBR=henrika@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/42209004

Cr-Original-Commit-Position: refs/heads/master@{#8626}
Cr-Mirrored-From: https://chromium.googlesource.com/external/webrtc
Cr-Mirrored-Commit: e9217b4bdbf9a8fd8b4882b2f995665927f28ad2
diff --git a/modules/audio_coding/main/test/TestVADDTX.cc b/modules/audio_coding/main/test/TestVADDTX.cc
index 0aeaf20..475e699 100644
--- a/modules/audio_coding/main/test/TestVADDTX.cc
+++ b/modules/audio_coding/main/test/TestVADDTX.cc
@@ -37,21 +37,18 @@
   ResetStatistics();
 }
 
-int32_t ActivityMonitor::InFrameType(int16_t frame_type) {
+int32_t ActivityMonitor::InFrameType(FrameType frame_type) {
   counter_[frame_type]++;
   return 0;
 }
 
 void ActivityMonitor::PrintStatistics() {
   printf("\n");
-  printf("kActiveNormalEncoded  kPassiveNormalEncoded  kPassiveDTXWB  ");
-  printf("kPassiveDTXNB kPassiveDTXSWB kNoEncoding\n");
-  printf("%19u", counter_[1]);
-  printf("%22u", counter_[2]);
-  printf("%14u", counter_[3]);
-  printf("%14u", counter_[4]);
-  printf("%14u", counter_[5]);
-  printf("%11u", counter_[0]);
+  printf("kFrameEmpty       %u\n", counter_[kFrameEmpty]);
+  printf("kAudioFrameSpeech %u\n", counter_[kAudioFrameSpeech]);
+  printf("kAudioFrameCN     %u\n", counter_[kAudioFrameCN]);
+  printf("kVideoFrameKey    %u\n", counter_[kVideoFrameKey]);
+  printf("kVideoFrameDelta  %u\n", counter_[kVideoFrameDelta]);
   printf("\n\n");
 }
 
@@ -71,7 +68,6 @@
   EXPECT_EQ(0, acm_send_->RegisterTransportCallback(channel_.get()));
   channel_->RegisterReceiverACM(acm_receive_.get());
   EXPECT_EQ(0, acm_send_->RegisterVADCallback(monitor_.get()));
-  assert(monitor_->kPacketTypes == this->kPacketTypes);
 }
 
 void TestVadDtx::RegisterCodec(CodecInst codec_param) {
@@ -118,22 +114,19 @@
   monitor_->PrintStatistics();
 #endif
 
-  uint32_t stats[kPacketTypes];
+  uint32_t stats[5];
   monitor_->GetStatistics(stats);
   monitor_->ResetStatistics();
 
-  for (int i = 0; i < kPacketTypes; i++) {
+  for (const auto& st : stats) {
+    int i = &st - stats;  // Calculate the current position in stats.
     switch (expects[i]) {
       case 0: {
-        EXPECT_EQ(static_cast<uint32_t>(0), stats[i]) << "stats["
-                                                      << i
-                                                      << "] error.";
+        EXPECT_EQ(0u, st) << "stats[" << i << "] error.";
         break;
       }
       case 1: {
-        EXPECT_GT(stats[i], static_cast<uint32_t>(0)) << "stats["
-                                                      << i
-                                                      << "] error.";
+        EXPECT_GT(st, 0u) << "stats[" << i << "] error.";
         break;
       }
     }
@@ -198,14 +191,7 @@
 
 // Set the expectation and run the test.
 void TestWebRtcVadDtx::Test(bool new_outfile) {
-  int expects[kPacketTypes];
-  int frequency = acm_send_->SendFrequency();
-  expects[0] = -1;  // Do not care.
-  expects[1] = 1;
-  expects[2] = vad_enabled_ && !use_webrtc_dtx_;
-  expects[3] = use_webrtc_dtx_ && (frequency == 8000);
-  expects[4] = use_webrtc_dtx_ && (frequency == 16000);
-  expects[5] = use_webrtc_dtx_ && (frequency == 32000);
+  int expects[] = {-1, 1, use_webrtc_dtx_, 0, 0};
   if (new_outfile) {
     output_file_num_++;
   }
@@ -251,7 +237,7 @@
 // Following is the implementation of TestOpusDtx.
 void TestOpusDtx::Perform() {
 #ifdef WEBRTC_CODEC_OPUS
-  int expects[kPacketTypes] = {0, 1, 0, 0, 0, 0};
+  int expects[] = {0, 1, 0, 0, 0};
 
   // Register Opus as send codec
   std::string out_filename = webrtc::test::OutputPath() +
@@ -263,7 +249,7 @@
       32000, 1, out_filename, false, expects);
 
   EXPECT_EQ(0, acm_send_->EnableOpusDtx());
-  expects[0] = 1;
+  expects[kFrameEmpty] = 1;
   Run(webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"),
       32000, 1, out_filename, true, expects);
 
@@ -271,7 +257,7 @@
   out_filename = webrtc::test::OutputPath() + "testOpusDtx_outFile_stereo.pcm";
   RegisterCodec(kOpusStereo);
   EXPECT_EQ(0, acm_send_->DisableOpusDtx());
-  expects[0] = 0;
+  expects[kFrameEmpty] = 0;
   Run(webrtc::test::ResourcePath("audio_coding/teststereo32kHz", "pcm"),
       32000, 2, out_filename, false, expects);
 
@@ -279,7 +265,7 @@
   EXPECT_EQ(0, acm_send_->SetOpusApplication(kVoip));
   EXPECT_EQ(0, acm_send_->EnableOpusDtx());
 
-  expects[0] = 1;
+  expects[kFrameEmpty] = 1;
   Run(webrtc::test::ResourcePath("audio_coding/teststereo32kHz", "pcm"),
       32000, 2, out_filename, true, expects);
 #endif
diff --git a/modules/audio_coding/main/test/TestVADDTX.h b/modules/audio_coding/main/test/TestVADDTX.h
index 773d379..b664a9b 100644
--- a/modules/audio_coding/main/test/TestVADDTX.h
+++ b/modules/audio_coding/main/test/TestVADDTX.h
@@ -23,22 +23,18 @@
 
 class ActivityMonitor : public ACMVADCallback {
  public:
-  static const int kPacketTypes = 6;
-
   ActivityMonitor();
-  int32_t InFrameType(int16_t frame_type);
+  int32_t InFrameType(FrameType frame_type);
   void PrintStatistics();
   void ResetStatistics();
   void GetStatistics(uint32_t* stats);
  private:
-  // Counting according to
-  //   counter_[0] - kNoEncoding,
-  //   counter_[1] - kActiveNormalEncoded,
-  //   counter_[2] - kPassiveNormalEncoded,
-  //   counter_[3] - kPassiveDTXNB,
-  //   counter_[4] - kPassiveDTXWB,
-  //   counter_[5] - kPassiveDTXSWB
-  uint32_t counter_[kPacketTypes];
+  // 0 - kFrameEmpty
+  // 1 - kAudioFrameSpeech
+  // 2 - kAudioFrameCN
+  // 3 - kVideoFrameKey (not used by audio)
+  // 4 - kVideoFrameDelta (not used by audio)
+  uint32_t counter_[5];
 };
 
 
@@ -49,7 +45,6 @@
 class TestVadDtx : public ACMTest {
  public:
   static const int kOutputFreqHz = 16000;
-  static const int kPacketTypes = 6;
 
   TestVadDtx();
 
@@ -65,12 +60,11 @@
   // 0  : there have been no packets of type |x|,
   // 1  : there have been packets of type |x|,
   // with |x| indicates the following packet types
-  // 0 - kNoEncoding
-  // 1 - kActiveNormalEncoded
-  // 2 - kPassiveNormalEncoded
-  // 3 - kPassiveDTXNB
-  // 4 - kPassiveDTXWB
-  // 5 - kPassiveDTXSWB
+  // 0 - kFrameEmpty
+  // 1 - kAudioFrameSpeech
+  // 2 - kAudioFrameCN
+  // 3 - kVideoFrameKey (not used by audio)
+  // 4 - kVideoFrameDelta (not used by audio)
   void Run(std::string in_filename, int frequency, int channels,
            std::string out_filename, bool append, const int* expects);
 
diff --git a/modules/audio_coding/main/test/utility.cc b/modules/audio_coding/main/test/utility.cc
index 0848954..e4e6dd4 100644
--- a/modules/audio_coding/main/test/utility.cc
+++ b/modules/audio_coding/main/test/utility.cc
@@ -13,6 +13,7 @@
 #include <assert.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 
 #include "testing/gtest/include/gtest/gtest.h"
 #include "webrtc/common.h"
@@ -305,28 +306,23 @@
 }
 
 void VADCallback::Reset() {
-  for (int n = 0; n < 6; n++) {
-    _numFrameTypes[n] = 0;
-  }
+  memset(_numFrameTypes, 0, sizeof(_numFrameTypes));
 }
 
 VADCallback::VADCallback() {
-  for (int n = 0; n < 6; n++) {
-    _numFrameTypes[n] = 0;
-  }
+  memset(_numFrameTypes, 0, sizeof(_numFrameTypes));
 }
 
 void VADCallback::PrintFrameTypes() {
-  fprintf(stdout, "No encoding.................. %d\n", _numFrameTypes[0]);
-  fprintf(stdout, "Active normal encoded........ %d\n", _numFrameTypes[1]);
-  fprintf(stdout, "Passive normal encoded....... %d\n", _numFrameTypes[2]);
-  fprintf(stdout, "Passive DTX wideband......... %d\n", _numFrameTypes[3]);
-  fprintf(stdout, "Passive DTX narrowband....... %d\n", _numFrameTypes[4]);
-  fprintf(stdout, "Passive DTX super-wideband... %d\n", _numFrameTypes[5]);
+  printf("kFrameEmpty......... %d\n", _numFrameTypes[kFrameEmpty]);
+  printf("kAudioFrameSpeech... %d\n", _numFrameTypes[kAudioFrameSpeech]);
+  printf("kAudioFrameCN....... %d\n", _numFrameTypes[kAudioFrameCN]);
+  printf("kVideoFrameKey...... %d\n", _numFrameTypes[kVideoFrameKey]);
+  printf("kVideoFrameDelta.... %d\n", _numFrameTypes[kVideoFrameDelta]);
 }
 
-int32_t VADCallback::InFrameType(int16_t frameType) {
-  _numFrameTypes[frameType]++;
+int32_t VADCallback::InFrameType(FrameType frame_type) {
+  _numFrameTypes[frame_type]++;
   return 0;
 }
 
diff --git a/modules/audio_coding/main/test/utility.h b/modules/audio_coding/main/test/utility.h
index 038643b..eccb68f 100644
--- a/modules/audio_coding/main/test/utility.h
+++ b/modules/audio_coding/main/test/utility.h
@@ -134,13 +134,13 @@
   ~VADCallback() {
   }
 
-  int32_t InFrameType(int16_t frameType);
+  int32_t InFrameType(FrameType frame_type);
 
   void PrintFrameTypes();
   void Reset();
 
  private:
-  uint32_t _numFrameTypes[6];
+  uint32_t _numFrameTypes[5];
 };
 
 void UseLegacyAcm(webrtc::Config* config);