From bbd7ce6c8330e1e69055f7dc624d60dc19718cd0 Mon Sep 17 00:00:00 2001 From: Alexander Bergmann Date: Mon, 24 Feb 2020 10:24:18 +0100 Subject: [PATCH] Move _STREAM_BOUNDARY before _STREAM_PART (#131) The boundary delimiter (_STREAM_BOUNDARY) needs to be send before the body part (_STREAM_PART) too follow RFC2046. This caused ffplay/ffmpeg to fail to open the MJPEG stream. --- examples/single_chip/camera_web_server/main/app_httpd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/single_chip/camera_web_server/main/app_httpd.c b/examples/single_chip/camera_web_server/main/app_httpd.c index 171866c..e51304b 100644 --- a/examples/single_chip/camera_web_server/main/app_httpd.c +++ b/examples/single_chip/camera_web_server/main/app_httpd.c @@ -588,6 +588,10 @@ static esp_err_t stream_handler(httpd_req_t *req) #endif } if (res == ESP_OK) + { + res = httpd_resp_send_chunk(req, _STREAM_BOUNDARY, strlen(_STREAM_BOUNDARY)); + } + if (res == ESP_OK) { size_t hlen = snprintf((char *)part_buf, 64, _STREAM_PART, _jpg_buf_len); res = httpd_resp_send_chunk(req, (const char *)part_buf, hlen); @@ -596,10 +600,6 @@ static esp_err_t stream_handler(httpd_req_t *req) { res = httpd_resp_send_chunk(req, (const char *)_jpg_buf, _jpg_buf_len); } - if (res == ESP_OK) - { - res = httpd_resp_send_chunk(req, _STREAM_BOUNDARY, strlen(_STREAM_BOUNDARY)); - } if (fb) { esp_camera_fb_return(fb);