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 	public static GType getType()
144 	{
145 		return gst_clock_get_type();
146 	}
147 
148 	/**
149 	 * Compares the two #GstClockID instances. This function can be used
150 	 * as a GCompareFunc when sorting ids.
151 	 *
152 	 * Params:
153 	 *     id1 = A #GstClockID
154 	 *     id2 = A #GstClockID to compare with
155 	 *
156 	 * Return: negative value if a < b; zero if a = b; positive value if a > b
157 	 *
158 	 *     MT safe.
159 	 */
160 	public static int idCompareFunc(void* id1, void* id2)
161 	{
162 		return gst_clock_id_compare_func(id1, id2);
163 	}
164 
165 	/**
166 	 * Get the time of the clock ID
167 	 *
168 	 * Params:
169 	 *     id = The #GstClockID to query
170 	 *
171 	 * Return: the time of the given clock id.
172 	 *
173 	 *     MT safe.
174 	 */
175 	public static GstClockTime idGetTime(GstClockID id)
176 	{
177 		return gst_clock_id_get_time(id);
178 	}
179 
180 	/**
181 	 * Increase the refcount of given @id.
182 	 *
183 	 * Params:
184 	 *     id = The #GstClockID to ref
185 	 *
186 	 * Return: The same #GstClockID with increased refcount.
187 	 *
188 	 *     MT safe.
189 	 */
190 	public static GstClockID idRef(GstClockID id)
191 	{
192 		return gst_clock_id_ref(id);
193 	}
194 
195 	/**
196 	 * Unref given @id. When the refcount reaches 0 the
197 	 * #GstClockID will be freed.
198 	 *
199 	 * MT safe.
200 	 *
201 	 * Params:
202 	 *     id = The #GstClockID to unref
203 	 */
204 	public static void idUnref(GstClockID id)
205 	{
206 		gst_clock_id_unref(id);
207 	}
208 
209 	/**
210 	 * Cancel an outstanding request with @id. This can either
211 	 * be an outstanding async notification or a pending sync notification.
212 	 * After this call, @id cannot be used anymore to receive sync or
213 	 * async notifications, you need to create a new #GstClockID.
214 	 *
215 	 * MT safe.
216 	 *
217 	 * Params:
218 	 *     id = The id to unschedule
219 	 */
220 	public static void idUnschedule(GstClockID id)
221 	{
222 		gst_clock_id_unschedule(id);
223 	}
224 
225 	/**
226 	 * Perform a blocking wait on @id.
227 	 * @id should have been created with gst_clock_new_single_shot_id()
228 	 * or gst_clock_new_periodic_id() and should not have been unscheduled
229 	 * with a call to gst_clock_id_unschedule().
230 	 *
231 	 * If the @jitter argument is not %NULL and this function returns #GST_CLOCK_OK
232 	 * or #GST_CLOCK_EARLY, it will contain the difference
233 	 * against the clock and the time of @id when this method was
234 	 * called.
235 	 * Positive values indicate how late @id was relative to the clock
236 	 * (in which case this function will return #GST_CLOCK_EARLY).
237 	 * Negative values indicate how much time was spent waiting on the clock
238 	 * before this function returned.
239 	 *
240 	 * Params:
241 	 *     id = The #GstClockID to wait on
242 	 *     jitter = a pointer that will contain the jitter,
243 	 *         can be %NULL.
244 	 *
245 	 * Return: the result of the blocking wait. #GST_CLOCK_EARLY will be returned
246 	 *     if the current clock time is past the time of @id, #GST_CLOCK_OK if
247 	 *     @id was scheduled in time. #GST_CLOCK_UNSCHEDULED if @id was
248 	 *     unscheduled with gst_clock_id_unschedule().
249 	 *
250 	 *     MT safe.
251 	 */
252 	public static GstClockReturn idWait(GstClockID id, out GstClockTimeDiff jitter)
253 	{
254 		return gst_clock_id_wait(id, &jitter);
255 	}
256 
257 	/**
258 	 * Register a callback on the given #GstClockID @id with the given
259 	 * function and user_data. When passing a #GstClockID with an invalid
260 	 * time to this function, the callback will be called immediately
261 	 * with  a time set to GST_CLOCK_TIME_NONE. The callback will
262 	 * be called when the time of @id has been reached.
263 	 *
264 	 * The callback @func can be invoked from any thread, either provided by the
265 	 * core or from a streaming thread. The application should be prepared for this.
266 	 *
267 	 * Params:
268 	 *     id = a #GstClockID to wait on
269 	 *     func = The callback function
270 	 *     userData = User data passed in the callback
271 	 *     destroyData = #GDestroyNotify for user_data
272 	 *
273 	 * Return: the result of the non blocking wait.
274 	 *
275 	 *     MT safe.
276 	 */
277 	public static GstClockReturn idWaitAsync(GstClockID id, GstClockCallback func, void* userData, GDestroyNotify destroyData)
278 	{
279 		return gst_clock_id_wait_async(id, func, userData, destroyData);
280 	}
281 
282 	/**
283 	 * The time @master of the master clock and the time @slave of the slave
284 	 * clock are added to the list of observations. If enough observations
285 	 * are available, a linear regression algorithm is run on the
286 	 * observations and @clock is recalibrated.
287 	 *
288 	 * If this functions returns %TRUE, @r_squared will contain the
289 	 * correlation coefficient of the interpolation. A value of 1.0
290 	 * means a perfect regression was performed. This value can
291 	 * be used to control the sampling frequency of the master and slave
292 	 * clocks.
293 	 *
294 	 * Params:
295 	 *     slave = a time on the slave
296 	 *     master = a time on the master
297 	 *     rSquared = a pointer to hold the result
298 	 *
299 	 * Return: %TRUE if enough observations were added to run the
300 	 *     regression algorithm.
301 	 *
302 	 *     MT safe.
303 	 */
304 	public bool addObservation(GstClockTime slave, GstClockTime master, out double rSquared)
305 	{
306 		return gst_clock_add_observation(gstClock, slave, master, &rSquared) != 0;
307 	}
308 
309 	/**
310 	 * Add a clock observation to the internal slaving algorithm the same as
311 	 * gst_clock_add_observation(), and return the result of the master clock
312 	 * estimation, without updating the internal calibration.
313 	 *
314 	 * The caller can then take the results and call gst_clock_set_calibration()
315 	 * with the values, or some modified version of them.
316 	 *
317 	 * Params:
318 	 *     slave = a time on the slave
319 	 *     master = a time on the master
320 	 *     rSquared = a pointer to hold the result
321 	 *     internal = a location to store the internal time
322 	 *     external = a location to store the external time
323 	 *     rateNum = a location to store the rate numerator
324 	 *     rateDenom = a location to store the rate denominator
325 	 *
326 	 * Since: 1.6
327 	 */
328 	public bool addObservationUnapplied(GstClockTime slave, GstClockTime master, out double rSquared, out GstClockTime internal, out GstClockTime external, out GstClockTime rateNum, out GstClockTime rateDenom)
329 	{
330 		return gst_clock_add_observation_unapplied(gstClock, slave, master, &rSquared, &internal, &external, &rateNum, &rateDenom) != 0;
331 	}
332 
333 	/**
334 	 * Converts the given @internal clock time to the external time, adjusting for the
335 	 * rate and reference time set with gst_clock_set_calibration() and making sure
336 	 * that the returned time is increasing. This function should be called with the
337 	 * clock's OBJECT_LOCK held and is mainly used by clock subclasses.
338 	 *
339 	 * This function is the reverse of gst_clock_unadjust_unlocked().
340 	 *
341 	 * Params:
342 	 *     internal = a clock time
343 	 *
344 	 * Return: the converted time of the clock.
345 	 */
346 	public GstClockTime adjustUnlocked(GstClockTime internal)
347 	{
348 		return gst_clock_adjust_unlocked(gstClock, internal);
349 	}
350 
351 	/**
352 	 * Converts the given @internal_target clock time to the external time,
353 	 * using the passed calibration parameters. This function performs the
354 	 * same calculation as gst_clock_adjust_unlocked() when called using the
355 	 * current calibration parameters, but doesn't ensure a monotonically
356 	 * increasing result as gst_clock_adjust_unlocked() does.
357 	 *
358 	 * Params:
359 	 *     internalTarget = a clock time
360 	 *     cinternal = a reference internal time
361 	 *     cexternal = a reference external time
362 	 *     cnum = the numerator of the rate of the clock relative to its
363 	 *         internal time
364 	 *     cdenom = the denominator of the rate of the clock
365 	 *
366 	 * Return: the converted time of the clock.
367 	 *
368 	 * Since: 1.6
369 	 */
370 	public GstClockTime adjustWithCalibration(GstClockTime internalTarget, GstClockTime cinternal, GstClockTime cexternal, GstClockTime cnum, GstClockTime cdenom)
371 	{
372 		return gst_clock_adjust_with_calibration(gstClock, internalTarget, cinternal, cexternal, cnum, cdenom);
373 	}
374 
375 	/**
376 	 * Gets the internal rate and reference time of @clock. See
377 	 * gst_clock_set_calibration() for more information.
378 	 *
379 	 * @internal, @external, @rate_num, and @rate_denom can be left %NULL if the
380 	 * caller is not interested in the values.
381 	 *
382 	 * MT safe.
383 	 *
384 	 * Params:
385 	 *     internal = a location to store the internal time
386 	 *     external = a location to store the external time
387 	 *     rateNum = a location to store the rate numerator
388 	 *     rateDenom = a location to store the rate denominator
389 	 */
390 	public void getCalibration(out GstClockTime internal, out GstClockTime external, out GstClockTime rateNum, out GstClockTime rateDenom)
391 	{
392 		gst_clock_get_calibration(gstClock, &internal, &external, &rateNum, &rateDenom);
393 	}
394 
395 	/**
396 	 * Gets the current internal time of the given clock. The time is returned
397 	 * unadjusted for the offset and the rate.
398 	 *
399 	 * Return: the internal time of the clock. Or GST_CLOCK_TIME_NONE when
400 	 *     given invalid input.
401 	 *
402 	 *     MT safe.
403 	 */
404 	public GstClockTime getInternalTime()
405 	{
406 		return gst_clock_get_internal_time(gstClock);
407 	}
408 
409 	/**
410 	 * Get the master clock that @clock is slaved to or %NULL when the clock is
411 	 * not slaved to any master clock.
412 	 *
413 	 * Return: a master #GstClock or %NULL
414 	 *     when this clock is not slaved to a master clock. Unref after
415 	 *     usage.
416 	 *
417 	 *     MT safe.
418 	 */
419 	public Clock getMaster()
420 	{
421 		auto p = gst_clock_get_master(gstClock);
422 		
423 		if(p is null)
424 		{
425 			return null;
426 		}
427 		
428 		return ObjectG.getDObject!(Clock)(cast(GstClock*) p, true);
429 	}
430 
431 	/**
432 	 * Get the accuracy of the clock. The accuracy of the clock is the granularity
433 	 * of the values returned by gst_clock_get_time().
434 	 *
435 	 * Return: the resolution of the clock in units of #GstClockTime.
436 	 *
437 	 *     MT safe.
438 	 */
439 	public GstClockTime getResolution()
440 	{
441 		return gst_clock_get_resolution(gstClock);
442 	}
443 
444 	/**
445 	 * Gets the current time of the given clock. The time is always
446 	 * monotonically increasing and adjusted according to the current
447 	 * offset and rate.
448 	 *
449 	 * Return: the time of the clock. Or GST_CLOCK_TIME_NONE when
450 	 *     given invalid input.
451 	 *
452 	 *     MT safe.
453 	 */
454 	public GstClockTime getTime()
455 	{
456 		return gst_clock_get_time(gstClock);
457 	}
458 
459 	/**
460 	 * Get the amount of time that master and slave clocks are sampled.
461 	 *
462 	 * Return: the interval between samples.
463 	 */
464 	public GstClockTime getTimeout()
465 	{
466 		return gst_clock_get_timeout(gstClock);
467 	}
468 
469 	/**
470 	 * Checks if the clock is currently synced.
471 	 *
472 	 * This returns if GST_CLOCK_FLAG_NEEDS_STARTUP_SYNC is not set on the clock.
473 	 *
474 	 * Return: %TRUE if the clock is currently synced
475 	 *
476 	 * Since: 1.6
477 	 */
478 	public bool isSynced()
479 	{
480 		return gst_clock_is_synced(gstClock) != 0;
481 	}
482 
483 	/**
484 	 * Get an ID from @clock to trigger a periodic notification.
485 	 * The periodic notifications will start at time @start_time and
486 	 * will then be fired with the given @interval. @id should be unreffed
487 	 * after usage.
488 	 *
489 	 * Free-function: gst_clock_id_unref
490 	 *
491 	 * Params:
492 	 *     startTime = the requested start time
493 	 *     interval = the requested interval
494 	 *
495 	 * Return: a #GstClockID that can be used to request the
496 	 *     time notification.
497 	 *
498 	 *     MT safe.
499 	 */
500 	public GstClockID newPeriodicId(GstClockTime startTime, GstClockTime interval)
501 	{
502 		return gst_clock_new_periodic_id(gstClock, startTime, interval);
503 	}
504 
505 	/**
506 	 * Get a #GstClockID from @clock to trigger a single shot
507 	 * notification at the requested time. The single shot id should be
508 	 * unreffed after usage.
509 	 *
510 	 * Free-function: gst_clock_id_unref
511 	 *
512 	 * Params:
513 	 *     time = the requested time
514 	 *
515 	 * Return: a #GstClockID that can be used to request the
516 	 *     time notification.
517 	 *
518 	 *     MT safe.
519 	 */
520 	public GstClockID newSingleShotId(GstClockTime time)
521 	{
522 		return gst_clock_new_single_shot_id(gstClock, time);
523 	}
524 
525 	/**
526 	 * Reinitializes the provided periodic @id to the provided start time and
527 	 * interval. Does not modify the reference count.
528 	 *
529 	 * Params:
530 	 *     id = a #GstClockID
531 	 *     startTime = the requested start time
532 	 *     interval = the requested interval
533 	 *
534 	 * Return: %TRUE if the GstClockID could be reinitialized to the provided
535 	 *     @time, else %FALSE.
536 	 */
537 	public bool periodicIdReinit(GstClockID id, GstClockTime startTime, GstClockTime interval)
538 	{
539 		return gst_clock_periodic_id_reinit(gstClock, id, startTime, interval) != 0;
540 	}
541 
542 	/**
543 	 * Adjusts the rate and time of @clock. A rate of 1/1 is the normal speed of
544 	 * the clock. Values bigger than 1/1 make the clock go faster.
545 	 *
546 	 * @internal and @external are calibration parameters that arrange that
547 	 * gst_clock_get_time() should have been @external at internal time @internal.
548 	 * This internal time should not be in the future; that is, it should be less
549 	 * than the value of gst_clock_get_internal_time() when this function is called.
550 	 *
551 	 * Subsequent calls to gst_clock_get_time() will return clock times computed as
552 	 * follows:
553 	 *
554 	 * <programlisting>
555 	 * time = (internal_time - internal) * rate_num / rate_denom + external
556 	 * </programlisting>
557 	 *
558 	 * This formula is implemented in gst_clock_adjust_unlocked(). Of course, it
559 	 * tries to do the integer arithmetic as precisely as possible.
560 	 *
561 	 * Note that gst_clock_get_time() always returns increasing values so when you
562 	 * move the clock backwards, gst_clock_get_time() will report the previous value
563 	 * until the clock catches up.
564 	 *
565 	 * MT safe.
566 	 *
567 	 * Params:
568 	 *     internal = a reference internal time
569 	 *     external = a reference external time
570 	 *     rateNum = the numerator of the rate of the clock relative to its
571 	 *         internal time
572 	 *     rateDenom = the denominator of the rate of the clock
573 	 */
574 	public void setCalibration(GstClockTime internal, GstClockTime external, GstClockTime rateNum, GstClockTime rateDenom)
575 	{
576 		gst_clock_set_calibration(gstClock, internal, external, rateNum, rateDenom);
577 	}
578 
579 	/**
580 	 * Set @master as the master clock for @clock. @clock will be automatically
581 	 * calibrated so that gst_clock_get_time() reports the same time as the
582 	 * master clock.
583 	 *
584 	 * A clock provider that slaves its clock to a master can get the current
585 	 * calibration values with gst_clock_get_calibration().
586 	 *
587 	 * @master can be %NULL in which case @clock will not be slaved anymore. It will
588 	 * however keep reporting its time adjusted with the last configured rate
589 	 * and time offsets.
590 	 *
591 	 * Params:
592 	 *     master = a master #GstClock
593 	 *
594 	 * Return: %TRUE if the clock is capable of being slaved to a master clock.
595 	 *     Trying to set a master on a clock without the
596 	 *     #GST_CLOCK_FLAG_CAN_SET_MASTER flag will make this function return %FALSE.
597 	 *
598 	 *     MT safe.
599 	 */
600 	public bool setMaster(Clock master)
601 	{
602 		return gst_clock_set_master(gstClock, (master is null) ? null : master.getClockStruct()) != 0;
603 	}
604 
605 	/**
606 	 * Set the accuracy of the clock. Some clocks have the possibility to operate
607 	 * with different accuracy at the expense of more resource usage. There is
608 	 * normally no need to change the default resolution of a clock. The resolution
609 	 * of a clock can only be changed if the clock has the
610 	 * #GST_CLOCK_FLAG_CAN_SET_RESOLUTION flag set.
611 	 *
612 	 * Params:
613 	 *     resolution = The resolution to set
614 	 *
615 	 * Return: the new resolution of the clock.
616 	 */
617 	public GstClockTime setResolution(GstClockTime resolution)
618 	{
619 		return gst_clock_set_resolution(gstClock, resolution);
620 	}
621 
622 	/**
623 	 * Sets @clock to synced and emits the GstClock::synced signal, and wakes up any
624 	 * thread waiting in gst_clock_wait_for_sync().
625 	 *
626 	 * This function must only be called if GST_CLOCK_FLAG_NEEDS_STARTUP_SYNC
627 	 * is set on the clock, and is intended to be called by subclasses only.
628 	 *
629 	 * Params:
630 	 *     synced = if the clock is synced
631 	 *
632 	 * Since: 1.6
633 	 */
634 	public void setSynced(bool synced)
635 	{
636 		gst_clock_set_synced(gstClock, synced);
637 	}
638 
639 	/**
640 	 * Set the amount of time, in nanoseconds, to sample master and slave
641 	 * clocks
642 	 *
643 	 * Params:
644 	 *     timeout = a timeout
645 	 */
646 	public void setTimeout(GstClockTime timeout)
647 	{
648 		gst_clock_set_timeout(gstClock, timeout);
649 	}
650 
651 	/**
652 	 * Reinitializes the provided single shot @id to the provided time. Does not
653 	 * modify the reference count.
654 	 *
655 	 * Params:
656 	 *     id = a #GstClockID
657 	 *     time = The requested time.
658 	 *
659 	 * Return: %TRUE if the GstClockID could be reinitialized to the provided
660 	 *     @time, else %FALSE.
661 	 */
662 	public bool singleShotIdReinit(GstClockID id, GstClockTime time)
663 	{
664 		return gst_clock_single_shot_id_reinit(gstClock, id, time) != 0;
665 	}
666 
667 	/**
668 	 * Converts the given @external clock time to the internal time of @clock,
669 	 * using the rate and reference time set with gst_clock_set_calibration().
670 	 * This function should be called with the clock's OBJECT_LOCK held and
671 	 * is mainly used by clock subclasses.
672 	 *
673 	 * This function is the reverse of gst_clock_adjust_unlocked().
674 	 *
675 	 * Params:
676 	 *     external = an external clock time
677 	 *
678 	 * Return: the internal time of the clock corresponding to @external.
679 	 */
680 	public GstClockTime unadjustUnlocked(GstClockTime external)
681 	{
682 		return gst_clock_unadjust_unlocked(gstClock, external);
683 	}
684 
685 	/**
686 	 * Waits until @clock is synced for reporting the current time. If @timeout
687 	 * is %GST_CLOCK_TIME_NONE it will wait forever, otherwise it will time out
688 	 * after @timeout nanoseconds.
689 	 *
690 	 * For asynchronous waiting, the GstClock::synced signal can be used.
691 	 *
692 	 *
693 	 * This returns immediately with TRUE if GST_CLOCK_FLAG_NEEDS_STARTUP_SYNC
694 	 * is not set on the clock, or if the clock is already synced.
695 	 *
696 	 * Params:
697 	 *     timeout = timeout for waiting or %GST_CLOCK_TIME_NONE
698 	 *
699 	 * Return: %TRUE if waiting was successful, or %FALSE on timeout
700 	 *
701 	 * Since: 1.6
702 	 */
703 	public bool waitForSync(GstClockTime timeout)
704 	{
705 		return gst_clock_wait_for_sync(gstClock, timeout) != 0;
706 	}
707 
708 	int[string] connectedSignals;
709 
710 	void delegate(bool, Clock)[] onSyncedListeners;
711 	/**
712 	 * Signaled on clocks with GST_CLOCK_FLAG_NEEDS_STARTUP_SYNC set once
713 	 * the clock is synchronized, or when it completely lost synchronization.
714 	 * This signal will not be emitted on clocks without the flag.
715 	 *
716 	 * This signal will be emitted from an arbitrary thread, most likely not
717 	 * the application's main thread.
718 	 *
719 	 * Params:
720 	 *     synced = if the clock is synced now
721 	 *
722 	 * Since: 1.6
723 	 */
724 	void addOnSynced(void delegate(bool, Clock) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
725 	{
726 		if ( "synced" !in connectedSignals )
727 		{
728 			Signals.connectData(
729 				this,
730 				"synced",
731 				cast(GCallback)&callBackSynced,
732 				cast(void*)this,
733 				null,
734 				connectFlags);
735 			connectedSignals["synced"] = 1;
736 		}
737 		onSyncedListeners ~= dlg;
738 	}
739 	extern(C) static void callBackSynced(GstClock* clockStruct, bool synced, Clock _clock)
740 	{
741 		foreach ( void delegate(bool, Clock) dlg; _clock.onSyncedListeners )
742 		{
743 			dlg(synced, _clock);
744 		}
745 	}
746 }