From 13e02063d63146096952fc6a6ef0bc3ced5b1203 Mon Sep 17 00:00:00 2001 From: Alexander Bergmann Date: Fri, 14 Feb 2020 10:03:38 +0100 Subject: [PATCH] Move _STREAM_BOUNDARY before _STREAM_PART (#3720) 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. --- .../ESP32/examples/Camera/CameraWebServer/app_httpd.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libraries/ESP32/examples/Camera/CameraWebServer/app_httpd.cpp b/libraries/ESP32/examples/Camera/CameraWebServer/app_httpd.cpp index 07d29ee7..5e33ec7c 100644 --- a/libraries/ESP32/examples/Camera/CameraWebServer/app_httpd.cpp +++ b/libraries/ESP32/examples/Camera/CameraWebServer/app_httpd.cpp @@ -403,6 +403,9 @@ static esp_err_t stream_handler(httpd_req_t *req){ } } } + 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); @@ -410,9 +413,6 @@ static esp_err_t stream_handler(httpd_req_t *req){ if(res == ESP_OK){ 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); fb = NULL;