diff --git a/gst/rtsp/gstrtspsrc.c b/gst/rtsp/gstrtspsrc.c index c8fb921370..832656a054 100644 --- a/gst/rtsp/gstrtspsrc.c +++ b/gst/rtsp/gstrtspsrc.c @@ -3952,10 +3952,6 @@ gst_rtspsrc_reconnect (GstRTSPSrc * src, gboolean async) /* we can try only TCP now */ src->cur_protocols = GST_RTSP_LOWER_TRANS_TCP; - /* pause to prepare for a restart */ - if ((res = gst_rtspsrc_pause (src, FALSE, async)) < 0) - goto done; - /* close and cleanup our state */ if ((res = gst_rtspsrc_close (src, async)) < 0) goto done; @@ -5744,11 +5740,13 @@ done: no_sdp: { GST_WARNING_OBJECT (src, "can't get sdp"); + src->open_error = TRUE; goto done; } open_failed: { GST_WARNING_OBJECT (src, "can't setup streaming from sdp"); + src->open_error = TRUE; goto done; } } @@ -5986,6 +5984,30 @@ clear_rtp_base (GstRTSPSrc * src, GstRTSPStream * stream) } } +static GstRTSPResult +gst_rtspsrc_ensure_open (GstRTSPSrc * src, gboolean async) +{ + GstRTSPResult res = GST_RTSP_OK; + + if (src->state < GST_RTSP_STATE_READY) { + res = GST_RTSP_ERROR; + if (src->open_error) { + GST_DEBUG_OBJECT (src, "the stream was in error"); + goto done; + } + if (async) + gst_rtspsrc_loop_start_cmd (src, CMD_OPEN); + + if ((res = gst_rtspsrc_open (src, async)) < 0) { + GST_DEBUG_OBJECT (src, "failed to open stream"); + goto done; + } + } + +done: + return res; +} + static GstRTSPResult gst_rtspsrc_play (GstRTSPSrc * src, GstSegment * segment, gboolean async) { @@ -5999,6 +6021,9 @@ gst_rtspsrc_play (GstRTSPSrc * src, GstSegment * segment, gboolean async) GST_DEBUG_OBJECT (src, "PLAY..."); + if ((res = gst_rtspsrc_ensure_open (src, async)) < 0) + goto open_failed; + if (!(src->methods & GST_RTSP_PLAY)) goto not_supported; @@ -6149,6 +6174,11 @@ done: return res; /* ERRORS */ +open_failed: + { + GST_DEBUG_OBJECT (src, "failed to open stream"); + goto done; + } not_supported: { GST_DEBUG_OBJECT (src, "PLAY is not supported"); @@ -6195,6 +6225,9 @@ gst_rtspsrc_pause (GstRTSPSrc * src, gboolean idle, gboolean async) GST_DEBUG_OBJECT (src, "PAUSE..."); + if ((res = gst_rtspsrc_ensure_open (src, async)) < 0) + goto open_failed; + if (!(src->methods & GST_RTSP_PAUSE)) goto not_supported; @@ -6261,6 +6294,11 @@ done: return res; /* ERRORS */ +open_failed: + { + GST_DEBUG_OBJECT (src, "failed to open stream"); + goto done; + } not_supported: { GST_DEBUG_OBJECT (src, "PAUSE is not supported"); @@ -6395,6 +6433,7 @@ gst_rtspsrc_thread (GstRTSPSrc * src) src->cur_protocols = src->protocols; /* first attempt, don't ignore timeouts */ src->ignore_timeout = FALSE; + src->open_error = FALSE; ret = gst_rtspsrc_open (src, TRUE); break; case CMD_PLAY: diff --git a/gst/rtsp/gstrtspsrc.h b/gst/rtsp/gstrtspsrc.h index b5744248cc..f69a3edd27 100644 --- a/gst/rtsp/gstrtspsrc.h +++ b/gst/rtsp/gstrtspsrc.h @@ -182,6 +182,7 @@ struct _GstRTSPSrc { gboolean ignore_timeout; gboolean flushing; gboolean waiting; + gboolean open_error; /* mutex for protecting state changes */ GStaticRecMutex *state_rec_lock;