Removed plugable schedulers.
[platform/upstream/gstreamer.git] / gst / gstevent.h
1 /* GStreamer
2  * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3  *                    2000 Wim Taymans <wim.taymans@chello.be>
4  *
5  * gstevent.h: Header for GstEvent subsystem
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
24 #ifndef __GST_EVENT_H__
25 #define __GST_EVENT_H__
26
27 #include <gst/gstminiobject.h>
28 #include <gst/gstformat.h>
29 #include <gst/gstobject.h>
30 #include <gst/gststructure.h>
31
32 G_BEGIN_DECLS
33
34 /**
35  * GstEventType:
36  * @GST_EVENT_UNKNOWN: 
37  * @GST_EVENT_EOS:
38  * @GST_EVENT_FLUSH:
39  * @GST_EVENT_DISCONTINUOUS:
40  * @GST_EVENT_QOS:
41  * @GST_EVENT_SEEK:
42  * @GST_EVENT_SIZE:
43  * @GST_EVENT_RATE:
44  * @GST_EVENT_NAVIGATION:
45  * @GST_EVENT_TAG:
46  */
47 typedef enum {
48   GST_EVENT_UNKNOWN             = 0,
49   GST_EVENT_EOS                 = 1,
50   GST_EVENT_FLUSH               = 2,
51   GST_EVENT_DISCONTINUOUS       = 3,
52   GST_EVENT_QOS                 = 4,
53   GST_EVENT_SEEK                = 5,
54   GST_EVENT_SIZE                = 8,
55   GST_EVENT_RATE                = 9,
56   GST_EVENT_NAVIGATION          = 10,
57   GST_EVENT_TAG                 = 11
58 } GstEventType;
59 #define GST_EVENT_ANY GST_EVENT_NAVIGATION
60
61 #define GST_EVENT_TRACE_NAME    "GstEvent"
62
63 typedef struct _GstEvent GstEvent;
64 typedef struct _GstEventClass GstEventClass;
65
66 #define GST_TYPE_EVENT                         (gst_event_get_type())
67 #define GST_IS_EVENT(obj)                      (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_EVENT))
68 #define GST_IS_EVENT_CLASS(klass)              (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_EVENT))
69 #define GST_EVENT_GET_CLASS(obj)               (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_EVENT, GstEventClass))
70 #define GST_EVENT(obj)                         (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_EVENT, GstEvent))
71 #define GST_EVENT_CLASS(klass)                 (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_EVENT, GstEventClass))
72
73 #define GST_EVENT_TYPE(event)           (GST_EVENT(event)->type)
74 #define GST_EVENT_TIMESTAMP(event)      (GST_EVENT(event)->timestamp)
75 #define GST_EVENT_SRC(event)            (GST_EVENT(event)->src)
76
77 #define GST_EVENT_IS_INTERRUPT(event) (GST_EVENT_TYPE (event) == GST_EVENT_INTERRUPT)
78
79 #define GST_SEEK_FORMAT_SHIFT   0
80 #define GST_SEEK_METHOD_SHIFT   16
81 #define GST_SEEK_FLAGS_SHIFT    20
82 #define GST_SEEK_FORMAT_MASK    0x0000ffff
83 #define GST_SEEK_METHOD_MASK    0x000f0000
84 #define GST_SEEK_FLAGS_MASK     0xfff00000
85
86 typedef enum {
87   GST_EVENT_FLAG_NONE           = 0,
88
89   /* indicates negative rates are supported */
90   GST_RATE_FLAG_NEGATIVE        = (1 << 1)
91 } GstEventFlag;
92
93 typedef struct
94 {
95   GstEventType  type;
96   GstEventFlag  flags;
97 } GstEventMask;
98
99 #ifdef G_HAVE_ISO_VARARGS
100 #define GST_EVENT_MASK_FUNCTION(type,functionname, ...)      \
101 static const GstEventMask*                              \
102 functionname (type pad)                                 \
103 {                                                       \
104   static const GstEventMask masks[] = {                 \
105     __VA_ARGS__,                                        \
106     { 0, }                                              \
107   };                                                    \
108   return masks;                                         \
109 }
110 #elif defined(G_HAVE_GNUC_VARARGS)
111 #define GST_EVENT_MASK_FUNCTION(type,functionname, a...)     \
112 static const GstEventMask*                              \
113 functionname (type pad)                                 \
114 {                                                       \
115   static const GstEventMask masks[] = {                 \
116     a,                                                  \
117     { 0, }                                              \
118   };                                                    \
119   return masks;                                         \
120 }
121 #endif
122
123 /* seek events, extends GstEventFlag */
124 typedef enum {
125   /* | with some format */
126   /* | with one of these */
127   GST_SEEK_METHOD_CUR           = (1 << (GST_SEEK_METHOD_SHIFT + 0)),
128   GST_SEEK_METHOD_SET           = (1 << (GST_SEEK_METHOD_SHIFT + 1)),
129   GST_SEEK_METHOD_END           = (1 << (GST_SEEK_METHOD_SHIFT + 2)),
130
131   /* | with optional seek flags */
132   /* seek flags */
133   GST_SEEK_FLAG_FLUSH           = (1 << (GST_SEEK_FLAGS_SHIFT + 0)),
134   GST_SEEK_FLAG_ACCURATE        = (1 << (GST_SEEK_FLAGS_SHIFT + 1)),
135   GST_SEEK_FLAG_KEY_UNIT        = (1 << (GST_SEEK_FLAGS_SHIFT + 2)),
136   GST_SEEK_FLAG_SEGMENT_LOOP    = (1 << (GST_SEEK_FLAGS_SHIFT + 3))
137         
138 } GstSeekType;
139
140 typedef enum {
141   GST_SEEK_CERTAIN,
142   GST_SEEK_FUZZY
143 } GstSeekAccuracy;
144
145 typedef struct
146 {
147   GstFormat     format;
148   gint64        start_value;
149   gint64        end_value;
150 } GstFormatValue;
151
152 #define GST_EVENT_SEEK_TYPE(event)              (GST_EVENT(event)->event_data.seek.type)
153 #define GST_EVENT_SEEK_FORMAT(event)            (GST_EVENT_SEEK_TYPE(event) & GST_SEEK_FORMAT_MASK)
154 #define GST_EVENT_SEEK_METHOD(event)            (GST_EVENT_SEEK_TYPE(event) & GST_SEEK_METHOD_MASK)
155 #define GST_EVENT_SEEK_FLAGS(event)             (GST_EVENT_SEEK_TYPE(event) & GST_SEEK_FLAGS_MASK)
156 #define GST_EVENT_SEEK_OFFSET(event)            (GST_EVENT(event)->event_data.seek.offset)
157 #define GST_EVENT_SEEK_ENDOFFSET(event)         (GST_EVENT(event)->event_data.seek.endoffset)
158 #define GST_EVENT_SEEK_ACCURACY(event)          (GST_EVENT(event)->event_data.seek.accuracy)
159
160 #define GST_EVENT_DISCONT_RATE(event)           (GST_EVENT(event)->event_data.discont.rate)
161 #define GST_EVENT_DISCONT_OFFSET(event,i)       (GST_EVENT(event)->event_data.discont.offsets[i])
162 #define GST_EVENT_DISCONT_OFFSET_LEN(event)     (GST_EVENT(event)->event_data.discont.noffsets)
163
164 #define GST_EVENT_FLUSH_DONE(event)             (GST_EVENT(event)->event_data.flush.done)
165
166 #define GST_EVENT_SIZE_FORMAT(event)            (GST_EVENT(event)->event_data.size.format)
167 #define GST_EVENT_SIZE_VALUE(event)             (GST_EVENT(event)->event_data.size.value)
168
169 #define GST_EVENT_RATE_VALUE(event)             (GST_EVENT(event)->event_data.rate.value)
170
171 struct _GstEvent {
172   GstMiniObject mini_object;
173
174   /*< public >*/ /* with COW */
175   GstEventType  type;
176   guint64       timestamp;
177   GstObject     *src;
178
179   union {
180     struct {
181       GstSeekType       type;
182       gint64            offset;
183       gint64            endoffset;
184       GstSeekAccuracy   accuracy;
185     } seek;
186     struct {
187       GstFormatValue    offsets[8];
188       gint              noffsets;
189       gdouble           rate;
190     } discont;
191     struct {
192       gboolean          done;
193     } flush;
194     struct {
195       GstFormat         format;
196       gint64            value;
197     } size;
198     struct {
199       gdouble           value;
200     } rate;
201     struct {
202       GstStructure      *structure;
203     } structure;
204   } event_data;
205
206   /*< private >*/
207   gpointer _gst_reserved[GST_PADDING];
208 };
209
210 struct _GstEventClass {
211   GstMiniObjectClass mini_object_class;
212
213   /*< private >*/
214   gpointer _gst_reserved[GST_PADDING];
215 };
216
217 void            _gst_event_initialize           (void);
218         
219 GType           gst_event_get_type              (void);
220 GstEvent*       gst_event_new                   (GstEventType type);
221
222 /* refcounting */
223 #define         gst_event_ref(ev)               GST_EVENT (gst_mini_object_ref (GST_MINI_OBJECT (ev)))
224 #define         gst_event_unref(ev)             gst_mini_object_unref (GST_MINI_OBJECT (ev))
225 /* copy buffer */
226 #define         gst_event_copy(ev)              GST_EVENT (gst_mini_object_copy (GST_MINI_OBJECT (ev)))
227
228 gboolean        gst_event_masks_contains        (const GstEventMask *masks, GstEventMask *mask);
229
230 /* seek event */
231 GstEvent*       gst_event_new_seek              (GstSeekType type, gint64 offset);
232
233 GstEvent*       gst_event_new_segment_seek      (GstSeekType type, gint64 start, gint64 stop);
234
235
236 /* size events */
237 GstEvent*       gst_event_new_size              (GstFormat format, gint64 value);
238
239 /* discontinous event */
240 GstEvent*       gst_event_new_discontinuous     (gdouble rate,
241                                                  GstFormat format1, ...);
242 GstEvent*       gst_event_new_discontinuous_valist      (gdouble rate,
243                                                  GstFormat format1,
244                                                  va_list var_args);
245 gboolean        gst_event_discont_get_value     (GstEvent *event, GstFormat format, 
246                                                  gint64 *start_value, gint64 *end_value);
247
248 #define         gst_event_new_filler()          gst_event_new(GST_EVENT_FILLER)
249 #define         gst_event_new_eos()             gst_event_new(GST_EVENT_EOS)
250
251 /* flush events */
252 GstEvent*       gst_event_new_flush             (gboolean done);
253
254 G_END_DECLS
255
256 #endif /* __GST_EVENT_H__ */