mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-11 09:55:36 +00:00
gst-libs/gst/app/: Move private data into a private instance struct. Add padding to instance and class structures exp...
Original commit message from CVS: * 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).
This commit is contained in:
parent
15583abf25
commit
d2b82026c8
5 changed files with 389 additions and 267 deletions
36
ChangeLog
36
ChangeLog
|
@ -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 <wim.taymans@collabora.co.uk>
|
2009-01-06 Wim Taymans <wim.taymans@collabora.co.uk>
|
||||||
|
|
||||||
* tests/examples/app/appsrc_ex.c: (main):
|
* tests/examples/app/appsrc_ex.c: (main):
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
* <link linkend="gst-plugins-base-libs-appsink">libgstapp</link> section in
|
* <link linkend="gst-plugins-base-libs-appsink">libgstapp</link> section in
|
||||||
* the GStreamer Plugins Base Libraries documentation.
|
* 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
|
* The eos signal can also be used to be informed when the EOS state is reached
|
||||||
* to avoid polling.
|
* 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
|
#ifdef HAVE_CONFIG_H
|
||||||
|
@ -86,6 +89,21 @@
|
||||||
|
|
||||||
#include "gstappsink.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);
|
GST_DEBUG_CATEGORY (app_sink_debug);
|
||||||
#define GST_CAT_DEFAULT app_sink_debug
|
#define GST_CAT_DEFAULT app_sink_debug
|
||||||
|
@ -356,18 +374,23 @@ gst_app_sink_class_init (GstAppSinkClass * klass)
|
||||||
|
|
||||||
klass->pull_preroll = gst_app_sink_pull_preroll;
|
klass->pull_preroll = gst_app_sink_pull_preroll;
|
||||||
klass->pull_buffer = gst_app_sink_pull_buffer;
|
klass->pull_buffer = gst_app_sink_pull_buffer;
|
||||||
|
|
||||||
|
g_type_class_add_private (klass, sizeof (GstAppSinkPrivate));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_app_sink_init (GstAppSink * appsink, GstAppSinkClass * klass)
|
gst_app_sink_init (GstAppSink * appsink, GstAppSinkClass * klass)
|
||||||
{
|
{
|
||||||
appsink->mutex = g_mutex_new ();
|
appsink->priv = G_TYPE_INSTANCE_GET_PRIVATE (appsink, GST_TYPE_APP_SINK,
|
||||||
appsink->cond = g_cond_new ();
|
GstAppSinkPrivate);
|
||||||
appsink->queue = g_queue_new ();
|
|
||||||
|
|
||||||
appsink->emit_signals = DEFAULT_PROP_EMIT_SIGNALS;
|
appsink->priv->mutex = g_mutex_new ();
|
||||||
appsink->max_buffers = DEFAULT_PROP_MAX_BUFFERS;
|
appsink->priv->cond = g_cond_new ();
|
||||||
appsink->drop = DEFAULT_PROP_DROP;
|
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
|
static void
|
||||||
|
@ -377,20 +400,20 @@ gst_app_sink_dispose (GObject * obj)
|
||||||
GstBuffer *buffer;
|
GstBuffer *buffer;
|
||||||
|
|
||||||
GST_OBJECT_LOCK (appsink);
|
GST_OBJECT_LOCK (appsink);
|
||||||
if (appsink->caps) {
|
if (appsink->priv->caps) {
|
||||||
gst_caps_unref (appsink->caps);
|
gst_caps_unref (appsink->priv->caps);
|
||||||
appsink->caps = NULL;
|
appsink->priv->caps = NULL;
|
||||||
}
|
}
|
||||||
GST_OBJECT_UNLOCK (appsink);
|
GST_OBJECT_UNLOCK (appsink);
|
||||||
|
|
||||||
g_mutex_lock (appsink->mutex);
|
g_mutex_lock (appsink->priv->mutex);
|
||||||
if (appsink->preroll) {
|
if (appsink->priv->preroll) {
|
||||||
gst_buffer_unref (appsink->preroll);
|
gst_buffer_unref (appsink->priv->preroll);
|
||||||
appsink->preroll = NULL;
|
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);
|
gst_buffer_unref (buffer);
|
||||||
g_mutex_unlock (appsink->mutex);
|
g_mutex_unlock (appsink->priv->mutex);
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->dispose (obj);
|
G_OBJECT_CLASS (parent_class)->dispose (obj);
|
||||||
}
|
}
|
||||||
|
@ -400,9 +423,9 @@ gst_app_sink_finalize (GObject * obj)
|
||||||
{
|
{
|
||||||
GstAppSink *appsink = GST_APP_SINK (obj);
|
GstAppSink *appsink = GST_APP_SINK (obj);
|
||||||
|
|
||||||
g_mutex_free (appsink->mutex);
|
g_mutex_free (appsink->priv->mutex);
|
||||||
g_cond_free (appsink->cond);
|
g_cond_free (appsink->priv->cond);
|
||||||
g_queue_free (appsink->queue);
|
g_queue_free (appsink->priv->queue);
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->finalize (obj);
|
G_OBJECT_CLASS (parent_class)->finalize (obj);
|
||||||
}
|
}
|
||||||
|
@ -472,11 +495,11 @@ gst_app_sink_unlock_start (GstBaseSink * bsink)
|
||||||
{
|
{
|
||||||
GstAppSink *appsink = GST_APP_SINK (bsink);
|
GstAppSink *appsink = GST_APP_SINK (bsink);
|
||||||
|
|
||||||
g_mutex_lock (appsink->mutex);
|
g_mutex_lock (appsink->priv->mutex);
|
||||||
GST_DEBUG_OBJECT (appsink, "unlock start");
|
GST_DEBUG_OBJECT (appsink, "unlock start");
|
||||||
appsink->flushing = TRUE;
|
appsink->priv->flushing = TRUE;
|
||||||
g_cond_signal (appsink->cond);
|
g_cond_signal (appsink->priv->cond);
|
||||||
g_mutex_unlock (appsink->mutex);
|
g_mutex_unlock (appsink->priv->mutex);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -486,11 +509,11 @@ gst_app_sink_unlock_stop (GstBaseSink * bsink)
|
||||||
{
|
{
|
||||||
GstAppSink *appsink = GST_APP_SINK (bsink);
|
GstAppSink *appsink = GST_APP_SINK (bsink);
|
||||||
|
|
||||||
g_mutex_lock (appsink->mutex);
|
g_mutex_lock (appsink->priv->mutex);
|
||||||
GST_DEBUG_OBJECT (appsink, "unlock stop");
|
GST_DEBUG_OBJECT (appsink, "unlock stop");
|
||||||
appsink->flushing = FALSE;
|
appsink->priv->flushing = FALSE;
|
||||||
g_cond_signal (appsink->cond);
|
g_cond_signal (appsink->priv->cond);
|
||||||
g_mutex_unlock (appsink->mutex);
|
g_mutex_unlock (appsink->priv->mutex);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -501,11 +524,11 @@ gst_app_sink_flush_unlocked (GstAppSink * appsink)
|
||||||
GstBuffer *buffer;
|
GstBuffer *buffer;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (appsink, "flush stop appsink");
|
GST_DEBUG_OBJECT (appsink, "flush stop appsink");
|
||||||
appsink->is_eos = FALSE;
|
appsink->priv->is_eos = FALSE;
|
||||||
gst_buffer_replace (&appsink->preroll, NULL);
|
gst_buffer_replace (&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);
|
gst_buffer_unref (buffer);
|
||||||
g_cond_signal (appsink->cond);
|
g_cond_signal (appsink->priv->cond);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -513,10 +536,10 @@ gst_app_sink_start (GstBaseSink * psink)
|
||||||
{
|
{
|
||||||
GstAppSink *appsink = GST_APP_SINK (psink);
|
GstAppSink *appsink = GST_APP_SINK (psink);
|
||||||
|
|
||||||
g_mutex_lock (appsink->mutex);
|
g_mutex_lock (appsink->priv->mutex);
|
||||||
GST_DEBUG_OBJECT (appsink, "starting");
|
GST_DEBUG_OBJECT (appsink, "starting");
|
||||||
appsink->started = TRUE;
|
appsink->priv->started = TRUE;
|
||||||
g_mutex_unlock (appsink->mutex);
|
g_mutex_unlock (appsink->priv->mutex);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -526,12 +549,12 @@ gst_app_sink_stop (GstBaseSink * psink)
|
||||||
{
|
{
|
||||||
GstAppSink *appsink = GST_APP_SINK (psink);
|
GstAppSink *appsink = GST_APP_SINK (psink);
|
||||||
|
|
||||||
g_mutex_lock (appsink->mutex);
|
g_mutex_lock (appsink->priv->mutex);
|
||||||
GST_DEBUG_OBJECT (appsink, "stopping");
|
GST_DEBUG_OBJECT (appsink, "stopping");
|
||||||
appsink->flushing = TRUE;
|
appsink->priv->flushing = TRUE;
|
||||||
appsink->started = FALSE;
|
appsink->priv->started = FALSE;
|
||||||
gst_app_sink_flush_unlocked (appsink);
|
gst_app_sink_flush_unlocked (appsink);
|
||||||
g_mutex_unlock (appsink->mutex);
|
g_mutex_unlock (appsink->priv->mutex);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -544,11 +567,11 @@ gst_app_sink_event (GstBaseSink * sink, GstEvent * event)
|
||||||
switch (event->type) {
|
switch (event->type) {
|
||||||
case GST_EVENT_EOS:
|
case GST_EVENT_EOS:
|
||||||
|
|
||||||
g_mutex_lock (appsink->mutex);
|
g_mutex_lock (appsink->priv->mutex);
|
||||||
GST_DEBUG_OBJECT (appsink, "receiving EOS");
|
GST_DEBUG_OBJECT (appsink, "receiving EOS");
|
||||||
appsink->is_eos = TRUE;
|
appsink->priv->is_eos = TRUE;
|
||||||
g_cond_signal (appsink->cond);
|
g_cond_signal (appsink->priv->cond);
|
||||||
g_mutex_unlock (appsink->mutex);
|
g_mutex_unlock (appsink->priv->mutex);
|
||||||
|
|
||||||
/* emit EOS now */
|
/* emit EOS now */
|
||||||
g_signal_emit (appsink, gst_app_sink_signals[SIGNAL_EOS], 0);
|
g_signal_emit (appsink, gst_app_sink_signals[SIGNAL_EOS], 0);
|
||||||
|
@ -559,10 +582,10 @@ gst_app_sink_event (GstBaseSink * sink, GstEvent * event)
|
||||||
GST_DEBUG_OBJECT (appsink, "received FLUSH_START");
|
GST_DEBUG_OBJECT (appsink, "received FLUSH_START");
|
||||||
break;
|
break;
|
||||||
case GST_EVENT_FLUSH_STOP:
|
case GST_EVENT_FLUSH_STOP:
|
||||||
g_mutex_lock (appsink->mutex);
|
g_mutex_lock (appsink->priv->mutex);
|
||||||
GST_DEBUG_OBJECT (appsink, "received FLUSH_STOP");
|
GST_DEBUG_OBJECT (appsink, "received FLUSH_STOP");
|
||||||
gst_app_sink_flush_unlocked (appsink);
|
gst_app_sink_flush_unlocked (appsink);
|
||||||
g_mutex_unlock (appsink->mutex);
|
g_mutex_unlock (appsink->priv->mutex);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -576,15 +599,15 @@ gst_app_sink_preroll (GstBaseSink * psink, GstBuffer * buffer)
|
||||||
GstAppSink *appsink = GST_APP_SINK (psink);
|
GstAppSink *appsink = GST_APP_SINK (psink);
|
||||||
gboolean emit;
|
gboolean emit;
|
||||||
|
|
||||||
g_mutex_lock (appsink->mutex);
|
g_mutex_lock (appsink->priv->mutex);
|
||||||
if (appsink->flushing)
|
if (appsink->priv->flushing)
|
||||||
goto flushing;
|
goto flushing;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (appsink, "setting preroll buffer %p", buffer);
|
GST_DEBUG_OBJECT (appsink, "setting preroll buffer %p", buffer);
|
||||||
gst_buffer_replace (&appsink->preroll, buffer);
|
gst_buffer_replace (&appsink->priv->preroll, buffer);
|
||||||
g_cond_signal (appsink->cond);
|
g_cond_signal (appsink->priv->cond);
|
||||||
emit = appsink->emit_signals;
|
emit = appsink->priv->emit_signals;
|
||||||
g_mutex_unlock (appsink->mutex);
|
g_mutex_unlock (appsink->priv->mutex);
|
||||||
|
|
||||||
if (emit)
|
if (emit)
|
||||||
g_signal_emit (appsink, gst_app_sink_signals[SIGNAL_NEW_PREROLL], 0);
|
g_signal_emit (appsink, gst_app_sink_signals[SIGNAL_NEW_PREROLL], 0);
|
||||||
|
@ -594,7 +617,7 @@ gst_app_sink_preroll (GstBaseSink * psink, GstBuffer * buffer)
|
||||||
flushing:
|
flushing:
|
||||||
{
|
{
|
||||||
GST_DEBUG_OBJECT (appsink, "we are flushing");
|
GST_DEBUG_OBJECT (appsink, "we are flushing");
|
||||||
g_mutex_unlock (appsink->mutex);
|
g_mutex_unlock (appsink->priv->mutex);
|
||||||
return GST_FLOW_WRONG_STATE;
|
return GST_FLOW_WRONG_STATE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -605,36 +628,36 @@ gst_app_sink_render (GstBaseSink * psink, GstBuffer * buffer)
|
||||||
GstAppSink *appsink = GST_APP_SINK (psink);
|
GstAppSink *appsink = GST_APP_SINK (psink);
|
||||||
gboolean emit;
|
gboolean emit;
|
||||||
|
|
||||||
g_mutex_lock (appsink->mutex);
|
g_mutex_lock (appsink->priv->mutex);
|
||||||
if (appsink->flushing)
|
if (appsink->priv->flushing)
|
||||||
goto flushing;
|
goto flushing;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (appsink, "pushing render buffer %p on queue (%d)",
|
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 &&
|
while (appsink->priv->max_buffers > 0 &&
|
||||||
appsink->queue->length >= appsink->max_buffers) {
|
appsink->priv->queue->length >= appsink->priv->max_buffers) {
|
||||||
if (appsink->drop) {
|
if (appsink->priv->drop) {
|
||||||
GstBuffer *buf;
|
GstBuffer *buf;
|
||||||
|
|
||||||
/* we need to drop the oldest buffer and try again */
|
/* 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_DEBUG_OBJECT (appsink, "dropping old buffer %p", buf);
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
} else {
|
} else {
|
||||||
GST_DEBUG_OBJECT (appsink, "waiting for free space, length %d >= %d",
|
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 */
|
/* wait for a buffer to be removed or flush */
|
||||||
g_cond_wait (appsink->cond, appsink->mutex);
|
g_cond_wait (appsink->priv->cond, appsink->priv->mutex);
|
||||||
if (appsink->flushing)
|
if (appsink->priv->flushing)
|
||||||
goto flushing;
|
goto flushing;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* we need to ref the buffer when pushing it in the queue */
|
/* 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_cond_signal (appsink->cond);
|
g_cond_signal (appsink->priv->cond);
|
||||||
emit = appsink->emit_signals;
|
emit = appsink->priv->emit_signals;
|
||||||
g_mutex_unlock (appsink->mutex);
|
g_mutex_unlock (appsink->priv->mutex);
|
||||||
|
|
||||||
if (emit)
|
if (emit)
|
||||||
g_signal_emit (appsink, gst_app_sink_signals[SIGNAL_NEW_BUFFER], 0);
|
g_signal_emit (appsink, gst_app_sink_signals[SIGNAL_NEW_BUFFER], 0);
|
||||||
|
@ -644,7 +667,7 @@ gst_app_sink_render (GstBaseSink * psink, GstBuffer * buffer)
|
||||||
flushing:
|
flushing:
|
||||||
{
|
{
|
||||||
GST_DEBUG_OBJECT (appsink, "we are flushing");
|
GST_DEBUG_OBJECT (appsink, "we are flushing");
|
||||||
g_mutex_unlock (appsink->mutex);
|
g_mutex_unlock (appsink->priv->mutex);
|
||||||
return GST_FLOW_WRONG_STATE;
|
return GST_FLOW_WRONG_STATE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -657,7 +680,7 @@ gst_app_sink_getcaps (GstBaseSink * psink)
|
||||||
GstAppSink *appsink = GST_APP_SINK (psink);
|
GstAppSink *appsink = GST_APP_SINK (psink);
|
||||||
|
|
||||||
GST_OBJECT_LOCK (appsink);
|
GST_OBJECT_LOCK (appsink);
|
||||||
if ((caps = appsink->caps))
|
if ((caps = appsink->priv->caps))
|
||||||
gst_caps_ref (caps);
|
gst_caps_ref (caps);
|
||||||
GST_DEBUG_OBJECT (appsink, "got caps %" GST_PTR_FORMAT, caps);
|
GST_DEBUG_OBJECT (appsink, "got caps %" GST_PTR_FORMAT, caps);
|
||||||
GST_OBJECT_UNLOCK (appsink);
|
GST_OBJECT_UNLOCK (appsink);
|
||||||
|
@ -676,6 +699,8 @@ gst_app_sink_getcaps (GstBaseSink * psink)
|
||||||
* a copy of the caps structure. After calling this method, the sink will only
|
* 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
|
* accept caps that match @caps. If @caps is non-fixed, you must check the caps
|
||||||
* on the buffers to get the actual used caps.
|
* on the buffers to get the actual used caps.
|
||||||
|
*
|
||||||
|
* Since: 0.10.22
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
gst_app_sink_set_caps (GstAppSink * appsink, const GstCaps * caps)
|
gst_app_sink_set_caps (GstAppSink * appsink, const GstCaps * caps)
|
||||||
|
@ -687,11 +712,11 @@ gst_app_sink_set_caps (GstAppSink * appsink, const GstCaps * caps)
|
||||||
|
|
||||||
GST_OBJECT_LOCK (appsink);
|
GST_OBJECT_LOCK (appsink);
|
||||||
GST_DEBUG_OBJECT (appsink, "setting caps to %" GST_PTR_FORMAT, caps);
|
GST_DEBUG_OBJECT (appsink, "setting caps to %" GST_PTR_FORMAT, caps);
|
||||||
if ((old = appsink->caps) != caps) {
|
if ((old = appsink->priv->caps) != caps) {
|
||||||
if (caps)
|
if (caps)
|
||||||
appsink->caps = gst_caps_copy (caps);
|
appsink->priv->caps = gst_caps_copy (caps);
|
||||||
else
|
else
|
||||||
appsink->caps = NULL;
|
appsink->priv->caps = NULL;
|
||||||
if (old)
|
if (old)
|
||||||
gst_caps_unref (old);
|
gst_caps_unref (old);
|
||||||
}
|
}
|
||||||
|
@ -705,6 +730,8 @@ gst_app_sink_set_caps (GstAppSink * appsink, const GstCaps * caps)
|
||||||
* Get the configured caps on @appsink.
|
* Get the configured caps on @appsink.
|
||||||
*
|
*
|
||||||
* Returns: the #GstCaps accepted by the sink. gst_caps_unref() after usage.
|
* Returns: the #GstCaps accepted by the sink. gst_caps_unref() after usage.
|
||||||
|
*
|
||||||
|
* Since: 0.10.22
|
||||||
*/
|
*/
|
||||||
GstCaps *
|
GstCaps *
|
||||||
gst_app_sink_get_caps (GstAppSink * appsink)
|
gst_app_sink_get_caps (GstAppSink * appsink)
|
||||||
|
@ -715,7 +742,7 @@ gst_app_sink_get_caps (GstAppSink * appsink)
|
||||||
g_return_val_if_fail (GST_IS_APP_SINK (appsink), NULL);
|
g_return_val_if_fail (GST_IS_APP_SINK (appsink), NULL);
|
||||||
|
|
||||||
GST_OBJECT_LOCK (appsink);
|
GST_OBJECT_LOCK (appsink);
|
||||||
if ((caps = appsink->caps))
|
if ((caps = appsink->priv->caps))
|
||||||
gst_caps_ref (caps);
|
gst_caps_ref (caps);
|
||||||
GST_DEBUG_OBJECT (appsink, "getting caps of %" GST_PTR_FORMAT, caps);
|
GST_DEBUG_OBJECT (appsink, "getting caps of %" GST_PTR_FORMAT, caps);
|
||||||
GST_OBJECT_UNLOCK (appsink);
|
GST_OBJECT_UNLOCK (appsink);
|
||||||
|
@ -734,6 +761,8 @@ gst_app_sink_get_caps (GstAppSink * appsink)
|
||||||
* PLAYING state.
|
* PLAYING state.
|
||||||
*
|
*
|
||||||
* Returns: %TRUE if no more buffers can be pulled and the appsink is EOS.
|
* Returns: %TRUE if no more buffers can be pulled and the appsink is EOS.
|
||||||
|
*
|
||||||
|
* Since: 0.10.22
|
||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
gst_app_sink_is_eos (GstAppSink * appsink)
|
gst_app_sink_is_eos (GstAppSink * appsink)
|
||||||
|
@ -743,25 +772,25 @@ gst_app_sink_is_eos (GstAppSink * appsink)
|
||||||
g_return_val_if_fail (appsink != NULL, FALSE);
|
g_return_val_if_fail (appsink != NULL, FALSE);
|
||||||
g_return_val_if_fail (GST_IS_APP_SINK (appsink), FALSE);
|
g_return_val_if_fail (GST_IS_APP_SINK (appsink), FALSE);
|
||||||
|
|
||||||
g_mutex_lock (appsink->mutex);
|
g_mutex_lock (appsink->priv->mutex);
|
||||||
if (!appsink->started)
|
if (!appsink->priv->started)
|
||||||
goto not_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");
|
GST_DEBUG_OBJECT (appsink, "we are EOS and the queue is empty");
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
} else {
|
} else {
|
||||||
GST_DEBUG_OBJECT (appsink, "we are not yet EOS");
|
GST_DEBUG_OBJECT (appsink, "we are not yet EOS");
|
||||||
ret = FALSE;
|
ret = FALSE;
|
||||||
}
|
}
|
||||||
g_mutex_unlock (appsink->mutex);
|
g_mutex_unlock (appsink->priv->mutex);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
not_started:
|
not_started:
|
||||||
{
|
{
|
||||||
GST_DEBUG_OBJECT (appsink, "we are stopped, return TRUE");
|
GST_DEBUG_OBJECT (appsink, "we are stopped, return TRUE");
|
||||||
g_mutex_unlock (appsink->mutex);
|
g_mutex_unlock (appsink->priv->mutex);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -774,15 +803,17 @@ not_started:
|
||||||
* Make appsink emit the "new-preroll" and "new-buffer" signals. This option is
|
* Make appsink emit the "new-preroll" and "new-buffer" signals. This option is
|
||||||
* by default disabled because signal emission is expensive and unneeded when
|
* by default disabled because signal emission is expensive and unneeded when
|
||||||
* the application prefers to operate in pull mode.
|
* the application prefers to operate in pull mode.
|
||||||
|
*
|
||||||
|
* Since: 0.10.22
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
gst_app_sink_set_emit_signals (GstAppSink * appsink, gboolean emit)
|
gst_app_sink_set_emit_signals (GstAppSink * appsink, gboolean emit)
|
||||||
{
|
{
|
||||||
g_return_if_fail (GST_IS_APP_SINK (appsink));
|
g_return_if_fail (GST_IS_APP_SINK (appsink));
|
||||||
|
|
||||||
g_mutex_lock (appsink->mutex);
|
g_mutex_lock (appsink->priv->mutex);
|
||||||
appsink->emit_signals = emit;
|
appsink->priv->emit_signals = emit;
|
||||||
g_mutex_unlock (appsink->mutex);
|
g_mutex_unlock (appsink->priv->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -793,6 +824,8 @@ gst_app_sink_set_emit_signals (GstAppSink * appsink, gboolean emit)
|
||||||
*
|
*
|
||||||
* Returns: %TRUE if @appsink is emiting the "new-preroll" and "new-buffer"
|
* Returns: %TRUE if @appsink is emiting the "new-preroll" and "new-buffer"
|
||||||
* signals.
|
* signals.
|
||||||
|
*
|
||||||
|
* Since: 0.10.22
|
||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
gst_app_sink_get_emit_signals (GstAppSink * appsink)
|
gst_app_sink_get_emit_signals (GstAppSink * appsink)
|
||||||
|
@ -801,9 +834,9 @@ gst_app_sink_get_emit_signals (GstAppSink * appsink)
|
||||||
|
|
||||||
g_return_val_if_fail (GST_IS_APP_SINK (appsink), FALSE);
|
g_return_val_if_fail (GST_IS_APP_SINK (appsink), FALSE);
|
||||||
|
|
||||||
g_mutex_lock (appsink->mutex);
|
g_mutex_lock (appsink->priv->mutex);
|
||||||
result = appsink->emit_signals;
|
result = appsink->priv->emit_signals;
|
||||||
g_mutex_unlock (appsink->mutex);
|
g_mutex_unlock (appsink->priv->mutex);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -816,19 +849,21 @@ gst_app_sink_get_emit_signals (GstAppSink * appsink)
|
||||||
* Set the maximum amount of buffers that can be queued in @appsink. After this
|
* 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
|
* amount of buffers are queued in appsink, any more buffers will block upstream
|
||||||
* elements until a buffer is pulled from @appsink.
|
* elements until a buffer is pulled from @appsink.
|
||||||
|
*
|
||||||
|
* Since: 0.10.22
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
gst_app_sink_set_max_buffers (GstAppSink * appsink, guint max)
|
gst_app_sink_set_max_buffers (GstAppSink * appsink, guint max)
|
||||||
{
|
{
|
||||||
g_return_if_fail (GST_IS_APP_SINK (appsink));
|
g_return_if_fail (GST_IS_APP_SINK (appsink));
|
||||||
|
|
||||||
g_mutex_lock (appsink->mutex);
|
g_mutex_lock (appsink->priv->mutex);
|
||||||
if (max != appsink->max_buffers) {
|
if (max != appsink->priv->max_buffers) {
|
||||||
appsink->max_buffers = max;
|
appsink->priv->max_buffers = max;
|
||||||
/* signal the change */
|
/* 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -838,6 +873,8 @@ gst_app_sink_set_max_buffers (GstAppSink * appsink, guint max)
|
||||||
* Get the maximum amount of buffers that can be queued in @appsink.
|
* Get the maximum amount of buffers that can be queued in @appsink.
|
||||||
*
|
*
|
||||||
* Returns: The maximum amount of buffers that can be queued.
|
* Returns: The maximum amount of buffers that can be queued.
|
||||||
|
*
|
||||||
|
* Since: 0.10.22
|
||||||
*/
|
*/
|
||||||
guint
|
guint
|
||||||
gst_app_sink_get_max_buffers (GstAppSink * appsink)
|
gst_app_sink_get_max_buffers (GstAppSink * appsink)
|
||||||
|
@ -846,9 +883,9 @@ gst_app_sink_get_max_buffers (GstAppSink * appsink)
|
||||||
|
|
||||||
g_return_val_if_fail (GST_IS_APP_SINK (appsink), 0);
|
g_return_val_if_fail (GST_IS_APP_SINK (appsink), 0);
|
||||||
|
|
||||||
g_mutex_lock (appsink->mutex);
|
g_mutex_lock (appsink->priv->mutex);
|
||||||
result = appsink->max_buffers;
|
result = appsink->priv->max_buffers;
|
||||||
g_mutex_unlock (appsink->mutex);
|
g_mutex_unlock (appsink->priv->mutex);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -860,19 +897,21 @@ gst_app_sink_get_max_buffers (GstAppSink * appsink)
|
||||||
*
|
*
|
||||||
* Instruct @appsink to drop old buffers when the maximum amount of queued
|
* Instruct @appsink to drop old buffers when the maximum amount of queued
|
||||||
* buffers is reached.
|
* buffers is reached.
|
||||||
|
*
|
||||||
|
* Since: 0.10.22
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
gst_app_sink_set_drop (GstAppSink * appsink, gboolean drop)
|
gst_app_sink_set_drop (GstAppSink * appsink, gboolean drop)
|
||||||
{
|
{
|
||||||
g_return_if_fail (GST_IS_APP_SINK (appsink));
|
g_return_if_fail (GST_IS_APP_SINK (appsink));
|
||||||
|
|
||||||
g_mutex_lock (appsink->mutex);
|
g_mutex_lock (appsink->priv->mutex);
|
||||||
if (appsink->drop != drop) {
|
if (appsink->priv->drop != drop) {
|
||||||
appsink->drop = drop;
|
appsink->priv->drop = drop;
|
||||||
/* signal the change */
|
/* 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -884,6 +923,8 @@ gst_app_sink_set_drop (GstAppSink * appsink, gboolean drop)
|
||||||
*
|
*
|
||||||
* Returns: %TRUE if @appsink is dropping old buffers when the queue is
|
* Returns: %TRUE if @appsink is dropping old buffers when the queue is
|
||||||
* filled.
|
* filled.
|
||||||
|
*
|
||||||
|
* Since: 0.10.22
|
||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
gst_app_sink_get_drop (GstAppSink * appsink)
|
gst_app_sink_get_drop (GstAppSink * appsink)
|
||||||
|
@ -892,9 +933,9 @@ gst_app_sink_get_drop (GstAppSink * appsink)
|
||||||
|
|
||||||
g_return_val_if_fail (GST_IS_APP_SINK (appsink), FALSE);
|
g_return_val_if_fail (GST_IS_APP_SINK (appsink), FALSE);
|
||||||
|
|
||||||
g_mutex_lock (appsink->mutex);
|
g_mutex_lock (appsink->priv->mutex);
|
||||||
result = appsink->drop;
|
result = appsink->priv->drop;
|
||||||
g_mutex_unlock (appsink->mutex);
|
g_mutex_unlock (appsink->priv->mutex);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -921,6 +962,8 @@ gst_app_sink_get_drop (GstAppSink * appsink)
|
||||||
* element is set to the READY/NULL state.
|
* element is set to the READY/NULL state.
|
||||||
*
|
*
|
||||||
* Returns: a #GstBuffer or NULL when the appsink is stopped or EOS.
|
* Returns: a #GstBuffer or NULL when the appsink is stopped or EOS.
|
||||||
|
*
|
||||||
|
* Since: 0.10.22
|
||||||
*/
|
*/
|
||||||
GstBuffer *
|
GstBuffer *
|
||||||
gst_app_sink_pull_preroll (GstAppSink * appsink)
|
gst_app_sink_pull_preroll (GstAppSink * appsink)
|
||||||
|
@ -930,26 +973,26 @@ gst_app_sink_pull_preroll (GstAppSink * appsink)
|
||||||
g_return_val_if_fail (appsink != NULL, NULL);
|
g_return_val_if_fail (appsink != NULL, NULL);
|
||||||
g_return_val_if_fail (GST_IS_APP_SINK (appsink), 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) {
|
while (TRUE) {
|
||||||
GST_DEBUG_OBJECT (appsink, "trying to grab a buffer");
|
GST_DEBUG_OBJECT (appsink, "trying to grab a buffer");
|
||||||
if (!appsink->started)
|
if (!appsink->priv->started)
|
||||||
goto not_started;
|
goto not_started;
|
||||||
|
|
||||||
if (appsink->preroll != NULL)
|
if (appsink->priv->preroll != NULL)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (appsink->is_eos)
|
if (appsink->priv->is_eos)
|
||||||
goto eos;
|
goto eos;
|
||||||
|
|
||||||
/* nothing to return, wait */
|
/* nothing to return, wait */
|
||||||
GST_DEBUG_OBJECT (appsink, "waiting for the preroll buffer");
|
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);
|
GST_DEBUG_OBJECT (appsink, "we have the preroll buffer %p", buf);
|
||||||
g_mutex_unlock (appsink->mutex);
|
g_mutex_unlock (appsink->priv->mutex);
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
|
|
||||||
|
@ -957,13 +1000,13 @@ gst_app_sink_pull_preroll (GstAppSink * appsink)
|
||||||
eos:
|
eos:
|
||||||
{
|
{
|
||||||
GST_DEBUG_OBJECT (appsink, "we are EOS, return NULL");
|
GST_DEBUG_OBJECT (appsink, "we are EOS, return NULL");
|
||||||
g_mutex_unlock (appsink->mutex);
|
g_mutex_unlock (appsink->priv->mutex);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
not_started:
|
not_started:
|
||||||
{
|
{
|
||||||
GST_DEBUG_OBJECT (appsink, "we are stopped, return NULL");
|
GST_DEBUG_OBJECT (appsink, "we are stopped, return NULL");
|
||||||
g_mutex_unlock (appsink->mutex);
|
g_mutex_unlock (appsink->priv->mutex);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -985,6 +1028,8 @@ not_started:
|
||||||
* %NULL. Use gst_app_sink_is_eos () to check for the EOS condition.
|
* %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.
|
* Returns: a #GstBuffer or NULL when the appsink is stopped or EOS.
|
||||||
|
*
|
||||||
|
* Since: 0.10.22
|
||||||
*/
|
*/
|
||||||
GstBuffer *
|
GstBuffer *
|
||||||
gst_app_sink_pull_buffer (GstAppSink * appsink)
|
gst_app_sink_pull_buffer (GstAppSink * appsink)
|
||||||
|
@ -994,27 +1039,27 @@ gst_app_sink_pull_buffer (GstAppSink * appsink)
|
||||||
g_return_val_if_fail (appsink != NULL, NULL);
|
g_return_val_if_fail (appsink != NULL, NULL);
|
||||||
g_return_val_if_fail (GST_IS_APP_SINK (appsink), 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) {
|
while (TRUE) {
|
||||||
GST_DEBUG_OBJECT (appsink, "trying to grab a buffer");
|
GST_DEBUG_OBJECT (appsink, "trying to grab a buffer");
|
||||||
if (!appsink->started)
|
if (!appsink->priv->started)
|
||||||
goto not_started;
|
goto not_started;
|
||||||
|
|
||||||
if (!g_queue_is_empty (appsink->queue))
|
if (!g_queue_is_empty (appsink->priv->queue))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (appsink->is_eos)
|
if (appsink->priv->is_eos)
|
||||||
goto eos;
|
goto eos;
|
||||||
|
|
||||||
/* nothing to return, wait */
|
/* nothing to return, wait */
|
||||||
GST_DEBUG_OBJECT (appsink, "waiting for a buffer");
|
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);
|
GST_DEBUG_OBJECT (appsink, "we have a buffer %p", buf);
|
||||||
g_cond_signal (appsink->cond);
|
g_cond_signal (appsink->priv->cond);
|
||||||
g_mutex_unlock (appsink->mutex);
|
g_mutex_unlock (appsink->priv->mutex);
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
|
|
||||||
|
@ -1022,13 +1067,13 @@ gst_app_sink_pull_buffer (GstAppSink * appsink)
|
||||||
eos:
|
eos:
|
||||||
{
|
{
|
||||||
GST_DEBUG_OBJECT (appsink, "we are EOS, return NULL");
|
GST_DEBUG_OBJECT (appsink, "we are EOS, return NULL");
|
||||||
g_mutex_unlock (appsink->mutex);
|
g_mutex_unlock (appsink->priv->mutex);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
not_started:
|
not_started:
|
||||||
{
|
{
|
||||||
GST_DEBUG_OBJECT (appsink, "we are stopped, return NULL");
|
GST_DEBUG_OBJECT (appsink, "we are stopped, return NULL");
|
||||||
g_mutex_unlock (appsink->mutex);
|
g_mutex_unlock (appsink->priv->mutex);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,24 +38,17 @@ G_BEGIN_DECLS
|
||||||
|
|
||||||
typedef struct _GstAppSink GstAppSink;
|
typedef struct _GstAppSink GstAppSink;
|
||||||
typedef struct _GstAppSinkClass GstAppSinkClass;
|
typedef struct _GstAppSinkClass GstAppSinkClass;
|
||||||
|
typedef struct _GstAppSinkPrivate GstAppSinkPrivate;
|
||||||
|
|
||||||
struct _GstAppSink
|
struct _GstAppSink
|
||||||
{
|
{
|
||||||
GstBaseSink basesink;
|
GstBaseSink basesink;
|
||||||
|
|
||||||
/*< private >*/
|
/*< private >*/
|
||||||
GstCaps *caps;
|
GstAppSinkPrivate *priv;
|
||||||
gboolean emit_signals;
|
|
||||||
guint max_buffers;
|
|
||||||
gboolean drop;
|
|
||||||
|
|
||||||
GCond *cond;
|
/*< private >*/
|
||||||
GMutex *mutex;
|
gpointer _gst_reserved[GST_PADDING];
|
||||||
GQueue *queue;
|
|
||||||
GstBuffer *preroll;
|
|
||||||
gboolean flushing;
|
|
||||||
gboolean started;
|
|
||||||
gboolean is_eos;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstAppSinkClass
|
struct _GstAppSinkClass
|
||||||
|
@ -70,6 +63,9 @@ struct _GstAppSinkClass
|
||||||
/* actions */
|
/* actions */
|
||||||
GstBuffer * (*pull_preroll) (GstAppSink *sink);
|
GstBuffer * (*pull_preroll) (GstAppSink *sink);
|
||||||
GstBuffer * (*pull_buffer) (GstAppSink *sink);
|
GstBuffer * (*pull_buffer) (GstAppSink *sink);
|
||||||
|
|
||||||
|
/*< private >*/
|
||||||
|
gpointer _gst_reserved[GST_PADDING];
|
||||||
};
|
};
|
||||||
|
|
||||||
GType gst_app_sink_get_type(void);
|
GType gst_app_sink_get_type(void);
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
* <link linkend="gst-plugins-base-libs-appsrc">libgstapp</link> section in the
|
* <link linkend="gst-plugins-base-libs-appsrc">libgstapp</link> section in the
|
||||||
* GStreamer Plugins Base Libraries documentation.
|
* GStreamer Plugins Base Libraries documentation.
|
||||||
*
|
*
|
||||||
|
* Since: 0.10.22
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -95,6 +96,8 @@
|
||||||
* gst_app_src_end_of_stream() or emit the end-of-stream action signal. After
|
* 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
|
* 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.
|
* happened or the state of the appsrc has gone through READY.
|
||||||
|
*
|
||||||
|
* Since: 0.10.22
|
||||||
*
|
*
|
||||||
* Last reviewed on 2008-12-17 (0.10.10)
|
* Last reviewed on 2008-12-17 (0.10.10)
|
||||||
*/
|
*/
|
||||||
|
@ -111,6 +114,29 @@
|
||||||
#include "gstapp-marshal.h"
|
#include "gstapp-marshal.h"
|
||||||
#include "gstappsrc.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);
|
GST_DEBUG_CATEGORY (app_src_debug);
|
||||||
#define GST_CAT_DEFAULT app_src_debug
|
#define GST_CAT_DEFAULT app_src_debug
|
||||||
|
@ -446,22 +472,27 @@ gst_app_src_class_init (GstAppSrcClass * klass)
|
||||||
|
|
||||||
klass->push_buffer = gst_app_src_push_buffer_action;
|
klass->push_buffer = gst_app_src_push_buffer_action;
|
||||||
klass->end_of_stream = gst_app_src_end_of_stream;
|
klass->end_of_stream = gst_app_src_end_of_stream;
|
||||||
|
|
||||||
|
g_type_class_add_private (klass, sizeof (GstAppSrcPrivate));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_app_src_init (GstAppSrc * appsrc, GstAppSrcClass * klass)
|
gst_app_src_init (GstAppSrc * appsrc, GstAppSrcClass * klass)
|
||||||
{
|
{
|
||||||
appsrc->mutex = g_mutex_new ();
|
appsrc->priv = G_TYPE_INSTANCE_GET_PRIVATE (appsrc, GST_TYPE_APP_SRC,
|
||||||
appsrc->cond = g_cond_new ();
|
GstAppSrcPrivate);
|
||||||
appsrc->queue = g_queue_new ();
|
|
||||||
|
|
||||||
appsrc->size = DEFAULT_PROP_SIZE;
|
appsrc->priv->mutex = g_mutex_new ();
|
||||||
appsrc->stream_type = DEFAULT_PROP_STREAM_TYPE;
|
appsrc->priv->cond = g_cond_new ();
|
||||||
appsrc->max_bytes = DEFAULT_PROP_MAX_BYTES;
|
appsrc->priv->queue = g_queue_new ();
|
||||||
appsrc->format = DEFAULT_PROP_FORMAT;
|
|
||||||
appsrc->block = DEFAULT_PROP_BLOCK;
|
appsrc->priv->size = DEFAULT_PROP_SIZE;
|
||||||
appsrc->min_latency = DEFAULT_PROP_MIN_LATENCY;
|
appsrc->priv->stream_type = DEFAULT_PROP_STREAM_TYPE;
|
||||||
appsrc->max_latency = DEFAULT_PROP_MAX_LATENCY;
|
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);
|
gst_base_src_set_live (GST_BASE_SRC (appsrc), DEFAULT_PROP_IS_LIVE);
|
||||||
}
|
}
|
||||||
|
@ -471,7 +502,7 @@ gst_app_src_flush_queued (GstAppSrc * src)
|
||||||
{
|
{
|
||||||
GstBuffer *buf;
|
GstBuffer *buf;
|
||||||
|
|
||||||
while ((buf = g_queue_pop_head (src->queue)))
|
while ((buf = g_queue_pop_head (src->priv->queue)))
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -480,9 +511,9 @@ gst_app_src_dispose (GObject * obj)
|
||||||
{
|
{
|
||||||
GstAppSrc *appsrc = GST_APP_SRC (obj);
|
GstAppSrc *appsrc = GST_APP_SRC (obj);
|
||||||
|
|
||||||
if (appsrc->caps) {
|
if (appsrc->priv->caps) {
|
||||||
gst_caps_unref (appsrc->caps);
|
gst_caps_unref (appsrc->priv->caps);
|
||||||
appsrc->caps = NULL;
|
appsrc->priv->caps = NULL;
|
||||||
}
|
}
|
||||||
gst_app_src_flush_queued (appsrc);
|
gst_app_src_flush_queued (appsrc);
|
||||||
|
|
||||||
|
@ -494,9 +525,9 @@ gst_app_src_finalize (GObject * obj)
|
||||||
{
|
{
|
||||||
GstAppSrc *appsrc = GST_APP_SRC (obj);
|
GstAppSrc *appsrc = GST_APP_SRC (obj);
|
||||||
|
|
||||||
g_mutex_free (appsrc->mutex);
|
g_mutex_free (appsrc->priv->mutex);
|
||||||
g_cond_free (appsrc->cond);
|
g_cond_free (appsrc->priv->cond);
|
||||||
g_queue_free (appsrc->queue);
|
g_queue_free (appsrc->priv->queue);
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->finalize (obj);
|
G_OBJECT_CLASS (parent_class)->finalize (obj);
|
||||||
}
|
}
|
||||||
|
@ -521,10 +552,10 @@ gst_app_src_set_property (GObject * object, guint prop_id,
|
||||||
gst_app_src_set_max_bytes (appsrc, g_value_get_uint64 (value));
|
gst_app_src_set_max_bytes (appsrc, g_value_get_uint64 (value));
|
||||||
break;
|
break;
|
||||||
case PROP_FORMAT:
|
case PROP_FORMAT:
|
||||||
appsrc->format = g_value_get_enum (value);
|
appsrc->priv->format = g_value_get_enum (value);
|
||||||
break;
|
break;
|
||||||
case PROP_BLOCK:
|
case PROP_BLOCK:
|
||||||
appsrc->block = g_value_get_boolean (value);
|
appsrc->priv->block = g_value_get_boolean (value);
|
||||||
break;
|
break;
|
||||||
case PROP_IS_LIVE:
|
case PROP_IS_LIVE:
|
||||||
gst_base_src_set_live (GST_BASE_SRC (appsrc),
|
gst_base_src_set_live (GST_BASE_SRC (appsrc),
|
||||||
|
@ -572,10 +603,10 @@ gst_app_src_get_property (GObject * object, guint prop_id, GValue * value,
|
||||||
g_value_set_uint64 (value, gst_app_src_get_max_bytes (appsrc));
|
g_value_set_uint64 (value, gst_app_src_get_max_bytes (appsrc));
|
||||||
break;
|
break;
|
||||||
case PROP_FORMAT:
|
case PROP_FORMAT:
|
||||||
g_value_set_enum (value, appsrc->format);
|
g_value_set_enum (value, appsrc->priv->format);
|
||||||
break;
|
break;
|
||||||
case PROP_BLOCK:
|
case PROP_BLOCK:
|
||||||
g_value_set_boolean (value, appsrc->block);
|
g_value_set_boolean (value, appsrc->priv->block);
|
||||||
break;
|
break;
|
||||||
case PROP_IS_LIVE:
|
case PROP_IS_LIVE:
|
||||||
g_value_set_boolean (value, gst_base_src_is_live (GST_BASE_SRC (appsrc)));
|
g_value_set_boolean (value, gst_base_src_is_live (GST_BASE_SRC (appsrc)));
|
||||||
|
@ -607,11 +638,11 @@ gst_app_src_unlock (GstBaseSrc * bsrc)
|
||||||
{
|
{
|
||||||
GstAppSrc *appsrc = GST_APP_SRC (bsrc);
|
GstAppSrc *appsrc = GST_APP_SRC (bsrc);
|
||||||
|
|
||||||
g_mutex_lock (appsrc->mutex);
|
g_mutex_lock (appsrc->priv->mutex);
|
||||||
GST_DEBUG_OBJECT (appsrc, "unlock start");
|
GST_DEBUG_OBJECT (appsrc, "unlock start");
|
||||||
appsrc->flushing = TRUE;
|
appsrc->priv->flushing = TRUE;
|
||||||
g_cond_broadcast (appsrc->cond);
|
g_cond_broadcast (appsrc->priv->cond);
|
||||||
g_mutex_unlock (appsrc->mutex);
|
g_mutex_unlock (appsrc->priv->mutex);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -621,11 +652,11 @@ gst_app_src_unlock_stop (GstBaseSrc * bsrc)
|
||||||
{
|
{
|
||||||
GstAppSrc *appsrc = GST_APP_SRC (bsrc);
|
GstAppSrc *appsrc = GST_APP_SRC (bsrc);
|
||||||
|
|
||||||
g_mutex_lock (appsrc->mutex);
|
g_mutex_lock (appsrc->priv->mutex);
|
||||||
GST_DEBUG_OBJECT (appsrc, "unlock stop");
|
GST_DEBUG_OBJECT (appsrc, "unlock stop");
|
||||||
appsrc->flushing = FALSE;
|
appsrc->priv->flushing = FALSE;
|
||||||
g_cond_broadcast (appsrc->cond);
|
g_cond_broadcast (appsrc->priv->cond);
|
||||||
g_mutex_unlock (appsrc->mutex);
|
g_mutex_unlock (appsrc->priv->mutex);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -635,16 +666,16 @@ gst_app_src_start (GstBaseSrc * bsrc)
|
||||||
{
|
{
|
||||||
GstAppSrc *appsrc = GST_APP_SRC (bsrc);
|
GstAppSrc *appsrc = GST_APP_SRC (bsrc);
|
||||||
|
|
||||||
g_mutex_lock (appsrc->mutex);
|
g_mutex_lock (appsrc->priv->mutex);
|
||||||
GST_DEBUG_OBJECT (appsrc, "starting");
|
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
|
/* set the offset to -1 so that we always do a first seek. This is only used
|
||||||
* in random-access mode. */
|
* in random-access mode. */
|
||||||
appsrc->offset = -1;
|
appsrc->priv->offset = -1;
|
||||||
appsrc->flushing = FALSE;
|
appsrc->priv->flushing = FALSE;
|
||||||
g_mutex_unlock (appsrc->mutex);
|
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;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -654,13 +685,13 @@ gst_app_src_stop (GstBaseSrc * bsrc)
|
||||||
{
|
{
|
||||||
GstAppSrc *appsrc = GST_APP_SRC (bsrc);
|
GstAppSrc *appsrc = GST_APP_SRC (bsrc);
|
||||||
|
|
||||||
g_mutex_lock (appsrc->mutex);
|
g_mutex_lock (appsrc->priv->mutex);
|
||||||
GST_DEBUG_OBJECT (appsrc, "stopping");
|
GST_DEBUG_OBJECT (appsrc, "stopping");
|
||||||
appsrc->is_eos = FALSE;
|
appsrc->priv->is_eos = FALSE;
|
||||||
appsrc->flushing = TRUE;
|
appsrc->priv->flushing = TRUE;
|
||||||
appsrc->started = FALSE;
|
appsrc->priv->started = FALSE;
|
||||||
gst_app_src_flush_queued (appsrc);
|
gst_app_src_flush_queued (appsrc);
|
||||||
g_mutex_unlock (appsrc->mutex);
|
g_mutex_unlock (appsrc->priv->mutex);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -671,7 +702,7 @@ gst_app_src_is_seekable (GstBaseSrc * src)
|
||||||
GstAppSrc *appsrc = GST_APP_SRC (src);
|
GstAppSrc *appsrc = GST_APP_SRC (src);
|
||||||
gboolean res = FALSE;
|
gboolean res = FALSE;
|
||||||
|
|
||||||
switch (appsrc->stream_type) {
|
switch (appsrc->priv->stream_type) {
|
||||||
case GST_APP_STREAM_TYPE_STREAM:
|
case GST_APP_STREAM_TYPE_STREAM:
|
||||||
break;
|
break;
|
||||||
case GST_APP_STREAM_TYPE_SEEKABLE:
|
case GST_APP_STREAM_TYPE_SEEKABLE:
|
||||||
|
@ -688,7 +719,7 @@ gst_app_src_check_get_range (GstBaseSrc * src)
|
||||||
GstAppSrc *appsrc = GST_APP_SRC (src);
|
GstAppSrc *appsrc = GST_APP_SRC (src);
|
||||||
gboolean res = FALSE;
|
gboolean res = FALSE;
|
||||||
|
|
||||||
switch (appsrc->stream_type) {
|
switch (appsrc->priv->stream_type) {
|
||||||
case GST_APP_STREAM_TYPE_STREAM:
|
case GST_APP_STREAM_TYPE_STREAM:
|
||||||
case GST_APP_STREAM_TYPE_SEEKABLE:
|
case GST_APP_STREAM_TYPE_SEEKABLE:
|
||||||
break;
|
break;
|
||||||
|
@ -725,12 +756,12 @@ gst_app_src_query (GstBaseSrc * src, GstQuery * query)
|
||||||
res = gst_base_src_query_latency (src, &live, &min, &max);
|
res = gst_base_src_query_latency (src, &live, &min, &max);
|
||||||
|
|
||||||
/* overwrite with our values when we need to */
|
/* overwrite with our values when we need to */
|
||||||
g_mutex_lock (appsrc->mutex);
|
g_mutex_lock (appsrc->priv->mutex);
|
||||||
if (appsrc->min_latency != -1)
|
if (appsrc->priv->min_latency != -1)
|
||||||
min = appsrc->min_latency;
|
min = appsrc->priv->min_latency;
|
||||||
if (appsrc->max_latency != -1)
|
if (appsrc->priv->max_latency != -1)
|
||||||
max = appsrc->max_latency;
|
max = appsrc->priv->max_latency;
|
||||||
g_mutex_unlock (appsrc->mutex);
|
g_mutex_unlock (appsrc->priv->mutex);
|
||||||
|
|
||||||
gst_query_set_latency (query, live, min, max);
|
gst_query_set_latency (query, live, min, max);
|
||||||
break;
|
break;
|
||||||
|
@ -757,7 +788,7 @@ gst_app_src_do_seek (GstBaseSrc * src, GstSegment * segment)
|
||||||
desired_position, gst_format_get_name (segment->format));
|
desired_position, gst_format_get_name (segment->format));
|
||||||
|
|
||||||
/* no need to try to seek in streaming mode */
|
/* 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;
|
return TRUE;
|
||||||
|
|
||||||
g_signal_emit (appsrc, gst_app_src_signals[SIGNAL_SEEK_DATA], 0,
|
g_signal_emit (appsrc, gst_app_src_signals[SIGNAL_SEEK_DATA], 0,
|
||||||
|
@ -780,22 +811,22 @@ gst_app_src_create (GstBaseSrc * bsrc, guint64 offset, guint size,
|
||||||
GstAppSrc *appsrc = GST_APP_SRC (bsrc);
|
GstAppSrc *appsrc = GST_APP_SRC (bsrc);
|
||||||
GstFlowReturn ret;
|
GstFlowReturn ret;
|
||||||
|
|
||||||
g_mutex_lock (appsrc->mutex);
|
g_mutex_lock (appsrc->priv->mutex);
|
||||||
/* check flushing first */
|
/* check flushing first */
|
||||||
if (G_UNLIKELY (appsrc->flushing))
|
if (G_UNLIKELY (appsrc->priv->flushing))
|
||||||
goto 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
|
/* if we are dealing with a random-access stream, issue a seek if the offset
|
||||||
* changed. */
|
* changed. */
|
||||||
if (G_UNLIKELY (appsrc->offset != offset)) {
|
if (G_UNLIKELY (appsrc->priv->offset != offset)) {
|
||||||
gboolean res;
|
gboolean res;
|
||||||
|
|
||||||
g_mutex_unlock (appsrc->mutex);
|
g_mutex_unlock (appsrc->priv->mutex);
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (appsrc,
|
GST_DEBUG_OBJECT (appsrc,
|
||||||
"we are at %" G_GINT64_FORMAT ", seek to %" G_GINT64_FORMAT,
|
"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,
|
g_signal_emit (appsrc, gst_app_src_signals[SIGNAL_SEEK_DATA], 0,
|
||||||
offset, &res);
|
offset, &res);
|
||||||
|
@ -804,46 +835,46 @@ gst_app_src_create (GstBaseSrc * bsrc, guint64 offset, guint size,
|
||||||
/* failing to seek is fatal */
|
/* failing to seek is fatal */
|
||||||
goto seek_error;
|
goto seek_error;
|
||||||
|
|
||||||
g_mutex_lock (appsrc->mutex);
|
g_mutex_lock (appsrc->priv->mutex);
|
||||||
|
|
||||||
appsrc->offset = offset;
|
appsrc->priv->offset = offset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
/* return data as long as we have some */
|
/* 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;
|
guint buf_size;
|
||||||
|
|
||||||
*buf = g_queue_pop_head (appsrc->queue);
|
*buf = g_queue_pop_head (appsrc->priv->queue);
|
||||||
buf_size = GST_BUFFER_SIZE (*buf);
|
buf_size = GST_BUFFER_SIZE (*buf);
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (appsrc, "we have buffer %p of size %u", *buf, buf_size);
|
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 */
|
/* only update the offset when in random_access mode */
|
||||||
if (appsrc->stream_type == GST_APP_STREAM_TYPE_RANDOM_ACCESS) {
|
if (appsrc->priv->stream_type == GST_APP_STREAM_TYPE_RANDOM_ACCESS) {
|
||||||
appsrc->offset += buf_size;
|
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 */
|
/* signal that we removed an item */
|
||||||
g_cond_broadcast (appsrc->cond);
|
g_cond_broadcast (appsrc->priv->cond);
|
||||||
|
|
||||||
ret = GST_FLOW_OK;
|
ret = GST_FLOW_OK;
|
||||||
break;
|
break;
|
||||||
} else {
|
} 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. */
|
/* 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,
|
g_signal_emit (appsrc, gst_app_src_signals[SIGNAL_NEED_DATA], 0, size,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
g_mutex_lock (appsrc->mutex);
|
g_mutex_lock (appsrc->priv->mutex);
|
||||||
/* we can be flushing now because we released the lock */
|
/* we can be flushing now because we released the lock */
|
||||||
if (G_UNLIKELY (appsrc->flushing))
|
if (G_UNLIKELY (appsrc->priv->flushing))
|
||||||
goto flushing;
|
goto flushing;
|
||||||
|
|
||||||
/* if we have a buffer now, continue the loop and try to return it. In
|
/* if we have a buffer now, continue the loop and try to return it. In
|
||||||
|
@ -851,20 +882,20 @@ gst_app_src_create (GstBaseSrc * bsrc, guint64 offset, guint size,
|
||||||
* signal) we can still be empty because the pushed buffer got flushed or
|
* signal) we can still be empty because the pushed buffer got flushed or
|
||||||
* when the application pushes the requested buffer later, we support both
|
* when the application pushes the requested buffer later, we support both
|
||||||
* possiblities. */
|
* possiblities. */
|
||||||
if (!g_queue_is_empty (appsrc->queue))
|
if (!g_queue_is_empty (appsrc->priv->queue))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* no buffer yet, maybe we are EOS, if not, block for more data. */
|
/* no buffer yet, maybe we are EOS, if not, block for more data. */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check EOS */
|
/* check EOS */
|
||||||
if (G_UNLIKELY (appsrc->is_eos))
|
if (G_UNLIKELY (appsrc->priv->is_eos))
|
||||||
goto eos;
|
goto eos;
|
||||||
|
|
||||||
/* nothing to return, wait a while for new data or flushing. */
|
/* 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;
|
return ret;
|
||||||
|
|
||||||
|
@ -872,13 +903,13 @@ gst_app_src_create (GstBaseSrc * bsrc, guint64 offset, guint size,
|
||||||
flushing:
|
flushing:
|
||||||
{
|
{
|
||||||
GST_DEBUG_OBJECT (appsrc, "we are flushing");
|
GST_DEBUG_OBJECT (appsrc, "we are flushing");
|
||||||
g_mutex_unlock (appsrc->mutex);
|
g_mutex_unlock (appsrc->priv->mutex);
|
||||||
return GST_FLOW_WRONG_STATE;
|
return GST_FLOW_WRONG_STATE;
|
||||||
}
|
}
|
||||||
eos:
|
eos:
|
||||||
{
|
{
|
||||||
GST_DEBUG_OBJECT (appsrc, "we are EOS");
|
GST_DEBUG_OBJECT (appsrc, "we are EOS");
|
||||||
g_mutex_unlock (appsrc->mutex);
|
g_mutex_unlock (appsrc->priv->mutex);
|
||||||
return GST_FLOW_UNEXPECTED;
|
return GST_FLOW_UNEXPECTED;
|
||||||
}
|
}
|
||||||
seek_error:
|
seek_error:
|
||||||
|
@ -900,6 +931,8 @@ seek_error:
|
||||||
* a copy of the caps structure. After calling this method, the source will
|
* 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
|
* only produce caps that match @caps. @caps must be fixed and the caps on the
|
||||||
* buffers must match the caps or left NULL.
|
* buffers must match the caps or left NULL.
|
||||||
|
*
|
||||||
|
* Since: 0.10.22
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
gst_app_src_set_caps (GstAppSrc * appsrc, const GstCaps * caps)
|
gst_app_src_set_caps (GstAppSrc * appsrc, const GstCaps * caps)
|
||||||
|
@ -910,11 +943,11 @@ gst_app_src_set_caps (GstAppSrc * appsrc, const GstCaps * caps)
|
||||||
|
|
||||||
GST_OBJECT_LOCK (appsrc);
|
GST_OBJECT_LOCK (appsrc);
|
||||||
GST_DEBUG_OBJECT (appsrc, "setting caps to %" GST_PTR_FORMAT, caps);
|
GST_DEBUG_OBJECT (appsrc, "setting caps to %" GST_PTR_FORMAT, caps);
|
||||||
if ((old = appsrc->caps) != caps) {
|
if ((old = appsrc->priv->caps) != caps) {
|
||||||
if (caps)
|
if (caps)
|
||||||
appsrc->caps = gst_caps_copy (caps);
|
appsrc->priv->caps = gst_caps_copy (caps);
|
||||||
else
|
else
|
||||||
appsrc->caps = NULL;
|
appsrc->priv->caps = NULL;
|
||||||
if (old)
|
if (old)
|
||||||
gst_caps_unref (old);
|
gst_caps_unref (old);
|
||||||
}
|
}
|
||||||
|
@ -928,6 +961,8 @@ gst_app_src_set_caps (GstAppSrc * appsrc, const GstCaps * caps)
|
||||||
* Get the configured caps on @appsrc.
|
* Get the configured caps on @appsrc.
|
||||||
*
|
*
|
||||||
* Returns: the #GstCaps produced by the source. gst_caps_unref() after usage.
|
* Returns: the #GstCaps produced by the source. gst_caps_unref() after usage.
|
||||||
|
*
|
||||||
|
* Since: 0.10.22
|
||||||
*/
|
*/
|
||||||
GstCaps *
|
GstCaps *
|
||||||
gst_app_src_get_caps (GstAppSrc * appsrc)
|
gst_app_src_get_caps (GstAppSrc * appsrc)
|
||||||
|
@ -938,7 +973,7 @@ gst_app_src_get_caps (GstAppSrc * appsrc)
|
||||||
g_return_val_if_fail (GST_IS_APP_SRC (appsrc), NULL);
|
g_return_val_if_fail (GST_IS_APP_SRC (appsrc), NULL);
|
||||||
|
|
||||||
GST_OBJECT_LOCK (appsrc);
|
GST_OBJECT_LOCK (appsrc);
|
||||||
if ((caps = appsrc->caps))
|
if ((caps = appsrc->priv->caps))
|
||||||
gst_caps_ref (caps);
|
gst_caps_ref (caps);
|
||||||
GST_DEBUG_OBJECT (appsrc, "getting caps of %" GST_PTR_FORMAT, caps);
|
GST_DEBUG_OBJECT (appsrc, "getting caps of %" GST_PTR_FORMAT, caps);
|
||||||
GST_OBJECT_UNLOCK (appsrc);
|
GST_OBJECT_UNLOCK (appsrc);
|
||||||
|
@ -953,6 +988,8 @@ gst_app_src_get_caps (GstAppSrc * appsrc)
|
||||||
*
|
*
|
||||||
* Set the size of the stream in bytes. A value of -1 means that the size is
|
* Set the size of the stream in bytes. A value of -1 means that the size is
|
||||||
* not known.
|
* not known.
|
||||||
|
*
|
||||||
|
* Since: 0.10.22
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
gst_app_src_set_size (GstAppSrc * appsrc, gint64 size)
|
gst_app_src_set_size (GstAppSrc * appsrc, gint64 size)
|
||||||
|
@ -962,7 +999,7 @@ gst_app_src_set_size (GstAppSrc * appsrc, gint64 size)
|
||||||
|
|
||||||
GST_OBJECT_LOCK (appsrc);
|
GST_OBJECT_LOCK (appsrc);
|
||||||
GST_DEBUG_OBJECT (appsrc, "setting size of %" G_GINT64_FORMAT, size);
|
GST_DEBUG_OBJECT (appsrc, "setting size of %" G_GINT64_FORMAT, size);
|
||||||
appsrc->size = size;
|
appsrc->priv->size = size;
|
||||||
GST_OBJECT_UNLOCK (appsrc);
|
GST_OBJECT_UNLOCK (appsrc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -974,6 +1011,8 @@ gst_app_src_set_size (GstAppSrc * appsrc, gint64 size)
|
||||||
* not known.
|
* not known.
|
||||||
*
|
*
|
||||||
* Returns: the size of the stream previously set with gst_app_src_set_size();
|
* Returns: the size of the stream previously set with gst_app_src_set_size();
|
||||||
|
*
|
||||||
|
* Since: 0.10.22
|
||||||
*/
|
*/
|
||||||
gint64
|
gint64
|
||||||
gst_app_src_get_size (GstAppSrc * appsrc)
|
gst_app_src_get_size (GstAppSrc * appsrc)
|
||||||
|
@ -984,7 +1023,7 @@ gst_app_src_get_size (GstAppSrc * appsrc)
|
||||||
g_return_val_if_fail (GST_IS_APP_SRC (appsrc), -1);
|
g_return_val_if_fail (GST_IS_APP_SRC (appsrc), -1);
|
||||||
|
|
||||||
GST_OBJECT_LOCK (appsrc);
|
GST_OBJECT_LOCK (appsrc);
|
||||||
size = appsrc->size;
|
size = appsrc->priv->size;
|
||||||
GST_DEBUG_OBJECT (appsrc, "getting size of %" G_GINT64_FORMAT, size);
|
GST_DEBUG_OBJECT (appsrc, "getting size of %" G_GINT64_FORMAT, size);
|
||||||
GST_OBJECT_UNLOCK (appsrc);
|
GST_OBJECT_UNLOCK (appsrc);
|
||||||
|
|
||||||
|
@ -1000,6 +1039,8 @@ gst_app_src_get_size (GstAppSrc * appsrc)
|
||||||
* be connected to.
|
* be connected to.
|
||||||
*
|
*
|
||||||
* A stream_type stream
|
* A stream_type stream
|
||||||
|
*
|
||||||
|
* Since: 0.10.22
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
gst_app_src_set_stream_type (GstAppSrc * appsrc, GstAppStreamType type)
|
gst_app_src_set_stream_type (GstAppSrc * appsrc, GstAppStreamType type)
|
||||||
|
@ -1009,7 +1050,7 @@ gst_app_src_set_stream_type (GstAppSrc * appsrc, GstAppStreamType type)
|
||||||
|
|
||||||
GST_OBJECT_LOCK (appsrc);
|
GST_OBJECT_LOCK (appsrc);
|
||||||
GST_DEBUG_OBJECT (appsrc, "setting stream_type of %d", type);
|
GST_DEBUG_OBJECT (appsrc, "setting stream_type of %d", type);
|
||||||
appsrc->stream_type = type;
|
appsrc->priv->stream_type = type;
|
||||||
GST_OBJECT_UNLOCK (appsrc);
|
GST_OBJECT_UNLOCK (appsrc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1021,6 +1062,8 @@ gst_app_src_set_stream_type (GstAppSrc * appsrc, GstAppStreamType type)
|
||||||
* with gst_app_src_set_stream_type().
|
* with gst_app_src_set_stream_type().
|
||||||
*
|
*
|
||||||
* Returns: the stream type.
|
* Returns: the stream type.
|
||||||
|
*
|
||||||
|
* Since: 0.10.22
|
||||||
*/
|
*/
|
||||||
GstAppStreamType
|
GstAppStreamType
|
||||||
gst_app_src_get_stream_type (GstAppSrc * appsrc)
|
gst_app_src_get_stream_type (GstAppSrc * appsrc)
|
||||||
|
@ -1031,7 +1074,7 @@ gst_app_src_get_stream_type (GstAppSrc * appsrc)
|
||||||
g_return_val_if_fail (GST_IS_APP_SRC (appsrc), FALSE);
|
g_return_val_if_fail (GST_IS_APP_SRC (appsrc), FALSE);
|
||||||
|
|
||||||
GST_OBJECT_LOCK (appsrc);
|
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_DEBUG_OBJECT (appsrc, "getting stream_type of %d", stream_type);
|
||||||
GST_OBJECT_UNLOCK (appsrc);
|
GST_OBJECT_UNLOCK (appsrc);
|
||||||
|
|
||||||
|
@ -1046,20 +1089,22 @@ gst_app_src_get_stream_type (GstAppSrc * appsrc)
|
||||||
* Set the maximum amount of bytes that can be queued in @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
|
* After the maximum amount of bytes are queued, @appsrc will emit the
|
||||||
* "enough-data" signal.
|
* "enough-data" signal.
|
||||||
|
*
|
||||||
|
* Since: 0.10.22
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
gst_app_src_set_max_bytes (GstAppSrc * appsrc, guint64 max)
|
gst_app_src_set_max_bytes (GstAppSrc * appsrc, guint64 max)
|
||||||
{
|
{
|
||||||
g_return_if_fail (GST_IS_APP_SRC (appsrc));
|
g_return_if_fail (GST_IS_APP_SRC (appsrc));
|
||||||
|
|
||||||
g_mutex_lock (appsrc->mutex);
|
g_mutex_lock (appsrc->priv->mutex);
|
||||||
if (max != appsrc->max_bytes) {
|
if (max != appsrc->priv->max_bytes) {
|
||||||
GST_DEBUG_OBJECT (appsrc, "setting max-bytes to %" G_GUINT64_FORMAT, max);
|
GST_DEBUG_OBJECT (appsrc, "setting max-bytes to %" G_GUINT64_FORMAT, max);
|
||||||
appsrc->max_bytes = max;
|
appsrc->priv->max_bytes = max;
|
||||||
/* signal the change */
|
/* 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1069,6 +1114,8 @@ gst_app_src_set_max_bytes (GstAppSrc * appsrc, guint64 max)
|
||||||
* Get the maximum amount of bytes that can be queued in @appsrc.
|
* Get the maximum amount of bytes that can be queued in @appsrc.
|
||||||
*
|
*
|
||||||
* Returns: The maximum amount of bytes that can be queued.
|
* Returns: The maximum amount of bytes that can be queued.
|
||||||
|
*
|
||||||
|
* Since: 0.10.22
|
||||||
*/
|
*/
|
||||||
guint64
|
guint64
|
||||||
gst_app_src_get_max_bytes (GstAppSrc * appsrc)
|
gst_app_src_get_max_bytes (GstAppSrc * appsrc)
|
||||||
|
@ -1077,10 +1124,10 @@ gst_app_src_get_max_bytes (GstAppSrc * appsrc)
|
||||||
|
|
||||||
g_return_val_if_fail (GST_IS_APP_SRC (appsrc), 0);
|
g_return_val_if_fail (GST_IS_APP_SRC (appsrc), 0);
|
||||||
|
|
||||||
g_mutex_lock (appsrc->mutex);
|
g_mutex_lock (appsrc->priv->mutex);
|
||||||
result = appsrc->max_bytes;
|
result = appsrc->priv->max_bytes;
|
||||||
GST_DEBUG_OBJECT (appsrc, "getting max-bytes of %" G_GUINT64_FORMAT, result);
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -1091,16 +1138,16 @@ gst_app_src_set_latencies (GstAppSrc * appsrc, gboolean do_min, guint64 min,
|
||||||
{
|
{
|
||||||
gboolean changed = FALSE;
|
gboolean changed = FALSE;
|
||||||
|
|
||||||
g_mutex_lock (appsrc->mutex);
|
g_mutex_lock (appsrc->priv->mutex);
|
||||||
if (do_min && appsrc->min_latency != min) {
|
if (do_min && appsrc->priv->min_latency != min) {
|
||||||
appsrc->min_latency = min;
|
appsrc->priv->min_latency = min;
|
||||||
changed = TRUE;
|
changed = TRUE;
|
||||||
}
|
}
|
||||||
if (do_max && appsrc->max_latency != max) {
|
if (do_max && appsrc->priv->max_latency != max) {
|
||||||
appsrc->max_latency = max;
|
appsrc->priv->max_latency = max;
|
||||||
changed = TRUE;
|
changed = TRUE;
|
||||||
}
|
}
|
||||||
g_mutex_unlock (appsrc->mutex);
|
g_mutex_unlock (appsrc->priv->mutex);
|
||||||
|
|
||||||
if (changed) {
|
if (changed) {
|
||||||
GST_DEBUG_OBJECT (appsrc, "posting latency changed");
|
GST_DEBUG_OBJECT (appsrc, "posting latency changed");
|
||||||
|
@ -1117,6 +1164,8 @@ gst_app_src_set_latencies (GstAppSrc * appsrc, gboolean do_min, guint64 min,
|
||||||
*
|
*
|
||||||
* Configure the @min and @max latency in @src. If @min is set to -1, the
|
* 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.
|
* default latency calculations for pseudo-live sources will be used.
|
||||||
|
*
|
||||||
|
* Since: 0.10.22
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
gst_app_src_set_latency (GstAppSrc * appsrc, guint64 min, guint64 max)
|
gst_app_src_set_latency (GstAppSrc * appsrc, guint64 min, guint64 max)
|
||||||
|
@ -1131,18 +1180,20 @@ gst_app_src_set_latency (GstAppSrc * appsrc, guint64 min, guint64 max)
|
||||||
* @max: the min latency
|
* @max: the min latency
|
||||||
*
|
*
|
||||||
* Retrieve the min and max latencies in @min and @max respectively.
|
* Retrieve the min and max latencies in @min and @max respectively.
|
||||||
|
*
|
||||||
|
* Since: 0.10.22
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
gst_app_src_get_latency (GstAppSrc * appsrc, guint64 * min, guint64 * max)
|
gst_app_src_get_latency (GstAppSrc * appsrc, guint64 * min, guint64 * max)
|
||||||
{
|
{
|
||||||
g_return_if_fail (GST_IS_APP_SRC (appsrc));
|
g_return_if_fail (GST_IS_APP_SRC (appsrc));
|
||||||
|
|
||||||
g_mutex_lock (appsrc->mutex);
|
g_mutex_lock (appsrc->priv->mutex);
|
||||||
if (min)
|
if (min)
|
||||||
*min = appsrc->min_latency;
|
*min = appsrc->priv->min_latency;
|
||||||
if (max)
|
if (max)
|
||||||
*max = appsrc->max_latency;
|
*max = appsrc->priv->max_latency;
|
||||||
g_mutex_unlock (appsrc->mutex);
|
g_mutex_unlock (appsrc->priv->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
|
@ -1155,37 +1206,39 @@ gst_app_src_push_buffer_full (GstAppSrc * appsrc, GstBuffer * buffer,
|
||||||
g_return_val_if_fail (GST_IS_APP_SRC (appsrc), GST_FLOW_ERROR);
|
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_return_val_if_fail (GST_IS_BUFFER (buffer), GST_FLOW_ERROR);
|
||||||
|
|
||||||
g_mutex_lock (appsrc->mutex);
|
g_mutex_lock (appsrc->priv->mutex);
|
||||||
|
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
/* can't accept buffers when we are flushing or EOS */
|
/* can't accept buffers when we are flushing or EOS */
|
||||||
if (appsrc->flushing)
|
if (appsrc->priv->flushing)
|
||||||
goto flushing;
|
goto flushing;
|
||||||
|
|
||||||
if (appsrc->is_eos)
|
if (appsrc->priv->is_eos)
|
||||||
goto eos;
|
goto eos;
|
||||||
|
|
||||||
if (appsrc->max_bytes && appsrc->queued_bytes >= appsrc->max_bytes) {
|
if (appsrc->priv->max_bytes
|
||||||
GST_DEBUG_OBJECT (appsrc, "queue filled (%" G_GUINT64_FORMAT " >= %"
|
&& appsrc->priv->queued_bytes >= appsrc->priv->max_bytes) {
|
||||||
G_GUINT64_FORMAT ")", appsrc->queued_bytes, appsrc->max_bytes);
|
GST_DEBUG_OBJECT (appsrc,
|
||||||
|
"queue filled (%" G_GUINT64_FORMAT " >= %" G_GUINT64_FORMAT ")",
|
||||||
|
appsrc->priv->queued_bytes, appsrc->priv->max_bytes);
|
||||||
|
|
||||||
if (first) {
|
if (first) {
|
||||||
/* only signal on the first push */
|
/* 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,
|
g_signal_emit (appsrc, gst_app_src_signals[SIGNAL_ENOUGH_DATA], 0,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
g_mutex_lock (appsrc->mutex);
|
g_mutex_lock (appsrc->priv->mutex);
|
||||||
/* continue to check for flushing/eos after releasing the lock */
|
/* continue to check for flushing/eos after releasing the lock */
|
||||||
first = FALSE;
|
first = FALSE;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (appsrc->block) {
|
if (appsrc->priv->block) {
|
||||||
GST_DEBUG_OBJECT (appsrc, "waiting for free space");
|
GST_DEBUG_OBJECT (appsrc, "waiting for free space");
|
||||||
/* we are filled, wait until a buffer gets popped or when we
|
/* we are filled, wait until a buffer gets popped or when we
|
||||||
* flush. */
|
* flush. */
|
||||||
g_cond_wait (appsrc->cond, appsrc->mutex);
|
g_cond_wait (appsrc->priv->cond, appsrc->priv->mutex);
|
||||||
} else {
|
} else {
|
||||||
/* no need to wait for free space, we just pump more data into the
|
/* 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
|
* queue hoping that the caller reacts to the enough-data signal and
|
||||||
|
@ -1199,10 +1252,10 @@ gst_app_src_push_buffer_full (GstAppSrc * appsrc, GstBuffer * buffer,
|
||||||
GST_DEBUG_OBJECT (appsrc, "queueing buffer %p", buffer);
|
GST_DEBUG_OBJECT (appsrc, "queueing buffer %p", buffer);
|
||||||
if (!steal_ref)
|
if (!steal_ref)
|
||||||
gst_buffer_ref (buffer);
|
gst_buffer_ref (buffer);
|
||||||
g_queue_push_tail (appsrc->queue, buffer);
|
g_queue_push_tail (appsrc->priv->queue, buffer);
|
||||||
appsrc->queued_bytes += GST_BUFFER_SIZE (buffer);
|
appsrc->priv->queued_bytes += GST_BUFFER_SIZE (buffer);
|
||||||
g_cond_broadcast (appsrc->cond);
|
g_cond_broadcast (appsrc->priv->cond);
|
||||||
g_mutex_unlock (appsrc->mutex);
|
g_mutex_unlock (appsrc->priv->mutex);
|
||||||
|
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
|
|
||||||
|
@ -1212,7 +1265,7 @@ flushing:
|
||||||
GST_DEBUG_OBJECT (appsrc, "refuse buffer %p, we are flushing", buffer);
|
GST_DEBUG_OBJECT (appsrc, "refuse buffer %p, we are flushing", buffer);
|
||||||
if (steal_ref)
|
if (steal_ref)
|
||||||
gst_buffer_unref (buffer);
|
gst_buffer_unref (buffer);
|
||||||
g_mutex_unlock (appsrc->mutex);
|
g_mutex_unlock (appsrc->priv->mutex);
|
||||||
return GST_FLOW_WRONG_STATE;
|
return GST_FLOW_WRONG_STATE;
|
||||||
}
|
}
|
||||||
eos:
|
eos:
|
||||||
|
@ -1220,7 +1273,7 @@ eos:
|
||||||
GST_DEBUG_OBJECT (appsrc, "refuse buffer %p, we are EOS", buffer);
|
GST_DEBUG_OBJECT (appsrc, "refuse buffer %p, we are EOS", buffer);
|
||||||
if (steal_ref)
|
if (steal_ref)
|
||||||
gst_buffer_unref (buffer);
|
gst_buffer_unref (buffer);
|
||||||
g_mutex_unlock (appsrc->mutex);
|
g_mutex_unlock (appsrc->priv->mutex);
|
||||||
return GST_FLOW_UNEXPECTED;
|
return GST_FLOW_UNEXPECTED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1236,6 +1289,8 @@ eos:
|
||||||
* Returns: #GST_FLOW_OK when the buffer was successfuly queued.
|
* Returns: #GST_FLOW_OK when the buffer was successfuly queued.
|
||||||
* #GST_FLOW_WRONG_STATE when @appsrc is not PAUSED or PLAYING.
|
* #GST_FLOW_WRONG_STATE when @appsrc is not PAUSED or PLAYING.
|
||||||
* #GST_FLOW_UNEXPECTED when EOS occured.
|
* #GST_FLOW_UNEXPECTED when EOS occured.
|
||||||
|
*
|
||||||
|
* Since: 0.10.22
|
||||||
*/
|
*/
|
||||||
GstFlowReturn
|
GstFlowReturn
|
||||||
gst_app_src_push_buffer (GstAppSrc * appsrc, GstBuffer * buffer)
|
gst_app_src_push_buffer (GstAppSrc * appsrc, GstBuffer * buffer)
|
||||||
|
@ -1260,6 +1315,8 @@ gst_app_src_push_buffer_action (GstAppSrc * appsrc, GstBuffer * buffer)
|
||||||
*
|
*
|
||||||
* Returns: #GST_FLOW_OK when the EOS was successfuly queued.
|
* Returns: #GST_FLOW_OK when the EOS was successfuly queued.
|
||||||
* #GST_FLOW_WRONG_STATE when @appsrc is not PAUSED or PLAYING.
|
* #GST_FLOW_WRONG_STATE when @appsrc is not PAUSED or PLAYING.
|
||||||
|
*
|
||||||
|
* Since: 0.10.22
|
||||||
*/
|
*/
|
||||||
GstFlowReturn
|
GstFlowReturn
|
||||||
gst_app_src_end_of_stream (GstAppSrc * appsrc)
|
gst_app_src_end_of_stream (GstAppSrc * appsrc)
|
||||||
|
@ -1267,16 +1324,16 @@ gst_app_src_end_of_stream (GstAppSrc * appsrc)
|
||||||
g_return_val_if_fail (appsrc, GST_FLOW_ERROR);
|
g_return_val_if_fail (appsrc, GST_FLOW_ERROR);
|
||||||
g_return_val_if_fail (GST_IS_APP_SRC (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
|
/* can't accept buffers when we are flushing. We can accept them when we are
|
||||||
* EOS although it will not do anything. */
|
* EOS although it will not do anything. */
|
||||||
if (appsrc->flushing)
|
if (appsrc->priv->flushing)
|
||||||
goto flushing;
|
goto flushing;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (appsrc, "sending EOS");
|
GST_DEBUG_OBJECT (appsrc, "sending EOS");
|
||||||
appsrc->is_eos = TRUE;
|
appsrc->priv->is_eos = TRUE;
|
||||||
g_cond_broadcast (appsrc->cond);
|
g_cond_broadcast (appsrc->priv->cond);
|
||||||
g_mutex_unlock (appsrc->mutex);
|
g_mutex_unlock (appsrc->priv->mutex);
|
||||||
|
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@ G_BEGIN_DECLS
|
||||||
|
|
||||||
typedef struct _GstAppSrc GstAppSrc;
|
typedef struct _GstAppSrc GstAppSrc;
|
||||||
typedef struct _GstAppSrcClass GstAppSrcClass;
|
typedef struct _GstAppSrcClass GstAppSrcClass;
|
||||||
|
typedef struct _GstAppSrcPrivate GstAppSrcPrivate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GstAppStreamType:
|
* GstAppStreamType:
|
||||||
|
@ -62,26 +63,10 @@ struct _GstAppSrc
|
||||||
GstBaseSrc basesrc;
|
GstBaseSrc basesrc;
|
||||||
|
|
||||||
/*< private >*/
|
/*< private >*/
|
||||||
GCond *cond;
|
GstAppSrcPrivate *priv;
|
||||||
GMutex *mutex;
|
|
||||||
GQueue *queue;
|
|
||||||
|
|
||||||
GstCaps *caps;
|
/*< private >*/
|
||||||
gint64 size;
|
gpointer _gst_reserved[GST_PADDING];
|
||||||
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;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstAppSrcClass
|
struct _GstAppSrcClass
|
||||||
|
@ -96,6 +81,9 @@ struct _GstAppSrcClass
|
||||||
/* actions */
|
/* actions */
|
||||||
GstFlowReturn (*push_buffer) (GstAppSrc *src, GstBuffer *buffer);
|
GstFlowReturn (*push_buffer) (GstAppSrc *src, GstBuffer *buffer);
|
||||||
GstFlowReturn (*end_of_stream) (GstAppSrc *src);
|
GstFlowReturn (*end_of_stream) (GstAppSrc *src);
|
||||||
|
|
||||||
|
/*< private >*/
|
||||||
|
gpointer _gst_reserved[GST_PADDING];
|
||||||
};
|
};
|
||||||
|
|
||||||
GType gst_app_src_get_type(void);
|
GType gst_app_src_get_type(void);
|
||||||
|
|
Loading…
Reference in a new issue