From 34d94a146323261282675f484ca40eab737c5a1f Mon Sep 17 00:00:00 2001 From: Lorenzo Miniero Date: Fri, 1 Jul 2022 15:17:20 +0200 Subject: [PATCH] Check response codes of RTSP requests (see #3015) --- plugins/janus_streaming.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/plugins/janus_streaming.c b/plugins/janus_streaming.c index 0c61427748..5c15414ad7 100644 --- a/plugins/janus_streaming.c +++ b/plugins/janus_streaming.c @@ -6685,8 +6685,10 @@ static int janus_streaming_rtsp_connect_to_server(janus_streaming_mountpoint *mp if(audio_fds.fd != -1) close(audio_fds.fd); if(audio_fds.rtcp_fd != -1) close(audio_fds.rtcp_fd); return -5; - } else if(code != 200) { - JANUS_LOG(LOG_ERR, "Couldn't get SETUP code: %ld\n", code); + } + res = curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &code); + if(code != 200) { + JANUS_LOG(LOG_ERR, "Couldn't SETUP, got error code: %ld\n", code); g_strfreev(parts); curl_easy_cleanup(curl); g_free(curldata->buffer); @@ -6858,8 +6860,10 @@ static int janus_streaming_rtsp_connect_to_server(janus_streaming_mountpoint *mp if(audio_fds.fd != -1) close(audio_fds.fd); if(audio_fds.rtcp_fd != -1) close(audio_fds.rtcp_fd); return -6; - } else if(code != 200) { - JANUS_LOG(LOG_ERR, "Couldn't get SETUP code: %ld\n", code); + } + res = curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &code); + if(code != 200) { + JANUS_LOG(LOG_ERR, "Couldn't SETUP, got error code: %ld\n", code); g_strfreev(parts); curl_easy_cleanup(curl); g_free(curldata->buffer); @@ -7122,6 +7126,13 @@ static int janus_streaming_rtsp_play(janus_streaming_rtp_source *source) { janus_mutex_unlock(&source->rtsp_mutex); return -1; } + long code = 0; + res = curl_easy_getinfo(source->curl, CURLINFO_RESPONSE_CODE, &code); + if(code != 200) { + JANUS_LOG(LOG_ERR, "Couldn't PLAY, got error code: %ld\n", code); + janus_mutex_unlock(&source->rtsp_mutex); + return -1; + } JANUS_LOG(LOG_VERB, "PLAY answer:%s\n", source->curldata->buffer); janus_mutex_unlock(&source->rtsp_mutex); return 0;