From ee55783bf2d46219e4b9e372fd6d708bf71a1851 Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Mon, 22 Jul 2024 15:18:46 +0200 Subject: [PATCH] vcap/rtsp: perform TEARDOWN only if SETUP Do not perform TEARDOWN if SETUP was not issued - this is mostly only required to avoid false-positive error when probably another problem occured before (otherwise the SETUP would have been called). --- src/video_capture/rtsp.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/video_capture/rtsp.c b/src/video_capture/rtsp.c index 5e0a8a663..e6c53cd40 100644 --- a/src/video_capture/rtsp.c +++ b/src/video_capture/rtsp.c @@ -282,6 +282,7 @@ struct rtsp_state { pthread_cond_t keepalive_cv; _Bool rtsp_error_occurred; + bool setup_completed; _Bool sps_pps_emitted; ///< emit SPS/PPS once first to reduce decoding errors }; @@ -825,12 +826,12 @@ init_rtsp(struct rtsp_state *s) { //http://curl.haxx.se/libcurl/c/curl_easy_perform.html /* request server options */ - if (!rtsp_options(s->curl, s->uri)) { + if (!rtsp_options(s->curl, s->uri) || s->rtsp_error_occurred) { goto error; } /* request session description and write response to sdp file */ - if (!rtsp_describe(s->curl, s->uri, sdp_file)) { + if (!rtsp_describe(s->curl, s->uri, sdp_file) || s->rtsp_error_occurred) { goto error; } @@ -881,6 +882,7 @@ init_rtsp(struct rtsp_state *s) { goto error; } } + s->setup_completed = true; /* get start nal size attribute from sdp file */ len_nals = get_nals(sdp_file, (char *) s->vrtsp_state.h264_offset_buffer, (int *) &s->vrtsp_state.desc.width, (int *) &s->vrtsp_state.desc.height); @@ -1184,7 +1186,9 @@ vidcap_rtsp_done(void *state) { free(s->artsp_state.control); if (s->curl != NULL) { - rtsp_teardown(s->curl, s->uri); + if (s->setup_completed) { + rtsp_teardown(s->curl, s->uri); + } curl_easy_cleanup(s->curl); curl_global_cleanup();