mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-26 00:58:12 +00:00
gst/rtsp/gstrtspsrc.*: Implement redirect for the DESCRIBE reply. Fixes #506025.
Original commit message from CVS: * gst/rtsp/gstrtspsrc.c: (gst_rtspsrc_send), (gst_rtspsrc_open): * gst/rtsp/gstrtspsrc.h: Implement redirect for the DESCRIBE reply. Fixes #506025.
This commit is contained in:
parent
3761fb69e6
commit
eb5e87944c
3 changed files with 63 additions and 6 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2007-12-31 Wim Taymans <wim.taymans@collabora.co.uk>
|
||||||
|
|
||||||
|
* gst/rtsp/gstrtspsrc.c: (gst_rtspsrc_send), (gst_rtspsrc_open):
|
||||||
|
* gst/rtsp/gstrtspsrc.h:
|
||||||
|
Implement redirect for the DESCRIBE reply. Fixes #506025.
|
||||||
|
|
||||||
2007-12-29 Sebastian Dröge <slomo@circular-chaos.org>
|
2007-12-29 Sebastian Dröge <slomo@circular-chaos.org>
|
||||||
|
|
||||||
* ext/flac/gstflacdec.c: (gst_flac_dec_write):
|
* ext/flac/gstflacdec.c: (gst_flac_dec_write):
|
||||||
|
|
|
@ -3216,24 +3216,34 @@ gst_rtspsrc_send (GstRTSPSrc * src, GstRTSPMessage * request,
|
||||||
{
|
{
|
||||||
GstRTSPStatusCode int_code = GST_RTSP_STS_OK;
|
GstRTSPStatusCode int_code = GST_RTSP_STS_OK;
|
||||||
GstRTSPResult res;
|
GstRTSPResult res;
|
||||||
|
gint count;
|
||||||
gboolean retry;
|
gboolean retry;
|
||||||
GstRTSPMethod method;
|
GstRTSPMethod method;
|
||||||
|
|
||||||
|
count = 0;
|
||||||
do {
|
do {
|
||||||
retry = FALSE;
|
retry = FALSE;
|
||||||
|
|
||||||
|
/* make sure we don't loop forever */
|
||||||
|
if (count++ > 8)
|
||||||
|
break;
|
||||||
|
|
||||||
/* save method so we can disable it when the server complains */
|
/* save method so we can disable it when the server complains */
|
||||||
method = request->type_data.request.method;
|
method = request->type_data.request.method;
|
||||||
|
|
||||||
if ((res = gst_rtspsrc_try_send (src, request, response, &int_code)) < 0)
|
if ((res = gst_rtspsrc_try_send (src, request, response, &int_code)) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (int_code == GST_RTSP_STS_UNAUTHORIZED) {
|
switch (int_code) {
|
||||||
if (gst_rtspsrc_setup_auth (src, response)) {
|
case GST_RTSP_STS_UNAUTHORIZED:
|
||||||
/* Try the request/response again after configuring the auth info
|
if (gst_rtspsrc_setup_auth (src, response)) {
|
||||||
* and loop again */
|
/* Try the request/response again after configuring the auth info
|
||||||
retry = TRUE;
|
* and loop again */
|
||||||
}
|
retry = TRUE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} while (retry == TRUE);
|
} while (retry == TRUE);
|
||||||
|
|
||||||
|
@ -3261,6 +3271,29 @@ error_response:
|
||||||
GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND, (NULL), ("%s",
|
GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND, (NULL), ("%s",
|
||||||
response->type_data.response.reason));
|
response->type_data.response.reason));
|
||||||
break;
|
break;
|
||||||
|
case GST_RTSP_STS_MOVED_PERMANENTLY:
|
||||||
|
case GST_RTSP_STS_MOVE_TEMPORARILY:
|
||||||
|
{
|
||||||
|
gchar *new_location;
|
||||||
|
|
||||||
|
GST_DEBUG_OBJECT (src, "got redirection");
|
||||||
|
/* if we don't have a Location Header, we must error */
|
||||||
|
if (gst_rtsp_message_get_header (response, GST_RTSP_HDR_LOCATION,
|
||||||
|
&new_location, 0) < 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* When we receive a redirect result, we go back to the INIT state after
|
||||||
|
* parsing the new URI. The caller should do the needed steps to issue
|
||||||
|
* a new setup when it detects this state change. */
|
||||||
|
GST_DEBUG_OBJECT (src, "redirection to %s", new_location);
|
||||||
|
|
||||||
|
gst_rtspsrc_uri_set_uri (GST_URI_HANDLER (src), new_location);
|
||||||
|
|
||||||
|
src->need_redirect = TRUE;
|
||||||
|
src->state = GST_RTSP_STATE_INIT;
|
||||||
|
res = GST_RTSP_OK;
|
||||||
|
break;
|
||||||
|
}
|
||||||
case GST_RTSP_STS_NOT_ACCEPTABLE:
|
case GST_RTSP_STS_NOT_ACCEPTABLE:
|
||||||
case GST_RTSP_STS_NOT_IMPLEMENTED:
|
case GST_RTSP_STS_NOT_IMPLEMENTED:
|
||||||
case GST_RTSP_STS_METHOD_NOT_ALLOWED:
|
case GST_RTSP_STS_METHOD_NOT_ALLOWED:
|
||||||
|
@ -3816,9 +3849,11 @@ gst_rtspsrc_open (GstRTSPSrc * src)
|
||||||
|
|
||||||
GST_RTSP_STATE_LOCK (src);
|
GST_RTSP_STATE_LOCK (src);
|
||||||
|
|
||||||
|
restart:
|
||||||
/* reset our state */
|
/* reset our state */
|
||||||
gst_segment_init (&src->segment, GST_FORMAT_TIME);
|
gst_segment_init (&src->segment, GST_FORMAT_TIME);
|
||||||
src->need_range = TRUE;
|
src->need_range = TRUE;
|
||||||
|
src->need_redirect = FALSE;
|
||||||
|
|
||||||
/* can't continue without a valid url */
|
/* can't continue without a valid url */
|
||||||
if (G_UNLIKELY (src->url == NULL))
|
if (G_UNLIKELY (src->url == NULL))
|
||||||
|
@ -3876,6 +3911,21 @@ gst_rtspsrc_open (GstRTSPSrc * src)
|
||||||
if ((res = gst_rtspsrc_send (src, &request, &response, NULL)) < 0)
|
if ((res = gst_rtspsrc_send (src, &request, &response, NULL)) < 0)
|
||||||
goto send_error;
|
goto send_error;
|
||||||
|
|
||||||
|
/* we only perform redirect for the describe, currently */
|
||||||
|
if (src->need_redirect) {
|
||||||
|
/* close connection, we don't have to send a TEARDOWN yet, ignore the
|
||||||
|
* result. */
|
||||||
|
gst_rtsp_connection_close (src->connection);
|
||||||
|
gst_rtsp_connection_free (src->connection);
|
||||||
|
src->connection = NULL;
|
||||||
|
|
||||||
|
gst_rtsp_message_unset (&request);
|
||||||
|
gst_rtsp_message_unset (&response);
|
||||||
|
|
||||||
|
/* and now retry */
|
||||||
|
goto restart;
|
||||||
|
}
|
||||||
|
|
||||||
/* check if reply is SDP */
|
/* check if reply is SDP */
|
||||||
gst_rtsp_message_get_header (&response, GST_RTSP_HDR_CONTENT_TYPE, &respcont,
|
gst_rtsp_message_get_header (&response, GST_RTSP_HDR_CONTENT_TYPE, &respcont,
|
||||||
0);
|
0);
|
||||||
|
|
|
@ -176,6 +176,7 @@ struct _GstRTSPSrc {
|
||||||
GstRTSPLowerTrans cur_protocols;
|
GstRTSPLowerTrans cur_protocols;
|
||||||
gboolean tried_url_auth;
|
gboolean tried_url_auth;
|
||||||
gchar *addr;
|
gchar *addr;
|
||||||
|
gboolean need_redirect;
|
||||||
|
|
||||||
/* supported methods */
|
/* supported methods */
|
||||||
gint methods;
|
gint methods;
|
||||||
|
|
Loading…
Reference in a new issue