|
@@ -324,42 +324,27 @@ esp_err_t handler_init(httpd_req_t *req)
|
|
|
return ESP_OK;
|
|
return ESP_OK;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-esp_err_t handler_stream(httpd_req_t *req)
|
|
|
|
|
|
|
+static esp_err_t handler_stream_worker(httpd_req_t *req)
|
|
|
{
|
|
{
|
|
|
-#ifdef DEBUG_DETAIL_ON
|
|
|
|
|
- LogFile.WriteHeapInfo("handler_stream - Start");
|
|
|
|
|
- ESP_LOGD(TAG, "handler_stream uri: %s", req->uri);
|
|
|
|
|
-#endif
|
|
|
|
|
-
|
|
|
|
|
- char _query[50] = ""; // stays empty when the request has no query string
|
|
|
|
|
|
|
+ char _query[50] = "";
|
|
|
char _value[10];
|
|
char _value[10];
|
|
|
bool flashlightOn = false;
|
|
bool flashlightOn = false;
|
|
|
|
|
|
|
|
if (httpd_req_get_url_query_str(req, _query, 50) == ESP_OK)
|
|
if (httpd_req_get_url_query_str(req, _query, 50) == ESP_OK)
|
|
|
{
|
|
{
|
|
|
- // ESP_LOGD(TAG, "Query: %s", _query);
|
|
|
|
|
- if (httpd_query_key_value(_query, "flashlight", _value, 10) == ESP_OK)
|
|
|
|
|
|
|
+ if (httpd_query_key_value(_query, "flashlight", _value, 10) == ESP_OK &&
|
|
|
|
|
+ strlen(_value) > 0)
|
|
|
{
|
|
{
|
|
|
-#ifdef DEBUG_DETAIL_ON
|
|
|
|
|
- ESP_LOGD(TAG, "flashlight is found%s", _value);
|
|
|
|
|
-#endif
|
|
|
|
|
- if (strlen(_value) > 0)
|
|
|
|
|
- {
|
|
|
|
|
- flashlightOn = true;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ flashlightOn = true;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // Closing the browser popup makes the next stream send fail. Propagate
|
|
|
|
|
- // that error so esp_http_server closes the client session instead of
|
|
|
|
|
- // treating the interrupted stream as a reusable successful connection.
|
|
|
|
|
- const esp_err_t streamResult = Camera.CaptureToStream(req, flashlightOn);
|
|
|
|
|
-
|
|
|
|
|
-#ifdef DEBUG_DETAIL_ON
|
|
|
|
|
- LogFile.WriteHeapInfo("handler_stream - Done");
|
|
|
|
|
-#endif
|
|
|
|
|
|
|
+ return Camera.CaptureToStream(req, flashlightOn);
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
- return streamResult;
|
|
|
|
|
|
|
+esp_err_t handler_stream(httpd_req_t *req)
|
|
|
|
|
+{
|
|
|
|
|
+ return dispatch_camera_http_request_async(req, handler_stream_worker, "stream");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
esp_err_t handler_flow_start(httpd_req_t *req)
|
|
esp_err_t handler_flow_start(httpd_req_t *req)
|