guint num_buffers;
guint max_buffers;
gboolean drop;
+#ifdef TIZEN_FEATURE_GST_UPSTREAM
+ gboolean wait_on_eos;
+#endif
GCond cond;
GMutex mutex;
#define DEFAULT_PROP_EMIT_SIGNALS FALSE
#define DEFAULT_PROP_MAX_BUFFERS 0
#define DEFAULT_PROP_DROP FALSE
+#ifdef TIZEN_FEATURE_GST_UPSTREAM
+#define DEFAULT_PROP_WAIT_ON_EOS TRUE
+#endif
enum
{
PROP_EMIT_SIGNALS,
PROP_MAX_BUFFERS,
PROP_DROP,
+#ifdef TIZEN_FEATURE_GST_UPSTREAM
+ PROP_WAIT_ON_EOS,
+#endif
PROP_LAST
};
"Drop old buffers when the buffer queue is filled", DEFAULT_PROP_DROP,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+#ifdef TIZEN_FEATURE_GST_UPSTREAM
+ /**
+ * GstAppSink::wait-on-eos:
+ *
+ * Wait for all buffers to be processed after receiving an EOS.
+ *
+ * In cases where it is uncertain if an @appsink will have a consumer for its buffers
+ * when it receives an EOS, set to %FALSE to ensure that the @appsink will not hang.
+ *
+ * Since: 1.8
+ */
+ g_object_class_install_property (gobject_class, PROP_WAIT_ON_EOS,
+ g_param_spec_boolean ("wait-on-eos", "Wait on EOS",
+ "Wait for all buffers to be processed after receiving an EOS",
+ DEFAULT_PROP_WAIT_ON_EOS,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+#endif
+
/**
* GstAppSink::eos:
* @appsink: the appsink element that emitted the signal
priv->emit_signals = DEFAULT_PROP_EMIT_SIGNALS;
priv->max_buffers = DEFAULT_PROP_MAX_BUFFERS;
priv->drop = DEFAULT_PROP_DROP;
+#ifdef TIZEN_FEATURE_GST_UPSTREAM
+ priv->wait_on_eos = DEFAULT_PROP_WAIT_ON_EOS;
+#endif
}
static void
case PROP_DROP:
gst_app_sink_set_drop (appsink, g_value_get_boolean (value));
break;
+#ifdef TIZEN_FEATURE_GST_UPSTREAM
+ case PROP_WAIT_ON_EOS:
+ gst_app_sink_set_wait_on_eos (appsink, g_value_get_boolean (value));
+ break;
+#endif
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
case PROP_DROP:
g_value_set_boolean (value, gst_app_sink_get_drop (appsink));
break;
+#ifdef TIZEN_FEATURE_GST_UPSTREAM
+ case PROP_WAIT_ON_EOS:
+ g_value_set_boolean (value, gst_app_sink_get_wait_on_eos (appsink));
+ break;
+#endif
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
* Otherwise we might signal EOS before all buffers are
* consumed, which is a bit confusing for the application
*/
+#ifndef TIZEN_FEATURE_GST_UPSTREAM
while (priv->num_buffers > 0 && !priv->flushing)
+#else
+ while (priv->num_buffers > 0 && !priv->flushing && priv->wait_on_eos)
+#endif
g_cond_wait (&priv->cond, &priv->mutex);
if (priv->flushing)
emit = FALSE;
return result;
}
+#ifdef TIZEN_FEATURE_GST_UPSTREAM
+/**
+ * gst_app_sink_set_wait_on_eos:
+ * @appsink: a #GstAppSink
+ * @wait: the new state
+ *
+ * Instruct @appsink to wait for all buffers to be consumed when an EOS is received.
+ *
+ */
+void
+gst_app_sink_set_wait_on_eos (GstAppSink * appsink, gboolean wait)
+{
+ GstAppSinkPrivate *priv;
+
+ g_return_if_fail (GST_IS_APP_SINK (appsink));
+
+ priv = appsink->priv;
+
+ g_mutex_lock (&priv->mutex);
+ if (priv->wait_on_eos != wait) {
+ priv->wait_on_eos = wait;
+ /* signal the change */
+ g_cond_signal (&priv->cond);
+ }
+ g_mutex_unlock (&priv->mutex);
+}
+
+/**
+ * gst_app_sink_get_wait_on_eos:
+ * @appsink: a #GstAppSink
+ *
+ * Check if @appsink will wait for all buffers to be consumed when an EOS is
+ * received.
+ *
+ * Returns: %TRUE if @appsink will wait for all buffers to be consumed when an
+ * EOS is received.
+ */
+gboolean
+gst_app_sink_get_wait_on_eos (GstAppSink * appsink)
+{
+ gboolean result;
+ GstAppSinkPrivate *priv;
+
+ g_return_val_if_fail (GST_IS_APP_SINK (appsink), FALSE);
+
+ priv = appsink->priv;
+
+ g_mutex_lock (&priv->mutex);
+ result = priv->wait_on_eos;
+ g_mutex_unlock (&priv->mutex);
+
+ return result;
+}
+#endif
+
/**
* gst_app_sink_pull_preroll:
* @appsink: a #GstAppSink