2 * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3 * 2000 Wim Taymans <wim.taymans@chello.be>
5 * gstindex.h: Header for GstIndex, base class to handle efficient
6 * storage or caching of seeking information.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 * Boston, MA 02111-1307, USA.
24 #ifndef __GST_INDEX_H__
25 #define __GST_INDEX_H__
27 #include <gst/gstobject.h>
28 #include <gst/gstformat.h>
29 #include <gst/gstpluginfeature.h>
33 #define GST_TYPE_INDEX (gst_index_get_type ())
34 #define GST_INDEX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_INDEX, GstIndex))
35 #define GST_IS_INDEX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_INDEX))
36 #define GST_INDEX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_INDEX, GstIndexClass))
37 #define GST_IS_INDEX_CLASS(klass) (GST_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_INDEX))
38 #define GST_INDEX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_INDEX, GstIndexClass))
40 typedef struct _GstIndexEntry GstIndexEntry;
41 typedef struct _GstIndexGroup GstIndexGroup;
42 typedef struct _GstIndex GstIndex;
43 typedef struct _GstIndexClass GstIndexClass;
53 GST_INDEX_ENTRY_ASSOCIATION,
54 GST_INDEX_ENTRY_OBJECT,
55 GST_INDEX_ENTRY_FORMAT
59 GST_INDEX_LOOKUP_EXACT,
60 GST_INDEX_LOOKUP_BEFORE,
61 GST_INDEX_LOOKUP_AFTER
62 } GstIndexLookupMethod;
64 #define GST_INDEX_NASSOCS(entry) ((entry)->data.assoc.nassocs)
65 #define GST_INDEX_ASSOC_FLAGS(entry) ((entry)->data.assoc.flags)
66 #define GST_INDEX_ASSOC_FORMAT(entry,i) ((entry)->data.assoc.assocs[(i)].format)
67 #define GST_INDEX_ASSOC_VALUE(entry,i) ((entry)->data.assoc.assocs[(i)].value)
69 typedef struct _GstIndexAssociation GstIndexAssociation;
71 struct _GstIndexAssociation {
77 GST_ASSOCIATION_FLAG_NONE = 0,
78 GST_ASSOCIATION_FLAG_KEY_UNIT = (1 << 0),
80 /* new flags should start here */
81 GST_ASSOCIATION_FLAG_LAST = (1 << 8)
84 #define GST_INDEX_FORMAT_FORMAT(entry) ((entry)->data.format.format)
85 #define GST_INDEX_FORMAT_KEY(entry) ((entry)->data.format.key)
87 #define GST_INDEX_ID_INVALID (-1)
89 #define GST_INDEX_ID_DESCRIPTION(entry) ((entry)->data.id.description)
91 struct _GstIndexEntry {
92 GstIndexEntryType type;
117 struct _GstIndexGroup {
118 /* unique ID of group in index */
121 /* list of entries */
124 /* the certainty level of the group */
125 GstIndexCertainty certainty;
127 /* peer group that contains more certain entries */
131 typedef gboolean (*GstIndexFilter) (GstIndex *index,
132 GstIndexEntry *entry);
135 GST_INDEX_RESOLVER_CUSTOM,
136 GST_INDEX_RESOLVER_GTYPE,
137 GST_INDEX_RESOLVER_PATH
138 } GstIndexResolverMethod;
140 typedef gboolean (*GstIndexResolver) (GstIndex *index,
142 gchar **writer_string,
145 GST_INDEX_WRITABLE = GST_OBJECT_FLAG_LAST,
148 GST_INDEX_FLAG_LAST = GST_OBJECT_FLAG_LAST + 8
151 #define GST_INDEX_IS_READABLE(obj) (GST_FLAG_IS_SET (obj, GST_INDEX_READABLE))
152 #define GST_INDEX_IS_WRITABLE(obj) (GST_FLAG_IS_SET (obj, GST_INDEX_WRITABLE))
158 GstIndexGroup *curgroup;
161 GstIndexResolverMethod method;
162 GstIndexResolver resolver;
163 gpointer resolver_user_data;
165 GstIndexFilter filter;
166 gpointer filter_user_data;
171 gpointer _gst_reserved[GST_PADDING];
174 struct _GstIndexClass {
175 GstObjectClass parent_class;
177 gboolean (*get_writer_id) (GstIndex *index, gint *writer_id, gchar *writer_string);
179 void (*commit) (GstIndex *index, gint id);
181 /* abstract methods */
182 void (*add_entry) (GstIndex *index, GstIndexEntry *entry);
184 GstIndexEntry* (*get_assoc_entry) (GstIndex *index, gint id,
185 GstIndexLookupMethod method, GstAssocFlags flags,
186 GstFormat format, gint64 value,
187 GCompareDataFunc func,
190 void (*entry_added) (GstIndex *index, GstIndexEntry *entry);
192 gpointer _gst_reserved[GST_PADDING];
195 GType gst_index_get_type (void);
196 GstIndex* gst_index_new (void);
197 void gst_index_commit (GstIndex *index, gint id);
199 gint gst_index_get_group (GstIndex *index);
200 gint gst_index_new_group (GstIndex *index);
201 gboolean gst_index_set_group (GstIndex *index, gint groupnum);
203 void gst_index_set_certainty (GstIndex *index,
204 GstIndexCertainty certainty);
205 GstIndexCertainty gst_index_get_certainty (GstIndex *index);
207 void gst_index_set_filter (GstIndex *index,
208 GstIndexFilter filter, gpointer user_data);
209 void gst_index_set_resolver (GstIndex *index,
210 GstIndexResolver resolver, gpointer user_data);
212 gboolean gst_index_get_writer_id (GstIndex *index, GstObject *writer, gint *id);
214 GstIndexEntry* gst_index_add_format (GstIndex *index, gint id, GstFormat format);
215 GstIndexEntry* gst_index_add_association (GstIndex *index, gint id, GstAssocFlags flags,
216 GstFormat format, gint64 value, ...);
217 GstIndexEntry* gst_index_add_object (GstIndex *index, gint id, gchar *key,
218 GType type, gpointer object);
219 GstIndexEntry* gst_index_add_id (GstIndex *index, gint id,
222 GstIndexEntry* gst_index_get_assoc_entry (GstIndex *index, gint id,
223 GstIndexLookupMethod method, GstAssocFlags flags,
224 GstFormat format, gint64 value);
225 GstIndexEntry* gst_index_get_assoc_entry_full (GstIndex *index, gint id,
226 GstIndexLookupMethod method, GstAssocFlags flags,
227 GstFormat format, gint64 value,
228 GCompareDataFunc func,
231 /* working with index entries */
232 GstIndexEntry * gst_index_entry_copy (GstIndexEntry *entry);
233 void gst_index_entry_free (GstIndexEntry *entry);
234 gboolean gst_index_entry_assoc_map (GstIndexEntry *entry,
235 GstFormat format, gint64 *value);
240 #define GST_TYPE_INDEX_FACTORY (gst_index_factory_get_type())
241 #define GST_INDEX_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_INDEX_FACTORY, GstIndexFactory))
242 #define GST_IS_INDEX_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_INDEX_FACTORY))
243 #define GST_INDEX_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_INDEX_FACTORY, GstIndexFactoryClass))
244 #define GST_IS_INDEX_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_INDEX_FACTORY))
245 #define GST_INDEX_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_INDEX_FACTORY, GstIndexFactoryClass))
247 typedef struct _GstIndexFactory GstIndexFactory;
248 typedef struct _GstIndexFactoryClass GstIndexFactoryClass;
250 struct _GstIndexFactory {
251 GstPluginFeature feature;
253 gchar *longdesc; /* long description of the index (well, don't overdo it..) */
254 GType type; /* unique GType of the index */
256 gpointer _gst_reserved[GST_PADDING];
259 struct _GstIndexFactoryClass {
260 GstPluginFeatureClass parent;
262 gpointer _gst_reserved[GST_PADDING];
265 GType gst_index_factory_get_type (void);
267 GstIndexFactory* gst_index_factory_new (const gchar *name,
268 const gchar *longdesc, GType type);
269 void gst_index_factory_destroy (GstIndexFactory *factory);
271 GstIndexFactory* gst_index_factory_find (const gchar *name);
273 GstIndex* gst_index_factory_create (GstIndexFactory *factory);
274 GstIndex* gst_index_factory_make (const gchar *name);
278 #endif /* __GST_INDEX_H__ */