Compile ACM2 and ACM1.

First patch set is the same as patch set 3 of http://review.webrtc.org/2237004/

-Make ACM1 to depend on ACM2.
-Remove APIs to set and get background noise mode. There is no VoE call to these
APIs.
-Remove APIs to set and get receive side VAD mode. There is no VoE call to these
APIs, and NetEq 4, doesn't support them.
-Remove callback for in-band DTMF detection. ACM doesn't support in-band DTMF
detection.
-Use acm_common_defs.h everywhere required.
-Complete ACM factory method.
-Update ACMCodecDatabase of ACM2. CNG full-band need to be define-guarded.
Remove dynamic payload-type assignment.

BUG=
R=andrew@webrtc.org

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

git-svn-id: http://webrtc.googlecode.com/svn/trunk@4785 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/webrtc/modules/audio_coding/main/acm2/acm_codec_database.cc b/webrtc/modules/audio_coding/main/acm2/acm_codec_database.cc
index 8e14fbb..f99c85b 100644
--- a/webrtc/modules/audio_coding/main/acm2/acm_codec_database.cc
+++ b/webrtc/modules/audio_coding/main/acm2/acm_codec_database.cc
@@ -102,26 +102,9 @@
 
 namespace webrtc {
 
-// We dynamically allocate some of the dynamic payload types to the defined
-// codecs. Note! There are a limited number of payload types. If more codecs
-// are defined they will receive reserved fixed payload types (values 69-95).
-const int kDynamicPayloadtypes[ACMCodecDB::kMaxNumCodecs] = {
-  107, 108, 109, 111, 112, 113, 114, 115, 116, 117, 92,
-  91,  90,  89,  88,  87,  86,  85,  84,  83,  82,  81, 80,
-  79,  78,  77,  76,  75,  74,  73,  72,  71,  70,  69, 68,
-  67, 66, 65
-};
-
-// Creates database with all supported codecs at compile time.
-// Each entry needs the following parameters in the given order:
-// payload type, name, sampling frequency, packet size in samples,
-// number of channels, and default rate.
-#if (defined(WEBRTC_CODEC_AMR) || defined(WEBRTC_CODEC_AMRWB) || \
-    defined(WEBRTC_CODEC_CELT) || defined(WEBRTC_CODEC_G722_1) || \
-    defined(WEBRTC_CODEC_G722_1C) || defined(WEBRTC_CODEC_G729_1) || \
-    defined(WEBRTC_CODEC_PCM16) || defined(WEBRTC_CODEC_SPEEX))
-static int count_database = 0;
-#endif
+// Not yet used payload-types.
+// 83,  82,  81, 80, 79,  78,  77,  76,  75,  74,  73,  72,  71,  70,  69, 68,
+// 67, 66, 65
 
 const CodecInst ACMCodecDB::database_[] = {
 #if (defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX))
@@ -133,13 +116,13 @@
 #endif
 #ifdef WEBRTC_CODEC_PCM16
   // Mono
-  {kDynamicPayloadtypes[count_database++], "L16", 8000, 80, 1, 128000},
-  {kDynamicPayloadtypes[count_database++], "L16", 16000, 160, 1, 256000},
-  {kDynamicPayloadtypes[count_database++], "L16", 32000, 320, 1, 512000},
+  {107, "L16", 8000, 80, 1, 128000},
+  {108, "L16", 16000, 160, 1, 256000},
+  {109, "L16", 32000, 320, 1, 512000},
   // Stereo
-  {kDynamicPayloadtypes[count_database++], "L16", 8000, 80, 2, 128000},
-  {kDynamicPayloadtypes[count_database++], "L16", 16000, 160, 2, 256000},
-  {kDynamicPayloadtypes[count_database++], "L16", 32000, 320, 2, 512000},
+  {111, "L16", 8000, 80, 2, 128000},
+  {112, "L16", 16000, 160, 2, 256000},
+  {113, "L16", 32000, 320, 2, 512000},
 #endif
   // G.711, PCM mu-law and A-law.
   // Mono
@@ -152,16 +135,16 @@
   {102, "ILBC", 8000, 240, 1, 13300},
 #endif
 #ifdef WEBRTC_CODEC_AMR
-  {kDynamicPayloadtypes[count_database++], "AMR", 8000, 160, 1, 12200},
+  {114, "AMR", 8000, 160, 1, 12200},
 #endif
 #ifdef WEBRTC_CODEC_AMRWB
-  {kDynamicPayloadtypes[count_database++], "AMR-WB", 16000, 320, 1, 20000},
+  {115, "AMR-WB", 16000, 320, 1, 20000},
 #endif
 #ifdef WEBRTC_CODEC_CELT
   // Mono
-  {kDynamicPayloadtypes[count_database++], "CELT", 32000, 640, 1, 64000},
+  {116, "CELT", 32000, 640, 1, 64000},
   // Stereo
-  {kDynamicPayloadtypes[count_database++], "CELT", 32000, 640, 2, 64000},
+  {117, "CELT", 32000, 640, 2, 64000},
 #endif
 #ifdef WEBRTC_CODEC_G722
   // Mono
@@ -170,20 +153,20 @@
   {119, "G722", 16000, 320, 2, 64000},
 #endif
 #ifdef WEBRTC_CODEC_G722_1
-  {kDynamicPayloadtypes[count_database++], "G7221", 16000, 320, 1, 32000},
-  {kDynamicPayloadtypes[count_database++], "G7221", 16000, 320, 1, 24000},
-  {kDynamicPayloadtypes[count_database++], "G7221", 16000, 320, 1, 16000},
+  {92, "G7221", 16000, 320, 1, 32000},
+  {91, "G7221", 16000, 320, 1, 24000},
+  {90, "G7221", 16000, 320, 1, 16000},
 #endif
 #ifdef WEBRTC_CODEC_G722_1C
-  {kDynamicPayloadtypes[count_database++], "G7221", 32000, 640, 1, 48000},
-  {kDynamicPayloadtypes[count_database++], "G7221", 32000, 640, 1, 32000},
-  {kDynamicPayloadtypes[count_database++], "G7221", 32000, 640, 1, 24000},
+  {89, "G7221", 32000, 640, 1, 48000},
+  {88, "G7221", 32000, 640, 1, 32000},
+  {87, "G7221", 32000, 640, 1, 24000},
 #endif
 #ifdef WEBRTC_CODEC_G729
   {18, "G729", 8000, 240, 1, 8000},
 #endif
 #ifdef WEBRTC_CODEC_G729_1
-  {kDynamicPayloadtypes[count_database++], "G7291", 16000, 320, 1, 32000},
+  {86, "G7291", 16000, 320, 1, 32000},
 #endif
 #ifdef WEBRTC_CODEC_GSMFR
   {3, "GSM", 8000, 160, 1, 13200},
@@ -194,14 +177,16 @@
   {120, "opus", 48000, 960, 2, 64000},
 #endif
 #ifdef WEBRTC_CODEC_SPEEX
-  {kDynamicPayloadtypes[count_database++], "speex", 8000, 160, 1, 11000},
-  {kDynamicPayloadtypes[count_database++], "speex", 16000, 320, 1, 22000},
+  {85, "speex", 8000, 160, 1, 11000},
+  {84, "speex", 16000, 320, 1, 22000},
 #endif
   // Comfort noise for four different sampling frequencies.
   {13, "CN", 8000, 240, 1, 0},
   {98, "CN", 16000, 480, 1, 0},
   {99, "CN", 32000, 960, 1, 0},
+#ifdef ENABLE_48000_HZ
   {100, "CN", 48000, 1440, 1, 0},
+#endif
 #ifdef WEBRTC_CODEC_AVT
   {106, "telephone-event", 8000, 240, 1, 0},
 #endif
@@ -295,7 +280,9 @@
     {1, {240}, 240, 1, false},
     {1, {480}, 480, 1, false},
     {1, {960}, 960, 1, false},
+#ifdef ENABLE_48000_HZ
     {1, {1440}, 1440, 1, false},
+#endif
 #ifdef WEBRTC_CODEC_AVT
     {1, {240}, 240, 1, false},
 #endif
@@ -383,8 +370,10 @@
     // Comfort noise for three different sampling frequencies.
     kDecoderCNGnb,
     kDecoderCNGwb,
-    kDecoderCNGswb32kHz,
-    kDecoderCNGswb48kHz
+    kDecoderCNGswb32kHz
+#ifdef ENABLE_48000_HZ
+    , kDecoderCNGswb48kHz
+#endif
 #ifdef WEBRTC_CODEC_AVT
     , kDecoderAVT
 #endif
@@ -710,10 +699,12 @@
         codec_id = kCNSWB;
         break;
       }
+#ifdef ENABLE_48000_HZ
       case 48000: {
         codec_id = kCNFB;
         break;
       }
+#endif
       default: {
         return NULL;
       }
@@ -765,10 +756,12 @@
         codec_id = kCNSWB;
         break;
       }
+#ifdef ENABLE_48000_HZ
       case 48000: {
         codec_id = kCNFB;
         break;
       }
+#endif
       default: {
         return NULL;
       }
diff --git a/webrtc/modules/audio_coding/main/acm2/acm_codec_database.h b/webrtc/modules/audio_coding/main/acm2/acm_codec_database.h
index a8a7643..b992b7d 100644
--- a/webrtc/modules/audio_coding/main/acm2/acm_codec_database.h
+++ b/webrtc/modules/audio_coding/main/acm2/acm_codec_database.h
@@ -103,7 +103,9 @@
     , kCNNB
     , kCNWB
     , kCNSWB
+#ifdef ENABLE_48000_HZ
     , kCNFB
+#endif
 #ifdef WEBRTC_CODEC_AVT
     , kAVT
 #endif
@@ -187,6 +189,9 @@
 #ifndef WEBRTC_CODEC_RED
   enum {kRED = -1};
 #endif
+#ifndef ENABLE_48000_HZ
+  enum { kCNFB = -1 };
+#endif
 
   // kMaxNumCodecs - Maximum number of codecs that can be activated in one
   //                 build.
diff --git a/webrtc/modules/audio_coding/main/acm2/acm_common_defs.h b/webrtc/modules/audio_coding/main/acm2/acm_common_defs.h
index 39287ea..26aa74d 100644
--- a/webrtc/modules/audio_coding/main/acm2/acm_common_defs.h
+++ b/webrtc/modules/audio_coding/main/acm2/acm_common_defs.h
@@ -24,22 +24,13 @@
 #error iSAC and iSACFX codecs cannot be enabled at the same time
 #endif
 
-#ifndef STR_CASE_CMP
-#ifdef WIN32
-// OS-dependent case-insensitive string comparison
-#define STR_CASE_CMP(x, y) ::_stricmp(x, y)
-#else
-// OS-dependent case-insensitive string comparison
-#define STR_CASE_CMP(x, y) ::strcasecmp(x, y)
-#endif
-#endif
 
 namespace webrtc {
 
 // 60 ms is the maximum block size we support. An extra 20 ms is considered
 // for safety if process() method is not called when it should be, i.e. we
-// accept 20 ms of jitter. 80 ms @ 32 kHz (super wide-band) is 2560 samples.
-#define AUDIO_BUFFER_SIZE_W16  2560
+// accept 20 ms of jitter. 80 ms @ 48 kHz (full-band) stereo is 7680 samples.
+#define AUDIO_BUFFER_SIZE_W16 7680
 
 // There is one timestamp per each 10 ms of audio
 // the audio buffer, at max, may contain 32 blocks of 10ms
@@ -93,6 +84,17 @@
   ACMVADMode vad_mode;
 };
 
+// TODO(turajs): Remove when ACM1 is removed.
+struct WebRtcACMAudioBuff {
+  int16_t in_audio[AUDIO_BUFFER_SIZE_W16];
+  int16_t in_audio_ix_read;
+  int16_t in_audio_ix_write;
+  uint32_t in_timestamp[TIMESTAMP_BUFFER_SIZE_W32];
+  int16_t in_timestamp_ix_write;
+  uint32_t last_timestamp;
+  uint32_t last_in_timestamp;
+};
+
 }  // namespace webrtc
 
 #endif  // WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_COMMON_DEFS_H_
diff --git a/webrtc/modules/audio_coding/main/acm2/acm_isac.cc b/webrtc/modules/audio_coding/main/acm2/acm_isac.cc
index e2de7ef..7957fd3 100644
--- a/webrtc/modules/audio_coding/main/acm2/acm_isac.cc
+++ b/webrtc/modules/audio_coding/main/acm2/acm_isac.cc
@@ -301,7 +301,7 @@
                              uint32_t arrival_timestamp) {
     return ACM_ISAC_DECODE_BWE(static_cast<ACM_ISAC_STRUCT*>(state_),
                                reinterpret_cast<const uint16_t*>(payload),
-                               payload_len,
+                               static_cast<uint32_t>(payload_len),
                                rtp_sequence_number,
                                rtp_timestamp,
                                arrival_timestamp);
@@ -311,7 +311,7 @@
                               size_t encoded_len, int16_t* decoded,
                               SpeechType* speech_type) {
     int16_t temp_type = 1;  // Default is speech.
-    int16_t ret = ACM_ISAC_DECODERCU(static_cast<ISACStruct*>(state_),
+    int16_t ret = ACM_ISAC_DECODERCU(static_cast<ACM_ISAC_STRUCT*>(state_),
                                      reinterpret_cast<const uint16_t*>(encoded),
                                      static_cast<int16_t>(encoded_len), decoded,
                                      &temp_type);
diff --git a/webrtc/modules/audio_coding/main/acm2/acm_receiver.cc b/webrtc/modules/audio_coding/main/acm2/acm_receiver.cc
index 5a36f86..949a705 100644
--- a/webrtc/modules/audio_coding/main/acm2/acm_receiver.cc
+++ b/webrtc/modules/audio_coding/main/acm2/acm_receiver.cc
@@ -179,7 +179,7 @@
   // improve performance. Here, this call has to be placed before the following
   // block, therefore, we keep it inside critical section. Otherwise, we have to
   // release |neteq_crit_sect_| and acquire it again, which seems an overkill.
-  if (neteq_->SetMinimumDelay(delay_ms) < 0)
+  if (!neteq_->SetMinimumDelay(delay_ms))
     return -1;
 
   const int kLatePacketThreshold = 5;
@@ -593,7 +593,8 @@
 
 int AcmReceiver::RedPayloadType() const {
   CriticalSectionScoped lock(neteq_crit_sect_);
-  if (!decoders_[ACMCodecDB::kRED].registered) {
+  if (ACMCodecDB::kRED < 0 ||
+      !decoders_[ACMCodecDB::kRED].registered) {
     LOG_F(LS_WARNING) << "RED is not registered.";
     return -1;
   }
@@ -620,7 +621,7 @@
 
   acm_stat->currentBufferSize = neteq_stat.current_buffer_size_ms;
   acm_stat->preferredBufferSize = neteq_stat.preferred_buffer_size_ms;
-  acm_stat->jitterPeaksFound = neteq_stat.jitter_peaks_found;
+  acm_stat->jitterPeaksFound = neteq_stat.jitter_peaks_found ? true : false;
   acm_stat->currentPacketLossRate = neteq_stat.packet_loss_rate;
   acm_stat->currentDiscardRate = neteq_stat.packet_discard_rate;
   acm_stat->currentExpandRate = neteq_stat.expand_rate;
@@ -745,7 +746,7 @@
   int max_num_packets;
   int buffer_size_byte;
   int max_buffer_size_byte;
-  const float kBufferingThresholdScale = 0.9;
+  const float kBufferingThresholdScale = 0.9f;
   neteq_->PacketBufferStatistics(&num_packets, &max_num_packets,
                                  &buffer_size_byte, &max_buffer_size_byte);
   if (num_packets > max_num_packets * kBufferingThresholdScale ||
@@ -786,7 +787,8 @@
 int AcmReceiver::RtpHeaderToCodecIndex(
     const RTPHeader &rtp_header, const uint8_t* payload) const {
   uint8_t payload_type = rtp_header.payloadType;
-  if (decoders_[ACMCodecDB::kRED].registered &&
+  if (ACMCodecDB::kRED >= 0 &&  // This ensures that RED is defined in WebRTC.
+      decoders_[ACMCodecDB::kRED].registered &&
       payload_type == decoders_[ACMCodecDB::kRED].payload_type) {
     // This is a RED packet, get the payload of the audio codec.
     payload_type = payload[0] & 0x7F;
diff --git a/webrtc/modules/audio_coding/main/acm2/audio_coding_module.cc b/webrtc/modules/audio_coding/main/acm2/audio_coding_module.cc
index 491160d..afb6920 100644
--- a/webrtc/modules/audio_coding/main/acm2/audio_coding_module.cc
+++ b/webrtc/modules/audio_coding/main/acm2/audio_coding_module.cc
@@ -13,18 +13,24 @@
 #include "webrtc/common_types.h"
 #include "webrtc/modules/audio_coding/main/acm2/acm_codec_database.h"
 #include "webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.h"
+#include "webrtc/modules/audio_coding/main/source/audio_coding_module_impl.h"
+#include "webrtc/system_wrappers/interface/clock.h"
 #include "webrtc/system_wrappers/interface/trace.h"
 
 namespace webrtc {
 
 // Create module
 AudioCodingModule* AudioCodingModule::Create(int id) {
-  return new AudioCodingModuleImpl(id);
+  return new acm1::AudioCodingModuleImpl(id, Clock::GetRealTimeClock());
+}
+
+AudioCodingModule* AudioCodingModule::Create(int id, Clock* clock) {
+  return new acm1::AudioCodingModuleImpl(id, clock);
 }
 
 // Destroy module
 void AudioCodingModule::Destroy(AudioCodingModule* module) {
-  delete static_cast<AudioCodingModuleImpl*>(module);
+  delete module;
 }
 
 // Get number of supported codecs
@@ -90,11 +96,12 @@
   }
 }
 
-AudioCodingModule* AudioCodingModuleFactory::Create(const int32_t id) const {
-  return NULL;
+AudioCodingModule* AudioCodingModuleFactory::Create(int id) const {
+  return new acm1::AudioCodingModuleImpl(static_cast<int32_t>(id),
+                                         Clock::GetRealTimeClock());
 }
 
-AudioCodingModule* NewAudioCodingModuleFactory::Create(const int32_t id) const {
+AudioCodingModule* NewAudioCodingModuleFactory::Create(int id) const {
   return new AudioCodingModuleImpl(id);
 }
 
diff --git a/webrtc/modules/audio_coding/main/acm2/audio_coding_module.gypi b/webrtc/modules/audio_coding/main/acm2/audio_coding_module.gypi
index f526250..e86fbfc 100644
--- a/webrtc/modules/audio_coding/main/acm2/audio_coding_module.gypi
+++ b/webrtc/modules/audio_coding/main/acm2/audio_coding_module.gypi
@@ -16,6 +16,7 @@
       ],
       'dependencies': [
         '<@(audio_coding_dependencies)',
+        'NetEq4',
       ],
       'include_dirs': [
         '../interface',
@@ -40,6 +41,7 @@
         'acm_cng.h',
         'acm_codec_database.cc',
         'acm_codec_database.h',
+        'acm_common_defs.h',
         'acm_dtmf_playout.cc',
         'acm_dtmf_playout.h',
         'acm_g722.cc',
diff --git a/webrtc/modules/audio_coding/main/acm2/initial_delay_manager.cc b/webrtc/modules/audio_coding/main/acm2/initial_delay_manager.cc
index 038b132..ac79aa5 100644
--- a/webrtc/modules/audio_coding/main/acm2/initial_delay_manager.cc
+++ b/webrtc/modules/audio_coding/main/acm2/initial_delay_manager.cc
@@ -153,7 +153,6 @@
 void InitialDelayManager::LatePackets(
     uint32_t timestamp_now, SyncStream* sync_stream) {
   assert(sync_stream);
-  const int kLateThreshold = 5;
   sync_stream->num_sync_packets = 0;
 
   // If there is no estimate of timestamp increment, |timestamp_step_|, then
@@ -171,7 +170,7 @@
   int num_late_packets = (timestamp_now - last_receive_timestamp_) /
       timestamp_step_;
 
-  if (num_late_packets < kLateThreshold)
+  if (num_late_packets < late_packet_threshold_)
     return;
 
   int sync_offset = 1;  // One gap at the end of the sync-stream.
diff --git a/webrtc/modules/audio_coding/main/interface/audio_coding_module.h b/webrtc/modules/audio_coding/main/interface/audio_coding_module.h
index 12b5a63..0074809 100644
--- a/webrtc/modules/audio_coding/main/interface/audio_coding_module.h
+++ b/webrtc/modules/audio_coding/main/interface/audio_coding_module.h
@@ -85,8 +85,8 @@
   // injected into ACM. ACM will take the owner ship of the object clock and
   // delete it when destroyed.
   //
-  static AudioCodingModule* Create(const int32_t id);
-  static AudioCodingModule* Create(const int32_t id, Clock* clock);
+  static AudioCodingModule* Create(int id);
+  static AudioCodingModule* Create(int id, Clock* clock);
   virtual ~AudioCodingModule() {};
 
   // TODO(ajm): Deprecated. Remove all calls to this unneeded method.
@@ -103,7 +103,7 @@
   // Return value:
   //   number of supported codecs.
   ///
-  static uint8_t NumberOfCodecs();
+  static int NumberOfCodecs();
 
   ///////////////////////////////////////////////////////////////////////////
   // int32_t Codec()
@@ -120,7 +120,7 @@
   //   -1 if the list number (list_id) is invalid.
   //    0 if succeeded.
   //
-  static int32_t Codec(uint8_t list_id, CodecInst* codec);
+  static int Codec(int list_id, CodecInst* codec);
 
   ///////////////////////////////////////////////////////////////////////////
   // int32_t Codec()
@@ -141,7 +141,7 @@
   //   -1 if no codec matches the given parameters.
   //    0 if succeeded.
   //
-  static int32_t Codec(const char* payload_name, CodecInst* codec,
+  static int Codec(const char* payload_name, CodecInst* codec,
                        int sampling_freq_hz, int channels);
 
   ///////////////////////////////////////////////////////////////////////////
@@ -160,7 +160,7 @@
   //   if the codec is found, the index of the codec in the list,
   //   -1 if the codec is not found.
   //
-  static int32_t Codec(const char* payload_name, int sampling_freq_hz,
+  static int Codec(const char* payload_name, int sampling_freq_hz,
                              int channels);
 
   ///////////////////////////////////////////////////////////////////////////
@@ -582,8 +582,8 @@
   //   -1 if fails to unregister.
   //    0 if the given codec is successfully unregistered.
   //
-  virtual int32_t UnregisterReceiveCodec(
-      const int16_t payload_type) = 0;
+  virtual int UnregisterReceiveCodec(
+      uint8_t payload_type) = 0;
 
   ///////////////////////////////////////////////////////////////////////////
   // int32_t ReceiveCodec()
@@ -683,29 +683,6 @@
   virtual int LeastRequiredDelayMs() const = 0;
 
   ///////////////////////////////////////////////////////////////////////////
-  // int32_t RegisterIncomingMessagesCallback()
-  // Used by the module to deliver messages to the codec module/application
-  // when a DTMF tone is detected, as well as when it stopped.
-  //
-  // Inputs:
-  //   -in_message_callback: pointer to callback function which will be called
-  //                         if DTMF is detected.
-  //   -cpt                : enables CPT (Call Progress Tone) detection for the
-  //                         specified country. c.f. definition of ACMCountries
-  //                         in audio_coding_module_typedefs.h for valid
-  //                         entries. The default value disables CPT
-  //                         detection.
-  //
-  // Return value:
-  //   -1 if the message callback could not be registered
-  //    0 if registration is successful.
-  //
-  virtual int32_t
-      RegisterIncomingMessagesCallback(
-          AudioCodingFeedback* in_message_callback,
-          const ACMCountries cpt = ACMDisableCountryDetection) = 0;
-
-  ///////////////////////////////////////////////////////////////////////////
   // int32_t SetDtmfPlayoutStatus()
   // Configure DTMF playout, i.e. whether out-of-band
   // DTMF tones are played or not.
@@ -731,39 +708,6 @@
   virtual bool DtmfPlayoutStatus() const = 0;
 
   ///////////////////////////////////////////////////////////////////////////
-  // int32_t SetBackgroundNoiseMode()
-  // Sets the mode of the background noise playout in an event of long
-  // packet loss burst. For the valid modes see the declaration of
-  // ACMBackgroundNoiseMode in audio_coding_module_typedefs.h.
-  //
-  // Input:
-  //   -mode               : the mode for the background noise playout.
-  //
-  // Return value:
-  //   -1 if failed to set the mode.
-  //    0 if succeeded in setting the mode.
-  //
-  virtual int32_t SetBackgroundNoiseMode(
-      const ACMBackgroundNoiseMode mode) = 0;
-
-  ///////////////////////////////////////////////////////////////////////////
-  // int32_t BackgroundNoiseMode()
-  // Call this method to get the mode of the background noise playout.
-  // Playout of background noise is a result of a long packet loss burst.
-  // See ACMBackgroundNoiseMode in audio_coding_module_typedefs.h for
-  // possible modes.
-  //
-  // Output:
-  //   -mode             : a reference to ACMBackgroundNoiseMode enumerator.
-  //
-  // Return value:
-  //    0 if the output is a valid mode.
-  //   -1 if ACM failed to output a valid mode.
-  //
-  // TODO(tlegrand): Change function to return the mode.
-  virtual int32_t BackgroundNoiseMode(ACMBackgroundNoiseMode* mode) = 0;
-
-  ///////////////////////////////////////////////////////////////////////////
   // int32_t PlayoutTimestamp()
   // The send timestamp of an RTP packet is associated with the decoded
   // audio of the packet in question. This function returns the timestamp of
@@ -853,39 +797,6 @@
                                         AudioFrame* audio_frame) = 0;
 
   ///////////////////////////////////////////////////////////////////////////
-  //   (CNG) Comfort Noise Generation
-  //   Generate comfort noise when receiving DTX packets
-  //
-
-  ///////////////////////////////////////////////////////////////////////////
-  // int16_t SetReceiveVADMode()
-  // Configure VAD aggressiveness on the incoming stream.
-  //
-  // Input:
-  //   -mode               : aggressiveness of the VAD on incoming stream.
-  //                         See audio_coding_module_typedefs.h for the
-  //                         definition of ACMVADMode, and possible
-  //                         values for aggressiveness.
-  //
-  // Return value:
-  //   -1 if fails to set the mode,
-  //    0 if the mode is set successfully.
-  //
-  virtual int16_t SetReceiveVADMode(const ACMVADMode mode) = 0;
-
-  ///////////////////////////////////////////////////////////////////////////
-  // ACMVADMode ReceiveVADMode()
-  // Get VAD aggressiveness on the incoming stream.
-  //
-  // Return value:
-  //   aggressiveness of VAD, running on the incoming stream. A more
-  //   aggressive mode means more audio frames will be labeled as in-active.
-  //   See audio_coding_module_typedefs.h for the definition of
-  //   ACMVADMode.
-  //
-  virtual ACMVADMode ReceiveVADMode() const = 0;
-
-  ///////////////////////////////////////////////////////////////////////////
   //   Codec specific
   //
 
@@ -904,8 +815,7 @@
   //   -1 if failed to set the maximum rate.
   //    0 if the maximum rate is set successfully.
   //
-  virtual int32_t SetISACMaxRate(
-      const uint32_t max_rate_bps) = 0;
+  virtual int SetISACMaxRate(int max_rate_bps) = 0;
 
   ///////////////////////////////////////////////////////////////////////////
   // int32_t SetISACMaxPayloadSize()
@@ -922,8 +832,7 @@
   //   -1 if failed to set the maximum  payload-size.
   //    0 if the given length is set successfully.
   //
-  virtual int32_t SetISACMaxPayloadSize(
-      const uint16_t max_payload_len_bytes) = 0;
+  virtual int SetISACMaxPayloadSize(int max_payload_len_bytes) = 0;
 
   ///////////////////////////////////////////////////////////////////////////
   // int32_t ConfigISACBandwidthEstimator()
@@ -950,9 +859,9 @@
   //    0 if the configuration was successfully applied.
   //
   virtual int32_t ConfigISACBandwidthEstimator(
-      const uint8_t init_frame_size_ms,
-      const uint16_t init_rate_bps,
-      const bool enforce_frame_size = false) = 0;
+      int init_frame_size_ms,
+      int init_rate_bps,
+      bool enforce_frame_size = false) = 0;
 
   ///////////////////////////////////////////////////////////////////////////
   //   statistics
@@ -960,7 +869,8 @@
 
   ///////////////////////////////////////////////////////////////////////////
   // int32_t  NetworkStatistics()
-  // Get network statistics.
+  // Get network statistics. Note that the internal statistics of NetEq are
+  // reset by this call.
   //
   // Input:
   //   -network_statistics : a structure that contains network statistics.
@@ -970,7 +880,7 @@
   //    0 if statistics are set successfully.
   //
   virtual int32_t NetworkStatistics(
-      ACMNetworkStatistics* network_statistics) const = 0;
+      ACMNetworkStatistics* network_statistics) = 0;
 
   //
   // Set an initial delay for playout.
diff --git a/webrtc/modules/audio_coding/main/source/acm_amr.cc b/webrtc/modules/audio_coding/main/source/acm_amr.cc
index 5590970..d398607 100644
--- a/webrtc/modules/audio_coding/main/source/acm_amr.cc
+++ b/webrtc/modules/audio_coding/main/source/acm_amr.cc
@@ -11,7 +11,7 @@
 #include "webrtc/modules/audio_coding/main/source/acm_amr.h"
 
 #include "webrtc/modules/audio_coding/main/interface/audio_coding_module_typedefs.h"
-#include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
+#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h"
 #include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
 #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
 #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
diff --git a/webrtc/modules/audio_coding/main/source/acm_amrwb.cc b/webrtc/modules/audio_coding/main/source/acm_amrwb.cc
index e2b7635..8b1b58d 100644
--- a/webrtc/modules/audio_coding/main/source/acm_amrwb.cc
+++ b/webrtc/modules/audio_coding/main/source/acm_amrwb.cc
@@ -11,7 +11,7 @@
 #include "webrtc/modules/audio_coding/main/source/acm_amrwb.h"
 
 #include "webrtc/modules/audio_coding/main/interface/audio_coding_module_typedefs.h"
-#include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
+#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h"
 #include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
 #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
 #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
diff --git a/webrtc/modules/audio_coding/main/source/acm_celt.cc b/webrtc/modules/audio_coding/main/source/acm_celt.cc
index 81a0346..3b83814 100644
--- a/webrtc/modules/audio_coding/main/source/acm_celt.cc
+++ b/webrtc/modules/audio_coding/main/source/acm_celt.cc
@@ -10,7 +10,7 @@
 
 #include "webrtc/modules/audio_coding/main/source/acm_celt.h"
 
-#include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
+#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h"
 #include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
 #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
 #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
diff --git a/webrtc/modules/audio_coding/main/source/acm_cng.cc b/webrtc/modules/audio_coding/main/source/acm_cng.cc
index 57c48cd..6f3a505 100644
--- a/webrtc/modules/audio_coding/main/source/acm_cng.cc
+++ b/webrtc/modules/audio_coding/main/source/acm_cng.cc
@@ -12,7 +12,7 @@
 
 #include "webrtc/modules/audio_coding/codecs/cng/include/webrtc_cng.h"
 #include "webrtc/modules/audio_coding/main/source/acm_codec_database.h"
-#include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
+#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h"
 #include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
 #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
 #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
diff --git a/webrtc/modules/audio_coding/main/source/acm_codec_database.cc b/webrtc/modules/audio_coding/main/source/acm_codec_database.cc
index c3a54d9..138effd 100644
--- a/webrtc/modules/audio_coding/main/source/acm_codec_database.cc
+++ b/webrtc/modules/audio_coding/main/source/acm_codec_database.cc
@@ -17,7 +17,7 @@
 // references, where appropriate.
 #include "webrtc/modules/audio_coding/main/source/acm_codec_database.h"
 
-#include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
+#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h"
 #include "webrtc/system_wrappers/interface/trace.h"
 
 // Includes needed to create the codecs.
diff --git a/webrtc/modules/audio_coding/main/source/acm_common_defs.h b/webrtc/modules/audio_coding/main/source/acm_common_defs.h
deleted file mode 100644
index ecc41f8..0000000
--- a/webrtc/modules/audio_coding/main/source/acm_common_defs.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- *  Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
- *
- *  Use of this source code is governed by a BSD-style license
- *  that can be found in the LICENSE file in the root of the source
- *  tree. An additional intellectual property rights grant can be found
- *  in the file PATENTS.  All contributing project authors may
- *  be found in the AUTHORS file in the root of the source tree.
- */
-
-#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_COMMON_DEFS_H_
-#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_COMMON_DEFS_H_
-
-#include <string.h>
-
-#include "webrtc/common_types.h"
-#include "webrtc/engine_configurations.h"
-#include "webrtc/modules/audio_coding/main/interface/audio_coding_module_typedefs.h"
-#include "webrtc/typedefs.h"
-
-// Checks for enabled codecs, we prevent enabling codecs which are not
-// compatible.
-#if ((defined WEBRTC_CODEC_ISAC) && (defined WEBRTC_CODEC_ISACFX))
-#error iSAC and iSACFX codecs cannot be enabled at the same time
-#endif
-
-namespace webrtc {
-
-namespace acm1 {
-
-// 60 ms is the maximum block size we support. An extra 20 ms is considered
-// for safety if process() method is not called when it should be, i.e. we
-// accept 20 ms of jitter. 80 ms @ 48 kHz (full-band) stereo is 7680 samples.
-#define AUDIO_BUFFER_SIZE_W16  7680
-
-// There is one timestamp per each 10 ms of audio
-// the audio buffer, at max, may contain 32 blocks of 10ms
-// audio if the sampling frequency is 8000 Hz (80 samples per block).
-// Therefore, The size of the buffer where we keep timestamps
-// is defined as follows
-#define TIMESTAMP_BUFFER_SIZE_W32  (AUDIO_BUFFER_SIZE_W16/80)
-
-// The maximum size of a payload, that is 60 ms of PCM-16 @ 32 kHz stereo
-#define MAX_PAYLOAD_SIZE_BYTE   7680
-
-// General codec specific defines
-const int kIsacWbDefaultRate = 32000;
-const int kIsacSwbDefaultRate = 56000;
-const int kIsacPacSize480 = 480;
-const int kIsacPacSize960 = 960;
-const int kIsacPacSize1440 = 1440;
-
-// An encoded bit-stream is labeled by one of the following enumerators.
-//
-//   kNoEncoding              : There has been no encoding.
-//   kActiveNormalEncoded     : Active audio frame coded by the codec.
-//   kPassiveNormalEncoded    : Passive audio frame coded by the codec.
-//   kPassiveDTXNB            : Passive audio frame coded by narrow-band CN.
-//   kPassiveDTXWB            : Passive audio frame coded by wide-band CN.
-//   kPassiveDTXSWB           : Passive audio frame coded by super-wide-band CN.
-//   kPassiveDTXFB            : Passive audio frame coded by full-band CN.
-enum WebRtcACMEncodingType {
-  kNoEncoding,
-  kActiveNormalEncoded,
-  kPassiveNormalEncoded,
-  kPassiveDTXNB,
-  kPassiveDTXWB,
-  kPassiveDTXSWB,
-  kPassiveDTXFB
-};
-
-// A structure which contains codec parameters. For instance, used when
-// initializing encoder and decoder.
-//
-//   codec_inst: c.f. common_types.h
-//   enable_dtx: set true to enable DTX. If codec does not have
-//               internal DTX, this will enable VAD.
-//   enable_vad: set true to enable VAD.
-//   vad_mode: VAD mode, c.f. audio_coding_module_typedefs.h
-//             for possible values.
-struct WebRtcACMCodecParams {
-  CodecInst codec_inst;
-  bool enable_dtx;
-  bool enable_vad;
-  ACMVADMode vad_mode;
-};
-
-// A structure that encapsulates audio buffer and related parameters
-// used for synchronization of audio of two ACMs.
-//
-//   in_audio: same as ACMGenericCodec::in_audio_
-//   in_audio_ix_read: same as ACMGenericCodec::in_audio_ix_read_
-//   in_audio_ix_write: same as ACMGenericCodec::in_audio_ix_write_
-//   in_timestamp: same as ACMGenericCodec::in_timestamp_
-//   in_timestamp_ix_write: same as ACMGenericCodec::in_timestamp_ix_write_
-//   last_timestamp: same as ACMGenericCodec::last_timestamp_
-//   last_in_timestamp: same as AudioCodingModuleImpl::last_in_timestamp_
-//
-struct WebRtcACMAudioBuff {
-  int16_t in_audio[AUDIO_BUFFER_SIZE_W16];
-  int16_t in_audio_ix_read;
-  int16_t in_audio_ix_write;
-  uint32_t in_timestamp[TIMESTAMP_BUFFER_SIZE_W32];
-  int16_t in_timestamp_ix_write;
-  uint32_t last_timestamp;
-  uint32_t last_in_timestamp;
-};
-
-}  // namespace acm1
-
-}  // namespace webrtc
-
-#endif  // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_COMMON_DEFS_H_
diff --git a/webrtc/modules/audio_coding/main/source/acm_dtmf_playout.cc b/webrtc/modules/audio_coding/main/source/acm_dtmf_playout.cc
index c8dea71..32195e6 100644
--- a/webrtc/modules/audio_coding/main/source/acm_dtmf_playout.cc
+++ b/webrtc/modules/audio_coding/main/source/acm_dtmf_playout.cc
@@ -10,7 +10,7 @@
 
 #include "webrtc/modules/audio_coding/main/source/acm_dtmf_playout.h"
 
-#include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
+#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h"
 #include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
 #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
 #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
diff --git a/webrtc/modules/audio_coding/main/source/acm_g722.cc b/webrtc/modules/audio_coding/main/source/acm_g722.cc
index 5368b35..1c19109 100644
--- a/webrtc/modules/audio_coding/main/source/acm_g722.cc
+++ b/webrtc/modules/audio_coding/main/source/acm_g722.cc
@@ -12,7 +12,7 @@
 
 #include "webrtc/modules/audio_coding/codecs/g722/include/g722_interface.h"
 #include "webrtc/modules/audio_coding/main/source/acm_codec_database.h"
-#include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
+#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h"
 #include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
 #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
 #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
diff --git a/webrtc/modules/audio_coding/main/source/acm_g7221.cc b/webrtc/modules/audio_coding/main/source/acm_g7221.cc
index c9074ac..ed172fd 100644
--- a/webrtc/modules/audio_coding/main/source/acm_g7221.cc
+++ b/webrtc/modules/audio_coding/main/source/acm_g7221.cc
@@ -11,7 +11,7 @@
 #include "webrtc/modules/audio_coding/main/source/acm_g7221.h"
 
 #include "webrtc/modules/audio_coding/main/source/acm_codec_database.h"
-#include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
+#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h"
 #include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
 #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
 #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
diff --git a/webrtc/modules/audio_coding/main/source/acm_g7221c.cc b/webrtc/modules/audio_coding/main/source/acm_g7221c.cc
index 91071e9..96caba0 100644
--- a/webrtc/modules/audio_coding/main/source/acm_g7221c.cc
+++ b/webrtc/modules/audio_coding/main/source/acm_g7221c.cc
@@ -11,7 +11,7 @@
 #include "webrtc/modules/audio_coding/main/source/acm_g7221c.h"
 
 #include "webrtc/modules/audio_coding/main/source/acm_codec_database.h"
-#include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
+#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h"
 #include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
 #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
 #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
diff --git a/webrtc/modules/audio_coding/main/source/acm_g729.cc b/webrtc/modules/audio_coding/main/source/acm_g729.cc
index 5b75ab9..406bb61 100644
--- a/webrtc/modules/audio_coding/main/source/acm_g729.cc
+++ b/webrtc/modules/audio_coding/main/source/acm_g729.cc
@@ -10,7 +10,7 @@
 
 #include "webrtc/modules/audio_coding/main/source/acm_g729.h"
 
-#include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
+#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h"
 #include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
 #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
 #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
diff --git a/webrtc/modules/audio_coding/main/source/acm_g7291.cc b/webrtc/modules/audio_coding/main/source/acm_g7291.cc
index fd241b3..0da6c99 100644
--- a/webrtc/modules/audio_coding/main/source/acm_g7291.cc
+++ b/webrtc/modules/audio_coding/main/source/acm_g7291.cc
@@ -10,7 +10,7 @@
 
 #include "webrtc/modules/audio_coding/main/source/acm_g7291.h"
 
-#include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
+#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h"
 #include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
 #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
 #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
diff --git a/webrtc/modules/audio_coding/main/source/acm_generic_codec.cc b/webrtc/modules/audio_coding/main/source/acm_generic_codec.cc
index 52f5114..6c43301 100644
--- a/webrtc/modules/audio_coding/main/source/acm_generic_codec.cc
+++ b/webrtc/modules/audio_coding/main/source/acm_generic_codec.cc
@@ -16,7 +16,7 @@
 #include "webrtc/common_audio/vad/include/webrtc_vad.h"
 #include "webrtc/modules/audio_coding/codecs/cng/include/webrtc_cng.h"
 #include "webrtc/modules/audio_coding/main/source/acm_codec_database.h"
-#include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
+#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h"
 #include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
 #include "webrtc/system_wrappers/interface/trace.h"
 
diff --git a/webrtc/modules/audio_coding/main/source/acm_generic_codec.h b/webrtc/modules/audio_coding/main/source/acm_generic_codec.h
index 3951a94..d6403f5 100644
--- a/webrtc/modules/audio_coding/main/source/acm_generic_codec.h
+++ b/webrtc/modules/audio_coding/main/source/acm_generic_codec.h
@@ -12,7 +12,7 @@
 #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_GENERIC_CODEC_H_
 
 #include "webrtc/modules/audio_coding/main/interface/audio_coding_module_typedefs.h"
-#include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
+#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h"
 #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
 #include "webrtc/system_wrappers/interface/rw_lock_wrapper.h"
 #include "webrtc/system_wrappers/interface/trace.h"
diff --git a/webrtc/modules/audio_coding/main/source/acm_gsmfr.cc b/webrtc/modules/audio_coding/main/source/acm_gsmfr.cc
index 9fa0410..5ea0c56 100644
--- a/webrtc/modules/audio_coding/main/source/acm_gsmfr.cc
+++ b/webrtc/modules/audio_coding/main/source/acm_gsmfr.cc
@@ -10,7 +10,7 @@
 
 #include "webrtc/modules/audio_coding/main/source/acm_gsmfr.h"
 
-#include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
+#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h"
 #include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
 #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
 #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
diff --git a/webrtc/modules/audio_coding/main/source/acm_ilbc.cc b/webrtc/modules/audio_coding/main/source/acm_ilbc.cc
index b47e750..0f8049e 100644
--- a/webrtc/modules/audio_coding/main/source/acm_ilbc.cc
+++ b/webrtc/modules/audio_coding/main/source/acm_ilbc.cc
@@ -9,7 +9,7 @@
  */
 #include "webrtc/modules/audio_coding/main/source/acm_ilbc.h"
 
-#include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
+#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h"
 #include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
 #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
 #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
diff --git a/webrtc/modules/audio_coding/main/source/acm_isac.cc b/webrtc/modules/audio_coding/main/source/acm_isac.cc
index b9316d6..61fa32f 100644
--- a/webrtc/modules/audio_coding/main/source/acm_isac.cc
+++ b/webrtc/modules/audio_coding/main/source/acm_isac.cc
@@ -10,7 +10,7 @@
 #include "webrtc/modules/audio_coding/main/source/acm_isac.h"
 
 #include "webrtc/modules/audio_coding/main/source/acm_codec_database.h"
-#include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
+#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h"
 #include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
 #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
 #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
diff --git a/webrtc/modules/audio_coding/main/source/acm_opus.cc b/webrtc/modules/audio_coding/main/source/acm_opus.cc
index 3a619d0..413f371 100644
--- a/webrtc/modules/audio_coding/main/source/acm_opus.cc
+++ b/webrtc/modules/audio_coding/main/source/acm_opus.cc
@@ -11,7 +11,7 @@
 #include "webrtc/modules/audio_coding/main/source/acm_opus.h"
 
 #include "webrtc/modules/audio_coding/main/source/acm_codec_database.h"
-#include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
+#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h"
 #include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
 #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
 #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
diff --git a/webrtc/modules/audio_coding/main/source/acm_pcm16b.cc b/webrtc/modules/audio_coding/main/source/acm_pcm16b.cc
index b0032b8..6fe12f7 100644
--- a/webrtc/modules/audio_coding/main/source/acm_pcm16b.cc
+++ b/webrtc/modules/audio_coding/main/source/acm_pcm16b.cc
@@ -11,7 +11,7 @@
 #include "webrtc/modules/audio_coding/main/source/acm_pcm16b.h"
 
 #include "webrtc/modules/audio_coding/main/source/acm_codec_database.h"
-#include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
+#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h"
 #include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
 #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
 #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
diff --git a/webrtc/modules/audio_coding/main/source/acm_pcma.cc b/webrtc/modules/audio_coding/main/source/acm_pcma.cc
index c646417..9e5514a 100644
--- a/webrtc/modules/audio_coding/main/source/acm_pcma.cc
+++ b/webrtc/modules/audio_coding/main/source/acm_pcma.cc
@@ -11,7 +11,7 @@
 #include "webrtc/modules/audio_coding/main/source/acm_pcma.h"
 
 #include "webrtc/modules/audio_coding/codecs/g711/include/g711_interface.h"
-#include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
+#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h"
 #include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
 #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
 #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
diff --git a/webrtc/modules/audio_coding/main/source/acm_pcmu.cc b/webrtc/modules/audio_coding/main/source/acm_pcmu.cc
index 5b6a457..6f4eb27 100644
--- a/webrtc/modules/audio_coding/main/source/acm_pcmu.cc
+++ b/webrtc/modules/audio_coding/main/source/acm_pcmu.cc
@@ -11,7 +11,7 @@
 #include "webrtc/modules/audio_coding/main/source/acm_pcmu.h"
 
 #include "webrtc/modules/audio_coding/codecs/g711/include/g711_interface.h"
-#include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
+#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h"
 #include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
 #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
 #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
diff --git a/webrtc/modules/audio_coding/main/source/acm_red.cc b/webrtc/modules/audio_coding/main/source/acm_red.cc
index bc44c72..0d8134c 100644
--- a/webrtc/modules/audio_coding/main/source/acm_red.cc
+++ b/webrtc/modules/audio_coding/main/source/acm_red.cc
@@ -10,7 +10,7 @@
 
 #include "webrtc/modules/audio_coding/main/source/acm_red.h"
 
-#include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
+#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h"
 #include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
 #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
 #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
diff --git a/webrtc/modules/audio_coding/main/source/acm_speex.cc b/webrtc/modules/audio_coding/main/source/acm_speex.cc
index 5752693..1567929 100644
--- a/webrtc/modules/audio_coding/main/source/acm_speex.cc
+++ b/webrtc/modules/audio_coding/main/source/acm_speex.cc
@@ -11,7 +11,7 @@
 #include "webrtc/modules/audio_coding/main/source/acm_speex.h"
 
 #include "webrtc/modules/audio_coding/main/source/acm_codec_database.h"
-#include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
+#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h"
 #include "webrtc/modules/audio_coding/main/source/acm_neteq.h"
 #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq.h"
 #include "webrtc/modules/audio_coding/neteq/interface/webrtc_neteq_help_macros.h"
diff --git a/webrtc/modules/audio_coding/main/source/audio_coding_module.cc b/webrtc/modules/audio_coding/main/source/audio_coding_module.cc
deleted file mode 100644
index 9461a1f..0000000
--- a/webrtc/modules/audio_coding/main/source/audio_coding_module.cc
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- *  Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
- *
- *  Use of this source code is governed by a BSD-style license
- *  that can be found in the LICENSE file in the root of the source
- *  tree. An additional intellectual property rights grant can be found
- *  in the file PATENTS.  All contributing project authors may
- *  be found in the AUTHORS file in the root of the source tree.
- */
-
-#include "webrtc/modules/audio_coding/main/interface/audio_coding_module.h"
-
-#include "webrtc/common_types.h"
-#include "webrtc/modules/audio_coding/main/source/acm_codec_database.h"
-#include "webrtc/modules/audio_coding/main/source/acm_dtmf_detection.h"
-#include "webrtc/modules/audio_coding/main/source/audio_coding_module_impl.h"
-#include "webrtc/system_wrappers/interface/clock.h"
-#include "webrtc/system_wrappers/interface/trace.h"
-
-namespace webrtc {
-
-// Create module
-AudioCodingModule* AudioCodingModule::Create(const int32_t id) {
-  return new acm1::AudioCodingModuleImpl(id, Clock::GetRealTimeClock());
-}
-
-// Used for testing by inserting a simulated clock. ACM will not destroy the
-// injected |clock| the client has to take care of that.
-AudioCodingModule* AudioCodingModule::Create(const int32_t id,
-                                             Clock* clock) {
-  return new acm1::AudioCodingModuleImpl(id, clock);
-}
-
-// Destroy module
-void AudioCodingModule::Destroy(AudioCodingModule* module) {
-  delete static_cast<acm1::AudioCodingModuleImpl*>(module);
-}
-
-// Get number of supported codecs
-uint8_t AudioCodingModule::NumberOfCodecs() {
-  return static_cast<uint8_t>(acm1::ACMCodecDB::kNumCodecs);
-}
-
-// Get supported codec param with id
-int32_t AudioCodingModule::Codec(uint8_t list_id,
-                                 CodecInst* codec) {
-  // Get the codec settings for the codec with the given list ID
-  return acm1::ACMCodecDB::Codec(list_id, codec);
-}
-
-// Get supported codec Param with name, frequency and number of channels.
-int32_t AudioCodingModule::Codec(const char* payload_name,
-                                 CodecInst* codec, int sampling_freq_hz,
-                                 int channels) {
-  int codec_id;
-
-  // Get the id of the codec from the database.
-  codec_id = acm1::ACMCodecDB::CodecId(payload_name, sampling_freq_hz,
-                                       channels);
-  if (codec_id < 0) {
-    // We couldn't find a matching codec, set the parameters to unacceptable
-    // values and return.
-    codec->plname[0] = '\0';
-    codec->pltype = -1;
-    codec->pacsize = 0;
-    codec->rate = 0;
-    codec->plfreq = 0;
-    return -1;
-  }
-
-  // Get default codec settings.
-  acm1::ACMCodecDB::Codec(codec_id, codec);
-
-  // Keep the number of channels from the function call. For most codecs it
-  // will be the same value as in default codec settings, but not for all.
-  codec->channels = channels;
-
-  return 0;
-}
-
-// Get supported codec Index with name, frequency and number of channels.
-int32_t AudioCodingModule::Codec(const char* payload_name,
-                                 int sampling_freq_hz, int channels) {
-  return acm1::ACMCodecDB::CodecId(payload_name, sampling_freq_hz, channels);
-}
-
-// Checks the validity of the parameters of the given codec
-bool AudioCodingModule::IsCodecValid(const CodecInst& codec) {
-  int mirror_id;
-
-  int codec_number = acm1::ACMCodecDB::CodecNumber(&codec, &mirror_id);
-
-  if (codec_number < 0) {
-    WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, -1,
-                 "Invalid codec settings.");
-    return false;
-  } else {
-    return true;
-  }
-}
-
-AudioCodingModule* AudioCodingModuleFactory::Create(int id) const {
-  return new acm1::AudioCodingModuleImpl(static_cast<int32_t>(id),
-                                         Clock::GetRealTimeClock());
-}
-
-AudioCodingModule* NewAudioCodingModuleFactory::Create(int id) const {
-  // TODO(minyue): return new AudioCodingModuleImpl (new version).
-  return NULL;
-}
-
-}  // namespace webrtc
diff --git a/webrtc/modules/audio_coding/main/source/audio_coding_module.gypi b/webrtc/modules/audio_coding/main/source/audio_coding_module.gypi
index 1709c17..94c3bcb 100644
--- a/webrtc/modules/audio_coding/main/source/audio_coding_module.gypi
+++ b/webrtc/modules/audio_coding/main/source/audio_coding_module.gypi
@@ -37,6 +37,7 @@
       ],
       'dependencies': [
         '<@(audio_coding_dependencies)',
+        'acm2',
       ],
       'include_dirs': [
         '../interface',
@@ -100,7 +101,6 @@
         'acm_red.h',
         'acm_resampler.cc',
         'acm_resampler.h',
-        'audio_coding_module.cc',
         'audio_coding_module_impl.cc',
         'audio_coding_module_impl.h',
         'nack.cc',
@@ -146,4 +146,7 @@
       ],
     }],
   ],
+  'includes': [
+    '../acm2/audio_coding_module.gypi',
+  ],
 }
diff --git a/webrtc/modules/audio_coding/main/source/audio_coding_module_impl.cc b/webrtc/modules/audio_coding/main/source/audio_coding_module_impl.cc
index 93b21e6..f5f8450 100644
--- a/webrtc/modules/audio_coding/main/source/audio_coding_module_impl.cc
+++ b/webrtc/modules/audio_coding/main/source/audio_coding_module_impl.cc
@@ -17,7 +17,7 @@
 
 #include "webrtc/engine_configurations.h"
 #include "webrtc/modules/audio_coding/main/source/acm_codec_database.h"
-#include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
+#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h"
 #include "webrtc/modules/audio_coding/main/source/acm_dtmf_detection.h"
 #include "webrtc/modules/audio_coding/main/source/acm_generic_codec.h"
 #include "webrtc/modules/audio_coding/main/source/acm_resampler.h"
@@ -1262,64 +1262,6 @@
   return 0;
 }
 
-// Used by the module to deliver messages to the codec module/application
-// AVT(DTMF).
-int32_t AudioCodingModuleImpl::RegisterIncomingMessagesCallback(
-#ifndef WEBRTC_DTMF_DETECTION
-    AudioCodingFeedback* /* incoming_message */,
-    const ACMCountries /* cpt */) {
-  return -1;
-#else
-    AudioCodingFeedback* incoming_message,
-    const ACMCountries cpt) {
-  int16_t status = 0;
-
-  // Enter the critical section for callback.
-  {
-    CriticalSectionScoped lock(callback_crit_sect_);
-    dtmf_callback_ = incoming_message;
-  }
-  // Enter the ACM critical section to set up the DTMF class.
-  {
-    CriticalSectionScoped lock(acm_crit_sect_);
-    // Check if the call is to disable or enable the callback.
-    if (incoming_message == NULL) {
-      // Callback is disabled, delete DTMF-detector class.
-      if (dtmf_detector_ != NULL) {
-        delete dtmf_detector_;
-        dtmf_detector_ = NULL;
-      }
-      status = 0;
-    } else {
-      status = 0;
-      if (dtmf_detector_ == NULL) {
-        dtmf_detector_ = new ACMDTMFDetection;
-        if (dtmf_detector_ == NULL) {
-          status = -1;
-        }
-      }
-      if (status >= 0) {
-        status = dtmf_detector_->Enable(cpt);
-        if (status < 0) {
-          // Failed to initialize if DTMF-detection was not enabled before,
-          // delete the class, and set the callback to NULL and return -1.
-          delete dtmf_detector_;
-          dtmf_detector_ = NULL;
-        }
-      }
-    }
-  }
-  // Check if we failed in setting up the DTMF-detector class.
-  if ((status < 0)) {
-    // We failed, we cannot have the callback.
-    CriticalSectionScoped lock(callback_crit_sect_);
-    dtmf_callback_ = NULL;
-  }
-
-  return status;
-#endif
-}
-
 // Add 10MS of raw (PCM) audio data to the encoder.
 int32_t AudioCodingModuleImpl::Add10MsData(
     const AudioFrame& audio_frame) {
@@ -2463,26 +2405,11 @@
 }
 
 /////////////////////////////////////////
-//   (CNG) Comfort Noise Generation
-//   Generate comfort noise when receiving DTX packets
-//
-
-// Get VAD aggressiveness on the incoming stream
-ACMVADMode AudioCodingModuleImpl::ReceiveVADMode() const {
-  return neteq_.vad_mode();
-}
-
-// Configure VAD aggressiveness on the incoming stream.
-int16_t AudioCodingModuleImpl::SetReceiveVADMode(const ACMVADMode mode) {
-  return neteq_.SetVADMode(mode);
-}
-
-/////////////////////////////////////////
 //   Statistics
 //
 
 int32_t AudioCodingModuleImpl::NetworkStatistics(
-    ACMNetworkStatistics* statistics) const {
+    ACMNetworkStatistics* statistics) {
   int32_t status;
   status = neteq_.NetworkStatistics(statistics);
   return status;
@@ -2722,8 +2649,7 @@
   return 0;
 }
 
-int32_t AudioCodingModuleImpl::SetISACMaxRate(
-    const uint32_t max_bit_per_sec) {
+int AudioCodingModuleImpl::SetISACMaxRate(int max_bit_per_sec) {
   CriticalSectionScoped lock(acm_crit_sect_);
 
   if (!HaveValidEncoder("SetISACMaxRate")) {
@@ -2733,8 +2659,7 @@
   return codecs_[current_send_codec_idx_]->SetISACMaxRate(max_bit_per_sec);
 }
 
-int32_t AudioCodingModuleImpl::SetISACMaxPayloadSize(
-    const uint16_t max_size_bytes) {
+int AudioCodingModuleImpl::SetISACMaxPayloadSize(int max_size_bytes) {
   CriticalSectionScoped lock(acm_crit_sect_);
 
   if (!HaveValidEncoder("SetISACMaxPayloadSize")) {
@@ -2746,9 +2671,9 @@
 }
 
 int32_t AudioCodingModuleImpl::ConfigISACBandwidthEstimator(
-    const uint8_t frame_size_ms,
-    const uint16_t rate_bit_per_sec,
-    const bool enforce_frame_size) {
+    int frame_size_ms,
+    int rate_bit_per_sec,
+    bool enforce_frame_size) {
   CriticalSectionScoped lock(acm_crit_sect_);
 
   if (!HaveValidEncoder("ConfigISACBandwidthEstimator")) {
@@ -2759,21 +2684,6 @@
       frame_size_ms, rate_bit_per_sec, enforce_frame_size);
 }
 
-int32_t AudioCodingModuleImpl::SetBackgroundNoiseMode(
-    const ACMBackgroundNoiseMode mode) {
-  if ((mode < On) || (mode > Off)) {
-    WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, id_,
-                 "The specified background noise is out of range.\n");
-    return -1;
-  }
-  return neteq_.SetBackgroundNoiseMode(mode);
-}
-
-int32_t AudioCodingModuleImpl::BackgroundNoiseMode(
-    ACMBackgroundNoiseMode* mode) {
-  return neteq_.BackgroundNoiseMode(*mode);
-}
-
 int32_t AudioCodingModuleImpl::PlayoutTimestamp(
     uint32_t* timestamp) {
   WEBRTC_TRACE(webrtc::kTraceStream, webrtc::kTraceAudioCoding, id_,
@@ -2809,8 +2719,7 @@
   return true;
 }
 
-int32_t AudioCodingModuleImpl::UnregisterReceiveCodec(
-    const int16_t payload_type) {
+int AudioCodingModuleImpl::UnregisterReceiveCodec(uint8_t payload_type) {
   CriticalSectionScoped lock(acm_crit_sect_);
   int id;
 
diff --git a/webrtc/modules/audio_coding/main/source/audio_coding_module_impl.h b/webrtc/modules/audio_coding/main/source/audio_coding_module_impl.h
index 64afe4f..b63ae09 100644
--- a/webrtc/modules/audio_coding/main/source/audio_coding_module_impl.h
+++ b/webrtc/modules/audio_coding/main/source/audio_coding_module_impl.h
@@ -23,14 +23,14 @@
 
 namespace webrtc {
 
+struct WebRtcACMAudioBuff;
+struct WebRtcACMCodecParams;
 class CriticalSectionWrapper;
 class RWLockWrapper;
 class Clock;
 
 namespace acm1 {
 
-struct WebRtcACMAudioBuff;
-struct WebRtcACMCodecParams;
 class ACMDTMFDetection;
 class ACMGenericCodec;
 class Nack;
@@ -96,20 +96,9 @@
   // called to deliver the encoded buffers.
   int32_t RegisterTransportCallback(AudioPacketizationCallback* transport);
 
-  // Used by the module to deliver messages to the codec module/application
-  // AVT(DTMF).
-  int32_t RegisterIncomingMessagesCallback(
-      AudioCodingFeedback* incoming_message, const ACMCountries cpt);
-
   // Add 10 ms of raw (PCM) audio data to the encoder.
   int32_t Add10MsData(const AudioFrame& audio_frame);
 
-  // Set background noise mode for NetEQ, on, off or fade.
-  int32_t SetBackgroundNoiseMode(const ACMBackgroundNoiseMode mode);
-
-  // Get current background noise mode.
-  int32_t BackgroundNoiseMode(ACMBackgroundNoiseMode* mode);
-
   /////////////////////////////////////////
   // (FEC) Forward Error Correction
   //
@@ -134,12 +123,6 @@
 
   int32_t RegisterVADCallback(ACMVADCallback* vad_callback);
 
-  // Get VAD aggressiveness on the incoming stream.
-  ACMVADMode ReceiveVADMode() const;
-
-  // Configure VAD aggressiveness on the incoming stream.
-  int16_t SetReceiveVADMode(const ACMVADMode mode);
-
   /////////////////////////////////////////
   //   Receiver
   //
@@ -220,7 +203,7 @@
   //   Statistics
   //
 
-  int32_t NetworkStatistics(ACMNetworkStatistics* statistics) const;
+  int32_t NetworkStatistics(ACMNetworkStatistics* statistics);
 
   void DestructEncoderInst(void* inst);
 
@@ -243,16 +226,16 @@
 
   int32_t IsInternalDTXReplacedWithWebRtc(bool* uses_webrtc_dtx);
 
-  int32_t SetISACMaxRate(const uint32_t max_bit_per_sec);
+  int SetISACMaxRate(int max_bit_per_sec);
 
-  int32_t SetISACMaxPayloadSize(const uint16_t max_size_bytes);
+  int SetISACMaxPayloadSize(int max_size_bytes);
 
   int32_t ConfigISACBandwidthEstimator(
-      const uint8_t frame_size_ms,
-      const uint16_t rate_bit_per_sec,
-      const bool enforce_frame_size = false);
+      int frame_size_ms,
+      int rate_bit_per_sec,
+      bool enforce_frame_size = false);
 
-  int32_t UnregisterReceiveCodec(const int16_t payload_type);
+  int UnregisterReceiveCodec(uint8_t payload_type);
 
   std::vector<uint16_t> GetNackList(int round_trip_time_ms) const;
 
diff --git a/webrtc/modules/audio_coding/main/test/APITest.cc b/webrtc/modules/audio_coding/main/test/APITest.cc
index cb7115e..a9e2e71 100644
--- a/webrtc/modules/audio_coding/main/test/APITest.cc
+++ b/webrtc/modules/audio_coding/main/test/APITest.cc
@@ -22,7 +22,7 @@
 #include "testing/gtest/include/gtest/gtest.h"
 #include "webrtc/common_types.h"
 #include "webrtc/engine_configurations.h"
-#include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
+#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h"
 #include "webrtc/modules/audio_coding/main/test/utility.h"
 #include "webrtc/system_wrappers/interface/event_wrapper.h"
 #include "webrtc/system_wrappers/interface/thread_wrapper.h"
@@ -98,11 +98,6 @@
     _payloadUsed[n] = false;
   }
 
-  for (n = 0; n < 3; n++) {
-    _receiveVADActivityA[n] = 0;
-    _receiveVADActivityB[n] = 0;
-  }
-
   _movingDot[40] = '\0';
 
   for (int n = 0; n < 40; n++) {
@@ -352,7 +347,6 @@
     if (_writeToFile) {
       _outFileA.Write10MsData(audioFrame);
     }
-    _receiveVADActivityA[(int) audioFrame.vad_activity_]++;
   }
   return true;
 }
@@ -374,7 +368,6 @@
     if (_writeToFile) {
       _outFileB.Write10MsData(audioFrame);
     }
-    _receiveVADActivityB[(int) audioFrame.vad_activity_]++;
   }
   return true;
 }
@@ -458,7 +451,7 @@
   {
     WriteLockScoped cs(_apiTestRWLock);
     if (thread == 'A') {
-      _testNumA = (_testNumB + 1 + (rand() % 6)) % 7;
+      _testNumA = (_testNumB + 1 + (rand() % 4)) % 5;
       testNum = _testNumA;
 
       _movingDot[_dotPositionA] = ' ';
@@ -471,7 +464,7 @@
       _dotPositionA += _dotMoveDirectionA;
       _movingDot[_dotPositionA] = (_dotMoveDirectionA > 0) ? '>' : '<';
     } else {
-      _testNumB = (_testNumA + 1 + (rand() % 6)) % 7;
+      _testNumB = (_testNumA + 1 + (rand() % 4)) % 5;
       testNum = _testNumB;
 
       _movingDot[_dotPositionB] = ' ';
@@ -507,14 +500,6 @@
     case 4:
       TestRegisteration('A');
       break;
-    case 5:
-      TestReceiverVAD('A');
-      break;
-    case 6:
-#ifdef WEBRTC_DTMF_DETECTION
-      LookForDTMF('A');
-#endif
-      break;
     default:
       fprintf(stderr, "Wrong Test Number\n");
       getchar();
@@ -543,10 +528,6 @@
     // VAD TEST
     TestSendVAD('A');
     TestRegisteration('A');
-    TestReceiverVAD('A');
-#ifdef WEBRTC_DTMF_DETECTION
-    LookForDTMF('A');
-#endif
   }
   return true;
 }
@@ -981,18 +962,15 @@
 void APITest::TestPlayout(char receiveSide) {
   AudioCodingModule* receiveACM;
   AudioPlayoutMode* playoutMode = NULL;
-  ACMBackgroundNoiseMode* bgnMode = NULL;
   switch (receiveSide) {
     case 'A': {
       receiveACM = _acmA;
       playoutMode = &_playoutModeA;
-      bgnMode = &_bgnModeA;
       break;
     }
     case 'B': {
       receiveACM = _acmB;
       playoutMode = &_playoutModeB;
-      bgnMode = &_bgnModeB;
       break;
     }
     default:
@@ -1005,29 +983,6 @@
   CHECK_ERROR_MT(receiveFreqHz);
   CHECK_ERROR_MT(playoutFreqHz);
 
-  char bgnString[25];
-  switch (*bgnMode) {
-    case On: {
-      *bgnMode = Fade;
-      strncpy(bgnString, "Fade", 25);
-      break;
-    }
-    case Fade: {
-      *bgnMode = Off;
-      strncpy(bgnString, "OFF", 25);
-      break;
-    }
-    case Off: {
-      *bgnMode = On;
-      strncpy(bgnString, "ON", 25);
-      break;
-    }
-    default:
-      *bgnMode = On;
-      strncpy(bgnString, "ON", 25);
-  }
-  CHECK_ERROR_MT(receiveACM->SetBackgroundNoiseMode(*bgnMode));
-  bgnString[24] = '\0';
 
   char playoutString[25];
   switch (*playoutMode) {
@@ -1060,63 +1015,10 @@
     fprintf(stdout, "Receive Frequency....... %d Hz\n", receiveFreqHz);
     fprintf(stdout, "Playout Frequency....... %d Hz\n", playoutFreqHz);
     fprintf(stdout, "Audio Playout Mode...... %s\n", playoutString);
-    fprintf(stdout, "Background Noise Mode... %s\n", bgnString);
   }
 }
 
 // set/get receiver VAD status & mode.
-void APITest::TestReceiverVAD(char side) {
-  AudioCodingModule* myACM;
-  int* myReceiveVADActivity;
-
-  if (side == 'A') {
-    myACM = _acmA;
-    myReceiveVADActivity = _receiveVADActivityA;
-  } else {
-    myACM = _acmB;
-    myReceiveVADActivity = _receiveVADActivityB;
-  }
-
-  ACMVADMode mode = myACM->ReceiveVADMode();
-
-  CHECK_ERROR_MT(mode);
-
-  if (!_randomTest) {
-    fprintf(stdout, "\n\nCurrent Receive VAD at side %c\n", side);
-    fprintf(stdout, "----------------------------------\n");
-    fprintf(stdout, "mode.......... %d\n", (int) mode);
-    fprintf(stdout, "VAD Active.... %d\n", myReceiveVADActivity[0]);
-    fprintf(stdout, "VAD Passive... %d\n", myReceiveVADActivity[1]);
-    fprintf(stdout, "VAD Unknown... %d\n", myReceiveVADActivity[2]);
-  }
-
-  if (!_randomTest) {
-    fprintf(stdout, "\nChange Receive VAD at side %c\n\n", side);
-  }
-
-  switch (mode) {
-    case VADNormal:
-      mode = VADAggr;
-      break;
-    case VADLowBitrate:
-      mode = VADVeryAggr;
-      break;
-    case VADAggr:
-      mode = VADLowBitrate;
-      break;
-    case VADVeryAggr:
-      mode = VADNormal;
-      break;
-    default:
-      mode = VADNormal;
-
-      CHECK_ERROR_MT(myACM->SetReceiveVADMode(mode));
-  }
-  for (int n = 0; n < 3; n++) {
-    myReceiveVADActivity[n] = 0;
-  }
-}
-
 void APITest::TestSendVAD(char side) {
   if (_randomTest) {
     return;
@@ -1317,23 +1219,4 @@
   Wait(500);
 }
 
-void APITest::LookForDTMF(char side) {
-  if (!_randomTest) {
-    fprintf(stdout, "\n\nLooking for DTMF Signal in Side %c\n", side);
-    fprintf(stdout, "----------------------------------------\n");
-  }
-
-  if (side == 'A') {
-    _acmB->RegisterIncomingMessagesCallback(NULL);
-    _acmA->RegisterIncomingMessagesCallback(_dtmfCallback);
-    Wait(1000);
-    _acmA->RegisterIncomingMessagesCallback(NULL);
-  } else {
-    _acmA->RegisterIncomingMessagesCallback(NULL);
-    _acmB->RegisterIncomingMessagesCallback(_dtmfCallback);
-    Wait(1000);
-    _acmB->RegisterIncomingMessagesCallback(NULL);
-  }
-}
-
 }  // namespace webrtc
diff --git a/webrtc/modules/audio_coding/main/test/APITest.h b/webrtc/modules/audio_coding/main/test/APITest.h
index f29abf4..f9e9a91 100644
--- a/webrtc/modules/audio_coding/main/test/APITest.h
+++ b/webrtc/modules/audio_coding/main/test/APITest.h
@@ -56,9 +56,6 @@
   // Receiver Frequency, playout frequency.
   void TestPlayout(char receiveSide);
 
-  // set/get receiver VAD status & mode.
-  void TestReceiverVAD(char side);
-
   //
   void TestSendVAD(char side);
 
@@ -68,8 +65,6 @@
 
   void Wait(uint32_t waitLengthMs);
 
-  void LookForDTMF(char side);
-
   void RunTest(char thread);
 
   bool PushAudioRunA();
@@ -145,11 +140,6 @@
   AudioPlayoutMode _playoutModeA;
   AudioPlayoutMode _playoutModeB;
 
-  ACMBackgroundNoiseMode _bgnModeA;
-  ACMBackgroundNoiseMode _bgnModeB;
-
-  int _receiveVADActivityA[3];
-  int _receiveVADActivityB[3];
   bool _verbose;
 
   int _dotPositionA;
diff --git a/webrtc/modules/audio_coding/main/test/EncodeDecodeTest.cc b/webrtc/modules/audio_coding/main/test/EncodeDecodeTest.cc
index bab207c..1ee6abc 100644
--- a/webrtc/modules/audio_coding/main/test/EncodeDecodeTest.cc
+++ b/webrtc/modules/audio_coding/main/test/EncodeDecodeTest.cc
@@ -20,7 +20,7 @@
 #include "testing/gtest/include/gtest/gtest.h"
 #include "webrtc/common_types.h"
 #include "webrtc/modules/audio_coding/main/interface/audio_coding_module.h"
-#include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
+#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h"
 #include "webrtc/modules/audio_coding/main/test/utility.h"
 #include "webrtc/system_wrappers/interface/scoped_ptr.h"
 #include "webrtc/system_wrappers/interface/trace.h"
diff --git a/webrtc/modules/audio_coding/main/test/TestVADDTX.cc b/webrtc/modules/audio_coding/main/test/TestVADDTX.cc
index 620329b..29c9ade 100644
--- a/webrtc/modules/audio_coding/main/test/TestVADDTX.cc
+++ b/webrtc/modules/audio_coding/main/test/TestVADDTX.cc
@@ -16,7 +16,7 @@
 #include "webrtc/engine_configurations.h"
 #include "webrtc/modules/audio_coding/main/interface/audio_coding_module_typedefs.h"
 #include "webrtc/modules/audio_coding/main/test/utility.h"
-#include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
+#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h"
 #include "webrtc/test/testsupport/fileutils.h"
 #include "webrtc/system_wrappers/interface/trace.h"
 
diff --git a/webrtc/modules/audio_coding/main/test/delay_test.cc b/webrtc/modules/audio_coding/main/test/delay_test.cc
index 57a912a..1a0f8f8 100644
--- a/webrtc/modules/audio_coding/main/test/delay_test.cc
+++ b/webrtc/modules/audio_coding/main/test/delay_test.cc
@@ -20,7 +20,7 @@
 #include "webrtc/common_types.h"
 #include "webrtc/engine_configurations.h"
 #include "webrtc/modules/audio_coding/main/interface/audio_coding_module_typedefs.h"
-#include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
+#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h"
 #include "webrtc/modules/audio_coding/main/test/Channel.h"
 #include "webrtc/modules/audio_coding/main/test/PCMFile.h"
 #include "webrtc/modules/audio_coding/main/test/utility.h"
diff --git a/webrtc/modules/audio_coding/main/test/dual_stream_unittest.cc b/webrtc/modules/audio_coding/main/test/dual_stream_unittest.cc
index d8cdce5..85b1c8e 100644
--- a/webrtc/modules/audio_coding/main/test/dual_stream_unittest.cc
+++ b/webrtc/modules/audio_coding/main/test/dual_stream_unittest.cc
@@ -8,7 +8,7 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
-#include "../source/acm_common_defs.h"
+#include "../acm2/acm_common_defs.h"
 #include "gtest/gtest.h"
 #include "audio_coding_module.h"
 #include "PCMFile.h"
diff --git a/webrtc/modules/audio_coding/main/test/iSACTest.cc b/webrtc/modules/audio_coding/main/test/iSACTest.cc
index 50809fc..26f5b1f 100644
--- a/webrtc/modules/audio_coding/main/test/iSACTest.cc
+++ b/webrtc/modules/audio_coding/main/test/iSACTest.cc
@@ -23,7 +23,7 @@
 #include <time.h>
 #endif
 
-#include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
+#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h"
 #include "webrtc/modules/audio_coding/main/test/utility.h"
 #include "webrtc/system_wrappers/interface/event_wrapper.h"
 #include "webrtc/system_wrappers/interface/tick_util.h"
diff --git a/webrtc/modules/audio_coding/main/test/utility.cc b/webrtc/modules/audio_coding/main/test/utility.cc
index 62594ea..4b69640 100644
--- a/webrtc/modules/audio_coding/main/test/utility.cc
+++ b/webrtc/modules/audio_coding/main/test/utility.cc
@@ -17,7 +17,7 @@
 #include "testing/gtest/include/gtest/gtest.h"
 #include "webrtc/common_types.h"
 #include "webrtc/modules/audio_coding/main/interface/audio_coding_module.h"
-#include "webrtc/modules/audio_coding/main/source/acm_common_defs.h"
+#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h"
 
 #define NUM_CODECS_WITH_FIXED_PAYLOAD_TYPE 13