summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gst/rtsp-sink/gstrtspclientsink.c18
-rw-r--r--gst/rtsp-sink/gstrtspclientsink.h5
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;