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 (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))
41 /* this scheduler works with a fixed clock */
42 GST_SCHEDULER_FLAG_FIXED_CLOCK = GST_OBJECT_FLAG_LAST,
45 GST_SCHEDULER_FLAG_LAST = GST_OBJECT_FLAG_LAST + 4
48 #define GST_SCHEDULER_PARENT(sched) ((sched)->parent)
49 #define GST_SCHEDULER_STATE(sched) ((sched)->state)
51 /*typedef struct _GstScheduler GstScheduler; */
52 /*typedef struct _GstSchedulerClass GstSchedulerClass; */
54 GST_SCHEDULER_STATE_NONE,
55 GST_SCHEDULER_STATE_RUNNING,
56 GST_SCHEDULER_STATE_STOPPED,
57 GST_SCHEDULER_STATE_ERROR
60 struct _GstScheduler {
64 GstScheduler *parent_sched;
66 GstSchedulerState state;
68 GstClock *current_clock;
70 GList *clock_providers;
71 GList *clock_receivers;
78 struct _GstSchedulerClass {
79 GstObjectClass parent_class;
82 void (*setup) (GstScheduler *sched);
83 void (*reset) (GstScheduler *sched);
84 void (*add_element) (GstScheduler *sched, GstElement *element);
85 void (*remove_element) (GstScheduler *sched, GstElement *element);
86 void (*add_scheduler) (GstScheduler *sched, GstScheduler *sched2);
87 void (*remove_scheduler) (GstScheduler *sched, GstScheduler *sched2);
88 GstElementStateReturn (*state_transition) (GstScheduler *sched, GstElement *element, gint transition);
89 void (*scheduling_change) (GstScheduler *sched, GstElement *element);
90 void (*lock_element) (GstScheduler *sched, GstElement *element);
91 void (*unlock_element) (GstScheduler *sched, GstElement *element);
92 gboolean (*yield) (GstScheduler *sched, GstElement *element);
93 gboolean (*interrupt) (GstScheduler *sched, GstElement *element);
94 void (*error) (GstScheduler *sched, GstElement *element);
95 void (*pad_link) (GstScheduler *sched, GstPad *srcpad, GstPad *sinkpad);
96 void (*pad_unlink) (GstScheduler *sched, GstPad *srcpad, GstPad *sinkpad);
97 void (*pad_select) (GstScheduler *sched, GList *padlist);
98 GstClockReturn (*clock_wait) (GstScheduler *sched, GstElement *element,
99 GstClockID id, GstClockTimeDiff *jitter);
100 GstSchedulerState (*iterate) (GstScheduler *sched);
102 void (*show) (GstScheduler *sched);
105 void (*object_sync) (GstScheduler *sched, GstClock *clock, GstObject *object,
111 GType gst_scheduler_get_type (void);
113 #define gst_scheduler_destroy(sched) gst_object_destroy(GST_OBJECT(sched))
116 void gst_scheduler_setup (GstScheduler *sched);
117 void gst_scheduler_reset (GstScheduler *sched);
118 void gst_scheduler_add_element (GstScheduler *sched, GstElement *element);
119 void gst_scheduler_remove_element (GstScheduler *sched, GstElement *element);
120 void gst_scheduler_add_scheduler (GstScheduler *sched, GstScheduler *sched2);
121 void gst_scheduler_remove_scheduler (GstScheduler *sched, GstScheduler *sched2);
122 GstElementStateReturn gst_scheduler_state_transition (GstScheduler *sched, GstElement *element, gint transition);
123 void gst_scheduler_scheduling_change (GstScheduler *sched, GstElement *element);
124 void gst_scheduler_lock_element (GstScheduler *sched, GstElement *element);
125 void gst_scheduler_unlock_element (GstScheduler *sched, GstElement *element);
126 gboolean gst_scheduler_yield (GstScheduler *sched, GstElement *element);
127 gboolean gst_scheduler_interrupt (GstScheduler *sched, GstElement *element);
128 void gst_scheduler_error (GstScheduler *sched, GstElement *element);
129 void gst_scheduler_pad_link (GstScheduler *sched, GstPad *srcpad, GstPad *sinkpad);
130 void gst_scheduler_pad_unlink (GstScheduler *sched, GstPad *srcpad, GstPad *sinkpad);
131 GstPad* gst_scheduler_pad_select (GstScheduler *sched, GList *padlist);
132 GstClockReturn gst_scheduler_clock_wait (GstScheduler *sched, GstElement *element,
133 GstClockID id, GstClockTimeDiff *jitter);
134 gboolean gst_scheduler_iterate (GstScheduler *sched);
136 void gst_scheduler_use_clock (GstScheduler *sched, GstClock *clock);
137 void gst_scheduler_set_clock (GstScheduler *sched, GstClock *clock);
138 GstClock* gst_scheduler_get_clock (GstScheduler *sched);
139 void gst_scheduler_auto_clock (GstScheduler *sched);
141 void gst_scheduler_show (GstScheduler *sched);
144 * creating schedulers
147 #define GST_TYPE_SCHEDULER_FACTORY (gst_scheduler_factory_get_type ())
148 #define GST_SCHEDULER_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_SCHEDULER_FACTORY, GstSchedulerFactory))
149 #define GST_IS_SCHEDULER_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_SCHEDULER_FACTORY))
150 #define GST_SCHEDULER_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_SCHEDULER_FACTORY, GstSchedulerFactoryClass))
151 #define GST_IS_SCHEDULER_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_SCHEDULER_FACTORY))
152 #define GST_SCHEDULER_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_SCHEDULER_FACTORY, GstSchedulerFactoryClass))
154 /* change this to change the default scheduler */
155 #define GST_SCHEDULER_DEFAULT_NAME "opt"
157 typedef struct _GstSchedulerFactory GstSchedulerFactory;
158 typedef struct _GstSchedulerFactoryClass GstSchedulerFactoryClass;
160 struct _GstSchedulerFactory {
161 GstPluginFeature feature;
163 gchar *longdesc; /* long description of the scheduler (well, don't overdo it..) */
164 GType type; /* unique GType of the scheduler */
167 struct _GstSchedulerFactoryClass {
168 GstPluginFeatureClass parent;
171 GType gst_scheduler_factory_get_type (void);
173 GstSchedulerFactory* gst_scheduler_factory_new (const gchar *name, const gchar *longdesc, GType type);
174 void gst_scheduler_factory_destroy (GstSchedulerFactory *factory);
176 GstSchedulerFactory* gst_scheduler_factory_find (const gchar *name);
178 GstScheduler* gst_scheduler_factory_create (GstSchedulerFactory *factory, GstElement *parent);
179 GstScheduler* gst_scheduler_factory_make (const gchar *name, GstElement *parent);
181 void gst_scheduler_factory_set_default_name (const gchar* name);
182 const gchar* gst_scheduler_factory_get_default_name (void);
187 #endif /* __GST_SCHEDULER_H__ */