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 94ace06883
commit d7ed8d1e35

View file

@ -265,6 +265,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 {
@ -807,6 +810,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 {