query: add gst_clear_query()
[platform/upstream/gstreamer.git] / gst / gstclock.h
1 /* GStreamer
2  * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3  *                    2000 Wim Taymans <wtay@chello.be>
4  *                    2005 Wim Taymans <wim@fluendo.com>
5  *
6  * gstclock.h: Header for clock subsystem
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License along with this library; if not, write to the
20  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
21  * Boston, MA 02110-1301, USA.
22  */
23
24 #ifndef __GST_CLOCK_H__
25 #define __GST_CLOCK_H__
26
27 #include <gst/gstconfig.h>
28 #include <glib.h>
29
30 G_BEGIN_DECLS
31
32 /* --- standard type macros --- */
33 #define GST_TYPE_CLOCK                  (gst_clock_get_type ())
34 #define GST_CLOCK(clock)                (G_TYPE_CHECK_INSTANCE_CAST ((clock), GST_TYPE_CLOCK, GstClock))
35 #define GST_IS_CLOCK(clock)             (G_TYPE_CHECK_INSTANCE_TYPE ((clock), GST_TYPE_CLOCK))
36 #define GST_CLOCK_CLASS(cclass)         (G_TYPE_CHECK_CLASS_CAST ((cclass), GST_TYPE_CLOCK, GstClockClass))
37 #define GST_IS_CLOCK_CLASS(cclass)      (G_TYPE_CHECK_CLASS_TYPE ((cclass), GST_TYPE_CLOCK))
38 #define GST_CLOCK_GET_CLASS(clock)      (G_TYPE_INSTANCE_GET_CLASS ((clock), GST_TYPE_CLOCK, GstClockClass))
39 #define GST_CLOCK_CAST(clock)           ((GstClock*)(clock))
40
41 /**
42  * GstClockTime:
43  *
44  * A datatype to hold a time, measured in nanoseconds.
45  */
46 typedef guint64 GstClockTime;
47
48 /**
49  * GST_TYPE_CLOCK_TIME:
50  *
51  * The #GType of a #GstClockTime.
52  */
53 #define GST_TYPE_CLOCK_TIME G_TYPE_UINT64
54
55 /**
56  * GstClockTimeDiff:
57  *
58  * A datatype to hold a time difference, measured in nanoseconds.
59  */
60 typedef gint64 GstClockTimeDiff;
61 /**
62  * GstClockID:
63  *
64  * A datatype to hold the handle to an outstanding sync or async clock callback.
65  */
66 typedef gpointer GstClockID;
67
68 /**
69  * GST_CLOCK_TIME_NONE: (value 18446744073709551615) (type GstClockTime)
70  *
71  * Constant to define an undefined clock time.
72  */
73 #define GST_CLOCK_TIME_NONE             ((GstClockTime) -1)
74 /**
75  * GST_CLOCK_TIME_IS_VALID:
76  * @time: clock time to validate
77  *
78  * Tests if a given #GstClockTime represents a valid defined time.
79  */
80 #define GST_CLOCK_TIME_IS_VALID(time)   (((GstClockTime)(time)) != GST_CLOCK_TIME_NONE)
81
82 /**
83  * GST_CLOCK_STIME_NONE: (value -9223372036854775808) (type GstClockTimeDiff)
84  *
85  * Constant to define an undefined clock time.
86  */
87 #define GST_CLOCK_STIME_NONE             ((GstClockTimeDiff)G_MININT64)
88 /**
89  * GST_CLOCK_STIME_IS_VALID:
90  * @time: signed clock time to validate
91  *
92  * Tests if a given #GstClockTimeDiff of #gint64 represents a valid defined time.
93  *
94  * Since: 1.6
95  */
96 #define GST_CLOCK_STIME_IS_VALID(time)   (((GstClockTimeDiff)(time)) != GST_CLOCK_STIME_NONE)
97
98 /**
99  * GST_SECOND: (value 1000000000) (type GstClockTimeDiff)
100  *
101  * Constant that defines one GStreamer second.
102  */
103 #define GST_SECOND  ((GstClockTimeDiff)(G_USEC_PER_SEC * G_GINT64_CONSTANT (1000)))
104 /**
105  * GST_MSECOND: (value 1000000) (type GstClockTimeDiff)
106  *
107  * Constant that defines one GStreamer millisecond.
108  */
109 #define GST_MSECOND ((GstClockTimeDiff)(GST_SECOND / G_GINT64_CONSTANT (1000)))
110 /**
111  * GST_USECOND: (value 1000) (type GstClockTimeDiff)
112  *
113  * Constant that defines one GStreamer microsecond.
114  */
115 #define GST_USECOND ((GstClockTimeDiff)(GST_SECOND / G_GINT64_CONSTANT (1000000)))
116 /**
117  * GST_NSECOND: (value 1) (type GstClockTimeDiff)
118  *
119  * Constant that defines one GStreamer nanosecond
120  */
121 #define GST_NSECOND ((GstClockTimeDiff)(GST_SECOND / G_GINT64_CONSTANT (1000000000)))
122
123
124 /**
125  * GST_TIME_AS_SECONDS:
126  * @time: the time
127  *
128  * Convert a #GstClockTime to seconds.
129  */
130 #define GST_TIME_AS_SECONDS(time)  ((time) / GST_SECOND)
131 /**
132  * GST_TIME_AS_MSECONDS:
133  * @time: the time
134  *
135  * Convert a #GstClockTime to milliseconds (1/1000 of a second).
136  */
137 #define GST_TIME_AS_MSECONDS(time) ((time) / G_GINT64_CONSTANT (1000000))
138 /**
139  * GST_TIME_AS_USECONDS:
140  * @time: the time
141  *
142  * Convert a #GstClockTime to microseconds (1/1000000 of a second).
143  */
144 #define GST_TIME_AS_USECONDS(time) ((time) / G_GINT64_CONSTANT (1000))
145 /**
146  * GST_TIME_AS_NSECONDS:
147  * @time: the time
148  *
149  * Convert a #GstClockTime to nanoseconds (1/1000000000 of a second).
150  */
151 #define GST_TIME_AS_NSECONDS(time) (time)
152
153 /**
154  * GST_CLOCK_DIFF:
155  * @s: the first time
156  * @e: the second time
157  *
158  * Calculate a difference between two clock times as a #GstClockTimeDiff.
159  * The difference is calculated as @e - @s.
160  */
161 #define GST_CLOCK_DIFF(s, e)            (GstClockTimeDiff)((e) - (s))
162
163 /**
164  * GST_TIMEVAL_TO_TIME:
165  * @tv: the timeval to convert
166  *
167  * Convert a #GTimeVal to a #GstClockTime.
168  */
169 #define GST_TIMEVAL_TO_TIME(tv)         (GstClockTime)((tv).tv_sec * GST_SECOND + (tv).tv_usec * GST_USECOND)
170
171 /**
172  * GST_TIME_TO_TIMEVAL:
173  * @t: The #GstClockTime to convert
174  * @tv: The target timeval
175  *
176  * Convert a #GstClockTime to a #GTimeVal
177  *
178  * > on 32-bit systems, a timeval has a range of only 2^32 - 1 seconds,
179  * > which is about 68 years.  Expect trouble if you want to schedule stuff
180  * > in your pipeline for 2038.
181  */
182 #define GST_TIME_TO_TIMEVAL(t,tv)                               \
183 G_STMT_START {                                                  \
184   g_assert ("Value of time " #t " is out of timeval's range" && \
185       ((t) / GST_SECOND) < G_MAXLONG);                          \
186   (tv).tv_sec  = (glong) (((GstClockTime) (t)) / GST_SECOND);   \
187   (tv).tv_usec = (glong) ((((GstClockTime) (t)) -               \
188                   ((GstClockTime) (tv).tv_sec) * GST_SECOND)    \
189                  / GST_USECOND);                                \
190 } G_STMT_END
191
192 /**
193  * GST_TIMESPEC_TO_TIME:
194  * @ts: the timespec to convert
195  *
196  * Convert a struct timespec (see man pselect) to a #GstClockTime.
197  */
198 #define GST_TIMESPEC_TO_TIME(ts)        (GstClockTime)((ts).tv_sec * GST_SECOND + (ts).tv_nsec * GST_NSECOND)
199 /**
200  * GST_TIME_TO_TIMESPEC:
201  * @t: The #GstClockTime to convert
202  * @ts: The target timespec
203  *
204  * Convert a #GstClockTime to a struct timespec (see man pselect)
205  */
206 #define GST_TIME_TO_TIMESPEC(t,ts)                                \
207 G_STMT_START {                                                    \
208   g_assert ("Value of time " #t " is out of timespec's range" &&  \
209       ((t) / GST_SECOND) < G_MAXLONG);                            \
210   (ts).tv_sec  =  (glong) ((t) / GST_SECOND);                     \
211   (ts).tv_nsec = (glong) (((t) - (ts).tv_sec * GST_SECOND) / GST_NSECOND);        \
212 } G_STMT_END
213
214 /* timestamp debugging macros */
215 /**
216  * GST_TIME_FORMAT: (skip):
217  *
218  * A string that can be used in printf-like format strings to display a
219  * #GstClockTime value in h:m:s format.  Use GST_TIME_ARGS() to construct
220  * the matching arguments.
221  *
222  * Example:
223  * |[<!-- language="C" -->
224  * printf("%" GST_TIME_FORMAT "\n", GST_TIME_ARGS(ts));
225  * ]|
226  */
227 #define GST_TIME_FORMAT "u:%02u:%02u.%09u"
228 /**
229  * GST_TIME_ARGS: (skip):
230  * @t: a #GstClockTime
231  *
232  * Format @t for the #GST_TIME_FORMAT format string. Note: @t will be
233  * evaluated more than once.
234  */
235 #define GST_TIME_ARGS(t) \
236         GST_CLOCK_TIME_IS_VALID (t) ? \
237         (guint) (((GstClockTime)(t)) / (GST_SECOND * 60 * 60)) : 99, \
238         GST_CLOCK_TIME_IS_VALID (t) ? \
239         (guint) ((((GstClockTime)(t)) / (GST_SECOND * 60)) % 60) : 99, \
240         GST_CLOCK_TIME_IS_VALID (t) ? \
241         (guint) ((((GstClockTime)(t)) / GST_SECOND) % 60) : 99, \
242         GST_CLOCK_TIME_IS_VALID (t) ? \
243         (guint) (((GstClockTime)(t)) % GST_SECOND) : 999999999
244 /**
245  * GST_STIME_FORMAT: (skip):
246  *
247  * A string that can be used in printf-like format strings to display a signed
248  * #GstClockTimeDiff or #gint64 value in h:m:s format.  Use GST_TIME_ARGS() to
249  * construct the matching arguments.
250  *
251  * Example:
252  * |[
253  * printf("%" GST_STIME_FORMAT "\n", GST_STIME_ARGS(ts));
254  * ]|
255  *
256  * Since: 1.6
257  */
258 #define GST_STIME_FORMAT "c%" GST_TIME_FORMAT
259 /**
260  * GST_STIME_ARGS: (skip):
261  * @t: a #GstClockTimeDiff or #gint64
262  *
263  * Format @t for the #GST_STIME_FORMAT format string. Note: @t will be
264  * evaluated more than once.
265  *
266  * Since: 1.6
267  */
268 #define GST_STIME_ARGS(t)                                               \
269   ((t) == GST_CLOCK_STIME_NONE || (t) >= 0) ? '+' : '-',                \
270     GST_CLOCK_STIME_IS_VALID (t) ?                                      \
271     (guint) (((GstClockTime)(ABS(t))) / (GST_SECOND * 60 * 60)) : 99,   \
272     GST_CLOCK_STIME_IS_VALID (t) ?                                      \
273     (guint) ((((GstClockTime)(ABS(t))) / (GST_SECOND * 60)) % 60) : 99, \
274     GST_CLOCK_STIME_IS_VALID (t) ?                                      \
275     (guint) ((((GstClockTime)(ABS(t))) / GST_SECOND) % 60) : 99,        \
276     GST_CLOCK_STIME_IS_VALID (t) ?                                      \
277     (guint) (((GstClockTime)(ABS(t))) % GST_SECOND) : 999999999
278
279 typedef struct _GstClockEntry   GstClockEntry;
280 typedef struct _GstClock        GstClock;
281 typedef struct _GstClockClass   GstClockClass;
282 typedef struct _GstClockPrivate GstClockPrivate;
283
284 /* --- prototype for async callbacks --- */
285 /**
286  * GstClockCallback:
287  * @clock: The clock that triggered the callback
288  * @time: The time it was triggered
289  * @id: The #GstClockID that expired
290  * @user_data: user data passed in the gst_clock_id_wait_async() function
291  *
292  * The function prototype of the callback.
293  *
294  * Returns: %TRUE or %FALSE (currently unused)
295  */
296 typedef gboolean        (*GstClockCallback)     (GstClock *clock, GstClockTime time,
297                                                  GstClockID id, gpointer user_data);
298 /**
299  * GstClockReturn:
300  * @GST_CLOCK_OK: The operation succeeded.
301  * @GST_CLOCK_EARLY: The operation was scheduled too late.
302  * @GST_CLOCK_UNSCHEDULED: The clockID was unscheduled
303  * @GST_CLOCK_BUSY: The ClockID is busy
304  * @GST_CLOCK_BADTIME: A bad time was provided to a function.
305  * @GST_CLOCK_ERROR: An error occurred
306  * @GST_CLOCK_UNSUPPORTED: Operation is not supported
307  * @GST_CLOCK_DONE: The ClockID is done waiting
308  *
309  * The return value of a clock operation.
310  */
311 typedef enum
312 {
313   GST_CLOCK_OK          =  0,
314   GST_CLOCK_EARLY       =  1,
315   GST_CLOCK_UNSCHEDULED =  2,
316   GST_CLOCK_BUSY        =  3,
317   GST_CLOCK_BADTIME     =  4,
318   GST_CLOCK_ERROR       =  5,
319   GST_CLOCK_UNSUPPORTED =  6,
320   GST_CLOCK_DONE        =  7
321 } GstClockReturn;
322
323 /**
324  * GstClockEntryType:
325  * @GST_CLOCK_ENTRY_SINGLE: a single shot timeout
326  * @GST_CLOCK_ENTRY_PERIODIC: a periodic timeout request
327  *
328  * The type of the clock entry
329  */
330 typedef enum {
331   GST_CLOCK_ENTRY_SINGLE,
332   GST_CLOCK_ENTRY_PERIODIC
333 } GstClockEntryType;
334
335 /**
336  * GST_CLOCK_ENTRY:
337  * @entry: the entry to cast
338  *
339  * Cast to a clock entry
340  */
341 #define GST_CLOCK_ENTRY(entry)          ((GstClockEntry *)(entry))
342
343 #ifndef GST_DISABLE_DEPRECATED
344 /**
345  * GST_CLOCK_ENTRY_CLOCK:
346  * @entry: the entry to query
347  *
348  * Get the owner clock of the entry
349  *
350  * Deprecated: Use gst_clock_id_get_clock() instead.
351  */
352 #define GST_CLOCK_ENTRY_CLOCK(entry)    ((entry)->clock)
353 #endif
354 /**
355  * GST_CLOCK_ENTRY_TYPE:
356  * @entry: the entry to query
357  *
358  * Get the type of the clock entry
359  */
360 #define GST_CLOCK_ENTRY_TYPE(entry)     ((entry)->type)
361 /**
362  * GST_CLOCK_ENTRY_TIME:
363  * @entry: the entry to query
364  *
365  * Get the requested time of this entry
366  */
367 #define GST_CLOCK_ENTRY_TIME(entry)     ((entry)->time)
368 /**
369  * GST_CLOCK_ENTRY_INTERVAL:
370  * @entry: the entry to query
371  *
372  * Get the interval of this periodic entry
373  */
374 #define GST_CLOCK_ENTRY_INTERVAL(entry) ((entry)->interval)
375 /**
376  * GST_CLOCK_ENTRY_STATUS:
377  * @entry: the entry to query
378  *
379  * The status of the entry
380  */
381 #define GST_CLOCK_ENTRY_STATUS(entry)   ((entry)->status)
382
383 /**
384  * GstClockEntry:
385  * @refcount: reference counter (read-only)
386  *
387  * All pending timeouts or periodic notifies are converted into
388  * an entry.
389  * Note that GstClockEntry should be treated as an opaque structure. It must
390  * not be extended or allocated using a custom allocator.
391  */
392 struct _GstClockEntry {
393   gint                  refcount;
394   /*< protected >*/
395 #ifndef GST_REMOVE_DEPRECATED
396 #ifndef GST_DISABLE_DEPRECATED
397   GstClock              *clock;
398 #else
399   gpointer               _clock;
400 #endif
401 #endif
402   GstClockEntryType      type;
403   GstClockTime           time;
404   GstClockTime           interval;
405   GstClockReturn         status;
406   GstClockCallback       func;
407   gpointer               user_data;
408   GDestroyNotify         destroy_data;
409   gboolean               unscheduled;
410   gboolean               woken_up;
411
412   /*< private >*/
413   union {
414     gpointer _gst_reserved[GST_PADDING];
415     struct {
416       GWeakRef clock;
417     } abi;
418   } ABI;
419 };
420
421 #include <gst/gstobject.h>
422
423 /**
424  * GstClockFlags:
425  * @GST_CLOCK_FLAG_CAN_DO_SINGLE_SYNC: clock can do a single sync timeout request
426  * @GST_CLOCK_FLAG_CAN_DO_SINGLE_ASYNC: clock can do a single async timeout request
427  * @GST_CLOCK_FLAG_CAN_DO_PERIODIC_SYNC: clock can do sync periodic timeout requests
428  * @GST_CLOCK_FLAG_CAN_DO_PERIODIC_ASYNC: clock can do async periodic timeout callbacks
429  * @GST_CLOCK_FLAG_CAN_SET_RESOLUTION: clock's resolution can be changed
430  * @GST_CLOCK_FLAG_CAN_SET_MASTER: clock can be slaved to a master clock
431  * @GST_CLOCK_FLAG_NEEDS_STARTUP_SYNC: clock needs to be synced before it can be used
432  *     (Since 1.6)
433  * @GST_CLOCK_FLAG_LAST: subclasses can add additional flags starting from this flag
434  *
435  * The capabilities of this clock
436  */
437 typedef enum {
438   GST_CLOCK_FLAG_CAN_DO_SINGLE_SYNC     = (GST_OBJECT_FLAG_LAST << 0),
439   GST_CLOCK_FLAG_CAN_DO_SINGLE_ASYNC    = (GST_OBJECT_FLAG_LAST << 1),
440   GST_CLOCK_FLAG_CAN_DO_PERIODIC_SYNC   = (GST_OBJECT_FLAG_LAST << 2),
441   GST_CLOCK_FLAG_CAN_DO_PERIODIC_ASYNC  = (GST_OBJECT_FLAG_LAST << 3),
442   GST_CLOCK_FLAG_CAN_SET_RESOLUTION     = (GST_OBJECT_FLAG_LAST << 4),
443   GST_CLOCK_FLAG_CAN_SET_MASTER         = (GST_OBJECT_FLAG_LAST << 5),
444   GST_CLOCK_FLAG_NEEDS_STARTUP_SYNC     = (GST_OBJECT_FLAG_LAST << 6),
445   /* padding */
446   GST_CLOCK_FLAG_LAST                   = (GST_OBJECT_FLAG_LAST << 8)
447 } GstClockFlags;
448
449 /**
450  * GST_CLOCK_FLAGS:
451  * @clock: the clock to query
452  *
453  * Gets the #GstClockFlags clock flags.
454  */
455 #define GST_CLOCK_FLAGS(clock)  GST_OBJECT_FLAGS(clock)
456
457 /**
458  * GstClock:
459  *
460  * #GstClock base structure. The values of this structure are
461  * protected for subclasses, use the methods to use the #GstClock.
462  */
463 struct _GstClock {
464   GstObject      object;
465
466   /*< private >*/
467   GstClockPrivate *priv;
468
469   gpointer _gst_reserved[GST_PADDING];
470 };
471
472 /**
473  * GstClockClass:
474  * @parent_class: the parent class structure
475  * @change_resolution: change the resolution of the clock. Not all values might
476  *                     be acceptable. The new resolution should be returned.
477  * @get_resolution: get the resolution of the clock.
478  * @get_internal_time: get the internal unadjusted time of the clock.
479  *        implement @wait_jitter instead.
480  * @wait: perform a blocking wait on the given #GstClockEntry and return
481  *               the jitter.
482  * @wait_async: perform an asynchronous wait for the given #GstClockEntry.
483  * @unschedule: unblock a blocking or async wait operation.
484  *
485  * GStreamer clock class. Override the vmethods to implement the clock
486  * functionality.
487  */
488 struct _GstClockClass {
489   GstObjectClass        parent_class;
490
491   /*< public >*/
492   /* vtable */
493   GstClockTime          (*change_resolution)    (GstClock *clock,
494                                                  GstClockTime old_resolution,
495                                                  GstClockTime new_resolution);
496   GstClockTime          (*get_resolution)       (GstClock *clock);
497
498   GstClockTime          (*get_internal_time)    (GstClock *clock);
499
500   /* waiting on an ID */
501   GstClockReturn        (*wait)                 (GstClock *clock, GstClockEntry *entry,
502                                                  GstClockTimeDiff *jitter);
503   GstClockReturn        (*wait_async)           (GstClock *clock, GstClockEntry *entry);
504   void                  (*unschedule)           (GstClock *clock, GstClockEntry *entry);
505
506   /*< private >*/
507   gpointer _gst_reserved[GST_PADDING];
508 };
509
510 GST_API
511 GType                   gst_clock_get_type              (void);
512
513 GST_API
514 GstClockTime            gst_clock_set_resolution        (GstClock *clock,
515                                                          GstClockTime resolution);
516 GST_API
517 GstClockTime            gst_clock_get_resolution        (GstClock *clock);
518
519 GST_API
520 GstClockTime            gst_clock_get_time              (GstClock *clock);
521
522 GST_API
523 void                    gst_clock_set_calibration       (GstClock *clock, GstClockTime internal,
524                                                          GstClockTime external,
525                                                          GstClockTime rate_num,
526                                                          GstClockTime rate_denom);
527 GST_API
528 void                    gst_clock_get_calibration       (GstClock *clock, GstClockTime *internal,
529                                                          GstClockTime *external,
530                                                          GstClockTime *rate_num,
531                                                          GstClockTime *rate_denom);
532
533 /* master/slave clocks */
534
535 GST_API
536 gboolean                gst_clock_set_master            (GstClock *clock, GstClock *master);
537
538 GST_API
539 GstClock*               gst_clock_get_master            (GstClock *clock);
540
541 GST_API
542 void                    gst_clock_set_timeout           (GstClock *clock,
543                                                          GstClockTime timeout);
544 GST_API
545 GstClockTime            gst_clock_get_timeout           (GstClock *clock);
546
547 GST_API
548 gboolean                gst_clock_add_observation       (GstClock *clock, GstClockTime slave,
549                                                          GstClockTime master, gdouble *r_squared);
550 GST_API
551 gboolean                gst_clock_add_observation_unapplied (GstClock *clock, GstClockTime slave,
552                                                          GstClockTime master, gdouble *r_squared,
553                                                          GstClockTime *internal,
554                                                          GstClockTime *external,
555                                                          GstClockTime *rate_num,
556                                                          GstClockTime *rate_denom);
557
558 /* getting and adjusting internal/external time */
559
560 GST_API
561 GstClockTime            gst_clock_get_internal_time     (GstClock *clock);
562
563 GST_API
564 GstClockTime            gst_clock_adjust_unlocked       (GstClock *clock, GstClockTime internal);
565
566 GST_API
567 GstClockTime            gst_clock_adjust_with_calibration (GstClock *clock,
568                                                          GstClockTime internal_target,
569                                                          GstClockTime cinternal,
570                                                          GstClockTime cexternal,
571                                                          GstClockTime cnum,
572                                                          GstClockTime cdenom);
573 GST_API
574 GstClockTime            gst_clock_unadjust_with_calibration (GstClock *clock,
575                                                          GstClockTime external_target,
576                                                          GstClockTime cinternal,
577                                                          GstClockTime cexternal,
578                                                          GstClockTime cnum,
579                                                          GstClockTime cdenom);
580 GST_API
581 GstClockTime            gst_clock_unadjust_unlocked     (GstClock * clock, GstClockTime external);
582
583 /* waiting for, signalling and checking for synchronization */
584
585 GST_API
586 gboolean                gst_clock_wait_for_sync         (GstClock * clock, GstClockTime timeout);
587
588 GST_API
589 gboolean                gst_clock_is_synced             (GstClock * clock);
590
591 /* to be used by subclasses only */
592
593 GST_API
594 void                    gst_clock_set_synced            (GstClock * clock, gboolean synced);
595
596 /* creating IDs that can be used to get notifications */
597
598 GST_API
599 GstClockID              gst_clock_new_single_shot_id    (GstClock *clock,
600                                                          GstClockTime time);
601 GST_API
602 GstClockID              gst_clock_new_periodic_id       (GstClock *clock,
603                                                          GstClockTime start_time,
604                                                          GstClockTime interval);
605
606 /* reference counting */
607
608 GST_API
609 GstClockID              gst_clock_id_ref                (GstClockID id);
610
611 GST_API
612 void                    gst_clock_id_unref              (GstClockID id);
613
614 /* operations on IDs */
615
616 GST_API
617 gint                    gst_clock_id_compare_func       (gconstpointer id1, gconstpointer id2);
618
619 GST_API
620 GstClock *              gst_clock_id_get_clock          (GstClockID id);
621
622 GST_API
623 gboolean                gst_clock_id_uses_clock         (GstClockID id, GstClock * clock);
624
625 GST_API
626 GstClockTime            gst_clock_id_get_time           (GstClockID id);
627
628 GST_API
629 GstClockReturn          gst_clock_id_wait               (GstClockID id,
630                                                          GstClockTimeDiff *jitter);
631 GST_API
632 GstClockReturn          gst_clock_id_wait_async         (GstClockID id,
633                                                          GstClockCallback func,
634                                                          gpointer user_data,
635                                                          GDestroyNotify destroy_data);
636 GST_API
637 void                    gst_clock_id_unschedule         (GstClockID id);
638
639 GST_API
640 gboolean                gst_clock_single_shot_id_reinit (GstClock * clock,
641                                                          GstClockID id,
642                                                          GstClockTime time);
643 GST_API
644 gboolean                gst_clock_periodic_id_reinit    (GstClock * clock,
645                                                          GstClockID id,
646                                                          GstClockTime start_time,
647                                                          GstClockTime interval);
648
649 #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
650 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstClock, gst_object_unref)
651 #endif
652
653 G_END_DECLS
654
655 #endif /* __GST_CLOCK_H__ */