rtspsrc: Only update from the Content-Base header in the initial OPTION / DESCRIBE response

Some servers send a new content base in the SETUP response, which is
just the non-aggregate control URL of the individual streams.

See https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/3563

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6926>
This commit is contained in:
Sebastian Dröge 2024-05-27 14:14:24 +03:00 committed by GStreamer Marge Bot
parent e65344afac
commit 9b60b32cf8

View file

@ -6733,7 +6733,8 @@ propagate_error:
static GstRTSPResult
gst_rtsp_src_receive_response (GstRTSPSrc * src, GstRTSPConnInfo * conninfo,
GstRTSPMessage * response, GstRTSPStatusCode * code)
GstRTSPMessage * response, GstRTSPStatusCode * code,
gboolean update_content_base)
{
GstRTSPStatusCode thecode;
gchar *content_base = NULL;
@ -6794,12 +6795,14 @@ next:
if (thecode != GST_RTSP_STS_OK)
return GST_RTSP_OK;
/* store new content base if any */
gst_rtsp_message_get_header (response, GST_RTSP_HDR_CONTENT_BASE,
&content_base, 0);
if (content_base) {
g_free (src->content_base);
src->content_base = g_strdup (content_base);
if (update_content_base) {
/* store new content base if any */
gst_rtsp_message_get_header (response, GST_RTSP_HDR_CONTENT_BASE,
&content_base, 0);
if (content_base) {
g_free (src->content_base);
src->content_base = g_strdup (content_base);
}
}
return GST_RTSP_OK;
@ -6846,7 +6849,7 @@ server_eof:
static GstRTSPResult
gst_rtspsrc_try_send (GstRTSPSrc * src, GstRTSPConnInfo * conninfo,
GstRTSPMessage * request, GstRTSPMessage * response,
GstRTSPStatusCode * code)
GstRTSPStatusCode * code, gboolean update_content_base)
{
GstRTSPResult res;
gint try = 0;
@ -6875,7 +6878,9 @@ again:
if (!response)
return res;
res = gst_rtsp_src_receive_response (src, conninfo, response, code);
res =
gst_rtsp_src_receive_response (src, conninfo, response, code,
update_content_base);
if (res == GST_RTSP_EEOF) {
GST_WARNING_OBJECT (src, "server closed connection");
/* only try once after reconnect, then fallthrough and error out */
@ -6951,7 +6956,8 @@ receive_error:
static GstRTSPResult
gst_rtspsrc_send (GstRTSPSrc * src, GstRTSPConnInfo * conninfo,
GstRTSPMessage * request, GstRTSPMessage * response,
GstRTSPStatusCode * code, GstRTSPVersion * versions)
GstRTSPStatusCode * code, GstRTSPVersion * versions,
gboolean update_content_base)
{
GstRTSPStatusCode int_code = GST_RTSP_STS_OK;
GstRTSPResult res = GST_RTSP_ERROR;
@ -6976,7 +6982,7 @@ gst_rtspsrc_send (GstRTSPSrc * src, GstRTSPConnInfo * conninfo,
if ((res =
gst_rtspsrc_try_send (src, conninfo, request, response,
&int_code)) < 0)
&int_code, update_content_base)) < 0)
goto error;
switch (int_code) {
@ -7103,7 +7109,8 @@ static GstRTSPResult
gst_rtspsrc_send_cb (GstRTSPExtension * ext, GstRTSPMessage * request,
GstRTSPMessage * response, GstRTSPSrc * src)
{
return gst_rtspsrc_send (src, &src->conninfo, request, response, NULL, NULL);
return gst_rtspsrc_send (src, &src->conninfo, request, response, NULL, NULL,
FALSE);
}
@ -7589,7 +7596,7 @@ gst_rtspsrc_setup_streams_end (GstRTSPSrc * src, gboolean async)
if (!src->conninfo.connection)
conninfo = &((GstRTSPStream *) tmp->data)->conninfo;
gst_rtsp_src_receive_response (src, conninfo, &response, NULL);
gst_rtsp_src_receive_response (src, conninfo, &response, NULL, FALSE);
gst_rtsp_src_setup_stream_from_response (src, stream,
&response, NULL, 0, NULL, NULL);
@ -7820,7 +7827,7 @@ gst_rtspsrc_setup_streams_start (GstRTSPSrc * src, gboolean async)
/* handle the code ourselves */
res =
gst_rtspsrc_send (src, conninfo, &request,
pipelined_request_id ? NULL : &response, &code, NULL);
pipelined_request_id ? NULL : &response, &code, NULL, FALSE);
if (res < 0)
goto send_error;
@ -8363,7 +8370,7 @@ restart:
if ((res =
gst_rtspsrc_send (src, &src->conninfo, &request, &response,
NULL, versions)) < 0) {
NULL, versions, TRUE)) < 0) {
goto send_error;
}
@ -8400,7 +8407,7 @@ restart:
if ((res =
gst_rtspsrc_send (src, &src->conninfo, &request, &response,
NULL, NULL)) < 0)
NULL, NULL, TRUE)) < 0)
goto send_error;
/* we only perform redirect for describe and play, currently */
@ -8641,7 +8648,8 @@ gst_rtspsrc_close (GstRTSPSrc * src, gboolean async, gboolean only_close)
GST_ELEMENT_PROGRESS (src, CONTINUE, "close", ("Closing stream"));
if ((res =
gst_rtspsrc_send (src, info, &request, &response, NULL, NULL)) < 0)
gst_rtspsrc_send (src, info, &request, &response, NULL, NULL,
FALSE)) < 0)
goto send_error;
/* FIXME, parse result? */
@ -9088,7 +9096,8 @@ restart:
GST_ELEMENT_PROGRESS (src, CONTINUE, "request", ("Sending PLAY request"));
if ((res =
gst_rtspsrc_send (src, conninfo, &request, &response, NULL, NULL))
gst_rtspsrc_send (src, conninfo, &request, &response, NULL, NULL,
FALSE))
< 0)
goto send_error;
@ -9321,7 +9330,7 @@ gst_rtspsrc_pause (GstRTSPSrc * src, gboolean async)
if ((res =
gst_rtspsrc_send (src, conninfo, &request, &response, NULL,
NULL)) < 0)
NULL, FALSE)) < 0)
goto send_error;
gst_rtsp_message_unset (&request);
@ -9931,7 +9940,7 @@ gst_rtspsrc_get_parameter (GstRTSPSrc * src, ParameterRequest * req)
}
if ((res = gst_rtspsrc_send (src, &src->conninfo,
&request, &response, &code, NULL)) < 0)
&request, &response, &code, NULL, FALSE)) < 0)
goto send_error;
res = gst_rtsp_message_get_body (&response, (guint8 **) & recv_body,
@ -10051,7 +10060,7 @@ gst_rtspsrc_set_parameter (GstRTSPSrc * src, ParameterRequest * req)
}
if ((res = gst_rtspsrc_send (src, &src->conninfo,
&request, &response, &code, NULL)) < 0)
&request, &response, &code, NULL, FALSE)) < 0)
goto send_error;
done: