1 /* 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #ifndef WEBRTC_MODULES_AUDIO_CODING_NETEQ_AUDIO_DECODER_IMPL_H_ 12 #define WEBRTC_MODULES_AUDIO_CODING_NETEQ_AUDIO_DECODER_IMPL_H_ 13 14 #include <assert.h> 15 16 #include "webrtc/engine_configurations.h" 17 #include "webrtc/base/constructormagic.h" 18 #include "webrtc/modules/audio_coding/codecs/audio_decoder.h" 19 #include "webrtc/modules/audio_coding/codecs/cng/webrtc_cng.h" 20 #ifdef WEBRTC_CODEC_G722 21 #include "webrtc/modules/audio_coding/codecs/g722/g722_interface.h" 22 #endif 23 #include "webrtc/modules/audio_coding/acm2/rent_a_codec.h" 24 #include "webrtc/typedefs.h" 25 26 namespace webrtc { 27 28 // AudioDecoderCng is a special type of AudioDecoder. It inherits from 29 // AudioDecoder just to fit in the DecoderDatabase. None of the class methods 30 // should be used, except constructor, destructor, and accessors. 31 // TODO(hlundin): Consider the possibility to create a super-class to 32 // AudioDecoder that is stored in DecoderDatabase. Then AudioDecoder and a 33 // specific CngDecoder class could both inherit from that class. 34 class AudioDecoderCng : public AudioDecoder { 35 public: 36 explicit AudioDecoderCng(); 37 ~AudioDecoderCng() override; 38 void Reset() override; 39 int IncomingPacket(const uint8_t* payload, 40 size_t payload_len, 41 uint16_t rtp_sequence_number, 42 uint32_t rtp_timestamp, 43 uint32_t arrival_timestamp) override; 44 45 CNG_dec_inst* CngDecoderInstance() override; 46 size_t Channels() const override; 47 48 protected: 49 int DecodeInternal(const uint8_t* encoded, 50 size_t encoded_len, 51 int sample_rate_hz, 52 int16_t* decoded, 53 SpeechType* speech_type) override; 54 55 private: 56 CNG_dec_inst* dec_state_; 57 RTC_DISALLOW_COPY_AND_ASSIGN(AudioDecoderCng); 58 }; 59 60 using NetEqDecoder = acm2::RentACodec::NetEqDecoder; 61 62 // Returns true if |codec_type| is supported. 63 bool CodecSupported(NetEqDecoder codec_type); 64 65 // Returns the sample rate for |codec_type|. 66 int CodecSampleRateHz(NetEqDecoder codec_type); 67 68 // Creates an AudioDecoder object of type |codec_type|. Returns NULL for for 69 // unsupported codecs, and when creating an AudioDecoder is not applicable 70 // (e.g., for RED and DTMF/AVT types). 71 AudioDecoder* CreateAudioDecoder(NetEqDecoder codec_type); 72 73 } // namespace webrtc 74 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_AUDIO_DECODER_IMPL_H_ 75