From 0a55c86e6a930304fb5d84210c5a6c3dcd61fe24 Mon Sep 17 00:00:00 2001 From: Daniel Morin Date: Tue, 22 Aug 2023 16:11:06 -0400 Subject: [PATCH] rtspsrc: update rtsp url on redirect - If a redirect took place on a GET when rtsp is tunneled we update the rtsp url too. - log source and final destination on redirect Part-of: --- .../gst-plugins-good/gst/rtsp/gstrtspsrc.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/subprojects/gst-plugins-good/gst/rtsp/gstrtspsrc.c b/subprojects/gst-plugins-good/gst/rtsp/gstrtspsrc.c index a914aa0603..7bce71c3a8 100644 --- a/subprojects/gst-plugins-good/gst/rtsp/gstrtspsrc.c +++ b/subprojects/gst-plugins-good/gst/rtsp/gstrtspsrc.c @@ -1256,7 +1256,7 @@ gst_rtspsrc_class_init (GstRTSPSrcClass * klass) * @sample: RTP sample to send back * * Deprecated: 1.22: Use action signal GstRTSPSrc::push-backchannel-sample instead. - * IMPORTANT: Please note that this signal decrements the reference count + * IMPORTANT: Please note that this signal decrements the reference count * of sample internally! So it cannot be used from other * language bindings in general. * @@ -5351,6 +5351,8 @@ gst_rtsp_conninfo_connect (GstRTSPSrc * src, GstRTSPConnInfo * info, GstRTSPResult res; GstRTSPMessage response; gboolean retry = FALSE; + GstRTSPUrl *url; + gchar *new_url; memset (&response, 0, sizeof (response)); gst_rtsp_message_init (&response); do { @@ -5431,7 +5433,19 @@ gst_rtsp_conninfo_connect (GstRTSPSrc * src, GstRTSPConnInfo * info, if (res == GST_RTSP_OK) info->connected = TRUE; - else if (!retry) + else if (res == GST_RTSP_OK_REDIRECT) { + url = gst_rtsp_connection_get_url (info->connection); + + if (url == NULL || info->url_str == NULL) + goto could_not_connect; + + new_url = gst_rtsp_url_get_request_uri (url); + GST_DEBUG_OBJECT (src, "redirected from %s to %s", info->url_str, + new_url); + g_free (info->url_str); + info->url_str = new_url; + info->connected = TRUE; + } else if (!retry) goto could_not_connect; } } while (!info->connected && retry);