Subclassing GstSystemClock in Rust

Rodrigo Santos rsantos at sequence.film
Tue Oct 25 15:40:53 UTC 2022


Hey Sebastian,



Thanks for your reply, indeed that change made my code to compile without any issues. 



However, when I try to use my custom implementation it is not working as I'd expect. Here's my current code: https://pastebin.com/TnxvZUPT. I'm using it as such:   



let pipeline = Pipeline::new(Some("pipeline"));

pipeline.set_clock(Some(&clock)).expect("could not set pipeline clock");



You can assume clock is indeed an instance of my CustomClock. Because of the following lines



impl ClockImpl for CustomClock { 

    fn internal_time(&self) -> gst::ClockTime {

        println!("internal_time");

        self.parent_internal_time()

    }

}



I'd expect to see on the console the string "internal_time" but that doesn't happen (I also set a breakpoint on that function and it's never hit).



Any ideas what I'm missing to get my custom "internal_time" function to be called?





Rodrigo Santos








---- On Fri, 21 Oct 2022 15:47:49 -0300 Sebastian Dröge via gstreamer-devel <gstreamer-devel at lists.freedesktop.org> wrote ---



On Fri, 2022-10-21 at 12:30 -0300, Rodrigo Santos via gstreamer-devel wrote:

Hey folks, I'm trying to create a CustomClock implementation in Rust that is a subclass of GstSystemClock. I found some examples of how one can create GstElements in Rust but none explaining how to subclass a GstSystemClock. 



Is it possible to create a custom clock implementation purely in Rust? 



The code below is the boilerplate I implemented so far. This code doesn't compiler, one of the error messages says: 



type ParentType = gst_sys::GstSystemClock; 

    |                       ^^^^^^^^^^^^^^^^^^^^^^^ the trait `FromGlibPtrNone<*mut _>` is not implemented for `GstSystemClock`



I'm fairly new to create new GLib types and Gstreamer plugins in Rust, what am I missing? 





You would use `type ParentType = gst::SystemClock`. The one you selected there is the plain C type.

In addition to that you'll also have to implement the SystemClockImpl trait.



Once that is done, I think your code should compile like this unless I missed something.



-- 

Sebastian Dröge, Centricular Ltd · https://www.centricular.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20221025/0d2a08a5/attachment.htm>


More information about the gstreamer-devel mailing list