diff options
author | François Laignel <fengalin@free.fr> | 2022-10-17 20:48:43 +0300 |
---|---|---|
committer | François Laignel <fengalin@mailo.com> | 2022-10-18 13:36:59 +0300 |
commit | 8011eadfd2137b4c21fa8e6dfffe6891cb2be406 (patch) | |
tree | 1db00e75b8cc26362bda0cfc86fd424b27482440 /net | |
parent | e66378d2544f9e39acfac18143cfac4afa8ae7ac (diff) |
Use new format constructors
See https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1128
Diffstat (limited to 'net')
-rw-r--r-- | net/aws/src/aws_transcribe_parse/imp.rs | 10 | ||||
-rw-r--r-- | net/aws/src/aws_transcriber/imp.rs | 9 | ||||
-rw-r--r-- | net/hlssink3/src/imp.rs | 4 | ||||
-rw-r--r-- | net/ndi/src/ndisink/imp.rs | 6 | ||||
-rw-r--r-- | net/ndi/src/ndisrc/receiver.rs | 53 | ||||
-rw-r--r-- | net/onvif/src/onvifmetadatacombiner/imp.rs | 12 | ||||
-rw-r--r-- | net/onvif/src/onvifmetadataparse/imp.rs | 8 | ||||
-rw-r--r-- | net/raptorq/src/raptorqdec/imp.rs | 4 | ||||
-rw-r--r-- | net/raptorq/src/raptorqenc/imp.rs | 2 | ||||
-rw-r--r-- | net/raptorq/tests/raptorq.rs | 5 | ||||
-rw-r--r-- | net/reqwest/tests/reqwesthttpsrc.rs | 14 |
11 files changed, 56 insertions, 71 deletions
diff --git a/net/aws/src/aws_transcribe_parse/imp.rs b/net/aws/src/aws_transcribe_parse/imp.rs index 12dc13523..18cde1fa7 100644 --- a/net/aws/src/aws_transcribe_parse/imp.rs +++ b/net/aws/src/aws_transcribe_parse/imp.rs @@ -125,7 +125,7 @@ impl TranscribeParse { ) })?; - let mut last_pts: gst::ClockTime = gst::ClockTime::from_nseconds(0); + let mut last_pts = gst::ClockTime::ZERO; for mut item in transcript.results.items.drain(..) { match item.type_.as_str() { @@ -139,7 +139,7 @@ impl TranscribeParse { let outbuf = outbuf.get_mut().unwrap(); outbuf.set_pts(last_pts); - outbuf.set_duration(gst::ClockTime::from_nseconds(0)); + outbuf.set_duration(gst::ClockTime::ZERO); } self.srcpad.push(outbuf).map_err(|err| { @@ -170,10 +170,8 @@ impl TranscribeParse { } }; - let start_pts = - gst::ClockTime::from_nseconds((start_time as f64 * 1_000_000_000.0) as u64); - let end_pts = - gst::ClockTime::from_nseconds((end_time as f64 * 1_000_000_000.0) as u64); + let start_pts = ((start_time as f64 * 1_000_000_000.0) as u64).nseconds(); + let end_pts = ((end_time as f64 * 1_000_000_000.0) as u64).nseconds(); let duration = end_pts.saturating_sub(start_pts); if start_pts > last_pts { diff --git a/net/aws/src/aws_transcriber/imp.rs b/net/aws/src/aws_transcriber/imp.rs index 247f78126..49eaf56ce 100644 --- a/net/aws/src/aws_transcriber/imp.rs +++ b/net/aws/src/aws_transcriber/imp.rs @@ -111,7 +111,7 @@ static RUNTIME: Lazy<runtime::Runtime> = Lazy::new(|| { }); const DEFAULT_LATENCY: gst::ClockTime = gst::ClockTime::from_seconds(8); -const DEFAULT_LATENESS: gst::ClockTime = gst::ClockTime::from_seconds(0); +const DEFAULT_LATENESS: gst::ClockTime = gst::ClockTime::ZERO; const DEFAULT_STABILITY: AwsTranscriberResultStability = AwsTranscriberResultStability::Low; const DEFAULT_VOCABULARY_FILTER_METHOD: AwsTranscriberVocabularyFilterMethod = AwsTranscriberVocabularyFilterMethod::Mask; @@ -395,11 +395,8 @@ impl Transcriber { for item in &alternative.items[state.partial_index..] { let start_time = - gst::ClockTime::from_nseconds((item.start_time as f64 * 1_000_000_000.0) as u64) - + lateness; - let end_time = - gst::ClockTime::from_nseconds((item.end_time as f64 * 1_000_000_000.0) as u64) - + lateness; + ((item.start_time as f64 * 1_000_000_000.0) as u64).nseconds() + lateness; + let end_time = ((item.end_time as f64 * 1_000_000_000.0) as u64).nseconds() + lateness; if !item.stable { break; diff --git a/net/hlssink3/src/imp.rs b/net/hlssink3/src/imp.rs index 1b305d090..b62c63ab1 100644 --- a/net/hlssink3/src/imp.rs +++ b/net/hlssink3/src/imp.rs @@ -493,7 +493,7 @@ impl ObjectImpl for HlsSink3 { settings.target_duration = value.get().expect("type checked upstream"); settings.splitmuxsink.set_property( "max-size-time", - &(gst::ClockTime::from_seconds(settings.target_duration as u64)), + &((settings.target_duration as u64).seconds()), ); } "playlist-length" => { @@ -627,7 +627,7 @@ impl ObjectImpl for HlsSink3 { ("location", &location), ( "max-size-time", - &(gst::ClockTime::from_seconds(settings.target_duration as u64)), + &(settings.target_duration as u64).seconds(), ), ("send-keyframe-requests", &settings.send_keyframe_requests), ("muxer", &mux), diff --git a/net/ndi/src/ndisink/imp.rs b/net/ndi/src/ndisink/imp.rs index f2ec74922..f0aaf1fe3 100644 --- a/net/ndi/src/ndisink/imp.rs +++ b/net/ndi/src/ndisink/imp.rs @@ -279,7 +279,7 @@ impl BaseSinkImpl for NdiSink { if *timecode < 0 { gst::ClockTime::NONE.display() } else { - Some(gst::ClockTime::from_nseconds(*timecode as u64 * 100)).display() + Some((*timecode as u64 * 100).nseconds()).display() }, info, ); @@ -323,7 +323,7 @@ impl BaseSinkImpl for NdiSink { if timecode < 0 { gst::ClockTime::NONE.display() } else { - Some(gst::ClockTime::from_nseconds(timecode as u64 * 100)).display() + Some((timecode as u64 * 100).nseconds()).display() }, info ); @@ -358,7 +358,7 @@ impl BaseSinkImpl for NdiSink { if timecode < 0 { gst::ClockTime::NONE.display() } else { - Some(gst::ClockTime::from_nseconds(timecode as u64 * 100)).display() + Some((timecode as u64 * 100).nseconds()).display() }, info, ); diff --git a/net/ndi/src/ndisrc/receiver.rs b/net/ndi/src/ndisrc/receiver.rs index 90484bacb..ac88a762f 100644 --- a/net/ndi/src/ndisrc/receiver.rs +++ b/net/ndi/src/ndisrc/receiver.rs @@ -303,8 +303,8 @@ impl Observations { CAT, obj: element, "Local time {}, remote time {}, slope correct {}/{}", - gst::ClockTime::from_nseconds(local_time), - gst::ClockTime::from_nseconds(remote_time), + local_time.nseconds(), + remote_time.nseconds(), inner.slope_correction.0, inner.slope_correction.1, ); @@ -337,18 +337,18 @@ impl Observations { CAT, obj: element, "Initializing base time: local {}, remote {}", - gst::ClockTime::from_nseconds(local_time), - gst::ClockTime::from_nseconds(remote_time), + local_time.nseconds(), + remote_time.nseconds(), ); inner.base_remote_time = Some(remote_time); inner.base_local_time = Some(local_time); - return Some((gst::ClockTime::from_nseconds(local_time), duration, true)); + return Some((local_time.nseconds(), duration, true)); } }; if inner.times.len() < PREFILL_WINDOW_LENGTH { - return Some((gst::ClockTime::from_nseconds(local_time), duration, false)); + return Some((local_time.nseconds(), duration, false)); } // Check if the slope is simply wrong and try correcting @@ -426,15 +426,15 @@ impl Observations { CAT, obj: element, "Initializing base time: local {}, remote {}, slope correction {}/{}", - gst::ClockTime::from_nseconds(local_time), - gst::ClockTime::from_nseconds(remote_time), + local_time.nseconds(), + remote_time.nseconds(), inner.slope_correction.0, inner.slope_correction.1, ); inner.base_remote_time = Some(remote_time); inner.base_local_time = Some(local_time); - return Some((gst::ClockTime::from_nseconds(local_time), duration, discont)); + return Some((local_time.nseconds(), duration, discont)); } } } @@ -447,8 +447,8 @@ impl Observations { CAT, obj: element, "Local diff {}, remote diff {}, delta {}", - gst::ClockTime::from_nseconds(local_diff), - gst::ClockTime::from_nseconds(remote_diff), + local_diff.nseconds(), + remote_diff.nseconds(), delta, ); @@ -469,15 +469,15 @@ impl Observations { CAT, obj: element, "Initializing base time: local {}, remote {}", - gst::ClockTime::from_nseconds(local_time), - gst::ClockTime::from_nseconds(remote_time), + local_time.nseconds(), + remote_time.nseconds(), ); inner.reset(); inner.base_remote_time = Some(remote_time); inner.base_local_time = Some(local_time); - return Some((gst::ClockTime::from_nseconds(local_time), duration, discont)); + return Some((local_time.nseconds(), duration, discont)); } if inner.filling { @@ -526,14 +526,9 @@ impl Observations { inner.skew, inner.min_delta ); - gst::trace!( - CAT, - obj: element, - "Outputting {}", - gst::ClockTime::from_nseconds(out_time) - ); + gst::trace!(CAT, obj: element, "Outputting {}", out_time.nseconds()); - Some((gst::ClockTime::from_nseconds(out_time), duration, false)) + Some((out_time.nseconds(), duration, false)) } } @@ -839,7 +834,7 @@ impl Receiver { CAT, obj: &element, "Received metadata at timecode {}: {}", - gst::ClockTime::from_nseconds(frame.timecode() as u64 * 100), + (frame.timecode() as u64 * 100).nseconds(), metadata, ); } @@ -901,13 +896,13 @@ impl Receiver { ) -> Option<(gst::ClockTime, Option<gst::ClockTime>, bool)> { let receive_time = element.current_running_time()?; - let real_time_now = gst::ClockTime::from_nseconds(glib::real_time() as u64 * 1000); + let real_time_now = (glib::real_time() as u64 * 1000).nseconds(); let timestamp = if timestamp == ndisys::NDIlib_recv_timestamp_undefined { gst::ClockTime::NONE } else { - Some(gst::ClockTime::from_nseconds(timestamp as u64 * 100)) + Some((timestamp as u64 * 100).nseconds()) }; - let timecode = gst::ClockTime::from_nseconds(timecode as u64 * 100); + let timecode = (timecode as u64 * 100).nseconds(); gst::log!( CAT, @@ -1305,14 +1300,14 @@ impl Receiver { gst::ReferenceTimestampMeta::add( buffer, &*crate::TIMECODE_CAPS, - gst::ClockTime::from_nseconds(video_frame.timecode() as u64 * 100), + (video_frame.timecode() as u64 * 100).nseconds(), gst::ClockTime::NONE, ); if video_frame.timestamp() != ndisys::NDIlib_recv_timestamp_undefined { gst::ReferenceTimestampMeta::add( buffer, &*crate::TIMESTAMP_CAPS, - gst::ClockTime::from_nseconds(video_frame.timestamp() as u64 * 100), + (video_frame.timestamp() as u64 * 100).nseconds(), gst::ClockTime::NONE, ); } @@ -1676,14 +1671,14 @@ impl Receiver { gst::ReferenceTimestampMeta::add( buffer, &*crate::TIMECODE_CAPS, - gst::ClockTime::from_nseconds(audio_frame.timecode() as u64 * 100), + (audio_frame.timecode() as u64 * 100).nseconds(), gst::ClockTime::NONE, ); if audio_frame.timestamp() != ndisys::NDIlib_recv_timestamp_undefined { gst::ReferenceTimestampMeta::add( buffer, &*crate::TIMESTAMP_CAPS, - gst::ClockTime::from_nseconds(audio_frame.timestamp() as u64 * 100), + (audio_frame.timestamp() as u64 * 100).nseconds(), gst::ClockTime::NONE, ); } diff --git a/net/onvif/src/onvifmetadatacombiner/imp.rs b/net/onvif/src/onvifmetadatacombiner/imp.rs index b919eee68..414ac674d 100644 --- a/net/onvif/src/onvifmetadatacombiner/imp.rs +++ b/net/onvif/src/onvifmetadatacombiner/imp.rs @@ -217,7 +217,7 @@ impl OnvifMetadataCombiner { imp: self, "could not calculate duration for current media buffer" ); - Some(gst::ClockTime::from_nseconds(0)) + Some(gst::ClockTime::ZERO) } } } else if timeout { @@ -226,7 +226,7 @@ impl OnvifMetadataCombiner { imp: self, "could not calculate duration for current media buffer" ); - Some(gst::ClockTime::from_nseconds(0)) + Some(gst::ClockTime::ZERO) } else { gst::trace!( CAT, @@ -304,11 +304,9 @@ impl AggregatorImpl for OnvifMetadataCombiner { s.set("frames", buflist); } - let position = buffer.pts().opt_add( - buffer - .duration() - .unwrap_or_else(|| gst::ClockTime::from_nseconds(0)), - ); + let position = buffer + .pts() + .opt_add(buffer.duration().unwrap_or(gst::ClockTime::ZERO)); gst::log!(CAT, imp: self, "Updating position: {:?}", position); diff --git a/net/onvif/src/onvifmetadataparse/imp.rs b/net/onvif/src/onvifmetadataparse/imp.rs index d69ca15e6..3833d2b9e 100644 --- a/net/onvif/src/onvifmetadataparse/imp.rs +++ b/net/onvif/src/onvifmetadataparse/imp.rs @@ -69,7 +69,7 @@ impl Default for Settings { fn default() -> Self { Settings { latency: None, - max_lateness: Some(gst::ClockTime::from_mseconds(200)), + max_lateness: Some(200.mseconds()), } } } @@ -359,8 +359,8 @@ impl OnvifMetadataParse { gst::FlowError::Error })?; - let dt_unix_ns = gst::ClockTime::from_nseconds(dt.timestamp_nanos() as u64) - + crate::PRIME_EPOCH_OFFSET; + let dt_unix_ns = + (dt.timestamp_nanos() as u64).nseconds() + crate::PRIME_EPOCH_OFFSET; gst::trace!( CAT, @@ -909,7 +909,7 @@ impl OnvifMetadataParse { if parsed { gst::ClockTime::ZERO } else { - gst::ClockTime::from_seconds(6) + 6.seconds() } }; state.configured_latency = latency; diff --git a/net/raptorq/src/raptorqdec/imp.rs b/net/raptorq/src/raptorqdec/imp.rs index f8cc4a6bb..b12f76a9d 100644 --- a/net/raptorq/src/raptorqdec/imp.rs +++ b/net/raptorq/src/raptorqdec/imp.rs @@ -547,8 +547,8 @@ impl RaptorqDec { let tolerance = settings.repair_window_tolerance as u64; let repair_window = fmtp_param_from_caps::<u64>("repair-window", incaps)?; - let tolerance = gst::ClockTime::from_mseconds(tolerance); - let repair_window = gst::ClockTime::from_useconds(repair_window); + let tolerance = tolerance.mseconds(); + let repair_window = repair_window.useconds(); let repair_window = Some(repair_window + tolerance); let media_packets_reset_threshold = settings.media_packets_reset_threshold as usize; diff --git a/net/raptorq/src/raptorqenc/imp.rs b/net/raptorq/src/raptorqenc/imp.rs index 339d6d3a2..f1bf9e8f5 100644 --- a/net/raptorq/src/raptorqenc/imp.rs +++ b/net/raptorq/src/raptorqenc/imp.rs @@ -177,7 +177,7 @@ impl RaptorqEnc { .unwrap_or(0); let delays = (1..=state.repair_packets_num) - .map(|n| gst::ClockTime::from_mseconds((n * delay_step) as u64)) + .map(|n| ((n * delay_step) as u64).mseconds()) .collect::<Vec<_>>(); let base_time = self.instance().base_time(); diff --git a/net/raptorq/tests/raptorq.rs b/net/raptorq/tests/raptorq.rs index 8595c3071..0985e3201 100644 --- a/net/raptorq/tests/raptorq.rs +++ b/net/raptorq/tests/raptorq.rs @@ -195,8 +195,7 @@ impl RaptorqTest { } // Check if repair packets pushed from encoder are delayed properly - let delay_step = - gst::ClockTime::from_mseconds((self.repair_window / self.repair_packets) as u64); + let delay_step = ((self.repair_window / self.repair_packets) as u64).mseconds(); let mut delay = delay_step; let repair_packets = (0..self.repair_packets) @@ -556,7 +555,7 @@ fn test_raptorq_repair_window_tolerance() { h_dec.set_src_caps_str("application/x-rtp"); h_dec_fec.set_src_caps(caps); - h_enc_fec.set_time(gst::ClockTime::from_seconds(1)).unwrap(); + h_enc_fec.set_time(1.seconds()).unwrap(); let result = h_enc.pull(); assert!(result.is_ok()); diff --git a/net/reqwest/tests/reqwesthttpsrc.rs b/net/reqwest/tests/reqwesthttpsrc.rs index 5c7c28257..aa45f954d 100644 --- a/net/reqwest/tests/reqwesthttpsrc.rs +++ b/net/reqwest/tests/reqwesthttpsrc.rs @@ -930,13 +930,12 @@ fn test_seek_after_ready() { assert_eq!(current_state, gst::State::Ready); h.run(|src| { - src.seek_simple(gst::SeekFlags::FLUSH, gst::format::Bytes::from_u64(123)) - .unwrap(); + src.seek_simple(gst::SeekFlags::FLUSH, 123.bytes()).unwrap(); src.set_state(gst::State::Playing).unwrap(); }); let segment = h.wait_for_segment(false); - assert_eq!(segment.start(), Some(gst::format::Bytes::from_u64(123))); + assert_eq!(segment.start(), Some(123.bytes())); let mut expected_output = vec![0; 8192 - 123]; for (i, d) in expected_output.iter_mut().enumerate() { @@ -1009,12 +1008,11 @@ fn test_seek_after_buffer_received() { //seek to a position after a buffer is Received h.run(|src| { - src.seek_simple(gst::SeekFlags::FLUSH, gst::format::Bytes::from_u64(123)) - .unwrap(); + src.seek_simple(gst::SeekFlags::FLUSH, 123.bytes()).unwrap(); }); let segment = h.wait_for_segment(true); - assert_eq!(segment.start(), Some(gst::format::Bytes::from_u64(123))); + assert_eq!(segment.start(), Some(123.bytes())); let mut expected_output = vec![0; 8192 - 123]; for (i, d) in expected_output.iter_mut().enumerate() { @@ -1086,8 +1084,8 @@ fn test_seek_with_stop_position() { assert_eq!(buffer.offset(), 0); //seek to a position after a buffer is Received - let start = gst::format::Bytes::from_u64(123); - let stop = gst::format::Bytes::from_u64(131); + let start = 123.bytes(); + let stop = 131.bytes(); h.run(move |src| { src.seek( 1.0, |