fix doc build fix autogen
[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/gsttypes.h>
28 #include <gst/gstdata.h>
29 #include <gst/gstformat.h>
30 #include <gst/gstobject.h>
31 #include <gst/gststructure.h>
32
33 G_BEGIN_DECLS
34
35 typedef enum {
36   GST_EVENT_UNKNOWN             = 0,
37   GST_EVENT_EOS                 = 1,
38   GST_EVENT_FLUSH               = 2,
39   GST_EVENT_EMPTY               = 3,
40   GST_EVENT_DISCONTINUOUS       = 4,
41   /*GST_EVENT_NEW_MEDIA         = 5, <- removed */
42   GST_EVENT_QOS                 = 6,
43   GST_EVENT_SEEK                = 7,
44   GST_EVENT_SEEK_SEGMENT        = 8,
45   GST_EVENT_SEGMENT_DONE        = 9,
46   GST_EVENT_SIZE                = 10,
47   GST_EVENT_RATE                = 11,
48   GST_EVENT_FILLER              = 12,
49   GST_EVENT_TS_OFFSET           = 13,
50   GST_EVENT_INTERRUPT           = 14,
51   GST_EVENT_NAVIGATION          = 15,
52   GST_EVENT_TAG                 = 16
53 } GstEventType;
54
55 extern GType _gst_event_type;
56
57 #define GST_EVENT_TRACE_NAME    "GstEvent"
58
59 #define GST_TYPE_EVENT          (_gst_event_type)
60 #define GST_EVENT(event)        ((GstEvent*)(event))
61 #define GST_IS_EVENT(event)     (GST_DATA_TYPE(event) == GST_TYPE_EVENT)
62
63 #define GST_EVENT_TYPE(event)           (GST_EVENT(event)->type)
64 #define GST_EVENT_TIMESTAMP(event)      (GST_EVENT(event)->timestamp)
65 #define GST_EVENT_SRC(event)            (GST_EVENT(event)->src)
66
67 #define GST_EVENT_IS_INTERRUPT(event) (GST_EVENT_TYPE (event) == GST_EVENT_INTERRUPT)
68
69 #define GST_SEEK_FORMAT_SHIFT   0
70 #define GST_SEEK_METHOD_SHIFT   16
71 #define GST_SEEK_FLAGS_SHIFT    20
72 #define GST_SEEK_FORMAT_MASK    0x0000ffff
73 #define GST_SEEK_METHOD_MASK    0x000f0000
74 #define GST_SEEK_FLAGS_MASK     0xfff00000
75
76 typedef enum {
77   GST_EVENT_FLAG_NONE           = 0,
78
79   /* indicates negative rates are supported */
80   GST_RATE_FLAG_NEGATIVE        = (1 << 1) 
81 } GstEventFlag;
82
83 typedef struct
84 {
85   GstEventType  type;
86   GstEventFlag  flags;
87 } GstEventMask;
88
89 #ifdef G_HAVE_ISO_VARARGS
90 #define GST_EVENT_MASK_FUNCTION(type,functionname, ...)      \
91 static const GstEventMask*                              \
92 functionname (type pad)                                 \
93 {                                                       \
94   static const GstEventMask masks[] = {                 \
95     __VA_ARGS__,                                        \
96     { 0, }                                              \
97   };                                                    \
98   return masks;                                         \
99 }
100 #elif defined(G_HAVE_GNUC_VARARGS)
101 #define GST_EVENT_MASK_FUNCTION(type,functionname, a...)     \
102 static const GstEventMask*                              \
103 functionname (type pad)                                 \
104 {                                                       \
105   static const GstEventMask masks[] = {                 \
106     a,                                                  \
107     { 0, }                                              \
108   };                                                    \
109   return masks;                                         \
110 }
111 #endif
112
113 /* seek events, extends GstEventFlag */
114 typedef enum {
115   /* | with some format */
116   /* | with one of these */
117   GST_SEEK_METHOD_CUR           = (1 << (GST_SEEK_METHOD_SHIFT + 0)),
118   GST_SEEK_METHOD_SET           = (1 << (GST_SEEK_METHOD_SHIFT + 1)),
119   GST_SEEK_METHOD_END           = (1 << (GST_SEEK_METHOD_SHIFT + 2)),
120
121   /* | with optional seek flags */
122   /* seek flags */
123   GST_SEEK_FLAG_FLUSH           = (1 << (GST_SEEK_FLAGS_SHIFT + 0)),
124   GST_SEEK_FLAG_ACCURATE        = (1 << (GST_SEEK_FLAGS_SHIFT + 1)),
125   GST_SEEK_FLAG_KEY_UNIT        = (1 << (GST_SEEK_FLAGS_SHIFT + 2)),
126   GST_SEEK_FLAG_SEGMENT_LOOP    = (1 << (GST_SEEK_FLAGS_SHIFT + 3))
127         
128 } GstSeekType;
129
130 typedef enum {
131   GST_SEEK_CERTAIN,
132   GST_SEEK_FUZZY
133 } GstSeekAccuracy;
134
135 typedef struct
136 {
137   GstFormat     format;
138   gint64        value;
139 } GstFormatValue;
140
141 #define GST_EVENT_SEEK_TYPE(event)              (GST_EVENT(event)->event_data.seek.type)
142 #define GST_EVENT_SEEK_FORMAT(event)            (GST_EVENT_SEEK_TYPE(event) & GST_SEEK_FORMAT_MASK)
143 #define GST_EVENT_SEEK_METHOD(event)            (GST_EVENT_SEEK_TYPE(event) & GST_SEEK_METHOD_MASK)
144 #define GST_EVENT_SEEK_FLAGS(event)             (GST_EVENT_SEEK_TYPE(event) & GST_SEEK_FLAGS_MASK)
145 #define GST_EVENT_SEEK_OFFSET(event)            (GST_EVENT(event)->event_data.seek.offset)
146 #define GST_EVENT_SEEK_ENDOFFSET(event)         (GST_EVENT(event)->event_data.seek.endoffset)
147 #define GST_EVENT_SEEK_ACCURACY(event)          (GST_EVENT(event)->event_data.seek.accuracy)
148
149 #define GST_EVENT_DISCONT_NEW_MEDIA(event)      (GST_EVENT(event)->event_data.discont.new_media)
150 #define GST_EVENT_DISCONT_OFFSET(event,i)       (GST_EVENT(event)->event_data.discont.offsets[i])
151 #define GST_EVENT_DISCONT_OFFSET_LEN(event)     (GST_EVENT(event)->event_data.discont.noffsets)
152
153 #define GST_EVENT_SIZE_FORMAT(event)            (GST_EVENT(event)->event_data.size.format)
154 #define GST_EVENT_SIZE_VALUE(event)             (GST_EVENT(event)->event_data.size.value)
155
156 #define GST_EVENT_RATE_VALUE(event)             (GST_EVENT(event)->event_data.rate.value)
157
158 struct _GstEvent {
159   GstData data;
160
161   GstEventType  type;
162   guint64       timestamp;
163   GstObject     *src;
164
165   union {
166     struct {
167       GstSeekType       type;
168       gint64            offset;
169       gint64            endoffset;
170       GstSeekAccuracy   accuracy;
171     } seek;
172     struct {
173       GstFormatValue    offsets[8];
174       gint              noffsets;
175       gboolean          new_media;
176     } discont;
177     struct {
178       GstFormat         format;
179       gint64            value;
180     } size;
181     struct {
182       gdouble           value;
183     } rate;
184     struct {
185       GstStructure      *structure;
186     } structure;
187   } event_data;
188
189   gpointer _gst_reserved[GST_PADDING];
190 };
191
192 void            _gst_event_initialize           (void);
193         
194 GType           gst_event_get_type              (void);
195 GstEvent*       gst_event_new                   (GstEventType type);
196
197 /* refcounting */
198 #define         gst_event_ref(ev)               GST_EVENT (gst_data_ref (GST_DATA (ev)))
199 #define         gst_event_ref_by_count(ev,c)    GST_EVENT (gst_data_ref_by_count (GST_DATA (ev), c))
200 #define         gst_event_unref(ev)             gst_data_unref (GST_DATA (ev))
201 /* copy buffer */
202 #define         gst_event_copy(ev)              GST_EVENT (gst_data_copy (GST_DATA (ev)))
203
204 gboolean        gst_event_masks_contains        (const GstEventMask *masks, GstEventMask *mask);
205
206 /* seek event */
207 GstEvent*       gst_event_new_seek              (GstSeekType type, gint64 offset);
208
209 GstEvent*       gst_event_new_segment_seek      (GstSeekType type, gint64 start, gint64 stop);
210
211
212 /* size events */
213 GstEvent*       gst_event_new_size              (GstFormat format, gint64 value);
214
215 /* discontinous event */
216 GstEvent*       gst_event_new_discontinuous     (gboolean new_media,
217                                                  GstFormat format1, ...);
218 GstEvent*       gst_event_new_discontinuous_valist      (gboolean new_media,
219                                                  GstFormat format1, 
220                                                  va_list var_args);
221 gboolean        gst_event_discont_get_value     (GstEvent *event, GstFormat format, gint64 *value);
222
223 #define         gst_event_new_filler()          gst_event_new(GST_EVENT_FILLER)
224
225 /* flush events */
226 #define         gst_event_new_flush()           gst_event_new(GST_EVENT_FLUSH)
227
228 G_END_DECLS
229
230 #endif /* __GST_EVENT_H__ */