diff options
author | Sebastian Dröge <sebastian@centricular.com> | 2015-02-19 19:45:06 +0200 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2015-02-19 19:45:06 +0200 |
commit | dc39f9c302053c8c91d360f4af2b9cbcbd85ef56 (patch) | |
tree | ace1a39624bf12803e8a33a14f9e22659d769949 | |
parent | 96e1d3934d973d98acac5d998b85bbc936af2894 (diff) |
Even if we're not in reliable mode. It's a bit unexpected to just silently
drop everything in the beginning.
-rw-r--r-- | gst/gstnicesink.c | 19 | ||||
-rw-r--r-- | gst/gstnicesink.h | 1 |
2 files changed, 18 insertions, 2 deletions
diff --git a/gst/gstnicesink.c b/gst/gstnicesink.c index a6f099d..f0bc55d 100644 --- a/gst/gstnicesink.c +++ b/gst/gstnicesink.c @@ -183,6 +183,17 @@ _reliable_transport_writable (NiceAgent *agent, guint stream_id, GST_OBJECT_UNLOCK (sink); } +static void +_connected (NiceAgent * agent, guint stream_id, guint component_id, NiceComponentState state, GstNiceSink *nicesink) +{ + GST_OBJECT_LOCK (nicesink); + if (nicesink->stream_id == stream_id && nicesink->component_id == component_id) { + nicesink->state = state; + g_cond_broadcast (&nicesink->writable_cond); + } + GST_OBJECT_UNLOCK (nicesink); +} + static GstFlowReturn gst_nice_sink_render (GstBaseSink *basesink, GstBuffer *buffer) { @@ -211,8 +222,10 @@ gst_nice_sink_render (GstBaseSink *basesink, GstBuffer *buffer) if (ret > 0) written += ret; - if (nicesink->reliable && written < size) + if (written < size && (nicesink->reliable || + nicesink->state < NICE_COMPONENT_STATE_READY)) g_cond_wait (&nicesink->writable_cond, GST_OBJECT_GET_LOCK (nicesink)); + if (nicesink->flushing) { #if GST_CHECK_VERSION (1,0,0) flow_ret = GST_FLOW_FLUSHING; @@ -221,7 +234,7 @@ gst_nice_sink_render (GstBaseSink *basesink, GstBuffer *buffer) #endif break; } - } while (nicesink->reliable && written < size); + } while (written < size); GST_OBJECT_UNLOCK (nicesink); #if GST_CHECK_VERSION (1,0,0) @@ -288,6 +301,7 @@ gst_nice_sink_set_property ( } else { sink->agent = g_value_dup_object (value); g_object_get (sink->agent, "reliable", &sink->reliable, NULL); + g_signal_connect (sink->agent, "component-state-changed", G_CALLBACK (_connected), sink); if (sink->reliable) sink->writable_id = g_signal_connect (sink->agent, "reliable-transport-writable", @@ -368,6 +382,7 @@ gst_nice_sink_change_state (GstElement * element, GstStateChange transition) "Trying to start Nice sink without an agent set"); return GST_STATE_CHANGE_FAILURE; } + sink->state = NICE_COMPONENT_STATE_DISCONNECTED; break; case GST_STATE_CHANGE_READY_TO_PAUSED: case GST_STATE_CHANGE_PAUSED_TO_PLAYING: diff --git a/gst/gstnicesink.h b/gst/gstnicesink.h index 9529f64..3a5045d 100644 --- a/gst/gstnicesink.h +++ b/gst/gstnicesink.h @@ -69,6 +69,7 @@ struct _GstNiceSink GCond writable_cond; gulong writable_id; gboolean flushing; + NiceComponentState state; }; typedef struct _GstNiceSinkClass GstNiceSinkClass; |