Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/sdroege/gst-plugin-rs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrançois Laignel <fengalin@free.fr>2022-10-17 20:48:43 +0300
committerFrançois Laignel <fengalin@mailo.com>2022-10-18 13:36:59 +0300
commit8011eadfd2137b4c21fa8e6dfffe6891cb2be406 (patch)
tree1db00e75b8cc26362bda0cfc86fd424b27482440
parente66378d2544f9e39acfac18143cfac4afa8ae7ac (diff)
Use new format constructors
See https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1128
-rw-r--r--audio/audiofx/src/audioecho/imp.rs6
-rw-r--r--audio/audiofx/src/audioloudnorm/imp.rs12
-rw-r--r--audio/audiofx/src/audiornnoise/imp.rs4
-rw-r--r--audio/audiofx/src/ebur128level/imp.rs5
-rw-r--r--audio/audiofx/tests/audioloudnorm.rs2
-rw-r--r--generic/fmp4/examples/hls_live.rs4
-rw-r--r--generic/fmp4/examples/hls_vod.rs4
-rw-r--r--generic/fmp4/src/fmp4mux/boxes.rs3
-rw-r--r--generic/fmp4/src/fmp4mux/imp.rs25
-rw-r--r--generic/fmp4/tests/tests.rs390
-rw-r--r--generic/sodium/src/decrypter/imp.rs2
-rw-r--r--generic/sodium/src/encrypter/imp.rs2
-rw-r--r--generic/sodium/tests/decrypter.rs4
-rw-r--r--generic/threadshare/src/jitterbuffer/jitterbuffer.rs6
-rw-r--r--generic/threadshare/src/proxy/imp.rs3
-rw-r--r--generic/threadshare/src/queue/imp.rs3
-rw-r--r--generic/threadshare/tests/proxy.rs2
-rw-r--r--generic/threadshare/tests/queue.rs2
-rw-r--r--generic/threadshare/tests/tcpclientsrc.rs2
-rw-r--r--net/aws/src/aws_transcribe_parse/imp.rs10
-rw-r--r--net/aws/src/aws_transcriber/imp.rs9
-rw-r--r--net/hlssink3/src/imp.rs4
-rw-r--r--net/ndi/src/ndisink/imp.rs6
-rw-r--r--net/ndi/src/ndisrc/receiver.rs53
-rw-r--r--net/onvif/src/onvifmetadatacombiner/imp.rs12
-rw-r--r--net/onvif/src/onvifmetadataparse/imp.rs8
-rw-r--r--net/raptorq/src/raptorqdec/imp.rs4
-rw-r--r--net/raptorq/src/raptorqenc/imp.rs2
-rw-r--r--net/raptorq/tests/raptorq.rs5
-rw-r--r--net/reqwest/tests/reqwesthttpsrc.rs14
-rw-r--r--text/json/tests/json.rs10
-rw-r--r--text/regex/tests/regex.rs6
-rw-r--r--text/wrap/src/gsttextwrap/imp.rs3
-rw-r--r--text/wrap/tests/textwrap.rs10
-rw-r--r--utils/fallbackswitch/src/fallbacksrc/imp.rs18
-rw-r--r--utils/fallbackswitch/tests/fallbackswitch.rs190
-rw-r--r--utils/togglerecord/tests/tests.rs295
-rw-r--r--utils/uriplaylistbin/tests/uriplaylistbin.rs15
-rw-r--r--video/cdg/src/cdgparse/imp.rs26
-rw-r--r--video/closedcaption/src/ccdetect/imp.rs3
-rw-r--r--video/closedcaption/src/cea608overlay/imp.rs4
-rw-r--r--video/closedcaption/src/jsontovtt/imp.rs60
-rw-r--r--video/closedcaption/src/transcriberbin/imp.rs4
-rw-r--r--video/closedcaption/src/tttocea608/imp.rs10
-rw-r--r--video/closedcaption/tests/ccdetect.rs121
-rw-r--r--video/closedcaption/tests/cea608tott.rs16
-rw-r--r--video/closedcaption/tests/mcc_enc.rs2
-rw-r--r--video/closedcaption/tests/mcc_parse.rs4
-rw-r--r--video/closedcaption/tests/scc_enc.rs6
-rw-r--r--video/closedcaption/tests/scc_parse.rs8
-rw-r--r--video/closedcaption/tests/tttocea608.rs167
-rw-r--r--video/dav1d/src/dav1ddec/imp.rs6
-rw-r--r--video/flavors/src/flvdemux/imp.rs11
-rw-r--r--video/gif/src/gifenc/imp.rs2
-rw-r--r--video/gif/tests/gifenc.rs4
-rw-r--r--video/rspng/tests/pngenc.rs4
-rw-r--r--video/webp/src/dec/imp.rs2
-rw-r--r--video/webp/tests/webpdec.rs2
58 files changed, 593 insertions, 1024 deletions
diff --git a/audio/audiofx/src/audioecho/imp.rs b/audio/audiofx/src/audioecho/imp.rs
index 8659cce9..05e07009 100644
--- a/audio/audiofx/src/audioecho/imp.rs
+++ b/audio/audiofx/src/audioecho/imp.rs
@@ -137,14 +137,12 @@ impl ObjectImpl for AudioEcho {
"max-delay" => {
let mut settings = self.settings.lock().unwrap();
if self.state.lock().unwrap().is_none() {
- settings.max_delay =
- gst::ClockTime::from_nseconds(value.get().expect("type checked upstream"));
+ settings.max_delay = value.get::<u64>().unwrap().nseconds();
}
}
"delay" => {
let mut settings = self.settings.lock().unwrap();
- settings.delay =
- gst::ClockTime::from_nseconds(value.get().expect("type checked upstream"));
+ settings.delay = value.get::<u64>().unwrap().nseconds();
}
"intensity" => {
let mut settings = self.settings.lock().unwrap();
diff --git a/audio/audiofx/src/audioloudnorm/imp.rs b/audio/audiofx/src/audioloudnorm/imp.rs
index 6bbc1c1e..b55e7013 100644
--- a/audio/audiofx/src/audioloudnorm/imp.rs
+++ b/audio/audiofx/src/audioloudnorm/imp.rs
@@ -632,9 +632,7 @@ impl State {
// PTS is 2.9s seconds before the input PTS as we buffer 3s of samples and just
// outputted here the first 100ms of that.
- let pts = pts
- .into()
- .map(|pts| pts + 100 * gst::ClockTime::MSECOND - 3 * gst::ClockTime::SECOND);
+ let pts = pts.into().map(|pts| pts + 100.mseconds() - 3.seconds());
Ok((outbuf, pts))
}
@@ -766,9 +764,7 @@ impl State {
// PTS is 2.9s seconds before the input PTS as we buffer 3s of samples and just
// outputted here the first 100ms of that.
- let pts = pts
- .into()
- .map(|pts| pts + 100 * gst::ClockTime::MSECOND - 3 * gst::ClockTime::SECOND);
+ let pts = pts.into().map(|pts| pts + 100.mseconds() - 3.seconds());
Ok((outbuf, pts))
}
@@ -1674,8 +1670,8 @@ impl AudioLoudNorm {
let (live, min_latency, max_latency) = peer_query.result();
q.set(
live,
- min_latency + 3 * gst::ClockTime::SECOND,
- max_latency.opt_add(3 * gst::ClockTime::SECOND),
+ min_latency + 3.seconds(),
+ max_latency.opt_add(3.seconds()),
);
true
} else {
diff --git a/audio/audiofx/src/audiornnoise/imp.rs b/audio/audiofx/src/audiornnoise/imp.rs
index 321bf40a..07b5b348 100644
--- a/audio/audiofx/src/audiornnoise/imp.rs
+++ b/audio/audiofx/src/audiornnoise/imp.rs
@@ -340,8 +340,8 @@ impl BaseTransformImpl for AudioRNNoise {
max.display(),
);
- min += gst::ClockTime::from_seconds((FRAME_SIZE / 48000) as u64);
- max = max.opt_add(gst::ClockTime::from_seconds((FRAME_SIZE / 48000) as u64));
+ min += ((FRAME_SIZE / 48000) as u64).seconds();
+ max = max.opt_add(((FRAME_SIZE / 48000) as u64).seconds());
q.set(live, min, max);
return true;
}
diff --git a/audio/audiofx/src/ebur128level/imp.rs b/audio/audiofx/src/ebur128level/imp.rs
index dd0135bf..1271bfb4 100644
--- a/audio/audiofx/src/ebur128level/imp.rs
+++ b/audio/audiofx/src/ebur128level/imp.rs
@@ -195,8 +195,7 @@ impl ObjectImpl for EbuR128Level {
settings.post_messages = post_messages;
}
"interval" => {
- let interval =
- gst::ClockTime::from_nseconds(value.get().expect("type checked upstream"));
+ let interval = value.get::<u64>().unwrap().nseconds();
gst::info!(
CAT,
imp: self,
@@ -455,7 +454,7 @@ impl BaseTransformImpl for EbuR128Level {
gst::FlowError::Error
})?;
- state.interval_frames_remaining -= gst::ClockTime::from_nseconds(to_process);
+ state.interval_frames_remaining -= to_process.nseconds();
state.num_frames += to_process;
// The timestamp we report in messages is always the timestamp until which measurements
diff --git a/audio/audiofx/tests/audioloudnorm.rs b/audio/audiofx/tests/audioloudnorm.rs
index e3999211..3540c9f9 100644
--- a/audio/audiofx/tests/audioloudnorm.rs
+++ b/audio/audiofx/tests/audioloudnorm.rs
@@ -151,7 +151,7 @@ fn run_test(
num_samples += data.len() / channels as usize;
r128.add_frames_f64(data).unwrap();
- expected_ts += gst::ClockTime::from_seconds(data.len() as u64 / channels as u64) / 192_000;
+ expected_ts += (data.len() as u64 / channels as u64).seconds() / 192_000;
}
assert_eq!(
diff --git a/generic/fmp4/examples/hls_live.rs b/generic/fmp4/examples/hls_live.rs
index 624a317a..f29ec157 100644
--- a/generic/fmp4/examples/hls_live.rs
+++ b/generic/fmp4/examples/hls_live.rs
@@ -445,7 +445,7 @@ impl VideoStream {
enc.set_property("bframes", 0u32);
enc.set_property("bitrate", self.bitrate as u32 / 1000u32);
enc.set_property_from_str("tune", "zerolatency");
- mux.set_property("fragment-duration", gst::ClockTime::from_mseconds(2500));
+ mux.set_property("fragment-duration", 2500.mseconds());
mux.set_property_from_str("header-update-mode", "update");
mux.set_property("write-mehd", true);
@@ -477,7 +477,7 @@ impl AudioStream {
src.set_property("is-live", true);
src.set_property_from_str("wave", &self.wave);
- mux.set_property("fragment-duration", gst::ClockTime::from_mseconds(2500));
+ mux.set_property("fragment-duration", 2500.mseconds());
mux.set_property_from_str("header-update-mode", "update");
mux.set_property("write-mehd", true);
diff --git a/generic/fmp4/examples/hls_vod.rs b/generic/fmp4/examples/hls_vod.rs
index c818d9d6..730c5a6f 100644
--- a/generic/fmp4/examples/hls_vod.rs
+++ b/generic/fmp4/examples/hls_vod.rs
@@ -339,7 +339,7 @@ impl VideoStream {
src.set_property("num-buffers", 300);
enc.set_property("bframes", 0u32);
enc.set_property("bitrate", self.bitrate as u32 / 1000u32);
- mux.set_property("fragment-duration", gst::ClockTime::from_mseconds(2500));
+ mux.set_property("fragment-duration", 2500.mseconds());
mux.set_property_from_str("header-update-mode", "update");
mux.set_property("write-mehd", true);
@@ -378,7 +378,7 @@ impl AudioStream {
gst_audio::AudioCapsBuilder::new().rate(44100).build(),
);
- mux.set_property("fragment-duration", gst::ClockTime::from_mseconds(2500));
+ mux.set_property("fragment-duration", 2500.mseconds());
mux.set_property_from_str("header-update-mode", "update");
mux.set_property("write-mehd", true);
diff --git a/generic/fmp4/src/fmp4mux/boxes.rs b/generic/fmp4/src/fmp4mux/boxes.rs
index b82507d7..9b69fb36 100644
--- a/generic/fmp4/src/fmp4mux/boxes.rs
+++ b/generic/fmp4/src/fmp4mux/boxes.rs
@@ -459,7 +459,8 @@ fn caps_to_timescale(caps: &gst::CapsRef) -> u32 {
}
if fps.denom() != 1 && fps.denom() != 1001 {
- if let Some(fps) = gst::ClockTime::from_nseconds(fps.denom() as u64)
+ if let Some(fps) = (fps.denom() as u64)
+ .nseconds()
.mul_div_round(1_000_000_000, fps.numer() as u64)
.and_then(gst_video::guess_framerate)
{
diff --git a/generic/fmp4/src/fmp4mux/imp.rs b/generic/fmp4/src/fmp4mux/imp.rs
index 7433a1dd..8d60bf85 100644
--- a/generic/fmp4/src/fmp4mux/imp.rs
+++ b/generic/fmp4/src/fmp4mux/imp.rs
@@ -45,8 +45,7 @@ fn get_utc_time_from_buffer(buffer: &gst::BufferRef) -> Option<gst::ClockTime> {
if meta.reference().can_intersect(&UNIX_CAPS) {
Some(meta.timestamp())
} else if meta.reference().can_intersect(&NTP_CAPS) {
- meta.timestamp()
- .checked_sub(gst::ClockTime::from_seconds(NTP_UNIX_OFFSET))
+ meta.timestamp().checked_sub(NTP_UNIX_OFFSET.seconds())
} else {
None
}
@@ -913,13 +912,11 @@ impl FMP4Mux {
let calculate_pts = |buffer: &Buffer| -> gst::ClockTime {
let composition_time_offset = buffer.composition_time_offset.unwrap_or(0);
if composition_time_offset > 0 {
- buffer.timestamp + gst::ClockTime::from_nseconds(composition_time_offset as u64)
+ buffer.timestamp + (composition_time_offset as u64).nseconds()
} else {
buffer
.timestamp
- .checked_sub(gst::ClockTime::from_nseconds(
- (-composition_time_offset) as u64,
- ))
+ .checked_sub(((-composition_time_offset) as u64).nseconds())
.unwrap()
}
};
@@ -957,13 +954,11 @@ impl FMP4Mux {
};
let buffer_utc_time = if buffer_pts_diff >= 0 {
utc_time
- .checked_sub(gst::ClockTime::from_nseconds(buffer_pts_diff as u64))
+ .checked_sub((buffer_pts_diff as u64).nseconds())
.unwrap()
} else {
utc_time
- .checked_add(gst::ClockTime::from_nseconds(
- (-buffer_pts_diff) as u64,
- ))
+ .checked_add(((-buffer_pts_diff) as u64).nseconds())
.unwrap()
};
@@ -1035,15 +1030,11 @@ impl FMP4Mux {
if let Some(composition_time_offset) = buffer.composition_time_offset {
if composition_time_offset >= 0 {
utc_time
- .checked_sub(gst::ClockTime::from_nseconds(
- composition_time_offset as u64,
- ))
+ .checked_sub((composition_time_offset as u64).nseconds())
.unwrap()
} else {
utc_time
- .checked_add(gst::ClockTime::from_nseconds(
- (-composition_time_offset) as u64,
- ))
+ .checked_add(((-composition_time_offset) as u64).nseconds())
.unwrap()
}
} else {
@@ -2122,7 +2113,7 @@ impl AggregatorImpl for FMP4Mux {
gst::StreamError::Format,
["Longer GOPs than fragment duration"]
);
- state.timeout_delay += gst::ClockTime::from_seconds(1);
+ state.timeout_delay += 1.seconds();
drop(state);
for (sinkpad, event) in upstream_events {
diff --git a/generic/fmp4/tests/tests.rs b/generic/fmp4/tests/tests.rs
index bf44643f..073b6ae0 100644
--- a/generic/fmp4/tests/tests.rs
+++ b/generic/fmp4/tests/tests.rs
@@ -28,7 +28,7 @@ fn test_buffer_flags_single_stream(cmaf: bool) {
// 5s fragment duration
h.element()
.unwrap()
- .set_property("fragment-duration", gst::ClockTime::from_seconds(5));
+ .set_property("fragment-duration", 5.seconds());
h.set_src_caps(
gst::Caps::builder("video/x-h264")
@@ -45,7 +45,7 @@ fn test_buffer_flags_single_stream(cmaf: bool) {
let output_offset = if cmaf {
gst::ClockTime::ZERO
} else {
- gst::ClockTime::from_seconds(60 * 60 * 1000)
+ (60 * 60 * 1000).seconds()
};
// Push 7 buffers of 1s each, 1st and 6 buffer without DELTA_UNIT flag
@@ -53,8 +53,8 @@ fn test_buffer_flags_single_stream(cmaf: bool) {
let mut buffer = gst::Buffer::with_size(1).unwrap();
{
let buffer = buffer.get_mut().unwrap();
- buffer.set_pts(gst::ClockTime::from_seconds(i));
- buffer.set_dts(gst::ClockTime::from_seconds(i));
+ buffer.set_pts(i.seconds());
+ buffer.set_dts(i.seconds());
buffer.set_duration(gst::ClockTime::SECOND);
if i != 0 && i != 5 {
buffer.set_flags(gst::BufferFlags::DELTA_UNIT);
@@ -76,7 +76,7 @@ fn test_buffer_flags_single_stream(cmaf: bool) {
assert_eq!(
gst_video::UpstreamForceKeyUnitEvent::parse(&ev).unwrap(),
gst_video::UpstreamForceKeyUnitEvent {
- running_time: Some(gst::ClockTime::from_seconds(5)),
+ running_time: Some(5.seconds()),
all_headers: true,
count: 0
}
@@ -102,10 +102,7 @@ fn test_buffer_flags_single_stream(cmaf: bool) {
fragment_header.dts(),
Some(gst::ClockTime::ZERO + output_offset)
);
- assert_eq!(
- fragment_header.duration(),
- Some(gst::ClockTime::from_seconds(5))
- );
+ assert_eq!(fragment_header.duration(), Some(5.seconds()));
for i in 0..5 {
let buffer = h.pull().unwrap();
@@ -117,14 +114,8 @@ fn test_buffer_flags_single_stream(cmaf: bool) {
} else {
assert_eq!(buffer.flags(), gst::BufferFlags::DELTA_UNIT);
}
- assert_eq!(
- buffer.pts(),
- Some(gst::ClockTime::from_seconds(i) + output_offset)
- );
- assert_eq!(
- buffer.dts(),
- Some(gst::ClockTime::from_seconds(i) + output_offset)
- );
+ assert_eq!(buffer.pts(), Some(i.seconds() + output_offset));
+ assert_eq!(buffer.dts(), Some(i.seconds() + output_offset));
assert_eq!(buffer.duration(), Some(gst::ClockTime::SECOND));
}
@@ -132,18 +123,9 @@ fn test_buffer_flags_single_stream(cmaf: bool) {
let fragment_header = h.pull().unwrap();
assert_eq!(fragment_header.flags(), gst::BufferFlags::HEADER);
- assert_eq!(
- fragment_header.pts(),
- Some(gst::ClockTime::from_seconds(5) + output_offset)
- );
- assert_eq!(
- fragment_header.dts(),
- Some(gst::ClockTime::from_seconds(5) + output_offset)
- );
- assert_eq!(
- fragment_header.duration(),
- Some(gst::ClockTime::from_seconds(2))
- );
+ assert_eq!(fragment_header.pts(), Some(5.seconds() + output_offset));
+ assert_eq!(fragment_header.dts(), Some(5.seconds() + output_offset));
+ assert_eq!(fragment_header.duration(), Some(2.seconds()));
for i in 5..7 {
let buffer = h.pull().unwrap();
@@ -155,14 +137,8 @@ fn test_buffer_flags_single_stream(cmaf: bool) {
} else {
assert_eq!(buffer.flags(), gst::BufferFlags::DELTA_UNIT);
}
- assert_eq!(
- buffer.pts(),
- Some(gst::ClockTime::from_seconds(i) + output_offset)
- );
- assert_eq!(
- buffer.dts(),
- Some(gst::ClockTime::from_seconds(i) + output_offset)
- );
+ assert_eq!(buffer.pts(), Some(i.seconds() + output_offset));
+ assert_eq!(buffer.dts(), Some(i.seconds() + output_offset));
assert_eq!(buffer.duration(), Some(gst::ClockTime::SECOND));
}
@@ -200,7 +176,7 @@ fn test_buffer_flags_multi_stream() {
// 5s fragment duration
h1.element()
.unwrap()
- .set_property("fragment-duration", gst::ClockTime::from_seconds(5));
+ .set_property("fragment-duration", 5.seconds());
h1.set_src_caps(
gst::Caps::builder("video/x-h264")
@@ -231,15 +207,15 @@ fn test_buffer_flags_multi_stream() {
);
h2.play();
- let output_offset = gst::ClockTime::from_seconds(60 * 60 * 1000);
+ let output_offset = (60 * 60 * 1000).seconds();
// Push 7 buffers of 1s each, 1st and last buffer without DELTA_UNIT flag
for i in 0..7 {
let mut buffer = gst::Buffer::with_size(1).unwrap();
{
let buffer = buffer.get_mut().unwrap();
- buffer.set_pts(gst::ClockTime::from_seconds(i));
- buffer.set_dts(gst::ClockTime::from_seconds(i));
+ buffer.set_pts(i.seconds());
+ buffer.set_dts(i.seconds());
buffer.set_duration(gst::ClockTime::SECOND);
if i != 0 && i != 5 {
buffer.set_flags(gst::BufferFlags::DELTA_UNIT);
@@ -250,8 +226,8 @@ fn test_buffer_flags_multi_stream() {
let mut buffer = gst::Buffer::with_size(1).unwrap();
{
let buffer = buffer.get_mut().unwrap();
- buffer.set_pts(gst::ClockTime::from_seconds(i));
- buffer.set_dts(gst::ClockTime::from_seconds(i));
+ buffer.set_pts(i.seconds());
+ buffer.set_dts(i.seconds());
buffer.set_duration(gst::ClockTime::SECOND);
}
assert_eq!(h2.push(buffer), Ok(gst::FlowSuccess::Ok));
@@ -270,7 +246,7 @@ fn test_buffer_flags_multi_stream() {
assert_eq!(
gst_video::UpstreamForceKeyUnitEvent::parse(&ev).unwrap(),
gst_video::UpstreamForceKeyUnitEvent {
- running_time: Some(gst::ClockTime::from_seconds(5)),
+ running_time: Some(5.seconds()),
all_headers: true,
count: 0
}
@@ -289,7 +265,7 @@ fn test_buffer_flags_multi_stream() {
assert_eq!(
gst_video::UpstreamForceKeyUnitEvent::parse(&ev).unwrap(),
gst_video::UpstreamForceKeyUnitEvent {
- running_time: Some(gst::ClockTime::from_seconds(5)),
+ running_time: Some(5.seconds()),
all_headers: true,
count: 0
}
@@ -315,10 +291,7 @@ fn test_buffer_flags_multi_stream() {
fragment_header.dts(),
Some(gst::ClockTime::ZERO + output_offset)
);
- assert_eq!(
- fragment_header.duration(),
- Some(gst::ClockTime::from_seconds(5))
- );
+ assert_eq!(fragment_header.duration(), Some(5.seconds()));
for i in 0..5 {
for j in 0..2 {
@@ -332,16 +305,10 @@ fn test_buffer_flags_multi_stream() {
assert_eq!(buffer.flags(), gst::BufferFlags::DELTA_UNIT);
}
- assert_eq!(
- buffer.pts(),
- Some(gst::ClockTime::from_seconds(i) + output_offset)
- );
+ assert_eq!(buffer.pts(), Some(i.seconds() + output_offset));
if j == 0 {
- assert_eq!(
- buffer.dts(),
- Some(gst::ClockTime::from_seconds(i) + output_offset)
- );
+ assert_eq!(buffer.dts(), Some(i.seconds() + output_offset));
} else {
assert!(buffer.dts().is_none());
}
@@ -354,18 +321,9 @@ fn test_buffer_flags_multi_stream() {
let fragment_header = h1.pull().unwrap();
assert_eq!(fragment_header.flags(), gst::BufferFlags::HEADER);
- assert_eq!(
- fragment_header.pts(),
- Some(gst::ClockTime::from_seconds(5) + output_offset)
- );
- assert_eq!(
- fragment_header.dts(),
- Some(gst::ClockTime::from_seconds(5) + output_offset)
- );
- assert_eq!(
- fragment_header.duration(),
- Some(gst::ClockTime::from_seconds(2))
- );
+ assert_eq!(fragment_header.pts(), Some(5.seconds() + output_offset));
+ assert_eq!(fragment_header.dts(), Some(5.seconds() + output_offset));
+ assert_eq!(fragment_header.duration(), Some(2.seconds()));
for i in 5..7 {
for j in 0..2 {
@@ -378,15 +336,9 @@ fn test_buffer_flags_multi_stream() {
} else {
assert_eq!(buffer.flags(), gst::BufferFlags::DELTA_UNIT);
}
- assert_eq!(
- buffer.pts(),
- Some(gst::ClockTime::from_seconds(i) + output_offset)
- );
+ assert_eq!(buffer.pts(), Some(i.seconds() + output_offset));
if j == 0 {
- assert_eq!(
- buffer.dts(),
- Some(gst::ClockTime::from_seconds(i) + output_offset)
- );
+ assert_eq!(buffer.dts(), Some(i.seconds() + output_offset));
} else {
assert!(buffer.dts().is_none());
}
@@ -416,7 +368,7 @@ fn test_live_timeout() {
// 5s fragment duration
h1.element()
.unwrap()
- .set_property("fragment-duration", gst::ClockTime::from_seconds(5));
+ .set_property("fragment-duration", 5.seconds());
h1.set_src_caps(
gst::Caps::builder("video/x-h264")
@@ -447,15 +399,15 @@ fn test_live_timeout() {
);
h2.play();
- let output_offset = gst::ClockTime::from_seconds(60 * 60 * 1000);
+ let output_offset = (60 * 60 * 1000).seconds();
// Push 7 buffers of 1s each, 1st and last buffer without DELTA_UNIT flag
for i in 0..7 {
let mut buffer = gst::Buffer::with_size(1).unwrap();
{
let buffer = buffer.get_mut().unwrap();
- buffer.set_pts(gst::ClockTime::from_seconds(i));
- buffer.set_dts(gst::ClockTime::from_seconds(i));
+ buffer.set_pts(i.seconds());
+ buffer.set_dts(i.seconds());
buffer.set_duration(gst::ClockTime::SECOND);
if i != 0 && i != 5 {
buffer.set_flags(gst::BufferFlags::DELTA_UNIT);
@@ -470,8 +422,8 @@ fn test_live_timeout() {
let mut buffer = gst::Buffer::with_size(1).unwrap();
{
let buffer = buffer.get_mut().unwrap();
- buffer.set_pts(gst::ClockTime::from_seconds(i));
- buffer.set_dts(gst::ClockTime::from_seconds(i));
+ buffer.set_pts(i.seconds());
+ buffer.set_dts(i.seconds());
buffer.set_duration(gst::ClockTime::SECOND);
}
assert_eq!(h2.push(buffer), Ok(gst::FlowSuccess::Ok));
@@ -491,7 +443,7 @@ fn test_live_timeout() {
assert_eq!(
gst_video::UpstreamForceKeyUnitEvent::parse(&ev).unwrap(),
gst_video::UpstreamForceKeyUnitEvent {
- running_time: Some(gst::ClockTime::from_seconds(5)),
+ running_time: Some(5.seconds()),
all_headers: true,
count: 0
}
@@ -510,7 +462,7 @@ fn test_live_timeout() {
assert_eq!(
gst_video::UpstreamForceKeyUnitEvent::parse(&ev).unwrap(),
gst_video::UpstreamForceKeyUnitEvent {
- running_time: Some(gst::ClockTime::from_seconds(5)),
+ running_time: Some(5.seconds()),
all_headers: true,
count: 0
}
@@ -519,7 +471,7 @@ fn test_live_timeout() {
}
// Advance time and crank the clock: this should bring us to the end of the first fragment
- h1.set_time(gst::ClockTime::from_seconds(5)).unwrap();
+ h1.set_time(5.seconds()).unwrap();
h1.crank_single_clock_wait().unwrap();
let header = h1.pull().unwrap();
@@ -540,10 +492,7 @@ fn test_live_timeout() {
fragment_header.dts(),
Some(gst::ClockTime::ZERO + output_offset)
);
- assert_eq!(
- fragment_header.duration(),
- Some(gst::ClockTime::from_seconds(5))
- );
+ assert_eq!(fragment_header.duration(), Some(5.seconds()));
for i in 0..5 {
for j in 0..2 {
@@ -567,16 +516,10 @@ fn test_live_timeout() {
assert_eq!(buffer.flags(), gst::BufferFlags::DELTA_UNIT);
}
- assert_eq!(
- buffer.pts(),
- Some(gst::ClockTime::from_seconds(i) + output_offset)
- );
+ assert_eq!(buffer.pts(), Some(i.seconds() + output_offset));
if j == 0 {
- assert_eq!(
- buffer.dts(),
- Some(gst::ClockTime::from_seconds(i) + output_offset)
- );
+ assert_eq!(buffer.dts(), Some(i.seconds() + output_offset));
} else {
assert!(buffer.dts().is_none());
}
@@ -589,18 +532,9 @@ fn test_live_timeout() {
let fragment_header = h1.pull().unwrap();
assert_eq!(fragment_header.flags(), gst::BufferFlags::HEADER);
- assert_eq!(
- fragment_header.pts(),
- Some(gst::ClockTime::from_seconds(5) + output_offset)
- );
- assert_eq!(
- fragment_header.dts(),
- Some(gst::ClockTime::from_seconds(5) + output_offset)
- );
- assert_eq!(
- fragment_header.duration(),
- Some(gst::ClockTime::from_seconds(2))
- );
+ assert_eq!(fragment_header.pts(), Some(5.seconds() + output_offset));
+ assert_eq!(fragment_header.dts(), Some(5.seconds() + output_offset));
+ assert_eq!(fragment_header.duration(), Some(2.seconds()));
for i in 5..7 {
for j in 0..2 {
@@ -618,15 +552,9 @@ fn test_live_timeout() {
} else {
assert_eq!(buffer.flags(), gst::BufferFlags::DELTA_UNIT);
}
- assert_eq!(
- buffer.pts(),
- Some(gst::ClockTime::from_seconds(i) + output_offset)
- );
+ assert_eq!(buffer.pts(), Some(i.seconds() + output_offset));
if j == 0 {
- assert_eq!(
- buffer.dts(),
- Some(gst::ClockTime::from_seconds(i) + output_offset)
- );
+ assert_eq!(buffer.dts(), Some(i.seconds() + output_offset));
} else {
assert!(buffer.dts().is_none());
}
@@ -656,7 +584,7 @@ fn test_gap_events() {
// 5s fragment duration
h1.element()
.unwrap()
- .set_property("fragment-duration", gst::ClockTime::from_seconds(5));
+ .set_property("fragment-duration", 5.seconds());
h1.set_src_caps(
gst::Caps::builder("video/x-h264")
@@ -687,15 +615,15 @@ fn test_gap_events() {
);
h2.play();
- let output_offset = gst::ClockTime::from_seconds(60 * 60 * 1000);
+ let output_offset = (60 * 60 * 1000).seconds();
// Push 7 buffers of 1s each, 1st and last buffer without DELTA_UNIT flag
for i in 0..7 {
let mut buffer = gst::Buffer::with_size(1).unwrap();
{
let buffer = buffer.get_mut().unwrap();
- buffer.set_pts(gst::ClockTime::from_seconds(i));
- buffer.set_dts(gst::ClockTime::from_seconds(i));
+ buffer.set_pts(i.seconds());
+ buffer.set_dts(i.seconds());
buffer.set_duration(gst::ClockTime::SECOND);
if i != 0 && i != 5 {
buffer.set_flags(gst::BufferFlags::DELTA_UNIT);
@@ -705,7 +633,7 @@ fn test_gap_events() {
// Replace buffer 3 and 6 with a gap event
if i == 3 || i == 6 {
- let ev = gst::event::Gap::builder(gst::ClockTime::from_seconds(i))
+ let ev = gst::event::Gap::builder(i.seconds())
.duration(gst::ClockTime::SECOND)
.build();
assert!(h2.push_event(ev));
@@ -713,8 +641,8 @@ fn test_gap_events() {
let mut buffer = gst::Buffer::with_size(1).unwrap();
{
let buffer = buffer.get_mut().unwrap();
- buffer.set_pts(gst::ClockTime::from_seconds(i));
- buffer.set_dts(gst::ClockTime::from_seconds(i));
+ buffer.set_pts(i.seconds());
+ buffer.set_dts(i.seconds());
buffer.set_duration(gst::ClockTime::SECOND);
}
assert_eq!(h2.push(buffer), Ok(gst::FlowSuccess::Ok));
@@ -734,7 +662,7 @@ fn test_gap_events() {
assert_eq!(
gst_video::UpstreamForceKeyUnitEvent::parse(&ev).unwrap(),
gst_video::UpstreamForceKeyUnitEvent {
- running_time: Some(gst::ClockTime::from_seconds(5)),
+ running_time: Some(5.seconds()),
all_headers: true,
count: 0
}
@@ -753,7 +681,7 @@ fn test_gap_events() {
assert_eq!(
gst_video::UpstreamForceKeyUnitEvent::parse(&ev).unwrap(),
gst_video::UpstreamForceKeyUnitEvent {
- running_time: Some(gst::ClockTime::from_seconds(5)),
+ running_time: Some(5.seconds()),
all_headers: true,
count: 0
}
@@ -762,7 +690,7 @@ fn test_gap_events() {
}
// Advance time and crank the clock: this should bring us to the end of the first fragment
- h1.set_time(gst::ClockTime::from_seconds(5)).unwrap();
+ h1.set_time(5.seconds()).unwrap();
h1.crank_single_clock_wait().unwrap();
let header = h1.pull().unwrap();
@@ -783,10 +711,7 @@ fn test_gap_events() {
fragment_header.dts(),
Some(gst::ClockTime::ZERO + output_offset)
);
- assert_eq!(
- fragment_header.duration(),
- Some(gst::ClockTime::from_seconds(5))
- );
+ assert_eq!(fragment_header.duration(), Some(5.seconds()));
for i in 0..5 {
for j in 0..2 {
@@ -805,16 +730,10 @@ fn test_gap_events() {
assert_eq!(buffer.flags(), gst::BufferFlags::DELTA_UNIT);
}
- assert_eq!(
- buffer.pts(),
- Some(gst::ClockTime::from_seconds(i) + output_offset)
- );
+ assert_eq!(buffer.pts(), Some(i.seconds() + output_offset));
if j == 0 {
- assert_eq!(
- buffer.dts(),
- Some(gst::ClockTime::from_seconds(i) + output_offset)
- );
+ assert_eq!(buffer.dts(), Some(i.seconds() + output_offset));
} else {
assert!(buffer.dts().is_none());
}
@@ -827,18 +746,9 @@ fn test_gap_events() {
let fragment_header = h1.pull().unwrap();
assert_eq!(fragment_header.flags(), gst::BufferFlags::HEADER);
- assert_eq!(
- fragment_header.pts(),
- Some(gst::ClockTime::from_seconds(5) + output_offset)
- );
- assert_eq!(
- fragment_header.dts(),
- Some(gst::ClockTime::from_seconds(5) + output_offset)
- );
- assert_eq!(
- fragment_header.duration(),
- Some(gst::ClockTime::from_seconds(2))
- );
+ assert_eq!(fragment_header.pts(), Some(5.seconds() + output_offset));
+ assert_eq!(fragment_header.dts(), Some(5.seconds() + output_offset));
+ assert_eq!(fragment_header.duration(), Some(2.seconds()));
for i in 5..7 {
for j in 0..2 {
@@ -856,15 +766,9 @@ fn test_gap_events() {
} else {
assert_eq!(buffer.flags(), gst::BufferFlags::DELTA_UNIT);
}
- assert_eq!(
- buffer.pts(),
- Some(gst::ClockTime::from_seconds(i) + output_offset)
- );
+ assert_eq!(buffer.pts(), Some(i.seconds() + output_offset));
if j == 0 {
- assert_eq!(
- buffer.dts(),
- Some(gst::ClockTime::from_seconds(i) + output_offset)
- );
+ assert_eq!(buffer.dts(), Some(i.seconds() + output_offset));
} else {
assert!(buffer.dts().is_none());
}
@@ -891,7 +795,7 @@ fn test_single_stream_short_gops() {
// 5s fragment duration
h.element()
.unwrap()
- .set_property("fragment-duration", gst::ClockTime::from_seconds(5));
+ .set_property("fragment-duration", 5.seconds());
h.set_src_caps(
gst::Caps::builder("video/x-h264")
@@ -905,15 +809,15 @@ fn test_single_stream_short_gops() {
);
h.play();
- let output_offset = gst::ClockTime::from_seconds(60 * 60 * 1000);
+ let output_offset = (60 * 60 * 1000).seconds();
// Push 8 buffers of 1s each, 1st, 4th and 7th buffer without DELTA_UNIT flag
for i in 0..8 {
let mut buffer = gst::Buffer::with_size(1).unwrap();
{
let buffer = buffer.get_mut().unwrap();
- buffer.set_pts(gst::ClockTime::from_seconds(i));
- buffer.set_dts(gst::ClockTime::from_seconds(i));
+ buffer.set_pts(i.seconds());
+ buffer.set_dts(i.seconds());
buffer.set_duration(gst::ClockTime::SECOND);
if i != 0 && i != 3 && i != 6 {
buffer.set_flags(gst::BufferFlags::DELTA_UNIT);
@@ -931,11 +835,7 @@ fn test_single_stream_short_gops() {
}
};
- let fku_time = if i == 2 {
- gst::ClockTime::from_seconds(5)
- } else {
- gst::ClockTime::from_seconds(8)
- };
+ let fku_time = if i == 2 { 5.seconds() } else { 8.seconds() };
assert_eq!(ev.type_(), gst::EventType::CustomUpstream);
assert_eq!(
@@ -967,10 +867,7 @@ fn test_single_stream_short_gops() {
fragment_header.dts(),
Some(gst::ClockTime::ZERO + output_offset)
);
- assert_eq!(
- fragment_header.duration(),
- Some(gst::ClockTime::from_seconds(3))
- );
+ assert_eq!(fragment_header.duration(), Some(3.seconds()));
for i in 0..3 {
let buffer = h.pull().unwrap();
@@ -982,14 +879,8 @@ fn test_single_stream_short_gops() {
} else {
assert_eq!(buffer.flags(), gst::BufferFlags::DELTA_UNIT);
}
- assert_eq!(
- buffer.pts(),
- Some(gst::ClockTime::from_seconds(i) + output_offset)
- );
- assert_eq!(
- buffer.dts(),
- Some(gst::ClockTime::from_seconds(i) + output_offset)
- );
+ assert_eq!(buffer.pts(), Some(i.seconds() + output_offset));
+ assert_eq!(buffer.dts(), Some(i.seconds() + output_offset));
assert_eq!(buffer.duration(), Some(gst::ClockTime::SECOND));
}
@@ -997,18 +888,9 @@ fn test_single_stream_short_gops() {
let fragment_header = h.pull().unwrap();
assert_eq!(fragment_header.flags(), gst::BufferFlags::HEADER);
- assert_eq!(
- fragment_header.pts(),
- Some(gst::ClockTime::from_seconds(3) + output_offset)
- );
- assert_eq!(
- fragment_header.dts(),
- Some(gst::ClockTime::from_seconds(3) + output_offset)
- );
- assert_eq!(
- fragment_header.duration(),
- Some(gst::ClockTime::from_seconds(5))
- );
+ assert_eq!(fragment_header.pts(), Some(3.seconds() + output_offset));
+ assert_eq!(fragment_header.dts(), Some(3.seconds() + output_offset));
+ assert_eq!(fragment_header.duration(), Some(5.seconds()));
for i in 3..8 {
let buffer = h.pull().unwrap();
@@ -1020,14 +902,8 @@ fn test_single_stream_short_gops() {
} else {
assert_eq!(buffer.flags(), gst::BufferFlags::DELTA_UNIT);
}
- assert_eq!(
- buffer.pts(),
- Some(gst::ClockTime::from_seconds(i) + output_offset)
- );
- assert_eq!(
- buffer.dts(),
- Some(gst::ClockTime::from_seconds(i) + output_offset)
- );
+ assert_eq!(buffer.pts(), Some(i.seconds() + output_offset));
+ assert_eq!(buffer.dts(), Some(i.seconds() + output_offset));
assert_eq!(buffer.duration(), Some(gst::ClockTime::SECOND));
}
@@ -1050,7 +926,7 @@ fn test_single_stream_long_gops() {
// 5s fragment duration
h.element()
.unwrap()
- .set_property("fragment-duration", gst::ClockTime::from_seconds(5));
+ .set_property("fragment-duration", 5.seconds());
h.set_src_caps(
gst::Caps::builder("video/x-h264")
@@ -1064,15 +940,15 @@ fn test_single_stream_long_gops() {
);
h.play();
- let output_offset = gst::ClockTime::from_seconds(60 * 60 * 1000);
+ let output_offset = (60 * 60 * 1000).seconds();
// Push 10 buffers of 1s each, 1st and 7th buffer without DELTA_UNIT flag
for i in 0..10 {
let mut buffer = gst::Buffer::with_size(1).unwrap();
{
let buffer = buffer.get_mut().unwrap();
- buffer.set_pts(gst::ClockTime::from_seconds(i));
- buffer.set_dts(gst::ClockTime::from_seconds(i));
+ buffer.set_pts(i.seconds());
+ buffer.set_dts(i.seconds());
buffer.set_duration(gst::ClockTime::SECOND);
if i != 0 && i != 6 {
buffer.set_flags(gst::BufferFlags::DELTA_UNIT);
@@ -1090,11 +966,7 @@ fn test_single_stream_long_gops() {
}
};
- let fku_time = if i == 2 {
- gst::ClockTime::from_seconds(5)
- } else {
- gst::ClockTime::from_seconds(11)
- };
+ let fku_time = if i == 2 { 5.seconds() } else { 11.seconds() };
assert_eq!(ev.type_(), gst::EventType::CustomUpstream);
assert_eq!(
@@ -1126,10 +998,7 @@ fn test_single_stream_long_gops() {
fragment_header.dts(),
Some(gst::ClockTime::ZERO + output_offset)
);
- assert_eq!(
- fragment_header.duration(),
- Some(gst::ClockTime::from_seconds(6))
- );
+ assert_eq!(fragment_header.duration(), Some(6.seconds()));
for i in 0..6 {
let buffer = h.pull().unwrap();
@@ -1141,14 +1010,8 @@ fn test_single_stream_long_gops() {
} else {
assert_eq!(buffer.flags(), gst::BufferFlags::DELTA_UNIT);
}
- assert_eq!(
- buffer.pts(),
- Some(gst::ClockTime::from_seconds(i) + output_offset)
- );
- assert_eq!(
- buffer.dts(),
- Some(gst::ClockTime::from_seconds(i) + output_offset)
- );
+ assert_eq!(buffer.pts(), Some(i.seconds() + output_offset));
+ assert_eq!(buffer.dts(), Some(i.seconds() + output_offset));
assert_eq!(buffer.duration(), Some(gst::ClockTime::SECOND));
}
@@ -1156,18 +1019,9 @@ fn test_single_stream_long_gops() {
let fragment_header = h.pull().unwrap();
assert_eq!(fragment_header.flags(), gst::BufferFlags::HEADER);
- assert_eq!(
- fragment_header.pts(),
- Some(gst::ClockTime::from_seconds(6) + output_offset)
- );
- assert_eq!(
- fragment_header.dts(),
- Some(gst::ClockTime::from_seconds(6) + output_offset)
- );
- assert_eq!(
- fragment_header.duration(),
- Some(gst::ClockTime::from_seconds(4))
- );
+ assert_eq!(fragment_header.pts(), Some(6.seconds() + output_offset));
+ assert_eq!(fragment_header.dts(), Some(6.seconds() + output_offset));
+ assert_eq!(fragment_header.duration(), Some(4.seconds()));
for i in 6..10 {
let buffer = h.pull().unwrap();
@@ -1179,14 +1033,8 @@ fn test_single_stream_long_gops() {
} else {
assert_eq!(buffer.flags(), gst::BufferFlags::DELTA_UNIT);
}
- assert_eq!(
- buffer.pts(),
- Some(gst::ClockTime::from_seconds(i) + output_offset)
- );
- assert_eq!(
- buffer.dts(),
- Some(gst::ClockTime::from_seconds(i) + output_offset)
- );
+ assert_eq!(buffer.pts(), Some(i.seconds() + output_offset));
+ assert_eq!(buffer.dts(), Some(i.seconds() + output_offset));
assert_eq!(buffer.duration(), Some(gst::ClockTime::SECOND));
}
@@ -1210,7 +1058,7 @@ fn test_buffer_multi_stream_short_gops() {
// 5s fragment duration
h1.element()
.unwrap()
- .set_property("fragment-duration", gst::ClockTime::from_seconds(5));
+ .set_property("fragment-duration", 5.seconds());
h1.set_src_caps(
gst::Caps::builder("video/x-h264")
@@ -1241,15 +1089,15 @@ fn test_buffer_multi_stream_short_gops() {
);
h2.play();
- let output_offset = gst::ClockTime::from_seconds(60 * 60 * 1000);
+ let output_offset = (60 * 60 * 1000).seconds();
// Push 8 buffers of 1s each, 1st, 4th and 7th buffer without DELTA_UNIT flag
for i in 0..8 {
let mut buffer = gst::Buffer::with_size(1).unwrap();
{
let buffer = buffer.get_mut().unwrap();
- buffer.set_pts(gst::ClockTime::from_seconds(i));
- buffer.set_dts(gst::ClockTime::from_seconds(i));
+ buffer.set_pts(i.seconds());
+ buffer.set_dts(i.seconds());
buffer.set_duration(gst::ClockTime::SECOND);
if i != 0 && i != 3 && i != 6 {
buffer.set_flags(gst::BufferFlags::DELTA_UNIT);
@@ -1260,8 +1108,8 @@ fn test_buffer_multi_stream_short_gops() {
let mut buffer = gst::Buffer::with_size(1).unwrap();
{
let buffer = buffer.get_mut().unwrap();
- buffer.set_pts(gst::ClockTime::from_seconds(i));
- buffer.set_dts(gst::ClockTime::from_seconds(i));
+ buffer.set_pts(i.seconds());
+ buffer.set_dts(i.seconds());
buffer.set_duration(gst::ClockTime::SECOND);
}
assert_eq!(h2.push(buffer), Ok(gst::FlowSuccess::Ok));
@@ -1276,11 +1124,7 @@ fn test_buffer_multi_stream_short_gops() {
}
};
- let fku_time = if i == 2 {
- gst::ClockTime::from_seconds(5)
- } else {
- gst::ClockTime::from_seconds(8)
- };
+ let fku_time = if i == 2 { 5.seconds() } else { 8.seconds() };
assert_eq!(ev.type_(), gst::EventType::CustomUpstream);
assert_eq!(
@@ -1331,10 +1175,7 @@ fn test_buffer_multi_stream_short_gops() {
fragment_header.dts(),
Some(gst::ClockTime::ZERO + output_offset)
);
- assert_eq!(
- fragment_header.duration(),
- Some(gst::ClockTime::from_seconds(3))
- );
+ assert_eq!(fragment_header.duration(), Some(3.seconds()));
for i in 0..3 {
for j in 0..2 {
@@ -1348,16 +1189,10 @@ fn test_buffer_multi_stream_short_gops() {
assert_eq!(buffer.flags(), gst::BufferFlags::DELTA_UNIT);
}
- assert_eq!(
- buffer.pts(),
- Some(gst::ClockTime::from_seconds(i) + output_offset)
- );
+ assert_eq!(buffer.pts(), Some(i.seconds() + output_offset));
if j == 0 {
- assert_eq!(
- buffer.dts(),
- Some(gst::ClockTime::from_seconds(i) + output_offset)
- );
+ assert_eq!(buffer.dts(), Some(i.seconds() + output_offset));
} else {
assert!(buffer.dts().is_none());
}
@@ -1370,18 +1205,9 @@ fn test_buffer_multi_stream_short_gops() {
let fragment_header = h1.pull().unwrap();
assert_eq!(fragment_header.flags(), gst::BufferFlags::HEADER);
- assert_eq!(
- fragment_header.pts(),
- Some(gst::ClockTime::from_seconds(3) + output_offset)
- );
- assert_eq!(
- fragment_header.dts(),
- Some(gst::ClockTime::from_seconds(3) + output_offset)
- );
- assert_eq!(
- fragment_header.duration(),
- Some(gst::ClockTime::from_seconds(5))
- );
+ assert_eq!(fragment_header.pts(), Some(3.seconds() + output_offset));
+ assert_eq!(fragment_header.dts(), Some(3.seconds() + output_offset));
+ assert_eq!(fragment_header.duration(), Some(5.seconds()));
for i in 3..8 {
for j in 0..2 {
@@ -1394,15 +1220,9 @@ fn test_buffer_multi_stream_short_gops() {
} else {
assert_eq!(buffer.flags(), gst::BufferFlags::DELTA_UNIT);
}
- assert_eq!(
- buffer.pts(),
- Some(gst::ClockTime::from_seconds(i) + output_offset)
- );
+ assert_eq!(buffer.pts(), Some(i.seconds() + output_offset));
if j == 0 {
- assert_eq!(
- buffer.dts(),
- Some(gst::ClockTime::from_seconds(i) + output_offset)
- );
+ assert_eq!(buffer.dts(), Some(i.seconds() + output_offset));
} else {
assert!(buffer.dts().is_none());
}
diff --git a/generic/sodium/src/decrypter/imp.rs b/generic/sodium/src/decrypter/imp.rs
index f51efd1e..ce9d638e 100644
--- a/generic/sodium/src/decrypter/imp.rs
+++ b/generic/sodium/src/decrypter/imp.rs
@@ -337,7 +337,7 @@ impl Decrypter {
let size = size - total_chunks * box_::MACBYTES as u64;
gst::debug!(CAT, obj: pad, "Setting duration bytes: {}", size);
- q.set(gst::format::Bytes::from_u64(size));
+ q.set(size.bytes());
true
}
diff --git a/generic/sodium/src/encrypter/imp.rs b/generic/sodium/src/encrypter/imp.rs
index ba511f71..fd121c2e 100644
--- a/generic/sodium/src/encrypter/imp.rs
+++ b/generic/sodium/src/encrypter/imp.rs
@@ -314,7 +314,7 @@ impl Encrypter {
let size = size + crate::HEADERS_SIZE as u64;
gst::debug!(CAT, obj: pad, "Setting duration bytes: {}", size);
- q.set(gst::format::Bytes::from_u64(size));
+ q.set(size.bytes());
true
}
diff --git a/generic/sodium/tests/decrypter.rs b/generic/sodium/tests/decrypter.rs
index 2005ade0..3243ffea 100644
--- a/generic/sodium/tests/decrypter.rs
+++ b/generic/sodium/tests/decrypter.rs
@@ -190,8 +190,8 @@ fn test_pull_range() {
// get the seeking capabilities
let (seekable, start, stop) = q.result();
assert!(seekable);
- assert_eq!(start, gst::format::Bytes::ZERO.into());
- assert_eq!(stop, gst::format::Bytes::from_u64(6043).into());
+ assert_eq!(start, 0.bytes().into());
+ assert_eq!(stop, 6043.bytes().into());
// do pulls
let expected_array_1 = [
diff --git a/generic/threadshare/src/jitterbuffer/jitterbuffer.rs b/generic/threadshare/src/jitterbuffer/jitterbuffer.rs
index 97150162..e9df2a2f 100644
--- a/generic/threadshare/src/jitterbuffer/jitterbuffer.rs
+++ b/generic/threadshare/src/jitterbuffer/jitterbuffer.rs
@@ -19,6 +19,8 @@
use super::ffi;
+use gst::prelude::*;
+
use std::ptr;
use glib::translate::*;
@@ -117,7 +119,7 @@ impl RTPJitterBufferItem {
if item.as_ref().dts == gst::ffi::GST_CLOCK_TIME_NONE {
None
} else {
- Some(gst::ClockTime::from_nseconds(item.as_ref().dts))
+ Some(item.as_ref().dts.nseconds())
}
}
}
@@ -128,7 +130,7 @@ impl RTPJitterBufferItem {
if item.as_ref().pts == gst::ffi::GST_CLOCK_TIME_NONE {
None
} else {
- Some(gst::ClockTime::from_nseconds(item.as_ref().pts))
+ Some(item.as_ref().pts.nseconds())
}
}
}
diff --git a/generic/threadshare/src/proxy/imp.rs b/generic/threadshare/src/proxy/imp.rs
index 9cad8078..862e0730 100644
--- a/generic/threadshare/src/proxy/imp.rs
+++ b/generic/threadshare/src/proxy/imp.rs
@@ -1111,8 +1111,7 @@ impl ObjectImpl for ProxySrc {
settings.max_size_bytes = value.get().expect("type checked upstream");
}
"max-size-time" => {
- settings.max_size_time =
- gst::ClockTime::from_nseconds(value.get().expect("type checked upstream"));
+ settings.max_size_time = value.get::<u64>().unwrap().nseconds();
}
"context" => {
settings.context = value
diff --git a/generic/threadshare/src/queue/imp.rs b/generic/threadshare/src/queue/imp.rs
index 32f6f472..93ba22e1 100644
--- a/generic/threadshare/src/queue/imp.rs
+++ b/generic/threadshare/src/queue/imp.rs
@@ -697,8 +697,7 @@ impl ObjectImpl for Queue {
settings.max_size_bytes = value.get().expect("type checked upstream");
}
"max-size-time" => {
- settings.max_size_time =
- gst::ClockTime::from_nseconds(value.get().expect("type checked upstream"));
+ settings.max_size_time = value.get::<u64>().unwrap().nseconds();
}
"context" => {
settings.context = value
diff --git a/generic/threadshare/tests/proxy.rs b/generic/threadshare/tests/proxy.rs
index 5097ccb0..19888919 100644
--- a/generic/threadshare/tests/proxy.rs
+++ b/generic/threadshare/tests/proxy.rs
@@ -74,7 +74,7 @@ fn test_push() {
let mut eos = false;
let bus = pipeline.bus().unwrap();
- while let Some(msg) = bus.timed_pop(5 * gst::ClockTime::SECOND) {
+ while let Some(msg) = bus.timed_pop(5.seconds()) {
use gst::MessageView;
match msg.view() {
MessageView::Eos(..) => {
diff --git a/generic/threadshare/tests/queue.rs b/generic/threadshare/tests/queue.rs
index 49c7c3bd..003412ed 100644
--- a/generic/threadshare/tests/queue.rs
+++ b/generic/threadshare/tests/queue.rs
@@ -68,7 +68,7 @@ fn test_push() {
let mut eos = false;
let bus = pipeline.bus().unwrap();
- while let Some(msg) = bus.timed_pop(5 * gst::ClockTime::SECOND) {
+ while let Some(msg) = bus.timed_pop(5.seconds()) {
use gst::MessageView;
match msg.view() {
MessageView::Eos(..) => {
diff --git a/generic/threadshare/tests/tcpclientsrc.rs b/generic/threadshare/tests/tcpclientsrc.rs
index d76004d3..a0d3766e 100644
--- a/generic/threadshare/tests/tcpclientsrc.rs
+++ b/generic/threadshare/tests/tcpclientsrc.rs
@@ -92,7 +92,7 @@ fn test_push() {
let mut eos = false;
let bus = pipeline.bus().unwrap();
- while let Some(msg) = bus.timed_pop(5 * gst::ClockTime::SECOND) {
+ while let Some(msg) = bus.timed_pop(5.seconds()) {
use gst::MessageView;
match msg.view() {
MessageView::Eos(..) => {
diff --git a/net/aws/src/aws_transcribe_parse/imp.rs b/net/aws/src/aws_transcribe_parse/imp.rs
index 12dc1352..18cde1fa 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 247f7812..49eaf56c 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 1b305d09..b62c63ab 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 f2ec7492..f0aaf1fe 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 90484bac..ac88a762 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 b919eee6..414ac674 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 d69ca15e..3833d2b9 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 f8cc4a6b..b12f76a9 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 339d6d3a..f1bf9e8f 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 8595c307..0985e320 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 5c7c2825..aa45f954 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,
diff --git a/text/json/tests/json.rs b/text/json/tests/json.rs
index 1bfe702a..759649b6 100644
--- a/text/json/tests/json.rs
+++ b/text/json/tests/json.rs
@@ -8,6 +8,8 @@
#![allow(clippy::single_match)]
+use gst::prelude::*;
+
fn init() {
use std::sync::Once;
static INIT: Once = Once::new();
@@ -31,8 +33,8 @@ fn test_enc() {
let buf = {
let mut buf = gst::Buffer::from_mut_slice(Vec::from(input));
let buf_ref = buf.get_mut().unwrap();
- buf_ref.set_pts(gst::ClockTime::from_seconds(0));
- buf_ref.set_duration(gst::ClockTime::from_seconds(2));
+ buf_ref.set_pts(gst::ClockTime::ZERO);
+ buf_ref.set_duration(2.seconds());
buf
};
@@ -47,7 +49,7 @@ fn test_enc() {
let buf = h.pull().expect("Couldn't pull buffer");
assert_eq!(buf.pts(), Some(gst::ClockTime::ZERO));
- assert_eq!(buf.duration(), Some(2 * gst::ClockTime::SECOND));
+ assert_eq!(buf.duration(), Some(2.seconds()));
let map = buf.map_readable().expect("Couldn't map buffer readable");
assert_eq!(
std::str::from_utf8(map.as_ref()),
@@ -93,6 +95,6 @@ fn test_parse() {
let buf = h.pull().expect("Couldn't pull buffer");
let map = buf.map_readable().expect("Couldn't map buffer readable");
assert_eq!(buf.pts(), Some(gst::ClockTime::ZERO));
- assert_eq!(buf.duration(), Some(2 * gst::ClockTime::SECOND));
+ assert_eq!(buf.duration(), Some(2.seconds()));
assert_eq!(std::str::from_utf8(map.as_ref()), Ok("{\"foo\":42}"));
}
diff --git a/text/regex/tests/regex.rs b/text/regex/tests/regex.rs
index e9c2d04a..25871c4b 100644
--- a/text/regex/tests/regex.rs
+++ b/text/regex/tests/regex.rs
@@ -46,8 +46,8 @@ fn test_replace_all() {
let buf = {
let mut buf = gst::Buffer::from_mut_slice(Vec::from(&input[..]));
let buf_ref = buf.get_mut().unwrap();
- buf_ref.set_pts(gst::ClockTime::from_seconds(0));
- buf_ref.set_duration(gst::ClockTime::from_seconds(2));
+ buf_ref.set_pts(gst::ClockTime::ZERO);
+ buf_ref.set_duration(2.seconds());
buf
};
@@ -56,7 +56,7 @@ fn test_replace_all() {
let buf = h.pull().expect("Couldn't pull buffer");
assert_eq!(buf.pts(), Some(gst::ClockTime::ZERO));
- assert_eq!(buf.duration(), Some(2 * gst::ClockTime::SECOND));
+ assert_eq!(buf.duration(), Some(2.seconds()));
let map = buf.map_readable().expect("Couldn't map buffer readable");
diff --git a/text/wrap/src/gsttextwrap/imp.rs b/text/wrap/src/gsttextwrap/imp.rs
index c1aab864..a6bfaa62 100644
--- a/text/wrap/src/gsttextwrap/imp.rs
+++ b/text/wrap/src/gsttextwrap/imp.rs
@@ -509,8 +509,7 @@ impl ObjectImpl for TextWrap {
"accumulate-time" => {
let mut settings = self.settings.lock().unwrap();
let old_accumulate_time = settings.accumulate_time;
- settings.accumulate_time =
- gst::ClockTime::from_nseconds(value.get().expect("type checked upstream"));
+ settings.accumulate_time = value.get::<u64>().unwrap().nseconds();
if settings.accumulate_time != old_accumulate_time {
gst::debug!(
CAT,
diff --git a/text/wrap/tests/textwrap.rs b/text/wrap/tests/textwrap.rs
index a385f89e..9adf1cc4 100644
--- a/text/wrap/tests/textwrap.rs
+++ b/text/wrap/tests/textwrap.rs
@@ -38,8 +38,8 @@ fn test_columns() {
let buf = {
let mut buf = gst::Buffer::from_mut_slice(Vec::from(&input[..]));
let buf_ref = buf.get_mut().unwrap();
- buf_ref.set_pts(gst::ClockTime::from_seconds(0));
- buf_ref.set_duration(gst::ClockTime::from_seconds(2));
+ buf_ref.set_pts(gst::ClockTime::ZERO);
+ buf_ref.set_duration(2.seconds());
buf
};
@@ -48,7 +48,7 @@ fn test_columns() {
let buf = h.pull().expect("Couldn't pull buffer");
assert_eq!(buf.pts(), Some(gst::ClockTime::ZERO));
- assert_eq!(buf.duration(), Some(2 * gst::ClockTime::SECOND));
+ assert_eq!(buf.duration(), Some(2.seconds()));
let map = buf.map_readable().expect("Couldn't map buffer readable");
@@ -77,8 +77,8 @@ fn test_lines() {
let buf = {
let mut buf = gst::Buffer::from_mut_slice(Vec::from(&input[..]));
let buf_ref = buf.get_mut().unwrap();
- buf_ref.set_pts(gst::ClockTime::from_seconds(0));
- buf_ref.set_duration(gst::ClockTime::from_seconds(2));
+ buf_ref.set_pts(gst::ClockTime::ZERO);
+ buf_ref.set_duration(2.seconds());
buf
};
diff --git a/utils/fallbackswitch/src/fallbacksrc/imp.rs b/utils/fallbackswitch/src/fallbacksrc/imp.rs
index b2ba74a6..739d2771 100644
--- a/utils/fallbackswitch/src/fallbacksrc/imp.rs
+++ b/utils/fallbackswitch/src/fallbacksrc/imp.rs
@@ -96,9 +96,9 @@ impl Default for Settings {
uri: None,
source: None,
fallback_uri: None,
- timeout: 5 * gst::ClockTime::SECOND,
- restart_timeout: 5 * gst::ClockTime::SECOND,
- retry_timeout: 60 * gst::ClockTime::SECOND,
+ timeout: 5.seconds(),
+ restart_timeout: 5.seconds(),
+ retry_timeout: 60.seconds(),
restart_on_eos: false,
min_latency: gst::ClockTime::ZERO,
buffer_duration: -1,
@@ -918,10 +918,7 @@ impl FallbackSrc {
queue.set_properties(&[
("max-size-bytes", &0u32),
("max-size-buffers", &0u32),
- (
- "max-size-time",
- &(cmp::max(min_latency, gst::ClockTime::from_seconds(1))),
- ),
+ ("max-size-time", &(cmp::max(min_latency, 1.seconds()))),
]);
bin.add_many(&[
@@ -975,10 +972,7 @@ impl FallbackSrc {
queue.set_properties(&[
("max-size-bytes", &0u32),
("max-size-buffers", &0u32),
- (
- "max-size-time",
- &(cmp::max(min_latency, gst::ClockTime::from_seconds(1))),
- ),
+ ("max-size-time", &(cmp::max(min_latency, 1.seconds()))),
]);
bin.add_many(&[
@@ -1764,7 +1758,7 @@ impl FallbackSrc {
("max-size-buffers", &0u32),
(
"max-size-time",
- &(cmp::max(state.settings.min_latency, gst::ClockTime::from_seconds(1))),
+ &(cmp::max(state.settings.min_latency, 1.seconds())),
),
]);
let clocksync = gst::ElementFactory::make("clocksync", None).unwrap_or_else(|_| {
diff --git a/utils/fallbackswitch/tests/fallbackswitch.rs b/utils/fallbackswitch/tests/fallbackswitch.rs
index 52e08402..1c35fb05 100644
--- a/utils/fallbackswitch/tests/fallbackswitch.rs
+++ b/utils/fallbackswitch/tests/fallbackswitch.rs
@@ -55,15 +55,15 @@ fn test_no_fallback_no_drops() {
let buffer = pull_buffer(&pipeline);
assert_buffer!(buffer, Some(gst::ClockTime::ZERO));
- push_buffer(&pipeline, gst::ClockTime::SECOND);
- set_time(&pipeline, gst::ClockTime::SECOND + LATENCY);
+ push_buffer(&pipeline, 1.seconds());
+ set_time(&pipeline, 1.seconds() + LATENCY);
let buffer = pull_buffer(&pipeline);
assert_buffer!(buffer, Some(gst::ClockTime::SECOND));
- push_buffer(&pipeline, 2 * gst::ClockTime::SECOND);
- set_time(&pipeline, 2 * gst::ClockTime::SECOND + LATENCY);
+ push_buffer(&pipeline, 2.seconds());
+ set_time(&pipeline, 2.seconds() + LATENCY);
let buffer = pull_buffer(&pipeline);
- assert_buffer!(buffer, Some(2 * gst::ClockTime::SECOND));
+ assert_buffer!(buffer, Some(2.seconds()));
push_eos(&pipeline);
wait_eos(&pipeline);
@@ -90,17 +90,17 @@ fn test_no_drops(live: bool) {
let buffer = pull_buffer(&pipeline);
assert_buffer!(buffer, Some(gst::ClockTime::ZERO));
- push_fallback_buffer(&pipeline, gst::ClockTime::SECOND);
- push_buffer(&pipeline, gst::ClockTime::SECOND);
- set_time(&pipeline, gst::ClockTime::SECOND + LATENCY);
+ push_fallback_buffer(&pipeline, 1.seconds());
+ push_buffer(&pipeline, 1.seconds());
+ set_time(&pipeline, 1.seconds() + LATENCY);
let buffer = pull_buffer(&pipeline);
assert_buffer!(buffer, Some(gst::ClockTime::SECOND));
- push_buffer(&pipeline, 2 * gst::ClockTime::SECOND);
- push_fallback_buffer(&pipeline, 2 * gst::ClockTime::SECOND);
- set_time(&pipeline, 2 * gst::ClockTime::SECOND + LATENCY);
+ push_buffer(&pipeline, 2.seconds());
+ push_fallback_buffer(&pipeline, 2.seconds());
+ set_time(&pipeline, 2.seconds() + LATENCY);
let buffer = pull_buffer(&pipeline);
- assert_buffer!(buffer, Some(2 * gst::ClockTime::SECOND));
+ assert_buffer!(buffer, Some(2.seconds()));
// EOS on the fallback should not be required
push_eos(&pipeline);
@@ -129,15 +129,15 @@ fn test_no_drops_but_no_fallback_frames(live: bool) {
let buffer = pull_buffer(&pipeline);
assert_buffer!(buffer, Some(gst::ClockTime::ZERO));
- push_buffer(&pipeline, gst::ClockTime::SECOND);
- set_time(&pipeline, gst::ClockTime::SECOND + LATENCY);
+ push_buffer(&pipeline, 1.seconds());
+ set_time(&pipeline, 1.seconds() + LATENCY);
let buffer = pull_buffer(&pipeline);
assert_buffer!(buffer, Some(gst::ClockTime::SECOND));
- push_buffer(&pipeline, 2 * gst::ClockTime::SECOND);
- set_time(&pipeline, 2 * gst::ClockTime::SECOND + LATENCY);
+ push_buffer(&pipeline, 2.seconds());
+ set_time(&pipeline, 2.seconds() + LATENCY);
let buffer = pull_buffer(&pipeline);
- assert_buffer!(buffer, Some(2 * gst::ClockTime::SECOND));
+ assert_buffer!(buffer, Some(2.seconds()));
// EOS on the fallback should not be required
push_eos(&pipeline);
@@ -167,18 +167,15 @@ fn test_short_drop(live: bool) {
// A timeout at 1s will get rid of the fallback buffer
// but not output anything
- push_fallback_buffer(&pipeline, gst::ClockTime::SECOND);
+ push_fallback_buffer(&pipeline, 1.seconds());
// Time out the fallback buffer at +10ms
- set_time(
- &pipeline,
- gst::ClockTime::SECOND + 10 * gst::ClockTime::MSECOND,
- );
+ set_time(&pipeline, 1.seconds() + 10.mseconds());
- push_fallback_buffer(&pipeline, 2 * gst::ClockTime::SECOND);
- push_buffer(&pipeline, 2 * gst::ClockTime::SECOND);
- set_time(&pipeline, 2 * gst::ClockTime::SECOND + LATENCY);
+ push_fallback_buffer(&pipeline, 2.seconds());
+ push_buffer(&pipeline, 2.seconds());
+ set_time(&pipeline, 2.seconds() + LATENCY);
let buffer = pull_buffer(&pipeline);
- assert_buffer!(buffer, Some(2 * gst::ClockTime::SECOND));
+ assert_buffer!(buffer, Some(2.seconds()));
push_eos(&pipeline);
push_fallback_eos(&pipeline);
@@ -208,38 +205,26 @@ fn test_long_drop_and_eos(live: bool) {
assert_buffer!(buffer, Some(gst::ClockTime::ZERO));
// Produce a second frame but only from the fallback source
- push_fallback_buffer(&pipeline, gst::ClockTime::SECOND);
- set_time(
- &pipeline,
- gst::ClockTime::SECOND + 10 * gst::ClockTime::MSECOND,
- );
+ push_fallback_buffer(&pipeline, 1.seconds());
+ set_time(&pipeline, 1.seconds() + 10.mseconds());
// Produce a third frame but only from the fallback source
- push_fallback_buffer(&pipeline, 2 * gst::ClockTime::SECOND);
- set_time(
- &pipeline,
- 2 * gst::ClockTime::SECOND + 10 * gst::ClockTime::MSECOND,
- );
+ push_fallback_buffer(&pipeline, 2.seconds());
+ set_time(&pipeline, 2.seconds() + 10.mseconds());
// Produce a fourth frame but only from the fallback source
// This should be output now
- push_fallback_buffer(&pipeline, 3 * gst::ClockTime::SECOND);
- set_time(
- &pipeline,
- 3 * gst::ClockTime::SECOND + 10 * gst::ClockTime::MSECOND,
- );
+ push_fallback_buffer(&pipeline, 3.seconds());
+ set_time(&pipeline, 3.seconds() + 10.mseconds());
let buffer = pull_buffer(&pipeline);
- assert_fallback_buffer!(buffer, Some(3 * gst::ClockTime::SECOND));
+ assert_fallback_buffer!(buffer, Some(3.seconds()));
// Produce a fifth frame but only from the fallback source
// This should be output now
- push_fallback_buffer(&pipeline, 4 * gst::ClockTime::SECOND);
- set_time(
- &pipeline,
- 4 * gst::ClockTime::SECOND + 10 * gst::ClockTime::MSECOND,
- );
+ push_fallback_buffer(&pipeline, 4.seconds());
+ set_time(&pipeline, 4.seconds() + 10.mseconds());
let buffer = pull_buffer(&pipeline);
- assert_fallback_buffer!(buffer, Some(4 * gst::ClockTime::SECOND));
+ assert_fallback_buffer!(buffer, Some(4.seconds()));
// Wait for EOS to arrive at appsink
push_eos(&pipeline);
@@ -273,70 +258,49 @@ fn test_long_drop_and_recover(live: bool) {
assert!(mainsink.property::<bool>("is-healthy"));
// Produce a second frame but only from the fallback source
- push_fallback_buffer(&pipeline, gst::ClockTime::SECOND);
- set_time(
- &pipeline,
- gst::ClockTime::SECOND + 10 * gst::ClockTime::MSECOND,
- );
+ push_fallback_buffer(&pipeline, 1.seconds());
+ set_time(&pipeline, 1.seconds() + 10.mseconds());
// Produce a third frame but only from the fallback source
- push_fallback_buffer(&pipeline, 2 * gst::ClockTime::SECOND);
- set_time(
- &pipeline,
- 2 * gst::ClockTime::SECOND + 10 * gst::ClockTime::MSECOND,
- );
+ push_fallback_buffer(&pipeline, 2.seconds());
+ set_time(&pipeline, 2.seconds() + 10.mseconds());
// Produce a fourth frame but only from the fallback source
// This should be output now
- push_fallback_buffer(&pipeline, 3 * gst::ClockTime::SECOND);
- set_time(
- &pipeline,
- 3 * gst::ClockTime::SECOND + 10 * gst::ClockTime::MSECOND,
- );
+ push_fallback_buffer(&pipeline, 3.seconds());
+ set_time(&pipeline, 3.seconds() + 10.mseconds());
let buffer = pull_buffer(&pipeline);
- assert_fallback_buffer!(buffer, Some(3 * gst::ClockTime::SECOND));
+ assert_fallback_buffer!(buffer, Some(3.seconds()));
// Produce a fifth frame but only from the fallback source
// This should be output now
- push_fallback_buffer(&pipeline, 4 * gst::ClockTime::SECOND);
- set_time(
- &pipeline,
- 4 * gst::ClockTime::SECOND + 10 * gst::ClockTime::MSECOND,
- );
+ push_fallback_buffer(&pipeline, 4.seconds());
+ set_time(&pipeline, 4.seconds() + 10.mseconds());
let buffer = pull_buffer(&pipeline);
- assert_fallback_buffer!(buffer, Some(4 * gst::ClockTime::SECOND));
+ assert_fallback_buffer!(buffer, Some(4.seconds()));
// Produce a sixth frame from the normal source
- push_buffer(&pipeline, 5 * gst::ClockTime::SECOND);
- set_time(
- &pipeline,
- 5 * gst::ClockTime::SECOND + 10 * gst::ClockTime::MSECOND,
- );
+ push_buffer(&pipeline, 5.seconds());
+ set_time(&pipeline, 5.seconds() + 10.mseconds());
let buffer = pull_buffer(&pipeline);
- assert_buffer!(buffer, Some(5 * gst::ClockTime::SECOND));
+ assert_buffer!(buffer, Some(5.seconds()));
assert!(!mainsink.property::<bool>("is-healthy"));
drop(mainsink);
drop(switch);
// Produce a seventh frame from the normal source but no fallback.
// This should still be output immediately
- push_buffer(&pipeline, 6 * gst::ClockTime::SECOND);
- set_time(
- &pipeline,
- 6 * gst::ClockTime::SECOND + 10 * gst::ClockTime::MSECOND,
- );
+ push_buffer(&pipeline, 6.seconds());
+ set_time(&pipeline, 6.seconds() + 10.mseconds());
let buffer = pull_buffer(&pipeline);
- assert_buffer!(buffer, Some(6 * gst::ClockTime::SECOND));
+ assert_buffer!(buffer, Some(6.seconds()));
// Produce a eight frame from the normal source
- push_buffer(&pipeline, 7 * gst::ClockTime::SECOND);
- push_fallback_buffer(&pipeline, 7 * gst::ClockTime::SECOND);
- set_time(
- &pipeline,
- 7 * gst::ClockTime::SECOND + 10 * gst::ClockTime::MSECOND,
- );
+ push_buffer(&pipeline, 7.seconds());
+ push_fallback_buffer(&pipeline, 7.seconds());
+ set_time(&pipeline, 7.seconds() + 10.mseconds());
let buffer = pull_buffer(&pipeline);
- assert_buffer!(buffer, Some(7 * gst::ClockTime::SECOND));
+ assert_buffer!(buffer, Some(7.seconds()));
// Wait for EOS to arrive at appsink
push_eos(&pipeline);
@@ -364,38 +328,26 @@ fn test_initial_timeout(live: bool) {
set_time(&pipeline, gst::ClockTime::ZERO);
// Produce a second frame but only from the fallback source
- push_fallback_buffer(&pipeline, gst::ClockTime::SECOND);
- set_time(
- &pipeline,
- gst::ClockTime::SECOND + 10 * gst::ClockTime::MSECOND,
- );
+ push_fallback_buffer(&pipeline, 1.seconds());
+ set_time(&pipeline, 1.seconds() + 10.mseconds());
// Produce a third frame but only from the fallback source
- push_fallback_buffer(&pipeline, 2 * gst::ClockTime::SECOND);
- set_time(
- &pipeline,
- 2 * gst::ClockTime::SECOND + 10 * gst::ClockTime::MSECOND,
- );
+ push_fallback_buffer(&pipeline, 2.seconds());
+ set_time(&pipeline, 2.seconds() + 10.mseconds());
// Produce a fourth frame but only from the fallback source
// This should be output now
- push_fallback_buffer(&pipeline, 3 * gst::ClockTime::SECOND);
- set_time(
- &pipeline,
- 3 * gst::ClockTime::SECOND + 10 * gst::ClockTime::MSECOND,
- );
+ push_fallback_buffer(&pipeline, 3.seconds());
+ set_time(&pipeline, 3.seconds() + 10.mseconds());
let buffer = pull_buffer(&pipeline);
- assert_fallback_buffer!(buffer, Some(3 * gst::ClockTime::SECOND));
+ assert_fallback_buffer!(buffer, Some(3.seconds()));
// Produce a fifth frame but only from the fallback source
// This should be output now
- push_fallback_buffer(&pipeline, 4 * gst::ClockTime::SECOND);
- set_time(
- &pipeline,
- 4 * gst::ClockTime::SECOND + 10 * gst::ClockTime::MSECOND,
- );
+ push_fallback_buffer(&pipeline, 4.seconds());
+ set_time(&pipeline, 4.seconds() + 10.mseconds());
let buffer = pull_buffer(&pipeline);
- assert_fallback_buffer!(buffer, Some(4 * gst::ClockTime::SECOND));
+ assert_fallback_buffer!(buffer, Some(4.seconds()));
// Wait for EOS to arrive at appsink
push_eos(&pipeline);
@@ -457,9 +409,9 @@ fn test_manual_switch(live: bool) {
assert_buffer!(buffer, Some(gst::ClockTime::ZERO));
switch.set_property("active-pad", &fallbacksink);
- push_fallback_buffer(&pipeline, gst::ClockTime::SECOND);
- push_buffer(&pipeline, gst::ClockTime::SECOND);
- set_time(&pipeline, gst::ClockTime::SECOND + LATENCY);
+ push_fallback_buffer(&pipeline, 1.seconds());
+ push_buffer(&pipeline, 1.seconds());
+ set_time(&pipeline, 1.seconds() + LATENCY);
let mut buffer = pull_buffer(&pipeline);
// FIXME: Sometimes we first get the ZERO buffer from the fallback sink
if buffer.pts() == Some(gst::ClockTime::ZERO) {
@@ -468,15 +420,15 @@ fn test_manual_switch(live: bool) {
assert_fallback_buffer!(buffer, Some(gst::ClockTime::SECOND));
switch.set_property("active-pad", &mainsink);
- push_buffer(&pipeline, 2 * gst::ClockTime::SECOND);
- push_fallback_buffer(&pipeline, 2 * gst::ClockTime::SECOND);
- set_time(&pipeline, 2 * gst::ClockTime::SECOND + LATENCY);
+ push_buffer(&pipeline, 2.seconds());
+ push_fallback_buffer(&pipeline, 2.seconds());
+ set_time(&pipeline, 2.seconds() + LATENCY);
buffer = pull_buffer(&pipeline);
// FIXME: Sometimes we first get the 1sec buffer from the main sink
if buffer.pts() == Some(gst::ClockTime::SECOND) {
buffer = pull_buffer(&pipeline);
}
- assert_buffer!(buffer, Some(2 * gst::ClockTime::SECOND));
+ assert_buffer!(buffer, Some(2.seconds()));
drop(mainsink);
drop(fallbacksink);
@@ -539,7 +491,7 @@ fn setup_pipeline(
);
let switch = gst::ElementFactory::make("fallbackswitch", Some("switch")).unwrap();
- switch.set_property("timeout", 3 * gst::ClockTime::SECOND);
+ switch.set_property("timeout", 3.seconds());
if let Some(imm) = immediate_fallback {
switch.set_property("immediate-fallback", imm);
}
diff --git a/utils/togglerecord/tests/tests.rs b/utils/togglerecord/tests/tests.rs
index cc891f54..8e16990d 100644
--- a/utils/togglerecord/tests/tests.rs
+++ b/utils/togglerecord/tests/tests.rs
@@ -143,8 +143,8 @@ fn setup_sender_receiver(
let mut buffer = buffer.clone();
{
let buffer = buffer.make_mut();
- buffer.set_pts(offset + i * 20 * gst::ClockTime::MSECOND);
- buffer.set_duration(20 * gst::ClockTime::MSECOND);
+ buffer.set_pts(offset + i * 20.mseconds());
+ buffer.set_duration(20.mseconds());
}
let _ = sinkpad.chain(buffer);
i += 1;
@@ -156,11 +156,8 @@ fn setup_sender_receiver(
buffer
.get_mut()
.unwrap()
- .set_pts(offset + i * 20 * gst::ClockTime::MSECOND);
- buffer
- .get_mut()
- .unwrap()
- .set_duration(20 * gst::ClockTime::MSECOND);
+ .set_pts(offset + i * 20.mseconds());
+ buffer.get_mut().unwrap().set_duration(20.mseconds());
buffer
.get_mut()
.unwrap()
@@ -171,10 +168,7 @@ fn setup_sender_receiver(
}
SendData::Gaps(n) => {
for _ in 0..n {
- let event = gst::event::Gap::new(
- offset + i * 20 * gst::ClockTime::MSECOND,
- 20 * gst::ClockTime::MSECOND,
- );
+ let event = gst::event::Gap::new(offset + i * 20.mseconds(), 20.mseconds());
let _ = sinkpad.send_event(event);
i += 1;
}
@@ -297,9 +291,9 @@ fn test_one_stream_open() {
assert_eq!(buffers.len(), 10);
for (index, &(running_time, pts, duration)) in buffers.iter().enumerate() {
let index = index as u64;
- assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(pts.unwrap(), index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND);
+ assert_eq!(running_time.unwrap(), index * 20.mseconds());
+ assert_eq!(pts.unwrap(), index * 20.mseconds());
+ assert_eq!(duration.unwrap(), 20.mseconds());
}
thread.join().unwrap();
@@ -330,9 +324,9 @@ fn test_one_stream_gaps_open() {
assert_eq!(buffers.len(), 10);
for (index, &(running_time, pts, duration)) in buffers.iter().enumerate() {
let index = index as u64;
- assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(pts.unwrap(), index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND);
+ assert_eq!(running_time.unwrap(), index * 20.mseconds());
+ assert_eq!(pts.unwrap(), index * 20.mseconds());
+ assert_eq!(duration.unwrap(), 20.mseconds());
}
thread.join().unwrap();
@@ -364,9 +358,9 @@ fn test_one_stream_close_open() {
assert_eq!(buffers.len(), 10);
for (index, &(running_time, pts, duration)) in buffers.iter().enumerate() {
let index = index as u64;
- assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(pts.unwrap(), (10 + index) * 20 * gst::ClockTime::MSECOND);
- assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND);
+ assert_eq!(running_time.unwrap(), index * 20.mseconds());
+ assert_eq!(pts.unwrap(), (10 + index) * 20.mseconds());
+ assert_eq!(duration.unwrap(), 20.mseconds());
}
thread.join().unwrap();
@@ -399,9 +393,9 @@ fn test_one_stream_open_close() {
assert_eq!(buffers.len(), 10);
for (index, &(running_time, pts, duration)) in buffers.iter().enumerate() {
let index = index as u64;
- assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(pts.unwrap(), index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND);
+ assert_eq!(running_time.unwrap(), index * 20.mseconds());
+ assert_eq!(pts.unwrap(), index * 20.mseconds());
+ assert_eq!(duration.unwrap(), 20.mseconds());
}
thread.join().unwrap();
@@ -437,15 +431,15 @@ fn test_one_stream_open_close_open() {
assert_eq!(buffers.len(), 20);
for (index, &(running_time, pts, duration)) in buffers.iter().enumerate() {
let pts_off = if index >= 10 {
- 10 * 20 * gst::ClockTime::MSECOND
+ 10 * 20.mseconds()
} else {
gst::ClockTime::ZERO
};
let index = index as u64;
- assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(pts.unwrap(), pts_off + index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND);
+ assert_eq!(running_time.unwrap(), index * 20.mseconds());
+ assert_eq!(pts.unwrap(), pts_off + index * 20.mseconds());
+ assert_eq!(duration.unwrap(), 20.mseconds());
}
thread.join().unwrap();
@@ -483,9 +477,9 @@ fn test_two_stream_open() {
let (buffers_1, _) = recv_buffers(&receiver_output_1, &mut segment_1, 0);
for (index, &(running_time, pts, duration)) in buffers_1.iter().enumerate() {
let index = index as u64;
- assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(pts.unwrap(), index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND);
+ assert_eq!(running_time.unwrap(), index * 20.mseconds());
+ assert_eq!(pts.unwrap(), index * 20.mseconds());
+ assert_eq!(duration.unwrap(), 20.mseconds());
}
assert_eq!(buffers_1.len(), 10);
@@ -494,9 +488,9 @@ fn test_two_stream_open() {
let (buffers_2, _) = recv_buffers(&receiver_output_2, &mut segment_2, 0);
for (index, &(running_time, pts, duration)) in buffers_2.iter().enumerate() {
let index = index as u64;
- assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(pts.unwrap(), index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND);
+ assert_eq!(running_time.unwrap(), index * 20.mseconds());
+ assert_eq!(pts.unwrap(), index * 20.mseconds());
+ assert_eq!(duration.unwrap(), 20.mseconds());
}
assert_eq!(buffers_2.len(), 10);
@@ -517,12 +511,7 @@ fn test_two_stream_open_shift() {
let (sender_input_1, receiver_input_done_1, receiver_output_1, thread_1) =
setup_sender_receiver(&pipeline, &togglerecord, "src", gst::ClockTime::ZERO);
let (sender_input_2, receiver_input_done_2, receiver_output_2, thread_2) =
- setup_sender_receiver(
- &pipeline,
- &togglerecord,
- "src_%u",
- 5 * gst::ClockTime::MSECOND,
- );
+ setup_sender_receiver(&pipeline, &togglerecord, "src_%u", 5.mseconds());
pipeline.set_state(gst::State::Playing).unwrap();
@@ -541,9 +530,9 @@ fn test_two_stream_open_shift() {
let (buffers_1, _) = recv_buffers(&receiver_output_1, &mut segment_1, 0);
for (index, &(running_time, pts, duration)) in buffers_1.iter().enumerate() {
let index = index as u64;
- assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(pts.unwrap(), index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND);
+ assert_eq!(running_time.unwrap(), index * 20.mseconds());
+ assert_eq!(pts.unwrap(), index * 20.mseconds());
+ assert_eq!(duration.unwrap(), 20.mseconds());
}
assert_eq!(buffers_1.len(), 10);
@@ -552,18 +541,12 @@ fn test_two_stream_open_shift() {
let (buffers_2, _) = recv_buffers(&receiver_output_2, &mut segment_2, 0);
for (index, &(running_time, pts, duration)) in buffers_2.iter().enumerate() {
let index = index as u64;
- assert_eq!(
- running_time.unwrap(),
- 5 * gst::ClockTime::MSECOND + index * 20 * gst::ClockTime::MSECOND
- );
- assert_eq!(
- pts.unwrap(),
- 5 * gst::ClockTime::MSECOND + index * 20 * gst::ClockTime::MSECOND
- );
+ assert_eq!(running_time.unwrap(), 5.mseconds() + index * 20.mseconds());
+ assert_eq!(pts.unwrap(), 5.mseconds() + index * 20.mseconds());
if index == 9 {
- assert_eq!(duration.unwrap(), 15 * gst::ClockTime::MSECOND);
+ assert_eq!(duration.unwrap(), 15.mseconds());
} else {
- assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND);
+ assert_eq!(duration.unwrap(), 20.mseconds());
}
}
assert_eq!(buffers_2.len(), 10);
@@ -583,7 +566,7 @@ fn test_two_stream_open_shift_main() {
pipeline.add(&togglerecord).unwrap();
let (sender_input_1, receiver_input_done_1, receiver_output_1, thread_1) =
- setup_sender_receiver(&pipeline, &togglerecord, "src", 5 * gst::ClockTime::MSECOND);
+ setup_sender_receiver(&pipeline, &togglerecord, "src", 5.mseconds());
let (sender_input_2, receiver_input_done_2, receiver_output_2, thread_2) =
setup_sender_receiver(&pipeline, &togglerecord, "src_%u", gst::ClockTime::ZERO);
@@ -605,12 +588,9 @@ fn test_two_stream_open_shift_main() {
let (buffers_1, _) = recv_buffers(&receiver_output_1, &mut segment_1, 0);
for (index, &(running_time, pts, duration)) in buffers_1.iter().enumerate() {
let index = index as u64;
- assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(
- pts.unwrap(),
- 5 * gst::ClockTime::MSECOND + index * 20 * gst::ClockTime::MSECOND
- );
- assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND);
+ assert_eq!(running_time.unwrap(), index * 20.mseconds());
+ assert_eq!(pts.unwrap(), 5.mseconds() + index * 20.mseconds());
+ assert_eq!(duration.unwrap(), 20.mseconds());
}
assert_eq!(buffers_1.len(), 10);
@@ -621,26 +601,17 @@ fn test_two_stream_open_shift_main() {
for (index, &(running_time, pts, duration)) in buffers_2.iter().enumerate() {
let index = index as u64;
if index == 0 {
- assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(
- pts.unwrap(),
- 5 * gst::ClockTime::MSECOND + index * 20 * gst::ClockTime::MSECOND
- );
- assert_eq!(duration.unwrap(), 15 * gst::ClockTime::MSECOND);
+ assert_eq!(running_time.unwrap(), index * 20.mseconds());
+ assert_eq!(pts.unwrap(), 5.mseconds() + index * 20.mseconds());
+ assert_eq!(duration.unwrap(), 15.mseconds());
} else if index == 10 {
- assert_eq!(
- running_time.unwrap(),
- index * 20 * gst::ClockTime::MSECOND - 5 * gst::ClockTime::MSECOND
- );
- assert_eq!(pts.unwrap(), index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(duration.unwrap(), 5 * gst::ClockTime::MSECOND);
+ assert_eq!(running_time.unwrap(), index * 20.mseconds() - 5.mseconds());
+ assert_eq!(pts.unwrap(), index * 20.mseconds());
+ assert_eq!(duration.unwrap(), 5.mseconds());
} else {
- assert_eq!(
- running_time.unwrap(),
- index * 20 * gst::ClockTime::MSECOND - 5 * gst::ClockTime::MSECOND
- );
- assert_eq!(pts.unwrap(), index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND);
+ assert_eq!(running_time.unwrap(), index * 20.mseconds() - 5.mseconds());
+ assert_eq!(pts.unwrap(), index * 20.mseconds());
+ assert_eq!(duration.unwrap(), 20.mseconds());
}
}
assert_eq!(buffers_2.len(), 11);
@@ -697,9 +668,9 @@ fn test_two_stream_open_close() {
let (buffers_1, _) = recv_buffers(&receiver_output_1, &mut segment_1, 0);
for (index, &(running_time, pts, duration)) in buffers_1.iter().enumerate() {
let index = index as u64;
- assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(pts.unwrap(), index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND);
+ assert_eq!(running_time.unwrap(), index * 20.mseconds());
+ assert_eq!(pts.unwrap(), index * 20.mseconds());
+ assert_eq!(duration.unwrap(), 20.mseconds());
}
assert_eq!(buffers_1.len(), 10);
@@ -708,9 +679,9 @@ fn test_two_stream_open_close() {
let (buffers_2, _) = recv_buffers(&receiver_output_2, &mut segment_2, 0);
for (index, &(running_time, pts, duration)) in buffers_2.iter().enumerate() {
let index = index as u64;
- assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(pts.unwrap(), index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND);
+ assert_eq!(running_time.unwrap(), index * 20.mseconds());
+ assert_eq!(pts.unwrap(), index * 20.mseconds());
+ assert_eq!(duration.unwrap(), 20.mseconds());
}
assert_eq!(buffers_2.len(), 10);
@@ -766,9 +737,9 @@ fn test_two_stream_close_open() {
let (buffers_1, _) = recv_buffers(&receiver_output_1, &mut segment_1, 0);
for (index, &(running_time, pts, duration)) in buffers_1.iter().enumerate() {
let index = index as u64;
- assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(pts.unwrap(), (10 + index) * 20 * gst::ClockTime::MSECOND);
- assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND);
+ assert_eq!(running_time.unwrap(), index * 20.mseconds());
+ assert_eq!(pts.unwrap(), (10 + index) * 20.mseconds());
+ assert_eq!(duration.unwrap(), 20.mseconds());
}
assert_eq!(buffers_1.len(), 10);
@@ -777,9 +748,9 @@ fn test_two_stream_close_open() {
let (buffers_2, _) = recv_buffers(&receiver_output_2, &mut segment_2, 0);
for (index, &(running_time, pts, duration)) in buffers_2.iter().enumerate() {
let index = index as u64;
- assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(pts.unwrap(), (10 + index) * 20 * gst::ClockTime::MSECOND);
- assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND);
+ assert_eq!(running_time.unwrap(), index * 20.mseconds());
+ assert_eq!(pts.unwrap(), (10 + index) * 20.mseconds());
+ assert_eq!(duration.unwrap(), 20.mseconds());
}
assert_eq!(buffers_2.len(), 10);
@@ -848,15 +819,15 @@ fn test_two_stream_open_close_open() {
let (buffers_1, _) = recv_buffers(&receiver_output_1, &mut segment_1, 0);
for (index, &(running_time, pts, duration)) in buffers_1.iter().enumerate() {
let pts_off = if index >= 10 {
- 10 * 20 * gst::ClockTime::MSECOND
+ 10 * 20.mseconds()
} else {
gst::ClockTime::ZERO
};
let index = index as u64;
- assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(pts.unwrap(), pts_off + index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND);
+ assert_eq!(running_time.unwrap(), index * 20.mseconds());
+ assert_eq!(pts.unwrap(), pts_off + index * 20.mseconds());
+ assert_eq!(duration.unwrap(), 20.mseconds());
}
assert_eq!(buffers_1.len(), 20);
@@ -865,15 +836,15 @@ fn test_two_stream_open_close_open() {
let (buffers_2, _) = recv_buffers(&receiver_output_2, &mut segment_2, 0);
for (index, &(running_time, pts, duration)) in buffers_2.iter().enumerate() {
let pts_off = if index >= 10 {
- 10 * 20 * gst::ClockTime::MSECOND
+ 10 * 20.mseconds()
} else {
gst::ClockTime::ZERO
};
let index = index as u64;
- assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(pts.unwrap(), pts_off + index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND);
+ assert_eq!(running_time.unwrap(), index * 20.mseconds());
+ assert_eq!(pts.unwrap(), pts_off + index * 20.mseconds());
+ assert_eq!(duration.unwrap(), 20.mseconds());
}
assert_eq!(buffers_2.len(), 20);
@@ -948,15 +919,15 @@ fn test_two_stream_open_close_open_gaps() {
let (buffers_1, _) = recv_buffers(&receiver_output_1, &mut segment_1, 0);
for (index, &(running_time, pts, duration)) in buffers_1.iter().enumerate() {
let pts_off = if index >= 10 {
- 10 * 20 * gst::ClockTime::MSECOND
+ 10 * 20.mseconds()
} else {
gst::ClockTime::ZERO
};
let index = index as u64;
- assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(pts.unwrap(), pts_off + index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND);
+ assert_eq!(running_time.unwrap(), index * 20.mseconds());
+ assert_eq!(pts.unwrap(), pts_off + index * 20.mseconds());
+ assert_eq!(duration.unwrap(), 20.mseconds());
}
assert_eq!(buffers_1.len(), 20);
@@ -965,15 +936,15 @@ fn test_two_stream_open_close_open_gaps() {
let (buffers_2, _) = recv_buffers(&receiver_output_2, &mut segment_2, 0);
for (index, &(running_time, pts, duration)) in buffers_2.iter().enumerate() {
let pts_off = if index >= 10 {
- 10 * 20 * gst::ClockTime::MSECOND
+ 10 * 20.mseconds()
} else {
gst::ClockTime::ZERO
};
let index = index as u64;
- assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(pts.unwrap(), pts_off + index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND);
+ assert_eq!(running_time.unwrap(), index * 20.mseconds());
+ assert_eq!(pts.unwrap(), pts_off + index * 20.mseconds());
+ assert_eq!(duration.unwrap(), 20.mseconds());
}
assert_eq!(buffers_2.len(), 20);
@@ -1049,9 +1020,9 @@ fn test_two_stream_close_open_close_delta() {
let (buffers_1, _) = recv_buffers(&receiver_output_1, &mut segment_1, 0);
for (index, &(running_time, pts, duration)) in buffers_1.iter().enumerate() {
let index = index as u64;
- assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(pts.unwrap(), (11 + index) * 20 * gst::ClockTime::MSECOND);
- assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND);
+ assert_eq!(running_time.unwrap(), index * 20.mseconds());
+ assert_eq!(pts.unwrap(), (11 + index) * 20.mseconds());
+ assert_eq!(duration.unwrap(), 20.mseconds());
}
assert_eq!(buffers_1.len(), 10);
@@ -1060,9 +1031,9 @@ fn test_two_stream_close_open_close_delta() {
let (buffers_2, _) = recv_buffers(&receiver_output_2, &mut segment_2, 0);
for (index, &(running_time, pts, duration)) in buffers_2.iter().enumerate() {
let index = index as u64;
- assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(pts.unwrap(), (11 + index) * 20 * gst::ClockTime::MSECOND);
- assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND);
+ assert_eq!(running_time.unwrap(), index * 20.mseconds());
+ assert_eq!(pts.unwrap(), (11 + index) * 20.mseconds());
+ assert_eq!(duration.unwrap(), 20.mseconds());
}
assert_eq!(buffers_2.len(), 10);
@@ -1144,15 +1115,15 @@ fn test_three_stream_open_close_open() {
let (buffers_1, _) = recv_buffers(&receiver_output_1, &mut segment_1, 0);
for (index, &(running_time, pts, duration)) in buffers_1.iter().enumerate() {
let pts_off = if index >= 10 {
- 10 * 20 * gst::ClockTime::MSECOND
+ 10 * 20.mseconds()
} else {
gst::ClockTime::ZERO
};
let index = index as u64;
- assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(pts.unwrap(), pts_off + index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND);
+ assert_eq!(running_time.unwrap(), index * 20.mseconds());
+ assert_eq!(pts.unwrap(), pts_off + index * 20.mseconds());
+ assert_eq!(duration.unwrap(), 20.mseconds());
}
assert_eq!(buffers_1.len(), 20);
@@ -1161,15 +1132,15 @@ fn test_three_stream_open_close_open() {
let (buffers_2, _) = recv_buffers(&receiver_output_2, &mut segment_2, 0);
for (index, &(running_time, pts, duration)) in buffers_2.iter().enumerate() {
let pts_off = if index >= 10 {
- 10 * 20 * gst::ClockTime::MSECOND
+ 10 * 20.mseconds()
} else {
gst::ClockTime::ZERO
};
let index = index as u64;
- assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(pts.unwrap(), pts_off + index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND);
+ assert_eq!(running_time.unwrap(), index * 20.mseconds());
+ assert_eq!(pts.unwrap(), pts_off + index * 20.mseconds());
+ assert_eq!(duration.unwrap(), 20.mseconds());
}
assert_eq!(buffers_2.len(), 20);
@@ -1177,15 +1148,15 @@ fn test_three_stream_open_close_open() {
let (buffers_3, _) = recv_buffers(&receiver_output_3, &mut segment_3, 0);
for (index, &(running_time, pts, duration)) in buffers_3.iter().enumerate() {
let pts_off = if index >= 10 {
- 10 * 20 * gst::ClockTime::MSECOND
+ 10 * 20.mseconds()
} else {
gst::ClockTime::ZERO
};
let index = index as u64;
- assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(pts.unwrap(), pts_off + index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND);
+ assert_eq!(running_time.unwrap(), index * 20.mseconds());
+ assert_eq!(pts.unwrap(), pts_off + index * 20.mseconds());
+ assert_eq!(duration.unwrap(), 20.mseconds());
}
assert_eq!(buffers_3.len(), 20);
@@ -1246,9 +1217,9 @@ fn test_two_stream_main_eos() {
let (buffers_1, saw_eos) = recv_buffers(&receiver_output_1, &mut segment_1, 0);
for (index, &(running_time, pts, duration)) in buffers_1.iter().enumerate() {
let index = index as u64;
- assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(pts.unwrap(), index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND);
+ assert_eq!(running_time.unwrap(), index * 20.mseconds());
+ assert_eq!(pts.unwrap(), index * 20.mseconds());
+ assert_eq!(duration.unwrap(), 20.mseconds());
}
assert_eq!(buffers_1.len(), 10);
assert!(saw_eos);
@@ -1258,9 +1229,9 @@ fn test_two_stream_main_eos() {
let (buffers_2, saw_eos) = recv_buffers(&receiver_output_2, &mut segment_2, 0);
for (index, &(running_time, pts, duration)) in buffers_2.iter().enumerate() {
let index = index as u64;
- assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(pts.unwrap(), index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND);
+ assert_eq!(running_time.unwrap(), index * 20.mseconds());
+ assert_eq!(pts.unwrap(), index * 20.mseconds());
+ assert_eq!(duration.unwrap(), 20.mseconds());
}
assert_eq!(buffers_2.len(), 10);
assert!(saw_eos);
@@ -1313,9 +1284,9 @@ fn test_two_stream_secondary_eos_first() {
let (buffers_1, saw_eos) = recv_buffers(&receiver_output_1, &mut segment_1, 0);
for (index, &(running_time, pts, duration)) in buffers_1.iter().enumerate() {
let index = index as u64;
- assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(pts.unwrap(), index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND);
+ assert_eq!(running_time.unwrap(), index * 20.mseconds());
+ assert_eq!(pts.unwrap(), index * 20.mseconds());
+ assert_eq!(duration.unwrap(), 20.mseconds());
}
assert_eq!(buffers_1.len(), 10);
assert!(saw_eos);
@@ -1326,9 +1297,9 @@ fn test_two_stream_secondary_eos_first() {
let (buffers_2, saw_eos) = recv_buffers(&receiver_output_2, &mut segment_2, 0);
for (index, &(running_time, pts, duration)) in buffers_2.iter().enumerate() {
let index = index as u64;
- assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(pts.unwrap(), index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND);
+ assert_eq!(running_time.unwrap(), index * 20.mseconds());
+ assert_eq!(pts.unwrap(), index * 20.mseconds());
+ assert_eq!(duration.unwrap(), 20.mseconds());
}
assert_eq!(buffers_2.len(), 9);
assert!(saw_eos);
@@ -1403,9 +1374,9 @@ fn test_three_stream_main_eos() {
let (buffers_1, saw_eos) = recv_buffers(&receiver_output_1, &mut segment_1, 0);
for (index, &(running_time, pts, duration)) in buffers_1.iter().enumerate() {
let index = index as u64;
- assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(pts.unwrap(), index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND);
+ assert_eq!(running_time.unwrap(), index * 20.mseconds());
+ assert_eq!(pts.unwrap(), index * 20.mseconds());
+ assert_eq!(duration.unwrap(), 20.mseconds());
}
assert_eq!(buffers_1.len(), 10);
assert!(saw_eos);
@@ -1415,9 +1386,9 @@ fn test_three_stream_main_eos() {
let (buffers_2, saw_eos) = recv_buffers(&receiver_output_2, &mut segment_2, 0);
for (index, &(running_time, pts, duration)) in buffers_2.iter().enumerate() {
let index = index as u64;
- assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(pts.unwrap(), index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND);
+ assert_eq!(running_time.unwrap(), index * 20.mseconds());
+ assert_eq!(pts.unwrap(), index * 20.mseconds());
+ assert_eq!(duration.unwrap(), 20.mseconds());
}
assert_eq!(buffers_2.len(), 10);
assert!(saw_eos);
@@ -1426,9 +1397,9 @@ fn test_three_stream_main_eos() {
let (buffers_3, saw_eos) = recv_buffers(&receiver_output_3, &mut segment_3, 0);
for (index, &(running_time, pts, duration)) in buffers_3.iter().enumerate() {
let index = index as u64;
- assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(pts.unwrap(), index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND);
+ assert_eq!(running_time.unwrap(), index * 20.mseconds());
+ assert_eq!(pts.unwrap(), index * 20.mseconds());
+ assert_eq!(duration.unwrap(), 20.mseconds());
}
assert_eq!(buffers_3.len(), 10);
assert!(saw_eos);
@@ -1503,9 +1474,9 @@ fn test_three_stream_main_and_second_eos() {
let (buffers_1, saw_eos) = recv_buffers(&receiver_output_1, &mut segment_1, 0);
for (index, &(running_time, pts, duration)) in buffers_1.iter().enumerate() {
let index = index as u64;
- assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(pts.unwrap(), index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND);
+ assert_eq!(running_time.unwrap(), index * 20.mseconds());
+ assert_eq!(pts.unwrap(), index * 20.mseconds());
+ assert_eq!(duration.unwrap(), 20.mseconds());
}
assert_eq!(buffers_1.len(), 10);
assert!(saw_eos);
@@ -1515,9 +1486,9 @@ fn test_three_stream_main_and_second_eos() {
let (buffers_2, saw_eos) = recv_buffers(&receiver_output_2, &mut segment_2, 0);
for (index, &(running_time, pts, duration)) in buffers_2.iter().enumerate() {
let index = index as u64;
- assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(pts.unwrap(), index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND);
+ assert_eq!(running_time.unwrap(), index * 20.mseconds());
+ assert_eq!(pts.unwrap(), index * 20.mseconds());
+ assert_eq!(duration.unwrap(), 20.mseconds());
}
assert_eq!(buffers_2.len(), 9);
assert!(saw_eos);
@@ -1527,9 +1498,9 @@ fn test_three_stream_main_and_second_eos() {
let (buffers_3, saw_eos) = recv_buffers(&receiver_output_3, &mut segment_3, 0);
for (index, &(running_time, pts, duration)) in buffers_3.iter().enumerate() {
let index = index as u64;
- assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(pts.unwrap(), index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND);
+ assert_eq!(running_time.unwrap(), index * 20.mseconds());
+ assert_eq!(pts.unwrap(), index * 20.mseconds());
+ assert_eq!(duration.unwrap(), 20.mseconds());
}
assert_eq!(buffers_3.len(), 10);
assert!(saw_eos);
@@ -1590,9 +1561,9 @@ fn test_three_stream_secondary_eos_first() {
let (buffers_1, saw_eos) = recv_buffers(&receiver_output_1, &mut segment_1, 0);
for (index, &(running_time, pts, duration)) in buffers_1.iter().enumerate() {
let index = index as u64;
- assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(pts.unwrap(), index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND);
+ assert_eq!(running_time.unwrap(), index * 20.mseconds());
+ assert_eq!(pts.unwrap(), index * 20.mseconds());
+ assert_eq!(duration.unwrap(), 20.mseconds());
}
assert_eq!(buffers_1.len(), 10);
assert!(saw_eos);
@@ -1602,9 +1573,9 @@ fn test_three_stream_secondary_eos_first() {
let (buffers_2, saw_eos) = recv_buffers(&receiver_output_2, &mut segment_2, 0);
for (index, &(running_time, pts, duration)) in buffers_2.iter().enumerate() {
let index = index as u64;
- assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(pts.unwrap(), index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND);
+ assert_eq!(running_time.unwrap(), index * 20.mseconds());
+ assert_eq!(pts.unwrap(), index * 20.mseconds());
+ assert_eq!(duration.unwrap(), 20.mseconds());
}
assert_eq!(buffers_2.len(), 9);
assert!(saw_eos);
@@ -1613,9 +1584,9 @@ fn test_three_stream_secondary_eos_first() {
let (buffers_3, saw_eos) = recv_buffers(&receiver_output_3, &mut segment_3, 0);
for (index, &(running_time, pts, duration)) in buffers_3.iter().enumerate() {
let index = index as u64;
- assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(pts.unwrap(), index * 20 * gst::ClockTime::MSECOND);
- assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND);
+ assert_eq!(running_time.unwrap(), index * 20.mseconds());
+ assert_eq!(pts.unwrap(), index * 20.mseconds());
+ assert_eq!(duration.unwrap(), 20.mseconds());
}
assert_eq!(buffers_3.len(), 9);
assert!(saw_eos);
diff --git a/utils/uriplaylistbin/tests/uriplaylistbin.rs b/utils/uriplaylistbin/tests/uriplaylistbin.rs
index 4532358b..f86005b2 100644
--- a/utils/uriplaylistbin/tests/uriplaylistbin.rs
+++ b/utils/uriplaylistbin/tests/uriplaylistbin.rs
@@ -34,28 +34,28 @@ impl TestMedia {
fn ogg() -> Self {
Self {
uri: file_name_to_uri("sample.ogg"),
- len: gst::ClockTime::from_mseconds(510),
+ len: 510.mseconds(),
}
}
fn mkv() -> Self {
Self {
uri: file_name_to_uri("sample.mkv"),
- len: gst::ClockTime::from_mseconds(510),
+ len: 510.mseconds(),
}
}
fn missing_file() -> Self {
Self {
uri: "file:///not-there.ogg".to_string(),
- len: gst::ClockTime::from_mseconds(10),
+ len: 10.mseconds(),
}
}
fn missing_http() -> Self {
Self {
uri: "http:///not-there.ogg".to_string(),
- len: gst::ClockTime::from_mseconds(10),
+ len: 10.mseconds(),
}
}
}
@@ -87,12 +87,7 @@ fn test(
pipeline.add_many(&[&playlist, &mq]).unwrap();
- let total_len = gst::ClockTime::from_nseconds(
- medias
- .iter()
- .map(|t| t.len.nseconds() * (iterations as u64))
- .sum(),
- );
+ let total_len: gst::ClockTime = medias.iter().map(|t| t.len * (iterations as u64)).sum();
let uris: Vec<String> = medias.iter().map(|t| t.uri.clone()).collect();
diff --git a/video/cdg/src/cdgparse/imp.rs b/video/cdg/src/cdgparse/imp.rs
index 12ea2552..4cf32b5f 100644
--- a/video/cdg/src/cdgparse/imp.rs
+++ b/video/cdg/src/cdgparse/imp.rs
@@ -92,22 +92,20 @@ impl ElementImpl for CdgParse {
}
fn bytes_to_time(bytes: Bytes) -> gst::ClockTime {
- let nb = *bytes / CDG_PACKET_SIZE as u64;
- gst::ClockTime::from_nseconds(
- nb.mul_div_round(*gst::ClockTime::SECOND, CDG_PACKET_PERIOD)
- .unwrap(),
- )
+ let nb = bytes / CDG_PACKET_SIZE as u64;
+ nb.mul_div_round(*gst::ClockTime::SECOND, CDG_PACKET_PERIOD)
+ .unwrap()
+ .nseconds()
}
fn time_to_bytes(time: gst::ClockTime) -> Bytes {
- Bytes::from_u64(
- time.nseconds()
- .mul_div_round(
- CDG_PACKET_PERIOD * CDG_PACKET_SIZE as u64,
- *gst::ClockTime::SECOND,
- )
- .unwrap(),
- )
+ time.nseconds()
+ .mul_div_round(
+ CDG_PACKET_PERIOD * CDG_PACKET_SIZE as u64,
+ *gst::ClockTime::SECOND,
+ )
+ .unwrap()
+ .bytes()
}
impl BaseParseImpl for CdgParse {
@@ -191,7 +189,7 @@ impl BaseParseImpl for CdgParse {
}
};
- let pts = bytes_to_time(Bytes::from_u64(frame.offset()));
+ let pts = bytes_to_time(frame.offset().bytes());
let buffer = frame.buffer_mut().unwrap();
buffer.set_pts(pts);
diff --git a/video/closedcaption/src/ccdetect/imp.rs b/video/closedcaption/src/ccdetect/imp.rs
index b6691dd4..d8fcf5b3 100644
--- a/video/closedcaption/src/ccdetect/imp.rs
+++ b/video/closedcaption/src/ccdetect/imp.rs
@@ -258,8 +258,7 @@ impl ObjectImpl for CCDetect {
match pspec.name() {
"window" => {
let mut settings = self.settings.lock().unwrap();
- settings.window =
- gst::ClockTime::from_nseconds(value.get().expect("type checked upstream"));
+ settings.window = value.get::<u64>().unwrap().nseconds();
}
_ => unimplemented!(),
}
diff --git a/video/closedcaption/src/cea608overlay/imp.rs b/video/closedcaption/src/cea608overlay/imp.rs
index b4b56cc8..dccaf568 100644
--- a/video/closedcaption/src/cea608overlay/imp.rs
+++ b/video/closedcaption/src/cea608overlay/imp.rs
@@ -577,7 +577,7 @@ impl ObjectImpl for Cea608Overlay {
glib::ParamSpecUInt64::builder("timeout")
.nick("Timeout")
.blurb("Duration after which to erase overlay when no cc data has arrived for the selected field")
- .minimum(gst::ClockTime::from_seconds(16).nseconds())
+ .minimum(16.seconds().nseconds())
.default_value(u64::MAX)
.mutable_playing()
.build(),
@@ -613,7 +613,7 @@ impl ObjectImpl for Cea608Overlay {
settings.timeout = match timeout {
u64::MAX => gst::ClockTime::NONE,
- _ => Some(gst::ClockTime::from_nseconds(timeout)),
+ _ => Some(timeout.nseconds()),
};
}
_ => unimplemented!(),
diff --git a/video/closedcaption/src/jsontovtt/imp.rs b/video/closedcaption/src/jsontovtt/imp.rs
index 842a055d..3f28c416 100644
--- a/video/closedcaption/src/jsontovtt/imp.rs
+++ b/video/closedcaption/src/jsontovtt/imp.rs
@@ -582,7 +582,7 @@ impl ObjectImpl for JsonToVtt {
vec![glib::ParamSpecUInt64::builder("timeout")
.nick("Timeout")
.blurb("Duration after which to erase text when no data has arrived")
- .minimum(gst::ClockTime::from_seconds(16).nseconds())
+ .minimum(16.seconds().nseconds())
.default_value(u64::MAX)
.mutable_playing()
.build()]
@@ -601,7 +601,7 @@ impl ObjectImpl for JsonToVtt {
settings.timeout = match timeout {
u64::MAX => gst::ClockTime::NONE,
- _ => Some(gst::ClockTime::from_nseconds(timeout)),
+ _ => Some(timeout.nseconds()),
};
state.settings.timeout = settings.timeout;
}
@@ -707,15 +707,12 @@ mod tests {
let segment = gst::FormattedSegment::<gst::ClockTime>::new();
- let pts: gst::ClockTime = gst::ClockTime::from_nseconds(0);
- let duration: Option<gst::ClockTime> = Some(gst::ClockTime::from_nseconds(10));
+ let pts = gst::ClockTime::ZERO;
+ let duration = Some(10.nseconds());
assert_eq!(
clamp(&segment, pts, duration),
- Some((
- gst::ClockTime::from_nseconds(0),
- Some(gst::ClockTime::from_nseconds(10))
- ))
+ Some((gst::ClockTime::ZERO, Some(10.nseconds())))
);
}
@@ -724,17 +721,14 @@ mod tests {
gst::init().unwrap();
let mut segment = gst::FormattedSegment::<gst::ClockTime>::new();
- segment.set_start(gst::ClockTime::from_nseconds(2));
+ segment.set_start(2.nseconds());
- let pts = gst::ClockTime::from_nseconds(0);
- let duration = Some(gst::ClockTime::from_nseconds(10));
+ let pts = gst::ClockTime::ZERO;
+ let duration = Some(10.nseconds());
assert_eq!(
clamp(&segment, pts, duration),
- Some((
- gst::ClockTime::from_nseconds(2),
- Some(gst::ClockTime::from_nseconds(8))
- ))
+ Some((2.nseconds(), Some(8.nseconds())))
);
}
@@ -743,17 +737,14 @@ mod tests {
gst::init().unwrap();
let mut segment = gst::FormattedSegment::<gst::ClockTime>::new();
- segment.set_stop(gst::ClockTime::from_nseconds(7));
+ segment.set_stop(7.nseconds());
- let pts = gst::ClockTime::from_nseconds(0);
- let duration = Some(gst::ClockTime::from_nseconds(10));
+ let pts = gst::ClockTime::ZERO;
+ let duration = Some(10.nseconds());
assert_eq!(
clamp(&segment, pts, duration),
- Some((
- gst::ClockTime::from_nseconds(0),
- Some(gst::ClockTime::from_nseconds(7))
- ))
+ Some((gst::ClockTime::ZERO, Some(7.nseconds())))
);
}
@@ -762,18 +753,15 @@ mod tests {
gst::init().unwrap();
let mut segment = gst::FormattedSegment::<gst::ClockTime>::new();
- segment.set_start(gst::ClockTime::from_nseconds(2));
- segment.set_stop(gst::ClockTime::from_nseconds(7));
+ segment.set_start(2.nseconds());
+ segment.set_stop(7.nseconds());
- let pts = gst::ClockTime::from_nseconds(0);
- let duration = Some(gst::ClockTime::from_nseconds(10));
+ let pts = gst::ClockTime::ZERO;
+ let duration = Some(10.nseconds());
assert_eq!(
clamp(&segment, pts, duration),
- Some((
- gst::ClockTime::from_nseconds(2),
- Some(gst::ClockTime::from_nseconds(5))
- ))
+ Some((2.nseconds(), Some(5.nseconds())))
);
}
@@ -782,10 +770,10 @@ mod tests {
gst::init().unwrap();
let mut segment = gst::FormattedSegment::<gst::ClockTime>::new();
- segment.set_start(gst::ClockTime::from_nseconds(15));
+ segment.set_start(15.nseconds());
- let pts = gst::ClockTime::from_nseconds(0);
- let duration = Some(gst::ClockTime::from_nseconds(10));
+ let pts = gst::ClockTime::ZERO;
+ let duration = Some(10.nseconds());
assert_eq!(clamp(&segment, pts, duration), None);
}
@@ -795,10 +783,10 @@ mod tests {
gst::init().unwrap();
let mut segment = gst::FormattedSegment::<gst::ClockTime>::new();
- segment.set_stop(gst::ClockTime::from_nseconds(10));
+ segment.set_stop(10.nseconds());
- let pts = gst::ClockTime::from_nseconds(15);
- let duration = Some(gst::ClockTime::from_nseconds(10));
+ let pts = 15.nseconds();
+ let duration = Some(10.nseconds());
assert_eq!(clamp(&segment, pts, duration), None);
}
diff --git a/video/closedcaption/src/transcriberbin/imp.rs b/video/closedcaption/src/transcriberbin/imp.rs
index 07710c96..251cc278 100644
--- a/video/closedcaption/src/transcriberbin/imp.rs
+++ b/video/closedcaption/src/transcriberbin/imp.rs
@@ -220,9 +220,7 @@ impl TranscriberBin {
self.instance().add(&state.internal_bin)?;
- state
- .cccombiner
- .set_property("latency", 100 * gst::ClockTime::MSECOND);
+ state.cccombiner.set_property("latency", 100.mseconds());
self.audio_sinkpad
.set_target(Some(&state.internal_bin.static_pad("audio_sink").unwrap()))?;
diff --git a/video/closedcaption/src/tttocea608/imp.rs b/video/closedcaption/src/tttocea608/imp.rs
index c1b6d90f..ee89f42a 100644
--- a/video/closedcaption/src/tttocea608/imp.rs
+++ b/video/closedcaption/src/tttocea608/imp.rs
@@ -204,7 +204,9 @@ impl State {
let (fps_n, fps_d) = (self.framerate.numer() as u64, self.framerate.denom() as u64);
- let pts = (self.last_frame_no * gst::ClockTime::SECOND)
+ let pts = self
+ .last_frame_no
+ .seconds()
.mul_div_round(fps_d, fps_n)
.unwrap();
@@ -214,7 +216,9 @@ impl State {
gst::debug!(CAT, imp: imp, "More text than bandwidth!");
}
- let next_pts = (self.last_frame_no * gst::ClockTime::SECOND)
+ let next_pts = self
+ .last_frame_no
+ .seconds()
.mul_div_round(fps_d, fps_n)
.unwrap();
@@ -1065,7 +1069,7 @@ impl ObjectImpl for TtToCea608 {
settings.roll_up_timeout = match timeout {
u64::MAX => gst::ClockTime::NONE,
- _ => Some(gst::ClockTime::from_nseconds(timeout)),
+ _ => Some(timeout.nseconds()),
};
}
_ => unimplemented!(),
diff --git a/video/closedcaption/tests/ccdetect.rs b/video/closedcaption/tests/ccdetect.rs
index 57069273..5d8c9444 100644
--- a/video/closedcaption/tests/ccdetect.rs
+++ b/video/closedcaption/tests/ccdetect.rs
@@ -78,34 +78,13 @@ fn test_have_cc_data_notify() {
assert_push_data!(h, state, valid_cc608_data, ClockTime::ZERO, 1, 0);
/* invalid cc608 data moves cc608 property to false */
- assert_push_data!(
- h,
- state,
- invalid_cc608_data,
- ClockTime::from_nseconds(1_000_000_000),
- 2,
- 0
- );
+ assert_push_data!(h, state, invalid_cc608_data, 1_000_000_000.nseconds(), 2, 0);
/* valid cc708 data moves cc708 property to true */
- assert_push_data!(
- h,
- state,
- valid_cc708_data,
- ClockTime::from_nseconds(2_000_000_000),
- 2,
- 1
- );
+ assert_push_data!(h, state, valid_cc708_data, 2_000_000_000.nseconds(), 2, 1);
/* invalid cc708 data moves cc708 property to false */
- assert_push_data!(
- h,
- state,
- invalid_cc708_data,
- ClockTime::from_nseconds(3_000_000_000),
- 2,
- 2
- );
+ assert_push_data!(h, state, invalid_cc708_data, 3_000_000_000.nseconds(), 2, 2);
}
#[test]
@@ -143,7 +122,7 @@ fn test_cc_data_window() {
h,
state,
valid_cc608_data.clone(),
- ClockTime::from_nseconds(300_000_000),
+ 300_000_000.nseconds(),
1,
0
);
@@ -153,40 +132,26 @@ fn test_cc_data_window() {
h,
state,
invalid_cc608_data.clone(),
- ClockTime::from_nseconds(600_000_000),
+ 600_000_000.nseconds(),
1,
0
);
/* invalid cc608 data after window expires, cc608 changes to false */
- assert_push_data!(
- h,
- state,
- invalid_cc608_data,
- ClockTime::from_nseconds(1_000_000_000),
- 2,
- 0
- );
+ assert_push_data!(h, state, invalid_cc608_data, 1_000_000_000.nseconds(), 2, 0);
/* valid cc608 data before window expires, no change */
assert_push_data!(
h,
state,
valid_cc608_data.clone(),
- ClockTime::from_nseconds(1_300_000_000),
+ 1_300_000_000.nseconds(),
2,
0
);
/* valid cc608 data after window expires, property changes */
- assert_push_data!(
- h,
- state,
- valid_cc608_data,
- ClockTime::from_nseconds(1_600_000_000),
- 3,
- 0
- );
+ assert_push_data!(h, state, valid_cc608_data, 1_600_000_000.nseconds(), 3, 0);
}
#[test]
@@ -235,14 +200,7 @@ fn test_have_cdp_notify() {
assert_push_data!(h, state, valid_cc608_data, ClockTime::ZERO, 1, 0);
/* invalid cc608 data moves cc608 property to false */
- assert_push_data!(
- h,
- state,
- invalid_cc608_data,
- ClockTime::from_nseconds(1_000_000_000),
- 2,
- 0
- );
+ assert_push_data!(h, state, invalid_cc608_data, 1_000_000_000.nseconds(), 2, 0);
}
#[test]
@@ -300,56 +258,21 @@ fn test_malformed_cdp_notify() {
});
/* all invalid data does not change properties */
- assert_push_data!(h, state, too_short, ClockTime::from_nseconds(0), 0, 0);
- assert_push_data!(h, state, wrong_magic, ClockTime::from_nseconds(1_000), 0, 0);
- assert_push_data!(
- h,
- state,
- length_too_long,
- ClockTime::from_nseconds(2_000),
- 0,
- 0
- );
- assert_push_data!(
- h,
- state,
- length_too_short,
- ClockTime::from_nseconds(3_000),
- 0,
- 0
- );
- assert_push_data!(
- h,
- state,
- wrong_cc_data_header_byte,
- ClockTime::from_nseconds(4_000),
- 0,
- 0
- );
- assert_push_data!(
- h,
- state,
- big_cc_count,
- ClockTime::from_nseconds(5_000),
- 0,
- 0
- );
+ assert_push_data!(h, state, too_short, ClockTime::ZERO, 0, 0);
+ assert_push_data!(h, state, wrong_magic, 1_000.nseconds(), 0, 0);
+ assert_push_data!(h, state, length_too_long, 2_000.nseconds(), 0, 0);
+ assert_push_data!(h, state, length_too_short, 3_000.nseconds(), 0, 0);
+ assert_push_data!(h, state, wrong_cc_data_header_byte, 4_000.nseconds(), 0, 0);
+ assert_push_data!(h, state, big_cc_count, 5_000.nseconds(), 0, 0);
assert_push_data!(
h,
state,
wrong_cc_count_reserved_bits,
- ClockTime::from_nseconds(6_000),
- 0,
- 0
- );
- assert_push_data!(
- h,
- state,
- cc608_after_cc708,
- ClockTime::from_nseconds(7_000),
+ 6_000.nseconds(),
0,
0
);
+ assert_push_data!(h, state, cc608_after_cc708, 7_000.nseconds(), 0, 0);
}
#[test]
@@ -382,10 +305,7 @@ fn test_gap_events() {
assert_push_data!(h, state, valid_cc608_data, ClockTime::ZERO, 1, 0);
/* pushing gap event within the window changes nothing */
- assert!(h.push_event(gst::event::Gap::new(
- ClockTime::from_nseconds(100_000_000),
- ClockTime::from_nseconds(1)
- )),);
+ assert!(h.push_event(gst::event::Gap::new(100_000_000.nseconds(), 1.nseconds())));
{
let state_guard = state.lock().unwrap();
@@ -394,10 +314,7 @@ fn test_gap_events() {
}
/* pushing gap event outside the window moves cc608 property to false */
- assert!(h.push_event(gst::event::Gap::new(
- ClockTime::from_nseconds(1_000_000_000),
- ClockTime::from_nseconds(1)
- )),);
+ assert!(h.push_event(gst::event::Gap::new(1_000_000_000.nseconds(), 1.nseconds())));
{
let state_guard = state.lock().unwrap();
diff --git a/video/closedcaption/tests/cea608tott.rs b/video/closedcaption/tests/cea608tott.rs
index b3169b8b..01db571d 100644
--- a/video/closedcaption/tests/cea608tott.rs
+++ b/video/closedcaption/tests/cea608tott.rs
@@ -36,23 +36,23 @@ fn test_parse() {
// Check the first 4 output buffers
let expected: [(ClockTime, ClockTime, &'static str); 4] = [
(
- ClockTime::from_nseconds(15_048_366_666),
- ClockTime::from_nseconds(3_236_566_667),
+ 15_048_366_666.nseconds(),
+ 3_236_566_667.nseconds(),
"From New York,\r\nthis is Democracy Now!",
),
(
- ClockTime::from_nseconds(18_985_633_333),
- ClockTime::from_nseconds(1_234_566_667),
+ 18_985_633_333.nseconds(),
+ 1_234_566_667.nseconds(),
"Yes, I’m supporting\r\nDonald Trump.",
),
(
- ClockTime::from_nseconds(20_220_200_000),
- ClockTime::from_nseconds(2_168_833_333),
+ 20_220_200_000.nseconds(),
+ 2_168_833_333.nseconds(),
"I’m doing so as enthusiastically\r\nas I can,",
),
(
- ClockTime::from_nseconds(22_389_033_333),
- ClockTime::from_nseconds(2_235_566_667),
+ 22_389_033_333.nseconds(),
+ 2_235_566_667.nseconds(),
"even the fact I think\r\nhe’s a terrible human being.",
),
];
diff --git a/video/closedcaption/tests/mcc_enc.rs b/video/closedcaption/tests/mcc_enc.rs
index a35a50f2..c00f053b 100644
--- a/video/closedcaption/tests/mcc_enc.rs
+++ b/video/closedcaption/tests/mcc_enc.rs
@@ -111,7 +111,7 @@ Time Code Rate=30DF\r\n\
let mut buf = gst::Buffer::from_mut_slice(Vec::from(input));
let buf_ref = buf.get_mut().unwrap();
gst_video::VideoTimeCodeMeta::add(buf_ref, &tc);
- buf_ref.set_pts(gst::ClockTime::from_seconds(0));
+ buf_ref.set_pts(gst::ClockTime::ZERO);
buf
};
diff --git a/video/closedcaption/tests/mcc_parse.rs b/video/closedcaption/tests/mcc_parse.rs
index 4ea00974..8c67fae8 100644
--- a/video/closedcaption/tests/mcc_parse.rs
+++ b/video/closedcaption/tests/mcc_parse.rs
@@ -170,7 +170,7 @@ fn test_pull() {
gst::SeekType::Set,
gst::ClockTime::SECOND,
gst::SeekType::Set,
- 2 * gst::ClockTime::SECOND,
+ 2.seconds(),
));
loop {
@@ -179,7 +179,7 @@ fn test_pull() {
while h.buffers_in_queue() != 0 {
if let Ok(buffer) = h.pull() {
let pts = buffer.pts().unwrap();
- assert!(pts > gst::ClockTime::SECOND && pts < 2 * gst::ClockTime::SECOND);
+ assert!(pts > gst::ClockTime::SECOND && pts < 2.seconds());
}
}
diff --git a/video/closedcaption/tests/scc_enc.rs b/video/closedcaption/tests/scc_enc.rs
index 33a068e4..b23e9d70 100644
--- a/video/closedcaption/tests/scc_enc.rs
+++ b/video/closedcaption/tests/scc_enc.rs
@@ -45,7 +45,7 @@ fn test_encode_single_packet() {
let mut buf = gst::Buffer::from_mut_slice(Vec::from(&input[..]));
let buf_ref = buf.get_mut().unwrap();
gst_video::VideoTimeCodeMeta::add(buf_ref, &tc);
- buf_ref.set_pts(gst::ClockTime::from_seconds(0));
+ buf_ref.set_pts(gst::ClockTime::ZERO);
buf
};
@@ -117,7 +117,7 @@ fn test_encode_multiple_packets() {
let mut buf = gst::Buffer::from_mut_slice(Vec::from(&input1[..]));
let buf_ref = buf.get_mut().unwrap();
gst_video::VideoTimeCodeMeta::add(buf_ref, &tc1);
- buf_ref.set_pts(gst::ClockTime::from_seconds(0));
+ buf_ref.set_pts(gst::ClockTime::ZERO);
buf
};
@@ -127,7 +127,7 @@ fn test_encode_multiple_packets() {
let mut tc = tc1.clone();
tc.increment_frame();
gst_video::VideoTimeCodeMeta::add(buf_ref, &tc);
- buf_ref.set_pts(gst::ClockTime::from_seconds(0));
+ buf_ref.set_pts(gst::ClockTime::ZERO);
buf
};
diff --git a/video/closedcaption/tests/scc_parse.rs b/video/closedcaption/tests/scc_parse.rs
index 63b04ca5..542ed711 100644
--- a/video/closedcaption/tests/scc_parse.rs
+++ b/video/closedcaption/tests/scc_parse.rs
@@ -235,9 +235,9 @@ fn test_pull() {
1.0,
gst::SeekFlags::FLUSH,
gst::SeekType::Set,
- 18 * gst::ClockTime::SECOND,
+ 18.seconds(),
gst::SeekType::Set,
- 19 * gst::ClockTime::SECOND,
+ 19.seconds(),
));
loop {
@@ -248,9 +248,7 @@ fn test_pull() {
let pts = buffer.pts().unwrap();
let end_time = pts + buffer.duration().unwrap();
- assert!(
- end_time >= 18 * gst::ClockTime::SECOND && pts < 19 * gst::ClockTime::SECOND
- );
+ assert!(end_time >= 18.seconds() && pts < 19.seconds());
}
}
diff --git a/video/closedcaption/tests/tttocea608.rs b/video/closedcaption/tests/tttocea608.rs
index 17b5d384..89ccff61 100644
--- a/video/closedcaption/tests/tttocea608.rs
+++ b/video/closedcaption/tests/tttocea608.rs
@@ -6,6 +6,7 @@
//
// SPDX-License-Identifier: MPL-2.0
+use gst::prelude::*;
use gst::ClockTime;
use pretty_assertions::assert_eq;
@@ -61,38 +62,38 @@ fn test_one_timed_buffer_and_eos() {
let expected: [(ClockTime, ClockTime, [u8; 2usize]); 7] = [
(
- ClockTime::from_nseconds(1_000_000_000),
- ClockTime::from_nseconds(33_333_333),
+ 1_000_000_000.nseconds(),
+ 33_333_333.nseconds(),
[0x94, 0x20],
), /* resume_caption_loading */
(
- ClockTime::from_nseconds(1_033_333_333),
- ClockTime::from_nseconds(33_333_334),
+ 1_033_333_333.nseconds(),
+ 33_333_334.nseconds(),
[0x94, 0xae],
), /* erase_non_displayed_memory */
(
- ClockTime::from_nseconds(1_066_666_667),
- ClockTime::from_nseconds(33_333_333),
+ 1_066_666_667.nseconds(),
+ 33_333_333.nseconds(),
[0x94, 0x70],
), /* preamble */
(
- ClockTime::from_nseconds(1_100_000_000),
- ClockTime::from_nseconds(33_333_333),
+ 1_100_000_000.nseconds(),
+ 33_333_333.nseconds(),
[0xc8, 0xe5],
), /* H e */
(
- ClockTime::from_nseconds(1_133_333_333),
- ClockTime::from_nseconds(33_333_334),
+ 1_133_333_333.nseconds(),
+ 33_333_334.nseconds(),
[0xec, 0xec],
), /* l l */
(
- ClockTime::from_nseconds(1_166_666_667),
- ClockTime::from_nseconds(33_333_333),
+ 1_166_666_667.nseconds(),
+ 33_333_333.nseconds(),
[0xef, 0x80],
), /* o, nil */
(
- ClockTime::from_nseconds(1_200_000_000),
- ClockTime::from_nseconds(33_333_333),
+ 1_200_000_000.nseconds(),
+ 33_333_333.nseconds(),
[0x94, 0x2f],
), /* end_of_caption */
];
@@ -125,7 +126,7 @@ fn test_one_timed_buffer_and_eos() {
loop {
let outbuf = h.try_pull().unwrap();
let data = outbuf.map_readable().unwrap();
- if outbuf.pts().unwrap() == ClockTime::from_nseconds(2_200_000_000) {
+ if outbuf.pts().unwrap() == 2_200_000_000.nseconds() {
assert_eq!(&*data, &[0x94, 0x2c]);
break;
} else {
@@ -154,18 +155,10 @@ fn test_erase_display_memory_non_spliced() {
let _event = h.pull_event().unwrap();
}
- let inbuf = new_timed_buffer(
- &"Hello",
- ClockTime::from_nseconds(1_000_000_000),
- ClockTime::SECOND,
- );
+ let inbuf = new_timed_buffer(&"Hello", 1_000_000_000.nseconds(), ClockTime::SECOND);
assert_eq!(h.push(inbuf), Ok(gst::FlowSuccess::Ok));
- let inbuf = new_timed_buffer(
- &"World",
- ClockTime::from_nseconds(3_000_000_000),
- ClockTime::SECOND,
- );
+ let inbuf = new_timed_buffer(&"World", 3_000_000_000.nseconds(), ClockTime::SECOND);
assert_eq!(h.push(inbuf), Ok(gst::FlowSuccess::Ok));
let mut erase_display_buffers = 0;
@@ -173,7 +166,7 @@ fn test_erase_display_memory_non_spliced() {
while h.buffers_in_queue() > 0 {
let outbuf = h.pull().unwrap();
- if outbuf.pts().unwrap() == ClockTime::from_nseconds(2_200_000_000) {
+ if outbuf.pts().unwrap() == 2_200_000_000.nseconds() {
let data = outbuf.map_readable().unwrap();
assert_eq!(&*data, &[0x94, 0x2c]);
erase_display_buffers += 1;
@@ -204,16 +197,12 @@ fn test_erase_display_memory_spliced() {
let _event = h.pull_event().unwrap();
}
- let inbuf = new_timed_buffer(
- &"Hello",
- ClockTime::from_nseconds(1_000_000_000),
- ClockTime::SECOND,
- );
+ let inbuf = new_timed_buffer(&"Hello", 1_000_000_000.nseconds(), ClockTime::SECOND);
assert_eq!(h.push(inbuf), Ok(gst::FlowSuccess::Ok));
let inbuf = new_timed_buffer(
&"World, Lorem Ipsum",
- ClockTime::from_nseconds(2_000_000_000),
+ 2_000_000_000.nseconds(),
ClockTime::SECOND,
);
assert_eq!(h.push(inbuf), Ok(gst::FlowSuccess::Ok));
@@ -228,7 +217,7 @@ fn test_erase_display_memory_spliced() {
let pts = outbuf.pts().unwrap();
assert!(pts >= prev_pts);
- if pts == ClockTime::from_nseconds(2_200_000_000) {
+ if pts == 2_200_000_000.nseconds() {
let data = outbuf.map_readable().unwrap();
assert_eq!(&*data, &[0x94, 0x2c]);
erase_display_buffers += 1;
@@ -254,18 +243,10 @@ fn test_output_gaps() {
let _event = h.pull_event().unwrap();
}
- let inbuf = new_timed_buffer(
- &"Hello",
- ClockTime::from_nseconds(1_000_000_000),
- ClockTime::SECOND,
- );
+ let inbuf = new_timed_buffer(&"Hello", 1_000_000_000.nseconds(), ClockTime::SECOND);
assert_eq!(h.push(inbuf), Ok(gst::FlowSuccess::Ok));
- let inbuf = new_timed_buffer(
- &"World",
- ClockTime::from_nseconds(3_000_000_000),
- ClockTime::SECOND,
- );
+ let inbuf = new_timed_buffer(&"World", 3_000_000_000.nseconds(), ClockTime::SECOND);
assert_eq!(h.push(inbuf), Ok(gst::FlowSuccess::Ok));
h.push_event(gst::event::Eos::new());
@@ -284,9 +265,7 @@ fn test_output_gaps() {
/* Hello */
loop {
let outbuf = h.pull().unwrap();
- if outbuf.pts().unwrap() + outbuf.duration().unwrap()
- >= ClockTime::from_nseconds(1_233_333_333)
- {
+ if outbuf.pts().unwrap() + outbuf.duration().unwrap() >= 1_233_333_333.nseconds() {
break;
}
@@ -297,14 +276,12 @@ fn test_output_gaps() {
/* Padding */
loop {
let outbuf = h.pull().unwrap();
- if outbuf.pts().unwrap() + outbuf.duration().unwrap()
- >= ClockTime::from_nseconds(3_000_000_000)
- {
+ if outbuf.pts().unwrap() + outbuf.duration().unwrap() >= 3_000_000_000.nseconds() {
break;
}
let data = outbuf.map_readable().unwrap();
- if outbuf.pts().unwrap() == ClockTime::from_nseconds(2_200_000_000) {
+ if outbuf.pts().unwrap() == 2_200_000_000.nseconds() {
/* Erase display one second after Hello */
assert_eq!(&*data, &[0x94, 0x2C]);
} else {
@@ -315,9 +292,7 @@ fn test_output_gaps() {
/* World */
loop {
let outbuf = h.pull().unwrap();
- if outbuf.pts().unwrap() + outbuf.duration().unwrap()
- >= ClockTime::from_nseconds(3_233_333_333)
- {
+ if outbuf.pts().unwrap() + outbuf.duration().unwrap() >= 3_233_333_333.nseconds() {
break;
}
@@ -345,33 +320,33 @@ fn test_one_timed_buffer_and_eos_roll_up2() {
let inbuf = new_timed_buffer(&"Hello", ClockTime::SECOND, ClockTime::SECOND);
assert_eq!(h.push(inbuf), Ok(gst::FlowSuccess::Ok));
- let inbuf = new_timed_buffer(&"World", 2 * ClockTime::SECOND, ClockTime::from_nseconds(1));
+ let inbuf = new_timed_buffer(&"World", 2.seconds(), 1.nseconds());
assert_eq!(h.push(inbuf), Ok(gst::FlowSuccess::Ok));
let expected: [(ClockTime, ClockTime, [u8; 2usize]); 5] = [
(
- ClockTime::from_nseconds(1_000_000_000),
- ClockTime::from_nseconds(33_333_333),
+ 1_000_000_000.nseconds(),
+ 33_333_333.nseconds(),
[0x94, 0x25],
), /* roll_up_2 */
(
- ClockTime::from_nseconds(1_033_333_333),
- ClockTime::from_nseconds(33_333_334),
+ 1_033_333_333.nseconds(),
+ 33_333_334.nseconds(),
[0x94, 0x70],
), /* preamble */
(
- ClockTime::from_nseconds(1_066_666_667),
- ClockTime::from_nseconds(33_333_333),
+ 1_066_666_667.nseconds(),
+ 33_333_333.nseconds(),
[0xc8, 0xe5],
), /* H e */
(
- ClockTime::from_nseconds(1_100_000_000),
- ClockTime::from_nseconds(33_333_333),
+ 1_100_000_000.nseconds(),
+ 33_333_333.nseconds(),
[0xec, 0xec],
), /* l l */
(
- ClockTime::from_nseconds(1_133_333_333),
- ClockTime::from_nseconds(33_333_334),
+ 1_133_333_333.nseconds(),
+ 33_333_334.nseconds(),
[0xef, 0x80],
), /* o nil */
];
@@ -399,7 +374,7 @@ fn test_one_timed_buffer_and_eos_roll_up2() {
/* Padding */
loop {
let outbuf = h.pull().unwrap();
- if outbuf.pts().unwrap() + outbuf.duration().unwrap() >= 2 * ClockTime::SECOND {
+ if outbuf.pts().unwrap() + outbuf.duration().unwrap() >= 2.seconds() {
break;
}
@@ -408,21 +383,9 @@ fn test_one_timed_buffer_and_eos_roll_up2() {
}
let expected: [(ClockTime, ClockTime, [u8; 2usize]); 3] = [
- (
- ClockTime::from_nseconds(2_000_000_000),
- ClockTime::ZERO,
- [0x20, 0x57],
- ), /* SPACE W */
- (
- ClockTime::from_nseconds(2_000_000_000),
- ClockTime::ZERO,
- [0xef, 0xf2],
- ), /* o r */
- (
- ClockTime::from_nseconds(2_000_000_000),
- ClockTime::ZERO,
- [0xec, 0x64],
- ), /* l d */
+ (2_000_000_000.nseconds(), ClockTime::ZERO, [0x20, 0x57]), /* SPACE W */
+ (2_000_000_000.nseconds(), ClockTime::ZERO, [0xef, 0xf2]), /* o r */
+ (2_000_000_000.nseconds(), ClockTime::ZERO, [0xec, 0x64]), /* l d */
];
for (i, e) in expected.iter().enumerate() {
@@ -475,58 +438,58 @@ fn test_word_wrap_roll_up() {
let expected: [(ClockTime, ClockTime, [u8; 2usize]); 11] = [
(
- ClockTime::from_nseconds(1_000_000_000),
- ClockTime::from_nseconds(33_333_333),
+ 1_000_000_000.nseconds(),
+ 33_333_333.nseconds(),
[0x94, 0x25],
), /* roll_up_2 */
(
- ClockTime::from_nseconds(1_033_333_333),
- ClockTime::from_nseconds(33_333_334),
+ 1_033_333_333.nseconds(),
+ 33_333_334.nseconds(),
[0x94, 0x7c],
), /* preamble */
(
- ClockTime::from_nseconds(1_066_666_667),
- ClockTime::from_nseconds(33_333_333),
+ 1_066_666_667.nseconds(),
+ 33_333_333.nseconds(),
[0xc8, 0xe5],
), /* H e */
(
- ClockTime::from_nseconds(1_100_000_000),
- ClockTime::from_nseconds(33_333_333),
+ 1_100_000_000.nseconds(),
+ 33_333_333.nseconds(),
[0xec, 0xec],
), /* l l */
(
- ClockTime::from_nseconds(1_133_333_333),
- ClockTime::from_nseconds(33_333_334),
+ 1_133_333_333.nseconds(),
+ 33_333_334.nseconds(),
[0xef, 0x20],
), /* o SPACE */
(
- ClockTime::from_nseconds(1_166_666_667),
- ClockTime::from_nseconds(33_333_333),
+ 1_166_666_667.nseconds(),
+ 33_333_333.nseconds(),
[0x94, 0xad],
), /* carriage return */
(
- ClockTime::from_nseconds(1_200_000_000),
- ClockTime::from_nseconds(33_333_333),
+ 1_200_000_000.nseconds(),
+ 33_333_333.nseconds(),
[0x94, 0x25],
), /* roll_up_2 */
(
- ClockTime::from_nseconds(1_233_333_333),
- ClockTime::from_nseconds(33_333_334),
+ 1_233_333_333.nseconds(),
+ 33_333_334.nseconds(),
[0x94, 0x7c],
), /* preamble */
(
- ClockTime::from_nseconds(1_266_666_667),
- ClockTime::from_nseconds(33_333_333),
+ 1_266_666_667.nseconds(),
+ 33_333_333.nseconds(),
[0x57, 0xef],
), /* W o */
(
- ClockTime::from_nseconds(1_300_000_000),
- ClockTime::from_nseconds(33_333_333),
+ 1_300_000_000.nseconds(),
+ 33_333_333.nseconds(),
[0xf2, 0xec],
), /* r l */
(
- ClockTime::from_nseconds(1_333_333_333),
- ClockTime::from_nseconds(33_333_334),
+ 1_333_333_333.nseconds(),
+ 33_333_334.nseconds(),
[0x64, 0x80],
), /* d nil */
];
diff --git a/video/dav1d/src/dav1ddec/imp.rs b/video/dav1d/src/dav1ddec/imp.rs
index 21115868..1fa7ea8a 100644
--- a/video/dav1d/src/dav1ddec/imp.rs
+++ b/video/dav1d/src/dav1ddec/imp.rs
@@ -344,7 +344,7 @@ impl Dav1dDec {
out_buffer
.get_mut()
.unwrap()
- .set_duration(gst::ClockTime::from_nseconds(duration));
+ .set_duration(duration.nseconds());
}
Ok(out_buffer)
@@ -614,9 +614,7 @@ impl VideoDecoderImpl for Dav1dDec {
n => n,
};
- let latency = frame_latency
- * (info.fps().denom() as u64)
- * gst::ClockTime::SECOND
+ let latency = frame_latency * (info.fps().denom() as u64).seconds()
/ (fps_n as u64);
gst::debug!(CAT, imp: self, "Reporting latency of {}", latency);
diff --git a/video/flavors/src/flvdemux/imp.rs b/video/flavors/src/flvdemux/imp.rs
index 7905a969..67d2f7d9 100644
--- a/video/flavors/src/flvdemux/imp.rs
+++ b/video/flavors/src/flvdemux/imp.rs
@@ -936,7 +936,7 @@ impl StreamingState {
{
let buffer = buffer.get_mut().unwrap();
- buffer.set_pts(gst::ClockTime::from_mseconds(tag_header.timestamp as u64));
+ buffer.set_pts((tag_header.timestamp as u64).mseconds());
}
gst::trace!(
@@ -1130,7 +1130,7 @@ impl StreamingState {
if !is_keyframe {
buffer.set_flags(gst::BufferFlags::DELTA_UNIT);
}
- buffer.set_dts(gst::ClockTime::from_mseconds(tag_header.timestamp as u64));
+ buffer.set_dts((tag_header.timestamp as u64).mseconds());
// Prevent negative numbers
let pts = if cts < 0 && tag_header.timestamp < (-cts) as u32 {
@@ -1138,7 +1138,7 @@ impl StreamingState {
} else {
((tag_header.timestamp as i64) + (cts as i64)) as u64
};
- buffer.set_pts(gst::ClockTime::from_mseconds(pts));
+ buffer.set_pts(pts.mseconds());
}
gst::trace!(
@@ -1487,9 +1487,8 @@ impl Metadata {
for arg in args {
match (arg.name, &arg.data) {
("duration", &flavors::ScriptDataValue::Number(duration)) => {
- metadata.duration = Some(gst::ClockTime::from_nseconds(
- (duration * 1000.0 * 1000.0 * 1000.0) as u64,
- ));
+ metadata.duration =
+ Some(((duration * 1000.0 * 1000.0 * 1000.0) as u64).nseconds());
}
("creationdate", &flavors::ScriptDataValue::String(date)) => {
metadata.creation_date = Some(String::from(date));
diff --git a/video/gif/src/gifenc/imp.rs b/video/gif/src/gifenc/imp.rs
index 64435a50..043fa114 100644
--- a/video/gif/src/gifenc/imp.rs
+++ b/video/gif/src/gifenc/imp.rs
@@ -375,7 +375,7 @@ impl VideoEncoderImpl for GifEnc {
gif_frame.delay = (frame_delay.mseconds() as f32 / 10.0).round() as u16;
state.gif_pts = state
.gif_pts
- .opt_add(gst::ClockTime::from_mseconds(gif_frame.delay as u64 * 10));
+ .opt_add((gif_frame.delay as u64 * 10).mseconds());
// encode new frame
let context = state.context.as_mut().unwrap();
diff --git a/video/gif/tests/gifenc.rs b/video/gif/tests/gifenc.rs
index 8d9ce9a6..fd928e6d 100644
--- a/video/gif/tests/gifenc.rs
+++ b/video/gif/tests/gifenc.rs
@@ -8,6 +8,8 @@
//
// SPDX-License-Identifier: MIT OR Apache-2.0
+use gst::prelude::*;
+
fn init() {
use std::sync::Once;
static INIT: Once = Once::new();
@@ -48,7 +50,7 @@ fn test_encode(video_info: &gst_video::VideoInfo) {
let mut buffer = gst::Buffer::with_size(video_info.size()).unwrap();
{
let buffer = buffer.get_mut().unwrap();
- buffer.set_pts(gst::ClockTime::from_seconds(pts));
+ buffer.set_pts(pts.seconds());
}
let mut vframe =
gst_video::VideoFrame::from_buffer_writable(buffer, video_info).unwrap();
diff --git a/video/rspng/tests/pngenc.rs b/video/rspng/tests/pngenc.rs
index bcac6e1f..dabdb979 100644
--- a/video/rspng/tests/pngenc.rs
+++ b/video/rspng/tests/pngenc.rs
@@ -8,6 +8,8 @@
//
// SPDX-License-Identifier: MIT OR Apache-2.0
+use gst::prelude::*;
+
fn init() {
use std::sync::Once;
static INIT: Once = Once::new();
@@ -72,7 +74,7 @@ fn test_png_encode(video_info: &gst_video::VideoInfo) {
let mut buffer = gst::Buffer::with_size(video_info.size()).unwrap();
{
let buffer = buffer.get_mut().unwrap();
- buffer.set_pts(gst::ClockTime::from_seconds(pts));
+ buffer.set_pts(pts.seconds());
}
let mut vframe =
gst_video::VideoFrame::from_buffer_writable(buffer, video_info).unwrap();
diff --git a/video/webp/src/dec/imp.rs b/video/webp/src/dec/imp.rs
index 277f5692..645f71e7 100644
--- a/video/webp/src/dec/imp.rs
+++ b/video/webp/src/dec/imp.rs
@@ -203,7 +203,7 @@ impl WebPDec {
gst::error_msg!(gst::StreamError::Decode, ["Failed to get next frame"])
})?;
- let timestamp = frame.timestamp as u64 * gst::ClockTime::MSECOND;
+ let timestamp = (frame.timestamp as u64).mseconds();
let duration =
prev_timestamp.and_then(|prev_timestamp| timestamp.checked_sub(prev_timestamp));
diff --git a/video/webp/tests/webpdec.rs b/video/webp/tests/webpdec.rs
index a7b4e2c6..95451faf 100644
--- a/video/webp/tests/webpdec.rs
+++ b/video/webp/tests/webpdec.rs
@@ -33,7 +33,7 @@ fn test_decode() {
let mut expected_timestamp: Option<gst::ClockTime> = Some(gst::ClockTime::ZERO);
let mut count = 0;
- let expected_duration: Option<gst::ClockTime> = Some(gst::ClockTime::from_nseconds(40_000_000));
+ let expected_duration: Option<gst::ClockTime> = Some(40_000_000.nseconds());
while let Some(buf) = h.try_pull() {
assert_eq!(buf.pts(), expected_timestamp);