26static constexpr char STREAM_PATH_PREFIX[] =
"/audio/microphones/";
27static constexpr size_t STREAM_PATH_PREFIX_LEN =
sizeof(STREAM_PATH_PREFIX) - 1;
29static constexpr StringRef LIST_PATH(STREAM_PATH_PREFIX, STREAM_PATH_PREFIX_LEN - 1);
48 std::unique_ptr<ring_buffer::RingBuffer>
ring;
49 AsyncStreamResponse *
stream{
nullptr};
63 this->
stop_reason.compare_exchange_strong(none, reason);
72 const char *stream_path, std::span<ClientSlot> clients)
75 void setup()
override;
80 bool canHandle(AsyncWebServerRequest *request)
const override;
92 void on_audio_(std::span<const uint8_t> data);
96 return static_cast<unsigned>(client - this->
clients_.data());
void on_audio_(std::span< const uint8_t > data)
bool canHandle(AsyncWebServerRequest *request) const override
void send_audio_(ClientSlot *client)
microphone::MicrophoneSource * source_
void dump_config() override
MicrophoneHttpStream(microphone::MicrophoneSource *source, web_server_base::WebServerBase *base, const char *stream_path, std::span< ClientSlot > clients)
std::span< ClientSlot > clients_
static constexpr size_t SEND_CHUNK_SIZE
void finish_client_(ClientSlot *client)
web_server_base::WebServerBase * base_
unsigned client_index_(const ClientSlot *client) const
const char * stream_id_() const
static constexpr size_t SINGLE_RING_SIZE
void service_client_(ClientSlot *client)
const char * stream_path_
void write_audio_(ClientSlot *client, std::span< const uint8_t > data)
static constexpr size_t MULTI_RING_SIZE
float get_setup_priority() const override
void handleRequest(AsyncWebServerRequest *request) override
static constexpr uint32_t AUDIO_WAIT_TIMEOUT_MS
@ STOP_REASON_AUDIO_TIMEOUT
@ STOP_REASON_BUFFER_FULL
@ STOP_REASON_SEND_FAILED
@ STOP_REASON_PEER_CLOSED
constexpr size_t CHUNK_HDR_LEN
std::atomic< StreamState > state
std::atomic< StopReason > stop_reason
char chunk_header[web_server_base::CHUNK_HDR_LEN]
void set_stop_reason(StopReason reason)
Record the first reason the stream stops; later reasons are ignored.
AsyncStreamResponse * stream
std::unique_ptr< ring_buffer::RingBuffer > ring
std::atomic< uint8_t > writers