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 // Returns a pointer to a statically allocated string with the codec | |
59 // name, e.g. "g711A" or "g711U". The default implementation returns | |
60 // null, which means no name. Used to set | |
61 // EncodedInfoLeaf::encoder_name in AudioEncoderPcm::EncodeImpl | |
62 virtual const char* GetCodecName() const; | |
ossu
2016/05/12 12:50:14
I think this should have a name that refers to log
aleloi
2016/05/12 13:25:47
The names in WebRTC and histograms.xml do not have
| |
63 | |
58 private: | 64 private: |
59 const int sample_rate_hz_; | 65 const int sample_rate_hz_; |
60 const size_t num_channels_; | 66 const size_t num_channels_; |
61 const int payload_type_; | 67 const int payload_type_; |
62 const size_t num_10ms_frames_per_packet_; | 68 const size_t num_10ms_frames_per_packet_; |
63 const size_t full_frame_samples_; | 69 const size_t full_frame_samples_; |
64 std::vector<int16_t> speech_buffer_; | 70 std::vector<int16_t> speech_buffer_; |
65 uint32_t first_timestamp_in_buffer_; | 71 uint32_t first_timestamp_in_buffer_; |
66 }; | 72 }; |
67 | 73 |
68 struct CodecInst; | 74 struct CodecInst; |
69 | 75 |
70 class AudioEncoderPcmA final : public AudioEncoderPcm { | 76 class AudioEncoderPcmA final : public AudioEncoderPcm { |
71 public: | 77 public: |
72 struct Config : public AudioEncoderPcm::Config { | 78 struct Config : public AudioEncoderPcm::Config { |
73 Config() : AudioEncoderPcm::Config(8) {} | 79 Config() : AudioEncoderPcm::Config(8) {} |
74 }; | 80 }; |
75 | 81 |
76 explicit AudioEncoderPcmA(const Config& config) | 82 explicit AudioEncoderPcmA(const Config& config) |
77 : AudioEncoderPcm(config, kSampleRateHz) {} | 83 : AudioEncoderPcm(config, kSampleRateHz) {} |
78 explicit AudioEncoderPcmA(const CodecInst& codec_inst); | 84 explicit AudioEncoderPcmA(const CodecInst& codec_inst); |
79 | 85 |
80 protected: | 86 protected: |
81 size_t EncodeCall(const int16_t* audio, | 87 size_t EncodeCall(const int16_t* audio, |
82 size_t input_len, | 88 size_t input_len, |
83 uint8_t* encoded) override; | 89 uint8_t* encoded) override; |
84 | 90 |
85 size_t BytesPerSample() const override; | 91 size_t BytesPerSample() const override; |
86 | 92 |
93 const char* GetCodecName() const override; | |
94 | |
87 private: | 95 private: |
88 static const int kSampleRateHz = 8000; | 96 static const int kSampleRateHz = 8000; |
89 RTC_DISALLOW_COPY_AND_ASSIGN(AudioEncoderPcmA); | 97 RTC_DISALLOW_COPY_AND_ASSIGN(AudioEncoderPcmA); |
90 }; | 98 }; |
91 | 99 |
92 class AudioEncoderPcmU final : public AudioEncoderPcm { | 100 class AudioEncoderPcmU final : public AudioEncoderPcm { |
93 public: | 101 public: |
94 struct Config : public AudioEncoderPcm::Config { | 102 struct Config : public AudioEncoderPcm::Config { |
95 Config() : AudioEncoderPcm::Config(0) {} | 103 Config() : AudioEncoderPcm::Config(0) {} |
96 }; | 104 }; |
97 | 105 |
98 explicit AudioEncoderPcmU(const Config& config) | 106 explicit AudioEncoderPcmU(const Config& config) |
99 : AudioEncoderPcm(config, kSampleRateHz) {} | 107 : AudioEncoderPcm(config, kSampleRateHz) {} |
100 explicit AudioEncoderPcmU(const CodecInst& codec_inst); | 108 explicit AudioEncoderPcmU(const CodecInst& codec_inst); |
101 | 109 |
102 protected: | 110 protected: |
103 size_t EncodeCall(const int16_t* audio, | 111 size_t EncodeCall(const int16_t* audio, |
104 size_t input_len, | 112 size_t input_len, |
105 uint8_t* encoded) override; | 113 uint8_t* encoded) override; |
106 | 114 |
107 size_t BytesPerSample() const override; | 115 size_t BytesPerSample() const override; |
108 | 116 |
117 const char* GetCodecName() const override; | |
118 | |
109 private: | 119 private: |
110 static const int kSampleRateHz = 8000; | 120 static const int kSampleRateHz = 8000; |
111 RTC_DISALLOW_COPY_AND_ASSIGN(AudioEncoderPcmU); | 121 RTC_DISALLOW_COPY_AND_ASSIGN(AudioEncoderPcmU); |
112 }; | 122 }; |
113 | 123 |
114 } // namespace webrtc | 124 } // namespace webrtc |
115 | 125 |
116 #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_G711_AUDIO_ENCODER_PCM_H_ | 126 #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_G711_AUDIO_ENCODER_PCM_H_ |
OLD | NEW |