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