mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-26 11:31:06 +00:00
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:
parent
94ace06883
commit
d7ed8d1e35
1 changed files with 23 additions and 0 deletions
|
@ -265,6 +265,9 @@ pub trait ElementExtManual: 'static {
|
||||||
where
|
where
|
||||||
F: FnOnce(&Self) -> T + Send + 'static,
|
F: FnOnce(&Self) -> T + Send + 'static,
|
||||||
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 {
|
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")))
|
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 {
|
impl ElementClass {
|
||||||
|
|
Loading…
Reference in a new issue