<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta content="text/html;charset=UTF-8" http-equiv="Content-Type"></head><body ><div style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt;"><div>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. <br></div><div><br></div><div>Is it possible to create a custom clock implementation purely in Rust? <br></div><div><br></div><div>The code below is the boilerplate I implemented so far. This code doesn't compiler, one of the error messages says: <br></div><div><br></div><div>type ParentType = gst_sys::GstSystemClock; <br></div><div> | ^^^^^^^^^^^^^^^^^^^^^^^ the trait `FromGlibPtrNone<*mut _>` is not implemented for `GstSystemClock`<br></div><div><br></div><div>I'm fairly new to create new GLib types and Gstreamer plugins in Rust, what am I missing? <br></div><div><br></div><div>PS: a while ago I've done a similar implementation in C (<a href="https://github.com/TeleMidia/LibPlay/blob/master/lib/lp-clock.c" target="_blank">LibPlay/lp-clock.c at master ยท TeleMidia/LibPlay (github.com)</a>) and now I'm trying to do it purely in Rust.<br></div><div><br></div><div>use gstreamer as gst; <br></div><div>use gst::glib;<br></div><div>use gst::prelude::*;<br></div><div>use gst::subclass::prelude::*;<br></div><div>use gstreamer_sys as gst_sys;<br></div><div><br></div><div>pub struct CustomClock {<br></div><div> current_time_in_ns: gst::ClockTime,<br></div><div> internal_clock: gst::Clock,<br></div><div>}<br></div><div><br></div><div>impl CustomClock {<br></div><div> pub fn new() -> Self {<br></div><div> let sys_clock = gst::SystemClock::obtain();<br></div><div> let now = sys_clock.internal_time();<br></div><div><br></div><div> Self {<br></div><div> current_time_in_ns: now,<br></div><div> internal_clock: sys_clock<br></div><div> }<br></div><div> }<br></div><div><br></div><div> pub fn advance_time(self: &mut Self, time_in_ns: gst::ClockTime) {<br></div><div> self.current_time_in_ns += time_in_ns;<br></div><div> }<br></div><div>}<br></div><div><br></div><div>#[glib::object_subclass]<br></div><div>impl ObjectSubclass for CustomClock {<br></div><div> const NAME: &'static str = "CustomClock";<br></div><div> type Type = CustomClock;<br></div><div> type ParentType = gst_sys::GstSystemClock;<br></div><div>}<br></div><div><br></div><div>// Implementation of glib::Object virtual methods<br></div><div>impl ObjectImpl for CustomClock {}<br></div><div><br></div><div>impl GstObjectImpl for CustomClock {}<br></div><div><br></div><div>impl ClockImpl for CustomClock {<br></div><div> fn internal_time(&self, clock: &Self::Type) -> gst::ClockTime {<br></div><div> self.current_time_in_ns<br></div><div> }<br></div><div>}<br></div><div><br></div><div class="zmail_signature_below"><div id="" data-zbluepencil-ignore="true" data-sigid="8819909000000014001"><div>Rodrigo Santos<br></div></div></div><div><br></div></div><br></body></html>