summaryrefslogtreecommitdiff
path: root/gst/imagefreeze
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian.droege@collabora.co.uk>2010-08-10 20:11:26 +0200
committerSebastian Dröge <sebastian.droege@collabora.co.uk>2010-09-04 14:52:05 +0200
commit134b1f0eeed0a6d900765829f0885473b7444f41 (patch)
treeda17c29e26f29154f7d28e5dc76b326891656caf /gst/imagefreeze
parentb990b0caac93a0775cb45331497235538f0feb53 (diff)
downloadgstreamer-plugins-good-134b1f0eeed0a6d900765829f0885473b7444f41.tar.gz
imagefreeze: Passthrough buffer allocations
Diffstat (limited to 'gst/imagefreeze')
-rw-r--r--gst/imagefreeze/gstimagefreeze.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/gst/imagefreeze/gstimagefreeze.c b/gst/imagefreeze/gstimagefreeze.c
index bf1b65e39..78ccda032 100644
--- a/gst/imagefreeze/gstimagefreeze.c
+++ b/gst/imagefreeze/gstimagefreeze.c
@@ -56,6 +56,8 @@ static gboolean gst_image_freeze_sink_event (GstPad * pad, GstEvent * event);
static gboolean gst_image_freeze_sink_setcaps (GstPad * pad, GstCaps * caps);
static GstCaps *gst_image_freeze_sink_getcaps (GstPad * pad);
static gboolean gst_image_freeze_sink_query (GstPad * pad, GstQuery * query);
+static GstFlowReturn gst_image_freeze_sink_bufferalloc (GstPad * pad,
+ guint64 offset, guint size, GstCaps * caps, GstBuffer ** buf);
static void gst_image_freeze_src_loop (GstPad * pad);
static gboolean gst_image_freeze_src_event (GstPad * pad, GstEvent * event);
static gboolean gst_image_freeze_src_query (GstPad * pad, GstQuery * query);
@@ -119,6 +121,8 @@ gst_image_freeze_init (GstImageFreeze * self, GstImageFreezeClass * g_class)
GST_DEBUG_FUNCPTR (gst_image_freeze_sink_setcaps));
gst_pad_set_getcaps_function (self->sinkpad,
GST_DEBUG_FUNCPTR (gst_image_freeze_sink_getcaps));
+ gst_pad_set_bufferalloc_function (self->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_image_freeze_sink_bufferalloc));
gst_element_add_pad (GST_ELEMENT (self), self->sinkpad);
self->srcpad = gst_pad_new_from_static_template (&src_pad_template, "src");
@@ -305,6 +309,38 @@ gst_image_freeze_sink_query (GstPad * pad, GstQuery * query)
return ret;
}
+static GstFlowReturn
+gst_image_freeze_sink_bufferalloc (GstPad * pad, guint64 offset, guint size,
+ GstCaps * caps, GstBuffer ** buf)
+{
+ GstImageFreeze *self = GST_IMAGE_FREEZE (gst_pad_get_parent (pad));
+ GstFlowReturn ret;
+ gboolean do_alloc;
+
+ GST_LOG_OBJECT (pad, "Allocating buffer with offset 0x%" G_GINT64_MODIFIER
+ "x and size %u with caps: %" GST_PTR_FORMAT, offset, size, caps);
+
+ *buf = NULL;
+
+ GST_OBJECT_LOCK (self);
+ do_alloc = self->buffer == NULL;
+ GST_OBJECT_UNLOCK (self);
+
+ if (do_alloc) {
+ ret = gst_pad_alloc_buffer (self->srcpad, offset, size, caps, buf);
+ if (G_UNLIKELY (ret != GST_FLOW_OK))
+ GST_ERROR_OBJECT (pad, "Allocating buffer failed: %s",
+ gst_flow_get_name (ret));
+ } else {
+ /* In this case GstPad will allocate a buffer for us */
+ ret = GST_FLOW_OK;
+ }
+
+ gst_object_unref (self);
+
+ return ret;
+}
+
static gboolean
gst_image_freeze_convert (GstImageFreeze * self,
GstFormat src_format, gint64 src_value,