tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

audio_decoder_pcm.h (2971B)


      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_G711_AUDIO_DECODER_PCM_H_
     12 #define MODULES_AUDIO_CODING_CODECS_G711_AUDIO_DECODER_PCM_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 "rtc_base/buffer.h"
     21 #include "rtc_base/checks.h"
     22 
     23 namespace webrtc {
     24 
     25 class AudioDecoderPcmU final : public AudioDecoder {
     26 public:
     27  explicit AudioDecoderPcmU(size_t num_channels) : num_channels_(num_channels) {
     28    RTC_DCHECK_GE(num_channels, 1);
     29    RTC_DCHECK_LE(num_channels, AudioDecoder::kMaxNumberOfChannels);
     30  }
     31 
     32  AudioDecoderPcmU(const AudioDecoderPcmU&) = delete;
     33  AudioDecoderPcmU& operator=(const AudioDecoderPcmU&) = delete;
     34 
     35  void Reset() override;
     36  std::vector<ParseResult> ParsePayload(Buffer&& payload,
     37                                        uint32_t timestamp) override;
     38  int PacketDuration(const uint8_t* encoded, size_t encoded_len) const override;
     39  int PacketDurationRedundant(const uint8_t* encoded,
     40                              size_t encoded_len) const override;
     41  int SampleRateHz() const override;
     42  size_t Channels() const override;
     43 
     44 protected:
     45  int DecodeInternal(const uint8_t* encoded,
     46                     size_t encoded_len,
     47                     int sample_rate_hz,
     48                     int16_t* decoded,
     49                     SpeechType* speech_type) override;
     50 
     51 private:
     52  const size_t num_channels_;
     53 };
     54 
     55 class AudioDecoderPcmA final : public AudioDecoder {
     56 public:
     57  explicit AudioDecoderPcmA(size_t num_channels) : num_channels_(num_channels) {
     58    RTC_DCHECK_GE(num_channels, 1);
     59    RTC_DCHECK_LE(num_channels, AudioDecoder::kMaxNumberOfChannels);
     60  }
     61 
     62  AudioDecoderPcmA(const AudioDecoderPcmA&) = delete;
     63  AudioDecoderPcmA& operator=(const AudioDecoderPcmA&) = delete;
     64 
     65  void Reset() override;
     66  std::vector<ParseResult> ParsePayload(Buffer&& payload,
     67                                        uint32_t timestamp) override;
     68  int PacketDuration(const uint8_t* encoded, size_t encoded_len) const override;
     69  int PacketDurationRedundant(const uint8_t* encoded,
     70                              size_t encoded_len) const override;
     71  int SampleRateHz() const override;
     72  size_t Channels() const override;
     73 
     74 protected:
     75  int DecodeInternal(const uint8_t* encoded,
     76                     size_t encoded_len,
     77                     int sample_rate_hz,
     78                     int16_t* decoded,
     79                     SpeechType* speech_type) override;
     80 
     81 private:
     82  const size_t num_channels_;
     83 };
     84 
     85 }  // namespace webrtc
     86 
     87 #endif  // MODULES_AUDIO_CODING_CODECS_G711_AUDIO_DECODER_PCM_H_