arduino-audio-tools
|
Represents the content of a URL as Stream. We use the WiFi.h API. If you run into performance issues, check if the data is provided chunked. In this chase you can check if setting the protocol to "HTTP/1.0" improves the situation. More...
#include <URLStream.h>
Public Member Functions | |
URLStream (Client &clientPar, int readBufferSize=DEFAULT_BUFFER_SIZE) | |
URLStream (const char *network, const char *password, int readBufferSize=DEFAULT_BUFFER_SIZE) | |
URLStream (const URLStream &)=delete | |
URLStream (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) |
Adds/Updates a request header. | |
virtual AudioInfo | audioInfo () override |
provides the actual input AudioInfo | |
virtual AudioInfo | audioInfoOut () |
virtual int | available () override |
int | availableForWrite () override |
Writes are not supported. | |
virtual bool | begin () |
virtual bool | begin (const char *urlStr, const char *acceptMime, MethodID action, const char *reqMime, Stream &reqData, int len=-1) |
Execute e.g. http POST request which submits the content as a stream. | |
virtual bool | begin (const char *urlStr, const char *acceptMime=nullptr, MethodID action=GET, const char *reqMime="", const char *reqData="") override |
Execute http request: by default we use a GET request. | |
void | clear () |
Releases the memory from the request and reply. | |
virtual void | clearNotifyAudioChange () |
Deletes all change notify subscriptions. | |
int | contentLength () override |
Provides the reported data size from the http reply. | |
virtual void | end () override |
virtual void | flush () override |
const char * | getReplyHeader (const char *key) |
Provides reply header information. | |
virtual HttpRequest & | httpRequest () override |
provides access to the HttpRequest | |
bool | isNotifyActive () |
Checks if the automatic AudioInfo update is active. | |
operator bool () | |
virtual int | peek () override |
virtual int | read () override |
virtual size_t | readBytes (uint8_t *data, size_t len) override |
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 | setAutoCreateLines (bool flag) |
If set to true, new undefined reply parameters will be stored. | |
void | setCACert (const char *cert) override |
Define the Root PEM Certificate for SSL. | |
void | setClient (Client &clientPar) override |
(Re-)defines the client | |
void | setConnectionClose (bool close) |
Sets if the connection should be close automatically. | |
virtual bool | setMetadataCallback (void(*fn)(MetaDataType info, const char *str, int len)) |
void | setNotifyActive (bool flag) |
Deactivate/Reactivate automatic AudioInfo updates: (default is active) | |
void | setOnConnectCallback (void(*callback)(HttpRequest &request, Url &url, HttpRequestHeader &request_header)) |
Callback which allows you to add additional paramters dynamically. | |
void | setPassword (const char *password) override |
Sets the password that will be used for logging in (when calling begin) | |
void | setPowerSave (bool ps) |
void | setReadBufferSize (int readBufferSize) |
Defines the buffer that is used by individual read() or peek() calls. | |
void | setSSID (const char *ssid) override |
Sets the ssid that will be used for logging in (when calling begin) | |
virtual void | setTimeout (int ms) |
Defines the client timeout. | |
void | setWaitForData (bool flag) |
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 |
waits for some data - returns false if the request has failed | |
virtual size_t | write (const uint8_t *, size_t len) override |
virtual size_t | write (uint8_t) override |
virtual void | writeSilence (size_t len) |
Writes len bytes of silence (=0). | |
Protected Member Functions | |
void | fillBuffer () |
Client & | getClient (bool isSecure) |
Determines the client. | |
bool | isEOS () |
bool | login () |
virtual int | not_supported (int out, const char *msg="") |
void | notifyAudioChange (AudioInfo info) |
bool | preProcess (const char *urlStr, const char *acceptMime) |
template<typename T > | |
int | process (MethodID action, Url &url, const char *reqMime, T reqData, int len=-1) |
Process the Http request and handle redirects. | |
void | refillReadBuffer () |
Protected Attributes | |
int | _timeout = 10 |
bool | active = false |
Client * | client = nullptr |
WiFiClient * | clientInsecure = nullptr |
int | clientTimeout = URL_CLIENT_TIMEOUT |
unsigned long | handshakeTimeout = URL_HANDSHAKE_TIMEOUT |
AudioInfo | info |
bool | is_notify_active = true |
bool | is_power_save = false |
const char * | network = nullptr |
Vector< AudioInfoSupport * > | notify_vector |
const char * | password = nullptr |
Vector< uint8_t > | read_buffer {0} |
uint16_t | read_buffer_size = DEFAULT_BUFFER_SIZE |
uint16_t | read_pos |
uint16_t | read_size |
HttpRequest | request |
long | size |
RingBuffer< uint8_t > | tmp_in {0} |
RingBuffer< uint8_t > | tmp_out {0} |
long | total_read |
Url | url |
Str | url_str |
bool | wait_for_data = true |
Represents the content of a URL as Stream. We use the WiFi.h API. If you run into performance issues, check if the data is provided chunked. In this chase you can check if setting the protocol to "HTTP/1.0" improves the situation.
|
inlinevirtualinherited |
Adds target to be notified about audio changes.
Reimplemented in CodecNOP, MP3DecoderMAD, EncodedAudioOutput, EncodedAudioStream, AACDecoderFDK, DecoderBasic, MP3DecoderHelix, OggContainerDecoder, Pipeline, and Pipeline::ModifyingStreamAdapter.
|
inlinevirtual |
Adds/Updates a request header.
Implements AbstractURLStream.
|
inlineoverridevirtualinherited |
provides the actual input AudioInfo
Implements AudioInfoSupport.
Reimplemented in JupyterAudioT< T >, MozziStream, TimerCallbackAudioStream, 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, and ResampleStream.
|
inlineoverridevirtual |
Reimplemented from BaseStream.
|
inlineoverridevirtualinherited |
|
inlinevirtualinherited |
Reimplemented in AudioOutputWithCallback, HLSStreamT< URLStream >, SPDIFOutput, VS1053Stream, WM8960Stream, ESPNowStream, TimerCallbackAudioStream, QueueStream< T >, QueueStream< uint8_t >, DynamicMemoryStream, AudioFFTBase, AnalogAudioArduino, AnalogAudioStream, MemoryStream, GeneratedSoundStream< T >, GeneratedSoundStream< int16_t >, FormatConverterStream, and Pipeline.
|
inlineoverridevirtual |
Execute http request: by default we use a GET request.
Implements AbstractURLStream.
|
inlineoverridevirtual |
Provides the reported data size from the http reply.
Implements AbstractURLStream.
|
inlineoverridevirtual |
Implements AbstractURLStream.
|
inlineoverridevirtual |
Reimplemented from BaseStream.
|
inlinevirtual |
Provides reply header information.
Implements AbstractURLStream.
|
inlineoverridevirtual |
provides access to the HttpRequest
Implements AbstractURLStream.
|
inlinevirtual |
Reimplemented from AudioStream.
|
inlineoverridevirtual |
Reimplemented from AudioStream.
|
inlineoverridevirtualinherited |
Defines the input AudioInfo.
Implements AudioInfoSupport.
Reimplemented in VS1053Stream, WM8960Stream, I2SBitBang, ChannelFormatConverterStreamT< T >, ChannelFormatConverterStream, VolumeStream, MiniAudioStream, PortAudioStream, I2SCodecStream, MozziStream, SPDIFOutput, AudioLoRa, AnalogAudioStream, I2SStream, MeasuringStream, VolumeMeter, TimerCallbackAudioStream, AudioBLEStream, LoRaStream, AudioFFTBase, AudioKitStream, VBANStream, AnalogAudioArduino, Equalizer3Bands, AdapterAudioOutputToAudioStream, TimedStream, ProgressStream, FormatConverterStream, FadeStream, Pipeline::ModifyingStreamAdapter, PureDataStream, GeneratedSoundStream< T >, GeneratedSoundStream< int16_t >, NumberFormatConverterStreamT< TFrom, TTo >, NumberFormatConverterStream, Pipeline, and ResampleStream.
|
inlineoverridevirtual |
Define the Root PEM Certificate for SSL.
Implements AbstractURLStream.
|
inlineoverridevirtual |
(Re-)defines the client
Implements AbstractURLStream.
|
inlinevirtual |
Sets if the connection should be close automatically.
Implements AbstractURLStream.
|
inlinevirtualinherited |
Reimplemented in ICYStreamT< T >.
|
inlineoverridevirtual |
Sets the password that will be used for logging in (when calling begin)
Implements AbstractURLStream.
|
inlinevirtual |
if set to true, it activates the power save mode which comes at the cost of performance! - By default this is deactivated. 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 for some data - returns false if the request has failed
Implements AbstractURLStream.
|
inlineoverridevirtual |
Reimplemented from AudioStream.
|
inlineoverridevirtual |
Reimplemented from BaseStream.