From 2c7953055fc450775cb38f2b6edc6fd1c4754d00 Mon Sep 17 00:00:00 2001 From: Luc Date: Mon, 30 Sep 2019 08:42:28 +0800 Subject: [PATCH] Add define to allow camera to be streamed on another page --- esp3d/configuration.h | 7 +++++++ esp3d/src/include/version.h | 2 +- esp3d/src/modules/camera/camera.cpp | 3 +++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/esp3d/configuration.h b/esp3d/configuration.h index ebeb8bd9..c8737f12 100644 --- a/esp3d/configuration.h +++ b/esp3d/configuration.h @@ -152,6 +152,13 @@ //#define CAMERA_DEVICE_FLIP_HORIZONTALY//comment to disable #define CUSTOM_CAMERA_NAME "ESP32-CAM" +//Allow remote access by enabling cross origin access +//check https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS +//this should be enabled only in specific cases +//like show the camera in web page different than device web server +//if you do not know what is that then better left it commented +//#define ESP_ACCESS_CONTROL_ALLOW_ORIGIN + //Extra features ///////////////////////////////////////////////////////////////////////// /************************************ * diff --git a/esp3d/src/include/version.h b/esp3d/src/include/version.h index 17260062..97bc6f85 100644 --- a/esp3d/src/include/version.h +++ b/esp3d/src/include/version.h @@ -22,7 +22,7 @@ #define _VERSION_ESP3D_H //version and sources location -#define FW_VERSION "3.0.0.a17" +#define FW_VERSION "3.0.0.a18" #define REPOSITORY "https://github.com/luc-github/ESP3D" #endif //_VERSION_ESP3D_H diff --git a/esp3d/src/modules/camera/camera.cpp b/esp3d/src/modules/camera/camera.cpp index 74bd33db..bc6bece9 100644 --- a/esp3d/src/modules/camera/camera.cpp +++ b/esp3d/src/modules/camera/camera.cpp @@ -54,6 +54,9 @@ static esp_err_t stream_handler(httpd_req_t *req) return ESP_FAIL; } esp3d_camera.connect(true); +#ifdef ESP_ACCESS_CONTROL_ALLOW_ORIGIN + httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*"); +#endif //ESP_ACCESS_CONTROL_ALLOw_ORIGIN camera_fb_t * fb = NULL; esp_err_t res = ESP_OK; size_t _jpg_buf_len = 0;