meta: transform docs
[platform/upstream/gstreamer.git] / gst / gstmeta.c
index 5258855..8a0978a 100644 (file)
 static GHashTable *metainfo = NULL;
 static GRWLock lock;
 
+GQuark _gst_meta_transform_copy;
+GQuark _gst_meta_tag_memory;
+
 void
 _priv_gst_meta_initialize (void)
 {
   g_rw_lock_init (&lock);
   metainfo = g_hash_table_new (g_str_hash, g_str_equal);
+
+  _gst_meta_transform_copy = g_quark_from_static_string ("gst-copy");
+  _gst_meta_tag_memory = g_quark_from_static_string ("memory");
+}
+
+/**
+ * gst_meta_api_type_register:
+ * @api: an API to register
+ * @tags: tags for @api
+ *
+ * Register and return a GType for the @api and associate it with
+ * @tags.
+ *
+ * Returns: a unique GType for @api.
+ */
+GType
+gst_meta_api_type_register (const gchar * api, const gchar ** tags)
+{
+  GType type;
+
+  g_return_val_if_fail (api != NULL, 0);
+  g_return_val_if_fail (tags != NULL, 0);
+
+  GST_CAT_DEBUG (GST_CAT_META, "register API \"%s\"", api);
+  type = g_pointer_type_register_static (api);
+
+  if (type != 0) {
+    gint i;
+
+    for (i = 0; tags[i]; i++) {
+      GST_CAT_DEBUG (GST_CAT_META, "  adding tag \"%s\"", tags[i]);
+      g_type_set_qdata (type, g_quark_from_string (tags[i]),
+          GINT_TO_POINTER (TRUE));
+    }
+  }
+  return type;
+}
+
+/**
+ * gst_meta_api_type_has_tag:
+ * @api: an API
+ * @tag: the tag to check
+ *
+ * Check if @api was registered with @tag.
+ *
+ * Returns: %TRUE if @api was registered with @tag.
+ */
+gboolean
+gst_meta_api_type_has_tag (GType api, GQuark tag)
+{
+  g_return_val_if_fail (api != 0, FALSE);
+  g_return_val_if_fail (tag != 0, FALSE);
+
+  return g_type_get_qdata (api, tag) != NULL;
 }
 
 /**
  * gst_meta_register:
- * @api: the name of the #GstMeta API
+ * @api: the type of the #GstMeta API
  * @impl: the name of the #GstMeta implementation
  * @size: the size of the #GstMeta structure
  * @init_func: a #GstMetaInitFunction
  * @free_func: a #GstMetaFreeFunction
- * @copy_func: a #GstMetaCopyFunction
  * @transform_func: a #GstMetaTransformFunction
+ * @tags: a NULL terminated array of strings describing what the metadata
+ *        contains info about.
  *
  * Register a new #GstMeta implementation.
  *
@@ -61,27 +119,27 @@ _priv_gst_meta_initialize (void)
  */
 
 const GstMetaInfo *
-gst_meta_register (const gchar * api, const gchar * impl, gsize size,
+gst_meta_register (GType api, const gchar * impl, gsize size,
     GstMetaInitFunction init_func, GstMetaFreeFunction free_func,
-    GstMetaCopyFunction copy_func, GstMetaTransformFunction transform_func)
+    GstMetaTransformFunction transform_func)
 {
   GstMetaInfo *info;
 
-  g_return_val_if_fail (api != NULL, NULL);
+  g_return_val_if_fail (api != 0, NULL);
   g_return_val_if_fail (impl != NULL, NULL);
   g_return_val_if_fail (size != 0, NULL);
 
   info = g_slice_new (GstMetaInfo);
-  info->api = g_quark_from_string (api);
+  info->api = api;
   info->type = g_pointer_type_register_static (impl);
   info->size = size;
   info->init_func = init_func;
   info->free_func = free_func;
-  info->copy_func = copy_func;
   info->transform_func = transform_func;
 
-  GST_DEBUG ("register \"%s\" implementing \"%s\" of size %" G_GSIZE_FORMAT,
-      api, impl, size);
+  GST_CAT_DEBUG (GST_CAT_META,
+      "register \"%s\" implementing \"%s\" of size %" G_GSIZE_FORMAT, impl,
+      g_type_name (api), size);
 
   g_rw_lock_writer_lock (&lock);
   g_hash_table_insert (metainfo, (gpointer) impl, (gpointer) info);