audio_decoder_opus.h (2553B)
1 /* 2 * Copyright (c) 2015 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 MODULES_AUDIO_CODING_CODECS_OPUS_AUDIO_DECODER_OPUS_H_ 12 #define MODULES_AUDIO_CODING_CODECS_OPUS_AUDIO_DECODER_OPUS_H_ 13 14 #include <stddef.h> 15 #include <stdint.h> 16 17 #include <vector> 18 19 #include "api/audio_codecs/audio_decoder.h" 20 #include "api/field_trials_view.h" 21 #include "modules/audio_coding/codecs/opus/opus_interface.h" 22 #include "rtc_base/buffer.h" 23 24 namespace webrtc { 25 26 class AudioDecoderOpusImpl final : public AudioDecoder { 27 public: 28 explicit AudioDecoderOpusImpl(const FieldTrialsView& field_trails, 29 size_t num_channels, 30 int sample_rate_hz); 31 32 ~AudioDecoderOpusImpl() override; 33 34 AudioDecoderOpusImpl(const AudioDecoderOpusImpl&) = delete; 35 AudioDecoderOpusImpl& operator=(const AudioDecoderOpusImpl&) = delete; 36 37 std::vector<ParseResult> ParsePayload(Buffer&& payload, 38 uint32_t timestamp) override; 39 void Reset() override; 40 int PacketDuration(const uint8_t* encoded, size_t encoded_len) const override; 41 int PacketDurationRedundant(const uint8_t* encoded, 42 size_t encoded_len) const override; 43 bool PacketHasFec(const uint8_t* encoded, size_t encoded_len) const override; 44 int SampleRateHz() const override; 45 size_t Channels() const override; 46 void GeneratePlc(size_t requested_samples_per_channel, 47 BufferT<int16_t>* concealment_audio) override; 48 49 protected: 50 int DecodeInternal(const uint8_t* encoded, 51 size_t encoded_len, 52 int sample_rate_hz, 53 int16_t* decoded, 54 SpeechType* speech_type) override; 55 int DecodeRedundantInternal(const uint8_t* encoded, 56 size_t encoded_len, 57 int sample_rate_hz, 58 int16_t* decoded, 59 SpeechType* speech_type) override; 60 61 private: 62 OpusDecInst* dec_state_; 63 const size_t channels_; 64 const int sample_rate_hz_; 65 const bool generate_plc_; 66 }; 67 68 } // namespace webrtc 69 70 #endif // MODULES_AUDIO_CODING_CODECS_OPUS_AUDIO_DECODER_OPUS_H_