| 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 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 uint8_t* encoded) override; | 47 uint8_t* encoded) override; |
| 48 void Reset() override; | 48 void Reset() override; |
| 49 | 49 |
| 50 protected: | 50 protected: |
| 51 AudioEncoderPcm(const Config& config, int sample_rate_hz); | 51 AudioEncoderPcm(const Config& config, int sample_rate_hz); |
| 52 | 52 |
| 53 virtual size_t EncodeCall(const int16_t* audio, | 53 virtual size_t EncodeCall(const int16_t* audio, |
| 54 size_t input_len, | 54 size_t input_len, |
| 55 uint8_t* encoded) = 0; | 55 uint8_t* encoded) = 0; |
| 56 | 56 |
| 57 virtual int BytesPerSample() const = 0; | 57 virtual size_t BytesPerSample() const = 0; |
| 58 | 58 |
| 59 private: | 59 private: |
| 60 const int sample_rate_hz_; | 60 const int sample_rate_hz_; |
| 61 const int num_channels_; | 61 const int num_channels_; |
| 62 const int payload_type_; | 62 const int payload_type_; |
| 63 const size_t num_10ms_frames_per_packet_; | 63 const size_t num_10ms_frames_per_packet_; |
| 64 const size_t full_frame_samples_; | 64 const size_t full_frame_samples_; |
| 65 std::vector<int16_t> speech_buffer_; | 65 std::vector<int16_t> speech_buffer_; |
| 66 uint32_t first_timestamp_in_buffer_; | 66 uint32_t first_timestamp_in_buffer_; |
| 67 }; | 67 }; |
| 68 | 68 |
| 69 struct CodecInst; | 69 struct CodecInst; |
| 70 | 70 |
| 71 class AudioEncoderPcmA final : public AudioEncoderPcm { | 71 class AudioEncoderPcmA final : public AudioEncoderPcm { |
| 72 public: | 72 public: |
| 73 struct Config : public AudioEncoderPcm::Config { | 73 struct Config : public AudioEncoderPcm::Config { |
| 74 Config() : AudioEncoderPcm::Config(8) {} | 74 Config() : AudioEncoderPcm::Config(8) {} |
| 75 }; | 75 }; |
| 76 | 76 |
| 77 explicit AudioEncoderPcmA(const Config& config) | 77 explicit AudioEncoderPcmA(const Config& config) |
| 78 : AudioEncoderPcm(config, kSampleRateHz) {} | 78 : AudioEncoderPcm(config, kSampleRateHz) {} |
| 79 explicit AudioEncoderPcmA(const CodecInst& codec_inst); | 79 explicit AudioEncoderPcmA(const CodecInst& codec_inst); |
| 80 | 80 |
| 81 protected: | 81 protected: |
| 82 size_t EncodeCall(const int16_t* audio, | 82 size_t EncodeCall(const int16_t* audio, |
| 83 size_t input_len, | 83 size_t input_len, |
| 84 uint8_t* encoded) override; | 84 uint8_t* encoded) override; |
| 85 | 85 |
| 86 int BytesPerSample() const override; | 86 size_t BytesPerSample() const override; |
| 87 | 87 |
| 88 private: | 88 private: |
| 89 static const int kSampleRateHz = 8000; | 89 static const int kSampleRateHz = 8000; |
| 90 RTC_DISALLOW_COPY_AND_ASSIGN(AudioEncoderPcmA); | 90 RTC_DISALLOW_COPY_AND_ASSIGN(AudioEncoderPcmA); |
| 91 }; | 91 }; |
| 92 | 92 |
| 93 class AudioEncoderPcmU final : public AudioEncoderPcm { | 93 class AudioEncoderPcmU final : public AudioEncoderPcm { |
| 94 public: | 94 public: |
| 95 struct Config : public AudioEncoderPcm::Config { | 95 struct Config : public AudioEncoderPcm::Config { |
| 96 Config() : AudioEncoderPcm::Config(0) {} | 96 Config() : AudioEncoderPcm::Config(0) {} |
| 97 }; | 97 }; |
| 98 | 98 |
| 99 explicit AudioEncoderPcmU(const Config& config) | 99 explicit AudioEncoderPcmU(const Config& config) |
| 100 : AudioEncoderPcm(config, kSampleRateHz) {} | 100 : AudioEncoderPcm(config, kSampleRateHz) {} |
| 101 explicit AudioEncoderPcmU(const CodecInst& codec_inst); | 101 explicit AudioEncoderPcmU(const CodecInst& codec_inst); |
| 102 | 102 |
| 103 protected: | 103 protected: |
| 104 size_t EncodeCall(const int16_t* audio, | 104 size_t EncodeCall(const int16_t* audio, |
| 105 size_t input_len, | 105 size_t input_len, |
| 106 uint8_t* encoded) override; | 106 uint8_t* encoded) override; |
| 107 | 107 |
| 108 int BytesPerSample() const override; | 108 size_t BytesPerSample() const override; |
| 109 | 109 |
| 110 private: | 110 private: |
| 111 static const int kSampleRateHz = 8000; | 111 static const int kSampleRateHz = 8000; |
| 112 RTC_DISALLOW_COPY_AND_ASSIGN(AudioEncoderPcmU); | 112 RTC_DISALLOW_COPY_AND_ASSIGN(AudioEncoderPcmU); |
| 113 }; | 113 }; |
| 114 | 114 |
| 115 } // namespace webrtc | 115 } // namespace webrtc |
| 116 | 116 |
| 117 #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_G711_AUDIO_ENCODER_PCM_H_ | 117 #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_G711_AUDIO_ENCODER_PCM_H_ |
| OLD | NEW |