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