summaryrefslogtreecommitdiffstats
path: root/gst
diff options
context:
space:
mode:
authorOlivier Crete <olivier.crete@collabora.co.uk>2007-12-19 00:57:39 +0000
committerEdward Hervey <bilboed@bilboed.com>2009-02-17 19:29:59 +0100
commitee9906672b7857ea38b3160112f95ebf503b1ef2 (patch)
tree268893ce754bd7a4b844bbc8977dfce2e1f0e97c /gst
parent8d8c9adf3024acef39862d8938532f9697490350 (diff)
downloadgst-plugins-bad-ee9906672b7857ea38b3160112f95ebf503b1ef2.tar.gz
gst-plugins-bad-ee9906672b7857ea38b3160112f95ebf503b1ef2.tar.bz2
gst-plugins-bad-ee9906672b7857ea38b3160112f95ebf503b1ef2.zip
[MOVED FROM GST-P-FARSIGHT] Use do the alloc_buffer function in the valve
20071219005739-3e2dc-2a0fdfa2f38f03ab4791fe5c4ab85e8790113683.gz
Diffstat (limited to 'gst')
-rw-r--r--gst/valve/gstvalve.c43
-rw-r--r--gst/valve/gstvalve.h2
2 files changed, 41 insertions, 4 deletions
diff --git a/gst/valve/gstvalve.c b/gst/valve/gstvalve.c
index 4ff7f347..5b765c65 100644
--- a/gst/valve/gstvalve.c
+++ b/gst/valve/gstvalve.c
@@ -74,10 +74,11 @@ static void gst_valve_get_property (GObject *object,
guint prop_id, GValue *value, GParamSpec *pspec);
static void gst_valve_dispose (GObject *object);
-static GstFlowReturn
-gst_valve_transform_ip (GstBaseTransform *trans, GstBuffer *buf);
-static gboolean
-gst_valve_event (GstBaseTransform *trans, GstEvent *event);
+static GstFlowReturn gst_valve_transform_ip (GstBaseTransform *trans,
+ GstBuffer *buf);
+static gboolean gst_valve_event (GstBaseTransform *trans, GstEvent *event);
+static GstFlowReturn gst_valve_buffer_alloc (GstPad * pad, guint64 offset,
+ guint size, GstCaps * caps, GstBuffer ** buf);
static void
@@ -139,6 +140,14 @@ gst_valve_init (GstValve *valve, GstValveClass *klass)
valve->drop = 0;
+ valve->original_allocfunc =
+ GST_BASE_TRANSFORM (valve)->sinkpad->bufferallocfunc;
+
+ gst_pad_set_bufferalloc_function (
+ GST_BASE_TRANSFORM (valve)->sinkpad,
+ GST_DEBUG_FUNCPTR(gst_valve_buffer_alloc));
+
+
#if GST_VERSION_MINOR >= 10 && GST_VERSION_MICRO >= 13
gst_base_transform_set_passthrough ((GstBaseTransform *)valve, TRUE);
#endif
@@ -223,6 +232,32 @@ gst_valve_event (GstBaseTransform *trans, GstEvent *event)
return ret;
}
+static GstFlowReturn
+gst_valve_buffer_alloc (GstPad * pad, guint64 offset, guint size,
+ GstCaps * caps, GstBuffer ** buf)
+{
+ GstValve *valve = GST_VALVE (gst_pad_get_parent_element (pad));
+ GstFlowReturn ret = GST_FLOW_OK;
+
+ GST_OBJECT_LOCK (GST_OBJECT (valve));
+ if (valve->drop)
+ {
+ *buf = gst_buffer_new_and_alloc (size);
+ GST_BUFFER_OFFSET (*buf) = offset;
+ gst_buffer_set_caps (*buf, caps);
+ }
+ else
+ {
+ ret = valve->original_allocfunc (pad, offset, size, caps, buf);
+ }
+ GST_OBJECT_UNLOCK (GST_OBJECT (valve));
+
+ gst_object_unref (valve);
+
+ return ret;
+}
+
+
gboolean
gst_valve_plugin_init (GstPlugin *plugin)
{
diff --git a/gst/valve/gstvalve.h b/gst/valve/gstvalve.h
index 60f683f4..f60d7e18 100644
--- a/gst/valve/gstvalve.h
+++ b/gst/valve/gstvalve.h
@@ -54,6 +54,8 @@ struct _GstValve
gboolean drop;
+ GstPadBufferAllocFunction original_allocfunc;
+
/*< private > */
gpointer _gst_reserved[GST_PADDING];
};