AudioCodingModule: Specify decoders using SdpAudioFormat

NetEq already uses SdpAudioFormat internally; this CL adds an
AudioCodingModule::RegisterReceiveCodec overload that accepts
SdpAudioFormat, and propagates it through AcmReceiver into NetEq.

The intention is to get rid of the other ways to specify decoders and
always use SdpAudioFormat. (And eventually to do the same for encoders
too.)

NOTRY=true
BUG=5801

Review-Url: https://codereview.webrtc.org/2365653004
Cr-Commit-Position: refs/heads/master@{#14506}
diff --git a/webrtc/modules/audio_coding/neteq/decoder_database.cc b/webrtc/modules/audio_coding/neteq/decoder_database.cc
index ebea7e8..07c3471 100644
--- a/webrtc/modules/audio_coding/neteq/decoder_database.cc
+++ b/webrtc/modules/audio_coding/neteq/decoder_database.cc
@@ -85,7 +85,12 @@
 rtc::Optional<DecoderDatabase::DecoderInfo::CngDecoder>
 DecoderDatabase::DecoderInfo::CngDecoder::Create(const SdpAudioFormat& format) {
   if (STR_CASE_CMP(format.name.c_str(), "CN") == 0) {
-    return rtc::Optional<CngDecoder>({format.clockrate_hz});
+    // CN has a 1:1 RTP clock rate to sample rate ratio.
+    const int sample_rate_hz = format.clockrate_hz;
+    RTC_DCHECK(sample_rate_hz == 8000 || sample_rate_hz == 16000 ||
+               sample_rate_hz == 32000 || sample_rate_hz == 48000);
+    return rtc::Optional<DecoderDatabase::DecoderInfo::CngDecoder>(
+        {sample_rate_hz});
   } else {
     return rtc::Optional<CngDecoder>();
   }
@@ -141,6 +146,20 @@
   return kOK;
 }
 
+int DecoderDatabase::RegisterPayload(int rtp_payload_type,
+                                     const SdpAudioFormat& audio_format) {
+  if (rtp_payload_type < 0 || rtp_payload_type > 0x7f) {
+    return kInvalidRtpPayloadType;
+  }
+  const auto ret = decoders_.insert(std::make_pair(
+      rtp_payload_type, DecoderInfo(audio_format, decoder_factory_.get())));
+  if (ret.second == false) {
+    // Database already contains a decoder with type |rtp_payload_type|.
+    return kDecoderExists;
+  }
+  return kOK;
+}
+
 int DecoderDatabase::InsertExternal(uint8_t rtp_payload_type,
                                     NetEqDecoder codec_type,
                                     const std::string& codec_name,