From f9e3b72ff6788030521d93d1fc29fed61bab40d2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 2 Nov 2009 09:22:37 +0100 Subject: [PATCH] structure: API: Add gst_structure_id_has_field{,_typed} --- docs/gst/gstreamer-sections.txt | 2 ++ gst/gststructure.c | 73 ++++++++++++++++++++++++++++++++--------- gst/gststructure.h | 5 +++ win32/common/libgstreamer.def | 2 ++ 4 files changed, 67 insertions(+), 15 deletions(-) diff --git a/docs/gst/gstreamer-sections.txt b/docs/gst/gstreamer-sections.txt index f6798e6..67f73b70 100644 --- a/docs/gst/gstreamer-sections.txt +++ b/docs/gst/gstreamer-sections.txt @@ -2054,6 +2054,8 @@ gst_structure_foreach gst_structure_n_fields gst_structure_has_field gst_structure_has_field_typed +gst_structure_id_has_field +gst_structure_id_has_field_typed gst_structure_get_boolean gst_structure_get_int gst_structure_get_uint diff --git a/gst/gststructure.c b/gst/gststructure.c index b3ceb4e..e23f712 100644 --- a/gst/gststructure.c +++ b/gst/gststructure.c @@ -1031,6 +1031,30 @@ gst_structure_map_in_place (GstStructure * structure, } /** + * gst_structure_id_has_field: + * @structure: a #GstStructure + * @field: #GQuark of the field name + * + * Check if @structure contains a field named @field. + * + * Returns: TRUE if the structure contains a field with the given name + * + * Since: 0.10.26 + */ +gboolean +gst_structure_id_has_field (const GstStructure * structure, GQuark field) +{ + GstStructureField *f; + + g_return_val_if_fail (structure != NULL, FALSE); + g_return_val_if_fail (field != 0, FALSE); + + f = gst_structure_id_get_field (structure, field); + + return (f != NULL); +} + +/** * gst_structure_has_field: * @structure: a #GstStructure * @fieldname: the name of a field @@ -1043,14 +1067,39 @@ gboolean gst_structure_has_field (const GstStructure * structure, const gchar * fieldname) { - GstStructureField *field; + g_return_val_if_fail (structure != NULL, FALSE); + g_return_val_if_fail (fieldname != NULL, FALSE); - g_return_val_if_fail (structure != NULL, 0); - g_return_val_if_fail (fieldname != NULL, 0); + return gst_structure_id_has_field (structure, + g_quark_from_string (fieldname)); +} - field = gst_structure_get_field (structure, fieldname); +/** + * gst_structure_id_has_field_typed: + * @structure: a #GstStructure + * @field: #GQuark of the field name + * @type: the type of a value + * + * Check if @structure contains a field named @field and with GType @type. + * + * Returns: TRUE if the structure contains a field with the given name and type + * + * Since: 0.10.16 + */ +gboolean +gst_structure_id_has_field_typed (const GstStructure * structure, + GQuark field, GType type) +{ + GstStructureField *f; + + g_return_val_if_fail (structure != NULL, FALSE); + g_return_val_if_fail (field != 0, FALSE); - return (field != NULL); + f = gst_structure_id_get_field (structure, field); + if (f == NULL) + return FALSE; + + return (G_VALUE_TYPE (&f->value) == type); } /** @@ -1067,19 +1116,13 @@ gboolean gst_structure_has_field_typed (const GstStructure * structure, const gchar * fieldname, GType type) { - GstStructureField *field; - - g_return_val_if_fail (structure != NULL, 0); - g_return_val_if_fail (fieldname != NULL, 0); - - field = gst_structure_get_field (structure, fieldname); - if (field == NULL) - return FALSE; + g_return_val_if_fail (structure != NULL, FALSE); + g_return_val_if_fail (fieldname != NULL, FALSE); - return (G_VALUE_TYPE (&field->value) == type); + return gst_structure_id_has_field_typed (structure, + g_quark_from_string (fieldname), type); } - /* utility functions */ /** diff --git a/gst/gststructure.h b/gst/gststructure.h index aa3aa5d..84e09aa 100644 --- a/gst/gststructure.h +++ b/gst/gststructure.h @@ -172,6 +172,11 @@ gboolean gst_structure_map_in_place (GstStructure gpointer user_data); gint gst_structure_n_fields (const GstStructure *structure); const gchar * gst_structure_nth_field_name (const GstStructure *structure, guint index); +gboolean gst_structure_id_has_field (const GstStructure *structure, + GQuark field); +gboolean gst_structure_id_has_field_typed (const GstStructure *structure, + GQuark field, + GType type); gboolean gst_structure_has_field (const GstStructure *structure, const gchar *fieldname); gboolean gst_structure_has_field_typed (const GstStructure *structure, diff --git a/win32/common/libgstreamer.def b/win32/common/libgstreamer.def index fc88756..869b227 100644 --- a/win32/common/libgstreamer.def +++ b/win32/common/libgstreamer.def @@ -905,6 +905,8 @@ EXPORTS gst_structure_id_get gst_structure_id_get_valist gst_structure_id_get_value + gst_structure_id_has_field + gst_structure_id_has_field_typed gst_structure_id_new gst_structure_id_set gst_structure_id_set_valist -- 2.7.4