AcmReceiver: Eliminate AcmReceiver::decoders_

BUG=webrtc:5801

Review-Url: https://codereview.webrtc.org/2351183002
Cr-Commit-Position: refs/heads/master@{#14335}
diff --git a/webrtc/modules/audio_coding/neteq/decoder_database.h b/webrtc/modules/audio_coding/neteq/decoder_database.h
index 3728d1d..296d059 100644
--- a/webrtc/modules/audio_coding/neteq/decoder_database.h
+++ b/webrtc/modules/audio_coding/neteq/decoder_database.h
@@ -64,9 +64,8 @@
       return decoder ? decoder->SampleRateHz() : cng_decoder_->sample_rate_hz;
     }
 
-    const SdpAudioFormat& GetFormat() const {
-      RTC_DCHECK(audio_format_);
-      return *audio_format_;
+    const SdpAudioFormat* GetFormat() const {
+      return audio_format_ ? &*audio_format_ : nullptr;
     }
 
     // Returns true if |codec_type| is comfort noise.
diff --git a/webrtc/modules/audio_coding/neteq/include/neteq.h b/webrtc/modules/audio_coding/neteq/include/neteq.h
index 952ab23..98bb37c 100644
--- a/webrtc/modules/audio_coding/neteq/include/neteq.h
+++ b/webrtc/modules/audio_coding/neteq/include/neteq.h
@@ -259,6 +259,11 @@
   // value if we have no decoder for that payload type.
   virtual rtc::Optional<CodecInst> GetDecoder(int payload_type) const = 0;
 
+  // Returns the decoder format for the given payload type. Returns null if no
+  // such payload type was registered, or if it was registered without
+  // providing an SdpAudioFormat.
+  virtual const SdpAudioFormat* GetDecoderFormat(int payload_type) const = 0;
+
   // Not implemented.
   virtual int SetTargetNumberOfChannels() = 0;
 
diff --git a/webrtc/modules/audio_coding/neteq/neteq_impl.cc b/webrtc/modules/audio_coding/neteq/neteq_impl.cc
index 98588f4..221b07c 100644
--- a/webrtc/modules/audio_coding/neteq/neteq_impl.cc
+++ b/webrtc/modules/audio_coding/neteq/neteq_impl.cc
@@ -457,6 +457,18 @@
   return rtc::Optional<CodecInst>(ci);
 }
 
+const SdpAudioFormat* NetEqImpl::GetDecoderFormat(int payload_type) const {
+  rtc::CritScope lock(&crit_sect_);
+  const DecoderDatabase::DecoderInfo* const di =
+      decoder_database_->GetDecoderInfo(payload_type);
+  if (!di) {
+    return nullptr;  // Payload type not registered.
+  }
+  // This will return null if the payload type was registered without an
+  // SdpAudioFormat.
+  return di->GetFormat();
+}
+
 int NetEqImpl::SetTargetNumberOfChannels() {
   return kNotImplemented;
 }
diff --git a/webrtc/modules/audio_coding/neteq/neteq_impl.h b/webrtc/modules/audio_coding/neteq/neteq_impl.h
index 7903ba6..dd35301 100644
--- a/webrtc/modules/audio_coding/neteq/neteq_impl.h
+++ b/webrtc/modules/audio_coding/neteq/neteq_impl.h
@@ -173,6 +173,8 @@
 
   rtc::Optional<CodecInst> GetDecoder(int payload_type) const override;
 
+  const SdpAudioFormat* GetDecoderFormat(int payload_type) const override;
+
   int SetTargetNumberOfChannels() override;
 
   int SetTargetSampleRate() override;
diff --git a/webrtc/modules/audio_coding/neteq/timestamp_scaler.cc b/webrtc/modules/audio_coding/neteq/timestamp_scaler.cc
index 1f28639..fc3a846 100644
--- a/webrtc/modules/audio_coding/neteq/timestamp_scaler.cc
+++ b/webrtc/modules/audio_coding/neteq/timestamp_scaler.cc
@@ -50,7 +50,7 @@
       // support timestamp scaling of them.
       denominator_ = numerator_;
     } else {
-      denominator_ = info->GetFormat().clockrate_hz;
+      denominator_ = info->GetFormat()->clockrate_hz;
     }
   }
   if (numerator_ != denominator_) {