Use new format constructors

See https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1128
This commit is contained in:
François Laignel 2022-10-17 19:48:43 +02:00 committed by François Laignel
parent e66378d254
commit 8011eadfd2
58 changed files with 593 additions and 1024 deletions

View file

@ -137,14 +137,12 @@ impl ObjectImpl for AudioEcho {
"max-delay" => { "max-delay" => {
let mut settings = self.settings.lock().unwrap(); let mut settings = self.settings.lock().unwrap();
if self.state.lock().unwrap().is_none() { if self.state.lock().unwrap().is_none() {
settings.max_delay = settings.max_delay = value.get::<u64>().unwrap().nseconds();
gst::ClockTime::from_nseconds(value.get().expect("type checked upstream"));
} }
} }
"delay" => { "delay" => {
let mut settings = self.settings.lock().unwrap(); let mut settings = self.settings.lock().unwrap();
settings.delay = settings.delay = value.get::<u64>().unwrap().nseconds();
gst::ClockTime::from_nseconds(value.get().expect("type checked upstream"));
} }
"intensity" => { "intensity" => {
let mut settings = self.settings.lock().unwrap(); let mut settings = self.settings.lock().unwrap();

View file

@ -632,9 +632,7 @@ impl State {
// PTS is 2.9s seconds before the input PTS as we buffer 3s of samples and just // PTS is 2.9s seconds before the input PTS as we buffer 3s of samples and just
// outputted here the first 100ms of that. // outputted here the first 100ms of that.
let pts = pts let pts = pts.into().map(|pts| pts + 100.mseconds() - 3.seconds());
.into()
.map(|pts| pts + 100 * gst::ClockTime::MSECOND - 3 * gst::ClockTime::SECOND);
Ok((outbuf, pts)) 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 // PTS is 2.9s seconds before the input PTS as we buffer 3s of samples and just
// outputted here the first 100ms of that. // outputted here the first 100ms of that.
let pts = pts let pts = pts.into().map(|pts| pts + 100.mseconds() - 3.seconds());
.into()
.map(|pts| pts + 100 * gst::ClockTime::MSECOND - 3 * gst::ClockTime::SECOND);
Ok((outbuf, pts)) Ok((outbuf, pts))
} }
@ -1674,8 +1670,8 @@ impl AudioLoudNorm {
let (live, min_latency, max_latency) = peer_query.result(); let (live, min_latency, max_latency) = peer_query.result();
q.set( q.set(
live, live,
min_latency + 3 * gst::ClockTime::SECOND, min_latency + 3.seconds(),
max_latency.opt_add(3 * gst::ClockTime::SECOND), max_latency.opt_add(3.seconds()),
); );
true true
} else { } else {

View file

@ -340,8 +340,8 @@ impl BaseTransformImpl for AudioRNNoise {
max.display(), max.display(),
); );
min += gst::ClockTime::from_seconds((FRAME_SIZE / 48000) as u64); min += ((FRAME_SIZE / 48000) as u64).seconds();
max = max.opt_add(gst::ClockTime::from_seconds((FRAME_SIZE / 48000) as u64)); max = max.opt_add(((FRAME_SIZE / 48000) as u64).seconds());
q.set(live, min, max); q.set(live, min, max);
return true; return true;
} }

View file

@ -195,8 +195,7 @@ impl ObjectImpl for EbuR128Level {
settings.post_messages = post_messages; settings.post_messages = post_messages;
} }
"interval" => { "interval" => {
let interval = let interval = value.get::<u64>().unwrap().nseconds();
gst::ClockTime::from_nseconds(value.get().expect("type checked upstream"));
gst::info!( gst::info!(
CAT, CAT,
imp: self, imp: self,
@ -455,7 +454,7 @@ impl BaseTransformImpl for EbuR128Level {
gst::FlowError::Error 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; state.num_frames += to_process;
// The timestamp we report in messages is always the timestamp until which measurements // The timestamp we report in messages is always the timestamp until which measurements

View file

@ -151,7 +151,7 @@ fn run_test(
num_samples += data.len() / channels as usize; num_samples += data.len() / channels as usize;
r128.add_frames_f64(data).unwrap(); 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!( assert_eq!(

View file

@ -445,7 +445,7 @@ impl VideoStream {
enc.set_property("bframes", 0u32); enc.set_property("bframes", 0u32);
enc.set_property("bitrate", self.bitrate as u32 / 1000u32); enc.set_property("bitrate", self.bitrate as u32 / 1000u32);
enc.set_property_from_str("tune", "zerolatency"); 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_from_str("header-update-mode", "update");
mux.set_property("write-mehd", true); mux.set_property("write-mehd", true);
@ -477,7 +477,7 @@ impl AudioStream {
src.set_property("is-live", true); src.set_property("is-live", true);
src.set_property_from_str("wave", &self.wave); 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_from_str("header-update-mode", "update");
mux.set_property("write-mehd", true); mux.set_property("write-mehd", true);

View file

@ -339,7 +339,7 @@ impl VideoStream {
src.set_property("num-buffers", 300); src.set_property("num-buffers", 300);
enc.set_property("bframes", 0u32); enc.set_property("bframes", 0u32);
enc.set_property("bitrate", self.bitrate as u32 / 1000u32); 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_from_str("header-update-mode", "update");
mux.set_property("write-mehd", true); mux.set_property("write-mehd", true);
@ -378,7 +378,7 @@ impl AudioStream {
gst_audio::AudioCapsBuilder::new().rate(44100).build(), 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_from_str("header-update-mode", "update");
mux.set_property("write-mehd", true); mux.set_property("write-mehd", true);

View file

@ -459,7 +459,8 @@ fn caps_to_timescale(caps: &gst::CapsRef) -> u32 {
} }
if fps.denom() != 1 && fps.denom() != 1001 { 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) .mul_div_round(1_000_000_000, fps.numer() as u64)
.and_then(gst_video::guess_framerate) .and_then(gst_video::guess_framerate)
{ {

View file

@ -45,8 +45,7 @@ fn get_utc_time_from_buffer(buffer: &gst::BufferRef) -> Option<gst::ClockTime> {
if meta.reference().can_intersect(&UNIX_CAPS) { if meta.reference().can_intersect(&UNIX_CAPS) {
Some(meta.timestamp()) Some(meta.timestamp())
} else if meta.reference().can_intersect(&NTP_CAPS) { } else if meta.reference().can_intersect(&NTP_CAPS) {
meta.timestamp() meta.timestamp().checked_sub(NTP_UNIX_OFFSET.seconds())
.checked_sub(gst::ClockTime::from_seconds(NTP_UNIX_OFFSET))
} else { } else {
None None
} }
@ -913,13 +912,11 @@ impl FMP4Mux {
let calculate_pts = |buffer: &Buffer| -> gst::ClockTime { let calculate_pts = |buffer: &Buffer| -> gst::ClockTime {
let composition_time_offset = buffer.composition_time_offset.unwrap_or(0); let composition_time_offset = buffer.composition_time_offset.unwrap_or(0);
if composition_time_offset > 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 { } else {
buffer buffer
.timestamp .timestamp
.checked_sub(gst::ClockTime::from_nseconds( .checked_sub(((-composition_time_offset) as u64).nseconds())
(-composition_time_offset) as u64,
))
.unwrap() .unwrap()
} }
}; };
@ -957,13 +954,11 @@ impl FMP4Mux {
}; };
let buffer_utc_time = if buffer_pts_diff >= 0 { let buffer_utc_time = if buffer_pts_diff >= 0 {
utc_time utc_time
.checked_sub(gst::ClockTime::from_nseconds(buffer_pts_diff as u64)) .checked_sub((buffer_pts_diff as u64).nseconds())
.unwrap() .unwrap()
} else { } else {
utc_time utc_time
.checked_add(gst::ClockTime::from_nseconds( .checked_add(((-buffer_pts_diff) as u64).nseconds())
(-buffer_pts_diff) as u64,
))
.unwrap() .unwrap()
}; };
@ -1035,15 +1030,11 @@ impl FMP4Mux {
if let Some(composition_time_offset) = buffer.composition_time_offset { if let Some(composition_time_offset) = buffer.composition_time_offset {
if composition_time_offset >= 0 { if composition_time_offset >= 0 {
utc_time utc_time
.checked_sub(gst::ClockTime::from_nseconds( .checked_sub((composition_time_offset as u64).nseconds())
composition_time_offset as u64,
))
.unwrap() .unwrap()
} else { } else {
utc_time utc_time
.checked_add(gst::ClockTime::from_nseconds( .checked_add(((-composition_time_offset) as u64).nseconds())
(-composition_time_offset) as u64,
))
.unwrap() .unwrap()
} }
} else { } else {
@ -2122,7 +2113,7 @@ impl AggregatorImpl for FMP4Mux {
gst::StreamError::Format, gst::StreamError::Format,
["Longer GOPs than fragment duration"] ["Longer GOPs than fragment duration"]
); );
state.timeout_delay += gst::ClockTime::from_seconds(1); state.timeout_delay += 1.seconds();
drop(state); drop(state);
for (sinkpad, event) in upstream_events { for (sinkpad, event) in upstream_events {

View file

@ -28,7 +28,7 @@ fn test_buffer_flags_single_stream(cmaf: bool) {
// 5s fragment duration // 5s fragment duration
h.element() h.element()
.unwrap() .unwrap()
.set_property("fragment-duration", gst::ClockTime::from_seconds(5)); .set_property("fragment-duration", 5.seconds());
h.set_src_caps( h.set_src_caps(
gst::Caps::builder("video/x-h264") gst::Caps::builder("video/x-h264")
@ -45,7 +45,7 @@ fn test_buffer_flags_single_stream(cmaf: bool) {
let output_offset = if cmaf { let output_offset = if cmaf {
gst::ClockTime::ZERO gst::ClockTime::ZERO
} else { } 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 // 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 mut buffer = gst::Buffer::with_size(1).unwrap();
{ {
let buffer = buffer.get_mut().unwrap(); let buffer = buffer.get_mut().unwrap();
buffer.set_pts(gst::ClockTime::from_seconds(i)); buffer.set_pts(i.seconds());
buffer.set_dts(gst::ClockTime::from_seconds(i)); buffer.set_dts(i.seconds());
buffer.set_duration(gst::ClockTime::SECOND); buffer.set_duration(gst::ClockTime::SECOND);
if i != 0 && i != 5 { if i != 0 && i != 5 {
buffer.set_flags(gst::BufferFlags::DELTA_UNIT); buffer.set_flags(gst::BufferFlags::DELTA_UNIT);
@ -76,7 +76,7 @@ fn test_buffer_flags_single_stream(cmaf: bool) {
assert_eq!( assert_eq!(
gst_video::UpstreamForceKeyUnitEvent::parse(&ev).unwrap(), gst_video::UpstreamForceKeyUnitEvent::parse(&ev).unwrap(),
gst_video::UpstreamForceKeyUnitEvent { gst_video::UpstreamForceKeyUnitEvent {
running_time: Some(gst::ClockTime::from_seconds(5)), running_time: Some(5.seconds()),
all_headers: true, all_headers: true,
count: 0 count: 0
} }
@ -102,10 +102,7 @@ fn test_buffer_flags_single_stream(cmaf: bool) {
fragment_header.dts(), fragment_header.dts(),
Some(gst::ClockTime::ZERO + output_offset) Some(gst::ClockTime::ZERO + output_offset)
); );
assert_eq!( assert_eq!(fragment_header.duration(), Some(5.seconds()));
fragment_header.duration(),
Some(gst::ClockTime::from_seconds(5))
);
for i in 0..5 { for i in 0..5 {
let buffer = h.pull().unwrap(); let buffer = h.pull().unwrap();
@ -117,14 +114,8 @@ fn test_buffer_flags_single_stream(cmaf: bool) {
} else { } else {
assert_eq!(buffer.flags(), gst::BufferFlags::DELTA_UNIT); assert_eq!(buffer.flags(), gst::BufferFlags::DELTA_UNIT);
} }
assert_eq!( assert_eq!(buffer.pts(), Some(i.seconds() + output_offset));
buffer.pts(), assert_eq!(buffer.dts(), Some(i.seconds() + output_offset));
Some(gst::ClockTime::from_seconds(i) + output_offset)
);
assert_eq!(
buffer.dts(),
Some(gst::ClockTime::from_seconds(i) + output_offset)
);
assert_eq!(buffer.duration(), Some(gst::ClockTime::SECOND)); 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(); let fragment_header = h.pull().unwrap();
assert_eq!(fragment_header.flags(), gst::BufferFlags::HEADER); assert_eq!(fragment_header.flags(), gst::BufferFlags::HEADER);
assert_eq!( assert_eq!(fragment_header.pts(), Some(5.seconds() + output_offset));
fragment_header.pts(), assert_eq!(fragment_header.dts(), Some(5.seconds() + output_offset));
Some(gst::ClockTime::from_seconds(5) + output_offset) assert_eq!(fragment_header.duration(), Some(2.seconds()));
);
assert_eq!(
fragment_header.dts(),
Some(gst::ClockTime::from_seconds(5) + output_offset)
);
assert_eq!(
fragment_header.duration(),
Some(gst::ClockTime::from_seconds(2))
);
for i in 5..7 { for i in 5..7 {
let buffer = h.pull().unwrap(); let buffer = h.pull().unwrap();
@ -155,14 +137,8 @@ fn test_buffer_flags_single_stream(cmaf: bool) {
} else { } else {
assert_eq!(buffer.flags(), gst::BufferFlags::DELTA_UNIT); assert_eq!(buffer.flags(), gst::BufferFlags::DELTA_UNIT);
} }
assert_eq!( assert_eq!(buffer.pts(), Some(i.seconds() + output_offset));
buffer.pts(), assert_eq!(buffer.dts(), Some(i.seconds() + output_offset));
Some(gst::ClockTime::from_seconds(i) + output_offset)
);
assert_eq!(
buffer.dts(),
Some(gst::ClockTime::from_seconds(i) + output_offset)
);
assert_eq!(buffer.duration(), Some(gst::ClockTime::SECOND)); assert_eq!(buffer.duration(), Some(gst::ClockTime::SECOND));
} }
@ -200,7 +176,7 @@ fn test_buffer_flags_multi_stream() {
// 5s fragment duration // 5s fragment duration
h1.element() h1.element()
.unwrap() .unwrap()
.set_property("fragment-duration", gst::ClockTime::from_seconds(5)); .set_property("fragment-duration", 5.seconds());
h1.set_src_caps( h1.set_src_caps(
gst::Caps::builder("video/x-h264") gst::Caps::builder("video/x-h264")
@ -231,15 +207,15 @@ fn test_buffer_flags_multi_stream() {
); );
h2.play(); 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 // Push 7 buffers of 1s each, 1st and last buffer without DELTA_UNIT flag
for i in 0..7 { for i in 0..7 {
let mut buffer = gst::Buffer::with_size(1).unwrap(); let mut buffer = gst::Buffer::with_size(1).unwrap();
{ {
let buffer = buffer.get_mut().unwrap(); let buffer = buffer.get_mut().unwrap();
buffer.set_pts(gst::ClockTime::from_seconds(i)); buffer.set_pts(i.seconds());
buffer.set_dts(gst::ClockTime::from_seconds(i)); buffer.set_dts(i.seconds());
buffer.set_duration(gst::ClockTime::SECOND); buffer.set_duration(gst::ClockTime::SECOND);
if i != 0 && i != 5 { if i != 0 && i != 5 {
buffer.set_flags(gst::BufferFlags::DELTA_UNIT); 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 mut buffer = gst::Buffer::with_size(1).unwrap();
{ {
let buffer = buffer.get_mut().unwrap(); let buffer = buffer.get_mut().unwrap();
buffer.set_pts(gst::ClockTime::from_seconds(i)); buffer.set_pts(i.seconds());
buffer.set_dts(gst::ClockTime::from_seconds(i)); buffer.set_dts(i.seconds());
buffer.set_duration(gst::ClockTime::SECOND); buffer.set_duration(gst::ClockTime::SECOND);
} }
assert_eq!(h2.push(buffer), Ok(gst::FlowSuccess::Ok)); assert_eq!(h2.push(buffer), Ok(gst::FlowSuccess::Ok));
@ -270,7 +246,7 @@ fn test_buffer_flags_multi_stream() {
assert_eq!( assert_eq!(
gst_video::UpstreamForceKeyUnitEvent::parse(&ev).unwrap(), gst_video::UpstreamForceKeyUnitEvent::parse(&ev).unwrap(),
gst_video::UpstreamForceKeyUnitEvent { gst_video::UpstreamForceKeyUnitEvent {
running_time: Some(gst::ClockTime::from_seconds(5)), running_time: Some(5.seconds()),
all_headers: true, all_headers: true,
count: 0 count: 0
} }
@ -289,7 +265,7 @@ fn test_buffer_flags_multi_stream() {
assert_eq!( assert_eq!(
gst_video::UpstreamForceKeyUnitEvent::parse(&ev).unwrap(), gst_video::UpstreamForceKeyUnitEvent::parse(&ev).unwrap(),
gst_video::UpstreamForceKeyUnitEvent { gst_video::UpstreamForceKeyUnitEvent {
running_time: Some(gst::ClockTime::from_seconds(5)), running_time: Some(5.seconds()),
all_headers: true, all_headers: true,
count: 0 count: 0
} }
@ -315,10 +291,7 @@ fn test_buffer_flags_multi_stream() {
fragment_header.dts(), fragment_header.dts(),
Some(gst::ClockTime::ZERO + output_offset) Some(gst::ClockTime::ZERO + output_offset)
); );
assert_eq!( assert_eq!(fragment_header.duration(), Some(5.seconds()));
fragment_header.duration(),
Some(gst::ClockTime::from_seconds(5))
);
for i in 0..5 { for i in 0..5 {
for j in 0..2 { 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.flags(), gst::BufferFlags::DELTA_UNIT);
} }
assert_eq!( assert_eq!(buffer.pts(), Some(i.seconds() + output_offset));
buffer.pts(),
Some(gst::ClockTime::from_seconds(i) + output_offset)
);
if j == 0 { if j == 0 {
assert_eq!( assert_eq!(buffer.dts(), Some(i.seconds() + output_offset));
buffer.dts(),
Some(gst::ClockTime::from_seconds(i) + output_offset)
);
} else { } else {
assert!(buffer.dts().is_none()); assert!(buffer.dts().is_none());
} }
@ -354,18 +321,9 @@ fn test_buffer_flags_multi_stream() {
let fragment_header = h1.pull().unwrap(); let fragment_header = h1.pull().unwrap();
assert_eq!(fragment_header.flags(), gst::BufferFlags::HEADER); assert_eq!(fragment_header.flags(), gst::BufferFlags::HEADER);
assert_eq!( assert_eq!(fragment_header.pts(), Some(5.seconds() + output_offset));
fragment_header.pts(), assert_eq!(fragment_header.dts(), Some(5.seconds() + output_offset));
Some(gst::ClockTime::from_seconds(5) + output_offset) assert_eq!(fragment_header.duration(), Some(2.seconds()));
);
assert_eq!(
fragment_header.dts(),
Some(gst::ClockTime::from_seconds(5) + output_offset)
);
assert_eq!(
fragment_header.duration(),
Some(gst::ClockTime::from_seconds(2))
);
for i in 5..7 { for i in 5..7 {
for j in 0..2 { for j in 0..2 {
@ -378,15 +336,9 @@ fn test_buffer_flags_multi_stream() {
} else { } else {
assert_eq!(buffer.flags(), gst::BufferFlags::DELTA_UNIT); assert_eq!(buffer.flags(), gst::BufferFlags::DELTA_UNIT);
} }
assert_eq!( assert_eq!(buffer.pts(), Some(i.seconds() + output_offset));
buffer.pts(),
Some(gst::ClockTime::from_seconds(i) + output_offset)
);
if j == 0 { if j == 0 {
assert_eq!( assert_eq!(buffer.dts(), Some(i.seconds() + output_offset));
buffer.dts(),
Some(gst::ClockTime::from_seconds(i) + output_offset)
);
} else { } else {
assert!(buffer.dts().is_none()); assert!(buffer.dts().is_none());
} }
@ -416,7 +368,7 @@ fn test_live_timeout() {
// 5s fragment duration // 5s fragment duration
h1.element() h1.element()
.unwrap() .unwrap()
.set_property("fragment-duration", gst::ClockTime::from_seconds(5)); .set_property("fragment-duration", 5.seconds());
h1.set_src_caps( h1.set_src_caps(
gst::Caps::builder("video/x-h264") gst::Caps::builder("video/x-h264")
@ -447,15 +399,15 @@ fn test_live_timeout() {
); );
h2.play(); 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 // Push 7 buffers of 1s each, 1st and last buffer without DELTA_UNIT flag
for i in 0..7 { for i in 0..7 {
let mut buffer = gst::Buffer::with_size(1).unwrap(); let mut buffer = gst::Buffer::with_size(1).unwrap();
{ {
let buffer = buffer.get_mut().unwrap(); let buffer = buffer.get_mut().unwrap();
buffer.set_pts(gst::ClockTime::from_seconds(i)); buffer.set_pts(i.seconds());
buffer.set_dts(gst::ClockTime::from_seconds(i)); buffer.set_dts(i.seconds());
buffer.set_duration(gst::ClockTime::SECOND); buffer.set_duration(gst::ClockTime::SECOND);
if i != 0 && i != 5 { if i != 0 && i != 5 {
buffer.set_flags(gst::BufferFlags::DELTA_UNIT); 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 mut buffer = gst::Buffer::with_size(1).unwrap();
{ {
let buffer = buffer.get_mut().unwrap(); let buffer = buffer.get_mut().unwrap();
buffer.set_pts(gst::ClockTime::from_seconds(i)); buffer.set_pts(i.seconds());
buffer.set_dts(gst::ClockTime::from_seconds(i)); buffer.set_dts(i.seconds());
buffer.set_duration(gst::ClockTime::SECOND); buffer.set_duration(gst::ClockTime::SECOND);
} }
assert_eq!(h2.push(buffer), Ok(gst::FlowSuccess::Ok)); assert_eq!(h2.push(buffer), Ok(gst::FlowSuccess::Ok));
@ -491,7 +443,7 @@ fn test_live_timeout() {
assert_eq!( assert_eq!(
gst_video::UpstreamForceKeyUnitEvent::parse(&ev).unwrap(), gst_video::UpstreamForceKeyUnitEvent::parse(&ev).unwrap(),
gst_video::UpstreamForceKeyUnitEvent { gst_video::UpstreamForceKeyUnitEvent {
running_time: Some(gst::ClockTime::from_seconds(5)), running_time: Some(5.seconds()),
all_headers: true, all_headers: true,
count: 0 count: 0
} }
@ -510,7 +462,7 @@ fn test_live_timeout() {
assert_eq!( assert_eq!(
gst_video::UpstreamForceKeyUnitEvent::parse(&ev).unwrap(), gst_video::UpstreamForceKeyUnitEvent::parse(&ev).unwrap(),
gst_video::UpstreamForceKeyUnitEvent { gst_video::UpstreamForceKeyUnitEvent {
running_time: Some(gst::ClockTime::from_seconds(5)), running_time: Some(5.seconds()),
all_headers: true, all_headers: true,
count: 0 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 // 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(); h1.crank_single_clock_wait().unwrap();
let header = h1.pull().unwrap(); let header = h1.pull().unwrap();
@ -540,10 +492,7 @@ fn test_live_timeout() {
fragment_header.dts(), fragment_header.dts(),
Some(gst::ClockTime::ZERO + output_offset) Some(gst::ClockTime::ZERO + output_offset)
); );
assert_eq!( assert_eq!(fragment_header.duration(), Some(5.seconds()));
fragment_header.duration(),
Some(gst::ClockTime::from_seconds(5))
);
for i in 0..5 { for i in 0..5 {
for j in 0..2 { for j in 0..2 {
@ -567,16 +516,10 @@ fn test_live_timeout() {
assert_eq!(buffer.flags(), gst::BufferFlags::DELTA_UNIT); assert_eq!(buffer.flags(), gst::BufferFlags::DELTA_UNIT);
} }
assert_eq!( assert_eq!(buffer.pts(), Some(i.seconds() + output_offset));
buffer.pts(),
Some(gst::ClockTime::from_seconds(i) + output_offset)
);
if j == 0 { if j == 0 {
assert_eq!( assert_eq!(buffer.dts(), Some(i.seconds() + output_offset));
buffer.dts(),
Some(gst::ClockTime::from_seconds(i) + output_offset)
);
} else { } else {
assert!(buffer.dts().is_none()); assert!(buffer.dts().is_none());
} }
@ -589,18 +532,9 @@ fn test_live_timeout() {
let fragment_header = h1.pull().unwrap(); let fragment_header = h1.pull().unwrap();
assert_eq!(fragment_header.flags(), gst::BufferFlags::HEADER); assert_eq!(fragment_header.flags(), gst::BufferFlags::HEADER);
assert_eq!( assert_eq!(fragment_header.pts(), Some(5.seconds() + output_offset));
fragment_header.pts(), assert_eq!(fragment_header.dts(), Some(5.seconds() + output_offset));
Some(gst::ClockTime::from_seconds(5) + output_offset) assert_eq!(fragment_header.duration(), Some(2.seconds()));
);
assert_eq!(
fragment_header.dts(),
Some(gst::ClockTime::from_seconds(5) + output_offset)
);
assert_eq!(
fragment_header.duration(),
Some(gst::ClockTime::from_seconds(2))
);
for i in 5..7 { for i in 5..7 {
for j in 0..2 { for j in 0..2 {
@ -618,15 +552,9 @@ fn test_live_timeout() {
} else { } else {
assert_eq!(buffer.flags(), gst::BufferFlags::DELTA_UNIT); assert_eq!(buffer.flags(), gst::BufferFlags::DELTA_UNIT);
} }
assert_eq!( assert_eq!(buffer.pts(), Some(i.seconds() + output_offset));
buffer.pts(),
Some(gst::ClockTime::from_seconds(i) + output_offset)
);
if j == 0 { if j == 0 {
assert_eq!( assert_eq!(buffer.dts(), Some(i.seconds() + output_offset));
buffer.dts(),
Some(gst::ClockTime::from_seconds(i) + output_offset)
);
} else { } else {
assert!(buffer.dts().is_none()); assert!(buffer.dts().is_none());
} }
@ -656,7 +584,7 @@ fn test_gap_events() {
// 5s fragment duration // 5s fragment duration
h1.element() h1.element()
.unwrap() .unwrap()
.set_property("fragment-duration", gst::ClockTime::from_seconds(5)); .set_property("fragment-duration", 5.seconds());
h1.set_src_caps( h1.set_src_caps(
gst::Caps::builder("video/x-h264") gst::Caps::builder("video/x-h264")
@ -687,15 +615,15 @@ fn test_gap_events() {
); );
h2.play(); 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 // Push 7 buffers of 1s each, 1st and last buffer without DELTA_UNIT flag
for i in 0..7 { for i in 0..7 {
let mut buffer = gst::Buffer::with_size(1).unwrap(); let mut buffer = gst::Buffer::with_size(1).unwrap();
{ {
let buffer = buffer.get_mut().unwrap(); let buffer = buffer.get_mut().unwrap();
buffer.set_pts(gst::ClockTime::from_seconds(i)); buffer.set_pts(i.seconds());
buffer.set_dts(gst::ClockTime::from_seconds(i)); buffer.set_dts(i.seconds());
buffer.set_duration(gst::ClockTime::SECOND); buffer.set_duration(gst::ClockTime::SECOND);
if i != 0 && i != 5 { if i != 0 && i != 5 {
buffer.set_flags(gst::BufferFlags::DELTA_UNIT); buffer.set_flags(gst::BufferFlags::DELTA_UNIT);
@ -705,7 +633,7 @@ fn test_gap_events() {
// Replace buffer 3 and 6 with a gap event // Replace buffer 3 and 6 with a gap event
if i == 3 || i == 6 { 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) .duration(gst::ClockTime::SECOND)
.build(); .build();
assert!(h2.push_event(ev)); assert!(h2.push_event(ev));
@ -713,8 +641,8 @@ fn test_gap_events() {
let mut buffer = gst::Buffer::with_size(1).unwrap(); let mut buffer = gst::Buffer::with_size(1).unwrap();
{ {
let buffer = buffer.get_mut().unwrap(); let buffer = buffer.get_mut().unwrap();
buffer.set_pts(gst::ClockTime::from_seconds(i)); buffer.set_pts(i.seconds());
buffer.set_dts(gst::ClockTime::from_seconds(i)); buffer.set_dts(i.seconds());
buffer.set_duration(gst::ClockTime::SECOND); buffer.set_duration(gst::ClockTime::SECOND);
} }
assert_eq!(h2.push(buffer), Ok(gst::FlowSuccess::Ok)); assert_eq!(h2.push(buffer), Ok(gst::FlowSuccess::Ok));
@ -734,7 +662,7 @@ fn test_gap_events() {
assert_eq!( assert_eq!(
gst_video::UpstreamForceKeyUnitEvent::parse(&ev).unwrap(), gst_video::UpstreamForceKeyUnitEvent::parse(&ev).unwrap(),
gst_video::UpstreamForceKeyUnitEvent { gst_video::UpstreamForceKeyUnitEvent {
running_time: Some(gst::ClockTime::from_seconds(5)), running_time: Some(5.seconds()),
all_headers: true, all_headers: true,
count: 0 count: 0
} }
@ -753,7 +681,7 @@ fn test_gap_events() {
assert_eq!( assert_eq!(
gst_video::UpstreamForceKeyUnitEvent::parse(&ev).unwrap(), gst_video::UpstreamForceKeyUnitEvent::parse(&ev).unwrap(),
gst_video::UpstreamForceKeyUnitEvent { gst_video::UpstreamForceKeyUnitEvent {
running_time: Some(gst::ClockTime::from_seconds(5)), running_time: Some(5.seconds()),
all_headers: true, all_headers: true,
count: 0 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 // 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(); h1.crank_single_clock_wait().unwrap();
let header = h1.pull().unwrap(); let header = h1.pull().unwrap();
@ -783,10 +711,7 @@ fn test_gap_events() {
fragment_header.dts(), fragment_header.dts(),
Some(gst::ClockTime::ZERO + output_offset) Some(gst::ClockTime::ZERO + output_offset)
); );
assert_eq!( assert_eq!(fragment_header.duration(), Some(5.seconds()));
fragment_header.duration(),
Some(gst::ClockTime::from_seconds(5))
);
for i in 0..5 { for i in 0..5 {
for j in 0..2 { for j in 0..2 {
@ -805,16 +730,10 @@ fn test_gap_events() {
assert_eq!(buffer.flags(), gst::BufferFlags::DELTA_UNIT); assert_eq!(buffer.flags(), gst::BufferFlags::DELTA_UNIT);
} }
assert_eq!( assert_eq!(buffer.pts(), Some(i.seconds() + output_offset));
buffer.pts(),
Some(gst::ClockTime::from_seconds(i) + output_offset)
);
if j == 0 { if j == 0 {
assert_eq!( assert_eq!(buffer.dts(), Some(i.seconds() + output_offset));
buffer.dts(),
Some(gst::ClockTime::from_seconds(i) + output_offset)
);
} else { } else {
assert!(buffer.dts().is_none()); assert!(buffer.dts().is_none());
} }
@ -827,18 +746,9 @@ fn test_gap_events() {
let fragment_header = h1.pull().unwrap(); let fragment_header = h1.pull().unwrap();
assert_eq!(fragment_header.flags(), gst::BufferFlags::HEADER); assert_eq!(fragment_header.flags(), gst::BufferFlags::HEADER);
assert_eq!( assert_eq!(fragment_header.pts(), Some(5.seconds() + output_offset));
fragment_header.pts(), assert_eq!(fragment_header.dts(), Some(5.seconds() + output_offset));
Some(gst::ClockTime::from_seconds(5) + output_offset) assert_eq!(fragment_header.duration(), Some(2.seconds()));
);
assert_eq!(
fragment_header.dts(),
Some(gst::ClockTime::from_seconds(5) + output_offset)
);
assert_eq!(
fragment_header.duration(),
Some(gst::ClockTime::from_seconds(2))
);
for i in 5..7 { for i in 5..7 {
for j in 0..2 { for j in 0..2 {
@ -856,15 +766,9 @@ fn test_gap_events() {
} else { } else {
assert_eq!(buffer.flags(), gst::BufferFlags::DELTA_UNIT); assert_eq!(buffer.flags(), gst::BufferFlags::DELTA_UNIT);
} }
assert_eq!( assert_eq!(buffer.pts(), Some(i.seconds() + output_offset));
buffer.pts(),
Some(gst::ClockTime::from_seconds(i) + output_offset)
);
if j == 0 { if j == 0 {
assert_eq!( assert_eq!(buffer.dts(), Some(i.seconds() + output_offset));
buffer.dts(),
Some(gst::ClockTime::from_seconds(i) + output_offset)
);
} else { } else {
assert!(buffer.dts().is_none()); assert!(buffer.dts().is_none());
} }
@ -891,7 +795,7 @@ fn test_single_stream_short_gops() {
// 5s fragment duration // 5s fragment duration
h.element() h.element()
.unwrap() .unwrap()
.set_property("fragment-duration", gst::ClockTime::from_seconds(5)); .set_property("fragment-duration", 5.seconds());
h.set_src_caps( h.set_src_caps(
gst::Caps::builder("video/x-h264") gst::Caps::builder("video/x-h264")
@ -905,15 +809,15 @@ fn test_single_stream_short_gops() {
); );
h.play(); 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 // Push 8 buffers of 1s each, 1st, 4th and 7th buffer without DELTA_UNIT flag
for i in 0..8 { for i in 0..8 {
let mut buffer = gst::Buffer::with_size(1).unwrap(); let mut buffer = gst::Buffer::with_size(1).unwrap();
{ {
let buffer = buffer.get_mut().unwrap(); let buffer = buffer.get_mut().unwrap();
buffer.set_pts(gst::ClockTime::from_seconds(i)); buffer.set_pts(i.seconds());
buffer.set_dts(gst::ClockTime::from_seconds(i)); buffer.set_dts(i.seconds());
buffer.set_duration(gst::ClockTime::SECOND); buffer.set_duration(gst::ClockTime::SECOND);
if i != 0 && i != 3 && i != 6 { if i != 0 && i != 3 && i != 6 {
buffer.set_flags(gst::BufferFlags::DELTA_UNIT); buffer.set_flags(gst::BufferFlags::DELTA_UNIT);
@ -931,11 +835,7 @@ fn test_single_stream_short_gops() {
} }
}; };
let fku_time = if i == 2 { let fku_time = if i == 2 { 5.seconds() } else { 8.seconds() };
gst::ClockTime::from_seconds(5)
} else {
gst::ClockTime::from_seconds(8)
};
assert_eq!(ev.type_(), gst::EventType::CustomUpstream); assert_eq!(ev.type_(), gst::EventType::CustomUpstream);
assert_eq!( assert_eq!(
@ -967,10 +867,7 @@ fn test_single_stream_short_gops() {
fragment_header.dts(), fragment_header.dts(),
Some(gst::ClockTime::ZERO + output_offset) Some(gst::ClockTime::ZERO + output_offset)
); );
assert_eq!( assert_eq!(fragment_header.duration(), Some(3.seconds()));
fragment_header.duration(),
Some(gst::ClockTime::from_seconds(3))
);
for i in 0..3 { for i in 0..3 {
let buffer = h.pull().unwrap(); let buffer = h.pull().unwrap();
@ -982,14 +879,8 @@ fn test_single_stream_short_gops() {
} else { } else {
assert_eq!(buffer.flags(), gst::BufferFlags::DELTA_UNIT); assert_eq!(buffer.flags(), gst::BufferFlags::DELTA_UNIT);
} }
assert_eq!( assert_eq!(buffer.pts(), Some(i.seconds() + output_offset));
buffer.pts(), assert_eq!(buffer.dts(), Some(i.seconds() + output_offset));
Some(gst::ClockTime::from_seconds(i) + output_offset)
);
assert_eq!(
buffer.dts(),
Some(gst::ClockTime::from_seconds(i) + output_offset)
);
assert_eq!(buffer.duration(), Some(gst::ClockTime::SECOND)); assert_eq!(buffer.duration(), Some(gst::ClockTime::SECOND));
} }
@ -997,18 +888,9 @@ fn test_single_stream_short_gops() {
let fragment_header = h.pull().unwrap(); let fragment_header = h.pull().unwrap();
assert_eq!(fragment_header.flags(), gst::BufferFlags::HEADER); assert_eq!(fragment_header.flags(), gst::BufferFlags::HEADER);
assert_eq!( assert_eq!(fragment_header.pts(), Some(3.seconds() + output_offset));
fragment_header.pts(), assert_eq!(fragment_header.dts(), Some(3.seconds() + output_offset));
Some(gst::ClockTime::from_seconds(3) + output_offset) assert_eq!(fragment_header.duration(), Some(5.seconds()));
);
assert_eq!(
fragment_header.dts(),
Some(gst::ClockTime::from_seconds(3) + output_offset)
);
assert_eq!(
fragment_header.duration(),
Some(gst::ClockTime::from_seconds(5))
);
for i in 3..8 { for i in 3..8 {
let buffer = h.pull().unwrap(); let buffer = h.pull().unwrap();
@ -1020,14 +902,8 @@ fn test_single_stream_short_gops() {
} else { } else {
assert_eq!(buffer.flags(), gst::BufferFlags::DELTA_UNIT); assert_eq!(buffer.flags(), gst::BufferFlags::DELTA_UNIT);
} }
assert_eq!( assert_eq!(buffer.pts(), Some(i.seconds() + output_offset));
buffer.pts(), assert_eq!(buffer.dts(), Some(i.seconds() + output_offset));
Some(gst::ClockTime::from_seconds(i) + output_offset)
);
assert_eq!(
buffer.dts(),
Some(gst::ClockTime::from_seconds(i) + output_offset)
);
assert_eq!(buffer.duration(), Some(gst::ClockTime::SECOND)); assert_eq!(buffer.duration(), Some(gst::ClockTime::SECOND));
} }
@ -1050,7 +926,7 @@ fn test_single_stream_long_gops() {
// 5s fragment duration // 5s fragment duration
h.element() h.element()
.unwrap() .unwrap()
.set_property("fragment-duration", gst::ClockTime::from_seconds(5)); .set_property("fragment-duration", 5.seconds());
h.set_src_caps( h.set_src_caps(
gst::Caps::builder("video/x-h264") gst::Caps::builder("video/x-h264")
@ -1064,15 +940,15 @@ fn test_single_stream_long_gops() {
); );
h.play(); 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 // Push 10 buffers of 1s each, 1st and 7th buffer without DELTA_UNIT flag
for i in 0..10 { for i in 0..10 {
let mut buffer = gst::Buffer::with_size(1).unwrap(); let mut buffer = gst::Buffer::with_size(1).unwrap();
{ {
let buffer = buffer.get_mut().unwrap(); let buffer = buffer.get_mut().unwrap();
buffer.set_pts(gst::ClockTime::from_seconds(i)); buffer.set_pts(i.seconds());
buffer.set_dts(gst::ClockTime::from_seconds(i)); buffer.set_dts(i.seconds());
buffer.set_duration(gst::ClockTime::SECOND); buffer.set_duration(gst::ClockTime::SECOND);
if i != 0 && i != 6 { if i != 0 && i != 6 {
buffer.set_flags(gst::BufferFlags::DELTA_UNIT); buffer.set_flags(gst::BufferFlags::DELTA_UNIT);
@ -1090,11 +966,7 @@ fn test_single_stream_long_gops() {
} }
}; };
let fku_time = if i == 2 { let fku_time = if i == 2 { 5.seconds() } else { 11.seconds() };
gst::ClockTime::from_seconds(5)
} else {
gst::ClockTime::from_seconds(11)
};
assert_eq!(ev.type_(), gst::EventType::CustomUpstream); assert_eq!(ev.type_(), gst::EventType::CustomUpstream);
assert_eq!( assert_eq!(
@ -1126,10 +998,7 @@ fn test_single_stream_long_gops() {
fragment_header.dts(), fragment_header.dts(),
Some(gst::ClockTime::ZERO + output_offset) Some(gst::ClockTime::ZERO + output_offset)
); );
assert_eq!( assert_eq!(fragment_header.duration(), Some(6.seconds()));
fragment_header.duration(),
Some(gst::ClockTime::from_seconds(6))
);
for i in 0..6 { for i in 0..6 {
let buffer = h.pull().unwrap(); let buffer = h.pull().unwrap();
@ -1141,14 +1010,8 @@ fn test_single_stream_long_gops() {
} else { } else {
assert_eq!(buffer.flags(), gst::BufferFlags::DELTA_UNIT); assert_eq!(buffer.flags(), gst::BufferFlags::DELTA_UNIT);
} }
assert_eq!( assert_eq!(buffer.pts(), Some(i.seconds() + output_offset));
buffer.pts(), assert_eq!(buffer.dts(), Some(i.seconds() + output_offset));
Some(gst::ClockTime::from_seconds(i) + output_offset)
);
assert_eq!(
buffer.dts(),
Some(gst::ClockTime::from_seconds(i) + output_offset)
);
assert_eq!(buffer.duration(), Some(gst::ClockTime::SECOND)); assert_eq!(buffer.duration(), Some(gst::ClockTime::SECOND));
} }
@ -1156,18 +1019,9 @@ fn test_single_stream_long_gops() {
let fragment_header = h.pull().unwrap(); let fragment_header = h.pull().unwrap();
assert_eq!(fragment_header.flags(), gst::BufferFlags::HEADER); assert_eq!(fragment_header.flags(), gst::BufferFlags::HEADER);
assert_eq!( assert_eq!(fragment_header.pts(), Some(6.seconds() + output_offset));
fragment_header.pts(), assert_eq!(fragment_header.dts(), Some(6.seconds() + output_offset));
Some(gst::ClockTime::from_seconds(6) + output_offset) assert_eq!(fragment_header.duration(), Some(4.seconds()));
);
assert_eq!(
fragment_header.dts(),
Some(gst::ClockTime::from_seconds(6) + output_offset)
);
assert_eq!(
fragment_header.duration(),
Some(gst::ClockTime::from_seconds(4))
);
for i in 6..10 { for i in 6..10 {
let buffer = h.pull().unwrap(); let buffer = h.pull().unwrap();
@ -1179,14 +1033,8 @@ fn test_single_stream_long_gops() {
} else { } else {
assert_eq!(buffer.flags(), gst::BufferFlags::DELTA_UNIT); assert_eq!(buffer.flags(), gst::BufferFlags::DELTA_UNIT);
} }
assert_eq!( assert_eq!(buffer.pts(), Some(i.seconds() + output_offset));
buffer.pts(), assert_eq!(buffer.dts(), Some(i.seconds() + output_offset));
Some(gst::ClockTime::from_seconds(i) + output_offset)
);
assert_eq!(
buffer.dts(),
Some(gst::ClockTime::from_seconds(i) + output_offset)
);
assert_eq!(buffer.duration(), Some(gst::ClockTime::SECOND)); assert_eq!(buffer.duration(), Some(gst::ClockTime::SECOND));
} }
@ -1210,7 +1058,7 @@ fn test_buffer_multi_stream_short_gops() {
// 5s fragment duration // 5s fragment duration
h1.element() h1.element()
.unwrap() .unwrap()
.set_property("fragment-duration", gst::ClockTime::from_seconds(5)); .set_property("fragment-duration", 5.seconds());
h1.set_src_caps( h1.set_src_caps(
gst::Caps::builder("video/x-h264") gst::Caps::builder("video/x-h264")
@ -1241,15 +1089,15 @@ fn test_buffer_multi_stream_short_gops() {
); );
h2.play(); 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 // Push 8 buffers of 1s each, 1st, 4th and 7th buffer without DELTA_UNIT flag
for i in 0..8 { for i in 0..8 {
let mut buffer = gst::Buffer::with_size(1).unwrap(); let mut buffer = gst::Buffer::with_size(1).unwrap();
{ {
let buffer = buffer.get_mut().unwrap(); let buffer = buffer.get_mut().unwrap();
buffer.set_pts(gst::ClockTime::from_seconds(i)); buffer.set_pts(i.seconds());
buffer.set_dts(gst::ClockTime::from_seconds(i)); buffer.set_dts(i.seconds());
buffer.set_duration(gst::ClockTime::SECOND); buffer.set_duration(gst::ClockTime::SECOND);
if i != 0 && i != 3 && i != 6 { if i != 0 && i != 3 && i != 6 {
buffer.set_flags(gst::BufferFlags::DELTA_UNIT); 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 mut buffer = gst::Buffer::with_size(1).unwrap();
{ {
let buffer = buffer.get_mut().unwrap(); let buffer = buffer.get_mut().unwrap();
buffer.set_pts(gst::ClockTime::from_seconds(i)); buffer.set_pts(i.seconds());
buffer.set_dts(gst::ClockTime::from_seconds(i)); buffer.set_dts(i.seconds());
buffer.set_duration(gst::ClockTime::SECOND); buffer.set_duration(gst::ClockTime::SECOND);
} }
assert_eq!(h2.push(buffer), Ok(gst::FlowSuccess::Ok)); 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 { let fku_time = if i == 2 { 5.seconds() } else { 8.seconds() };
gst::ClockTime::from_seconds(5)
} else {
gst::ClockTime::from_seconds(8)
};
assert_eq!(ev.type_(), gst::EventType::CustomUpstream); assert_eq!(ev.type_(), gst::EventType::CustomUpstream);
assert_eq!( assert_eq!(
@ -1331,10 +1175,7 @@ fn test_buffer_multi_stream_short_gops() {
fragment_header.dts(), fragment_header.dts(),
Some(gst::ClockTime::ZERO + output_offset) Some(gst::ClockTime::ZERO + output_offset)
); );
assert_eq!( assert_eq!(fragment_header.duration(), Some(3.seconds()));
fragment_header.duration(),
Some(gst::ClockTime::from_seconds(3))
);
for i in 0..3 { for i in 0..3 {
for j in 0..2 { 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.flags(), gst::BufferFlags::DELTA_UNIT);
} }
assert_eq!( assert_eq!(buffer.pts(), Some(i.seconds() + output_offset));
buffer.pts(),
Some(gst::ClockTime::from_seconds(i) + output_offset)
);
if j == 0 { if j == 0 {
assert_eq!( assert_eq!(buffer.dts(), Some(i.seconds() + output_offset));
buffer.dts(),
Some(gst::ClockTime::from_seconds(i) + output_offset)
);
} else { } else {
assert!(buffer.dts().is_none()); assert!(buffer.dts().is_none());
} }
@ -1370,18 +1205,9 @@ fn test_buffer_multi_stream_short_gops() {
let fragment_header = h1.pull().unwrap(); let fragment_header = h1.pull().unwrap();
assert_eq!(fragment_header.flags(), gst::BufferFlags::HEADER); assert_eq!(fragment_header.flags(), gst::BufferFlags::HEADER);
assert_eq!( assert_eq!(fragment_header.pts(), Some(3.seconds() + output_offset));
fragment_header.pts(), assert_eq!(fragment_header.dts(), Some(3.seconds() + output_offset));
Some(gst::ClockTime::from_seconds(3) + output_offset) assert_eq!(fragment_header.duration(), Some(5.seconds()));
);
assert_eq!(
fragment_header.dts(),
Some(gst::ClockTime::from_seconds(3) + output_offset)
);
assert_eq!(
fragment_header.duration(),
Some(gst::ClockTime::from_seconds(5))
);
for i in 3..8 { for i in 3..8 {
for j in 0..2 { for j in 0..2 {
@ -1394,15 +1220,9 @@ fn test_buffer_multi_stream_short_gops() {
} else { } else {
assert_eq!(buffer.flags(), gst::BufferFlags::DELTA_UNIT); assert_eq!(buffer.flags(), gst::BufferFlags::DELTA_UNIT);
} }
assert_eq!( assert_eq!(buffer.pts(), Some(i.seconds() + output_offset));
buffer.pts(),
Some(gst::ClockTime::from_seconds(i) + output_offset)
);
if j == 0 { if j == 0 {
assert_eq!( assert_eq!(buffer.dts(), Some(i.seconds() + output_offset));
buffer.dts(),
Some(gst::ClockTime::from_seconds(i) + output_offset)
);
} else { } else {
assert!(buffer.dts().is_none()); assert!(buffer.dts().is_none());
} }

View file

@ -337,7 +337,7 @@ impl Decrypter {
let size = size - total_chunks * box_::MACBYTES as u64; let size = size - total_chunks * box_::MACBYTES as u64;
gst::debug!(CAT, obj: pad, "Setting duration bytes: {}", size); gst::debug!(CAT, obj: pad, "Setting duration bytes: {}", size);
q.set(gst::format::Bytes::from_u64(size)); q.set(size.bytes());
true true
} }

View file

@ -314,7 +314,7 @@ impl Encrypter {
let size = size + crate::HEADERS_SIZE as u64; let size = size + crate::HEADERS_SIZE as u64;
gst::debug!(CAT, obj: pad, "Setting duration bytes: {}", size); gst::debug!(CAT, obj: pad, "Setting duration bytes: {}", size);
q.set(gst::format::Bytes::from_u64(size)); q.set(size.bytes());
true true
} }

View file

@ -190,8 +190,8 @@ fn test_pull_range() {
// get the seeking capabilities // get the seeking capabilities
let (seekable, start, stop) = q.result(); let (seekable, start, stop) = q.result();
assert!(seekable); assert!(seekable);
assert_eq!(start, gst::format::Bytes::ZERO.into()); assert_eq!(start, 0.bytes().into());
assert_eq!(stop, gst::format::Bytes::from_u64(6043).into()); assert_eq!(stop, 6043.bytes().into());
// do pulls // do pulls
let expected_array_1 = [ let expected_array_1 = [

View file

@ -19,6 +19,8 @@
use super::ffi; use super::ffi;
use gst::prelude::*;
use std::ptr; use std::ptr;
use glib::translate::*; use glib::translate::*;
@ -117,7 +119,7 @@ impl RTPJitterBufferItem {
if item.as_ref().dts == gst::ffi::GST_CLOCK_TIME_NONE { if item.as_ref().dts == gst::ffi::GST_CLOCK_TIME_NONE {
None None
} else { } 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 { if item.as_ref().pts == gst::ffi::GST_CLOCK_TIME_NONE {
None None
} else { } else {
Some(gst::ClockTime::from_nseconds(item.as_ref().pts)) Some(item.as_ref().pts.nseconds())
} }
} }
} }

View file

@ -1111,8 +1111,7 @@ impl ObjectImpl for ProxySrc {
settings.max_size_bytes = value.get().expect("type checked upstream"); settings.max_size_bytes = value.get().expect("type checked upstream");
} }
"max-size-time" => { "max-size-time" => {
settings.max_size_time = settings.max_size_time = value.get::<u64>().unwrap().nseconds();
gst::ClockTime::from_nseconds(value.get().expect("type checked upstream"));
} }
"context" => { "context" => {
settings.context = value settings.context = value

View file

@ -697,8 +697,7 @@ impl ObjectImpl for Queue {
settings.max_size_bytes = value.get().expect("type checked upstream"); settings.max_size_bytes = value.get().expect("type checked upstream");
} }
"max-size-time" => { "max-size-time" => {
settings.max_size_time = settings.max_size_time = value.get::<u64>().unwrap().nseconds();
gst::ClockTime::from_nseconds(value.get().expect("type checked upstream"));
} }
"context" => { "context" => {
settings.context = value settings.context = value

View file

@ -74,7 +74,7 @@ fn test_push() {
let mut eos = false; let mut eos = false;
let bus = pipeline.bus().unwrap(); 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; use gst::MessageView;
match msg.view() { match msg.view() {
MessageView::Eos(..) => { MessageView::Eos(..) => {

View file

@ -68,7 +68,7 @@ fn test_push() {
let mut eos = false; let mut eos = false;
let bus = pipeline.bus().unwrap(); 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; use gst::MessageView;
match msg.view() { match msg.view() {
MessageView::Eos(..) => { MessageView::Eos(..) => {

View file

@ -92,7 +92,7 @@ fn test_push() {
let mut eos = false; let mut eos = false;
let bus = pipeline.bus().unwrap(); 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; use gst::MessageView;
match msg.view() { match msg.view() {
MessageView::Eos(..) => { MessageView::Eos(..) => {

View file

@ -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(..) { for mut item in transcript.results.items.drain(..) {
match item.type_.as_str() { match item.type_.as_str() {
@ -139,7 +139,7 @@ impl TranscribeParse {
let outbuf = outbuf.get_mut().unwrap(); let outbuf = outbuf.get_mut().unwrap();
outbuf.set_pts(last_pts); 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| { self.srcpad.push(outbuf).map_err(|err| {
@ -170,10 +170,8 @@ impl TranscribeParse {
} }
}; };
let start_pts = let start_pts = ((start_time as f64 * 1_000_000_000.0) as u64).nseconds();
gst::ClockTime::from_nseconds((start_time as f64 * 1_000_000_000.0) as u64); let end_pts = ((end_time as f64 * 1_000_000_000.0) as u64).nseconds();
let end_pts =
gst::ClockTime::from_nseconds((end_time as f64 * 1_000_000_000.0) as u64);
let duration = end_pts.saturating_sub(start_pts); let duration = end_pts.saturating_sub(start_pts);
if start_pts > last_pts { if start_pts > last_pts {

View file

@ -111,7 +111,7 @@ static RUNTIME: Lazy<runtime::Runtime> = Lazy::new(|| {
}); });
const DEFAULT_LATENCY: gst::ClockTime = gst::ClockTime::from_seconds(8); 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_STABILITY: AwsTranscriberResultStability = AwsTranscriberResultStability::Low;
const DEFAULT_VOCABULARY_FILTER_METHOD: AwsTranscriberVocabularyFilterMethod = const DEFAULT_VOCABULARY_FILTER_METHOD: AwsTranscriberVocabularyFilterMethod =
AwsTranscriberVocabularyFilterMethod::Mask; AwsTranscriberVocabularyFilterMethod::Mask;
@ -395,11 +395,8 @@ impl Transcriber {
for item in &alternative.items[state.partial_index..] { for item in &alternative.items[state.partial_index..] {
let start_time = let start_time =
gst::ClockTime::from_nseconds((item.start_time as f64 * 1_000_000_000.0) as u64) ((item.start_time as f64 * 1_000_000_000.0) as u64).nseconds() + lateness;
+ lateness; let end_time = ((item.end_time as f64 * 1_000_000_000.0) as u64).nseconds() + lateness;
let end_time =
gst::ClockTime::from_nseconds((item.end_time as f64 * 1_000_000_000.0) as u64)
+ lateness;
if !item.stable { if !item.stable {
break; break;

View file

@ -493,7 +493,7 @@ impl ObjectImpl for HlsSink3 {
settings.target_duration = value.get().expect("type checked upstream"); settings.target_duration = value.get().expect("type checked upstream");
settings.splitmuxsink.set_property( settings.splitmuxsink.set_property(
"max-size-time", "max-size-time",
&(gst::ClockTime::from_seconds(settings.target_duration as u64)), &((settings.target_duration as u64).seconds()),
); );
} }
"playlist-length" => { "playlist-length" => {
@ -627,7 +627,7 @@ impl ObjectImpl for HlsSink3 {
("location", &location), ("location", &location),
( (
"max-size-time", "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), ("send-keyframe-requests", &settings.send_keyframe_requests),
("muxer", &mux), ("muxer", &mux),

View file

@ -279,7 +279,7 @@ impl BaseSinkImpl for NdiSink {
if *timecode < 0 { if *timecode < 0 {
gst::ClockTime::NONE.display() gst::ClockTime::NONE.display()
} else { } else {
Some(gst::ClockTime::from_nseconds(*timecode as u64 * 100)).display() Some((*timecode as u64 * 100).nseconds()).display()
}, },
info, info,
); );
@ -323,7 +323,7 @@ impl BaseSinkImpl for NdiSink {
if timecode < 0 { if timecode < 0 {
gst::ClockTime::NONE.display() gst::ClockTime::NONE.display()
} else { } else {
Some(gst::ClockTime::from_nseconds(timecode as u64 * 100)).display() Some((timecode as u64 * 100).nseconds()).display()
}, },
info info
); );
@ -358,7 +358,7 @@ impl BaseSinkImpl for NdiSink {
if timecode < 0 { if timecode < 0 {
gst::ClockTime::NONE.display() gst::ClockTime::NONE.display()
} else { } else {
Some(gst::ClockTime::from_nseconds(timecode as u64 * 100)).display() Some((timecode as u64 * 100).nseconds()).display()
}, },
info, info,
); );

View file

@ -303,8 +303,8 @@ impl Observations {
CAT, CAT,
obj: element, obj: element,
"Local time {}, remote time {}, slope correct {}/{}", "Local time {}, remote time {}, slope correct {}/{}",
gst::ClockTime::from_nseconds(local_time), local_time.nseconds(),
gst::ClockTime::from_nseconds(remote_time), remote_time.nseconds(),
inner.slope_correction.0, inner.slope_correction.0,
inner.slope_correction.1, inner.slope_correction.1,
); );
@ -337,18 +337,18 @@ impl Observations {
CAT, CAT,
obj: element, obj: element,
"Initializing base time: local {}, remote {}", "Initializing base time: local {}, remote {}",
gst::ClockTime::from_nseconds(local_time), local_time.nseconds(),
gst::ClockTime::from_nseconds(remote_time), remote_time.nseconds(),
); );
inner.base_remote_time = Some(remote_time); inner.base_remote_time = Some(remote_time);
inner.base_local_time = Some(local_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 { 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 // Check if the slope is simply wrong and try correcting
@ -426,15 +426,15 @@ impl Observations {
CAT, CAT,
obj: element, obj: element,
"Initializing base time: local {}, remote {}, slope correction {}/{}", "Initializing base time: local {}, remote {}, slope correction {}/{}",
gst::ClockTime::from_nseconds(local_time), local_time.nseconds(),
gst::ClockTime::from_nseconds(remote_time), remote_time.nseconds(),
inner.slope_correction.0, inner.slope_correction.0,
inner.slope_correction.1, inner.slope_correction.1,
); );
inner.base_remote_time = Some(remote_time); inner.base_remote_time = Some(remote_time);
inner.base_local_time = Some(local_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, CAT,
obj: element, obj: element,
"Local diff {}, remote diff {}, delta {}", "Local diff {}, remote diff {}, delta {}",
gst::ClockTime::from_nseconds(local_diff), local_diff.nseconds(),
gst::ClockTime::from_nseconds(remote_diff), remote_diff.nseconds(),
delta, delta,
); );
@ -469,15 +469,15 @@ impl Observations {
CAT, CAT,
obj: element, obj: element,
"Initializing base time: local {}, remote {}", "Initializing base time: local {}, remote {}",
gst::ClockTime::from_nseconds(local_time), local_time.nseconds(),
gst::ClockTime::from_nseconds(remote_time), remote_time.nseconds(),
); );
inner.reset(); inner.reset();
inner.base_remote_time = Some(remote_time); inner.base_remote_time = Some(remote_time);
inner.base_local_time = Some(local_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 { if inner.filling {
@ -526,14 +526,9 @@ impl Observations {
inner.skew, inner.skew,
inner.min_delta inner.min_delta
); );
gst::trace!( gst::trace!(CAT, obj: element, "Outputting {}", out_time.nseconds());
CAT,
obj: element,
"Outputting {}",
gst::ClockTime::from_nseconds(out_time)
);
Some((gst::ClockTime::from_nseconds(out_time), duration, false)) Some((out_time.nseconds(), duration, false))
} }
} }
@ -839,7 +834,7 @@ impl Receiver {
CAT, CAT,
obj: &element, obj: &element,
"Received metadata at timecode {}: {}", "Received metadata at timecode {}: {}",
gst::ClockTime::from_nseconds(frame.timecode() as u64 * 100), (frame.timecode() as u64 * 100).nseconds(),
metadata, metadata,
); );
} }
@ -901,13 +896,13 @@ impl Receiver {
) -> Option<(gst::ClockTime, Option<gst::ClockTime>, bool)> { ) -> Option<(gst::ClockTime, Option<gst::ClockTime>, bool)> {
let receive_time = element.current_running_time()?; 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 { let timestamp = if timestamp == ndisys::NDIlib_recv_timestamp_undefined {
gst::ClockTime::NONE gst::ClockTime::NONE
} else { } 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!( gst::log!(
CAT, CAT,
@ -1305,14 +1300,14 @@ impl Receiver {
gst::ReferenceTimestampMeta::add( gst::ReferenceTimestampMeta::add(
buffer, buffer,
&*crate::TIMECODE_CAPS, &*crate::TIMECODE_CAPS,
gst::ClockTime::from_nseconds(video_frame.timecode() as u64 * 100), (video_frame.timecode() as u64 * 100).nseconds(),
gst::ClockTime::NONE, gst::ClockTime::NONE,
); );
if video_frame.timestamp() != ndisys::NDIlib_recv_timestamp_undefined { if video_frame.timestamp() != ndisys::NDIlib_recv_timestamp_undefined {
gst::ReferenceTimestampMeta::add( gst::ReferenceTimestampMeta::add(
buffer, buffer,
&*crate::TIMESTAMP_CAPS, &*crate::TIMESTAMP_CAPS,
gst::ClockTime::from_nseconds(video_frame.timestamp() as u64 * 100), (video_frame.timestamp() as u64 * 100).nseconds(),
gst::ClockTime::NONE, gst::ClockTime::NONE,
); );
} }
@ -1676,14 +1671,14 @@ impl Receiver {
gst::ReferenceTimestampMeta::add( gst::ReferenceTimestampMeta::add(
buffer, buffer,
&*crate::TIMECODE_CAPS, &*crate::TIMECODE_CAPS,
gst::ClockTime::from_nseconds(audio_frame.timecode() as u64 * 100), (audio_frame.timecode() as u64 * 100).nseconds(),
gst::ClockTime::NONE, gst::ClockTime::NONE,
); );
if audio_frame.timestamp() != ndisys::NDIlib_recv_timestamp_undefined { if audio_frame.timestamp() != ndisys::NDIlib_recv_timestamp_undefined {
gst::ReferenceTimestampMeta::add( gst::ReferenceTimestampMeta::add(
buffer, buffer,
&*crate::TIMESTAMP_CAPS, &*crate::TIMESTAMP_CAPS,
gst::ClockTime::from_nseconds(audio_frame.timestamp() as u64 * 100), (audio_frame.timestamp() as u64 * 100).nseconds(),
gst::ClockTime::NONE, gst::ClockTime::NONE,
); );
} }

View file

@ -217,7 +217,7 @@ impl OnvifMetadataCombiner {
imp: self, imp: self,
"could not calculate duration for current media buffer" "could not calculate duration for current media buffer"
); );
Some(gst::ClockTime::from_nseconds(0)) Some(gst::ClockTime::ZERO)
} }
} }
} else if timeout { } else if timeout {
@ -226,7 +226,7 @@ impl OnvifMetadataCombiner {
imp: self, imp: self,
"could not calculate duration for current media buffer" "could not calculate duration for current media buffer"
); );
Some(gst::ClockTime::from_nseconds(0)) Some(gst::ClockTime::ZERO)
} else { } else {
gst::trace!( gst::trace!(
CAT, CAT,
@ -304,11 +304,9 @@ impl AggregatorImpl for OnvifMetadataCombiner {
s.set("frames", buflist); s.set("frames", buflist);
} }
let position = buffer.pts().opt_add( let position = buffer
buffer .pts()
.duration() .opt_add(buffer.duration().unwrap_or(gst::ClockTime::ZERO));
.unwrap_or_else(|| gst::ClockTime::from_nseconds(0)),
);
gst::log!(CAT, imp: self, "Updating position: {:?}", position); gst::log!(CAT, imp: self, "Updating position: {:?}", position);

View file

@ -69,7 +69,7 @@ impl Default for Settings {
fn default() -> Self { fn default() -> Self {
Settings { Settings {
latency: None, latency: None,
max_lateness: Some(gst::ClockTime::from_mseconds(200)), max_lateness: Some(200.mseconds()),
} }
} }
} }
@ -359,8 +359,8 @@ impl OnvifMetadataParse {
gst::FlowError::Error gst::FlowError::Error
})?; })?;
let dt_unix_ns = gst::ClockTime::from_nseconds(dt.timestamp_nanos() as u64) let dt_unix_ns =
+ crate::PRIME_EPOCH_OFFSET; (dt.timestamp_nanos() as u64).nseconds() + crate::PRIME_EPOCH_OFFSET;
gst::trace!( gst::trace!(
CAT, CAT,
@ -909,7 +909,7 @@ impl OnvifMetadataParse {
if parsed { if parsed {
gst::ClockTime::ZERO gst::ClockTime::ZERO
} else { } else {
gst::ClockTime::from_seconds(6) 6.seconds()
} }
}; };
state.configured_latency = latency; state.configured_latency = latency;

View file

@ -547,8 +547,8 @@ impl RaptorqDec {
let tolerance = settings.repair_window_tolerance as u64; let tolerance = settings.repair_window_tolerance as u64;
let repair_window = fmtp_param_from_caps::<u64>("repair-window", incaps)?; let repair_window = fmtp_param_from_caps::<u64>("repair-window", incaps)?;
let tolerance = gst::ClockTime::from_mseconds(tolerance); let tolerance = tolerance.mseconds();
let repair_window = gst::ClockTime::from_useconds(repair_window); let repair_window = repair_window.useconds();
let repair_window = Some(repair_window + tolerance); let repair_window = Some(repair_window + tolerance);
let media_packets_reset_threshold = settings.media_packets_reset_threshold as usize; let media_packets_reset_threshold = settings.media_packets_reset_threshold as usize;

View file

@ -177,7 +177,7 @@ impl RaptorqEnc {
.unwrap_or(0); .unwrap_or(0);
let delays = (1..=state.repair_packets_num) 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<_>>(); .collect::<Vec<_>>();
let base_time = self.instance().base_time(); let base_time = self.instance().base_time();

View file

@ -195,8 +195,7 @@ impl RaptorqTest {
} }
// Check if repair packets pushed from encoder are delayed properly // Check if repair packets pushed from encoder are delayed properly
let delay_step = let delay_step = ((self.repair_window / self.repair_packets) as u64).mseconds();
gst::ClockTime::from_mseconds((self.repair_window / self.repair_packets) as u64);
let mut delay = delay_step; let mut delay = delay_step;
let repair_packets = (0..self.repair_packets) 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.set_src_caps_str("application/x-rtp");
h_dec_fec.set_src_caps(caps); 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(); let result = h_enc.pull();
assert!(result.is_ok()); assert!(result.is_ok());

View file

@ -930,13 +930,12 @@ fn test_seek_after_ready() {
assert_eq!(current_state, gst::State::Ready); assert_eq!(current_state, gst::State::Ready);
h.run(|src| { h.run(|src| {
src.seek_simple(gst::SeekFlags::FLUSH, gst::format::Bytes::from_u64(123)) src.seek_simple(gst::SeekFlags::FLUSH, 123.bytes()).unwrap();
.unwrap();
src.set_state(gst::State::Playing).unwrap(); src.set_state(gst::State::Playing).unwrap();
}); });
let segment = h.wait_for_segment(false); 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]; let mut expected_output = vec![0; 8192 - 123];
for (i, d) in expected_output.iter_mut().enumerate() { 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 //seek to a position after a buffer is Received
h.run(|src| { h.run(|src| {
src.seek_simple(gst::SeekFlags::FLUSH, gst::format::Bytes::from_u64(123)) src.seek_simple(gst::SeekFlags::FLUSH, 123.bytes()).unwrap();
.unwrap();
}); });
let segment = h.wait_for_segment(true); 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]; let mut expected_output = vec![0; 8192 - 123];
for (i, d) in expected_output.iter_mut().enumerate() { for (i, d) in expected_output.iter_mut().enumerate() {
@ -1086,8 +1084,8 @@ fn test_seek_with_stop_position() {
assert_eq!(buffer.offset(), 0); assert_eq!(buffer.offset(), 0);
//seek to a position after a buffer is Received //seek to a position after a buffer is Received
let start = gst::format::Bytes::from_u64(123); let start = 123.bytes();
let stop = gst::format::Bytes::from_u64(131); let stop = 131.bytes();
h.run(move |src| { h.run(move |src| {
src.seek( src.seek(
1.0, 1.0,

View file

@ -8,6 +8,8 @@
#![allow(clippy::single_match)] #![allow(clippy::single_match)]
use gst::prelude::*;
fn init() { fn init() {
use std::sync::Once; use std::sync::Once;
static INIT: Once = Once::new(); static INIT: Once = Once::new();
@ -31,8 +33,8 @@ fn test_enc() {
let buf = { let buf = {
let mut buf = gst::Buffer::from_mut_slice(Vec::from(input)); let mut buf = gst::Buffer::from_mut_slice(Vec::from(input));
let buf_ref = buf.get_mut().unwrap(); let buf_ref = buf.get_mut().unwrap();
buf_ref.set_pts(gst::ClockTime::from_seconds(0)); buf_ref.set_pts(gst::ClockTime::ZERO);
buf_ref.set_duration(gst::ClockTime::from_seconds(2)); buf_ref.set_duration(2.seconds());
buf buf
}; };
@ -47,7 +49,7 @@ fn test_enc() {
let buf = h.pull().expect("Couldn't pull buffer"); let buf = h.pull().expect("Couldn't pull buffer");
assert_eq!(buf.pts(), Some(gst::ClockTime::ZERO)); 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"); let map = buf.map_readable().expect("Couldn't map buffer readable");
assert_eq!( assert_eq!(
std::str::from_utf8(map.as_ref()), std::str::from_utf8(map.as_ref()),
@ -93,6 +95,6 @@ fn test_parse() {
let buf = h.pull().expect("Couldn't pull buffer"); let buf = h.pull().expect("Couldn't pull buffer");
let map = buf.map_readable().expect("Couldn't map buffer readable"); let map = buf.map_readable().expect("Couldn't map buffer readable");
assert_eq!(buf.pts(), Some(gst::ClockTime::ZERO)); 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}")); assert_eq!(std::str::from_utf8(map.as_ref()), Ok("{\"foo\":42}"));
} }

View file

@ -46,8 +46,8 @@ fn test_replace_all() {
let buf = { let buf = {
let mut buf = gst::Buffer::from_mut_slice(Vec::from(&input[..])); let mut buf = gst::Buffer::from_mut_slice(Vec::from(&input[..]));
let buf_ref = buf.get_mut().unwrap(); let buf_ref = buf.get_mut().unwrap();
buf_ref.set_pts(gst::ClockTime::from_seconds(0)); buf_ref.set_pts(gst::ClockTime::ZERO);
buf_ref.set_duration(gst::ClockTime::from_seconds(2)); buf_ref.set_duration(2.seconds());
buf buf
}; };
@ -56,7 +56,7 @@ fn test_replace_all() {
let buf = h.pull().expect("Couldn't pull buffer"); let buf = h.pull().expect("Couldn't pull buffer");
assert_eq!(buf.pts(), Some(gst::ClockTime::ZERO)); 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"); let map = buf.map_readable().expect("Couldn't map buffer readable");

View file

@ -509,8 +509,7 @@ impl ObjectImpl for TextWrap {
"accumulate-time" => { "accumulate-time" => {
let mut settings = self.settings.lock().unwrap(); let mut settings = self.settings.lock().unwrap();
let old_accumulate_time = settings.accumulate_time; let old_accumulate_time = settings.accumulate_time;
settings.accumulate_time = settings.accumulate_time = value.get::<u64>().unwrap().nseconds();
gst::ClockTime::from_nseconds(value.get().expect("type checked upstream"));
if settings.accumulate_time != old_accumulate_time { if settings.accumulate_time != old_accumulate_time {
gst::debug!( gst::debug!(
CAT, CAT,

View file

@ -38,8 +38,8 @@ fn test_columns() {
let buf = { let buf = {
let mut buf = gst::Buffer::from_mut_slice(Vec::from(&input[..])); let mut buf = gst::Buffer::from_mut_slice(Vec::from(&input[..]));
let buf_ref = buf.get_mut().unwrap(); let buf_ref = buf.get_mut().unwrap();
buf_ref.set_pts(gst::ClockTime::from_seconds(0)); buf_ref.set_pts(gst::ClockTime::ZERO);
buf_ref.set_duration(gst::ClockTime::from_seconds(2)); buf_ref.set_duration(2.seconds());
buf buf
}; };
@ -48,7 +48,7 @@ fn test_columns() {
let buf = h.pull().expect("Couldn't pull buffer"); let buf = h.pull().expect("Couldn't pull buffer");
assert_eq!(buf.pts(), Some(gst::ClockTime::ZERO)); 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"); let map = buf.map_readable().expect("Couldn't map buffer readable");
@ -77,8 +77,8 @@ fn test_lines() {
let buf = { let buf = {
let mut buf = gst::Buffer::from_mut_slice(Vec::from(&input[..])); let mut buf = gst::Buffer::from_mut_slice(Vec::from(&input[..]));
let buf_ref = buf.get_mut().unwrap(); let buf_ref = buf.get_mut().unwrap();
buf_ref.set_pts(gst::ClockTime::from_seconds(0)); buf_ref.set_pts(gst::ClockTime::ZERO);
buf_ref.set_duration(gst::ClockTime::from_seconds(2)); buf_ref.set_duration(2.seconds());
buf buf
}; };

View file

@ -96,9 +96,9 @@ impl Default for Settings {
uri: None, uri: None,
source: None, source: None,
fallback_uri: None, fallback_uri: None,
timeout: 5 * gst::ClockTime::SECOND, timeout: 5.seconds(),
restart_timeout: 5 * gst::ClockTime::SECOND, restart_timeout: 5.seconds(),
retry_timeout: 60 * gst::ClockTime::SECOND, retry_timeout: 60.seconds(),
restart_on_eos: false, restart_on_eos: false,
min_latency: gst::ClockTime::ZERO, min_latency: gst::ClockTime::ZERO,
buffer_duration: -1, buffer_duration: -1,
@ -918,10 +918,7 @@ impl FallbackSrc {
queue.set_properties(&[ queue.set_properties(&[
("max-size-bytes", &0u32), ("max-size-bytes", &0u32),
("max-size-buffers", &0u32), ("max-size-buffers", &0u32),
( ("max-size-time", &(cmp::max(min_latency, 1.seconds()))),
"max-size-time",
&(cmp::max(min_latency, gst::ClockTime::from_seconds(1))),
),
]); ]);
bin.add_many(&[ bin.add_many(&[
@ -975,10 +972,7 @@ impl FallbackSrc {
queue.set_properties(&[ queue.set_properties(&[
("max-size-bytes", &0u32), ("max-size-bytes", &0u32),
("max-size-buffers", &0u32), ("max-size-buffers", &0u32),
( ("max-size-time", &(cmp::max(min_latency, 1.seconds()))),
"max-size-time",
&(cmp::max(min_latency, gst::ClockTime::from_seconds(1))),
),
]); ]);
bin.add_many(&[ bin.add_many(&[
@ -1764,7 +1758,7 @@ impl FallbackSrc {
("max-size-buffers", &0u32), ("max-size-buffers", &0u32),
( (
"max-size-time", "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(|_| { let clocksync = gst::ElementFactory::make("clocksync", None).unwrap_or_else(|_| {

View file

@ -55,15 +55,15 @@ fn test_no_fallback_no_drops() {
let buffer = pull_buffer(&pipeline); let buffer = pull_buffer(&pipeline);
assert_buffer!(buffer, Some(gst::ClockTime::ZERO)); assert_buffer!(buffer, Some(gst::ClockTime::ZERO));
push_buffer(&pipeline, gst::ClockTime::SECOND); push_buffer(&pipeline, 1.seconds());
set_time(&pipeline, gst::ClockTime::SECOND + LATENCY); set_time(&pipeline, 1.seconds() + LATENCY);
let buffer = pull_buffer(&pipeline); let buffer = pull_buffer(&pipeline);
assert_buffer!(buffer, Some(gst::ClockTime::SECOND)); assert_buffer!(buffer, Some(gst::ClockTime::SECOND));
push_buffer(&pipeline, 2 * gst::ClockTime::SECOND); push_buffer(&pipeline, 2.seconds());
set_time(&pipeline, 2 * gst::ClockTime::SECOND + LATENCY); set_time(&pipeline, 2.seconds() + LATENCY);
let buffer = pull_buffer(&pipeline); let buffer = pull_buffer(&pipeline);
assert_buffer!(buffer, Some(2 * gst::ClockTime::SECOND)); assert_buffer!(buffer, Some(2.seconds()));
push_eos(&pipeline); push_eos(&pipeline);
wait_eos(&pipeline); wait_eos(&pipeline);
@ -90,17 +90,17 @@ fn test_no_drops(live: bool) {
let buffer = pull_buffer(&pipeline); let buffer = pull_buffer(&pipeline);
assert_buffer!(buffer, Some(gst::ClockTime::ZERO)); assert_buffer!(buffer, Some(gst::ClockTime::ZERO));
push_fallback_buffer(&pipeline, gst::ClockTime::SECOND); push_fallback_buffer(&pipeline, 1.seconds());
push_buffer(&pipeline, gst::ClockTime::SECOND); push_buffer(&pipeline, 1.seconds());
set_time(&pipeline, gst::ClockTime::SECOND + LATENCY); set_time(&pipeline, 1.seconds() + LATENCY);
let buffer = pull_buffer(&pipeline); let buffer = pull_buffer(&pipeline);
assert_buffer!(buffer, Some(gst::ClockTime::SECOND)); assert_buffer!(buffer, Some(gst::ClockTime::SECOND));
push_buffer(&pipeline, 2 * gst::ClockTime::SECOND); push_buffer(&pipeline, 2.seconds());
push_fallback_buffer(&pipeline, 2 * gst::ClockTime::SECOND); push_fallback_buffer(&pipeline, 2.seconds());
set_time(&pipeline, 2 * gst::ClockTime::SECOND + LATENCY); set_time(&pipeline, 2.seconds() + LATENCY);
let buffer = pull_buffer(&pipeline); 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 // EOS on the fallback should not be required
push_eos(&pipeline); push_eos(&pipeline);
@ -129,15 +129,15 @@ fn test_no_drops_but_no_fallback_frames(live: bool) {
let buffer = pull_buffer(&pipeline); let buffer = pull_buffer(&pipeline);
assert_buffer!(buffer, Some(gst::ClockTime::ZERO)); assert_buffer!(buffer, Some(gst::ClockTime::ZERO));
push_buffer(&pipeline, gst::ClockTime::SECOND); push_buffer(&pipeline, 1.seconds());
set_time(&pipeline, gst::ClockTime::SECOND + LATENCY); set_time(&pipeline, 1.seconds() + LATENCY);
let buffer = pull_buffer(&pipeline); let buffer = pull_buffer(&pipeline);
assert_buffer!(buffer, Some(gst::ClockTime::SECOND)); assert_buffer!(buffer, Some(gst::ClockTime::SECOND));
push_buffer(&pipeline, 2 * gst::ClockTime::SECOND); push_buffer(&pipeline, 2.seconds());
set_time(&pipeline, 2 * gst::ClockTime::SECOND + LATENCY); set_time(&pipeline, 2.seconds() + LATENCY);
let buffer = pull_buffer(&pipeline); 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 // EOS on the fallback should not be required
push_eos(&pipeline); push_eos(&pipeline);
@ -167,18 +167,15 @@ fn test_short_drop(live: bool) {
// A timeout at 1s will get rid of the fallback buffer // A timeout at 1s will get rid of the fallback buffer
// but not output anything // but not output anything
push_fallback_buffer(&pipeline, gst::ClockTime::SECOND); push_fallback_buffer(&pipeline, 1.seconds());
// Time out the fallback buffer at +10ms // Time out the fallback buffer at +10ms
set_time( set_time(&pipeline, 1.seconds() + 10.mseconds());
&pipeline,
gst::ClockTime::SECOND + 10 * gst::ClockTime::MSECOND,
);
push_fallback_buffer(&pipeline, 2 * gst::ClockTime::SECOND); push_fallback_buffer(&pipeline, 2.seconds());
push_buffer(&pipeline, 2 * gst::ClockTime::SECOND); push_buffer(&pipeline, 2.seconds());
set_time(&pipeline, 2 * gst::ClockTime::SECOND + LATENCY); set_time(&pipeline, 2.seconds() + LATENCY);
let buffer = pull_buffer(&pipeline); let buffer = pull_buffer(&pipeline);
assert_buffer!(buffer, Some(2 * gst::ClockTime::SECOND)); assert_buffer!(buffer, Some(2.seconds()));
push_eos(&pipeline); push_eos(&pipeline);
push_fallback_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)); assert_buffer!(buffer, Some(gst::ClockTime::ZERO));
// Produce a second frame but only from the fallback source // Produce a second frame but only from the fallback source
push_fallback_buffer(&pipeline, gst::ClockTime::SECOND); push_fallback_buffer(&pipeline, 1.seconds());
set_time( set_time(&pipeline, 1.seconds() + 10.mseconds());
&pipeline,
gst::ClockTime::SECOND + 10 * gst::ClockTime::MSECOND,
);
// Produce a third frame but only from the fallback source // Produce a third frame but only from the fallback source
push_fallback_buffer(&pipeline, 2 * gst::ClockTime::SECOND); push_fallback_buffer(&pipeline, 2.seconds());
set_time( set_time(&pipeline, 2.seconds() + 10.mseconds());
&pipeline,
2 * gst::ClockTime::SECOND + 10 * gst::ClockTime::MSECOND,
);
// Produce a fourth frame but only from the fallback source // Produce a fourth frame but only from the fallback source
// This should be output now // This should be output now
push_fallback_buffer(&pipeline, 3 * gst::ClockTime::SECOND); push_fallback_buffer(&pipeline, 3.seconds());
set_time( set_time(&pipeline, 3.seconds() + 10.mseconds());
&pipeline,
3 * gst::ClockTime::SECOND + 10 * gst::ClockTime::MSECOND,
);
let buffer = pull_buffer(&pipeline); 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 // Produce a fifth frame but only from the fallback source
// This should be output now // This should be output now
push_fallback_buffer(&pipeline, 4 * gst::ClockTime::SECOND); push_fallback_buffer(&pipeline, 4.seconds());
set_time( set_time(&pipeline, 4.seconds() + 10.mseconds());
&pipeline,
4 * gst::ClockTime::SECOND + 10 * gst::ClockTime::MSECOND,
);
let buffer = pull_buffer(&pipeline); 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 // Wait for EOS to arrive at appsink
push_eos(&pipeline); push_eos(&pipeline);
@ -273,70 +258,49 @@ fn test_long_drop_and_recover(live: bool) {
assert!(mainsink.property::<bool>("is-healthy")); assert!(mainsink.property::<bool>("is-healthy"));
// Produce a second frame but only from the fallback source // Produce a second frame but only from the fallback source
push_fallback_buffer(&pipeline, gst::ClockTime::SECOND); push_fallback_buffer(&pipeline, 1.seconds());
set_time( set_time(&pipeline, 1.seconds() + 10.mseconds());
&pipeline,
gst::ClockTime::SECOND + 10 * gst::ClockTime::MSECOND,
);
// Produce a third frame but only from the fallback source // Produce a third frame but only from the fallback source
push_fallback_buffer(&pipeline, 2 * gst::ClockTime::SECOND); push_fallback_buffer(&pipeline, 2.seconds());
set_time( set_time(&pipeline, 2.seconds() + 10.mseconds());
&pipeline,
2 * gst::ClockTime::SECOND + 10 * gst::ClockTime::MSECOND,
);
// Produce a fourth frame but only from the fallback source // Produce a fourth frame but only from the fallback source
// This should be output now // This should be output now
push_fallback_buffer(&pipeline, 3 * gst::ClockTime::SECOND); push_fallback_buffer(&pipeline, 3.seconds());
set_time( set_time(&pipeline, 3.seconds() + 10.mseconds());
&pipeline,
3 * gst::ClockTime::SECOND + 10 * gst::ClockTime::MSECOND,
);
let buffer = pull_buffer(&pipeline); 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 // Produce a fifth frame but only from the fallback source
// This should be output now // This should be output now
push_fallback_buffer(&pipeline, 4 * gst::ClockTime::SECOND); push_fallback_buffer(&pipeline, 4.seconds());
set_time( set_time(&pipeline, 4.seconds() + 10.mseconds());
&pipeline,
4 * gst::ClockTime::SECOND + 10 * gst::ClockTime::MSECOND,
);
let buffer = pull_buffer(&pipeline); 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 // Produce a sixth frame from the normal source
push_buffer(&pipeline, 5 * gst::ClockTime::SECOND); push_buffer(&pipeline, 5.seconds());
set_time( set_time(&pipeline, 5.seconds() + 10.mseconds());
&pipeline,
5 * gst::ClockTime::SECOND + 10 * gst::ClockTime::MSECOND,
);
let buffer = pull_buffer(&pipeline); 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")); assert!(!mainsink.property::<bool>("is-healthy"));
drop(mainsink); drop(mainsink);
drop(switch); drop(switch);
// Produce a seventh frame from the normal source but no fallback. // Produce a seventh frame from the normal source but no fallback.
// This should still be output immediately // This should still be output immediately
push_buffer(&pipeline, 6 * gst::ClockTime::SECOND); push_buffer(&pipeline, 6.seconds());
set_time( set_time(&pipeline, 6.seconds() + 10.mseconds());
&pipeline,
6 * gst::ClockTime::SECOND + 10 * gst::ClockTime::MSECOND,
);
let buffer = pull_buffer(&pipeline); 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 // Produce a eight frame from the normal source
push_buffer(&pipeline, 7 * gst::ClockTime::SECOND); push_buffer(&pipeline, 7.seconds());
push_fallback_buffer(&pipeline, 7 * gst::ClockTime::SECOND); push_fallback_buffer(&pipeline, 7.seconds());
set_time( set_time(&pipeline, 7.seconds() + 10.mseconds());
&pipeline,
7 * gst::ClockTime::SECOND + 10 * gst::ClockTime::MSECOND,
);
let buffer = pull_buffer(&pipeline); 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 // Wait for EOS to arrive at appsink
push_eos(&pipeline); push_eos(&pipeline);
@ -364,38 +328,26 @@ fn test_initial_timeout(live: bool) {
set_time(&pipeline, gst::ClockTime::ZERO); set_time(&pipeline, gst::ClockTime::ZERO);
// Produce a second frame but only from the fallback source // Produce a second frame but only from the fallback source
push_fallback_buffer(&pipeline, gst::ClockTime::SECOND); push_fallback_buffer(&pipeline, 1.seconds());
set_time( set_time(&pipeline, 1.seconds() + 10.mseconds());
&pipeline,
gst::ClockTime::SECOND + 10 * gst::ClockTime::MSECOND,
);
// Produce a third frame but only from the fallback source // Produce a third frame but only from the fallback source
push_fallback_buffer(&pipeline, 2 * gst::ClockTime::SECOND); push_fallback_buffer(&pipeline, 2.seconds());
set_time( set_time(&pipeline, 2.seconds() + 10.mseconds());
&pipeline,
2 * gst::ClockTime::SECOND + 10 * gst::ClockTime::MSECOND,
);
// Produce a fourth frame but only from the fallback source // Produce a fourth frame but only from the fallback source
// This should be output now // This should be output now
push_fallback_buffer(&pipeline, 3 * gst::ClockTime::SECOND); push_fallback_buffer(&pipeline, 3.seconds());
set_time( set_time(&pipeline, 3.seconds() + 10.mseconds());
&pipeline,
3 * gst::ClockTime::SECOND + 10 * gst::ClockTime::MSECOND,
);
let buffer = pull_buffer(&pipeline); 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 // Produce a fifth frame but only from the fallback source
// This should be output now // This should be output now
push_fallback_buffer(&pipeline, 4 * gst::ClockTime::SECOND); push_fallback_buffer(&pipeline, 4.seconds());
set_time( set_time(&pipeline, 4.seconds() + 10.mseconds());
&pipeline,
4 * gst::ClockTime::SECOND + 10 * gst::ClockTime::MSECOND,
);
let buffer = pull_buffer(&pipeline); 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 // Wait for EOS to arrive at appsink
push_eos(&pipeline); push_eos(&pipeline);
@ -457,9 +409,9 @@ fn test_manual_switch(live: bool) {
assert_buffer!(buffer, Some(gst::ClockTime::ZERO)); assert_buffer!(buffer, Some(gst::ClockTime::ZERO));
switch.set_property("active-pad", &fallbacksink); switch.set_property("active-pad", &fallbacksink);
push_fallback_buffer(&pipeline, gst::ClockTime::SECOND); push_fallback_buffer(&pipeline, 1.seconds());
push_buffer(&pipeline, gst::ClockTime::SECOND); push_buffer(&pipeline, 1.seconds());
set_time(&pipeline, gst::ClockTime::SECOND + LATENCY); set_time(&pipeline, 1.seconds() + LATENCY);
let mut buffer = pull_buffer(&pipeline); let mut buffer = pull_buffer(&pipeline);
// FIXME: Sometimes we first get the ZERO buffer from the fallback sink // FIXME: Sometimes we first get the ZERO buffer from the fallback sink
if buffer.pts() == Some(gst::ClockTime::ZERO) { 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)); assert_fallback_buffer!(buffer, Some(gst::ClockTime::SECOND));
switch.set_property("active-pad", &mainsink); switch.set_property("active-pad", &mainsink);
push_buffer(&pipeline, 2 * gst::ClockTime::SECOND); push_buffer(&pipeline, 2.seconds());
push_fallback_buffer(&pipeline, 2 * gst::ClockTime::SECOND); push_fallback_buffer(&pipeline, 2.seconds());
set_time(&pipeline, 2 * gst::ClockTime::SECOND + LATENCY); set_time(&pipeline, 2.seconds() + LATENCY);
buffer = pull_buffer(&pipeline); buffer = pull_buffer(&pipeline);
// FIXME: Sometimes we first get the 1sec buffer from the main sink // FIXME: Sometimes we first get the 1sec buffer from the main sink
if buffer.pts() == Some(gst::ClockTime::SECOND) { if buffer.pts() == Some(gst::ClockTime::SECOND) {
buffer = pull_buffer(&pipeline); buffer = pull_buffer(&pipeline);
} }
assert_buffer!(buffer, Some(2 * gst::ClockTime::SECOND)); assert_buffer!(buffer, Some(2.seconds()));
drop(mainsink); drop(mainsink);
drop(fallbacksink); drop(fallbacksink);
@ -539,7 +491,7 @@ fn setup_pipeline(
); );
let switch = gst::ElementFactory::make("fallbackswitch", Some("switch")).unwrap(); 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 { if let Some(imm) = immediate_fallback {
switch.set_property("immediate-fallback", imm); switch.set_property("immediate-fallback", imm);
} }

View file

@ -143,8 +143,8 @@ fn setup_sender_receiver(
let mut buffer = buffer.clone(); let mut buffer = buffer.clone();
{ {
let buffer = buffer.make_mut(); let buffer = buffer.make_mut();
buffer.set_pts(offset + i * 20 * gst::ClockTime::MSECOND); buffer.set_pts(offset + i * 20.mseconds());
buffer.set_duration(20 * gst::ClockTime::MSECOND); buffer.set_duration(20.mseconds());
} }
let _ = sinkpad.chain(buffer); let _ = sinkpad.chain(buffer);
i += 1; i += 1;
@ -156,11 +156,8 @@ fn setup_sender_receiver(
buffer buffer
.get_mut() .get_mut()
.unwrap() .unwrap()
.set_pts(offset + i * 20 * gst::ClockTime::MSECOND); .set_pts(offset + i * 20.mseconds());
buffer buffer.get_mut().unwrap().set_duration(20.mseconds());
.get_mut()
.unwrap()
.set_duration(20 * gst::ClockTime::MSECOND);
buffer buffer
.get_mut() .get_mut()
.unwrap() .unwrap()
@ -171,10 +168,7 @@ fn setup_sender_receiver(
} }
SendData::Gaps(n) => { SendData::Gaps(n) => {
for _ in 0..n { for _ in 0..n {
let event = gst::event::Gap::new( let event = gst::event::Gap::new(offset + i * 20.mseconds(), 20.mseconds());
offset + i * 20 * gst::ClockTime::MSECOND,
20 * gst::ClockTime::MSECOND,
);
let _ = sinkpad.send_event(event); let _ = sinkpad.send_event(event);
i += 1; i += 1;
} }
@ -297,9 +291,9 @@ fn test_one_stream_open() {
assert_eq!(buffers.len(), 10); assert_eq!(buffers.len(), 10);
for (index, &(running_time, pts, duration)) in buffers.iter().enumerate() { for (index, &(running_time, pts, duration)) in buffers.iter().enumerate() {
let index = index as u64; let index = index as u64;
assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND); assert_eq!(running_time.unwrap(), index * 20.mseconds());
assert_eq!(pts.unwrap(), index * 20 * gst::ClockTime::MSECOND); assert_eq!(pts.unwrap(), index * 20.mseconds());
assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND); assert_eq!(duration.unwrap(), 20.mseconds());
} }
thread.join().unwrap(); thread.join().unwrap();
@ -330,9 +324,9 @@ fn test_one_stream_gaps_open() {
assert_eq!(buffers.len(), 10); assert_eq!(buffers.len(), 10);
for (index, &(running_time, pts, duration)) in buffers.iter().enumerate() { for (index, &(running_time, pts, duration)) in buffers.iter().enumerate() {
let index = index as u64; let index = index as u64;
assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND); assert_eq!(running_time.unwrap(), index * 20.mseconds());
assert_eq!(pts.unwrap(), index * 20 * gst::ClockTime::MSECOND); assert_eq!(pts.unwrap(), index * 20.mseconds());
assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND); assert_eq!(duration.unwrap(), 20.mseconds());
} }
thread.join().unwrap(); thread.join().unwrap();
@ -364,9 +358,9 @@ fn test_one_stream_close_open() {
assert_eq!(buffers.len(), 10); assert_eq!(buffers.len(), 10);
for (index, &(running_time, pts, duration)) in buffers.iter().enumerate() { for (index, &(running_time, pts, duration)) in buffers.iter().enumerate() {
let index = index as u64; let index = index as u64;
assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND); assert_eq!(running_time.unwrap(), index * 20.mseconds());
assert_eq!(pts.unwrap(), (10 + index) * 20 * gst::ClockTime::MSECOND); assert_eq!(pts.unwrap(), (10 + index) * 20.mseconds());
assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND); assert_eq!(duration.unwrap(), 20.mseconds());
} }
thread.join().unwrap(); thread.join().unwrap();
@ -399,9 +393,9 @@ fn test_one_stream_open_close() {
assert_eq!(buffers.len(), 10); assert_eq!(buffers.len(), 10);
for (index, &(running_time, pts, duration)) in buffers.iter().enumerate() { for (index, &(running_time, pts, duration)) in buffers.iter().enumerate() {
let index = index as u64; let index = index as u64;
assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND); assert_eq!(running_time.unwrap(), index * 20.mseconds());
assert_eq!(pts.unwrap(), index * 20 * gst::ClockTime::MSECOND); assert_eq!(pts.unwrap(), index * 20.mseconds());
assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND); assert_eq!(duration.unwrap(), 20.mseconds());
} }
thread.join().unwrap(); thread.join().unwrap();
@ -437,15 +431,15 @@ fn test_one_stream_open_close_open() {
assert_eq!(buffers.len(), 20); assert_eq!(buffers.len(), 20);
for (index, &(running_time, pts, duration)) in buffers.iter().enumerate() { for (index, &(running_time, pts, duration)) in buffers.iter().enumerate() {
let pts_off = if index >= 10 { let pts_off = if index >= 10 {
10 * 20 * gst::ClockTime::MSECOND 10 * 20.mseconds()
} else { } else {
gst::ClockTime::ZERO gst::ClockTime::ZERO
}; };
let index = index as u64; let index = index as u64;
assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND); assert_eq!(running_time.unwrap(), index * 20.mseconds());
assert_eq!(pts.unwrap(), pts_off + index * 20 * gst::ClockTime::MSECOND); assert_eq!(pts.unwrap(), pts_off + index * 20.mseconds());
assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND); assert_eq!(duration.unwrap(), 20.mseconds());
} }
thread.join().unwrap(); thread.join().unwrap();
@ -483,9 +477,9 @@ fn test_two_stream_open() {
let (buffers_1, _) = recv_buffers(&receiver_output_1, &mut segment_1, 0); let (buffers_1, _) = recv_buffers(&receiver_output_1, &mut segment_1, 0);
for (index, &(running_time, pts, duration)) in buffers_1.iter().enumerate() { for (index, &(running_time, pts, duration)) in buffers_1.iter().enumerate() {
let index = index as u64; let index = index as u64;
assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND); assert_eq!(running_time.unwrap(), index * 20.mseconds());
assert_eq!(pts.unwrap(), index * 20 * gst::ClockTime::MSECOND); assert_eq!(pts.unwrap(), index * 20.mseconds());
assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND); assert_eq!(duration.unwrap(), 20.mseconds());
} }
assert_eq!(buffers_1.len(), 10); 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); let (buffers_2, _) = recv_buffers(&receiver_output_2, &mut segment_2, 0);
for (index, &(running_time, pts, duration)) in buffers_2.iter().enumerate() { for (index, &(running_time, pts, duration)) in buffers_2.iter().enumerate() {
let index = index as u64; let index = index as u64;
assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND); assert_eq!(running_time.unwrap(), index * 20.mseconds());
assert_eq!(pts.unwrap(), index * 20 * gst::ClockTime::MSECOND); assert_eq!(pts.unwrap(), index * 20.mseconds());
assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND); assert_eq!(duration.unwrap(), 20.mseconds());
} }
assert_eq!(buffers_2.len(), 10); 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) = let (sender_input_1, receiver_input_done_1, receiver_output_1, thread_1) =
setup_sender_receiver(&pipeline, &togglerecord, "src", gst::ClockTime::ZERO); setup_sender_receiver(&pipeline, &togglerecord, "src", gst::ClockTime::ZERO);
let (sender_input_2, receiver_input_done_2, receiver_output_2, thread_2) = let (sender_input_2, receiver_input_done_2, receiver_output_2, thread_2) =
setup_sender_receiver( setup_sender_receiver(&pipeline, &togglerecord, "src_%u", 5.mseconds());
&pipeline,
&togglerecord,
"src_%u",
5 * gst::ClockTime::MSECOND,
);
pipeline.set_state(gst::State::Playing).unwrap(); 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); let (buffers_1, _) = recv_buffers(&receiver_output_1, &mut segment_1, 0);
for (index, &(running_time, pts, duration)) in buffers_1.iter().enumerate() { for (index, &(running_time, pts, duration)) in buffers_1.iter().enumerate() {
let index = index as u64; let index = index as u64;
assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND); assert_eq!(running_time.unwrap(), index * 20.mseconds());
assert_eq!(pts.unwrap(), index * 20 * gst::ClockTime::MSECOND); assert_eq!(pts.unwrap(), index * 20.mseconds());
assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND); assert_eq!(duration.unwrap(), 20.mseconds());
} }
assert_eq!(buffers_1.len(), 10); 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); let (buffers_2, _) = recv_buffers(&receiver_output_2, &mut segment_2, 0);
for (index, &(running_time, pts, duration)) in buffers_2.iter().enumerate() { for (index, &(running_time, pts, duration)) in buffers_2.iter().enumerate() {
let index = index as u64; let index = index as u64;
assert_eq!( assert_eq!(running_time.unwrap(), 5.mseconds() + index * 20.mseconds());
running_time.unwrap(), assert_eq!(pts.unwrap(), 5.mseconds() + index * 20.mseconds());
5 * gst::ClockTime::MSECOND + index * 20 * gst::ClockTime::MSECOND
);
assert_eq!(
pts.unwrap(),
5 * gst::ClockTime::MSECOND + index * 20 * gst::ClockTime::MSECOND
);
if index == 9 { if index == 9 {
assert_eq!(duration.unwrap(), 15 * gst::ClockTime::MSECOND); assert_eq!(duration.unwrap(), 15.mseconds());
} else { } else {
assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND); assert_eq!(duration.unwrap(), 20.mseconds());
} }
} }
assert_eq!(buffers_2.len(), 10); assert_eq!(buffers_2.len(), 10);
@ -583,7 +566,7 @@ fn test_two_stream_open_shift_main() {
pipeline.add(&togglerecord).unwrap(); pipeline.add(&togglerecord).unwrap();
let (sender_input_1, receiver_input_done_1, receiver_output_1, thread_1) = 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) = let (sender_input_2, receiver_input_done_2, receiver_output_2, thread_2) =
setup_sender_receiver(&pipeline, &togglerecord, "src_%u", gst::ClockTime::ZERO); 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); let (buffers_1, _) = recv_buffers(&receiver_output_1, &mut segment_1, 0);
for (index, &(running_time, pts, duration)) in buffers_1.iter().enumerate() { for (index, &(running_time, pts, duration)) in buffers_1.iter().enumerate() {
let index = index as u64; let index = index as u64;
assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND); assert_eq!(running_time.unwrap(), index * 20.mseconds());
assert_eq!( assert_eq!(pts.unwrap(), 5.mseconds() + index * 20.mseconds());
pts.unwrap(), assert_eq!(duration.unwrap(), 20.mseconds());
5 * gst::ClockTime::MSECOND + index * 20 * gst::ClockTime::MSECOND
);
assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND);
} }
assert_eq!(buffers_1.len(), 10); 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() { for (index, &(running_time, pts, duration)) in buffers_2.iter().enumerate() {
let index = index as u64; let index = index as u64;
if index == 0 { if index == 0 {
assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND); assert_eq!(running_time.unwrap(), index * 20.mseconds());
assert_eq!( assert_eq!(pts.unwrap(), 5.mseconds() + index * 20.mseconds());
pts.unwrap(), assert_eq!(duration.unwrap(), 15.mseconds());
5 * gst::ClockTime::MSECOND + index * 20 * gst::ClockTime::MSECOND
);
assert_eq!(duration.unwrap(), 15 * gst::ClockTime::MSECOND);
} else if index == 10 { } else if index == 10 {
assert_eq!( assert_eq!(running_time.unwrap(), index * 20.mseconds() - 5.mseconds());
running_time.unwrap(), assert_eq!(pts.unwrap(), index * 20.mseconds());
index * 20 * gst::ClockTime::MSECOND - 5 * gst::ClockTime::MSECOND assert_eq!(duration.unwrap(), 5.mseconds());
);
assert_eq!(pts.unwrap(), index * 20 * gst::ClockTime::MSECOND);
assert_eq!(duration.unwrap(), 5 * gst::ClockTime::MSECOND);
} else { } else {
assert_eq!( assert_eq!(running_time.unwrap(), index * 20.mseconds() - 5.mseconds());
running_time.unwrap(), assert_eq!(pts.unwrap(), index * 20.mseconds());
index * 20 * gst::ClockTime::MSECOND - 5 * gst::ClockTime::MSECOND assert_eq!(duration.unwrap(), 20.mseconds());
);
assert_eq!(pts.unwrap(), index * 20 * gst::ClockTime::MSECOND);
assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND);
} }
} }
assert_eq!(buffers_2.len(), 11); 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); let (buffers_1, _) = recv_buffers(&receiver_output_1, &mut segment_1, 0);
for (index, &(running_time, pts, duration)) in buffers_1.iter().enumerate() { for (index, &(running_time, pts, duration)) in buffers_1.iter().enumerate() {
let index = index as u64; let index = index as u64;
assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND); assert_eq!(running_time.unwrap(), index * 20.mseconds());
assert_eq!(pts.unwrap(), index * 20 * gst::ClockTime::MSECOND); assert_eq!(pts.unwrap(), index * 20.mseconds());
assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND); assert_eq!(duration.unwrap(), 20.mseconds());
} }
assert_eq!(buffers_1.len(), 10); 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); let (buffers_2, _) = recv_buffers(&receiver_output_2, &mut segment_2, 0);
for (index, &(running_time, pts, duration)) in buffers_2.iter().enumerate() { for (index, &(running_time, pts, duration)) in buffers_2.iter().enumerate() {
let index = index as u64; let index = index as u64;
assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND); assert_eq!(running_time.unwrap(), index * 20.mseconds());
assert_eq!(pts.unwrap(), index * 20 * gst::ClockTime::MSECOND); assert_eq!(pts.unwrap(), index * 20.mseconds());
assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND); assert_eq!(duration.unwrap(), 20.mseconds());
} }
assert_eq!(buffers_2.len(), 10); 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); let (buffers_1, _) = recv_buffers(&receiver_output_1, &mut segment_1, 0);
for (index, &(running_time, pts, duration)) in buffers_1.iter().enumerate() { for (index, &(running_time, pts, duration)) in buffers_1.iter().enumerate() {
let index = index as u64; let index = index as u64;
assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND); assert_eq!(running_time.unwrap(), index * 20.mseconds());
assert_eq!(pts.unwrap(), (10 + index) * 20 * gst::ClockTime::MSECOND); assert_eq!(pts.unwrap(), (10 + index) * 20.mseconds());
assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND); assert_eq!(duration.unwrap(), 20.mseconds());
} }
assert_eq!(buffers_1.len(), 10); 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); let (buffers_2, _) = recv_buffers(&receiver_output_2, &mut segment_2, 0);
for (index, &(running_time, pts, duration)) in buffers_2.iter().enumerate() { for (index, &(running_time, pts, duration)) in buffers_2.iter().enumerate() {
let index = index as u64; let index = index as u64;
assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND); assert_eq!(running_time.unwrap(), index * 20.mseconds());
assert_eq!(pts.unwrap(), (10 + index) * 20 * gst::ClockTime::MSECOND); assert_eq!(pts.unwrap(), (10 + index) * 20.mseconds());
assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND); assert_eq!(duration.unwrap(), 20.mseconds());
} }
assert_eq!(buffers_2.len(), 10); 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); let (buffers_1, _) = recv_buffers(&receiver_output_1, &mut segment_1, 0);
for (index, &(running_time, pts, duration)) in buffers_1.iter().enumerate() { for (index, &(running_time, pts, duration)) in buffers_1.iter().enumerate() {
let pts_off = if index >= 10 { let pts_off = if index >= 10 {
10 * 20 * gst::ClockTime::MSECOND 10 * 20.mseconds()
} else { } else {
gst::ClockTime::ZERO gst::ClockTime::ZERO
}; };
let index = index as u64; let index = index as u64;
assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND); assert_eq!(running_time.unwrap(), index * 20.mseconds());
assert_eq!(pts.unwrap(), pts_off + index * 20 * gst::ClockTime::MSECOND); assert_eq!(pts.unwrap(), pts_off + index * 20.mseconds());
assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND); assert_eq!(duration.unwrap(), 20.mseconds());
} }
assert_eq!(buffers_1.len(), 20); 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); let (buffers_2, _) = recv_buffers(&receiver_output_2, &mut segment_2, 0);
for (index, &(running_time, pts, duration)) in buffers_2.iter().enumerate() { for (index, &(running_time, pts, duration)) in buffers_2.iter().enumerate() {
let pts_off = if index >= 10 { let pts_off = if index >= 10 {
10 * 20 * gst::ClockTime::MSECOND 10 * 20.mseconds()
} else { } else {
gst::ClockTime::ZERO gst::ClockTime::ZERO
}; };
let index = index as u64; let index = index as u64;
assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND); assert_eq!(running_time.unwrap(), index * 20.mseconds());
assert_eq!(pts.unwrap(), pts_off + index * 20 * gst::ClockTime::MSECOND); assert_eq!(pts.unwrap(), pts_off + index * 20.mseconds());
assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND); assert_eq!(duration.unwrap(), 20.mseconds());
} }
assert_eq!(buffers_2.len(), 20); 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); let (buffers_1, _) = recv_buffers(&receiver_output_1, &mut segment_1, 0);
for (index, &(running_time, pts, duration)) in buffers_1.iter().enumerate() { for (index, &(running_time, pts, duration)) in buffers_1.iter().enumerate() {
let pts_off = if index >= 10 { let pts_off = if index >= 10 {
10 * 20 * gst::ClockTime::MSECOND 10 * 20.mseconds()
} else { } else {
gst::ClockTime::ZERO gst::ClockTime::ZERO
}; };
let index = index as u64; let index = index as u64;
assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND); assert_eq!(running_time.unwrap(), index * 20.mseconds());
assert_eq!(pts.unwrap(), pts_off + index * 20 * gst::ClockTime::MSECOND); assert_eq!(pts.unwrap(), pts_off + index * 20.mseconds());
assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND); assert_eq!(duration.unwrap(), 20.mseconds());
} }
assert_eq!(buffers_1.len(), 20); 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); let (buffers_2, _) = recv_buffers(&receiver_output_2, &mut segment_2, 0);
for (index, &(running_time, pts, duration)) in buffers_2.iter().enumerate() { for (index, &(running_time, pts, duration)) in buffers_2.iter().enumerate() {
let pts_off = if index >= 10 { let pts_off = if index >= 10 {
10 * 20 * gst::ClockTime::MSECOND 10 * 20.mseconds()
} else { } else {
gst::ClockTime::ZERO gst::ClockTime::ZERO
}; };
let index = index as u64; let index = index as u64;
assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND); assert_eq!(running_time.unwrap(), index * 20.mseconds());
assert_eq!(pts.unwrap(), pts_off + index * 20 * gst::ClockTime::MSECOND); assert_eq!(pts.unwrap(), pts_off + index * 20.mseconds());
assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND); assert_eq!(duration.unwrap(), 20.mseconds());
} }
assert_eq!(buffers_2.len(), 20); 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); let (buffers_1, _) = recv_buffers(&receiver_output_1, &mut segment_1, 0);
for (index, &(running_time, pts, duration)) in buffers_1.iter().enumerate() { for (index, &(running_time, pts, duration)) in buffers_1.iter().enumerate() {
let index = index as u64; let index = index as u64;
assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND); assert_eq!(running_time.unwrap(), index * 20.mseconds());
assert_eq!(pts.unwrap(), (11 + index) * 20 * gst::ClockTime::MSECOND); assert_eq!(pts.unwrap(), (11 + index) * 20.mseconds());
assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND); assert_eq!(duration.unwrap(), 20.mseconds());
} }
assert_eq!(buffers_1.len(), 10); 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); let (buffers_2, _) = recv_buffers(&receiver_output_2, &mut segment_2, 0);
for (index, &(running_time, pts, duration)) in buffers_2.iter().enumerate() { for (index, &(running_time, pts, duration)) in buffers_2.iter().enumerate() {
let index = index as u64; let index = index as u64;
assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND); assert_eq!(running_time.unwrap(), index * 20.mseconds());
assert_eq!(pts.unwrap(), (11 + index) * 20 * gst::ClockTime::MSECOND); assert_eq!(pts.unwrap(), (11 + index) * 20.mseconds());
assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND); assert_eq!(duration.unwrap(), 20.mseconds());
} }
assert_eq!(buffers_2.len(), 10); 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); let (buffers_1, _) = recv_buffers(&receiver_output_1, &mut segment_1, 0);
for (index, &(running_time, pts, duration)) in buffers_1.iter().enumerate() { for (index, &(running_time, pts, duration)) in buffers_1.iter().enumerate() {
let pts_off = if index >= 10 { let pts_off = if index >= 10 {
10 * 20 * gst::ClockTime::MSECOND 10 * 20.mseconds()
} else { } else {
gst::ClockTime::ZERO gst::ClockTime::ZERO
}; };
let index = index as u64; let index = index as u64;
assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND); assert_eq!(running_time.unwrap(), index * 20.mseconds());
assert_eq!(pts.unwrap(), pts_off + index * 20 * gst::ClockTime::MSECOND); assert_eq!(pts.unwrap(), pts_off + index * 20.mseconds());
assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND); assert_eq!(duration.unwrap(), 20.mseconds());
} }
assert_eq!(buffers_1.len(), 20); 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); let (buffers_2, _) = recv_buffers(&receiver_output_2, &mut segment_2, 0);
for (index, &(running_time, pts, duration)) in buffers_2.iter().enumerate() { for (index, &(running_time, pts, duration)) in buffers_2.iter().enumerate() {
let pts_off = if index >= 10 { let pts_off = if index >= 10 {
10 * 20 * gst::ClockTime::MSECOND 10 * 20.mseconds()
} else { } else {
gst::ClockTime::ZERO gst::ClockTime::ZERO
}; };
let index = index as u64; let index = index as u64;
assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND); assert_eq!(running_time.unwrap(), index * 20.mseconds());
assert_eq!(pts.unwrap(), pts_off + index * 20 * gst::ClockTime::MSECOND); assert_eq!(pts.unwrap(), pts_off + index * 20.mseconds());
assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND); assert_eq!(duration.unwrap(), 20.mseconds());
} }
assert_eq!(buffers_2.len(), 20); 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); let (buffers_3, _) = recv_buffers(&receiver_output_3, &mut segment_3, 0);
for (index, &(running_time, pts, duration)) in buffers_3.iter().enumerate() { for (index, &(running_time, pts, duration)) in buffers_3.iter().enumerate() {
let pts_off = if index >= 10 { let pts_off = if index >= 10 {
10 * 20 * gst::ClockTime::MSECOND 10 * 20.mseconds()
} else { } else {
gst::ClockTime::ZERO gst::ClockTime::ZERO
}; };
let index = index as u64; let index = index as u64;
assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND); assert_eq!(running_time.unwrap(), index * 20.mseconds());
assert_eq!(pts.unwrap(), pts_off + index * 20 * gst::ClockTime::MSECOND); assert_eq!(pts.unwrap(), pts_off + index * 20.mseconds());
assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND); assert_eq!(duration.unwrap(), 20.mseconds());
} }
assert_eq!(buffers_3.len(), 20); 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); 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() { for (index, &(running_time, pts, duration)) in buffers_1.iter().enumerate() {
let index = index as u64; let index = index as u64;
assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND); assert_eq!(running_time.unwrap(), index * 20.mseconds());
assert_eq!(pts.unwrap(), index * 20 * gst::ClockTime::MSECOND); assert_eq!(pts.unwrap(), index * 20.mseconds());
assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND); assert_eq!(duration.unwrap(), 20.mseconds());
} }
assert_eq!(buffers_1.len(), 10); assert_eq!(buffers_1.len(), 10);
assert!(saw_eos); 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); 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() { for (index, &(running_time, pts, duration)) in buffers_2.iter().enumerate() {
let index = index as u64; let index = index as u64;
assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND); assert_eq!(running_time.unwrap(), index * 20.mseconds());
assert_eq!(pts.unwrap(), index * 20 * gst::ClockTime::MSECOND); assert_eq!(pts.unwrap(), index * 20.mseconds());
assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND); assert_eq!(duration.unwrap(), 20.mseconds());
} }
assert_eq!(buffers_2.len(), 10); assert_eq!(buffers_2.len(), 10);
assert!(saw_eos); 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); 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() { for (index, &(running_time, pts, duration)) in buffers_1.iter().enumerate() {
let index = index as u64; let index = index as u64;
assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND); assert_eq!(running_time.unwrap(), index * 20.mseconds());
assert_eq!(pts.unwrap(), index * 20 * gst::ClockTime::MSECOND); assert_eq!(pts.unwrap(), index * 20.mseconds());
assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND); assert_eq!(duration.unwrap(), 20.mseconds());
} }
assert_eq!(buffers_1.len(), 10); assert_eq!(buffers_1.len(), 10);
assert!(saw_eos); 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); 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() { for (index, &(running_time, pts, duration)) in buffers_2.iter().enumerate() {
let index = index as u64; let index = index as u64;
assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND); assert_eq!(running_time.unwrap(), index * 20.mseconds());
assert_eq!(pts.unwrap(), index * 20 * gst::ClockTime::MSECOND); assert_eq!(pts.unwrap(), index * 20.mseconds());
assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND); assert_eq!(duration.unwrap(), 20.mseconds());
} }
assert_eq!(buffers_2.len(), 9); assert_eq!(buffers_2.len(), 9);
assert!(saw_eos); 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); 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() { for (index, &(running_time, pts, duration)) in buffers_1.iter().enumerate() {
let index = index as u64; let index = index as u64;
assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND); assert_eq!(running_time.unwrap(), index * 20.mseconds());
assert_eq!(pts.unwrap(), index * 20 * gst::ClockTime::MSECOND); assert_eq!(pts.unwrap(), index * 20.mseconds());
assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND); assert_eq!(duration.unwrap(), 20.mseconds());
} }
assert_eq!(buffers_1.len(), 10); assert_eq!(buffers_1.len(), 10);
assert!(saw_eos); 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); 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() { for (index, &(running_time, pts, duration)) in buffers_2.iter().enumerate() {
let index = index as u64; let index = index as u64;
assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND); assert_eq!(running_time.unwrap(), index * 20.mseconds());
assert_eq!(pts.unwrap(), index * 20 * gst::ClockTime::MSECOND); assert_eq!(pts.unwrap(), index * 20.mseconds());
assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND); assert_eq!(duration.unwrap(), 20.mseconds());
} }
assert_eq!(buffers_2.len(), 10); assert_eq!(buffers_2.len(), 10);
assert!(saw_eos); 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); 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() { for (index, &(running_time, pts, duration)) in buffers_3.iter().enumerate() {
let index = index as u64; let index = index as u64;
assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND); assert_eq!(running_time.unwrap(), index * 20.mseconds());
assert_eq!(pts.unwrap(), index * 20 * gst::ClockTime::MSECOND); assert_eq!(pts.unwrap(), index * 20.mseconds());
assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND); assert_eq!(duration.unwrap(), 20.mseconds());
} }
assert_eq!(buffers_3.len(), 10); assert_eq!(buffers_3.len(), 10);
assert!(saw_eos); 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); 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() { for (index, &(running_time, pts, duration)) in buffers_1.iter().enumerate() {
let index = index as u64; let index = index as u64;
assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND); assert_eq!(running_time.unwrap(), index * 20.mseconds());
assert_eq!(pts.unwrap(), index * 20 * gst::ClockTime::MSECOND); assert_eq!(pts.unwrap(), index * 20.mseconds());
assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND); assert_eq!(duration.unwrap(), 20.mseconds());
} }
assert_eq!(buffers_1.len(), 10); assert_eq!(buffers_1.len(), 10);
assert!(saw_eos); 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); 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() { for (index, &(running_time, pts, duration)) in buffers_2.iter().enumerate() {
let index = index as u64; let index = index as u64;
assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND); assert_eq!(running_time.unwrap(), index * 20.mseconds());
assert_eq!(pts.unwrap(), index * 20 * gst::ClockTime::MSECOND); assert_eq!(pts.unwrap(), index * 20.mseconds());
assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND); assert_eq!(duration.unwrap(), 20.mseconds());
} }
assert_eq!(buffers_2.len(), 9); assert_eq!(buffers_2.len(), 9);
assert!(saw_eos); 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); 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() { for (index, &(running_time, pts, duration)) in buffers_3.iter().enumerate() {
let index = index as u64; let index = index as u64;
assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND); assert_eq!(running_time.unwrap(), index * 20.mseconds());
assert_eq!(pts.unwrap(), index * 20 * gst::ClockTime::MSECOND); assert_eq!(pts.unwrap(), index * 20.mseconds());
assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND); assert_eq!(duration.unwrap(), 20.mseconds());
} }
assert_eq!(buffers_3.len(), 10); assert_eq!(buffers_3.len(), 10);
assert!(saw_eos); 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); 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() { for (index, &(running_time, pts, duration)) in buffers_1.iter().enumerate() {
let index = index as u64; let index = index as u64;
assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND); assert_eq!(running_time.unwrap(), index * 20.mseconds());
assert_eq!(pts.unwrap(), index * 20 * gst::ClockTime::MSECOND); assert_eq!(pts.unwrap(), index * 20.mseconds());
assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND); assert_eq!(duration.unwrap(), 20.mseconds());
} }
assert_eq!(buffers_1.len(), 10); assert_eq!(buffers_1.len(), 10);
assert!(saw_eos); 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); 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() { for (index, &(running_time, pts, duration)) in buffers_2.iter().enumerate() {
let index = index as u64; let index = index as u64;
assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND); assert_eq!(running_time.unwrap(), index * 20.mseconds());
assert_eq!(pts.unwrap(), index * 20 * gst::ClockTime::MSECOND); assert_eq!(pts.unwrap(), index * 20.mseconds());
assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND); assert_eq!(duration.unwrap(), 20.mseconds());
} }
assert_eq!(buffers_2.len(), 9); assert_eq!(buffers_2.len(), 9);
assert!(saw_eos); 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); 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() { for (index, &(running_time, pts, duration)) in buffers_3.iter().enumerate() {
let index = index as u64; let index = index as u64;
assert_eq!(running_time.unwrap(), index * 20 * gst::ClockTime::MSECOND); assert_eq!(running_time.unwrap(), index * 20.mseconds());
assert_eq!(pts.unwrap(), index * 20 * gst::ClockTime::MSECOND); assert_eq!(pts.unwrap(), index * 20.mseconds());
assert_eq!(duration.unwrap(), 20 * gst::ClockTime::MSECOND); assert_eq!(duration.unwrap(), 20.mseconds());
} }
assert_eq!(buffers_3.len(), 9); assert_eq!(buffers_3.len(), 9);
assert!(saw_eos); assert!(saw_eos);

View file

@ -34,28 +34,28 @@ impl TestMedia {
fn ogg() -> Self { fn ogg() -> Self {
Self { Self {
uri: file_name_to_uri("sample.ogg"), uri: file_name_to_uri("sample.ogg"),
len: gst::ClockTime::from_mseconds(510), len: 510.mseconds(),
} }
} }
fn mkv() -> Self { fn mkv() -> Self {
Self { Self {
uri: file_name_to_uri("sample.mkv"), uri: file_name_to_uri("sample.mkv"),
len: gst::ClockTime::from_mseconds(510), len: 510.mseconds(),
} }
} }
fn missing_file() -> Self { fn missing_file() -> Self {
Self { Self {
uri: "file:///not-there.ogg".to_string(), uri: "file:///not-there.ogg".to_string(),
len: gst::ClockTime::from_mseconds(10), len: 10.mseconds(),
} }
} }
fn missing_http() -> Self { fn missing_http() -> Self {
Self { Self {
uri: "http:///not-there.ogg".to_string(), 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(); pipeline.add_many(&[&playlist, &mq]).unwrap();
let total_len = gst::ClockTime::from_nseconds( let total_len: gst::ClockTime = medias.iter().map(|t| t.len * (iterations as u64)).sum();
medias
.iter()
.map(|t| t.len.nseconds() * (iterations as u64))
.sum(),
);
let uris: Vec<String> = medias.iter().map(|t| t.uri.clone()).collect(); let uris: Vec<String> = medias.iter().map(|t| t.uri.clone()).collect();

View file

@ -92,22 +92,20 @@ impl ElementImpl for CdgParse {
} }
fn bytes_to_time(bytes: Bytes) -> gst::ClockTime { fn bytes_to_time(bytes: Bytes) -> gst::ClockTime {
let nb = *bytes / CDG_PACKET_SIZE as u64; let nb = bytes / CDG_PACKET_SIZE as u64;
gst::ClockTime::from_nseconds( nb.mul_div_round(*gst::ClockTime::SECOND, CDG_PACKET_PERIOD)
nb.mul_div_round(*gst::ClockTime::SECOND, CDG_PACKET_PERIOD) .unwrap()
.unwrap(), .nseconds()
)
} }
fn time_to_bytes(time: gst::ClockTime) -> Bytes { fn time_to_bytes(time: gst::ClockTime) -> Bytes {
Bytes::from_u64( time.nseconds()
time.nseconds() .mul_div_round(
.mul_div_round( CDG_PACKET_PERIOD * CDG_PACKET_SIZE as u64,
CDG_PACKET_PERIOD * CDG_PACKET_SIZE as u64, *gst::ClockTime::SECOND,
*gst::ClockTime::SECOND, )
) .unwrap()
.unwrap(), .bytes()
)
} }
impl BaseParseImpl for CdgParse { 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(); let buffer = frame.buffer_mut().unwrap();
buffer.set_pts(pts); buffer.set_pts(pts);

View file

@ -258,8 +258,7 @@ impl ObjectImpl for CCDetect {
match pspec.name() { match pspec.name() {
"window" => { "window" => {
let mut settings = self.settings.lock().unwrap(); let mut settings = self.settings.lock().unwrap();
settings.window = settings.window = value.get::<u64>().unwrap().nseconds();
gst::ClockTime::from_nseconds(value.get().expect("type checked upstream"));
} }
_ => unimplemented!(), _ => unimplemented!(),
} }

View file

@ -577,7 +577,7 @@ impl ObjectImpl for Cea608Overlay {
glib::ParamSpecUInt64::builder("timeout") glib::ParamSpecUInt64::builder("timeout")
.nick("Timeout") .nick("Timeout")
.blurb("Duration after which to erase overlay when no cc data has arrived for the selected field") .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) .default_value(u64::MAX)
.mutable_playing() .mutable_playing()
.build(), .build(),
@ -613,7 +613,7 @@ impl ObjectImpl for Cea608Overlay {
settings.timeout = match timeout { settings.timeout = match timeout {
u64::MAX => gst::ClockTime::NONE, u64::MAX => gst::ClockTime::NONE,
_ => Some(gst::ClockTime::from_nseconds(timeout)), _ => Some(timeout.nseconds()),
}; };
} }
_ => unimplemented!(), _ => unimplemented!(),

View file

@ -582,7 +582,7 @@ impl ObjectImpl for JsonToVtt {
vec![glib::ParamSpecUInt64::builder("timeout") vec![glib::ParamSpecUInt64::builder("timeout")
.nick("Timeout") .nick("Timeout")
.blurb("Duration after which to erase text when no data has arrived") .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) .default_value(u64::MAX)
.mutable_playing() .mutable_playing()
.build()] .build()]
@ -601,7 +601,7 @@ impl ObjectImpl for JsonToVtt {
settings.timeout = match timeout { settings.timeout = match timeout {
u64::MAX => gst::ClockTime::NONE, u64::MAX => gst::ClockTime::NONE,
_ => Some(gst::ClockTime::from_nseconds(timeout)), _ => Some(timeout.nseconds()),
}; };
state.settings.timeout = settings.timeout; state.settings.timeout = settings.timeout;
} }
@ -707,15 +707,12 @@ mod tests {
let segment = gst::FormattedSegment::<gst::ClockTime>::new(); let segment = gst::FormattedSegment::<gst::ClockTime>::new();
let pts: gst::ClockTime = gst::ClockTime::from_nseconds(0); let pts = gst::ClockTime::ZERO;
let duration: Option<gst::ClockTime> = Some(gst::ClockTime::from_nseconds(10)); let duration = Some(10.nseconds());
assert_eq!( assert_eq!(
clamp(&segment, pts, duration), clamp(&segment, pts, duration),
Some(( Some((gst::ClockTime::ZERO, Some(10.nseconds())))
gst::ClockTime::from_nseconds(0),
Some(gst::ClockTime::from_nseconds(10))
))
); );
} }
@ -724,17 +721,14 @@ mod tests {
gst::init().unwrap(); gst::init().unwrap();
let mut segment = gst::FormattedSegment::<gst::ClockTime>::new(); 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 pts = gst::ClockTime::ZERO;
let duration = Some(gst::ClockTime::from_nseconds(10)); let duration = Some(10.nseconds());
assert_eq!( assert_eq!(
clamp(&segment, pts, duration), clamp(&segment, pts, duration),
Some(( Some((2.nseconds(), Some(8.nseconds())))
gst::ClockTime::from_nseconds(2),
Some(gst::ClockTime::from_nseconds(8))
))
); );
} }
@ -743,17 +737,14 @@ mod tests {
gst::init().unwrap(); gst::init().unwrap();
let mut segment = gst::FormattedSegment::<gst::ClockTime>::new(); 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 pts = gst::ClockTime::ZERO;
let duration = Some(gst::ClockTime::from_nseconds(10)); let duration = Some(10.nseconds());
assert_eq!( assert_eq!(
clamp(&segment, pts, duration), clamp(&segment, pts, duration),
Some(( Some((gst::ClockTime::ZERO, Some(7.nseconds())))
gst::ClockTime::from_nseconds(0),
Some(gst::ClockTime::from_nseconds(7))
))
); );
} }
@ -762,18 +753,15 @@ mod tests {
gst::init().unwrap(); gst::init().unwrap();
let mut segment = gst::FormattedSegment::<gst::ClockTime>::new(); let mut segment = gst::FormattedSegment::<gst::ClockTime>::new();
segment.set_start(gst::ClockTime::from_nseconds(2)); segment.set_start(2.nseconds());
segment.set_stop(gst::ClockTime::from_nseconds(7)); segment.set_stop(7.nseconds());
let pts = gst::ClockTime::from_nseconds(0); let pts = gst::ClockTime::ZERO;
let duration = Some(gst::ClockTime::from_nseconds(10)); let duration = Some(10.nseconds());
assert_eq!( assert_eq!(
clamp(&segment, pts, duration), clamp(&segment, pts, duration),
Some(( Some((2.nseconds(), Some(5.nseconds())))
gst::ClockTime::from_nseconds(2),
Some(gst::ClockTime::from_nseconds(5))
))
); );
} }
@ -782,10 +770,10 @@ mod tests {
gst::init().unwrap(); gst::init().unwrap();
let mut segment = gst::FormattedSegment::<gst::ClockTime>::new(); 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 pts = gst::ClockTime::ZERO;
let duration = Some(gst::ClockTime::from_nseconds(10)); let duration = Some(10.nseconds());
assert_eq!(clamp(&segment, pts, duration), None); assert_eq!(clamp(&segment, pts, duration), None);
} }
@ -795,10 +783,10 @@ mod tests {
gst::init().unwrap(); gst::init().unwrap();
let mut segment = gst::FormattedSegment::<gst::ClockTime>::new(); 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 pts = 15.nseconds();
let duration = Some(gst::ClockTime::from_nseconds(10)); let duration = Some(10.nseconds());
assert_eq!(clamp(&segment, pts, duration), None); assert_eq!(clamp(&segment, pts, duration), None);
} }

View file

@ -220,9 +220,7 @@ impl TranscriberBin {
self.instance().add(&state.internal_bin)?; self.instance().add(&state.internal_bin)?;
state state.cccombiner.set_property("latency", 100.mseconds());
.cccombiner
.set_property("latency", 100 * gst::ClockTime::MSECOND);
self.audio_sinkpad self.audio_sinkpad
.set_target(Some(&state.internal_bin.static_pad("audio_sink").unwrap()))?; .set_target(Some(&state.internal_bin.static_pad("audio_sink").unwrap()))?;

View file

@ -204,7 +204,9 @@ impl State {
let (fps_n, fps_d) = (self.framerate.numer() as u64, self.framerate.denom() as u64); 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) .mul_div_round(fps_d, fps_n)
.unwrap(); .unwrap();
@ -214,7 +216,9 @@ impl State {
gst::debug!(CAT, imp: imp, "More text than bandwidth!"); 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) .mul_div_round(fps_d, fps_n)
.unwrap(); .unwrap();
@ -1065,7 +1069,7 @@ impl ObjectImpl for TtToCea608 {
settings.roll_up_timeout = match timeout { settings.roll_up_timeout = match timeout {
u64::MAX => gst::ClockTime::NONE, u64::MAX => gst::ClockTime::NONE,
_ => Some(gst::ClockTime::from_nseconds(timeout)), _ => Some(timeout.nseconds()),
}; };
} }
_ => unimplemented!(), _ => unimplemented!(),

View file

@ -78,34 +78,13 @@ fn test_have_cc_data_notify() {
assert_push_data!(h, state, valid_cc608_data, ClockTime::ZERO, 1, 0); assert_push_data!(h, state, valid_cc608_data, ClockTime::ZERO, 1, 0);
/* invalid cc608 data moves cc608 property to false */ /* invalid cc608 data moves cc608 property to false */
assert_push_data!( assert_push_data!(h, state, invalid_cc608_data, 1_000_000_000.nseconds(), 2, 0);
h,
state,
invalid_cc608_data,
ClockTime::from_nseconds(1_000_000_000),
2,
0
);
/* valid cc708 data moves cc708 property to true */ /* valid cc708 data moves cc708 property to true */
assert_push_data!( assert_push_data!(h, state, valid_cc708_data, 2_000_000_000.nseconds(), 2, 1);
h,
state,
valid_cc708_data,
ClockTime::from_nseconds(2_000_000_000),
2,
1
);
/* invalid cc708 data moves cc708 property to false */ /* invalid cc708 data moves cc708 property to false */
assert_push_data!( assert_push_data!(h, state, invalid_cc708_data, 3_000_000_000.nseconds(), 2, 2);
h,
state,
invalid_cc708_data,
ClockTime::from_nseconds(3_000_000_000),
2,
2
);
} }
#[test] #[test]
@ -143,7 +122,7 @@ fn test_cc_data_window() {
h, h,
state, state,
valid_cc608_data.clone(), valid_cc608_data.clone(),
ClockTime::from_nseconds(300_000_000), 300_000_000.nseconds(),
1, 1,
0 0
); );
@ -153,40 +132,26 @@ fn test_cc_data_window() {
h, h,
state, state,
invalid_cc608_data.clone(), invalid_cc608_data.clone(),
ClockTime::from_nseconds(600_000_000), 600_000_000.nseconds(),
1, 1,
0 0
); );
/* invalid cc608 data after window expires, cc608 changes to false */ /* invalid cc608 data after window expires, cc608 changes to false */
assert_push_data!( assert_push_data!(h, state, invalid_cc608_data, 1_000_000_000.nseconds(), 2, 0);
h,
state,
invalid_cc608_data,
ClockTime::from_nseconds(1_000_000_000),
2,
0
);
/* valid cc608 data before window expires, no change */ /* valid cc608 data before window expires, no change */
assert_push_data!( assert_push_data!(
h, h,
state, state,
valid_cc608_data.clone(), valid_cc608_data.clone(),
ClockTime::from_nseconds(1_300_000_000), 1_300_000_000.nseconds(),
2, 2,
0 0
); );
/* valid cc608 data after window expires, property changes */ /* valid cc608 data after window expires, property changes */
assert_push_data!( assert_push_data!(h, state, valid_cc608_data, 1_600_000_000.nseconds(), 3, 0);
h,
state,
valid_cc608_data,
ClockTime::from_nseconds(1_600_000_000),
3,
0
);
} }
#[test] #[test]
@ -235,14 +200,7 @@ fn test_have_cdp_notify() {
assert_push_data!(h, state, valid_cc608_data, ClockTime::ZERO, 1, 0); assert_push_data!(h, state, valid_cc608_data, ClockTime::ZERO, 1, 0);
/* invalid cc608 data moves cc608 property to false */ /* invalid cc608 data moves cc608 property to false */
assert_push_data!( assert_push_data!(h, state, invalid_cc608_data, 1_000_000_000.nseconds(), 2, 0);
h,
state,
invalid_cc608_data,
ClockTime::from_nseconds(1_000_000_000),
2,
0
);
} }
#[test] #[test]
@ -300,56 +258,21 @@ fn test_malformed_cdp_notify() {
}); });
/* all invalid data does not change properties */ /* 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, too_short, ClockTime::ZERO, 0, 0);
assert_push_data!(h, state, wrong_magic, ClockTime::from_nseconds(1_000), 0, 0); assert_push_data!(h, state, wrong_magic, 1_000.nseconds(), 0, 0);
assert_push_data!( assert_push_data!(h, state, length_too_long, 2_000.nseconds(), 0, 0);
h, assert_push_data!(h, state, length_too_short, 3_000.nseconds(), 0, 0);
state, assert_push_data!(h, state, wrong_cc_data_header_byte, 4_000.nseconds(), 0, 0);
length_too_long, assert_push_data!(h, state, big_cc_count, 5_000.nseconds(), 0, 0);
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!( assert_push_data!(
h, h,
state, state,
wrong_cc_count_reserved_bits, wrong_cc_count_reserved_bits,
ClockTime::from_nseconds(6_000), 6_000.nseconds(),
0,
0
);
assert_push_data!(
h,
state,
cc608_after_cc708,
ClockTime::from_nseconds(7_000),
0, 0,
0 0
); );
assert_push_data!(h, state, cc608_after_cc708, 7_000.nseconds(), 0, 0);
} }
#[test] #[test]
@ -382,10 +305,7 @@ fn test_gap_events() {
assert_push_data!(h, state, valid_cc608_data, ClockTime::ZERO, 1, 0); assert_push_data!(h, state, valid_cc608_data, ClockTime::ZERO, 1, 0);
/* pushing gap event within the window changes nothing */ /* pushing gap event within the window changes nothing */
assert!(h.push_event(gst::event::Gap::new( assert!(h.push_event(gst::event::Gap::new(100_000_000.nseconds(), 1.nseconds())));
ClockTime::from_nseconds(100_000_000),
ClockTime::from_nseconds(1)
)),);
{ {
let state_guard = state.lock().unwrap(); 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 */ /* pushing gap event outside the window moves cc608 property to false */
assert!(h.push_event(gst::event::Gap::new( assert!(h.push_event(gst::event::Gap::new(1_000_000_000.nseconds(), 1.nseconds())));
ClockTime::from_nseconds(1_000_000_000),
ClockTime::from_nseconds(1)
)),);
{ {
let state_guard = state.lock().unwrap(); let state_guard = state.lock().unwrap();

View file

@ -36,23 +36,23 @@ fn test_parse() {
// Check the first 4 output buffers // Check the first 4 output buffers
let expected: [(ClockTime, ClockTime, &'static str); 4] = [ let expected: [(ClockTime, ClockTime, &'static str); 4] = [
( (
ClockTime::from_nseconds(15_048_366_666), 15_048_366_666.nseconds(),
ClockTime::from_nseconds(3_236_566_667), 3_236_566_667.nseconds(),
"From New York,\r\nthis is Democracy Now!", "From New York,\r\nthis is Democracy Now!",
), ),
( (
ClockTime::from_nseconds(18_985_633_333), 18_985_633_333.nseconds(),
ClockTime::from_nseconds(1_234_566_667), 1_234_566_667.nseconds(),
"Yes, Im supporting\r\nDonald Trump.", "Yes, Im supporting\r\nDonald Trump.",
), ),
( (
ClockTime::from_nseconds(20_220_200_000), 20_220_200_000.nseconds(),
ClockTime::from_nseconds(2_168_833_333), 2_168_833_333.nseconds(),
"Im doing so as enthusiastically\r\nas I can,", "Im doing so as enthusiastically\r\nas I can,",
), ),
( (
ClockTime::from_nseconds(22_389_033_333), 22_389_033_333.nseconds(),
ClockTime::from_nseconds(2_235_566_667), 2_235_566_667.nseconds(),
"even the fact I think\r\nhes a terrible human being.", "even the fact I think\r\nhes a terrible human being.",
), ),
]; ];

View file

@ -111,7 +111,7 @@ Time Code Rate=30DF\r\n\
let mut buf = gst::Buffer::from_mut_slice(Vec::from(input)); let mut buf = gst::Buffer::from_mut_slice(Vec::from(input));
let buf_ref = buf.get_mut().unwrap(); let buf_ref = buf.get_mut().unwrap();
gst_video::VideoTimeCodeMeta::add(buf_ref, &tc); gst_video::VideoTimeCodeMeta::add(buf_ref, &tc);
buf_ref.set_pts(gst::ClockTime::from_seconds(0)); buf_ref.set_pts(gst::ClockTime::ZERO);
buf buf
}; };

View file

@ -170,7 +170,7 @@ fn test_pull() {
gst::SeekType::Set, gst::SeekType::Set,
gst::ClockTime::SECOND, gst::ClockTime::SECOND,
gst::SeekType::Set, gst::SeekType::Set,
2 * gst::ClockTime::SECOND, 2.seconds(),
)); ));
loop { loop {
@ -179,7 +179,7 @@ fn test_pull() {
while h.buffers_in_queue() != 0 { while h.buffers_in_queue() != 0 {
if let Ok(buffer) = h.pull() { if let Ok(buffer) = h.pull() {
let pts = buffer.pts().unwrap(); let pts = buffer.pts().unwrap();
assert!(pts > gst::ClockTime::SECOND && pts < 2 * gst::ClockTime::SECOND); assert!(pts > gst::ClockTime::SECOND && pts < 2.seconds());
} }
} }

View file

@ -45,7 +45,7 @@ fn test_encode_single_packet() {
let mut buf = gst::Buffer::from_mut_slice(Vec::from(&input[..])); let mut buf = gst::Buffer::from_mut_slice(Vec::from(&input[..]));
let buf_ref = buf.get_mut().unwrap(); let buf_ref = buf.get_mut().unwrap();
gst_video::VideoTimeCodeMeta::add(buf_ref, &tc); gst_video::VideoTimeCodeMeta::add(buf_ref, &tc);
buf_ref.set_pts(gst::ClockTime::from_seconds(0)); buf_ref.set_pts(gst::ClockTime::ZERO);
buf buf
}; };
@ -117,7 +117,7 @@ fn test_encode_multiple_packets() {
let mut buf = gst::Buffer::from_mut_slice(Vec::from(&input1[..])); let mut buf = gst::Buffer::from_mut_slice(Vec::from(&input1[..]));
let buf_ref = buf.get_mut().unwrap(); let buf_ref = buf.get_mut().unwrap();
gst_video::VideoTimeCodeMeta::add(buf_ref, &tc1); gst_video::VideoTimeCodeMeta::add(buf_ref, &tc1);
buf_ref.set_pts(gst::ClockTime::from_seconds(0)); buf_ref.set_pts(gst::ClockTime::ZERO);
buf buf
}; };
@ -127,7 +127,7 @@ fn test_encode_multiple_packets() {
let mut tc = tc1.clone(); let mut tc = tc1.clone();
tc.increment_frame(); tc.increment_frame();
gst_video::VideoTimeCodeMeta::add(buf_ref, &tc); gst_video::VideoTimeCodeMeta::add(buf_ref, &tc);
buf_ref.set_pts(gst::ClockTime::from_seconds(0)); buf_ref.set_pts(gst::ClockTime::ZERO);
buf buf
}; };

View file

@ -235,9 +235,9 @@ fn test_pull() {
1.0, 1.0,
gst::SeekFlags::FLUSH, gst::SeekFlags::FLUSH,
gst::SeekType::Set, gst::SeekType::Set,
18 * gst::ClockTime::SECOND, 18.seconds(),
gst::SeekType::Set, gst::SeekType::Set,
19 * gst::ClockTime::SECOND, 19.seconds(),
)); ));
loop { loop {
@ -248,9 +248,7 @@ fn test_pull() {
let pts = buffer.pts().unwrap(); let pts = buffer.pts().unwrap();
let end_time = pts + buffer.duration().unwrap(); let end_time = pts + buffer.duration().unwrap();
assert!( assert!(end_time >= 18.seconds() && pts < 19.seconds());
end_time >= 18 * gst::ClockTime::SECOND && pts < 19 * gst::ClockTime::SECOND
);
} }
} }

View file

@ -6,6 +6,7 @@
// //
// SPDX-License-Identifier: MPL-2.0 // SPDX-License-Identifier: MPL-2.0
use gst::prelude::*;
use gst::ClockTime; use gst::ClockTime;
use pretty_assertions::assert_eq; use pretty_assertions::assert_eq;
@ -61,38 +62,38 @@ fn test_one_timed_buffer_and_eos() {
let expected: [(ClockTime, ClockTime, [u8; 2usize]); 7] = [ let expected: [(ClockTime, ClockTime, [u8; 2usize]); 7] = [
( (
ClockTime::from_nseconds(1_000_000_000), 1_000_000_000.nseconds(),
ClockTime::from_nseconds(33_333_333), 33_333_333.nseconds(),
[0x94, 0x20], [0x94, 0x20],
), /* resume_caption_loading */ ), /* resume_caption_loading */
( (
ClockTime::from_nseconds(1_033_333_333), 1_033_333_333.nseconds(),
ClockTime::from_nseconds(33_333_334), 33_333_334.nseconds(),
[0x94, 0xae], [0x94, 0xae],
), /* erase_non_displayed_memory */ ), /* erase_non_displayed_memory */
( (
ClockTime::from_nseconds(1_066_666_667), 1_066_666_667.nseconds(),
ClockTime::from_nseconds(33_333_333), 33_333_333.nseconds(),
[0x94, 0x70], [0x94, 0x70],
), /* preamble */ ), /* preamble */
( (
ClockTime::from_nseconds(1_100_000_000), 1_100_000_000.nseconds(),
ClockTime::from_nseconds(33_333_333), 33_333_333.nseconds(),
[0xc8, 0xe5], [0xc8, 0xe5],
), /* H e */ ), /* H e */
( (
ClockTime::from_nseconds(1_133_333_333), 1_133_333_333.nseconds(),
ClockTime::from_nseconds(33_333_334), 33_333_334.nseconds(),
[0xec, 0xec], [0xec, 0xec],
), /* l l */ ), /* l l */
( (
ClockTime::from_nseconds(1_166_666_667), 1_166_666_667.nseconds(),
ClockTime::from_nseconds(33_333_333), 33_333_333.nseconds(),
[0xef, 0x80], [0xef, 0x80],
), /* o, nil */ ), /* o, nil */
( (
ClockTime::from_nseconds(1_200_000_000), 1_200_000_000.nseconds(),
ClockTime::from_nseconds(33_333_333), 33_333_333.nseconds(),
[0x94, 0x2f], [0x94, 0x2f],
), /* end_of_caption */ ), /* end_of_caption */
]; ];
@ -125,7 +126,7 @@ fn test_one_timed_buffer_and_eos() {
loop { loop {
let outbuf = h.try_pull().unwrap(); let outbuf = h.try_pull().unwrap();
let data = outbuf.map_readable().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]); assert_eq!(&*data, &[0x94, 0x2c]);
break; break;
} else { } else {
@ -154,18 +155,10 @@ fn test_erase_display_memory_non_spliced() {
let _event = h.pull_event().unwrap(); let _event = h.pull_event().unwrap();
} }
let inbuf = new_timed_buffer( let inbuf = new_timed_buffer(&"Hello", 1_000_000_000.nseconds(), ClockTime::SECOND);
&"Hello",
ClockTime::from_nseconds(1_000_000_000),
ClockTime::SECOND,
);
assert_eq!(h.push(inbuf), Ok(gst::FlowSuccess::Ok)); assert_eq!(h.push(inbuf), Ok(gst::FlowSuccess::Ok));
let inbuf = new_timed_buffer( let inbuf = new_timed_buffer(&"World", 3_000_000_000.nseconds(), ClockTime::SECOND);
&"World",
ClockTime::from_nseconds(3_000_000_000),
ClockTime::SECOND,
);
assert_eq!(h.push(inbuf), Ok(gst::FlowSuccess::Ok)); assert_eq!(h.push(inbuf), Ok(gst::FlowSuccess::Ok));
let mut erase_display_buffers = 0; let mut erase_display_buffers = 0;
@ -173,7 +166,7 @@ fn test_erase_display_memory_non_spliced() {
while h.buffers_in_queue() > 0 { while h.buffers_in_queue() > 0 {
let outbuf = h.pull().unwrap(); 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(); let data = outbuf.map_readable().unwrap();
assert_eq!(&*data, &[0x94, 0x2c]); assert_eq!(&*data, &[0x94, 0x2c]);
erase_display_buffers += 1; erase_display_buffers += 1;
@ -204,16 +197,12 @@ fn test_erase_display_memory_spliced() {
let _event = h.pull_event().unwrap(); let _event = h.pull_event().unwrap();
} }
let inbuf = new_timed_buffer( let inbuf = new_timed_buffer(&"Hello", 1_000_000_000.nseconds(), ClockTime::SECOND);
&"Hello",
ClockTime::from_nseconds(1_000_000_000),
ClockTime::SECOND,
);
assert_eq!(h.push(inbuf), Ok(gst::FlowSuccess::Ok)); assert_eq!(h.push(inbuf), Ok(gst::FlowSuccess::Ok));
let inbuf = new_timed_buffer( let inbuf = new_timed_buffer(
&"World, Lorem Ipsum", &"World, Lorem Ipsum",
ClockTime::from_nseconds(2_000_000_000), 2_000_000_000.nseconds(),
ClockTime::SECOND, ClockTime::SECOND,
); );
assert_eq!(h.push(inbuf), Ok(gst::FlowSuccess::Ok)); assert_eq!(h.push(inbuf), Ok(gst::FlowSuccess::Ok));
@ -228,7 +217,7 @@ fn test_erase_display_memory_spliced() {
let pts = outbuf.pts().unwrap(); let pts = outbuf.pts().unwrap();
assert!(pts >= prev_pts); 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(); let data = outbuf.map_readable().unwrap();
assert_eq!(&*data, &[0x94, 0x2c]); assert_eq!(&*data, &[0x94, 0x2c]);
erase_display_buffers += 1; erase_display_buffers += 1;
@ -254,18 +243,10 @@ fn test_output_gaps() {
let _event = h.pull_event().unwrap(); let _event = h.pull_event().unwrap();
} }
let inbuf = new_timed_buffer( let inbuf = new_timed_buffer(&"Hello", 1_000_000_000.nseconds(), ClockTime::SECOND);
&"Hello",
ClockTime::from_nseconds(1_000_000_000),
ClockTime::SECOND,
);
assert_eq!(h.push(inbuf), Ok(gst::FlowSuccess::Ok)); assert_eq!(h.push(inbuf), Ok(gst::FlowSuccess::Ok));
let inbuf = new_timed_buffer( let inbuf = new_timed_buffer(&"World", 3_000_000_000.nseconds(), ClockTime::SECOND);
&"World",
ClockTime::from_nseconds(3_000_000_000),
ClockTime::SECOND,
);
assert_eq!(h.push(inbuf), Ok(gst::FlowSuccess::Ok)); assert_eq!(h.push(inbuf), Ok(gst::FlowSuccess::Ok));
h.push_event(gst::event::Eos::new()); h.push_event(gst::event::Eos::new());
@ -284,9 +265,7 @@ fn test_output_gaps() {
/* Hello */ /* Hello */
loop { loop {
let outbuf = h.pull().unwrap(); let outbuf = h.pull().unwrap();
if outbuf.pts().unwrap() + outbuf.duration().unwrap() if outbuf.pts().unwrap() + outbuf.duration().unwrap() >= 1_233_333_333.nseconds() {
>= ClockTime::from_nseconds(1_233_333_333)
{
break; break;
} }
@ -297,14 +276,12 @@ fn test_output_gaps() {
/* Padding */ /* Padding */
loop { loop {
let outbuf = h.pull().unwrap(); let outbuf = h.pull().unwrap();
if outbuf.pts().unwrap() + outbuf.duration().unwrap() if outbuf.pts().unwrap() + outbuf.duration().unwrap() >= 3_000_000_000.nseconds() {
>= ClockTime::from_nseconds(3_000_000_000)
{
break; break;
} }
let data = outbuf.map_readable().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() {
/* Erase display one second after Hello */ /* Erase display one second after Hello */
assert_eq!(&*data, &[0x94, 0x2C]); assert_eq!(&*data, &[0x94, 0x2C]);
} else { } else {
@ -315,9 +292,7 @@ fn test_output_gaps() {
/* World */ /* World */
loop { loop {
let outbuf = h.pull().unwrap(); let outbuf = h.pull().unwrap();
if outbuf.pts().unwrap() + outbuf.duration().unwrap() if outbuf.pts().unwrap() + outbuf.duration().unwrap() >= 3_233_333_333.nseconds() {
>= ClockTime::from_nseconds(3_233_333_333)
{
break; break;
} }
@ -345,33 +320,33 @@ fn test_one_timed_buffer_and_eos_roll_up2() {
let inbuf = new_timed_buffer(&"Hello", ClockTime::SECOND, ClockTime::SECOND); let inbuf = new_timed_buffer(&"Hello", ClockTime::SECOND, ClockTime::SECOND);
assert_eq!(h.push(inbuf), Ok(gst::FlowSuccess::Ok)); 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)); assert_eq!(h.push(inbuf), Ok(gst::FlowSuccess::Ok));
let expected: [(ClockTime, ClockTime, [u8; 2usize]); 5] = [ let expected: [(ClockTime, ClockTime, [u8; 2usize]); 5] = [
( (
ClockTime::from_nseconds(1_000_000_000), 1_000_000_000.nseconds(),
ClockTime::from_nseconds(33_333_333), 33_333_333.nseconds(),
[0x94, 0x25], [0x94, 0x25],
), /* roll_up_2 */ ), /* roll_up_2 */
( (
ClockTime::from_nseconds(1_033_333_333), 1_033_333_333.nseconds(),
ClockTime::from_nseconds(33_333_334), 33_333_334.nseconds(),
[0x94, 0x70], [0x94, 0x70],
), /* preamble */ ), /* preamble */
( (
ClockTime::from_nseconds(1_066_666_667), 1_066_666_667.nseconds(),
ClockTime::from_nseconds(33_333_333), 33_333_333.nseconds(),
[0xc8, 0xe5], [0xc8, 0xe5],
), /* H e */ ), /* H e */
( (
ClockTime::from_nseconds(1_100_000_000), 1_100_000_000.nseconds(),
ClockTime::from_nseconds(33_333_333), 33_333_333.nseconds(),
[0xec, 0xec], [0xec, 0xec],
), /* l l */ ), /* l l */
( (
ClockTime::from_nseconds(1_133_333_333), 1_133_333_333.nseconds(),
ClockTime::from_nseconds(33_333_334), 33_333_334.nseconds(),
[0xef, 0x80], [0xef, 0x80],
), /* o nil */ ), /* o nil */
]; ];
@ -399,7 +374,7 @@ fn test_one_timed_buffer_and_eos_roll_up2() {
/* Padding */ /* Padding */
loop { loop {
let outbuf = h.pull().unwrap(); 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; break;
} }
@ -408,21 +383,9 @@ fn test_one_timed_buffer_and_eos_roll_up2() {
} }
let expected: [(ClockTime, ClockTime, [u8; 2usize]); 3] = [ let expected: [(ClockTime, ClockTime, [u8; 2usize]); 3] = [
( (2_000_000_000.nseconds(), ClockTime::ZERO, [0x20, 0x57]), /* SPACE W */
ClockTime::from_nseconds(2_000_000_000), (2_000_000_000.nseconds(), ClockTime::ZERO, [0xef, 0xf2]), /* o r */
ClockTime::ZERO, (2_000_000_000.nseconds(), ClockTime::ZERO, [0xec, 0x64]), /* l d */
[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 */
]; ];
for (i, e) in expected.iter().enumerate() { for (i, e) in expected.iter().enumerate() {
@ -475,58 +438,58 @@ fn test_word_wrap_roll_up() {
let expected: [(ClockTime, ClockTime, [u8; 2usize]); 11] = [ let expected: [(ClockTime, ClockTime, [u8; 2usize]); 11] = [
( (
ClockTime::from_nseconds(1_000_000_000), 1_000_000_000.nseconds(),
ClockTime::from_nseconds(33_333_333), 33_333_333.nseconds(),
[0x94, 0x25], [0x94, 0x25],
), /* roll_up_2 */ ), /* roll_up_2 */
( (
ClockTime::from_nseconds(1_033_333_333), 1_033_333_333.nseconds(),
ClockTime::from_nseconds(33_333_334), 33_333_334.nseconds(),
[0x94, 0x7c], [0x94, 0x7c],
), /* preamble */ ), /* preamble */
( (
ClockTime::from_nseconds(1_066_666_667), 1_066_666_667.nseconds(),
ClockTime::from_nseconds(33_333_333), 33_333_333.nseconds(),
[0xc8, 0xe5], [0xc8, 0xe5],
), /* H e */ ), /* H e */
( (
ClockTime::from_nseconds(1_100_000_000), 1_100_000_000.nseconds(),
ClockTime::from_nseconds(33_333_333), 33_333_333.nseconds(),
[0xec, 0xec], [0xec, 0xec],
), /* l l */ ), /* l l */
( (
ClockTime::from_nseconds(1_133_333_333), 1_133_333_333.nseconds(),
ClockTime::from_nseconds(33_333_334), 33_333_334.nseconds(),
[0xef, 0x20], [0xef, 0x20],
), /* o SPACE */ ), /* o SPACE */
( (
ClockTime::from_nseconds(1_166_666_667), 1_166_666_667.nseconds(),
ClockTime::from_nseconds(33_333_333), 33_333_333.nseconds(),
[0x94, 0xad], [0x94, 0xad],
), /* carriage return */ ), /* carriage return */
( (
ClockTime::from_nseconds(1_200_000_000), 1_200_000_000.nseconds(),
ClockTime::from_nseconds(33_333_333), 33_333_333.nseconds(),
[0x94, 0x25], [0x94, 0x25],
), /* roll_up_2 */ ), /* roll_up_2 */
( (
ClockTime::from_nseconds(1_233_333_333), 1_233_333_333.nseconds(),
ClockTime::from_nseconds(33_333_334), 33_333_334.nseconds(),
[0x94, 0x7c], [0x94, 0x7c],
), /* preamble */ ), /* preamble */
( (
ClockTime::from_nseconds(1_266_666_667), 1_266_666_667.nseconds(),
ClockTime::from_nseconds(33_333_333), 33_333_333.nseconds(),
[0x57, 0xef], [0x57, 0xef],
), /* W o */ ), /* W o */
( (
ClockTime::from_nseconds(1_300_000_000), 1_300_000_000.nseconds(),
ClockTime::from_nseconds(33_333_333), 33_333_333.nseconds(),
[0xf2, 0xec], [0xf2, 0xec],
), /* r l */ ), /* r l */
( (
ClockTime::from_nseconds(1_333_333_333), 1_333_333_333.nseconds(),
ClockTime::from_nseconds(33_333_334), 33_333_334.nseconds(),
[0x64, 0x80], [0x64, 0x80],
), /* d nil */ ), /* d nil */
]; ];

View file

@ -344,7 +344,7 @@ impl Dav1dDec {
out_buffer out_buffer
.get_mut() .get_mut()
.unwrap() .unwrap()
.set_duration(gst::ClockTime::from_nseconds(duration)); .set_duration(duration.nseconds());
} }
Ok(out_buffer) Ok(out_buffer)
@ -614,9 +614,7 @@ impl VideoDecoderImpl for Dav1dDec {
n => n, n => n,
}; };
let latency = frame_latency let latency = frame_latency * (info.fps().denom() as u64).seconds()
* (info.fps().denom() as u64)
* gst::ClockTime::SECOND
/ (fps_n as u64); / (fps_n as u64);
gst::debug!(CAT, imp: self, "Reporting latency of {}", latency); gst::debug!(CAT, imp: self, "Reporting latency of {}", latency);

View file

@ -936,7 +936,7 @@ impl StreamingState {
{ {
let buffer = buffer.get_mut().unwrap(); 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!( gst::trace!(
@ -1130,7 +1130,7 @@ impl StreamingState {
if !is_keyframe { if !is_keyframe {
buffer.set_flags(gst::BufferFlags::DELTA_UNIT); 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 // Prevent negative numbers
let pts = if cts < 0 && tag_header.timestamp < (-cts) as u32 { let pts = if cts < 0 && tag_header.timestamp < (-cts) as u32 {
@ -1138,7 +1138,7 @@ impl StreamingState {
} else { } else {
((tag_header.timestamp as i64) + (cts as i64)) as u64 ((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!( gst::trace!(
@ -1487,9 +1487,8 @@ impl Metadata {
for arg in args { for arg in args {
match (arg.name, &arg.data) { match (arg.name, &arg.data) {
("duration", &flavors::ScriptDataValue::Number(duration)) => { ("duration", &flavors::ScriptDataValue::Number(duration)) => {
metadata.duration = Some(gst::ClockTime::from_nseconds( metadata.duration =
(duration * 1000.0 * 1000.0 * 1000.0) as u64, Some(((duration * 1000.0 * 1000.0 * 1000.0) as u64).nseconds());
));
} }
("creationdate", &flavors::ScriptDataValue::String(date)) => { ("creationdate", &flavors::ScriptDataValue::String(date)) => {
metadata.creation_date = Some(String::from(date)); metadata.creation_date = Some(String::from(date));

View file

@ -375,7 +375,7 @@ impl VideoEncoderImpl for GifEnc {
gif_frame.delay = (frame_delay.mseconds() as f32 / 10.0).round() as u16; gif_frame.delay = (frame_delay.mseconds() as f32 / 10.0).round() as u16;
state.gif_pts = state state.gif_pts = state
.gif_pts .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 // encode new frame
let context = state.context.as_mut().unwrap(); let context = state.context.as_mut().unwrap();

View file

@ -8,6 +8,8 @@
// //
// SPDX-License-Identifier: MIT OR Apache-2.0 // SPDX-License-Identifier: MIT OR Apache-2.0
use gst::prelude::*;
fn init() { fn init() {
use std::sync::Once; use std::sync::Once;
static INIT: Once = Once::new(); 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 mut buffer = gst::Buffer::with_size(video_info.size()).unwrap();
{ {
let buffer = buffer.get_mut().unwrap(); let buffer = buffer.get_mut().unwrap();
buffer.set_pts(gst::ClockTime::from_seconds(pts)); buffer.set_pts(pts.seconds());
} }
let mut vframe = let mut vframe =
gst_video::VideoFrame::from_buffer_writable(buffer, video_info).unwrap(); gst_video::VideoFrame::from_buffer_writable(buffer, video_info).unwrap();

View file

@ -8,6 +8,8 @@
// //
// SPDX-License-Identifier: MIT OR Apache-2.0 // SPDX-License-Identifier: MIT OR Apache-2.0
use gst::prelude::*;
fn init() { fn init() {
use std::sync::Once; use std::sync::Once;
static INIT: Once = Once::new(); 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 mut buffer = gst::Buffer::with_size(video_info.size()).unwrap();
{ {
let buffer = buffer.get_mut().unwrap(); let buffer = buffer.get_mut().unwrap();
buffer.set_pts(gst::ClockTime::from_seconds(pts)); buffer.set_pts(pts.seconds());
} }
let mut vframe = let mut vframe =
gst_video::VideoFrame::from_buffer_writable(buffer, video_info).unwrap(); gst_video::VideoFrame::from_buffer_writable(buffer, video_info).unwrap();

View file

@ -203,7 +203,7 @@ impl WebPDec {
gst::error_msg!(gst::StreamError::Decode, ["Failed to get next frame"]) 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 = let duration =
prev_timestamp.and_then(|prev_timestamp| timestamp.checked_sub(prev_timestamp)); prev_timestamp.and_then(|prev_timestamp| timestamp.checked_sub(prev_timestamp));

View file

@ -33,7 +33,7 @@ fn test_decode() {
let mut expected_timestamp: Option<gst::ClockTime> = Some(gst::ClockTime::ZERO); let mut expected_timestamp: Option<gst::ClockTime> = Some(gst::ClockTime::ZERO);
let mut count = 0; 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() { while let Some(buf) = h.try_pull() {
assert_eq!(buf.pts(), expected_timestamp); assert_eq!(buf.pts(), expected_timestamp);