2 * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3 * 2000 Wim Taymans <wtay@chello.be>
5 * gstscheduler.h: Header for default scheduler code
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.
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.
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.
24 #ifndef __GST_SCHEDULER_H__
25 #define __GST_SCHEDULER_H__
28 #include <gst/gstelement.h>
29 #include <gst/gstbin.h>
33 #define GST_TYPE_SCHEDULER \
34 (gst_scheduler_get_type())
35 #define GST_SCHEDULER(obj) \
36 (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_SCHEDULER,GstScheduler))
37 #define GST_SCHEDULER_CLASS(klass) \
38 (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_SCHEDULER,GstSchedulerClass))
39 #define GST_IS_SCHEDULER(obj) \
40 (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_SCHEDULER))
41 #define GST_IS_SCHEDULER_CLASS(obj) \
42 (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SCHEDULER))
45 /* this scheduler works with a fixed clock */
46 GST_SCHEDULER_FLAG_FIXED_CLOCK = GST_OBJECT_FLAG_LAST,
49 GST_SCHEDULER_FLAG_LAST = GST_OBJECT_FLAG_LAST + 4
52 #define GST_SCHEDULER_PARENT(sched) ((sched)->parent)
53 #define GST_SCHEDULER_STATE(sched) ((sched)->state)
55 /*typedef struct _GstScheduler GstScheduler; */
56 /*typedef struct _GstSchedulerClass GstSchedulerClass; */
58 GST_SCHEDULER_STATE_NONE,
59 GST_SCHEDULER_STATE_RUNNING,
60 GST_SCHEDULER_STATE_STOPPED,
61 GST_SCHEDULER_STATE_ERROR
64 struct _GstScheduler {
68 GstScheduler *parent_sched;
70 GstSchedulerState state;
72 GstClock *current_clock;
74 GList *clock_providers;
75 GList *clock_receivers;
80 struct _GstSchedulerClass {
81 GstObjectClass parent_class;
84 void (*setup) (GstScheduler *sched);
85 gboolean (*get_preferred_stack) (GstScheduler *sched, gpointer *stack, gulong *size);
86 void (*reset) (GstScheduler *sched);
87 void (*add_element) (GstScheduler *sched, GstElement *element);
88 void (*remove_element) (GstScheduler *sched, GstElement *element);
89 void (*add_scheduler) (GstScheduler *sched, GstScheduler *sched2);
90 void (*remove_scheduler) (GstScheduler *sched, GstScheduler *sched2);
91 GstElementStateReturn (*state_transition) (GstScheduler *sched, GstElement *element, gint transition);
92 void (*lock_element) (GstScheduler *sched, GstElement *element);
93 void (*unlock_element) (GstScheduler *sched, GstElement *element);
94 void (*yield) (GstScheduler *sched, GstElement *element);
95 gboolean (*interrupt) (GstScheduler *sched, GstElement *element);
96 void (*error) (GstScheduler *sched, GstElement *element);
97 void (*pad_connect) (GstScheduler *sched, GstPad *srcpad, GstPad *sinkpad);
98 void (*pad_disconnect) (GstScheduler *sched, GstPad *srcpad, GstPad *sinkpad);
99 void (*pad_select) (GstScheduler *sched, GList *padlist);
100 GstClockReturn (*clock_wait) (GstScheduler *sched, GstElement *element,
101 GstClock *clock, GstClockTime time, GstClockTimeDiff *jitter);
102 GstSchedulerState (*iterate) (GstScheduler *sched);
104 void (*show) (GstScheduler *sched);
106 /* signals go here */
109 GType gst_scheduler_get_type (void);
111 #define gst_scheduler_destroy(sched) gst_object_destroy(GST_OBJECT(sched))
114 void gst_scheduler_setup (GstScheduler *sched);
115 gboolean gst_scheduler_get_preferred_stack(GstScheduler *sched, gpointer *stack, gulong *size);
116 void gst_scheduler_reset (GstScheduler *sched);
117 void gst_scheduler_add_element (GstScheduler *sched, GstElement *element);
118 void gst_scheduler_remove_element (GstScheduler *sched, GstElement *element);
119 void gst_scheduler_add_scheduler (GstScheduler *sched, GstScheduler *sched2);
120 void gst_scheduler_remove_scheduler (GstScheduler *sched, GstScheduler *sched2);
121 GstElementStateReturn gst_scheduler_state_transition (GstScheduler *sched, GstElement *element, gint transition);
122 void gst_scheduler_lock_element (GstScheduler *sched, GstElement *element);
123 void gst_scheduler_unlock_element (GstScheduler *sched, GstElement *element);
124 void gst_scheduler_yield (GstScheduler *sched, GstElement *element);
125 gboolean gst_scheduler_interrupt (GstScheduler *sched, GstElement *element);
126 void gst_scheduler_error (GstScheduler *sched, GstElement *element);
127 void gst_scheduler_pad_connect (GstScheduler *sched, GstPad *srcpad, GstPad *sinkpad);
128 void gst_scheduler_pad_disconnect (GstScheduler *sched, GstPad *srcpad, GstPad *sinkpad);
129 GstPad* gst_scheduler_pad_select (GstScheduler *sched, GList *padlist);
130 GstClockReturn gst_scheduler_clock_wait (GstScheduler *sched, GstElement *element,
131 GstClock *clock, GstClockTime time, GstClockTimeDiff *jitter);
132 gboolean gst_scheduler_iterate (GstScheduler *sched);
134 void gst_scheduler_use_clock (GstScheduler *sched, GstClock *clock);
135 void gst_scheduler_set_clock (GstScheduler *sched, GstClock *clock);
136 GstClock* gst_scheduler_get_clock (GstScheduler *sched);
137 void gst_scheduler_auto_clock (GstScheduler *sched);
139 void gst_scheduler_show (GstScheduler *sched);
142 * creating schedulers
145 #define GST_TYPE_SCHEDULER_FACTORY \
146 (gst_scheduler_factory_get_type ())
147 #define GST_SCHEDULER_FACTORY(obj) \
148 (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_SCHEDULER_FACTORY, GstSchedulerFactory))
149 #define GST_SCHEDULER_FACTORY_CLASS(klass) \
150 (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_SCHEDULER_FACTORY, GstSchedulerFactoryClass))
151 #define GST_IS_SCHEDULER_FACTORY(obj) \
152 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_SCHEDULER_FACTORY))
153 #define GST_IS_SCHEDULER_FACTORY_CLASS(obj) \
154 (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_SCHEDULER_FACTORY))
156 typedef struct _GstSchedulerFactory GstSchedulerFactory;
157 typedef struct _GstSchedulerFactoryClass GstSchedulerFactoryClass;
159 struct _GstSchedulerFactory {
160 GstPluginFeature feature;
162 gchar *longdesc; /* long description of the scheduler (well, don't overdo it..) */
163 GType type; /* unique GType of the scheduler */
166 struct _GstSchedulerFactoryClass {
167 GstPluginFeatureClass parent;
170 GType gst_scheduler_factory_get_type (void);
172 GstSchedulerFactory* gst_scheduler_factory_new (const gchar *name, const gchar *longdesc, GType type);
173 void gst_scheduler_factory_destroy (GstSchedulerFactory *factory);
175 GstSchedulerFactory* gst_scheduler_factory_find (const gchar *name);
177 GstScheduler* gst_scheduler_factory_create (GstSchedulerFactory *factory, GstElement *parent);
178 GstScheduler* gst_scheduler_factory_make (const gchar *name, GstElement *parent);
180 void gst_scheduler_factory_set_default_name (const gchar* name);
181 const gchar* gst_scheduler_factory_get_default_name (void);
186 #endif /* __GST_SCHEDULER_H__ */