Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
URLStream Class Reference

Represents the content of a URL as Stream. We use the WiFi.h API. More...

#include <URLStream.h>

Inheritance diagram for URLStream:
AbstractURLStream AudioStream BaseStream AudioInfoSupport AudioInfoSource Stream Print

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 *header, const char *value)
 Adds/Updates a request header.
virtual AudioInfo audioInfo () override
 provides the actual input AudioInfo
virtual AudioInfo audioInfoOut ()
 provides the actual output AudioInfo: this is usually the same as audioInfo() unless we use a transforming stream
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 ()
virtual void end () override
virtual void flush () override
virtual HttpRequesthttpRequest () 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 setClient (Client &clientPar) override
 (Re-)defines the client
void setConnectionClose (bool close)
 Sets if the connection should be close automatically.
void setLogLevel (AudioLogger::LogLevel level)
 Defines the class specific custom log level.
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)
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 ()
const char * urlStr ()
virtual bool waitForData (int timeout)
 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 ()
ClientgetClient (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
Clientclient = nullptr
int clientTimeout = URL_CLIENT_TIMEOUT
CustomLogLevel custom_log_level
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
StrExt url_str
bool wait_for_data = true

Detailed Description

Represents the content of a URL as Stream. We use the WiFi.h API.

Phil Schatzmann

Member Function Documentation

◆ setPowerSave()

void setPowerSave ( bool  ps)

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.

The documentation for this class was generated from the following file: