arduino-audio-tools
|
Icecast/Shoutcast audio stream that separates ICY metadata from audio bytes. More...
#include <ICYStreamT.h>
Public Member Functions | |
ICYStreamT (Client &clientPar, int readBufferSize=DEFAULT_BUFFER_SIZE) | |
ICYStreamT (const char *ssid, const char *password, int readBufferSize=DEFAULT_BUFFER_SIZE) | |
Default constructor. | |
ICYStreamT (int readBufferSize=DEFAULT_BUFFER_SIZE) | |
virtual void | addNotifyAudioChange (AudioInfoSupport &bi) |
Adds target to be notified about audio changes. | |
void | addRequestHeader (const char *key, const char *value) override |
Adds/Updates a request header. | |
virtual AudioInfo | audioInfo () override |
provides the actual input AudioInfo | |
virtual AudioInfo | audioInfoOut () |
virtual int | available () override |
Delegates available() from the underlying stream. | |
int | availableForWrite () override |
Writes are not supported. | |
virtual bool | begin () |
virtual bool | begin (const char *urlStr, const char *acceptMime=nullptr, MethodID action=GET, const char *reqMime="", const char *reqData="") override |
virtual void | clearNotifyAudioChange () |
Deletes all change notify subscriptions. | |
int | contentLength () override |
Provides the reported data size from the http reply. | |
virtual void | end () override |
Ends the processing. | |
virtual void | flush () override |
const char * | getReplyHeader (const char *key) override |
Provides reply header info. | |
virtual HttpRequest & | httpRequest () override |
provides access to the HttpRequest | |
bool | isNotifyActive () |
Checks if the automatic AudioInfo update is active. | |
const char * | mime () override |
Provides the MIME type for the current stream. | |
operator bool () | |
True if the underlying URL stream is ready/connected. | |
virtual int | read () override |
virtual size_t | readBytes (uint8_t *data, size_t len) override |
Reads audio bytes, stripping out any interleaved ICY metadata. | |
virtual size_t | readSilence (uint8_t *buffer, size_t length) |
Source to generate silence: just sets the buffer to 0. | |
virtual bool | removeNotifyAudioChange (AudioInfoSupport &bi) |
Removes a target in order not to be notified about audio changes. | |
virtual void | setAudioInfo (AudioInfo newInfo) override |
Defines the input AudioInfo. | |
void | setCACert (const char *cert) |
Define the Root PEM certificate for TLS/SSL. | |
void | setClient (Client &client) override |
(Re-)defines the client | |
void | setConnectionClose (bool flag) override |
Add Connection: close to request header. | |
virtual bool | setMetadataCallback (void(*fn)(MetaDataType info, const char *str, int len)) override |
Defines the metadata callback function. | |
void | setNotifyActive (bool flag) |
Deactivate/Reactivate automatic AudioInfo updates: (default is active) | |
void | setPassword (const char *password) override |
Sets the password that will be used for logging in (when calling begin) | |
void | setPowerSave (bool active) |
If set to true, activates power save mode at the cost of performance (ESP32 only). | |
void | setReadBufferSize (int readBufferSize) |
void | setSSID (const char *ssid) override |
Sets the ssid that will be used for logging in (when calling begin) | |
void | setWriteBufferSize (int size) |
size_t | totalRead () override |
Total amout of data that was consumed so far. | |
const char * | urlStr () override |
Provides the url as string. | |
bool | waitForData (int timeout) override |
virtual size_t | write (const uint8_t *data, size_t len) override |
virtual size_t | write (uint8_t ch) override |
virtual void | writeSilence (size_t len) |
Writes len bytes of silence (=0). | |
Protected Member Functions | |
virtual int | not_supported (int out, const char *msg="") |
void | notifyAudioChange (AudioInfo info) |
void | refillReadBuffer () |
Protected Attributes | |
int | _timeout = 10 |
void(* | callback )(MetaDataType info, const char *str, int len) = nullptr |
MetaDataICY | icy |
AudioInfo | info |
bool | is_notify_active = true |
Vector< AudioInfoSupport * > | notify_vector |
RingBuffer< uint8_t > | tmp_in {0} |
RingBuffer< uint8_t > | tmp_out {0} |
T | url |
int | write_buffer_size = MAX_SINGLE_CHARS |
Icecast/Shoutcast audio stream that separates ICY metadata from audio bytes.
ICY/Shoutcast servers interleave metadata blocks into the audio byte stream. This wrapper enables ICY metadata handling while exposing a clean audio-only stream via the standard read/available methods. Metadata is parsed by MetaDataICY and delivered through a user-supplied callback.
The class inherits from AbstractURLStream and delegates network/HTTP work to an underlying URL-like stream instance of type T. ICY support is enabled by adding the request header "Icy-MetaData: 1" and by removing metadata bytes from the returned audio stream while forwarding metadata via the callback.
Notes
T | Underlying URL stream type; must implement the AbstractURLStream interface (e.g., provide begin/end/read/available/httpRequest, credentials, headers, etc.). |
|
inlinevirtualinherited |
Adds target to be notified about audio changes.
Reimplemented in CodecNOP, EncodedAudioOutput, EncodedAudioStream, AACDecoderFDK, DecoderBasic, MP3DecoderHelix, MP3DecoderMAD, OggContainerDecoder, Pipeline, and Pipeline::ModifyingStreamAdapter.
|
inlineoverridevirtual |
Adds/Updates a request header.
Implements AbstractURLStream.
|
inlineoverridevirtualinherited |
provides the actual input AudioInfo
Implements AudioInfoSupport.
Reimplemented in JupyterAudioT< T >, MozziStream, TimerCallbackAudioStream, EncodedAudioStream, PureDataStream, AdapterAudioOutputToAudioStream, GeneratedSoundStream< T >, GeneratedSoundStream< int16_t >, and InputMerge< T >.
|
inlinevirtualinherited |
provides the actual output AudioInfo: this is usually the same as audioInfo() unless we use a transforming stream
Reimplemented in PureDataStream, PWMAudioOutput, ChannelFormatConverterStreamT< T >, ChannelFormatConverterStream, NumberFormatConverterStreamT< TFrom, TTo >, NumberFormatConverterStream, FormatConverterStream, Pipeline, ResampleStream, and ResampleStreamT< TInterpolator >.
|
inlineoverridevirtual |
Delegates available() from the underlying stream.
Reimplemented from BaseStream.
|
inlineoverridevirtualinherited |
|
inlinevirtualinherited |
Reimplemented in AudioOutputWithCallback, SPDIFOutput, VS1053Stream, WM8960Stream, ESPNowStream, Equalizer3BandsPerChannel, TimerCallbackAudioStream, FrequencyDetectorAutoCorrelation, GoertzelStream, AudioFFTBase, HLSStreamT< URLStream >, AnalogAudioArduino, AnalogAudioStream, MemoryStream, GeneratedSoundStream< T >, GeneratedSoundStream< int16_t >, FormatConverterStream, QueueStream< T >, QueueStream< uint8_t >, DynamicMemoryStream, and Pipeline.
|
inlineoverridevirtual |
Implements AbstractURLStream.
|
inlineoverridevirtual |
Provides the reported data size from the http reply.
Implements AbstractURLStream.
|
inlineoverridevirtual |
Ends the processing.
Implements AbstractURLStream.
|
inlineoverridevirtualinherited |
Reimplemented from Print.
Reimplemented in ResampleStream, BufferedTaskStream, and BufferedStream.
|
inlineoverridevirtual |
Provides reply header info.
Implements AbstractURLStream.
|
inlineoverridevirtual |
provides access to the HttpRequest
Implements AbstractURLStream.
|
inlineoverridevirtualinherited |
Provides the MIME type for the current stream.
Implements MimeSource.
|
inlinevirtual |
True if the underlying URL stream is ready/connected.
Reimplemented from AudioStream.
|
inlineoverridevirtual |
Reads audio bytes, stripping out any interleaved ICY metadata.
Reimplemented from AudioStream.
|
inlineoverridevirtualinherited |
Defines the input AudioInfo.
Implements AudioInfoSupport.
Reimplemented in VS1053Stream, WM8960Stream, ChannelFormatConverterStreamT< T >, ChannelFormatConverterStream, VolumeStream, MiniAudioStream, PortAudioStream, I2SCodecStream, MozziStream, SPDIFOutput, AudioLoRa, AnalogAudioStream, I2SStream, TimerCallbackAudioStream, AudioBLEStream, LoRaStream, AudioFFTBase, AudioKitStream, VBANStream, AnalogAudioArduino, Equalizer3Bands, Equalizer3BandsPerChannel, AdapterAudioOutputToAudioStream, TimedStream, MeasuringStream, ProgressStream, CallbackStream, VolumeMeter, FormatConverterStream, FadeStream, GoertzelStream, Pipeline::ModifyingStreamAdapter, PureDataStream, GeneratedSoundStream< T >, GeneratedSoundStream< int16_t >, NumberFormatConverterStreamT< TFrom, TTo >, NumberFormatConverterStream, Pipeline, ResampleStream, and ResampleStreamT< TInterpolator >.
|
inlinevirtual |
Define the Root PEM certificate for TLS/SSL.
Implements AbstractURLStream.
|
inlineoverridevirtual |
(Re-)defines the client
Implements AbstractURLStream.
|
inlineoverridevirtual |
Add Connection: close to request header.
Implements AbstractURLStream.
|
inlineoverridevirtual |
Defines the metadata callback function.
Reimplemented from AbstractURLStream.
|
inlineoverridevirtual |
Sets the password that will be used for logging in (when calling begin)
Implements AbstractURLStream.
|
inlinevirtual |
If set to true, activates power save mode at the cost of performance (ESP32 only).
Implements AbstractURLStream.
|
inlineoverridevirtual |
Sets the ssid that will be used for logging in (when calling begin)
Implements AbstractURLStream.
|
inlineoverridevirtual |
Total amout of data that was consumed so far.
Implements AbstractURLStream.
|
inlineoverridevirtual |
Provides the url as string.
Implements AbstractURLStream.
|
inlineoverridevirtual |
Waits the indicated time for the data to be available waits for some data - returns false if the request has failed
Implements AbstractURLStream.
|
inlineoverridevirtualinherited |
Implements BaseStream.
Reimplemented in I2SCodecStream, MozziStream, SPDIFOutput, I2SStream, A2DPStream, FaustStream< DSP >, AudioFFTBase, TfLiteAudioStream, VS1053Stream, AnalogAudioStream, AudioEffectStreamT< T >, Equalizer3Bands, Equalizer3BandsPerChannel, BufferedTaskStream, TimedStream, BufferedStream, MeasuringStream, ProgressStream, FrequencyDetectorAutoCorrelation, FrequencyDetectorZeroCrossing, GoertzelStream, ResampleStreamT< TInterpolator >, VolumeStream, DynamicResamplingQueueStream, TfLiteAudioStreamBase, and AnalogDriverESP32V2::IO16Bit.
|
inlineoverridevirtualinherited |
Reimplemented in BufferedTaskStream, and BufferedStream.