diff options
author | Edgard Lima <edgard.lima@indt.org.br> | 2007-10-31 16:21:02 +0000 |
---|---|---|
committer | Edgard Lima <edgard.lima@indt.org.br> | 2007-10-31 16:21:02 +0000 |
commit | 5888898c570f0f22c930d8c66fe0949d00a90b93 (patch) | |
tree | eb33f602f1c1a1ddda3274c89a819f6f44f3591e /ext/metadata | |
parent | 7412141912cc527a231697e38793871b17e6425b (diff) | |
download | gst-plugins-bad-5888898c570f0f22c930d8c66fe0949d00a90b93.tar.gz gst-plugins-bad-5888898c570f0f22c930d8c66fe0949d00a90b93.tar.bz2 gst-plugins-bad-5888898c570f0f22c930d8c66fe0949d00a90b93.zip |
Now sending iptc tag in whole chunk. Ready to also send exif and xmp in the same way (look at bug #486659).
Original commit message from CVS:
Now sending iptc tag in whole chunk. Ready to also send exif and xmp in the same way (look at bug #486659).
Diffstat (limited to 'ext/metadata')
-rw-r--r-- | ext/metadata/gstmetadataparse.c | 60 | ||||
-rw-r--r-- | ext/metadata/gstmetadataparse.h | 1 | ||||
-rw-r--r-- | ext/metadata/metadataparseexif.c | 21 | ||||
-rw-r--r-- | ext/metadata/metadataparseexif.h | 5 | ||||
-rw-r--r-- | ext/metadata/metadataparseiptc.c | 44 | ||||
-rw-r--r-- | ext/metadata/metadataparseiptc.h | 5 | ||||
-rw-r--r-- | ext/metadata/metadataparsexmp.c | 11 | ||||
-rw-r--r-- | ext/metadata/metadataparsexmp.h | 5 |
8 files changed, 128 insertions, 24 deletions
diff --git a/ext/metadata/gstmetadataparse.c b/ext/metadata/gstmetadataparse.c index 81b0b360..2a4f18d0 100644 --- a/ext/metadata/gstmetadataparse.c +++ b/ext/metadata/gstmetadataparse.c @@ -154,6 +154,8 @@ static int gst_metadata_parse_parse (GstMetadataParse * filter, const guint8 * buf, guint32 size); +static void gst_metadata_parse_send_tags (GstMetadataParse * filter); + static void gst_metadata_parse_base_init (gpointer gclass) { @@ -472,6 +474,10 @@ gst_metadata_parse_dispose_members (GstMetadataParse * filter) gst_object_unref (filter->adapter); filter->adapter = NULL; } + if (filter->taglist) { + gst_tag_list_free (filter->taglist); + filter->taglist = NULL; + } } static void @@ -481,6 +487,7 @@ gst_metadata_parse_init_members (GstMetadataParse * filter) filter->exif = TRUE; filter->iptc = TRUE; filter->xmp = TRUE; + filter->taglist = NULL; filter->adapter = NULL; filter->next_offset = 0; filter->next_size = 0; @@ -632,6 +639,40 @@ gst_metadata_parse_get_type_name (int img_type) return type_name; } +static void +gst_metadata_parse_send_tags (GstMetadataParse * filter) +{ + + GstMessage *msg; + GstTagList *taglist; + GstEvent *event; + + if (PARSE_DATA_OPTION (filter->parse_data) & PARSE_OPT_EXIF) + metadataparse_exif_tag_list_add (filter->taglist, GST_TAG_MERGE_KEEP, + filter->parse_data.adpt_exif); + if (PARSE_DATA_OPTION (filter->parse_data) & PARSE_OPT_IPTC) + metadataparse_iptc_tag_list_add (filter->taglist, GST_TAG_MERGE_KEEP, + filter->parse_data.adpt_iptc); + if (PARSE_DATA_OPTION (filter->parse_data) & PARSE_OPT_XMP) + metadataparse_xmp_tag_list_add (filter->taglist, GST_TAG_MERGE_KEEP, + filter->parse_data.adpt_xmp); + + if (!gst_tag_list_is_empty (filter->taglist)) { + + taglist = gst_tag_list_copy (filter->taglist); + msg = gst_message_new_tag (GST_OBJECT (filter), 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); + } + + + + filter->need_send_tag = FALSE; +} + /* * return: * -1 -> error @@ -740,11 +781,7 @@ gst_metadata_parse_chain (GstPad * pad, GstBuffer * buf) } if (filter->need_send_tag) { - metadataparse_exif_dump (filter->parse_data.adpt_exif); - metadataparse_iptc_dump (filter->parse_data.adpt_iptc); - metadataparse_xmp_dump (filter->parse_data.adpt_xmp); - - filter->need_send_tag = FALSE; + gst_metadata_parse_send_tags (filter); } gst_buffer_set_caps (buf, GST_PAD_CAPS (filter->srcpad)); @@ -859,11 +896,7 @@ gst_metadata_parse_get_range (GstPad * pad, filter = GST_METADATA_PARSE (gst_pad_get_parent (pad)); if (filter->need_send_tag) { - metadataparse_exif_dump (filter->parse_data.adpt_exif); - metadataparse_iptc_dump (filter->parse_data.adpt_iptc); - metadataparse_xmp_dump (filter->parse_data.adpt_xmp); - - filter->need_send_tag = FALSE; + gst_metadata_parse_send_tags (filter); } ret = gst_pad_pull_range (filter->sinkpad, offset, size, buf); @@ -885,6 +918,7 @@ gst_metadata_parse_change_state (GstElement * element, case GST_STATE_CHANGE_NULL_TO_READY: gst_metadata_parse_init_members (filter); filter->adapter = gst_adapter_new (); + filter->taglist = gst_tag_list_new (); break; default: break; @@ -924,6 +958,12 @@ gst_metadata_parse_plugin_init (GstPlugin * plugin) GST_DEBUG_CATEGORY_INIT (gst_metadata_parse_xmp_debug, "metadataparse_xmp", 0, "Metadata xmp demuxer"); + /* FIXME: register tag should be done by plugin 'cause muxer element also uses it */ + metadataparse_exif_tags_register (); + + metadataparse_iptc_tags_register (); + + metadataparse_xmp_tags_register (); return gst_element_register (plugin, "metadataparse", GST_RANK_PRIMARY + 1, GST_TYPE_METADATA_PARSE); diff --git a/ext/metadata/gstmetadataparse.h b/ext/metadata/gstmetadataparse.h index adffa702..5ae49cb3 100644 --- a/ext/metadata/gstmetadataparse.h +++ b/ext/metadata/gstmetadataparse.h @@ -83,6 +83,7 @@ struct _GstMetadataParse gboolean need_send_tag; + GstTagList *taglist; ParseData parse_data; GstAdapter * adapter; guint32 next_offset; diff --git a/ext/metadata/metadataparseexif.c b/ext/metadata/metadataparseexif.c index abd9f50a..5ed97bba 100644 --- a/ext/metadata/metadataparseexif.c +++ b/ext/metadata/metadataparseexif.c @@ -46,10 +46,16 @@ GST_DEBUG_CATEGORY (gst_metadata_parse_exif_debug); #define GST_CAT_DEFAULT gst_metadata_parse_exif_debug +void +metadataparse_exif_tags_register (void) +{ +} + #ifndef HAVE_EXIF void -metadataparse_exif_dump (GstAdapter * adapter) +metadataparse_exif_tag_list_add (GstTagList * taglist, GstTagMergeMode mode, + GstAdapter * adapter) { GST_LOG ("EXIF not defined, here I should send just one tag as whole chunk"); @@ -66,7 +72,8 @@ exif_data_foreach_content_func (ExifContent * content, void *callback_data); static void exif_content_foreach_entry_func (ExifEntry * entry, void *); void -metadataparse_exif_dump (GstAdapter * adapter) +metadataparse_exif_tag_list_add (GstTagList * taglist, GstTagMergeMode mode, + GstAdapter * adapter) { const guint8 *buf; guint32 size; @@ -84,7 +91,7 @@ metadataparse_exif_dump (GstAdapter * adapter) } exif_data_foreach_content (exif, exif_data_foreach_content_func, - (void *) NULL /* app data */ ); + (void *) taglist); done: @@ -96,20 +103,22 @@ done: } static void -exif_data_foreach_content_func (ExifContent * content, void *callback_data) +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); exif_content_foreach_entry (content, exif_content_foreach_entry_func, - callback_data); + user_data); } static void -exif_content_foreach_entry_func (ExifEntry * entry, void *unused) +exif_content_foreach_entry_func (ExifEntry * entry, void *user_data) { char buf[2048]; + GstTagList *taglist = (GstTagList *) user_data; GST_LOG ("\n Entry %p: %s (%s)\n" " Size, Comps: %d, %d\n" diff --git a/ext/metadata/metadataparseexif.h b/ext/metadata/metadataparseexif.h index fdbed28d..4830e5a3 100644 --- a/ext/metadata/metadataparseexif.h +++ b/ext/metadata/metadataparseexif.h @@ -50,7 +50,10 @@ G_BEGIN_DECLS extern void -metadataparse_exif_dump(GstAdapter *adapter); +metadataparse_exif_tag_list_add (GstTagList *taglist, GstTagMergeMode mode, GstAdapter * adapter); + +extern void +metadataparse_exif_tags_register (void); G_END_DECLS diff --git a/ext/metadata/metadataparseiptc.c b/ext/metadata/metadataparseiptc.c index b6d0e4cf..9c983a70 100644 --- a/ext/metadata/metadataparseiptc.c +++ b/ext/metadata/metadataparseiptc.c @@ -46,14 +46,46 @@ GST_DEBUG_CATEGORY (gst_metadata_parse_iptc_debug); #define GST_CAT_DEFAULT gst_metadata_parse_iptc_debug +#define GST_TAG_IPTC "iptc" + +void +metadataparse_iptc_tags_register (void) +{ + gst_tag_register (GST_TAG_IPTC, GST_TAG_FLAG_META, + GST_TYPE_BUFFER, GST_TAG_IPTC, "iptc metadata chunk", NULL); +} + +void +metadataparse_tag_list_add_chunk (GstTagList * taglist, GstTagMergeMode mode, + const gchar * name, GstAdapter * adapter) +{ + GstBuffer *buf; + guint size; + + if (adapter && (size = gst_adapter_available (adapter))) { + + buf = gst_buffer_new_and_alloc (size); + + gst_adapter_copy (adapter, GST_BUFFER_DATA (buf), 0, size); + + gst_tag_list_add (taglist, mode, name, buf, NULL); + + gst_buffer_unref (buf); + } + +} + #ifndef HAVE_IPTC void -metadataparse_iptc_dump (GstAdapter * adapter) +metadataparse_iptc_tag_list_add (GstTagList * taglist, GstTagMergeMode mode, + GstAdapter * adapter) { GST_LOG ("IPTC not defined, here I should send just one tag as whole chunk"); + metadataparse_tag_list_add_chunk (taglist, mode, GST_TAG_IPTC, adapter); + } #else /* ifndef HAVE_IPTC */ @@ -64,7 +96,8 @@ static void iptc_data_foreach_dataset_func (IptcDataSet * dataset, void *user_data); void -metadataparse_iptc_dump (GstAdapter * adapter) +metadataparse_iptc_tag_list_add (GstTagList * taglist, GstTagMergeMode mode, + GstAdapter * adapter) { const guint8 *buf; guint32 size; @@ -74,6 +107,9 @@ metadataparse_iptc_dump (GstAdapter * adapter) goto done; } + /* add chunk tag */ + metadataparse_tag_list_add_chunk (taglist, mode, GST_TAG_IPTC, adapter); + buf = gst_adapter_peek (adapter, size); iptc = iptc_data_new_from_data (buf, size); @@ -81,7 +117,8 @@ metadataparse_iptc_dump (GstAdapter * adapter) goto done; } - iptc_data_foreach_dataset (iptc, iptc_data_foreach_dataset_func, NULL); + iptc_data_foreach_dataset (iptc, iptc_data_foreach_dataset_func, + (void *) taglist); done: @@ -97,6 +134,7 @@ iptc_data_foreach_dataset_func (IptcDataSet * dataset, void *user_data) { char *buf[256]; + GstTagList *taglist = (GstTagList *) user_data; GST_LOG ("name -> %s", iptc_tag_get_name (dataset->record, dataset->tag)); GST_LOG ("title -> %s", iptc_tag_get_title (dataset->record, dataset->tag)); diff --git a/ext/metadata/metadataparseiptc.h b/ext/metadata/metadataparseiptc.h index 4bba6e4f..29bb559c 100644 --- a/ext/metadata/metadataparseiptc.h +++ b/ext/metadata/metadataparseiptc.h @@ -50,7 +50,10 @@ G_BEGIN_DECLS extern void -metadataparse_iptc_dump(GstAdapter *adapter); +metadataparse_iptc_tag_list_add (GstTagList *taglist, GstTagMergeMode mode, GstAdapter * adapter); + +extern void +metadataparse_iptc_tags_register (void); G_END_DECLS diff --git a/ext/metadata/metadataparsexmp.c b/ext/metadata/metadataparsexmp.c index 7aee17f2..5af6bd62 100644 --- a/ext/metadata/metadataparsexmp.c +++ b/ext/metadata/metadataparsexmp.c @@ -46,10 +46,16 @@ GST_DEBUG_CATEGORY (gst_metadata_parse_xmp_debug); #define GST_CAT_DEFAULT gst_metadata_parse_xmp_debug +void +metadataparse_xmp_tags_register (void) +{ +} + #ifndef HAVE_XMP void -metadataparse_xmp_dump (GstAdapter * adapter) +metadataparse_xmp_tag_list_add (GstTagList * taglist, GstTagMergeMode mode, + GstAdapter * adapter) { GST_LOG ("XMP not defined, here I should send just one tag as whole chunk"); @@ -59,7 +65,8 @@ metadataparse_xmp_dump (GstAdapter * adapter) #else /* ifndef HAVE_XMP */ void -metadataparse_xmp_dump (GstAdapter * adapter) +metadataparse_xmp_tag_list_add (GstTagList * taglist, GstTagMergeMode mode, + GstAdapter * adapter) { GST_LOG ("XMP still not implemented"); diff --git a/ext/metadata/metadataparsexmp.h b/ext/metadata/metadataparsexmp.h index 6e988a23..a3e0c8c2 100644 --- a/ext/metadata/metadataparsexmp.h +++ b/ext/metadata/metadataparsexmp.h @@ -50,7 +50,10 @@ G_BEGIN_DECLS extern void -metadataparse_xmp_dump(GstAdapter *adapter); +metadataparse_xmp_tag_list_add (GstTagList *taglist, GstTagMergeMode mode, GstAdapter * adapter); + +extern void +metadataparse_xmp_tags_register (void); G_END_DECLS |