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/base/constructormagic.h" | 16 #include "webrtc/base/constructormagic.h" |
17 #include "webrtc/modules/audio_coding/codecs/audio_encoder.h" | 17 #include "webrtc/modules/audio_coding/codecs/audio_encoder.h" |
18 | 18 |
19 namespace webrtc { | 19 namespace webrtc { |
20 | 20 |
21 class AudioEncoderPcm : public AudioEncoder { | 21 class AudioEncoderPcm : public AudioEncoder { |
22 public: | 22 public: |
23 using AudioEncoder::EncodeInternal; | |
24 | |
25 struct Config { | 23 struct Config { |
26 public: | 24 public: |
27 bool IsOk() const; | 25 bool IsOk() const; |
28 | 26 |
29 int frame_size_ms; | 27 int frame_size_ms; |
30 size_t num_channels; | 28 size_t num_channels; |
31 int payload_type; | 29 int payload_type; |
32 | 30 |
33 protected: | 31 protected: |
34 explicit Config(int pt) | 32 explicit Config(int pt) |
35 : frame_size_ms(20), num_channels(1), payload_type(pt) {} | 33 : frame_size_ms(20), num_channels(1), payload_type(pt) {} |
36 }; | 34 }; |
37 | 35 |
38 ~AudioEncoderPcm() override; | 36 ~AudioEncoderPcm() override; |
39 | 37 |
40 size_t MaxEncodedBytes() const override; | 38 size_t MaxEncodedBytes() const override; |
41 int SampleRateHz() const override; | 39 int SampleRateHz() const override; |
42 size_t NumChannels() const override; | 40 size_t NumChannels() const override; |
43 size_t Num10MsFramesInNextPacket() const override; | 41 size_t Num10MsFramesInNextPacket() const override; |
44 size_t Max10MsFramesInAPacket() const override; | 42 size_t Max10MsFramesInAPacket() const override; |
45 int GetTargetBitrate() const override; | 43 int GetTargetBitrate() const override; |
46 void Reset() override; | 44 void Reset() override; |
47 | 45 |
48 protected: | 46 protected: |
49 AudioEncoderPcm(const Config& config, int sample_rate_hz); | 47 AudioEncoderPcm(const Config& config, int sample_rate_hz); |
50 | 48 |
51 EncodedInfo EncodeInternal(uint32_t rtp_timestamp, | 49 EncodedInfo EncodeImpl(uint32_t rtp_timestamp, |
52 rtc::ArrayView<const int16_t> audio, | 50 rtc::ArrayView<const int16_t> audio, |
53 rtc::Buffer* encoded) override; | 51 rtc::Buffer* encoded) override; |
54 | 52 |
55 virtual size_t EncodeCall(const int16_t* audio, | 53 virtual size_t EncodeCall(const int16_t* audio, |
56 size_t input_len, | 54 size_t input_len, |
57 uint8_t* encoded) = 0; | 55 uint8_t* encoded) = 0; |
58 | 56 |
59 virtual size_t BytesPerSample() const = 0; | 57 virtual size_t BytesPerSample() const = 0; |
60 | 58 |
61 private: | 59 private: |
62 const int sample_rate_hz_; | 60 const int sample_rate_hz_; |
63 const size_t num_channels_; | 61 const size_t num_channels_; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 size_t BytesPerSample() const override; | 108 size_t BytesPerSample() const override; |
111 | 109 |
112 private: | 110 private: |
113 static const int kSampleRateHz = 8000; | 111 static const int kSampleRateHz = 8000; |
114 RTC_DISALLOW_COPY_AND_ASSIGN(AudioEncoderPcmU); | 112 RTC_DISALLOW_COPY_AND_ASSIGN(AudioEncoderPcmU); |
115 }; | 113 }; |
116 | 114 |
117 } // namespace webrtc | 115 } // namespace webrtc |
118 | 116 |
119 #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 |