sync elements: implement provide_clock

Since those are using the clock for sync, they need to also
provide a clock for good measure. The reason is that even if
downstream elements provide a clock, we don't want to have
that clock selected because it might not be running yet.
This commit is contained in:
Mathieu Duponchelle 2020-06-02 19:31:58 +02:00
parent dfaf59a59b
commit 3d26d2f27b
3 changed files with 18 additions and 0 deletions

View file

@ -556,6 +556,8 @@ impl ObjectImpl for InputSelector {
let element = obj.downcast_ref::<gst::Element>().unwrap(); let element = obj.downcast_ref::<gst::Element>().unwrap();
element.add_pad(self.src_pad.gst_pad()).unwrap(); element.add_pad(self.src_pad.gst_pad()).unwrap();
element
.set_element_flags(gst::ElementFlags::PROVIDE_CLOCK | gst::ElementFlags::REQUIRE_CLOCK);
} }
} }
@ -626,6 +628,10 @@ impl ElementImpl for InputSelector {
let _ = element.post_message(&gst::Message::new_latency().src(Some(element)).build()); let _ = element.post_message(&gst::Message::new_latency().src(Some(element)).build());
} }
fn provide_clock(&self, _element: &gst::Element) -> Option<gst::Clock> {
Some(gst::SystemClock::obtain())
}
} }
pub fn register(plugin: &gst::Plugin) -> Result<(), glib::BoolError> { pub fn register(plugin: &gst::Plugin) -> Result<(), glib::BoolError> {

View file

@ -1592,6 +1592,8 @@ impl ObjectImpl for JitterBuffer {
let element = obj.downcast_ref::<gst::Element>().unwrap(); let element = obj.downcast_ref::<gst::Element>().unwrap();
element.add_pad(self.sink_pad.gst_pad()).unwrap(); element.add_pad(self.sink_pad.gst_pad()).unwrap();
element.add_pad(self.src_pad.gst_pad()).unwrap(); element.add_pad(self.src_pad.gst_pad()).unwrap();
element
.set_element_flags(gst::ElementFlags::PROVIDE_CLOCK | gst::ElementFlags::REQUIRE_CLOCK);
} }
} }
@ -1634,6 +1636,10 @@ impl ElementImpl for JitterBuffer {
Ok(success) Ok(success)
} }
fn provide_clock(&self, _element: &gst::Element) -> Option<gst::Clock> {
Some(gst::SystemClock::obtain())
}
} }
pub fn register(plugin: &gst::Plugin) -> Result<(), glib::BoolError> { pub fn register(plugin: &gst::Plugin) -> Result<(), glib::BoolError> {

View file

@ -1095,6 +1095,8 @@ impl ObjectImpl for Transcriber {
let element = obj.downcast_ref::<gst::Element>().unwrap(); let element = obj.downcast_ref::<gst::Element>().unwrap();
element.add_pad(&self.sinkpad).unwrap(); element.add_pad(&self.sinkpad).unwrap();
element.add_pad(&self.srcpad).unwrap(); element.add_pad(&self.srcpad).unwrap();
element
.set_element_flags(gst::ElementFlags::PROVIDE_CLOCK | gst::ElementFlags::REQUIRE_CLOCK);
} }
fn set_property(&self, _obj: &glib::Object, id: usize, value: &glib::Value) { fn set_property(&self, _obj: &glib::Object, id: usize, value: &glib::Value) {
@ -1170,6 +1172,10 @@ impl ElementImpl for Transcriber {
Ok(success) Ok(success)
} }
fn provide_clock(&self, _element: &gst::Element) -> Option<gst::Clock> {
Some(gst::SystemClock::obtain())
}
} }
pub fn register(plugin: &gst::Plugin) -> Result<(), glib::BoolError> { pub fn register(plugin: &gst::Plugin) -> Result<(), glib::BoolError> {