@@ -156,116 +156,4 @@ class CodecNOP : public AudioDecoder, public AudioEncoder {
156
156
virtual const char *mime () { return nullptr ; }
157
157
};
158
158
159
- /* *
160
- * @brief A Streaming Decoder where we provide both the input and output
161
- * as streams.
162
- * @ingroup codecs
163
- * @author Phil Schatzmann
164
- * @copyright GPLv3
165
- */
166
- class StreamingDecoder : public AudioInfoSource {
167
- public:
168
- // / Starts the processing
169
- virtual bool begin () = 0;
170
-
171
- // / Releases the reserved memory
172
- virtual void end () = 0;
173
-
174
- // / Defines the output Stream
175
- virtual void setOutput (Print &out_stream) { p_print = &out_stream; }
176
-
177
- // / Defines the output streams and register to be notified
178
- virtual void setOutput (AudioStream &out_stream) {
179
- Print *p_print = &out_stream;
180
- setOutput (*p_print);
181
- addNotifyAudioChange (out_stream);
182
- }
183
-
184
- // / Defines the output streams and register to be notified
185
- virtual void setOutput (AudioOutput &out_stream) {
186
- Print *p_print = &out_stream;
187
- setOutput (*p_print);
188
- addNotifyAudioChange (out_stream);
189
- }
190
-
191
- // / Stream Interface: Decode directly by taking data from the stream. This is
192
- // / more efficient then feeding the decoder with write: just call copy() in
193
- // / the loop
194
- void setInput (Stream &inStream) { this ->p_input = &inStream; }
195
-
196
- // / Provides the last available MP3FrameInfo
197
- virtual AudioInfo audioInfo () = 0;
198
-
199
- // / checks if the class is active
200
- virtual operator bool () = 0;
201
-
202
- // / Process a single read operation - to be called in the loop
203
- virtual bool copy () = 0;
204
-
205
- // / Process all data
206
- bool copyAll () {
207
- bool result = false ;
208
- while (copy ()) {
209
- result = true ;
210
- }
211
- return result;
212
- }
213
-
214
- protected:
215
- virtual size_t readBytes (uint8_t *data, size_t len) = 0;
216
- Print *p_print = nullptr ;
217
- Stream *p_input = nullptr ;
218
- };
219
-
220
- /* *
221
- * @brief Converts any AudioDecoder to a StreamingDecoder
222
- * @ingroup codecs
223
- * @author Phil Schatzmann
224
- * @copyright GPLv3
225
- */
226
- class StreamingDecoderAdapter : public StreamingDecoder {
227
- public:
228
- StreamingDecoderAdapter (AudioDecoder &decoder,
229
- int copySize = DEFAULT_BUFFER_SIZE) {
230
- p_decoder = &decoder;
231
- if (copySize > 0 ) resize (copySize);
232
- }
233
- // / Starts the processing
234
- bool begin () override { return p_input != nullptr && p_decoder->begin (); }
235
-
236
- // / Releases the reserved memory
237
- void end () override { p_decoder->end (); }
238
-
239
- // / Defines the output Stream
240
- void setOutput (Print &out_stream) override {
241
- p_decoder->setOutput (out_stream);
242
- }
243
-
244
- // / Provides the last available MP3FrameInfo
245
- AudioInfo audioInfo () override { return p_decoder->audioInfo (); }
246
-
247
- // / checks if the class is active
248
- virtual operator bool () override { return *p_decoder; }
249
-
250
- // / Process a single read operation - to be called in the loop
251
- virtual bool copy () override {
252
- int read = readBytes (&buffer[0 ], buffer.size ());
253
- int written = 0 ;
254
- if (read > 0 ) written = p_decoder->write (&buffer[0 ], read);
255
- return written > 0 ;
256
- }
257
-
258
- // / Adjust the buffer size: the existing content of the buffer is lost!
259
- void resize (int bufferSize) { buffer.resize (bufferSize); }
260
-
261
- protected:
262
- AudioDecoder *p_decoder = nullptr ;
263
- Vector<uint8_t > buffer{0 };
264
-
265
- size_t readBytes (uint8_t *data, size_t len) override {
266
- if (p_input == nullptr ) return 0 ;
267
- return p_input->readBytes (data, len);
268
- }
269
- };
270
-
271
159
} // namespace audio_tools
0 commit comments