Converts any AudioDecoder to a StreamingDecoder.
More...
#include <StreamingDecoder.h>
Converts any AudioDecoder to a StreamingDecoder.
This adapter class allows you to use any existing AudioDecoder with the StreamingDecoder interface. It handles the conversion between the write-based AudioDecoder API and the stream-based StreamingDecoder API by using an internal buffer.
- Note
- The adapter reads data from the input stream into a buffer, then feeds that data to the wrapped AudioDecoder using its write() method.
- Author
- Phil Schatzmann
- Copyright
- GPLv3
◆ StreamingDecoderAdapter()
Constructor.
- Parameters
-
| decoder | The AudioDecoder to wrap |
| mimeStr | The MIME type string for this decoder |
| copySize | Buffer size for data transfer (default: DEFAULT_BUFFER_SIZE) |
◆ addNotifyAudioChange()
Adds target to be notified about audio changes.
Reimplemented in CodecNOP, EncodedAudioOutput, EncodedAudioStream, AACDecoderFDK, DecoderBasic, CodecChain, MP3DecoderHelix, MP3DecoderMAD, OggContainerDecoder, RTSPClient< TcpClient, UdpSocket >, Pipeline, and Pipeline::ModifyingStreamAdapter.
◆ audioInfo()
◆ audioInfoOut()
provides the actual output AudioInfo: this is usually the same as audioInfo() unless we use a transforming stream
Reimplemented in MP3EncoderShine, PureDataStream, PWMAudioOutput< PWMDriverT >, ChannelFormatConverterStreamT< T >, ChannelFormatConverterStream, NumberFormatConverterStreamT< TFrom, TTo >, NumberFormatConverterStream, FormatConverterStream, Pipeline, ResampleStream, and ResampleStreamT< TInterpolator >.
◆ begin()
Starts the processing.
Initializes the wrapped decoder.
- Returns
- true if initialization was successful, false otherwise
Implements StreamingDecoder.
◆ clearNotifyAudioChange()
| virtual void clearNotifyAudioChange |
( |
| ) |
|
|
inlinevirtualinherited |
◆ copy()
Process a single read operation - to be called in the loop.
Reads data from the input stream into the internal buffer, then feeds it to the wrapped AudioDecoder for processing.
- Returns
- true if data was processed successfully, false otherwise
Implements StreamingDecoder.
◆ copyAll()
Process all available data.
Convenience method that calls copy() repeatedly until all available data has been processed.
- Returns
- true if any data was processed, false if no data was available
◆ end()
Releases the reserved memory.
Calls end() on the wrapped decoder to clean up resources.
Implements StreamingDecoder.
◆ isNotifyActive()
Checks if the automatic AudioInfo update is active.
◆ mime()
Provides the MIME type.
Returns the MIME type that was defined in the constructor.
- Returns
- MIME type string
Implements StreamingDecoder.
◆ notifyAudioChange()
◆ operator bool()
| virtual operator bool |
( |
| ) |
|
|
inlineoverridevirtual |
Checks if the class is active.
- Returns
- true if the wrapped decoder is active, false otherwise
Implements StreamingDecoder.
◆ readBytes()
| size_t readBytes |
( |
uint8_t * |
data, |
|
|
size_t |
len |
|
) |
| |
|
inlineoverrideprotectedvirtual |
Reads bytes from the input stream.
- Parameters
-
| data | Buffer to store the read data |
| len | Maximum number of bytes to read |
- Returns
- Number of bytes actually read
Implements StreamingDecoder.
◆ removeNotifyAudioChange()
◆ resize()
| bool resize |
( |
size_t |
bufferSize | ) |
|
|
inline |
Adjust the buffer size.
Changes the internal buffer size. The existing content of the buffer is lost!
- Parameters
-
| bufferSize | New buffer size in bytes |
◆ setAudioInfo()
|
|
inlineoverrideprotectedvirtualinherited |
◆ setInput()
| void setInput |
( |
Stream & |
inStream | ) |
|
|
inlineinherited |
Stream Interface: Decode directly by taking data from the stream.
This is more efficient than feeding the decoder with write: just call copy() in the loop to process data from the input stream.
- Parameters
-
| inStream | The input stream containing encoded audio data |
◆ setNotifyActive()
| void setNotifyActive |
( |
bool |
flag | ) |
|
|
inlineinherited |
Deactivate/Reactivate automatic AudioInfo updates: (default is active)
◆ setOutput() [1/3]
Defines the output streams and register to be notified.
Sets the output stream and registers for audio info change notifications.
- Parameters
-
| out_stream | The AudioOutput to write decoded audio data to |
Reimplemented in MultiStreamingDecoder.
◆ setOutput() [2/3]
Defines the output streams and register to be notified.
Sets the output stream and registers for audio info change notifications.
- Parameters
-
| out_stream | The AudioStream to write decoded audio data to |
Reimplemented in MultiStreamingDecoder.
◆ setOutput() [3/3]
| void setOutput |
( |
Print & |
out_stream | ) |
|
|
inlineoverridevirtual |
Defines the output Stream.
Sets the output stream for the wrapped decoder.
- Parameters
-
| out_stream | The output stream for decoded audio data |
Reimplemented from StreamingDecoder.
◆ buffer
Internal buffer for data transfer.
◆ info
◆ is_notify_active
| bool is_notify_active = true |
|
protectedinherited |
◆ mime_str
| const char* mime_str = nullptr |
|
protected |
◆ notify_vector
◆ p_decoder
◆ p_input
Input stream for encoded audio data.
◆ p_print
Output stream for decoded PCM data.
The documentation for this class was generated from the following file: