1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gstreamer.Clock;
26 
27 private import gobject.ObjectG;
28 private import gobject.Signals;
29 private import gstreamer.ObjectGst;
30 private import gstreamerc.gstreamer;
31 public  import gstreamerc.gstreamertypes;
32 public  import gtkc.gdktypes;
33 
34 
35 /**
36  * GStreamer uses a global clock to synchronize the plugins in a pipeline.
37  * Different clock implementations are possible by implementing this abstract
38  * base class or, more conveniently, by subclassing #GstSystemClock.
39  * 
40  * The #GstClock returns a monotonically increasing time with the method
41  * gst_clock_get_time(). Its accuracy and base time depend on the specific
42  * clock implementation but time is always expressed in nanoseconds. Since the
43  * baseline of the clock is undefined, the clock time returned is not
44  * meaningful in itself, what matters are the deltas between two clock times.
45  * The time returned by a clock is called the absolute time.
46  * 
47  * The pipeline uses the clock to calculate the running time. Usually all
48  * renderers synchronize to the global clock using the buffer timestamps, the
49  * newsegment events and the element's base time, see #GstPipeline.
50  * 
51  * A clock implementation can support periodic and single shot clock
52  * notifications both synchronous and asynchronous.
53  * 
54  * One first needs to create a #GstClockID for the periodic or single shot
55  * notification using gst_clock_new_single_shot_id() or
56  * gst_clock_new_periodic_id().
57  * 
58  * To perform a blocking wait for the specific time of the #GstClockID use the
59  * gst_clock_id_wait(). To receive a callback when the specific time is reached
60  * in the clock use gst_clock_id_wait_async(). Both these calls can be
61  * interrupted with the gst_clock_id_unschedule() call. If the blocking wait is
62  * unscheduled a return value of #GST_CLOCK_UNSCHEDULED is returned.
63  * 
64  * Periodic callbacks scheduled async will be repeatedly called automatically
65  * until it is unscheduled. To schedule a sync periodic callback,
66  * gst_clock_id_wait() should be called repeatedly.
67  * 
68  * The async callbacks can happen from any thread, either provided by the core
69  * or from a streaming thread. The application should be prepared for this.
70  * 
71  * A #GstClockID that has been unscheduled cannot be used again for any wait
72  * operation, a new #GstClockID should be created and the old unscheduled one
73  * should be destroyed with gst_clock_id_unref().
74  * 
75  * It is possible to perform a blocking wait on the same #GstClockID from
76  * multiple threads. However, registering the same #GstClockID for multiple
77  * async notifications is not possible, the callback will only be called for
78  * the thread registering the entry last.
79  * 
80  * None of the wait operations unref the #GstClockID, the owner is responsible
81  * for unreffing the ids itself. This holds for both periodic and single shot
82  * notifications. The reason being that the owner of the #GstClockID has to
83  * keep a handle to the #GstClockID to unblock the wait on FLUSHING events or
84  * state changes and if the entry would be unreffed automatically, the handle
85  * might become invalid without any notification.
86  * 
87  * These clock operations do not operate on the running time, so the callbacks
88  * will also occur when not in PLAYING state as if the clock just keeps on
89  * running. Some clocks however do not progress when the element that provided
90  * the clock is not PLAYING.
91  * 
92  * When a clock has the #GST_CLOCK_FLAG_CAN_SET_MASTER flag set, it can be
93  * slaved to another #GstClock with the gst_clock_set_master(). The clock will
94  * then automatically be synchronized to this master clock by repeatedly
95  * sampling the master clock and the slave clock and recalibrating the slave
96  * clock with gst_clock_set_calibration(). This feature is mostly useful for
97  * plugins that have an internal clock but must operate with another clock
98  * selected by the #GstPipeline.  They can track the offset and rate difference
99  * of their internal clock relative to the master clock by using the
100  * gst_clock_get_calibration() function.
101  * 
102  * The master/slave synchronisation can be tuned with the #GstClock:timeout,
103  * #GstClock:window-size and #GstClock:window-threshold properties.
104  * The #GstClock:timeout property defines the interval to sample the master
105  * clock and run the calibration functions. #GstClock:window-size defines the
106  * number of samples to use when calibrating and #GstClock:window-threshold
107  * defines the minimum number of samples before the calibration is performed.
108  */
109 public class Clock : ObjectGst
110 {
111 	/** the main Gtk struct */
112 	protected GstClock* gstClock;
113 
114 	/** Get the main Gtk struct */
115 	public GstClock* getClockStruct()
116 	{
117 		return gstClock;
118 	}
119 
120 	/** the main Gtk struct as a void* */
121 	protected override void* getStruct()
122 	{
123 		return cast(void*)gstClock;
124 	}
125 
126 	protected override void setStruct(GObject* obj)
127 	{
128 		gstClock = cast(GstClock*)obj;
129 		super.setStruct(obj);
130 	}
131 
132 	/**
133 	 * Sets our main struct and passes it to the parent class.
134 	 */
135 	public this (GstClock* gstClock, bool ownedRef = false)
136 	{
137 		this.gstClock = gstClock;
138 		super(cast(GstObject*)gstClock, ownedRef);
139 	}
140 
141 	/**
142 	 */
143 
144 	public static GType getType()
145 	{
146 		return gst_clock_get_type();
147 	}
148 
149 	/**
150 	 * Compares the two #GstClockID instances. This function can be used
151 	 * as a GCompareFunc when sorting ids.
152 	 *
153 	 * Params:
154 	 *     id1 = A #GstClockID
155 	 *     id2 = A #GstClockID to compare with
156 	 *
157 	 * Return: negative value if a < b; zero if a = b; positive value if a > b
158 	 *
159 	 *     MT safe.
160 	 */
161 	public static int idCompareFunc(void* id1, void* id2)
162 	{
163 		return gst_clock_id_compare_func(id1, id2);
164 	}
165 
166 	/**
167 	 * Get the time of the clock ID
168 	 *
169 	 * Params:
170 	 *     id = The #GstClockID to query
171 	 *
172 	 * Return: the time of the given clock id.
173 	 *
174 	 *     MT safe.
175 	 */
176 	public static GstClockTime idGetTime(GstClockID id)
177 	{
178 		return gst_clock_id_get_time(id);
179 	}
180 
181 	/**
182 	 * Increase the refcount of given @id.
183 	 *
184 	 * Params:
185 	 *     id = The #GstClockID to ref
186 	 *
187 	 * Return: The same #GstClockID with increased refcount.
188 	 *
189 	 *     MT safe.
190 	 */
191 	public static GstClockID idRef(GstClockID id)
192 	{
193 		return gst_clock_id_ref(id);
194 	}
195 
196 	/**
197 	 * Unref given @id. When the refcount reaches 0 the
198 	 * #GstClockID will be freed.
199 	 *
200 	 * MT safe.
201 	 *
202 	 * Params:
203 	 *     id = The #GstClockID to unref
204 	 */
205 	public static void idUnref(GstClockID id)
206 	{
207 		gst_clock_id_unref(id);
208 	}
209 
210 	/**
211 	 * Cancel an outstanding request with @id. This can either
212 	 * be an outstanding async notification or a pending sync notification.
213 	 * After this call, @id cannot be used anymore to receive sync or
214 	 * async notifications, you need to create a new #GstClockID.
215 	 *
216 	 * MT safe.
217 	 *
218 	 * Params:
219 	 *     id = The id to unschedule
220 	 */
221 	public static void idUnschedule(GstClockID id)
222 	{
223 		gst_clock_id_unschedule(id);
224 	}
225 
226 	/**
227 	 * Perform a blocking wait on @id.
228 	 * @id should have been created with gst_clock_new_single_shot_id()
229 	 * or gst_clock_new_periodic_id() and should not have been unscheduled
230 	 * with a call to gst_clock_id_unschedule().
231 	 *
232 	 * If the @jitter argument is not %NULL and this function returns #GST_CLOCK_OK
233 	 * or #GST_CLOCK_EARLY, it will contain the difference
234 	 * against the clock and the time of @id when this method was
235 	 * called.
236 	 * Positive values indicate how late @id was relative to the clock
237 	 * (in which case this function will return #GST_CLOCK_EARLY).
238 	 * Negative values indicate how much time was spent waiting on the clock
239 	 * before this function returned.
240 	 *
241 	 * Params:
242 	 *     id = The #GstClockID to wait on
243 	 *     jitter = a pointer that will contain the jitter,
244 	 *         can be %NULL.
245 	 *
246 	 * Return: the result of the blocking wait. #GST_CLOCK_EARLY will be returned
247 	 *     if the current clock time is past the time of @id, #GST_CLOCK_OK if
248 	 *     @id was scheduled in time. #GST_CLOCK_UNSCHEDULED if @id was
249 	 *     unscheduled with gst_clock_id_unschedule().
250 	 *
251 	 *     MT safe.
252 	 */
253 	public static GstClockReturn idWait(GstClockID id, out GstClockTimeDiff jitter)
254 	{
255 		return gst_clock_id_wait(id, &jitter);
256 	}
257 
258 	/**
259 	 * Register a callback on the given #GstClockID @id with the given
260 	 * function and user_data. When passing a #GstClockID with an invalid
261 	 * time to this function, the callback will be called immediately
262 	 * with  a time set to GST_CLOCK_TIME_NONE. The callback will
263 	 * be called when the time of @id has been reached.
264 	 *
265 	 * The callback @func can be invoked from any thread, either provided by the
266 	 * core or from a streaming thread. The application should be prepared for this.
267 	 *
268 	 * Params:
269 	 *     id = a #GstClockID to wait on
270 	 *     func = The callback function
271 	 *     userData = User data passed in the callback
272 	 *     destroyData = #GDestroyNotify for user_data
273 	 *
274 	 * Return: the result of the non blocking wait.
275 	 *
276 	 *     MT safe.
277 	 */
278 	public static GstClockReturn idWaitAsync(GstClockID id, GstClockCallback func, void* userData, GDestroyNotify destroyData)
279 	{
280 		return gst_clock_id_wait_async(id, func, userData, destroyData);
281 	}
282 
283 	/**
284 	 * The time @master of the master clock and the time @slave of the slave
285 	 * clock are added to the list of observations. If enough observations
286 	 * are available, a linear regression algorithm is run on the
287 	 * observations and @clock is recalibrated.
288 	 *
289 	 * If this functions returns %TRUE, @r_squared will contain the
290 	 * correlation coefficient of the interpolation. A value of 1.0
291 	 * means a perfect regression was performed. This value can
292 	 * be used to control the sampling frequency of the master and slave
293 	 * clocks.
294 	 *
295 	 * Params:
296 	 *     slave = a time on the slave
297 	 *     master = a time on the master
298 	 *     rSquared = a pointer to hold the result
299 	 *
300 	 * Return: %TRUE if enough observations were added to run the
301 	 *     regression algorithm.
302 	 *
303 	 *     MT safe.
304 	 */
305 	public bool addObservation(GstClockTime slave, GstClockTime master, out double rSquared)
306 	{
307 		return gst_clock_add_observation(gstClock, slave, master, &rSquared) != 0;
308 	}
309 
310 	/**
311 	 * Add a clock observation to the internal slaving algorithm the same as
312 	 * gst_clock_add_observation(), and return the result of the master clock
313 	 * estimation, without updating the internal calibration.
314 	 *
315 	 * The caller can then take the results and call gst_clock_set_calibration()
316 	 * with the values, or some modified version of them.
317 	 *
318 	 * Params:
319 	 *     slave = a time on the slave
320 	 *     master = a time on the master
321 	 *     rSquared = a pointer to hold the result
322 	 *     internal = a location to store the internal time
323 	 *     external = a location to store the external time
324 	 *     rateNum = a location to store the rate numerator
325 	 *     rateDenom = a location to store the rate denominator
326 	 *
327 	 * Since: 1.6
328 	 */
329 	public bool addObservationUnapplied(GstClockTime slave, GstClockTime master, out double rSquared, out GstClockTime internal, out GstClockTime external, out GstClockTime rateNum, out GstClockTime rateDenom)
330 	{
331 		return gst_clock_add_observation_unapplied(gstClock, slave, master, &rSquared, &internal, &external, &rateNum, &rateDenom) != 0;
332 	}
333 
334 	/**
335 	 * Converts the given @internal clock time to the external time, adjusting for the
336 	 * rate and reference time set with gst_clock_set_calibration() and making sure
337 	 * that the returned time is increasing. This function should be called with the
338 	 * clock's OBJECT_LOCK held and is mainly used by clock subclasses.
339 	 *
340 	 * This function is the reverse of gst_clock_unadjust_unlocked().
341 	 *
342 	 * Params:
343 	 *     internal = a clock time
344 	 *
345 	 * Return: the converted time of the clock.
346 	 */
347 	public GstClockTime adjustUnlocked(GstClockTime internal)
348 	{
349 		return gst_clock_adjust_unlocked(gstClock, internal);
350 	}
351 
352 	/**
353 	 * Converts the given @internal_target clock time to the external time,
354 	 * using the passed calibration parameters. This function performs the
355 	 * same calculation as gst_clock_adjust_unlocked() when called using the
356 	 * current calibration parameters, but doesn't ensure a monotonically
357 	 * increasing result as gst_clock_adjust_unlocked() does.
358 	 *
359 	 * Params:
360 	 *     internalTarget = a clock time
361 	 *     cinternal = a reference internal time
362 	 *     cexternal = a reference external time
363 	 *     cnum = the numerator of the rate of the clock relative to its
364 	 *         internal time
365 	 *     cdenom = the denominator of the rate of the clock
366 	 *
367 	 * Return: the converted time of the clock.
368 	 *
369 	 * Since: 1.6
370 	 */
371 	public GstClockTime adjustWithCalibration(GstClockTime internalTarget, GstClockTime cinternal, GstClockTime cexternal, GstClockTime cnum, GstClockTime cdenom)
372 	{
373 		return gst_clock_adjust_with_calibration(gstClock, internalTarget, cinternal, cexternal, cnum, cdenom);
374 	}
375 
376 	/**
377 	 * Gets the internal rate and reference time of @clock. See
378 	 * gst_clock_set_calibration() for more information.
379 	 *
380 	 * @internal, @external, @rate_num, and @rate_denom can be left %NULL if the
381 	 * caller is not interested in the values.
382 	 *
383 	 * MT safe.
384 	 *
385 	 * Params:
386 	 *     internal = a location to store the internal time
387 	 *     external = a location to store the external time
388 	 *     rateNum = a location to store the rate numerator
389 	 *     rateDenom = a location to store the rate denominator
390 	 */
391 	public void getCalibration(out GstClockTime internal, out GstClockTime external, out GstClockTime rateNum, out GstClockTime rateDenom)
392 	{
393 		gst_clock_get_calibration(gstClock, &internal, &external, &rateNum, &rateDenom);
394 	}
395 
396 	/**
397 	 * Gets the current internal time of the given clock. The time is returned
398 	 * unadjusted for the offset and the rate.
399 	 *
400 	 * Return: the internal time of the clock. Or GST_CLOCK_TIME_NONE when
401 	 *     given invalid input.
402 	 *
403 	 *     MT safe.
404 	 */
405 	public GstClockTime getInternalTime()
406 	{
407 		return gst_clock_get_internal_time(gstClock);
408 	}
409 
410 	/**
411 	 * Get the master clock that @clock is slaved to or %NULL when the clock is
412 	 * not slaved to any master clock.
413 	 *
414 	 * Return: a master #GstClock or %NULL
415 	 *     when this clock is not slaved to a master clock. Unref after
416 	 *     usage.
417 	 *
418 	 *     MT safe.
419 	 */
420 	public Clock getMaster()
421 	{
422 		auto p = gst_clock_get_master(gstClock);
423 		
424 		if(p is null)
425 		{
426 			return null;
427 		}
428 		
429 		return ObjectG.getDObject!(Clock)(cast(GstClock*) p, true);
430 	}
431 
432 	/**
433 	 * Get the accuracy of the clock. The accuracy of the clock is the granularity
434 	 * of the values returned by gst_clock_get_time().
435 	 *
436 	 * Return: the resolution of the clock in units of #GstClockTime.
437 	 *
438 	 *     MT safe.
439 	 */
440 	public GstClockTime getResolution()
441 	{
442 		return gst_clock_get_resolution(gstClock);
443 	}
444 
445 	/**
446 	 * Gets the current time of the given clock. The time is always
447 	 * monotonically increasing and adjusted according to the current
448 	 * offset and rate.
449 	 *
450 	 * Return: the time of the clock. Or GST_CLOCK_TIME_NONE when
451 	 *     given invalid input.
452 	 *
453 	 *     MT safe.
454 	 */
455 	public GstClockTime getTime()
456 	{
457 		return gst_clock_get_time(gstClock);
458 	}
459 
460 	/**
461 	 * Get the amount of time that master and slave clocks are sampled.
462 	 *
463 	 * Return: the interval between samples.
464 	 */
465 	public GstClockTime getTimeout()
466 	{
467 		return gst_clock_get_timeout(gstClock);
468 	}
469 
470 	/**
471 	 * Checks if the clock is currently synced.
472 	 *
473 	 * This returns if GST_CLOCK_FLAG_NEEDS_STARTUP_SYNC is not set on the clock.
474 	 *
475 	 * Return: %TRUE if the clock is currently synced
476 	 *
477 	 * Since: 1.6
478 	 */
479 	public bool isSynced()
480 	{
481 		return gst_clock_is_synced(gstClock) != 0;
482 	}
483 
484 	/**
485 	 * Get an ID from @clock to trigger a periodic notification.
486 	 * The periodic notifications will start at time @start_time and
487 	 * will then be fired with the given @interval. @id should be unreffed
488 	 * after usage.
489 	 *
490 	 * Free-function: gst_clock_id_unref
491 	 *
492 	 * Params:
493 	 *     startTime = the requested start time
494 	 *     interval = the requested interval
495 	 *
496 	 * Return: a #GstClockID that can be used to request the
497 	 *     time notification.
498 	 *
499 	 *     MT safe.
500 	 */
501 	public GstClockID newPeriodicId(GstClockTime startTime, GstClockTime interval)
502 	{
503 		return gst_clock_new_periodic_id(gstClock, startTime, interval);
504 	}
505 
506 	/**
507 	 * Get a #GstClockID from @clock to trigger a single shot
508 	 * notification at the requested time. The single shot id should be
509 	 * unreffed after usage.
510 	 *
511 	 * Free-function: gst_clock_id_unref
512 	 *
513 	 * Params:
514 	 *     time = the requested time
515 	 *
516 	 * Return: a #GstClockID that can be used to request the
517 	 *     time notification.
518 	 *
519 	 *     MT safe.
520 	 */
521 	public GstClockID newSingleShotId(GstClockTime time)
522 	{
523 		return gst_clock_new_single_shot_id(gstClock, time);
524 	}
525 
526 	/**
527 	 * Reinitializes the provided periodic @id to the provided start time and
528 	 * interval. Does not modify the reference count.
529 	 *
530 	 * Params:
531 	 *     id = a #GstClockID
532 	 *     startTime = the requested start time
533 	 *     interval = the requested interval
534 	 *
535 	 * Return: %TRUE if the GstClockID could be reinitialized to the provided
536 	 *     @time, else %FALSE.
537 	 */
538 	public bool periodicIdReinit(GstClockID id, GstClockTime startTime, GstClockTime interval)
539 	{
540 		return gst_clock_periodic_id_reinit(gstClock, id, startTime, interval) != 0;
541 	}
542 
543 	/**
544 	 * Adjusts the rate and time of @clock. A rate of 1/1 is the normal speed of
545 	 * the clock. Values bigger than 1/1 make the clock go faster.
546 	 *
547 	 * @internal and @external are calibration parameters that arrange that
548 	 * gst_clock_get_time() should have been @external at internal time @internal.
549 	 * This internal time should not be in the future; that is, it should be less
550 	 * than the value of gst_clock_get_internal_time() when this function is called.
551 	 *
552 	 * Subsequent calls to gst_clock_get_time() will return clock times computed as
553 	 * follows:
554 	 *
555 	 * <programlisting>
556 	 * time = (internal_time - internal) * rate_num / rate_denom + external
557 	 * </programlisting>
558 	 *
559 	 * This formula is implemented in gst_clock_adjust_unlocked(). Of course, it
560 	 * tries to do the integer arithmetic as precisely as possible.
561 	 *
562 	 * Note that gst_clock_get_time() always returns increasing values so when you
563 	 * move the clock backwards, gst_clock_get_time() will report the previous value
564 	 * until the clock catches up.
565 	 *
566 	 * MT safe.
567 	 *
568 	 * Params:
569 	 *     internal = a reference internal time
570 	 *     external = a reference external time
571 	 *     rateNum = the numerator of the rate of the clock relative to its
572 	 *         internal time
573 	 *     rateDenom = the denominator of the rate of the clock
574 	 */
575 	public void setCalibration(GstClockTime internal, GstClockTime external, GstClockTime rateNum, GstClockTime rateDenom)
576 	{
577 		gst_clock_set_calibration(gstClock, internal, external, rateNum, rateDenom);
578 	}
579 
580 	/**
581 	 * Set @master as the master clock for @clock. @clock will be automatically
582 	 * calibrated so that gst_clock_get_time() reports the same time as the
583 	 * master clock.
584 	 *
585 	 * A clock provider that slaves its clock to a master can get the current
586 	 * calibration values with gst_clock_get_calibration().
587 	 *
588 	 * @master can be %NULL in which case @clock will not be slaved anymore. It will
589 	 * however keep reporting its time adjusted with the last configured rate
590 	 * and time offsets.
591 	 *
592 	 * Params:
593 	 *     master = a master #GstClock
594 	 *
595 	 * Return: %TRUE if the clock is capable of being slaved to a master clock.
596 	 *     Trying to set a master on a clock without the
597 	 *     #GST_CLOCK_FLAG_CAN_SET_MASTER flag will make this function return %FALSE.
598 	 *
599 	 *     MT safe.
600 	 */
601 	public bool setMaster(Clock master)
602 	{
603 		return gst_clock_set_master(gstClock, (master is null) ? null : master.getClockStruct()) != 0;
604 	}
605 
606 	/**
607 	 * Set the accuracy of the clock. Some clocks have the possibility to operate
608 	 * with different accuracy at the expense of more resource usage. There is
609 	 * normally no need to change the default resolution of a clock. The resolution
610 	 * of a clock can only be changed if the clock has the
611 	 * #GST_CLOCK_FLAG_CAN_SET_RESOLUTION flag set.
612 	 *
613 	 * Params:
614 	 *     resolution = The resolution to set
615 	 *
616 	 * Return: the new resolution of the clock.
617 	 */
618 	public GstClockTime setResolution(GstClockTime resolution)
619 	{
620 		return gst_clock_set_resolution(gstClock, resolution);
621 	}
622 
623 	/**
624 	 * Sets @clock to synced and emits the GstClock::synced signal, and wakes up any
625 	 * thread waiting in gst_clock_wait_for_sync().
626 	 *
627 	 * This function must only be called if GST_CLOCK_FLAG_NEEDS_STARTUP_SYNC
628 	 * is set on the clock, and is intended to be called by subclasses only.
629 	 *
630 	 * Params:
631 	 *     synced = if the clock is synced
632 	 *
633 	 * Since: 1.6
634 	 */
635 	public void setSynced(bool synced)
636 	{
637 		gst_clock_set_synced(gstClock, synced);
638 	}
639 
640 	/**
641 	 * Set the amount of time, in nanoseconds, to sample master and slave
642 	 * clocks
643 	 *
644 	 * Params:
645 	 *     timeout = a timeout
646 	 */
647 	public void setTimeout(GstClockTime timeout)
648 	{
649 		gst_clock_set_timeout(gstClock, timeout);
650 	}
651 
652 	/**
653 	 * Reinitializes the provided single shot @id to the provided time. Does not
654 	 * modify the reference count.
655 	 *
656 	 * Params:
657 	 *     id = a #GstClockID
658 	 *     time = The requested time.
659 	 *
660 	 * Return: %TRUE if the GstClockID could be reinitialized to the provided
661 	 *     @time, else %FALSE.
662 	 */
663 	public bool singleShotIdReinit(GstClockID id, GstClockTime time)
664 	{
665 		return gst_clock_single_shot_id_reinit(gstClock, id, time) != 0;
666 	}
667 
668 	/**
669 	 * Converts the given @external clock time to the internal time of @clock,
670 	 * using the rate and reference time set with gst_clock_set_calibration().
671 	 * This function should be called with the clock's OBJECT_LOCK held and
672 	 * is mainly used by clock subclasses.
673 	 *
674 	 * This function is the reverse of gst_clock_adjust_unlocked().
675 	 *
676 	 * Params:
677 	 *     external = an external clock time
678 	 *
679 	 * Return: the internal time of the clock corresponding to @external.
680 	 */
681 	public GstClockTime unadjustUnlocked(GstClockTime external)
682 	{
683 		return gst_clock_unadjust_unlocked(gstClock, external);
684 	}
685 
686 	/**
687 	 * Waits until @clock is synced for reporting the current time. If @timeout
688 	 * is %GST_CLOCK_TIME_NONE it will wait forever, otherwise it will time out
689 	 * after @timeout nanoseconds.
690 	 *
691 	 * For asynchronous waiting, the GstClock::synced signal can be used.
692 	 *
693 	 *
694 	 * This returns immediately with TRUE if GST_CLOCK_FLAG_NEEDS_STARTUP_SYNC
695 	 * is not set on the clock, or if the clock is already synced.
696 	 *
697 	 * Params:
698 	 *     timeout = timeout for waiting or %GST_CLOCK_TIME_NONE
699 	 *
700 	 * Return: %TRUE if waiting was successful, or %FALSE on timeout
701 	 *
702 	 * Since: 1.6
703 	 */
704 	public bool waitForSync(GstClockTime timeout)
705 	{
706 		return gst_clock_wait_for_sync(gstClock, timeout) != 0;
707 	}
708 
709 	int[string] connectedSignals;
710 
711 	void delegate(bool, Clock)[] onSyncedListeners;
712 	/**
713 	 * Signaled on clocks with GST_CLOCK_FLAG_NEEDS_STARTUP_SYNC set once
714 	 * the clock is synchronized, or when it completely lost synchronization.
715 	 * This signal will not be emitted on clocks without the flag.
716 	 *
717 	 * This signal will be emitted from an arbitrary thread, most likely not
718 	 * the application's main thread.
719 	 *
720 	 * Params:
721 	 *     synced = if the clock is synced now
722 	 *
723 	 * Since: 1.6
724 	 */
725 	void addOnSynced(void delegate(bool, Clock) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
726 	{
727 		if ( "synced" !in connectedSignals )
728 		{
729 			Signals.connectData(
730 				this,
731 				"synced",
732 				cast(GCallback)&callBackSynced,
733 				cast(void*)this,
734 				null,
735 				connectFlags);
736 			connectedSignals["synced"] = 1;
737 		}
738 		onSyncedListeners ~= dlg;
739 	}
740 	extern(C) static void callBackSynced(GstClock* clockStruct, bool synced, Clock _clock)
741 	{
742 		foreach ( void delegate(bool, Clock) dlg; _clock.onSyncedListeners )
743 		{
744 			dlg(synced, _clock);
745 		}
746 	}
747 }