Blame libs/gst/base/gstindex.c

Packit Service 963350
/* GStreamer
Packit Service 963350
 * Copyright (C) 2001 RidgeRun (http://www.ridgerun.com/)
Packit Service 963350
 * Written by Erik Walthinsen <omega@ridgerun.com>
Packit Service 963350
 *
Packit Service 963350
 * gstindex.c: Index for mappings and other data
Packit Service 963350
 *
Packit Service 963350
 * This library is free software; you can redistribute it and/or
Packit Service 963350
 * modify it under the terms of the GNU Library General Public
Packit Service 963350
 * License as published by the Free Software Foundation; either
Packit Service 963350
 * version 2 of the License, or (at your option) any later version.
Packit Service 963350
 *
Packit Service 963350
 * This library is distributed in the hope that it will be useful,
Packit Service 963350
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 963350
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service 963350
 * Library General Public License for more details.
Packit Service 963350
 *
Packit Service 963350
 * You should have received a copy of the GNU Library General Public
Packit Service 963350
 * License along with this library; if not, write to the
Packit Service 963350
 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
Packit Service 963350
 * Boston, MA 02110-1301, USA.
Packit Service 963350
 */
Packit Service 963350
Packit Service 963350
/**
Packit Service 963350
 * SECTION:gstindex
Packit Service 963350
 * @title: GstIndexEntry
Packit Service 963350
 * @short_description: Generate indexes on objects
Packit Service 963350
 * @see_also: #GstIndexFactory
Packit Service 963350
 *
Packit Service 963350
 * #GstIndex is used to generate a stream index of one or more elements
Packit Service 963350
 * in a pipeline.
Packit Service 963350
 *
Packit Service 963350
 * Elements will overload the set_index and get_index virtual methods in
Packit Service 963350
 * #GstElement. When streaming data, the element will add index entries if it
Packit Service 963350
 * has an index set.
Packit Service 963350
 *
Packit Service 963350
 * Each element that adds to the index will do that using a writer_id. The
Packit Service 963350
 * writer_id is obtained from gst_index_get_writer_id().
Packit Service 963350
 *
Packit Service 963350
 * The application that wants to index the stream will create a new index object
Packit Service 963350
 * using gst_index_new() or gst_index_factory_make(). The index is assigned to a
Packit Service 963350
 * specific element, a bin or the whole pipeline. This will cause indexable
Packit Service 963350
 * elements to add entires to the index while playing.
Packit Service 963350
 */
Packit Service 963350
Packit Service 963350
/* FIXME: complete gobject annotations */
Packit Service 963350
/* FIXME-0.11: cleanup API
Packit Service 963350
 * - no one seems to use GstIndexGroup, GstIndexCertainty
Packit Service 963350
 *
Packit Service 963350
 * - the API for application to use the index is mostly missing
Packit Service 963350
 *   - apps need to get a list of writers
Packit Service 963350
 *   - apps need to be able to iterate over each writers index entry collection
Packit Service 963350
 * - gst_index_get_assoc_entry() should pass ownership
Packit Service 963350
 *   - the GstIndexEntry structure is large and contains repetitive information
Packit Service 963350
 *   - we want to allow Indexers to implement a saner storage and create
Packit Service 963350
 *     GstIndexEntries on demand (the app has to free them), might even make
Packit Service 963350
 *     sense to ask the app to provide a ptr and fill it.
Packit Service 963350
 */
Packit Service 963350
Packit Service 963350
#ifdef HAVE_CONFIG_H
Packit Service 963350
#include "config.h"
Packit Service 963350
#endif
Packit Service 963350
Packit Service 963350
#include <gst/gst.h>
Packit Service 963350
Packit Service 963350
/* Index signals and args */
Packit Service 963350
enum
Packit Service 963350
{
Packit Service 963350
  ENTRY_ADDED,
Packit Service 963350
  LAST_SIGNAL
Packit Service 963350
};
Packit Service 963350
Packit Service 963350
enum
Packit Service 963350
{
Packit Service 963350
  ARG_0,
Packit Service 963350
  ARG_RESOLVER
Packit Service 963350
      /* FILL ME */
Packit Service 963350
};
Packit Service 963350
Packit Service 963350
#if 0
Packit Service 963350
GST_DEBUG_CATEGORY_STATIC (index_debug);
Packit Service 963350
#define GST_CAT_DEFAULT index_debug
Packit Service 963350
#endif
Packit Service 963350
Packit Service 963350
static void gst_index_finalize (GObject * object);
Packit Service 963350
Packit Service 963350
static void gst_index_set_property (GObject * object, guint prop_id,
Packit Service 963350
    const GValue * value, GParamSpec * pspec);
Packit Service 963350
static void gst_index_get_property (GObject * object, guint prop_id,
Packit Service 963350
    GValue * value, GParamSpec * pspec);
Packit Service 963350
Packit Service 963350
static GstIndexGroup *gst_index_group_new (guint groupnum);
Packit Service 963350
static void gst_index_group_free (GstIndexGroup * group);
Packit Service 963350
Packit Service 963350
static gboolean gst_index_path_resolver (GstIndex * index, GstObject * writer,
Packit Service 963350
    gchar ** writer_string, gpointer data);
Packit Service 963350
static gboolean gst_index_gtype_resolver (GstIndex * index, GstObject * writer,
Packit Service 963350
    gchar ** writer_string, gpointer data);
Packit Service 963350
static void gst_index_add_entry (GstIndex * index, GstIndexEntry * entry);
Packit Service 963350
Packit Service 963350
static guint gst_index_signals[LAST_SIGNAL] = { 0 };
Packit Service 963350
Packit Service 963350
typedef struct
Packit Service 963350
{
Packit Service 963350
  GstIndexResolverMethod method;
Packit Service 963350
  GstIndexResolver resolver;
Packit Service 963350
  gpointer user_data;
Packit Service 963350
}
Packit Service 963350
ResolverEntry;
Packit Service 963350
Packit Service 963350
static const ResolverEntry resolvers[] = {
Packit Service 963350
  {GST_INDEX_RESOLVER_CUSTOM, NULL, NULL},
Packit Service 963350
  {GST_INDEX_RESOLVER_GTYPE, gst_index_gtype_resolver, NULL},
Packit Service 963350
  {GST_INDEX_RESOLVER_PATH, gst_index_path_resolver, NULL},
Packit Service 963350
};
Packit Service 963350
Packit Service 963350
#define GST_TYPE_INDEX_RESOLVER (gst_index_resolver_get_type())
Packit Service 963350
static GType
Packit Service 963350
gst_index_resolver_get_type (void)
Packit Service 963350
{
Packit Service 963350
  static GType index_resolver_type = 0;
Packit Service 963350
  static const GEnumValue index_resolver[] = {
Packit Service 963350
    {GST_INDEX_RESOLVER_CUSTOM, "GST_INDEX_RESOLVER_CUSTOM", "custom"},
Packit Service 963350
    {GST_INDEX_RESOLVER_GTYPE, "GST_INDEX_RESOLVER_GTYPE", "gtype"},
Packit Service 963350
    {GST_INDEX_RESOLVER_PATH, "GST_INDEX_RESOLVER_PATH", "path"},
Packit Service 963350
    {0, NULL, NULL},
Packit Service 963350
  };
Packit Service 963350
Packit Service 963350
  if (!index_resolver_type) {
Packit Service 963350
    index_resolver_type =
Packit Service 963350
        g_enum_register_static ("GstIndexResolver", index_resolver);
Packit Service 963350
  }
Packit Service 963350
  return index_resolver_type;
Packit Service 963350
}
Packit Service 963350
Packit Service 963350
G_DEFINE_BOXED_TYPE (GstIndexEntry, gst_index_entry,
Packit Service 963350
    (GBoxedCopyFunc) gst_index_entry_copy,
Packit Service 963350
    (GBoxedFreeFunc) gst_index_entry_free);
Packit Service 963350
Packit Service 963350
#if 0
Packit Service 963350
#define _do_init \
Packit Service 963350
{ \
Packit Service 963350
  GST_DEBUG_CATEGORY_INIT (index_debug, "GST_INDEX", GST_DEBUG_BOLD, \
Packit Service 963350
      "Generic indexing support"); \
Packit Service 963350
}
Packit Service 963350
#endif
Packit Service 963350
Packit Service 963350
G_DEFINE_TYPE (GstIndex, gst_index, GST_TYPE_OBJECT);
Packit Service 963350
Packit Service 963350
static void
Packit Service 963350
gst_index_class_init (GstIndexClass * klass)
Packit Service 963350
{
Packit Service 963350
  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
Packit Service 963350
Packit Service 963350
  /**
Packit Service 963350
   * GstIndex::entry-added
Packit Service 963350
   * @gstindex: the object which received the signal.
Packit Service 963350
   * @arg1: The entry added to the index.
Packit Service 963350
   *
Packit Service 963350
   * Is emitted when a new entry is added to the index.
Packit Service 963350
   */
Packit Service 963350
  gst_index_signals[ENTRY_ADDED] =
Packit Service 963350
      g_signal_new ("entry-added", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
Packit Service 963350
      G_STRUCT_OFFSET (GstIndexClass, entry_added), NULL, NULL,
Packit Service 963350
      g_cclosure_marshal_generic, G_TYPE_NONE, 1, GST_TYPE_INDEX_ENTRY);
Packit Service 963350
Packit Service 963350
  gobject_class->set_property = gst_index_set_property;
Packit Service 963350
  gobject_class->get_property = gst_index_get_property;
Packit Service 963350
  gobject_class->finalize = gst_index_finalize;
Packit Service 963350
Packit Service 963350
  g_object_class_install_property (gobject_class, ARG_RESOLVER,
Packit Service 963350
      g_param_spec_enum ("resolver", "Resolver",
Packit Service 963350
          "Select a predefined object to string mapper",
Packit Service 963350
          GST_TYPE_INDEX_RESOLVER, GST_INDEX_RESOLVER_PATH,
Packit Service 963350
          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
Packit Service 963350
}
Packit Service 963350
Packit Service 963350
static void
Packit Service 963350
gst_index_init (GstIndex * index)
Packit Service 963350
{
Packit Service 963350
  index->curgroup = gst_index_group_new (0);
Packit Service 963350
  index->maxgroup = 0;
Packit Service 963350
  index->groups = g_list_prepend (NULL, index->curgroup);
Packit Service 963350
Packit Service 963350
  index->writers = g_hash_table_new (NULL, NULL);
Packit Service 963350
  index->last_id = 0;
Packit Service 963350
Packit Service 963350
  index->method = GST_INDEX_RESOLVER_PATH;
Packit Service 963350
  index->resolver = resolvers[index->method].resolver;
Packit Service 963350
  index->resolver_user_data = resolvers[index->method].user_data;
Packit Service 963350
Packit Service 963350
  GST_OBJECT_FLAG_SET (index, GST_INDEX_WRITABLE);
Packit Service 963350
  GST_OBJECT_FLAG_SET (index, GST_INDEX_READABLE);
Packit Service 963350
Packit Service 963350
  GST_DEBUG ("created new index");
Packit Service 963350
}
Packit Service 963350
Packit Service 963350
static void
Packit Service 963350
gst_index_free_writer (gpointer key, gpointer value, gpointer user_data)
Packit Service 963350
{
Packit Service 963350
  GstIndexEntry *entry = (GstIndexEntry *) value;
Packit Service 963350
Packit Service 963350
  if (entry) {
Packit Service 963350
    gst_index_entry_free (entry);
Packit Service 963350
  }
Packit Service 963350
}
Packit Service 963350
Packit Service 963350
static void
Packit Service 963350
gst_index_finalize (GObject * object)
Packit Service 963350
{
Packit Service 963350
  GstIndex *index = GST_INDEX (object);
Packit Service 963350
Packit Service 963350
  if (index->groups) {
Packit Service 963350
    g_list_foreach (index->groups, (GFunc) gst_index_group_free, NULL);
Packit Service 963350
    g_list_free (index->groups);
Packit Service 963350
    index->groups = NULL;
Packit Service 963350
  }
Packit Service 963350
Packit Service 963350
  if (index->writers) {
Packit Service 963350
    g_hash_table_foreach (index->writers, gst_index_free_writer, NULL);
Packit Service 963350
    g_hash_table_destroy (index->writers);
Packit Service 963350
    index->writers = NULL;
Packit Service 963350
  }
Packit Service 963350
Packit Service 963350
  if (index->filter_user_data && index->filter_user_data_destroy)
Packit Service 963350
    index->filter_user_data_destroy (index->filter_user_data);
Packit Service 963350
Packit Service 963350
  if (index->resolver_user_data && index->resolver_user_data_destroy)
Packit Service 963350
    index->resolver_user_data_destroy (index->resolver_user_data);
Packit Service 963350
Packit Service 963350
  G_OBJECT_CLASS (gst_index_parent_class)->finalize (object);
Packit Service 963350
}
Packit Service 963350
Packit Service 963350
static void
Packit Service 963350
gst_index_set_property (GObject * object, guint prop_id,
Packit Service 963350
    const GValue * value, GParamSpec * pspec)
Packit Service 963350
{
Packit Service 963350
  GstIndex *index;
Packit Service 963350
Packit Service 963350
  index = GST_INDEX (object);
Packit Service 963350
Packit Service 963350
  switch (prop_id) {
Packit Service 963350
    case ARG_RESOLVER:
Packit Service 963350
      index->method = (GstIndexResolverMethod) g_value_get_enum (value);
Packit Service 963350
      index->resolver = resolvers[index->method].resolver;
Packit Service 963350
      index->resolver_user_data = resolvers[index->method].user_data;
Packit Service 963350
      break;
Packit Service 963350
    default:
Packit Service 963350
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
Packit Service 963350
      break;
Packit Service 963350
  }
Packit Service 963350
}
Packit Service 963350
Packit Service 963350
static void
Packit Service 963350
gst_index_get_property (GObject * object, guint prop_id,
Packit Service 963350
    GValue * value, GParamSpec * pspec)
Packit Service 963350
{
Packit Service 963350
  GstIndex *index;
Packit Service 963350
Packit Service 963350
  index = GST_INDEX (object);
Packit Service 963350
Packit Service 963350
  switch (prop_id) {
Packit Service 963350
    case ARG_RESOLVER:
Packit Service 963350
      g_value_set_enum (value, index->method);
Packit Service 963350
      break;
Packit Service 963350
    default:
Packit Service 963350
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
Packit Service 963350
      break;
Packit Service 963350
  }
Packit Service 963350
}
Packit Service 963350
Packit Service 963350
static GstIndexGroup *
Packit Service 963350
gst_index_group_new (guint groupnum)
Packit Service 963350
{
Packit Service 963350
  GstIndexGroup *indexgroup = g_slice_new (GstIndexGroup);
Packit Service 963350
Packit Service 963350
  indexgroup->groupnum = groupnum;
Packit Service 963350
  indexgroup->entries = NULL;
Packit Service 963350
  indexgroup->certainty = GST_INDEX_UNKNOWN;
Packit Service 963350
  indexgroup->peergroup = -1;
Packit Service 963350
Packit Service 963350
  GST_DEBUG ("created new index group %d", groupnum);
Packit Service 963350
Packit Service 963350
  return indexgroup;
Packit Service 963350
}
Packit Service 963350
Packit Service 963350
static void
Packit Service 963350
gst_index_group_free (GstIndexGroup * group)
Packit Service 963350
{
Packit Service 963350
  g_slice_free (GstIndexGroup, group);
Packit Service 963350
}
Packit Service 963350
Packit Service 963350
/* do not resurrect this, add a derived dummy index class instead */
Packit Service 963350
#if 0
Packit Service 963350
/**
Packit Service 963350
 * gst_index_new:
Packit Service 963350
 *
Packit Service 963350
 * Create a new dummy index object. Use gst_element_set_index() to assign that
Packit Service 963350
 * to an element or pipeline. This index is not storing anything, but will
Packit Service 963350
 * still emit e.g. the #GstIndex::entry-added signal.
Packit Service 963350
 *
Packit Service 963350
 * Returns: (transfer full): a new index object
Packit Service 963350
 */
Packit Service 963350
GstIndex *
Packit Service 963350
gst_index_new (void)
Packit Service 963350
{
Packit Service 963350
  GstIndex *index;
Packit Service 963350
Packit Service 963350
  index = g_object_new (gst_index_get_type (), NULL);
Packit Service 963350
Packit Service 963350
  return index;
Packit Service 963350
}
Packit Service 963350
Packit Service 963350
/**
Packit Service 963350
 * gst_index_commit:
Packit Service 963350
 * @index: the index to commit
Packit Service 963350
 * @id: the writer that commited the index
Packit Service 963350
 *
Packit Service 963350
 * Tell the index that the writer with the given id is done
Packit Service 963350
 * with this index and is not going to write any more entries
Packit Service 963350
 * to it.
Packit Service 963350
 */
Packit Service 963350
void
Packit Service 963350
gst_index_commit (GstIndex * index, gint id)
Packit Service 963350
{
Packit Service 963350
  GstIndexClass *iclass;
Packit Service 963350
Packit Service 963350
  iclass = GST_INDEX_GET_CLASS (index);
Packit Service 963350
Packit Service 963350
  if (iclass->commit)
Packit Service 963350
    iclass->commit (index, id);
Packit Service 963350
}
Packit Service 963350
Packit Service 963350
/**
Packit Service 963350
 * gst_index_get_group:
Packit Service 963350
 * @index: the index to get the current group from
Packit Service 963350
 *
Packit Service 963350
 * Get the id of the current group.
Packit Service 963350
 *
Packit Service 963350
 * Returns: the id of the current group.
Packit Service 963350
 */
Packit Service 963350
gint
Packit Service 963350
gst_index_get_group (GstIndex * index)
Packit Service 963350
{
Packit Service 963350
  return index->curgroup->groupnum;
Packit Service 963350
}
Packit Service 963350
Packit Service 963350
/**
Packit Service 963350
 * gst_index_new_group:
Packit Service 963350
 * @index: the index to create the new group in
Packit Service 963350
 *
Packit Service 963350
 * Create a new group for the given index. It will be
Packit Service 963350
 * set as the current group.
Packit Service 963350
 *
Packit Service 963350
 * Returns: the id of the newly created group.
Packit Service 963350
 */
Packit Service 963350
gint
Packit Service 963350
gst_index_new_group (GstIndex * index)
Packit Service 963350
{
Packit Service 963350
  index->curgroup = gst_index_group_new (++index->maxgroup);
Packit Service 963350
  index->groups = g_list_append (index->groups, index->curgroup);
Packit Service 963350
  GST_DEBUG ("created new group %d in index", index->maxgroup);
Packit Service 963350
  return index->maxgroup;
Packit Service 963350
}
Packit Service 963350
Packit Service 963350
/**
Packit Service 963350
 * gst_index_set_group:
Packit Service 963350
 * @index: the index to set the new group in
Packit Service 963350
 * @groupnum: the groupnumber to set
Packit Service 963350
 *
Packit Service 963350
 * Set the current groupnumber to the given argument.
Packit Service 963350
 *
Packit Service 963350
 * Returns: %TRUE if the operation succeeded, %FALSE if the group
Packit Service 963350
 * did not exist.
Packit Service 963350
 */
Packit Service 963350
gboolean
Packit Service 963350
gst_index_set_group (GstIndex * index, gint groupnum)
Packit Service 963350
{
Packit Service 963350
  GList *list;
Packit Service 963350
  GstIndexGroup *indexgroup;
Packit Service 963350
Packit Service 963350
  /* first check for null change */
Packit Service 963350
  if (groupnum == index->curgroup->groupnum)
Packit Service 963350
    return TRUE;
Packit Service 963350
Packit Service 963350
  /* else search for the proper group */
Packit Service 963350
  list = index->groups;
Packit Service 963350
  while (list) {
Packit Service 963350
    indexgroup = (GstIndexGroup *) (list->data);
Packit Service 963350
    list = g_list_next (list);
Packit Service 963350
    if (indexgroup->groupnum == groupnum) {
Packit Service 963350
      index->curgroup = indexgroup;
Packit Service 963350
      GST_DEBUG ("switched to index group %d", indexgroup->groupnum);
Packit Service 963350
      return TRUE;
Packit Service 963350
    }
Packit Service 963350
  }
Packit Service 963350
Packit Service 963350
  /* couldn't find the group in question */
Packit Service 963350
  GST_DEBUG ("couldn't find index group %d", groupnum);
Packit Service 963350
  return FALSE;
Packit Service 963350
}
Packit Service 963350
#endif
Packit Service 963350
Packit Service 963350
#if 0
Packit Service 963350
/**
Packit Service 963350
 * gst_index_set_certainty:
Packit Service 963350
 * @index: the index to set the certainty on
Packit Service 963350
 * @certainty: the certainty to set
Packit Service 963350
 *
Packit Service 963350
 * Set the certainty of the given index.
Packit Service 963350
 */
Packit Service 963350
void
Packit Service 963350
gst_index_set_certainty (GstIndex * index, GstIndexCertainty certainty)
Packit Service 963350
{
Packit Service 963350
  index->curgroup->certainty = certainty;
Packit Service 963350
}
Packit Service 963350
Packit Service 963350
/**
Packit Service 963350
 * gst_index_get_certainty:
Packit Service 963350
 * @index: the index to get the certainty of
Packit Service 963350
 *
Packit Service 963350
 * Get the certainty of the given index.
Packit Service 963350
 *
Packit Service 963350
 * Returns: the certainty of the index.
Packit Service 963350
 */
Packit Service 963350
GstIndexCertainty
Packit Service 963350
gst_index_get_certainty (GstIndex * index)
Packit Service 963350
{
Packit Service 963350
  return index->curgroup->certainty;
Packit Service 963350
}
Packit Service 963350
#endif
Packit Service 963350
Packit Service 963350
#if 0
Packit Service 963350
/**
Packit Service 963350
 * gst_index_set_filter:
Packit Service 963350
 * @index: the index to register the filter on
Packit Service 963350
 * @filter: the filter to register
Packit Service 963350
 * @user_data: data passed to the filter function
Packit Service 963350
 *
Packit Service 963350
 * Lets the app register a custom filter function so that
Packit Service 963350
 * it can select what entries should be stored in the index.
Packit Service 963350
 */
Packit Service 963350
void
Packit Service 963350
gst_index_set_filter (GstIndex * index,
Packit Service 963350
    GstIndexFilter filter, gpointer user_data)
Packit Service 963350
{
Packit Service 963350
  g_return_if_fail (GST_IS_INDEX (index));
Packit Service 963350
Packit Service 963350
  gst_index_set_filter_full (index, filter, user_data, NULL);
Packit Service 963350
}
Packit Service 963350
Packit Service 963350
/**
Packit Service 963350
 * gst_index_set_filter_full:
Packit Service 963350
 * @index: the index to register the filter on
Packit Service 963350
 * @filter: the filter to register
Packit Service 963350
 * @user_data: data passed to the filter function
Packit Service 963350
 * @user_data_destroy: function to call when @user_data is unset
Packit Service 963350
 *
Packit Service 963350
 * Lets the app register a custom filter function so that
Packit Service 963350
 * it can select what entries should be stored in the index.
Packit Service 963350
 */
Packit Service 963350
void
Packit Service 963350
gst_index_set_filter_full (GstIndex * index,
Packit Service 963350
    GstIndexFilter filter, gpointer user_data, GDestroyNotify user_data_destroy)
Packit Service 963350
{
Packit Service 963350
  g_return_if_fail (GST_IS_INDEX (index));
Packit Service 963350
Packit Service 963350
  if (index->filter_user_data && index->filter_user_data_destroy)
Packit Service 963350
    index->filter_user_data_destroy (index->filter_user_data);
Packit Service 963350
Packit Service 963350
  index->filter = filter;
Packit Service 963350
  index->filter_user_data = user_data;
Packit Service 963350
  index->filter_user_data_destroy = user_data_destroy;
Packit Service 963350
}
Packit Service 963350
Packit Service 963350
/**
Packit Service 963350
 * gst_index_set_resolver:
Packit Service 963350
 * @index: the index to register the resolver on
Packit Service 963350
 * @resolver: the resolver to register
Packit Service 963350
 * @user_data: data passed to the resolver function
Packit Service 963350
 *
Packit Service 963350
 * Lets the app register a custom function to map index
Packit Service 963350
 * ids to writer descriptions.
Packit Service 963350
 */
Packit Service 963350
void
Packit Service 963350
gst_index_set_resolver (GstIndex * index,
Packit Service 963350
    GstIndexResolver resolver, gpointer user_data)
Packit Service 963350
{
Packit Service 963350
  gst_index_set_resolver_full (index, resolver, user_data, NULL);
Packit Service 963350
}
Packit Service 963350
Packit Service 963350
/**
Packit Service 963350
 * gst_index_set_resolver_full:
Packit Service 963350
 * @index: the index to register the resolver on
Packit Service 963350
 * @resolver: the resolver to register
Packit Service 963350
 * @user_data: data passed to the resolver function
Packit Service 963350
 * @user_data_destroy: destroy function for @user_data
Packit Service 963350
 *
Packit Service 963350
 * Lets the app register a custom function to map index
Packit Service 963350
 * ids to writer descriptions.
Packit Service 963350
 */
Packit Service 963350
void
Packit Service 963350
gst_index_set_resolver_full (GstIndex * index, GstIndexResolver resolver,
Packit Service 963350
    gpointer user_data, GDestroyNotify user_data_destroy)
Packit Service 963350
{
Packit Service 963350
  g_return_if_fail (GST_IS_INDEX (index));
Packit Service 963350
Packit Service 963350
  if (index->resolver_user_data && index->resolver_user_data_destroy)
Packit Service 963350
    index->resolver_user_data_destroy (index->resolver_user_data);
Packit Service 963350
Packit Service 963350
  index->resolver = resolver;
Packit Service 963350
  index->resolver_user_data = user_data;
Packit Service 963350
  index->resolver_user_data_destroy = user_data_destroy;
Packit Service 963350
  index->method = GST_INDEX_RESOLVER_CUSTOM;
Packit Service 963350
}
Packit Service 963350
#endif
Packit Service 963350
Packit Service 963350
/**
Packit Service 963350
 * gst_index_entry_copy:
Packit Service 963350
 * @entry: the entry to copy
Packit Service 963350
 *
Packit Service 963350
 * Copies an entry and returns the result.
Packit Service 963350
 *
Packit Service 963350
 * Free-function: gst_index_entry_free
Packit Service 963350
 *
Packit Service 963350
 * Returns: (transfer full): a newly allocated #GstIndexEntry.
Packit Service 963350
 */
Packit Service 963350
GstIndexEntry *
Packit Service 963350
gst_index_entry_copy (GstIndexEntry * entry)
Packit Service 963350
{
Packit Service 963350
  GstIndexEntry *new_entry = g_slice_new (GstIndexEntry);
Packit Service 963350
Packit Service 963350
  memcpy (new_entry, entry, sizeof (GstIndexEntry));
Packit Service 963350
  return new_entry;
Packit Service 963350
}
Packit Service 963350
Packit Service 963350
/**
Packit Service 963350
 * gst_index_entry_free:
Packit Service 963350
 * @entry: (transfer full): the entry to free
Packit Service 963350
 *
Packit Service 963350
 * Free the memory used by the given entry.
Packit Service 963350
 */
Packit Service 963350
void
Packit Service 963350
gst_index_entry_free (GstIndexEntry * entry)
Packit Service 963350
{
Packit Service 963350
  switch (entry->type) {
Packit Service 963350
    case GST_INDEX_ENTRY_ID:
Packit Service 963350
      if (entry->data.id.description) {
Packit Service 963350
        g_free (entry->data.id.description);
Packit Service 963350
        entry->data.id.description = NULL;
Packit Service 963350
      }
Packit Service 963350
      break;
Packit Service 963350
    case GST_INDEX_ENTRY_ASSOCIATION:
Packit Service 963350
      if (entry->data.assoc.assocs) {
Packit Service 963350
        g_free (entry->data.assoc.assocs);
Packit Service 963350
        entry->data.assoc.assocs = NULL;
Packit Service 963350
      }
Packit Service 963350
      break;
Packit Service 963350
    case GST_INDEX_ENTRY_OBJECT:
Packit Service 963350
      break;
Packit Service 963350
    case GST_INDEX_ENTRY_FORMAT:
Packit Service 963350
      break;
Packit Service 963350
  }
Packit Service 963350
Packit Service 963350
  g_slice_free (GstIndexEntry, entry);
Packit Service 963350
}
Packit Service 963350
Packit Service 963350
#if 0
Packit Service 963350
/**
Packit Service 963350
 * gst_index_add_format:
Packit Service 963350
 * @index: the index to add the entry to
Packit Service 963350
 * @id: the id of the index writer
Packit Service 963350
 * @format: the format to add to the index
Packit Service 963350
 *
Packit Service 963350
 * Adds a format entry into the index. This function is
Packit Service 963350
 * used to map dynamic #GstFormat ids to their original
Packit Service 963350
 * format key.
Packit Service 963350
 *
Packit Service 963350
 * Free-function: gst_index_entry_free
Packit Service 963350
 *
Packit Service 963350
 * Returns: (transfer full): a pointer to the newly added entry in the index.
Packit Service 963350
 */
Packit Service 963350
GstIndexEntry *
Packit Service 963350
gst_index_add_format (GstIndex * index, gint id, GstFormat format)
Packit Service 963350
{
Packit Service 963350
  GstIndexEntry *entry;
Packit Service 963350
  const GstFormatDefinition *def;
Packit Service 963350
Packit Service 963350
  g_return_val_if_fail (GST_IS_INDEX (index), NULL);
Packit Service 963350
  g_return_val_if_fail (format != 0, NULL);
Packit Service 963350
Packit Service 963350
  if (!GST_INDEX_IS_WRITABLE (index) || id == -1)
Packit Service 963350
    return NULL;
Packit Service 963350
Packit Service 963350
  entry = g_slice_new (GstIndexEntry);
Packit Service 963350
  entry->type = GST_INDEX_ENTRY_FORMAT;
Packit Service 963350
  entry->id = id;
Packit Service 963350
  entry->data.format.format = format;
Packit Service 963350
Packit Service 963350
  def = gst_format_get_details (format);
Packit Service 963350
  entry->data.format.key = def->nick;
Packit Service 963350
Packit Service 963350
  gst_index_add_entry (index, entry);
Packit Service 963350
Packit Service 963350
  return entry;
Packit Service 963350
}
Packit Service 963350
#endif
Packit Service 963350
Packit Service 963350
/**
Packit Service 963350
 * gst_index_add_id:
Packit Service 963350
 * @index: the index to add the entry to
Packit Service 963350
 * @id: the id of the index writer
Packit Service 963350
 * @description: the description of the index writer
Packit Service 963350
 *
Packit Service 963350
 * Add an id entry into the index.
Packit Service 963350
 *
Packit Service 963350
 * Returns: a pointer to the newly added entry in the index.
Packit Service 963350
 */
Packit Service 963350
GstIndexEntry *
Packit Service 963350
gst_index_add_id (GstIndex * index, gint id, gchar * description)
Packit Service 963350
{
Packit Service 963350
  GstIndexEntry *entry;
Packit Service 963350
Packit Service 963350
  g_return_val_if_fail (GST_IS_INDEX (index), NULL);
Packit Service 963350
  g_return_val_if_fail (description != NULL, NULL);
Packit Service 963350
Packit Service 963350
  if (!GST_INDEX_IS_WRITABLE (index) || id == -1)
Packit Service 963350
    return NULL;
Packit Service 963350
Packit Service 963350
  entry = g_slice_new (GstIndexEntry);
Packit Service 963350
  entry->type = GST_INDEX_ENTRY_ID;
Packit Service 963350
  entry->id = id;
Packit Service 963350
  entry->data.id.description = description;
Packit Service 963350
Packit Service 963350
  gst_index_add_entry (index, entry);
Packit Service 963350
Packit Service 963350
  return entry;
Packit Service 963350
}
Packit Service 963350
Packit Service 963350
static gboolean
Packit Service 963350
gst_index_path_resolver (GstIndex * index, GstObject * writer,
Packit Service 963350
    gchar ** writer_string, gpointer data)
Packit Service 963350
{
Packit Service 963350
  *writer_string = gst_object_get_path_string (writer);
Packit Service 963350
Packit Service 963350
  return TRUE;
Packit Service 963350
}
Packit Service 963350
Packit Service 963350
static gboolean
Packit Service 963350
gst_index_gtype_resolver (GstIndex * index, GstObject * writer,
Packit Service 963350
    gchar ** writer_string, gpointer data)
Packit Service 963350
{
Packit Service 963350
  g_return_val_if_fail (writer != NULL, FALSE);
Packit Service 963350
Packit Service 963350
  if (GST_IS_PAD (writer)) {
Packit Service 963350
    GstObject *element = gst_object_get_parent (GST_OBJECT (writer));
Packit Service 963350
    gchar *name;
Packit Service 963350
Packit Service 963350
    name = gst_object_get_name (writer);
Packit Service 963350
    if (element) {
Packit Service 963350
      *writer_string = g_strdup_printf ("%s.%s",
Packit Service 963350
          G_OBJECT_TYPE_NAME (element), name);
Packit Service 963350
      gst_object_unref (element);
Packit Service 963350
    } else {
Packit Service 963350
      *writer_string = name;
Packit Service 963350
      name = NULL;
Packit Service 963350
    }
Packit Service 963350
Packit Service 963350
    g_free (name);
Packit Service 963350
Packit Service 963350
  } else {
Packit Service 963350
    *writer_string = g_strdup (G_OBJECT_TYPE_NAME (writer));
Packit Service 963350
  }
Packit Service 963350
Packit Service 963350
  return TRUE;
Packit Service 963350
}
Packit Service 963350
Packit Service 963350
/**
Packit Service 963350
 * gst_index_get_writer_id:
Packit Service 963350
 * @index: the index to get a unique write id for
Packit Service 963350
 * @writer: the #GstObject to allocate an id for
Packit Service 963350
 * @id: a pointer to a gint to hold the id
Packit Service 963350
 *
Packit Service 963350
 * Before entries can be added to the index, a writer
Packit Service 963350
 * should obtain a unique id. The methods to add new entries
Packit Service 963350
 * to the index require this id as an argument.
Packit Service 963350
 *
Packit Service 963350
 * The application can implement a custom function to map the writer object
Packit Service 963350
 * to a string. That string will be used to register or look up an id
Packit Service 963350
 * in the index.
Packit Service 963350
 *
Packit Service 963350
 * > The caller must not hold @writer's GST_OBJECT_LOCK(), as the default
Packit Service 963350
 * > resolver may call functions that take the object lock as well, and
Packit Service 963350
 * > the lock is not recursive.
Packit Service 963350
 *
Packit Service 963350
 * Returns: %TRUE if the writer would be mapped to an id.
Packit Service 963350
 */
Packit Service 963350
gboolean
Packit Service 963350
gst_index_get_writer_id (GstIndex * index, GstObject * writer, gint * id)
Packit Service 963350
{
Packit Service 963350
  gchar *writer_string = NULL;
Packit Service 963350
  GstIndexEntry *entry;
Packit Service 963350
  GstIndexClass *iclass;
Packit Service 963350
  gboolean success = FALSE;
Packit Service 963350
Packit Service 963350
  g_return_val_if_fail (GST_IS_INDEX (index), FALSE);
Packit Service 963350
  g_return_val_if_fail (GST_IS_OBJECT (writer), FALSE);
Packit Service 963350
  g_return_val_if_fail (id, FALSE);
Packit Service 963350
Packit Service 963350
  *id = -1;
Packit Service 963350
Packit Service 963350
  /* first try to get a previously cached id */
Packit Service 963350
  entry = g_hash_table_lookup (index->writers, writer);
Packit Service 963350
  if (entry == NULL) {
Packit Service 963350
Packit Service 963350
    iclass = GST_INDEX_GET_CLASS (index);
Packit Service 963350
Packit Service 963350
    /* let the app make a string */
Packit Service 963350
    if (index->resolver) {
Packit Service 963350
      gboolean res;
Packit Service 963350
Packit Service 963350
      res =
Packit Service 963350
          index->resolver (index, writer, &writer_string,
Packit Service 963350
          index->resolver_user_data);
Packit Service 963350
      if (!res)
Packit Service 963350
        return FALSE;
Packit Service 963350
    } else {
Packit Service 963350
      g_warning ("no resolver found");
Packit Service 963350
      return FALSE;
Packit Service 963350
    }
Packit Service 963350
Packit Service 963350
    /* if the index has a resolver, make it map this string to an id */
Packit Service 963350
    if (iclass->get_writer_id) {
Packit Service 963350
      success = iclass->get_writer_id (index, id, writer_string);
Packit Service 963350
    }
Packit Service 963350
    /* if the index could not resolve, we allocate one ourselves */
Packit Service 963350
    if (!success) {
Packit Service 963350
      *id = ++index->last_id;
Packit Service 963350
    }
Packit Service 963350
Packit Service 963350
    entry = gst_index_add_id (index, *id, writer_string);
Packit Service 963350
    if (!entry) {
Packit Service 963350
      /* index is probably not writable, make an entry anyway
Packit Service 963350
       * to keep it in our cache */
Packit Service 963350
      entry = g_slice_new (GstIndexEntry);
Packit Service 963350
      entry->type = GST_INDEX_ENTRY_ID;
Packit Service 963350
      entry->id = *id;
Packit Service 963350
      entry->data.id.description = writer_string;
Packit Service 963350
    }
Packit Service 963350
    g_hash_table_insert (index->writers, writer, entry);
Packit Service 963350
  } else {
Packit Service 963350
    *id = entry->id;
Packit Service 963350
  }
Packit Service 963350
Packit Service 963350
  return TRUE;
Packit Service 963350
}
Packit Service 963350
Packit Service 963350
static void
Packit Service 963350
gst_index_add_entry (GstIndex * index, GstIndexEntry * entry)
Packit Service 963350
{
Packit Service 963350
  GstIndexClass *iclass;
Packit Service 963350
Packit Service 963350
  iclass = GST_INDEX_GET_CLASS (index);
Packit Service 963350
Packit Service 963350
  if (iclass->add_entry) {
Packit Service 963350
    iclass->add_entry (index, entry);
Packit Service 963350
  }
Packit Service 963350
Packit Service 963350
  g_signal_emit (index, gst_index_signals[ENTRY_ADDED], 0, entry);
Packit Service 963350
}
Packit Service 963350
Packit Service 963350
/**
Packit Service 963350
 * gst_index_add_associationv:
Packit Service 963350
 * @index: the index to add the entry to
Packit Service 963350
 * @id: the id of the index writer
Packit Service 963350
 * @flags: optinal flags for this entry
Packit Service 963350
 * @n: number of associations
Packit Service 963350
 * @list: (array length=n): list of associations
Packit Service 963350
 *
Packit Service 963350
 * Associate given format/value pairs with each other.
Packit Service 963350
 *
Packit Service 963350
 * Returns: a pointer to the newly added entry in the index.
Packit Service 963350
 */
Packit Service 963350
GstIndexEntry *
Packit Service 963350
gst_index_add_associationv (GstIndex * index, gint id,
Packit Service 963350
    GstIndexAssociationFlags flags, gint n, const GstIndexAssociation * list)
Packit Service 963350
{
Packit Service 963350
  GstIndexEntry *entry;
Packit Service 963350
Packit Service 963350
  g_return_val_if_fail (n > 0, NULL);
Packit Service 963350
  g_return_val_if_fail (list != NULL, NULL);
Packit Service 963350
  g_return_val_if_fail (GST_IS_INDEX (index), NULL);
Packit Service 963350
Packit Service 963350
  if (!GST_INDEX_IS_WRITABLE (index) || id == -1)
Packit Service 963350
    return NULL;
Packit Service 963350
Packit Service 963350
  entry = g_slice_new (GstIndexEntry);
Packit Service 963350
Packit Service 963350
  entry->type = GST_INDEX_ENTRY_ASSOCIATION;
Packit Service 963350
  entry->id = id;
Packit Service 963350
  entry->data.assoc.flags = flags;
Packit Service 963350
  entry->data.assoc.assocs = g_memdup (list, sizeof (GstIndexAssociation) * n);
Packit Service 963350
  entry->data.assoc.nassocs = n;
Packit Service 963350
Packit Service 963350
  gst_index_add_entry (index, entry);
Packit Service 963350
Packit Service 963350
  return entry;
Packit Service 963350
}
Packit Service 963350
Packit Service 963350
#if 0
Packit Service 963350
/**
Packit Service 963350
 * gst_index_add_association:
Packit Service 963350
 * @index: the index to add the entry to
Packit Service 963350
 * @id: the id of the index writer
Packit Service 963350
 * @flags: optinal flags for this entry
Packit Service 963350
 * @format: the format of the value
Packit Service 963350
 * @value: the value
Packit Service 963350
 * @...: other format/value pairs or 0 to end the list
Packit Service 963350
 *
Packit Service 963350
 * Associate given format/value pairs with each other.
Packit Service 963350
 * Be sure to pass gint64 values to this functions varargs,
Packit Service 963350
 * you might want to use a gint64 cast to be sure.
Packit Service 963350
 *
Packit Service 963350
 * Returns: a pointer to the newly added entry in the index.
Packit Service 963350
 */
Packit Service 963350
GstIndexEntry *
Packit Service 963350
gst_index_add_association (GstIndex * index, gint id,
Packit Service 963350
    GstIndexAssociationFlags flags, GstFormat format, gint64 value, ...)
Packit Service 963350
{
Packit Service 963350
  va_list args;
Packit Service 963350
  GstIndexEntry *entry;
Packit Service 963350
  GstIndexAssociation *list;
Packit Service 963350
  gint n_assocs = 0;
Packit Service 963350
  GstFormat cur_format;
Packit Service 963350
  GArray *array;
Packit Service 963350
Packit Service 963350
  g_return_val_if_fail (GST_IS_INDEX (index), NULL);
Packit Service 963350
  g_return_val_if_fail (format != 0, NULL);
Packit Service 963350
Packit Service 963350
  if (!GST_INDEX_IS_WRITABLE (index) || id == -1)
Packit Service 963350
    return NULL;
Packit Service 963350
Packit Service 963350
  array = g_array_new (FALSE, FALSE, sizeof (GstIndexAssociation));
Packit Service 963350
Packit Service 963350
  {
Packit Service 963350
    GstIndexAssociation a;
Packit Service 963350
Packit Service 963350
    a.format = format;
Packit Service 963350
    a.value = value;
Packit Service 963350
    n_assocs = 1;
Packit Service 963350
    g_array_append_val (array, a);
Packit Service 963350
  }
Packit Service 963350
Packit Service 963350
  va_start (args, value);
Packit Service 963350
Packit Service 963350
  while ((cur_format = va_arg (args, GstFormat))) {
Packit Service 963350
    GstIndexAssociation a;
Packit Service 963350
Packit Service 963350
    a.format = cur_format;
Packit Service 963350
    a.value = va_arg (args, gint64);
Packit Service 963350
    n_assocs++;
Packit Service 963350
    g_array_append_val (array, a);
Packit Service 963350
  }
Packit Service 963350
Packit Service 963350
  va_end (args);
Packit Service 963350
Packit Service 963350
  list = (GstIndexAssociation *) g_array_free (array, FALSE);
Packit Service 963350
Packit Service 963350
  entry = gst_index_add_associationv (index, id, flags, n_assocs, list);
Packit Service 963350
  g_free (list);
Packit Service 963350
Packit Service 963350
  return entry;
Packit Service 963350
}
Packit Service 963350
Packit Service 963350
/**
Packit Service 963350
 * gst_index_add_object:
Packit Service 963350
 * @index: the index to add the object to
Packit Service 963350
 * @id: the id of the index writer
Packit Service 963350
 * @key: a key for the object
Packit Service 963350
 * @type: the GType of the object
Packit Service 963350
 * @object: a pointer to the object to add
Packit Service 963350
 *
Packit Service 963350
 * Add the given object to the index with the given key.
Packit Service 963350
 *
Packit Service 963350
 * This function is not yet implemented.
Packit Service 963350
 *
Packit Service 963350
 * Returns: a pointer to the newly added entry in the index.
Packit Service 963350
 */
Packit Service 963350
GstIndexEntry *
Packit Service 963350
gst_index_add_object (GstIndex * index, gint id, gchar * key,
Packit Service 963350
    GType type, gpointer object)
Packit Service 963350
{
Packit Service 963350
  if (!GST_INDEX_IS_WRITABLE (index) || id == -1)
Packit Service 963350
    return NULL;
Packit Service 963350
Packit Service 963350
  return NULL;
Packit Service 963350
}
Packit Service 963350
#endif
Packit Service 963350
Packit Service 963350
static gint
Packit Service 963350
gst_index_compare_func (gconstpointer a, gconstpointer b, gpointer user_data)
Packit Service 963350
{
Packit Service 963350
  if (a < b)
Packit Service 963350
    return -1;
Packit Service 963350
  if (a > b)
Packit Service 963350
    return 1;
Packit Service 963350
  return 0;
Packit Service 963350
}
Packit Service 963350
Packit Service 963350
/**
Packit Service 963350
 * gst_index_get_assoc_entry:
Packit Service 963350
 * @index: the index to search
Packit Service 963350
 * @id: the id of the index writer
Packit Service 963350
 * @method: The lookup method to use
Packit Service 963350
 * @flags: Flags for the entry
Packit Service 963350
 * @format: the format of the value
Packit Service 963350
 * @value: the value to find
Packit Service 963350
 *
Packit Service 963350
 * Finds the given format/value in the index
Packit Service 963350
 *
Packit Service 963350
 * Returns: (nullable): the entry associated with the value or %NULL if the
Packit Service 963350
 *   value was not found.
Packit Service 963350
 */
Packit Service 963350
GstIndexEntry *
Packit Service 963350
gst_index_get_assoc_entry (GstIndex * index, gint id,
Packit Service 963350
    GstIndexLookupMethod method, GstIndexAssociationFlags flags,
Packit Service 963350
    GstFormat format, gint64 value)
Packit Service 963350
{
Packit Service 963350
  g_return_val_if_fail (GST_IS_INDEX (index), NULL);
Packit Service 963350
Packit Service 963350
  if (id == -1)
Packit Service 963350
    return NULL;
Packit Service 963350
Packit Service 963350
  return gst_index_get_assoc_entry_full (index, id, method, flags, format,
Packit Service 963350
      value, gst_index_compare_func, NULL);
Packit Service 963350
}
Packit Service 963350
Packit Service 963350
/**
Packit Service 963350
 * gst_index_get_assoc_entry_full:
Packit Service 963350
 * @index: the index to search
Packit Service 963350
 * @id: the id of the index writer
Packit Service 963350
 * @method: The lookup method to use
Packit Service 963350
 * @flags: Flags for the entry
Packit Service 963350
 * @format: the format of the value
Packit Service 963350
 * @value: the value to find
Packit Service 963350
 * @func: the function used to compare entries
Packit Service 963350
 * @user_data: user data passed to the compare function
Packit Service 963350
 *
Packit Service 963350
 * Finds the given format/value in the index with the given
Packit Service 963350
 * compare function and user_data.
Packit Service 963350
 *
Packit Service 963350
 * Returns: (nullable): the entry associated with the value or %NULL if the
Packit Service 963350
 *   value was not found.
Packit Service 963350
 */
Packit Service 963350
GstIndexEntry *
Packit Service 963350
gst_index_get_assoc_entry_full (GstIndex * index, gint id,
Packit Service 963350
    GstIndexLookupMethod method, GstIndexAssociationFlags flags,
Packit Service 963350
    GstFormat format, gint64 value, GCompareDataFunc func, gpointer user_data)
Packit Service 963350
{
Packit Service 963350
  GstIndexClass *iclass;
Packit Service 963350
Packit Service 963350
  g_return_val_if_fail (GST_IS_INDEX (index), NULL);
Packit Service 963350
Packit Service 963350
  if (id == -1)
Packit Service 963350
    return NULL;
Packit Service 963350
Packit Service 963350
  iclass = GST_INDEX_GET_CLASS (index);
Packit Service 963350
Packit Service 963350
  if (iclass->get_assoc_entry)
Packit Service 963350
    return iclass->get_assoc_entry (index, id, method, flags, format, value,
Packit Service 963350
        func, user_data);
Packit Service 963350
Packit Service 963350
  return NULL;
Packit Service 963350
}
Packit Service 963350
Packit Service 963350
/**
Packit Service 963350
 * gst_index_entry_assoc_map:
Packit Service 963350
 * @entry: the index to search
Packit Service 963350
 * @format: the format of the value the find
Packit Service 963350
 * @value: a pointer to store the value
Packit Service 963350
 *
Packit Service 963350
 * Gets alternative formats associated with the indexentry.
Packit Service 963350
 *
Packit Service 963350
 * Returns: %TRUE if there was a value associated with the given
Packit Service 963350
 * format.
Packit Service 963350
 */
Packit Service 963350
gboolean
Packit Service 963350
gst_index_entry_assoc_map (GstIndexEntry * entry,
Packit Service 963350
    GstFormat format, gint64 * value)
Packit Service 963350
{
Packit Service 963350
  gint i;
Packit Service 963350
Packit Service 963350
  g_return_val_if_fail (entry != NULL, FALSE);
Packit Service 963350
  g_return_val_if_fail (value != NULL, FALSE);
Packit Service 963350
Packit Service 963350
  for (i = 0; i < GST_INDEX_NASSOCS (entry); i++) {
Packit Service 963350
    if (GST_INDEX_ASSOC_FORMAT (entry, i) == format) {
Packit Service 963350
      *value = GST_INDEX_ASSOC_VALUE (entry, i);
Packit Service 963350
      return TRUE;
Packit Service 963350
    }
Packit Service 963350
  }
Packit Service 963350
  return FALSE;
Packit Service 963350
}