gststructure: Adds datetime getter function
authorThiago Santos <thiago.sousa.santos@collabora.co.uk>
Wed, 23 Jun 2010 14:30:02 +0000 (11:30 -0300)
committerThiago Santos <thiago.sousa.santos@collabora.co.uk>
Mon, 26 Jul 2010 14:57:52 +0000 (11:57 -0300)
Adds gst_structure_get_date_time function

API: gst_structure_get_date_time

Fixes #594504

docs/gst/gstreamer-sections.txt
gst/gststructure.c
gst/gststructure.h
win32/common/libgstreamer.def

index 7a4b833..3f9920f 100644 (file)
@@ -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
index 231e15e..39869d2 100644 (file)
@@ -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
index 05dc976..98f197b 100644 (file)
@@ -23,6 +23,7 @@
 #include <gst/gstconfig.h>
 #include <glib-object.h>
 #include <gst/gstclock.h>
+#include <gst/gstdatetime.h>
 #include <gst/glib-compat.h>
 
 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);
index 6c2da35..2a013ea 100644 (file)
@@ -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