mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2025-09-01 09:13:48 +00:00
all: fixes for Clock: non-optional return types
See: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1739 Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/2304>
This commit is contained in:
parent
52121e6ea7
commit
43b37aed8b
17 changed files with 26 additions and 36 deletions
|
@ -23,7 +23,7 @@ async fn main() -> Result<(), Error> {
|
|||
sink_pipeline.bus().unwrap().stream(),
|
||||
]);
|
||||
|
||||
let base_time = gst::SystemClock::obtain().time().unwrap();
|
||||
let base_time = gst::SystemClock::obtain().time();
|
||||
|
||||
src_pipeline.set_clock(Some(&gst::SystemClock::obtain()))?;
|
||||
src_pipeline.set_start_time(gst::ClockTime::NONE);
|
||||
|
|
|
@ -168,7 +168,7 @@ async fn main() -> Result<(), Error> {
|
|||
|
||||
println!("h for help");
|
||||
|
||||
let base_time = gst::SystemClock::obtain().time().unwrap();
|
||||
let base_time = gst::SystemClock::obtain().time();
|
||||
|
||||
let mut producers: HashMap<String, Producer> = HashMap::new();
|
||||
let mut consumers: HashMap<String, Consumer> = HashMap::new();
|
||||
|
|
|
@ -307,7 +307,7 @@ fn setup_appsink(appsink: &gst_app::AppSink, name: &str, path: &Path, is_video:
|
|||
|
||||
if state.start_date_time.is_none() {
|
||||
let now_utc = Utc::now();
|
||||
let now_gst = sink.clock().unwrap().time().unwrap();
|
||||
let now_gst = sink.clock().unwrap().time();
|
||||
let pts_clock_time = pts + sink.base_time().unwrap();
|
||||
|
||||
let diff = now_gst.checked_sub(pts_clock_time).unwrap();
|
||||
|
|
|
@ -430,7 +430,7 @@ impl HlsBaseSink {
|
|||
{
|
||||
let obj = self.obj();
|
||||
let now_utc = Utc::now();
|
||||
let now_gst = obj.clock().unwrap().time().unwrap();
|
||||
let now_gst = obj.clock().unwrap().time();
|
||||
let pts_clock_time = running_time + obj.base_time().unwrap();
|
||||
|
||||
let diff = now_gst.nseconds() as i64 - pts_clock_time.nseconds() as i64;
|
||||
|
|
|
@ -734,7 +734,6 @@ impl MpegTsLiveSource {
|
|||
let new_pts = self
|
||||
.external_clock
|
||||
.adjust_unlocked(pts + base_time)
|
||||
.expect("Couldn't adjust {pts}")
|
||||
.saturating_sub(base_time);
|
||||
gst::debug!(
|
||||
CAT,
|
||||
|
@ -788,7 +787,6 @@ impl MpegTsLiveSource {
|
|||
let new_pts = self
|
||||
.external_clock
|
||||
.adjust_unlocked(pts + base_time)
|
||||
.expect("Couldn't adjust {pts}")
|
||||
.saturating_sub(base_time);
|
||||
gst::debug!(
|
||||
CAT,
|
||||
|
|
|
@ -958,8 +958,8 @@ impl NdiSrc {
|
|||
gst::Clock::unadjust_with_calibration(clock_time, internal, external, num, denom);
|
||||
} else {
|
||||
// Otherwise measure the difference between both clocks and work with that.
|
||||
let now_internal = state.clock.time().unwrap();
|
||||
let now_external = external_clock.time().unwrap();
|
||||
let now_internal = state.clock.time();
|
||||
let now_external = external_clock.time();
|
||||
|
||||
if now_internal > now_external {
|
||||
let diff = now_internal - now_external;
|
||||
|
|
|
@ -329,7 +329,7 @@ impl Receiver {
|
|||
} else if let Some((clock, base_time)) =
|
||||
Option::zip(element.clock(), element.base_time())
|
||||
{
|
||||
clock.time().map(|now| now.saturating_sub(base_time))
|
||||
Some(clock.time().saturating_sub(base_time))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
|
|
@ -1280,7 +1280,7 @@ impl OnvifMetadataParse {
|
|||
// Drain until the current clock running time minus the configured latency when
|
||||
// live
|
||||
if let Some((now, base_time)) = Option::zip(
|
||||
self.obj().clock().and_then(|clock| clock.time()),
|
||||
self.obj().clock().as_ref().map(gst::Clock::time),
|
||||
self.obj().base_time(),
|
||||
) {
|
||||
gst::trace!(
|
||||
|
@ -1348,7 +1348,7 @@ impl OnvifMetadataParse {
|
|||
imp = self,
|
||||
"Waiting on timer with time {}, now {}",
|
||||
clock_wait.time(),
|
||||
clock_wait.clock().and_then(|clock| clock.time()).display(),
|
||||
clock_wait.clock().as_ref().map(gst::Clock::time).display(),
|
||||
);
|
||||
|
||||
drop(state);
|
||||
|
|
|
@ -243,7 +243,7 @@ impl RelationMeta2OnvifMeta {
|
|||
.try_into()
|
||||
.unwrap();
|
||||
let utc_now = gst::ClockTime::from_nseconds(utc_now);
|
||||
let running_time_now = clock.time().unwrap() - base_time;
|
||||
let running_time_now = clock.time() - base_time;
|
||||
|
||||
let rt_diff = utc_now - running_time_now;
|
||||
running_time_now + rt_diff
|
||||
|
|
|
@ -449,7 +449,7 @@ impl Detector {
|
|||
|
||||
fn update_rtts(&mut self, packets: &Vec<Packet>) {
|
||||
let mut rtt = Duration::nanoseconds(i64::MAX);
|
||||
let now = ts2dur(self.clock.time().unwrap());
|
||||
let now = ts2dur(self.clock.time());
|
||||
for packet in packets {
|
||||
rtt = (now - packet.departure).min(rtt);
|
||||
}
|
||||
|
@ -1082,7 +1082,7 @@ impl BandwidthEstimator {
|
|||
let clock = gst::SystemClock::obtain();
|
||||
|
||||
bwe.imp().state.lock().unwrap().clock_entry =
|
||||
Some(clock.new_single_shot_id(clock.time().unwrap() + dur2ts(BURST_TIME)));
|
||||
Some(clock.new_single_shot_id(clock.time() + dur2ts(BURST_TIME)));
|
||||
|
||||
self.srcpad.start_task(move || {
|
||||
let pause = || {
|
||||
|
@ -1119,7 +1119,7 @@ impl BandwidthEstimator {
|
|||
let list = {
|
||||
let mut state = lock_state();
|
||||
clock
|
||||
.single_shot_id_reinit(&clock_entry, clock.time().unwrap() + dur2ts(BURST_TIME))
|
||||
.single_shot_id_reinit(&clock_entry, clock.time() + dur2ts(BURST_TIME))
|
||||
.unwrap();
|
||||
state.clock_entry = Some(clock_entry);
|
||||
state.create_buffer_list(&bwe)
|
||||
|
|
|
@ -780,7 +780,7 @@ impl PushSrcImpl for SineSrc {
|
|||
imp = self,
|
||||
"Waiting until {}, now {}",
|
||||
wait_until,
|
||||
clock.time().display(),
|
||||
clock.time(),
|
||||
);
|
||||
let (res, jitter) = id.wait();
|
||||
gst::log!(CAT, imp = self, "Waited res {:?} jitter {}", res, jitter);
|
||||
|
|
|
@ -695,7 +695,7 @@ For working in live mode, we have to add a few different parts in various places
|
|||
imp = self,
|
||||
"Waiting until {}, now {}",
|
||||
wait_until,
|
||||
clock.time().display(),
|
||||
clock.time(),
|
||||
);
|
||||
let (res, jitter) = id.wait();
|
||||
gst::log!(
|
||||
|
@ -864,7 +864,7 @@ Now as a last step, we need to actually make use of the new struct we added arou
|
|||
imp = self,
|
||||
"Waiting until {}, now {}",
|
||||
wait_until,
|
||||
clock.time().display(),
|
||||
clock.time(),
|
||||
);
|
||||
let (res, jitter) = id.wait();
|
||||
gst::log!(
|
||||
|
|
|
@ -4045,7 +4045,7 @@ impl FallbackSrc {
|
|||
|
||||
gst::debug!(CAT, imp = imp, "Waiting for 1s before retrying");
|
||||
let clock = gst::SystemClock::obtain();
|
||||
let wait_time = clock.time().unwrap() + gst::ClockTime::SECOND;
|
||||
let wait_time = clock.time() + gst::ClockTime::SECOND;
|
||||
if fallback_source {
|
||||
assert!(state
|
||||
.fallback_source
|
||||
|
@ -4273,7 +4273,7 @@ impl FallbackSrc {
|
|||
}
|
||||
|
||||
let clock = gst::SystemClock::obtain();
|
||||
let wait_time = clock.time().unwrap() + state.settings.restart_timeout - elapsed;
|
||||
let wait_time = clock.time() + state.settings.restart_timeout - elapsed;
|
||||
gst::debug!(
|
||||
CAT,
|
||||
imp = self,
|
||||
|
|
|
@ -344,7 +344,7 @@ impl SinkState {
|
|||
let wait_until = running_time + base_time;
|
||||
let wait_until = wait_until.saturating_add(extra_time);
|
||||
|
||||
let now = clock.time()?;
|
||||
let now = clock.time();
|
||||
|
||||
/* If the buffer is already late, skip the clock wait */
|
||||
if wait_until < now {
|
||||
|
@ -569,7 +569,7 @@ impl FallbackSwitch {
|
|||
|
||||
/* If we're already running behind, fire the timeout immediately */
|
||||
let now = clock.time();
|
||||
if now.is_some_and(|now| wait_until <= now) {
|
||||
if wait_until <= now {
|
||||
self.handle_timeout(state, settings);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -542,7 +542,7 @@ fn setup_pipeline(
|
|||
loop {
|
||||
while let Some(clock_id) = clock.peek_next_pending_id().and_then(|clock_id| {
|
||||
// Process if the clock ID is in the past or now
|
||||
if clock.time().is_some_and(|time| time >= clock_id.time()) {
|
||||
if clock.time() >= clock_id.time() {
|
||||
Some(clock_id)
|
||||
} else {
|
||||
None
|
||||
|
@ -567,10 +567,7 @@ fn setup_pipeline(
|
|||
// at the top of the queue. We don't want to do a busy loop here.
|
||||
while clock.peek_next_pending_id().iter().any(|clock_id| {
|
||||
// Sleep if the clock ID is in the future
|
||||
// FIXME probably can expect clock.time()
|
||||
clock
|
||||
.time()
|
||||
.is_none_or(|clock_time| clock_time < clock_id.time())
|
||||
clock.time() < clock_id.time()
|
||||
}) {
|
||||
use std::{thread, time};
|
||||
|
||||
|
|
|
@ -384,9 +384,7 @@ impl ToggleRecord {
|
|||
let mut settings = self.settings.lock();
|
||||
|
||||
if rec_state.time_start_block.is_none() {
|
||||
rec_state.time_start_block = clock
|
||||
.as_ref()
|
||||
.map_or(state.current_running_time, |c| c.time());
|
||||
rec_state.time_start_block = clock.as_ref().map(gst::Clock::time);
|
||||
}
|
||||
while !settings.record && !state.flushing {
|
||||
gst::debug!(CAT, obj = pad, "Waiting for record=true");
|
||||
|
@ -411,7 +409,7 @@ impl ToggleRecord {
|
|||
if let Some(time_start_block) = rec_state.time_start_block {
|
||||
// If we have a time_start_block it means the clock is there
|
||||
let clock = clock.expect("Cannot find pipeline clock");
|
||||
rec_state.blocked_duration += clock.time().unwrap() - time_start_block;
|
||||
rec_state.blocked_duration += clock.time() - time_start_block;
|
||||
if settings.live {
|
||||
rec_state.running_time_offset = rec_state.blocked_duration.nseconds() as i64;
|
||||
}
|
||||
|
@ -505,7 +503,7 @@ impl ToggleRecord {
|
|||
let settings_changed = match rec_state.recording_state {
|
||||
RecordingState::Recording if !settings.record => {
|
||||
let clock = self.obj().clock().expect("Cannot find pipeline clock");
|
||||
rec_state.time_start_block = Some(clock.time().unwrap());
|
||||
rec_state.time_start_block = Some(clock.time());
|
||||
gst::debug!(CAT, obj = pad, "Stopping recording");
|
||||
rec_state.recording_state = RecordingState::Stopping;
|
||||
true
|
||||
|
|
|
@ -362,10 +362,7 @@ impl TracerImpl for BufferLateness {
|
|||
let Some(buffer_clock_time) = running_time.checked_add(base_time) else {
|
||||
return;
|
||||
};
|
||||
let pipeline_clock_time = match clock.time() {
|
||||
Some(time) => time,
|
||||
None => return,
|
||||
};
|
||||
let pipeline_clock_time = clock.time();
|
||||
|
||||
log.push(LogLine {
|
||||
timestamp: ts,
|
||||
|
|
Loading…
Reference in a new issue