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 * Note: The @clock parameter is unused and can be NULL 359 * 360 * Params: 361 * internalTarget = a clock time 362 * cinternal = a reference internal time 363 * cexternal = a reference external time 364 * cnum = the numerator of the rate of the clock relative to its 365 * internal time 366 * cdenom = the denominator of the rate of the clock 367 * 368 * Return: the converted time of the clock. 369 * 370 * Since: 1.6 371 */ 372 public GstClockTime adjustWithCalibration(GstClockTime internalTarget, GstClockTime cinternal, GstClockTime cexternal, GstClockTime cnum, GstClockTime cdenom) 373 { 374 return gst_clock_adjust_with_calibration(gstClock, internalTarget, cinternal, cexternal, cnum, cdenom); 375 } 376 377 /** 378 * Gets the internal rate and reference time of @clock. See 379 * gst_clock_set_calibration() for more information. 380 * 381 * @internal, @external, @rate_num, and @rate_denom can be left %NULL if the 382 * caller is not interested in the values. 383 * 384 * MT safe. 385 * 386 * Params: 387 * internal = a location to store the internal time 388 * external = a location to store the external time 389 * rateNum = a location to store the rate numerator 390 * rateDenom = a location to store the rate denominator 391 */ 392 public void getCalibration(out GstClockTime internal, out GstClockTime external, out GstClockTime rateNum, out GstClockTime rateDenom) 393 { 394 gst_clock_get_calibration(gstClock, &internal, &external, &rateNum, &rateDenom); 395 } 396 397 /** 398 * Gets the current internal time of the given clock. The time is returned 399 * unadjusted for the offset and the rate. 400 * 401 * Return: the internal time of the clock. Or GST_CLOCK_TIME_NONE when 402 * given invalid input. 403 * 404 * MT safe. 405 */ 406 public GstClockTime getInternalTime() 407 { 408 return gst_clock_get_internal_time(gstClock); 409 } 410 411 /** 412 * Get the master clock that @clock is slaved to or %NULL when the clock is 413 * not slaved to any master clock. 414 * 415 * Return: a master #GstClock or %NULL 416 * when this clock is not slaved to a master clock. Unref after 417 * usage. 418 * 419 * MT safe. 420 */ 421 public Clock getMaster() 422 { 423 auto p = gst_clock_get_master(gstClock); 424 425 if(p is null) 426 { 427 return null; 428 } 429 430 return ObjectG.getDObject!(Clock)(cast(GstClock*) p, true); 431 } 432 433 /** 434 * Get the accuracy of the clock. The accuracy of the clock is the granularity 435 * of the values returned by gst_clock_get_time(). 436 * 437 * Return: the resolution of the clock in units of #GstClockTime. 438 * 439 * MT safe. 440 */ 441 public GstClockTime getResolution() 442 { 443 return gst_clock_get_resolution(gstClock); 444 } 445 446 /** 447 * Gets the current time of the given clock. The time is always 448 * monotonically increasing and adjusted according to the current 449 * offset and rate. 450 * 451 * Return: the time of the clock. Or GST_CLOCK_TIME_NONE when 452 * given invalid input. 453 * 454 * MT safe. 455 */ 456 public GstClockTime getTime() 457 { 458 return gst_clock_get_time(gstClock); 459 } 460 461 /** 462 * Get the amount of time that master and slave clocks are sampled. 463 * 464 * Return: the interval between samples. 465 */ 466 public GstClockTime getTimeout() 467 { 468 return gst_clock_get_timeout(gstClock); 469 } 470 471 /** 472 * Checks if the clock is currently synced. 473 * 474 * This returns if GST_CLOCK_FLAG_NEEDS_STARTUP_SYNC is not set on the clock. 475 * 476 * Return: %TRUE if the clock is currently synced 477 * 478 * Since: 1.6 479 */ 480 public bool isSynced() 481 { 482 return gst_clock_is_synced(gstClock) != 0; 483 } 484 485 /** 486 * Get an ID from @clock to trigger a periodic notification. 487 * The periodic notifications will start at time @start_time and 488 * will then be fired with the given @interval. @id should be unreffed 489 * after usage. 490 * 491 * Free-function: gst_clock_id_unref 492 * 493 * Params: 494 * startTime = the requested start time 495 * interval = the requested interval 496 * 497 * Return: a #GstClockID that can be used to request the 498 * time notification. 499 * 500 * MT safe. 501 */ 502 public GstClockID newPeriodicId(GstClockTime startTime, GstClockTime interval) 503 { 504 return gst_clock_new_periodic_id(gstClock, startTime, interval); 505 } 506 507 /** 508 * Get a #GstClockID from @clock to trigger a single shot 509 * notification at the requested time. The single shot id should be 510 * unreffed after usage. 511 * 512 * Free-function: gst_clock_id_unref 513 * 514 * Params: 515 * time = the requested time 516 * 517 * Return: a #GstClockID that can be used to request the 518 * time notification. 519 * 520 * MT safe. 521 */ 522 public GstClockID newSingleShotId(GstClockTime time) 523 { 524 return gst_clock_new_single_shot_id(gstClock, time); 525 } 526 527 /** 528 * Reinitializes the provided periodic @id to the provided start time and 529 * interval. Does not modify the reference count. 530 * 531 * Params: 532 * id = a #GstClockID 533 * startTime = the requested start time 534 * interval = the requested interval 535 * 536 * Return: %TRUE if the GstClockID could be reinitialized to the provided 537 * @time, else %FALSE. 538 */ 539 public bool periodicIdReinit(GstClockID id, GstClockTime startTime, GstClockTime interval) 540 { 541 return gst_clock_periodic_id_reinit(gstClock, id, startTime, interval) != 0; 542 } 543 544 /** 545 * Adjusts the rate and time of @clock. A rate of 1/1 is the normal speed of 546 * the clock. Values bigger than 1/1 make the clock go faster. 547 * 548 * @internal and @external are calibration parameters that arrange that 549 * gst_clock_get_time() should have been @external at internal time @internal. 550 * This internal time should not be in the future; that is, it should be less 551 * than the value of gst_clock_get_internal_time() when this function is called. 552 * 553 * Subsequent calls to gst_clock_get_time() will return clock times computed as 554 * follows: 555 * 556 * <programlisting> 557 * time = (internal_time - internal) * rate_num / rate_denom + external 558 * </programlisting> 559 * 560 * This formula is implemented in gst_clock_adjust_unlocked(). Of course, it 561 * tries to do the integer arithmetic as precisely as possible. 562 * 563 * Note that gst_clock_get_time() always returns increasing values so when you 564 * move the clock backwards, gst_clock_get_time() will report the previous value 565 * until the clock catches up. 566 * 567 * MT safe. 568 * 569 * Params: 570 * internal = a reference internal time 571 * external = a reference external time 572 * rateNum = the numerator of the rate of the clock relative to its 573 * internal time 574 * rateDenom = the denominator of the rate of the clock 575 */ 576 public void setCalibration(GstClockTime internal, GstClockTime external, GstClockTime rateNum, GstClockTime rateDenom) 577 { 578 gst_clock_set_calibration(gstClock, internal, external, rateNum, rateDenom); 579 } 580 581 /** 582 * Set @master as the master clock for @clock. @clock will be automatically 583 * calibrated so that gst_clock_get_time() reports the same time as the 584 * master clock. 585 * 586 * A clock provider that slaves its clock to a master can get the current 587 * calibration values with gst_clock_get_calibration(). 588 * 589 * @master can be %NULL in which case @clock will not be slaved anymore. It will 590 * however keep reporting its time adjusted with the last configured rate 591 * and time offsets. 592 * 593 * Params: 594 * master = a master #GstClock 595 * 596 * Return: %TRUE if the clock is capable of being slaved to a master clock. 597 * Trying to set a master on a clock without the 598 * #GST_CLOCK_FLAG_CAN_SET_MASTER flag will make this function return %FALSE. 599 * 600 * MT safe. 601 */ 602 public bool setMaster(Clock master) 603 { 604 return gst_clock_set_master(gstClock, (master is null) ? null : master.getClockStruct()) != 0; 605 } 606 607 /** 608 * Set the accuracy of the clock. Some clocks have the possibility to operate 609 * with different accuracy at the expense of more resource usage. There is 610 * normally no need to change the default resolution of a clock. The resolution 611 * of a clock can only be changed if the clock has the 612 * #GST_CLOCK_FLAG_CAN_SET_RESOLUTION flag set. 613 * 614 * Params: 615 * resolution = The resolution to set 616 * 617 * Return: the new resolution of the clock. 618 */ 619 public GstClockTime setResolution(GstClockTime resolution) 620 { 621 return gst_clock_set_resolution(gstClock, resolution); 622 } 623 624 /** 625 * Sets @clock to synced and emits the GstClock::synced signal, and wakes up any 626 * thread waiting in gst_clock_wait_for_sync(). 627 * 628 * This function must only be called if GST_CLOCK_FLAG_NEEDS_STARTUP_SYNC 629 * is set on the clock, and is intended to be called by subclasses only. 630 * 631 * Params: 632 * synced = if the clock is synced 633 * 634 * Since: 1.6 635 */ 636 public void setSynced(bool synced) 637 { 638 gst_clock_set_synced(gstClock, synced); 639 } 640 641 /** 642 * Set the amount of time, in nanoseconds, to sample master and slave 643 * clocks 644 * 645 * Params: 646 * timeout = a timeout 647 */ 648 public void setTimeout(GstClockTime timeout) 649 { 650 gst_clock_set_timeout(gstClock, timeout); 651 } 652 653 /** 654 * Reinitializes the provided single shot @id to the provided time. Does not 655 * modify the reference count. 656 * 657 * Params: 658 * id = a #GstClockID 659 * time = The requested time. 660 * 661 * Return: %TRUE if the GstClockID could be reinitialized to the provided 662 * @time, else %FALSE. 663 */ 664 public bool singleShotIdReinit(GstClockID id, GstClockTime time) 665 { 666 return gst_clock_single_shot_id_reinit(gstClock, id, time) != 0; 667 } 668 669 /** 670 * Converts the given @external clock time to the internal time of @clock, 671 * using the rate and reference time set with gst_clock_set_calibration(). 672 * This function should be called with the clock's OBJECT_LOCK held and 673 * is mainly used by clock subclasses. 674 * 675 * This function is the reverse of gst_clock_adjust_unlocked(). 676 * 677 * Params: 678 * external = an external clock time 679 * 680 * Return: the internal time of the clock corresponding to @external. 681 */ 682 public GstClockTime unadjustUnlocked(GstClockTime external) 683 { 684 return gst_clock_unadjust_unlocked(gstClock, external); 685 } 686 687 /** 688 * Converts the given @external_target clock time to the internal time, 689 * using the passed calibration parameters. This function performs the 690 * same calculation as gst_clock_unadjust_unlocked() when called using the 691 * current calibration parameters. 692 * 693 * Note: The @clock parameter is unused and can be NULL 694 * 695 * Params: 696 * externalTarget = a clock time 697 * cinternal = a reference internal time 698 * cexternal = a reference external time 699 * cnum = the numerator of the rate of the clock relative to its 700 * internal time 701 * cdenom = the denominator of the rate of the clock 702 * 703 * Return: the converted time of the clock. 704 * 705 * Since: 1.8 706 */ 707 public GstClockTime unadjustWithCalibration(GstClockTime externalTarget, GstClockTime cinternal, GstClockTime cexternal, GstClockTime cnum, GstClockTime cdenom) 708 { 709 return gst_clock_unadjust_with_calibration(gstClock, externalTarget, cinternal, cexternal, cnum, cdenom); 710 } 711 712 /** 713 * Waits until @clock is synced for reporting the current time. If @timeout 714 * is %GST_CLOCK_TIME_NONE it will wait forever, otherwise it will time out 715 * after @timeout nanoseconds. 716 * 717 * For asynchronous waiting, the GstClock::synced signal can be used. 718 * 719 * 720 * This returns immediately with TRUE if GST_CLOCK_FLAG_NEEDS_STARTUP_SYNC 721 * is not set on the clock, or if the clock is already synced. 722 * 723 * Params: 724 * timeout = timeout for waiting or %GST_CLOCK_TIME_NONE 725 * 726 * Return: %TRUE if waiting was successful, or %FALSE on timeout 727 * 728 * Since: 1.6 729 */ 730 public bool waitForSync(GstClockTime timeout) 731 { 732 return gst_clock_wait_for_sync(gstClock, timeout) != 0; 733 } 734 735 int[string] connectedSignals; 736 737 void delegate(bool, Clock)[] onSyncedListeners; 738 /** 739 * Signaled on clocks with GST_CLOCK_FLAG_NEEDS_STARTUP_SYNC set once 740 * the clock is synchronized, or when it completely lost synchronization. 741 * This signal will not be emitted on clocks without the flag. 742 * 743 * This signal will be emitted from an arbitrary thread, most likely not 744 * the application's main thread. 745 * 746 * Params: 747 * synced = if the clock is synced now 748 * 749 * Since: 1.6 750 */ 751 void addOnSynced(void delegate(bool, Clock) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 752 { 753 if ( "synced" !in connectedSignals ) 754 { 755 Signals.connectData( 756 this, 757 "synced", 758 cast(GCallback)&callBackSynced, 759 cast(void*)this, 760 null, 761 connectFlags); 762 connectedSignals["synced"] = 1; 763 } 764 onSyncedListeners ~= dlg; 765 } 766 extern(C) static void callBackSynced(GstClock* clockStruct, bool synced, Clock _clock) 767 { 768 foreach ( void delegate(bool, Clock) dlg; _clock.onSyncedListeners ) 769 { 770 dlg(synced, _clock); 771 } 772 } 773 }