element: Enforce that elements created by gst_element_factory_create/make() are floating
[platform/upstream/gstreamer.git] / gst / gstmeta.c
index 954ff59..4bcaa7a 100644 (file)
@@ -21,6 +21,7 @@
 
 /**
  * SECTION:gstmeta
+ * @title: GstMeta
  * @short_description: Buffer metadata
  *
  * The #GstMeta structure should be included as the first member of a #GstBuffer
@@ -69,7 +70,7 @@ _priv_gst_meta_initialize (void)
 /**
  * gst_meta_api_type_register:
  * @api: an API to register
- * @tags: tags for @api
+ * @tags: (array zero-terminated=1): tags for @api
  *
  * Register and return a GType for the @api and associate it with
  * @tags.
@@ -157,7 +158,8 @@ gst_meta_api_type_get_tags (GType api)
  * The same @info can be retrieved later with gst_meta_get_info() by using
  * @impl as the key.
  *
- * Returns: (transfer none): a #GstMetaInfo that can be used to access metadata.
+ * Returns: (transfer none) (nullable): a #GstMetaInfo that can be used to
+ * access metadata.
  */
 
 const GstMetaInfo *
@@ -172,6 +174,10 @@ gst_meta_register (GType api, const gchar * impl, gsize size,
   g_return_val_if_fail (impl != NULL, NULL);
   g_return_val_if_fail (size != 0, NULL);
 
+  if (init_func == NULL)
+    g_critical ("Registering meta implementation '%s' without init function",
+        impl);
+
   /* first try to register the implementation name. It's possible
    * that this fails because it was already registered. Don't warn,
    * glib did this for us already. */
@@ -205,8 +211,8 @@ gst_meta_register (GType api, const gchar * impl, gsize size,
  * Lookup a previously registered meta info structure by its implementation name
  * @impl.
  *
- * Returns: (transfer none): a #GstMetaInfo with @impl, or #NULL when no such
- * metainfo exists.
+ * Returns: (transfer none) (nullable): a #GstMetaInfo with @impl, or
+ * %NULL when no such metainfo exists.
  */
 const GstMetaInfo *
 gst_meta_get_info (const gchar * impl)
@@ -221,3 +227,51 @@ gst_meta_get_info (const gchar * impl)
 
   return info;
 }
+
+/**
+ * gst_meta_get_seqnum:
+ * @meta: a #GstMeta
+ *
+ * Gets seqnum for this meta.
+ *
+ * Since: 1.16
+ */
+guint64
+gst_meta_get_seqnum (const GstMeta * meta)
+{
+  GstMetaItem *meta_item;
+  guint8 *p;
+
+  g_return_val_if_fail (meta != NULL, 0);
+
+  p = (guint8 *) meta;
+  p -= G_STRUCT_OFFSET (GstMetaItem, meta);
+  meta_item = (GstMetaItem *) p;
+  return meta_item->seq_num;
+}
+
+/**
+ * gst_meta_compare_seqnum:
+ * @meta1: a #GstMeta
+ * @meta2: a #GstMeta
+ *
+ * Meta sequence number compare function. Can be used as #GCompareFunc
+ * or a #GCompareDataFunc.
+ *
+ * Returns: a negative number if @meta1 comes before @meta2, 0 if both metas
+ *   have an equal sequence number, or a positive integer if @meta1 comes
+ *   after @meta2.
+ *
+ * Since: 1.16
+ */
+gint
+gst_meta_compare_seqnum (const GstMeta * meta1, const GstMeta * meta2)
+{
+  guint64 seqnum1 = gst_meta_get_seqnum (meta1);
+  guint64 seqnum2 = gst_meta_get_seqnum (meta2);
+
+  if (seqnum1 == seqnum2)
+    return 0;
+
+  return (seqnum1 < seqnum2) ? -1 : 1;
+}