mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 17:20:36 +00:00
rtspsrc: open on play and pause when not done yet
With the async state changes, it is possible that we need to open the stream before play and pause. Also make sure we remember a previous open failure so that we don't keep trying again.
This commit is contained in:
parent
6fe680934a
commit
ddfcd8bbfd
2 changed files with 44 additions and 4 deletions
|
@ -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:
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue