- Removed unused locking from the cothreads
[platform/upstream/gstreamer.git] / gst / gsttimecache.h
1 /* GStreamer
2  * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3  *                    2000 Wim Taymans <wim.taymans@chello.be>
4  *
5  * gsttimecache.h: Header for GstTimeCache
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public
18  * License along with this library; if not, write to the
19  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20  * Boston, MA 02111-1307, USA.
21  */
22
23 #ifndef __GST_TIME_CACHE_H__
24 #define __GST_TIME_CACHE_H__
25
26 #include <gst/gstobject.h>
27
28 G_BEGIN_DECLS
29
30 #define GST_TYPE_TIME_CACHE             (gst_time_cache_get_type ())
31 #define GST_TIME_CACHE(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_TIME_CACHE, GstTimeCache))
32 #define GST_TIME_CACHE_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_TIME_CACHE, GstTimeCacheClass))
33 #define GST_IS_TIME_CACHE(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_TIME_CACHE))
34 #define GST_IS_TIME_CACHE_CLASS(obj)    (GST_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_TIME_CACHE))
35
36 typedef struct _GstTimeCacheEntry GstTimeCacheEntry;
37 typedef struct _GstTimeCacheGroup GstTimeCacheGroup;
38 typedef struct _GstTimeCache GstTimeCache;
39 typedef struct _GstTimeCacheClass GstTimeCacheClass;
40
41 typedef enum {
42   GST_TIME_CACHE_UNKNOWN,
43   GST_TIME_CACHE_CERTAIN,
44   GST_TIME_CACHE_FUZZY_LOCATION,
45   GST_TIME_CACHE_FUZZY_TIMESTAMP,
46   GST_TIME_CACHE_FUZZY,
47 } GstTimeCacheCertainty;
48
49 struct _GstTimeCacheEntry {
50   guint64 location;
51   gint64 timestamp;
52 };
53
54 struct _GstTimeCacheGroup {
55   /* unique ID of group in cache */
56   gint groupnum;
57
58   /* list of entries */
59   GList *entries;
60
61   /* the certainty level of the group */
62   GstTimeCacheCertainty certainty;
63
64   /* peer group that contains more certain entries */
65   gint peergroup;
66
67   /* range variables */
68   gint64 mintimestamp,maxtimestamp;
69   guint64 minlocation,maxlocation;
70 };
71
72 struct _GstTimeCacheClass {
73   GstObjectClass parent_class;
74 };
75
76 struct _GstTimeCache {
77   GstObject             object;
78
79   GList                 *groups;
80   GstTimeCacheGroup     *curgroup;
81   gint                  maxgroup;
82 };
83
84 GType                   gst_time_cache_get_type         (void);
85 GstTimeCache*           gst_time_cache_new              (void);
86
87 gint                    gst_time_cache_get_group        (GstTimeCache *tc);
88 gint                    gst_time_cache_new_group        (GstTimeCache *tc);
89 gboolean                gst_time_cache_set_group        (GstTimeCache *tc, gint groupnum);
90
91 void                    gst_time_cache_set_certainty    (GstTimeCache *tc, GstTimeCacheCertainty certainty);
92 GstTimeCacheCertainty   gst_time_cache_get_certainty    (GstTimeCache *tc);
93
94 void                    gst_time_cache_add_entry        (GstTimeCache *tc, guint64 location, gint64 timestamp);
95
96 gboolean                gst_time_cache_find_location    (GstTimeCache *tc, guint64 location, gint64 *timestamp);
97 gboolean                gst_time_cache_find_timestamp   (GstTimeCache *tc, gint64 timestamp, guint64 *location);
98
99
100 G_END_DECLS
101
102 #endif /* __GST_TIME_CACHE_H__ */