#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
+#include "tag.h"
#include <gst/gsttagsetter.h>
#include "gsttageditingprivate.h"
#include <stdio.h>
#include <time.h>
#include <ctype.h>
+static const gchar *schema_list[] = {
+ "dc",
+ "xap",
+ "tiff",
+ "exif",
+ "photoshop",
+ "Iptc4xmpCore",
+ NULL
+};
+
+/**
+ * gst_tag_xmp_list_schemas:
+ *
+ * Gets the list of supported schemas in the xmp lib
+ *
+ * Returns: a %NULL terminated array of strings with the schema names
+ *
+ * Since: 0.10.33
+ */
+const gchar **
+gst_tag_xmp_list_schemas (void)
+{
+ return schema_list;
+}
+
+typedef struct _XmpSerializationData XmpSerializationData;
typedef struct _XmpTag XmpTag;
/*
const gchar * gst_tag, const gchar * xmp_tag_value,
const gchar * str, GSList ** pending_tags);
+struct _XmpSerializationData
+{
+ GString *data;
+ GList *schemas;
+};
+
+static gboolean
+xmp_serialization_data_use_schema (XmpSerializationData * serdata,
+ const gchar * schemaname)
+{
+ GList *iter;
+ if (serdata->schemas == NULL)
+ return TRUE;
+
+ for (iter = serdata->schemas; iter; iter = g_list_next (iter)) {
+ const gchar *name = (const gchar *) iter->data;
+
+ if (strcmp (name, schemaname) == 0)
+ return TRUE;
+ }
+ return FALSE;
+}
+
#define GST_XMP_TAG_TYPE_SIMPLE 0
#define GST_XMP_TAG_TYPE_BAG 1
* have our lists modified during usage
*/
static GPtrArray *
-_xmp_tag_get_mapping (const gchar * gst_tag)
+_xmp_tag_get_mapping (const gchar * gst_tag, XmpSerializationData * serdata)
{
GPtrArray *ret = NULL;
GHashTableIter iter;
GQuark key = g_quark_from_string (gst_tag);
gpointer iterkey, value;
+ const gchar *schemaname;
g_hash_table_iter_init (&iter, __xmp_schemas);
while (!ret && g_hash_table_iter_next (&iter, &iterkey, &value)) {
GstXmpSchema *schema = (GstXmpSchema *) value;
- ret = (GPtrArray *) gst_xmp_schema_lookup (schema, GUINT_TO_POINTER (key));
+ schemaname = g_quark_to_string (GPOINTER_TO_UINT (iterkey));
+ if (xmp_serialization_data_use_schema (serdata, schemaname))
+ ret =
+ (GPtrArray *) gst_xmp_schema_lookup (schema, GUINT_TO_POINTER (key));
}
return ret;
}
schema = gst_xmp_schema_new ();
_gst_xmp_schema_add_simple_mapping (schema, GST_TAG_USER_RATING,
"xmp:Rating", GST_XMP_TAG_TYPE_SIMPLE, NULL, deserialize_xmp_rating);
- _gst_xmp_add_schema ("xmp", schema);
+ _gst_xmp_add_schema ("xap", schema);
/* tiff */
schema = gst_xmp_schema_new ();
write_one_tag (const GstTagList * list, const gchar * tag, gpointer user_data)
{
guint i = 0, ct = gst_tag_list_get_tag_size (list, tag), tag_index;
- GString *data = user_data;
+ XmpSerializationData *serialization_data = user_data;
+ GString *data = serialization_data->data;
GPtrArray *xmp_tag_array = NULL;
char *s;
/* map gst-tag to xmp tag */
- xmp_tag_array = _xmp_tag_get_mapping (tag);
+ xmp_tag_array = _xmp_tag_get_mapping (tag, serialization_data);
if (!xmp_tag_array) {
GST_WARNING ("no mapping for %s to xmp", tag);
}
/**
- * gst_tag_list_to_xmp_buffer:
+ * gst_tag_list_to_xmp_buffer_full:
* @list: tags
* @read_only: does the container forbid inplace editing
+ * @schemas: list of schemas to be used on serialization
*
- * Formats a taglist as a xmp packet.
+ * Formats a taglist as a xmp packet using only the selected
+ * schemas. An empty list (%NULL) means that all schemas should
+ * be used
*
* Returns: new buffer or %NULL, unref the buffer when done
*
- * Since: 0.10.29
+ * Since: 0.10.33
*/
GstBuffer *
-gst_tag_list_to_xmp_buffer (const GstTagList * list, gboolean read_only)
+gst_tag_list_to_xmp_buffer_full (const GstTagList * list, gboolean read_only,
+ GList * schemas)
{
GstBuffer *buffer = NULL;
- GString *data = g_string_sized_new (4096);
+ XmpSerializationData serialization_data;
+ GString *data;
guint i;
+ serialization_data.data = g_string_sized_new (4096);
+ serialization_data.schemas = schemas;
+ data = serialization_data.data;
+
xmp_tags_initialize ();
g_return_val_if_fail (GST_IS_TAG_LIST (list), NULL);
"<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"");
i = 0;
while (ns_match[i].ns_prefix) {
- g_string_append_printf (data, " xmlns:%s=\"%s\"", ns_match[i].ns_prefix,
- ns_match[i].ns_uri);
+ if (xmp_serialization_data_use_schema (&serialization_data,
+ ns_match[i].ns_prefix))
+ g_string_append_printf (data, " xmlns:%s=\"%s\"",
+ ns_match[i].ns_prefix, ns_match[i].ns_uri);
i++;
}
g_string_append (data, ">\n");
g_string_append (data, "<rdf:Description rdf:about=\"\">\n");
/* iterate the taglist */
- gst_tag_list_foreach (list, write_one_tag, data);
+ gst_tag_list_foreach (list, write_one_tag, &serialization_data);
/* xmp footer */
g_string_append (data, "</rdf:Description>\n");
return buffer;
}
+/**
+ * gst_tag_list_to_xmp_buffer:
+ * @list: tags
+ * @read_only: does the container forbid inplace editing
+ *
+ * Formats a taglist as a xmp packet.
+ *
+ * Returns: new buffer or %NULL, unref the buffer when done
+ *
+ * Since: 0.10.29
+ */
+GstBuffer *
+gst_tag_list_to_xmp_buffer (const GstTagList * list, gboolean read_only)
+{
+ return gst_tag_list_to_xmp_buffer_full (list, read_only, NULL);
+}
+
#undef gst_xmp_schema_lookup
#undef gst_xmp_schema_insert