arduino-audio-tools
Loading...
Searching...
No Matches
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 MimeSource 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 () override
 Reopens the last url.
 
bool begin (const char *urlStr)
 Open an HLS url.
 
virtual void clearNotifyAudioChange ()
 Deletes all change notify subscriptions.
 
const charcodec ()
 Returns the string representation of the codec of the audio stream.
 
int contentLength () override
 Provides the content length of the actual .ts Segment.
 
const charcontentType ()
 Provides the content type from the http reply.
 
void end () override
 ends the request
 
virtual void flush () override
 
const chargetReplyHeader (const char *header) override
 
bool isNotifyActive ()
 Checks if the automatic AudioInfo update is active.
 
const charmime () override
 Provides the MIME type for the current stream.
 
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) override
 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) override
 Sets the password that will be used for logging in (when calling begin)
 
void setPowerSave (bool flag) override
 Changes the Wifi to power saving mode.
 
void setSSID (const char *ssid) override
 Sets the ssid that will be used for logging in (when calling begin)
 
void setURLResolver (const char *(*cb)(const char *segment, const char *reqURL))
 
void setWriteBufferSize (int size)
 
size_t totalRead () override
 Total amout of data that was consumed so far.
 
const charurlStr () 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) override
 Not implemented.
 
bool begin (const char *urlStr, const char *acceptMime, MethodID action=GET, const char *reqMime="", const char *reqData="") override
 Added to comply with AbstractURLStream.
 
HttpRequesthttpRequest () override
 provides access to the HttpRequest
 
void login ()
 
virtual int not_supported (int out, const char *msg="")
 
void notifyAudioChange (AudioInfo info)
 
void refillReadBuffer ()
 Refill small read buffer (e.g. 8 bytes) to avoid single byte reads when calling read()
 
void setClient (Client &clientPar) override
 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 charpassword = nullptr
 
const charssid = nullptr
 
RingBuffer< uint8_ttmp_in {0}
 
RingBuffer< uint8_ttmp_out {0}
 
int write_buffer_size = MAX_SINGLE_CHARS
 

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

Constructor & Destructor Documentation

◆ HLSStreamT() [1/2]

template<typename URLStream >
HLSStreamT ( )
default

Empty constructor.

◆ HLSStreamT() [2/2]

template<typename URLStream >
HLSStreamT ( const char ssid,
const char password 
)
inline

Convenience constructor which logs in to the WiFi.

Member Function Documentation

◆ addNotifyAudioChange()

virtual void addNotifyAudioChange ( AudioInfoSupport bi)
inlinevirtualinherited

◆ addRequestHeader()

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

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/3]

template<typename URLStream >
bool begin ( )
inlineoverridevirtual

Reopens the last url.

Reimplemented from BaseStream.

◆ begin() [2/3]

template<typename URLStream >
bool begin ( const char urlStr)
inline

Open an HLS url.

◆ begin() [3/3]

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

Added to comply with AbstractURLStream.

Implements AbstractURLStream.

◆ clearNotifyAudioChange()

virtual void clearNotifyAudioChange ( )
inlinevirtualinherited

Deletes all change notify subscriptions.

Reimplemented in RTSPClient< TcpClient, UdpSocket >.

◆ codec()

template<typename URLStream >
const char * codec ( )
inline

Returns the string representation of the codec of the audio stream.

◆ contentLength()

template<typename URLStream >
int contentLength ( )
inlineoverridevirtual

Provides the content length of the actual .ts Segment.

Implements AbstractURLStream.

◆ contentType()

template<typename URLStream >
const char * contentType ( )
inline

Provides the content type from the http reply.

◆ end()

template<typename URLStream >
void end ( )
inlineoverridevirtual

ends the request

Implements AbstractURLStream.

◆ flush()

virtual void flush ( )
inlineoverridevirtualinherited

◆ getReplyHeader()

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

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

Implements AbstractURLStream.

◆ httpRequest()

template<typename URLStream >
HttpRequest & httpRequest ( )
inlineoverrideprotectedvirtual

provides access to the HttpRequest

Implements AbstractURLStream.

◆ isNotifyActive()

bool isNotifyActive ( )
inlineinherited

Checks if the automatic AudioInfo update is active.

◆ login()

template<typename URLStream >
void login ( )
inlineprotected

◆ mime()

const char * mime ( )
inlineoverridevirtualinherited

Provides the MIME type for the current stream.

Implements MimeSource.

◆ not_supported()

virtual int not_supported ( int  out,
const char msg = "" 
)
inlineprotectedvirtualinherited

◆ notifyAudioChange()

void notifyAudioChange ( AudioInfo  info)
inlineprotectedinherited

◆ operator bool()

virtual operator bool ( )
inlinevirtualinherited

◆ 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.

◆ readSilence()

virtual size_t readSilence ( uint8_t buffer,
size_t  length 
)
inlinevirtualinherited

Source to generate silence: just sets the buffer to 0.

◆ refillReadBuffer()

void refillReadBuffer ( )
inlineprotectedinherited

Refill small read buffer (e.g. 8 bytes) to avoid single byte reads when calling read()

◆ removeNotifyAudioChange()

virtual bool removeNotifyAudioChange ( AudioInfoSupport bi)
inlinevirtualinherited

Removes a target in order not to be notified about audio changes.

Reimplemented in RTSPClient< TcpClient, UdpSocket >.

◆ setAudioInfo()

virtual void setAudioInfo ( AudioInfo  info)
inlineoverridevirtualinherited

◆ setBufferSize()

template<typename URLStream >
void setBufferSize ( int  size,
int  count 
)
inline

Redefines the read buffer size.

◆ setCACert()

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

Defines the certificate.

Implements AbstractURLStream.

◆ setClient()

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

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 ICYStreamBuffered, and ICYStreamT< T >.

◆ setNotifyActive()

void setNotifyActive ( bool  flag)
inlineinherited

Deactivate/Reactivate automatic AudioInfo updates: (default is active)

◆ setPassword()

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

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

Implements AbstractURLStream.

◆ setPowerSave()

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

Changes the Wifi to power saving mode.

Implements AbstractURLStream.

◆ setSSID()

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

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

◆ setWriteBufferSize()

void setWriteBufferSize ( int  size)
inlineinherited

◆ 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

◆ writeSilence()

virtual void writeSilence ( size_t  len)
inlinevirtualinherited

Writes len bytes of silence (=0).

Member Data Documentation

◆ _timeout

int _timeout = 10
protectedinherited

◆ info

AudioInfo info
protectedinherited

◆ is_notify_active

bool is_notify_active = true
protectedinherited

◆ notify_vector

Vector<AudioInfoSupport*> notify_vector
protectedinherited

◆ parser

◆ password

template<typename URLStream >
const char* password = nullptr
protected

◆ ssid

template<typename URLStream >
const char* ssid = nullptr
protected

◆ tmp_in

RingBuffer<uint8_t> tmp_in {0}
protectedinherited

◆ tmp_out

RingBuffer<uint8_t> tmp_out {0}
protectedinherited

◆ write_buffer_size

int write_buffer_size = MAX_SINGLE_CHARS
protectedinherited

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