Karl Wiberg | 5678843 | 2015-09-15 15:28:18 | [diff] [blame] | 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 | |
kjellander@webrtc.org | 9592d2a | 2015-11-18 22:07:57 | [diff] [blame] | 11 | #ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_OPUS_AUDIO_DECODER_OPUS_H_ |
| 12 | #define WEBRTC_MODULES_AUDIO_CODING_CODECS_OPUS_AUDIO_DECODER_OPUS_H_ |
Karl Wiberg | 5678843 | 2015-09-15 15:28:18 | [diff] [blame] | 13 | |
kwiberg | f7c7480 | 2017-02-10 16:15:44 | [diff] [blame] | 14 | #include "webrtc/api/audio_codecs/audio_decoder.h" |
kjellander@webrtc.org | 9592d2a | 2015-11-18 22:07:57 | [diff] [blame] | 15 | #include "webrtc/modules/audio_coding/codecs/opus/opus_interface.h" |
Edward Lemur | 76de83e | 2017-07-06 17:44:34 | [diff] [blame] | 16 | #include "webrtc/rtc_base/constructormagic.h" |
Karl Wiberg | 5678843 | 2015-09-15 15:28:18 | [diff] [blame] | 17 | |
| 18 | namespace webrtc { |
| 19 | |
kwiberg | 50f70b3 | 2017-06-30 12:24:56 | [diff] [blame] | 20 | class AudioDecoderOpusImpl final : public AudioDecoder { |
Karl Wiberg | 5678843 | 2015-09-15 15:28:18 | [diff] [blame] | 21 | public: |
kwiberg | 50f70b3 | 2017-06-30 12:24:56 | [diff] [blame] | 22 | explicit AudioDecoderOpusImpl(size_t num_channels); |
| 23 | ~AudioDecoderOpusImpl() override; |
Karl Wiberg | 5678843 | 2015-09-15 15:28:18 | [diff] [blame] | 24 | |
ossu | 15d1e47 | 2016-09-22 09:06:28 | [diff] [blame] | 25 | std::vector<ParseResult> ParsePayload(rtc::Buffer&& payload, |
| 26 | uint32_t timestamp) override; |
Karl Wiberg | 5678843 | 2015-09-15 15:28:18 | [diff] [blame] | 27 | void Reset() override; |
| 28 | int PacketDuration(const uint8_t* encoded, size_t encoded_len) const override; |
| 29 | int PacketDurationRedundant(const uint8_t* encoded, |
| 30 | size_t encoded_len) const override; |
| 31 | bool PacketHasFec(const uint8_t* encoded, size_t encoded_len) const override; |
kwiberg | 7a441a0 | 2016-05-31 09:46:20 | [diff] [blame] | 32 | int SampleRateHz() const override; |
Karl Wiberg | 5678843 | 2015-09-15 15:28:18 | [diff] [blame] | 33 | size_t Channels() const override; |
| 34 | |
| 35 | protected: |
| 36 | int DecodeInternal(const uint8_t* encoded, |
| 37 | size_t encoded_len, |
| 38 | int sample_rate_hz, |
| 39 | int16_t* decoded, |
| 40 | SpeechType* speech_type) override; |
| 41 | int DecodeRedundantInternal(const uint8_t* encoded, |
| 42 | size_t encoded_len, |
| 43 | int sample_rate_hz, |
| 44 | int16_t* decoded, |
| 45 | SpeechType* speech_type) override; |
| 46 | |
| 47 | private: |
| 48 | OpusDecInst* dec_state_; |
| 49 | const size_t channels_; |
kwiberg | 50f70b3 | 2017-06-30 12:24:56 | [diff] [blame] | 50 | RTC_DISALLOW_COPY_AND_ASSIGN(AudioDecoderOpusImpl); |
Karl Wiberg | 5678843 | 2015-09-15 15:28:18 | [diff] [blame] | 51 | }; |
| 52 | |
| 53 | } // namespace webrtc |
| 54 | |
kjellander@webrtc.org | 9592d2a | 2015-11-18 22:07:57 | [diff] [blame] | 55 | #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_OPUS_AUDIO_DECODER_OPUS_H_ |