Switch to using AudioEncoderIsac instead of ACMISAC

This change switches from the old codec wrapper ACMISAC to the new
AudioEncoderIsac wrapped in an ACMGenericCodecWrapper.

This is also the CL where the old codec for producing redundancy (RED)
is inactivated. All RED payloads are now produces through the
AudioEncoderCopyRed or AudioEncoderIsacRed classes.

BUG=4228
TEST=Please, try the iSAC codec extensively.
COAUTHOR=kwiberg@webrtc.org
R=tina.legrand@webrtc.org

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

Cr-Commit-Position: refs/heads/master@{#8342}
git-svn-id: http://webrtc.googlecode.com/svn/trunk@8342 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 c366295..17d49a9 100644
--- a/webrtc/modules/audio_coding/main/acm2/acm_codec_database.cc
+++ b/webrtc/modules/audio_coding/main/acm2/acm_codec_database.cc
@@ -578,7 +578,9 @@
   // All we have support for right now.
   if (!STR_CASE_CMP(codec_inst.plname, "ISAC")) {
 #if (defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX))
-    return new ACMISAC(kISAC, enable_red);
+    return new ACMGenericCodecWrapper(codec_inst, cng_pt_nb, cng_pt_wb,
+                                      cng_pt_swb, cng_pt_fb, enable_red,
+                                      red_payload_type);
 #endif
   } else if (!STR_CASE_CMP(codec_inst.plname, "PCMU") ||
              !STR_CASE_CMP(codec_inst.plname, "PCMA")) {
diff --git a/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.cc b/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.cc
index fc1191a..1837be6 100644
--- a/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.cc
+++ b/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.cc
@@ -270,7 +270,6 @@
   FrameType frame_type = kAudioFrameSpeech;
   uint8_t current_payload_type = 0;
   bool has_data_to_send = false;
-  bool red_active = false;
   RTPFragmentationHeader my_fragmentation;
 
   // Keep the scope of the ACM critical section limited.
@@ -295,43 +294,39 @@
     } else {
       switch (encoding_type) {
         case kNoEncoding: {
-          current_payload_type = previous_pltype_;
+          FATAL() << "This case is no longer valid.";
           frame_type = kFrameEmpty;
           length_bytes = 0;
           break;
         }
         case kActiveNormalEncoded:
         case kPassiveNormalEncoded: {
-          current_payload_type = static_cast<uint8_t>(send_codec_inst_.pltype);
           frame_type = kAudioFrameSpeech;
           break;
         }
         case kPassiveDTXNB: {
-          current_payload_type = cng_nb_pltype_;
           frame_type = kAudioFrameCN;
           is_first_red_ = true;
           break;
         }
         case kPassiveDTXWB: {
-          current_payload_type = cng_wb_pltype_;
           frame_type = kAudioFrameCN;
           is_first_red_ = true;
           break;
         }
         case kPassiveDTXSWB: {
-          current_payload_type = cng_swb_pltype_;
           frame_type = kAudioFrameCN;
           is_first_red_ = true;
           break;
         }
         case kPassiveDTXFB: {
-          current_payload_type = cng_fb_pltype_;
           frame_type = kAudioFrameCN;
           is_first_red_ = true;
           break;
         }
       }
       has_data_to_send = true;
+      current_payload_type = encoded_info.payload_type;
       previous_pltype_ = current_payload_type;
 
       ConvertEncodedInfoToFragmentationHeader(encoded_info, &my_fragmentation);
@@ -348,8 +343,9 @@
       // have been switched to the new AudioEncoder interface.
       if ((codecs_[current_send_codec_idx_]->ExternalRedNeeded()) &&
           ((encoding_type == kActiveNormalEncoded) ||
-              (encoding_type == kPassiveNormalEncoded))) {
+           (encoding_type == kPassiveNormalEncoded))) {
         DCHECK(encoded_info.redundant.empty());
+        FATAL() << "Don't go here!";
         // RED is enabled within this scope.
         //
         // Note that, a special solution exists for iSAC since it is the only
@@ -389,7 +385,6 @@
         //
         //  Hence, even if every second packet is dropped, perfect
         //  reconstruction is possible.
-        red_active = true;
 
         has_data_to_send = false;
         // Skip the following part for the first packet in a RED session.
@@ -457,7 +452,7 @@
     CriticalSectionScoped lock(callback_crit_sect_);
 
     if (packetization_callback_ != NULL) {
-      if (red_active || my_fragmentation.fragmentationVectorSize > 0) {
+      if (my_fragmentation.fragmentationVectorSize > 0) {
         // Callback with payload data, including redundant data (RED).
         packetization_callback_->SendData(frame_type, current_payload_type,
                                           rtp_timestamp, stream, length_bytes,
diff --git a/webrtc/modules/audio_coding/main/acm2/audio_coding_module_unittest.cc b/webrtc/modules/audio_coding/main/acm2/audio_coding_module_unittest.cc
index 4ee5339..5185c12 100644
--- a/webrtc/modules/audio_coding/main/acm2/audio_coding_module_unittest.cc
+++ b/webrtc/modules/audio_coding/main/acm2/audio_coding_module_unittest.cc
@@ -809,15 +809,14 @@
   ASSERT_NO_FATAL_FAILURE(
       SetUpTest(acm2::ACMCodecDB::kISACSWB, 1, 104, 960, 960));
   Run(AcmReceiverBitExactness::PlatformChecksum(
-          "98d960600eb4ddb3fcbe11f5057ddfd7",
+          "2b3c387d06f00b7b7aad4c9be56fb83d",
           "",
-          "2f6dfe142f735f1d96f6bd86d2526f42"),
+          "5683b58da0fbf2063c7adc2e6bfb3fb8"),
       AcmReceiverBitExactness::PlatformChecksum(
-          "cc9d2d86a71d6f99f97680a5c27e2762",
+          "bcc2041e7744c7ebd9f701866856849c",
           "",
-          "7b214fc3a5e33d68bf30e77969371f31"),
-      33,
-      test::AcmReceiveTest::kMonoOutput);
+          "ce86106a93419aefb063097108ec94ab"),
+      33, test::AcmReceiveTest::kMonoOutput);
 }
 
 TEST_F(AcmSenderBitExactness, Pcm16_8000khz_10ms) {
diff --git a/webrtc/modules/audio_coding/main/acm2/audio_coding_module_unittest_oldapi.cc b/webrtc/modules/audio_coding/main/acm2/audio_coding_module_unittest_oldapi.cc
index 8cff055..56f4096 100644
--- a/webrtc/modules/audio_coding/main/acm2/audio_coding_module_unittest_oldapi.cc
+++ b/webrtc/modules/audio_coding/main/acm2/audio_coding_module_unittest_oldapi.cc
@@ -824,15 +824,14 @@
 TEST_F(AcmSenderBitExactnessOldApi, DISABLED_ON_ANDROID(IsacSwb30ms)) {
   ASSERT_NO_FATAL_FAILURE(SetUpTest("ISAC", 32000, 1, 104, 960, 960));
   Run(AcmReceiverBitExactnessOldApi::PlatformChecksum(
-          "98d960600eb4ddb3fcbe11f5057ddfd7",
+          "2b3c387d06f00b7b7aad4c9be56fb83d",
           "",
-          "2f6dfe142f735f1d96f6bd86d2526f42"),
+          "5683b58da0fbf2063c7adc2e6bfb3fb8"),
       AcmReceiverBitExactnessOldApi::PlatformChecksum(
-          "cc9d2d86a71d6f99f97680a5c27e2762",
+          "bcc2041e7744c7ebd9f701866856849c",
           "",
-          "7b214fc3a5e33d68bf30e77969371f31"),
-      33,
-      test::AcmReceiveTestOldApi::kMonoOutput);
+          "ce86106a93419aefb063097108ec94ab"),
+      33, test::AcmReceiveTestOldApi::kMonoOutput);
 }
 
 TEST_F(AcmSenderBitExactnessOldApi, Pcm16_8000khz_10ms) {