tag: xmp: Adds mapping for GST_TAG_CAPTURING_EXPOSURE_COMPENSATION

Adds mapping for GST_TAG_CAPTURING_EXPOSURE_COMPENSATION for xmp
library.

Includes unit tests.
This commit is contained in:
Thiago Santos 2011-04-13 23:17:14 -03:00
parent dae1c37dfe
commit e57473178b
2 changed files with 30 additions and 1 deletions

View file

@ -897,6 +897,9 @@ _init_xmp_tag_map (gpointer user_data)
_gst_xmp_schema_add_simple_mapping (schema, GST_TAG_GEO_LOCATION_LONGITUDE, _gst_xmp_schema_add_simple_mapping (schema, GST_TAG_GEO_LOCATION_LONGITUDE,
"exif:GPSLongitude", GST_XMP_TAG_TYPE_SIMPLE, serialize_exif_longitude, "exif:GPSLongitude", GST_XMP_TAG_TYPE_SIMPLE, serialize_exif_longitude,
deserialize_exif_longitude); deserialize_exif_longitude);
_gst_xmp_schema_add_simple_mapping (schema,
GST_TAG_CAPTURING_EXPOSURE_COMPENSATION, "exif:ExposureBiasValue",
GST_XMP_TAG_TYPE_SIMPLE, NULL, NULL);
/* compound exif tags */ /* compound exif tags */
array = g_ptr_array_sized_new (2); array = g_ptr_array_sized_new (2);
@ -984,7 +987,7 @@ static void
xmp_tags_initialize () xmp_tags_initialize ()
{ {
static GOnce my_once = G_ONCE_INIT; static GOnce my_once = G_ONCE_INIT;
g_once (&my_once, (GThreadFunc)_init_xmp_tag_map, NULL); g_once (&my_once, (GThreadFunc) _init_xmp_tag_map, NULL);
} }
typedef struct _GstXmpNamespaceMatch GstXmpNamespaceMatch; typedef struct _GstXmpNamespaceMatch GstXmpNamespaceMatch;
@ -1034,6 +1037,18 @@ read_one_tag (GstTagList * list, const gchar * tag, XmpTag * xmptag,
gst_tag_list_add (list, merge_mode, tag, v, NULL); gst_tag_list_add (list, merge_mode, tag, v, NULL);
break; break;
} }
case G_TYPE_DOUBLE:{
gdouble value = 0;
gint frac_n, frac_d;
if (sscanf (v, "%d/%d", &frac_n, &frac_d) == 2) {
gst_util_fraction_to_double (frac_n, frac_d, &value);
gst_tag_list_add (list, merge_mode, tag, value, NULL);
} else {
GST_WARNING ("Failed to parse fraction: %s", v);
}
break;
}
default: default:
if (tag_type == GST_TYPE_DATE_TIME) { if (tag_type == GST_TYPE_DATE_TIME) {
GstDateTime *datetime = NULL; GstDateTime *datetime = NULL;
@ -1461,6 +1476,8 @@ gst_value_serialize_xmp (const GValue * value)
return g_strdup_printf ("%d", g_value_get_int (value)); return g_strdup_printf ("%d", g_value_get_int (value));
case G_TYPE_UINT: case G_TYPE_UINT:
return g_strdup_printf ("%u", g_value_get_uint (value)); return g_strdup_printf ("%u", g_value_get_uint (value));
case G_TYPE_DOUBLE:
return double_to_fraction_string (g_value_get_double (value));
default: default:
break; break;
} }

View file

@ -945,6 +945,8 @@ GST_START_TEST (test_xmp_tags_serialization_deserialization)
GDate *date; GDate *date;
GstDateTime *datetime; GstDateTime *datetime;
gst_tag_register_musicbrainz_tags ();
g_value_init (&value, G_TYPE_STRING); g_value_init (&value, G_TYPE_STRING);
g_value_set_static_string (&value, "my string"); g_value_set_static_string (&value, "my string");
do_simple_xmp_tag_serialization_deserialization (GST_TAG_ARTIST, &value); do_simple_xmp_tag_serialization_deserialization (GST_TAG_ARTIST, &value);
@ -1055,6 +1057,16 @@ GST_START_TEST (test_xmp_tags_serialization_deserialization)
g_value_set_double (&value, 359.99); g_value_set_double (&value, 359.99);
do_simple_xmp_tag_serialization_deserialization do_simple_xmp_tag_serialization_deserialization
(GST_TAG_GEO_LOCATION_CAPTURE_DIRECTION, &value); (GST_TAG_GEO_LOCATION_CAPTURE_DIRECTION, &value);
g_value_set_double (&value, 0.0);
do_simple_xmp_tag_serialization_deserialization
(GST_TAG_CAPTURING_EXPOSURE_COMPENSATION, &value);
g_value_set_double (&value, 1.0);
do_simple_xmp_tag_serialization_deserialization
(GST_TAG_CAPTURING_EXPOSURE_COMPENSATION, &value);
g_value_set_double (&value, -2.5);
do_simple_xmp_tag_serialization_deserialization
(GST_TAG_CAPTURING_EXPOSURE_COMPENSATION, &value);
g_value_unset (&value); g_value_unset (&value);
g_value_init (&value, GST_TYPE_DATE); g_value_init (&value, GST_TYPE_DATE);