From 8e2b79a90c941aea0b6ede12ae0291a330577f2f Mon Sep 17 00:00:00 2001 From: Mathieu Duponchelle Date: Mon, 13 Apr 2020 17:06:14 +0200 Subject: [PATCH] threadshare: remove hand-rolled get_current_running_time Instead, use the new Element method exposed in --- generic/threadshare/src/inputselector.rs | 3 +-- .../threadshare/src/jitterbuffer/jitterbuffer.rs | 5 ++--- generic/threadshare/src/lib.rs | 13 ------------- generic/threadshare/src/udpsink.rs | 2 +- 4 files changed, 4 insertions(+), 19 deletions(-) diff --git a/generic/threadshare/src/inputselector.rs b/generic/threadshare/src/inputselector.rs index 47e3ba6f..8811ccd1 100644 --- a/generic/threadshare/src/inputselector.rs +++ b/generic/threadshare/src/inputselector.rs @@ -37,7 +37,6 @@ use std::sync::{Arc, Mutex}; use std::time::Duration; use std::u32; -use crate::get_current_running_time; use crate::runtime::prelude::*; use crate::runtime::{self, PadSink, PadSinkRef, PadSrc, PadSrcRef}; @@ -120,7 +119,7 @@ impl InputSelectorPadSinkHandler { /* Wait until specified time */ async fn sync(&self, element: &gst::Element, running_time: gst::ClockTime) { - let now = get_current_running_time(&element); + let now = element.get_current_running_time(); if now.is_some() && now < running_time { let delay = running_time - now; diff --git a/generic/threadshare/src/jitterbuffer/jitterbuffer.rs b/generic/threadshare/src/jitterbuffer/jitterbuffer.rs index 6e2a2244..07ece795 100644 --- a/generic/threadshare/src/jitterbuffer/jitterbuffer.rs +++ b/generic/threadshare/src/jitterbuffer/jitterbuffer.rs @@ -40,7 +40,6 @@ use std::sync::Arc; use std::sync::Mutex as StdMutex; use std::time::Duration; -use crate::get_current_running_time; use crate::runtime::prelude::*; use crate::runtime::{self, Context, PadSink, PadSinkRef, PadSrc, PadSrcRef, Task}; @@ -426,7 +425,7 @@ impl SinkHandler { } if dts == gst::CLOCK_TIME_NONE { - dts = get_current_running_time(element); + dts = element.get_current_running_time(); pts = dts; estimated_dts = state.clock_rate.is_some(); @@ -919,7 +918,7 @@ impl SrcHandler { latency: gst::ClockTime, context_wait: gst::ClockTime, ) -> (gst::ClockTime, Option<(gst::ClockTime, Duration)>) { - let now = get_current_running_time(element); + let now = element.get_current_running_time(); gst_debug!( CAT, diff --git a/generic/threadshare/src/lib.rs b/generic/threadshare/src/lib.rs index beb53569..61514837 100644 --- a/generic/threadshare/src/lib.rs +++ b/generic/threadshare/src/lib.rs @@ -46,7 +46,6 @@ use glib_sys as glib_ffi; use gst; use gst::gst_plugin_define; -use gst::prelude::*; use gstreamer_sys as gst_ffi; fn plugin_init(plugin: &gst::Plugin) -> Result<(), glib::BoolError> { @@ -104,15 +103,3 @@ impl<'a> Drop for MutexGuard<'a> { } } } - -pub fn get_current_running_time(element: &gst::Element) -> gst::ClockTime { - if let Some(clock) = element.get_clock() { - if clock.get_time() > element.get_base_time() { - clock.get_time() - element.get_base_time() - } else { - 0.into() - } - } else { - gst::CLOCK_TIME_NONE - } -} diff --git a/generic/threadshare/src/udpsink.rs b/generic/threadshare/src/udpsink.rs index 18cd414f..38617aa3 100644 --- a/generic/threadshare/src/udpsink.rs +++ b/generic/threadshare/src/udpsink.rs @@ -745,7 +745,7 @@ impl UdpSinkPadHandler { /* Wait until specified time */ async fn sync(&self, element: &gst::Element, running_time: gst::ClockTime) { - let now = super::get_current_running_time(&element); + let now = element.get_current_running_time(); if now < running_time { let delay = running_time - now;