#include <audio_reader.h>
|
static esp_err_t | http_event_handler (esp_http_client_event_t *evt) |
| Monitors the http client events to attempt determining the file type from the Content-Type header. More...
|
|
static AudioFileType | get_audio_type (const char *content_type) |
| Determines the audio file type from the http header's Content-Type key. More...
|
|
Definition at line 23 of file audio_reader.h.
◆ AudioReader()
esphome::audio::AudioReader::AudioReader |
( |
size_t |
buffer_size | ) |
|
|
inline |
Constructs an AudioReader object.
The transfer buffer isn't allocated here, but only if necessary (an http source) in the start function.
- Parameters
-
buffer_size | Transfer buffer size in bytes. |
Definition at line 33 of file audio_reader.h.
◆ ~AudioReader()
esphome::audio::AudioReader::~AudioReader |
( |
| ) |
|
◆ add_sink()
esp_err_t esphome::audio::AudioReader::add_sink |
( |
const std::weak_ptr< RingBuffer > & |
output_ring_buffer | ) |
|
Adds a sink ring buffer for audio data.
Takes ownership of the ring buffer in a shared_ptr
- Parameters
-
output_ring_buffer | weak_ptr of a shared_ptr of the sink ring buffer to transfer ownership |
- Returns
- ESP_OK if successful, ESP_ERR_INVALID_STATE otherwise
Definition at line 55 of file audio_reader.cpp.
◆ cleanup_connection_()
void esphome::audio::AudioReader::cleanup_connection_ |
( |
| ) |
|
|
protected |
◆ file_read_()
◆ get_audio_type()
AudioFileType esphome::audio::AudioReader::get_audio_type |
( |
const char * |
content_type | ) |
|
|
staticprotected |
Determines the audio file type from the http header's Content-Type key.
- Parameters
-
content_type | string with the Content-Type key |
- Returns
- AudioFileType of the url, if it can be determined. If not, return AudioFileType::NONE.
Definition at line 212 of file audio_reader.cpp.
◆ http_event_handler()
esp_err_t esphome::audio::AudioReader::http_event_handler |
( |
esp_http_client_event_t * |
evt | ) |
|
|
staticprotected |
Monitors the http client events to attempt determining the file type from the Content-Type header.
Definition at line 230 of file audio_reader.cpp.
◆ http_read_()
◆ read()
Reads new file data from the source and sends to the ring buffer sink.
- Returns
- AudioReaderState
Definition at line 202 of file audio_reader.cpp.
◆ start() [1/2]
esp_err_t esphome::audio::AudioReader::start |
( |
const std::string & |
uri, |
|
|
AudioFileType & |
file_type |
|
) |
| |
Starts reading an audio file from an http source.
The transfer buffer is allocated here.
- Parameters
-
uri | Web url to the http file. |
file_type | AudioFileType variable passed-by-reference indicating the type of file being read. |
- Returns
- ESP_OK if successful, an ESP_ERR* code otherwise.
Definition at line 81 of file audio_reader.cpp.
◆ start() [2/2]
Starts reading an audio file from flash.
No transfer buffer is allocated.
- Parameters
-
audio_file | AudioFile struct containing the file. |
file_type | AudioFileType variable passed-by-reference indicating the type of file being read. |
- Returns
- ESP_OK
Definition at line 70 of file audio_reader.cpp.
◆ audio_file_type_
◆ buffer_size_
size_t esphome::audio::AudioReader::buffer_size_ |
|
protected |
◆ client_
esp_http_client_handle_t esphome::audio::AudioReader::client_ {nullptr} |
|
protected |
◆ current_audio_file_
AudioFile* esphome::audio::AudioReader::current_audio_file_ {nullptr} |
|
protected |
◆ file_current_
const uint8_t* esphome::audio::AudioReader::file_current_ {nullptr} |
|
protected |
◆ file_ring_buffer_
std::shared_ptr<RingBuffer> esphome::audio::AudioReader::file_ring_buffer_ |
|
protected |
◆ no_data_read_count_
uint32_t esphome::audio::AudioReader::no_data_read_count_ |
|
protected |
◆ output_transfer_buffer_
The documentation for this class was generated from the following files: