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