ext/metadata/: Reverting. Will need to wait for core 0.10.21 release.
authorStefan Kost <ensonic@users.sourceforge.net>
Thu, 2 Oct 2008 14:42:25 +0000 (14:42 +0000)
committerStefan Kost <ensonic@users.sourceforge.net>
Thu, 2 Oct 2008 14:42:25 +0000 (14:42 +0000)
Original commit message from CVS:
* ext/metadata/README:
* ext/metadata/metadataexif.c:
* ext/metadata/metadatatags.c:
* ext/metadata/metadatatags.h:
Reverting. Will need to wait for core 0.10.21 release.

ChangeLog
ext/metadata/README
ext/metadata/metadataexif.c
ext/metadata/metadatatags.c
ext/metadata/metadatatags.h

index c19df6a..bd4c52a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,14 @@
        * ext/metadata/metadataexif.c:
        * ext/metadata/metadatatags.c:
        * ext/metadata/metadatatags.h:
+         Reverting. Will need to wait for core 0.10.21 release.
+
+2008-10-02  Stefan Kost  <ensonic@users.sf.net>
+
+       * ext/metadata/README:
+       * ext/metadata/metadataexif.c:
+       * ext/metadata/metadatatags.c:
+       * ext/metadata/metadatatags.h:
          Use core gsp tags.
 
 2008-09-30  Sebastian Dröge  <sebastian.droege@collabora.co.uk>
index 999b463..f3cd20d 100644 (file)
@@ -87,12 +87,3 @@ Obs: By looking at the proposed design (1- view and 2- modify) seems that the me
   application could send width and height tag events to the pipeline
 * should metadatamux get info from caps (width and height) and use if not receive a event with such tags?
 
-
-Testing
-GST_DEBUG="*:2,metadata*:4" 
-gst-launch videotestsrc num-buffers=1 ! jpegenc ! taginject  tags="geo-location-latitude=66.1,geo-location-longitude=22.5,geo-location-elevation=10.3" ! metadatamux ! filesink location="meta_test.jpeg"
-exiv2 -pt pr meta_test.jpeg | grep "Exif.GPSInfo"
-exif meta_test.jpeg
-
-gst-launch -t filesrc location="meta_test.jpeg" ! metadatademux ! fakesink
-
index 58ffe6d..89c4e2b 100644 (file)
@@ -241,13 +241,13 @@ static MapIntStr mappedTags[] = {
    GST_TAG_IMAGE_YRESOLUTION             /*GST_TYPE_FRACTION*/},   /* inches */
 
   {EXIF_TAG_GPS_ALTITUDE,                /*RATIONAL,*/  EXIF_IFD_GPS,
-   GST_TAG_GEO_LOCATION_ELEVATION        /*G_TYPE_DOUBLE*/},
+   GST_TAG_GPS_ALTITUDE                  /*GST_TYPE_FRACTION*/},
 
   {EXIF_TAG_GPS_LATITUDE,                /*RATIONAL(3),*/  EXIF_IFD_GPS,
-   GST_TAG_GEO_LOCATION_LATITUDE         /*G_TYPE_DOUBLE*/},
+   GST_TAG_GPS_LATITUDE                  /*G_TYPE_STRING*/},
 
   {EXIF_TAG_GPS_LONGITUDE,               /*RATIONAL(3),*/  EXIF_IFD_GPS,
-   GST_TAG_GEO_LOCATION_LONGITUDE        /*G_TYPE_DOUBLE*/},
+   GST_TAG_GPS_LONGITUDE                 /*G_TYPE_STRING*/},
 
   {0, EXIF_IFD_COUNT, NULL}
 };
@@ -289,6 +289,13 @@ static gboolean metadataparse_exif_convert_to_datetime (GString * dt);
 
 static gboolean metadatamux_exif_convert_from_datetime (GString * dt);
 
+static gboolean
+metadatamux_exif_convert_from_gps (guint8 * data, const char *lt, char *ref);
+
+static gboolean
+metadataparse_exif_convert_to_gps (const guint8 * data, GString * lt,
+    const int exif_tag, const MEUserData * meudata);
+
 /*
  * extern functions implementations
  */
@@ -524,6 +531,7 @@ static void
 metadataparse_exif_content_foreach_entry_func (ExifEntry * entry,
     void *user_data)
 {
+  char buf[2048];
   MEUserData *meudata = (MEUserData *) user_data;
   GType type = G_TYPE_NONE;
   ExifByteOrder byte_order;
@@ -565,6 +573,14 @@ metadataparse_exif_content_foreach_entry_func (ExifEntry * entry,
           numerator = (gint) v_rat.numerator;
           denominator = (gint) v_rat.denominator;
         }
+        if (meudata->altitude_ref == 1) {
+          if (entry->tag == EXIF_TAG_GPS_ALTITUDE) {
+            if (numerator > 0)
+              numerator = -numerator;
+            if (denominator < 0)
+              denominator = -denominator;
+          }
+        }
         if (meudata->resolution_unit == 3) {
           /* converts from cm to inches */
           if (entry->tag == EXIF_TAG_X_RESOLUTION
@@ -594,7 +610,6 @@ metadataparse_exif_content_foreach_entry_func (ExifEntry * entry,
     switch (type) {
       case G_TYPE_STRING:
       {
-        char buf[2048];
         const gchar *str = exif_entry_get_value (entry, buf, sizeof (buf));
         GString *value = NULL;
 
@@ -611,6 +626,17 @@ metadataparse_exif_content_foreach_entry_func (ExifEntry * entry,
             str = NULL;
           }
 
+        } else if (entry->tag == EXIF_TAG_GPS_LATITUDE
+            || entry->tag == EXIF_TAG_GPS_LONGITUDE) {
+          value = g_string_new_len (str, 11);
+          /* 21 is enough memory to hold "DDD:MM:SSk" */
+          if (metadataparse_exif_convert_to_gps (entry->data, value,
+                  entry->tag, meudata)) {
+            str = value->str;
+          } else {
+            GST_ERROR ("Unexpected date & time format for %s", tag);
+            str = NULL;
+          }
         }
         if (str)
           gst_tag_list_add (meudata->taglist, meudata->mode, tag, str, NULL);
@@ -656,58 +682,28 @@ metadataparse_exif_content_foreach_entry_func (ExifEntry * entry,
         gst_tag_list_add (meudata->taglist, meudata->mode, tag, value, NULL);
       }
         break;
-      case G_TYPE_DOUBLE:
-      {
-        gdouble value = 0.0;
-
-        if (entry->tag == EXIF_TAG_GPS_LATITUDE
-            || entry->tag == EXIF_TAG_GPS_LONGITUDE) {
-          ExifRational *rt = (ExifRational *) entry->data;
-
-          /* DDD - degrees */
-          value = (gdouble) rt->numerator / (gdouble) rt->denominator;
-          rt++;
-
-          /* MM - minutes and SS - seconds */
-          if (rt->numerator % rt->denominator) {
-            value += (gdouble) rt->numerator / (gdouble) rt->denominator;
-          } else {
-            value += rt->numerator / rt->denominator;
-            rt++;
-            value += rt->numerator / rt->denominator;
-          }
-          GST_DEBUG ("long/lat : %lf", value);
-        }
-        if (entry->tag == EXIF_TAG_GPS_ALTITUDE) {
-          ExifRational v_rat = exif_get_rational (entry->data, byte_order);
-          value = (gdouble) v_rat.numerator / (gdouble) v_rat.denominator;
-          GST_DEBUG ("Altitude = %lf", value);
-        }
-        gst_tag_list_add (meudata->taglist, meudata->mode, tag, value, NULL);
-      }
-        break;
       default:
         break;
     }
+
   }
 
 
 done:
-  {
-    char buf[2048];
-    GST_LOG ("\n    Entry %p: %s (%s)\n"
-        "      Size, Comps: %d, %d\n"
-        "      Value: %s\n"
-        "      Title: %s\n"
-        "      Description: %s\n",
-        entry,
-        exif_tag_get_name (entry->tag),
-        exif_format_get_name (entry->format),
-        entry->size,
-        (int) (entry->components),
-        exif_entry_get_value (entry, buf, sizeof (buf)),
-        exif_tag_get_title (entry->tag), exif_tag_get_description (entry->tag));
-  }
+
+  GST_LOG ("\n    Entry %p: %s (%s)\n"
+      "      Size, Comps: %d, %d\n"
+      "      Value: %s\n"
+      "      Title: %s\n"
+      "      Description: %s\n",
+      entry,
+      exif_tag_get_name (entry->tag),
+      exif_format_get_name (entry->format),
+      entry->size,
+      (int) (entry->components),
+      exif_entry_get_value (entry, buf, sizeof (buf)),
+      exif_tag_get_title (entry->tag), exif_tag_get_description (entry->tag));
+
   return;
 
 }
@@ -758,53 +754,64 @@ metadataparse_handle_unit_tags (ExifEntry * entry, MEUserData * meudata,
               GST_TAG_IMAGE_YRESOLUTION, value * 0.4f, NULL);
         }
       }
+
       break;
     case EXIF_TAG_GPS_ALTITUDE_REF:
     {
-      gdouble value;
+      const GValue *value = gst_tag_list_get_value_index (meudata->taglist,
+          GST_TAG_GPS_ALTITUDE, 0);
 
       meudata->altitude_ref = entry->data[0];
 
-      if (gst_tag_list_get_double (meudata->taglist,
-              GST_TAG_GEO_LOCATION_ELEVATION, &value)) {
-        GST_DEBUG ("alt-ref: %d", meudata->altitude_ref);
-        if (((meudata->altitude_ref == 1) && (value > 0.0)) ||
-            ((meudata->altitude_ref == 0) && (value < 0.0))) {
-          gst_tag_list_add (meudata->taglist, GST_TAG_MERGE_REPLACE,
-              GST_TAG_GEO_LOCATION_ELEVATION, -value, NULL);
+      if (value) {
+        gint n, d;
+
+        n = gst_value_get_fraction_numerator (value);
+        d = gst_value_get_fraction_denominator (value);
+        if (meudata->altitude_ref == 1) {       /* bellow sea */
+          if (IS_FRACT_POSITIVE (n, d)) {       /* if n * d > 0 */
+            gst_tag_list_add (meudata->taglist, GST_TAG_MERGE_REPLACE,
+                GST_TAG_GPS_ALTITUDE, -n, d, NULL);
+          }
         }
       }
     }
       break;
     case EXIF_TAG_GPS_LATITUDE_REF:
     {
-      gdouble value;
+
+      gchar *value = NULL;
 
       meudata->latitude_ref = entry->data[0];
-      if (gst_tag_list_get_double (meudata->taglist,
-              GST_TAG_GEO_LOCATION_LATITUDE, &value)) {
-        GST_DEBUG ("lat-ref: %c", meudata->latitude_ref);
-        if (((meudata->latitude_ref == 'S') && (value > 0.0)) ||
-            ((meudata->latitude_ref == 'N') && (value < 0.0))) {
+      if (gst_tag_list_get_string (meudata->taglist, GST_TAG_GPS_LATITUDE,
+              &value)) {
+        GString *str = g_string_new (value);
+
+        if (str->len == 10) {
+          str->str[9] = meudata->latitude_ref;
           gst_tag_list_add (meudata->taglist, GST_TAG_MERGE_REPLACE,
-              GST_TAG_GEO_LOCATION_LATITUDE, -value, NULL);
+              GST_TAG_GPS_LATITUDE, str->str, NULL);
         }
+        g_string_free (str, TRUE);
       }
+
     }
       break;
     case EXIF_TAG_GPS_LONGITUDE_REF:
     {
-      gdouble value;
+      gchar *value = NULL;
 
       meudata->longitude_ref = entry->data[0];
-      if (gst_tag_list_get_double (meudata->taglist,
-              GST_TAG_GEO_LOCATION_LONGITUDE, &value)) {
-        GST_DEBUG ("lon-ref: %c", meudata->longitude_ref);
-        if (((meudata->longitude_ref == 'W') && (value > 0.0)) ||
-            ((meudata->longitude_ref == 'E') && (value < 0.0))) {
+      if (gst_tag_list_get_string (meudata->taglist, GST_TAG_GPS_LONGITUDE,
+              &value)) {
+        GString *str = g_string_new (value);
+
+        if (str->len == 10) {
+          str->str[9] = meudata->longitude_ref;
           gst_tag_list_add (meudata->taglist, GST_TAG_MERGE_REPLACE,
-              GST_TAG_GEO_LOCATION_LONGITUDE, -value, NULL);
+              GST_TAG_GPS_LONGITUDE, str->str, NULL);
         }
+        g_string_free (str, TRUE);
       }
     }
       break;
@@ -890,6 +897,33 @@ metadatamux_exif_for_each_tag_in_list (const GstTagList * list,
       {
         ExifRational r;
 
+        if (entry->tag == EXIF_TAG_GPS_ALTITUDE) {
+
+          ExifEntry *ref_entry = NULL;
+
+          ref_entry = exif_data_get_entry (ed, EXIF_TAG_GPS_ALTITUDE_REF);
+          if (ref_entry) {
+            exif_entry_ref (ref_entry);
+          } else {
+            ref_entry = exif_entry_new ();
+            exif_content_add_entry (ed->ifd[EXIF_IFD_GPS], ref_entry);
+            exif_entry_initialize (ref_entry, EXIF_TAG_GPS_ALTITUDE_REF);
+          }
+          if (ref_entry->data == NULL) {
+            ref_entry->format = EXIF_FORMAT_BYTE;
+            ref_entry->components = 1;
+            ref_entry->size = 1;
+            ref_entry->data = g_malloc (1);
+          }
+          /* if n * d > 0 */
+          if (IS_FRACT_POSITIVE (numerator, denominator)) {
+            ref_entry->data[0] = 0;
+          } else {
+            ref_entry->data[0] = 1;
+          }
+          exif_entry_unref (ref_entry);
+
+        }
         if (entry->tag == EXIF_TAG_X_RESOLUTION ||
             entry->tag == EXIF_TAG_Y_RESOLUTION) {
           ExifEntry *unit_entry = NULL;
@@ -926,12 +960,14 @@ metadatamux_exif_for_each_tag_in_list (const GstTagList * list,
     entry->data = g_malloc (entry->size);
     memcpy (entry->data, GST_BUFFER_DATA (buf), entry->size);
   } else {
+
     switch (type) {
       case G_TYPE_STRING:
       {
         gchar *value = NULL;
 
         if (gst_tag_list_get_string (list, tag, &value)) {
+
           if (entry->tag == EXIF_TAG_DATE_TIME_DIGITIZED
               || entry->tag == EXIF_TAG_DATE_TIME
               || entry->tag == EXIF_TAG_DATE_TIME_ORIGINAL) {
@@ -945,13 +981,45 @@ metadatamux_exif_for_each_tag_in_list (const GstTagList * list,
             g_free (value);
             value = datetime->str;
             g_string_free (datetime, FALSE);
-          } else if (value) {
+          } else if (entry->tag == EXIF_TAG_GPS_LATITUDE
+              || entry->tag == EXIF_TAG_GPS_LONGITUDE) {
+            char ref;
+
+            if (metadatamux_exif_convert_from_gps (entry->data, value, &ref)) {
+              ExifEntry *ref_entry = NULL;
+              const ExifTag ref_tag = entry->tag == EXIF_TAG_GPS_LATITUDE ?
+                  EXIF_TAG_GPS_LATITUDE_REF : EXIF_TAG_GPS_LONGITUDE_REF;
+
+              ref_entry = exif_data_get_entry (ed, ref_tag);
+              if (ref_entry) {
+                exif_entry_ref (ref_entry);
+              } else {
+                ref_entry = exif_entry_new ();
+                exif_content_add_entry (ed->ifd[EXIF_IFD_GPS], ref_entry);
+                exif_entry_initialize (ref_entry, ref_tag);
+              }
+              if (ref_entry->data == NULL) {
+                ref_entry->format = EXIF_FORMAT_ASCII;
+                ref_entry->components = 2;
+                ref_entry->size = 2;
+                ref_entry->data = g_malloc (2);
+              }
+              ref_entry->data[0] = ref;
+              ref_entry->data[1] = 0;
+              exif_entry_unref (ref_entry);
+            }
+            /* has already been add and it is not an Exif ASCII type */
+            g_free (value);
+            value = NULL;
+          }
+          if (value) {
             entry->components = strlen (value) + 1;
             entry->size =
                 exif_format_get_size (entry->format) * entry->components;
             entry->data = (guint8 *) value;
             value = NULL;
           }
+
         }
       }
         break;
@@ -990,89 +1058,6 @@ metadatamux_exif_for_each_tag_in_list (const GstTagList * list,
 
       }
         break;
-      case G_TYPE_DOUBLE:
-      {
-        gdouble value;
-
-        gst_tag_list_get_double (list, tag, &value);
-        if (entry->tag == EXIF_TAG_GPS_LATITUDE
-            || entry->tag == EXIF_TAG_GPS_LONGITUDE) {
-          ExifRational *rt = (ExifRational *) entry->data;
-          gdouble v = fabs (value);
-          ExifEntry *ref_entry = NULL;
-          char ref;
-          const ExifTag ref_tag = entry->tag == EXIF_TAG_GPS_LATITUDE ?
-              EXIF_TAG_GPS_LATITUDE_REF : EXIF_TAG_GPS_LONGITUDE_REF;
-
-          rt->numerator = (gulong) v;
-          rt->denominator = 1;
-          v -= rt->numerator;
-          rt++;
-
-          rt->numerator = (gulong) (0.5 + value * 100.0);
-          rt->denominator = 100;
-          rt++;
-
-          rt->numerator = 0;
-          rt->denominator = 1;
-
-          if (entry->tag == EXIF_TAG_GPS_LONGITUDE) {
-            GST_DEBUG ("longitude : %lf", value);
-            ref = (value < 0.0) ? 'W' : 'E';
-          } else {
-            GST_DEBUG ("latitude : %lf", value);
-            ref = (value < 0.0) ? 'S' : 'N';
-          }
-
-          ref_entry = exif_data_get_entry (ed, ref_tag);
-          if (ref_entry) {
-            exif_entry_ref (ref_entry);
-          } else {
-            ref_entry = exif_entry_new ();
-            exif_content_add_entry (ed->ifd[EXIF_IFD_GPS], ref_entry);
-            exif_entry_initialize (ref_entry, ref_tag);
-          }
-          if (ref_entry->data == NULL) {
-            ref_entry->format = EXIF_FORMAT_ASCII;
-            ref_entry->components = 2;
-            ref_entry->size = 2;
-            ref_entry->data = g_malloc (2);
-          }
-          ref_entry->data[0] = ref;
-          ref_entry->data[1] = 0;
-          exif_entry_unref (ref_entry);
-        } else if (entry->tag == EXIF_TAG_GPS_ALTITUDE) {
-          ExifEntry *ref_entry = NULL;
-          ExifRational *rt = (ExifRational *) entry->data;
-
-          rt->numerator = (gulong) fabs (10.0 * value);
-          rt->denominator = 10;
-
-          GST_DEBUG ("altitude : %lf", value);
-
-          ref_entry = exif_data_get_entry (ed, EXIF_TAG_GPS_ALTITUDE_REF);
-          if (ref_entry) {
-            exif_entry_ref (ref_entry);
-          } else {
-            ref_entry = exif_entry_new ();
-            exif_content_add_entry (ed->ifd[EXIF_IFD_GPS], ref_entry);
-            exif_entry_initialize (ref_entry, EXIF_TAG_GPS_ALTITUDE_REF);
-          }
-          if (ref_entry->data == NULL) {
-            ref_entry->format = EXIF_FORMAT_BYTE;
-            ref_entry->components = 1;
-            ref_entry->size = 1;
-            ref_entry->data = g_malloc (1);
-          }
-          if (value > 0.0) {
-            ref_entry->data[0] = 0;
-          } else {
-            ref_entry->data[0] = 1;
-          }
-          exif_entry_unref (ref_entry);
-        }
-      }
-        break;
       default:
         break;
     }
@@ -1286,4 +1271,172 @@ done:
 
 }
 
+/*
+ * metadatamux_exif_convert_from_gps:
+ * @data: pointer to an array of 3 ExifRational in which gps will be stored
+ * @lt: a string containing the gps coordinate formated as "DDD,MM,SSk"
+ * or "DDD,MM.mmk" (this is the same as specified in XMP).
+ * @ref: at the end will store the reference ('N', 'S', 'E', 'W')
+ *
+ * This function converts from the format "DDD,MM,SSk" or "DDD,MM.mmk"
+ * (the same as specified in XMP) into Exif coordinates.
+ * D- degrees, M- minutes, S- seconds, k- 'N', 'S', 'E', 'W'
+ * (North, South, East, West)
+ *
+ * Returns:
+ * <itemizedlist>
+ * <listitem><para>%TRUE if converted sucessfull
+ * </para></listitem>
+ * <listitem><para>%FALSE if @lt is bad formated
+ * </para></listitem>
+ * </itemizedlist>
+ */
+
+static gboolean
+metadatamux_exif_convert_from_gps (guint8 * data, const char *lt, char *ref)
+{
+  /* "DDD,MM,SSk" or "DDD,MM.mmk" */
+  /*  0123456789      0123456789 */
+  gboolean ret = TRUE;
+  char *p = (char *) lt;
+  ExifRational *rt = (ExifRational *) data;
+
+  if (strlen (lt) != 10)
+    goto error;
+
+  if (lt[6] == ',' || lt[6] == '.') {
+    if (IS_NUMBER (*p) && IS_NUMBER (*(p + 1)) && IS_NUMBER (*(p + 2))) {
+      rt->numerator = CHAR_TO_INT (*p) * 100;
+      p++;
+      rt->numerator += CHAR_TO_INT (*p) * 10;
+      p++;
+      rt->numerator += CHAR_TO_INT (*p);
+      p++;
+      rt->denominator = 1;
+    } else {
+      goto error;
+    }
+    p++;
+    rt++;
+    if (IS_NUMBER (*p) && IS_NUMBER (*(p + 1))) {
+      rt->numerator = CHAR_TO_INT (*p) * 10;
+      p++;
+      rt->numerator += CHAR_TO_INT (*p);
+      p++;
+      rt->denominator = 1;
+    } else {
+      goto error;
+    }
+    p++;
+    rt++;
+    if (IS_NUMBER (*p) && IS_NUMBER (*(p + 1))) {
+      rt->numerator = CHAR_TO_INT (*p) * 10;
+      p++;
+      rt->numerator += CHAR_TO_INT (*p);
+      p++;
+      rt->denominator = 1;
+    } else {
+      goto error;
+    }
+  } else {
+    goto error;
+  }
+
+  if (lt[9] != 'N' && lt[9] != 'S' && lt[9] != 'E' && lt[9] != 'W')
+    goto error;
+
+  *ref = lt[9];
+
+  goto done;
+error:
+
+  ret = FALSE;
+
+done:
+
+  return ret;
+
+}
+
+/*
+ * metadatamux_exif_convert_from_gps:
+ * @data: pointer to an array of 3 ExifRational from which gps will be read
+ * @lt: at the end this will have the gps coordinate formated as "DDD,MM,SSk"
+ * or "DDD,MM.mmk" (this is the same as specified in XMP).
+ * @exif_tag: EXIF_TAG_GPS_LATITUDE or EXIF_TAG_GPS_LONGITUDE
+ * @meudata: at the end will store the reference ('N', 'S', 'E', 'W')
+ * in @meudata->latitude_ref or meudata->longitude_ref depending on @exif_tag
+ *
+ * This function converts from Exif coordinates to the format "DDD,MM,SSk"
+ * or "DDD,MM.mmk" (the same as specified in XMP).
+ * D- degrees, M- minutes, S- seconds, k- 'N', 'S', 'E', 'W'
+ * (North, South, East, West)
+ * Precondition: @lt->allocated_len must be at least 11.
+ *
+ * Returns:
+ * <itemizedlist>
+ * <listitem><para>%TRUE if converted sucessfull
+ * </para></listitem>
+ * <listitem><para>%FALSE if error
+ * </para></listitem>
+ * </itemizedlist>
+ */
+
+static gboolean
+metadataparse_exif_convert_to_gps (const guint8 * data, GString * lt,
+    const int exif_tag, const MEUserData * meudata)
+{
+  ExifRational *rt = (ExifRational *) data;
+  char *str = lt->str;
+  gboolean ret = TRUE;
+  char ref;
+
+  if (lt->allocated_len < 11)
+    goto error;
+
+  if (exif_tag == EXIF_TAG_GPS_LATITUDE)
+    ref = meudata->latitude_ref;
+  else if (exif_tag == EXIF_TAG_GPS_LONGITUDE)
+    ref = meudata->longitude_ref;
+  else
+    goto error;
+
+  /* DDD - degrees */
+
+  sprintf (str, "%03u,", rt->numerator / rt->denominator);
+  rt++;
+  str += 4;
+
+  /* MM - minutes and SS - seconds */
+
+  if (rt->numerator % rt->denominator) {
+    sprintf (str, "%05.02f", (float) rt->numerator / (float) rt->denominator);
+    str += 5;
+    *str++ = ref;
+    *str = '\0';
+  } else {
+    sprintf (str, "%02u,", rt->numerator / rt->denominator);
+    str += 3;
+    rt++;
+    sprintf (str, "%02u", rt->numerator / rt->denominator);
+    str += 2;
+    *str++ = ref;
+    *str = '\0';
+  }
+
+  /* if here, everything is ok */
+  goto done;
+error:
+
+  ret = FALSE;
+
+done:
+
+  /* FIXME: do we need to check if the date is valid ? */
+
+  if (ret)
+    lt->len = 10;
+  return ret;
+}
+
 #endif /* else (ifndef HAVE_EXIF) */
index 82e6c38..b79830d 100644 (file)
@@ -427,6 +427,35 @@ metadata_tags_exif_register (void)
   gst_tag_register (GST_TAG_IMAGE_YRESOLUTION, GST_TAG_FLAG_META,
       GST_TYPE_FRACTION, GST_TAG_IMAGE_YRESOLUTION,
       "Vertical resolution in pixels per inch", NULL);
+
+  /* GPS tags */
+
+  /* Altitude:
+   * positive values means above the sea level
+   * negative values means under the sea level
+   */
+
+  gst_tag_register (GST_TAG_GPS_ALTITUDE, GST_TAG_FLAG_META,
+      GST_TYPE_FRACTION, GST_TAG_GPS_ALTITUDE, "Altitude", NULL);
+
+  /* Latitude:
+   * "DDD,MM,SSk" or "DDD,MM.mmk" fixed size string where:
+   * D- degrees, M- minutes, S-seconds,
+   * mm- fraction of minutes, k- N (north) or S (south)
+   */
+
+  gst_tag_register (GST_TAG_GPS_LATITUDE, GST_TAG_FLAG_META,
+      G_TYPE_STRING, GST_TAG_GPS_LATITUDE, "Latitude", NULL);
+
+  /* Longitude:
+   * "DDD,MM,SSk" or "DDD,MM.mmk" fixed size string where:
+   * D- degrees, M- minutes, S-seconds,
+   * mm- fraction of minutes, k- N (north) or S (south)
+   */
+
+  gst_tag_register (GST_TAG_GPS_LONGITUDE, GST_TAG_FLAG_META,
+      G_TYPE_STRING, GST_TAG_GPS_LONGITUDE, "Longitude", NULL);
+
 }
 
 /*
index 8500f15..004a17c 100644 (file)
@@ -116,10 +116,13 @@ typedef enum {
 #define GST_TAG_IMAGE_XRESOLUTION          "image-xresolution"
 #define GST_TAG_IMAGE_YRESOLUTION          "image-yresolution"
 
+#define GST_TAG_GPS_ALTITUDE               "gps-altitude"
 #define GST_TAG_GPS_AREA_INFORMATION       ""
 #define GST_TAG_GPS_DIFFERENTIAL           ""
 #define GST_TAG_GPS_DOP                    ""
 #define GST_TAG_GPS_IMAGE_DIRECTION        ""
+#define GST_TAG_GPS_LATITUDE               "gps-latitude"
+#define GST_TAG_GPS_LONGITUDE              "gps-longitude"
 #define GST_TAG_GPS_MEASURE_MODE           ""
 #define GST_TAG_GPS_PROCESSING_METHOD      ""
 #define GST_TAG_GPS_SATELLITES             ""