arduino-audio-tools
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
AudioWAVServerT< Client, Server > Class Template Reference

A simple Arduino Webserver which streams the audio as WAV data. This class is based on the AudioEncodedServer class. All you need to do is to provide the data with a callback method or from a Stream. More...

#include <AudioEncodedServerT.h>

Inheritance diagram for AudioWAVServerT< Client, Server >:
AudioEncoderServerT< Client, Server > AudioServerT< Client, Server >

Public Member Functions

 AudioWAVServerT (const char *network, const char *password, int port=80)
 Construct a new Audio WAV Server object.
 
 AudioWAVServerT (int port=80)
 Construct a new Audio WAV Server object We assume that the WiFi is already connected.
 
 ~AudioWAVServerT ()
 Destructor: release the allocated encoder.
 
AudioEncoderaudioEncoder ()
 
bool begin ()
 Just starts the server.
 
bool begin (AudioServerDataCallback cb, AudioInfo info)
 Start the server. The data must be provided by a callback method.
 
bool begin (AudioServerDataCallback cb, const char *contentType)
 Start the server. The data must be provided by a callback method.
 
bool begin (AudioServerDataCallback cb, int sample_rate, int channels, int bits_per_sample=16)
 Start the server. The data must be provided by a callback method.
 
bool begin (AudioStream &in, BaseConverter *converter=nullptr)
 Start the server. You need to be connected to WiFI before calling this method.
 
bool begin (Stream &in, AudioInfo info, BaseConverter *converter=nullptr)
 Start the server. You need to be connected to WiFI before calling this method.
 
bool begin (Stream &in, const char *contentType)
 Start the server. You need to be connected to WiFI before calling this method.
 
bool begin (Stream &in, int sample_rate, int channels, int bits_per_sample=16, BaseConverter *converter=nullptr)
 Start the server. You need to be connected to WiFI before calling this method.
 
bool copy ()
 Add this method to your loop Returns true while the client is connected. (The same functionality like doLoop())
 
bool doLoop ()
 Add this method to your loop Returns true while the client is connected.
 
void end ()
 Ends the connection and resets the state.
 
bool isChunked ()
 Determines if chunked transfer encoding is active.
 
bool isClientConnected ()
 Checks if any client has connected.
 
size_t maxOutputSize ()
 Provides the defined total number of bytes that will be sent.
 
 operator bool ()
 Checks if any client has connected.
 
Streamout ()
 Provides the output stream.
 
Clientout_ptr ()
 Provides a pointer to the WiFiClient.
 
void setChunked (bool flag)
 
void setContentType (const char *contentType)
 Defines the content type (MIME type) of the data that will be sent to the client. Needs to be set before calling begin().
 
void setConverter (BaseConverter *c)
 defines a converter that will be used when the audio is rendered
 
void setCopyBufferSize (int size)
 Changes the copy buffer size.
 
void setMaxOutputSize (size_t size)
 
WAVEncoderwavEncoder ()
 

Protected Member Functions

void connectWiFi ()
 
void endChunked ()
 Sends the terminating 0-length chunk when chunked transfer is active.
 
void processClient ()
 Handle an new client connection and return the data.
 
void sendReplyContent () override
 
void sendReplyHeader () override
 
void setupServer (int port)
 
bool startServer ()
 

Protected Attributes

AudioInfo audio_info
 
AudioServerDataCallback callback = nullptr
 
ChunkedPrint chunked_print
 
Client client_obj
 
const char * content_type = nullptr
 
BaseConverterconverter_ptr = nullptr
 
StreamCopy copier
 
EncodedAudioOutput encoded_stream
 
AudioEncoderencoder = nullptr
 
Streamin = nullptr
 
bool is_chunked = true
 
size_t max_output_size = 0
 
std::string network
 
std::string password
 
size_t sent = 0
 
Server server
 

Detailed Description

template<class Client, class Server>
class audio_tools::AudioWAVServerT< Client, Server >

A simple Arduino Webserver which streams the audio as WAV data. This class is based on the AudioEncodedServer class. All you need to do is to provide the data with a callback method or from a Stream.

Author
Phil Schatzmann

Constructor & Destructor Documentation

◆ AudioWAVServerT() [1/2]

template<class Client , class Server >
AudioWAVServerT ( int  port = 80)
inline

Construct a new Audio WAV Server object We assume that the WiFi is already connected.

◆ AudioWAVServerT() [2/2]

template<class Client , class Server >
AudioWAVServerT ( const char *  network,
const char *  password,
int  port = 80 
)
inline

Construct a new Audio WAV Server object.

Parameters
network
password

◆ ~AudioWAVServerT()

template<class Client , class Server >
~AudioWAVServerT ( )
inline

Destructor: release the allocated encoder.

Member Function Documentation

◆ audioEncoder()

template<class Client , class Server >
AudioEncoder * audioEncoder ( )
inlineinherited

◆ begin() [1/8]

template<class Client , class Server >
bool begin ( )
inlineinherited

Just starts the server.

◆ begin() [2/8]

template<class Client , class Server >
bool begin ( AudioServerDataCallback  cb,
AudioInfo  info 
)
inlineinherited

Start the server. The data must be provided by a callback method.

Parameters
cb
info

◆ begin() [3/8]

template<class Client , class Server >
bool begin ( AudioServerDataCallback  cb,
const char *  contentType 
)
inlineinherited

Start the server. The data must be provided by a callback method.

Parameters
cb
contentTypeMime Type of result

◆ begin() [4/8]

template<class Client , class Server >
bool begin ( AudioServerDataCallback  cb,
int  sample_rate,
int  channels,
int  bits_per_sample = 16 
)
inlineinherited

Start the server. The data must be provided by a callback method.

Parameters
cb
sample_rate
channels

◆ begin() [5/8]

template<class Client , class Server >
bool begin ( AudioStream in,
BaseConverter converter = nullptr 
)
inlineinherited

Start the server. You need to be connected to WiFI before calling this method.

Parameters
in
converter

◆ begin() [6/8]

template<class Client , class Server >
bool begin ( Stream in,
AudioInfo  info,
BaseConverter converter = nullptr 
)
inlineinherited

Start the server. You need to be connected to WiFI before calling this method.

Parameters
in
info
converter

◆ begin() [7/8]

template<class Client , class Server >
bool begin ( Stream in,
const char *  contentType 
)
inlineinherited

Start the server. You need to be connected to WiFI before calling this method.

Parameters
in
contentTypeMime Type of result

◆ begin() [8/8]

template<class Client , class Server >
bool begin ( Stream in,
int  sample_rate,
int  channels,
int  bits_per_sample = 16,
BaseConverter converter = nullptr 
)
inlineinherited

Start the server. You need to be connected to WiFI before calling this method.

Parameters
in
sample_rate
channels

◆ connectWiFi()

template<class Client , class Server >
void connectWiFi ( )
inlineprotectedinherited

◆ copy()

template<class Client , class Server >
bool copy ( )
inlineinherited

Add this method to your loop Returns true while the client is connected. (The same functionality like doLoop())

Returns
true
false

◆ doLoop()

template<class Client , class Server >
bool doLoop ( )
inlineinherited

Add this method to your loop Returns true while the client is connected.

◆ end()

template<class Client , class Server >
void end ( )
inlineinherited

Ends the connection and resets the state.

◆ endChunked()

template<class Client , class Server >
void endChunked ( )
inlineprotectedinherited

Sends the terminating 0-length chunk when chunked transfer is active.

◆ isChunked()

template<class Client , class Server >
bool isChunked ( )
inlineinherited

Determines if chunked transfer encoding is active.

◆ isClientConnected()

template<class Client , class Server >
bool isClientConnected ( )
inlineinherited

Checks if any client has connected.

◆ maxOutputSize()

template<class Client , class Server >
size_t maxOutputSize ( )
inlineinherited

Provides the defined total number of bytes that will be sent.

◆ operator bool()

template<class Client , class Server >
operator bool ( )
inlineinherited

Checks if any client has connected.

◆ out()

template<class Client , class Server >
Stream & out ( )
inlineinherited

Provides the output stream.

◆ out_ptr()

template<class Client , class Server >
Client * out_ptr ( )
inlineinherited

Provides a pointer to the WiFiClient.

◆ processClient()

template<class Client , class Server >
void processClient ( )
inlineprotectedinherited

Handle an new client connection and return the data.

◆ sendReplyContent()

template<class Client , class Server >
void sendReplyContent ( )
inlineoverrideprotectedvirtualinherited

Reimplemented from AudioServerT< Client, Server >.

◆ sendReplyHeader()

template<class Client , class Server >
void sendReplyHeader ( )
inlineoverrideprotectedvirtualinherited

Reimplemented from AudioServerT< Client, Server >.

◆ setChunked()

template<class Client , class Server >
void setChunked ( bool  flag)
inlineinherited

Activates/deactivates HTTP chunked transfer encoding (Transfer-Encoding: chunked) instead of relying on the connection close to signal the end of the data. Needs to be set before calling begin().

◆ setContentType()

template<class Client , class Server >
void setContentType ( const char *  contentType)
inlineinherited

Defines the content type (MIME type) of the data that will be sent to the client. Needs to be set before calling begin().

◆ setConverter()

template<class Client , class Server >
void setConverter ( BaseConverter c)
inlineinherited

defines a converter that will be used when the audio is rendered

◆ setCopyBufferSize()

template<class Client , class Server >
void setCopyBufferSize ( int  size)
inlineinherited

Changes the copy buffer size.

◆ setMaxOutputSize()

template<class Client , class Server >
void setMaxOutputSize ( size_t  size)
inlineinherited

Defines the total number of bytes that will be sent so that a Content-Length header can be provided. If no size is defined (default), the size is unknown up front, so we fall back to chunked transfer encoding instead. Needs to be set before calling begin().

◆ setupServer()

template<class Client , class Server >
void setupServer ( int  port)
inlineprotectedinherited

◆ startServer()

template<class Client , class Server >
bool startServer ( )
inlineprotectedinherited

Connects to WiFi (if enabled) and starts the server: shared tail of all begin() overloads

◆ wavEncoder()

template<class Client , class Server >
WAVEncoder & wavEncoder ( )
inline

Member Data Documentation

◆ audio_info

template<class Client , class Server >
AudioInfo audio_info
protectedinherited

◆ callback

template<class Client , class Server >
AudioServerDataCallback callback = nullptr
protectedinherited

◆ chunked_print

template<class Client , class Server >
ChunkedPrint chunked_print
protectedinherited

◆ client_obj

template<class Client , class Server >
Client client_obj
protectedinherited

◆ content_type

template<class Client , class Server >
const char* content_type = nullptr
protectedinherited

◆ converter_ptr

template<class Client , class Server >
BaseConverter* converter_ptr = nullptr
protectedinherited

◆ copier

template<class Client , class Server >
StreamCopy copier
protectedinherited

◆ encoded_stream

template<class Client , class Server >
EncodedAudioOutput encoded_stream
protectedinherited

◆ encoder

template<class Client , class Server >
AudioEncoder* encoder = nullptr
protectedinherited

◆ in

template<class Client , class Server >
Stream* in = nullptr
protectedinherited

◆ is_chunked

template<class Client , class Server >
bool is_chunked = true
protectedinherited

◆ max_output_size

template<class Client , class Server >
size_t max_output_size = 0
protectedinherited

◆ network

template<class Client , class Server >
std::string network
protectedinherited

◆ password

template<class Client , class Server >
std::string password
protectedinherited

◆ sent

template<class Client , class Server >
size_t sent = 0
protectedinherited

◆ server

template<class Client , class Server >
Server server
protectedinherited

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