2007-10-30 12:49:04 +00:00
|
|
|
/*
|
|
|
|
* GStreamer
|
|
|
|
* Copyright 2007 Edgard Lima <edgard.lima@indt.org.br>
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
* DEALINGS IN THE SOFTWARE.
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the
|
|
|
|
* GNU Lesser General Public License Version 2.1 (the "LGPL"), in
|
|
|
|
* which case the following provisions apply instead of the ones
|
|
|
|
* mentioned above:
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2008-01-23 16:35:34 +00:00
|
|
|
* SECTION: element-metadatademux
|
|
|
|
* @see_also: #metadatamux
|
2007-10-30 12:49:04 +00:00
|
|
|
*
|
|
|
|
* <refsect2>
|
2008-01-23 16:35:34 +00:00
|
|
|
* <para>
|
|
|
|
* This element parses image files JPEG and PNG, to find metadata chunks (EXIF,
|
|
|
|
* IPTC, XMP) in it, and then send individual tags as a 'tag message' do the
|
|
|
|
* application and as 'tag event' to the next element in pipeline. It also
|
|
|
|
* strips out the metadata chunks from original stream (unless the 'parse-only'
|
|
|
|
* property is set to 'true'). In addition the whole metadata chunk (striped
|
|
|
|
* or not) it also sent as a message to the application bus, so the application
|
|
|
|
* can have more controls about the metadata.
|
|
|
|
* </para>
|
2007-10-30 12:49:04 +00:00
|
|
|
* <title>Example launch line</title>
|
|
|
|
* <para>
|
|
|
|
* <programlisting>
|
2008-01-23 16:35:34 +00:00
|
|
|
* gst-launch -v -m filesrc location=./test.jpeg ! metadatademux ! fakesink
|
|
|
|
* silent=TRUE
|
|
|
|
* </programlisting>
|
|
|
|
* <programlisting>
|
|
|
|
* GST_DEBUG:*metadata:5 gst-launch filesrc location=./test.jpeg !
|
|
|
|
* metadatademux ! fakesink
|
|
|
|
* </programlisting>
|
|
|
|
* </para>
|
|
|
|
* <title>Application sample code using 'libexif' to have more control</title>
|
|
|
|
* <para>
|
|
|
|
* <programlisting>
|
|
|
|
* val = gst_tag_list_get_value_index (taglist, GST_TAG_EXIF, 0);
|
|
|
|
* if (val) {
|
|
|
|
* exif_chunk = gst_value_get_buffer (val);
|
|
|
|
* if (exif_chunk) {
|
|
|
|
* ed = exif_data_new_from_data (GST_BUFFER_DATA (exif_chunk),
|
|
|
|
* GST_BUFFER_SIZE (exif_chunk));
|
|
|
|
* }
|
|
|
|
* }
|
2007-10-30 12:49:04 +00:00
|
|
|
* </programlisting>
|
2008-01-23 16:35:34 +00:00
|
|
|
* This same idea can be used to handle IPTC and XMP directly by using
|
|
|
|
* libdata and exempi (or any other libraries). Notice: the whole metadata
|
|
|
|
* chunk sent as a message to the application contains only metadata data, i.e.
|
|
|
|
* the wrapper specific to the file format (JPEG, PNG, ...) is already
|
|
|
|
* striped out.
|
2007-10-30 12:49:04 +00:00
|
|
|
* </para>
|
|
|
|
* </refsect2>
|
|
|
|
*/
|
|
|
|
|
2008-01-23 16:35:34 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* includes
|
|
|
|
*/
|
|
|
|
|
2007-10-30 12:49:04 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <gst/gst.h>
|
|
|
|
|
2007-12-14 18:18:37 +00:00
|
|
|
#include "gstmetadatademux.h"
|
2007-10-30 12:49:04 +00:00
|
|
|
|
2007-11-28 08:13:52 +00:00
|
|
|
#include "metadataexif.h"
|
2007-10-30 12:49:04 +00:00
|
|
|
|
2007-11-28 08:13:52 +00:00
|
|
|
#include "metadataiptc.h"
|
2007-10-30 12:49:04 +00:00
|
|
|
|
2007-11-28 08:13:52 +00:00
|
|
|
#include "metadataxmp.h"
|
2007-10-30 12:49:04 +00:00
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
2008-01-23 16:35:34 +00:00
|
|
|
/*
|
|
|
|
* enum and types
|
|
|
|
*/
|
2007-10-30 12:49:04 +00:00
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
ARG_0,
|
2007-12-17 12:37:36 +00:00
|
|
|
ARG_PARSE_ONLY
|
2007-10-30 12:49:04 +00:00
|
|
|
};
|
|
|
|
|
2008-01-23 16:35:34 +00:00
|
|
|
/*
|
|
|
|
* defines and static global vars
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2010-02-05 09:16:27 +00:00
|
|
|
GST_DEBUG_CATEGORY (gst_metadata_demux_debug);
|
2008-01-23 16:35:34 +00:00
|
|
|
#define GST_CAT_DEFAULT gst_metadata_demux_debug
|
|
|
|
|
|
|
|
#define GOTO_DONE_IF_NULL(ptr) \
|
|
|
|
do { if ( NULL == (ptr) ) goto done; } while(FALSE)
|
|
|
|
#define GOTO_DONE_IF_NULL_AND_FAIL(ptr, ret) \
|
|
|
|
do { if ( NULL == (ptr) ) { (ret) = FALSE; goto done; } } while(FALSE)
|
|
|
|
|
2007-10-30 12:49:04 +00:00
|
|
|
static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
|
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS,
|
2007-10-30 18:21:22 +00:00
|
|
|
GST_STATIC_CAPS ("image/jpeg, "
|
|
|
|
"tags-extracted = (bool) false;"
|
|
|
|
"image/png, " "tags-extracted = (bool) false")
|
2007-10-30 12:49:04 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
|
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_ALWAYS,
|
2007-10-30 18:21:22 +00:00
|
|
|
GST_STATIC_CAPS ("image/jpeg, "
|
|
|
|
"tags-extracted = (bool) true;"
|
|
|
|
"image/png, " "tags-extracted = (bool) true")
|
2007-10-30 12:49:04 +00:00
|
|
|
);
|
|
|
|
|
2007-12-14 18:18:37 +00:00
|
|
|
static GstMetadataDemuxClass *metadata_parent_class = NULL;
|
2007-10-30 12:49:04 +00:00
|
|
|
|
2008-01-23 16:35:34 +00:00
|
|
|
/*
|
|
|
|
* static helper functions declaration
|
|
|
|
*/
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_metadata_demux_configure_srccaps (GstMetadataDemux * filter);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* GObject callback functions declaration
|
|
|
|
*/
|
|
|
|
|
2007-12-14 18:18:37 +00:00
|
|
|
static void gst_metadata_demux_set_property (GObject * object, guint prop_id,
|
2007-10-30 12:49:04 +00:00
|
|
|
const GValue * value, GParamSpec * pspec);
|
2008-01-23 16:35:34 +00:00
|
|
|
|
2007-12-14 18:18:37 +00:00
|
|
|
static void gst_metadata_demux_get_property (GObject * object, guint prop_id,
|
2007-10-30 12:49:04 +00:00
|
|
|
GValue * value, GParamSpec * pspec);
|
|
|
|
|
2008-01-23 16:35:34 +00:00
|
|
|
/*
|
|
|
|
* GstBaseMetadata virtual functions declaration
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void gst_metadata_demux_send_tags (GstBaseMetadata * base);
|
|
|
|
|
2007-12-14 18:18:37 +00:00
|
|
|
static gboolean gst_metadata_demux_set_caps (GstPad * pad, GstCaps * caps);
|
2008-01-23 16:35:34 +00:00
|
|
|
|
|
|
|
static GstCaps *gst_metadata_demux_get_caps (GstPad * pad);
|
|
|
|
|
2007-12-14 18:18:37 +00:00
|
|
|
static gboolean gst_metadata_demux_sink_event (GstPad * pad, GstEvent * event);
|
2007-10-30 12:49:04 +00:00
|
|
|
|
2008-01-23 16:35:34 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* GST BOILERPLATE
|
|
|
|
*/
|
|
|
|
|
|
|
|
GST_BOILERPLATE (GstMetadataDemux, gst_metadata_demux, GstBaseMetadata,
|
|
|
|
GST_TYPE_BASE_METADATA);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* static helper functions implementation
|
|
|
|
*/
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_metadata_demux_configure_srccaps (GstMetadataDemux * filter)
|
|
|
|
{
|
|
|
|
GstCaps *caps = NULL;
|
|
|
|
gboolean ret = FALSE;
|
2010-03-22 12:16:33 +00:00
|
|
|
const gchar *mime = NULL;
|
2008-01-23 16:35:34 +00:00
|
|
|
|
|
|
|
switch (GST_BASE_METADATA_IMG_TYPE (filter)) {
|
|
|
|
case IMG_JPEG:
|
|
|
|
mime = "image/jpeg";
|
|
|
|
break;
|
|
|
|
case IMG_PNG:
|
|
|
|
mime = "image/png";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ret = FALSE;
|
|
|
|
goto done;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
caps =
|
|
|
|
gst_caps_new_simple (mime, "tags-extracted", G_TYPE_BOOLEAN, TRUE, NULL);
|
|
|
|
|
|
|
|
ret = gst_pad_set_caps (GST_BASE_METADATA_SRC_PAD (filter), caps);
|
|
|
|
|
|
|
|
done:
|
|
|
|
|
|
|
|
if (caps) {
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
caps = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* GObject callback functions implementation
|
|
|
|
*/
|
2007-11-19 13:05:23 +00:00
|
|
|
|
2007-10-30 12:49:04 +00:00
|
|
|
static void
|
2007-12-14 18:18:37 +00:00
|
|
|
gst_metadata_demux_base_init (gpointer gclass)
|
2007-10-30 12:49:04 +00:00
|
|
|
{
|
|
|
|
GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
|
|
|
|
|
|
|
|
gst_element_class_add_pad_template (element_class,
|
|
|
|
gst_static_pad_template_get (&src_factory));
|
|
|
|
gst_element_class_add_pad_template (element_class,
|
|
|
|
gst_static_pad_template_get (&sink_factory));
|
2010-03-18 16:30:26 +00:00
|
|
|
gst_element_class_set_details_simple (element_class, "Metadata demuxer",
|
|
|
|
"Demuxer/Extracter/Metadata",
|
|
|
|
"Send metadata tags (EXIF, IPTC and XMP) and "
|
|
|
|
"remove metadata chunks from stream",
|
|
|
|
"Edgard Lima <edgard.lima@indt.org.br>");
|
2007-10-30 12:49:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-12-14 18:18:37 +00:00
|
|
|
gst_metadata_demux_class_init (GstMetadataDemuxClass * klass)
|
2007-10-30 12:49:04 +00:00
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
|
|
|
GstElementClass *gstelement_class;
|
2007-12-19 09:50:47 +00:00
|
|
|
GstBaseMetadataClass *gstbasemetadata_class;
|
2007-10-30 12:49:04 +00:00
|
|
|
|
|
|
|
gobject_class = (GObjectClass *) klass;
|
|
|
|
gstelement_class = (GstElementClass *) klass;
|
2007-12-19 09:50:47 +00:00
|
|
|
gstbasemetadata_class = (GstBaseMetadataClass *) klass;
|
2007-10-30 12:49:04 +00:00
|
|
|
|
|
|
|
metadata_parent_class = g_type_class_peek_parent (klass);
|
|
|
|
|
2007-12-14 18:18:37 +00:00
|
|
|
gobject_class->set_property = gst_metadata_demux_set_property;
|
|
|
|
gobject_class->get_property = gst_metadata_demux_get_property;
|
2007-10-30 12:49:04 +00:00
|
|
|
|
2007-12-17 12:37:36 +00:00
|
|
|
g_object_class_install_property (gobject_class, ARG_PARSE_ONLY,
|
|
|
|
g_param_spec_boolean ("parse-only", "parse-only",
|
|
|
|
"If TRUE, don't strip out any chunk", FALSE, G_PARAM_READWRITE));
|
|
|
|
|
2007-12-19 09:50:47 +00:00
|
|
|
gstbasemetadata_class->processing =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_metadata_demux_send_tags);
|
|
|
|
gstbasemetadata_class->set_caps =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_metadata_demux_set_caps);
|
|
|
|
gstbasemetadata_class->get_sink_caps =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_metadata_demux_get_caps);
|
|
|
|
gstbasemetadata_class->get_src_caps =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_metadata_demux_get_caps);
|
|
|
|
gstbasemetadata_class->sink_event =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_metadata_demux_sink_event);
|
2007-10-30 12:49:04 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-12-14 18:18:37 +00:00
|
|
|
gst_metadata_demux_init (GstMetadataDemux * filter,
|
|
|
|
GstMetadataDemuxClass * gclass)
|
2007-10-30 12:49:04 +00:00
|
|
|
{
|
2007-12-19 09:50:47 +00:00
|
|
|
gst_base_metadata_set_option_flag (GST_BASE_METADATA (filter),
|
|
|
|
META_OPT_EXIF | META_OPT_IPTC | META_OPT_XMP | META_OPT_DEMUX);
|
2007-10-30 12:49:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-12-14 18:18:37 +00:00
|
|
|
gst_metadata_demux_set_property (GObject * object, guint prop_id,
|
2007-10-30 12:49:04 +00:00
|
|
|
const GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
|
|
|
switch (prop_id) {
|
2007-12-17 12:37:36 +00:00
|
|
|
case ARG_PARSE_ONLY:
|
|
|
|
if (g_value_get_boolean (value))
|
2007-12-19 09:50:47 +00:00
|
|
|
gst_base_metadata_set_option_flag (GST_BASE_METADATA (object),
|
|
|
|
META_OPT_PARSE_ONLY);
|
2007-12-17 12:37:36 +00:00
|
|
|
else
|
2007-12-19 09:50:47 +00:00
|
|
|
gst_base_metadata_unset_option_flag (GST_BASE_METADATA (object),
|
|
|
|
META_OPT_PARSE_ONLY);
|
2007-12-17 12:37:36 +00:00
|
|
|
break;
|
2007-10-30 12:49:04 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-12-14 18:18:37 +00:00
|
|
|
gst_metadata_demux_get_property (GObject * object, guint prop_id,
|
2007-10-30 12:49:04 +00:00
|
|
|
GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
2007-12-19 09:50:47 +00:00
|
|
|
guint8 option =
|
|
|
|
gst_base_metadata_get_option_flag (GST_BASE_METADATA (object));
|
2007-10-30 12:49:04 +00:00
|
|
|
|
|
|
|
switch (prop_id) {
|
2007-12-17 12:37:36 +00:00
|
|
|
case ARG_PARSE_ONLY:
|
2007-12-19 09:50:47 +00:00
|
|
|
g_value_set_boolean (value, option & META_OPT_PARSE_ONLY);
|
2007-12-17 12:37:36 +00:00
|
|
|
break;
|
2007-10-30 12:49:04 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-01-23 16:35:34 +00:00
|
|
|
/*
|
|
|
|
* GstBaseMetadata virtual functions implementation
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* gst_metadata_demux_send_tags:
|
|
|
|
* @base: the base metadata instance
|
|
|
|
*
|
|
|
|
* Send individual tags as message to the bus and as event to the next
|
|
|
|
* element, and send the whole metadata chunk (with file specific wrapper
|
|
|
|
* striped) to the next element as a event.
|
|
|
|
*
|
|
|
|
* Returns: nothing
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2007-10-30 12:49:04 +00:00
|
|
|
static void
|
2007-12-19 09:50:47 +00:00
|
|
|
gst_metadata_demux_send_tags (GstBaseMetadata * base)
|
2007-10-30 12:49:04 +00:00
|
|
|
{
|
2007-11-23 17:35:21 +00:00
|
|
|
|
2007-12-19 09:50:47 +00:00
|
|
|
GstMetadataDemux *filter = GST_METADATA_DEMUX (base);
|
|
|
|
GstMessage *msg;
|
|
|
|
GstTagList *taglist = gst_tag_list_new ();
|
|
|
|
GstEvent *event;
|
|
|
|
GstPad *srcpad = GST_BASE_METADATA_SRC_PAD (filter);
|
2007-11-23 17:35:21 +00:00
|
|
|
|
2008-01-23 16:35:34 +00:00
|
|
|
/* get whole chunk */
|
|
|
|
|
2007-12-19 09:50:47 +00:00
|
|
|
if (gst_base_metadata_get_option_flag (base) & META_OPT_EXIF)
|
|
|
|
metadataparse_exif_tag_list_add (taglist, GST_TAG_MERGE_KEEP,
|
|
|
|
GST_BASE_METADATA_EXIF_ADAPTER (base), METADATA_TAG_MAP_WHOLECHUNK);
|
|
|
|
if (gst_base_metadata_get_option_flag (base) & META_OPT_IPTC)
|
|
|
|
metadataparse_iptc_tag_list_add (taglist, GST_TAG_MERGE_KEEP,
|
|
|
|
GST_BASE_METADATA_IPTC_ADAPTER (base), METADATA_TAG_MAP_WHOLECHUNK);
|
|
|
|
if (gst_base_metadata_get_option_flag (base) & META_OPT_XMP)
|
|
|
|
metadataparse_xmp_tag_list_add (taglist, GST_TAG_MERGE_KEEP,
|
|
|
|
GST_BASE_METADATA_XMP_ADAPTER (base), METADATA_TAG_MAP_WHOLECHUNK);
|
|
|
|
|
|
|
|
if (taglist && !gst_tag_list_is_empty (taglist)) {
|
|
|
|
|
|
|
|
msg =
|
|
|
|
gst_message_new_tag (GST_OBJECT (filter), gst_tag_list_copy (taglist));
|
|
|
|
gst_element_post_message (GST_ELEMENT (filter), msg);
|
2007-11-23 17:35:21 +00:00
|
|
|
|
2007-12-19 09:50:47 +00:00
|
|
|
event = gst_event_new_tag (taglist);
|
|
|
|
gst_pad_push_event (srcpad, event);
|
|
|
|
taglist = NULL;
|
2007-11-23 17:35:21 +00:00
|
|
|
}
|
2007-10-30 12:49:04 +00:00
|
|
|
|
2007-12-19 09:50:47 +00:00
|
|
|
if (!taglist)
|
|
|
|
taglist = gst_tag_list_new ();
|
2007-11-18 21:06:51 +00:00
|
|
|
|
2008-01-23 16:35:34 +00:00
|
|
|
/*get individual tags */
|
|
|
|
|
2007-12-19 09:50:47 +00:00
|
|
|
if (gst_base_metadata_get_option_flag (base) & META_OPT_EXIF)
|
|
|
|
metadataparse_exif_tag_list_add (taglist, GST_TAG_MERGE_KEEP,
|
|
|
|
GST_BASE_METADATA_EXIF_ADAPTER (base), METADATA_TAG_MAP_INDIVIDUALS);
|
|
|
|
if (gst_base_metadata_get_option_flag (base) & META_OPT_IPTC)
|
|
|
|
metadataparse_iptc_tag_list_add (taglist, GST_TAG_MERGE_KEEP,
|
|
|
|
GST_BASE_METADATA_IPTC_ADAPTER (base), METADATA_TAG_MAP_INDIVIDUALS);
|
|
|
|
if (gst_base_metadata_get_option_flag (base) & META_OPT_XMP)
|
|
|
|
metadataparse_xmp_tag_list_add (taglist, GST_TAG_MERGE_KEEP,
|
|
|
|
GST_BASE_METADATA_XMP_ADAPTER (base), METADATA_TAG_MAP_INDIVIDUALS);
|
2007-11-23 17:35:21 +00:00
|
|
|
|
2007-12-19 09:50:47 +00:00
|
|
|
if (taglist && !gst_tag_list_is_empty (taglist)) {
|
2007-11-23 17:35:21 +00:00
|
|
|
|
2007-12-19 09:50:47 +00:00
|
|
|
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);
|
2007-12-04 16:42:25 +00:00
|
|
|
|
2007-10-30 12:49:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2007-12-14 18:18:37 +00:00
|
|
|
gst_metadata_demux_set_caps (GstPad * pad, GstCaps * caps)
|
2007-10-30 12:49:04 +00:00
|
|
|
{
|
2007-12-14 18:18:37 +00:00
|
|
|
GstMetadataDemux *filter = NULL;
|
2007-10-30 12:49:04 +00:00
|
|
|
GstStructure *structure = NULL;
|
|
|
|
const gchar *mime = NULL;
|
|
|
|
gboolean ret = FALSE;
|
2007-12-19 09:50:47 +00:00
|
|
|
gboolean based = TRUE;
|
2007-10-30 12:49:04 +00:00
|
|
|
|
2007-12-14 18:18:37 +00:00
|
|
|
filter = GST_METADATA_DEMUX (gst_pad_get_parent (pad));
|
2007-10-30 12:49:04 +00:00
|
|
|
|
|
|
|
structure = gst_caps_get_structure (caps, 0);
|
|
|
|
|
|
|
|
mime = gst_structure_get_name (structure);
|
|
|
|
|
|
|
|
if (strcmp (mime, "image/jpeg") == 0) {
|
2007-12-19 09:50:47 +00:00
|
|
|
GST_BASE_METADATA_IMG_TYPE (filter) = IMG_JPEG;
|
2007-10-30 12:49:04 +00:00
|
|
|
} else if (strcmp (mime, "image/png") == 0) {
|
2007-12-19 09:50:47 +00:00
|
|
|
GST_BASE_METADATA_IMG_TYPE (filter) = IMG_PNG;
|
2007-10-30 12:49:04 +00:00
|
|
|
} else {
|
2007-10-30 18:21:22 +00:00
|
|
|
ret = FALSE;
|
2007-10-30 12:49:04 +00:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2007-12-19 09:50:47 +00:00
|
|
|
if (gst_structure_get_boolean (structure, "tags-extracted", &based)) {
|
|
|
|
if (based == TRUE) {
|
2007-10-30 18:21:22 +00:00
|
|
|
ret = FALSE;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-12-14 18:18:37 +00:00
|
|
|
ret = gst_metadata_demux_configure_srccaps (filter);
|
2007-10-30 12:49:04 +00:00
|
|
|
|
|
|
|
done:
|
|
|
|
|
|
|
|
gst_object_unref (filter);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-12-19 09:50:47 +00:00
|
|
|
static GstCaps *
|
|
|
|
gst_metadata_demux_get_caps (GstPad * pad)
|
2007-10-30 12:49:04 +00:00
|
|
|
{
|
2007-12-14 18:18:37 +00:00
|
|
|
GstMetadataDemux *filter = NULL;
|
2007-12-19 09:50:47 +00:00
|
|
|
GstPad *otherpad;
|
|
|
|
GstCaps *caps_new = NULL;
|
|
|
|
GstCaps *caps_otherpad_peer = NULL;
|
2007-10-30 12:49:04 +00:00
|
|
|
|
2007-12-14 18:18:37 +00:00
|
|
|
filter = GST_METADATA_DEMUX (gst_pad_get_parent (pad));
|
2007-10-30 12:49:04 +00:00
|
|
|
|
2007-12-19 09:50:47 +00:00
|
|
|
(GST_BASE_METADATA_SRC_PAD (filter) == pad) ?
|
|
|
|
(otherpad = GST_BASE_METADATA_SINK_PAD (filter)) :
|
|
|
|
(otherpad = GST_BASE_METADATA_SRC_PAD (filter));
|
2007-11-23 17:35:21 +00:00
|
|
|
|
2007-12-19 09:50:47 +00:00
|
|
|
caps_new = gst_caps_copy (gst_pad_get_pad_template_caps (pad));
|
2007-11-23 17:35:21 +00:00
|
|
|
|
2007-12-19 09:50:47 +00:00
|
|
|
caps_otherpad_peer = gst_pad_get_allowed_caps (otherpad);
|
|
|
|
GOTO_DONE_IF_NULL (caps_otherpad_peer);
|
2007-10-30 12:49:04 +00:00
|
|
|
|
2007-12-19 09:50:47 +00:00
|
|
|
if (gst_caps_is_empty (caps_otherpad_peer)
|
|
|
|
|| gst_caps_is_any (caps_otherpad_peer)) {
|
|
|
|
goto done;
|
2007-11-18 21:06:51 +00:00
|
|
|
} else {
|
2007-10-30 12:49:04 +00:00
|
|
|
|
2007-12-19 09:50:47 +00:00
|
|
|
guint i;
|
|
|
|
guint caps_size = 0;
|
2007-10-30 12:49:04 +00:00
|
|
|
|
2007-12-19 09:50:47 +00:00
|
|
|
caps_size = gst_caps_get_size (caps_otherpad_peer);
|
2007-11-02 16:50:42 +00:00
|
|
|
|
2007-12-19 09:50:47 +00:00
|
|
|
gst_caps_unref (caps_new);
|
2007-10-30 12:49:04 +00:00
|
|
|
|
2007-12-19 09:50:47 +00:00
|
|
|
caps_new = gst_caps_new_empty ();
|
2007-12-14 18:18:37 +00:00
|
|
|
|
2007-12-19 09:50:47 +00:00
|
|
|
for (i = 0; i < caps_size; ++i) {
|
|
|
|
GstStructure *structure = NULL;
|
|
|
|
GstStructure *structure_new = NULL;
|
|
|
|
const gchar *mime = NULL;
|
2007-10-30 12:49:04 +00:00
|
|
|
|
2007-12-19 09:50:47 +00:00
|
|
|
structure = gst_caps_get_structure (caps_otherpad_peer, i);
|
2007-10-30 12:49:04 +00:00
|
|
|
|
2007-12-19 09:50:47 +00:00
|
|
|
mime = gst_structure_get_name (structure);
|
2007-10-30 12:49:04 +00:00
|
|
|
|
2007-12-19 09:50:47 +00:00
|
|
|
if (pad == GST_BASE_METADATA_SINK_PAD (filter)) {
|
|
|
|
structure_new =
|
|
|
|
gst_structure_new (mime, "tags-extracted", G_TYPE_BOOLEAN, FALSE,
|
|
|
|
NULL);
|
2007-10-30 12:49:04 +00:00
|
|
|
} else {
|
2007-12-19 09:50:47 +00:00
|
|
|
structure_new =
|
|
|
|
gst_structure_new (mime, "tags-extracted", G_TYPE_BOOLEAN, TRUE,
|
|
|
|
NULL);
|
2007-10-30 12:49:04 +00:00
|
|
|
}
|
|
|
|
|
2007-12-19 09:50:47 +00:00
|
|
|
gst_caps_append_structure (caps_new, structure_new);
|
2007-10-30 12:49:04 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2007-11-02 16:50:42 +00:00
|
|
|
}
|
|
|
|
|
2007-10-30 12:49:04 +00:00
|
|
|
done:
|
|
|
|
|
2007-12-19 09:50:47 +00:00
|
|
|
if (caps_otherpad_peer) {
|
|
|
|
gst_caps_unref (caps_otherpad_peer);
|
|
|
|
caps_otherpad_peer = NULL;
|
2007-11-23 17:35:21 +00:00
|
|
|
}
|
|
|
|
|
2007-12-19 09:50:47 +00:00
|
|
|
gst_object_unref (filter);
|
2007-11-28 08:13:52 +00:00
|
|
|
|
2007-12-19 09:50:47 +00:00
|
|
|
return caps_new;
|
2007-11-02 12:03:04 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2007-12-19 09:50:47 +00:00
|
|
|
gst_metadata_demux_sink_event (GstPad * pad, GstEvent * event)
|
2007-11-02 12:03:04 +00:00
|
|
|
{
|
2007-12-19 09:50:47 +00:00
|
|
|
return gst_pad_event_default (pad, event);
|
2007-10-30 12:49:04 +00:00
|
|
|
}
|
|
|
|
|
2007-11-02 12:03:04 +00:00
|
|
|
|
2007-10-30 12:49:04 +00:00
|
|
|
/*
|
|
|
|
* element plugin init function
|
|
|
|
*/
|
|
|
|
|
|
|
|
gboolean
|
2007-12-14 18:18:37 +00:00
|
|
|
gst_metadata_demux_plugin_init (GstPlugin * plugin)
|
2007-10-30 12:49:04 +00:00
|
|
|
{
|
2007-12-14 18:18:37 +00:00
|
|
|
GST_DEBUG_CATEGORY_INIT (gst_metadata_demux_debug, "metadatademux", 0,
|
2007-10-30 12:49:04 +00:00
|
|
|
"Metadata demuxer");
|
|
|
|
|
2007-12-14 18:18:37 +00:00
|
|
|
return gst_element_register (plugin, "metadatademux",
|
2008-02-02 23:25:10 +00:00
|
|
|
GST_RANK_NONE, GST_TYPE_METADATA_DEMUX);
|
2007-10-30 12:49:04 +00:00
|
|
|
}
|