RuiSantosdotme/ESP32-CAM-Arduino-IDE

How to stop the stream

OttoKlaasen opened this issue · 4 comments

Dear Sir,

regarding this coder, once the stream is started, how to you close the stream via software ?

void startCameraServer(){
httpd_config_t config = HTTPD_DEFAULT_CONFIG();
config.server_port = 80;
httpd_uri_t index_uri = {
.uri = "/",
.method = HTTP_GET,
.handler = stream_handler,
.user_ctx = NULL
};
//Serial.printf("Starting web server on port: '%d'\n", config.server_port);
if (httpd_start(&stream_httpd, &config) == ESP_OK) {
httpd_register_uri_handler(stream_httpd, &index_uri);
}
}

Of course i can set the ESP32 in deep sleep which stops the stream, but i am looking for a software method.

Maybe you have some suggestion.

Kind regards
Otto Klaasen

p.s

I change the code like this but when using first call with true and second call with false is does not stop the stream but start a second stream which error out:

bool startCameraServer(bool StartStream){
httpd_config_t config = HTTPD_DEFAULT_CONFIG();
// If startstream is true the stram will work
if (StartStream){
config.server_port = 80;
}
else {
config.server_port = -1;
}

httpd_uri_t index_uri = {
.uri = "/",
.method = _HTTP_GET,
// .method = HTTP_GET, // Original code
.handler = stream_handler,
.user_ctx = NULL
};

//Serial.printf("Starting web server on port: '%d'\n", config.server_port);
if (httpd_start(&stream_httpd, &config) == ESP_OK) {
httpd_register_uri_handler(stream_httpd, &index_uri);
Serial.println("Video Stream started.");
}
else {
Serial.println("Video Stream NOT started.");
}
Serial.print("Stream port: ");Serial.println(config.server_port);

return StartStream;

}

Hello,
While searching the web, I see this message.
I am interested in your question, OttoKlaasen.
Did you have information to stop the video stream by coding (keeping the display of the last image)?
If anyone sees this message, please direct me to an early solution ...

Hello guys,
I minterested to know like you how to stop stream.
have you got some answers.
Thanks