+2009-01-06 Tim-Philipp Müller <tim.muller at collabora co uk>
+
+ * gst-libs/gst/app/gstappsink.c: (_GstAppSinkPrivate),
+ (gst_app_sink_class_init), (gst_app_sink_init),
+ (gst_app_sink_dispose), (gst_app_sink_finalize),
+ (gst_app_sink_unlock_start), (gst_app_sink_unlock_stop),
+ (gst_app_sink_flush_unlocked), (gst_app_sink_start),
+ (gst_app_sink_stop), (gst_app_sink_event), (gst_app_sink_preroll),
+ (gst_app_sink_render), (gst_app_sink_getcaps),
+ (gst_app_sink_set_caps), (gst_app_sink_get_caps),
+ (gst_app_sink_is_eos), (gst_app_sink_set_emit_signals),
+ (gst_app_sink_get_emit_signals), (gst_app_sink_set_max_buffers),
+ (gst_app_sink_get_max_buffers), (gst_app_sink_set_drop),
+ (gst_app_sink_get_drop), (gst_app_sink_pull_preroll),
+ (gst_app_sink_pull_buffer)::
+ * gst-libs/gst/app/gstappsink.h: (GstAppSinkPrivate), (_GstAppSink)::
+ * gst-libs/gst/app/gstappsrc.c: (_GstAppSrcPrivate),
+ (gst_app_src_class_init), (gst_app_src_init),
+ (gst_app_src_flush_queued), (gst_app_src_dispose),
+ (gst_app_src_finalize), (gst_app_src_set_property),
+ (gst_app_src_get_property), (gst_app_src_unlock),
+ (gst_app_src_unlock_stop), (gst_app_src_start), (gst_app_src_stop),
+ (gst_app_src_is_seekable), (gst_app_src_check_get_range),
+ (gst_app_src_query), (gst_app_src_do_seek), (gst_app_src_create),
+ (gst_app_src_set_caps), (gst_app_src_get_caps),
+ (gst_app_src_set_size), (gst_app_src_get_size),
+ (gst_app_src_set_stream_type), (gst_app_src_get_stream_type),
+ (gst_app_src_set_max_bytes), (gst_app_src_get_max_bytes),
+ (gst_app_src_set_latencies), (gst_app_src_set_latency),
+ (gst_app_src_get_latency), (gst_app_src_push_buffer_full),
+ (gst_app_src_push_buffer_action), (gst_app_src_end_of_stream)::
+ * gst-libs/gst/app/gstappsrc.h: (GstAppSrcPrivate)::
+ Move private data into a private instance struct. Add padding to
+ instance and class structures exposed in public headers. Add
+ Since markers to the gtk-doc blurbs (#566750).
+
2009-01-06 Wim Taymans <wim.taymans@collabora.co.uk>
* tests/examples/app/appsrc_ex.c: (main):
* <link linkend="gst-plugins-base-libs-appsink">libgstapp</link> section in
* the GStreamer Plugins Base Libraries documentation.
*
+ * Since: 0.10.22
*/
* The eos signal can also be used to be informed when the EOS state is reached
* to avoid polling.
*
- * Last reviewed on 2008-12-17 (0.10.10)
+ * Since: 0.10.22
+ *
+ * Last reviewed on 2008-12-17 (0.10.22)
*/
#ifdef HAVE_CONFIG_H
#include "gstappsink.h"
+struct _GstAppSinkPrivate
+{
+ GstCaps *caps;
+ gboolean emit_signals;
+ guint max_buffers;
+ gboolean drop;
+
+ GCond *cond;
+ GMutex *mutex;
+ GQueue *queue;
+ GstBuffer *preroll;
+ gboolean flushing;
+ gboolean started;
+ gboolean is_eos;
+};
GST_DEBUG_CATEGORY (app_sink_debug);
#define GST_CAT_DEFAULT app_sink_debug
klass->pull_preroll = gst_app_sink_pull_preroll;
klass->pull_buffer = gst_app_sink_pull_buffer;
+
+ g_type_class_add_private (klass, sizeof (GstAppSinkPrivate));
}
static void
gst_app_sink_init (GstAppSink * appsink, GstAppSinkClass * klass)
{
- appsink->mutex = g_mutex_new ();
- appsink->cond = g_cond_new ();
- appsink->queue = g_queue_new ();
+ appsink->priv = G_TYPE_INSTANCE_GET_PRIVATE (appsink, GST_TYPE_APP_SINK,
+ GstAppSinkPrivate);
- appsink->emit_signals = DEFAULT_PROP_EMIT_SIGNALS;
- appsink->max_buffers = DEFAULT_PROP_MAX_BUFFERS;
- appsink->drop = DEFAULT_PROP_DROP;
+ appsink->priv->mutex = g_mutex_new ();
+ appsink->priv->cond = g_cond_new ();
+ appsink->priv->queue = g_queue_new ();
+
+ appsink->priv->emit_signals = DEFAULT_PROP_EMIT_SIGNALS;
+ appsink->priv->max_buffers = DEFAULT_PROP_MAX_BUFFERS;
+ appsink->priv->drop = DEFAULT_PROP_DROP;
}
static void
GstBuffer *buffer;
GST_OBJECT_LOCK (appsink);
- if (appsink->caps) {
- gst_caps_unref (appsink->caps);
- appsink->caps = NULL;
+ if (appsink->priv->caps) {
+ gst_caps_unref (appsink->priv->caps);
+ appsink->priv->caps = NULL;
}
GST_OBJECT_UNLOCK (appsink);
- g_mutex_lock (appsink->mutex);
- if (appsink->preroll) {
- gst_buffer_unref (appsink->preroll);
- appsink->preroll = NULL;
+ g_mutex_lock (appsink->priv->mutex);
+ if (appsink->priv->preroll) {
+ gst_buffer_unref (appsink->priv->preroll);
+ appsink->priv->preroll = NULL;
}
- while ((buffer = g_queue_pop_head (appsink->queue)))
+ while ((buffer = g_queue_pop_head (appsink->priv->queue)))
gst_buffer_unref (buffer);
- g_mutex_unlock (appsink->mutex);
+ g_mutex_unlock (appsink->priv->mutex);
G_OBJECT_CLASS (parent_class)->dispose (obj);
}
{
GstAppSink *appsink = GST_APP_SINK (obj);
- g_mutex_free (appsink->mutex);
- g_cond_free (appsink->cond);
- g_queue_free (appsink->queue);
+ g_mutex_free (appsink->priv->mutex);
+ g_cond_free (appsink->priv->cond);
+ g_queue_free (appsink->priv->queue);
G_OBJECT_CLASS (parent_class)->finalize (obj);
}
{
GstAppSink *appsink = GST_APP_SINK (bsink);
- g_mutex_lock (appsink->mutex);
+ g_mutex_lock (appsink->priv->mutex);
GST_DEBUG_OBJECT (appsink, "unlock start");
- appsink->flushing = TRUE;
- g_cond_signal (appsink->cond);
- g_mutex_unlock (appsink->mutex);
+ appsink->priv->flushing = TRUE;
+ g_cond_signal (appsink->priv->cond);
+ g_mutex_unlock (appsink->priv->mutex);
return TRUE;
}
{
GstAppSink *appsink = GST_APP_SINK (bsink);
- g_mutex_lock (appsink->mutex);
+ g_mutex_lock (appsink->priv->mutex);
GST_DEBUG_OBJECT (appsink, "unlock stop");
- appsink->flushing = FALSE;
- g_cond_signal (appsink->cond);
- g_mutex_unlock (appsink->mutex);
+ appsink->priv->flushing = FALSE;
+ g_cond_signal (appsink->priv->cond);
+ g_mutex_unlock (appsink->priv->mutex);
return TRUE;
}
GstBuffer *buffer;
GST_DEBUG_OBJECT (appsink, "flush stop appsink");
- appsink->is_eos = FALSE;
- gst_buffer_replace (&appsink->preroll, NULL);
- while ((buffer = g_queue_pop_head (appsink->queue)))
+ appsink->priv->is_eos = FALSE;
+ gst_buffer_replace (&appsink->priv->preroll, NULL);
+ while ((buffer = g_queue_pop_head (appsink->priv->queue)))
gst_buffer_unref (buffer);
- g_cond_signal (appsink->cond);
+ g_cond_signal (appsink->priv->cond);
}
static gboolean
{
GstAppSink *appsink = GST_APP_SINK (psink);
- g_mutex_lock (appsink->mutex);
+ g_mutex_lock (appsink->priv->mutex);
GST_DEBUG_OBJECT (appsink, "starting");
- appsink->started = TRUE;
- g_mutex_unlock (appsink->mutex);
+ appsink->priv->started = TRUE;
+ g_mutex_unlock (appsink->priv->mutex);
return TRUE;
}
{
GstAppSink *appsink = GST_APP_SINK (psink);
- g_mutex_lock (appsink->mutex);
+ g_mutex_lock (appsink->priv->mutex);
GST_DEBUG_OBJECT (appsink, "stopping");
- appsink->flushing = TRUE;
- appsink->started = FALSE;
+ appsink->priv->flushing = TRUE;
+ appsink->priv->started = FALSE;
gst_app_sink_flush_unlocked (appsink);
- g_mutex_unlock (appsink->mutex);
+ g_mutex_unlock (appsink->priv->mutex);
return TRUE;
}
switch (event->type) {
case GST_EVENT_EOS:
- g_mutex_lock (appsink->mutex);
+ g_mutex_lock (appsink->priv->mutex);
GST_DEBUG_OBJECT (appsink, "receiving EOS");
- appsink->is_eos = TRUE;
- g_cond_signal (appsink->cond);
- g_mutex_unlock (appsink->mutex);
+ appsink->priv->is_eos = TRUE;
+ g_cond_signal (appsink->priv->cond);
+ g_mutex_unlock (appsink->priv->mutex);
/* emit EOS now */
g_signal_emit (appsink, gst_app_sink_signals[SIGNAL_EOS], 0);
GST_DEBUG_OBJECT (appsink, "received FLUSH_START");
break;
case GST_EVENT_FLUSH_STOP:
- g_mutex_lock (appsink->mutex);
+ g_mutex_lock (appsink->priv->mutex);
GST_DEBUG_OBJECT (appsink, "received FLUSH_STOP");
gst_app_sink_flush_unlocked (appsink);
- g_mutex_unlock (appsink->mutex);
+ g_mutex_unlock (appsink->priv->mutex);
break;
default:
break;
GstAppSink *appsink = GST_APP_SINK (psink);
gboolean emit;
- g_mutex_lock (appsink->mutex);
- if (appsink->flushing)
+ g_mutex_lock (appsink->priv->mutex);
+ if (appsink->priv->flushing)
goto flushing;
GST_DEBUG_OBJECT (appsink, "setting preroll buffer %p", buffer);
- gst_buffer_replace (&appsink->preroll, buffer);
- g_cond_signal (appsink->cond);
- emit = appsink->emit_signals;
- g_mutex_unlock (appsink->mutex);
+ gst_buffer_replace (&appsink->priv->preroll, buffer);
+ g_cond_signal (appsink->priv->cond);
+ emit = appsink->priv->emit_signals;
+ g_mutex_unlock (appsink->priv->mutex);
if (emit)
g_signal_emit (appsink, gst_app_sink_signals[SIGNAL_NEW_PREROLL], 0);
flushing:
{
GST_DEBUG_OBJECT (appsink, "we are flushing");
- g_mutex_unlock (appsink->mutex);
+ g_mutex_unlock (appsink->priv->mutex);
return GST_FLOW_WRONG_STATE;
}
}
GstAppSink *appsink = GST_APP_SINK (psink);
gboolean emit;
- g_mutex_lock (appsink->mutex);
- if (appsink->flushing)
+ g_mutex_lock (appsink->priv->mutex);
+ if (appsink->priv->flushing)
goto flushing;
GST_DEBUG_OBJECT (appsink, "pushing render buffer %p on queue (%d)",
- buffer, appsink->queue->length);
+ buffer, appsink->priv->queue->length);
- while (appsink->max_buffers > 0 &&
- appsink->queue->length >= appsink->max_buffers) {
- if (appsink->drop) {
+ while (appsink->priv->max_buffers > 0 &&
+ appsink->priv->queue->length >= appsink->priv->max_buffers) {
+ if (appsink->priv->drop) {
GstBuffer *buf;
/* we need to drop the oldest buffer and try again */
- buf = g_queue_pop_head (appsink->queue);
+ buf = g_queue_pop_head (appsink->priv->queue);
GST_DEBUG_OBJECT (appsink, "dropping old buffer %p", buf);
gst_buffer_unref (buf);
} else {
GST_DEBUG_OBJECT (appsink, "waiting for free space, length %d >= %d",
- appsink->queue->length, appsink->max_buffers);
+ appsink->priv->queue->length, appsink->priv->max_buffers);
/* wait for a buffer to be removed or flush */
- g_cond_wait (appsink->cond, appsink->mutex);
- if (appsink->flushing)
+ g_cond_wait (appsink->priv->cond, appsink->priv->mutex);
+ if (appsink->priv->flushing)
goto flushing;
}
}
/* we need to ref the buffer when pushing it in the queue */
- g_queue_push_tail (appsink->queue, gst_buffer_ref (buffer));
- g_cond_signal (appsink->cond);
- emit = appsink->emit_signals;
- g_mutex_unlock (appsink->mutex);
+ g_queue_push_tail (appsink->priv->queue, gst_buffer_ref (buffer));
+ g_cond_signal (appsink->priv->cond);
+ emit = appsink->priv->emit_signals;
+ g_mutex_unlock (appsink->priv->mutex);
if (emit)
g_signal_emit (appsink, gst_app_sink_signals[SIGNAL_NEW_BUFFER], 0);
flushing:
{
GST_DEBUG_OBJECT (appsink, "we are flushing");
- g_mutex_unlock (appsink->mutex);
+ g_mutex_unlock (appsink->priv->mutex);
return GST_FLOW_WRONG_STATE;
}
}
GstAppSink *appsink = GST_APP_SINK (psink);
GST_OBJECT_LOCK (appsink);
- if ((caps = appsink->caps))
+ if ((caps = appsink->priv->caps))
gst_caps_ref (caps);
GST_DEBUG_OBJECT (appsink, "got caps %" GST_PTR_FORMAT, caps);
GST_OBJECT_UNLOCK (appsink);
* a copy of the caps structure. After calling this method, the sink will only
* accept caps that match @caps. If @caps is non-fixed, you must check the caps
* on the buffers to get the actual used caps.
+ *
+ * Since: 0.10.22
*/
void
gst_app_sink_set_caps (GstAppSink * appsink, const GstCaps * caps)
GST_OBJECT_LOCK (appsink);
GST_DEBUG_OBJECT (appsink, "setting caps to %" GST_PTR_FORMAT, caps);
- if ((old = appsink->caps) != caps) {
+ if ((old = appsink->priv->caps) != caps) {
if (caps)
- appsink->caps = gst_caps_copy (caps);
+ appsink->priv->caps = gst_caps_copy (caps);
else
- appsink->caps = NULL;
+ appsink->priv->caps = NULL;
if (old)
gst_caps_unref (old);
}
* Get the configured caps on @appsink.
*
* Returns: the #GstCaps accepted by the sink. gst_caps_unref() after usage.
+ *
+ * Since: 0.10.22
*/
GstCaps *
gst_app_sink_get_caps (GstAppSink * appsink)
g_return_val_if_fail (GST_IS_APP_SINK (appsink), NULL);
GST_OBJECT_LOCK (appsink);
- if ((caps = appsink->caps))
+ if ((caps = appsink->priv->caps))
gst_caps_ref (caps);
GST_DEBUG_OBJECT (appsink, "getting caps of %" GST_PTR_FORMAT, caps);
GST_OBJECT_UNLOCK (appsink);
* PLAYING state.
*
* Returns: %TRUE if no more buffers can be pulled and the appsink is EOS.
+ *
+ * Since: 0.10.22
*/
gboolean
gst_app_sink_is_eos (GstAppSink * appsink)
g_return_val_if_fail (appsink != NULL, FALSE);
g_return_val_if_fail (GST_IS_APP_SINK (appsink), FALSE);
- g_mutex_lock (appsink->mutex);
- if (!appsink->started)
+ g_mutex_lock (appsink->priv->mutex);
+ if (!appsink->priv->started)
goto not_started;
- if (appsink->is_eos && g_queue_is_empty (appsink->queue)) {
+ if (appsink->priv->is_eos && g_queue_is_empty (appsink->priv->queue)) {
GST_DEBUG_OBJECT (appsink, "we are EOS and the queue is empty");
ret = TRUE;
} else {
GST_DEBUG_OBJECT (appsink, "we are not yet EOS");
ret = FALSE;
}
- g_mutex_unlock (appsink->mutex);
+ g_mutex_unlock (appsink->priv->mutex);
return ret;
not_started:
{
GST_DEBUG_OBJECT (appsink, "we are stopped, return TRUE");
- g_mutex_unlock (appsink->mutex);
+ g_mutex_unlock (appsink->priv->mutex);
return TRUE;
}
}
* Make appsink emit the "new-preroll" and "new-buffer" signals. This option is
* by default disabled because signal emission is expensive and unneeded when
* the application prefers to operate in pull mode.
+ *
+ * Since: 0.10.22
*/
void
gst_app_sink_set_emit_signals (GstAppSink * appsink, gboolean emit)
{
g_return_if_fail (GST_IS_APP_SINK (appsink));
- g_mutex_lock (appsink->mutex);
- appsink->emit_signals = emit;
- g_mutex_unlock (appsink->mutex);
+ g_mutex_lock (appsink->priv->mutex);
+ appsink->priv->emit_signals = emit;
+ g_mutex_unlock (appsink->priv->mutex);
}
/**
*
* Returns: %TRUE if @appsink is emiting the "new-preroll" and "new-buffer"
* signals.
+ *
+ * Since: 0.10.22
*/
gboolean
gst_app_sink_get_emit_signals (GstAppSink * appsink)
g_return_val_if_fail (GST_IS_APP_SINK (appsink), FALSE);
- g_mutex_lock (appsink->mutex);
- result = appsink->emit_signals;
- g_mutex_unlock (appsink->mutex);
+ g_mutex_lock (appsink->priv->mutex);
+ result = appsink->priv->emit_signals;
+ g_mutex_unlock (appsink->priv->mutex);
return result;
}
* Set the maximum amount of buffers that can be queued in @appsink. After this
* amount of buffers are queued in appsink, any more buffers will block upstream
* elements until a buffer is pulled from @appsink.
+ *
+ * Since: 0.10.22
*/
void
gst_app_sink_set_max_buffers (GstAppSink * appsink, guint max)
{
g_return_if_fail (GST_IS_APP_SINK (appsink));
- g_mutex_lock (appsink->mutex);
- if (max != appsink->max_buffers) {
- appsink->max_buffers = max;
+ g_mutex_lock (appsink->priv->mutex);
+ if (max != appsink->priv->max_buffers) {
+ appsink->priv->max_buffers = max;
/* signal the change */
- g_cond_signal (appsink->cond);
+ g_cond_signal (appsink->priv->cond);
}
- g_mutex_unlock (appsink->mutex);
+ g_mutex_unlock (appsink->priv->mutex);
}
/**
* Get the maximum amount of buffers that can be queued in @appsink.
*
* Returns: The maximum amount of buffers that can be queued.
+ *
+ * Since: 0.10.22
*/
guint
gst_app_sink_get_max_buffers (GstAppSink * appsink)
g_return_val_if_fail (GST_IS_APP_SINK (appsink), 0);
- g_mutex_lock (appsink->mutex);
- result = appsink->max_buffers;
- g_mutex_unlock (appsink->mutex);
+ g_mutex_lock (appsink->priv->mutex);
+ result = appsink->priv->max_buffers;
+ g_mutex_unlock (appsink->priv->mutex);
return result;
}
*
* Instruct @appsink to drop old buffers when the maximum amount of queued
* buffers is reached.
+ *
+ * Since: 0.10.22
*/
void
gst_app_sink_set_drop (GstAppSink * appsink, gboolean drop)
{
g_return_if_fail (GST_IS_APP_SINK (appsink));
- g_mutex_lock (appsink->mutex);
- if (appsink->drop != drop) {
- appsink->drop = drop;
+ g_mutex_lock (appsink->priv->mutex);
+ if (appsink->priv->drop != drop) {
+ appsink->priv->drop = drop;
/* signal the change */
- g_cond_signal (appsink->cond);
+ g_cond_signal (appsink->priv->cond);
}
- g_mutex_unlock (appsink->mutex);
+ g_mutex_unlock (appsink->priv->mutex);
}
/**
*
* Returns: %TRUE if @appsink is dropping old buffers when the queue is
* filled.
+ *
+ * Since: 0.10.22
*/
gboolean
gst_app_sink_get_drop (GstAppSink * appsink)
g_return_val_if_fail (GST_IS_APP_SINK (appsink), FALSE);
- g_mutex_lock (appsink->mutex);
- result = appsink->drop;
- g_mutex_unlock (appsink->mutex);
+ g_mutex_lock (appsink->priv->mutex);
+ result = appsink->priv->drop;
+ g_mutex_unlock (appsink->priv->mutex);
return result;
}
* element is set to the READY/NULL state.
*
* Returns: a #GstBuffer or NULL when the appsink is stopped or EOS.
+ *
+ * Since: 0.10.22
*/
GstBuffer *
gst_app_sink_pull_preroll (GstAppSink * appsink)
g_return_val_if_fail (appsink != NULL, NULL);
g_return_val_if_fail (GST_IS_APP_SINK (appsink), NULL);
- g_mutex_lock (appsink->mutex);
+ g_mutex_lock (appsink->priv->mutex);
while (TRUE) {
GST_DEBUG_OBJECT (appsink, "trying to grab a buffer");
- if (!appsink->started)
+ if (!appsink->priv->started)
goto not_started;
- if (appsink->preroll != NULL)
+ if (appsink->priv->preroll != NULL)
break;
- if (appsink->is_eos)
+ if (appsink->priv->is_eos)
goto eos;
/* nothing to return, wait */
GST_DEBUG_OBJECT (appsink, "waiting for the preroll buffer");
- g_cond_wait (appsink->cond, appsink->mutex);
+ g_cond_wait (appsink->priv->cond, appsink->priv->mutex);
}
- buf = gst_buffer_ref (appsink->preroll);
+ buf = gst_buffer_ref (appsink->priv->preroll);
GST_DEBUG_OBJECT (appsink, "we have the preroll buffer %p", buf);
- g_mutex_unlock (appsink->mutex);
+ g_mutex_unlock (appsink->priv->mutex);
return buf;
eos:
{
GST_DEBUG_OBJECT (appsink, "we are EOS, return NULL");
- g_mutex_unlock (appsink->mutex);
+ g_mutex_unlock (appsink->priv->mutex);
return NULL;
}
not_started:
{
GST_DEBUG_OBJECT (appsink, "we are stopped, return NULL");
- g_mutex_unlock (appsink->mutex);
+ g_mutex_unlock (appsink->priv->mutex);
return NULL;
}
}
* %NULL. Use gst_app_sink_is_eos () to check for the EOS condition.
*
* Returns: a #GstBuffer or NULL when the appsink is stopped or EOS.
+ *
+ * Since: 0.10.22
*/
GstBuffer *
gst_app_sink_pull_buffer (GstAppSink * appsink)
g_return_val_if_fail (appsink != NULL, NULL);
g_return_val_if_fail (GST_IS_APP_SINK (appsink), NULL);
- g_mutex_lock (appsink->mutex);
+ g_mutex_lock (appsink->priv->mutex);
while (TRUE) {
GST_DEBUG_OBJECT (appsink, "trying to grab a buffer");
- if (!appsink->started)
+ if (!appsink->priv->started)
goto not_started;
- if (!g_queue_is_empty (appsink->queue))
+ if (!g_queue_is_empty (appsink->priv->queue))
break;
- if (appsink->is_eos)
+ if (appsink->priv->is_eos)
goto eos;
/* nothing to return, wait */
GST_DEBUG_OBJECT (appsink, "waiting for a buffer");
- g_cond_wait (appsink->cond, appsink->mutex);
+ g_cond_wait (appsink->priv->cond, appsink->priv->mutex);
}
- buf = g_queue_pop_head (appsink->queue);
+ buf = g_queue_pop_head (appsink->priv->queue);
GST_DEBUG_OBJECT (appsink, "we have a buffer %p", buf);
- g_cond_signal (appsink->cond);
- g_mutex_unlock (appsink->mutex);
+ g_cond_signal (appsink->priv->cond);
+ g_mutex_unlock (appsink->priv->mutex);
return buf;
eos:
{
GST_DEBUG_OBJECT (appsink, "we are EOS, return NULL");
- g_mutex_unlock (appsink->mutex);
+ g_mutex_unlock (appsink->priv->mutex);
return NULL;
}
not_started:
{
GST_DEBUG_OBJECT (appsink, "we are stopped, return NULL");
- g_mutex_unlock (appsink->mutex);
+ g_mutex_unlock (appsink->priv->mutex);
return NULL;
}
}
typedef struct _GstAppSink GstAppSink;
typedef struct _GstAppSinkClass GstAppSinkClass;
+typedef struct _GstAppSinkPrivate GstAppSinkPrivate;
struct _GstAppSink
{
GstBaseSink basesink;
/*< private >*/
- GstCaps *caps;
- gboolean emit_signals;
- guint max_buffers;
- gboolean drop;
-
- GCond *cond;
- GMutex *mutex;
- GQueue *queue;
- GstBuffer *preroll;
- gboolean flushing;
- gboolean started;
- gboolean is_eos;
+ GstAppSinkPrivate *priv;
+
+ /*< private >*/
+ gpointer _gst_reserved[GST_PADDING];
};
struct _GstAppSinkClass
/* actions */
GstBuffer * (*pull_preroll) (GstAppSink *sink);
GstBuffer * (*pull_buffer) (GstAppSink *sink);
+
+ /*< private >*/
+ gpointer _gst_reserved[GST_PADDING];
};
GType gst_app_sink_get_type(void);
* <link linkend="gst-plugins-base-libs-appsrc">libgstapp</link> section in the
* GStreamer Plugins Base Libraries documentation.
*
+ * Since: 0.10.22
*/
/**
* gst_app_src_end_of_stream() or emit the end-of-stream action signal. After
* this call, no more buffers can be pushed into appsrc until a flushing seek
* happened or the state of the appsrc has gone through READY.
+ *
+ * Since: 0.10.22
*
* Last reviewed on 2008-12-17 (0.10.10)
*/
#include "gstapp-marshal.h"
#include "gstappsrc.h"
+struct _GstAppSrcPrivate
+{
+ GCond *cond;
+ GMutex *mutex;
+ GQueue *queue;
+
+ GstCaps *caps;
+ gint64 size;
+ GstAppStreamType stream_type;
+ guint64 max_bytes;
+ GstFormat format;
+ gboolean block;
+
+ gboolean flushing;
+ gboolean started;
+ gboolean is_eos;
+ guint64 queued_bytes;
+ guint64 offset;
+ GstAppStreamType current_type;
+
+ guint64 min_latency;
+ guint64 max_latency;
+};
GST_DEBUG_CATEGORY (app_src_debug);
#define GST_CAT_DEFAULT app_src_debug
klass->push_buffer = gst_app_src_push_buffer_action;
klass->end_of_stream = gst_app_src_end_of_stream;
+
+ g_type_class_add_private (klass, sizeof (GstAppSrcPrivate));
}
static void
gst_app_src_init (GstAppSrc * appsrc, GstAppSrcClass * klass)
{
- appsrc->mutex = g_mutex_new ();
- appsrc->cond = g_cond_new ();
- appsrc->queue = g_queue_new ();
-
- appsrc->size = DEFAULT_PROP_SIZE;
- appsrc->stream_type = DEFAULT_PROP_STREAM_TYPE;
- appsrc->max_bytes = DEFAULT_PROP_MAX_BYTES;
- appsrc->format = DEFAULT_PROP_FORMAT;
- appsrc->block = DEFAULT_PROP_BLOCK;
- appsrc->min_latency = DEFAULT_PROP_MIN_LATENCY;
- appsrc->max_latency = DEFAULT_PROP_MAX_LATENCY;
+ appsrc->priv = G_TYPE_INSTANCE_GET_PRIVATE (appsrc, GST_TYPE_APP_SRC,
+ GstAppSrcPrivate);
+
+ appsrc->priv->mutex = g_mutex_new ();
+ appsrc->priv->cond = g_cond_new ();
+ appsrc->priv->queue = g_queue_new ();
+
+ appsrc->priv->size = DEFAULT_PROP_SIZE;
+ appsrc->priv->stream_type = DEFAULT_PROP_STREAM_TYPE;
+ appsrc->priv->max_bytes = DEFAULT_PROP_MAX_BYTES;
+ appsrc->priv->format = DEFAULT_PROP_FORMAT;
+ appsrc->priv->block = DEFAULT_PROP_BLOCK;
+ appsrc->priv->min_latency = DEFAULT_PROP_MIN_LATENCY;
+ appsrc->priv->max_latency = DEFAULT_PROP_MAX_LATENCY;
gst_base_src_set_live (GST_BASE_SRC (appsrc), DEFAULT_PROP_IS_LIVE);
}
{
GstBuffer *buf;
- while ((buf = g_queue_pop_head (src->queue)))
+ while ((buf = g_queue_pop_head (src->priv->queue)))
gst_buffer_unref (buf);
}
{
GstAppSrc *appsrc = GST_APP_SRC (obj);
- if (appsrc->caps) {
- gst_caps_unref (appsrc->caps);
- appsrc->caps = NULL;
+ if (appsrc->priv->caps) {
+ gst_caps_unref (appsrc->priv->caps);
+ appsrc->priv->caps = NULL;
}
gst_app_src_flush_queued (appsrc);
{
GstAppSrc *appsrc = GST_APP_SRC (obj);
- g_mutex_free (appsrc->mutex);
- g_cond_free (appsrc->cond);
- g_queue_free (appsrc->queue);
+ g_mutex_free (appsrc->priv->mutex);
+ g_cond_free (appsrc->priv->cond);
+ g_queue_free (appsrc->priv->queue);
G_OBJECT_CLASS (parent_class)->finalize (obj);
}
gst_app_src_set_max_bytes (appsrc, g_value_get_uint64 (value));
break;
case PROP_FORMAT:
- appsrc->format = g_value_get_enum (value);
+ appsrc->priv->format = g_value_get_enum (value);
break;
case PROP_BLOCK:
- appsrc->block = g_value_get_boolean (value);
+ appsrc->priv->block = g_value_get_boolean (value);
break;
case PROP_IS_LIVE:
gst_base_src_set_live (GST_BASE_SRC (appsrc),
g_value_set_uint64 (value, gst_app_src_get_max_bytes (appsrc));
break;
case PROP_FORMAT:
- g_value_set_enum (value, appsrc->format);
+ g_value_set_enum (value, appsrc->priv->format);
break;
case PROP_BLOCK:
- g_value_set_boolean (value, appsrc->block);
+ g_value_set_boolean (value, appsrc->priv->block);
break;
case PROP_IS_LIVE:
g_value_set_boolean (value, gst_base_src_is_live (GST_BASE_SRC (appsrc)));
{
GstAppSrc *appsrc = GST_APP_SRC (bsrc);
- g_mutex_lock (appsrc->mutex);
+ g_mutex_lock (appsrc->priv->mutex);
GST_DEBUG_OBJECT (appsrc, "unlock start");
- appsrc->flushing = TRUE;
- g_cond_broadcast (appsrc->cond);
- g_mutex_unlock (appsrc->mutex);
+ appsrc->priv->flushing = TRUE;
+ g_cond_broadcast (appsrc->priv->cond);
+ g_mutex_unlock (appsrc->priv->mutex);
return TRUE;
}
{
GstAppSrc *appsrc = GST_APP_SRC (bsrc);
- g_mutex_lock (appsrc->mutex);
+ g_mutex_lock (appsrc->priv->mutex);
GST_DEBUG_OBJECT (appsrc, "unlock stop");
- appsrc->flushing = FALSE;
- g_cond_broadcast (appsrc->cond);
- g_mutex_unlock (appsrc->mutex);
+ appsrc->priv->flushing = FALSE;
+ g_cond_broadcast (appsrc->priv->cond);
+ g_mutex_unlock (appsrc->priv->mutex);
return TRUE;
}
{
GstAppSrc *appsrc = GST_APP_SRC (bsrc);
- g_mutex_lock (appsrc->mutex);
+ g_mutex_lock (appsrc->priv->mutex);
GST_DEBUG_OBJECT (appsrc, "starting");
- appsrc->started = TRUE;
+ appsrc->priv->started = TRUE;
/* set the offset to -1 so that we always do a first seek. This is only used
* in random-access mode. */
- appsrc->offset = -1;
- appsrc->flushing = FALSE;
- g_mutex_unlock (appsrc->mutex);
+ appsrc->priv->offset = -1;
+ appsrc->priv->flushing = FALSE;
+ g_mutex_unlock (appsrc->priv->mutex);
- gst_base_src_set_format (bsrc, appsrc->format);
+ gst_base_src_set_format (bsrc, appsrc->priv->format);
return TRUE;
}
{
GstAppSrc *appsrc = GST_APP_SRC (bsrc);
- g_mutex_lock (appsrc->mutex);
+ g_mutex_lock (appsrc->priv->mutex);
GST_DEBUG_OBJECT (appsrc, "stopping");
- appsrc->is_eos = FALSE;
- appsrc->flushing = TRUE;
- appsrc->started = FALSE;
+ appsrc->priv->is_eos = FALSE;
+ appsrc->priv->flushing = TRUE;
+ appsrc->priv->started = FALSE;
gst_app_src_flush_queued (appsrc);
- g_mutex_unlock (appsrc->mutex);
+ g_mutex_unlock (appsrc->priv->mutex);
return TRUE;
}
GstAppSrc *appsrc = GST_APP_SRC (src);
gboolean res = FALSE;
- switch (appsrc->stream_type) {
+ switch (appsrc->priv->stream_type) {
case GST_APP_STREAM_TYPE_STREAM:
break;
case GST_APP_STREAM_TYPE_SEEKABLE:
GstAppSrc *appsrc = GST_APP_SRC (src);
gboolean res = FALSE;
- switch (appsrc->stream_type) {
+ switch (appsrc->priv->stream_type) {
case GST_APP_STREAM_TYPE_STREAM:
case GST_APP_STREAM_TYPE_SEEKABLE:
break;
res = gst_base_src_query_latency (src, &live, &min, &max);
/* overwrite with our values when we need to */
- g_mutex_lock (appsrc->mutex);
- if (appsrc->min_latency != -1)
- min = appsrc->min_latency;
- if (appsrc->max_latency != -1)
- max = appsrc->max_latency;
- g_mutex_unlock (appsrc->mutex);
+ g_mutex_lock (appsrc->priv->mutex);
+ if (appsrc->priv->min_latency != -1)
+ min = appsrc->priv->min_latency;
+ if (appsrc->priv->max_latency != -1)
+ max = appsrc->priv->max_latency;
+ g_mutex_unlock (appsrc->priv->mutex);
gst_query_set_latency (query, live, min, max);
break;
desired_position, gst_format_get_name (segment->format));
/* no need to try to seek in streaming mode */
- if (appsrc->stream_type == GST_APP_STREAM_TYPE_STREAM)
+ if (appsrc->priv->stream_type == GST_APP_STREAM_TYPE_STREAM)
return TRUE;
g_signal_emit (appsrc, gst_app_src_signals[SIGNAL_SEEK_DATA], 0,
GstAppSrc *appsrc = GST_APP_SRC (bsrc);
GstFlowReturn ret;
- g_mutex_lock (appsrc->mutex);
+ g_mutex_lock (appsrc->priv->mutex);
/* check flushing first */
- if (G_UNLIKELY (appsrc->flushing))
+ if (G_UNLIKELY (appsrc->priv->flushing))
goto flushing;
- if (appsrc->stream_type == GST_APP_STREAM_TYPE_RANDOM_ACCESS) {
+ if (appsrc->priv->stream_type == GST_APP_STREAM_TYPE_RANDOM_ACCESS) {
/* if we are dealing with a random-access stream, issue a seek if the offset
* changed. */
- if (G_UNLIKELY (appsrc->offset != offset)) {
+ if (G_UNLIKELY (appsrc->priv->offset != offset)) {
gboolean res;
- g_mutex_unlock (appsrc->mutex);
+ g_mutex_unlock (appsrc->priv->mutex);
GST_DEBUG_OBJECT (appsrc,
"we are at %" G_GINT64_FORMAT ", seek to %" G_GINT64_FORMAT,
- appsrc->offset, offset);
+ appsrc->priv->offset, offset);
g_signal_emit (appsrc, gst_app_src_signals[SIGNAL_SEEK_DATA], 0,
offset, &res);
/* failing to seek is fatal */
goto seek_error;
- g_mutex_lock (appsrc->mutex);
+ g_mutex_lock (appsrc->priv->mutex);
- appsrc->offset = offset;
+ appsrc->priv->offset = offset;
}
}
while (TRUE) {
/* return data as long as we have some */
- if (!g_queue_is_empty (appsrc->queue)) {
+ if (!g_queue_is_empty (appsrc->priv->queue)) {
guint buf_size;
- *buf = g_queue_pop_head (appsrc->queue);
+ *buf = g_queue_pop_head (appsrc->priv->queue);
buf_size = GST_BUFFER_SIZE (*buf);
GST_DEBUG_OBJECT (appsrc, "we have buffer %p of size %u", *buf, buf_size);
- appsrc->queued_bytes -= buf_size;
+ appsrc->priv->queued_bytes -= buf_size;
/* only update the offset when in random_access mode */
- if (appsrc->stream_type == GST_APP_STREAM_TYPE_RANDOM_ACCESS) {
- appsrc->offset += buf_size;
+ if (appsrc->priv->stream_type == GST_APP_STREAM_TYPE_RANDOM_ACCESS) {
+ appsrc->priv->offset += buf_size;
}
- gst_buffer_set_caps (*buf, appsrc->caps);
+ gst_buffer_set_caps (*buf, appsrc->priv->caps);
/* signal that we removed an item */
- g_cond_broadcast (appsrc->cond);
+ g_cond_broadcast (appsrc->priv->cond);
ret = GST_FLOW_OK;
break;
} else {
- g_mutex_unlock (appsrc->mutex);
+ g_mutex_unlock (appsrc->priv->mutex);
/* we have no data, we need some. We fire the signal with the size hint. */
g_signal_emit (appsrc, gst_app_src_signals[SIGNAL_NEED_DATA], 0, size,
NULL);
- g_mutex_lock (appsrc->mutex);
+ g_mutex_lock (appsrc->priv->mutex);
/* we can be flushing now because we released the lock */
- if (G_UNLIKELY (appsrc->flushing))
+ if (G_UNLIKELY (appsrc->priv->flushing))
goto flushing;
/* if we have a buffer now, continue the loop and try to return it. In
* signal) we can still be empty because the pushed buffer got flushed or
* when the application pushes the requested buffer later, we support both
* possiblities. */
- if (!g_queue_is_empty (appsrc->queue))
+ if (!g_queue_is_empty (appsrc->priv->queue))
continue;
/* no buffer yet, maybe we are EOS, if not, block for more data. */
}
/* check EOS */
- if (G_UNLIKELY (appsrc->is_eos))
+ if (G_UNLIKELY (appsrc->priv->is_eos))
goto eos;
/* nothing to return, wait a while for new data or flushing. */
- g_cond_wait (appsrc->cond, appsrc->mutex);
+ g_cond_wait (appsrc->priv->cond, appsrc->priv->mutex);
}
- g_mutex_unlock (appsrc->mutex);
+ g_mutex_unlock (appsrc->priv->mutex);
return ret;
flushing:
{
GST_DEBUG_OBJECT (appsrc, "we are flushing");
- g_mutex_unlock (appsrc->mutex);
+ g_mutex_unlock (appsrc->priv->mutex);
return GST_FLOW_WRONG_STATE;
}
eos:
{
GST_DEBUG_OBJECT (appsrc, "we are EOS");
- g_mutex_unlock (appsrc->mutex);
+ g_mutex_unlock (appsrc->priv->mutex);
return GST_FLOW_UNEXPECTED;
}
seek_error:
* a copy of the caps structure. After calling this method, the source will
* only produce caps that match @caps. @caps must be fixed and the caps on the
* buffers must match the caps or left NULL.
+ *
+ * Since: 0.10.22
*/
void
gst_app_src_set_caps (GstAppSrc * appsrc, const GstCaps * caps)
GST_OBJECT_LOCK (appsrc);
GST_DEBUG_OBJECT (appsrc, "setting caps to %" GST_PTR_FORMAT, caps);
- if ((old = appsrc->caps) != caps) {
+ if ((old = appsrc->priv->caps) != caps) {
if (caps)
- appsrc->caps = gst_caps_copy (caps);
+ appsrc->priv->caps = gst_caps_copy (caps);
else
- appsrc->caps = NULL;
+ appsrc->priv->caps = NULL;
if (old)
gst_caps_unref (old);
}
* Get the configured caps on @appsrc.
*
* Returns: the #GstCaps produced by the source. gst_caps_unref() after usage.
+ *
+ * Since: 0.10.22
*/
GstCaps *
gst_app_src_get_caps (GstAppSrc * appsrc)
g_return_val_if_fail (GST_IS_APP_SRC (appsrc), NULL);
GST_OBJECT_LOCK (appsrc);
- if ((caps = appsrc->caps))
+ if ((caps = appsrc->priv->caps))
gst_caps_ref (caps);
GST_DEBUG_OBJECT (appsrc, "getting caps of %" GST_PTR_FORMAT, caps);
GST_OBJECT_UNLOCK (appsrc);
*
* Set the size of the stream in bytes. A value of -1 means that the size is
* not known.
+ *
+ * Since: 0.10.22
*/
void
gst_app_src_set_size (GstAppSrc * appsrc, gint64 size)
GST_OBJECT_LOCK (appsrc);
GST_DEBUG_OBJECT (appsrc, "setting size of %" G_GINT64_FORMAT, size);
- appsrc->size = size;
+ appsrc->priv->size = size;
GST_OBJECT_UNLOCK (appsrc);
}
* not known.
*
* Returns: the size of the stream previously set with gst_app_src_set_size();
+ *
+ * Since: 0.10.22
*/
gint64
gst_app_src_get_size (GstAppSrc * appsrc)
g_return_val_if_fail (GST_IS_APP_SRC (appsrc), -1);
GST_OBJECT_LOCK (appsrc);
- size = appsrc->size;
+ size = appsrc->priv->size;
GST_DEBUG_OBJECT (appsrc, "getting size of %" G_GINT64_FORMAT, size);
GST_OBJECT_UNLOCK (appsrc);
* be connected to.
*
* A stream_type stream
+ *
+ * Since: 0.10.22
*/
void
gst_app_src_set_stream_type (GstAppSrc * appsrc, GstAppStreamType type)
GST_OBJECT_LOCK (appsrc);
GST_DEBUG_OBJECT (appsrc, "setting stream_type of %d", type);
- appsrc->stream_type = type;
+ appsrc->priv->stream_type = type;
GST_OBJECT_UNLOCK (appsrc);
}
* with gst_app_src_set_stream_type().
*
* Returns: the stream type.
+ *
+ * Since: 0.10.22
*/
GstAppStreamType
gst_app_src_get_stream_type (GstAppSrc * appsrc)
g_return_val_if_fail (GST_IS_APP_SRC (appsrc), FALSE);
GST_OBJECT_LOCK (appsrc);
- stream_type = appsrc->stream_type;
+ stream_type = appsrc->priv->stream_type;
GST_DEBUG_OBJECT (appsrc, "getting stream_type of %d", stream_type);
GST_OBJECT_UNLOCK (appsrc);
* Set the maximum amount of bytes that can be queued in @appsrc.
* After the maximum amount of bytes are queued, @appsrc will emit the
* "enough-data" signal.
+ *
+ * Since: 0.10.22
*/
void
gst_app_src_set_max_bytes (GstAppSrc * appsrc, guint64 max)
{
g_return_if_fail (GST_IS_APP_SRC (appsrc));
- g_mutex_lock (appsrc->mutex);
- if (max != appsrc->max_bytes) {
+ g_mutex_lock (appsrc->priv->mutex);
+ if (max != appsrc->priv->max_bytes) {
GST_DEBUG_OBJECT (appsrc, "setting max-bytes to %" G_GUINT64_FORMAT, max);
- appsrc->max_bytes = max;
+ appsrc->priv->max_bytes = max;
/* signal the change */
- g_cond_broadcast (appsrc->cond);
+ g_cond_broadcast (appsrc->priv->cond);
}
- g_mutex_unlock (appsrc->mutex);
+ g_mutex_unlock (appsrc->priv->mutex);
}
/**
* Get the maximum amount of bytes that can be queued in @appsrc.
*
* Returns: The maximum amount of bytes that can be queued.
+ *
+ * Since: 0.10.22
*/
guint64
gst_app_src_get_max_bytes (GstAppSrc * appsrc)
g_return_val_if_fail (GST_IS_APP_SRC (appsrc), 0);
- g_mutex_lock (appsrc->mutex);
- result = appsrc->max_bytes;
+ g_mutex_lock (appsrc->priv->mutex);
+ result = appsrc->priv->max_bytes;
GST_DEBUG_OBJECT (appsrc, "getting max-bytes of %" G_GUINT64_FORMAT, result);
- g_mutex_unlock (appsrc->mutex);
+ g_mutex_unlock (appsrc->priv->mutex);
return result;
}
{
gboolean changed = FALSE;
- g_mutex_lock (appsrc->mutex);
- if (do_min && appsrc->min_latency != min) {
- appsrc->min_latency = min;
+ g_mutex_lock (appsrc->priv->mutex);
+ if (do_min && appsrc->priv->min_latency != min) {
+ appsrc->priv->min_latency = min;
changed = TRUE;
}
- if (do_max && appsrc->max_latency != max) {
- appsrc->max_latency = max;
+ if (do_max && appsrc->priv->max_latency != max) {
+ appsrc->priv->max_latency = max;
changed = TRUE;
}
- g_mutex_unlock (appsrc->mutex);
+ g_mutex_unlock (appsrc->priv->mutex);
if (changed) {
GST_DEBUG_OBJECT (appsrc, "posting latency changed");
*
* Configure the @min and @max latency in @src. If @min is set to -1, the
* default latency calculations for pseudo-live sources will be used.
+ *
+ * Since: 0.10.22
*/
void
gst_app_src_set_latency (GstAppSrc * appsrc, guint64 min, guint64 max)
* @max: the min latency
*
* Retrieve the min and max latencies in @min and @max respectively.
+ *
+ * Since: 0.10.22
*/
void
gst_app_src_get_latency (GstAppSrc * appsrc, guint64 * min, guint64 * max)
{
g_return_if_fail (GST_IS_APP_SRC (appsrc));
- g_mutex_lock (appsrc->mutex);
+ g_mutex_lock (appsrc->priv->mutex);
if (min)
- *min = appsrc->min_latency;
+ *min = appsrc->priv->min_latency;
if (max)
- *max = appsrc->max_latency;
- g_mutex_unlock (appsrc->mutex);
+ *max = appsrc->priv->max_latency;
+ g_mutex_unlock (appsrc->priv->mutex);
}
static GstFlowReturn
g_return_val_if_fail (GST_IS_APP_SRC (appsrc), GST_FLOW_ERROR);
g_return_val_if_fail (GST_IS_BUFFER (buffer), GST_FLOW_ERROR);
- g_mutex_lock (appsrc->mutex);
+ g_mutex_lock (appsrc->priv->mutex);
while (TRUE) {
/* can't accept buffers when we are flushing or EOS */
- if (appsrc->flushing)
+ if (appsrc->priv->flushing)
goto flushing;
- if (appsrc->is_eos)
+ if (appsrc->priv->is_eos)
goto eos;
- if (appsrc->max_bytes && appsrc->queued_bytes >= appsrc->max_bytes) {
- GST_DEBUG_OBJECT (appsrc, "queue filled (%" G_GUINT64_FORMAT " >= %"
- G_GUINT64_FORMAT ")", appsrc->queued_bytes, appsrc->max_bytes);
+ if (appsrc->priv->max_bytes
+ && appsrc->priv->queued_bytes >= appsrc->priv->max_bytes) {
+ GST_DEBUG_OBJECT (appsrc,
+ "queue filled (%" G_GUINT64_FORMAT " >= %" G_GUINT64_FORMAT ")",
+ appsrc->priv->queued_bytes, appsrc->priv->max_bytes);
if (first) {
/* only signal on the first push */
- g_mutex_unlock (appsrc->mutex);
+ g_mutex_unlock (appsrc->priv->mutex);
g_signal_emit (appsrc, gst_app_src_signals[SIGNAL_ENOUGH_DATA], 0,
NULL);
- g_mutex_lock (appsrc->mutex);
+ g_mutex_lock (appsrc->priv->mutex);
/* continue to check for flushing/eos after releasing the lock */
first = FALSE;
continue;
}
- if (appsrc->block) {
+ if (appsrc->priv->block) {
GST_DEBUG_OBJECT (appsrc, "waiting for free space");
/* we are filled, wait until a buffer gets popped or when we
* flush. */
- g_cond_wait (appsrc->cond, appsrc->mutex);
+ g_cond_wait (appsrc->priv->cond, appsrc->priv->mutex);
} else {
/* no need to wait for free space, we just pump more data into the
* queue hoping that the caller reacts to the enough-data signal and
GST_DEBUG_OBJECT (appsrc, "queueing buffer %p", buffer);
if (!steal_ref)
gst_buffer_ref (buffer);
- g_queue_push_tail (appsrc->queue, buffer);
- appsrc->queued_bytes += GST_BUFFER_SIZE (buffer);
- g_cond_broadcast (appsrc->cond);
- g_mutex_unlock (appsrc->mutex);
+ g_queue_push_tail (appsrc->priv->queue, buffer);
+ appsrc->priv->queued_bytes += GST_BUFFER_SIZE (buffer);
+ g_cond_broadcast (appsrc->priv->cond);
+ g_mutex_unlock (appsrc->priv->mutex);
return GST_FLOW_OK;
GST_DEBUG_OBJECT (appsrc, "refuse buffer %p, we are flushing", buffer);
if (steal_ref)
gst_buffer_unref (buffer);
- g_mutex_unlock (appsrc->mutex);
+ g_mutex_unlock (appsrc->priv->mutex);
return GST_FLOW_WRONG_STATE;
}
eos:
GST_DEBUG_OBJECT (appsrc, "refuse buffer %p, we are EOS", buffer);
if (steal_ref)
gst_buffer_unref (buffer);
- g_mutex_unlock (appsrc->mutex);
+ g_mutex_unlock (appsrc->priv->mutex);
return GST_FLOW_UNEXPECTED;
}
}
* Returns: #GST_FLOW_OK when the buffer was successfuly queued.
* #GST_FLOW_WRONG_STATE when @appsrc is not PAUSED or PLAYING.
* #GST_FLOW_UNEXPECTED when EOS occured.
+ *
+ * Since: 0.10.22
*/
GstFlowReturn
gst_app_src_push_buffer (GstAppSrc * appsrc, GstBuffer * buffer)
*
* Returns: #GST_FLOW_OK when the EOS was successfuly queued.
* #GST_FLOW_WRONG_STATE when @appsrc is not PAUSED or PLAYING.
+ *
+ * Since: 0.10.22
*/
GstFlowReturn
gst_app_src_end_of_stream (GstAppSrc * appsrc)
g_return_val_if_fail (appsrc, GST_FLOW_ERROR);
g_return_val_if_fail (GST_IS_APP_SRC (appsrc), GST_FLOW_ERROR);
- g_mutex_lock (appsrc->mutex);
+ g_mutex_lock (appsrc->priv->mutex);
/* can't accept buffers when we are flushing. We can accept them when we are
* EOS although it will not do anything. */
- if (appsrc->flushing)
+ if (appsrc->priv->flushing)
goto flushing;
GST_DEBUG_OBJECT (appsrc, "sending EOS");
- appsrc->is_eos = TRUE;
- g_cond_broadcast (appsrc->cond);
- g_mutex_unlock (appsrc->mutex);
+ appsrc->priv->is_eos = TRUE;
+ g_cond_broadcast (appsrc->priv->cond);
+ g_mutex_unlock (appsrc->priv->mutex);
return GST_FLOW_OK;
typedef struct _GstAppSrc GstAppSrc;
typedef struct _GstAppSrcClass GstAppSrcClass;
+typedef struct _GstAppSrcPrivate GstAppSrcPrivate;
/**
* GstAppStreamType:
GstBaseSrc basesrc;
/*< private >*/
- GCond *cond;
- GMutex *mutex;
- GQueue *queue;
-
- GstCaps *caps;
- gint64 size;
- GstAppStreamType stream_type;
- guint64 max_bytes;
- GstFormat format;
- gboolean block;
-
- gboolean flushing;
- gboolean started;
- gboolean is_eos;
- guint64 queued_bytes;
- guint64 offset;
- GstAppStreamType current_type;
-
- guint64 min_latency;
- guint64 max_latency;
+ GstAppSrcPrivate *priv;
+
+ /*< private >*/
+ gpointer _gst_reserved[GST_PADDING];
};
struct _GstAppSrcClass
/* actions */
GstFlowReturn (*push_buffer) (GstAppSrc *src, GstBuffer *buffer);
GstFlowReturn (*end_of_stream) (GstAppSrc *src);
+
+ /*< private >*/
+ gpointer _gst_reserved[GST_PADDING];
};
GType gst_app_src_get_type(void);