From 8efb5d2012bc57636016f3dbac523d732bc572ec Mon Sep 17 00:00:00 2001 From: Edgard Lima Date: Thu, 28 Feb 2008 10:41:56 +0000 Subject: Map Date-Time and GPS tags and Convert from EXIF to XMP Datatime as local time (those changes has been done in previo... Original commit message from CVS: Map Date-Time and GPS tags and Convert from EXIF to XMP Datatime as local time (those changes has been done in previous comit but had to be revert in 2008-02-10 due to frozen) --- ChangeLog | 12 + ext/metadata/TODO | 28 +- ext/metadata/metadata_mapping.htm | 340 ++++++++++++++---- ext/metadata/metadataexif.c | 723 ++++++++++++++++++++++++++++++++++++-- ext/metadata/metadatatags.c | 69 ++++ ext/metadata/metadatatags.h | 19 + tests/icles/metadata_editor.c | 34 +- 7 files changed, 1120 insertions(+), 105 deletions(-) diff --git a/ChangeLog b/ChangeLog index f964c422c..ccc581d86 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2008-02-28 Edgard Lima + + * ext/metadata/TODO: + * ext/metadata/metadata_mapping.htm: + * ext/metadata/metadataexif.c: + * ext/metadata/metadatatags.c: + * ext/metadata/metadatatags.h: + * tests/icles/metadata_editor.c: + Map Date-Time and GPS tags and Convert from EXIF to XMP Datatime as + local time (those changes has been done in previous comit but had to + be revert in 2008-02-10 due to frozen) + 2008-02-27 Zaheer Abbas Merali * sys/dvb/camutils.c: diff --git a/ext/metadata/TODO b/ext/metadata/TODO index 62ad06d87..e028df46c 100644 --- a/ext/metadata/TODO +++ b/ext/metadata/TODO @@ -3,7 +3,8 @@ This file contains a list of things to be done as well some open issues (questio INFO: -1- to see what tags are mapped so far run 'grep -n GST_TAG *.[ch]' into this folder. +1- To see the list of tags current mapped: + http://webcvs.freedesktop.org/gstreamer/gst-plugins-bad/ext/metadata/metadata_mapping.htm?view=co TODO: @@ -12,6 +13,9 @@ TODO: 3- Review the code (in order to move to gst-plugins-good) 4- Document how the plugin works (atchitecture and interaction beteween modules) 5- Improve the test application (to save also in png and to make it possible to set the metadata elements properties) +6- Implement GDateTime support in GLib to be used by GStreamer (http://bugzilla.gnome.org/show_bug.cgi?id=50076) +7- Use a standard GStreamer Data-Time type to map our Data-time tags +8- Make the correct merge mode for multiple value tags (bag and seq) like dc:creator, ... OPEN ISSUES: @@ -23,26 +27,32 @@ OPEN ISSUES: 4- Add GST_TYPE_FRACTION support for GStreamer TAGS 5- currently, in JPEG files, if there is a Photoshop segment, everything inside it but IPTC will be lost. From the point of view of implementation it is easy, but I still don't now how to solve from the point of view of "designing". Anyway I think it is not so important. 6- language is not considered in XMP (How to do it with GStreamer?) -7- Add a helper function that convert from value to string. For example, aperture-size is 2.7 and the app wants to show "f/2.7", 'contrast' is a range and the app wants to show as "Normal", "Soft", "Hard". For the time being it is up to the APP to make this conversion. +7- Add a helper function that convert from value to string. For example, +aperture-size is 2.7 and the app wants to show "f/2.7", 'contrast' is a range +and the app wants to show as "Normal", "Soft", "Hard". For the time being it is +up to the APP to make this conversion. LINKS IN BUGZILA 1- to move to good -http://bugzilla.gnome.org/show_bug.cgi?id=513182 + http://bugzilla.gnome.org/show_bug.cgi?id=513182 2- Proposal of new tags -http://bugzilla.gnome.org/show_bug.cgi?id=482947 + http://bugzilla.gnome.org/show_bug.cgi?id=482947 + http://bugzilla.gnome.org/show_bug.cgi?id=481169 3- Discussion about the architecture -http://bugzilla.gnome.org/show_bug.cgi?id=486659 + http://bugzilla.gnome.org/show_bug.cgi?id=486659 4- Also extraction image width and height and set caps properly -http://bugzilla.gnome.org/show_bug.cgi?id=503616 + http://bugzilla.gnome.org/show_bug.cgi?id=503616 KNOWN BUGS bugs in libexif: -https://sourceforge.net/tracker/?func=detail&atid=112272&aid=1884609&group_id=12272 +1- https://sourceforge.net/tracker/?func=detail&atid=112272&aid=1884609&group_id=12272 -1- EXIF_TAG_ISO_SPEED_RATINGS should be in EXIF_IFD_EXIF -2- EXIF_TAG_ISO_SPEED_RATINGS is not inserted anyway + a- EXIF_TAG_ISO_SPEED_RATINGS should be in EXIF_IFD_EXIF + b- EXIF_TAG_ISO_SPEED_RATINGS is not inserted anyway +2- EXIF_TAG_FLASH can't be written from the scratch +3- GST_TAG_CAPTURE_COLOR_SPACE can't be written from the scratch diff --git a/ext/metadata/metadata_mapping.htm b/ext/metadata/metadata_mapping.htm index 4c5508aec..64c14d1cb 100644 --- a/ext/metadata/metadata_mapping.htm +++ b/ext/metadata/metadata_mapping.htm @@ -7,7 +7,10 @@ - + + + + @@ -197,29 +200,32 @@ -

-

+

-

-

GST_TAG_CAPTURE_COLOR_SPACE

+

GST_TAG_CAPTURE_COLOR_SPACE

-

"capture-color-space"

+

"capture-color-space"

-

G_TYPE_UINT

+

G_TYPE_UINT

-

1- - sRGB;
0xFFFF - Uncalibrated

+

1- + sRGB;
0xFFFF - Uncalibrated

-

EXIF_TAG_COLOR_SPACE

+

EXIF_TAG_COLOR_SPACE

+

BUG + in libexif. Can't be created in a exif data created from the + scratch

-

-

+

-

-

-

+

-

@@ -321,7 +327,7 @@

0- - Auto exposure;
1- Manual exposure;
2- Auto bracket (the + Auto exposure;
1- Manual exposure;
2- Auto bracket (the camera shoots a series of frames of the same scene at different exposure settings)

@@ -602,8 +608,7 @@ -


-

+

-

GST_TAG_CAPTURE_ORIENTATION

@@ -782,20 +787,28 @@

-

-

GST_TAG_DEVICE_MAKE

+

GST_TAG_DATE_TIME_DIGITIZED

-

"device-make"

+

"date-time-digitized"

G_TYPE_STRING

-

The - manufacturer of the recording equipment

+

Date/Time + of image digitized
formated as subset + of ISO RFC + 8601:
YYYY
YYYY-MM
YYYY-MM-DD
YYYY-MM-DDThh:mmTZD
YYYY-MM-DDThh:mm:ssTZD
YYYY-MM-DDThh:mm:ss.sTZD
where:
YYYY + = four-digit year;
MM = two-digit month (01=January);
DD = + two-digit day of month (01 through 31);
hh = two digits of hour + (00 through 23);
mm = two digits of minute (00 through 59);
ss + = two digits of second (00 through 59);
s = one or more digits + representing a decimal fraction of a second;
TZD = time zone + designator (Z or +hh:mm or -hh:mm)

-

EXIF_TAG_MAKE

+

EXIF_TAG_DATE_TIME_DIGITIZED

-

@@ -809,21 +822,131 @@

-

-

GST_TAG_DEVICE_MODEL

+

GST_TAG_DATE_TIME_MODIFIED

-

"device-model"

+

"date-time-modified"

+ + +

G_TYPE_STRING

+ + +

Date/Time + of image was last modified
the same format as + GST_TAG_DATE_TIME_DIGITIZED

+ + +

EXIF_TAG_DATE_TIME

+ + +

-

+ + +

-

+ + + + +

-

+ + +

GST_TAG_DATE_TIME_ORIGINAL

+ + +

"date-time-original"

+ + +

G_TYPE_STRING

+ + +

Date/Time + of original image taken
the same format as + GST_TAG_DATE_TIME_DIGITIZED

+ + +

EXIF_TAG_DATE_TIME_ORIGINAL

+ + +

-

+ + +

-

+ + + + +

-

+ + +

GST_TAG_DEVICE_MAKE

+ + +

"device-make"

G_TYPE_STRING

The - model name or model number of the equipment

+ manufacturer of the recording equipment

+

EXIF_TAG_MAKE

+ + +

-

+ + +

-

+ + + + +

-

+ + +

GST_TAG_DEVICE_MODEL

+ + +

"device-model"

+ + +

G_TYPE_STRING

+ + +

The + model name or model number of the equipment

+ +

EXIF_TAG_MODEL

+ +

-

+ + +

-

+ + + + +

-

+ + +

GST_TAG_EXIF_MAKER_NOTE

+ + +

"exif-maker-note"

+ + +

GST_TYPE_BUFFER

+ + +

Camera + private data

+ + +

EXIF_TAG_MAKER_NOTE

+

-

@@ -836,20 +959,20 @@

-

-

GST_TAG_IMAGE_HEIGHT

+

GST_TAG_GPS_ALTITUDE

-

"image-height"

+

"gps-altitude"

-

G_TYPE_UINT

+

GST_TYPE_FRACTION

-

Image - height in pixels

+

Altitude + (positive means abive sea and negative bellow sea)

-

EXIF_TAG_PIXEL_Y_DIMENSION

+

EXIF_TAG_GPS_ALTITUDE

-

@@ -863,20 +986,76 @@

-

-

GST_TAG_IMAGE_WIDTH

+

GST_TAG_GPS_LATITUDE

-

"image-width"

+

"gps-latitude"

+ + +

G_TYPE_STRING

+ + +

Latitude + in the same format as specified in XMP:
"DDD,MM,SSk" + or "DDD,MM.mmk"
D- degrees
M- minutes
S- + seconds
k- 'N', 'S', 'E', 'W' (North, South, East, West)

+ + +

EXIF_TAG_GPS_LATITUDE

+ + +

-

+ + +

-

+ + + + +

-

+ + +

GST_TAG_GPS_LONGITUDE

+ + +

"gps-longitude"

+ + +

G_TYPE_STRING

+ + +

Longitude. + The format is the sames as GST_TAG_GPS_LATITUDE

+ + +

EXIF_TAG_GPS_LONGITUDE

+ + +

-

+ + +

-

+ + + + +

-

+ + +

GST_TAG_IMAGE_HEIGHT

+ + +

"image-height"

G_TYPE_UINT

Image - width in pixels

+ height in pixels

-

EXIF_TAG_PIXEL_X_DIMENSION

+

EXIF_TAG_PIXEL_Y_DIMENSION

-

@@ -890,21 +1069,20 @@

-

-

GST_TAG_IMAGE_XRESOLUTION

+

GST_TAG_IMAGE_WIDTH

-

"image-xresolution"

+

"image-width"

-

GST_TYPE_FRACTION

+

G_TYPE_UINT

-

Horizontal - resolution in pixels per inch.
Here it is always in inches.
In - EXIF it depends on EXIF_TAG_RESOLUTION_UNIT

+

Image + width in pixels

-

EXIF_TAG_X_RESOLUTION

+

EXIF_TAG_PIXEL_X_DIMENSION

-

@@ -918,21 +1096,21 @@

-

-

GST_TAG_IMAGE_YRESOLUTION

+

GST_TAG_IMAGE_XRESOLUTION

-

"image-yresolution"

+

"image-xresolution"

GST_TYPE_FRACTION

-

Vertical +

Horizontal resolution in pixels per inch.
Here it is always in inches.
In EXIF it depends on EXIF_TAG_RESOLUTION_UNIT

-

EXIF_TAG_Y_RESOLUTION

+

EXIF_TAG_X_RESOLUTION

-

@@ -943,27 +1121,27 @@ -

GST_TAG_COMPOSER

+

-

-

-

+

GST_TAG_IMAGE_YRESOLUTION

-

"composer"

+

"image-yresolution"

-

G_TYPE_STRING

+

GST_TYPE_FRACTION

-

Name - of the creator of the object, e.g. writer, photographer or graphic - artist.

+

Vertical + resolution in pixels per inch.
Here it is always in inches.
In + EXIF it depends on EXIF_TAG_RESOLUTION_UNIT

-

-

+

EXIF_TAG_Y_RESOLUTION

-

IPTC_TAG_BYLINE

+

-

-

@@ -971,82 +1149,110 @@ -

GST_TAG_COPYRIGHT

+

GST_TAG_COMPOSER

-

-

"copyright"

+

"composer"

G_TYPE_STRING

-

Any - necessary copyright notice.

+

Name + of the creator of the object, e.g. writer, photographer or graphic + artist.

-

-

IPTC_TAG_COPYRIGHT_NOTICE

+

IPTC_TAG_BYLINE

-

dc:rights”

+

-

-

GST_TAG_DESCRIPTION

+

GST_TAG_COPYRIGHT

-

-

"description"

+

"copyright"

G_TYPE_STRING

-

A - textual description of the data

+

Any + necessary copyright notice.

-

-

IPTC_TAG_CAPTION

+

IPTC_TAG_COPYRIGHT_NOTICE

-

dc:description”

+

dc:rights”

-

GST_TAG_TITLE

+

GST_TAG_DESCRIPTION

-

-

"title"

+

"description"

G_TYPE_STRING

A - shorthand reference for the object.

+ textual description of the data

-

-

IPTC_TAG_OBJECT_NAME

+

IPTC_TAG_CAPTION

+

dc:description”

+ + + + +

GST_TAG_TITLE

+ + +

-

+ + +

"title"

+ + +

G_TYPE_STRING

+ + +

A + shorthand reference for the object.

+ + +

-

+ + +

IPTC_TAG_OBJECT_NAME

+ +

dc:title”

diff --git a/ext/metadata/metadataexif.c b/ext/metadata/metadataexif.c index 14527fb6b..c5b8f80d8 100644 --- a/ext/metadata/metadataexif.c +++ b/ext/metadata/metadataexif.c @@ -114,6 +114,7 @@ metadatamux_exif_create_chunk_from_tag_list (guint8 ** buf, guint32 * size, #include #include #include +#include /* * enum and types @@ -124,6 +125,9 @@ typedef struct _tag_MEUserData GstTagList *taglist; GstTagMergeMode mode; ExifShort resolution_unit; /* 2- inches (default), 3- cm */ + int altitude_ref; /* -1- not specified, 0- above sea, 1- bellow sea */ + gchar latitude_ref; /* k- not specified, 'N'- north, 'S'- south */ + gchar longitude_ref; /* k- not specified, 'E'- north, 'W'- south */ } MEUserData; typedef struct _tag_MapIntStr @@ -203,17 +207,29 @@ static MapIntStr mappedTags[] = { {EXIF_TAG_SOFTWARE, /*ASCII,*/ EXIF_IFD_0, GST_TAG_CREATOR_TOOL /*G_TYPE_STRING*/}, + {EXIF_TAG_DATE_TIME_DIGITIZED, /*ASCII,*/ EXIF_IFD_EXIF, + GST_TAG_DATE_TIME_DIGITIZED /*G_TYPE_STRING*/}, + + {EXIF_TAG_DATE_TIME, /*ASCII,*/ EXIF_IFD_0, + GST_TAG_DATE_TIME_MODIFIED /*G_TYPE_STRING*/}, + + {EXIF_TAG_DATE_TIME_ORIGINAL, /*ASCII,*/ EXIF_IFD_EXIF, + GST_TAG_DATE_TIME_ORIGINAL /*G_TYPE_STRING*/}, + {EXIF_TAG_MAKE, /*ASCII,*/ EXIF_IFD_0, GST_TAG_DEVICE_MAKE /*G_TYPE_STRING*/}, {EXIF_TAG_MODEL, /*ASCII,*/ EXIF_IFD_0, GST_TAG_DEVICE_MODEL /*G_TYPE_STRING*/}, + {EXIF_TAG_MAKER_NOTE, /*UNDEFINED(size any)*/ EXIF_IFD_EXIF, + GST_TAG_EXIF_MAKER_NOTE /*GST_TYPE_BUFFER*/}, + {EXIF_TAG_PIXEL_Y_DIMENSION, /*LONG,*/ EXIF_IFD_EXIF, - GST_TAG_IMAGE_HEIGHT /*G_TYPE_INT*/}, /* inches */ + GST_TAG_IMAGE_HEIGHT /*G_TYPE_INT*/}, {EXIF_TAG_PIXEL_X_DIMENSION, /*LONG,*/ EXIF_IFD_EXIF, - GST_TAG_IMAGE_WIDTH /*G_TYPE_INT*/}, /* inches */ + GST_TAG_IMAGE_WIDTH /*G_TYPE_INT*/}, {EXIF_TAG_X_RESOLUTION, /*RATIONAL,*/ EXIF_IFD_0, GST_TAG_IMAGE_XRESOLUTION /*GST_TYPE_FRACTION*/}, /* inches */ @@ -221,10 +237,24 @@ static MapIntStr mappedTags[] = { {EXIF_TAG_Y_RESOLUTION, /*RATIONAL,*/ EXIF_IFD_0, GST_TAG_IMAGE_YRESOLUTION /*GST_TYPE_FRACTION*/}, /* inches */ + {EXIF_TAG_GPS_ALTITUDE, /*RATIONAL,*/ EXIF_IFD_GPS, + GST_TAG_GPS_ALTITUDE /*GST_TYPE_FRACTION*/}, + + {EXIF_TAG_GPS_LATITUDE, /*RATIONAL(3),*/ EXIF_IFD_GPS, + GST_TAG_GPS_LATITUDE /*G_TYPE_STRING*/}, + + {EXIF_TAG_GPS_LONGITUDE, /*RATIONAL(3),*/ EXIF_IFD_GPS, + GST_TAG_GPS_LONGITUDE /*G_TYPE_STRING*/}, + {0, EXIF_IFD_COUNT, NULL} }; /* *INDENT-ON* */ +#define IS_NUMBER(n) ('0' <= (n) && (n) <= '9') +#define IS_FRACT_POSITIVE(n,d) \ + ( ! ( ((n) >> (sizeof(n)*8-1)) ^ ((d) >> (sizeof(d)*8-1)) ) ) +#define CHAR_TO_INT(c) ((c) - '0') + /* * static helper functions declaration */ @@ -244,10 +274,25 @@ static void metadataparse_exif_content_foreach_entry_func (ExifEntry * entry, void *user_data); +static gboolean +metadataparse_handle_unit_tags (ExifEntry * entry, MEUserData * meudata, + const ExifByteOrder byte_order); + static void metadatamux_exif_for_each_tag_in_list (const GstTagList * list, const gchar * tag, gpointer user_data); +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 */ @@ -274,7 +319,7 @@ metadataparse_exif_tag_list_add (GstTagList * taglist, GstTagMergeMode mode, const guint8 *buf; guint32 size; ExifData *exif = NULL; - MEUserData user_data = { taglist, mode, 2 }; + MEUserData user_data = { taglist, mode, 2, -1, 'k', 'k' }; if (adapter == NULL || (size = gst_adapter_available (adapter)) == 0) { goto done; @@ -457,7 +502,7 @@ metadataparse_exif_data_foreach_content_func (ExifContent * content, { ExifIfd ifd = exif_content_get_ifd (content); - if (ifd == EXIF_IFD_0 || ifd == EXIF_IFD_EXIF) { + if (ifd == EXIF_IFD_0 || ifd == EXIF_IFD_EXIF || ifd == EXIF_IFD_GPS) { GST_LOG ("\n Content %p: %s (ifd=%d)", content, exif_ifd_get_name (ifd), ifd); @@ -494,23 +539,8 @@ metadataparse_exif_content_foreach_entry_func (ExifEntry * entry, return; byte_order = exif_data_get_byte_order (entry->parent->parent); - if (entry->tag == EXIF_TAG_RESOLUTION_UNIT) { - meudata->resolution_unit = exif_get_short (entry->data, byte_order); - if (meudata->resolution_unit == 3) { - /* if [xy]resolution has alredy been add in cm, replace it in inches */ - gfloat value; - - if (gst_tag_list_get_float (meudata->taglist, GST_TAG_IMAGE_XRESOLUTION, - &value)) - gst_tag_list_add (meudata->taglist, GST_TAG_MERGE_REPLACE, - GST_TAG_IMAGE_XRESOLUTION, value * 0.4f, NULL); - if (gst_tag_list_get_float (meudata->taglist, GST_TAG_IMAGE_YRESOLUTION, - &value)) - gst_tag_list_add (meudata->taglist, GST_TAG_MERGE_REPLACE, - GST_TAG_IMAGE_YRESOLUTION, value * 0.4f, NULL); - } + if (metadataparse_handle_unit_tags (entry, meudata, byte_order)) goto done; - } if (!tag) goto done; @@ -540,6 +570,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 @@ -558,12 +596,50 @@ metadataparse_exif_content_foreach_entry_func (ExifEntry * entry, gst_tag_list_add (meudata->taglist, meudata->mode, tag, numerator, denominator, NULL); + } else if (type == GST_TYPE_BUFFER) { + GstBuffer *buf = gst_buffer_new_and_alloc (entry->components); + + memcpy (GST_BUFFER_DATA (buf), entry->data, entry->components); + gst_tag_list_add (meudata->taglist, meudata->mode, tag, buf, NULL); + gst_buffer_unref (buf); } else { switch (type) { case G_TYPE_STRING: - gst_tag_list_add (meudata->taglist, meudata->mode, tag, - exif_entry_get_value (entry, buf, sizeof (buf)), NULL); + { + const gchar *str = exif_entry_get_value (entry, buf, sizeof (buf)); + GString *value = NULL; + + if (entry->tag == EXIF_TAG_DATE_TIME_DIGITIZED + || entry->tag == EXIF_TAG_DATE_TIME + || entry->tag == EXIF_TAG_DATE_TIME_ORIGINAL) { + value = g_string_new_len (str, 20); + /* 20 is enough memory to hold "YYYY-MM-DDTHH:MM:SS" */ + + if (metadataparse_exif_convert_to_datetime (value)) { + str = value->str; + } else { + GST_ERROR ("Unexpected date & time format for %s", tag); + 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); + if (value) + g_string_free (value, TRUE); + } break; case G_TYPE_INT: /* fall through */ @@ -629,6 +705,122 @@ done: } +/* + * metadataparse_handle_unit_tags: + * @entry: The exif entry that is supposed to have a tag that makes reference + * to other tag + * @meudata: contains references that can be used afterwards and the tag list + * @byte_order: used to read Exif values + * + * This function tries to parse Exif tags that are not mapped to Gst tags + * but makes reference to another Exif-Gst mapped tag. For example, + * 'resolution-unit' that says the units of 'image-xresolution', so proper + * conversion is done or a hint to the conversion is stored to @meudata + * to be used afterwards. + * + * Returns: + * + * %TRUE if the @entry->tag was handled + * + * %FALSE if this function does'n handle @entry->tag + * + * + */ + +static gboolean +metadataparse_handle_unit_tags (ExifEntry * entry, MEUserData * meudata, + const ExifByteOrder byte_order) +{ + gboolean ret = TRUE; + + switch (entry->tag) { + case EXIF_TAG_RESOLUTION_UNIT: + meudata->resolution_unit = exif_get_short (entry->data, byte_order); + if (meudata->resolution_unit == 3) { + /* if [xy]resolution has alredy been add in cm, replace it in inches */ + gfloat value; + + if (gst_tag_list_get_float (meudata->taglist, + GST_TAG_IMAGE_XRESOLUTION, &value)) { + gst_tag_list_add (meudata->taglist, GST_TAG_MERGE_REPLACE, + GST_TAG_IMAGE_XRESOLUTION, value * 0.4f, NULL); + } + if (gst_tag_list_get_float (meudata->taglist, + GST_TAG_IMAGE_YRESOLUTION, &value)) { + gst_tag_list_add (meudata->taglist, GST_TAG_MERGE_REPLACE, + GST_TAG_IMAGE_YRESOLUTION, value * 0.4f, NULL); + } + } + + break; + case EXIF_TAG_GPS_ALTITUDE_REF: + meudata->altitude_ref = entry->data[0]; + + const GValue *value = gst_tag_list_get_value_index (meudata->taglist, + GST_TAG_GPS_ALTITUDE, 0); + + 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: + { + + gchar *value = NULL; + + meudata->latitude_ref = entry->data[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_GPS_LATITUDE, str->str, NULL); + } + g_string_free (str, TRUE); + } + + } + break; + case EXIF_TAG_GPS_LONGITUDE_REF: + { + gchar *value = NULL; + + meudata->longitude_ref = entry->data[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_GPS_LONGITUDE, str->str, NULL); + } + g_string_free (str, TRUE); + } + } + break; + default: + ret = FALSE; + break; + } + + return ret; + +} + + /* * metadatamux_exif_for_each_tag_in_list: * @list: GStreamer tag list from which @tag belongs to @@ -669,6 +861,21 @@ metadatamux_exif_for_each_tag_in_list (const GstTagList * list, exif_entry_initialize (entry, exif_tag); } + if (entry->data == NULL) { + if (entry->tag == EXIF_TAG_GPS_ALTITUDE) { + entry->format = EXIF_FORMAT_RATIONAL; + entry->components = 1; + entry->size = exif_format_get_size (entry->format) * entry->components; + entry->data = g_malloc (entry->size); + } else if (entry->tag == EXIF_TAG_GPS_LATITUDE + || entry->tag == EXIF_TAG_GPS_LONGITUDE) { + entry->format = EXIF_FORMAT_RATIONAL; + entry->components = 3; + entry->size = exif_format_get_size (entry->format) * entry->components; + entry->data = g_malloc (entry->size); + } + } + if (type == GST_TYPE_FRACTION) { const GValue *gvalue = gst_tag_list_get_value_index (list, tag, 0); gint numerator = gst_value_get_fraction_numerator (gvalue); @@ -684,9 +891,35 @@ metadatamux_exif_for_each_tag_in_list (const GstTagList * list, break; case EXIF_FORMAT_RATIONAL: { - ExifRational r = { numerator, denominator }; + ExifRational r; - exif_set_rational (entry->data, byte_order, 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; @@ -700,11 +933,28 @@ metadatamux_exif_for_each_tag_in_list (const GstTagList * list, exif_set_short (unit_entry->data, byte_order, 2); } } + r.numerator = numerator; + r.denominator = denominator; + if (numerator < 0) + r.numerator = -numerator; + if (denominator < 0) + r.denominator = -denominator; + exif_set_rational (entry->data, byte_order, r); } break; default: break; } + } else if (type == GST_TYPE_BUFFER) { + const GValue *val = NULL; + GstBuffer *buf; + + val = gst_tag_list_get_value_index (list, tag, 0); + buf = gst_value_get_buffer (val); + entry->components = GST_BUFFER_SIZE (buf); + entry->size = GST_BUFFER_SIZE (buf); + entry->data = g_malloc (entry->size); + memcpy (entry->data, GST_BUFFER_DATA (buf), entry->size); } else { switch (type) { @@ -713,10 +963,59 @@ metadatamux_exif_for_each_tag_in_list (const GstTagList * list, gchar *value = NULL; if (gst_tag_list_get_string (list, tag, &value)) { - entry->components = strlen (value) + 1; - entry->size = - exif_format_get_size (entry->format) * entry->components; - entry->data = (guint8 *) value; + + if (entry->tag == EXIF_TAG_DATE_TIME_DIGITIZED + || entry->tag == EXIF_TAG_DATE_TIME + || entry->tag == EXIF_TAG_DATE_TIME_ORIGINAL) { + GString *datetime = g_string_new_len (value, + 20); /* enough memory to hold "YYYY:MM:DD HH:MM:SS" */ + + if (metadatamux_exif_convert_from_datetime (datetime)) { + } else { + GST_ERROR ("Unexpected date & time format for %s", tag); + } + g_free (value); + value = datetime->str; + g_string_free (datetime, FALSE); + } 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; @@ -767,5 +1066,373 @@ done: } +/* + * metadataparse_exif_convert_to_datetime: + * @dt: string containing date_time in format "YYYY:MM:DD HH:MM:SS" + * + * This function converts a exif date_and_time string @dt into the format + * specified by http://www.w3.org/TR/1998/NOTE-datetime-19980827, in which a + * subset of ISO RFC 8601 used by XMP. + * @dt->allocated_len must be not less than 21 to hold enough memory + * hold "YYYY:MM:DD HH:MM:SS" without additional allocation + * + * Returns: + * + * #TRUE if succeded + * + * #FALSE if failed + * + * + */ + +static gboolean +metadataparse_exif_convert_to_datetime (GString * dt) +{ + + /* "YYYY:MM:DD HH:MM:SS" */ + /* 012345678901234567890 */ + + if (dt->allocated_len < 20) + return FALSE; + + /* Fix me: Ideally would be good to get the time zone from othe Exif tag + * for the time being, just use local time as explained in XMP specification + * (converting from EXIF to XMP date and time) */ + + dt->str[4] = '-'; + dt->str[7] = '-'; + dt->str[10] = 'T'; + dt->str[19] = '\0'; + + return TRUE; + +} + + +/* + * metadatamux_exif_convert_from_datetime: + * @dt: string containing date_time in format specified by + * http://www.w3.org/TR/1998/NOTE-datetime-19980827 + * + * This function converts a date_and_time string @dt as specified by + * http://www.w3.org/TR/1998/NOTE-datetime-19980827, in which a + * subset of ISO RFC 8601 used by XMP, into Exif date_time format. + * @dt->allocated_len must be not less than 20 to hold enough memory + * hold "YYYY:MM:DD HH:MM:SS" without additional allocation + * + * Returns: + * + * #TRUE if succeded + * + * #FALSE if failed + * + * + */ + +static gboolean +metadatamux_exif_convert_from_datetime (GString * dt) +{ + gboolean ret = TRUE; + char *p = dt->str; + + if (dt->allocated_len < 20) + goto error; + + /* check YYYY */ + + if (IS_NUMBER (*p)) + p++; + else + goto error; + if (IS_NUMBER (*p)) + p++; + else + goto error; + if (IS_NUMBER (*p)) + p++; + else + goto error; + if (IS_NUMBER (*p)) + p++; + else + goto error; + + if (*p == '\0') { + sprintf (p, ":01:01 00:00:00"); + goto done; + } else if (*p == '-') { + *p++ = ':'; + } else + goto error; + + /* check MM */ + + if (IS_NUMBER (*p)) + p++; + else + goto error; + if (IS_NUMBER (*p)) + p++; + else + goto error; + + if (*p == '\0') { + sprintf (p, ":01 00:00:00"); + goto done; + } else if (*p == '-') { + *p++ = ':'; + } else + goto error; + + /* check DD */ + + if (IS_NUMBER (*p)) + p++; + else + goto error; + if (IS_NUMBER (*p)) + p++; + else + goto error; + + if (*p == '\0') { + sprintf (p, " 00:00:00"); + goto done; + } else if (*p == 'T') { + *p++ = ' '; + } else + goto error; + + /* check hh */ + + if (IS_NUMBER (*p)) + p++; + else + goto error; + if (IS_NUMBER (*p)) + p++; + else + goto error; + + if (*p++ != ':') + goto error; + + /* check mm */ + + if (IS_NUMBER (*p)) + p++; + else + goto error; + if (IS_NUMBER (*p)) + p++; + else + goto error; + + if (*p == ':') { + p++; + } else if (*p == 'Z' || *p == '+' || *p == '-') { + /* FIXME: in case of '+' or '-', it would be better to also fill another + * EXIF tag in order to save, somehow the time zone info */ + sprintf (p, ":00"); + goto done; + } else + goto error; + + /* check ss */ + + if (IS_NUMBER (*p)) + p++; + else + goto error; + if (IS_NUMBER (*p)) + p++; + else + goto error; + + *p = '\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) + dt->len = 19; + return ret; + +} + +/* + * 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: + * + * %TRUE if converted sucessfull + * + * %FALSE if @lt is bad formated + * + * + */ + +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: + * + * %TRUE if converted sucessfull + * + * %FALSE if error + * + * + */ + +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) */ diff --git a/ext/metadata/metadatatags.c b/ext/metadata/metadatatags.c index e8b0c1f34..b79830d1f 100644 --- a/ext/metadata/metadatatags.c +++ b/ext/metadata/metadatatags.c @@ -364,29 +364,98 @@ metadata_tags_exif_register (void) "The name of the first known tool used to create the resource." " Or firmware or driver version of device", NULL); + /* date and time tags */ + /* formated as subset of ISO RFC 8601 as described in + * http://www.w3.org/TR/1998/NOTE-datetime-19980827 + * which is: + * YYYY + * YYYY-MM + * YYYY-MM-DD + * YYYY-MM-DDThh:mmTZD + * YYYY-MM-DDThh:mm:ssTZD + * YYYY-MM-DDThh:mm:ss.sTZD + * where: + * YYYY = four-digit year + * MM = two-digit month (01=January) + * DD = two-digit day of month (01 through 31) + * hh = two digits of hour (00 through 23) + * mm = two digits of minute (00 through 59) + * ss = two digits of second (00 through 59) + * s = one or more digits representing a decimal fraction of a second + * TZD = time zone designator (Z or +hh:mm or -hh:mm) + */ + + gst_tag_register (GST_TAG_DATE_TIME_DIGITIZED, GST_TAG_FLAG_META, + G_TYPE_STRING, GST_TAG_DATE_TIME_DIGITIZED, + "Date/Time of image digitized", NULL); + + gst_tag_register (GST_TAG_DATE_TIME_MODIFIED, GST_TAG_FLAG_META, + G_TYPE_STRING, GST_TAG_DATE_TIME_MODIFIED, + "Date/Time of image was last modified", NULL); + + gst_tag_register (GST_TAG_DATE_TIME_ORIGINAL, GST_TAG_FLAG_META, + G_TYPE_STRING, GST_TAG_DATE_TIME_ORIGINAL, + "Date/Time of original image taken", NULL); + /* devices tags */ gst_tag_register (GST_TAG_DEVICE_MAKE, GST_TAG_FLAG_META, G_TYPE_STRING, GST_TAG_DEVICE_MAKE, "The manufacturer of the recording equipment", NULL); + gst_tag_register (GST_TAG_DEVICE_MODEL, GST_TAG_FLAG_META, G_TYPE_STRING, GST_TAG_DEVICE_MODEL, "The model name or model number of the equipment", NULL); + /* exif specific tags */ + + gst_tag_register (GST_TAG_EXIF_MAKER_NOTE, GST_TAG_FLAG_META, + GST_TYPE_BUFFER, GST_TAG_EXIF_MAKER_NOTE, "Camera private data", NULL); + /* image tags */ gst_tag_register (GST_TAG_IMAGE_HEIGHT, GST_TAG_FLAG_META, G_TYPE_UINT, GST_TAG_IMAGE_HEIGHT, "Image height in pixels", NULL); + gst_tag_register (GST_TAG_IMAGE_WIDTH, GST_TAG_FLAG_META, G_TYPE_UINT, GST_TAG_IMAGE_WIDTH, "Image width in pixels", NULL); gst_tag_register (GST_TAG_IMAGE_XRESOLUTION, GST_TAG_FLAG_META, GST_TYPE_FRACTION, GST_TAG_IMAGE_XRESOLUTION, "Horizontal resolution in pixels per inch", NULL); + 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); + } /* diff --git a/ext/metadata/metadatatags.h b/ext/metadata/metadatatags.h index 1e2981667..004a17c24 100644 --- a/ext/metadata/metadatatags.h +++ b/ext/metadata/metadatatags.h @@ -102,14 +102,33 @@ typedef enum { #define GST_TAG_CREATOR_TOOL "creator-tool" +#define GST_TAG_DATE_TIME_DIGITIZED "date-time-digitized" +#define GST_TAG_DATE_TIME_MODIFIED "date-time-modified" +#define GST_TAG_DATE_TIME_ORIGINAL "date-time-original" + #define GST_TAG_DEVICE_MAKE "device-make" #define GST_TAG_DEVICE_MODEL "device-model" +#define GST_TAG_EXIF_MAKER_NOTE "exif-maker-note" + #define GST_TAG_IMAGE_HEIGHT "image-height" #define GST_TAG_IMAGE_WIDTH "image-width" #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 "" +#define GST_TAG_GPS_SPEED "" +#define GST_TAG_GPS_TRACK "" + /* *INDENT-ON* */ /* diff --git a/tests/icles/metadata_editor.c b/tests/icles/metadata_editor.c index 02212bb26..e8bef14b6 100644 --- a/tests/icles/metadata_editor.c +++ b/tests/icles/metadata_editor.c @@ -136,6 +136,30 @@ GString *filename = NULL; * Helper functions */ +static void +dump_tag_buffer(const char *tag, guint8 * buf, guint32 size) +{ + guint32 i; + printf("\nDumping %s (size = %u)\n\n", tag, size); + + for(i=0; i> 16, i & 0xFFFF); + + printf("%02x", buf[i]); + + if (i % 16 != 15) + printf(" "); + else + printf("\n"); + + } + + printf("\n\n"); + +} + static void insert_tag_on_tree (const GstTagList * list, const gchar * tag, gpointer user_data) @@ -150,6 +174,13 @@ insert_tag_on_tree (const GstTagList * list, const gchar * tag, if (gst_tag_get_type (tag) == G_TYPE_STRING) { if (!gst_tag_list_get_string_index (list, tag, 0, &str)) g_assert_not_reached (); + } else if ( gst_tag_get_type (tag) == GST_TYPE_BUFFER ) { + const GValue *val = NULL; + GstBuffer *buf; + val = gst_tag_list_get_value_index (list, tag, 0); + buf = gst_value_get_buffer (val); + dump_tag_buffer(tag, GST_BUFFER_DATA(buf), GST_BUFFER_SIZE(buf)); + str = g_strdup("It has been printed to stdout"); } else { str = g_strdup_value_contents (gst_tag_list_get_value_index (list, tag, 0)); } @@ -215,7 +246,8 @@ change_tag_list (GstTagList ** list, const gchar * tag, const gchar * value) } break; default: - g_printerr ("Tags of type '%s' are not supported yet.\n", + g_printerr ("Tags of type '%s' are not supported yet for editing" + " by this application.\n", g_type_name (type)); break; } -- cgit v1.2.1