diff options
author | Edgard Lima <edgard.lima@indt.org.br> | 2007-11-28 14:03:35 +0000 |
---|---|---|
committer | Edgard Lima <edgard.lima@indt.org.br> | 2007-11-28 14:03:35 +0000 |
commit | 14da2ceef57b29bafd0cb9ba0d37ebd5c1571587 (patch) | |
tree | b76f11b33c1513de81255fdd4ce0daa25184f7e5 /ext | |
parent | c1e6c76cdb550c564f58e84c66b3e993ea36227d (diff) | |
download | gst-plugins-bad-14da2ceef57b29bafd0cb9ba0d37ebd5c1571587.tar.gz gst-plugins-bad-14da2ceef57b29bafd0cb9ba0d37ebd5c1571587.tar.bz2 gst-plugins-bad-14da2ceef57b29bafd0cb9ba0d37ebd5c1571587.zip |
Sending make and model individual tags and muxer now links fine.
Original commit message from CVS:
Sending make and model individual tags and muxer now links fine.
Diffstat (limited to 'ext')
-rw-r--r-- | ext/metadata/gstmetadatamux.c | 27 | ||||
-rw-r--r-- | ext/metadata/gstmetadataparse.c | 43 | ||||
-rw-r--r-- | ext/metadata/metadataexif.c | 67 | ||||
-rw-r--r-- | ext/metadata/metadataexif.h | 3 | ||||
-rw-r--r-- | ext/metadata/metadataiptc.c | 15 | ||||
-rw-r--r-- | ext/metadata/metadataiptc.h | 3 | ||||
-rw-r--r-- | ext/metadata/metadatatags.c | 6 | ||||
-rw-r--r-- | ext/metadata/metadatatags.h | 9 | ||||
-rw-r--r-- | ext/metadata/metadataxmp.c | 13 | ||||
-rw-r--r-- | ext/metadata/metadataxmp.h | 3 |
10 files changed, 145 insertions, 44 deletions
diff --git a/ext/metadata/gstmetadatamux.c b/ext/metadata/gstmetadatamux.c index 02bb99b6..600fd998 100644 --- a/ext/metadata/gstmetadatamux.c +++ b/ext/metadata/gstmetadatamux.c @@ -151,7 +151,7 @@ static int 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 @@ gst_metadata_mux_class_init (GstMetadataMuxClass * klass) 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 ?", - TRUE, G_PARAM_READWRITE)); + FALSE, G_PARAM_READWRITE)); gstelement_class->change_state = gst_metadata_mux_change_state; @@ -381,12 +381,10 @@ gst_metadata_mux_get_caps (GstPad * pad) 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 @@ gst_metadata_mux_init_members (GstMetadataMux * filter) { 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 @@ gst_metadata_mux_configure_srccaps (GstMetadataMux * filter) 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 @@ gst_metadata_mux_set_caps (GstPad * pad, GstCaps * caps) } if (gst_structure_get_boolean (structure, "tags-extracted", &muxd)) { - if (muxd == TRUE) { + if (muxd == FALSE) { ret = FALSE; goto done; } @@ -752,7 +749,7 @@ gst_metadata_mux_get_type_name (int img_type) } static void -gst_metadata_mux_send_tags (GstMetadataMux * filter) +gst_metadata_create_chunks_from_tags (GstMetadataMux * filter) { GstMessage *msg; @@ -1022,7 +1019,7 @@ gst_metadata_mux_chain (GstPad * pad, GstBuffer * buf) } 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 @@ gst_metadata_mux_get_range (GstPad * pad, 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, diff --git a/ext/metadata/gstmetadataparse.c b/ext/metadata/gstmetadataparse.c index 45532cd5..e4adaa6c 100644 --- a/ext/metadata/gstmetadataparse.c +++ b/ext/metadata/gstmetadataparse.c @@ -762,31 +762,52 @@ gst_metadata_parse_send_tags (GstMetadataParse * filter) { GstMessage *msg; - 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); - taglist = gst_tag_list_copy (filter->taglist); 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) + metadataparse_exif_tag_list_add (taglist, GST_TAG_MERGE_KEEP, + filter->parse_data.exif_adapter, METADATA_TAG_MAP_INDIVIDUALS); + if (META_DATA_OPTION (filter->parse_data) & META_OPT_IPTC) + metadataparse_iptc_tag_list_add (taglist, GST_TAG_MERGE_KEEP, + filter->parse_data.iptc_adapter, METADATA_TAG_MAP_INDIVIDUALS); + if (META_DATA_OPTION (filter->parse_data) & META_OPT_XMP) + metadataparse_xmp_tag_list_add (taglist, GST_TAG_MERGE_KEEP, + filter->parse_data.xmp_adapter, METADATA_TAG_MAP_INDIVIDUALS); + + if (taglist && !gst_tag_list_is_empty (taglist)) { + + msg = gst_message_new_tag (GST_OBJECT (filter), taglist); + gst_element_post_message (GST_ELEMENT (filter), msg); + taglist = NULL; + } + if (taglist) + gst_tag_list_free (taglist); filter->need_send_tag = FALSE; } diff --git a/ext/metadata/metadataexif.c b/ext/metadata/metadataexif.c index f7d89c13..583be86f 100644 --- a/ext/metadata/metadataexif.c +++ b/ext/metadata/metadataexif.c @@ -52,12 +52,14 @@ GST_DEBUG_CATEGORY (gst_metadata_exif_debug); 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 @@ metadatamux_exif_create_chunk_from_tag_list (GstAdapter ** adapter, #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; + static void 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; + +} + void metadataparse_exif_tag_list_add (GstTagList * taglist, GstTagMergeMode mode, - GstAdapter * adapter) + GstAdapter * adapter, MetadataTagMapping mapping) { 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 */ - 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); + + if (!(mapping & METADATA_TAG_MAP_INDIVIDUALS)) + goto done; buf = gst_adapter_peek (adapter, size); @@ -100,7 +143,7 @@ metadataparse_exif_tag_list_add (GstTagList * taglist, GstTagMergeMode mode, } exif_data_foreach_content (exif, exif_data_foreach_content_func, - (void *) taglist); + (void *) &user_data); done: @@ -115,7 +158,6 @@ static void 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 @@ static void exif_content_foreach_entry_func (ExifEntry * entry, void *user_data) { char buf[2048]; - GstTagList *taglist = (GstTagList *) user_data; + MEUserData *meudata = (MEUserData *) user_data; + GType type; + 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_content_foreach_entry_func (ExifEntry * entry, void *user_data) 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); + } + } /* diff --git a/ext/metadata/metadataexif.h b/ext/metadata/metadataexif.h index 6394013e..2fa6380f 100644 --- a/ext/metadata/metadataexif.h +++ b/ext/metadata/metadataexif.h @@ -46,12 +46,13 @@ #include <gst/gst.h> #include <gst/base/gstadapter.h> +#include "metadatatags.h" G_BEGIN_DECLS extern void metadataparse_exif_tag_list_add (GstTagList * taglist, GstTagMergeMode mode, - GstAdapter * adapter); + GstAdapter * adapter, MetadataTagMapping mapping); extern void metadatamux_exif_create_chunk_from_tag_list (GstAdapter ** adapter, diff --git a/ext/metadata/metadataiptc.c b/ext/metadata/metadataiptc.c index a391fc78..8c0507a4 100644 --- a/ext/metadata/metadataiptc.c +++ b/ext/metadata/metadataiptc.c @@ -52,12 +52,14 @@ GST_DEBUG_CATEGORY (gst_metadata_iptc_debug); void metadataparse_iptc_tag_list_add (GstTagList * taglist, GstTagMergeMode mode, - GstAdapter * adapter) + GstAdapter * adapter, MetadataTagMapping mapping) { 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); + if (mapping & METADATA_TAG_MAP_WHOLECHUNK) + metadataparse_util_tag_list_add_chunk (taglist, mode, GST_TAG_IPTC, + adapter); } @@ -78,7 +80,7 @@ iptc_data_foreach_dataset_func (IptcDataSet * dataset, void *user_data); void metadataparse_iptc_tag_list_add (GstTagList * taglist, GstTagMergeMode mode, - GstAdapter * adapter) + GstAdapter * adapter, MetadataTagMapping mapping) { const guint8 *buf; guint32 size; @@ -89,7 +91,12 @@ metadataparse_iptc_tag_list_add (GstTagList * taglist, GstTagMergeMode mode, } /* add chunk tag */ - metadataparse_util_tag_list_add_chunk (taglist, mode, GST_TAG_IPTC, adapter); + if (mapping & METADATA_TAG_MAP_WHOLECHUNK) + metadataparse_util_tag_list_add_chunk (taglist, mode, GST_TAG_IPTC, + adapter); + + if (!(mapping & METADATA_TAG_MAP_INDIVIDUALS)) + goto done; buf = gst_adapter_peek (adapter, size); diff --git a/ext/metadata/metadataiptc.h b/ext/metadata/metadataiptc.h index 4357f7fa..0681380b 100644 --- a/ext/metadata/metadataiptc.h +++ b/ext/metadata/metadataiptc.h @@ -46,12 +46,13 @@ #include <gst/gst.h> #include <gst/base/gstadapter.h> +#include "metadatatags.h" G_BEGIN_DECLS extern void metadataparse_iptc_tag_list_add (GstTagList * taglist, GstTagMergeMode mode, - GstAdapter * adapter); + GstAdapter * adapter, MetadataTagMapping mapping); extern void metadatamux_iptc_create_chunk_from_tag_list (GstAdapter ** adapter, diff --git a/ext/metadata/metadatatags.c b/ext/metadata/metadatatags.c index 91544b77..ceb97070 100644 --- a/ext/metadata/metadatatags.c +++ b/ext/metadata/metadatatags.c @@ -83,6 +83,12 @@ metadata_tags_xmp_register (void) void 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 (); diff --git a/ext/metadata/metadatatags.h b/ext/metadata/metadatatags.h index 094161ee..60dd0806 100644 --- a/ext/metadata/metadatatags.h +++ b/ext/metadata/metadatatags.h @@ -49,12 +49,21 @@ G_BEGIN_DECLS +/* 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" + extern void metadata_tags_register (void); diff --git a/ext/metadata/metadataxmp.c b/ext/metadata/metadataxmp.c index 900a454a..b417a935 100644 --- a/ext/metadata/metadataxmp.c +++ b/ext/metadata/metadataxmp.c @@ -52,12 +52,13 @@ GST_DEBUG_CATEGORY (gst_metadata_xmp_debug); void metadataparse_xmp_tag_list_add (GstTagList * taglist, GstTagMergeMode mode, - GstAdapter * adapter) + GstAdapter * adapter, MetadataTagMapping mapping) { 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); + if (mapping & METADATA_TAG_MAP_WHOLECHUNK) + metadataparse_util_tag_list_add_chunk (taglist, mode, GST_TAG_XMP, adapter); } @@ -109,7 +110,7 @@ metadataparse_xmp_dispose (void) void metadataparse_xmp_tag_list_add (GstTagList * taglist, GstTagMergeMode mode, - GstAdapter * adapter) + GstAdapter * adapter, MetadataTagMapping mapping) { const guint8 *buf; guint32 size; @@ -121,7 +122,11 @@ metadataparse_xmp_tag_list_add (GstTagList * taglist, GstTagMergeMode mode, } /* add chunk tag */ - metadataparse_util_tag_list_add_chunk (taglist, mode, GST_TAG_XMP, adapter); + if (mapping & METADATA_TAG_MAP_WHOLECHUNK) + metadataparse_util_tag_list_add_chunk (taglist, mode, GST_TAG_XMP, adapter); + + if (!(mapping & METADATA_TAG_MAP_INDIVIDUALS)) + goto done; buf = gst_adapter_peek (adapter, size); diff --git a/ext/metadata/metadataxmp.h b/ext/metadata/metadataxmp.h index 8c3ef19d..f7454c5d 100644 --- a/ext/metadata/metadataxmp.h +++ b/ext/metadata/metadataxmp.h @@ -46,12 +46,13 @@ #include <gst/gst.h> #include <gst/base/gstadapter.h> +#include "metadatatags.h" G_BEGIN_DECLS extern void metadataparse_xmp_tag_list_add (GstTagList * taglist, GstTagMergeMode mode, - GstAdapter * adapter); + GstAdapter * adapter, MetadataTagMapping mapping); extern gboolean metadataparse_xmp_init (void); |