*pending_tags = g_slist_delete_link (*pending_tags, entry);
}
+static void
+deserialize_xmp_rating (GstTagList * taglist, const gchar * gst_tag,
+ const gchar * xmp_tag, const gchar * str, GSList ** pending_tags)
+{
+ guint value;
+
+ if (sscanf (str, "%u", &value) != 1) {
+ GST_WARNING ("Failed to parse xmp:Rating %s", str);
+ return;
+ }
+
+ if (value < 0 || value > 100) {
+ GST_WARNING ("Unsupported Rating tag %u (should be from 0 to 100), "
+ "ignoring", value);
+ return;
+ }
+
+ gst_tag_list_add (taglist, GST_TAG_MERGE_REPLACE, gst_tag, value, NULL);
+}
+
/* look at this page for addtional schemas
* http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/XMP.html
*/
/* FIXME: we probably want GST_TAG_{,AUDIO_,VIDEO_}MIME_TYPE */
_xmp_tag_add_simple_mapping (GST_TAG_VIDEO_CODEC, "dc:format", NULL, NULL);
+ /* xap (xmp) schema */
+ _xmp_tag_add_simple_mapping (GST_TAG_USER_RATING, "xmp:Rating", NULL,
+ deserialize_xmp_rating);
+
/* exif schema */
_xmp_tag_add_simple_mapping (GST_TAG_GEO_LOCATION_LATITUDE,
"exif:GPSLatitude", serialize_exif_latitude, deserialize_exif_latitude);
switch (G_VALUE_TYPE (value)) {
case G_TYPE_STRING:
return g_markup_escape_text (g_value_get_string (value), -1);
+ case G_TYPE_INT:
+ return g_strdup_printf ("%d", g_value_get_int (value));
+ case G_TYPE_UINT:
+ return g_strdup_printf ("%u", g_value_get_uint (value));
default:
break;
}
g_date_free (date);
do_xmp_tag_serialization_deserialization (GST_TAG_DATE, &value);
g_value_unset (&value);
+
+ g_value_init (&value, G_TYPE_UINT);
+ g_value_set_uint (&value, 0);
+ do_xmp_tag_serialization_deserialization (GST_TAG_USER_RATING, &value);
+ g_value_set_uint (&value, 100);
+ do_xmp_tag_serialization_deserialization (GST_TAG_USER_RATING, &value);
+ g_value_set_uint (&value, 22);
+ do_xmp_tag_serialization_deserialization (GST_TAG_USER_RATING, &value);
+ g_value_unset (&value);
}
GST_END_TEST;