2 * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3 * 2000 Wim Taymans <wtay@chello.be>
5 * gstclock.h: Header for clock subsystem
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_CLOCK_H__
25 #define __GST_CLOCK_H__
29 #endif /* __cplusplus */
31 #include <gst/gstobject.h>
33 #define GST_TYPE_CLOCK \
34 (gst_clock_get_type())
35 #define GST_CLOCK(obj) \
36 (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_CLOCK,GstClock))
37 #define GST_CLOCK_CLASS(klass) \
38 (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_CLOCK,GstClockClass))
39 #define GST_IS_CLOCK(obj) \
40 (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_CLOCK))
41 #define GST_IS_CLOCK_CLASS(obj) \
42 (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_CLOCK))
44 typedef guint64 GstClockTime;
45 typedef gint64 GstClockTimeDiff;
46 typedef gpointer GstClockID;
48 #define GST_CLOCK_DIFF(s, e) (GstClockTimeDiff)((s)-(e))
49 #define GST_TIMEVAL_TO_TIME(tv) ((tv).tv_sec * (guint64) G_USEC_PER_SEC + (tv).tv_usec)
51 typedef struct _GstClock GstClock;
52 typedef struct _GstClockClass GstClockClass;
54 typedef void (*GstClockCallback) (GstClock *clock, GstClockTime time, GstClockID id, gpointer user_data);
58 GST_CLOCK_STOPPED = 0,
59 GST_CLOCK_TIMEOUT = 1,
67 GstClockTime start_time;
75 struct _GstClockClass {
76 GstObjectClass parent_class;
79 void (*activate) (GstClock *clock, gboolean active);
80 void (*reset) (GstClock *clock);
82 void (*set_time) (GstClock *clock, GstClockTime time);
83 GstClockTime (*get_time) (GstClock *clock);
85 GstClockReturn (*wait) (GstClock *clock, GstClockTime time);
86 GstClockID (*wait_async) (GstClock *clock, GstClockTime time,
87 GstClockCallback func, gpointer user_data);
88 void (*cancel_wait_async) (GstClock *clock, GstClockID id);
89 GstClockID (*notify_async) (GstClock *clock, GstClockTime interval,
90 GstClockCallback func, gpointer user_data);
91 void (*remove_notify_async) (GstClock *clock, GstClockID id);
93 void (*set_resolution) (GstClock *clock, guint64 resolution);
94 guint64 (*get_resolution) (GstClock *clock);
99 GType gst_clock_get_type (void);
101 void gst_clock_set_speed (GstClock *clock, gdouble speed);
102 void gst_clock_get_speed (GstClock *clock, gdouble speed);
104 void gst_clock_activate (GstClock *clock, gboolean active);
105 gboolean gst_clock_is_active (GstClock *clock);
106 void gst_clock_reset (GstClock *clock);
108 void gst_clock_set_time (GstClock *clock, GstClockTime time);
109 GstClockTime gst_clock_get_time (GstClock *clock);
111 GstClockReturn gst_clock_wait (GstClock *clock, GstClockTime time);
112 GstClockID gst_clock_wait_async (GstClock *clock, GstClockTime time,
113 GstClockCallback func, gpointer user_data);
114 void gst_clock_cancel_wait_async (GstClock *clock, GstClockID id);
115 GstClockID gst_clock_notify_async (GstClock *clock, GstClockTime interval,
116 GstClockCallback func, gpointer user_data);
117 void gst_clock_remove_notify_async (GstClock *clock, GstClockID id);
119 void gst_clock_set_resolution (GstClock *clock, guint64 resolution);
120 guint64 gst_clock_get_resolution (GstClock *clock);
124 #endif /* __cplusplus */
126 #endif /* __GST_CLOCK_H__ */