From f2c18c6c98b8e22ca7de43f76fea37f847e4b0e6 Mon Sep 17 00:00:00 2001 From: Thiago Santos Date: Wed, 23 Jun 2010 11:30:02 -0300 Subject: [PATCH] gststructure: Adds datetime getter function Adds gst_structure_get_date_time function API: gst_structure_get_date_time Fixes #594504 --- docs/gst/gstreamer-sections.txt | 1 + gst/gststructure.c | 42 +++++++++++++++++++++++++++++++++++++++++ gst/gststructure.h | 4 ++++ win32/common/libgstreamer.def | 1 + 4 files changed, 48 insertions(+) diff --git a/docs/gst/gstreamer-sections.txt b/docs/gst/gstreamer-sections.txt index 7a4b833..3f9920f 100644 --- a/docs/gst/gstreamer-sections.txt +++ b/docs/gst/gstreamer-sections.txt @@ -2085,6 +2085,7 @@ gst_structure_get_fourcc gst_structure_get_double gst_structure_get_string gst_structure_get_date +gst_structure_get_date_time gst_structure_get_clock_time gst_structure_get_enum gst_structure_get_fraction diff --git a/gst/gststructure.c b/gst/gststructure.c index 231e15e..39869d2 100644 --- a/gst/gststructure.c +++ b/gst/gststructure.c @@ -1310,6 +1310,48 @@ gst_structure_get_date (const GstStructure * structure, const gchar * fieldname, } /** + * gst_structure_get_date_time: + * @structure: a #GstStructure + * @fieldname: the name of a field + * @value: a pointer to a #GstDateTime to set + * + * Sets the datetime pointed to by @value corresponding to the datetime of the + * given field. Caller is responsible for making sure the field exists + * and has the correct type. + * + * On success @value will point to a reference of the datetime which + * should be unreffed with gst_date_time_unref() when no longer needed + * (note: this is inconsistent with e.g. gst_structure_get_string() + * which doesn't return a copy of the string). + * + * Returns: TRUE if the value could be set correctly. If there was no field + * with @fieldname or the existing field did not contain a data, this function + * returns FALSE. + */ +gboolean +gst_structure_get_date_time (const GstStructure * structure, + const gchar * fieldname, GstDateTime ** 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 (!GST_VALUE_HOLDS_DATE_TIME (&field->value)) + return FALSE; + + /* FIXME: 0.11 g_value_dup_boxed() -> g_value_get_boxed() */ + *value = g_value_dup_boxed (&field->value); + + return TRUE; +} + +/** * gst_structure_get_clock_time: * @structure: a #GstStructure * @fieldname: the name of a field diff --git a/gst/gststructure.h b/gst/gststructure.h index 05dc976..98f197b 100644 --- a/gst/gststructure.h +++ b/gst/gststructure.h @@ -23,6 +23,7 @@ #include #include #include +#include #include G_BEGIN_DECLS @@ -202,6 +203,9 @@ gboolean gst_structure_get_double (const GstStructure gboolean gst_structure_get_date (const GstStructure *structure, const gchar *fieldname, GDate **value); +gboolean gst_structure_get_date_time (const GstStructure *structure, + const gchar *fieldname, + GstDateTime **value); gboolean gst_structure_get_clock_time (const GstStructure *structure, const gchar *fieldname, GstClockTime *value); diff --git a/win32/common/libgstreamer.def b/win32/common/libgstreamer.def index 6c2da35..2a013ea 100644 --- a/win32/common/libgstreamer.def +++ b/win32/common/libgstreamer.def @@ -913,6 +913,7 @@ EXPORTS gst_structure_get_boolean gst_structure_get_clock_time gst_structure_get_date + gst_structure_get_date_time gst_structure_get_double gst_structure_get_enum gst_structure_get_field_type -- 2.7.4