|
arduino-audio-tools
|
A simple Arduino Webserver which encodes the provided PCM audio (from a Stream or a callback) with the given AudioEncoder and streams the result to the connected HTTP client, e.g. WAV, MP3 or any other supported format. This class extends AudioServerT, so it inherits its Client/Server template parameters as well as its transfer-encoding behavior: if setMaxOutputSize() is not called, the response defaults to Transfer-Encoding: chunked; otherwise a Content-Length header is sent instead.
More...
#include <AudioEncodedServerT.h>
Public Member Functions | |
| AudioEncoderServerT (AudioEncoder *encoder, const char *network, const char *password, int port=80) | |
| Construct a new Audio Server object. | |
| AudioEncoderServerT (AudioEncoder *encoder, int port=80) | |
| Construct a new Audio Server object that supports an AudioEncoder We assume that the WiFi is already connected. | |
| virtual | ~AudioEncoderServerT ()=default |
| Destructor release the memory. | |
| AudioEncoder * | audioEncoder () |
| 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. | |
| Stream & | out () |
| Provides the output stream. | |
| Client * | out_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) |
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 |
| BaseConverter * | converter_ptr = nullptr |
| StreamCopy | copier |
| EncodedAudioOutput | encoded_stream |
| AudioEncoder * | encoder = nullptr |
| Stream * | in = nullptr |
| bool | is_chunked = true |
| size_t | max_output_size = 0 |
| std::string | network |
| std::string | password |
| size_t | sent = 0 |
| Server | server |
A simple Arduino Webserver which encodes the provided PCM audio (from a Stream or a callback) with the given AudioEncoder and streams the result to the connected HTTP client, e.g. WAV, MP3 or any other supported format. This class extends AudioServerT, so it inherits its Client/Server template parameters as well as its transfer-encoding behavior: if setMaxOutputSize() is not called, the response defaults to Transfer-Encoding: chunked; otherwise a Content-Length header is sent instead.
| Client | the client class e.g. WiFiClient |
| Server | the server class e.g. WiFiServer |
|
inline |
Construct a new Audio Server object that supports an AudioEncoder We assume that the WiFi is already connected.
|
inline |
Construct a new Audio Server object.
| network | |
| password |
|
virtualdefault |
Destructor release the memory.
|
inline |
|
inlineinherited |
Just starts the server.
|
inline |
Start the server. The data must be provided by a callback method.
| cb | |
| info |
|
inlineinherited |
Start the server. The data must be provided by a callback method.
| cb | |
| contentType | Mime Type of result |
|
inline |
Start the server. The data must be provided by a callback method.
| cb | |
| sample_rate | |
| channels |
|
inline |
Start the server. You need to be connected to WiFI before calling this method.
| in | |
| converter |
|
inline |
Start the server. You need to be connected to WiFI before calling this method.
| in | |
| info | |
| converter |
|
inlineinherited |
Start the server. You need to be connected to WiFI before calling this method.
| in | |
| contentType | Mime Type of result |
|
inline |
Start the server. You need to be connected to WiFI before calling this method.
| in | |
| sample_rate | |
| channels |
|
inlineprotectedinherited |
|
inlineinherited |
Add this method to your loop Returns true while the client is connected. (The same functionality like doLoop())
|
inlineinherited |
Add this method to your loop Returns true while the client is connected.
|
inlineinherited |
Ends the connection and resets the state.
|
inlineprotectedinherited |
Sends the terminating 0-length chunk when chunked transfer is active.
|
inlineinherited |
Determines if chunked transfer encoding is active.
|
inlineinherited |
Checks if any client has connected.
|
inlineinherited |
Provides the defined total number of bytes that will be sent.
|
inlineinherited |
Checks if any client has connected.
Provides a pointer to the WiFiClient.
|
inlineprotectedinherited |
Handle an new client connection and return the data.
|
inlineoverrideprotectedvirtual |
Reimplemented from AudioServerT< Client, Server >.
|
inlineoverrideprotectedvirtual |
Reimplemented from AudioServerT< Client, Server >.
|
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().
|
inlineinherited |
Defines the content type (MIME type) of the data that will be sent to the client. Needs to be set before calling begin().
|
inlineinherited |
defines a converter that will be used when the audio is rendered
|
inlineinherited |
Changes the copy buffer 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().
|
inlineprotectedinherited |
|
inlineprotectedinherited |
Connects to WiFi (if enabled) and starts the server: shared tail of all begin() overloads
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protected |
|
protected |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |