2002-12-12 22:14:36 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
#include <gst/gst.h>
|
2002-12-12 22:14:36 +00:00
|
|
|
|
2010-03-02 21:58:06 +00:00
|
|
|
#include "gstindexers.h"
|
|
|
|
|
2005-12-06 19:29:15 +00:00
|
|
|
#define GST_TYPE_MEM_INDEX \
|
2002-12-12 22:14:36 +00:00
|
|
|
(gst_index_get_type ())
|
2005-12-06 19:29:15 +00:00
|
|
|
#define GST_MEM_INDEX(obj) \
|
2002-12-12 22:14:36 +00:00
|
|
|
(G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_MEM_INDEX, GstMemIndex))
|
2005-12-06 19:29:15 +00:00
|
|
|
#define GST_MEM_INDEX_CLASS(klass) \
|
2002-12-12 22:14:36 +00:00
|
|
|
(G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_MEM_INDEX, GstMemIndexClass))
|
2005-12-06 19:29:15 +00:00
|
|
|
#define GST_IS_MEM_INDEX(obj) \
|
2002-12-12 22:14:36 +00:00
|
|
|
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_MEM_INDEX))
|
2006-06-01 18:22:14 +00:00
|
|
|
#define GST_IS_MEM_INDEX_CLASS(klass) \
|
2002-12-12 22:14:36 +00:00
|
|
|
(GST_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_MEM_INDEX))
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2002-12-12 22:14:36 +00:00
|
|
|
/*
|
|
|
|
* Object model:
|
|
|
|
*
|
|
|
|
* All entries are simply added to a GList first. Then we build
|
|
|
|
* an index to each entry for each id/format
|
2005-10-15 15:30:24 +00:00
|
|
|
*
|
2002-12-12 22:14:36 +00:00
|
|
|
*
|
|
|
|
* memindex
|
|
|
|
* -----------------------------...
|
2005-10-15 15:30:24 +00:00
|
|
|
* ! !
|
|
|
|
* id1 id2
|
2002-12-12 22:14:36 +00:00
|
|
|
* ------------
|
|
|
|
* ! !
|
|
|
|
* format1 format2
|
|
|
|
* ! !
|
|
|
|
* GTree GTree
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* The memindex creates a MemIndexId object for each writer id, a
|
|
|
|
* Hashtable is kept to map the id to the MemIndexId
|
|
|
|
*
|
|
|
|
* The MemIndexId keeps a MemIndexFormatIndex for each format the
|
|
|
|
* specific writer wants indexed.
|
|
|
|
*
|
2005-10-15 15:30:24 +00:00
|
|
|
* The MemIndexFormatIndex keeps all the values of the particular
|
|
|
|
* format in a GTree, The values of the GTree point back to the entry.
|
2002-12-12 22:14:36 +00:00
|
|
|
*
|
|
|
|
* Finding a value for an id/format requires locating the correct GTree,
|
|
|
|
* then do a lookup in the Tree to get the required value.
|
|
|
|
*/
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GstFormat format;
|
|
|
|
gint offset;
|
|
|
|
GTree *tree;
|
2004-03-15 19:27:17 +00:00
|
|
|
}
|
|
|
|
GstMemIndexFormatIndex;
|
2002-12-12 22:14:36 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
gint id;
|
|
|
|
GHashTable *format_index;
|
2004-03-15 19:27:17 +00:00
|
|
|
}
|
|
|
|
GstMemIndexId;
|
2002-12-12 22:14:36 +00:00
|
|
|
|
|
|
|
typedef struct _GstMemIndex GstMemIndex;
|
|
|
|
typedef struct _GstMemIndexClass GstMemIndexClass;
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
struct _GstMemIndex
|
|
|
|
{
|
|
|
|
GstIndex parent;
|
2002-12-12 22:14:36 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
GList *associations;
|
2002-12-12 22:14:36 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
GHashTable *id_index;
|
2002-12-12 22:14:36 +00:00
|
|
|
};
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
struct _GstMemIndexClass
|
|
|
|
{
|
2002-12-12 22:14:36 +00:00
|
|
|
GstIndexClass parent_class;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Index signals and args */
|
2004-03-13 15:27:01 +00:00
|
|
|
enum
|
|
|
|
{
|
2002-12-12 22:14:36 +00:00
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
enum
|
|
|
|
{
|
2002-12-12 22:14:36 +00:00
|
|
|
ARG_0,
|
|
|
|
/* FILL ME */
|
|
|
|
};
|
|
|
|
|
2008-02-01 16:37:22 +00:00
|
|
|
static void gst_mem_index_finalize (GObject * object);
|
2002-12-12 22:14:36 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
static void gst_mem_index_add_entry (GstIndex * index, GstIndexEntry * entry);
|
|
|
|
static GstIndexEntry *gst_mem_index_get_assoc_entry (GstIndex * index, gint id,
|
|
|
|
GstIndexLookupMethod method, GstAssocFlags flags,
|
|
|
|
GstFormat format, gint64 value, GCompareDataFunc func, gpointer user_data);
|
2002-12-12 22:14:36 +00:00
|
|
|
|
|
|
|
#define CLASS(mem_index) GST_MEM_INDEX_CLASS (G_OBJECT_GET_CLASS (mem_index))
|
|
|
|
|
|
|
|
/*static guint gst_mem_index_signals[LAST_SIGNAL] = { 0 }; */
|
|
|
|
|
2010-08-06 17:34:42 +00:00
|
|
|
GType gst_mem_index_get_type (void);
|
|
|
|
|
2010-07-20 14:23:54 +00:00
|
|
|
G_DEFINE_TYPE (GstMemIndex, gst_mem_index, GST_TYPE_INDEX);
|
2002-12-12 22:14:36 +00:00
|
|
|
|
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_mem_index_class_init (GstMemIndexClass * klass)
|
2002-12-12 22:14:36 +00:00
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
|
|
|
GstIndexClass *gstindex_class;
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
gobject_class = (GObjectClass *) klass;
|
|
|
|
gstindex_class = (GstIndexClass *) klass;
|
2002-12-12 22:14:36 +00:00
|
|
|
|
2009-10-28 00:29:30 +00:00
|
|
|
gobject_class->finalize = gst_mem_index_finalize;
|
2002-12-12 22:14:36 +00:00
|
|
|
|
2008-02-01 16:37:22 +00:00
|
|
|
gstindex_class->add_entry = GST_DEBUG_FUNCPTR (gst_mem_index_add_entry);
|
|
|
|
gstindex_class->get_assoc_entry =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_mem_index_get_assoc_entry);
|
2002-12-12 22:14:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_mem_index_init (GstMemIndex * index)
|
2002-12-12 22:14:36 +00:00
|
|
|
{
|
2004-03-13 15:27:01 +00:00
|
|
|
GST_DEBUG ("created new mem index");
|
2002-12-12 22:14:36 +00:00
|
|
|
|
|
|
|
index->associations = NULL;
|
|
|
|
index->id_index = g_hash_table_new (g_int_hash, g_int_equal);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-02-01 16:37:22 +00:00
|
|
|
gst_mem_index_free_format (gpointer key, gpointer value, gpointer user_data)
|
2002-12-12 22:14:36 +00:00
|
|
|
{
|
2008-02-01 16:37:22 +00:00
|
|
|
GstMemIndexFormatIndex *index = (GstMemIndexFormatIndex *) value;
|
2002-12-12 22:14:36 +00:00
|
|
|
|
2008-02-01 16:37:22 +00:00
|
|
|
if (index->tree) {
|
|
|
|
g_tree_destroy (index->tree);
|
|
|
|
}
|
|
|
|
|
2008-04-03 07:52:31 +00:00
|
|
|
g_slice_free (GstMemIndexFormatIndex, index);
|
2008-02-01 16:37:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_mem_index_free_id (gpointer key, gpointer value, gpointer user_data)
|
|
|
|
{
|
|
|
|
GstMemIndexId *id_index = (GstMemIndexId *) value;
|
|
|
|
|
|
|
|
if (id_index->format_index) {
|
|
|
|
g_hash_table_foreach (id_index->format_index, gst_mem_index_free_format,
|
|
|
|
NULL);
|
|
|
|
g_hash_table_destroy (id_index->format_index);
|
|
|
|
id_index->format_index = NULL;
|
|
|
|
}
|
|
|
|
|
2008-04-03 07:52:31 +00:00
|
|
|
g_slice_free (GstMemIndexId, id_index);
|
2008-02-01 16:37:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_mem_index_finalize (GObject * object)
|
|
|
|
{
|
|
|
|
GstMemIndex *memindex = GST_MEM_INDEX (object);
|
|
|
|
|
|
|
|
/* Delete the trees referencing the associations first */
|
|
|
|
if (memindex->id_index) {
|
|
|
|
g_hash_table_foreach (memindex->id_index, gst_mem_index_free_id, NULL);
|
|
|
|
g_hash_table_destroy (memindex->id_index);
|
|
|
|
memindex->id_index = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Then delete the associations themselves */
|
|
|
|
if (memindex->associations) {
|
|
|
|
g_list_foreach (memindex->associations, (GFunc) gst_index_entry_free, NULL);
|
|
|
|
g_list_free (memindex->associations);
|
|
|
|
memindex->associations = NULL;
|
|
|
|
}
|
|
|
|
|
2010-08-06 17:34:42 +00:00
|
|
|
G_OBJECT_CLASS (gst_mem_index_parent_class)->finalize (object);
|
2002-12-12 22:14:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_mem_index_add_id (GstIndex * index, GstIndexEntry * entry)
|
2002-12-12 22:14:36 +00:00
|
|
|
{
|
|
|
|
GstMemIndex *memindex = GST_MEM_INDEX (index);
|
|
|
|
GstMemIndexId *id_index;
|
|
|
|
|
|
|
|
id_index = g_hash_table_lookup (memindex->id_index, &entry->id);
|
|
|
|
|
|
|
|
if (!id_index) {
|
2008-04-03 07:52:31 +00:00
|
|
|
id_index = g_slice_new0 (GstMemIndexId);
|
2002-12-12 22:14:36 +00:00
|
|
|
|
|
|
|
id_index->id = entry->id;
|
|
|
|
id_index->format_index = g_hash_table_new (g_int_hash, g_int_equal);
|
2003-01-05 16:51:46 +00:00
|
|
|
g_hash_table_insert (memindex->id_index, &id_index->id, id_index);
|
2002-12-12 22:14:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
2004-03-13 15:27:01 +00:00
|
|
|
mem_index_compare (gconstpointer a, gconstpointer b, gpointer user_data)
|
2002-12-12 22:14:36 +00:00
|
|
|
{
|
|
|
|
GstMemIndexFormatIndex *index = user_data;
|
|
|
|
gint64 val1, val2;
|
|
|
|
gint64 diff;
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
val1 = GST_INDEX_ASSOC_VALUE (((GstIndexEntry *) a), index->offset);
|
|
|
|
val2 = GST_INDEX_ASSOC_VALUE (((GstIndexEntry *) b), index->offset);
|
|
|
|
|
2002-12-12 22:14:36 +00:00
|
|
|
diff = (val2 - val1);
|
|
|
|
|
|
|
|
return (diff == 0 ? 0 : (diff > 0 ? 1 : -1));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_mem_index_index_format (GstMemIndexId * id_index, GstIndexEntry * entry,
|
|
|
|
gint assoc)
|
2002-12-12 22:14:36 +00:00
|
|
|
{
|
|
|
|
GstMemIndexFormatIndex *index;
|
|
|
|
GstFormat *format;
|
|
|
|
|
|
|
|
format = &GST_INDEX_ASSOC_FORMAT (entry, assoc);
|
|
|
|
|
|
|
|
index = g_hash_table_lookup (id_index->format_index, format);
|
|
|
|
|
|
|
|
if (!index) {
|
2008-04-03 07:52:31 +00:00
|
|
|
index = g_slice_new0 (GstMemIndexFormatIndex);
|
2002-12-12 22:14:36 +00:00
|
|
|
|
|
|
|
index->format = *format;
|
|
|
|
index->offset = assoc;
|
|
|
|
index->tree = g_tree_new_with_data (mem_index_compare, index);
|
|
|
|
|
2003-01-05 16:51:46 +00:00
|
|
|
g_hash_table_insert (id_index->format_index, &index->format, index);
|
2002-12-12 22:14:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
g_tree_insert (index->tree, entry, entry);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_mem_index_add_association (GstIndex * index, GstIndexEntry * entry)
|
2002-12-12 22:14:36 +00:00
|
|
|
{
|
|
|
|
GstMemIndex *memindex = GST_MEM_INDEX (index);
|
|
|
|
GstMemIndexId *id_index;
|
|
|
|
|
|
|
|
memindex->associations = g_list_prepend (memindex->associations, entry);
|
|
|
|
|
|
|
|
id_index = g_hash_table_lookup (memindex->id_index, &entry->id);
|
|
|
|
if (id_index) {
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
for (i = 0; i < GST_INDEX_NASSOCS (entry); i++) {
|
|
|
|
gst_mem_index_index_format (id_index, entry, i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_mem_index_add_object (GstIndex * index, GstIndexEntry * entry)
|
2002-12-12 22:14:36 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_mem_index_add_format (GstIndex * index, GstIndexEntry * entry)
|
2002-12-12 22:14:36 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_mem_index_add_entry (GstIndex * index, GstIndexEntry * entry)
|
2002-12-12 22:14:36 +00:00
|
|
|
{
|
2003-06-29 14:05:49 +00:00
|
|
|
GST_LOG_OBJECT (index, "added this entry");
|
2002-12-12 22:14:36 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
switch (entry->type) {
|
|
|
|
case GST_INDEX_ENTRY_ID:
|
|
|
|
gst_mem_index_add_id (index, entry);
|
|
|
|
break;
|
|
|
|
case GST_INDEX_ENTRY_ASSOCIATION:
|
|
|
|
gst_mem_index_add_association (index, entry);
|
|
|
|
break;
|
|
|
|
case GST_INDEX_ENTRY_OBJECT:
|
|
|
|
gst_mem_index_add_object (index, entry);
|
|
|
|
break;
|
|
|
|
case GST_INDEX_ENTRY_FORMAT:
|
|
|
|
gst_mem_index_add_format (index, entry);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2002-12-12 22:14:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
gint64 value;
|
2002-12-12 22:14:36 +00:00
|
|
|
GstMemIndexFormatIndex *index;
|
2004-03-13 15:27:01 +00:00
|
|
|
gboolean exact;
|
|
|
|
GstIndexEntry *lower;
|
|
|
|
gint64 low_diff;
|
|
|
|
GstIndexEntry *higher;
|
|
|
|
gint64 high_diff;
|
2004-03-15 19:27:17 +00:00
|
|
|
}
|
|
|
|
GstMemIndexSearchData;
|
2002-12-12 22:14:36 +00:00
|
|
|
|
|
|
|
static gint
|
2004-03-13 15:27:01 +00:00
|
|
|
mem_index_search (gconstpointer a, gconstpointer b)
|
2002-12-12 22:14:36 +00:00
|
|
|
{
|
|
|
|
GstMemIndexSearchData *data = (GstMemIndexSearchData *) b;
|
|
|
|
GstMemIndexFormatIndex *index = data->index;
|
|
|
|
gint64 val1, val2;
|
|
|
|
gint64 diff;
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
val1 = GST_INDEX_ASSOC_VALUE (((GstIndexEntry *) a), index->offset);
|
2002-12-12 22:14:36 +00:00
|
|
|
val2 = data->value;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2002-12-12 22:14:36 +00:00
|
|
|
diff = (val1 - val2);
|
|
|
|
if (diff == 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* exact matching, don't update low/high */
|
|
|
|
if (data->exact)
|
|
|
|
return (diff > 0 ? 1 : -1);
|
|
|
|
|
|
|
|
if (diff < 0) {
|
|
|
|
if (diff > data->low_diff) {
|
|
|
|
data->low_diff = diff;
|
|
|
|
data->lower = (GstIndexEntry *) a;
|
|
|
|
}
|
|
|
|
diff = -1;
|
2004-03-13 15:27:01 +00:00
|
|
|
} else {
|
2002-12-12 22:14:36 +00:00
|
|
|
if (diff < data->high_diff) {
|
|
|
|
data->high_diff = diff;
|
|
|
|
data->higher = (GstIndexEntry *) a;
|
|
|
|
}
|
|
|
|
diff = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return diff;
|
|
|
|
}
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
static GstIndexEntry *
|
|
|
|
gst_mem_index_get_assoc_entry (GstIndex * index, gint id,
|
|
|
|
GstIndexLookupMethod method,
|
|
|
|
GstAssocFlags flags,
|
|
|
|
GstFormat format, gint64 value, GCompareDataFunc func, gpointer user_data)
|
2002-12-12 22:14:36 +00:00
|
|
|
{
|
|
|
|
GstMemIndex *memindex = GST_MEM_INDEX (index);
|
|
|
|
GstMemIndexId *id_index;
|
|
|
|
GstMemIndexFormatIndex *format_index;
|
|
|
|
GstIndexEntry *entry;
|
|
|
|
GstMemIndexSearchData data;
|
|
|
|
|
|
|
|
id_index = g_hash_table_lookup (memindex->id_index, &id);
|
|
|
|
if (!id_index)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
format_index = g_hash_table_lookup (id_index->format_index, &format);
|
|
|
|
if (!format_index)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
data.value = value;
|
|
|
|
data.index = format_index;
|
|
|
|
data.exact = (method == GST_INDEX_LOOKUP_EXACT);
|
|
|
|
|
2005-10-15 15:30:24 +00:00
|
|
|
/* setup data for low/high checks if we are not looking
|
2002-12-12 22:14:36 +00:00
|
|
|
* for an exact match */
|
|
|
|
if (!data.exact) {
|
|
|
|
data.low_diff = G_MININT64;
|
|
|
|
data.lower = NULL;
|
|
|
|
data.high_diff = G_MAXINT64;
|
|
|
|
data.higher = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
entry = g_tree_search (format_index->tree, mem_index_search, &data);
|
|
|
|
|
|
|
|
/* get the low/high values if we're not exact */
|
2004-03-13 15:27:01 +00:00
|
|
|
if (entry == NULL && !data.exact) {
|
2002-12-12 22:14:36 +00:00
|
|
|
if (method == GST_INDEX_LOOKUP_BEFORE)
|
|
|
|
entry = data.lower;
|
|
|
|
else if (method == GST_INDEX_LOOKUP_AFTER) {
|
|
|
|
entry = data.higher;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-02-18 16:15:35 +00:00
|
|
|
if (entry && ((GST_INDEX_ASSOC_FLAGS (entry) & flags) != flags)) {
|
|
|
|
if (method != GST_INDEX_LOOKUP_EXACT) {
|
2002-12-26 22:35:58 +00:00
|
|
|
GList *l_entry = g_list_find (memindex->associations, entry);
|
|
|
|
|
|
|
|
entry = NULL;
|
|
|
|
|
|
|
|
while (l_entry) {
|
2004-03-15 19:27:17 +00:00
|
|
|
entry = (GstIndexEntry *) l_entry->data;
|
2002-12-26 22:35:58 +00:00
|
|
|
|
2004-03-15 19:27:17 +00:00
|
|
|
if (entry->id == id && (GST_INDEX_ASSOC_FLAGS (entry) & flags) == flags)
|
|
|
|
break;
|
2002-12-26 22:35:58 +00:00
|
|
|
|
2004-03-15 19:27:17 +00:00
|
|
|
if (method == GST_INDEX_LOOKUP_BEFORE)
|
|
|
|
l_entry = g_list_next (l_entry);
|
|
|
|
else if (method == GST_INDEX_LOOKUP_AFTER) {
|
|
|
|
l_entry = g_list_previous (l_entry);
|
|
|
|
}
|
2002-12-26 22:35:58 +00:00
|
|
|
}
|
2010-02-18 16:15:35 +00:00
|
|
|
} else {
|
|
|
|
entry = NULL;
|
2002-12-26 22:35:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-12-12 22:14:36 +00:00
|
|
|
return entry;
|
|
|
|
}
|
|
|
|
|
2003-01-04 16:26:58 +00:00
|
|
|
gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_mem_index_plugin_init (GstPlugin * plugin)
|
2002-12-12 22:14:36 +00:00
|
|
|
{
|
|
|
|
GstIndexFactory *factory;
|
|
|
|
|
|
|
|
factory = gst_index_factory_new ("memindex",
|
2004-03-13 15:27:01 +00:00
|
|
|
"A index that stores entries in memory", gst_mem_index_get_type ());
|
2002-12-12 22:14:36 +00:00
|
|
|
|
2005-09-18 06:59:25 +00:00
|
|
|
if (factory == NULL) {
|
|
|
|
g_warning ("failed to create memindex factory");
|
|
|
|
return FALSE;
|
2002-12-12 22:14:36 +00:00
|
|
|
}
|
2005-09-18 06:59:25 +00:00
|
|
|
|
|
|
|
GST_PLUGIN_FEATURE (factory)->plugin_name = g_strdup (plugin->desc.name);
|
|
|
|
GST_PLUGIN_FEATURE (factory)->loaded = TRUE;
|
|
|
|
|
|
|
|
gst_registry_add_feature (gst_registry_get_default (),
|
|
|
|
GST_PLUGIN_FEATURE (factory));
|
|
|
|
|
2002-12-12 22:14:36 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|