Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to stop the stream #2

Open
OttoKlaasen opened this issue May 2, 2020 · 4 comments
Open

How to stop the stream #2

OttoKlaasen opened this issue May 2, 2020 · 4 comments

Comments

@OttoKlaasen
Copy link

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;

}

@GitCool4753
Copy link

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 ...

@mononeuroico
Copy link

@jrbous
Copy link

jrbous commented Mar 30, 2022

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

@Jeronimo59
Copy link

Jeronimo59 commented Feb 7, 2024

Hello,
The video is streamed server-side by the stream_handler() function in 'app_httpd.cpp'.
Replacing the while(TRUE) loop with a while (isStreaming) lets you abort streaming by setting isStreaming to FALSE.

Sans titre

FYI I have implemented a timeout feature in stream_handler() to specify the duration of streaming (eg to save battery)
e.g. /stream?timeout=5000 will stop streaming after 5 seconds.

HTH

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants