gstreamer: Add Element::get_current_clock_time() and ::get_current_running_time()

This was added in GStreamer 1.18 but we can easily implement it
ourselves here for the time being and for older versions.
This commit is contained in:
Sebastian Dröge 2020-04-11 20:02:41 +03:00
parent c8ac89ec2b
commit d23d313b39

View file

@ -262,6 +262,9 @@ pub trait ElementExtManual: 'static {
where
F: FnOnce(&Self) -> T + Send + 'static,
T: Send + 'static;
fn get_current_running_time(&self) -> ::ClockTime;
fn get_current_clock_time(&self) -> ::ClockTime;
}
impl<O: IsA<Element>> ElementExtManual for O {
@ -804,6 +807,26 @@ impl<O: IsA<Element>> ElementExtManual for O {
Box::pin(receiver.map(|res| res.expect("sender dropped")))
}
fn get_current_running_time(&self) -> ::ClockTime {
use ElementExt;
let base_time = self.get_base_time();
let clock_time = self.get_current_clock_time();
clock_time - base_time
}
fn get_current_clock_time(&self) -> ::ClockTime {
use ClockExt;
use ElementExt;
if let Some(clock) = self.get_clock() {
clock.get_time()
} else {
::CLOCK_TIME_NONE
}
}
}
impl ElementClass {