mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 20:21:24 +00:00
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.
This commit is contained in:
parent
c1e6c76cdb
commit
14da2ceef5
11 changed files with 159 additions and 44 deletions
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
|||
2007-11-28 Edgard Lima <edgard.lima@indt.org.br>
|
||||
|
||||
* 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 <edgard.lima@indt.org.br>
|
||||
|
||||
* ext/metadata/Makefile.am:
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
@ -380,13 +380,11 @@ gst_metadata_mux_get_caps (GstPad * pad)
|
|||
mime = gst_structure_get_name (structure);
|
||||
|
||||
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,
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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 ();
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -52,11 +52,12 @@ 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");
|
||||
|
||||
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,8 +122,12 @@ metadataparse_xmp_tag_list_add (GstTagList * taglist, GstTagMergeMode mode,
|
|||
}
|
||||
|
||||
/* add chunk tag */
|
||||
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);
|
||||
|
||||
xmp = xmp_new (buf, size);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue