tpm gst-plugins-base: gst-plugins-base/ gst-plugins-base/gst-libs/gst/app/
[email protected] Tue, 6 Jan 2009 02:56:59 -0800 (PST)
| Newsgroups | gmane.comp.video.gstreamer.cvs |
|---|---|
| Message-ID | <[email protected]> |
--===============8706637566907891201==
CVS Root: /cvs/gstreamer
Module: gst-plugins-base
Changes by: tpm
Date: Tue Jan 06 2009 10:56:59 UTC
Log message:
* 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).
Modified files:
. : ChangeLog
gst-libs/gst/app: gstappsink.c gstappsink.h gstappsrc.c
gstappsrc.h
Links:
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-base/ChangeLog.diff?r1=1.4274&r2=1.4275
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-base/gst-libs/gst/app/gstappsink.c.diff?r1=1.16&r2=1.17
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-base/gst-libs/gst/app/gstappsink.h.diff?r1=1.5&r2=1.6
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-base/gst-libs/gst/app/gstappsrc.c.diff?r1=1.16&r2=1.17
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-base/gst-libs/gst/app/gstappsrc.h.diff?r1=1.8&r2=1.9
====Begin Diffs====
Index: ChangeLog
===================================================================
RCS file: /cvs/gstreamer/gst-plugins-base/ChangeLog,v
retrieving revision 1.4274
retrieving revision 1.4275
diff -u -d -r1.4274 -r1.4275
--- ChangeLog 6 Jan 2009 10:50:35 -0000 1.4274
+++ ChangeLog 6 Jan 2009 10:56:43 -0000 1.4275
@@ -1,3 +1,39 @@
+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 <[email protected]>
* tests/examples/app/appsrc_ex.c: (main):
Index: gstappsink.c
RCS file: /cvs/gstreamer/gst-plugins-base/gst-libs/gst/app/gstappsink.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- gstappsink.c 5 Jan 2009 23:04:57 -0000 1.16
+++ gstappsink.c 6 Jan 2009 10:56:44 -0000 1.17
@@ -29,6 +29,7 @@
* <link linkend="gst-plugins-base-libs-appsink">libgstapp</link> section in
* the GStreamer Plugins Base Libraries documentation.
*
+ * Since: 0.10.22
*/
@@ -71,7 +72,9 @@
* 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)
+ *
+ * Last reviewed on 2008-12-17 (0.10.22)
#ifdef HAVE_CONFIG_H
@@ -86,6 +89,21 @@
#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
@@ -356,18 +374,23 @@
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;
@@ -377,20 +400,20 @@
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);
@@ -400,9 +423,9 @@
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);
@@ -472,11 +495,11 @@
GstAppSink *appsink = GST_APP_SINK (bsink);
GST_DEBUG_OBJECT (appsink, "unlock start");
- appsink->flushing = TRUE;
- g_cond_signal (appsink->cond);
+ appsink->priv->flushing = TRUE;
+ g_cond_signal (appsink->priv->cond);
return TRUE;
@@ -486,11 +509,11 @@
GST_DEBUG_OBJECT (appsink, "unlock stop");
- appsink->flushing = FALSE;
+ appsink->priv->flushing = FALSE;
@@ -501,11 +524,11 @@
GST_DEBUG_OBJECT (appsink, "flush stop appsink");
- appsink->is_eos = FALSE;
- gst_buffer_replace (&appsink->preroll, NULL);
+ appsink->priv->is_eos = FALSE;
+ gst_buffer_replace (&appsink->priv->preroll, NULL);
static gboolean
@@ -513,10 +536,10 @@
GstAppSink *appsink = GST_APP_SINK (psink);
GST_DEBUG_OBJECT (appsink, "starting");
- appsink->started = TRUE;
+ appsink->priv->started = TRUE;
@@ -526,12 +549,12 @@
GST_DEBUG_OBJECT (appsink, "stopping");
- appsink->started = FALSE;
+ appsink->priv->started = FALSE;
gst_app_sink_flush_unlocked (appsink);
@@ -544,11 +567,11 @@
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);
@@ -559,10 +582,10 @@
GST_DEBUG_OBJECT (appsink, "received FLUSH_START");
break;
case GST_EVENT_FLUSH_STOP:
GST_DEBUG_OBJECT (appsink, "received FLUSH_STOP");
gst_app_sink_flush_unlocked (appsink);
default:
@@ -576,15 +599,15 @@
gboolean emit;
- if (appsink->flushing)
+ if (appsink->priv->flushing)
goto flushing;
GST_DEBUG_OBJECT (appsink, "setting preroll buffer %p", buffer);
- gst_buffer_replace (&appsink->preroll, buffer);
- emit = appsink->emit_signals;
+ gst_buffer_replace (&appsink->priv->preroll, buffer);
+ emit = appsink->priv->emit_signals;
if (emit)
g_signal_emit (appsink, gst_app_sink_signals[SIGNAL_NEW_PREROLL], 0);
@@ -594,7 +617,7 @@
flushing:
{
GST_DEBUG_OBJECT (appsink, "we are flushing");
- g_mutex_unlock (appsink->mutex);
+ g_mutex_unlock (appsink->priv->mutex);
return GST_FLOW_WRONG_STATE;
@@ -605,36 +628,36 @@
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_queue_push_tail (appsink->priv->queue, gst_buffer_ref (buffer));
g_signal_emit (appsink, gst_app_sink_signals[SIGNAL_NEW_BUFFER], 0);
@@ -644,7 +667,7 @@
@@ -657,7 +680,7 @@
- if ((caps = appsink->caps))
+ if ((caps = appsink->priv->caps))
gst_caps_ref (caps);
GST_DEBUG_OBJECT (appsink, "got caps %" GST_PTR_FORMAT, caps);
@@ -676,6 +699,8 @@
* 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.
void
gst_app_sink_set_caps (GstAppSink * appsink, const GstCaps * caps)
@@ -687,11 +712,11 @@
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);
@@ -705,6 +730,8 @@
* Get the configured caps on @appsink.
* Returns: the #GstCaps accepted by the sink. gst_caps_unref() after usage.
GstCaps *
gst_app_sink_get_caps (GstAppSink * appsink)
@@ -715,7 +742,7 @@
g_return_val_if_fail (GST_IS_APP_SINK (appsink), NULL);
GST_DEBUG_OBJECT (appsink, "getting caps of %" GST_PTR_FORMAT, caps);
@@ -734,6 +761,8 @@
* PLAYING state.
* Returns: %TRUE if no more buffers can be pulled and the appsink is EOS.
gboolean
gst_app_sink_is_eos (GstAppSink * appsink)
@@ -743,25 +772,25 @@
g_return_val_if_fail (appsink != NULL, FALSE);
g_return_val_if_fail (GST_IS_APP_SINK (appsink), FALSE);
- if (!appsink->started)
+ 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;
return ret;
not_started:
GST_DEBUG_OBJECT (appsink, "we are stopped, return TRUE");
return TRUE;
@@ -774,15 +803,17 @@
* 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.
gst_app_sink_set_emit_signals (GstAppSink * appsink, gboolean emit)
g_return_if_fail (GST_IS_APP_SINK (appsink));
- appsink->emit_signals = emit;
+ appsink->priv->emit_signals = emit;
/**
@@ -793,6 +824,8 @@
* Returns: %TRUE if @appsink is emiting the "new-preroll" and "new-buffer"
* signals.
gst_app_sink_get_emit_signals (GstAppSink * appsink)
@@ -801,9 +834,9 @@
- result = appsink->emit_signals;
+ result = appsink->priv->emit_signals;
return result;
@@ -816,19 +849,21 @@
* 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.
gst_app_sink_set_max_buffers (GstAppSink * appsink, guint max)
- if (max != appsink->max_buffers) {
- appsink->max_buffers = max;
+ 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);
@@ -838,6 +873,8 @@
* Get the maximum amount of buffers that can be queued in @appsink.
* Returns: The maximum amount of buffers that can be queued.
guint
gst_app_sink_get_max_buffers (GstAppSink * appsink)
@@ -846,9 +883,9 @@
g_return_val_if_fail (GST_IS_APP_SINK (appsink), 0);
- result = appsink->max_buffers;
+ result = appsink->priv->max_buffers;
@@ -860,19 +897,21 @@
* Instruct @appsink to drop old buffers when the maximum amount of queued
* buffers is reached.
gst_app_sink_set_drop (GstAppSink * appsink, gboolean drop)
- if (appsink->drop != drop) {
- appsink->drop = drop;
+ if (appsink->priv->drop != drop) {
+ appsink->priv->drop = drop;
@@ -884,6 +923,8 @@
* Returns: %TRUE if @appsink is dropping old buffers when the queue is
* filled.
gst_app_sink_get_drop (GstAppSink * appsink)
@@ -892,9 +933,9 @@
- result = appsink->drop;
+ result = appsink->priv->drop;
@@ -921,6 +962,8 @@
* element is set to the READY/NULL state.
* Returns: a #GstBuffer or NULL when the appsink is stopped or EOS.
GstBuffer *
gst_app_sink_pull_preroll (GstAppSink * appsink)
@@ -930,26 +973,26 @@
g_return_val_if_fail (appsink != NULL, NULL);
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)
- 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);
return buf;
@@ -957,13 +1000,13 @@
eos:
GST_DEBUG_OBJECT (appsink, "we are EOS, return NULL");
return NULL;
GST_DEBUG_OBJECT (appsink, "we are stopped, return NULL");
@@ -985,6 +1028,8 @@
* %NULL. Use gst_app_sink_is_eos () to check for the EOS condition.
gst_app_sink_pull_buffer (GstAppSink * appsink)
@@ -994,27 +1039,27 @@
- if (!g_queue_is_empty (appsink->queue))
+ if (!g_queue_is_empty (appsink->priv->queue))
GST_DEBUG_OBJECT (appsink, "waiting for a buffer");
- 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);
@@ -1022,13 +1067,13 @@
Index: gstappsink.h
RCS file: /cvs/gstreamer/gst-plugins-base/gst-libs/gst/app/gstappsink.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- gstappsink.h 5 May 2008 10:27:45 -0000 1.5
+++ gstappsink.h 6 Jan 2009 10:56:45 -0000 1.6
@@ -38,24 +38,17 @@
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;
+ GstAppSinkPrivate *priv;
- GCond *cond;
- GMutex *mutex;
- GQueue *queue;
- GstBuffer *preroll;
- gboolean flushing;
- gboolean started;
- gboolean is_eos;
+ /*< private >*/
+ gpointer _gst_reserved[GST_PADDING];
};
struct _GstAppSinkClass
@@ -70,6 +63,9 @@
/* actions */
GstBuffer * (*pull_preroll) (GstAppSink *sink);
GstBuffer * (*pull_buffer) (GstAppSink *sink);
GType gst_app_sink_get_type(void);
Index: gstappsrc.c
RCS file: /cvs/gstreamer/gst-plugins-base/gst-libs/gst/app/gstappsrc.c,v
--- gstappsrc.c 5 Jan 2009 23:04:57 -0000 1.16
+++ gstappsrc.c 6 Jan 2009 10:56:45 -0000 1.17
* <link linkend="gst-plugins-base-libs-appsrc">libgstapp</link> section in the
* GStreamer Plugins Base Libraries documentation.
*
@@ -95,6 +96,8 @@
* 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.
+ *
* Last reviewed on 2008-12-17 (0.10.10)
@@ -111,6 +114,29 @@
#include "gstapp-marshal.h"
#include "gstappsrc.h"
+struct _GstAppSrcPrivate
+ gint64 size;
+ GstAppStreamType stream_type;
+ guint64 max_bytes;
+ GstFormat format;
+ gboolean block;
+ 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
@@ -446,22 +472,27 @@
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));
gst_app_src_init (GstAppSrc * appsrc, GstAppSrcClass * klass)
- appsrc->mutex = g_mutex_new ();
- appsrc->cond = g_cond_new ();
- appsrc->queue = g_queue_new ();
+ appsrc->priv = G_TYPE_INSTANCE_GET_PRIVATE (appsrc, GST_TYPE_APP_SRC,
+ GstAppSrcPrivate);
- 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->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);
@@ -471,7 +502,7 @@
GstBuffer *buf;
- while ((buf = g_queue_pop_head (src->queue)))
+ while ((buf = g_queue_pop_head (src->priv->queue)))
gst_buffer_unref (buf);
@@ -480,9 +511,9 @@
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);
@@ -494,9 +525,9 @@
- 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);
@@ -521,10 +552,10 @@
gst_app_src_set_max_bytes (appsrc, g_value_get_uint64 (value));
case PROP_FORMAT:
- appsrc->format = g_value_get_enum (value);
+ appsrc->priv->format = g_value_get_enum (value);
case PROP_BLOCK:
- appsrc->block = g_value_get_boolean (value);
+ appsrc->priv->block = g_value_get_boolean (value);
case PROP_IS_LIVE:
gst_base_src_set_live (GST_BASE_SRC (appsrc),
@@ -572,10 +603,10 @@
g_value_set_uint64 (value, gst_app_src_get_max_bytes (appsrc));
- g_value_set_enum (value, appsrc->format);
+ g_value_set_enum (value, appsrc->priv->format);
- g_value_set_boolean (value, appsrc->block);
+ g_value_set_boolean (value, appsrc->priv->block);
g_value_set_boolean (value, gst_base_src_is_live (GST_BASE_SRC (appsrc)));
@@ -607,11 +638,11 @@
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);
@@ -621,11 +652,11 @@
GST_DEBUG_OBJECT (appsrc, "unlock stop");
- appsrc->flushing = FALSE;
+ appsrc->priv->flushing = FALSE;
@@ -635,16 +666,16 @@
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->priv->offset = -1;
- gst_base_src_set_format (bsrc, appsrc->format);
+ gst_base_src_set_format (bsrc, appsrc->priv->format);
@@ -654,13 +685,13 @@
GST_DEBUG_OBJECT (appsrc, "stopping");
- appsrc->is_eos = FALSE;
- appsrc->started = FALSE;
+ appsrc->priv->is_eos = FALSE;
+ appsrc->priv->started = FALSE;
@@ -671,7 +702,7 @@
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:
@@ -688,7 +719,7 @@
@@ -725,12 +756,12 @@
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);
@@ -757,7 +788,7 @@
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)
g_signal_emit (appsrc, gst_app_src_signals[SIGNAL_SEEK_DATA], 0,
@@ -780,22 +811,22 @@
GstFlowReturn ret;
/* check flushing first */
- if (G_UNLIKELY (appsrc->flushing))
+ if (G_UNLIKELY (appsrc->priv->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;
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);
@@ -804,46 +835,46 @@
/* failing to seek is fatal */
goto seek_error;
- appsrc->offset = offset;
+ appsrc->priv->offset = offset;
/* 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;
/* 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);
/* we can be flushing now because we released the lock */
- if (G_UNLIKELY (appsrc->flushing))
+ if (G_UNLIKELY (appsrc->priv->flushing))
/* if we have a buffer now, continue the loop and try to return it. In
@@ -851,20 +882,20 @@
* 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))
/* 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);
@@ -872,13 +903,13 @@
GST_DEBUG_OBJECT (appsrc, "we are flushing");
- g_mutex_unlock (appsrc->mutex);
+ g_mutex_unlock (appsrc->priv->mutex);
GST_DEBUG_OBJECT (appsrc, "we are EOS");
return GST_FLOW_UNEXPECTED;
seek_error:
@@ -900,6 +931,8 @@
* 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.
gst_app_src_set_caps (GstAppSrc * appsrc, const GstCaps * caps)
@@ -910,11 +943,11 @@
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) {
- appsrc->caps = gst_caps_copy (caps);
+ appsrc->priv->caps = gst_caps_copy (caps);
- appsrc->caps = NULL;
+ appsrc->priv->caps = NULL;
@@ -928,6 +961,8 @@
* Get the configured caps on @appsrc.
* Returns: the #GstCaps produced by the source. gst_caps_unref() after usage.
gst_app_src_get_caps (GstAppSrc * appsrc)
@@ -938,7 +973,7 @@
g_return_val_if_fail (GST_IS_APP_SRC (appsrc), NULL);
- if ((caps = appsrc->caps))
+ if ((caps = appsrc->priv->caps))
GST_DEBUG_OBJECT (appsrc, "getting caps of %" GST_PTR_FORMAT, caps);
GST_OBJECT_UNLOCK (appsrc);
@@ -953,6 +988,8 @@
* Set the size of the stream in bytes. A value of -1 means that the size is
* not known.
gst_app_src_set_size (GstAppSrc * appsrc, gint64 size)
@@ -962,7 +999,7 @@
GST_DEBUG_OBJECT (appsrc, "setting size of %" G_GINT64_FORMAT, size);
- appsrc->size = size;
+ appsrc->priv->size = size;
@@ -974,6 +1011,8 @@
* Returns: the size of the stream previously set with gst_app_src_set_size();
gint64
gst_app_src_get_size (GstAppSrc * appsrc)
@@ -984,7 +1023,7 @@
g_return_val_if_fail (GST_IS_APP_SRC (appsrc), -1);
- size = appsrc->size;
+ size = appsrc->priv->size;
GST_DEBUG_OBJECT (appsrc, "getting size of %" G_GINT64_FORMAT, size);
@@ -1000,6 +1039,8 @@
* be connected to.
* A stream_type stream
gst_app_src_set_stream_type (GstAppSrc * appsrc, GstAppStreamType type)
@@ -1009,7 +1050,7 @@
GST_DEBUG_OBJECT (appsrc, "setting stream_type of %d", type);
- appsrc->stream_type = type;
+ appsrc->priv->stream_type = type;
@@ -1021,6 +1062,8 @@
* with gst_app_src_set_stream_type().
* Returns: the stream type.
GstAppStreamType
gst_app_src_get_stream_type (GstAppSrc * appsrc)
@@ -1031,7 +1074,7 @@
g_return_val_if_fail (GST_IS_APP_SRC (appsrc), FALSE);
- stream_type = appsrc->stream_type;
+ stream_type = appsrc->priv->stream_type;
GST_DEBUG_OBJECT (appsrc, "getting stream_type of %d", stream_type);
@@ -1046,20 +1089,22 @@
* 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.
gst_app_src_set_max_bytes (GstAppSrc * appsrc, guint64 max)
g_return_if_fail (GST_IS_APP_SRC (appsrc));
- if (max != appsrc->max_bytes) {
+ 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;
- g_cond_broadcast (appsrc->cond);
+ g_cond_broadcast (appsrc->priv->cond);
@@ -1069,6 +1114,8 @@
* Get the maximum amount of bytes that can be queued in @appsrc.
* Returns: The maximum amount of bytes that can be queued.
guint64
gst_app_src_get_max_bytes (GstAppSrc * appsrc)
@@ -1077,10 +1124,10 @@
g_return_val_if_fail (GST_IS_APP_SRC (appsrc), 0);
- result = appsrc->max_bytes;
+ result = appsrc->priv->max_bytes;
GST_DEBUG_OBJECT (appsrc, "getting max-bytes of %" G_GUINT64_FORMAT, result);
@@ -1091,16 +1138,16 @@
gboolean changed = FALSE;
- if (do_min && appsrc->min_latency != min) {
- appsrc->min_latency = min;
+ 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;
if (changed) {
GST_DEBUG_OBJECT (appsrc, "posting latency changed");
@@ -1117,6 +1164,8 @@
* 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.
gst_app_src_set_latency (GstAppSrc * appsrc, guint64 min, guint64 max)
@@ -1131,18 +1180,20 @@
* @max: the min latency
* Retrieve the min and max latencies in @min and @max respectively.
gst_app_src_get_latency (GstAppSrc * appsrc, guint64 * min, guint64 * max)
if (min)
- *min = appsrc->min_latency;
+ *min = appsrc->priv->min_latency;
if (max)
- *max = appsrc->max_latency;
+ *max = appsrc->priv->max_latency;
static GstFlowReturn
@@ -1155,37 +1206,39 @@
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);
/* 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)
- 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;
- 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
@@ -1199,10 +1252,10 @@
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_queue_push_tail (appsrc->priv->queue, buffer);
+ appsrc->priv->queued_bytes += GST_BUFFER_SIZE (buffer);
return GST_FLOW_OK;
@@ -1212,7 +1265,7 @@
GST_DEBUG_OBJECT (appsrc, "refuse buffer %p, we are flushing", buffer);
if (steal_ref)
gst_buffer_unref (buffer);
@@ -1220,7 +1273,7 @@
GST_DEBUG_OBJECT (appsrc, "refuse buffer %p, we are EOS", buffer);
@@ -1236,6 +1289,8 @@
* 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.
GstFlowReturn
gst_app_src_push_buffer (GstAppSrc * appsrc, GstBuffer * buffer)
@@ -1260,6 +1315,8 @@
* Returns: #GST_FLOW_OK when the EOS was successfuly queued.
gst_app_src_end_of_stream (GstAppSrc * appsrc)
@@ -1267,16 +1324,16 @@
g_return_val_if_fail (appsrc, GST_FLOW_ERROR);
/* 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)
GST_DEBUG_OBJECT (appsrc, "sending EOS");
- appsrc->is_eos = TRUE;
+ appsrc->priv->is_eos = TRUE;
Index: gstappsrc.h
RCS file: /cvs/gstreamer/gst-plugins-base/gst-libs/gst/app/gstappsrc.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- gstappsrc.h 29 Dec 2008 16:45:20 -0000 1.8
+++ gstappsrc.h 6 Jan 2009 10:56:45 -0000 1.9
@@ -38,6 +38,7 @@
typedef struct _GstAppSrc GstAppSrc;
typedef struct _GstAppSrcClass GstAppSrcClass;
+typedef struct _GstAppSrcPrivate GstAppSrcPrivate;
* GstAppStreamType:
@@ -62,26 +63,10 @@
GstBaseSrc basesrc;
-
- gint64 size;
- GstAppStreamType stream_type;
- guint64 max_bytes;
- GstFormat format;
- gboolean block;
- guint64 queued_bytes;
- guint64 offset;
- GstAppStreamType current_type;
+ GstAppSrcPrivate *priv;
- guint64 min_latency;
- guint64 max_latency;
struct _GstAppSrcClass
@@ -96,6 +81,9 @@
GstFlowReturn (*push_buffer) (GstAppSrc *src, GstBuffer *buffer);
GstFlowReturn (*end_of_stream) (GstAppSrc *src);
GType gst_app_src_get_type(void);
--===============8706637566907891201==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
------------------------------------------------------------------------------
--===============8706637566907891201==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
gstreamer-cvs-verbose mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gstreamer-cvs-verbose
--===============8706637566907891201==--