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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 | 82 |
83 // Returns the current target bitrate in bits/s. The value -1 means that the | 83 // Returns the current target bitrate in bits/s. The value -1 means that the |
84 // codec adapts the target automatically, and a current target cannot be | 84 // codec adapts the target automatically, and a current target cannot be |
85 // provided. | 85 // provided. |
86 virtual int GetTargetBitrate() const = 0; | 86 virtual int GetTargetBitrate() const = 0; |
87 | 87 |
88 // Accepts one 10 ms block of input audio (i.e., SampleRateHz() / 100 * | 88 // Accepts one 10 ms block of input audio (i.e., SampleRateHz() / 100 * |
89 // NumChannels() samples). Multi-channel audio must be sample-interleaved. | 89 // NumChannels() samples). Multi-channel audio must be sample-interleaved. |
90 // The encoder appends zero or more bytes of output to |encoded| and returns | 90 // The encoder appends zero or more bytes of output to |encoded| and returns |
91 // additional encoding information. Encode() checks some preconditions, calls | 91 // additional encoding information. Encode() checks some preconditions, calls |
92 // EncodeInternal() which does the actual work, and then checks some | 92 // EncodeImpl() which does the actual work, and then checks some |
93 // postconditions. | 93 // postconditions. |
94 EncodedInfo Encode(uint32_t rtp_timestamp, | 94 EncodedInfo Encode(uint32_t rtp_timestamp, |
95 rtc::ArrayView<const int16_t> audio, | 95 rtc::ArrayView<const int16_t> audio, |
96 rtc::Buffer* encoded); | 96 rtc::Buffer* encoded); |
97 | 97 |
98 // Deprecated interface to Encode (remove eventually, bug 5591). May incur a | 98 // Deprecated interface to Encode (remove eventually, bug 5591). May incur a |
99 // copy. The encoder produces zero or more bytes of output in |encoded| and | 99 // copy. The encoder produces zero or more bytes of output in |encoded| and |
100 // returns additional encoding information. The caller is responsible for | 100 // returns additional encoding information. The caller is responsible for |
101 // making sure that |max_encoded_bytes| is not smaller than the number of | 101 // making sure that |max_encoded_bytes| is not smaller than the number of |
102 // bytes actually produced by the encoder. | 102 // bytes actually produced by the encoder. |
103 RTC_DEPRECATED EncodedInfo Encode(uint32_t rtp_timestamp, | 103 RTC_DEPRECATED EncodedInfo Encode(uint32_t rtp_timestamp, |
104 rtc::ArrayView<const int16_t> audio, | 104 rtc::ArrayView<const int16_t> audio, |
105 size_t max_encoded_bytes, | 105 size_t max_encoded_bytes, |
106 uint8_t* encoded); | 106 uint8_t* encoded); |
107 | 107 |
108 EncodedInfo DEPRECATED_Encode(uint32_t rtp_timestamp, | 108 EncodedInfo DEPRECATED_Encode(uint32_t rtp_timestamp, |
109 rtc::ArrayView<const int16_t> audio, | 109 rtc::ArrayView<const int16_t> audio, |
110 size_t max_encoded_bytes, | 110 size_t max_encoded_bytes, |
111 uint8_t* encoded); | 111 uint8_t* encoded); |
112 | 112 |
113 // Deprecated interface of EncodeInternal (also bug 5591). May incur a copy. | 113 // Deprecated interface EncodeInternal (see bug 5591). May incur a copy. |
114 // Subclasses implement this to perform the actual encoding. Called by | 114 // Subclasses implement this to perform the actual encoding. Called by |
115 // Encode(). By default, this is implemented as a call to the newer | 115 // Encode(). By default, this is implemented as a call to the newer |
116 // EncodeInternal() that accepts an rtc::Buffer instead of a raw pointer. | 116 // EncodeImpl() that accepts an rtc::Buffer instead of a raw pointer. |
117 // That version is protected, so see below. At least one of the two | 117 // That version is protected, so see below. At least one of EncodeInternal |
118 // interfaces of EncodeInternal _must_ be implemented by a subclass. | 118 // or EncodeImpl _must_ be implemented by a subclass. |
119 virtual EncodedInfo EncodeInternal( | 119 virtual EncodedInfo EncodeInternal( |
120 uint32_t rtp_timestamp, | 120 uint32_t rtp_timestamp, |
121 rtc::ArrayView<const int16_t> audio, | 121 rtc::ArrayView<const int16_t> audio, |
122 size_t max_encoded_bytes, | 122 size_t max_encoded_bytes, |
123 uint8_t* encoded); | 123 uint8_t* encoded); |
124 | 124 |
125 // Resets the encoder to its starting state, discarding any input that has | 125 // Resets the encoder to its starting state, discarding any input that has |
126 // been fed to the encoder but not yet emitted in a packet. | 126 // been fed to the encoder but not yet emitted in a packet. |
127 virtual void Reset() = 0; | 127 virtual void Reset() = 0; |
128 | 128 |
(...skipping 27 matching lines...) Expand all Loading... |
156 virtual void SetProjectedPacketLossRate(double fraction); | 156 virtual void SetProjectedPacketLossRate(double fraction); |
157 | 157 |
158 // Tells the encoder what average bitrate we'd like it to produce. The | 158 // Tells the encoder what average bitrate we'd like it to produce. The |
159 // encoder is free to adjust or disregard the given bitrate (the default | 159 // encoder is free to adjust or disregard the given bitrate (the default |
160 // implementation does the latter). | 160 // implementation does the latter). |
161 virtual void SetTargetBitrate(int target_bps); | 161 virtual void SetTargetBitrate(int target_bps); |
162 | 162 |
163 protected: | 163 protected: |
164 // Subclasses implement this to perform the actual encoding. Called by | 164 // Subclasses implement this to perform the actual encoding. Called by |
165 // Encode(). For compatibility reasons, this is implemented by default as a | 165 // Encode(). For compatibility reasons, this is implemented by default as a |
166 // call to the older version of EncodeInternal(). At least one of the two | 166 // call to the older interface EncodeInternal(). At least one of |
167 // interfaces of EncodeInternal _must_ be implemented by a subclass. | 167 // EncodeInternal or EncodeImpl _must_ be implemented by a |
168 // Preferably this one. | 168 // subclass. Preferably this one. |
169 virtual EncodedInfo EncodeInternal(uint32_t rtp_timestamp, | 169 virtual EncodedInfo EncodeImpl(uint32_t rtp_timestamp, |
170 rtc::ArrayView<const int16_t> audio, | 170 rtc::ArrayView<const int16_t> audio, |
171 rtc::Buffer* encoded); | 171 rtc::Buffer* encoded); |
172 }; | 172 }; |
173 } // namespace webrtc | 173 } // namespace webrtc |
174 #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_AUDIO_ENCODER_H_ | 174 #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_AUDIO_ENCODER_H_ |
OLD | NEW |