CVS Root: /cvs/gstreamer
Module: gstreamer
Changes by: wtay
Date: Fri Nov 21 2008 17:15:02 UTC
Log message:
* libs/gst/base/gstbasetransform.c: (gst_base_transform_init),
(gst_base_transform_getcaps), (gst_base_transform_find_transform),
(gst_base_transform_acceptcaps), (gst_base_transform_getrange):
Add beginnings of a more optimized acceptcaps function than the default
core one.
Modified files:
. : ChangeLog
libs/gst/base : gstbasetransform.c
Links:
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/ChangeLog.diff?r1=1.4169&r2=1.4170
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/libs/gst/base/gstbasetransform.c.diff?r1=1.129&r2=1.130
====Begin Diffs====
Index: ChangeLog
===================================================================
RCS file: /cvs/gstreamer/gstreamer/ChangeLog,v
retrieving revision 1.4169
retrieving revision 1.4170
diff -u -d -r1.4169 -r1.4170
--- ChangeLog 21 Nov 2008 16:48:45 -0000 1.4169
+++ ChangeLog 21 Nov 2008 17:14:46 -0000 1.4170
@@ -1,5 +1,13 @@
2008-11-21 Wim Taymans <[email protected]>
+ * libs/gst/base/gstbasetransform.c: (gst_base_transform_init),
+ (gst_base_transform_getcaps), (gst_base_transform_find_transform),
+ (gst_base_transform_acceptcaps), (gst_base_transform_getrange):
+ Add beginnings of a more optimized acceptcaps function than the default
+ core one.
+
+2008-11-21 Wim Taymans <[email protected]>
* gst/gstpad.c: (gst_pad_accept_caps):
Avoid getting the acceptcaps function too early.
Index: gstbasetransform.c
RCS file: /cvs/gstreamer/gstreamer/libs/gst/base/gstbasetransform.c,v
retrieving revision 1.129
retrieving revision 1.130
diff -u -d -r1.129 -r1.130
--- gstbasetransform.c 27 Oct 2008 15:02:48 -0000 1.129
+++ gstbasetransform.c 21 Nov 2008 17:14:48 -0000 1.130
@@ -314,6 +314,7 @@
static GstFlowReturn gst_base_transform_chain (GstPad * pad,
GstBuffer * buffer);
static GstCaps *gst_base_transform_getcaps (GstPad * pad);
+static gboolean gst_base_transform_acceptcaps (GstPad * pad, GstCaps * caps);
static gboolean gst_base_transform_setcaps (GstPad * pad, GstCaps * caps);
static GstFlowReturn gst_base_transform_buffer_alloc (GstPad * pad,
guint64 offset, guint size, GstCaps * caps, GstBuffer ** buf);
@@ -381,6 +382,8 @@
trans->sinkpad = gst_pad_new_from_template (pad_template, "sink");
gst_pad_set_getcaps_function (trans->sinkpad,
GST_DEBUG_FUNCPTR (gst_base_transform_getcaps));
+ gst_pad_set_acceptcaps_function (trans->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_base_transform_acceptcaps));
gst_pad_set_setcaps_function (trans->sinkpad,
GST_DEBUG_FUNCPTR (gst_base_transform_setcaps));
gst_pad_set_event_function (trans->sinkpad,
@@ -399,6 +402,8 @@
trans->srcpad = gst_pad_new_from_template (pad_template, "src");
gst_pad_set_getcaps_function (trans->srcpad,
+ gst_pad_set_acceptcaps_function (trans->srcpad,
gst_pad_set_event_function (trans->srcpad,
GST_DEBUG_FUNCPTR (gst_base_transform_src_event));
gst_pad_set_checkgetrange_function (trans->srcpad,
@@ -615,6 +620,7 @@
temp = gst_caps_intersect (caps, templ);
GST_DEBUG_OBJECT (pad, "intersected %" GST_PTR_FORMAT, temp);
gst_caps_unref (caps);
/* then see what we can transform this to */
caps = gst_base_transform_transform_caps (trans,
GST_PAD_DIRECTION (otherpad), temp);
@@ -632,7 +638,7 @@
/* this is what we can do */
caps = temp;
} else {
- /* no peer, our padtemplate is enough then */
+ /* no peer or the peer can do anything, our padtemplate is enough then */
caps = gst_caps_copy (gst_pad_get_pad_template_caps (pad));
}
@@ -962,6 +968,67 @@
}
+static gboolean
+gst_base_transform_acceptcaps (GstPad * pad, GstCaps * caps)
+{
+ GstBaseTransform *trans;
+ GstPad *otherpad;
+ GstCaps *othercaps = NULL;
+ gboolean ret = TRUE;
+ trans = GST_BASE_TRANSFORM (gst_pad_get_parent (pad));
+ otherpad = (pad == trans->srcpad) ? trans->sinkpad : trans->srcpad;
+ /* we need fixed caps for the check, fall back to the default implementation
+ * if we don't */
+ if (!gst_caps_is_fixed (caps)) {
+ GstCaps *intersect;
+ GST_DEBUG_OBJECT (pad, "non fixed accept caps %" GST_PTR_FORMAT, caps);
+ othercaps = gst_pad_get_caps (pad);
+ if (!othercaps)
+ goto no_transform_possible;
+ intersect = gst_caps_intersect (othercaps, caps);
+ GST_DEBUG_OBJECT (pad, "intersection %" GST_PTR_FORMAT, intersect);
+ ret = !gst_caps_is_empty (intersect);
+ gst_caps_unref (intersect);
+ if (!ret)
+ } else {
+ GST_DEBUG_OBJECT (pad, "accept caps %" GST_PTR_FORMAT, caps);
+ /* find best possible caps for the other pad as a way to see if we can
+ * transform this caps. */
+ othercaps = gst_base_transform_find_transform (trans, pad, caps);
+ if (!othercaps || gst_caps_is_empty (othercaps))
+ GST_DEBUG_OBJECT (pad, "we can transform to %" GST_PTR_FORMAT, othercaps);
+ }
+done:
+ if (othercaps)
+ gst_caps_unref (othercaps);
+ gst_object_unref (trans);
+ return ret;
+ /* ERRORS */
+no_transform_possible:
+ {
+ GST_WARNING_OBJECT (trans,
+ "transform could not transform %" GST_PTR_FORMAT
+ " in anything we support", caps);
+ ret = FALSE;
+ goto done;
+}
/* called when new caps arrive on the sink or source pad,
* We try to find the best caps for the other side using our _find_transform()
* function. If there are caps, we configure the transform for this new
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.