
Later steps in the refactoring will have the factory injected from the outside rather than owned by NetEq. BUG=webrtc:5801 Review-Url: https://codereview.webrtc.org/1928293002 Cr-Commit-Position: refs/heads/master@{#12604}
141 lines
4.4 KiB
C++
141 lines
4.4 KiB
C++
/*
|
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license
|
|
* that can be found in the LICENSE file in the root of the source
|
|
* tree. An additional intellectual property rights grant can be found
|
|
* in the file PATENTS. All contributing project authors may
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
*/
|
|
|
|
#include "webrtc/modules/audio_coding/neteq/audio_decoder_impl.h"
|
|
|
|
#include <assert.h>
|
|
|
|
#include "webrtc/base/checks.h"
|
|
#include "webrtc/modules/audio_coding/codecs/g711/audio_decoder_pcm.h"
|
|
#ifdef WEBRTC_CODEC_G722
|
|
#include "webrtc/modules/audio_coding/codecs/g722/audio_decoder_g722.h"
|
|
#endif
|
|
#ifdef WEBRTC_CODEC_ILBC
|
|
#include "webrtc/modules/audio_coding/codecs/ilbc/audio_decoder_ilbc.h"
|
|
#endif
|
|
#ifdef WEBRTC_CODEC_ISACFX
|
|
#include "webrtc/modules/audio_coding/codecs/isac/fix/include/audio_decoder_isacfix.h"
|
|
#include "webrtc/modules/audio_coding/codecs/isac/fix/include/audio_encoder_isacfix.h"
|
|
#endif
|
|
#ifdef WEBRTC_CODEC_ISAC
|
|
#include "webrtc/modules/audio_coding/codecs/isac/main/include/audio_decoder_isac.h"
|
|
#include "webrtc/modules/audio_coding/codecs/isac/main/include/audio_encoder_isac.h"
|
|
#endif
|
|
#ifdef WEBRTC_CODEC_OPUS
|
|
#include "webrtc/modules/audio_coding/codecs/opus/audio_decoder_opus.h"
|
|
#endif
|
|
#include "webrtc/modules/audio_coding/codecs/pcm16b/audio_decoder_pcm16b.h"
|
|
|
|
namespace webrtc {
|
|
|
|
bool CodecSupported(NetEqDecoder codec_type) {
|
|
switch (codec_type) {
|
|
case NetEqDecoder::kDecoderPCMu:
|
|
case NetEqDecoder::kDecoderPCMa:
|
|
case NetEqDecoder::kDecoderPCMu_2ch:
|
|
case NetEqDecoder::kDecoderPCMa_2ch:
|
|
#ifdef WEBRTC_CODEC_ILBC
|
|
case NetEqDecoder::kDecoderILBC:
|
|
#endif
|
|
#if defined(WEBRTC_CODEC_ISACFX) || defined(WEBRTC_CODEC_ISAC)
|
|
case NetEqDecoder::kDecoderISAC:
|
|
#endif
|
|
#ifdef WEBRTC_CODEC_ISAC
|
|
case NetEqDecoder::kDecoderISACswb:
|
|
#endif
|
|
case NetEqDecoder::kDecoderPCM16B:
|
|
case NetEqDecoder::kDecoderPCM16Bwb:
|
|
case NetEqDecoder::kDecoderPCM16Bswb32kHz:
|
|
case NetEqDecoder::kDecoderPCM16Bswb48kHz:
|
|
case NetEqDecoder::kDecoderPCM16B_2ch:
|
|
case NetEqDecoder::kDecoderPCM16Bwb_2ch:
|
|
case NetEqDecoder::kDecoderPCM16Bswb32kHz_2ch:
|
|
case NetEqDecoder::kDecoderPCM16Bswb48kHz_2ch:
|
|
case NetEqDecoder::kDecoderPCM16B_5ch:
|
|
#ifdef WEBRTC_CODEC_G722
|
|
case NetEqDecoder::kDecoderG722:
|
|
case NetEqDecoder::kDecoderG722_2ch:
|
|
#endif
|
|
#ifdef WEBRTC_CODEC_OPUS
|
|
case NetEqDecoder::kDecoderOpus:
|
|
case NetEqDecoder::kDecoderOpus_2ch:
|
|
#endif
|
|
case NetEqDecoder::kDecoderRED:
|
|
case NetEqDecoder::kDecoderAVT:
|
|
case NetEqDecoder::kDecoderCNGnb:
|
|
case NetEqDecoder::kDecoderCNGwb:
|
|
case NetEqDecoder::kDecoderCNGswb32kHz:
|
|
case NetEqDecoder::kDecoderCNGswb48kHz:
|
|
case NetEqDecoder::kDecoderArbitrary: {
|
|
return true;
|
|
}
|
|
default: {
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
|
|
int CodecSampleRateHz(NetEqDecoder codec_type) {
|
|
switch (codec_type) {
|
|
case NetEqDecoder::kDecoderPCMu:
|
|
case NetEqDecoder::kDecoderPCMa:
|
|
case NetEqDecoder::kDecoderPCMu_2ch:
|
|
case NetEqDecoder::kDecoderPCMa_2ch:
|
|
#ifdef WEBRTC_CODEC_ILBC
|
|
case NetEqDecoder::kDecoderILBC:
|
|
#endif
|
|
case NetEqDecoder::kDecoderPCM16B:
|
|
case NetEqDecoder::kDecoderPCM16B_2ch:
|
|
case NetEqDecoder::kDecoderPCM16B_5ch:
|
|
case NetEqDecoder::kDecoderCNGnb: {
|
|
return 8000;
|
|
}
|
|
#if defined(WEBRTC_CODEC_ISACFX) || defined(WEBRTC_CODEC_ISAC)
|
|
case NetEqDecoder::kDecoderISAC:
|
|
#endif
|
|
case NetEqDecoder::kDecoderPCM16Bwb:
|
|
case NetEqDecoder::kDecoderPCM16Bwb_2ch:
|
|
#ifdef WEBRTC_CODEC_G722
|
|
case NetEqDecoder::kDecoderG722:
|
|
case NetEqDecoder::kDecoderG722_2ch:
|
|
#endif
|
|
case NetEqDecoder::kDecoderCNGwb: {
|
|
return 16000;
|
|
}
|
|
#ifdef WEBRTC_CODEC_ISAC
|
|
case NetEqDecoder::kDecoderISACswb:
|
|
#endif
|
|
case NetEqDecoder::kDecoderPCM16Bswb32kHz:
|
|
case NetEqDecoder::kDecoderPCM16Bswb32kHz_2ch:
|
|
case NetEqDecoder::kDecoderCNGswb32kHz: {
|
|
return 32000;
|
|
}
|
|
case NetEqDecoder::kDecoderPCM16Bswb48kHz:
|
|
case NetEqDecoder::kDecoderPCM16Bswb48kHz_2ch: {
|
|
return 48000;
|
|
}
|
|
#ifdef WEBRTC_CODEC_OPUS
|
|
case NetEqDecoder::kDecoderOpus:
|
|
case NetEqDecoder::kDecoderOpus_2ch: {
|
|
return 48000;
|
|
}
|
|
#endif
|
|
case NetEqDecoder::kDecoderCNGswb48kHz: {
|
|
// TODO(tlegrand): Remove limitation once ACM has full 48 kHz support.
|
|
return 32000;
|
|
}
|
|
default: {
|
|
return -1; // Undefined sample rate.
|
|
}
|
|
}
|
|
}
|
|
|
|
} // namespace webrtc
|