2015-09-22 06:16:51 -07:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2015 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.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef MODULES_AUDIO_CODING_CODECS_G711_AUDIO_DECODER_PCM_H_
|
|
|
|
|
#define MODULES_AUDIO_CODING_CODECS_G711_AUDIO_DECODER_PCM_H_
|
2015-09-22 06:16:51 -07:00
|
|
|
|
2018-10-23 12:03:01 +02:00
|
|
|
#include <stddef.h>
|
|
|
|
|
#include <stdint.h>
|
2019-07-05 19:08:33 +02:00
|
|
|
|
2018-10-23 12:03:01 +02:00
|
|
|
#include <vector>
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "api/audio_codecs/audio_decoder.h"
|
2018-10-23 12:03:01 +02:00
|
|
|
#include "rtc_base/buffer.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "rtc_base/checks.h"
|
2019-01-11 09:11:00 -08:00
|
|
|
#include "rtc_base/constructor_magic.h"
|
2015-09-22 06:16:51 -07:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
2015-09-22 14:06:29 -07:00
|
|
|
class AudioDecoderPcmU final : public AudioDecoder {
|
2015-09-22 06:16:51 -07:00
|
|
|
public:
|
2015-09-22 14:06:29 -07:00
|
|
|
explicit AudioDecoderPcmU(size_t num_channels) : num_channels_(num_channels) {
|
2016-11-28 15:21:39 -08:00
|
|
|
RTC_DCHECK_GE(num_channels, 1);
|
2015-09-22 14:06:29 -07:00
|
|
|
}
|
2015-09-22 06:16:51 -07:00
|
|
|
void Reset() override;
|
2016-09-21 01:57:31 -07:00
|
|
|
std::vector<ParseResult> ParsePayload(rtc::Buffer&& payload,
|
2016-09-22 02:06:28 -07:00
|
|
|
uint32_t timestamp) override;
|
2015-09-22 06:16:51 -07:00
|
|
|
int PacketDuration(const uint8_t* encoded, size_t encoded_len) const override;
|
2016-05-31 02:46:20 -07:00
|
|
|
int SampleRateHz() const override;
|
2015-09-22 06:16:51 -07:00
|
|
|
size_t Channels() const override;
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
int DecodeInternal(const uint8_t* encoded,
|
|
|
|
|
size_t encoded_len,
|
|
|
|
|
int sample_rate_hz,
|
|
|
|
|
int16_t* decoded,
|
|
|
|
|
SpeechType* speech_type) override;
|
|
|
|
|
|
|
|
|
|
private:
|
2015-09-22 14:06:29 -07:00
|
|
|
const size_t num_channels_;
|
2015-09-22 06:16:51 -07:00
|
|
|
RTC_DISALLOW_COPY_AND_ASSIGN(AudioDecoderPcmU);
|
|
|
|
|
};
|
|
|
|
|
|
2015-09-22 14:06:29 -07:00
|
|
|
class AudioDecoderPcmA final : public AudioDecoder {
|
2015-09-22 06:16:51 -07:00
|
|
|
public:
|
2015-09-22 14:06:29 -07:00
|
|
|
explicit AudioDecoderPcmA(size_t num_channels) : num_channels_(num_channels) {
|
2016-11-28 15:21:39 -08:00
|
|
|
RTC_DCHECK_GE(num_channels, 1);
|
2015-09-22 14:06:29 -07:00
|
|
|
}
|
2015-09-22 06:16:51 -07:00
|
|
|
void Reset() override;
|
2016-09-21 01:57:31 -07:00
|
|
|
std::vector<ParseResult> ParsePayload(rtc::Buffer&& payload,
|
2016-09-22 02:06:28 -07:00
|
|
|
uint32_t timestamp) override;
|
2015-09-22 06:16:51 -07:00
|
|
|
int PacketDuration(const uint8_t* encoded, size_t encoded_len) const override;
|
2016-05-31 02:46:20 -07:00
|
|
|
int SampleRateHz() const override;
|
2015-09-22 06:16:51 -07:00
|
|
|
size_t Channels() const override;
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
int DecodeInternal(const uint8_t* encoded,
|
|
|
|
|
size_t encoded_len,
|
|
|
|
|
int sample_rate_hz,
|
|
|
|
|
int16_t* decoded,
|
|
|
|
|
SpeechType* speech_type) override;
|
|
|
|
|
|
|
|
|
|
private:
|
2015-09-22 14:06:29 -07:00
|
|
|
const size_t num_channels_;
|
2015-09-22 06:16:51 -07:00
|
|
|
RTC_DISALLOW_COPY_AND_ASSIGN(AudioDecoderPcmA);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|
2015-09-22 14:06:29 -07:00
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // MODULES_AUDIO_CODING_CODECS_G711_AUDIO_DECODER_PCM_H_
|