[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gstreamer-cvs
Subject:    gst-plugins-base: vorbistag: store DATE tag in GST_TAG_DATE_TIME instead of GST_TAG_DATE
From:       tpm () kemper ! freedesktop ! org (Tim Müller)
Date:       2012-06-28 13:21:04
Message-ID: 20120628132105.081491004A () kemper ! freedesktop ! org
[Download RAW message or body]

Module: gst-plugins-base
Branch: master
Commit: bc94374a8f28e3386161c401a25a88d818a70bb9
URL:    http://cgit.freedesktop.org/gstreamer/gst-plugins-base/commit/?id=bc94374a8f28e3386161c401a25a88d818a70bb9


Author: Oleksij Rempel <bug-track@fisher-privat.net>
Date:   Wed Jun 27 16:25:06 2012 +0200

vorbistag: store DATE tag in GST_TAG_DATE_TIME instead of GST_TAG_DATE

The DATE field may contain dates, partial dates, or dates with
time. Store the result in GST_TAG_DATE_TIME, so we can express
properly which fields are present or not, and can store the
time if there is one, and can serialise and deserialise the
tag without loss of information and without making up
information that's not there.

Instead of using short YYYY-MM-DD form we will store
long YYYY-MM-DDTHH:MM:SS+TS date and time.

According to this documentation we can do it:
http://wiki.xiph.org/VorbisComment#Date_and_time

This datetime format is needed by apps where more information
is needed. For example voice, meeting recording, etc.

https://bugzilla.gnome.org/show_bug.cgi?id=677712

---

 gst-libs/gst/tag/gstvorbistag.c |   65 ++++++++++++++-------------------------
 1 files changed, 23 insertions(+), 42 deletions(-)

diff --git a/gst-libs/gst/tag/gstvorbistag.c b/gst-libs/gst/tag/gstvorbistag.c
index d37ac83..e8f5f0b 100644
--- a/gst-libs/gst/tag/gstvorbistag.c
+++ b/gst-libs/gst/tag/gstvorbistag.c
@@ -64,7 +64,7 @@ static const GstTagEntryMatch tag_matches[] = {
   {GST_TAG_ORGANIZATION, "ORGANIZATION"},
   {GST_TAG_DESCRIPTION, "DESCRIPTION"},
   {GST_TAG_GENRE, "GENRE"},
-  {GST_TAG_DATE, "DATE"},
+  {GST_TAG_DATE_TIME, "DATE"},
   {GST_TAG_CONTACT, "CONTACT"},
   {GST_TAG_ISRC, "ISRC"},
   {GST_TAG_COMMENT, "COMMENT"},
@@ -272,38 +272,17 @@ gst_vorbis_tag_add (GstTagList * list, const gchar * tag, const \
gchar * value)  break;
     }
     default:{
-      if (tag_type == G_TYPE_DATE) {
-        guint y, d = 1, m = 1;
-        gchar *check = (gchar *) value;
-
-        y = strtoul (check, &check, 10);
-        if (*check == '-') {
-          check++;
-          m = strtoul (check, &check, 10);
-          if (*check == '-') {
-            check++;
-            d = strtoul (check, &check, 10);
-          }
-        }
-
-        /* accept dates like 2007-00-00 and 2007-05-00 */
-        if (y != 0) {
-          if (m == 0 && d == 0)
-            m = d = 1;
-          else if (m != 0 && d == 0)
-            d = 1;
-        }
+      if (tag_type == GST_TYPE_DATE_TIME) {
+        GstDateTime *datetime;
 
-        /* date might be followed by a time */
-        if ((*check == '\0' || g_ascii_isspace (*check)) && y != 0 &&
-            g_date_valid_dmy (d, m, y)) {
-          GDate *date;
+        datetime = gst_date_time_new_from_iso8601_string (value);
 
-          date = g_date_new_dmy (d, m, y);
-          gst_tag_list_add (list, GST_TAG_MERGE_APPEND, gst_tag, date, NULL);
-          g_date_free (date);
+        if (datetime) {
+          gst_tag_list_add (list, GST_TAG_MERGE_APPEND, gst_tag, datetime,
+              NULL);
+          gst_date_time_unref (datetime);
         } else {
-          GST_DEBUG ("skipping invalid date '%s' (%u,%u,%u)", value, y, m, d);
+          GST_WARNING ("could not parse datetime string '%s'", value);
         }
       } else {
         GST_WARNING ("Unhandled tag of type '%s' (%d)",
@@ -728,18 +707,20 @@ gst_tag_to_vorbis_comments (const GstTagList * list, const \
gchar * tag)  break;
       }
       default:{
-        if (tag_type == G_TYPE_DATE) {
-          GDate *date;
-
-          if (!gst_tag_list_get_date_index (list, tag, i, &date))
-            g_return_val_if_reached (NULL);
-
-          /* vorbis suggests using ISO date formats */
-          result =
-              g_strdup_printf ("%s=%04d-%02d-%02d", vorbis_tag,
-              (gint) g_date_get_year (date), (gint) g_date_get_month (date),
-              (gint) g_date_get_day (date));
-          g_date_free (date);
+        if (tag_type == GST_TYPE_DATE_TIME) {
+          GstDateTime *datetime;
+
+          if (gst_tag_list_get_date_time_index (list, tag, i, &datetime)) {
+            gchar *string;
+
+            /* vorbis suggests using ISO date formats:
+             * http://wiki.xiph.org/VorbisComment#Date_and_time */
+            string = gst_date_time_to_iso8601_string (datetime);
+            result = g_strdup_printf ("%s=%s", vorbis_tag, string);
+            g_free (string);
+
+            gst_date_time_unref (datetime);
+          }
         } else {
           GST_DEBUG ("Couldn't write tag %s", tag);
           continue;

_______________________________________________
gstreamer-commits mailing list
gstreamer-commits@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/gstreamer-commits


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic