From 66fd1a08391d7f85d7b9b49d5e37c9f04aac9310 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Sun, 12 Aug 2007 16:40:59 +0000 Subject: [PATCH] Add function to get uint from a structure. Original commit message from CVS: * docs/gst/gstreamer-sections.txt: * gst/gststructure.c: (gst_structure_get_uint): * gst/gststructure.h: Add function to get uint from a structure. API: gst_structure_get_uint() --- ChangeLog | 8 ++++++++ docs/gst/gstreamer-sections.txt | 1 + gst/gststructure.c | 36 ++++++++++++++++++++++++++++++++++++ gst/gststructure.h | 3 +++ 4 files changed, 48 insertions(+) diff --git a/ChangeLog b/ChangeLog index b2ae06c..725dca1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2007-08-12 Wim Taymans + * docs/gst/gstreamer-sections.txt: + * gst/gststructure.c: (gst_structure_get_uint): + * gst/gststructure.h: + Add function to get uint from a structure. + API: gst_structure_get_uint() + +2007-08-12 Wim Taymans + * gst/gstcaps.c: (gst_caps_set_simple_valist), (gst_caps_intersect): Fix proper check for simple caps. diff --git a/docs/gst/gstreamer-sections.txt b/docs/gst/gstreamer-sections.txt index 16722af..a0e9b3c 100644 --- a/docs/gst/gstreamer-sections.txt +++ b/docs/gst/gstreamer-sections.txt @@ -1768,6 +1768,7 @@ gst_structure_has_field gst_structure_has_field_typed gst_structure_get_boolean gst_structure_get_int +gst_structure_get_uint gst_structure_get_fourcc gst_structure_get_double gst_structure_get_string diff --git a/gst/gststructure.c b/gst/gststructure.c index 1ccb857..d837cb3 100644 --- a/gst/gststructure.c +++ b/gst/gststructure.c @@ -1043,6 +1043,42 @@ gst_structure_get_int (const GstStructure * structure, } /** + * gst_structure_get_uint: + * @structure: a #GstStructure + * @fieldname: the name of a field + * @value: a pointer to a uint to set + * + * Sets the uint pointed to by @value corresponding to the value of the + * given field. Caller is responsible for making sure the field exists + * and has the correct type. + * + * Returns: %TRUE if the value could be set correctly. If there was no field + * with @fieldname or the existing field did not contain a uint, this function + * returns %FALSE. + */ +gboolean +gst_structure_get_uint (const GstStructure * structure, + const gchar * fieldname, guint * value) +{ + GstStructureField *field; + + g_return_val_if_fail (structure != NULL, FALSE); + g_return_val_if_fail (fieldname != NULL, FALSE); + g_return_val_if_fail (value != NULL, FALSE); + + field = gst_structure_get_field (structure, fieldname); + + if (field == NULL) + return FALSE; + if (!G_VALUE_HOLDS_UINT (&field->value)) + return FALSE; + + *value = g_value_get_uint (&field->value); + + return TRUE; +} + +/** * gst_structure_get_fourcc: * @structure: a #GstStructure * @fieldname: the name of a field diff --git a/gst/gststructure.h b/gst/gststructure.h index 8bdfc84..0fc5031 100644 --- a/gst/gststructure.h +++ b/gst/gststructure.h @@ -167,6 +167,9 @@ gboolean gst_structure_get_boolean (const GstStructure gboolean gst_structure_get_int (const GstStructure *structure, const gchar *fieldname, gint *value); +gboolean gst_structure_get_uint (const GstStructure *structure, + const gchar *fieldname, + guint *value); gboolean gst_structure_get_fourcc (const GstStructure *structure, const gchar *fieldname, guint32 *value); -- 2.7.4