15 HTTP_CODE_NOT_MODIFIED = 304,
16 HTTP_CODE_NOT_FOUND = 404,
21static constexpr size_t READ_CHUNK = 1460;
30 public Parented<esphome::http_request::HttpRequestComponent> {
47 bool is_big_endian =
false);
107 std::shared_ptr<http_request::HttpContainer>
downloader_{
nullptr};
Helper class to easily give an object a parent of type T.
This class simplifies creating components that periodically check a state.
Primary TemplatableValue: stores either a constant value or a function pointer.
Buffer for managing downloaded data.
Lets a decoder read a download as it arrives, from the download buffer.
Download an image from a given URL, and decode it using the specified decoder.
std::string etag_
The value of the ETag HTTP header provided in the last response.
OnlineImage(const std::string &url, int width, int height, runtime_image::ImageFormat format, image::ImageType type, image::Transparency transparency, image::Image *placeholder, uint32_t buffer_size, bool is_big_endian=false)
Construct a new OnlineImage object.
LazyCallbackManager< void()> download_started_callback_
void loop_stream_()
loop() for a JPEG that is decoded as it downloads
bool validate_url_(const std::string &url)
uint32_t last_progress_time_
LazyCallbackManager< void(float, size_t)> download_progress_callback_
void add_on_finished_callback(F &&callback)
void add_on_download_started_callback(F &&callback)
Called when the server has accepted the request and the image starts to download.
CallbackManager< void(bool)> download_finished_callback_
std::vector< std::pair< std::string, TemplatableValue< std::string > > > request_headers_
void add_request_header(const std::string &header, V value)
Add the request header.
DownloadBuffer download_buffer_
void set_url(const std::string &url)
Set the URL to download the image from.
std::shared_ptr< http_request::HttpContainer > downloader_
CallbackManager< void()> download_error_callback_
void update_if(bool update)
Download now when update is true (the update flag of online_image.set_url).
size_t download_buffer_initial_size_
This is the initial size of the download buffer, not the current size.
void report_progress_(bool force)
Reports download progress, at most every PROGRESS_INTERVAL_MS unless force is set.
std::string last_modified_
The value of the Last-Modified HTTP header provided in the last response.
void add_on_progress_callback(F &&callback)
Called with the percentage downloaded (NAN when the server did not send the size) and the bytes read ...
void add_on_error_callback(F &&callback)
void release()
Release the buffer storing the image.
A dynamic image that can be loaded and decoded at runtime.
enum { HTTP_CODE_OK=200, HTTP_CODE_NOT_MODIFIED=304, HTTP_CODE_NOT_FOUND=404, } t_http_codes
ImageFormat
Image format types that can be decoded dynamically.