summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2010-04-17 02:18:25 +0200
committerBenjamin Otte <otte@redhat.com>2010-04-17 02:50:45 +0200
commit859fa001cbe6e299bda6351c502b2e9b9e5cb893 (patch)
tree9ae8601855001041096c86b4106af3dd6089a69f
parent10b92dc7b32172ae82d615443871681ecedced2c (diff)
Allow specifying that type of surfaces in a pipeline
1) Add surface-type property to video/x-cairo If surface-type == 0, any surface type can be used (including images). Otherwise, buffers must be of the given cairo_surface_type_t. The supported API makes sure to never expand the surface type. 2) Differentiate between "default" and "any" caps "default" are the caps gst-cairo can produce itself (read: everything that can be expressed using image surfaces). "any" include the default caps and all the other caps that can be created with specific sink elements. 3) Add API for these new caps. Every function that was previously available with _any is now available with _default, too. Both types are equally important. 3) Make projectm require GL surfaces This currently means that projectm cannot be linked to anything.
-rw-r--r--docs/libs/gst-plugins-cairo-libs-sections.txt6
-rw-r--r--ext/pango/gstpangotimeoverlay.c4
-rw-r--r--ext/projectM/gstprojectm.cpp17
-rw-r--r--ext/xlib/gstcairoglxsink.c10
-rw-r--r--ext/xlib/gstcairoxconvert.c4
-rw-r--r--ext/xlib/gstcairoxsink.c10
-rw-r--r--gst-libs/gst/cairo/gstcairobuffer.c14
-rw-r--r--gst-libs/gst/cairo/gstcairocaps.c65
-rw-r--r--gst-libs/gst/cairo/gstcairocaps.h1
-rw-r--r--gst-libs/gst/cairo/gstcairocaps2format.h4
-rw-r--r--gst-libs/gst/cairo/gstcairocapsany.h2
-rw-r--r--gst-libs/gst/cairo/gstcairoformat-private.h1
-rw-r--r--gst-libs/gst/cairo/gstcairoformat.c25
-rw-r--r--gst-libs/gst/cairo/gstcairoformat.h2
-rw-r--r--gst-libs/gst/cairo/gstcairopad.c23
-rw-r--r--gst-libs/gst/cairo/gstcairopad.h4
-rw-r--r--gst/cairo/gstcairocolorspace.c4
-rw-r--r--gst/cairo/gstcairomixer.c5
-rw-r--r--gst/cairo/gstcairopuzzle.c4
-rw-r--r--gst/cairo/gstcairoscale.c4
-rw-r--r--gst/cairo/gstcairotestsrc.c2
21 files changed, 175 insertions, 36 deletions
diff --git a/docs/libs/gst-plugins-cairo-libs-sections.txt b/docs/libs/gst-plugins-cairo-libs-sections.txt
index 2c83635..06d0540 100644
--- a/docs/libs/gst-plugins-cairo-libs-sections.txt
+++ b/docs/libs/gst-plugins-cairo-libs-sections.txt
@@ -3,13 +3,16 @@
GstCairoFormatOption
GstCairoFormat
gst_cairo_caps_any
+gst_cairo_caps_default
gst_cairo_caps_expand
-gst_cairo_pad_template_new
+gst_cairo_pad_template_new_any
+gst_cairo_pad_template_new_default
gst_cairo_format_new
gst_cairo_format_copy
gst_cairo_format_free
gst_cairo_format_to_caps
gst_cairo_format_is_native
+gst_cairo_format_get_surface_type
gst_cairo_format_get_width
gst_cairo_format_get_height
gst_cairo_format_get_buffer_size
@@ -25,7 +28,6 @@ gst_cairo_buffer_new_similar
gst_cairo_buffer_is_fixed
gst_cairo_buffer_set_format
gst_cairo_create_surface
-gst_cairo_create_similar_surface
GstCairoRestrictCapsFunction
gst_cairo_pad_alloc_buffer
gst_cairo_pad_alloc_buffer_full
diff --git a/ext/pango/gstpangotimeoverlay.c b/ext/pango/gstpangotimeoverlay.c
index acd47ee..4ac811e 100644
--- a/ext/pango/gstpangotimeoverlay.c
+++ b/ext/pango/gstpangotimeoverlay.c
@@ -139,9 +139,9 @@ gst_pango_time_overlay_base_init (gpointer klass)
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class,
- gst_cairo_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS));
+ gst_cairo_pad_template_new_any ("src", GST_PAD_SRC, GST_PAD_ALWAYS));
gst_element_class_add_pad_template (element_class,
- gst_cairo_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS));
+ gst_cairo_pad_template_new_any ("sink", GST_PAD_SINK, GST_PAD_ALWAYS));
gst_element_class_set_details_simple (element_class, "Time overlay",
"Filter/Editor/Video",
"Overlays buffer time stamps on a video stream",
diff --git a/ext/projectM/gstprojectm.cpp b/ext/projectM/gstprojectm.cpp
index f0bd596..5c3ccc3 100644
--- a/ext/projectM/gstprojectm.cpp
+++ b/ext/projectM/gstprojectm.cpp
@@ -97,6 +97,18 @@ static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
)
);
+static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("video/x-cairo, "
+ "surface-type = (int) 18, " /* 18 == GL */
+ "depth = (int) 16, "
+ "width = " GST_VIDEO_SIZE_RANGE ", "
+ "height = " GST_VIDEO_SIZE_RANGE ", "
+ "framerate = " GST_VIDEO_FPS_RANGE
+ )
+ );
+
GST_BOILERPLATE (GstProjectm, gst_projectm, GstElement,
GST_TYPE_ELEMENT);
@@ -106,7 +118,7 @@ gst_projectm_base_init (gpointer klass)
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class,
- gst_cairo_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS));
+ gst_static_pad_template_get (&src_template));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&sink_template));
gst_element_class_set_details_simple (element_class, "ProjectM",
@@ -495,8 +507,7 @@ gst_projectm_init (GstProjectm * projectm, GstProjectmClass *klass)
gst_pad_set_event_function (projectm->sinkpad, gst_projectm_sink_event);
gst_element_add_pad (GST_ELEMENT (projectm), projectm->sinkpad);
- projectm->srcpad = gst_pad_new_from_template (
- gst_element_class_get_pad_template (GST_ELEMENT_GET_CLASS (projectm), "src"), "src");
+ projectm->srcpad = gst_pad_new_from_static_template (&src_template, "src");
gst_pad_set_setcaps_function (projectm->srcpad, gst_projectm_src_setcaps);
gst_pad_set_fixatecaps_function (projectm->srcpad, gst_projectm_src_fixatecaps);
gst_pad_set_event_function (projectm->srcpad, gst_projectm_src_event);
diff --git a/ext/xlib/gstcairoglxsink.c b/ext/xlib/gstcairoglxsink.c
index cb5ba34..157ee94 100644
--- a/ext/xlib/gstcairoglxsink.c
+++ b/ext/xlib/gstcairoglxsink.c
@@ -403,11 +403,11 @@ gst_cairo_glx_sink_base_init (gpointer klass)
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class,
- gst_cairo_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS));
- gst_element_class_set_details_simple (element_class,
- "Cairo GLX Video Sink",
- "Sink/Video",
- "Outputs video to X11 using Cairo", "Benjamin Otte <otte@gnome.org>");
+ gst_cairo_pad_template_new_default ("sink", GST_PAD_SINK,
+ GST_PAD_ALWAYS));
+ gst_element_class_set_details_simple (element_class, "Cairo GLX Video Sink",
+ "Sink/Video", "Outputs video to X11 using Cairo",
+ "Benjamin Otte <otte@gnome.org>");
}
static void
diff --git a/ext/xlib/gstcairoxconvert.c b/ext/xlib/gstcairoxconvert.c
index fb1beb7..e2da7e8 100644
--- a/ext/xlib/gstcairoxconvert.c
+++ b/ext/xlib/gstcairoxconvert.c
@@ -165,9 +165,9 @@ gst_cairo_x_convert_base_init (gpointer klass)
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class,
- gst_cairo_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS));
+ gst_cairo_pad_template_new_any ("src", GST_PAD_SRC, GST_PAD_ALWAYS));
gst_element_class_add_pad_template (element_class,
- gst_cairo_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS));
+ gst_cairo_pad_template_new_any ("sink", GST_PAD_SINK, GST_PAD_ALWAYS));
gst_element_class_set_details_simple (element_class,
"Cairo X converter",
"Filter/Converter/Video",
diff --git a/ext/xlib/gstcairoxsink.c b/ext/xlib/gstcairoxsink.c
index dd691b1..c4999ac 100644
--- a/ext/xlib/gstcairoxsink.c
+++ b/ext/xlib/gstcairoxsink.c
@@ -353,11 +353,11 @@ gst_cairo_x_sink_base_init (gpointer klass)
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class,
- gst_cairo_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS));
- gst_element_class_set_details_simple (element_class,
- "Cairo X Video Sink",
- "Sink/Video",
- "Outputs video to X11 using Cairo", "Benjamin Otte <otte@gnome.org>");
+ gst_cairo_pad_template_new_default ("sink", GST_PAD_SINK,
+ GST_PAD_ALWAYS));
+ gst_element_class_set_details_simple (element_class, "Cairo X Video Sink",
+ "Sink/Video", "Outputs video to X11 using Cairo",
+ "Benjamin Otte <otte@gnome.org>");
}
static void
diff --git a/gst-libs/gst/cairo/gstcairobuffer.c b/gst-libs/gst/cairo/gstcairobuffer.c
index 807a776..b110705 100644
--- a/gst-libs/gst/cairo/gstcairobuffer.c
+++ b/gst-libs/gst/cairo/gstcairobuffer.c
@@ -158,6 +158,12 @@ gst_cairo_create_surface (GstBuffer * buffer, const GstCairoFormat * format)
cbuffer->surface = cairo_surface_reference (result);
cbuffer->fixed = TRUE;
}
+
+ /* sanity checks */
+ g_return_val_if_fail (gst_cairo_format_get_surface_type (format) == 0
+ || gst_cairo_format_get_surface_type (format) ==
+ cairo_surface_get_type (result), result);
+
} else {
static cairo_user_data_key_t buffer_free;
guint8 *data = GST_BUFFER_DATA (buffer);
@@ -165,6 +171,8 @@ gst_cairo_create_surface (GstBuffer * buffer, const GstCairoFormat * format)
int strides[4];
guint i;
+ g_return_val_if_fail (!gst_cairo_format_is_native (format), NULL);
+
for (i = 0; i < format->n_planes; i++) {
planes[i] = (char *) (data + gst_cairo_format_get_offset (format, i));
strides[i] = gst_cairo_format_get_stride (format, i);
@@ -201,6 +209,8 @@ gst_cairo_buffer_new (const GstCairoFormat * format)
gsize size;
g_return_val_if_fail (format != NULL, NULL);
+ g_return_val_if_fail (gst_cairo_format_get_surface_type (format) ==
+ CAIRO_SURFACE_TYPE_IMAGE, NULL);
/* Cairo guarantees that new surfaces will always be zeroed. We keep
* this promise as to not introduce weird unexplainable rendering
@@ -243,6 +253,10 @@ gst_cairo_buffer_new_similar (cairo_surface_t * surface,
g_return_val_if_fail (surface != NULL, NULL);
g_return_val_if_fail (format != NULL, NULL);
+ g_return_val_if_fail (gst_cairo_format_get_surface_type (format) ==
+ CAIRO_SURFACE_TYPE_IMAGE
+ || gst_cairo_format_get_surface_type (format) ==
+ cairo_surface_get_type (surface), NULL);
if (!gst_cairo_format_is_native (format))
return gst_cairo_buffer_new (format);
diff --git a/gst-libs/gst/cairo/gstcairocaps.c b/gst-libs/gst/cairo/gstcairocaps.c
index caaf92c..6f69d70 100644
--- a/gst-libs/gst/cairo/gstcairocaps.c
+++ b/gst-libs/gst/cairo/gstcairocaps.c
@@ -74,6 +74,57 @@ gst_cairo_caps_any (void)
return gst_caps_copy (GSIZE_TO_POINTER (any));
}
+static gboolean
+gst_cairo_structure_is_native (const GstStructure * check)
+{
+ static GQuark native_name = 0;
+
+ if (!native_name)
+ native_name = g_quark_from_static_string ("video/x-cairo");
+
+ return gst_structure_get_name_id (check) == native_name;
+}
+
+/**
+ * gst_cairo_caps_default:
+ *
+ * Returns a #GstCaps that references all formats that can be created by
+ * gst_cairo_buffer_new(). This does not include native formats that require
+ * special elements to handle them. If you write a sink element, you want to
+ * use these caps instead of gst_cairo_caps_any(). For elements that don't
+ * produce buffers themselves
+ * The returned caps will not be writable. Use gst_caps_make_writable() if
+ * you want to change them.
+ * <note>The caps returned by this function can change between versions
+ * of this library as new formats are added.</note>
+ *
+ * Returns: a #GstCaps, use gst_caps_unref() to get rid of it. The caps will
+ * not be writable.
+ **/
+GstCaps *
+gst_cairo_caps_default (void)
+{
+ static gsize default_ = 0;
+
+ if (g_once_init_enter (&default_)) {
+ GstCaps *caps = gst_caps_make_writable (gst_cairo_caps_any ());
+ guint i;
+
+ for (i = 0; i < gst_caps_get_size (caps); i++) {
+ GstStructure *check = gst_caps_get_structure (caps, i);
+
+ if (!gst_cairo_structure_is_native (check))
+ continue;
+
+ gst_structure_set (check, "surface-type", G_TYPE_INT, 0, NULL);
+ }
+
+ g_once_init_leave (&default_, GPOINTER_TO_SIZE (caps));
+ }
+
+ return gst_caps_ref (GSIZE_TO_POINTER (default_));
+}
+
/**
* gst_cairo_caps_expand:
* @caps: a valid cairo caps to expand
@@ -102,7 +153,19 @@ gst_cairo_caps_expand (const GstCaps * caps, GstCairoFormatOption expand)
GstCaps *copy;
if (expand & GST_CAIRO_FORMAT_FORMAT) {
- copy = gst_caps_make_writable (gst_cairo_caps_any ());
+ copy = gst_caps_make_writable (gst_cairo_caps_default ());
+ if (gst_cairo_structure_is_native (expand_me)) {
+ guint j;
+ for (j = 0; j < gst_caps_get_size (caps); j++) {
+ GstStructure *check = gst_caps_get_structure (caps, j);
+
+ if (!gst_cairo_structure_is_native (check))
+ continue;
+
+ gst_structure_set_value (check, "surface-type",
+ gst_structure_get_value (expand_me, "surface-type"));
+ }
+ }
} else {
copy = gst_caps_copy_nth (caps, i);
}
diff --git a/gst-libs/gst/cairo/gstcairocaps.h b/gst-libs/gst/cairo/gstcairocaps.h
index 6f097dd..9d7a4b6 100644
--- a/gst-libs/gst/cairo/gstcairocaps.h
+++ b/gst-libs/gst/cairo/gstcairocaps.h
@@ -28,6 +28,7 @@ G_BEGIN_DECLS
GstCaps * gst_cairo_caps_any (void);
+GstCaps * gst_cairo_caps_default (void);
GstCaps * gst_cairo_caps_expand (const GstCaps * caps,
GstCairoFormatOption expand);
diff --git a/gst-libs/gst/cairo/gstcairocaps2format.h b/gst-libs/gst/cairo/gstcairocaps2format.h
index 6281423..9fc39ce 100644
--- a/gst-libs/gst/cairo/gstcairocaps2format.h
+++ b/gst-libs/gst/cairo/gstcairocaps2format.h
@@ -25,9 +25,9 @@
*/
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
-GST_CAIRO_CAPS_FORMAT (-1, CAIRO_COLOR_SPACE_ARGB, 1, GST_VIDEO_FORMAT_BGRA, "video/x-cairo, width = " GST_VIDEO_SIZE_RANGE ", height = " GST_VIDEO_SIZE_RANGE ", framerate = " GST_VIDEO_FPS_RANGE)
+GST_CAIRO_CAPS_FORMAT (-1, CAIRO_COLOR_SPACE_ARGB, 1, GST_VIDEO_FORMAT_BGRA, "video/x-cairo, surface-type = [0, MAX], width = " GST_VIDEO_SIZE_RANGE ", height = " GST_VIDEO_SIZE_RANGE ", framerate = " GST_VIDEO_FPS_RANGE)
#else
-GST_CAIRO_CAPS_FORMAT (-1, CAIRO_COLOR_SPACE_ARGB, 1, GST_VIDEO_FORMAT_ARGB, "video/x-cairo, width = " GST_VIDEO_SIZE_RANGE ", height = " GST_VIDEO_SIZE_RANGE ", framerate = " GST_VIDEO_FPS_RANGE)
+GST_CAIRO_CAPS_FORMAT (-1, CAIRO_COLOR_SPACE_ARGB, 1, GST_VIDEO_FORMAT_ARGB, "video/x-cairo, surface-type = [0, MAX], width = " GST_VIDEO_SIZE_RANGE ", height = " GST_VIDEO_SIZE_RANGE ", framerate = " GST_VIDEO_FPS_RANGE)
#endif
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
diff --git a/gst-libs/gst/cairo/gstcairocapsany.h b/gst-libs/gst/cairo/gstcairocapsany.h
index 5a3e4a0..3ec15d7 100644
--- a/gst-libs/gst/cairo/gstcairocapsany.h
+++ b/gst-libs/gst/cairo/gstcairocapsany.h
@@ -1,3 +1,3 @@
/* This file is autogenerated by gstcairocapsany.c, do not edit */
-#define GST_CAIRO_CAPS_ANY """video/x-cairo, width = " GST_VIDEO_SIZE_RANGE ", height = " GST_VIDEO_SIZE_RANGE ", framerate = " GST_VIDEO_FPS_RANGE"; "GST_VIDEO_CAPS_BGRx"; "GST_VIDEO_CAPS_YUV("AYUV")"; "GST_VIDEO_CAPS_YUV("YUY2")"; "GST_VIDEO_CAPS_YUV("UYVY")"; "GST_VIDEO_CAPS_YUV("YVYU")"; "GST_VIDEO_CAPS_YUV("Y444")"; "GST_VIDEO_CAPS_YUV("Y42B")"; "GST_VIDEO_CAPS_YUV("I420")"; "GST_VIDEO_CAPS_YUV("YV12")
+#define GST_CAIRO_CAPS_ANY """video/x-cairo, surface-type = [0, MAX], width = " GST_VIDEO_SIZE_RANGE ", height = " GST_VIDEO_SIZE_RANGE ", framerate = " GST_VIDEO_FPS_RANGE"; "GST_VIDEO_CAPS_BGRx"; "GST_VIDEO_CAPS_YUV("AYUV")"; "GST_VIDEO_CAPS_YUV("YUY2")"; "GST_VIDEO_CAPS_YUV("UYVY")"; "GST_VIDEO_CAPS_YUV("YVYU")"; "GST_VIDEO_CAPS_YUV("Y444")"; "GST_VIDEO_CAPS_YUV("Y42B")"; "GST_VIDEO_CAPS_YUV("I420")"; "GST_VIDEO_CAPS_YUV("YV12")
diff --git a/gst-libs/gst/cairo/gstcairoformat-private.h b/gst-libs/gst/cairo/gstcairoformat-private.h
index dd935ae..cdafaf8 100644
--- a/gst-libs/gst/cairo/gstcairoformat-private.h
+++ b/gst-libs/gst/cairo/gstcairoformat-private.h
@@ -27,6 +27,7 @@ G_BEGIN_DECLS
struct _GstCairoFormat {
volatile unsigned int refcount;
+ cairo_surface_type_t surface_type; /* type of surfaces passed in this format or 0 for any/none */
cairo_format_t format; /* cairo format in use or 0 for unknown */
cairo_color_space_t color_space; /* cairo color space in use */
guint n_planes; /* number of planes for this format */
diff --git a/gst-libs/gst/cairo/gstcairoformat.c b/gst-libs/gst/cairo/gstcairoformat.c
index 940476e..68a6f7a 100644
--- a/gst-libs/gst/cairo/gstcairoformat.c
+++ b/gst-libs/gst/cairo/gstcairoformat.c
@@ -115,6 +115,14 @@ gst_cairo_format_new (GstCaps * caps)
get_format_for_caps (format, caps);
+ if (gst_cairo_format_is_native (format)) {
+ int tmp;
+ if (!gst_structure_get_int (structure, "surface-type", &tmp))
+ g_return_val_if_reached (NULL);
+ format->surface_type = tmp;
+ } else {
+ format->surface_type = CAIRO_SURFACE_TYPE_IMAGE;
+ }
if (!gst_structure_get_int (structure, "width", &format->width) ||
!gst_structure_get_int (structure, "height", &format->height) ||
!gst_structure_get_fraction (structure, "framerate",
@@ -188,6 +196,23 @@ gst_cairo_format_is_native (const GstCairoFormat * format)
}
/**
+ * gst_cairo_format_get_surface_type:
+ * @format: a format
+ *
+ * Gets the surface type for buffers passed in @format. If the surface
+ * type is not #CAIRO_SURFACE_TYPE_IMAGE, buffers passed in this format
+ * must contain Cairo surfaces in the given type.
+ *
+ * Returns: the type of surfaces passed through @format or
+ * #CAIRO_SURFACE_TYPE_IMAGE for any type.
+ **/
+cairo_surface_type_t
+gst_cairo_format_get_surface_type (const GstCairoFormat * format)
+{
+ return format->surface_type;
+}
+
+/**
* gst_cairo_format_to_caps:
* @format: the format
* @fixed: parts of the format to respect
diff --git a/gst-libs/gst/cairo/gstcairoformat.h b/gst-libs/gst/cairo/gstcairoformat.h
index 8d2b0e4..f2b9a29 100644
--- a/gst-libs/gst/cairo/gstcairoformat.h
+++ b/gst-libs/gst/cairo/gstcairoformat.h
@@ -45,6 +45,8 @@ GstCaps * gst_cairo_format_to_caps (const GstCairoFormat *
GstCairoFormatOption fixed);
gboolean gst_cairo_format_is_native (const GstCairoFormat * format);
+cairo_surface_type_t
+ gst_cairo_format_get_surface_type (const GstCairoFormat * format);
guint gst_cairo_format_get_width (const GstCairoFormat * format);
guint gst_cairo_format_get_height (const GstCairoFormat * format);
gsize gst_cairo_format_get_buffer_size (const GstCairoFormat * format);
diff --git a/gst-libs/gst/cairo/gstcairopad.c b/gst-libs/gst/cairo/gstcairopad.c
index 388c9b6..61a4a58 100644
--- a/gst-libs/gst/cairo/gstcairopad.c
+++ b/gst-libs/gst/cairo/gstcairopad.c
@@ -29,14 +29,15 @@
#include "gstcairoformat-private.h"
/**
- * gst_cairo_pad_template_new:
+ * gst_cairo_pad_template_new_any:
* @name: name of the template
* @dir: direction of template
* @presence: presence of pads created from this template
*
* This is a convenience macro for creating pad templates for use in
- * elements that use gst-plugins-cairo. It is recommended to use this
- * function when creating pad templates in your elements and not use
+ * elements that use gst-plugins-cairo that support the caps returned
+ * from gst_cairo_caps_any(). It is recommended to use this function
+ * when creating pad templates in your elements and not use
* GstStaticPadTemplate<!-- -->s, because then the element will
* automatically benefit from new formats added to gst-plugins-cairo.
*
@@ -45,6 +46,22 @@
**/
/**
+ * gst_cairo_pad_template_new_default:
+ * @name: name of the template
+ * @dir: direction of template
+ * @presence: presence of pads created from this template
+ *
+ * This is a convenience macro for creating pad templates for use in
+ * elements that use gst-plugins-cairo that support the caps returned
+ * from gst_cairo_caps_default(). It is recommended to use this function
+ * when creating pad templates in your elements and not use
+ * GstStaticPadTemplate<!-- -->s, because then the element will
+ * automatically benefit from new formats added to gst-plugins-cairo.
+ *
+ * Returns: a new pad template accepting all formats that
+ * gst-plugins-cairo can create buffers for.
+ **/
+/**
* GstCairoRestrictCapsFunction:
* @caps: caps to restrict
* @data: data passed to gst_cairo_pad_alloc_buffer_full()
diff --git a/gst-libs/gst/cairo/gstcairopad.h b/gst-libs/gst/cairo/gstcairopad.h
index 51a6447..5dc68f9 100644
--- a/gst-libs/gst/cairo/gstcairopad.h
+++ b/gst-libs/gst/cairo/gstcairopad.h
@@ -27,8 +27,10 @@
G_BEGIN_DECLS
-#define gst_cairo_pad_template_new(name,dir,presence) \
+#define gst_cairo_pad_template_new_any(name,dir,presence) \
gst_pad_template_new ((name), (dir), (presence), gst_cairo_caps_any ())
+#define gst_cairo_pad_template_new_default(name,dir,presence) \
+ gst_pad_template_new ((name), (dir), (presence), gst_cairo_caps_default())
typedef GstCaps * (* GstCairoRestrictCapsFunction) (GstCaps *caps, gpointer data);
diff --git a/gst/cairo/gstcairocolorspace.c b/gst/cairo/gstcairocolorspace.c
index 323c175..8fcf889 100644
--- a/gst/cairo/gstcairocolorspace.c
+++ b/gst/cairo/gstcairocolorspace.c
@@ -117,9 +117,9 @@ gst_cairo_colorspace_base_init (gpointer klass)
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class,
- gst_cairo_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS));
+ gst_cairo_pad_template_new_any ("src", GST_PAD_SRC, GST_PAD_ALWAYS));
gst_element_class_add_pad_template (element_class,
- gst_cairo_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS));
+ gst_cairo_pad_template_new_any ("sink", GST_PAD_SINK, GST_PAD_ALWAYS));
gst_element_class_set_details_simple (element_class,
"Cairo Colorspace converter",
"Filter/Converter/Video",
diff --git a/gst/cairo/gstcairomixer.c b/gst/cairo/gstcairomixer.c
index 148354b..ae46b86 100644
--- a/gst/cairo/gstcairomixer.c
+++ b/gst/cairo/gstcairomixer.c
@@ -121,9 +121,10 @@ gst_cairo_mixer_base_init (gpointer g_class)
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_add_pad_template (element_class,
- gst_cairo_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS));
+ gst_cairo_pad_template_new_any ("src", GST_PAD_SRC, GST_PAD_ALWAYS));
gst_element_class_add_pad_template (element_class,
- gst_cairo_pad_template_new ("sink_%d", GST_PAD_SINK, GST_PAD_REQUEST));
+ gst_cairo_pad_template_new_any ("sink_%d", GST_PAD_SINK,
+ GST_PAD_REQUEST));
gst_element_class_set_details_simple (element_class, "Video mixer",
"Filter/Editor/Video",
diff --git a/gst/cairo/gstcairopuzzle.c b/gst/cairo/gstcairopuzzle.c
index 3a1ea82..b8b6f38 100644
--- a/gst/cairo/gstcairopuzzle.c
+++ b/gst/cairo/gstcairopuzzle.c
@@ -450,9 +450,9 @@ gst_cairo_puzzle_base_init (gpointer klass)
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class,
- gst_cairo_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS));
+ gst_cairo_pad_template_new_any ("src", GST_PAD_SRC, GST_PAD_ALWAYS));
gst_element_class_add_pad_template (element_class,
- gst_cairo_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS));
+ gst_cairo_pad_template_new_any ("sink", GST_PAD_SINK, GST_PAD_ALWAYS));
gst_element_class_set_details_simple (element_class,
"a simple puzzle",
"Filter/Effect/Video/Games",
diff --git a/gst/cairo/gstcairoscale.c b/gst/cairo/gstcairoscale.c
index e4cd2dc..4e08b28 100644
--- a/gst/cairo/gstcairoscale.c
+++ b/gst/cairo/gstcairoscale.c
@@ -171,9 +171,9 @@ gst_cairo_scale_base_init (gpointer klass)
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class,
- gst_cairo_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS));
+ gst_cairo_pad_template_new_any ("src", GST_PAD_SRC, GST_PAD_ALWAYS));
gst_element_class_add_pad_template (element_class,
- gst_cairo_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS));
+ gst_cairo_pad_template_new_any ("sink", GST_PAD_SINK, GST_PAD_ALWAYS));
gst_element_class_set_details_simple (element_class,
"Cairo Scale converter",
"Filter/Converter/Video",
diff --git a/gst/cairo/gstcairotestsrc.c b/gst/cairo/gstcairotestsrc.c
index 4e0d84a..7e2adcf 100644
--- a/gst/cairo/gstcairotestsrc.c
+++ b/gst/cairo/gstcairotestsrc.c
@@ -166,7 +166,7 @@ gst_cairo_test_src_base_init (gpointer g_class)
"David A. Schleef <ds@schleef.org>, " "Benjamin Otte <otte@gnome.org>");
gst_element_class_add_pad_template (element_class,
- gst_cairo_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS));
+ gst_cairo_pad_template_new_any ("src", GST_PAD_SRC, GST_PAD_ALWAYS));
}
static void