Firmware flow
Send an encoded JPEG chunk
Selected Espressif-derived JPEG encoder callback in the matched CameraWebServer delivery.
The first chunk resets the count. A failed HTTP API call returns zero; a successful call adds the chunk length and returns that length to the encoder.
This is an Espressif-derived JPEG encoder callback. HTTP API success is not proof of end-to-end delivery, measured frame rate or working physical camera hardware.
Read the implementation
app_httpd.cpp — unmodified Espressif JPEG chunk callback. The explanatory diagram was reconstructed for this page.
Copyright 2015–2016 Espressif Systems (Shanghai) PTE LTD. Apache License, Version 2.0. Source copyright, permission and notice. Complete Apache 2.0 licence.
static size_t jpg_encode_stream(void *arg, size_t index, const void *data, size_t len)
{
jpg_chunking_t *j = (jpg_chunking_t *)arg;
if (!index)
{
j->len = 0;
}
if (httpd_resp_send_chunk(j->req, (const char *)data, len) != ESP_OK)
{
return 0;
}
j->len += len;
return len;
}Technical notes
Camera web-feed integration
The selected delivery uses the Espressif CameraWebServer application for camera capture and HTTP serving. The helper shown here is framework code used in that integration, rather than an independently developed camera server.
Account for each JPEG chunk
At the first encoder chunk, jpg_encode_stream() resets the accumulated length. It sends the chunk through the HTTP response API, returns zero if the send fails and increases the count only after a successful API result.
Separate optional framework features
Face detection and recognition are disabled in the selected source configuration. Their conditional routines do not establish an enabled project feature. The code explains JPEG response handling; physical camera operation, browser playback and frame rate were not tested in this review.