fix doc build fix autogen
[platform/upstream/gstreamer.git] / gst / gstindex.h
1 /* GStreamer
2  * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3  *                    2000 Wim Taymans <wim.taymans@chello.be>
4  *
5  * gstindex.h: Header for GstIndex, base class to handle efficient
6  *             storage or caching of seeking information.
7  *
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.
12  *
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.
17  *
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.
22  */
23
24 #ifndef __GST_INDEX_H__
25 #define __GST_INDEX_H__
26
27 #include <gst/gstobject.h>
28 #include <gst/gstformat.h>
29 #include <gst/gstpluginfeature.h>
30
31 G_BEGIN_DECLS
32
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))
39
40 typedef struct _GstIndexEntry GstIndexEntry;
41 typedef struct _GstIndexGroup GstIndexGroup;
42 typedef struct _GstIndex GstIndex;
43 typedef struct _GstIndexClass GstIndexClass;
44
45 typedef enum {
46   GST_INDEX_UNKNOWN,
47   GST_INDEX_CERTAIN,
48   GST_INDEX_FUZZY
49 } GstIndexCertainty;
50
51 typedef enum {
52   GST_INDEX_ENTRY_ID,
53   GST_INDEX_ENTRY_ASSOCIATION,
54   GST_INDEX_ENTRY_OBJECT,
55   GST_INDEX_ENTRY_FORMAT
56 } GstIndexEntryType;
57
58 typedef enum {
59   GST_INDEX_LOOKUP_EXACT,
60   GST_INDEX_LOOKUP_BEFORE,
61   GST_INDEX_LOOKUP_AFTER
62 } GstIndexLookupMethod;
63
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)
68
69 typedef struct _GstIndexAssociation GstIndexAssociation;
70
71 struct _GstIndexAssociation {
72   GstFormat     format;
73   gint64        value;
74 };
75
76 typedef enum {
77   GST_ASSOCIATION_FLAG_NONE     = 0,
78   GST_ASSOCIATION_FLAG_KEY_UNIT = (1 << 0),
79
80   /* new flags should start here */
81   GST_ASSOCIATION_FLAG_LAST     = (1 << 8)
82 } GstAssocFlags;
83
84 #define GST_INDEX_FORMAT_FORMAT(entry)          ((entry)->data.format.format)
85 #define GST_INDEX_FORMAT_KEY(entry)             ((entry)->data.format.key)
86
87 #define GST_INDEX_ID_INVALID                    (-1)
88
89 #define GST_INDEX_ID_DESCRIPTION(entry)         ((entry)->data.id.description)
90
91 struct _GstIndexEntry {
92   GstIndexEntryType      type;
93   gint                   id;
94
95   union {
96     struct {
97       gchar             *description;
98     } id;
99     struct {
100       gint               nassocs;
101       GstIndexAssociation 
102                         *assocs;
103       GstAssocFlags      flags;
104     } assoc;
105     struct {
106       gchar             *key;
107       GType              type;
108       gpointer           object;
109     } object;
110     struct {
111       GstFormat          format;
112       gchar             *key;
113     } format;
114   } data;
115 };
116
117 struct _GstIndexGroup {
118   /* unique ID of group in index */
119   gint groupnum;
120
121   /* list of entries */
122   GList *entries;
123
124   /* the certainty level of the group */
125   GstIndexCertainty certainty;
126
127   /* peer group that contains more certain entries */
128   gint peergroup;
129 };
130
131 typedef gboolean        (*GstIndexFilter)               (GstIndex *index, 
132                                                          GstIndexEntry *entry);
133
134 typedef enum {
135   GST_INDEX_RESOLVER_CUSTOM,
136   GST_INDEX_RESOLVER_GTYPE,
137   GST_INDEX_RESOLVER_PATH
138 } GstIndexResolverMethod;
139
140 typedef gboolean        (*GstIndexResolver)             (GstIndex *index, 
141                                                          GstObject *writer, 
142                                                          gchar **writer_string,
143                                                          gpointer user_data);
144 typedef enum {
145   GST_INDEX_WRITABLE            = GST_OBJECT_FLAG_LAST, 
146   GST_INDEX_READABLE,   
147
148   GST_INDEX_FLAG_LAST           = GST_OBJECT_FLAG_LAST + 8
149 } GstIndexFlags;
150
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))
153
154 struct _GstIndex {
155   GstObject              object;
156
157   GList                 *groups;
158   GstIndexGroup         *curgroup;
159   gint                   maxgroup;
160
161   GstIndexResolverMethod method;
162   GstIndexResolver       resolver;
163   gpointer               resolver_user_data;
164
165   GstIndexFilter         filter;
166   gpointer               filter_user_data;
167
168   GHashTable            *writers;
169   gint                   last_id;
170
171   gpointer _gst_reserved[GST_PADDING];
172 };
173
174 struct _GstIndexClass {
175   GstObjectClass parent_class;
176
177   gboolean      (*get_writer_id)        (GstIndex *index, gint *writer_id, gchar *writer_string);
178
179   void          (*commit)               (GstIndex *index, gint id);
180
181   /* abstract methods */
182   void          (*add_entry)            (GstIndex *index, GstIndexEntry *entry);
183
184   GstIndexEntry* (*get_assoc_entry)     (GstIndex *index, gint id, 
185                                          GstIndexLookupMethod method, GstAssocFlags flags,
186                                          GstFormat format, gint64 value,
187                                          GCompareDataFunc func,
188                                          gpointer user_data); 
189   /* signals */
190   void          (*entry_added)          (GstIndex *index, GstIndexEntry *entry);
191
192   gpointer _gst_reserved[GST_PADDING];
193 };
194
195 GType                   gst_index_get_type              (void);
196 GstIndex*               gst_index_new                   (void);
197 void                    gst_index_commit                (GstIndex *index, gint id);
198
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);
202
203 void                    gst_index_set_certainty         (GstIndex *index, 
204                                                          GstIndexCertainty certainty);
205 GstIndexCertainty       gst_index_get_certainty         (GstIndex *index);
206
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);
211
212 gboolean                gst_index_get_writer_id         (GstIndex *index, GstObject *writer, gint *id);
213
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,
220                                                          gchar *description); 
221
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,
229                                                          gpointer user_data);
230
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);
236 /*
237  * creating indexs
238  *
239  */
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))
246
247 typedef struct _GstIndexFactory GstIndexFactory;
248 typedef struct _GstIndexFactoryClass GstIndexFactoryClass;
249
250 struct _GstIndexFactory {
251   GstPluginFeature feature;
252             
253   gchar *longdesc;            /* long description of the index (well, don't overdo it..) */
254   GType type;                 /* unique GType of the index */
255
256   gpointer _gst_reserved[GST_PADDING];
257 };
258
259 struct _GstIndexFactoryClass {
260   GstPluginFeatureClass parent; 
261
262   gpointer _gst_reserved[GST_PADDING];
263 };
264
265 GType                   gst_index_factory_get_type      (void);
266
267 GstIndexFactory*        gst_index_factory_new           (const gchar *name, 
268                                                          const gchar *longdesc, GType type);
269 void                    gst_index_factory_destroy       (GstIndexFactory *factory);
270
271 GstIndexFactory*        gst_index_factory_find          (const gchar *name);
272
273 GstIndex*               gst_index_factory_create        (GstIndexFactory *factory);
274 GstIndex*               gst_index_factory_make          (const gchar *name);
275
276 G_END_DECLS
277
278 #endif /* __GST_INDEX_H__ */