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>
|
||||
|
||||
* tests/examples/app/appsrc_ex.c: (main):
|
||||
|
|
|
@ -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)
|
||||
* Since: 0.10.22
|
||||
*
|
||||
* 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 @@ gst_app_sink_class_init (GstAppSinkClass * klass)
|
|||
|
||||
klass->pull_preroll = gst_app_sink_pull_preroll;
|
||||
klass->pull_buffer = gst_app_sink_pull_buffer;
|
||||
|
||||
g_type_class_add_private (klass, sizeof (GstAppSinkPrivate));
|
||||
}
|
||||
|
||||
static void
|
||||
gst_app_sink_init (GstAppSink * appsink, GstAppSinkClass * klass)
|
||||
{
|
||||
appsink->mutex = g_mutex_new ();
|
||||
appsink->cond = g_cond_new ();
|
||||
appsink->queue = g_queue_new ();
|
||||
appsink->priv = G_TYPE_INSTANCE_GET_PRIVATE (appsink, GST_TYPE_APP_SINK,
|
||||
GstAppSinkPrivate);
|
||||
|
||||
appsink->emit_signals = DEFAULT_PROP_EMIT_SIGNALS;
|
||||
appsink->max_buffers = DEFAULT_PROP_MAX_BUFFERS;
|
||||
appsink->drop = DEFAULT_PROP_DROP;
|
||||
appsink->priv->mutex = g_mutex_new ();
|
||||
appsink->priv->cond = g_cond_new ();
|
||||
appsink->priv->queue = g_queue_new ();
|
||||
|
||||
appsink->priv->emit_signals = DEFAULT_PROP_EMIT_SIGNALS;
|
||||
appsink->priv->max_buffers = DEFAULT_PROP_MAX_BUFFERS;
|
||||
appsink->priv->drop = DEFAULT_PROP_DROP;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -377,20 +400,20 @@ gst_app_sink_dispose (GObject * obj)
|
|||
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 @@ gst_app_sink_finalize (GObject * obj)
|
|||
{
|
||||
GstAppSink *appsink = GST_APP_SINK (obj);
|
||||
|
||||
g_mutex_free (appsink->mutex);
|
||||
g_cond_free (appsink->cond);
|
||||
g_queue_free (appsink->queue);
|
||||
g_mutex_free (appsink->priv->mutex);
|
||||
g_cond_free (appsink->priv->cond);
|
||||
g_queue_free (appsink->priv->queue);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (obj);
|
||||
}
|
||||
|
@ -472,11 +495,11 @@ gst_app_sink_unlock_start (GstBaseSink * bsink)
|
|||
{
|
||||
GstAppSink *appsink = GST_APP_SINK (bsink);
|
||||
|
||||
g_mutex_lock (appsink->mutex);
|
||||
g_mutex_lock (appsink->priv->mutex);
|
||||
GST_DEBUG_OBJECT (appsink, "unlock start");
|
||||
appsink->flushing = TRUE;
|
||||
g_cond_signal (appsink->cond);
|
||||
g_mutex_unlock (appsink->mutex);
|
||||
appsink->priv->flushing = TRUE;
|
||||
g_cond_signal (appsink->priv->cond);
|
||||
g_mutex_unlock (appsink->priv->mutex);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -486,11 +509,11 @@ gst_app_sink_unlock_stop (GstBaseSink * bsink)
|
|||
{
|
||||
GstAppSink *appsink = GST_APP_SINK (bsink);
|
||||
|
||||
g_mutex_lock (appsink->mutex);
|
||||
g_mutex_lock (appsink->priv->mutex);
|
||||
GST_DEBUG_OBJECT (appsink, "unlock stop");
|
||||
appsink->flushing = FALSE;
|
||||
g_cond_signal (appsink->cond);
|
||||
g_mutex_unlock (appsink->mutex);
|
||||
appsink->priv->flushing = FALSE;
|
||||
g_cond_signal (appsink->priv->cond);
|
||||
g_mutex_unlock (appsink->priv->mutex);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -501,11 +524,11 @@ gst_app_sink_flush_unlocked (GstAppSink * appsink)
|
|||
GstBuffer *buffer;
|
||||
|
||||
GST_DEBUG_OBJECT (appsink, "flush stop appsink");
|
||||
appsink->is_eos = FALSE;
|
||||
gst_buffer_replace (&appsink->preroll, NULL);
|
||||
while ((buffer = g_queue_pop_head (appsink->queue)))
|
||||
appsink->priv->is_eos = FALSE;
|
||||
gst_buffer_replace (&appsink->priv->preroll, NULL);
|
||||
while ((buffer = g_queue_pop_head (appsink->priv->queue)))
|
||||
gst_buffer_unref (buffer);
|
||||
g_cond_signal (appsink->cond);
|
||||
g_cond_signal (appsink->priv->cond);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -513,10 +536,10 @@ gst_app_sink_start (GstBaseSink * psink)
|
|||
{
|
||||
GstAppSink *appsink = GST_APP_SINK (psink);
|
||||
|
||||
g_mutex_lock (appsink->mutex);
|
||||
g_mutex_lock (appsink->priv->mutex);
|
||||
GST_DEBUG_OBJECT (appsink, "starting");
|
||||
appsink->started = TRUE;
|
||||
g_mutex_unlock (appsink->mutex);
|
||||
appsink->priv->started = TRUE;
|
||||
g_mutex_unlock (appsink->priv->mutex);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -526,12 +549,12 @@ gst_app_sink_stop (GstBaseSink * psink)
|
|||
{
|
||||
GstAppSink *appsink = GST_APP_SINK (psink);
|
||||
|
||||
g_mutex_lock (appsink->mutex);
|
||||
g_mutex_lock (appsink->priv->mutex);
|
||||
GST_DEBUG_OBJECT (appsink, "stopping");
|
||||
appsink->flushing = TRUE;
|
||||
appsink->started = FALSE;
|
||||
appsink->priv->flushing = TRUE;
|
||||
appsink->priv->started = FALSE;
|
||||
gst_app_sink_flush_unlocked (appsink);
|
||||
g_mutex_unlock (appsink->mutex);
|
||||
g_mutex_unlock (appsink->priv->mutex);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -544,11 +567,11 @@ gst_app_sink_event (GstBaseSink * sink, GstEvent * event)
|
|||
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_app_sink_event (GstBaseSink * sink, GstEvent * event)
|
|||
GST_DEBUG_OBJECT (appsink, "received FLUSH_START");
|
||||
break;
|
||||
case GST_EVENT_FLUSH_STOP:
|
||||
g_mutex_lock (appsink->mutex);
|
||||
g_mutex_lock (appsink->priv->mutex);
|
||||
GST_DEBUG_OBJECT (appsink, "received FLUSH_STOP");
|
||||
gst_app_sink_flush_unlocked (appsink);
|
||||
g_mutex_unlock (appsink->mutex);
|
||||
g_mutex_unlock (appsink->priv->mutex);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -576,15 +599,15 @@ gst_app_sink_preroll (GstBaseSink * psink, GstBuffer * buffer)
|
|||
GstAppSink *appsink = GST_APP_SINK (psink);
|
||||
gboolean emit;
|
||||
|
||||
g_mutex_lock (appsink->mutex);
|
||||
if (appsink->flushing)
|
||||
g_mutex_lock (appsink->priv->mutex);
|
||||
if (appsink->priv->flushing)
|
||||
goto flushing;
|
||||
|
||||
GST_DEBUG_OBJECT (appsink, "setting preroll buffer %p", buffer);
|
||||
gst_buffer_replace (&appsink->preroll, buffer);
|
||||
g_cond_signal (appsink->cond);
|
||||
emit = appsink->emit_signals;
|
||||
g_mutex_unlock (appsink->mutex);
|
||||
gst_buffer_replace (&appsink->priv->preroll, buffer);
|
||||
g_cond_signal (appsink->priv->cond);
|
||||
emit = appsink->priv->emit_signals;
|
||||
g_mutex_unlock (appsink->priv->mutex);
|
||||
|
||||
if (emit)
|
||||
g_signal_emit (appsink, gst_app_sink_signals[SIGNAL_NEW_PREROLL], 0);
|
||||
|
@ -594,7 +617,7 @@ gst_app_sink_preroll (GstBaseSink * psink, GstBuffer * buffer)
|
|||
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_app_sink_render (GstBaseSink * psink, GstBuffer * buffer)
|
|||
GstAppSink *appsink = GST_APP_SINK (psink);
|
||||
gboolean emit;
|
||||
|
||||
g_mutex_lock (appsink->mutex);
|
||||
if (appsink->flushing)
|
||||
g_mutex_lock (appsink->priv->mutex);
|
||||
if (appsink->priv->flushing)
|
||||
goto flushing;
|
||||
|
||||
GST_DEBUG_OBJECT (appsink, "pushing render buffer %p on queue (%d)",
|
||||
buffer, appsink->queue->length);
|
||||
buffer, appsink->priv->queue->length);
|
||||
|
||||
while (appsink->max_buffers > 0 &&
|
||||
appsink->queue->length >= appsink->max_buffers) {
|
||||
if (appsink->drop) {
|
||||
while (appsink->priv->max_buffers > 0 &&
|
||||
appsink->priv->queue->length >= appsink->priv->max_buffers) {
|
||||
if (appsink->priv->drop) {
|
||||
GstBuffer *buf;
|
||||
|
||||
/* we need to drop the oldest buffer and try again */
|
||||
buf = g_queue_pop_head (appsink->queue);
|
||||
buf = g_queue_pop_head (appsink->priv->queue);
|
||||
GST_DEBUG_OBJECT (appsink, "dropping old buffer %p", buf);
|
||||
gst_buffer_unref (buf);
|
||||
} else {
|
||||
GST_DEBUG_OBJECT (appsink, "waiting for free space, length %d >= %d",
|
||||
appsink->queue->length, appsink->max_buffers);
|
||||
appsink->priv->queue->length, appsink->priv->max_buffers);
|
||||
/* wait for a buffer to be removed or flush */
|
||||
g_cond_wait (appsink->cond, appsink->mutex);
|
||||
if (appsink->flushing)
|
||||
g_cond_wait (appsink->priv->cond, appsink->priv->mutex);
|
||||
if (appsink->priv->flushing)
|
||||
goto flushing;
|
||||
}
|
||||
}
|
||||
/* we need to ref the buffer when pushing it in the queue */
|
||||
g_queue_push_tail (appsink->queue, gst_buffer_ref (buffer));
|
||||
g_cond_signal (appsink->cond);
|
||||
emit = appsink->emit_signals;
|
||||
g_mutex_unlock (appsink->mutex);
|
||||
g_queue_push_tail (appsink->priv->queue, gst_buffer_ref (buffer));
|
||||
g_cond_signal (appsink->priv->cond);
|
||||
emit = appsink->priv->emit_signals;
|
||||
g_mutex_unlock (appsink->priv->mutex);
|
||||
|
||||
if (emit)
|
||||
g_signal_emit (appsink, gst_app_sink_signals[SIGNAL_NEW_BUFFER], 0);
|
||||
|
@ -644,7 +667,7 @@ gst_app_sink_render (GstBaseSink * psink, GstBuffer * buffer)
|
|||
flushing:
|
||||
{
|
||||
GST_DEBUG_OBJECT (appsink, "we are flushing");
|
||||
g_mutex_unlock (appsink->mutex);
|
||||
g_mutex_unlock (appsink->priv->mutex);
|
||||
return GST_FLOW_WRONG_STATE;
|
||||
}
|
||||
}
|
||||
|
@ -657,7 +680,7 @@ gst_app_sink_getcaps (GstBaseSink * psink)
|
|||
GstAppSink *appsink = GST_APP_SINK (psink);
|
||||
|
||||
GST_OBJECT_LOCK (appsink);
|
||||
if ((caps = appsink->caps))
|
||||
if ((caps = appsink->priv->caps))
|
||||
gst_caps_ref (caps);
|
||||
GST_DEBUG_OBJECT (appsink, "got caps %" GST_PTR_FORMAT, caps);
|
||||
GST_OBJECT_UNLOCK (appsink);
|
||||
|
@ -676,6 +699,8 @@ gst_app_sink_getcaps (GstBaseSink * psink)
|
|||
* a copy of the caps structure. After calling this method, the sink will only
|
||||
* accept caps that match @caps. If @caps is non-fixed, you must check the caps
|
||||
* on the buffers to get the actual used caps.
|
||||
*
|
||||
* Since: 0.10.22
|
||||
*/
|
||||
void
|
||||
gst_app_sink_set_caps (GstAppSink * appsink, const GstCaps * caps)
|
||||
|
@ -687,11 +712,11 @@ gst_app_sink_set_caps (GstAppSink * appsink, const GstCaps * caps)
|
|||
|
||||
GST_OBJECT_LOCK (appsink);
|
||||
GST_DEBUG_OBJECT (appsink, "setting caps to %" GST_PTR_FORMAT, caps);
|
||||
if ((old = appsink->caps) != caps) {
|
||||
if ((old = appsink->priv->caps) != caps) {
|
||||
if (caps)
|
||||
appsink->caps = gst_caps_copy (caps);
|
||||
appsink->priv->caps = gst_caps_copy (caps);
|
||||
else
|
||||
appsink->caps = NULL;
|
||||
appsink->priv->caps = NULL;
|
||||
if (old)
|
||||
gst_caps_unref (old);
|
||||
}
|
||||
|
@ -705,6 +730,8 @@ gst_app_sink_set_caps (GstAppSink * appsink, const GstCaps * caps)
|
|||
* Get the configured caps on @appsink.
|
||||
*
|
||||
* Returns: the #GstCaps accepted by the sink. gst_caps_unref() after usage.
|
||||
*
|
||||
* Since: 0.10.22
|
||||
*/
|
||||
GstCaps *
|
||||
gst_app_sink_get_caps (GstAppSink * appsink)
|
||||
|
@ -715,7 +742,7 @@ gst_app_sink_get_caps (GstAppSink * appsink)
|
|||
g_return_val_if_fail (GST_IS_APP_SINK (appsink), NULL);
|
||||
|
||||
GST_OBJECT_LOCK (appsink);
|
||||
if ((caps = appsink->caps))
|
||||
if ((caps = appsink->priv->caps))
|
||||
gst_caps_ref (caps);
|
||||
GST_DEBUG_OBJECT (appsink, "getting caps of %" GST_PTR_FORMAT, caps);
|
||||
GST_OBJECT_UNLOCK (appsink);
|
||||
|
@ -734,6 +761,8 @@ gst_app_sink_get_caps (GstAppSink * appsink)
|
|||
* PLAYING state.
|
||||
*
|
||||
* Returns: %TRUE if no more buffers can be pulled and the appsink is EOS.
|
||||
*
|
||||
* Since: 0.10.22
|
||||
*/
|
||||
gboolean
|
||||
gst_app_sink_is_eos (GstAppSink * appsink)
|
||||
|
@ -743,25 +772,25 @@ gst_app_sink_is_eos (GstAppSink * appsink)
|
|||
g_return_val_if_fail (appsink != NULL, FALSE);
|
||||
g_return_val_if_fail (GST_IS_APP_SINK (appsink), FALSE);
|
||||
|
||||
g_mutex_lock (appsink->mutex);
|
||||
if (!appsink->started)
|
||||
g_mutex_lock (appsink->priv->mutex);
|
||||
if (!appsink->priv->started)
|
||||
goto not_started;
|
||||
|
||||
if (appsink->is_eos && g_queue_is_empty (appsink->queue)) {
|
||||
if (appsink->priv->is_eos && g_queue_is_empty (appsink->priv->queue)) {
|
||||
GST_DEBUG_OBJECT (appsink, "we are EOS and the queue is empty");
|
||||
ret = TRUE;
|
||||
} else {
|
||||
GST_DEBUG_OBJECT (appsink, "we are not yet EOS");
|
||||
ret = FALSE;
|
||||
}
|
||||
g_mutex_unlock (appsink->mutex);
|
||||
g_mutex_unlock (appsink->priv->mutex);
|
||||
|
||||
return ret;
|
||||
|
||||
not_started:
|
||||
{
|
||||
GST_DEBUG_OBJECT (appsink, "we are stopped, return TRUE");
|
||||
g_mutex_unlock (appsink->mutex);
|
||||
g_mutex_unlock (appsink->priv->mutex);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
@ -774,15 +803,17 @@ not_started:
|
|||
* Make appsink emit the "new-preroll" and "new-buffer" signals. This option is
|
||||
* by default disabled because signal emission is expensive and unneeded when
|
||||
* the application prefers to operate in pull mode.
|
||||
*
|
||||
* Since: 0.10.22
|
||||
*/
|
||||
void
|
||||
gst_app_sink_set_emit_signals (GstAppSink * appsink, gboolean emit)
|
||||
{
|
||||
g_return_if_fail (GST_IS_APP_SINK (appsink));
|
||||
|
||||
g_mutex_lock (appsink->mutex);
|
||||
appsink->emit_signals = emit;
|
||||
g_mutex_unlock (appsink->mutex);
|
||||
g_mutex_lock (appsink->priv->mutex);
|
||||
appsink->priv->emit_signals = emit;
|
||||
g_mutex_unlock (appsink->priv->mutex);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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"
|
||||
* signals.
|
||||
*
|
||||
* Since: 0.10.22
|
||||
*/
|
||||
gboolean
|
||||
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_mutex_lock (appsink->mutex);
|
||||
result = appsink->emit_signals;
|
||||
g_mutex_unlock (appsink->mutex);
|
||||
g_mutex_lock (appsink->priv->mutex);
|
||||
result = appsink->priv->emit_signals;
|
||||
g_mutex_unlock (appsink->priv->mutex);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -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
|
||||
* amount of buffers are queued in appsink, any more buffers will block upstream
|
||||
* elements until a buffer is pulled from @appsink.
|
||||
*
|
||||
* Since: 0.10.22
|
||||
*/
|
||||
void
|
||||
gst_app_sink_set_max_buffers (GstAppSink * appsink, guint max)
|
||||
{
|
||||
g_return_if_fail (GST_IS_APP_SINK (appsink));
|
||||
|
||||
g_mutex_lock (appsink->mutex);
|
||||
if (max != appsink->max_buffers) {
|
||||
appsink->max_buffers = max;
|
||||
g_mutex_lock (appsink->priv->mutex);
|
||||
if (max != appsink->priv->max_buffers) {
|
||||
appsink->priv->max_buffers = max;
|
||||
/* signal the change */
|
||||
g_cond_signal (appsink->cond);
|
||||
g_cond_signal (appsink->priv->cond);
|
||||
}
|
||||
g_mutex_unlock (appsink->mutex);
|
||||
g_mutex_unlock (appsink->priv->mutex);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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.
|
||||
*
|
||||
* Returns: The maximum amount of buffers that can be queued.
|
||||
*
|
||||
* Since: 0.10.22
|
||||
*/
|
||||
guint
|
||||
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_mutex_lock (appsink->mutex);
|
||||
result = appsink->max_buffers;
|
||||
g_mutex_unlock (appsink->mutex);
|
||||
g_mutex_lock (appsink->priv->mutex);
|
||||
result = appsink->priv->max_buffers;
|
||||
g_mutex_unlock (appsink->priv->mutex);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -860,19 +897,21 @@ gst_app_sink_get_max_buffers (GstAppSink * appsink)
|
|||
*
|
||||
* Instruct @appsink to drop old buffers when the maximum amount of queued
|
||||
* buffers is reached.
|
||||
*
|
||||
* Since: 0.10.22
|
||||
*/
|
||||
void
|
||||
gst_app_sink_set_drop (GstAppSink * appsink, gboolean drop)
|
||||
{
|
||||
g_return_if_fail (GST_IS_APP_SINK (appsink));
|
||||
|
||||
g_mutex_lock (appsink->mutex);
|
||||
if (appsink->drop != drop) {
|
||||
appsink->drop = drop;
|
||||
g_mutex_lock (appsink->priv->mutex);
|
||||
if (appsink->priv->drop != drop) {
|
||||
appsink->priv->drop = drop;
|
||||
/* signal the change */
|
||||
g_cond_signal (appsink->cond);
|
||||
g_cond_signal (appsink->priv->cond);
|
||||
}
|
||||
g_mutex_unlock (appsink->mutex);
|
||||
g_mutex_unlock (appsink->priv->mutex);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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
|
||||
* filled.
|
||||
*
|
||||
* Since: 0.10.22
|
||||
*/
|
||||
gboolean
|
||||
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_mutex_lock (appsink->mutex);
|
||||
result = appsink->drop;
|
||||
g_mutex_unlock (appsink->mutex);
|
||||
g_mutex_lock (appsink->priv->mutex);
|
||||
result = appsink->priv->drop;
|
||||
g_mutex_unlock (appsink->priv->mutex);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -921,6 +962,8 @@ gst_app_sink_get_drop (GstAppSink * appsink)
|
|||
* element is set to the READY/NULL state.
|
||||
*
|
||||
* Returns: a #GstBuffer or NULL when the appsink is stopped or EOS.
|
||||
*
|
||||
* Since: 0.10.22
|
||||
*/
|
||||
GstBuffer *
|
||||
gst_app_sink_pull_preroll (GstAppSink * appsink)
|
||||
|
@ -930,26 +973,26 @@ gst_app_sink_pull_preroll (GstAppSink * appsink)
|
|||
g_return_val_if_fail (appsink != NULL, NULL);
|
||||
g_return_val_if_fail (GST_IS_APP_SINK (appsink), NULL);
|
||||
|
||||
g_mutex_lock (appsink->mutex);
|
||||
g_mutex_lock (appsink->priv->mutex);
|
||||
|
||||
while (TRUE) {
|
||||
GST_DEBUG_OBJECT (appsink, "trying to grab a buffer");
|
||||
if (!appsink->started)
|
||||
if (!appsink->priv->started)
|
||||
goto not_started;
|
||||
|
||||
if (appsink->preroll != NULL)
|
||||
if (appsink->priv->preroll != NULL)
|
||||
break;
|
||||
|
||||
if (appsink->is_eos)
|
||||
if (appsink->priv->is_eos)
|
||||
goto eos;
|
||||
|
||||
/* nothing to return, wait */
|
||||
GST_DEBUG_OBJECT (appsink, "waiting for the preroll buffer");
|
||||
g_cond_wait (appsink->cond, appsink->mutex);
|
||||
g_cond_wait (appsink->priv->cond, appsink->priv->mutex);
|
||||
}
|
||||
buf = gst_buffer_ref (appsink->preroll);
|
||||
buf = gst_buffer_ref (appsink->priv->preroll);
|
||||
GST_DEBUG_OBJECT (appsink, "we have the preroll buffer %p", buf);
|
||||
g_mutex_unlock (appsink->mutex);
|
||||
g_mutex_unlock (appsink->priv->mutex);
|
||||
|
||||
return buf;
|
||||
|
||||
|
@ -957,13 +1000,13 @@ gst_app_sink_pull_preroll (GstAppSink * appsink)
|
|||
eos:
|
||||
{
|
||||
GST_DEBUG_OBJECT (appsink, "we are EOS, return NULL");
|
||||
g_mutex_unlock (appsink->mutex);
|
||||
g_mutex_unlock (appsink->priv->mutex);
|
||||
return NULL;
|
||||
}
|
||||
not_started:
|
||||
{
|
||||
GST_DEBUG_OBJECT (appsink, "we are stopped, return NULL");
|
||||
g_mutex_unlock (appsink->mutex);
|
||||
g_mutex_unlock (appsink->priv->mutex);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
@ -985,6 +1028,8 @@ not_started:
|
|||
* %NULL. Use gst_app_sink_is_eos () to check for the EOS condition.
|
||||
*
|
||||
* Returns: a #GstBuffer or NULL when the appsink is stopped or EOS.
|
||||
*
|
||||
* Since: 0.10.22
|
||||
*/
|
||||
GstBuffer *
|
||||
gst_app_sink_pull_buffer (GstAppSink * appsink)
|
||||
|
@ -994,27 +1039,27 @@ gst_app_sink_pull_buffer (GstAppSink * appsink)
|
|||
g_return_val_if_fail (appsink != NULL, NULL);
|
||||
g_return_val_if_fail (GST_IS_APP_SINK (appsink), NULL);
|
||||
|
||||
g_mutex_lock (appsink->mutex);
|
||||
g_mutex_lock (appsink->priv->mutex);
|
||||
|
||||
while (TRUE) {
|
||||
GST_DEBUG_OBJECT (appsink, "trying to grab a buffer");
|
||||
if (!appsink->started)
|
||||
if (!appsink->priv->started)
|
||||
goto not_started;
|
||||
|
||||
if (!g_queue_is_empty (appsink->queue))
|
||||
if (!g_queue_is_empty (appsink->priv->queue))
|
||||
break;
|
||||
|
||||
if (appsink->is_eos)
|
||||
if (appsink->priv->is_eos)
|
||||
goto eos;
|
||||
|
||||
/* nothing to return, wait */
|
||||
GST_DEBUG_OBJECT (appsink, "waiting for a buffer");
|
||||
g_cond_wait (appsink->cond, appsink->mutex);
|
||||
g_cond_wait (appsink->priv->cond, appsink->priv->mutex);
|
||||
}
|
||||
buf = g_queue_pop_head (appsink->queue);
|
||||
buf = g_queue_pop_head (appsink->priv->queue);
|
||||
GST_DEBUG_OBJECT (appsink, "we have a buffer %p", buf);
|
||||
g_cond_signal (appsink->cond);
|
||||
g_mutex_unlock (appsink->mutex);
|
||||
g_cond_signal (appsink->priv->cond);
|
||||
g_mutex_unlock (appsink->priv->mutex);
|
||||
|
||||
return buf;
|
||||
|
||||
|
@ -1022,13 +1067,13 @@ gst_app_sink_pull_buffer (GstAppSink * appsink)
|
|||
eos:
|
||||
{
|
||||
GST_DEBUG_OBJECT (appsink, "we are EOS, return NULL");
|
||||
g_mutex_unlock (appsink->mutex);
|
||||
g_mutex_unlock (appsink->priv->mutex);
|
||||
return NULL;
|
||||
}
|
||||
not_started:
|
||||
{
|
||||
GST_DEBUG_OBJECT (appsink, "we are stopped, return NULL");
|
||||
g_mutex_unlock (appsink->mutex);
|
||||
g_mutex_unlock (appsink->priv->mutex);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,24 +38,17 @@ G_BEGIN_DECLS
|
|||
|
||||
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 @@ struct _GstAppSinkClass
|
|||
/* actions */
|
||||
GstBuffer * (*pull_preroll) (GstAppSink *sink);
|
||||
GstBuffer * (*pull_buffer) (GstAppSink *sink);
|
||||
|
||||
/*< private >*/
|
||||
gpointer _gst_reserved[GST_PADDING];
|
||||
};
|
||||
|
||||
GType gst_app_sink_get_type(void);
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
* <link linkend="gst-plugins-base-libs-appsrc">libgstapp</link> section in the
|
||||
* GStreamer Plugins Base Libraries documentation.
|
||||
*
|
||||
* Since: 0.10.22
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -96,6 +97,8 @@
|
|||
* this call, no more buffers can be pushed into appsrc until a flushing seek
|
||||
* happened or the state of the appsrc has gone through READY.
|
||||
*
|
||||
* Since: 0.10.22
|
||||
*
|
||||
* Last reviewed on 2008-12-17 (0.10.10)
|
||||
*/
|
||||
|
||||
|
@ -111,6 +114,29 @@
|
|||
#include "gstapp-marshal.h"
|
||||
#include "gstappsrc.h"
|
||||
|
||||
struct _GstAppSrcPrivate
|
||||
{
|
||||
GCond *cond;
|
||||
GMutex *mutex;
|
||||
GQueue *queue;
|
||||
|
||||
GstCaps *caps;
|
||||
gint64 size;
|
||||
GstAppStreamType stream_type;
|
||||
guint64 max_bytes;
|
||||
GstFormat format;
|
||||
gboolean block;
|
||||
|
||||
gboolean flushing;
|
||||
gboolean started;
|
||||
gboolean is_eos;
|
||||
guint64 queued_bytes;
|
||||
guint64 offset;
|
||||
GstAppStreamType current_type;
|
||||
|
||||
guint64 min_latency;
|
||||
guint64 max_latency;
|
||||
};
|
||||
|
||||
GST_DEBUG_CATEGORY (app_src_debug);
|
||||
#define GST_CAT_DEFAULT app_src_debug
|
||||
|
@ -446,22 +472,27 @@ gst_app_src_class_init (GstAppSrcClass * klass)
|
|||
|
||||
klass->push_buffer = gst_app_src_push_buffer_action;
|
||||
klass->end_of_stream = gst_app_src_end_of_stream;
|
||||
|
||||
g_type_class_add_private (klass, sizeof (GstAppSrcPrivate));
|
||||
}
|
||||
|
||||
static void
|
||||
gst_app_src_init (GstAppSrc * appsrc, GstAppSrcClass * klass)
|
||||
{
|
||||
appsrc->mutex = g_mutex_new ();
|
||||
appsrc->cond = g_cond_new ();
|
||||
appsrc->queue = g_queue_new ();
|
||||
appsrc->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 @@ gst_app_src_flush_queued (GstAppSrc * src)
|
|||
{
|
||||
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 @@ gst_app_src_dispose (GObject * obj)
|
|||
{
|
||||
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 @@ gst_app_src_finalize (GObject * obj)
|
|||
{
|
||||
GstAppSrc *appsrc = GST_APP_SRC (obj);
|
||||
|
||||
g_mutex_free (appsrc->mutex);
|
||||
g_cond_free (appsrc->cond);
|
||||
g_queue_free (appsrc->queue);
|
||||
g_mutex_free (appsrc->priv->mutex);
|
||||
g_cond_free (appsrc->priv->cond);
|
||||
g_queue_free (appsrc->priv->queue);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (obj);
|
||||
}
|
||||
|
@ -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));
|
||||
break;
|
||||
case PROP_FORMAT:
|
||||
appsrc->format = g_value_get_enum (value);
|
||||
appsrc->priv->format = g_value_get_enum (value);
|
||||
break;
|
||||
case PROP_BLOCK:
|
||||
appsrc->block = g_value_get_boolean (value);
|
||||
appsrc->priv->block = g_value_get_boolean (value);
|
||||
break;
|
||||
case PROP_IS_LIVE:
|
||||
gst_base_src_set_live (GST_BASE_SRC (appsrc),
|
||||
|
@ -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));
|
||||
break;
|
||||
case PROP_FORMAT:
|
||||
g_value_set_enum (value, appsrc->format);
|
||||
g_value_set_enum (value, appsrc->priv->format);
|
||||
break;
|
||||
case PROP_BLOCK:
|
||||
g_value_set_boolean (value, appsrc->block);
|
||||
g_value_set_boolean (value, appsrc->priv->block);
|
||||
break;
|
||||
case PROP_IS_LIVE:
|
||||
g_value_set_boolean (value, gst_base_src_is_live (GST_BASE_SRC (appsrc)));
|
||||
|
@ -607,11 +638,11 @@ gst_app_src_unlock (GstBaseSrc * bsrc)
|
|||
{
|
||||
GstAppSrc *appsrc = GST_APP_SRC (bsrc);
|
||||
|
||||
g_mutex_lock (appsrc->mutex);
|
||||
g_mutex_lock (appsrc->priv->mutex);
|
||||
GST_DEBUG_OBJECT (appsrc, "unlock start");
|
||||
appsrc->flushing = TRUE;
|
||||
g_cond_broadcast (appsrc->cond);
|
||||
g_mutex_unlock (appsrc->mutex);
|
||||
appsrc->priv->flushing = TRUE;
|
||||
g_cond_broadcast (appsrc->priv->cond);
|
||||
g_mutex_unlock (appsrc->priv->mutex);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -621,11 +652,11 @@ gst_app_src_unlock_stop (GstBaseSrc * bsrc)
|
|||
{
|
||||
GstAppSrc *appsrc = GST_APP_SRC (bsrc);
|
||||
|
||||
g_mutex_lock (appsrc->mutex);
|
||||
g_mutex_lock (appsrc->priv->mutex);
|
||||
GST_DEBUG_OBJECT (appsrc, "unlock stop");
|
||||
appsrc->flushing = FALSE;
|
||||
g_cond_broadcast (appsrc->cond);
|
||||
g_mutex_unlock (appsrc->mutex);
|
||||
appsrc->priv->flushing = FALSE;
|
||||
g_cond_broadcast (appsrc->priv->cond);
|
||||
g_mutex_unlock (appsrc->priv->mutex);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -635,16 +666,16 @@ gst_app_src_start (GstBaseSrc * bsrc)
|
|||
{
|
||||
GstAppSrc *appsrc = GST_APP_SRC (bsrc);
|
||||
|
||||
g_mutex_lock (appsrc->mutex);
|
||||
g_mutex_lock (appsrc->priv->mutex);
|
||||
GST_DEBUG_OBJECT (appsrc, "starting");
|
||||
appsrc->started = TRUE;
|
||||
appsrc->priv->started = TRUE;
|
||||
/* set the offset to -1 so that we always do a first seek. This is only used
|
||||
* in random-access mode. */
|
||||
appsrc->offset = -1;
|
||||
appsrc->flushing = FALSE;
|
||||
g_mutex_unlock (appsrc->mutex);
|
||||
appsrc->priv->offset = -1;
|
||||
appsrc->priv->flushing = FALSE;
|
||||
g_mutex_unlock (appsrc->priv->mutex);
|
||||
|
||||
gst_base_src_set_format (bsrc, appsrc->format);
|
||||
gst_base_src_set_format (bsrc, appsrc->priv->format);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -654,13 +685,13 @@ gst_app_src_stop (GstBaseSrc * bsrc)
|
|||
{
|
||||
GstAppSrc *appsrc = GST_APP_SRC (bsrc);
|
||||
|
||||
g_mutex_lock (appsrc->mutex);
|
||||
g_mutex_lock (appsrc->priv->mutex);
|
||||
GST_DEBUG_OBJECT (appsrc, "stopping");
|
||||
appsrc->is_eos = FALSE;
|
||||
appsrc->flushing = TRUE;
|
||||
appsrc->started = FALSE;
|
||||
appsrc->priv->is_eos = FALSE;
|
||||
appsrc->priv->flushing = TRUE;
|
||||
appsrc->priv->started = FALSE;
|
||||
gst_app_src_flush_queued (appsrc);
|
||||
g_mutex_unlock (appsrc->mutex);
|
||||
g_mutex_unlock (appsrc->priv->mutex);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -671,7 +702,7 @@ gst_app_src_is_seekable (GstBaseSrc * src)
|
|||
GstAppSrc *appsrc = GST_APP_SRC (src);
|
||||
gboolean res = FALSE;
|
||||
|
||||
switch (appsrc->stream_type) {
|
||||
switch (appsrc->priv->stream_type) {
|
||||
case GST_APP_STREAM_TYPE_STREAM:
|
||||
break;
|
||||
case GST_APP_STREAM_TYPE_SEEKABLE:
|
||||
|
@ -688,7 +719,7 @@ gst_app_src_check_get_range (GstBaseSrc * src)
|
|||
GstAppSrc *appsrc = GST_APP_SRC (src);
|
||||
gboolean res = FALSE;
|
||||
|
||||
switch (appsrc->stream_type) {
|
||||
switch (appsrc->priv->stream_type) {
|
||||
case GST_APP_STREAM_TYPE_STREAM:
|
||||
case GST_APP_STREAM_TYPE_SEEKABLE:
|
||||
break;
|
||||
|
@ -725,12 +756,12 @@ gst_app_src_query (GstBaseSrc * src, GstQuery * query)
|
|||
res = gst_base_src_query_latency (src, &live, &min, &max);
|
||||
|
||||
/* overwrite with our values when we need to */
|
||||
g_mutex_lock (appsrc->mutex);
|
||||
if (appsrc->min_latency != -1)
|
||||
min = appsrc->min_latency;
|
||||
if (appsrc->max_latency != -1)
|
||||
max = appsrc->max_latency;
|
||||
g_mutex_unlock (appsrc->mutex);
|
||||
g_mutex_lock (appsrc->priv->mutex);
|
||||
if (appsrc->priv->min_latency != -1)
|
||||
min = appsrc->priv->min_latency;
|
||||
if (appsrc->priv->max_latency != -1)
|
||||
max = appsrc->priv->max_latency;
|
||||
g_mutex_unlock (appsrc->priv->mutex);
|
||||
|
||||
gst_query_set_latency (query, live, min, max);
|
||||
break;
|
||||
|
@ -757,7 +788,7 @@ gst_app_src_do_seek (GstBaseSrc * src, GstSegment * segment)
|
|||
desired_position, gst_format_get_name (segment->format));
|
||||
|
||||
/* no need to try to seek in streaming mode */
|
||||
if (appsrc->stream_type == GST_APP_STREAM_TYPE_STREAM)
|
||||
if (appsrc->priv->stream_type == GST_APP_STREAM_TYPE_STREAM)
|
||||
return TRUE;
|
||||
|
||||
g_signal_emit (appsrc, gst_app_src_signals[SIGNAL_SEEK_DATA], 0,
|
||||
|
@ -780,22 +811,22 @@ gst_app_src_create (GstBaseSrc * bsrc, guint64 offset, guint size,
|
|||
GstAppSrc *appsrc = GST_APP_SRC (bsrc);
|
||||
GstFlowReturn ret;
|
||||
|
||||
g_mutex_lock (appsrc->mutex);
|
||||
g_mutex_lock (appsrc->priv->mutex);
|
||||
/* check flushing first */
|
||||
if (G_UNLIKELY (appsrc->flushing))
|
||||
if (G_UNLIKELY (appsrc->priv->flushing))
|
||||
goto flushing;
|
||||
|
||||
if (appsrc->stream_type == GST_APP_STREAM_TYPE_RANDOM_ACCESS) {
|
||||
if (appsrc->priv->stream_type == GST_APP_STREAM_TYPE_RANDOM_ACCESS) {
|
||||
/* if we are dealing with a random-access stream, issue a seek if the offset
|
||||
* changed. */
|
||||
if (G_UNLIKELY (appsrc->offset != offset)) {
|
||||
if (G_UNLIKELY (appsrc->priv->offset != offset)) {
|
||||
gboolean res;
|
||||
|
||||
g_mutex_unlock (appsrc->mutex);
|
||||
g_mutex_unlock (appsrc->priv->mutex);
|
||||
|
||||
GST_DEBUG_OBJECT (appsrc,
|
||||
"we are at %" G_GINT64_FORMAT ", seek to %" G_GINT64_FORMAT,
|
||||
appsrc->offset, offset);
|
||||
appsrc->priv->offset, offset);
|
||||
|
||||
g_signal_emit (appsrc, gst_app_src_signals[SIGNAL_SEEK_DATA], 0,
|
||||
offset, &res);
|
||||
|
@ -804,46 +835,46 @@ gst_app_src_create (GstBaseSrc * bsrc, guint64 offset, guint size,
|
|||
/* failing to seek is fatal */
|
||||
goto seek_error;
|
||||
|
||||
g_mutex_lock (appsrc->mutex);
|
||||
g_mutex_lock (appsrc->priv->mutex);
|
||||
|
||||
appsrc->offset = offset;
|
||||
appsrc->priv->offset = offset;
|
||||
}
|
||||
}
|
||||
|
||||
while (TRUE) {
|
||||
/* return data as long as we have some */
|
||||
if (!g_queue_is_empty (appsrc->queue)) {
|
||||
if (!g_queue_is_empty (appsrc->priv->queue)) {
|
||||
guint buf_size;
|
||||
|
||||
*buf = g_queue_pop_head (appsrc->queue);
|
||||
*buf = g_queue_pop_head (appsrc->priv->queue);
|
||||
buf_size = GST_BUFFER_SIZE (*buf);
|
||||
|
||||
GST_DEBUG_OBJECT (appsrc, "we have buffer %p of size %u", *buf, buf_size);
|
||||
|
||||
appsrc->queued_bytes -= buf_size;
|
||||
appsrc->priv->queued_bytes -= buf_size;
|
||||
|
||||
/* only update the offset when in random_access mode */
|
||||
if (appsrc->stream_type == GST_APP_STREAM_TYPE_RANDOM_ACCESS) {
|
||||
appsrc->offset += buf_size;
|
||||
if (appsrc->priv->stream_type == GST_APP_STREAM_TYPE_RANDOM_ACCESS) {
|
||||
appsrc->priv->offset += buf_size;
|
||||
}
|
||||
|
||||
gst_buffer_set_caps (*buf, appsrc->caps);
|
||||
gst_buffer_set_caps (*buf, appsrc->priv->caps);
|
||||
|
||||
/* signal that we removed an item */
|
||||
g_cond_broadcast (appsrc->cond);
|
||||
g_cond_broadcast (appsrc->priv->cond);
|
||||
|
||||
ret = GST_FLOW_OK;
|
||||
break;
|
||||
} else {
|
||||
g_mutex_unlock (appsrc->mutex);
|
||||
g_mutex_unlock (appsrc->priv->mutex);
|
||||
|
||||
/* we have no data, we need some. We fire the signal with the size hint. */
|
||||
g_signal_emit (appsrc, gst_app_src_signals[SIGNAL_NEED_DATA], 0, size,
|
||||
NULL);
|
||||
|
||||
g_mutex_lock (appsrc->mutex);
|
||||
g_mutex_lock (appsrc->priv->mutex);
|
||||
/* we can be flushing now because we released the lock */
|
||||
if (G_UNLIKELY (appsrc->flushing))
|
||||
if (G_UNLIKELY (appsrc->priv->flushing))
|
||||
goto flushing;
|
||||
|
||||
/* if we have a buffer now, continue the loop and try to return it. In
|
||||
|
@ -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
|
||||
* when the application pushes the requested buffer later, we support both
|
||||
* possiblities. */
|
||||
if (!g_queue_is_empty (appsrc->queue))
|
||||
if (!g_queue_is_empty (appsrc->priv->queue))
|
||||
continue;
|
||||
|
||||
/* no buffer yet, maybe we are EOS, if not, block for more data. */
|
||||
}
|
||||
|
||||
/* check EOS */
|
||||
if (G_UNLIKELY (appsrc->is_eos))
|
||||
if (G_UNLIKELY (appsrc->priv->is_eos))
|
||||
goto eos;
|
||||
|
||||
/* nothing to return, wait a while for new data or flushing. */
|
||||
g_cond_wait (appsrc->cond, appsrc->mutex);
|
||||
g_cond_wait (appsrc->priv->cond, appsrc->priv->mutex);
|
||||
}
|
||||
g_mutex_unlock (appsrc->mutex);
|
||||
g_mutex_unlock (appsrc->priv->mutex);
|
||||
|
||||
return ret;
|
||||
|
||||
|
@ -872,13 +903,13 @@ gst_app_src_create (GstBaseSrc * bsrc, guint64 offset, guint size,
|
|||
flushing:
|
||||
{
|
||||
GST_DEBUG_OBJECT (appsrc, "we are flushing");
|
||||
g_mutex_unlock (appsrc->mutex);
|
||||
g_mutex_unlock (appsrc->priv->mutex);
|
||||
return GST_FLOW_WRONG_STATE;
|
||||
}
|
||||
eos:
|
||||
{
|
||||
GST_DEBUG_OBJECT (appsrc, "we are EOS");
|
||||
g_mutex_unlock (appsrc->mutex);
|
||||
g_mutex_unlock (appsrc->priv->mutex);
|
||||
return GST_FLOW_UNEXPECTED;
|
||||
}
|
||||
seek_error:
|
||||
|
@ -900,6 +931,8 @@ seek_error:
|
|||
* a copy of the caps structure. After calling this method, the source will
|
||||
* only produce caps that match @caps. @caps must be fixed and the caps on the
|
||||
* buffers must match the caps or left NULL.
|
||||
*
|
||||
* Since: 0.10.22
|
||||
*/
|
||||
void
|
||||
gst_app_src_set_caps (GstAppSrc * appsrc, const GstCaps * caps)
|
||||
|
@ -910,11 +943,11 @@ gst_app_src_set_caps (GstAppSrc * appsrc, const GstCaps * caps)
|
|||
|
||||
GST_OBJECT_LOCK (appsrc);
|
||||
GST_DEBUG_OBJECT (appsrc, "setting caps to %" GST_PTR_FORMAT, caps);
|
||||
if ((old = appsrc->caps) != caps) {
|
||||
if ((old = appsrc->priv->caps) != caps) {
|
||||
if (caps)
|
||||
appsrc->caps = gst_caps_copy (caps);
|
||||
appsrc->priv->caps = gst_caps_copy (caps);
|
||||
else
|
||||
appsrc->caps = NULL;
|
||||
appsrc->priv->caps = NULL;
|
||||
if (old)
|
||||
gst_caps_unref (old);
|
||||
}
|
||||
|
@ -928,6 +961,8 @@ gst_app_src_set_caps (GstAppSrc * appsrc, const GstCaps * caps)
|
|||
* Get the configured caps on @appsrc.
|
||||
*
|
||||
* Returns: the #GstCaps produced by the source. gst_caps_unref() after usage.
|
||||
*
|
||||
* Since: 0.10.22
|
||||
*/
|
||||
GstCaps *
|
||||
gst_app_src_get_caps (GstAppSrc * appsrc)
|
||||
|
@ -938,7 +973,7 @@ gst_app_src_get_caps (GstAppSrc * appsrc)
|
|||
g_return_val_if_fail (GST_IS_APP_SRC (appsrc), NULL);
|
||||
|
||||
GST_OBJECT_LOCK (appsrc);
|
||||
if ((caps = appsrc->caps))
|
||||
if ((caps = appsrc->priv->caps))
|
||||
gst_caps_ref (caps);
|
||||
GST_DEBUG_OBJECT (appsrc, "getting caps of %" GST_PTR_FORMAT, caps);
|
||||
GST_OBJECT_UNLOCK (appsrc);
|
||||
|
@ -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
|
||||
* not known.
|
||||
*
|
||||
* Since: 0.10.22
|
||||
*/
|
||||
void
|
||||
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_DEBUG_OBJECT (appsrc, "setting size of %" G_GINT64_FORMAT, size);
|
||||
appsrc->size = size;
|
||||
appsrc->priv->size = size;
|
||||
GST_OBJECT_UNLOCK (appsrc);
|
||||
}
|
||||
|
||||
|
@ -974,6 +1011,8 @@ gst_app_src_set_size (GstAppSrc * appsrc, gint64 size)
|
|||
* not known.
|
||||
*
|
||||
* Returns: the size of the stream previously set with gst_app_src_set_size();
|
||||
*
|
||||
* Since: 0.10.22
|
||||
*/
|
||||
gint64
|
||||
gst_app_src_get_size (GstAppSrc * appsrc)
|
||||
|
@ -984,7 +1023,7 @@ gst_app_src_get_size (GstAppSrc * appsrc)
|
|||
g_return_val_if_fail (GST_IS_APP_SRC (appsrc), -1);
|
||||
|
||||
GST_OBJECT_LOCK (appsrc);
|
||||
size = appsrc->size;
|
||||
size = appsrc->priv->size;
|
||||
GST_DEBUG_OBJECT (appsrc, "getting size of %" G_GINT64_FORMAT, size);
|
||||
GST_OBJECT_UNLOCK (appsrc);
|
||||
|
||||
|
@ -1000,6 +1039,8 @@ gst_app_src_get_size (GstAppSrc * appsrc)
|
|||
* be connected to.
|
||||
*
|
||||
* A stream_type stream
|
||||
*
|
||||
* Since: 0.10.22
|
||||
*/
|
||||
void
|
||||
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_DEBUG_OBJECT (appsrc, "setting stream_type of %d", type);
|
||||
appsrc->stream_type = type;
|
||||
appsrc->priv->stream_type = type;
|
||||
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().
|
||||
*
|
||||
* Returns: the stream type.
|
||||
*
|
||||
* Since: 0.10.22
|
||||
*/
|
||||
GstAppStreamType
|
||||
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);
|
||||
|
||||
GST_OBJECT_LOCK (appsrc);
|
||||
stream_type = appsrc->stream_type;
|
||||
stream_type = appsrc->priv->stream_type;
|
||||
GST_DEBUG_OBJECT (appsrc, "getting stream_type of %d", stream_type);
|
||||
GST_OBJECT_UNLOCK (appsrc);
|
||||
|
||||
|
@ -1046,20 +1089,22 @@ gst_app_src_get_stream_type (GstAppSrc * appsrc)
|
|||
* Set the maximum amount of bytes that can be queued in @appsrc.
|
||||
* After the maximum amount of bytes are queued, @appsrc will emit the
|
||||
* "enough-data" signal.
|
||||
*
|
||||
* Since: 0.10.22
|
||||
*/
|
||||
void
|
||||
gst_app_src_set_max_bytes (GstAppSrc * appsrc, guint64 max)
|
||||
{
|
||||
g_return_if_fail (GST_IS_APP_SRC (appsrc));
|
||||
|
||||
g_mutex_lock (appsrc->mutex);
|
||||
if (max != appsrc->max_bytes) {
|
||||
g_mutex_lock (appsrc->priv->mutex);
|
||||
if (max != appsrc->priv->max_bytes) {
|
||||
GST_DEBUG_OBJECT (appsrc, "setting max-bytes to %" G_GUINT64_FORMAT, max);
|
||||
appsrc->max_bytes = max;
|
||||
appsrc->priv->max_bytes = max;
|
||||
/* signal the change */
|
||||
g_cond_broadcast (appsrc->cond);
|
||||
g_cond_broadcast (appsrc->priv->cond);
|
||||
}
|
||||
g_mutex_unlock (appsrc->mutex);
|
||||
g_mutex_unlock (appsrc->priv->mutex);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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.
|
||||
*
|
||||
* Returns: The maximum amount of bytes that can be queued.
|
||||
*
|
||||
* Since: 0.10.22
|
||||
*/
|
||||
guint64
|
||||
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_mutex_lock (appsrc->mutex);
|
||||
result = appsrc->max_bytes;
|
||||
g_mutex_lock (appsrc->priv->mutex);
|
||||
result = appsrc->priv->max_bytes;
|
||||
GST_DEBUG_OBJECT (appsrc, "getting max-bytes of %" G_GUINT64_FORMAT, result);
|
||||
g_mutex_unlock (appsrc->mutex);
|
||||
g_mutex_unlock (appsrc->priv->mutex);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -1091,16 +1138,16 @@ gst_app_src_set_latencies (GstAppSrc * appsrc, gboolean do_min, guint64 min,
|
|||
{
|
||||
gboolean changed = FALSE;
|
||||
|
||||
g_mutex_lock (appsrc->mutex);
|
||||
if (do_min && appsrc->min_latency != min) {
|
||||
appsrc->min_latency = min;
|
||||
g_mutex_lock (appsrc->priv->mutex);
|
||||
if (do_min && appsrc->priv->min_latency != min) {
|
||||
appsrc->priv->min_latency = min;
|
||||
changed = TRUE;
|
||||
}
|
||||
if (do_max && appsrc->max_latency != max) {
|
||||
appsrc->max_latency = max;
|
||||
if (do_max && appsrc->priv->max_latency != max) {
|
||||
appsrc->priv->max_latency = max;
|
||||
changed = TRUE;
|
||||
}
|
||||
g_mutex_unlock (appsrc->mutex);
|
||||
g_mutex_unlock (appsrc->priv->mutex);
|
||||
|
||||
if (changed) {
|
||||
GST_DEBUG_OBJECT (appsrc, "posting latency changed");
|
||||
|
@ -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
|
||||
* default latency calculations for pseudo-live sources will be used.
|
||||
*
|
||||
* Since: 0.10.22
|
||||
*/
|
||||
void
|
||||
gst_app_src_set_latency (GstAppSrc * appsrc, guint64 min, guint64 max)
|
||||
|
@ -1131,18 +1180,20 @@ gst_app_src_set_latency (GstAppSrc * appsrc, guint64 min, guint64 max)
|
|||
* @max: the min latency
|
||||
*
|
||||
* Retrieve the min and max latencies in @min and @max respectively.
|
||||
*
|
||||
* Since: 0.10.22
|
||||
*/
|
||||
void
|
||||
gst_app_src_get_latency (GstAppSrc * appsrc, guint64 * min, guint64 * max)
|
||||
{
|
||||
g_return_if_fail (GST_IS_APP_SRC (appsrc));
|
||||
|
||||
g_mutex_lock (appsrc->mutex);
|
||||
g_mutex_lock (appsrc->priv->mutex);
|
||||
if (min)
|
||||
*min = appsrc->min_latency;
|
||||
*min = appsrc->priv->min_latency;
|
||||
if (max)
|
||||
*max = appsrc->max_latency;
|
||||
g_mutex_unlock (appsrc->mutex);
|
||||
*max = appsrc->priv->max_latency;
|
||||
g_mutex_unlock (appsrc->priv->mutex);
|
||||
}
|
||||
|
||||
static GstFlowReturn
|
||||
|
@ -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_BUFFER (buffer), GST_FLOW_ERROR);
|
||||
|
||||
g_mutex_lock (appsrc->mutex);
|
||||
g_mutex_lock (appsrc->priv->mutex);
|
||||
|
||||
while (TRUE) {
|
||||
/* can't accept buffers when we are flushing or EOS */
|
||||
if (appsrc->flushing)
|
||||
if (appsrc->priv->flushing)
|
||||
goto flushing;
|
||||
|
||||
if (appsrc->is_eos)
|
||||
if (appsrc->priv->is_eos)
|
||||
goto eos;
|
||||
|
||||
if (appsrc->max_bytes && appsrc->queued_bytes >= appsrc->max_bytes) {
|
||||
GST_DEBUG_OBJECT (appsrc, "queue filled (%" G_GUINT64_FORMAT " >= %"
|
||||
G_GUINT64_FORMAT ")", appsrc->queued_bytes, appsrc->max_bytes);
|
||||
if (appsrc->priv->max_bytes
|
||||
&& appsrc->priv->queued_bytes >= appsrc->priv->max_bytes) {
|
||||
GST_DEBUG_OBJECT (appsrc,
|
||||
"queue filled (%" G_GUINT64_FORMAT " >= %" G_GUINT64_FORMAT ")",
|
||||
appsrc->priv->queued_bytes, appsrc->priv->max_bytes);
|
||||
|
||||
if (first) {
|
||||
/* only signal on the first push */
|
||||
g_mutex_unlock (appsrc->mutex);
|
||||
g_mutex_unlock (appsrc->priv->mutex);
|
||||
|
||||
g_signal_emit (appsrc, gst_app_src_signals[SIGNAL_ENOUGH_DATA], 0,
|
||||
NULL);
|
||||
|
||||
g_mutex_lock (appsrc->mutex);
|
||||
g_mutex_lock (appsrc->priv->mutex);
|
||||
/* continue to check for flushing/eos after releasing the lock */
|
||||
first = FALSE;
|
||||
continue;
|
||||
}
|
||||
if (appsrc->block) {
|
||||
if (appsrc->priv->block) {
|
||||
GST_DEBUG_OBJECT (appsrc, "waiting for free space");
|
||||
/* we are filled, wait until a buffer gets popped or when we
|
||||
* flush. */
|
||||
g_cond_wait (appsrc->cond, appsrc->mutex);
|
||||
g_cond_wait (appsrc->priv->cond, appsrc->priv->mutex);
|
||||
} else {
|
||||
/* no need to wait for free space, we just pump more data into the
|
||||
* queue hoping that the caller reacts to the enough-data signal and
|
||||
|
@ -1199,10 +1252,10 @@ gst_app_src_push_buffer_full (GstAppSrc * appsrc, GstBuffer * buffer,
|
|||
GST_DEBUG_OBJECT (appsrc, "queueing buffer %p", buffer);
|
||||
if (!steal_ref)
|
||||
gst_buffer_ref (buffer);
|
||||
g_queue_push_tail (appsrc->queue, buffer);
|
||||
appsrc->queued_bytes += GST_BUFFER_SIZE (buffer);
|
||||
g_cond_broadcast (appsrc->cond);
|
||||
g_mutex_unlock (appsrc->mutex);
|
||||
g_queue_push_tail (appsrc->priv->queue, buffer);
|
||||
appsrc->priv->queued_bytes += GST_BUFFER_SIZE (buffer);
|
||||
g_cond_broadcast (appsrc->priv->cond);
|
||||
g_mutex_unlock (appsrc->priv->mutex);
|
||||
|
||||
return GST_FLOW_OK;
|
||||
|
||||
|
@ -1212,7 +1265,7 @@ flushing:
|
|||
GST_DEBUG_OBJECT (appsrc, "refuse buffer %p, we are flushing", buffer);
|
||||
if (steal_ref)
|
||||
gst_buffer_unref (buffer);
|
||||
g_mutex_unlock (appsrc->mutex);
|
||||
g_mutex_unlock (appsrc->priv->mutex);
|
||||
return GST_FLOW_WRONG_STATE;
|
||||
}
|
||||
eos:
|
||||
|
@ -1220,7 +1273,7 @@ eos:
|
|||
GST_DEBUG_OBJECT (appsrc, "refuse buffer %p, we are EOS", buffer);
|
||||
if (steal_ref)
|
||||
gst_buffer_unref (buffer);
|
||||
g_mutex_unlock (appsrc->mutex);
|
||||
g_mutex_unlock (appsrc->priv->mutex);
|
||||
return GST_FLOW_UNEXPECTED;
|
||||
}
|
||||
}
|
||||
|
@ -1236,6 +1289,8 @@ eos:
|
|||
* Returns: #GST_FLOW_OK when the buffer was successfuly queued.
|
||||
* #GST_FLOW_WRONG_STATE when @appsrc is not PAUSED or PLAYING.
|
||||
* #GST_FLOW_UNEXPECTED when EOS occured.
|
||||
*
|
||||
* Since: 0.10.22
|
||||
*/
|
||||
GstFlowReturn
|
||||
gst_app_src_push_buffer (GstAppSrc * appsrc, GstBuffer * buffer)
|
||||
|
@ -1260,6 +1315,8 @@ gst_app_src_push_buffer_action (GstAppSrc * appsrc, GstBuffer * buffer)
|
|||
*
|
||||
* Returns: #GST_FLOW_OK when the EOS was successfuly queued.
|
||||
* #GST_FLOW_WRONG_STATE when @appsrc is not PAUSED or PLAYING.
|
||||
*
|
||||
* Since: 0.10.22
|
||||
*/
|
||||
GstFlowReturn
|
||||
gst_app_src_end_of_stream (GstAppSrc * appsrc)
|
||||
|
@ -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 (GST_IS_APP_SRC (appsrc), GST_FLOW_ERROR);
|
||||
|
||||
g_mutex_lock (appsrc->mutex);
|
||||
g_mutex_lock (appsrc->priv->mutex);
|
||||
/* can't accept buffers when we are flushing. We can accept them when we are
|
||||
* EOS although it will not do anything. */
|
||||
if (appsrc->flushing)
|
||||
if (appsrc->priv->flushing)
|
||||
goto flushing;
|
||||
|
||||
GST_DEBUG_OBJECT (appsrc, "sending EOS");
|
||||
appsrc->is_eos = TRUE;
|
||||
g_cond_broadcast (appsrc->cond);
|
||||
g_mutex_unlock (appsrc->mutex);
|
||||
appsrc->priv->is_eos = TRUE;
|
||||
g_cond_broadcast (appsrc->priv->cond);
|
||||
g_mutex_unlock (appsrc->priv->mutex);
|
||||
|
||||
return GST_FLOW_OK;
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ G_BEGIN_DECLS
|
|||
|
||||
typedef struct _GstAppSrc GstAppSrc;
|
||||
typedef struct _GstAppSrcClass GstAppSrcClass;
|
||||
typedef struct _GstAppSrcPrivate GstAppSrcPrivate;
|
||||
|
||||
/**
|
||||
* GstAppStreamType:
|
||||
|
@ -62,26 +63,10 @@ struct _GstAppSrc
|
|||
GstBaseSrc basesrc;
|
||||
|
||||
/*< private >*/
|
||||
GCond *cond;
|
||||
GMutex *mutex;
|
||||
GQueue *queue;
|
||||
GstAppSrcPrivate *priv;
|
||||
|
||||
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;
|
||||
/*< private >*/
|
||||
gpointer _gst_reserved[GST_PADDING];
|
||||
};
|
||||
|
||||
struct _GstAppSrcClass
|
||||
|
@ -96,6 +81,9 @@ struct _GstAppSrcClass
|
|||
/* actions */
|
||||
GstFlowReturn (*push_buffer) (GstAppSrc *src, GstBuffer *buffer);
|
||||
GstFlowReturn (*end_of_stream) (GstAppSrc *src);
|
||||
|
||||
/*< private >*/
|
||||
gpointer _gst_reserved[GST_PADDING];
|
||||
};
|
||||
|
||||
GType gst_app_src_get_type(void);
|
||||
|
|
Loading…
Reference in a new issue