diff options
author | Patricia Muscalu <patricia@dovakhiin.com> | 2017-12-16 21:01:43 +0100 |
---|---|---|
committer | Edward Hervey <bilboed@bilboed.com> | 2017-12-18 11:34:48 +0100 |
commit | 96cfed48bfd06d4c620fa0630131ac0d5aa33db7 (patch) | |
tree | 097848263f7d823d98fddd0faa088c63244f394e | |
parent | b4ab386e8726c162c5744c74894a3cae7f970d65 (diff) |
rtspclientsink: Wait until OPEN has been scheduled
Make sure that the sink thread has started opening connection
to the server before continuing.
https://bugzilla.gnome.org/show_bug.cgi?id=790412
-rw-r--r-- | gst/rtsp-sink/gstrtspclientsink.c | 18 | ||||
-rw-r--r-- | gst/rtsp-sink/gstrtspclientsink.h | 5 |
2 files changed, 23 insertions, 0 deletions
diff --git a/gst/rtsp-sink/gstrtspclientsink.c b/gst/rtsp-sink/gstrtspclientsink.c index 73ca9db..d49f224 100644 --- a/gst/rtsp-sink/gstrtspclientsink.c +++ b/gst/rtsp-sink/gstrtspclientsink.c @@ -3025,6 +3025,12 @@ gst_rtsp_client_sink_open (GstRTSPClientSink * sink, gboolean async) sink->methods = GST_RTSP_SETUP | GST_RTSP_RECORD | GST_RTSP_PAUSE | GST_RTSP_TEARDOWN; + g_mutex_lock (&sink->open_conn_lock); + sink->open_conn_start = TRUE; + g_cond_broadcast (&sink->open_conn_cond); + GST_DEBUG_OBJECT (sink, "connection to server started"); + g_mutex_unlock (&sink->open_conn_lock); + if ((ret = gst_rtsp_client_sink_connect_to_server (sink, async)) < 0) goto open_failed; @@ -4569,6 +4575,18 @@ gst_rtsp_client_sink_change_state (GstElement * element, ret = GST_STATE_CHANGE_ASYNC; g_mutex_unlock (&rtsp_client_sink->preroll_lock); gst_rtsp_client_sink_loop_send_cmd (rtsp_client_sink, CMD_OPEN, 0); + + /* CMD_OPEN has been scheduled. Wait until the sink thread starts + * opening connection to the server */ + g_mutex_lock (&rtsp_client_sink->open_conn_lock); + while (!rtsp_client_sink->open_conn_start) { + GST_DEBUG_OBJECT (rtsp_client_sink, + "wait for connection to be started"); + g_cond_wait (&rtsp_client_sink->open_conn_cond, + &rtsp_client_sink->open_conn_lock); + } + rtsp_client_sink->open_conn_start = FALSE; + g_mutex_unlock (&rtsp_client_sink->open_conn_lock); break; case GST_STATE_CHANGE_PAUSED_TO_PLAYING:{ GST_DEBUG_OBJECT (rtsp_client_sink, diff --git a/gst/rtsp-sink/gstrtspclientsink.h b/gst/rtsp-sink/gstrtspclientsink.h index b27daf8..476165a 100644 --- a/gst/rtsp-sink/gstrtspclientsink.h +++ b/gst/rtsp-sink/gstrtspclientsink.h @@ -230,6 +230,11 @@ struct _GstRTSPClientSink { GMutex preroll_lock; GCond preroll_cond; + /* TRUE if connection to server has been scheduled */ + gboolean open_conn_start; + GMutex open_conn_lock; + GCond open_conn_cond; + GstClockTime rtx_time; GstRTSPProfile profiles; |