2 * Copyright (C) 2001 RidgeRun (http://www.ridgerun.com/)
3 * Written by Erik Walthinsen <omega@ridgerun.com>
5 * gstindex.c: Index for mappings and other data
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
25 * @title: GstIndexEntry
26 * @short_description: Generate indexes on objects
27 * @see_also: #GstIndexFactory
29 * #GstIndex is used to generate a stream index of one or more elements
32 * Elements will overload the set_index and get_index virtual methods in
33 * #GstElement. When streaming data, the element will add index entries if it
36 * Each element that adds to the index will do that using a writer_id. The
37 * writer_id is obtained from gst_index_get_writer_id().
39 * The application that wants to index the stream will create a new index object
40 * using gst_index_new() or gst_index_factory_make(). The index is assigned to a
41 * specific element, a bin or the whole pipeline. This will cause indexable
42 * elements to add entires to the index while playing.
45 /* FIXME: complete gobject annotations */
46 /* FIXME-0.11: cleanup API
47 * - no one seems to use GstIndexGroup, GstIndexCertainty
49 * - the API for application to use the index is mostly missing
50 * - apps need to get a list of writers
51 * - apps need to be able to iterate over each writers index entry collection
52 * - gst_index_get_assoc_entry() should pass ownership
53 * - the GstIndexEntry structure is large and contains repetitive information
54 * - we want to allow Indexers to implement a saner storage and create
55 * GstIndexEntries on demand (the app has to free them), might even make
56 * sense to ask the app to provide a ptr and fill it.
64 #ifdef TIZEN_FEATURE_UPSTREAM
65 #include "gst/glib-compat-private.h"
66 #endif /* TIZEN_FEATURE_UPSTREAM */
68 /* Index signals and args */
83 GST_DEBUG_CATEGORY_STATIC (index_debug);
84 #define GST_CAT_DEFAULT index_debug
87 static void gst_index_finalize (GObject * object);
89 static void gst_index_set_property (GObject * object, guint prop_id,
90 const GValue * value, GParamSpec * pspec);
91 static void gst_index_get_property (GObject * object, guint prop_id,
92 GValue * value, GParamSpec * pspec);
94 static GstIndexGroup *gst_index_group_new (guint groupnum);
95 static void gst_index_group_free (GstIndexGroup * group);
97 static gboolean gst_index_path_resolver (GstIndex * index, GstObject * writer,
98 gchar ** writer_string, gpointer data);
99 static gboolean gst_index_gtype_resolver (GstIndex * index, GstObject * writer,
100 gchar ** writer_string, gpointer data);
101 static void gst_index_add_entry (GstIndex * index, GstIndexEntry * entry);
103 static guint gst_index_signals[LAST_SIGNAL] = { 0 };
107 GstIndexResolverMethod method;
108 GstIndexResolver resolver;
113 static const ResolverEntry resolvers[] = {
114 {GST_INDEX_RESOLVER_CUSTOM, NULL, NULL},
115 {GST_INDEX_RESOLVER_GTYPE, gst_index_gtype_resolver, NULL},
116 {GST_INDEX_RESOLVER_PATH, gst_index_path_resolver, NULL},
119 #define GST_TYPE_INDEX_RESOLVER (gst_index_resolver_get_type())
121 gst_index_resolver_get_type (void)
123 static GType index_resolver_type = 0;
124 static const GEnumValue index_resolver[] = {
125 {GST_INDEX_RESOLVER_CUSTOM, "GST_INDEX_RESOLVER_CUSTOM", "custom"},
126 {GST_INDEX_RESOLVER_GTYPE, "GST_INDEX_RESOLVER_GTYPE", "gtype"},
127 {GST_INDEX_RESOLVER_PATH, "GST_INDEX_RESOLVER_PATH", "path"},
131 if (!index_resolver_type) {
132 index_resolver_type =
133 g_enum_register_static ("GstIndexResolver", index_resolver);
135 return index_resolver_type;
138 G_DEFINE_BOXED_TYPE (GstIndexEntry, gst_index_entry,
139 (GBoxedCopyFunc) gst_index_entry_copy,
140 (GBoxedFreeFunc) gst_index_entry_free);
145 GST_DEBUG_CATEGORY_INIT (index_debug, "GST_INDEX", GST_DEBUG_BOLD, \
146 "Generic indexing support"); \
150 G_DEFINE_TYPE (GstIndex, gst_index, GST_TYPE_OBJECT);
153 gst_index_class_init (GstIndexClass * klass)
155 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
158 * GstIndex::entry-added
159 * @gstindex: the object which received the signal.
160 * @arg1: The entry added to the index.
162 * Is emitted when a new entry is added to the index.
164 gst_index_signals[ENTRY_ADDED] =
165 g_signal_new ("entry-added", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
166 G_STRUCT_OFFSET (GstIndexClass, entry_added), NULL, NULL,
167 g_cclosure_marshal_generic, G_TYPE_NONE, 1, GST_TYPE_INDEX_ENTRY);
169 gobject_class->set_property = gst_index_set_property;
170 gobject_class->get_property = gst_index_get_property;
171 gobject_class->finalize = gst_index_finalize;
173 g_object_class_install_property (gobject_class, ARG_RESOLVER,
174 g_param_spec_enum ("resolver", "Resolver",
175 "Select a predefined object to string mapper",
176 GST_TYPE_INDEX_RESOLVER, GST_INDEX_RESOLVER_PATH,
177 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
181 gst_index_init (GstIndex * index)
183 index->curgroup = gst_index_group_new (0);
185 index->groups = g_list_prepend (NULL, index->curgroup);
187 index->writers = g_hash_table_new (NULL, NULL);
190 index->method = GST_INDEX_RESOLVER_PATH;
191 index->resolver = resolvers[index->method].resolver;
192 index->resolver_user_data = resolvers[index->method].user_data;
194 GST_OBJECT_FLAG_SET (index, GST_INDEX_WRITABLE);
195 GST_OBJECT_FLAG_SET (index, GST_INDEX_READABLE);
197 GST_DEBUG ("created new index");
201 gst_index_free_writer (gpointer key, gpointer value, gpointer user_data)
203 GstIndexEntry *entry = (GstIndexEntry *) value;
206 gst_index_entry_free (entry);
211 gst_index_finalize (GObject * object)
213 GstIndex *index = GST_INDEX (object);
216 g_list_foreach (index->groups, (GFunc) gst_index_group_free, NULL);
217 g_list_free (index->groups);
218 index->groups = NULL;
221 if (index->writers) {
222 g_hash_table_foreach (index->writers, gst_index_free_writer, NULL);
223 g_hash_table_destroy (index->writers);
224 index->writers = NULL;
227 if (index->filter_user_data && index->filter_user_data_destroy)
228 index->filter_user_data_destroy (index->filter_user_data);
230 if (index->resolver_user_data && index->resolver_user_data_destroy)
231 index->resolver_user_data_destroy (index->resolver_user_data);
233 G_OBJECT_CLASS (gst_index_parent_class)->finalize (object);
237 gst_index_set_property (GObject * object, guint prop_id,
238 const GValue * value, GParamSpec * pspec)
242 index = GST_INDEX (object);
246 index->method = (GstIndexResolverMethod) g_value_get_enum (value);
247 index->resolver = resolvers[index->method].resolver;
248 index->resolver_user_data = resolvers[index->method].user_data;
251 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
257 gst_index_get_property (GObject * object, guint prop_id,
258 GValue * value, GParamSpec * pspec)
262 index = GST_INDEX (object);
266 g_value_set_enum (value, index->method);
269 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
274 static GstIndexGroup *
275 gst_index_group_new (guint groupnum)
277 GstIndexGroup *indexgroup = g_slice_new (GstIndexGroup);
279 indexgroup->groupnum = groupnum;
280 indexgroup->entries = NULL;
281 indexgroup->certainty = GST_INDEX_UNKNOWN;
282 indexgroup->peergroup = -1;
284 GST_DEBUG ("created new index group %d", groupnum);
290 gst_index_group_free (GstIndexGroup * group)
292 g_slice_free (GstIndexGroup, group);
295 /* do not resurrect this, add a derived dummy index class instead */
300 * Create a new dummy index object. Use gst_element_set_index() to assign that
301 * to an element or pipeline. This index is not storing anything, but will
302 * still emit e.g. the #GstIndex::entry-added signal.
304 * Returns: (transfer full): a new index object
311 index = g_object_new (gst_index_get_type (), NULL);
318 * @index: the index to commit
319 * @id: the writer that committed the index
321 * Tell the index that the writer with the given id is done
322 * with this index and is not going to write any more entries
326 gst_index_commit (GstIndex * index, gint id)
328 GstIndexClass *iclass;
330 iclass = GST_INDEX_GET_CLASS (index);
333 iclass->commit (index, id);
337 * gst_index_get_group:
338 * @index: the index to get the current group from
340 * Get the id of the current group.
342 * Returns: the id of the current group.
345 gst_index_get_group (GstIndex * index)
347 return index->curgroup->groupnum;
351 * gst_index_new_group:
352 * @index: the index to create the new group in
354 * Create a new group for the given index. It will be
355 * set as the current group.
357 * Returns: the id of the newly created group.
360 gst_index_new_group (GstIndex * index)
362 index->curgroup = gst_index_group_new (++index->maxgroup);
363 index->groups = g_list_append (index->groups, index->curgroup);
364 GST_DEBUG ("created new group %d in index", index->maxgroup);
365 return index->maxgroup;
369 * gst_index_set_group:
370 * @index: the index to set the new group in
371 * @groupnum: the groupnumber to set
373 * Set the current groupnumber to the given argument.
375 * Returns: %TRUE if the operation succeeded, %FALSE if the group
379 gst_index_set_group (GstIndex * index, gint groupnum)
382 GstIndexGroup *indexgroup;
384 /* first check for null change */
385 if (groupnum == index->curgroup->groupnum)
388 /* else search for the proper group */
389 list = index->groups;
391 indexgroup = (GstIndexGroup *) (list->data);
392 list = g_list_next (list);
393 if (indexgroup->groupnum == groupnum) {
394 index->curgroup = indexgroup;
395 GST_DEBUG ("switched to index group %d", indexgroup->groupnum);
400 /* couldn't find the group in question */
401 GST_DEBUG ("couldn't find index group %d", groupnum);
408 * gst_index_set_certainty:
409 * @index: the index to set the certainty on
410 * @certainty: the certainty to set
412 * Set the certainty of the given index.
415 gst_index_set_certainty (GstIndex * index, GstIndexCertainty certainty)
417 index->curgroup->certainty = certainty;
421 * gst_index_get_certainty:
422 * @index: the index to get the certainty of
424 * Get the certainty of the given index.
426 * Returns: the certainty of the index.
429 gst_index_get_certainty (GstIndex * index)
431 return index->curgroup->certainty;
437 * gst_index_set_filter:
438 * @index: the index to register the filter on
439 * @filter: the filter to register
440 * @user_data: data passed to the filter function
442 * Lets the app register a custom filter function so that
443 * it can select what entries should be stored in the index.
446 gst_index_set_filter (GstIndex * index,
447 GstIndexFilter filter, gpointer user_data)
449 g_return_if_fail (GST_IS_INDEX (index));
451 gst_index_set_filter_full (index, filter, user_data, NULL);
455 * gst_index_set_filter_full:
456 * @index: the index to register the filter on
457 * @filter: the filter to register
458 * @user_data: data passed to the filter function
459 * @user_data_destroy: function to call when @user_data is unset
461 * Lets the app register a custom filter function so that
462 * it can select what entries should be stored in the index.
465 gst_index_set_filter_full (GstIndex * index,
466 GstIndexFilter filter, gpointer user_data, GDestroyNotify user_data_destroy)
468 g_return_if_fail (GST_IS_INDEX (index));
470 if (index->filter_user_data && index->filter_user_data_destroy)
471 index->filter_user_data_destroy (index->filter_user_data);
473 index->filter = filter;
474 index->filter_user_data = user_data;
475 index->filter_user_data_destroy = user_data_destroy;
479 * gst_index_set_resolver:
480 * @index: the index to register the resolver on
481 * @resolver: the resolver to register
482 * @user_data: data passed to the resolver function
484 * Lets the app register a custom function to map index
485 * ids to writer descriptions.
488 gst_index_set_resolver (GstIndex * index,
489 GstIndexResolver resolver, gpointer user_data)
491 gst_index_set_resolver_full (index, resolver, user_data, NULL);
495 * gst_index_set_resolver_full:
496 * @index: the index to register the resolver on
497 * @resolver: the resolver to register
498 * @user_data: data passed to the resolver function
499 * @user_data_destroy: destroy function for @user_data
501 * Lets the app register a custom function to map index
502 * ids to writer descriptions.
505 gst_index_set_resolver_full (GstIndex * index, GstIndexResolver resolver,
506 gpointer user_data, GDestroyNotify user_data_destroy)
508 g_return_if_fail (GST_IS_INDEX (index));
510 if (index->resolver_user_data && index->resolver_user_data_destroy)
511 index->resolver_user_data_destroy (index->resolver_user_data);
513 index->resolver = resolver;
514 index->resolver_user_data = user_data;
515 index->resolver_user_data_destroy = user_data_destroy;
516 index->method = GST_INDEX_RESOLVER_CUSTOM;
521 * gst_index_entry_copy:
522 * @entry: the entry to copy
524 * Copies an entry and returns the result.
526 * Free-function: gst_index_entry_free
528 * Returns: (transfer full): a newly allocated #GstIndexEntry.
531 gst_index_entry_copy (GstIndexEntry * entry)
533 GstIndexEntry *new_entry = g_slice_new (GstIndexEntry);
535 memcpy (new_entry, entry, sizeof (GstIndexEntry));
540 * gst_index_entry_free:
541 * @entry: (transfer full): the entry to free
543 * Free the memory used by the given entry.
546 gst_index_entry_free (GstIndexEntry * entry)
548 switch (entry->type) {
549 case GST_INDEX_ENTRY_ID:
550 if (entry->data.id.description) {
551 g_free (entry->data.id.description);
552 entry->data.id.description = NULL;
555 case GST_INDEX_ENTRY_ASSOCIATION:
556 if (entry->data.assoc.assocs) {
557 g_free (entry->data.assoc.assocs);
558 entry->data.assoc.assocs = NULL;
561 case GST_INDEX_ENTRY_OBJECT:
563 case GST_INDEX_ENTRY_FORMAT:
567 g_slice_free (GstIndexEntry, entry);
572 * gst_index_add_format:
573 * @index: the index to add the entry to
574 * @id: the id of the index writer
575 * @format: the format to add to the index
577 * Adds a format entry into the index. This function is
578 * used to map dynamic #GstFormat ids to their original
581 * Free-function: gst_index_entry_free
583 * Returns: (transfer full): a pointer to the newly added entry in the index.
586 gst_index_add_format (GstIndex * index, gint id, GstFormat format)
588 GstIndexEntry *entry;
589 const GstFormatDefinition *def;
591 g_return_val_if_fail (GST_IS_INDEX (index), NULL);
592 g_return_val_if_fail (format != 0, NULL);
594 if (!GST_INDEX_IS_WRITABLE (index) || id == -1)
597 entry = g_slice_new (GstIndexEntry);
598 entry->type = GST_INDEX_ENTRY_FORMAT;
600 entry->data.format.format = format;
602 def = gst_format_get_details (format);
603 entry->data.format.key = def->nick;
605 gst_index_add_entry (index, entry);
613 * @index: the index to add the entry to
614 * @id: the id of the index writer
615 * @description: the description of the index writer
617 * Add an id entry into the index.
619 * Returns: a pointer to the newly added entry in the index.
622 gst_index_add_id (GstIndex * index, gint id, gchar * description)
624 GstIndexEntry *entry;
626 g_return_val_if_fail (GST_IS_INDEX (index), NULL);
627 g_return_val_if_fail (description != NULL, NULL);
629 if (!GST_INDEX_IS_WRITABLE (index) || id == -1)
632 entry = g_slice_new (GstIndexEntry);
633 entry->type = GST_INDEX_ENTRY_ID;
635 entry->data.id.description = description;
637 gst_index_add_entry (index, entry);
643 gst_index_path_resolver (GstIndex * index, GstObject * writer,
644 gchar ** writer_string, gpointer data)
646 *writer_string = gst_object_get_path_string (writer);
652 gst_index_gtype_resolver (GstIndex * index, GstObject * writer,
653 gchar ** writer_string, gpointer data)
655 g_return_val_if_fail (writer != NULL, FALSE);
657 if (GST_IS_PAD (writer)) {
658 GstObject *element = gst_object_get_parent (GST_OBJECT (writer));
661 name = gst_object_get_name (writer);
663 *writer_string = g_strdup_printf ("%s.%s",
664 G_OBJECT_TYPE_NAME (element), name);
665 gst_object_unref (element);
667 *writer_string = name;
674 *writer_string = g_strdup (G_OBJECT_TYPE_NAME (writer));
681 * gst_index_get_writer_id:
682 * @index: the index to get a unique write id for
683 * @writer: the #GstObject to allocate an id for
684 * @id: a pointer to a gint to hold the id
686 * Before entries can be added to the index, a writer
687 * should obtain a unique id. The methods to add new entries
688 * to the index require this id as an argument.
690 * The application can implement a custom function to map the writer object
691 * to a string. That string will be used to register or look up an id
694 * > The caller must not hold @writer's GST_OBJECT_LOCK(), as the default
695 * > resolver may call functions that take the object lock as well, and
696 * > the lock is not recursive.
698 * Returns: %TRUE if the writer would be mapped to an id.
701 gst_index_get_writer_id (GstIndex * index, GstObject * writer, gint * id)
703 gchar *writer_string = NULL;
704 GstIndexEntry *entry;
705 GstIndexClass *iclass;
706 gboolean success = FALSE;
708 g_return_val_if_fail (GST_IS_INDEX (index), FALSE);
709 g_return_val_if_fail (GST_IS_OBJECT (writer), FALSE);
710 g_return_val_if_fail (id, FALSE);
714 /* first try to get a previously cached id */
715 entry = g_hash_table_lookup (index->writers, writer);
718 iclass = GST_INDEX_GET_CLASS (index);
720 /* let the app make a string */
721 if (index->resolver) {
725 index->resolver (index, writer, &writer_string,
726 index->resolver_user_data);
730 g_warning ("no resolver found");
734 /* if the index has a resolver, make it map this string to an id */
735 if (iclass->get_writer_id) {
736 success = iclass->get_writer_id (index, id, writer_string);
738 /* if the index could not resolve, we allocate one ourselves */
740 *id = ++index->last_id;
743 entry = gst_index_add_id (index, *id, writer_string);
745 /* index is probably not writable, make an entry anyway
746 * to keep it in our cache */
747 entry = g_slice_new (GstIndexEntry);
748 entry->type = GST_INDEX_ENTRY_ID;
750 entry->data.id.description = writer_string;
752 g_hash_table_insert (index->writers, writer, entry);
761 gst_index_add_entry (GstIndex * index, GstIndexEntry * entry)
763 GstIndexClass *iclass;
765 iclass = GST_INDEX_GET_CLASS (index);
767 if (iclass->add_entry) {
768 iclass->add_entry (index, entry);
771 g_signal_emit (index, gst_index_signals[ENTRY_ADDED], 0, entry);
775 * gst_index_add_associationv:
776 * @index: the index to add the entry to
777 * @id: the id of the index writer
778 * @flags: optional flags for this entry
779 * @n: number of associations
780 * @list: (array length=n): list of associations
782 * Associate given format/value pairs with each other.
784 * Returns: a pointer to the newly added entry in the index.
787 gst_index_add_associationv (GstIndex * index, gint id,
788 GstIndexAssociationFlags flags, gint n, const GstIndexAssociation * list)
790 GstIndexEntry *entry;
792 g_return_val_if_fail (n > 0, NULL);
793 g_return_val_if_fail (list != NULL, NULL);
794 g_return_val_if_fail (GST_IS_INDEX (index), NULL);
796 if (!GST_INDEX_IS_WRITABLE (index) || id == -1)
799 entry = g_slice_new (GstIndexEntry);
801 entry->type = GST_INDEX_ENTRY_ASSOCIATION;
803 entry->data.assoc.flags = flags;
804 #ifdef TIZEN_FEATURE_UPSTREAM
805 entry->data.assoc.assocs = g_memdup2 (list, sizeof (GstIndexAssociation) * n);
806 #else /* TIZEN_FEATURE_UPSTREAM */
807 entry->data.assoc.assocs = g_memdup (list, sizeof (GstIndexAssociation) * n);
808 #endif /* TIZEN_FEATURE_UPSTREAM */
809 entry->data.assoc.nassocs = n;
811 gst_index_add_entry (index, entry);
818 * gst_index_add_association:
819 * @index: the index to add the entry to
820 * @id: the id of the index writer
821 * @flags: optional flags for this entry
822 * @format: the format of the value
824 * @...: other format/value pairs or 0 to end the list
826 * Associate given format/value pairs with each other.
827 * Be sure to pass gint64 values to this functions varargs,
828 * you might want to use a gint64 cast to be sure.
830 * Returns: a pointer to the newly added entry in the index.
833 gst_index_add_association (GstIndex * index, gint id,
834 GstIndexAssociationFlags flags, GstFormat format, gint64 value, ...)
837 GstIndexEntry *entry;
838 GstIndexAssociation *list;
840 GstFormat cur_format;
843 g_return_val_if_fail (GST_IS_INDEX (index), NULL);
844 g_return_val_if_fail (format != 0, NULL);
846 if (!GST_INDEX_IS_WRITABLE (index) || id == -1)
849 array = g_array_new (FALSE, FALSE, sizeof (GstIndexAssociation));
852 GstIndexAssociation a;
857 g_array_append_val (array, a);
860 va_start (args, value);
862 while ((cur_format = va_arg (args, GstFormat))) {
863 GstIndexAssociation a;
865 a.format = cur_format;
866 a.value = va_arg (args, gint64);
868 g_array_append_val (array, a);
873 list = (GstIndexAssociation *) g_array_free (array, FALSE);
875 entry = gst_index_add_associationv (index, id, flags, n_assocs, list);
882 * gst_index_add_object:
883 * @index: the index to add the object to
884 * @id: the id of the index writer
885 * @key: a key for the object
886 * @type: the GType of the object
887 * @object: a pointer to the object to add
889 * Add the given object to the index with the given key.
891 * This function is not yet implemented.
893 * Returns: a pointer to the newly added entry in the index.
896 gst_index_add_object (GstIndex * index, gint id, gchar * key,
897 GType type, gpointer object)
899 if (!GST_INDEX_IS_WRITABLE (index) || id == -1)
907 gst_index_compare_func (gconstpointer a, gconstpointer b, gpointer user_data)
917 * gst_index_get_assoc_entry:
918 * @index: the index to search
919 * @id: the id of the index writer
920 * @method: The lookup method to use
921 * @flags: Flags for the entry
922 * @format: the format of the value
923 * @value: the value to find
925 * Finds the given format/value in the index
927 * Returns: (nullable): the entry associated with the value or %NULL if the
928 * value was not found.
931 gst_index_get_assoc_entry (GstIndex * index, gint id,
932 GstIndexLookupMethod method, GstIndexAssociationFlags flags,
933 GstFormat format, gint64 value)
935 g_return_val_if_fail (GST_IS_INDEX (index), NULL);
940 return gst_index_get_assoc_entry_full (index, id, method, flags, format,
941 value, gst_index_compare_func, NULL);
945 * gst_index_get_assoc_entry_full:
946 * @index: the index to search
947 * @id: the id of the index writer
948 * @method: The lookup method to use
949 * @flags: Flags for the entry
950 * @format: the format of the value
951 * @value: the value to find
952 * @func: the function used to compare entries
953 * @user_data: user data passed to the compare function
955 * Finds the given format/value in the index with the given
956 * compare function and user_data.
958 * Returns: (nullable): the entry associated with the value or %NULL if the
959 * value was not found.
962 gst_index_get_assoc_entry_full (GstIndex * index, gint id,
963 GstIndexLookupMethod method, GstIndexAssociationFlags flags,
964 GstFormat format, gint64 value, GCompareDataFunc func, gpointer user_data)
966 GstIndexClass *iclass;
968 g_return_val_if_fail (GST_IS_INDEX (index), NULL);
973 iclass = GST_INDEX_GET_CLASS (index);
975 if (iclass->get_assoc_entry)
976 return iclass->get_assoc_entry (index, id, method, flags, format, value,
983 * gst_index_entry_assoc_map:
984 * @entry: the index to search
985 * @format: the format of the value the find
986 * @value: a pointer to store the value
988 * Gets alternative formats associated with the indexentry.
990 * Returns: %TRUE if there was a value associated with the given
994 gst_index_entry_assoc_map (GstIndexEntry * entry,
995 GstFormat format, gint64 * value)
999 g_return_val_if_fail (entry != NULL, FALSE);
1000 g_return_val_if_fail (value != NULL, FALSE);
1002 for (i = 0; i < GST_INDEX_NASSOCS (entry); i++) {
1003 if (GST_INDEX_ASSOC_FORMAT (entry, i) == format) {
1004 *value = GST_INDEX_ASSOC_VALUE (entry, i);