Chromium Code Reviews| 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_format.h" | |
| 16 #include "webrtc/base/constructormagic.h" | 17 #include "webrtc/base/constructormagic.h" |
| 17 #include "webrtc/modules/audio_coding/codecs/audio_encoder.h" | 18 #include "webrtc/modules/audio_coding/codecs/audio_encoder.h" |
| 18 | 19 |
| 19 namespace webrtc { | 20 namespace webrtc { |
| 20 | 21 |
| 21 class AudioEncoderPcm : public AudioEncoder { | 22 class AudioEncoderPcm : public AudioEncoder { |
| 22 public: | 23 public: |
| 23 struct Config { | 24 struct Config { |
| 24 public: | 25 public: |
| 25 bool IsOk() const; | 26 bool IsOk() const; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 73 | 74 |
| 74 class AudioEncoderPcmA final : public AudioEncoderPcm { | 75 class AudioEncoderPcmA final : public AudioEncoderPcm { |
| 75 public: | 76 public: |
| 76 struct Config : public AudioEncoderPcm::Config { | 77 struct Config : public AudioEncoderPcm::Config { |
| 77 Config() : AudioEncoderPcm::Config(8) {} | 78 Config() : AudioEncoderPcm::Config(8) {} |
| 78 }; | 79 }; |
| 79 | 80 |
| 80 explicit AudioEncoderPcmA(const Config& config) | 81 explicit AudioEncoderPcmA(const Config& config) |
| 81 : AudioEncoderPcm(config, kSampleRateHz) {} | 82 : AudioEncoderPcm(config, kSampleRateHz) {} |
| 82 explicit AudioEncoderPcmA(const CodecInst& codec_inst); | 83 explicit AudioEncoderPcmA(const CodecInst& codec_inst); |
| 84 explicit AudioEncoderPcmA(int payload_type, const SdpAudioFormat& format); | |
|
kwiberg-webrtc
2017/02/19 21:41:10
Why explicit?
ossu
2017/02/20 12:20:26
Copied the line above, made changes, didn't think
| |
| 85 | |
| 86 static constexpr const char* GetPayloadName() { return "pcma"; } | |
| 87 static rtc::Optional<AudioFormatInfo> QueryAudioFormat( | |
| 88 const SdpAudioFormat& format); | |
| 83 | 89 |
| 84 protected: | 90 protected: |
| 85 size_t EncodeCall(const int16_t* audio, | 91 size_t EncodeCall(const int16_t* audio, |
| 86 size_t input_len, | 92 size_t input_len, |
| 87 uint8_t* encoded) override; | 93 uint8_t* encoded) override; |
| 88 | 94 |
| 89 size_t BytesPerSample() const override; | 95 size_t BytesPerSample() const override; |
| 90 | 96 |
| 91 AudioEncoder::CodecType GetCodecType() const override; | 97 AudioEncoder::CodecType GetCodecType() const override; |
| 92 | 98 |
| 93 private: | 99 private: |
| 94 static const int kSampleRateHz = 8000; | 100 static const int kSampleRateHz = 8000; |
| 95 RTC_DISALLOW_COPY_AND_ASSIGN(AudioEncoderPcmA); | 101 RTC_DISALLOW_COPY_AND_ASSIGN(AudioEncoderPcmA); |
| 96 }; | 102 }; |
| 97 | 103 |
| 98 class AudioEncoderPcmU final : public AudioEncoderPcm { | 104 class AudioEncoderPcmU final : public AudioEncoderPcm { |
| 99 public: | 105 public: |
| 100 struct Config : public AudioEncoderPcm::Config { | 106 struct Config : public AudioEncoderPcm::Config { |
| 101 Config() : AudioEncoderPcm::Config(0) {} | 107 Config() : AudioEncoderPcm::Config(0) {} |
| 102 }; | 108 }; |
| 103 | 109 |
| 104 explicit AudioEncoderPcmU(const Config& config) | 110 explicit AudioEncoderPcmU(const Config& config) |
| 105 : AudioEncoderPcm(config, kSampleRateHz) {} | 111 : AudioEncoderPcm(config, kSampleRateHz) {} |
| 106 explicit AudioEncoderPcmU(const CodecInst& codec_inst); | 112 explicit AudioEncoderPcmU(const CodecInst& codec_inst); |
| 113 explicit AudioEncoderPcmU(int payload_type, const SdpAudioFormat& format); | |
| 114 | |
| 115 static constexpr const char* GetPayloadName() { return "pcmu"; } | |
| 116 static rtc::Optional<AudioFormatInfo> QueryAudioFormat( | |
| 117 const SdpAudioFormat& format); | |
| 107 | 118 |
| 108 protected: | 119 protected: |
| 109 size_t EncodeCall(const int16_t* audio, | 120 size_t EncodeCall(const int16_t* audio, |
| 110 size_t input_len, | 121 size_t input_len, |
| 111 uint8_t* encoded) override; | 122 uint8_t* encoded) override; |
| 112 | 123 |
| 113 size_t BytesPerSample() const override; | 124 size_t BytesPerSample() const override; |
| 114 | 125 |
| 115 AudioEncoder::CodecType GetCodecType() const override; | 126 AudioEncoder::CodecType GetCodecType() const override; |
| 116 | 127 |
| 117 private: | 128 private: |
| 118 static const int kSampleRateHz = 8000; | 129 static const int kSampleRateHz = 8000; |
| 119 RTC_DISALLOW_COPY_AND_ASSIGN(AudioEncoderPcmU); | 130 RTC_DISALLOW_COPY_AND_ASSIGN(AudioEncoderPcmU); |
| 120 }; | 131 }; |
| 121 | 132 |
| 122 } // namespace webrtc | 133 } // namespace webrtc |
| 123 | 134 |
| 124 #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_G711_AUDIO_ENCODER_PCM_H_ | 135 #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_G711_AUDIO_ENCODER_PCM_H_ |
| OLD | NEW |