mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-31 03:29:50 +00:00
Renamed GstCache to GstIndex
Original commit message from CVS: Renamed GstCache to GstIndex
This commit is contained in:
parent
dc9aaf7da4
commit
fcd8d12069
16 changed files with 871 additions and 1365 deletions
|
@ -464,7 +464,7 @@ include/Makefile
|
|||
gst/Makefile
|
||||
gst/gstversion.h
|
||||
gst/autoplug/Makefile
|
||||
gst/caches/Makefile
|
||||
gst/indexers/Makefile
|
||||
gst/elements/Makefile
|
||||
gst/parse/Makefile
|
||||
gst/schedulers/Makefile
|
||||
|
@ -486,6 +486,7 @@ tests/sched/Makefile
|
|||
tests/threadstate/Makefile
|
||||
testsuite/Makefile
|
||||
testsuite/bytestream/Makefile
|
||||
testsuite/indexers/Makefile
|
||||
testsuite/caps/Makefile
|
||||
testsuite/cleanup/Makefile
|
||||
testsuite/clock/Makefile
|
||||
|
|
|
@ -43,8 +43,8 @@ endif
|
|||
|
||||
EXTRA_libgstreamer_@GST_MAJORMINOR@_la_SOURCES = gstcpuid_i386.s gstmarshal.list gstxml.c gsttypefind.c gstparse.c gstautoplug.c gsttrace.c
|
||||
|
||||
SUBDIRS = parse registries . $(GST_AUTOPLUG_DIRS) elements schedulers types caches
|
||||
DIST_SUBDIRS = autoplug elements parse registries schedulers types caches
|
||||
SUBDIRS = parse registries . $(GST_AUTOPLUG_DIRS) elements schedulers types indexers
|
||||
DIST_SUBDIRS = autoplug elements parse registries schedulers types indexers
|
||||
|
||||
libgstreamer_@GST_MAJORMINOR@_la_SOURCES = \
|
||||
gst.c \
|
||||
|
@ -55,7 +55,6 @@ libgstreamer_@GST_MAJORMINOR@_la_SOURCES = \
|
|||
gstbin.c \
|
||||
gstbuffer.c \
|
||||
gstbufferpool-default.c \
|
||||
gstcache.c \
|
||||
gstcaps.c \
|
||||
gstclock.c \
|
||||
gstcpu.c \
|
||||
|
@ -65,6 +64,7 @@ libgstreamer_@GST_MAJORMINOR@_la_SOURCES = \
|
|||
gstevent.c \
|
||||
gstextratypes.c \
|
||||
gstformat.c \
|
||||
gstindex.c \
|
||||
gstinfo.c \
|
||||
gstmemchunk.c \
|
||||
gstpad.c \
|
||||
|
@ -111,7 +111,6 @@ gst_headers = \
|
|||
gstbin.h \
|
||||
gstbuffer.h \
|
||||
gstbufferpool-default.h \
|
||||
gstcache.h \
|
||||
gstcaps.h \
|
||||
gstclock.h \
|
||||
gstcpu.h \
|
||||
|
@ -120,6 +119,7 @@ gst_headers = \
|
|||
gstevent.h \
|
||||
gstextratypes.h \
|
||||
gstformat.h \
|
||||
gstindex.h \
|
||||
gstinfo.h \
|
||||
gstlog.h \
|
||||
gstmacros.h \
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
plugindir = $(libdir)/gstreamer-@GST_MAJORMINOR@
|
||||
|
||||
plugin_LTLIBRARIES = libgstcaches.la
|
||||
|
||||
libgstcaches_la_SOURCES = gstmemcache.c
|
||||
libgstcaches_la_CFLAGS = $(GST_CFLAGS)
|
||||
libgstcaches_la_LIBADD =
|
||||
libgstcaches_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
|
|
@ -1,407 +0,0 @@
|
|||
/* 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.
|
||||
*/
|
||||
|
||||
#include <gst/gst_private.h>
|
||||
#include <gst/gstversion.h>
|
||||
#include <gst/gstplugin.h>
|
||||
#include <gst/gstcache.h>
|
||||
|
||||
#define GST_TYPE_MEM_CACHE \
|
||||
(gst_cache_get_type ())
|
||||
#define GST_MEM_CACHE(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_MEM_CACHE, GstMemCache))
|
||||
#define GST_MEM_CACHE_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_MEM_CACHE, GstMemCacheClass))
|
||||
#define GST_IS_MEM_CACHE(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_MEM_CACHE))
|
||||
#define GST_IS_MEM_CACHE_CLASS(obj) \
|
||||
(GST_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_MEM_CACHE))
|
||||
|
||||
/*
|
||||
* Object model:
|
||||
*
|
||||
* All entries are simply added to a GList first. Then we build
|
||||
* an index to each entry for each id/format
|
||||
*
|
||||
*
|
||||
* memcache
|
||||
* -----------------------------...
|
||||
* ! !
|
||||
* id1 id2
|
||||
* ------------
|
||||
* ! !
|
||||
* format1 format2
|
||||
* ! !
|
||||
* GTree GTree
|
||||
*
|
||||
*
|
||||
* The memcache creates a MemCacheId object for each writer id, a
|
||||
* Hashtable is kept to map the id to the MemCacheId
|
||||
*
|
||||
* The MemCacheId keeps a MemCacheFormatIndex for each format the
|
||||
* specific writer wants indexed.
|
||||
*
|
||||
* The MemCacheFormatIndex keeps all the values of the particular
|
||||
* format in a GTree, The values of the GTree point back to the entry.
|
||||
*
|
||||
* Finding a value for an id/format requires locating the correct GTree,
|
||||
* then do a lookup in the Tree to get the required value.
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
GstFormat format;
|
||||
gint offset;
|
||||
GTree *tree;
|
||||
} GstMemCacheFormatIndex;
|
||||
|
||||
typedef struct {
|
||||
gint id;
|
||||
GHashTable *format_index;
|
||||
} GstMemCacheId;
|
||||
|
||||
typedef struct _GstMemCache GstMemCache;
|
||||
typedef struct _GstMemCacheClass GstMemCacheClass;
|
||||
|
||||
struct _GstMemCache {
|
||||
GstCache parent;
|
||||
|
||||
GList *associations;
|
||||
|
||||
GHashTable *id_index;
|
||||
};
|
||||
|
||||
struct _GstMemCacheClass {
|
||||
GstCacheClass parent_class;
|
||||
};
|
||||
|
||||
/* Cache signals and args */
|
||||
enum {
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
enum {
|
||||
ARG_0,
|
||||
/* FILL ME */
|
||||
};
|
||||
|
||||
static void gst_mem_cache_class_init (GstMemCacheClass *klass);
|
||||
static void gst_mem_cache_init (GstMemCache *cache);
|
||||
static void gst_mem_cache_dispose (GObject *object);
|
||||
|
||||
static void gst_mem_cache_add_entry (GstCache *cache, GstCacheEntry *entry);
|
||||
static GstCacheEntry* gst_mem_cache_get_assoc_entry (GstCache *cache, gint id,
|
||||
GstCacheLookupMethod method,
|
||||
GstFormat format, gint64 value,
|
||||
GCompareDataFunc func,
|
||||
gpointer user_data);
|
||||
|
||||
#define CLASS(mem_cache) GST_MEM_CACHE_CLASS (G_OBJECT_GET_CLASS (mem_cache))
|
||||
|
||||
static GstCache *parent_class = NULL;
|
||||
/*static guint gst_mem_cache_signals[LAST_SIGNAL] = { 0 }; */
|
||||
|
||||
GType
|
||||
gst_mem_cache_get_type(void) {
|
||||
static GType mem_cache_type = 0;
|
||||
|
||||
if (!mem_cache_type) {
|
||||
static const GTypeInfo mem_cache_info = {
|
||||
sizeof(GstMemCacheClass),
|
||||
NULL,
|
||||
NULL,
|
||||
(GClassInitFunc)gst_mem_cache_class_init,
|
||||
NULL,
|
||||
NULL,
|
||||
sizeof(GstMemCache),
|
||||
1,
|
||||
(GInstanceInitFunc)gst_mem_cache_init,
|
||||
NULL
|
||||
};
|
||||
mem_cache_type = g_type_register_static(GST_TYPE_CACHE, "GstMemCache", &mem_cache_info, 0);
|
||||
}
|
||||
return mem_cache_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_mem_cache_class_init (GstMemCacheClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class;
|
||||
GstCacheClass *gstcache_class;
|
||||
|
||||
gobject_class = (GObjectClass*)klass;
|
||||
gstcache_class = (GstCacheClass*)klass;
|
||||
|
||||
parent_class = g_type_class_ref(GST_TYPE_CACHE);
|
||||
|
||||
gobject_class->dispose = gst_mem_cache_dispose;
|
||||
|
||||
gstcache_class->add_entry = gst_mem_cache_add_entry;
|
||||
gstcache_class->get_assoc_entry = gst_mem_cache_get_assoc_entry;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_mem_cache_init (GstMemCache *cache)
|
||||
{
|
||||
GST_DEBUG(0, "created new mem cache");
|
||||
|
||||
cache->associations = NULL;
|
||||
cache->id_index = g_hash_table_new (g_int_hash, g_int_equal);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_mem_cache_dispose (GObject *object)
|
||||
{
|
||||
//GstMemCache *memcache = GST_MEM_CACHE (object);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_mem_cache_add_id (GstCache *cache, GstCacheEntry *entry)
|
||||
{
|
||||
GstMemCache *memcache = GST_MEM_CACHE (cache);
|
||||
GstMemCacheId *id_index;
|
||||
|
||||
id_index = g_hash_table_lookup (memcache->id_index, &entry->id);
|
||||
|
||||
if (!id_index) {
|
||||
id_index = g_new0 (GstMemCacheId, 1);
|
||||
|
||||
id_index->id = entry->id;
|
||||
id_index->format_index = g_hash_table_new (g_int_hash, g_int_equal);
|
||||
g_hash_table_insert (memcache->id_index, &entry->id, id_index);
|
||||
}
|
||||
}
|
||||
|
||||
static gint
|
||||
mem_cache_compare (gconstpointer a,
|
||||
gconstpointer b,
|
||||
gpointer user_data)
|
||||
{
|
||||
GstMemCacheFormatIndex *index = user_data;
|
||||
gint64 val1, val2;
|
||||
gint64 diff;
|
||||
|
||||
val1 = GST_CACHE_ASSOC_VALUE (((GstCacheEntry *)a), index->offset);
|
||||
val2 = GST_CACHE_ASSOC_VALUE (((GstCacheEntry *)b), index->offset);
|
||||
|
||||
diff = (val2 - val1);
|
||||
|
||||
return (diff == 0 ? 0 : (diff > 0 ? 1 : -1));
|
||||
}
|
||||
|
||||
static void
|
||||
gst_mem_cache_index_format (GstMemCacheId *id_index, GstCacheEntry *entry, gint assoc)
|
||||
{
|
||||
GstMemCacheFormatIndex *index;
|
||||
GstFormat *format;
|
||||
|
||||
format = &GST_CACHE_ASSOC_FORMAT (entry, assoc);
|
||||
|
||||
index = g_hash_table_lookup (id_index->format_index, format);
|
||||
|
||||
if (!index) {
|
||||
index = g_new0 (GstMemCacheFormatIndex, 1);
|
||||
|
||||
index->format = *format;
|
||||
index->offset = assoc;
|
||||
index->tree = g_tree_new_with_data (mem_cache_compare, index);
|
||||
|
||||
g_hash_table_insert (id_index->format_index, format, index);
|
||||
}
|
||||
|
||||
g_tree_insert (index->tree, entry, entry);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_mem_cache_add_association (GstCache *cache, GstCacheEntry *entry)
|
||||
{
|
||||
GstMemCache *memcache = GST_MEM_CACHE (cache);
|
||||
GstMemCacheId *id_index;
|
||||
|
||||
memcache->associations = g_list_prepend (memcache->associations, entry);
|
||||
|
||||
id_index = g_hash_table_lookup (memcache->id_index, &entry->id);
|
||||
if (id_index) {
|
||||
gint i;
|
||||
|
||||
for (i = 0; i < GST_CACHE_NASSOCS (entry); i++) {
|
||||
gst_mem_cache_index_format (id_index, entry, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gst_mem_cache_add_object (GstCache *cache, GstCacheEntry *entry)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gst_mem_cache_add_format (GstCache *cache, GstCacheEntry *entry)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gst_mem_cache_add_entry (GstCache *cache, GstCacheEntry *entry)
|
||||
{
|
||||
GstMemCache *memcache = GST_MEM_CACHE (cache);
|
||||
|
||||
GST_DEBUG (0, "adding entry %p\n", memcache);
|
||||
|
||||
switch (entry->type){
|
||||
case GST_CACHE_ENTRY_ID:
|
||||
gst_mem_cache_add_id (cache, entry);
|
||||
break;
|
||||
case GST_CACHE_ENTRY_ASSOCIATION:
|
||||
gst_mem_cache_add_association (cache, entry);
|
||||
break;
|
||||
case GST_CACHE_ENTRY_OBJECT:
|
||||
gst_mem_cache_add_object (cache, entry);
|
||||
break;
|
||||
case GST_CACHE_ENTRY_FORMAT:
|
||||
gst_mem_cache_add_format (cache, entry);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
gint64 value;
|
||||
GstMemCacheFormatIndex *index;
|
||||
gboolean exact;
|
||||
GstCacheEntry *lower;
|
||||
gint64 low_diff;
|
||||
GstCacheEntry *higher;
|
||||
gint64 high_diff;
|
||||
} GstMemCacheSearchData;
|
||||
|
||||
static gint
|
||||
mem_cache_search (gconstpointer a,
|
||||
gconstpointer b)
|
||||
{
|
||||
GstMemCacheSearchData *data = (GstMemCacheSearchData *) b;
|
||||
GstMemCacheFormatIndex *index = data->index;
|
||||
gint64 val1, val2;
|
||||
gint64 diff;
|
||||
|
||||
val1 = GST_CACHE_ASSOC_VALUE (((GstCacheEntry *)a), index->offset);
|
||||
val2 = data->value;
|
||||
|
||||
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 = (GstCacheEntry *) a;
|
||||
}
|
||||
diff = -1;
|
||||
}
|
||||
else {
|
||||
if (diff < data->high_diff) {
|
||||
data->high_diff = diff;
|
||||
data->higher = (GstCacheEntry *) a;
|
||||
}
|
||||
diff = 1;
|
||||
}
|
||||
|
||||
return diff;
|
||||
}
|
||||
|
||||
static GstCacheEntry*
|
||||
gst_mem_cache_get_assoc_entry (GstCache *cache, gint id,
|
||||
GstCacheLookupMethod method,
|
||||
GstFormat format, gint64 value,
|
||||
GCompareDataFunc func,
|
||||
gpointer user_data)
|
||||
{
|
||||
GstMemCache *memcache = GST_MEM_CACHE (cache);
|
||||
GstMemCacheId *id_index;
|
||||
GstMemCacheFormatIndex *index;
|
||||
GstCacheEntry *entry;
|
||||
GstMemCacheSearchData data;
|
||||
|
||||
id_index = g_hash_table_lookup (memcache->id_index, &id);
|
||||
if (!id_index)
|
||||
return NULL;
|
||||
|
||||
index = g_hash_table_lookup (id_index->format_index, &format);
|
||||
if (!index)
|
||||
return NULL;
|
||||
|
||||
data.value = value;
|
||||
data.index = index;
|
||||
data.exact = (method == GST_CACHE_LOOKUP_EXACT);
|
||||
|
||||
/* setup data for low/high checks if we are not looking
|
||||
* 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 (index->tree, mem_cache_search, &data);
|
||||
|
||||
/* get the low/high values if we're not exact */
|
||||
if (entry == NULL && !data.exact) {
|
||||
if (method == GST_CACHE_LOOKUP_BEFORE)
|
||||
entry = data.lower;
|
||||
else if (method == GST_CACHE_LOOKUP_AFTER) {
|
||||
entry = data.higher;
|
||||
}
|
||||
}
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
plugin_init (GModule *module, GstPlugin *plugin)
|
||||
{
|
||||
GstCacheFactory *factory;
|
||||
|
||||
gst_plugin_set_longname (plugin, "A memory cache");
|
||||
|
||||
factory = gst_cache_factory_new ("memcache",
|
||||
"A cache that stores entries in memory",
|
||||
gst_mem_cache_get_type());
|
||||
|
||||
if (factory != NULL) {
|
||||
gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory));
|
||||
}
|
||||
else {
|
||||
g_warning ("could not register memcache");
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
GstPluginDesc plugin_desc = {
|
||||
GST_VERSION_MAJOR,
|
||||
GST_VERSION_MINOR,
|
||||
"gstcaches",
|
||||
plugin_init
|
||||
};
|
||||
|
|
@ -341,7 +341,7 @@ init_pre (void)
|
|||
gst_registry_add_path (_global_registry, PLUGINS_BUILDDIR "/gst/types");
|
||||
gst_registry_add_path (_global_registry, PLUGINS_BUILDDIR "/gst/autoplug");
|
||||
gst_registry_add_path (_global_registry, PLUGINS_BUILDDIR "/gst/schedulers");
|
||||
gst_registry_add_path (_global_registry, PLUGINS_BUILDDIR "/gst/caches");
|
||||
gst_registry_add_path (_global_registry, PLUGINS_BUILDDIR "/gst/indexers");
|
||||
#else
|
||||
/* add the main (installed) library path */
|
||||
gst_registry_add_path (_global_registry, PLUGINS_DIR);
|
||||
|
@ -448,7 +448,7 @@ init_post (void)
|
|||
#ifndef GST_DISABLE_AUTOPLUG
|
||||
gst_autoplug_factory_get_type ();
|
||||
#endif
|
||||
gst_cache_factory_get_type ();
|
||||
gst_index_factory_get_type ();
|
||||
|
||||
|
||||
plugin_path = g_getenv ("GST_PLUGIN_PATH");
|
||||
|
|
|
@ -35,10 +35,10 @@
|
|||
#include <gst/gstpad.h>
|
||||
#include <gst/gstbuffer.h>
|
||||
#include <gst/gstbufferpool-default.h>
|
||||
#include <gst/gstcache.h>
|
||||
#include <gst/gstcpu.h>
|
||||
#include <gst/gstelement.h>
|
||||
#include <gst/gstbin.h>
|
||||
#include <gst/gstindex.h>
|
||||
#include <gst/gstpipeline.h>
|
||||
#include <gst/gstthread.h>
|
||||
#include <gst/gsttype.h>
|
||||
|
|
662
gst/gstcache.c
662
gst/gstcache.c
|
@ -1,662 +0,0 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2001 RidgeRun (http://www.ridgerun.com/)
|
||||
* Written by Erik Walthinsen <omega@ridgerun.com>
|
||||
*
|
||||
* gstcache.c: Cache for mappings and other data
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "gstlog.h"
|
||||
#include "gst_private.h"
|
||||
#include "gstregistry.h"
|
||||
|
||||
#include "gstcache.h"
|
||||
|
||||
/* Cache signals and args */
|
||||
enum {
|
||||
ENTRY_ADDED,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
enum {
|
||||
ARG_0,
|
||||
/* FILL ME */
|
||||
};
|
||||
|
||||
static void gst_cache_class_init (GstCacheClass *klass);
|
||||
static void gst_cache_init (GstCache *cache);
|
||||
|
||||
#define CLASS(cache) GST_CACHE_CLASS (G_OBJECT_GET_CLASS (cache))
|
||||
|
||||
static GstObject *parent_class = NULL;
|
||||
static guint gst_cache_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
GType
|
||||
gst_cache_get_type(void) {
|
||||
static GType cache_type = 0;
|
||||
|
||||
if (!cache_type) {
|
||||
static const GTypeInfo cache_info = {
|
||||
sizeof(GstCacheClass),
|
||||
NULL,
|
||||
NULL,
|
||||
(GClassInitFunc)gst_cache_class_init,
|
||||
NULL,
|
||||
NULL,
|
||||
sizeof(GstCache),
|
||||
1,
|
||||
(GInstanceInitFunc)gst_cache_init,
|
||||
NULL
|
||||
};
|
||||
cache_type = g_type_register_static(GST_TYPE_OBJECT, "GstCache", &cache_info, 0);
|
||||
}
|
||||
return cache_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_cache_class_init (GstCacheClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class;
|
||||
GstElementClass *gstelement_class;
|
||||
|
||||
gobject_class = (GObjectClass*)klass;
|
||||
gstelement_class = (GstElementClass*)klass;
|
||||
|
||||
parent_class = g_type_class_ref(GST_TYPE_OBJECT);
|
||||
|
||||
gst_cache_signals[ENTRY_ADDED] =
|
||||
g_signal_new ("entry_added", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (GstCacheClass, entry_added), NULL, NULL,
|
||||
gst_marshal_VOID__POINTER, G_TYPE_NONE, 1,
|
||||
G_TYPE_POINTER);
|
||||
}
|
||||
|
||||
static GstCacheGroup *
|
||||
gst_cache_group_new(guint groupnum)
|
||||
{
|
||||
GstCacheGroup *cachegroup = g_new(GstCacheGroup,1);
|
||||
|
||||
cachegroup->groupnum = groupnum;
|
||||
cachegroup->entries = NULL;
|
||||
cachegroup->certainty = GST_CACHE_UNKNOWN;
|
||||
cachegroup->peergroup = -1;
|
||||
|
||||
GST_DEBUG(0, "created new cache group %d",groupnum);
|
||||
|
||||
return cachegroup;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_cache_init (GstCache *cache)
|
||||
{
|
||||
cache->curgroup = gst_cache_group_new(0);
|
||||
cache->maxgroup = 0;
|
||||
cache->groups = g_list_prepend(NULL, cache->curgroup);
|
||||
|
||||
cache->writers = g_hash_table_new (NULL, NULL);
|
||||
cache->last_id = 0;
|
||||
|
||||
GST_DEBUG(0, "created new cache");
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_cache_new:
|
||||
*
|
||||
* Create a new tilecache object
|
||||
*
|
||||
* Returns: a new cache object
|
||||
*/
|
||||
GstCache *
|
||||
gst_cache_new()
|
||||
{
|
||||
GstCache *cache;
|
||||
|
||||
cache = g_object_new (gst_cache_get_type (), NULL);
|
||||
|
||||
return cache;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_cache_get_group:
|
||||
* @cache: the cache to get the current group from
|
||||
*
|
||||
* Get the id of the current group.
|
||||
*
|
||||
* Returns: the id of the current group.
|
||||
*/
|
||||
gint
|
||||
gst_cache_get_group(GstCache *cache)
|
||||
{
|
||||
return cache->curgroup->groupnum;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_cache_new_group:
|
||||
* @cache: the cache to create the new group in
|
||||
*
|
||||
* Create a new group for the given cache. It will be
|
||||
* set as the current group.
|
||||
*
|
||||
* Returns: the id of the newly created group.
|
||||
*/
|
||||
gint
|
||||
gst_cache_new_group(GstCache *cache)
|
||||
{
|
||||
cache->curgroup = gst_cache_group_new(++cache->maxgroup);
|
||||
cache->groups = g_list_append(cache->groups,cache->curgroup);
|
||||
GST_DEBUG(0, "created new group %d in cache",cache->maxgroup);
|
||||
return cache->maxgroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_cache_set_group:
|
||||
* @cache: the cache to set the new group in
|
||||
* @groupnum: the groupnumber to set
|
||||
*
|
||||
* Set the current groupnumber to the given argument.
|
||||
*
|
||||
* Returns: TRUE if the operation succeeded, FALSE if the group
|
||||
* did not exist.
|
||||
*/
|
||||
gboolean
|
||||
gst_cache_set_group(GstCache *cache, gint groupnum)
|
||||
{
|
||||
GList *list;
|
||||
GstCacheGroup *cachegroup;
|
||||
|
||||
/* first check for null change */
|
||||
if (groupnum == cache->curgroup->groupnum)
|
||||
return TRUE;
|
||||
|
||||
/* else search for the proper group */
|
||||
list = cache->groups;
|
||||
while (list) {
|
||||
cachegroup = (GstCacheGroup *)(list->data);
|
||||
list = g_list_next(list);
|
||||
if (cachegroup->groupnum == groupnum) {
|
||||
cache->curgroup = cachegroup;
|
||||
GST_DEBUG(0, "swicachehed to cache group %d", cachegroup->groupnum);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/* couldn't find the group in question */
|
||||
GST_DEBUG(0, "couldn't find cache group %d",groupnum);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_cache_set_certainty:
|
||||
* @cache: the cache to set the certainty on
|
||||
* @certainty: the certainty to set
|
||||
*
|
||||
* Set the certainty of the given cache.
|
||||
*/
|
||||
void
|
||||
gst_cache_set_certainty(GstCache *cache, GstCacheCertainty certainty)
|
||||
{
|
||||
cache->curgroup->certainty = certainty;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_cache_get_certainty:
|
||||
* @cache: the cache to get the certainty of
|
||||
*
|
||||
* Get the certainty of the given cache.
|
||||
*
|
||||
* Returns: the certainty of the cache.
|
||||
*/
|
||||
GstCacheCertainty
|
||||
gst_cache_get_certainty(GstCache *cache)
|
||||
{
|
||||
return cache->curgroup->certainty;
|
||||
}
|
||||
|
||||
void
|
||||
gst_cache_set_filter (GstCache *cache,
|
||||
GstCacheFilter filter, gpointer user_data)
|
||||
{
|
||||
g_return_if_fail (GST_IS_CACHE (cache));
|
||||
|
||||
cache->filter = filter;
|
||||
cache->filter_user_data = user_data;
|
||||
}
|
||||
|
||||
void
|
||||
gst_cache_set_resolver (GstCache *cache,
|
||||
GstCacheResolver resolver, gpointer user_data)
|
||||
{
|
||||
g_return_if_fail (GST_IS_CACHE (cache));
|
||||
|
||||
cache->resolver = resolver;
|
||||
cache->resolver_user_data = user_data;
|
||||
}
|
||||
|
||||
void
|
||||
gst_cache_entry_free (GstCacheEntry *entry)
|
||||
{
|
||||
g_free (entry);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_cache_add_format:
|
||||
* @cache: the cache to add the entry to
|
||||
* @id: the id of the cache writer
|
||||
* @format: the format to add to the cache
|
||||
*
|
||||
* Adds a format entry into the cache. This function is
|
||||
* used to map dynamic GstFormat ids to their original
|
||||
* format key.
|
||||
*
|
||||
* Returns: a pointer to the newly added entry in the cache.
|
||||
*/
|
||||
GstCacheEntry*
|
||||
gst_cache_add_format (GstCache *cache, gint id, GstFormat format)
|
||||
{
|
||||
GstCacheEntry *entry;
|
||||
const GstFormatDefinition* def;
|
||||
|
||||
g_return_val_if_fail (GST_IS_CACHE (cache), NULL);
|
||||
g_return_val_if_fail (format != 0, NULL);
|
||||
|
||||
entry = g_new0 (GstCacheEntry, 1);
|
||||
entry->type = GST_CACHE_ENTRY_FORMAT;
|
||||
entry->id = id;
|
||||
entry->data.format.format = format;
|
||||
def = gst_format_get_details (format);
|
||||
entry->data.format.key = def->nick;
|
||||
|
||||
if (CLASS (cache)->add_entry)
|
||||
CLASS (cache)->add_entry (cache, entry);
|
||||
|
||||
g_signal_emit (G_OBJECT (cache), gst_cache_signals[ENTRY_ADDED], 0, entry);
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_cache_add_id:
|
||||
* @cache: the cache to add the entry to
|
||||
* @id: the id of the cache writer
|
||||
* @description: the description of the cache writer
|
||||
*
|
||||
* Returns: a pointer to the newly added entry in the cache.
|
||||
*/
|
||||
GstCacheEntry*
|
||||
gst_cache_add_id (GstCache *cache, gint id, gchar *description)
|
||||
{
|
||||
GstCacheEntry *entry;
|
||||
|
||||
g_return_val_if_fail (GST_IS_CACHE (cache), NULL);
|
||||
g_return_val_if_fail (description != NULL, NULL);
|
||||
|
||||
entry = g_new0 (GstCacheEntry, 1);
|
||||
entry->type = GST_CACHE_ENTRY_ID;
|
||||
entry->id = id;
|
||||
entry->data.id.description = description;
|
||||
|
||||
if (CLASS (cache)->add_entry)
|
||||
CLASS (cache)->add_entry (cache, entry);
|
||||
|
||||
g_signal_emit (G_OBJECT (cache), gst_cache_signals[ENTRY_ADDED], 0, entry);
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_cache_get_writer_id:
|
||||
* @cache: the cache to get a unique write 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 cache, a writer
|
||||
* should obtain a unique id. The methods to add new entries
|
||||
* to the cache require this id as an argument.
|
||||
*
|
||||
* The application or a GstCache subclass can implement
|
||||
* custom functions to map the writer object to an id.
|
||||
*
|
||||
* Returns: TRUE if the writer would be mapped to an id.
|
||||
*/
|
||||
gboolean
|
||||
gst_cache_get_writer_id (GstCache *cache, GstObject *writer, gint *id)
|
||||
{
|
||||
gchar *writer_string = NULL;
|
||||
gboolean success = FALSE;
|
||||
GstCacheEntry *entry;
|
||||
|
||||
g_return_val_if_fail (GST_IS_CACHE (cache), FALSE);
|
||||
g_return_val_if_fail (GST_IS_OBJECT (writer), FALSE);
|
||||
g_return_val_if_fail (id, FALSE);
|
||||
|
||||
*id = -1;
|
||||
|
||||
entry = g_hash_table_lookup (cache->writers, writer);
|
||||
if (entry == NULL) {
|
||||
*id = cache->last_id;
|
||||
|
||||
writer_string = gst_object_get_path_string (writer);
|
||||
|
||||
gst_cache_add_id (cache, *id, writer_string);
|
||||
cache->last_id++;
|
||||
g_hash_table_insert (cache->writers, writer, entry);
|
||||
}
|
||||
|
||||
if (CLASS (cache)->resolve_writer) {
|
||||
success = CLASS (cache)->resolve_writer (cache, writer, id, &writer_string);
|
||||
}
|
||||
|
||||
if (cache->resolver) {
|
||||
success = cache->resolver (cache, writer, id, &writer_string, cache->resolver_user_data);
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_cache_add_association:
|
||||
* @cache: the cache to add the entry to
|
||||
* @id: the id of the cache writer
|
||||
* @format: the format of the value
|
||||
* @value: the value
|
||||
* @...: other format/value pairs or 0 to end the list
|
||||
*
|
||||
* Associate given format/value pairs with eachother.
|
||||
* Be sure to pass gint64 values to this functions varargs,
|
||||
* you might want to use a gint64 cast to be sure.
|
||||
*
|
||||
* Returns: a pointer to the newly added entry in the cache.
|
||||
*/
|
||||
GstCacheEntry*
|
||||
gst_cache_add_association (GstCache *cache, gint id, GstAssocFlags flags,
|
||||
GstFormat format, gint64 value, ...)
|
||||
{
|
||||
va_list args;
|
||||
GstCacheAssociation *assoc;
|
||||
GstCacheEntry *entry;
|
||||
gulong size;
|
||||
gint nassocs = 0;
|
||||
GstFormat cur_format;
|
||||
volatile gint64 dummy;
|
||||
|
||||
g_return_val_if_fail (GST_IS_CACHE (cache), NULL);
|
||||
g_return_val_if_fail (format != 0, NULL);
|
||||
|
||||
va_start (args, value);
|
||||
|
||||
cur_format = format;
|
||||
|
||||
while (cur_format) {
|
||||
nassocs++;
|
||||
cur_format = va_arg (args, GstFormat);
|
||||
if (cur_format)
|
||||
dummy = va_arg (args, gint64);
|
||||
}
|
||||
va_end (args);
|
||||
|
||||
/* make room for two assoc */
|
||||
size = sizeof (GstCacheEntry) + (sizeof (GstCacheAssociation) * nassocs);
|
||||
|
||||
entry = g_malloc (size);
|
||||
|
||||
entry->type = GST_CACHE_ENTRY_ASSOCIATION;
|
||||
entry->id = id;
|
||||
entry->data.assoc.flags = flags;
|
||||
assoc = (GstCacheAssociation *) (((guint8 *) entry) + sizeof (GstCacheEntry));
|
||||
entry->data.assoc.assocs = assoc;
|
||||
entry->data.assoc.nassocs = nassocs;
|
||||
|
||||
va_start (args, value);
|
||||
while (format) {
|
||||
assoc->format = format;
|
||||
assoc->value = value;
|
||||
|
||||
assoc++;
|
||||
|
||||
format = va_arg (args, GstFormat);
|
||||
if (format)
|
||||
value = va_arg (args, gint64);
|
||||
}
|
||||
va_end (args);
|
||||
|
||||
if (CLASS (cache)->add_entry)
|
||||
CLASS (cache)->add_entry (cache, entry);
|
||||
|
||||
g_signal_emit (G_OBJECT (cache), gst_cache_signals[ENTRY_ADDED], 0, entry);
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
static gint
|
||||
gst_cache_compare_func (gconstpointer a,
|
||||
gconstpointer b,
|
||||
gpointer user_data)
|
||||
{
|
||||
return a - b;
|
||||
}
|
||||
|
||||
GstCacheEntry*
|
||||
gst_cache_get_assoc_entry (GstCache *cache, gint id,
|
||||
GstCacheLookupMethod method,
|
||||
GstFormat format, gint64 value)
|
||||
{
|
||||
g_return_val_if_fail (GST_IS_CACHE (cache), NULL);
|
||||
|
||||
return gst_cache_get_assoc_entry_full (cache, id, method, format, value,
|
||||
gst_cache_compare_func, NULL);
|
||||
}
|
||||
|
||||
GstCacheEntry*
|
||||
gst_cache_get_assoc_entry_full (GstCache *cache, gint id,
|
||||
GstCacheLookupMethod method,
|
||||
GstFormat format, gint64 value,
|
||||
GCompareDataFunc func,
|
||||
gpointer user_data)
|
||||
{
|
||||
g_return_val_if_fail (GST_IS_CACHE (cache), NULL);
|
||||
|
||||
if (CLASS(cache)->get_assoc_entry)
|
||||
return CLASS (cache)->get_assoc_entry (cache, id, method, format, value, func, user_data);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gst_cache_entry_assoc_map (GstCacheEntry *entry,
|
||||
GstFormat format, gint64 *value)
|
||||
{
|
||||
gint i;
|
||||
|
||||
g_return_val_if_fail (entry != NULL, FALSE);
|
||||
g_return_val_if_fail (value != NULL, FALSE);
|
||||
|
||||
for (i = 0; i < GST_CACHE_NASSOCS (entry); i++) {
|
||||
if (GST_CACHE_ASSOC_FORMAT (entry, i) == format) {
|
||||
*value = GST_CACHE_ASSOC_VALUE (entry, i);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
static void gst_cache_factory_class_init (GstCacheFactoryClass *klass);
|
||||
static void gst_cache_factory_init (GstCacheFactory *factory);
|
||||
|
||||
static GstPluginFeatureClass *factory_parent_class = NULL;
|
||||
/* static guint gst_cache_factory_signals[LAST_SIGNAL] = { 0 }; */
|
||||
|
||||
GType
|
||||
gst_cache_factory_get_type (void)
|
||||
{
|
||||
static GType cachefactory_type = 0;
|
||||
|
||||
if (!cachefactory_type) {
|
||||
static const GTypeInfo cachefactory_info = {
|
||||
sizeof (GstCacheFactoryClass),
|
||||
NULL,
|
||||
NULL,
|
||||
(GClassInitFunc) gst_cache_factory_class_init,
|
||||
NULL,
|
||||
NULL,
|
||||
sizeof(GstCacheFactory),
|
||||
0,
|
||||
(GInstanceInitFunc) gst_cache_factory_init,
|
||||
NULL
|
||||
};
|
||||
cachefactory_type = g_type_register_static (GST_TYPE_PLUGIN_FEATURE,
|
||||
"GstCacheFactory", &cachefactory_info, 0);
|
||||
}
|
||||
return cachefactory_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_cache_factory_class_init (GstCacheFactoryClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class;
|
||||
GstObjectClass *gstobject_class;
|
||||
GstPluginFeatureClass *gstpluginfeature_class;
|
||||
|
||||
gobject_class = (GObjectClass*)klass;
|
||||
gstobject_class = (GstObjectClass*)klass;
|
||||
gstpluginfeature_class = (GstPluginFeatureClass*) klass;
|
||||
|
||||
factory_parent_class = g_type_class_ref (GST_TYPE_PLUGIN_FEATURE);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_cache_factory_init (GstCacheFactory *factory)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_cache_factory_new:
|
||||
* @name: name of cachefactory to create
|
||||
* @longdesc: long description of cachefactory to create
|
||||
* @type: the GType of the GstCache element of this factory
|
||||
*
|
||||
* Create a new cachefactory with the given parameters
|
||||
*
|
||||
* Returns: a new #GstCacheFactory.
|
||||
*/
|
||||
GstCacheFactory*
|
||||
gst_cache_factory_new (const gchar *name, const gchar *longdesc, GType type)
|
||||
{
|
||||
GstCacheFactory *factory;
|
||||
|
||||
g_return_val_if_fail(name != NULL, NULL);
|
||||
factory = gst_cache_factory_find (name);
|
||||
if (!factory) {
|
||||
factory = GST_CACHE_FACTORY (g_object_new (GST_TYPE_CACHE_FACTORY, NULL));
|
||||
}
|
||||
|
||||
GST_PLUGIN_FEATURE_NAME (factory) = g_strdup (name);
|
||||
if (factory->longdesc)
|
||||
g_free (factory->longdesc);
|
||||
factory->longdesc = g_strdup (longdesc);
|
||||
factory->type = type;
|
||||
|
||||
return factory;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_cache_factory_destroy:
|
||||
* @factory: factory to destroy
|
||||
*
|
||||
* Removes the cache from the global list.
|
||||
*/
|
||||
void
|
||||
gst_cache_factory_destroy (GstCacheFactory *factory)
|
||||
{
|
||||
g_return_if_fail (factory != NULL);
|
||||
|
||||
/* we don't free the struct bacause someone might have a handle to it.. */
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_cache_factory_find:
|
||||
* @name: name of cachefactory to find
|
||||
*
|
||||
* Search for an cachefactory of the given name.
|
||||
*
|
||||
* Returns: #GstCacheFactory if found, NULL otherwise
|
||||
*/
|
||||
GstCacheFactory*
|
||||
gst_cache_factory_find (const gchar *name)
|
||||
{
|
||||
GstPluginFeature *feature;
|
||||
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
|
||||
GST_DEBUG (0,"gstcache: find \"%s\"", name);
|
||||
|
||||
feature = gst_registry_pool_find_feature (name, GST_TYPE_CACHE_FACTORY);
|
||||
if (feature)
|
||||
return GST_CACHE_FACTORY (feature);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_cache_factory_create:
|
||||
* @factory: the factory used to create the instance
|
||||
*
|
||||
* Create a new #GstCache instance from the
|
||||
* given cachefactory.
|
||||
*
|
||||
* Returns: A new #GstCache instance.
|
||||
*/
|
||||
GstCache*
|
||||
gst_cache_factory_create (GstCacheFactory *factory)
|
||||
{
|
||||
GstCache *new = NULL;
|
||||
|
||||
g_return_val_if_fail (factory != NULL, NULL);
|
||||
|
||||
if (gst_plugin_feature_ensure_loaded (GST_PLUGIN_FEATURE (factory))) {
|
||||
g_return_val_if_fail (factory->type != 0, NULL);
|
||||
|
||||
new = GST_CACHE (g_object_new(factory->type,NULL));
|
||||
}
|
||||
|
||||
return new;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_cache_factory_make:
|
||||
* @name: the name of the factory used to create the instance
|
||||
*
|
||||
* Create a new #GstCache instance from the
|
||||
* cachefactory with the given name.
|
||||
*
|
||||
* Returns: A new #GstCache instance.
|
||||
*/
|
||||
GstCache*
|
||||
gst_cache_factory_make (const gchar *name)
|
||||
{
|
||||
GstCacheFactory *factory;
|
||||
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
|
||||
factory = gst_cache_factory_find (name);
|
||||
|
||||
if (factory == NULL)
|
||||
return NULL;
|
||||
|
||||
return gst_cache_factory_create (factory);
|
||||
}
|
||||
|
248
gst/gstcache.h
248
gst/gstcache.h
|
@ -1,248 +0,0 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
|
||||
* 2000 Wim Taymans <wim.taymans@chello.be>
|
||||
*
|
||||
* gstcache.h: Header for GstCache
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef __GST_CACHE_H__
|
||||
#define __GST_CACHE_H__
|
||||
|
||||
#include <gst/gstobject.h>
|
||||
#include <gst/gstformat.h>
|
||||
#include <gst/gstpluginfeature.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_TYPE_CACHE (gst_cache_get_type ())
|
||||
#define GST_CACHE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_CACHE, GstCache))
|
||||
#define GST_CACHE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_CACHE, GstCacheClass))
|
||||
#define GST_IS_CACHE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_CACHE))
|
||||
#define GST_IS_CACHE_CLASS(obj) (GST_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_CACHE))
|
||||
|
||||
typedef struct _GstCacheEntry GstCacheEntry;
|
||||
typedef struct _GstCacheGroup GstCacheGroup;
|
||||
typedef struct _GstCache GstCache;
|
||||
typedef struct _GstCacheClass GstCacheClass;
|
||||
|
||||
typedef enum {
|
||||
GST_CACHE_UNKNOWN,
|
||||
GST_CACHE_CERTAIN,
|
||||
GST_CACHE_FUZZY
|
||||
} GstCacheCertainty;
|
||||
|
||||
typedef enum {
|
||||
GST_CACHE_ENTRY_ID,
|
||||
GST_CACHE_ENTRY_ASSOCIATION,
|
||||
GST_CACHE_ENTRY_OBJECT,
|
||||
GST_CACHE_ENTRY_FORMAT,
|
||||
} GstCacheEntryType;
|
||||
|
||||
typedef enum {
|
||||
GST_CACHE_LOOKUP_EXACT,
|
||||
GST_CACHE_LOOKUP_BEFORE,
|
||||
GST_CACHE_LOOKUP_AFTER,
|
||||
} GstCacheLookupMethod;
|
||||
|
||||
#define GST_CACHE_NASSOCS(entry) ((entry)->data.assoc.nassocs)
|
||||
#define GST_CACHE_ASSOC_FLAGS(entry) ((entry)->data.assoc.flags)
|
||||
#define GST_CACHE_ASSOC_FORMAT(entry,i) ((entry)->data.assoc.assocs[(i)].format)
|
||||
#define GST_CACHE_ASSOC_VALUE(entry,i) ((entry)->data.assoc.assocs[(i)].value)
|
||||
|
||||
typedef struct _GstCacheAssociation GstCacheAssociation;
|
||||
|
||||
struct _GstCacheAssociation {
|
||||
GstFormat format;
|
||||
gint64 value;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
GST_ACCOCIATION_FLAG_NONE = 0,
|
||||
GST_ACCOCIATION_FLAG_KEY_UNIT = (1 << 0),
|
||||
} GstAssocFlags;
|
||||
|
||||
#define GST_CACHE_FORMAT_FORMAT(entry) ((entry)->data.format.format)
|
||||
#define GST_CACHE_FORMAT_KEY(entry) ((entry)->data.format.key)
|
||||
|
||||
#define GST_CACHE_ID_DESCRIPTION(entry) ((entry)->data.id.description)
|
||||
|
||||
struct _GstCacheEntry {
|
||||
GstCacheEntryType type;
|
||||
gint id;
|
||||
|
||||
union {
|
||||
struct {
|
||||
gchar *description;
|
||||
} id;
|
||||
struct {
|
||||
gint nassocs;
|
||||
GstCacheAssociation
|
||||
*assocs;
|
||||
GstAssocFlags flags;
|
||||
} assoc;
|
||||
struct {
|
||||
gchar *key;
|
||||
GType type;
|
||||
gpointer object;
|
||||
} object;
|
||||
struct {
|
||||
GstFormat format;
|
||||
gchar *key;
|
||||
} format;
|
||||
} data;
|
||||
};
|
||||
|
||||
struct _GstCacheGroup {
|
||||
/* unique ID of group in cache */
|
||||
gint groupnum;
|
||||
|
||||
/* list of entries */
|
||||
GList *entries;
|
||||
|
||||
/* the certainty level of the group */
|
||||
GstCacheCertainty certainty;
|
||||
|
||||
/* peer group that contains more certain entries */
|
||||
gint peergroup;
|
||||
};
|
||||
|
||||
typedef gboolean (*GstCacheFilter) (GstCache *cache,
|
||||
GstCacheEntry *entry);
|
||||
|
||||
typedef gboolean (*GstCacheResolver) (GstCache *cache,
|
||||
GstObject *writer,
|
||||
gint *writer_id,
|
||||
gchar **writer_string,
|
||||
gpointer user_data);
|
||||
struct _GstCache {
|
||||
GstObject object;
|
||||
|
||||
GList *groups;
|
||||
GstCacheGroup *curgroup;
|
||||
gint maxgroup;
|
||||
|
||||
GstCacheResolver resolver;
|
||||
gpointer resolver_user_data;
|
||||
|
||||
GstCacheFilter filter;
|
||||
gpointer filter_user_data;
|
||||
|
||||
GHashTable *writers;
|
||||
gint last_id;
|
||||
};
|
||||
|
||||
struct _GstCacheClass {
|
||||
GstObjectClass parent_class;
|
||||
|
||||
gboolean (*resolve_writer) (GstCache *cache, GstObject *writer,
|
||||
gint *writer_id, gchar **writer_string);
|
||||
|
||||
/* abstract methods */
|
||||
void (*add_entry) (GstCache *cache, GstCacheEntry *entry);
|
||||
|
||||
GstCacheEntry* (*get_assoc_entry) (GstCache *cache, gint id,
|
||||
GstCacheLookupMethod method,
|
||||
GstFormat format, gint64 value,
|
||||
GCompareDataFunc func,
|
||||
gpointer user_data);
|
||||
/* signals */
|
||||
void (*entry_added) (GstCache *cache, GstCacheEntry *entry);
|
||||
};
|
||||
|
||||
GType gst_cache_get_type (void);
|
||||
GstCache* gst_cache_new (void);
|
||||
|
||||
gint gst_cache_get_group (GstCache *cache);
|
||||
gint gst_cache_new_group (GstCache *cache);
|
||||
gboolean gst_cache_set_group (GstCache *cache, gint groupnum);
|
||||
|
||||
void gst_cache_set_certainty (GstCache *cache,
|
||||
GstCacheCertainty certainty);
|
||||
GstCacheCertainty gst_cache_get_certainty (GstCache *cache);
|
||||
|
||||
void gst_cache_set_filter (GstCache *cache,
|
||||
GstCacheFilter filter, gpointer user_data);
|
||||
void gst_cache_set_resolver (GstCache *cache,
|
||||
GstCacheResolver resolver, gpointer user_data);
|
||||
|
||||
gboolean gst_cache_get_writer_id (GstCache *cache, GstObject *writer, gint *id);
|
||||
|
||||
GstCacheEntry* gst_cache_add_format (GstCache *cache, gint id, GstFormat format);
|
||||
GstCacheEntry* gst_cache_add_association (GstCache *cache, gint id, GstAssocFlags flags,
|
||||
GstFormat format, gint64 value, ...);
|
||||
GstCacheEntry* gst_cache_add_object (GstCache *cache, gint id, gchar *key,
|
||||
GType type, gpointer object);
|
||||
GstCacheEntry* gst_cache_add_id (GstCache *cache, gint id,
|
||||
gchar *description);
|
||||
|
||||
GstCacheEntry* gst_cache_get_assoc_entry (GstCache *cache, gint id,
|
||||
GstCacheLookupMethod method,
|
||||
GstFormat format, gint64 value);
|
||||
GstCacheEntry* gst_cache_get_assoc_entry_full (GstCache *cache, gint id,
|
||||
GstCacheLookupMethod method,
|
||||
GstFormat format, gint64 value,
|
||||
GCompareDataFunc func,
|
||||
gpointer user_data);
|
||||
|
||||
/* working with cache entries */
|
||||
void gst_cache_entry_free (GstCacheEntry *entry);
|
||||
gboolean gst_cache_entry_assoc_map (GstCacheEntry *entry,
|
||||
GstFormat format, gint64 *value);
|
||||
/*
|
||||
* creating caches
|
||||
*
|
||||
*/
|
||||
#define GST_TYPE_CACHE_FACTORY \
|
||||
(gst_cache_factory_get_type())
|
||||
#define GST_CACHE_FACTORY(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_CACHE_FACTORY,GstCacheFactory))
|
||||
#define GST_CACHE_FACTORY_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_CACHE_FACTORY,GstCacheFactoryClass))
|
||||
#define GST_IS_CACHE_FACTORY(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_CACHE_FACTORY))
|
||||
#define GST_IS_CACHE_FACTORY_CLASS(obj) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_CACHE_FACTORY))
|
||||
|
||||
typedef struct _GstCacheFactory GstCacheFactory;
|
||||
typedef struct _GstCacheFactoryClass GstCacheFactoryClass;
|
||||
|
||||
struct _GstCacheFactory {
|
||||
GstPluginFeature feature;
|
||||
|
||||
gchar *longdesc; /* long description of the cache (well, don't overdo it..) */
|
||||
GType type; /* unique GType of the cache */
|
||||
};
|
||||
|
||||
struct _GstCacheFactoryClass {
|
||||
GstPluginFeatureClass parent;
|
||||
};
|
||||
|
||||
GType gst_cache_factory_get_type (void);
|
||||
|
||||
GstCacheFactory* gst_cache_factory_new (const gchar *name,
|
||||
const gchar *longdesc, GType type);
|
||||
void gst_cache_factory_destroy (GstCacheFactory *factory);
|
||||
|
||||
GstCacheFactory* gst_cache_factory_find (const gchar *name);
|
||||
|
||||
GstCache* gst_cache_factory_create (GstCacheFactory *factory);
|
||||
GstCache* gst_cache_factory_make (const gchar *name);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GST_CACHE_H__ */
|
|
@ -771,26 +771,26 @@ gst_element_is_cachable (GstElement *element)
|
|||
{
|
||||
g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE);
|
||||
|
||||
return (CLASS (element)->set_cache != NULL);
|
||||
return (CLASS (element)->set_index != NULL);
|
||||
}
|
||||
|
||||
void
|
||||
gst_element_set_cache (GstElement *element, GstCache *cache)
|
||||
gst_element_set_index (GstElement *element, GstIndex *index)
|
||||
{
|
||||
g_return_if_fail (GST_IS_ELEMENT (element));
|
||||
g_return_if_fail (GST_IS_CACHE (cache));
|
||||
g_return_if_fail (GST_IS_INDEX (index));
|
||||
|
||||
if (CLASS (element)->set_cache)
|
||||
CLASS (element)->set_cache (element, cache);
|
||||
if (CLASS (element)->set_index)
|
||||
CLASS (element)->set_index (element, index);
|
||||
}
|
||||
|
||||
GstCache*
|
||||
gst_element_get_cache (GstElement *element)
|
||||
GstIndex*
|
||||
gst_element_get_index (GstElement *element)
|
||||
{
|
||||
g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE);
|
||||
|
||||
if (CLASS (element)->get_cache)
|
||||
return CLASS (element)->get_cache (element);
|
||||
if (CLASS (element)->get_index)
|
||||
return CLASS (element)->get_index (element);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include <gst/gstpad.h>
|
||||
#include <gst/gstclock.h>
|
||||
#include <gst/gstpluginfeature.h>
|
||||
#include <gst/gstcache.h>
|
||||
#include <gst/gstindex.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
@ -176,9 +176,9 @@ struct _GstElementClass {
|
|||
/* set/get clocks */
|
||||
GstClock* (*get_clock) (GstElement *element);
|
||||
void (*set_clock) (GstElement *element, GstClock *clock);
|
||||
/* cache */
|
||||
GstCache* (*get_cache) (GstElement *element);
|
||||
void (*set_cache) (GstElement *element, GstCache *cache);
|
||||
/* index */
|
||||
GstIndex* (*get_index) (GstElement *element);
|
||||
void (*set_index) (GstElement *element, GstIndex *index);
|
||||
};
|
||||
|
||||
void gst_element_class_add_pad_template (GstElementClass *klass, GstPadTemplate *templ);
|
||||
|
@ -223,10 +223,10 @@ GstClock* gst_element_get_clock (GstElement *element);
|
|||
void gst_element_set_clock (GstElement *element, GstClock *clock);
|
||||
GstClockReturn gst_element_clock_wait (GstElement *element, GstClock *clock,
|
||||
GstClockTime time, GstClockTimeDiff *jitter);
|
||||
/* caches */
|
||||
/* indexs */
|
||||
gboolean gst_element_is_cachable (GstElement *element);
|
||||
void gst_element_set_cache (GstElement *element, GstCache *cache);
|
||||
GstCache* gst_element_get_cache (GstElement *element);
|
||||
void gst_element_set_index (GstElement *element, GstIndex *index);
|
||||
GstIndex* gst_element_get_index (GstElement *element);
|
||||
|
||||
|
||||
gboolean gst_element_release_locks (GstElement *element);
|
||||
|
|
8
gst/indexers/Makefile.am
Normal file
8
gst/indexers/Makefile.am
Normal file
|
@ -0,0 +1,8 @@
|
|||
plugindir = $(libdir)/gstreamer-@GST_MAJORMINOR@
|
||||
|
||||
plugin_LTLIBRARIES = libgstindexers.la
|
||||
|
||||
libgstindexers_la_SOURCES = gstmemindex.c
|
||||
libgstindexers_la_CFLAGS = $(GST_CFLAGS)
|
||||
libgstindexers_la_LIBADD =
|
||||
libgstindexers_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
|
407
gst/indexers/gstmemindex.c
Normal file
407
gst/indexers/gstmemindex.c
Normal file
|
@ -0,0 +1,407 @@
|
|||
/* 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.
|
||||
*/
|
||||
|
||||
#include <gst/gst_private.h>
|
||||
#include <gst/gstversion.h>
|
||||
#include <gst/gstplugin.h>
|
||||
#include <gst/gstindex.h>
|
||||
|
||||
#define GST_TYPE_MEM_INDEX \
|
||||
(gst_index_get_type ())
|
||||
#define GST_MEM_INDEX(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_MEM_INDEX, GstMemIndex))
|
||||
#define GST_MEM_INDEX_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_MEM_INDEX, GstMemIndexClass))
|
||||
#define GST_IS_MEM_INDEX(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_MEM_INDEX))
|
||||
#define GST_IS_MEM_INDEX_CLASS(obj) \
|
||||
(GST_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_MEM_INDEX))
|
||||
|
||||
/*
|
||||
* Object model:
|
||||
*
|
||||
* All entries are simply added to a GList first. Then we build
|
||||
* an index to each entry for each id/format
|
||||
*
|
||||
*
|
||||
* memindex
|
||||
* -----------------------------...
|
||||
* ! !
|
||||
* id1 id2
|
||||
* ------------
|
||||
* ! !
|
||||
* 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.
|
||||
*
|
||||
* The MemIndexFormatIndex keeps all the values of the particular
|
||||
* format in a GTree, The values of the GTree point back to the entry.
|
||||
*
|
||||
* Finding a value for an id/format requires locating the correct GTree,
|
||||
* then do a lookup in the Tree to get the required value.
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
GstFormat format;
|
||||
gint offset;
|
||||
GTree *tree;
|
||||
} GstMemIndexFormatIndex;
|
||||
|
||||
typedef struct {
|
||||
gint id;
|
||||
GHashTable *format_index;
|
||||
} GstMemIndexId;
|
||||
|
||||
typedef struct _GstMemIndex GstMemIndex;
|
||||
typedef struct _GstMemIndexClass GstMemIndexClass;
|
||||
|
||||
struct _GstMemIndex {
|
||||
GstIndex parent;
|
||||
|
||||
GList *associations;
|
||||
|
||||
GHashTable *id_index;
|
||||
};
|
||||
|
||||
struct _GstMemIndexClass {
|
||||
GstIndexClass parent_class;
|
||||
};
|
||||
|
||||
/* Index signals and args */
|
||||
enum {
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
enum {
|
||||
ARG_0,
|
||||
/* FILL ME */
|
||||
};
|
||||
|
||||
static void gst_mem_index_class_init (GstMemIndexClass *klass);
|
||||
static void gst_mem_index_init (GstMemIndex *index);
|
||||
static void gst_mem_index_dispose (GObject *object);
|
||||
|
||||
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,
|
||||
GstFormat format, gint64 value,
|
||||
GCompareDataFunc func,
|
||||
gpointer user_data);
|
||||
|
||||
#define CLASS(mem_index) GST_MEM_INDEX_CLASS (G_OBJECT_GET_CLASS (mem_index))
|
||||
|
||||
static GstIndex *parent_class = NULL;
|
||||
/*static guint gst_mem_index_signals[LAST_SIGNAL] = { 0 }; */
|
||||
|
||||
GType
|
||||
gst_mem_index_get_type(void) {
|
||||
static GType mem_index_type = 0;
|
||||
|
||||
if (!mem_index_type) {
|
||||
static const GTypeInfo mem_index_info = {
|
||||
sizeof(GstMemIndexClass),
|
||||
NULL,
|
||||
NULL,
|
||||
(GClassInitFunc)gst_mem_index_class_init,
|
||||
NULL,
|
||||
NULL,
|
||||
sizeof(GstMemIndex),
|
||||
1,
|
||||
(GInstanceInitFunc)gst_mem_index_init,
|
||||
NULL
|
||||
};
|
||||
mem_index_type = g_type_register_static(GST_TYPE_INDEX, "GstMemIndex", &mem_index_info, 0);
|
||||
}
|
||||
return mem_index_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_mem_index_class_init (GstMemIndexClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class;
|
||||
GstIndexClass *gstindex_class;
|
||||
|
||||
gobject_class = (GObjectClass*)klass;
|
||||
gstindex_class = (GstIndexClass*)klass;
|
||||
|
||||
parent_class = g_type_class_ref(GST_TYPE_INDEX);
|
||||
|
||||
gobject_class->dispose = gst_mem_index_dispose;
|
||||
|
||||
gstindex_class->add_entry = gst_mem_index_add_entry;
|
||||
gstindex_class->get_assoc_entry = gst_mem_index_get_assoc_entry;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_mem_index_init (GstMemIndex *index)
|
||||
{
|
||||
GST_DEBUG(0, "created new mem index");
|
||||
|
||||
index->associations = NULL;
|
||||
index->id_index = g_hash_table_new (g_int_hash, g_int_equal);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_mem_index_dispose (GObject *object)
|
||||
{
|
||||
//GstMemIndex *memindex = GST_MEM_INDEX (object);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_mem_index_add_id (GstIndex *index, GstIndexEntry *entry)
|
||||
{
|
||||
GstMemIndex *memindex = GST_MEM_INDEX (index);
|
||||
GstMemIndexId *id_index;
|
||||
|
||||
id_index = g_hash_table_lookup (memindex->id_index, &entry->id);
|
||||
|
||||
if (!id_index) {
|
||||
id_index = g_new0 (GstMemIndexId, 1);
|
||||
|
||||
id_index->id = entry->id;
|
||||
id_index->format_index = g_hash_table_new (g_int_hash, g_int_equal);
|
||||
g_hash_table_insert (memindex->id_index, &entry->id, id_index);
|
||||
}
|
||||
}
|
||||
|
||||
static gint
|
||||
mem_index_compare (gconstpointer a,
|
||||
gconstpointer b,
|
||||
gpointer user_data)
|
||||
{
|
||||
GstMemIndexFormatIndex *index = user_data;
|
||||
gint64 val1, val2;
|
||||
gint64 diff;
|
||||
|
||||
val1 = GST_INDEX_ASSOC_VALUE (((GstIndexEntry *)a), index->offset);
|
||||
val2 = GST_INDEX_ASSOC_VALUE (((GstIndexEntry *)b), index->offset);
|
||||
|
||||
diff = (val2 - val1);
|
||||
|
||||
return (diff == 0 ? 0 : (diff > 0 ? 1 : -1));
|
||||
}
|
||||
|
||||
static void
|
||||
gst_mem_index_index_format (GstMemIndexId *id_index, GstIndexEntry *entry, gint assoc)
|
||||
{
|
||||
GstMemIndexFormatIndex *index;
|
||||
GstFormat *format;
|
||||
|
||||
format = &GST_INDEX_ASSOC_FORMAT (entry, assoc);
|
||||
|
||||
index = g_hash_table_lookup (id_index->format_index, format);
|
||||
|
||||
if (!index) {
|
||||
index = g_new0 (GstMemIndexFormatIndex, 1);
|
||||
|
||||
index->format = *format;
|
||||
index->offset = assoc;
|
||||
index->tree = g_tree_new_with_data (mem_index_compare, index);
|
||||
|
||||
g_hash_table_insert (id_index->format_index, format, index);
|
||||
}
|
||||
|
||||
g_tree_insert (index->tree, entry, entry);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_mem_index_add_association (GstIndex *index, GstIndexEntry *entry)
|
||||
{
|
||||
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
|
||||
gst_mem_index_add_object (GstIndex *index, GstIndexEntry *entry)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gst_mem_index_add_format (GstIndex *index, GstIndexEntry *entry)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gst_mem_index_add_entry (GstIndex *index, GstIndexEntry *entry)
|
||||
{
|
||||
GstMemIndex *memindex = GST_MEM_INDEX (index);
|
||||
|
||||
GST_DEBUG (0, "adding entry %p\n", memindex);
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
gint64 value;
|
||||
GstMemIndexFormatIndex *index;
|
||||
gboolean exact;
|
||||
GstIndexEntry *lower;
|
||||
gint64 low_diff;
|
||||
GstIndexEntry *higher;
|
||||
gint64 high_diff;
|
||||
} GstMemIndexSearchData;
|
||||
|
||||
static gint
|
||||
mem_index_search (gconstpointer a,
|
||||
gconstpointer b)
|
||||
{
|
||||
GstMemIndexSearchData *data = (GstMemIndexSearchData *) b;
|
||||
GstMemIndexFormatIndex *index = data->index;
|
||||
gint64 val1, val2;
|
||||
gint64 diff;
|
||||
|
||||
val1 = GST_INDEX_ASSOC_VALUE (((GstIndexEntry *)a), index->offset);
|
||||
val2 = data->value;
|
||||
|
||||
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;
|
||||
}
|
||||
else {
|
||||
if (diff < data->high_diff) {
|
||||
data->high_diff = diff;
|
||||
data->higher = (GstIndexEntry *) a;
|
||||
}
|
||||
diff = 1;
|
||||
}
|
||||
|
||||
return diff;
|
||||
}
|
||||
|
||||
static GstIndexEntry*
|
||||
gst_mem_index_get_assoc_entry (GstIndex *index, gint id,
|
||||
GstIndexLookupMethod method,
|
||||
GstFormat format, gint64 value,
|
||||
GCompareDataFunc func,
|
||||
gpointer user_data)
|
||||
{
|
||||
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);
|
||||
|
||||
/* setup data for low/high checks if we are not looking
|
||||
* 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 */
|
||||
if (entry == NULL && !data.exact) {
|
||||
if (method == GST_INDEX_LOOKUP_BEFORE)
|
||||
entry = data.lower;
|
||||
else if (method == GST_INDEX_LOOKUP_AFTER) {
|
||||
entry = data.higher;
|
||||
}
|
||||
}
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
plugin_init (GModule *module, GstPlugin *plugin)
|
||||
{
|
||||
GstIndexFactory *factory;
|
||||
|
||||
gst_plugin_set_longname (plugin, "A memory index");
|
||||
|
||||
factory = gst_index_factory_new ("memindex",
|
||||
"A index that stores entries in memory",
|
||||
gst_mem_index_get_type());
|
||||
|
||||
if (factory != NULL) {
|
||||
gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory));
|
||||
}
|
||||
else {
|
||||
g_warning ("could not register memindex");
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
GstPluginDesc plugin_desc = {
|
||||
GST_VERSION_MAJOR,
|
||||
GST_VERSION_MINOR,
|
||||
"gstindexs",
|
||||
plugin_init
|
||||
};
|
||||
|
|
@ -755,10 +755,10 @@ gst_xml_registry_parse_autoplug_factory (GMarkupParseContext *context, const gch
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gst_xml_registry_parse_cache_factory (GMarkupParseContext *context, const gchar *tag, const gchar *text,
|
||||
gst_xml_registry_parse_index_factory (GMarkupParseContext *context, const gchar *tag, const gchar *text,
|
||||
gsize text_len, GstXMLRegistry *registry, GError **error)
|
||||
{
|
||||
GstCacheFactory *factory = GST_CACHE_FACTORY (registry->current_feature);
|
||||
GstIndexFactory *factory = GST_INDEX_FACTORY (registry->current_feature);
|
||||
|
||||
if (!strcmp (tag, "name")) {
|
||||
registry->current_feature->name = g_strndup (text, text_len);
|
||||
|
@ -882,8 +882,8 @@ gst_xml_registry_start_element (GMarkupParseContext *context,
|
|||
}
|
||||
else if (GST_IS_AUTOPLUG_FACTORY (feature))
|
||||
xmlregistry->parser = gst_xml_registry_parse_autoplug_factory;
|
||||
else if (GST_IS_CACHE_FACTORY (feature))
|
||||
xmlregistry->parser = gst_xml_registry_parse_cache_factory;
|
||||
else if (GST_IS_INDEX_FACTORY (feature))
|
||||
xmlregistry->parser = gst_xml_registry_parse_index_factory;
|
||||
else {
|
||||
g_warning ("unkown feature type");
|
||||
}
|
||||
|
@ -1408,8 +1408,8 @@ gst_xml_registry_save_feature (GstXMLRegistry *xmlregistry, GstPluginFeature *fe
|
|||
else if (GST_IS_AUTOPLUG_FACTORY (feature)) {
|
||||
PUT_ESCAPED ("longdesc", GST_AUTOPLUG_FACTORY (feature)->longdesc);
|
||||
}
|
||||
else if (GST_IS_CACHE_FACTORY (feature)) {
|
||||
PUT_ESCAPED ("longdesc", GST_CACHE_FACTORY (feature)->longdesc);
|
||||
else if (GST_IS_INDEX_FACTORY (feature)) {
|
||||
PUT_ESCAPED ("longdesc", GST_INDEX_FACTORY (feature)->longdesc);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
|
8
plugins/indexers/Makefile.am
Normal file
8
plugins/indexers/Makefile.am
Normal file
|
@ -0,0 +1,8 @@
|
|||
plugindir = $(libdir)/gstreamer-@GST_MAJORMINOR@
|
||||
|
||||
plugin_LTLIBRARIES = libgstindexers.la
|
||||
|
||||
libgstindexers_la_SOURCES = gstmemindex.c
|
||||
libgstindexers_la_CFLAGS = $(GST_CFLAGS)
|
||||
libgstindexers_la_LIBADD =
|
||||
libgstindexers_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
|
407
plugins/indexers/gstmemindex.c
Normal file
407
plugins/indexers/gstmemindex.c
Normal file
|
@ -0,0 +1,407 @@
|
|||
/* 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.
|
||||
*/
|
||||
|
||||
#include <gst/gst_private.h>
|
||||
#include <gst/gstversion.h>
|
||||
#include <gst/gstplugin.h>
|
||||
#include <gst/gstindex.h>
|
||||
|
||||
#define GST_TYPE_MEM_INDEX \
|
||||
(gst_index_get_type ())
|
||||
#define GST_MEM_INDEX(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_MEM_INDEX, GstMemIndex))
|
||||
#define GST_MEM_INDEX_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_MEM_INDEX, GstMemIndexClass))
|
||||
#define GST_IS_MEM_INDEX(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_MEM_INDEX))
|
||||
#define GST_IS_MEM_INDEX_CLASS(obj) \
|
||||
(GST_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_MEM_INDEX))
|
||||
|
||||
/*
|
||||
* Object model:
|
||||
*
|
||||
* All entries are simply added to a GList first. Then we build
|
||||
* an index to each entry for each id/format
|
||||
*
|
||||
*
|
||||
* memindex
|
||||
* -----------------------------...
|
||||
* ! !
|
||||
* id1 id2
|
||||
* ------------
|
||||
* ! !
|
||||
* 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.
|
||||
*
|
||||
* The MemIndexFormatIndex keeps all the values of the particular
|
||||
* format in a GTree, The values of the GTree point back to the entry.
|
||||
*
|
||||
* Finding a value for an id/format requires locating the correct GTree,
|
||||
* then do a lookup in the Tree to get the required value.
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
GstFormat format;
|
||||
gint offset;
|
||||
GTree *tree;
|
||||
} GstMemIndexFormatIndex;
|
||||
|
||||
typedef struct {
|
||||
gint id;
|
||||
GHashTable *format_index;
|
||||
} GstMemIndexId;
|
||||
|
||||
typedef struct _GstMemIndex GstMemIndex;
|
||||
typedef struct _GstMemIndexClass GstMemIndexClass;
|
||||
|
||||
struct _GstMemIndex {
|
||||
GstIndex parent;
|
||||
|
||||
GList *associations;
|
||||
|
||||
GHashTable *id_index;
|
||||
};
|
||||
|
||||
struct _GstMemIndexClass {
|
||||
GstIndexClass parent_class;
|
||||
};
|
||||
|
||||
/* Index signals and args */
|
||||
enum {
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
enum {
|
||||
ARG_0,
|
||||
/* FILL ME */
|
||||
};
|
||||
|
||||
static void gst_mem_index_class_init (GstMemIndexClass *klass);
|
||||
static void gst_mem_index_init (GstMemIndex *index);
|
||||
static void gst_mem_index_dispose (GObject *object);
|
||||
|
||||
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,
|
||||
GstFormat format, gint64 value,
|
||||
GCompareDataFunc func,
|
||||
gpointer user_data);
|
||||
|
||||
#define CLASS(mem_index) GST_MEM_INDEX_CLASS (G_OBJECT_GET_CLASS (mem_index))
|
||||
|
||||
static GstIndex *parent_class = NULL;
|
||||
/*static guint gst_mem_index_signals[LAST_SIGNAL] = { 0 }; */
|
||||
|
||||
GType
|
||||
gst_mem_index_get_type(void) {
|
||||
static GType mem_index_type = 0;
|
||||
|
||||
if (!mem_index_type) {
|
||||
static const GTypeInfo mem_index_info = {
|
||||
sizeof(GstMemIndexClass),
|
||||
NULL,
|
||||
NULL,
|
||||
(GClassInitFunc)gst_mem_index_class_init,
|
||||
NULL,
|
||||
NULL,
|
||||
sizeof(GstMemIndex),
|
||||
1,
|
||||
(GInstanceInitFunc)gst_mem_index_init,
|
||||
NULL
|
||||
};
|
||||
mem_index_type = g_type_register_static(GST_TYPE_INDEX, "GstMemIndex", &mem_index_info, 0);
|
||||
}
|
||||
return mem_index_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_mem_index_class_init (GstMemIndexClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class;
|
||||
GstIndexClass *gstindex_class;
|
||||
|
||||
gobject_class = (GObjectClass*)klass;
|
||||
gstindex_class = (GstIndexClass*)klass;
|
||||
|
||||
parent_class = g_type_class_ref(GST_TYPE_INDEX);
|
||||
|
||||
gobject_class->dispose = gst_mem_index_dispose;
|
||||
|
||||
gstindex_class->add_entry = gst_mem_index_add_entry;
|
||||
gstindex_class->get_assoc_entry = gst_mem_index_get_assoc_entry;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_mem_index_init (GstMemIndex *index)
|
||||
{
|
||||
GST_DEBUG(0, "created new mem index");
|
||||
|
||||
index->associations = NULL;
|
||||
index->id_index = g_hash_table_new (g_int_hash, g_int_equal);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_mem_index_dispose (GObject *object)
|
||||
{
|
||||
//GstMemIndex *memindex = GST_MEM_INDEX (object);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_mem_index_add_id (GstIndex *index, GstIndexEntry *entry)
|
||||
{
|
||||
GstMemIndex *memindex = GST_MEM_INDEX (index);
|
||||
GstMemIndexId *id_index;
|
||||
|
||||
id_index = g_hash_table_lookup (memindex->id_index, &entry->id);
|
||||
|
||||
if (!id_index) {
|
||||
id_index = g_new0 (GstMemIndexId, 1);
|
||||
|
||||
id_index->id = entry->id;
|
||||
id_index->format_index = g_hash_table_new (g_int_hash, g_int_equal);
|
||||
g_hash_table_insert (memindex->id_index, &entry->id, id_index);
|
||||
}
|
||||
}
|
||||
|
||||
static gint
|
||||
mem_index_compare (gconstpointer a,
|
||||
gconstpointer b,
|
||||
gpointer user_data)
|
||||
{
|
||||
GstMemIndexFormatIndex *index = user_data;
|
||||
gint64 val1, val2;
|
||||
gint64 diff;
|
||||
|
||||
val1 = GST_INDEX_ASSOC_VALUE (((GstIndexEntry *)a), index->offset);
|
||||
val2 = GST_INDEX_ASSOC_VALUE (((GstIndexEntry *)b), index->offset);
|
||||
|
||||
diff = (val2 - val1);
|
||||
|
||||
return (diff == 0 ? 0 : (diff > 0 ? 1 : -1));
|
||||
}
|
||||
|
||||
static void
|
||||
gst_mem_index_index_format (GstMemIndexId *id_index, GstIndexEntry *entry, gint assoc)
|
||||
{
|
||||
GstMemIndexFormatIndex *index;
|
||||
GstFormat *format;
|
||||
|
||||
format = &GST_INDEX_ASSOC_FORMAT (entry, assoc);
|
||||
|
||||
index = g_hash_table_lookup (id_index->format_index, format);
|
||||
|
||||
if (!index) {
|
||||
index = g_new0 (GstMemIndexFormatIndex, 1);
|
||||
|
||||
index->format = *format;
|
||||
index->offset = assoc;
|
||||
index->tree = g_tree_new_with_data (mem_index_compare, index);
|
||||
|
||||
g_hash_table_insert (id_index->format_index, format, index);
|
||||
}
|
||||
|
||||
g_tree_insert (index->tree, entry, entry);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_mem_index_add_association (GstIndex *index, GstIndexEntry *entry)
|
||||
{
|
||||
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
|
||||
gst_mem_index_add_object (GstIndex *index, GstIndexEntry *entry)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gst_mem_index_add_format (GstIndex *index, GstIndexEntry *entry)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gst_mem_index_add_entry (GstIndex *index, GstIndexEntry *entry)
|
||||
{
|
||||
GstMemIndex *memindex = GST_MEM_INDEX (index);
|
||||
|
||||
GST_DEBUG (0, "adding entry %p\n", memindex);
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
gint64 value;
|
||||
GstMemIndexFormatIndex *index;
|
||||
gboolean exact;
|
||||
GstIndexEntry *lower;
|
||||
gint64 low_diff;
|
||||
GstIndexEntry *higher;
|
||||
gint64 high_diff;
|
||||
} GstMemIndexSearchData;
|
||||
|
||||
static gint
|
||||
mem_index_search (gconstpointer a,
|
||||
gconstpointer b)
|
||||
{
|
||||
GstMemIndexSearchData *data = (GstMemIndexSearchData *) b;
|
||||
GstMemIndexFormatIndex *index = data->index;
|
||||
gint64 val1, val2;
|
||||
gint64 diff;
|
||||
|
||||
val1 = GST_INDEX_ASSOC_VALUE (((GstIndexEntry *)a), index->offset);
|
||||
val2 = data->value;
|
||||
|
||||
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;
|
||||
}
|
||||
else {
|
||||
if (diff < data->high_diff) {
|
||||
data->high_diff = diff;
|
||||
data->higher = (GstIndexEntry *) a;
|
||||
}
|
||||
diff = 1;
|
||||
}
|
||||
|
||||
return diff;
|
||||
}
|
||||
|
||||
static GstIndexEntry*
|
||||
gst_mem_index_get_assoc_entry (GstIndex *index, gint id,
|
||||
GstIndexLookupMethod method,
|
||||
GstFormat format, gint64 value,
|
||||
GCompareDataFunc func,
|
||||
gpointer user_data)
|
||||
{
|
||||
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);
|
||||
|
||||
/* setup data for low/high checks if we are not looking
|
||||
* 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 */
|
||||
if (entry == NULL && !data.exact) {
|
||||
if (method == GST_INDEX_LOOKUP_BEFORE)
|
||||
entry = data.lower;
|
||||
else if (method == GST_INDEX_LOOKUP_AFTER) {
|
||||
entry = data.higher;
|
||||
}
|
||||
}
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
plugin_init (GModule *module, GstPlugin *plugin)
|
||||
{
|
||||
GstIndexFactory *factory;
|
||||
|
||||
gst_plugin_set_longname (plugin, "A memory index");
|
||||
|
||||
factory = gst_index_factory_new ("memindex",
|
||||
"A index that stores entries in memory",
|
||||
gst_mem_index_get_type());
|
||||
|
||||
if (factory != NULL) {
|
||||
gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory));
|
||||
}
|
||||
else {
|
||||
g_warning ("could not register memindex");
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
GstPluginDesc plugin_desc = {
|
||||
GST_VERSION_MAJOR,
|
||||
GST_VERSION_MINOR,
|
||||
"gstindexs",
|
||||
plugin_init
|
||||
};
|
||||
|
|
@ -817,10 +817,10 @@ print_element_list (void)
|
|||
g_print ("%s: %s: %s\n", plugin->name,
|
||||
GST_PLUGIN_FEATURE_NAME (factory), factory->longdesc);
|
||||
}
|
||||
else if (GST_IS_CACHE_FACTORY (feature)) {
|
||||
GstCacheFactory *factory;
|
||||
else if (GST_IS_INDEX_FACTORY (feature)) {
|
||||
GstIndexFactory *factory;
|
||||
|
||||
factory = GST_CACHE_FACTORY (feature);
|
||||
factory = GST_INDEX_FACTORY (feature);
|
||||
g_print ("%s: %s: %s\n", plugin->name,
|
||||
GST_PLUGIN_FEATURE_NAME (factory), factory->longdesc);
|
||||
}
|
||||
|
@ -862,7 +862,7 @@ print_plugin_info (GstPlugin *plugin)
|
|||
gint num_autoplug = 0;
|
||||
gint num_types = 0;
|
||||
gint num_schedulers = 0;
|
||||
gint num_caches = 0;
|
||||
gint num_indexes = 0;
|
||||
gint num_other = 0;
|
||||
|
||||
g_print ("Plugin Details:\n");
|
||||
|
@ -893,12 +893,12 @@ print_plugin_info (GstPlugin *plugin)
|
|||
g_print (" %s: %s\n", GST_OBJECT_NAME (factory), factory->longdesc);
|
||||
num_autoplug++;
|
||||
}
|
||||
else if (GST_IS_CACHE_FACTORY (feature)) {
|
||||
GstCacheFactory *factory;
|
||||
else if (GST_IS_INDEX_FACTORY (feature)) {
|
||||
GstIndexFactory *factory;
|
||||
|
||||
factory = GST_CACHE_FACTORY (feature);
|
||||
factory = GST_INDEX_FACTORY (feature);
|
||||
g_print (" %s: %s\n", GST_OBJECT_NAME (factory), factory->longdesc);
|
||||
num_caches++;
|
||||
num_indexes++;
|
||||
}
|
||||
else if (GST_IS_TYPE_FACTORY (feature)) {
|
||||
GstTypeFactory *factory;
|
||||
|
@ -935,8 +935,8 @@ print_plugin_info (GstPlugin *plugin)
|
|||
g_print (" +-- %d types\n", num_types);
|
||||
if (num_schedulers > 0)
|
||||
g_print (" +-- %d schedulers\n", num_schedulers);
|
||||
if (num_caches > 0)
|
||||
g_print (" +-- %d caches\n", num_caches);
|
||||
if (num_indexes > 0)
|
||||
g_print (" +-- %d indexes\n", num_indexes);
|
||||
if (num_other > 0)
|
||||
g_print (" +-- %d other objects\n", num_other);
|
||||
|
||||
|
|
Loading…
Reference in a new issue