arduino-audio-tools
All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Modules Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
HLSStreamT< URLStream > Class Template Reference

HTTP Live Streaming using HLS: The resulting .ts data is provided via readBytes() that dynamically reload new Segments. Please note that this reloading adds a considerable delay: So if you want to play back the audio, you should buffer the content in a seaparate task. More...

#include <HLSStream.h>

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

Public Member Functions

 HLSStreamT ()=default
 Empty constructor.
 
 HLSStreamT (const char *ssid, const char *password)
 Convenience constructor which logs in to the WiFi.
 
virtual void addNotifyAudioChange (AudioInfoSupport &bi)
 Adds target to be notified about audio changes.
 
virtual AudioInfo audioInfo () override
 provides the actual input AudioInfo
 
virtual AudioInfo audioInfoOut ()
 
int available () override
 Provides number of available bytes in the read buffer.
 
int availableForWrite () override
 Writes are not supported.
 
bool begin ()
 Reopens the last url.
 
bool begin (const char *urlStr)
 Open an HLS url.
 
virtual void clearNotifyAudioChange ()
 Deletes all change notify subscriptions.
 
const char * codec ()
 Returns the string representation of the codec of the audio stream.
 
int contentLength ()
 Provides the content length of the actual .ts Segment.
 
const char * contentType ()
 Provides the content type from the http reply.
 
void end ()
 ends the request
 
virtual void flush () override
 
const char * getReplyHeader (const char *header)
 
bool isNotifyActive ()
 Checks if the automatic AudioInfo update is active.
 
virtual operator bool ()
 
size_t readBytes (uint8_t *data, size_t len) override
 Provides the data fro the next .ts Segment.
 
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 setBufferSize (int size, int count)
 Redefines the read buffer size.
 
void setCACert (const char *cert)
 Defines the certificate.
 
void setConnectionClose (bool flag) override
 not implemented
 
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 setPassword (const char *password)
 Sets the password that will be used for logging in (when calling begin)
 
void setPowerSave (bool flag)
 Changes the Wifi to power saving mode.
 
void setSSID (const char *ssid)
 Sets the ssid that will be used for logging in (when calling begin)
 
void setURLResolver (const char *(*cb)(const char *segment, const char *reqURL))
 
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
 not implemented
 
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

void addRequestHeader (const char *header, const char *value)
 Not implemented.
 
bool begin (const char *urlStr, const char *acceptMime, MethodID action=GET, const char *reqMime="", const char *reqData="")
 Added to comply with AbstractURLStream.
 
HttpRequesthttpRequest ()
 provides access to the HttpRequest
 
void login ()
 
virtual int not_supported (int out, const char *msg="")
 
void notifyAudioChange (AudioInfo info)
 
void refillReadBuffer ()
 
void setClient (Client &clientPar)
 Not implemented: potential future improvement.
 

Protected Attributes

int _timeout = 10
 
AudioInfo info
 
bool is_notify_active = true
 
Vector< AudioInfoSupport * > notify_vector
 
audio_tools_hls::HLSParser< URLStreamparser
 
const char * password = nullptr
 
const char * ssid = nullptr
 
RingBuffer< uint8_t > tmp_in {0}
 
RingBuffer< uint8_t > tmp_out {0}
 

Detailed Description

template<typename URLStream>
class audio_tools::HLSStreamT< URLStream >

HTTP Live Streaming using HLS: The resulting .ts data is provided via readBytes() that dynamically reload new Segments. Please note that this reloading adds a considerable delay: So if you want to play back the audio, you should buffer the content in a seaparate task.

Author
Phil Schatzmann *@

Member Function Documentation

◆ addNotifyAudioChange()

virtual void addNotifyAudioChange ( AudioInfoSupport bi)
inlinevirtualinherited

◆ addRequestHeader()

template<typename URLStream >
void addRequestHeader ( const char *  header,
const char *  value 
)
inlineprotectedvirtual

Not implemented.

Implements AbstractURLStream.

◆ audioInfo()

virtual AudioInfo audioInfo ( )
inlineoverridevirtualinherited

◆ audioInfoOut()

virtual AudioInfo audioInfoOut ( )
inlinevirtualinherited

◆ available()

template<typename URLStream >
int available ( )
inlineoverridevirtual

Provides number of available bytes in the read buffer.

Reimplemented from BaseStream.

◆ availableForWrite()

int availableForWrite ( )
inlineoverridevirtualinherited

Writes are not supported.

Reimplemented from BaseStream.

Reimplemented in URLStreamESP32.

◆ begin() [1/2]

template<typename URLStream >
bool begin ( )
inlinevirtual

Reopens the last url.

Reimplemented from BaseStream.

◆ begin() [2/2]

template<typename URLStream >
bool begin ( const char *  urlStr,
const char *  acceptMime,
MethodID  action = GET,
const char *  reqMime = "",
const char *  reqData = "" 
)
inlineprotectedvirtual

Added to comply with AbstractURLStream.

Implements AbstractURLStream.

◆ contentLength()

template<typename URLStream >
int contentLength ( )
inlinevirtual

Provides the content length of the actual .ts Segment.

Implements AbstractURLStream.

◆ end()

template<typename URLStream >
void end ( )
inlinevirtual

ends the request

Implements AbstractURLStream.

◆ flush()

virtual void flush ( )
inlineoverridevirtualinherited

Reimplemented from Print.

Reimplemented in ResampleStream, BufferedTaskStream, and BufferedStream.

◆ getReplyHeader()

template<typename URLStream >
const char * getReplyHeader ( const char *  header)
inlinevirtual

Custom logic to provide the codec as Content-Type to support the MultiCodec

Implements AbstractURLStream.

◆ httpRequest()

template<typename URLStream >
HttpRequest & httpRequest ( )
inlineprotectedvirtual

provides access to the HttpRequest

Implements AbstractURLStream.

◆ operator bool()

virtual operator bool ( )
inlinevirtualinherited

Reimplemented in A2DPStream, Pipeline, I2SStream, and MemoryStream.

◆ readBytes()

template<typename URLStream >
size_t readBytes ( uint8_t *  data,
size_t  len 
)
inlineoverridevirtual

Provides the data fro the next .ts Segment.

Reimplemented from AudioStream.

◆ setAudioInfo()

virtual void setAudioInfo ( AudioInfo  info)
inlineoverridevirtualinherited

◆ setCACert()

template<typename URLStream >
void setCACert ( const char *  cert)
inlinevirtual

Defines the certificate.

Implements AbstractURLStream.

◆ setClient()

template<typename URLStream >
void setClient ( Client clientPar)
inlineprotectedvirtual

Not implemented: potential future improvement.

Implements AbstractURLStream.

◆ setConnectionClose()

template<typename URLStream >
void setConnectionClose ( bool  flag)
inlineoverridevirtual

not implemented

Implements AbstractURLStream.

◆ setMetadataCallback()

virtual bool setMetadataCallback ( void(*)(MetaDataType info, const char *str, int len)  fn)
inlinevirtualinherited

Reimplemented in ICYStreamT< T >.

◆ setPassword()

template<typename URLStream >
void setPassword ( const char *  password)
inlinevirtual

Sets the password that will be used for logging in (when calling begin)

Implements AbstractURLStream.

◆ setPowerSave()

template<typename URLStream >
void setPowerSave ( bool  flag)
inlinevirtual

Changes the Wifi to power saving mode.

Implements AbstractURLStream.

◆ setSSID()

template<typename URLStream >
void setSSID ( const char *  ssid)
inlinevirtual

Sets the ssid that will be used for logging in (when calling begin)

Implements AbstractURLStream.

◆ setURLResolver()

template<typename URLStream >
void setURLResolver ( const char *(*)(const char *segment, const char *reqURL)  cb)
inline

The resolving of relative addresses can be quite tricky: you can provide your custom resolver implementation

◆ totalRead()

template<typename URLStream >
size_t totalRead ( )
inlineoverridevirtual

Total amout of data that was consumed so far.

Implements AbstractURLStream.

◆ urlStr()

template<typename URLStream >
const char * urlStr ( )
inlineoverridevirtual

Provides the url as string.

Implements AbstractURLStream.

◆ waitForData()

template<typename URLStream >
bool waitForData ( int  timeout)
inlineoverridevirtual

not implemented

Implements AbstractURLStream.

◆ write() [1/2]

virtual size_t write ( const uint8_t *  data,
size_t  len 
)
inlineoverridevirtualinherited

◆ write() [2/2]

virtual size_t write ( uint8_t  ch)
inlineoverridevirtualinherited

Reimplemented in BufferedTaskStream, and BufferedStream.


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