Add define to allow camera to be streamed on another page

This commit is contained in:
Luc 2019-09-30 08:42:28 +08:00
parent 917cd071b6
commit 2c7953055f
3 changed files with 11 additions and 1 deletions

View File

@ -152,6 +152,13 @@
//#define CAMERA_DEVICE_FLIP_HORIZONTALY//comment to disable //#define CAMERA_DEVICE_FLIP_HORIZONTALY//comment to disable
#define CUSTOM_CAMERA_NAME "ESP32-CAM" #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 ///////////////////////////////////////////////////////////////////////// //Extra features /////////////////////////////////////////////////////////////////////////
/************************************ /************************************
* *

View File

@ -22,7 +22,7 @@
#define _VERSION_ESP3D_H #define _VERSION_ESP3D_H
//version and sources location //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" #define REPOSITORY "https://github.com/luc-github/ESP3D"
#endif //_VERSION_ESP3D_H #endif //_VERSION_ESP3D_H

View File

@ -54,6 +54,9 @@ static esp_err_t stream_handler(httpd_req_t *req)
return ESP_FAIL; return ESP_FAIL;
} }
esp3d_camera.connect(true); 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; camera_fb_t * fb = NULL;
esp_err_t res = ESP_OK; esp_err_t res = ESP_OK;
size_t _jpg_buf_len = 0; size_t _jpg_buf_len = 0;