Merge remote-tracking branch 'upstream/master' into tizen
[platform/upstream/gstreamer.git] / libs / gst / base / gstindex.c
index 30087d5..964508e 100644 (file)
  *
  * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
  */
 
 /**
  * SECTION:gstindex
+ * @title: GstIndexEntry
  * @short_description: Generate indexes on objects
  * @see_also: #GstIndexFactory
  *
- * GstIndex is used to generate a stream index of one or more elements
+ * #GstIndex is used to generate a stream index of one or more elements
  * in a pipeline.
  *
  * Elements will overload the set_index and get_index virtual methods in
@@ -38,7 +39,7 @@
  * The application that wants to index the stream will create a new index object
  * using gst_index_new() or gst_index_factory_make(). The index is assigned to a
  * specific element, a bin or the whole pipeline. This will cause indexable
- * elements to add entires to the index while playing.
+ * elements to add entries to the index while playing.
  */
 
 /* FIXME: complete gobject annotations */
@@ -60,6 +61,7 @@
 #endif
 
 #include <gst/gst.h>
+#include "gst/glib-compat-private.h"
 
 /* Index signals and args */
 enum
@@ -131,18 +133,9 @@ gst_index_resolver_get_type (void)
   return index_resolver_type;
 }
 
-GType
-gst_index_entry_get_type (void)
-{
-  static GType index_entry_type = 0;
-
-  if (!index_entry_type) {
-    index_entry_type = g_boxed_type_register_static ("GstIndexEntry",
-        (GBoxedCopyFunc) gst_index_entry_copy,
-        (GBoxedFreeFunc) gst_index_entry_free);
-  }
-  return index_entry_type;
-}
+G_DEFINE_BOXED_TYPE (GstIndexEntry, gst_index_entry,
+    (GBoxedCopyFunc) gst_index_entry_copy,
+    (GBoxedFreeFunc) gst_index_entry_free);
 
 #if 0
 #define _do_init \
@@ -169,7 +162,7 @@ gst_index_class_init (GstIndexClass * klass)
   gst_index_signals[ENTRY_ADDED] =
       g_signal_new ("entry-added", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
       G_STRUCT_OFFSET (GstIndexClass, entry_added), NULL, NULL,
-      gst_marshal_VOID__BOXED, G_TYPE_NONE, 1, GST_TYPE_INDEX_ENTRY);
+      NULL, G_TYPE_NONE, 1, GST_TYPE_INDEX_ENTRY);
 
   gobject_class->set_property = gst_index_set_property;
   gobject_class->get_property = gst_index_get_property;
@@ -297,6 +290,8 @@ gst_index_group_free (GstIndexGroup * group)
   g_slice_free (GstIndexGroup, group);
 }
 
+/* do not resurrect this, add a derived dummy index class instead */
+#if 0
 /**
  * gst_index_new:
  *
@@ -311,7 +306,7 @@ gst_index_new (void)
 {
   GstIndex *index;
 
-  index = g_object_newv (gst_index_get_type (), 0, NULL);
+  index = g_object_new (gst_index_get_type (), NULL);
 
   return index;
 }
@@ -319,7 +314,7 @@ gst_index_new (void)
 /**
  * gst_index_commit:
  * @index: the index to commit
- * @id: the writer that commited the index
+ * @id: the writer that committed the index
  *
  * Tell the index that the writer with the given id is done
  * with this index and is not going to write any more entries
@@ -336,7 +331,6 @@ gst_index_commit (GstIndex * index, gint id)
     iclass->commit (index, id);
 }
 
-
 /**
  * gst_index_get_group:
  * @index: the index to get the current group from
@@ -376,7 +370,7 @@ gst_index_new_group (GstIndex * index)
  *
  * Set the current groupnumber to the given argument.
  *
- * Returns: TRUE if the operation succeeded, FALSE if the group
+ * Returns: %TRUE if the operation succeeded, %FALSE if the group
  * did not exist.
  */
 gboolean
@@ -405,7 +399,9 @@ gst_index_set_group (GstIndex * index, gint groupnum)
   GST_DEBUG ("couldn't find index group %d", groupnum);
   return FALSE;
 }
+#endif
 
+#if 0
 /**
  * gst_index_set_certainty:
  * @index: the index to set the certainty on
@@ -432,7 +428,9 @@ gst_index_get_certainty (GstIndex * index)
 {
   return index->curgroup->certainty;
 }
+#endif
 
+#if 0
 /**
  * gst_index_set_filter:
  * @index: the index to register the filter on
@@ -500,8 +498,6 @@ gst_index_set_resolver (GstIndex * index,
  *
  * Lets the app register a custom function to map index
  * ids to writer descriptions.
- *
- * Since: 0.10.18
  */
 void
 gst_index_set_resolver_full (GstIndex * index, GstIndexResolver resolver,
@@ -517,6 +513,7 @@ gst_index_set_resolver_full (GstIndex * index, GstIndexResolver resolver,
   index->resolver_user_data_destroy = user_data_destroy;
   index->method = GST_INDEX_RESOLVER_CUSTOM;
 }
+#endif
 
 /**
  * gst_index_entry_copy:
@@ -568,6 +565,7 @@ gst_index_entry_free (GstIndexEntry * entry)
   g_slice_free (GstIndexEntry, entry);
 }
 
+#if 0
 /**
  * gst_index_add_format:
  * @index: the index to add the entry to
@@ -575,7 +573,7 @@ gst_index_entry_free (GstIndexEntry * entry)
  * @format: the format to add to the index
  *
  * Adds a format entry into the index. This function is
- * used to map dynamic GstFormat ids to their original
+ * used to map dynamic #GstFormat ids to their original
  * format key.
  *
  * Free-function: gst_index_entry_free
@@ -606,6 +604,7 @@ gst_index_add_format (GstIndex * index, gint id, GstFormat format)
 
   return entry;
 }
+#endif
 
 /**
  * gst_index_add_id:
@@ -679,7 +678,7 @@ gst_index_gtype_resolver (GstIndex * index, GstObject * writer,
 /**
  * gst_index_get_writer_id:
  * @index: the index to get a unique write id for
- * @writer: the GstObject to allocate an id for
+ * @writer: the #GstObject to allocate an id for
  * @id: a pointer to a gint to hold the id
  *
  * Before entries can be added to the index, a writer
@@ -690,13 +689,11 @@ gst_index_gtype_resolver (GstIndex * index, GstObject * writer,
  * to a string. That string will be used to register or look up an id
  * in the index.
  *
- * <note>
- * The caller must not hold @writer's #GST_OBJECT_LOCK, as the default
- * resolver may call functions that take the object lock as well, and
- * the lock is not recursive.
- * </note>
+ * > The caller must not hold @writer's GST_OBJECT_LOCK(), as the default
+ * > resolver may call functions that take the object lock as well, and
+ * > the lock is not recursive.
  *
- * Returns: TRUE if the writer would be mapped to an id.
+ * Returns: %TRUE if the writer would be mapped to an id.
  */
 gboolean
 gst_index_get_writer_id (GstIndex * index, GstObject * writer, gint * id)
@@ -776,17 +773,17 @@ gst_index_add_entry (GstIndex * index, GstIndexEntry * entry)
  * gst_index_add_associationv:
  * @index: the index to add the entry to
  * @id: the id of the index writer
- * @flags: optinal flags for this entry
+ * @flags: optional flags for this entry
  * @n: number of associations
- * @list: list of associations
+ * @list: (array length=n): list of associations
  *
  * Associate given format/value pairs with each other.
  *
  * Returns: a pointer to the newly added entry in the index.
  */
 GstIndexEntry *
-gst_index_add_associationv (GstIndex * index, gint id, GstAssocFlags flags,
-    gint n, const GstIndexAssociation * list)
+gst_index_add_associationv (GstIndex * index, gint id,
+    GstIndexAssociationFlags flags, gint n, const GstIndexAssociation * list)
 {
   GstIndexEntry *entry;
 
@@ -802,7 +799,7 @@ gst_index_add_associationv (GstIndex * index, gint id, GstAssocFlags flags,
   entry->type = GST_INDEX_ENTRY_ASSOCIATION;
   entry->id = id;
   entry->data.assoc.flags = flags;
-  entry->data.assoc.assocs = g_memdup (list, sizeof (GstIndexAssociation) * n);
+  entry->data.assoc.assocs = g_memdup2 (list, sizeof (GstIndexAssociation) * n);
   entry->data.assoc.nassocs = n;
 
   gst_index_add_entry (index, entry);
@@ -810,11 +807,12 @@ gst_index_add_associationv (GstIndex * index, gint id, GstAssocFlags flags,
   return entry;
 }
 
+#if 0
 /**
  * gst_index_add_association:
  * @index: the index to add the entry to
  * @id: the id of the index writer
- * @flags: optinal flags for this entry
+ * @flags: optional flags for this entry
  * @format: the format of the value
  * @value: the value
  * @...: other format/value pairs or 0 to end the list
@@ -826,8 +824,8 @@ gst_index_add_associationv (GstIndex * index, gint id, GstAssocFlags flags,
  * Returns: a pointer to the newly added entry in the index.
  */
 GstIndexEntry *
-gst_index_add_association (GstIndex * index, gint id, GstAssocFlags flags,
-    GstFormat format, gint64 value, ...)
+gst_index_add_association (GstIndex * index, gint id,
+    GstIndexAssociationFlags flags, GstFormat format, gint64 value, ...)
 {
   va_list args;
   GstIndexEntry *entry;
@@ -897,6 +895,7 @@ gst_index_add_object (GstIndex * index, gint id, gchar * key,
 
   return NULL;
 }
+#endif
 
 static gint
 gst_index_compare_func (gconstpointer a, gconstpointer b, gpointer user_data)
@@ -919,12 +918,12 @@ gst_index_compare_func (gconstpointer a, gconstpointer b, gpointer user_data)
  *
  * Finds the given format/value in the index
  *
- * Returns: the entry associated with the value or NULL if the
+ * Returns: (nullable): the entry associated with the value or %NULL if the
  *   value was not found.
  */
 GstIndexEntry *
 gst_index_get_assoc_entry (GstIndex * index, gint id,
-    GstIndexLookupMethod method, GstAssocFlags flags,
+    GstIndexLookupMethod method, GstIndexAssociationFlags flags,
     GstFormat format, gint64 value)
 {
   g_return_val_if_fail (GST_IS_INDEX (index), NULL);
@@ -950,12 +949,12 @@ gst_index_get_assoc_entry (GstIndex * index, gint id,
  * Finds the given format/value in the index with the given
  * compare function and user_data.
  *
- * Returns: the entry associated with the value or NULL if the
+ * Returns: (nullable): the entry associated with the value or %NULL if the
  *   value was not found.
  */
 GstIndexEntry *
 gst_index_get_assoc_entry_full (GstIndex * index, gint id,
-    GstIndexLookupMethod method, GstAssocFlags flags,
+    GstIndexLookupMethod method, GstIndexAssociationFlags flags,
     GstFormat format, gint64 value, GCompareDataFunc func, gpointer user_data)
 {
   GstIndexClass *iclass;
@@ -982,7 +981,7 @@ gst_index_get_assoc_entry_full (GstIndex * index, gint id,
  *
  * Gets alternative formats associated with the indexentry.
  *
- * Returns: TRUE if there was a value associated with the given
+ * Returns: %TRUE if there was a value associated with the given
  * format.
  */
 gboolean