1 | /* GStreamer |
---|
2 | * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu> |
---|
3 | * 2000 Wim Taymans <wtay@chello.be> |
---|
4 | * |
---|
5 | * gstscheduler.h: Header for default scheduler code |
---|
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_SCHEDULER_H__ |
---|
25 | #define __GST_SCHEDULER_H__ |
---|
26 | |
---|
27 | #include <glib.h> |
---|
28 | #include <gst/gstelement.h> |
---|
29 | #include <gst/gstbin.h> |
---|
30 | |
---|
31 | G_BEGIN_DECLS |
---|
32 | |
---|
33 | #define GST_TYPE_SCHEDULER (gst_scheduler_get_type ()) |
---|
34 | #define GST_SCHEDULER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_SCHEDULER, GstScheduler)) |
---|
35 | #define GST_IS_SCHEDULER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_SCHEDULER)) |
---|
36 | #define GST_SCHEDULER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_SCHEDULER,GstSchedulerClass)) |
---|
37 | #define GST_IS_SCHEDULER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_SCHEDULER)) |
---|
38 | #define GST_SCHEDULER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_SCHEDULER, GstSchedulerClass)) |
---|
39 | |
---|
40 | typedef enum { |
---|
41 | /* this scheduler works with a fixed clock */ |
---|
42 | GST_SCHEDULER_FLAG_FIXED_CLOCK = GST_OBJECT_FLAG_LAST, |
---|
43 | /* this scheduler supports select and lock calls */ |
---|
44 | GST_SCHEDULER_FLAG_NEW_API, |
---|
45 | |
---|
46 | /* padding */ |
---|
47 | GST_SCHEDULER_FLAG_LAST = GST_OBJECT_FLAG_LAST + 4 |
---|
48 | } GstSchedulerFlags; |
---|
49 | |
---|
50 | #define GST_SCHEDULER_PARENT(sched) ((sched)->parent) |
---|
51 | #define GST_SCHEDULER_STATE(sched) ((sched)->state) |
---|
52 | |
---|
53 | /*typedef struct _GstScheduler GstScheduler; */ |
---|
54 | /*typedef struct _GstSchedulerClass GstSchedulerClass; */ |
---|
55 | typedef enum { |
---|
56 | GST_SCHEDULER_STATE_NONE, |
---|
57 | GST_SCHEDULER_STATE_RUNNING, |
---|
58 | GST_SCHEDULER_STATE_STOPPED, |
---|
59 | GST_SCHEDULER_STATE_ERROR |
---|
60 | } GstSchedulerState; |
---|
61 | |
---|
62 | struct _GstScheduler { |
---|
63 | GstObject object; |
---|
64 | |
---|
65 | GstElement *parent; |
---|
66 | GstScheduler *parent_sched; |
---|
67 | |
---|
68 | GstSchedulerState state; |
---|
69 | GstClock *clock; |
---|
70 | GstClock *current_clock; |
---|
71 | |
---|
72 | GList *clock_providers; |
---|
73 | GList *clock_receivers; |
---|
74 | |
---|
75 | GList *schedulers; |
---|
76 | |
---|
77 | gpointer _gst_reserved[GST_PADDING]; |
---|
78 | }; |
---|
79 | |
---|
80 | struct _GstSchedulerClass { |
---|
81 | GstObjectClass parent_class; |
---|
82 | |
---|
83 | /* virtual methods */ |
---|
84 | void (*setup) (GstScheduler *sched); |
---|
85 | void (*reset) (GstScheduler *sched); |
---|
86 | void (*add_element) (GstScheduler *sched, GstElement *element); |
---|
87 | void (*remove_element) (GstScheduler *sched, GstElement *element); |
---|
88 | void (*add_scheduler) (GstScheduler *sched, GstScheduler *sched2); |
---|
89 | void (*remove_scheduler) (GstScheduler *sched, GstScheduler *sched2); |
---|
90 | GstElementStateReturn (*state_transition) (GstScheduler *sched, GstElement *element, gint transition); |
---|
91 | void (*scheduling_change) (GstScheduler *sched, GstElement *element); |
---|
92 | /* next two are optional, require NEW_API flag */ |
---|
93 | /* FIXME 0.9: rename to (un)lock_object */ |
---|
94 | void (*lock_element) (GstScheduler *sched, GstObject *object); |
---|
95 | void (*unlock_element) (GstScheduler *sched, GstObject *object); |
---|
96 | gboolean (*yield) (GstScheduler *sched, GstElement *element); |
---|
97 | gboolean (*interrupt) (GstScheduler *sched, GstElement *element); |
---|
98 | void (*error) (GstScheduler *sched, GstElement *element); |
---|
99 | void (*pad_link) (GstScheduler *sched, GstPad *srcpad, GstPad *sinkpad); |
---|
100 | void (*pad_unlink) (GstScheduler *sched, GstPad *srcpad, GstPad *sinkpad); |
---|
101 | /* optional, requires NEW_API flag */ |
---|
102 | GstData * (*pad_select) (GstScheduler *sched, GstPad **selected, GstPad **pads); |
---|
103 | GstClockReturn (*clock_wait) (GstScheduler *sched, GstElement *element, |
---|
104 | GstClockID id, GstClockTimeDiff *jitter); |
---|
105 | GstSchedulerState (*iterate) (GstScheduler *sched); |
---|
106 | /* for debugging */ |
---|
107 | void (*show) (GstScheduler *sched); |
---|
108 | |
---|
109 | /* signals */ |
---|
110 | void (*object_sync) (GstScheduler *sched, GstClock *clock, GstObject *object, |
---|
111 | GstClockID id); |
---|
112 | |
---|
113 | gpointer _gst_reserved[GST_PADDING]; |
---|
114 | }; |
---|
115 | |
---|
116 | GType gst_scheduler_get_type (void); |
---|
117 | |
---|
118 | |
---|
119 | void gst_scheduler_setup (GstScheduler *sched); |
---|
120 | void gst_scheduler_reset (GstScheduler *sched); |
---|
121 | void gst_scheduler_add_element (GstScheduler *sched, GstElement *element); |
---|
122 | void gst_scheduler_remove_element (GstScheduler *sched, GstElement *element); |
---|
123 | void gst_scheduler_add_scheduler (GstScheduler *sched, GstScheduler *sched2); |
---|
124 | void gst_scheduler_remove_scheduler (GstScheduler *sched, GstScheduler *sched2); |
---|
125 | GstElementStateReturn gst_scheduler_state_transition (GstScheduler *sched, GstElement *element, gint transition); |
---|
126 | void gst_scheduler_scheduling_change (GstScheduler *sched, GstElement *element); |
---|
127 | #ifndef GST_DISABLE_DEPRECATED |
---|
128 | void gst_scheduler_lock_element (GstScheduler *sched, GstElement *element); |
---|
129 | void gst_scheduler_unlock_element (GstScheduler *sched, GstElement *element); |
---|
130 | #endif |
---|
131 | gboolean gst_scheduler_yield (GstScheduler *sched, GstElement *element); |
---|
132 | gboolean gst_scheduler_interrupt (GstScheduler *sched, GstElement *element); |
---|
133 | void gst_scheduler_error (GstScheduler *sched, GstElement *element); |
---|
134 | void gst_scheduler_pad_link (GstScheduler *sched, GstPad *srcpad, GstPad *sinkpad); |
---|
135 | void gst_scheduler_pad_unlink (GstScheduler *sched, GstPad *srcpad, GstPad *sinkpad); |
---|
136 | #ifndef GST_DISABLE_DEPRECATED |
---|
137 | GstPad* gst_scheduler_pad_select (GstScheduler *sched, GList *padlist); |
---|
138 | #endif |
---|
139 | GstClockReturn gst_scheduler_clock_wait (GstScheduler *sched, GstElement *element, |
---|
140 | GstClockID id, GstClockTimeDiff *jitter); |
---|
141 | gboolean gst_scheduler_iterate (GstScheduler *sched); |
---|
142 | |
---|
143 | void gst_scheduler_use_clock (GstScheduler *sched, GstClock *clock); |
---|
144 | void gst_scheduler_set_clock (GstScheduler *sched, GstClock *clock); |
---|
145 | GstClock* gst_scheduler_get_clock (GstScheduler *sched); |
---|
146 | void gst_scheduler_auto_clock (GstScheduler *sched); |
---|
147 | |
---|
148 | void gst_scheduler_show (GstScheduler *sched); |
---|
149 | |
---|
150 | /* |
---|
151 | * creating schedulers |
---|
152 | * |
---|
153 | */ |
---|
154 | #define GST_TYPE_SCHEDULER_FACTORY (gst_scheduler_factory_get_type ()) |
---|
155 | #define GST_SCHEDULER_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_SCHEDULER_FACTORY, GstSchedulerFactory)) |
---|
156 | #define GST_IS_SCHEDULER_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_SCHEDULER_FACTORY)) |
---|
157 | #define GST_SCHEDULER_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_SCHEDULER_FACTORY, GstSchedulerFactoryClass)) |
---|
158 | #define GST_IS_SCHEDULER_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_SCHEDULER_FACTORY)) |
---|
159 | #define GST_SCHEDULER_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_SCHEDULER_FACTORY, GstSchedulerFactoryClass)) |
---|
160 | |
---|
161 | /* change this to change the default scheduler */ |
---|
162 | #define GST_SCHEDULER_DEFAULT_NAME "opt" |
---|
163 | |
---|
164 | typedef struct _GstSchedulerFactory GstSchedulerFactory; |
---|
165 | typedef struct _GstSchedulerFactoryClass GstSchedulerFactoryClass; |
---|
166 | |
---|
167 | struct _GstSchedulerFactory { |
---|
168 | GstPluginFeature feature; |
---|
169 | |
---|
170 | gchar *longdesc; /* long description of the scheduler (well, don't overdo it..) */ |
---|
171 | GType type; /* unique GType of the scheduler */ |
---|
172 | |
---|
173 | gpointer _gst_reserved[GST_PADDING]; |
---|
174 | }; |
---|
175 | |
---|
176 | struct _GstSchedulerFactoryClass { |
---|
177 | GstPluginFeatureClass parent; |
---|
178 | |
---|
179 | gpointer _gst_reserved[GST_PADDING]; |
---|
180 | }; |
---|
181 | |
---|
182 | GType gst_scheduler_factory_get_type (void); |
---|
183 | |
---|
184 | gboolean gst_scheduler_register (GstPlugin *plugin, const gchar *name, |
---|
185 | const gchar *longdesc, GType type); |
---|
186 | GstSchedulerFactory* gst_scheduler_factory_new (const gchar *name, const gchar *longdesc, GType type); |
---|
187 | void gst_scheduler_factory_destroy (GstSchedulerFactory *factory); |
---|
188 | |
---|
189 | GstSchedulerFactory* gst_scheduler_factory_find (const gchar *name); |
---|
190 | |
---|
191 | GstScheduler* gst_scheduler_factory_create (GstSchedulerFactory *factory, GstElement *parent); |
---|
192 | GstScheduler* gst_scheduler_factory_make (const gchar *name, GstElement *parent); |
---|
193 | |
---|
194 | void gst_scheduler_factory_set_default_name (const gchar* name); |
---|
195 | G_CONST_RETURN gchar* gst_scheduler_factory_get_default_name (void); |
---|
196 | |
---|
197 | |
---|
198 | G_END_DECLS |
---|
199 | |
---|
200 | #endif /* __GST_SCHEDULER_H__ */ |
---|