From 3449bfc30ebf78ac0e2a4a10455ccd2d9d9a5067 Mon Sep 17 00:00:00 2001 From: Thiago Santos Date: Wed, 21 Jul 2010 22:08:21 -0300 Subject: [PATCH] taglist: Add datetime get functions Adds _date_time_get and _date_time_get_index functions to taglist. API: gst_tag_list_get_date_time API: gst_tag_list_get_date_time_index Fixes #594504 --- docs/gst/gstreamer-sections.txt | 2 + gst/gsttaglist.c | 65 +++++++++++++++++++++++++++++++++ gst/gsttaglist.h | 8 ++++ win32/common/libgstreamer.def | 2 + 4 files changed, 77 insertions(+) diff --git a/docs/gst/gstreamer-sections.txt b/docs/gst/gstreamer-sections.txt index 4a2c0ead5f..868ca12f91 100644 --- a/docs/gst/gstreamer-sections.txt +++ b/docs/gst/gstreamer-sections.txt @@ -2268,6 +2268,8 @@ gst_tag_list_get_pointer gst_tag_list_get_pointer_index gst_tag_list_get_date gst_tag_list_get_date_index +gst_tag_list_get_date_time +gst_tag_list_get_date_time_index gst_tag_list_get_buffer gst_tag_list_get_buffer_index diff --git a/gst/gsttaglist.c b/gst/gsttaglist.c index f343d1bb58..bacbe4556f 100644 --- a/gst/gsttaglist.c +++ b/gst/gsttaglist.c @@ -1701,6 +1701,71 @@ gst_tag_list_get_date_index (const GstTagList * list, return (*value != NULL); } +/** + * gst_tag_list_get_date_time: + * @list: a #GstTagList to get the tag from + * @tag: tag to read out + * @value: address of a #GstDateTime pointer variable to store the result into + * + * Copies the first datetime for the given tag in the taglist into the variable + * pointed to by @value. Unref the date with gst_date_time_unref() when + * it is no longer needed. + * + * Returns: TRUE, if a datetime was copied, FALSE if the tag didn't exist in the + * given list or if it was #NULL. + * Since: 0.10.31 + */ +gboolean +gst_tag_list_get_date_time (const GstTagList * list, const gchar * tag, + GstDateTime ** value) +{ + GValue v = { 0, }; + + g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE); + g_return_val_if_fail (tag != NULL, FALSE); + g_return_val_if_fail (value != NULL, FALSE); + + if (!gst_tag_list_copy_value (&v, list, tag)) + return FALSE; + + g_return_val_if_fail (GST_VALUE_HOLDS_DATE_TIME (&v), FALSE); + + *value = (GstDateTime *) g_value_dup_boxed (&v); + g_value_unset (&v); + return (*value != NULL); +} + +/** + * gst_tag_list_get_date_time_index: + * @list: a #GstTagList to get the tag from + * @tag: tag to read out + * @index: number of entry to read out + * @value: location for the result + * + * Gets the datetime that is at the given index for the given tag in the given + * list and copies it into the variable pointed to by @value. Unref the datetime + * with gst_date_time_unref() when it is no longer needed. + * + * Returns: TRUE, if a value was copied, FALSE if the tag didn't exist in the + * given list or if it was #NULL. + * Since: 0.10.31 + */ +gboolean +gst_tag_list_get_date_time_index (const GstTagList * list, + const gchar * tag, guint index, GstDateTime ** value) +{ + const GValue *v; + + g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE); + g_return_val_if_fail (tag != NULL, FALSE); + g_return_val_if_fail (value != NULL, FALSE); + + if ((v = gst_tag_list_get_value_index (list, tag, index)) == NULL) + return FALSE; + *value = (GstDateTime *) g_value_dup_boxed (v); + return (*value != NULL); +} + /** * gst_tag_list_get_buffer: * @list: a #GstTagList to get the tag from diff --git a/gst/gsttaglist.h b/gst/gsttaglist.h index add6ea32ae..bafa647c71 100644 --- a/gst/gsttaglist.h +++ b/gst/gsttaglist.h @@ -23,6 +23,7 @@ #ifndef __GST_TAGLIST_H__ #define __GST_TAGLIST_H__ +#include #include #include #include @@ -363,6 +364,13 @@ gboolean gst_tag_list_get_date_index (const GstTagList * list, const gchar * tag, guint index, GDate ** value); +gboolean gst_tag_list_get_date_time (const GstTagList * list, + const gchar * tag, + GstDateTime ** value); +gboolean gst_tag_list_get_date_time_index (const GstTagList * list, + const gchar * tag, + guint index, + GstDateTime ** value); gboolean gst_tag_list_get_buffer (const GstTagList * list, const gchar * tag, GstBuffer ** value); diff --git a/win32/common/libgstreamer.def b/win32/common/libgstreamer.def index c9759cb563..6c2da35b33 100644 --- a/win32/common/libgstreamer.def +++ b/win32/common/libgstreamer.def @@ -980,6 +980,8 @@ EXPORTS gst_tag_list_get_char_index gst_tag_list_get_date gst_tag_list_get_date_index + gst_tag_list_get_date_time + gst_tag_list_get_date_time_index gst_tag_list_get_double gst_tag_list_get_double_index gst_tag_list_get_float