From: <al...@ke...> - 2007-11-28 14:03:45
|
CVS Root: /cvs/gstreamer Module: gst-plugins-bad Changes by: alima Date: Wed Nov 28 2007 14:03:49 UTC Log message: Sending make and model individual tags and muxer now links fine. Modified files: . : ChangeLog ext/metadata : gstmetadatamux.c gstmetadataparse.c metadataexif.c metadataexif.h metadataiptc.c metadataiptc.h metadatatags.c metadatatags.h metadataxmp.c metadataxmp.h Links: http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-bad/ChangeLog.diff?r1=1.2891&r2=1.2892 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-bad/ext/metadata/gstmetadatamux.c.diff?r1=1.2&r2=1.3 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-bad/ext/metadata/gstmetadataparse.c.diff?r1=1.11&r2=1.12 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-bad/ext/metadata/metadataexif.c.diff?r1=1.1&r2=1.2 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-bad/ext/metadata/metadataexif.h.diff?r1=1.1&r2=1.2 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-bad/ext/metadata/metadataiptc.c.diff?r1=1.1&r2=1.2 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-bad/ext/metadata/metadataiptc.h.diff?r1=1.1&r2=1.2 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-bad/ext/metadata/metadatatags.c.diff?r1=1.1&r2=1.2 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-bad/ext/metadata/metadatatags.h.diff?r1=1.1&r2=1.2 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-bad/ext/metadata/metadataxmp.c.diff?r1=1.1&r2=1.2 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-bad/ext/metadata/metadataxmp.h.diff?r1=1.1&r2=1.2 ====Begin Diffs==== Index: ChangeLog =================================================================== RCS file: /cvs/gstreamer/gst-plugins-bad/ChangeLog,v retrieving revision 1.2891 retrieving revision 1.2892 diff -u -d -r1.2891 -r1.2892 --- ChangeLog 28 Nov 2007 08:13:46 -0000 1.2891 +++ ChangeLog 28 Nov 2007 14:03:33 -0000 1.2892 @@ -1,5 +1,19 @@ 2007-11-28 Edgard Lima <edg...@in...> + * ext/metadata/gstmetadatamux.c: + * ext/metadata/gstmetadataparse.c: + * ext/metadata/metadataexif.c: + * ext/metadata/metadataexif.h: + * ext/metadata/metadataiptc.c: + * ext/metadata/metadataiptc.h: + * ext/metadata/metadatatags.c: + * ext/metadata/metadatatags.h: + * ext/metadata/metadataxmp.c: + * ext/metadata/metadataxmp.h: + Sending make and model individual tags and muxer now links fine. + +2007-11-28 Edgard Lima <edg...@in...> * ext/metadata/Makefile.am: * ext/metadata/gstmetadata.c: * ext/metadata/gstmetadatamux.c: Index: gstmetadatamux.c RCS file: /cvs/gstreamer/gst-plugins-bad/ext/metadata/gstmetadatamux.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- gstmetadatamux.c 28 Nov 2007 08:13:48 -0000 1.2 +++ gstmetadatamux.c 28 Nov 2007 14:03:34 -0000 1.3 @@ -151,7 +151,7 @@ gst_metadata_mux_mux (GstMetadataMux * filter, const guint8 * buf, guint32 size); -static void gst_metadata_mux_send_tags (GstMetadataMux * filter); +static void gst_metadata_mux_create_chunks_from_tags (GstMetadataMux * filter); @@ -214,11 +214,11 @@ g_object_class_install_property (gobject_class, ARG_IPTC, g_param_spec_boolean ("iptc", "IPTC", "Send IPTC metadata ?", - TRUE, G_PARAM_READWRITE)); + FALSE, G_PARAM_READWRITE)); g_object_class_install_property (gobject_class, ARG_XMP, g_param_spec_boolean ("xmp", "XMP", "Send XMP metadata ?", gstelement_class->change_state = gst_metadata_mux_change_state; @@ -381,12 +381,10 @@ if (pad == filter->sinkpad) { structure_new = - gst_structure_new (mime, "tags-extracted", G_TYPE_BOOLEAN, FALSE, - NULL); - } else { - structure_new = gst_structure_new (mime, "tags-extracted", G_TYPE_BOOLEAN, TRUE, NULL); + } else { + structure_new = gst_structure_new (mime, NULL); } gst_caps_append_structure (caps_new, structure_new); @@ -587,8 +585,8 @@ { filter->need_send_tag = FALSE; filter->exif = TRUE; - filter->iptc = TRUE; - filter->xmp = TRUE; + filter->iptc = FALSE; + filter->xmp = FALSE; filter->taglist = NULL; filter->adapter_parsing = NULL; @@ -629,8 +627,7 @@ break; } - caps = - gst_caps_new_simple (mime, "tags-extracted", G_TYPE_BOOLEAN, TRUE, NULL); + caps = gst_caps_new_simple (mime, NULL); ret = gst_pad_set_caps (filter->srcpad, caps); @@ -717,7 +714,7 @@ if (gst_structure_get_boolean (structure, "tags-extracted", &muxd)) { - if (muxd == TRUE) { + if (muxd == FALSE) { ret = FALSE; goto done; } @@ -752,7 +749,7 @@ } static void -gst_metadata_mux_send_tags (GstMetadataMux * filter) +gst_metadata_create_chunks_from_tags (GstMetadataMux * filter) GstMessage *msg; @@ -1022,7 +1019,7 @@ if (filter->need_send_tag) { - gst_metadata_mux_send_tags (filter); + gst_metadata_create_chunks_from_tags (filter); if (filter->offset_orig + GST_BUFFER_SIZE (buf) == filter->duration_orig) @@ -1629,7 +1626,7 @@ size_orig = size; if (filter->need_send_tag) { - gst_metadata_mux_send_tags (filter); + gst_metadata_create_chunks_from_tags (filter); gst_metadata_mux_translate_pos_to_orig (filter, offset, &offset_orig, Index: gstmetadataparse.c RCS file: /cvs/gstreamer/gst-plugins-bad/ext/metadata/gstmetadataparse.c,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- gstmetadataparse.c 28 Nov 2007 08:13:48 -0000 1.11 +++ gstmetadataparse.c 28 Nov 2007 14:03:34 -0000 1.12 @@ -762,31 +762,52 @@ - GstTagList *taglist; + GstTagList *taglist = gst_tag_list_new (); GstEvent *event; if (META_DATA_OPTION (filter->parse_data) & META_OPT_EXIF) - metadataparse_exif_tag_list_add (filter->taglist, GST_TAG_MERGE_KEEP, - filter->parse_data.exif_adapter); + metadataparse_exif_tag_list_add (taglist, GST_TAG_MERGE_KEEP, + filter->parse_data.exif_adapter, METADATA_TAG_MAP_WHOLECHUNK); if (META_DATA_OPTION (filter->parse_data) & META_OPT_IPTC) - metadataparse_iptc_tag_list_add (filter->taglist, GST_TAG_MERGE_KEEP, - filter->parse_data.iptc_adapter); + metadataparse_iptc_tag_list_add (taglist, GST_TAG_MERGE_KEEP, + filter->parse_data.iptc_adapter, METADATA_TAG_MAP_WHOLECHUNK); if (META_DATA_OPTION (filter->parse_data) & META_OPT_XMP) - metadataparse_xmp_tag_list_add (filter->taglist, GST_TAG_MERGE_KEEP, - filter->parse_data.xmp_adapter); + metadataparse_xmp_tag_list_add (taglist, GST_TAG_MERGE_KEEP, + filter->parse_data.xmp_adapter, METADATA_TAG_MAP_WHOLECHUNK); - if (!gst_tag_list_is_empty (filter->taglist)) { + if (taglist && !gst_tag_list_is_empty (taglist)) { - taglist = gst_tag_list_copy (filter->taglist); - msg = gst_message_new_tag (GST_OBJECT (filter), taglist); + msg = + gst_message_new_tag (GST_OBJECT (filter), gst_tag_list_copy (taglist)); gst_element_post_message (GST_ELEMENT (filter), msg); event = gst_event_new_tag (taglist); gst_pad_push_event (filter->srcpad, event); + taglist = NULL; + if (!taglist) + taglist = gst_tag_list_new (); + if (META_DATA_OPTION (filter->parse_data) & META_OPT_EXIF) + filter->parse_data.exif_adapter, METADATA_TAG_MAP_INDIVIDUALS); + if (META_DATA_OPTION (filter->parse_data) & META_OPT_IPTC) + filter->parse_data.iptc_adapter, METADATA_TAG_MAP_INDIVIDUALS); + if (META_DATA_OPTION (filter->parse_data) & META_OPT_XMP) + filter->parse_data.xmp_adapter, METADATA_TAG_MAP_INDIVIDUALS); + msg = gst_message_new_tag (GST_OBJECT (filter), taglist); + gst_element_post_message (GST_ELEMENT (filter), msg); + } + if (taglist) + gst_tag_list_free (taglist); Index: metadataexif.c RCS file: /cvs/gstreamer/gst-plugins-bad/ext/metadata/metadataexif.c,v retrieving revision 1.1 diff -u -d -r1.1 -r1.2 --- metadataexif.c 28 Nov 2007 08:13:49 -0000 1.1 +++ metadataexif.c 28 Nov 2007 14:03:34 -0000 1.2 @@ -52,12 +52,14 @@ void metadataparse_exif_tag_list_add (GstTagList * taglist, GstTagMergeMode mode, - GstAdapter * adapter) + GstAdapter * adapter, MetadataTagMapping mapping) GST_LOG ("EXIF not defined, here I should send just one tag as whole chunk"); - metadataparse_util_tag_list_add_chunk (taglist, mode, GST_TAG_EXIF, adapter); + if (mapping & METADATA_TAG_MAP_WHOLECHUNK) + metadataparse_util_tag_list_add_chunk (taglist, mode, GST_TAG_EXIF, + adapter); @@ -72,25 +74,66 @@ #include <libexif/exif-data.h> +typedef struct _tag_MEUserData +{ + GstTagList *taglist; + GstTagMergeMode mode; +} MEUserData; +typedef struct _tag_MapIntStr + ExifTag exif; + const gchar *str; + GType type; +} MapIntStr; exif_data_foreach_content_func (ExifContent * content, void *callback_data); static void exif_content_foreach_entry_func (ExifEntry * entry, void *); +const gchar * +metadataparse_exif_get_tag_from_exif (ExifTag exif, GType * type) + /* FIXEME: sorted with binary search */ + static const MapIntStr array[] = { + {EXIF_TAG_MAKE, GST_TAG_DEVICE_MAKE, G_TYPE_STRING}, + {EXIF_TAG_MODEL, GST_TAG_DEVICE_MODEL, G_TYPE_STRING}, + {0, NULL, G_TYPE_NONE} + }; + int i = 0; + while (array[i].exif) { + if (exif == array[i].exif) + break; + ++i; + *type = array[i].type; + return array[i].str; +} const guint8 *buf; guint32 size; ExifData *exif = NULL; + MEUserData user_data = { taglist, mode }; if (adapter == NULL || (size = gst_adapter_available (adapter)) == 0) { goto done; /* add chunk tag */ + if (!(mapping & METADATA_TAG_MAP_INDIVIDUALS)) + goto done; buf = gst_adapter_peek (adapter, size); @@ -100,7 +143,7 @@ exif_data_foreach_content (exif, exif_data_foreach_content_func, - (void *) taglist); + (void *) &user_data); done: @@ -115,7 +158,6 @@ exif_data_foreach_content_func (ExifContent * content, void *user_data) ExifIfd ifd = exif_content_get_ifd (content); - GstTagList *taglist = (GstTagList *) user_data; GST_LOG ("\n Content %p: %s (ifd=%d)", content, exif_ifd_get_name (ifd), ifd); @@ -127,7 +169,9 @@ exif_content_foreach_entry_func (ExifEntry * entry, void *user_data) char buf[2048]; + MEUserData *meudata = (MEUserData *) user_data; + const gchar *tag = metadataparse_exif_get_tag_from_exif (entry->tag, &type); GST_LOG ("\n Entry %p: %s (%s)\n" " Size, Comps: %d, %d\n" @@ -142,6 +186,15 @@ exif_entry_get_value (entry, buf, sizeof (buf)), exif_tag_get_title_in_ifd (entry->tag, EXIF_IFD_0), exif_tag_get_description_in_ifd (entry->tag, EXIF_IFD_0)); + if (tag) { + /* FIXME: create a generic function for this */ + /* could also be used with entry->format */ + if (type == G_TYPE_STRING) + gst_tag_list_add (meudata->taglist, meudata->mode, tag, + exif_entry_get_value (entry, buf, sizeof (buf)), NULL); /* Index: metadataexif.h RCS file: /cvs/gstreamer/gst-plugins-bad/ext/metadata/metadataexif.h,v --- metadataexif.h 28 Nov 2007 08:13:49 -0000 1.1 +++ metadataexif.h 28 Nov 2007 14:03:35 -0000 1.2 @@ -46,12 +46,13 @@ #include <gst/gst.h> #include <gst/base/gstadapter.h> +#include "metadatatags.h" G_BEGIN_DECLS extern void - GstAdapter * adapter); + GstAdapter * adapter, MetadataTagMapping mapping); metadatamux_exif_create_chunk_from_tag_list (GstAdapter ** adapter, Index: metadataiptc.c RCS file: /cvs/gstreamer/gst-plugins-bad/ext/metadata/metadataiptc.c,v --- metadataiptc.c 28 Nov 2007 08:13:49 -0000 1.1 +++ metadataiptc.c 28 Nov 2007 14:03:35 -0000 1.2 metadataparse_iptc_tag_list_add (GstTagList * taglist, GstTagMergeMode mode, GST_LOG ("IPTC not defined, here I should send just one tag as whole chunk"); - metadataparse_util_tag_list_add_chunk (taglist, mode, GST_TAG_IPTC, adapter); + metadataparse_util_tag_list_add_chunk (taglist, mode, GST_TAG_IPTC, @@ -78,7 +80,7 @@ @@ -89,7 +91,12 @@ Index: metadataiptc.h RCS file: /cvs/gstreamer/gst-plugins-bad/ext/metadata/metadataiptc.h,v --- metadataiptc.h 28 Nov 2007 08:13:50 -0000 1.1 +++ metadataiptc.h 28 Nov 2007 14:03:35 -0000 1.2 metadatamux_iptc_create_chunk_from_tag_list (GstAdapter ** adapter, Index: metadatatags.c RCS file: /cvs/gstreamer/gst-plugins-bad/ext/metadata/metadatatags.c,v --- metadatatags.c 28 Nov 2007 08:13:52 -0000 1.1 +++ metadatatags.c 28 Nov 2007 14:03:35 -0000 1.2 @@ -83,6 +83,12 @@ metadata_tags_register (void) + 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); metadata_tags_exif_register (); metadata_tags_iptc_register (); Index: metadatatags.h RCS file: /cvs/gstreamer/gst-plugins-bad/ext/metadata/metadatatags.h,v --- metadatatags.h 28 Nov 2007 08:13:52 -0000 1.1 +++ metadatatags.h 28 Nov 2007 14:03:35 -0000 1.2 @@ -49,12 +49,21 @@ +/* set bit to desired mapping */ +typedef enum { + METADATA_TAG_MAP_INDIVIDUALS = 1 << 0, + METADATA_TAG_MAP_WHOLECHUNK = 1 << 1 +} MetadataTagMapping; #define GST_TAG_EXIF "exif" #define GST_TAG_IPTC "iptc" #define GST_TAG_XMP "xmp" +#define GST_TAG_DEVICE_MAKE "device-make" +#define GST_TAG_DEVICE_MODEL "device-model" metadata_tags_register (void); Index: metadataxmp.c RCS file: /cvs/gstreamer/gst-plugins-bad/ext/metadata/metadataxmp.c,v --- metadataxmp.c 28 Nov 2007 08:13:52 -0000 1.1 +++ metadataxmp.c 28 Nov 2007 14:03:35 -0000 1.2 @@ -52,12 +52,13 @@ metadataparse_xmp_tag_list_add (GstTagList * taglist, GstTagMergeMode mode, GST_LOG ("XMP not defined, here I should send just one tag as whole chunk"); - metadataparse_util_tag_list_add_chunk (taglist, mode, GST_TAG_XMP, adapter); + metadataparse_util_tag_list_add_chunk (taglist, mode, GST_TAG_XMP, adapter); @@ -109,7 +110,7 @@ @@ -121,7 +122,11 @@ Index: metadataxmp.h RCS file: /cvs/gstreamer/gst-plugins-bad/ext/metadata/metadataxmp.h,v --- metadataxmp.h 28 Nov 2007 08:13:52 -0000 1.1 +++ metadataxmp.h 28 Nov 2007 14:03:35 -0000 1.2 extern gboolean metadataparse_xmp_init (void); |