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