1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842
// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT use glib; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::StaticType; use glib::Value; use glib_sys; use gobject_sys; use gst_sys; use std::boxed::Box as Box_; use std::mem; use std::mem::transmute; use ClockTime; use Object; glib_wrapper! { /// GStreamer uses a global clock to synchronize the plugins in a pipeline. /// Different clock implementations are possible by implementing this abstract /// base class or, more conveniently, by subclassing `SystemClock`. /// /// The `Clock` returns a monotonically increasing time with the method /// `ClockExt::get_time`. Its accuracy and base time depend on the specific /// clock implementation but time is always expressed in nanoseconds. Since the /// baseline of the clock is undefined, the clock time returned is not /// meaningful in itself, what matters are the deltas between two clock times. /// The time returned by a clock is called the absolute time. /// /// The pipeline uses the clock to calculate the running time. Usually all /// renderers synchronize to the global clock using the buffer timestamps, the /// newsegment events and the element's base time, see `Pipeline`. /// /// A clock implementation can support periodic and single shot clock /// notifications both synchronous and asynchronous. /// /// One first needs to create a `ClockID` for the periodic or single shot /// notification using `ClockExt::new_single_shot_id` or /// `ClockExt::new_periodic_id`. /// /// To perform a blocking wait for the specific time of the `ClockID` use the /// `Clock::id_wait`. To receive a callback when the specific time is reached /// in the clock use `Clock::id_wait_async`. Both these calls can be /// interrupted with the `Clock::id_unschedule` call. If the blocking wait is /// unscheduled a return value of `ClockReturn::Unscheduled` is returned. /// /// Periodic callbacks scheduled async will be repeatedly called automatically /// until it is unscheduled. To schedule a sync periodic callback, /// `Clock::id_wait` should be called repeatedly. /// /// The async callbacks can happen from any thread, either provided by the core /// or from a streaming thread. The application should be prepared for this. /// /// A `ClockID` that has been unscheduled cannot be used again for any wait /// operation, a new `ClockID` should be created and the old unscheduled one /// should be destroyed with `Clock::id_unref`. /// /// It is possible to perform a blocking wait on the same `ClockID` from /// multiple threads. However, registering the same `ClockID` for multiple /// async notifications is not possible, the callback will only be called for /// the thread registering the entry last. /// /// None of the wait operations unref the `ClockID`, the owner is responsible /// for unreffing the ids itself. This holds for both periodic and single shot /// notifications. The reason being that the owner of the `ClockID` has to /// keep a handle to the `ClockID` to unblock the wait on FLUSHING events or /// state changes and if the entry would be unreffed automatically, the handle /// might become invalid without any notification. /// /// These clock operations do not operate on the running time, so the callbacks /// will also occur when not in PLAYING state as if the clock just keeps on /// running. Some clocks however do not progress when the element that provided /// the clock is not PLAYING. /// /// When a clock has the `ClockFlags::CanSetMaster` flag set, it can be /// slaved to another `Clock` with the `ClockExt::set_master`. The clock will /// then automatically be synchronized to this master clock by repeatedly /// sampling the master clock and the slave clock and recalibrating the slave /// clock with `ClockExt::set_calibration`. This feature is mostly useful for /// plugins that have an internal clock but must operate with another clock /// selected by the `Pipeline`. They can track the offset and rate difference /// of their internal clock relative to the master clock by using the /// `ClockExt::get_calibration` function. /// /// The master/slave synchronisation can be tuned with the `Clock:timeout`, /// `Clock:window-size` and `Clock:window-threshold` properties. /// The `Clock:timeout` property defines the interval to sample the master /// clock and run the calibration functions. `Clock:window-size` defines the /// number of samples to use when calibrating and `Clock:window-threshold` /// defines the minimum number of samples before the calibration is performed. /// /// # Implements /// /// [`ClockExt`](trait.ClockExt.html), [`GstObjectExt`](trait.GstObjectExt.html), [`glib::object::ObjectExt`](../glib/object/trait.ObjectExt.html), [`ClockExtManual`](prelude/trait.ClockExtManual.html) pub struct Clock(Object<gst_sys::GstClock, gst_sys::GstClockClass, ClockClass>) @extends Object; match fn { get_type => || gst_sys::gst_clock_get_type(), } } impl Clock { //pub fn id_compare_func(id1: /*Unimplemented*/Option<Fundamental: Pointer>, id2: /*Unimplemented*/Option<Fundamental: Pointer>) -> i32 { // unsafe { TODO: call gst_sys:gst_clock_id_compare_func() } //} //#[cfg(any(feature = "v1_16", feature = "dox"))] //pub fn id_get_clock(id: /*Unimplemented*/ClockID) -> Option<Clock> { // unsafe { TODO: call gst_sys:gst_clock_id_get_clock() } //} //pub fn id_get_time(id: /*Unimplemented*/ClockID) -> ClockTime { // unsafe { TODO: call gst_sys:gst_clock_id_get_time() } //} //pub fn id_ref(id: /*Unimplemented*/ClockID) -> /*Unimplemented*/Option<ClockID> { // unsafe { TODO: call gst_sys:gst_clock_id_ref() } //} //pub fn id_unref(id: /*Unimplemented*/ClockID) { // unsafe { TODO: call gst_sys:gst_clock_id_unref() } //} //pub fn id_unschedule(id: /*Unimplemented*/ClockID) { // unsafe { TODO: call gst_sys:gst_clock_id_unschedule() } //} //#[cfg(any(feature = "v1_16", feature = "dox"))] //pub fn id_uses_clock<P: IsA<Clock>>(id: /*Unimplemented*/ClockID, clock: &P) -> bool { // unsafe { TODO: call gst_sys:gst_clock_id_uses_clock() } //} //pub fn id_wait(id: /*Unimplemented*/ClockID) -> (ClockReturn, ClockTimeDiff) { // unsafe { TODO: call gst_sys:gst_clock_id_wait() } //} //pub fn id_wait_async(id: /*Unimplemented*/ClockID, func: /*Unimplemented*/Fn(&Clock, ClockTime, /*Unimplemented*/ClockID) -> bool, user_data: /*Unimplemented*/Option<Fundamental: Pointer>) -> ClockReturn { // unsafe { TODO: call gst_sys:gst_clock_id_wait_async() } //} } unsafe impl Send for Clock {} unsafe impl Sync for Clock {} pub const NONE_CLOCK: Option<&Clock> = None; /// Trait containing all `Clock` methods. /// /// # Implementors /// /// [`Clock`](struct.Clock.html), [`SystemClock`](struct.SystemClock.html) pub trait ClockExt: 'static { /// The time `master` of the master clock and the time `slave` of the slave /// clock are added to the list of observations. If enough observations /// are available, a linear regression algorithm is run on the /// observations and `self` is recalibrated. /// /// If this functions returns `true`, `r_squared` will contain the /// correlation coefficient of the interpolation. A value of 1.0 /// means a perfect regression was performed. This value can /// be used to control the sampling frequency of the master and slave /// clocks. /// ## `slave` /// a time on the slave /// ## `master` /// a time on the master /// ## `r_squared` /// a pointer to hold the result /// /// # Returns /// /// `true` if enough observations were added to run the /// regression algorithm. /// /// MT safe. fn add_observation(&self, slave: ClockTime, master: ClockTime) -> Option<f64>; /// Add a clock observation to the internal slaving algorithm the same as /// `ClockExt::add_observation`, and return the result of the master clock /// estimation, without updating the internal calibration. /// /// The caller can then take the results and call `ClockExt::set_calibration` /// with the values, or some modified version of them. /// ## `slave` /// a time on the slave /// ## `master` /// a time on the master /// ## `r_squared` /// a pointer to hold the result /// ## `internal` /// a location to store the internal time /// ## `external` /// a location to store the external time /// ## `rate_num` /// a location to store the rate numerator /// ## `rate_denom` /// a location to store the rate denominator fn add_observation_unapplied( &self, slave: ClockTime, master: ClockTime, ) -> Option<(f64, ClockTime, ClockTime, ClockTime, ClockTime)>; /// Converts the given `internal` clock time to the external time, adjusting for the /// rate and reference time set with `ClockExt::set_calibration` and making sure /// that the returned time is increasing. This function should be called with the /// clock's OBJECT_LOCK held and is mainly used by clock subclasses. /// /// This function is the reverse of `ClockExt::unadjust_unlocked`. /// ## `internal` /// a clock time /// /// # Returns /// /// the converted time of the clock. fn adjust_unlocked(&self, internal: ClockTime) -> ClockTime; /// Gets the internal rate and reference time of `self`. See /// `ClockExt::set_calibration` for more information. /// /// `internal`, `external`, `rate_num`, and `rate_denom` can be left `None` if the /// caller is not interested in the values. /// /// MT safe. /// ## `internal` /// a location to store the internal time /// ## `external` /// a location to store the external time /// ## `rate_num` /// a location to store the rate numerator /// ## `rate_denom` /// a location to store the rate denominator fn get_calibration(&self) -> (ClockTime, ClockTime, ClockTime, ClockTime); /// Gets the current internal time of the given clock. The time is returned /// unadjusted for the offset and the rate. /// /// # Returns /// /// the internal time of the clock. Or GST_CLOCK_TIME_NONE when /// given invalid input. /// /// MT safe. fn get_internal_time(&self) -> ClockTime; /// Get the master clock that `self` is slaved to or `None` when the clock is /// not slaved to any master clock. /// /// # Returns /// /// a master `Clock` or `None` /// when this clock is not slaved to a master clock. Unref after /// usage. /// /// MT safe. fn get_master(&self) -> Option<Clock>; /// Get the accuracy of the clock. The accuracy of the clock is the granularity /// of the values returned by `ClockExt::get_time`. /// /// # Returns /// /// the resolution of the clock in units of `ClockTime`. /// /// MT safe. fn get_resolution(&self) -> ClockTime; /// Gets the current time of the given clock. The time is always /// monotonically increasing and adjusted according to the current /// offset and rate. /// /// # Returns /// /// the time of the clock. Or GST_CLOCK_TIME_NONE when /// given invalid input. /// /// MT safe. fn get_time(&self) -> ClockTime; /// Get the amount of time that master and slave clocks are sampled. /// /// # Returns /// /// the interval between samples. fn get_timeout(&self) -> ClockTime; /// Checks if the clock is currently synced. /// /// This returns if GST_CLOCK_FLAG_NEEDS_STARTUP_SYNC is not set on the clock. /// /// # Returns /// /// `true` if the clock is currently synced fn is_synced(&self) -> bool; //fn new_periodic_id(&self, start_time: ClockTime, interval: ClockTime) -> /*Unimplemented*/Option<ClockID>; //fn new_single_shot_id(&self, time: ClockTime) -> /*Unimplemented*/Option<ClockID>; //fn periodic_id_reinit(&self, id: /*Unimplemented*/ClockID, start_time: ClockTime, interval: ClockTime) -> bool; /// Adjusts the rate and time of `self`. A rate of 1/1 is the normal speed of /// the clock. Values bigger than 1/1 make the clock go faster. /// /// `internal` and `external` are calibration parameters that arrange that /// `ClockExt::get_time` should have been `external` at internal time `internal`. /// This internal time should not be in the future; that is, it should be less /// than the value of `ClockExt::get_internal_time` when this function is called. /// /// Subsequent calls to `ClockExt::get_time` will return clock times computed as /// follows: /// /// /// ```text /// time = (internal_time - internal) * rate_num / rate_denom + external /// ``` /// /// This formula is implemented in `ClockExt::adjust_unlocked`. Of course, it /// tries to do the integer arithmetic as precisely as possible. /// /// Note that `ClockExt::get_time` always returns increasing values so when you /// move the clock backwards, `ClockExt::get_time` will report the previous value /// until the clock catches up. /// /// MT safe. /// ## `internal` /// a reference internal time /// ## `external` /// a reference external time /// ## `rate_num` /// the numerator of the rate of the clock relative to its /// internal time /// ## `rate_denom` /// the denominator of the rate of the clock fn set_calibration( &self, internal: ClockTime, external: ClockTime, rate_num: ClockTime, rate_denom: ClockTime, ); /// Set `master` as the master clock for `self`. `self` will be automatically /// calibrated so that `ClockExt::get_time` reports the same time as the /// master clock. /// /// A clock provider that slaves its clock to a master can get the current /// calibration values with `ClockExt::get_calibration`. /// /// `master` can be `None` in which case `self` will not be slaved anymore. It will /// however keep reporting its time adjusted with the last configured rate /// and time offsets. /// ## `master` /// a master `Clock` /// /// # Returns /// /// `true` if the clock is capable of being slaved to a master clock. /// Trying to set a master on a clock without the /// `ClockFlags::CanSetMaster` flag will make this function return `false`. /// /// MT safe. fn set_master<P: IsA<Clock>>(&self, master: Option<&P>) -> Result<(), glib::error::BoolError>; /// Set the accuracy of the clock. Some clocks have the possibility to operate /// with different accuracy at the expense of more resource usage. There is /// normally no need to change the default resolution of a clock. The resolution /// of a clock can only be changed if the clock has the /// `ClockFlags::CanSetResolution` flag set. /// ## `resolution` /// The resolution to set /// /// # Returns /// /// the new resolution of the clock. fn set_resolution(&self, resolution: ClockTime) -> ClockTime; /// Sets `self` to synced and emits the GstClock::synced signal, and wakes up any /// thread waiting in `ClockExt::wait_for_sync`. /// /// This function must only be called if GST_CLOCK_FLAG_NEEDS_STARTUP_SYNC /// is set on the clock, and is intended to be called by subclasses only. /// ## `synced` /// if the clock is synced fn set_synced(&self, synced: bool); /// Set the amount of time, in nanoseconds, to sample master and slave /// clocks /// ## `timeout` /// a timeout fn set_timeout(&self, timeout: ClockTime); //fn single_shot_id_reinit(&self, id: /*Unimplemented*/ClockID, time: ClockTime) -> bool; /// Converts the given `external` clock time to the internal time of `self`, /// using the rate and reference time set with `ClockExt::set_calibration`. /// This function should be called with the clock's OBJECT_LOCK held and /// is mainly used by clock subclasses. /// /// This function is the reverse of `ClockExt::adjust_unlocked`. /// ## `external` /// an external clock time /// /// # Returns /// /// the internal time of the clock corresponding to `external`. fn unadjust_unlocked(&self, external: ClockTime) -> ClockTime; /// Waits until `self` is synced for reporting the current time. If `timeout` /// is `GST_CLOCK_TIME_NONE` it will wait forever, otherwise it will time out /// after `timeout` nanoseconds. /// /// For asynchronous waiting, the GstClock::synced signal can be used. /// /// This returns immediately with TRUE if GST_CLOCK_FLAG_NEEDS_STARTUP_SYNC /// is not set on the clock, or if the clock is already synced. /// ## `timeout` /// timeout for waiting or `GST_CLOCK_TIME_NONE` /// /// # Returns /// /// `true` if waiting was successful, or `false` on timeout fn wait_for_sync(&self, timeout: ClockTime) -> Result<(), glib::error::BoolError>; fn get_property_window_size(&self) -> i32; fn set_property_window_size(&self, window_size: i32); fn get_property_window_threshold(&self) -> i32; fn set_property_window_threshold(&self, window_threshold: i32); /// Signaled on clocks with GST_CLOCK_FLAG_NEEDS_STARTUP_SYNC set once /// the clock is synchronized, or when it completely lost synchronization. /// This signal will not be emitted on clocks without the flag. /// /// This signal will be emitted from an arbitrary thread, most likely not /// the application's main thread. /// ## `synced` /// if the clock is synced now fn connect_synced<F: Fn(&Self, bool) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId; fn connect_property_timeout_notify<F: Fn(&Self) + Send + Sync + 'static>( &self, f: F, ) -> SignalHandlerId; fn connect_property_window_size_notify<F: Fn(&Self) + Send + Sync + 'static>( &self, f: F, ) -> SignalHandlerId; fn connect_property_window_threshold_notify<F: Fn(&Self) + Send + Sync + 'static>( &self, f: F, ) -> SignalHandlerId; } impl<O: IsA<Clock>> ClockExt for O { fn add_observation(&self, slave: ClockTime, master: ClockTime) -> Option<f64> { unsafe { let mut r_squared = mem::MaybeUninit::uninit(); let ret = from_glib(gst_sys::gst_clock_add_observation( self.as_ref().to_glib_none().0, slave.to_glib(), master.to_glib(), r_squared.as_mut_ptr(), )); let r_squared = r_squared.assume_init(); if ret { Some(r_squared) } else { None } } } fn add_observation_unapplied( &self, slave: ClockTime, master: ClockTime, ) -> Option<(f64, ClockTime, ClockTime, ClockTime, ClockTime)> { unsafe { let mut r_squared = mem::MaybeUninit::uninit(); let mut internal = mem::MaybeUninit::uninit(); let mut external = mem::MaybeUninit::uninit(); let mut rate_num = mem::MaybeUninit::uninit(); let mut rate_denom = mem::MaybeUninit::uninit(); let ret = from_glib(gst_sys::gst_clock_add_observation_unapplied( self.as_ref().to_glib_none().0, slave.to_glib(), master.to_glib(), r_squared.as_mut_ptr(), internal.as_mut_ptr(), external.as_mut_ptr(), rate_num.as_mut_ptr(), rate_denom.as_mut_ptr(), )); let r_squared = r_squared.assume_init(); let internal = internal.assume_init(); let external = external.assume_init(); let rate_num = rate_num.assume_init(); let rate_denom = rate_denom.assume_init(); if ret { Some(( r_squared, from_glib(internal), from_glib(external), from_glib(rate_num), from_glib(rate_denom), )) } else { None } } } fn adjust_unlocked(&self, internal: ClockTime) -> ClockTime { unsafe { from_glib(gst_sys::gst_clock_adjust_unlocked( self.as_ref().to_glib_none().0, internal.to_glib(), )) } } fn get_calibration(&self) -> (ClockTime, ClockTime, ClockTime, ClockTime) { unsafe { let mut internal = mem::MaybeUninit::uninit(); let mut external = mem::MaybeUninit::uninit(); let mut rate_num = mem::MaybeUninit::uninit(); let mut rate_denom = mem::MaybeUninit::uninit(); gst_sys::gst_clock_get_calibration( self.as_ref().to_glib_none().0, internal.as_mut_ptr(), external.as_mut_ptr(), rate_num.as_mut_ptr(), rate_denom.as_mut_ptr(), ); let internal = internal.assume_init(); let external = external.assume_init(); let rate_num = rate_num.assume_init(); let rate_denom = rate_denom.assume_init(); ( from_glib(internal), from_glib(external), from_glib(rate_num), from_glib(rate_denom), ) } } fn get_internal_time(&self) -> ClockTime { unsafe { from_glib(gst_sys::gst_clock_get_internal_time( self.as_ref().to_glib_none().0, )) } } fn get_master(&self) -> Option<Clock> { unsafe { from_glib_full(gst_sys::gst_clock_get_master( self.as_ref().to_glib_none().0, )) } } fn get_resolution(&self) -> ClockTime { unsafe { from_glib(gst_sys::gst_clock_get_resolution( self.as_ref().to_glib_none().0, )) } } fn get_time(&self) -> ClockTime { unsafe { from_glib(gst_sys::gst_clock_get_time(self.as_ref().to_glib_none().0)) } } fn get_timeout(&self) -> ClockTime { unsafe { from_glib(gst_sys::gst_clock_get_timeout( self.as_ref().to_glib_none().0, )) } } fn is_synced(&self) -> bool { unsafe { from_glib(gst_sys::gst_clock_is_synced(self.as_ref().to_glib_none().0)) } } //fn new_periodic_id(&self, start_time: ClockTime, interval: ClockTime) -> /*Unimplemented*/Option<ClockID> { // unsafe { TODO: call gst_sys:gst_clock_new_periodic_id() } //} //fn new_single_shot_id(&self, time: ClockTime) -> /*Unimplemented*/Option<ClockID> { // unsafe { TODO: call gst_sys:gst_clock_new_single_shot_id() } //} //fn periodic_id_reinit(&self, id: /*Unimplemented*/ClockID, start_time: ClockTime, interval: ClockTime) -> bool { // unsafe { TODO: call gst_sys:gst_clock_periodic_id_reinit() } //} fn set_calibration( &self, internal: ClockTime, external: ClockTime, rate_num: ClockTime, rate_denom: ClockTime, ) { unsafe { gst_sys::gst_clock_set_calibration( self.as_ref().to_glib_none().0, internal.to_glib(), external.to_glib(), rate_num.to_glib(), rate_denom.to_glib(), ); } } fn set_master<P: IsA<Clock>>(&self, master: Option<&P>) -> Result<(), glib::error::BoolError> { unsafe { glib_result_from_gboolean!( gst_sys::gst_clock_set_master( self.as_ref().to_glib_none().0, master.map(|p| p.as_ref()).to_glib_none().0 ), "Failed to set master clock" ) } } fn set_resolution(&self, resolution: ClockTime) -> ClockTime { unsafe { from_glib(gst_sys::gst_clock_set_resolution( self.as_ref().to_glib_none().0, resolution.to_glib(), )) } } fn set_synced(&self, synced: bool) { unsafe { gst_sys::gst_clock_set_synced(self.as_ref().to_glib_none().0, synced.to_glib()); } } fn set_timeout(&self, timeout: ClockTime) { unsafe { gst_sys::gst_clock_set_timeout(self.as_ref().to_glib_none().0, timeout.to_glib()); } } //fn single_shot_id_reinit(&self, id: /*Unimplemented*/ClockID, time: ClockTime) -> bool { // unsafe { TODO: call gst_sys:gst_clock_single_shot_id_reinit() } //} fn unadjust_unlocked(&self, external: ClockTime) -> ClockTime { unsafe { from_glib(gst_sys::gst_clock_unadjust_unlocked( self.as_ref().to_glib_none().0, external.to_glib(), )) } } fn wait_for_sync(&self, timeout: ClockTime) -> Result<(), glib::error::BoolError> { unsafe { glib_result_from_gboolean!( gst_sys::gst_clock_wait_for_sync(self.as_ref().to_glib_none().0, timeout.to_glib()), "Timed out waiting for sync" ) } } fn get_property_window_size(&self) -> i32 { unsafe { let mut value = Value::from_type(<i32 as StaticType>::static_type()); gobject_sys::g_object_get_property( self.to_glib_none().0 as *mut gobject_sys::GObject, b"window-size\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value .get() .expect("Return Value for property `window-size` getter") .unwrap() } } fn set_property_window_size(&self, window_size: i32) { unsafe { gobject_sys::g_object_set_property( self.to_glib_none().0 as *mut gobject_sys::GObject, b"window-size\0".as_ptr() as *const _, Value::from(&window_size).to_glib_none().0, ); } } fn get_property_window_threshold(&self) -> i32 { unsafe { let mut value = Value::from_type(<i32 as StaticType>::static_type()); gobject_sys::g_object_get_property( self.to_glib_none().0 as *mut gobject_sys::GObject, b"window-threshold\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value .get() .expect("Return Value for property `window-threshold` getter") .unwrap() } } fn set_property_window_threshold(&self, window_threshold: i32) { unsafe { gobject_sys::g_object_set_property( self.to_glib_none().0 as *mut gobject_sys::GObject, b"window-threshold\0".as_ptr() as *const _, Value::from(&window_threshold).to_glib_none().0, ); } } fn connect_synced<F: Fn(&Self, bool) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn synced_trampoline<P, F: Fn(&P, bool) + Send + Sync + 'static>( this: *mut gst_sys::GstClock, synced: glib_sys::gboolean, f: glib_sys::gpointer, ) where P: IsA<Clock>, { let f: &F = &*(f as *const F); f( &Clock::from_glib_borrow(this).unsafe_cast_ref(), from_glib(synced), ) } unsafe { let f: Box_<F> = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"synced\0".as_ptr() as *const _, Some(transmute::<_, unsafe extern "C" fn()>( synced_trampoline::<Self, F> as *const (), )), Box_::into_raw(f), ) } } fn connect_property_timeout_notify<F: Fn(&Self) + Send + Sync + 'static>( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_timeout_trampoline<P, F: Fn(&P) + Send + Sync + 'static>( this: *mut gst_sys::GstClock, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA<Clock>, { let f: &F = &*(f as *const F); f(&Clock::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_<F> = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::timeout\0".as_ptr() as *const _, Some(transmute::<_, unsafe extern "C" fn()>( notify_timeout_trampoline::<Self, F> as *const (), )), Box_::into_raw(f), ) } } fn connect_property_window_size_notify<F: Fn(&Self) + Send + Sync + 'static>( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_window_size_trampoline<P, F: Fn(&P) + Send + Sync + 'static>( this: *mut gst_sys::GstClock, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA<Clock>, { let f: &F = &*(f as *const F); f(&Clock::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_<F> = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::window-size\0".as_ptr() as *const _, Some(transmute::<_, unsafe extern "C" fn()>( notify_window_size_trampoline::<Self, F> as *const (), )), Box_::into_raw(f), ) } } fn connect_property_window_threshold_notify<F: Fn(&Self) + Send + Sync + 'static>( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_window_threshold_trampoline< P, F: Fn(&P) + Send + Sync + 'static, >( this: *mut gst_sys::GstClock, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA<Clock>, { let f: &F = &*(f as *const F); f(&Clock::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_<F> = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::window-threshold\0".as_ptr() as *const _, Some(transmute::<_, unsafe extern "C" fn()>( notify_window_threshold_trampoline::<Self, F> as *const (), )), Box_::into_raw(f), ) } } }