From fb4dbf8ae540789e384b70b985cf10a10d0ad35e Mon Sep 17 00:00:00 2001 From: Edgard Lima Date: Tue, 30 Oct 2007 18:21:22 +0000 Subject: Changed kclass to "Parser/Extracter/Metadata", changed caps to "image/jpeg, tags-extract=true/false" and changed prio... Original commit message from CVS: Changed kclass to "Parser/Extracter/Metadata", changed caps to "image/jpeg, tags-extract=true/false" and changed priority to GST_RANK_PRIMARY+1. Also, srcpad can only work in push mode until fixed to also work in pull mode. --- ext/metadata/.gitignore | 7 ++++++ ext/metadata/gstmetadataparse.c | 54 ++++++++++++++++++++++++++--------------- ext/metadata/metadataparse.c | 5 ++++ ext/metadata/metadataparse.h | 3 --- 4 files changed, 47 insertions(+), 22 deletions(-) create mode 100644 ext/metadata/.gitignore (limited to 'ext/metadata') diff --git a/ext/metadata/.gitignore b/ext/metadata/.gitignore new file mode 100644 index 00000000..08f5ed37 --- /dev/null +++ b/ext/metadata/.gitignore @@ -0,0 +1,7 @@ +Makefile +Makefile.in +*.o +*.lo +*.la +.deps +.libs diff --git a/ext/metadata/gstmetadataparse.c b/ext/metadata/gstmetadataparse.c index d40384c8..81b0b360 100644 --- a/ext/metadata/gstmetadataparse.c +++ b/ext/metadata/gstmetadataparse.c @@ -99,13 +99,17 @@ enum static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, - GST_STATIC_CAPS ("image/jpeg;" "image/png") + GST_STATIC_CAPS ("image/jpeg, " + "tags-extracted = (bool) false;" + "image/png, " "tags-extracted = (bool) false") ); static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_SRC, GST_PAD_ALWAYS, - GST_STATIC_CAPS ("image/jpeg-metadata;" "image/png-metadata") + GST_STATIC_CAPS ("image/jpeg, " + "tags-extracted = (bool) true;" + "image/png, " "tags-extracted = (bool) true") ); GST_BOILERPLATE (GstMetadataParse, gst_metadata_parse, GstElement, @@ -155,7 +159,7 @@ gst_metadata_parse_base_init (gpointer gclass) { static GstElementDetails element_details = { "Metadata parser", - "Image/Extracter/Metadata", + "Parser/Extracter/Metadata", "Send metadata tags (EXIF, IPTC and XMP) while passing throught the contents", "Edgard Lima " }; @@ -236,8 +240,9 @@ gst_metadata_parse_init (GstMetadataParse * filter, GST_DEBUG_FUNCPTR (gst_metadata_parse_get_caps)); gst_pad_set_event_function (filter->srcpad, gst_metadata_parse_src_event); gst_pad_use_fixed_caps (filter->srcpad); +#if 0 /* FIXME it should also work with it */ gst_pad_set_getrange_function (filter->srcpad, gst_metadata_parse_get_range); - +#endif /* addind pads */ gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad); @@ -342,24 +347,24 @@ gst_metadata_parse_get_caps (GstPad * pad) for (i = 0; i < caps_size; ++i) { GstStructure *structure = NULL; GstStructure *structure_new = NULL; - GString *mime = NULL; + const gchar *mime = NULL; structure = gst_caps_get_structure (caps_otherpad_peer, i); - mime = g_string_new (gst_structure_get_name (structure)); - if (otherpad == filter->sinkpad) { - g_string_append (mime, "-metadata"); + mime = gst_structure_get_name (structure); + + if (pad == filter->sinkpad) { + structure_new = + gst_structure_new (mime, "tags-extracted", G_TYPE_BOOLEAN, FALSE, + NULL); } else { - /* strip ou "-metadata" */ - mime->str[mime->len - 9] = '\0'; + structure_new = + gst_structure_new (mime, "tags-extracted", G_TYPE_BOOLEAN, TRUE, + NULL); } - structure_new = gst_structure_empty_new (mime->str); - gst_caps_append_structure (caps_new, structure_new); - g_string_free (mime, TRUE); - } } @@ -494,17 +499,19 @@ gst_metadata_parse_configure_srccaps (GstMetadataParse * filter) switch (filter->img_type) { case IMG_JPEG: - mime = "image/jpeg-metadata"; + mime = "image/jpeg"; break; case IMG_PNG: - mime = "image/png-metadata"; + mime = "image/png"; break; default: + ret = FALSE; goto done; break; } - caps = gst_caps_new_simple (mime, NULL); + caps = + gst_caps_new_simple (mime, "tags-extracted", G_TYPE_BOOLEAN, TRUE, NULL); ret = gst_pad_set_caps (filter->srcpad, caps); @@ -573,6 +580,7 @@ gst_metadata_parse_set_caps (GstPad * pad, GstCaps * caps) GstStructure *structure = NULL; const gchar *mime = NULL; gboolean ret = FALSE; + gboolean parsed = TRUE; filter = GST_METADATA_PARSE (gst_pad_get_parent (pad)); @@ -585,9 +593,17 @@ gst_metadata_parse_set_caps (GstPad * pad, GstCaps * caps) } else if (strcmp (mime, "image/png") == 0) { filter->img_type = IMG_PNG; } else { + ret = FALSE; goto done; } + if (gst_structure_get_boolean (structure, "tags-extracted", &parsed)) { + if (parsed == TRUE) { + ret = FALSE; + goto done; + } + } + ret = gst_metadata_parse_configure_srccaps (filter); done: @@ -823,7 +839,7 @@ done: if (!gst_pad_is_active (filter->sinkpad)) { ret = gst_pad_activate_push (filter->srcpad, TRUE); - ret &= gst_pad_activate_push (filter->sinkpad, TRUE); + ret = ret && gst_pad_activate_push (filter->sinkpad, TRUE); } } while (FALSE); @@ -910,5 +926,5 @@ gst_metadata_parse_plugin_init (GstPlugin * plugin) return gst_element_register (plugin, "metadataparse", - GST_RANK_PRIMARY, GST_TYPE_METADATA_PARSE); + GST_RANK_PRIMARY + 1, GST_TYPE_METADATA_PARSE); } diff --git a/ext/metadata/metadataparse.c b/ext/metadata/metadataparse.c index 50fdbaba..9c7dfa84 100644 --- a/ext/metadata/metadataparse.c +++ b/ext/metadata/metadataparse.c @@ -103,6 +103,7 @@ metadataparse_parse (ParseData * parse_data, const guint8 * buf, (guint8 *) buf, &bufsize, &next_start, next_size); break; case IMG_PNG: + ret = 0; break; default: /* unexpected */ @@ -115,6 +116,10 @@ metadataparse_parse (ParseData * parse_data, const guint8 * buf, done: + if (ret == 0) { + parse_data->state = STATE_DONE; + } + return ret; } diff --git a/ext/metadata/metadataparse.h b/ext/metadata/metadataparse.h index 661bb31d..fde0a8b8 100644 --- a/ext/metadata/metadataparse.h +++ b/ext/metadata/metadataparse.h @@ -60,9 +60,6 @@ typedef enum _tag_ParseOption { typedef enum _tag_ParseState { STATE_NULL, STATE_READING, - STATE_EXIF, - STATE_IPTC, - STATE_XMP, STATE_DONE } ParseState; -- cgit v1.2.1