3#include "AudioServerT.h"
16template <
class Client,
class Server>
24 this->encoder = encoder;
34 const char *password,
int port = 80)
36 this->encoder = encoder;
53 int bits_per_sample = 16,
BaseConverter *converter =
nullptr) {
62 encoded_stream.
setOutput(&this->client_obj);
63 encoded_stream.setEncoder(encoder);
64 encoded_stream.
begin(audio_info);
79 this->audio_info = info;
82 encoded_stream.
setOutput(&this->client_obj);
83 encoded_stream.setEncoder(encoder);
84 if (!encoded_stream.
begin(audio_info)) {
85 LOGE(
"encoder begin failed");
105 encoded_stream.
setOutput(&this->client_obj);
106 encoded_stream.setEncoder(encoder);
107 encoded_stream.
begin(audio_info);
120 int bits_per_sample = 16) {
136 EncodedAudioOutput encoded_stream;
137 AudioInfo audio_info;
138 AudioEncoder *encoder =
nullptr;
141 void sendReplyHeader()
override {}
143 void sendReplyContent()
override {
151 if (this->callback !=
nullptr) {
153 encoded_stream.setOutput(this->
out_ptr());
154 encoded_stream.setEncoder(encoder);
155 encoded_stream.begin();
158 LOGI(
"sendReply - calling callback");
160 AudioServerT<Client, Server>::sendReplyHeader();
161 this->callback(&encoded_stream);
162 this->client_obj.stop();
163 }
else if (this->in !=
nullptr) {
165 LOGI(
"sendReply - Returning encoded stream...");
167 encoded_stream.setOutput(this->
out_ptr());
168 encoded_stream.setEncoder(encoder);
169 encoded_stream.begin();
171 this->copier.
begin(encoded_stream, *this->in);
172 if (!this->client_obj.connected()) {
173 LOGE(
"connection was closed");
176 AudioServerT<Client, Server>::sendReplyHeader();
189template <
class Client,
class Server>
210 if (encoder !=
nullptr) {
void(* AudioServerDataCallback)(Print *out)
Calback which writes the sound data to the stream.
Definition AudioServerT.h:11