diff options
author | Edgard Lima <edgard.lima@indt.org.br> | 2008-01-25 17:45:28 +0000 |
---|---|---|
committer | Edgard Lima <edgard.lima@indt.org.br> | 2008-01-25 17:45:28 +0000 |
commit | 9e31b57dc37cb94761ab3aa98018c6f9bc496e0c (patch) | |
tree | 3f9470e0fef203014f017eb35a06b1da3426ed53 /ext/metadata/metadataxmp.c | |
parent | ef421fee72539e6202c8535687f15da2c3d4d1a7 (diff) | |
download | gst-plugins-bad-9e31b57dc37cb94761ab3aa98018c6f9bc496e0c.tar.gz gst-plugins-bad-9e31b57dc37cb94761ab3aa98018c6f9bc496e0c.tar.bz2 gst-plugins-bad-9e31b57dc37cb94761ab3aa98018c6f9bc496e0c.zip |
Add lot of documentation.
Original commit message from CVS:
Add lot of documentation.
Diffstat (limited to 'ext/metadata/metadataxmp.c')
-rw-r--r-- | ext/metadata/metadataxmp.c | 621 |
1 files changed, 448 insertions, 173 deletions
diff --git a/ext/metadata/metadataxmp.c b/ext/metadata/metadataxmp.c index cc8172ce..6712fbdb 100644 --- a/ext/metadata/metadataxmp.c +++ b/ext/metadata/metadataxmp.c @@ -41,40 +41,76 @@ * Boston, MA 02111-1307, USA. */ +/* + * SECTION: metadataxmp + * @short_description: This module provides functions to extract tags from + * XMP metadata chunks and create XMP chunks from metadata tags. + * @see_also: #metadatatags.[c/h] + * + * If lib exempi isn't available at compilation time, only the whole chunk + * (#METADATA_TAG_MAP_WHOLECHUNK) tags is created. It means that individual + * tags aren't mapped. + * + * <refsect2> + * <para> + * #metadata_xmp_init must be called before any other function in this + * module and must be paired with a call to #metadata_xmp_dispose + * </para> + * </refsect2> + * + * Last reviewed on 2008-01-24 (0.10.15) + */ + +/* + * includes + */ + #include "metadataxmp.h" #include "metadataparseutil.h" #include "metadatatags.h" +/* + * defines + */ + GST_DEBUG_CATEGORY (gst_metadata_xmp_debug); #define GST_CAT_DEFAULT gst_metadata_xmp_debug -#ifndef HAVE_XMP - -void -metadataparse_xmp_tag_list_add (GstTagList * taglist, GstTagMergeMode mode, - GstAdapter * adapter, MetadataTagMapping mapping) -{ +/* + * Implementation when lib exempi isn't available at compilation time + */ - if (mapping & METADATA_TAG_MAP_WHOLECHUNK) { - 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); - } +#ifndef HAVE_XMP -} +/* + * extern functions implementations + */ gboolean -metadataparse_xmp_init (void) +metadata_xmp_init (void) { return TRUE; } void -metadataparse_xmp_dispose (void) +metadata_xmp_dispose (void) { return; } void +metadataparse_xmp_tag_list_add (GstTagList * taglist, GstTagMergeMode mode, + GstAdapter * adapter, MetadataTagMapping mapping) +{ + + if (mapping & METADATA_TAG_MAP_WHOLECHUNK) { + GST_LOG ("XMP not defined, sending just one tag as whole chunk"); + metadataparse_util_tag_list_add_chunk (taglist, mode, GST_TAG_XMP, adapter); + } + +} + +void metadatamux_xmp_create_chunk_from_tag_list (guint8 ** buf, guint32 * size, const GstTagList * taglist) { @@ -83,10 +119,20 @@ metadatamux_xmp_create_chunk_from_tag_list (guint8 ** buf, guint32 * size, #else /* ifndef HAVE_XMP */ +/* + * Implementation when lib exempi isn't available at compilation time + */ + +/* + * includes + */ + #include <xmp.h> #include <string.h> -#define XMP_SCHEMA_NODE 0x80000000UL +/* + * enum and types + */ typedef struct _tag_SchemaTagMap { @@ -102,6 +148,12 @@ typedef struct _tag_SchemaMap const SchemaTagMap *tags_map; } SchemaMap; +/* + * defines and static global vars + */ + +#define XMP_SCHEMA_NODE 0x80000000UL + static const SchemaTagMap schema_map_dublin_tags_map[] = { {"description", GST_TAG_DESCRIPTION}, {"title", GST_TAG_TITLE}, @@ -109,7 +161,8 @@ static const SchemaTagMap schema_map_dublin_tags_map[] = { {NULL, NULL} }; -static const SchemaMap schema_map_dublin = { "http://purl.org/dc/elements/1.1/", +static const SchemaMap schema_map_dublin = { + "http://purl.org/dc/elements/1.1/", "dc:", 3, schema_map_dublin_tags_map @@ -120,10 +173,22 @@ static const SchemaMap *schemas_map[] = { NULL }; +/* + * static helper functions declaration + */ + +static const SchemaTagMap *metadataparse_xmp_get_tagsmap_from_path (const + SchemaMap * schema_map, const gchar * path, uint32_t opt); + +static const SchemaTagMap *metadatamux_xmp_get_tagsmap_from_gsttag (const + SchemaMap * schema_map, const gchar * tag); + static void -metadataparse_xmp_iter_add_to_tag_list (GstTagList * taglist, - GstTagMergeMode mode, const char *path, const char *value, - const SchemaMap * schema_map, const uint32_t opt); +metadataparse_xmp_iter (GstTagList * taglist, GstTagMergeMode mode, XmpPtr xmp); + +static void +metadataparse_xmp_iter_node_schema (GstTagList * taglist, GstTagMergeMode mode, + XmpPtr xmp, const char *schema, const char *path); static void metadataparse_xmp_iter_array (GstTagList * taglist, GstTagMergeMode mode, @@ -131,34 +196,75 @@ metadataparse_xmp_iter_array (GstTagList * taglist, GstTagMergeMode mode, const SchemaMap * schema_map); static void -metadataparse_xmp_iter_node_schema (GstTagList * taglist, GstTagMergeMode mode, - XmpPtr xmp, const char *schema, const char *path); +metadataparse_xmp_iter_simple_qual (GstTagList * taglist, GstTagMergeMode mode, + const char *path, const char *value, const SchemaMap * schema_map); static void metadataparse_xmp_iter_simple (GstTagList * taglist, GstTagMergeMode mode, - const char *schema, const char *path, const char *value, - const SchemaMap * schema_map); + const char *path, const char *value, const SchemaMap * schema_map); static void -metadataparse_xmp_iter_simple_qual (GstTagList * taglist, GstTagMergeMode mode, - const char *schema, const char *path, const char *value, - const SchemaMap * schema_map); +metadataparse_xmp_iter_add_to_tag_list (GstTagList * taglist, + GstTagMergeMode mode, const char *path, const char *value, + const SchemaMap * schema_map, const uint32_t opt); static void -metadataparse_xmp_iter (GstTagList * taglist, GstTagMergeMode mode, XmpPtr xmp); +metadatamux_xmp_for_each_tag_in_list (const GstTagList * list, + const gchar * tag, gpointer user_data); + +/* + * extern functions implementations + */ + +/* + * metadata_xmp_init: + * + * Init lib exempi (if present in compilation time) + * This function must be called before any other function from this module. + * This function must not be called twice without call + * to #metadata_xmp_dispose beteween them. + * @see_also: #metadata_xmp_dispose + * + * Returns: nothing + */ gboolean -metadataparse_xmp_init (void) +metadata_xmp_init (void) { return xmp_init (); } +/* + * metadata_xmp_dispose: + * + * Call this function to free any resource allocated by #metadata_xmp_init + * @see_also: #metadata_xmp_init + * + * Returns: nothing + */ + void -metadataparse_xmp_dispose (void) +metadata_xmp_dispose (void) { xmp_terminate (); } +/* + * metadataparse_xmp_tag_list_add: + * @taglist: tag list in which extracted tags will be added + * @mode: tag list merge mode + * @adapter: contains the XMP metadata chunk + * @mapping: if is to extract individual tags and/or the whole chunk. + * + * This function gets a XMP chunk (@adapter) and extract tags from it + * and then to add to @taglist. + * Note: The XMP chunk (@adapetr) must NOT be wrapped by any bytes specific + * to any file format + * @see_also: #metadataparse_xmp_iter + * + * Returns: nothing + */ + void metadataparse_xmp_tag_list_add (GstTagList * taglist, GstTagMergeMode mode, GstAdapter * adapter, MetadataTagMapping mapping) @@ -172,8 +278,9 @@ metadataparse_xmp_tag_list_add (GstTagList * taglist, GstTagMergeMode mode, } /* add chunk tag */ - if (mapping & METADATA_TAG_MAP_WHOLECHUNK) + 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; @@ -196,32 +303,96 @@ done: } -static const SchemaTagMap * -metadataparse_get_tagsmap_from_gsttag (const SchemaMap * schema_map, - const gchar * tag) +/* + * metadatamux_xmp_create_chunk_from_tag_list: + * @buf: buffer that will have the created XMP chunk + * @size: size of the buffer that will be created + * @taglist: list of tags to be added to XMP chunk + * + * Get tags from @taglist, create a XMP chunk based on it and save to @buf. + * Note: The XMP chunk is NOT wrapped by any bytes specific to any file format + * + * Returns: nothing + */ + +void +metadatamux_xmp_create_chunk_from_tag_list (guint8 ** buf, guint32 * size, + const GstTagList * taglist) { - SchemaTagMap *tags_map = NULL; - int i; + GstBuffer *xmp_chunk = NULL; + const GValue *val = NULL; + XmpPtr xmp = NULL; + XmpStringPtr xmp_str_buf = xmp_string_new (); - if (NULL == schema_map) + if (!(buf && size)) goto done; + if (*buf) { + g_free (*buf); + *buf = NULL; + } + *size = 0; + val = gst_tag_list_get_value_index (taglist, GST_TAG_XMP, 0); + if (val) { + xmp_chunk = gst_value_get_buffer (val); + if (xmp_chunk) + xmp = xmp_new (GST_BUFFER_DATA (xmp_chunk), GST_BUFFER_SIZE (xmp_chunk)); + } - for (i = 0; schema_map->tags_map[i].gst_tag; i++) { - if (0 == strcmp (schema_map->tags_map[i].gst_tag, tag)) { - tags_map = (SchemaTagMap *) & schema_map->tags_map[i]; - break; - } + if (NULL == xmp) + xmp = xmp_new_empty (); + + gst_tag_list_foreach (taglist, metadatamux_xmp_for_each_tag_in_list, xmp); + + if (!xmp_serialize (xmp, xmp_str_buf, 0, 2)) { + GST_ERROR ("failed to serialize xmp into chunk\n"); + } else if (xmp_str_buf) { + unsigned int len = strlen (xmp_string_cstr (xmp_str_buf)); + + *size = len + 1; + *buf = malloc (*size); + memcpy (*buf, xmp_string_cstr (xmp_str_buf), *size); + } else { + GST_ERROR ("failed to serialize xmp into chunk\n"); } done: - return tags_map; + if (xmp_str_buf) + xmp_string_free (xmp_str_buf); + + if (xmp) + xmp_free (xmp); + return; } +/* + * static helper functions implementation + */ + +/* + * metadataparse_xmp_get_tagsmap_from_path: + * @schema_map: Structure containg a map beteween GST tags and tags into a XMP + * schema + * @path: string describing a XMP tag + * @opt: indicates if the string (@path) has extras caracters like '[' and ']' + * + * This returns a structure that contains the GStreamer tag mapped to an XMP + * tag. + * + * Returns: + * <itemizedlist> + * <listitem><para>Structure containing the GST tag mapped + * to the XMP tag (@path) + * </para></listitem> + * <listitem><para>%NULL if there is no mapped GST tag for XMP tag (@path) + * </para></listitem> + * </itemizedlist> + */ + static const SchemaTagMap * -metadataparse_get_tagsmap_from_path (const SchemaMap * schema_map, +metadataparse_xmp_get_tagsmap_from_path (const SchemaMap * schema_map, const gchar * path, uint32_t opt) { @@ -238,7 +409,7 @@ metadataparse_get_tagsmap_from_path (const SchemaMap * schema_map, string = g_string_new (path); - /* remove the language qualifier */ + /* remove the language qualifier "[xxx]" */ ch = string->str + string->len - 3; while (ch != string->str + schema_map->prefix_len) { if (*ch == '[') { @@ -266,75 +437,154 @@ done: } -static void -metadataparse_xmp_iter_add_to_tag_list (GstTagList * taglist, - GstTagMergeMode mode, const char *path, const char *value, - const SchemaMap * schema_map, const uint32_t opt) -{ - - const SchemaTagMap *smaptag = - metadataparse_get_tagsmap_from_path (schema_map, path, opt); +/* + * metadatamux_xmp_get_tagsmap_from_gsttag: + * @schema_map: Structure containg a map beteween GST tags and tags into a XMP + * schema + * @tag: GStreaner tag to look for + * + * This returns a structure that contains the XMP tag mapped to a GStreamer + * tag. + * + * Returns: + * <itemizedlist> + * <listitem><para>Structure containing the XMP tag mapped + * to the GST tag (@path) + * </para></listitem> + * <listitem><para>%NULL if there is no mapped XMP tag for GST @tag + * </para></listitem> + * </itemizedlist> + */ - if (NULL == smaptag) - goto done; +static const SchemaTagMap * +metadatamux_xmp_get_tagsmap_from_gsttag (const SchemaMap * schema_map, + const gchar * tag) +{ + SchemaTagMap *tags_map = NULL; + int i; - if (NULL == smaptag->gst_tag) + if (NULL == schema_map) goto done; - GType type = gst_tag_get_type (smaptag->gst_tag); - switch (type) { - case G_TYPE_STRING: - gst_tag_list_add (taglist, mode, smaptag->gst_tag, value, NULL); - break; - default: + for (i = 0; schema_map->tags_map[i].gst_tag; i++) { + if (0 == strcmp (schema_map->tags_map[i].gst_tag, tag)) { + tags_map = (SchemaTagMap *) & schema_map->tags_map[i]; break; + } } done: - return; + return tags_map; } +/* + * metadataparse_xmp_iter: + * @taglist: tag list in which extracted tags will be added + * @mode: tag list merge mode + * @xmp: handle to XMP data from lib exempi + * + * This function looks all the shemas in a XMP data (@xmp) and then calls + * #metadataparse_xmp_iter_node_schema for each schema. In the end, the idea is + * to add all XMP mapped tags to @taglist by unsing a specified merge @mode + * @see_also: #metadataparse_xmp_tag_list_add + * #metadataparse_xmp_iter_node_schema + * + * Returns: nothing + */ + void -metadataparse_xmp_iter_simple_qual (GstTagList * taglist, GstTagMergeMode mode, - const char *schema, const char *path, const char *value, - const SchemaMap * schema_map) +metadataparse_xmp_iter (GstTagList * taglist, GstTagMergeMode mode, XmpPtr xmp) { - GString *string = g_string_new (path); - gchar *ch; + XmpStringPtr xstr_schema = xmp_string_new (); + XmpStringPtr xstr_path = xmp_string_new (); + XmpStringPtr xstr_prop = xmp_string_new (); + uint32_t opt = 0; + XmpIteratorPtr xmp_iter = NULL; - /* remove the language qualifier */ - ch = string->str + string->len - 3; - while (ch != string->str + schema_map->prefix_len) { - if (*ch == '[') { - *ch = '\0'; + xmp_iter = xmp_iterator_new (xmp, NULL, NULL, XMP_ITER_JUSTCHILDREN); + + if (NULL == xmp_iter) + goto done; + + while (xmp_iterator_next (xmp_iter, xstr_schema, xstr_path, xstr_prop, &opt)) { + const char *schema = xmp_string_cstr (xstr_schema); + const char *path = xmp_string_cstr (xstr_path); + + if (XMP_IS_NODE_SCHEMA (opt)) { + GST_LOG ("%s", schema); + metadataparse_xmp_iter_node_schema (taglist, mode, xmp, schema, path); + } else { + GST_LOG ("Unexpected iteraction"); } - --ch; } - GST_LOG (" %s = %s", string->str, value); +done: - metadataparse_xmp_iter_add_to_tag_list (taglist, mode, path, value, - schema_map, XMP_PROP_HAS_QUALIFIERS); + if (xmp_iter) + xmp_iterator_free (xmp_iter); - g_string_free (string, TRUE); + if (xstr_prop) + xmp_string_free (xstr_prop); + + if (xstr_path) + xmp_string_free (xstr_path); + + if (xstr_schema) + xmp_string_free (xstr_schema); } +/* + * metadataparse_xmp_iter_node_schema: + * @taglist: tag list in which extracted tags will be added + * @mode: tag list merge mode + * @xmp: handle to XMP data from lib exempi + * @schema: schema name string + * @path: schema path + * + * This function gets a @schema, finds the #SchemaMap (structure + * containing @schema description and map with GST tags) to it. And then call + * #metadataparse_xmp_iter_array. In the end, the idea is + * to add all XMP Schema mapped tags to @taglist by unsing a specified + * merge @mode + * @see_also: #metadataparse_xmp_iter + * #metadataparse_xmp_iter_array + * + * Returns: nothing + */ void -metadataparse_xmp_iter_simple (GstTagList * taglist, GstTagMergeMode mode, - const char *schema, const char *path, const char *value, - const SchemaMap * schema_map) +metadataparse_xmp_iter_node_schema (GstTagList * taglist, GstTagMergeMode mode, + XmpPtr xmp, const char *schema, const char *path) { - GST_LOG (" %s = %s", path, value); + SchemaMap *schema_map = NULL; - metadataparse_xmp_iter_add_to_tag_list (taglist, mode, path, value, - schema_map, 0); + if (0 == strcmp (schema, "http://purl.org/dc/elements/1.1/")) { + schema_map = (SchemaMap *) & schema_map_dublin; + } + metadataparse_xmp_iter_array (taglist, mode, xmp, schema, path, schema_map); } +/* + * metadataparse_xmp_iter_array: + * @taglist: tag list in which extracted tags will be added + * @mode: tag list merge mode + * @xmp: handle to XMP data from lib exempi + * @schema: schema name string + * @path: schema path + * @schema_map: structure containing @schema description and map with GST tags + * + * This function looks all the tags into a @schema and call other functions in + * order to add the mapped ones to @taglist by using a specified merge @mode + * @see_also: #metadataparse_xmp_iter_node_schema + * #metadataparse_xmp_iter_simple_qual metadataparse_xmp_iter_simple + * + * Returns: nothing + */ + void metadataparse_xmp_iter_array (GstTagList * taglist, GstTagMergeMode mode, XmpPtr xmp, const char *schema, const char *path, @@ -362,10 +612,10 @@ metadataparse_xmp_iter_array (GstTagList * taglist, GstTagMergeMode mode, if (strcmp (path, "") != 0) { if (XMP_HAS_PROP_QUALIFIERS (opt)) { /* ignore language qualifier, just get the first */ - metadataparse_xmp_iter_simple_qual (taglist, mode, schema, path, - value, schema_map); + metadataparse_xmp_iter_simple_qual (taglist, mode, path, value, + schema_map); } else { - metadataparse_xmp_iter_simple (taglist, mode, schema, path, value, + metadataparse_xmp_iter_simple (taglist, mode, path, value, schema_map); } } @@ -408,64 +658,141 @@ done: } +/* + * metadataparse_xmp_iter_simple_qual: + * @taglist: tag list in which extracted tags will be added + * @mode: tag list merge mode + * @path: schema path + * @value: value of the (@path) tag + * @schema_map: structure containing @schema description and map with GST tags + * + * This function gets a XMP tag (@path) with quilifiers and try to add it + * to @taglist by calling #metadataparse_xmp_iter_add_to_tag_list + * @see_also: #metadataparse_xmp_iter_array + * #metadataparse_xmp_iter_simple #metadataparse_xmp_iter_add_to_tag_list + * + * Returns: nothing + */ + void -metadataparse_xmp_iter_node_schema (GstTagList * taglist, GstTagMergeMode mode, - XmpPtr xmp, const char *schema, const char *path) +metadataparse_xmp_iter_simple_qual (GstTagList * taglist, GstTagMergeMode mode, + const char *path, const char *value, const SchemaMap * schema_map) { - SchemaMap *schema_map = NULL; + GString *string = g_string_new (path); - if (0 == strcmp (schema, "http://purl.org/dc/elements/1.1/")) { - schema_map = (SchemaMap *) & schema_map_dublin; +#ifndef GST_DISABLE_GST_DEBUG + gchar *ch; + + /* remove the language qualifier */ + ch = string->str + string->len - 3; + while (ch != string->str + schema_map->prefix_len) { + if (*ch == '[') { + *ch = '\0'; + } + --ch; } + GST_LOG (" %s = %s", string->str, value); +#endif /* #ifndef GST_DISABLE_GST_DEBUG */ - metadataparse_xmp_iter_array (taglist, mode, xmp, schema, path, schema_map); + metadataparse_xmp_iter_add_to_tag_list (taglist, mode, path, value, + schema_map, XMP_PROP_HAS_QUALIFIERS); + + g_string_free (string, TRUE); } +/* + * metadataparse_xmp_iter_simple: + * @taglist: tag list in which extracted tags will be added + * @mode: tag list merge mode + * @path: schema path + * @value: value of the (@path) tag + * @schema_map: structure containing @schema description and map with GST tags + * + * This function gets a simple XMP tag (@path) and try to add it to @taglist by + * calling # metadataparse_xmp_iter_add_to_tag_list + * @see_also: #metadataparse_xmp_iter_array + * #metadataparse_xmp_iter_simple_qual #metadataparse_xmp_iter_add_to_tag_list + * + * Returns: nothing + */ + void -metadataparse_xmp_iter (GstTagList * taglist, GstTagMergeMode mode, XmpPtr xmp) +metadataparse_xmp_iter_simple (GstTagList * taglist, GstTagMergeMode mode, + const char *path, const char *value, const SchemaMap * schema_map) { - XmpStringPtr xstr_schema = xmp_string_new (); - XmpStringPtr xstr_path = xmp_string_new (); - XmpStringPtr xstr_prop = xmp_string_new (); - uint32_t opt = 0; - XmpIteratorPtr xmp_iter = NULL; + GST_LOG (" %s = %s", path, value); - xmp_iter = xmp_iterator_new (xmp, NULL, NULL, XMP_ITER_JUSTCHILDREN); + metadataparse_xmp_iter_add_to_tag_list (taglist, mode, path, value, + schema_map, 0); - if (NULL == xmp_iter) +} + +/* + * metadataparse_xmp_iter_add_to_tag_list: + * @taglist: tag list in which extracted tags will be added + * @mode: tag list merge mode + * @path: schema path + * @value: value of the (@path) tag + * @schema_map: structure containing @schema description and map with GST tags + * @opt: indicates if the string (@path) has extras caracters like '[' and ']' + * + * This function gets a XMP tag (@path) and see if it is mapped to a GST tag by + * calling #metadataparse_xmp_get_tagsmap_from_path, if so, add it to @taglist + * by using a specified merge @mode + * @see_also: #metadataparse_xmp_iter_simple_qual + * #metadataparse_xmp_iter_simple #metadataparse_xmp_get_tagsmap_from_path + * + * Returns: nothing + */ + +static void +metadataparse_xmp_iter_add_to_tag_list (GstTagList * taglist, + GstTagMergeMode mode, const char *path, const char *value, + const SchemaMap * schema_map, const uint32_t opt) +{ + + const SchemaTagMap *smaptag = + metadataparse_xmp_get_tagsmap_from_path (schema_map, path, opt); + + if (NULL == smaptag) goto done; - while (xmp_iterator_next (xmp_iter, xstr_schema, xstr_path, xstr_prop, &opt)) { - const char *schema = xmp_string_cstr (xstr_schema); - const char *path = xmp_string_cstr (xstr_path); + if (NULL == smaptag->gst_tag) + goto done; - if (XMP_IS_NODE_SCHEMA (opt)) { - GST_LOG ("%s", schema); - metadataparse_xmp_iter_node_schema (taglist, mode, xmp, schema, path); - } else { - GST_LOG ("Unexpected iteraction"); - } + GType type = gst_tag_get_type (smaptag->gst_tag); + + switch (type) { + case G_TYPE_STRING: + gst_tag_list_add (taglist, mode, smaptag->gst_tag, value, NULL); + break; + default: + break; } done: - if (xmp_iter) - xmp_iterator_free (xmp_iter); - - if (xstr_prop) - xmp_string_free (xstr_prop); - - if (xstr_path) - xmp_string_free (xstr_path); + return; - if (xstr_schema) - xmp_string_free (xstr_schema); } +/* + * metadatamux_xmp_for_each_tag_in_list: + * @list: GStreamer tag list from which @tag belongs to + * @tag: GStreamer tag to be added to the XMP chunk + * @user_data: pointer to #XmpPtr in which the tag will be added + * + * This function designed to be called for each tag in GST tag list. This + * function adds get the tag value from tag @list and then add it to the XMP + * chunk by using #XmpPtr and related functions from lib exempi + * @see_also: #metadatamux_xmp_create_chunk_from_tag_list + * + * Returns: nothing + */ static void -metadataxmp_for_each_tag_in_list (const GstTagList * list, const gchar * tag, - gpointer user_data) +metadatamux_xmp_for_each_tag_in_list (const GstTagList * list, + const gchar * tag, gpointer user_data) { XmpPtr xmp = (XmpPtr) user_data; int i; @@ -474,7 +801,7 @@ metadataxmp_for_each_tag_in_list (const GstTagList * list, const gchar * tag, const SchemaMap *smap = schemas_map[i]; const SchemaTagMap *stagmap = - metadataparse_get_tagsmap_from_gsttag (smap, tag); + metadatamux_xmp_get_tagsmap_from_gsttag (smap, tag); if (stagmap) { @@ -501,56 +828,4 @@ metadataxmp_for_each_tag_in_list (const GstTagList * list, const gchar * tag, } -void -metadatamux_xmp_create_chunk_from_tag_list (guint8 ** buf, guint32 * size, - const GstTagList * taglist) -{ - GstBuffer *xmp_chunk = NULL; - const GValue *val = NULL; - XmpPtr xmp = NULL; - XmpStringPtr xmp_str_buf = xmp_string_new (); - - if (!(buf && size)) - goto done; - if (*buf) { - g_free (*buf); - *buf = NULL; - } - *size = 0; - - val = gst_tag_list_get_value_index (taglist, GST_TAG_XMP, 0); - if (val) { - xmp_chunk = gst_value_get_buffer (val); - if (xmp_chunk) - xmp = xmp_new (GST_BUFFER_DATA (xmp_chunk), GST_BUFFER_SIZE (xmp_chunk)); - } - - if (NULL == xmp) - xmp = xmp_new_empty (); - - gst_tag_list_foreach (taglist, metadataxmp_for_each_tag_in_list, xmp); - - if (!xmp_serialize (xmp, xmp_str_buf, 0, 2)) { - GST_ERROR ("failed to serialize xmp into chunk\n"); - } else if (xmp_str_buf) { - unsigned int len = strlen (xmp_string_cstr (xmp_str_buf)); - - *size = len + 1; - *buf = malloc (*size); - memcpy (*buf, xmp_string_cstr (xmp_str_buf), *size); - } else { - GST_ERROR ("failed to serialize xmp into chunk\n"); - } - -done: - - if (xmp_str_buf) - xmp_string_free (xmp_str_buf); - - if (xmp) - xmp_free (xmp); - - return; -} - #endif /* else (ifndef HAVE_XMP) */ |