diff options
author | Benjamin Otte <otte@redhat.com> | 2010-04-19 17:14:07 +0200 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2010-04-19 17:14:07 +0200 |
commit | cf55f8482ad42ddf7457e5fe1e845329f5de94a6 (patch) | |
tree | ae3714b323164f922ec3efbbe04a5f9593a84188 | |
parent | e7af404f6a654a5fa1799896940227fd27d3f800 (diff) |
Add gst_cairo_caps_expand_surface_types() API
This allows filters to easily add surface types they support natively.
-rw-r--r-- | gst-libs/gst/cairo/gstcairocaps.c | 42 | ||||
-rw-r--r-- | gst-libs/gst/cairo/gstcairocaps.h | 2 |
2 files changed, 36 insertions, 8 deletions
diff --git a/gst-libs/gst/cairo/gstcairocaps.c b/gst-libs/gst/cairo/gstcairocaps.c index 738b73f..90a6a8d 100644 --- a/gst-libs/gst/cairo/gstcairocaps.c +++ b/gst-libs/gst/cairo/gstcairocaps.c @@ -109,32 +109,49 @@ gst_cairo_value_init_from_surface_types (GValue * value, } static GstCaps * -gst_cairo_caps_modify_surface_type_by_value (GstCaps * caps, +gst_cairo_caps_expand_surface_types_by_value (GstCaps * caps, const GValue * value) { guint i; for (i = 0; i < gst_caps_get_size (caps); i++) { GstStructure *check = gst_caps_get_structure (caps, i); + GValue unioned = { 0, }; if (!gst_cairo_structure_is_native (check)) continue; - gst_structure_set_value (check, "surface-type", value); + gst_value_union (&unioned, gst_structure_get_value (check, "surface-type"), + value); + gst_structure_set_value (check, "surface-type", &unioned); + g_value_unset (&unioned); } return caps; } -static GstCaps * -gst_cairo_caps_modify_surface_type (GstCaps * caps, +/** + * gst_cairo_caps_expand_surface_types: + * @caps: caps to expand. This function takes a reference to the caps. + * @types: The supported types to add to @caps. + * + * Modifies all native caps to also include the given surface @types. + * + * Returns: The expanded caps. + **/ +GstCaps * +gst_cairo_caps_expand_surface_types (GstCaps * caps, const cairo_surface_type_t * types) { GValue value = { 0, }; + g_return_val_if_fail (GST_IS_CAPS (caps), NULL); + + caps = gst_caps_make_writable (caps); gst_cairo_value_init_from_surface_types (&value, types); - gst_cairo_caps_modify_surface_type_by_value (caps, &value); + gst_cairo_caps_expand_surface_types_by_value (caps, &value); g_value_unset (&value); + return caps; } @@ -163,7 +180,16 @@ gst_cairo_caps_default (const cairo_surface_type_t * types) if (g_once_init_enter (&default_)) { GstCaps *caps = gst_caps_make_writable (gst_cairo_caps_any ()); - gst_cairo_caps_modify_surface_type (caps, NULL); + 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)); } @@ -172,7 +198,7 @@ gst_cairo_caps_default (const cairo_surface_type_t * types) return gst_caps_ref (GSIZE_TO_POINTER (default_)); else return - gst_cairo_caps_modify_surface_type (gst_caps_copy (GSIZE_TO_POINTER + gst_cairo_caps_expand_surface_types (gst_caps_copy (GSIZE_TO_POINTER (default_)), types); } @@ -206,7 +232,7 @@ gst_cairo_caps_expand (const GstCaps * caps, GstCairoFormatOption expand) if (expand & GST_CAIRO_FORMAT_FORMAT) { copy = gst_caps_make_writable (gst_cairo_caps_default (NULL)); if (gst_cairo_structure_is_native (expand_me)) { - copy = gst_cairo_caps_modify_surface_type_by_value (copy, + copy = gst_cairo_caps_expand_surface_types_by_value (copy, gst_structure_get_value (expand_me, "surface-type")); } } else { diff --git a/gst-libs/gst/cairo/gstcairocaps.h b/gst-libs/gst/cairo/gstcairocaps.h index a09be6b..9a959c8 100644 --- a/gst-libs/gst/cairo/gstcairocaps.h +++ b/gst-libs/gst/cairo/gstcairocaps.h @@ -32,6 +32,8 @@ GstCaps * gst_cairo_caps_default (const cairo_surface_typ GstCaps * gst_cairo_caps_expand (const GstCaps * caps, GstCairoFormatOption expand); +GstCaps * gst_cairo_caps_expand_surface_types (GstCaps * caps, + const cairo_surface_type_t * types); G_END_DECLS |