Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Side by Side Diff: webrtc/modules/audio_coding/codecs/audio_encoder.h

Issue 1864993002: Remove the deprecated EncodeInternal interface from AudioEncoder (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: AudioEncoderOpus: Renamed MaxEncodedBytes to ApproximateEncodedBytes Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 // vector. 45 // vector.
46 struct EncodedInfo : public EncodedInfoLeaf { 46 struct EncodedInfo : public EncodedInfoLeaf {
47 EncodedInfo(); 47 EncodedInfo();
48 ~EncodedInfo(); 48 ~EncodedInfo();
49 49
50 std::vector<EncodedInfoLeaf> redundant; 50 std::vector<EncodedInfoLeaf> redundant;
51 }; 51 };
52 52
53 virtual ~AudioEncoder() = default; 53 virtual ~AudioEncoder() = default;
54 54
55 // Returns the maximum number of bytes that can be produced by the encoder
56 // at each Encode() call. The caller can use the return value to determine
57 // the size of the buffer that needs to be allocated. This value is allowed
58 // to depend on encoder parameters like bitrate, frame size etc., so if
59 // any of these change, the caller of Encode() is responsible for checking
60 // that the buffer is large enough by calling MaxEncodedBytes() again.
61 virtual size_t MaxEncodedBytes() const = 0;
62
63 // Returns the input sample rate in Hz and the number of input channels. 55 // Returns the input sample rate in Hz and the number of input channels.
64 // These are constants set at instantiation time. 56 // These are constants set at instantiation time.
65 virtual int SampleRateHz() const = 0; 57 virtual int SampleRateHz() const = 0;
66 virtual size_t NumChannels() const = 0; 58 virtual size_t NumChannels() const = 0;
67 59
68 // Returns the rate at which the RTP timestamps are updated. The default 60 // Returns the rate at which the RTP timestamps are updated. The default
69 // implementation returns SampleRateHz(). 61 // implementation returns SampleRateHz().
70 virtual int RtpTimestampRateHz() const; 62 virtual int RtpTimestampRateHz() const;
71 63
72 // Returns the number of 10 ms frames the encoder will put in the next 64 // Returns the number of 10 ms frames the encoder will put in the next
(...skipping 15 matching lines...) Expand all
88 // Accepts one 10 ms block of input audio (i.e., SampleRateHz() / 100 * 80 // Accepts one 10 ms block of input audio (i.e., SampleRateHz() / 100 *
89 // NumChannels() samples). Multi-channel audio must be sample-interleaved. 81 // NumChannels() samples). Multi-channel audio must be sample-interleaved.
90 // The encoder appends zero or more bytes of output to |encoded| and returns 82 // The encoder appends zero or more bytes of output to |encoded| and returns
91 // additional encoding information. Encode() checks some preconditions, calls 83 // additional encoding information. Encode() checks some preconditions, calls
92 // EncodeImpl() which does the actual work, and then checks some 84 // EncodeImpl() which does the actual work, and then checks some
93 // postconditions. 85 // postconditions.
94 EncodedInfo Encode(uint32_t rtp_timestamp, 86 EncodedInfo Encode(uint32_t rtp_timestamp,
95 rtc::ArrayView<const int16_t> audio, 87 rtc::ArrayView<const int16_t> audio,
96 rtc::Buffer* encoded); 88 rtc::Buffer* encoded);
97 89
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
100 // returns additional encoding information. The caller is responsible for
101 // making sure that |max_encoded_bytes| is not smaller than the number of
102 // bytes actually produced by the encoder.
103 RTC_DEPRECATED EncodedInfo Encode(uint32_t rtp_timestamp,
104 rtc::ArrayView<const int16_t> audio,
105 size_t max_encoded_bytes,
106 uint8_t* encoded);
107
108 EncodedInfo DEPRECATED_Encode(uint32_t rtp_timestamp,
109 rtc::ArrayView<const int16_t> audio,
110 size_t max_encoded_bytes,
111 uint8_t* encoded);
112
113 // Deprecated interface EncodeInternal (see bug 5591). May incur a copy.
114 // Subclasses implement this to perform the actual encoding. Called by
115 // Encode(). By default, this is implemented as a call to the newer
116 // EncodeImpl() that accepts an rtc::Buffer instead of a raw pointer.
117 // That version is protected, so see below. At least one of EncodeInternal
118 // or EncodeImpl _must_ be implemented by a subclass.
119 virtual EncodedInfo EncodeInternal(
120 uint32_t rtp_timestamp,
121 rtc::ArrayView<const int16_t> audio,
122 size_t max_encoded_bytes,
123 uint8_t* encoded);
124
125 // Resets the encoder to its starting state, discarding any input that has 90 // 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. 91 // been fed to the encoder but not yet emitted in a packet.
127 virtual void Reset() = 0; 92 virtual void Reset() = 0;
128 93
129 // Enables or disables codec-internal FEC (forward error correction). Returns 94 // Enables or disables codec-internal FEC (forward error correction). Returns
130 // true if the codec was able to comply. The default implementation returns 95 // true if the codec was able to comply. The default implementation returns
131 // true when asked to disable FEC and false when asked to enable it (meaning 96 // true when asked to disable FEC and false when asked to enable it (meaning
132 // that FEC isn't supported). 97 // that FEC isn't supported).
133 virtual bool SetFec(bool enable); 98 virtual bool SetFec(bool enable);
134 99
(...skipping 20 matching lines...) Expand all
155 // does nothing. 120 // does nothing.
156 virtual void SetProjectedPacketLossRate(double fraction); 121 virtual void SetProjectedPacketLossRate(double fraction);
157 122
158 // Tells the encoder what average bitrate we'd like it to produce. The 123 // 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 124 // encoder is free to adjust or disregard the given bitrate (the default
160 // implementation does the latter). 125 // implementation does the latter).
161 virtual void SetTargetBitrate(int target_bps); 126 virtual void SetTargetBitrate(int target_bps);
162 127
163 protected: 128 protected:
164 // Subclasses implement this to perform the actual encoding. Called by 129 // Subclasses implement this to perform the actual encoding. Called by
165 // Encode(). For compatibility reasons, this is implemented by default as a 130 // Encode().
166 // call to the older interface EncodeInternal(). At least one of
167 // EncodeInternal or EncodeImpl _must_ be implemented by a
168 // subclass. Preferably this one.
169 virtual EncodedInfo EncodeImpl(uint32_t rtp_timestamp, 131 virtual EncodedInfo EncodeImpl(uint32_t rtp_timestamp,
170 rtc::ArrayView<const int16_t> audio, 132 rtc::ArrayView<const int16_t> audio,
171 rtc::Buffer* encoded); 133 rtc::Buffer* encoded) = 0;
134
135 private:
136 // This function is deprecated. It was used to return the maximum number of
137 // bytes that can be produced by the encoder at each Encode() call. Since the
138 // Encode interface was changed to use rtc::Buffer, this is no longer
139 // applicable. It is only kept in to avoid breaking subclasses that still have
140 // it implemented (with the override attribute). It will be removed as soon
141 // as these subclasses have been given a chance to change.
142 virtual size_t MaxEncodedBytes() const;
172 }; 143 };
173 } // namespace webrtc 144 } // namespace webrtc
174 #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_AUDIO_ENCODER_H_ 145 #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_AUDIO_ENCODER_H_
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/acm2/audio_coding_module_impl.cc ('k') | webrtc/modules/audio_coding/codecs/audio_encoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698