AudioCodingModuleImpl: Stop failing artificially for non-Opus encoders

All encoders already handle the "Opus-specific" requests sanely (by
failing nicely), so we don't need extra checks to protect them.

BUG=webrtc:5028

Review URL: https://codereview.webrtc.org/1527453005

Cr-Commit-Position: refs/heads/master@{#11051}
diff --git a/webrtc/modules/audio_coding/acm2/audio_coding_module_impl.cc b/webrtc/modules/audio_coding/acm2/audio_coding_module_impl.cc
index d8384aa..0572b26 100644
--- a/webrtc/modules/audio_coding/acm2/audio_coding_module_impl.cc
+++ b/webrtc/modules/audio_coding/acm2/audio_coding_module_impl.cc
@@ -744,8 +744,6 @@
   if (!HaveValidEncoder("SetOpusApplication")) {
     return -1;
   }
-  if (!codec_manager_.CurrentEncoderIsOpus())
-    return -1;
   AudioEncoder::Application app;
   switch (application) {
     case kVoip:
@@ -767,8 +765,6 @@
   if (!HaveValidEncoder("SetOpusMaxPlaybackRate")) {
     return -1;
   }
-  if (!codec_manager_.CurrentEncoderIsOpus())
-    return -1;
   rent_a_codec_.GetEncoderStack()->SetMaxPlaybackRate(frequency_hz);
   return 0;
 }
@@ -778,8 +774,6 @@
   if (!HaveValidEncoder("EnableOpusDtx")) {
     return -1;
   }
-  if (!codec_manager_.CurrentEncoderIsOpus())
-    return -1;
   return rent_a_codec_.GetEncoderStack()->SetDtx(true) ? 0 : -1;
 }
 
@@ -788,8 +782,6 @@
   if (!HaveValidEncoder("DisableOpusDtx")) {
     return -1;
   }
-  if (!codec_manager_.CurrentEncoderIsOpus())
-    return -1;
   return rent_a_codec_.GetEncoderStack()->SetDtx(false) ? 0 : -1;
 }
 
diff --git a/webrtc/modules/audio_coding/acm2/codec_manager.cc b/webrtc/modules/audio_coding/acm2/codec_manager.cc
index bc507dd..d8ef2bf 100644
--- a/webrtc/modules/audio_coding/acm2/codec_manager.cc
+++ b/webrtc/modules/audio_coding/acm2/codec_manager.cc
@@ -166,7 +166,9 @@
     return false;
   }
 
-  if (CurrentEncoderIsOpus()) {
+  // TODO(kwiberg): This doesn't protect Opus when injected as an external
+  // encoder.
+  if (send_codec_inst_ && IsOpus(*send_codec_inst_)) {
     // VAD/DTX not supported, but don't fail.
     enable = false;
   }
@@ -187,9 +189,5 @@
   return true;
 }
 
-bool CodecManager::CurrentEncoderIsOpus() const {
-  return send_codec_inst_ ? IsOpus(*send_codec_inst_) : false;
-}
-
 }  // namespace acm2
 }  // namespace webrtc
diff --git a/webrtc/modules/audio_coding/acm2/codec_manager.h b/webrtc/modules/audio_coding/acm2/codec_manager.h
index ad96d1d..9227e13 100644
--- a/webrtc/modules/audio_coding/acm2/codec_manager.h
+++ b/webrtc/modules/audio_coding/acm2/codec_manager.h
@@ -53,8 +53,6 @@
 
   bool SetCodecFEC(bool enable_codec_fec);
 
-  bool CurrentEncoderIsOpus() const;
-
  private:
   rtc::ThreadChecker thread_checker_;
   rtc::Optional<CodecInst> send_codec_inst_;
diff --git a/webrtc/modules/audio_coding/test/TestVADDTX.cc b/webrtc/modules/audio_coding/test/TestVADDTX.cc
index a7d2c21..229dc2d 100644
--- a/webrtc/modules/audio_coding/test/TestVADDTX.cc
+++ b/webrtc/modules/audio_coding/test/TestVADDTX.cc
@@ -234,10 +234,10 @@
 // Following is the implementation of TestOpusDtx.
 void TestOpusDtx::Perform() {
 #ifdef WEBRTC_CODEC_ISAC
-  // If we set other codec than Opus, DTX cannot be toggled.
+  // If we set other codec than Opus, DTX cannot be switched on.
   RegisterCodec(kIsacWb);
   EXPECT_EQ(-1, acm_send_->EnableOpusDtx());
-  EXPECT_EQ(-1, acm_send_->DisableOpusDtx());
+  EXPECT_EQ(0, acm_send_->DisableOpusDtx());
 #endif
 
 #ifdef WEBRTC_CODEC_OPUS