From: <wt...@ke...> - 2007-12-31 13:27:41
|
CVS Root: /cvs/gstreamer Module: gst-plugins-good Changes by: wtay Date: Mon Dec 31 2007 13:27:46 UTC Log message: * gst/rtsp/gstrtspsrc.c: (gst_rtspsrc_send), (gst_rtspsrc_open): * gst/rtsp/gstrtspsrc.h: Implement redirect for the DESCRIBE reply. Fixes #506025. Modified files: . : ChangeLog gst/rtsp : gstrtspsrc.c gstrtspsrc.h Links: http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/ChangeLog.diff?r1=1.3227&r2=1.3228 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/gst/rtsp/gstrtspsrc.c.diff?r1=1.121&r2=1.122 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/gst/rtsp/gstrtspsrc.h.diff?r1=1.44&r2=1.45 ====Begin Diffs==== Index: ChangeLog =================================================================== RCS file: /cvs/gstreamer/gst-plugins-good/ChangeLog,v retrieving revision 1.3227 retrieving revision 1.3228 diff -u -d -r1.3227 -r1.3228 --- ChangeLog 29 Dec 2007 16:48:32 -0000 1.3227 +++ ChangeLog 31 Dec 2007 13:27:31 -0000 1.3228 @@ -1,3 +1,9 @@ +2007-12-31 Wim Taymans <wim...@co...> + + * 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 <sl...@ci...> * ext/flac/gstflacdec.c: (gst_flac_dec_write): Index: gstrtspsrc.c RCS file: /cvs/gstreamer/gst-plugins-good/gst/rtsp/gstrtspsrc.c,v retrieving revision 1.121 retrieving revision 1.122 diff -u -d -r1.121 -r1.122 --- gstrtspsrc.c 15 Nov 2007 17:47:43 -0000 1.121 +++ gstrtspsrc.c 31 Dec 2007 13:27:32 -0000 1.122 @@ -3216,24 +3216,34 @@ { GstRTSPStatusCode int_code = GST_RTSP_STS_OK; GstRTSPResult res; + gint count; gboolean retry; GstRTSPMethod method; + count = 0; do { retry = FALSE; + /* make sure we don't loop forever */ + if (count++ > 8) + break; /* save method so we can disable it when the server complains */ method = request->type_data.request.method; if ((res = gst_rtspsrc_try_send (src, request, response, &int_code)) < 0) goto error; - if (int_code == GST_RTSP_STS_UNAUTHORIZED) { - if (gst_rtspsrc_setup_auth (src, response)) { - /* Try the request/response again after configuring the auth info - * and loop again */ - retry = TRUE; - } + switch (int_code) { + case GST_RTSP_STS_UNAUTHORIZED: + if (gst_rtspsrc_setup_auth (src, response)) { + /* Try the request/response again after configuring the auth info + * and loop again */ + retry = TRUE; + } + break; + default: } } while (retry == TRUE); @@ -3261,6 +3271,29 @@ GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND, (NULL), ("%s", response->type_data.response.reason)); 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; + } case GST_RTSP_STS_NOT_ACCEPTABLE: case GST_RTSP_STS_NOT_IMPLEMENTED: case GST_RTSP_STS_METHOD_NOT_ALLOWED: @@ -3816,9 +3849,11 @@ GST_RTSP_STATE_LOCK (src); +restart: /* reset our state */ gst_segment_init (&src->segment, GST_FORMAT_TIME); src->need_range = TRUE; + src->need_redirect = FALSE; /* can't continue without a valid url */ if (G_UNLIKELY (src->url == NULL)) @@ -3876,6 +3911,21 @@ if ((res = gst_rtspsrc_send (src, &request, &response, NULL)) < 0) 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 */ gst_rtsp_message_get_header (&response, GST_RTSP_HDR_CONTENT_TYPE, &respcont, 0); Index: gstrtspsrc.h RCS file: /cvs/gstreamer/gst-plugins-good/gst/rtsp/gstrtspsrc.h,v retrieving revision 1.44 retrieving revision 1.45 diff -u -d -r1.44 -r1.45 --- gstrtspsrc.h 1 Oct 2007 16:34:56 -0000 1.44 +++ gstrtspsrc.h 31 Dec 2007 13:27:32 -0000 1.45 @@ -176,6 +176,7 @@ GstRTSPLowerTrans cur_protocols; gboolean tried_url_auth; gchar *addr; + gboolean need_redirect; /* supported methods */ gint methods; |