19a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org/*
29a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org *  Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
39a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org *
49a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org *  Use of this source code is governed by a BSD-style license
59a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org *  that can be found in the LICENSE file in the root of the source
69a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org *  tree. An additional intellectual property rights grant can be found
79a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org *  in the file PATENTS.  All contributing project authors may
89a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org *  be found in the AUTHORS file in the root of the source tree.
99a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org */
109a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
11e5abc854f3dc47de16067c2a41476c39b7626722henrik.lundin@webrtc.org#include "webrtc/modules/audio_coding/neteq/interface/audio_decoder.h"
129a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
139a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#include <assert.h>
149a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
15e5abc854f3dc47de16067c2a41476c39b7626722henrik.lundin@webrtc.org#include "webrtc/modules/audio_coding/neteq/audio_decoder_impl.h"
169a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
179a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.orgnamespace webrtc {
189a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
19dd1b19d950158fbb1d7e1792c4db95460d5f8c49pbos@webrtc.orgint AudioDecoder::DecodeRedundant(const uint8_t* encoded,
20dd1b19d950158fbb1d7e1792c4db95460d5f8c49pbos@webrtc.org                                  size_t encoded_len,
21dd1b19d950158fbb1d7e1792c4db95460d5f8c49pbos@webrtc.org                                  int16_t* decoded,
22dd1b19d950158fbb1d7e1792c4db95460d5f8c49pbos@webrtc.org                                  SpeechType* speech_type) {
23dd1b19d950158fbb1d7e1792c4db95460d5f8c49pbos@webrtc.org  return Decode(encoded, encoded_len, decoded, speech_type);
24dd1b19d950158fbb1d7e1792c4db95460d5f8c49pbos@webrtc.org}
25dd1b19d950158fbb1d7e1792c4db95460d5f8c49pbos@webrtc.org
26dd1b19d950158fbb1d7e1792c4db95460d5f8c49pbos@webrtc.orgbool AudioDecoder::HasDecodePlc() const { return false; }
27dd1b19d950158fbb1d7e1792c4db95460d5f8c49pbos@webrtc.org
28dd1b19d950158fbb1d7e1792c4db95460d5f8c49pbos@webrtc.orgint AudioDecoder::DecodePlc(int num_frames, int16_t* decoded) { return -1; }
29dd1b19d950158fbb1d7e1792c4db95460d5f8c49pbos@webrtc.org
30dd1b19d950158fbb1d7e1792c4db95460d5f8c49pbos@webrtc.orgint AudioDecoder::IncomingPacket(const uint8_t* payload,
31dd1b19d950158fbb1d7e1792c4db95460d5f8c49pbos@webrtc.org                                 size_t payload_len,
32dd1b19d950158fbb1d7e1792c4db95460d5f8c49pbos@webrtc.org                                 uint16_t rtp_sequence_number,
33dd1b19d950158fbb1d7e1792c4db95460d5f8c49pbos@webrtc.org                                 uint32_t rtp_timestamp,
34dd1b19d950158fbb1d7e1792c4db95460d5f8c49pbos@webrtc.org                                 uint32_t arrival_timestamp) {
35dd1b19d950158fbb1d7e1792c4db95460d5f8c49pbos@webrtc.org  return 0;
36dd1b19d950158fbb1d7e1792c4db95460d5f8c49pbos@webrtc.org}
37dd1b19d950158fbb1d7e1792c4db95460d5f8c49pbos@webrtc.org
38dd1b19d950158fbb1d7e1792c4db95460d5f8c49pbos@webrtc.orgint AudioDecoder::ErrorCode() { return 0; }
39dd1b19d950158fbb1d7e1792c4db95460d5f8c49pbos@webrtc.org
40dd1b19d950158fbb1d7e1792c4db95460d5f8c49pbos@webrtc.orgint AudioDecoder::PacketDuration(const uint8_t* encoded, size_t encoded_len) {
41dd1b19d950158fbb1d7e1792c4db95460d5f8c49pbos@webrtc.org  return kNotImplemented;
42dd1b19d950158fbb1d7e1792c4db95460d5f8c49pbos@webrtc.org}
43dd1b19d950158fbb1d7e1792c4db95460d5f8c49pbos@webrtc.org
44835b016d936aeb6c48b42c211ef257d6d3057c4fminyue@webrtc.orgint AudioDecoder::PacketDurationRedundant(const uint8_t* encoded,
45835b016d936aeb6c48b42c211ef257d6d3057c4fminyue@webrtc.org                                          size_t encoded_len) const {
46835b016d936aeb6c48b42c211ef257d6d3057c4fminyue@webrtc.org  return kNotImplemented;
47835b016d936aeb6c48b42c211ef257d6d3057c4fminyue@webrtc.org}
48835b016d936aeb6c48b42c211ef257d6d3057c4fminyue@webrtc.org
49835b016d936aeb6c48b42c211ef257d6d3057c4fminyue@webrtc.orgbool AudioDecoder::PacketHasFec(const uint8_t* encoded,
50835b016d936aeb6c48b42c211ef257d6d3057c4fminyue@webrtc.org                                size_t encoded_len) const {
51835b016d936aeb6c48b42c211ef257d6d3057c4fminyue@webrtc.org  return false;
52835b016d936aeb6c48b42c211ef257d6d3057c4fminyue@webrtc.org}
53835b016d936aeb6c48b42c211ef257d6d3057c4fminyue@webrtc.org
54dd1b19d950158fbb1d7e1792c4db95460d5f8c49pbos@webrtc.orgNetEqDecoder AudioDecoder::codec_type() const { return codec_type_; }
55dd1b19d950158fbb1d7e1792c4db95460d5f8c49pbos@webrtc.org
569a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.orgbool AudioDecoder::CodecSupported(NetEqDecoder codec_type) {
579a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  switch (codec_type) {
589a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderPCMu:
599a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderPCMa:
609a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderPCMu_2ch:
619a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderPCMa_2ch:
629a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#ifdef WEBRTC_CODEC_ILBC
639a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderILBC:
649a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#endif
659a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#if defined(WEBRTC_CODEC_ISACFX) || defined(WEBRTC_CODEC_ISAC)
669a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderISAC:
679a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#endif
689a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#ifdef WEBRTC_CODEC_ISAC
699a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderISACswb:
704d9b02d493ae9484984d58f6abefd8bcc4862d62henrik.lundin@webrtc.org    case kDecoderISACfb:
719a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#endif
729a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#ifdef WEBRTC_CODEC_PCM16
739a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderPCM16B:
749a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderPCM16Bwb:
759a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderPCM16Bswb32kHz:
769a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderPCM16Bswb48kHz:
779a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderPCM16B_2ch:
789a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderPCM16Bwb_2ch:
799a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderPCM16Bswb32kHz_2ch:
809a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderPCM16Bswb48kHz_2ch:
819a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderPCM16B_5ch:
829a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#endif
839a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#ifdef WEBRTC_CODEC_G722
849a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderG722:
85162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org    case kDecoderG722_2ch:
869a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#endif
8724f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org#ifdef WEBRTC_CODEC_CELT
8824f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org    case kDecoderCELT_32:
8924f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org    case kDecoderCELT_32_2ch:
9024f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org#endif
919a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#ifdef WEBRTC_CODEC_OPUS
929a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderOpus:
939a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderOpus_2ch:
949a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#endif
959a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderRED:
969a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderAVT:
979a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderCNGnb:
989a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderCNGwb:
999a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderCNGswb32kHz:
1009a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderCNGswb48kHz:
1019a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderArbitrary: {
1029a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org      return true;
1039a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    }
1049a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    default: {
1059a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org      return false;
1069a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    }
1079a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  }
1089a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org}
1099a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
1109a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.orgint AudioDecoder::CodecSampleRateHz(NetEqDecoder codec_type) {
1119a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  switch (codec_type) {
1129a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderPCMu:
1139a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderPCMa:
1149a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderPCMu_2ch:
1159a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderPCMa_2ch:
1169a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#ifdef WEBRTC_CODEC_ILBC
1179a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderILBC:
1189a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#endif
1199a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#ifdef WEBRTC_CODEC_PCM16
1209a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderPCM16B:
1219a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderPCM16B_2ch:
1229a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderPCM16B_5ch:
1239a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#endif
1249a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderCNGnb: {
1259a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org      return 8000;
1269a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    }
1279a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#if defined(WEBRTC_CODEC_ISACFX) || defined(WEBRTC_CODEC_ISAC)
1289a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderISAC:
1299a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#endif
1309a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#ifdef WEBRTC_CODEC_PCM16
1319a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderPCM16Bwb:
1329a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderPCM16Bwb_2ch:
1339a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#endif
1349a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#ifdef WEBRTC_CODEC_G722
1359a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderG722:
136162639b2d729397915f9cbff160a828c1fc14c8fhenrik.lundin@webrtc.org    case kDecoderG722_2ch:
1379a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#endif
1389a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderCNGwb: {
1399a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org      return 16000;
1409a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    }
1419a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#ifdef WEBRTC_CODEC_ISAC
1429a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderISACswb:
1434d9b02d493ae9484984d58f6abefd8bcc4862d62henrik.lundin@webrtc.org    case kDecoderISACfb:
1449a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#endif
1459a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#ifdef WEBRTC_CODEC_PCM16
1469a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderPCM16Bswb32kHz:
1479a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderPCM16Bswb32kHz_2ch:
1489a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#endif
14924f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org#ifdef WEBRTC_CODEC_CELT
15024f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org    case kDecoderCELT_32:
15124f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org    case kDecoderCELT_32_2ch:
15224f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org#endif
1539a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderCNGswb32kHz: {
1549a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org      return 32000;
1559a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    }
1569a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#ifdef WEBRTC_CODEC_PCM16
1579a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderPCM16Bswb48kHz:
1589a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderPCM16Bswb48kHz_2ch: {
1599a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org      return 48000;
1609a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    }
1619a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#endif
1629a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#ifdef WEBRTC_CODEC_OPUS
1639a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderOpus:
1649a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderOpus_2ch: {
165254879d7e969771c28d0882582e02b1a0b0eeb14minyue@webrtc.org      return 48000;
1669a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    }
1679a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#endif
1689a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderCNGswb48kHz: {
1699a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org      // TODO(tlegrand): Remove limitation once ACM has full 48 kHz support.
1709a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org      return 32000;
1719a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    }
1729a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    default: {
1739a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org      return -1;  // Undefined sample rate.
1749a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    }
1759a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  }
1769a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org}
1779a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
1789a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.orgAudioDecoder* AudioDecoder::CreateAudioDecoder(NetEqDecoder codec_type) {
1799a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  if (!CodecSupported(codec_type)) {
1809a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    return NULL;
1819a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  }
1829a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  switch (codec_type) {
1839a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderPCMu:
1849a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org      return new AudioDecoderPcmU;
1859a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderPCMa:
1869a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org      return new AudioDecoderPcmA;
1879a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderPCMu_2ch:
1889a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org      return new AudioDecoderPcmUMultiCh(2);
1899a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderPCMa_2ch:
1909a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org      return new AudioDecoderPcmAMultiCh(2);
1919a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#ifdef WEBRTC_CODEC_ILBC
1929a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderILBC:
1939a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org      return new AudioDecoderIlbc;
1949a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#endif
1959a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#if defined(WEBRTC_CODEC_ISACFX)
1969a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderISAC:
1979a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org      return new AudioDecoderIsacFix;
1989a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#elif defined(WEBRTC_CODEC_ISAC)
1999a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderISAC:
2009a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org      return new AudioDecoderIsac;
2019a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#endif
2029a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#ifdef WEBRTC_CODEC_ISAC
2039a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderISACswb:
2049a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org      return new AudioDecoderIsacSwb;
2054d9b02d493ae9484984d58f6abefd8bcc4862d62henrik.lundin@webrtc.org    case kDecoderISACfb:
2064d9b02d493ae9484984d58f6abefd8bcc4862d62henrik.lundin@webrtc.org      return new AudioDecoderIsacFb;
2079a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#endif
2089a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#ifdef WEBRTC_CODEC_PCM16
2099a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderPCM16B:
2109a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderPCM16Bwb:
2119a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderPCM16Bswb32kHz:
2129a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderPCM16Bswb48kHz:
2139a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org      return new AudioDecoderPcm16B(codec_type);
2149a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderPCM16B_2ch:
2159a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderPCM16Bwb_2ch:
2169a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderPCM16Bswb32kHz_2ch:
2179a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderPCM16Bswb48kHz_2ch:
2189a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderPCM16B_5ch:
2199a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org      return new AudioDecoderPcm16BMultiCh(codec_type);
2209a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#endif
2219a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#ifdef WEBRTC_CODEC_G722
2229a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderG722:
2239a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org      return new AudioDecoderG722;
224a0bba27d883a681bb714cc1f7eeabd6754929c89turaj@webrtc.org    case kDecoderG722_2ch:
225a0bba27d883a681bb714cc1f7eeabd6754929c89turaj@webrtc.org      return new AudioDecoderG722Stereo;
2269a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#endif
22724f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org#ifdef WEBRTC_CODEC_CELT
22824f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org    case kDecoderCELT_32:
22924f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org    case kDecoderCELT_32_2ch:
23024f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org      return new AudioDecoderCelt(codec_type);
23124f07023ade0cf0058bd3546999068c902a94deaturaj@webrtc.org#endif
2329a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#ifdef WEBRTC_CODEC_OPUS
2339a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderOpus:
2349a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderOpus_2ch:
2359a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org      return new AudioDecoderOpus(codec_type);
2369a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org#endif
2379a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderCNGnb:
2389a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderCNGwb:
2399a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderCNGswb32kHz:
2409a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderCNGswb48kHz:
2419a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org      return new AudioDecoderCng(codec_type);
2429a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderRED:
2439a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderAVT:
2449a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case kDecoderArbitrary:
2459a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    default: {
2469a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org      return NULL;
2479a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    }
2489a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  }
2499a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org}
2509a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
2519a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.orgAudioDecoder::SpeechType AudioDecoder::ConvertSpeechType(int16_t type) {
2529a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  switch (type) {
2539a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case 0:  // TODO(hlundin): Both iSAC and Opus return 0 for speech.
2549a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case 1:
2559a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org      return kSpeech;
2569a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    case 2:
2579a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org      return kComfortNoise;
2589a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org    default:
2599a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org      assert(false);
2609a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org      return kSpeech;
2619a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org  }
2629a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org}
2639a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org
2649a400812ca0006d12e538d465ab6728a8ecd07aahenrik.lundin@webrtc.org}  // namespace webrtc
265