| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_G711_AUDIO_ENCODER_PCM_H_ | 11 #ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_G711_AUDIO_ENCODER_PCM_H_ |
| 12 #define WEBRTC_MODULES_AUDIO_CODING_CODECS_G711_AUDIO_ENCODER_PCM_H_ | 12 #define WEBRTC_MODULES_AUDIO_CODING_CODECS_G711_AUDIO_ENCODER_PCM_H_ |
| 13 | 13 |
| 14 #include <vector> | 14 #include <vector> |
| 15 | 15 |
| 16 #include "webrtc/api/audio_codecs/audio_encoder.h" | 16 #include "webrtc/api/audio_codecs/audio_encoder.h" |
| 17 #include "webrtc/api/audio_codecs/audio_format.h" | |
| 18 #include "webrtc/rtc_base/constructormagic.h" | 17 #include "webrtc/rtc_base/constructormagic.h" |
| 19 | 18 |
| 20 namespace webrtc { | 19 namespace webrtc { |
| 21 | 20 |
| 22 class AudioEncoderPcm : public AudioEncoder { | 21 class AudioEncoderPcm : public AudioEncoder { |
| 23 public: | 22 public: |
| 24 struct Config { | 23 struct Config { |
| 25 public: | 24 public: |
| 26 bool IsOk() const; | 25 bool IsOk() const; |
| 27 | 26 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 | 73 |
| 75 class AudioEncoderPcmA final : public AudioEncoderPcm { | 74 class AudioEncoderPcmA final : public AudioEncoderPcm { |
| 76 public: | 75 public: |
| 77 struct Config : public AudioEncoderPcm::Config { | 76 struct Config : public AudioEncoderPcm::Config { |
| 78 Config() : AudioEncoderPcm::Config(8) {} | 77 Config() : AudioEncoderPcm::Config(8) {} |
| 79 }; | 78 }; |
| 80 | 79 |
| 81 explicit AudioEncoderPcmA(const Config& config) | 80 explicit AudioEncoderPcmA(const Config& config) |
| 82 : AudioEncoderPcm(config, kSampleRateHz) {} | 81 : AudioEncoderPcm(config, kSampleRateHz) {} |
| 83 explicit AudioEncoderPcmA(const CodecInst& codec_inst); | 82 explicit AudioEncoderPcmA(const CodecInst& codec_inst); |
| 84 AudioEncoderPcmA(int payload_type, const SdpAudioFormat& format); | |
| 85 | |
| 86 static constexpr const char* GetPayloadName() { return "PCMA"; } | |
| 87 static rtc::Optional<AudioCodecInfo> QueryAudioEncoder( | |
| 88 const SdpAudioFormat& format); | |
| 89 | 83 |
| 90 protected: | 84 protected: |
| 91 size_t EncodeCall(const int16_t* audio, | 85 size_t EncodeCall(const int16_t* audio, |
| 92 size_t input_len, | 86 size_t input_len, |
| 93 uint8_t* encoded) override; | 87 uint8_t* encoded) override; |
| 94 | 88 |
| 95 size_t BytesPerSample() const override; | 89 size_t BytesPerSample() const override; |
| 96 | 90 |
| 97 AudioEncoder::CodecType GetCodecType() const override; | 91 AudioEncoder::CodecType GetCodecType() const override; |
| 98 | 92 |
| 99 private: | 93 private: |
| 100 static const int kSampleRateHz = 8000; | 94 static const int kSampleRateHz = 8000; |
| 101 RTC_DISALLOW_COPY_AND_ASSIGN(AudioEncoderPcmA); | 95 RTC_DISALLOW_COPY_AND_ASSIGN(AudioEncoderPcmA); |
| 102 }; | 96 }; |
| 103 | 97 |
| 104 class AudioEncoderPcmU final : public AudioEncoderPcm { | 98 class AudioEncoderPcmU final : public AudioEncoderPcm { |
| 105 public: | 99 public: |
| 106 struct Config : public AudioEncoderPcm::Config { | 100 struct Config : public AudioEncoderPcm::Config { |
| 107 Config() : AudioEncoderPcm::Config(0) {} | 101 Config() : AudioEncoderPcm::Config(0) {} |
| 108 }; | 102 }; |
| 109 | 103 |
| 110 explicit AudioEncoderPcmU(const Config& config) | 104 explicit AudioEncoderPcmU(const Config& config) |
| 111 : AudioEncoderPcm(config, kSampleRateHz) {} | 105 : AudioEncoderPcm(config, kSampleRateHz) {} |
| 112 explicit AudioEncoderPcmU(const CodecInst& codec_inst); | 106 explicit AudioEncoderPcmU(const CodecInst& codec_inst); |
| 113 AudioEncoderPcmU(int payload_type, const SdpAudioFormat& format); | |
| 114 | |
| 115 static constexpr const char* GetPayloadName() { return "PCMU"; } | |
| 116 static rtc::Optional<AudioCodecInfo> QueryAudioEncoder( | |
| 117 const SdpAudioFormat& format); | |
| 118 | 107 |
| 119 protected: | 108 protected: |
| 120 size_t EncodeCall(const int16_t* audio, | 109 size_t EncodeCall(const int16_t* audio, |
| 121 size_t input_len, | 110 size_t input_len, |
| 122 uint8_t* encoded) override; | 111 uint8_t* encoded) override; |
| 123 | 112 |
| 124 size_t BytesPerSample() const override; | 113 size_t BytesPerSample() const override; |
| 125 | 114 |
| 126 AudioEncoder::CodecType GetCodecType() const override; | 115 AudioEncoder::CodecType GetCodecType() const override; |
| 127 | 116 |
| 128 private: | 117 private: |
| 129 static const int kSampleRateHz = 8000; | 118 static const int kSampleRateHz = 8000; |
| 130 RTC_DISALLOW_COPY_AND_ASSIGN(AudioEncoderPcmU); | 119 RTC_DISALLOW_COPY_AND_ASSIGN(AudioEncoderPcmU); |
| 131 }; | 120 }; |
| 132 | 121 |
| 133 } // namespace webrtc | 122 } // namespace webrtc |
| 134 | 123 |
| 135 #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_G711_AUDIO_ENCODER_PCM_H_ | 124 #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_G711_AUDIO_ENCODER_PCM_H_ |
| OLD | NEW |