diff options
Diffstat (limited to 'generic')
-rw-r--r-- | generic/fmp4/examples/hls_live.rs | 4 | ||||
-rw-r--r-- | generic/fmp4/examples/hls_vod.rs | 4 | ||||
-rw-r--r-- | generic/fmp4/src/fmp4mux/boxes.rs | 3 | ||||
-rw-r--r-- | generic/fmp4/src/fmp4mux/imp.rs | 25 | ||||
-rw-r--r-- | generic/fmp4/tests/tests.rs | 390 | ||||
-rw-r--r-- | generic/sodium/src/decrypter/imp.rs | 2 | ||||
-rw-r--r-- | generic/sodium/src/encrypter/imp.rs | 2 | ||||
-rw-r--r-- | generic/sodium/tests/decrypter.rs | 4 | ||||
-rw-r--r-- | generic/threadshare/src/jitterbuffer/jitterbuffer.rs | 6 | ||||
-rw-r--r-- | generic/threadshare/src/proxy/imp.rs | 3 | ||||
-rw-r--r-- | generic/threadshare/src/queue/imp.rs | 3 | ||||
-rw-r--r-- | generic/threadshare/tests/proxy.rs | 2 | ||||
-rw-r--r-- | generic/threadshare/tests/queue.rs | 2 | ||||
-rw-r--r-- | generic/threadshare/tests/tcpclientsrc.rs | 2 |
14 files changed, 132 insertions, 320 deletions
diff --git a/generic/fmp4/examples/hls_live.rs b/generic/fmp4/examples/hls_live.rs index 624a317a9..f29ec157f 100644 --- a/generic/fmp4/examples/hls_live.rs +++ b/generic/fmp4/examples/hls_live.rs @@ -445,7 +445,7 @@ impl VideoStream { enc.set_property("bframes", 0u32); enc.set_property("bitrate", self.bitrate as u32 / 1000u32); enc.set_property_from_str("tune", "zerolatency"); - mux.set_property("fragment-duration", gst::ClockTime::from_mseconds(2500)); + mux.set_property("fragment-duration", 2500.mseconds()); mux.set_property_from_str("header-update-mode", "update"); mux.set_property("write-mehd", true); @@ -477,7 +477,7 @@ impl AudioStream { src.set_property("is-live", true); src.set_property_from_str("wave", &self.wave); - mux.set_property("fragment-duration", gst::ClockTime::from_mseconds(2500)); + mux.set_property("fragment-duration", 2500.mseconds()); mux.set_property_from_str("header-update-mode", "update"); mux.set_property("write-mehd", true); diff --git a/generic/fmp4/examples/hls_vod.rs b/generic/fmp4/examples/hls_vod.rs index c818d9d6f..730c5a6f7 100644 --- a/generic/fmp4/examples/hls_vod.rs +++ b/generic/fmp4/examples/hls_vod.rs @@ -339,7 +339,7 @@ impl VideoStream { src.set_property("num-buffers", 300); enc.set_property("bframes", 0u32); enc.set_property("bitrate", self.bitrate as u32 / 1000u32); - mux.set_property("fragment-duration", gst::ClockTime::from_mseconds(2500)); + mux.set_property("fragment-duration", 2500.mseconds()); mux.set_property_from_str("header-update-mode", "update"); mux.set_property("write-mehd", true); @@ -378,7 +378,7 @@ impl AudioStream { gst_audio::AudioCapsBuilder::new().rate(44100).build(), ); - mux.set_property("fragment-duration", gst::ClockTime::from_mseconds(2500)); + mux.set_property("fragment-duration", 2500.mseconds()); mux.set_property_from_str("header-update-mode", "update"); mux.set_property("write-mehd", true); diff --git a/generic/fmp4/src/fmp4mux/boxes.rs b/generic/fmp4/src/fmp4mux/boxes.rs index b82507d7e..9b69fb36f 100644 --- a/generic/fmp4/src/fmp4mux/boxes.rs +++ b/generic/fmp4/src/fmp4mux/boxes.rs @@ -459,7 +459,8 @@ fn caps_to_timescale(caps: &gst::CapsRef) -> u32 { } if fps.denom() != 1 && fps.denom() != 1001 { - if let Some(fps) = gst::ClockTime::from_nseconds(fps.denom() as u64) + if let Some(fps) = (fps.denom() as u64) + .nseconds() .mul_div_round(1_000_000_000, fps.numer() as u64) .and_then(gst_video::guess_framerate) { diff --git a/generic/fmp4/src/fmp4mux/imp.rs b/generic/fmp4/src/fmp4mux/imp.rs index 7433a1dd0..8d60bf851 100644 --- a/generic/fmp4/src/fmp4mux/imp.rs +++ b/generic/fmp4/src/fmp4mux/imp.rs @@ -45,8 +45,7 @@ fn get_utc_time_from_buffer(buffer: &gst::BufferRef) -> Option<gst::ClockTime> { if meta.reference().can_intersect(&UNIX_CAPS) { Some(meta.timestamp()) } else if meta.reference().can_intersect(&NTP_CAPS) { - meta.timestamp() - .checked_sub(gst::ClockTime::from_seconds(NTP_UNIX_OFFSET)) + meta.timestamp().checked_sub(NTP_UNIX_OFFSET.seconds()) } else { None } @@ -913,13 +912,11 @@ impl FMP4Mux { let calculate_pts = |buffer: &Buffer| -> gst::ClockTime { let composition_time_offset = buffer.composition_time_offset.unwrap_or(0); if composition_time_offset > 0 { - buffer.timestamp + gst::ClockTime::from_nseconds(composition_time_offset as u64) + buffer.timestamp + (composition_time_offset as u64).nseconds() } else { buffer .timestamp - .checked_sub(gst::ClockTime::from_nseconds( - (-composition_time_offset) as u64, - )) + .checked_sub(((-composition_time_offset) as u64).nseconds()) .unwrap() } }; @@ -957,13 +954,11 @@ impl FMP4Mux { }; let buffer_utc_time = if buffer_pts_diff >= 0 { utc_time - .checked_sub(gst::ClockTime::from_nseconds(buffer_pts_diff as u64)) + .checked_sub((buffer_pts_diff as u64).nseconds()) .unwrap() } else { utc_time - .checked_add(gst::ClockTime::from_nseconds( - (-buffer_pts_diff) as u64, - )) + .checked_add(((-buffer_pts_diff) as u64).nseconds()) .unwrap() }; @@ -1035,15 +1030,11 @@ impl FMP4Mux { if let Some(composition_time_offset) = buffer.composition_time_offset { if composition_time_offset >= 0 { utc_time - .checked_sub(gst::ClockTime::from_nseconds( - composition_time_offset as u64, - )) + .checked_sub((composition_time_offset as u64).nseconds()) .unwrap() } else { utc_time - .checked_add(gst::ClockTime::from_nseconds( - (-composition_time_offset) as u64, - )) + .checked_add(((-composition_time_offset) as u64).nseconds()) .unwrap() } } else { @@ -2122,7 +2113,7 @@ impl AggregatorImpl for FMP4Mux { gst::StreamError::Format, ["Longer GOPs than fragment duration"] ); - state.timeout_delay += gst::ClockTime::from_seconds(1); + state.timeout_delay += 1.seconds(); drop(state); for (sinkpad, event) in upstream_events { diff --git a/generic/fmp4/tests/tests.rs b/generic/fmp4/tests/tests.rs index bf44643fd..073b6ae05 100644 --- a/generic/fmp4/tests/tests.rs +++ b/generic/fmp4/tests/tests.rs @@ -28,7 +28,7 @@ fn test_buffer_flags_single_stream(cmaf: bool) { // 5s fragment duration h.element() .unwrap() - .set_property("fragment-duration", gst::ClockTime::from_seconds(5)); + .set_property("fragment-duration", 5.seconds()); h.set_src_caps( gst::Caps::builder("video/x-h264") @@ -45,7 +45,7 @@ fn test_buffer_flags_single_stream(cmaf: bool) { let output_offset = if cmaf { gst::ClockTime::ZERO } else { - gst::ClockTime::from_seconds(60 * 60 * 1000) + (60 * 60 * 1000).seconds() }; // Push 7 buffers of 1s each, 1st and 6 buffer without DELTA_UNIT flag @@ -53,8 +53,8 @@ fn test_buffer_flags_single_stream(cmaf: bool) { let mut buffer = gst::Buffer::with_size(1).unwrap(); { let buffer = buffer.get_mut().unwrap(); - buffer.set_pts(gst::ClockTime::from_seconds(i)); - buffer.set_dts(gst::ClockTime::from_seconds(i)); + buffer.set_pts(i.seconds()); + buffer.set_dts(i.seconds()); buffer.set_duration(gst::ClockTime::SECOND); if i != 0 && i != 5 { buffer.set_flags(gst::BufferFlags::DELTA_UNIT); @@ -76,7 +76,7 @@ fn test_buffer_flags_single_stream(cmaf: bool) { assert_eq!( gst_video::UpstreamForceKeyUnitEvent::parse(&ev).unwrap(), gst_video::UpstreamForceKeyUnitEvent { - running_time: Some(gst::ClockTime::from_seconds(5)), + running_time: Some(5.seconds()), all_headers: true, count: 0 } @@ -102,10 +102,7 @@ fn test_buffer_flags_single_stream(cmaf: bool) { fragment_header.dts(), Some(gst::ClockTime::ZERO + output_offset) ); - assert_eq!( - fragment_header.duration(), - Some(gst::ClockTime::from_seconds(5)) - ); + assert_eq!(fragment_header.duration(), Some(5.seconds())); for i in 0..5 { let buffer = h.pull().unwrap(); @@ -117,14 +114,8 @@ fn test_buffer_flags_single_stream(cmaf: bool) { } else { assert_eq!(buffer.flags(), gst::BufferFlags::DELTA_UNIT); } - assert_eq!( - buffer.pts(), - Some(gst::ClockTime::from_seconds(i) + output_offset) - ); - assert_eq!( - buffer.dts(), - Some(gst::ClockTime::from_seconds(i) + output_offset) - ); + assert_eq!(buffer.pts(), Some(i.seconds() + output_offset)); + assert_eq!(buffer.dts(), Some(i.seconds() + output_offset)); assert_eq!(buffer.duration(), Some(gst::ClockTime::SECOND)); } @@ -132,18 +123,9 @@ fn test_buffer_flags_single_stream(cmaf: bool) { let fragment_header = h.pull().unwrap(); assert_eq!(fragment_header.flags(), gst::BufferFlags::HEADER); - assert_eq!( - fragment_header.pts(), - Some(gst::ClockTime::from_seconds(5) + output_offset) - ); - assert_eq!( - fragment_header.dts(), - Some(gst::ClockTime::from_seconds(5) + output_offset) - ); - assert_eq!( - fragment_header.duration(), - Some(gst::ClockTime::from_seconds(2)) - ); + assert_eq!(fragment_header.pts(), Some(5.seconds() + output_offset)); + assert_eq!(fragment_header.dts(), Some(5.seconds() + output_offset)); + assert_eq!(fragment_header.duration(), Some(2.seconds())); for i in 5..7 { let buffer = h.pull().unwrap(); @@ -155,14 +137,8 @@ fn test_buffer_flags_single_stream(cmaf: bool) { } else { assert_eq!(buffer.flags(), gst::BufferFlags::DELTA_UNIT); } - assert_eq!( - buffer.pts(), - Some(gst::ClockTime::from_seconds(i) + output_offset) - ); - assert_eq!( - buffer.dts(), - Some(gst::ClockTime::from_seconds(i) + output_offset) - ); + assert_eq!(buffer.pts(), Some(i.seconds() + output_offset)); + assert_eq!(buffer.dts(), Some(i.seconds() + output_offset)); assert_eq!(buffer.duration(), Some(gst::ClockTime::SECOND)); } @@ -200,7 +176,7 @@ fn test_buffer_flags_multi_stream() { // 5s fragment duration h1.element() .unwrap() - .set_property("fragment-duration", gst::ClockTime::from_seconds(5)); + .set_property("fragment-duration", 5.seconds()); h1.set_src_caps( gst::Caps::builder("video/x-h264") @@ -231,15 +207,15 @@ fn test_buffer_flags_multi_stream() { ); h2.play(); - let output_offset = gst::ClockTime::from_seconds(60 * 60 * 1000); + let output_offset = (60 * 60 * 1000).seconds(); // Push 7 buffers of 1s each, 1st and last buffer without DELTA_UNIT flag for i in 0..7 { let mut buffer = gst::Buffer::with_size(1).unwrap(); { let buffer = buffer.get_mut().unwrap(); - buffer.set_pts(gst::ClockTime::from_seconds(i)); - buffer.set_dts(gst::ClockTime::from_seconds(i)); + buffer.set_pts(i.seconds()); + buffer.set_dts(i.seconds()); buffer.set_duration(gst::ClockTime::SECOND); if i != 0 && i != 5 { buffer.set_flags(gst::BufferFlags::DELTA_UNIT); @@ -250,8 +226,8 @@ fn test_buffer_flags_multi_stream() { let mut buffer = gst::Buffer::with_size(1).unwrap(); { let buffer = buffer.get_mut().unwrap(); - buffer.set_pts(gst::ClockTime::from_seconds(i)); - buffer.set_dts(gst::ClockTime::from_seconds(i)); + buffer.set_pts(i.seconds()); + buffer.set_dts(i.seconds()); buffer.set_duration(gst::ClockTime::SECOND); } assert_eq!(h2.push(buffer), Ok(gst::FlowSuccess::Ok)); @@ -270,7 +246,7 @@ fn test_buffer_flags_multi_stream() { assert_eq!( gst_video::UpstreamForceKeyUnitEvent::parse(&ev).unwrap(), gst_video::UpstreamForceKeyUnitEvent { - running_time: Some(gst::ClockTime::from_seconds(5)), + running_time: Some(5.seconds()), all_headers: true, count: 0 } @@ -289,7 +265,7 @@ fn test_buffer_flags_multi_stream() { assert_eq!( gst_video::UpstreamForceKeyUnitEvent::parse(&ev).unwrap(), gst_video::UpstreamForceKeyUnitEvent { - running_time: Some(gst::ClockTime::from_seconds(5)), + running_time: Some(5.seconds()), all_headers: true, count: 0 } @@ -315,10 +291,7 @@ fn test_buffer_flags_multi_stream() { fragment_header.dts(), Some(gst::ClockTime::ZERO + output_offset) ); - assert_eq!( - fragment_header.duration(), - Some(gst::ClockTime::from_seconds(5)) - ); + assert_eq!(fragment_header.duration(), Some(5.seconds())); for i in 0..5 { for j in 0..2 { @@ -332,16 +305,10 @@ fn test_buffer_flags_multi_stream() { assert_eq!(buffer.flags(), gst::BufferFlags::DELTA_UNIT); } - assert_eq!( - buffer.pts(), - Some(gst::ClockTime::from_seconds(i) + output_offset) - ); + assert_eq!(buffer.pts(), Some(i.seconds() + output_offset)); if j == 0 { - assert_eq!( - buffer.dts(), - Some(gst::ClockTime::from_seconds(i) + output_offset) - ); + assert_eq!(buffer.dts(), Some(i.seconds() + output_offset)); } else { assert!(buffer.dts().is_none()); } @@ -354,18 +321,9 @@ fn test_buffer_flags_multi_stream() { let fragment_header = h1.pull().unwrap(); assert_eq!(fragment_header.flags(), gst::BufferFlags::HEADER); - assert_eq!( - fragment_header.pts(), - Some(gst::ClockTime::from_seconds(5) + output_offset) - ); - assert_eq!( - fragment_header.dts(), - Some(gst::ClockTime::from_seconds(5) + output_offset) - ); - assert_eq!( - fragment_header.duration(), - Some(gst::ClockTime::from_seconds(2)) - ); + assert_eq!(fragment_header.pts(), Some(5.seconds() + output_offset)); + assert_eq!(fragment_header.dts(), Some(5.seconds() + output_offset)); + assert_eq!(fragment_header.duration(), Some(2.seconds())); for i in 5..7 { for j in 0..2 { @@ -378,15 +336,9 @@ fn test_buffer_flags_multi_stream() { } else { assert_eq!(buffer.flags(), gst::BufferFlags::DELTA_UNIT); } - assert_eq!( - buffer.pts(), - Some(gst::ClockTime::from_seconds(i) + output_offset) - ); + assert_eq!(buffer.pts(), Some(i.seconds() + output_offset)); if j == 0 { - assert_eq!( - buffer.dts(), - Some(gst::ClockTime::from_seconds(i) + output_offset) - ); + assert_eq!(buffer.dts(), Some(i.seconds() + output_offset)); } else { assert!(buffer.dts().is_none()); } @@ -416,7 +368,7 @@ fn test_live_timeout() { // 5s fragment duration h1.element() .unwrap() - .set_property("fragment-duration", gst::ClockTime::from_seconds(5)); + .set_property("fragment-duration", 5.seconds()); h1.set_src_caps( gst::Caps::builder("video/x-h264") @@ -447,15 +399,15 @@ fn test_live_timeout() { ); h2.play(); - let output_offset = gst::ClockTime::from_seconds(60 * 60 * 1000); + let output_offset = (60 * 60 * 1000).seconds(); // Push 7 buffers of 1s each, 1st and last buffer without DELTA_UNIT flag for i in 0..7 { let mut buffer = gst::Buffer::with_size(1).unwrap(); { let buffer = buffer.get_mut().unwrap(); - buffer.set_pts(gst::ClockTime::from_seconds(i)); - buffer.set_dts(gst::ClockTime::from_seconds(i)); + buffer.set_pts(i.seconds()); + buffer.set_dts(i.seconds()); buffer.set_duration(gst::ClockTime::SECOND); if i != 0 && i != 5 { buffer.set_flags(gst::BufferFlags::DELTA_UNIT); @@ -470,8 +422,8 @@ fn test_live_timeout() { let mut buffer = gst::Buffer::with_size(1).unwrap(); { let buffer = buffer.get_mut().unwrap(); - buffer.set_pts(gst::ClockTime::from_seconds(i)); - buffer.set_dts(gst::ClockTime::from_seconds(i)); + buffer.set_pts(i.seconds()); + buffer.set_dts(i.seconds()); buffer.set_duration(gst::ClockTime::SECOND); } assert_eq!(h2.push(buffer), Ok(gst::FlowSuccess::Ok)); @@ -491,7 +443,7 @@ fn test_live_timeout() { assert_eq!( gst_video::UpstreamForceKeyUnitEvent::parse(&ev).unwrap(), gst_video::UpstreamForceKeyUnitEvent { - running_time: Some(gst::ClockTime::from_seconds(5)), + running_time: Some(5.seconds()), all_headers: true, count: 0 } @@ -510,7 +462,7 @@ fn test_live_timeout() { assert_eq!( gst_video::UpstreamForceKeyUnitEvent::parse(&ev).unwrap(), gst_video::UpstreamForceKeyUnitEvent { - running_time: Some(gst::ClockTime::from_seconds(5)), + running_time: Some(5.seconds()), all_headers: true, count: 0 } @@ -519,7 +471,7 @@ fn test_live_timeout() { } // Advance time and crank the clock: this should bring us to the end of the first fragment - h1.set_time(gst::ClockTime::from_seconds(5)).unwrap(); + h1.set_time(5.seconds()).unwrap(); h1.crank_single_clock_wait().unwrap(); let header = h1.pull().unwrap(); @@ -540,10 +492,7 @@ fn test_live_timeout() { fragment_header.dts(), Some(gst::ClockTime::ZERO + output_offset) ); - assert_eq!( - fragment_header.duration(), - Some(gst::ClockTime::from_seconds(5)) - ); + assert_eq!(fragment_header.duration(), Some(5.seconds())); for i in 0..5 { for j in 0..2 { @@ -567,16 +516,10 @@ fn test_live_timeout() { assert_eq!(buffer.flags(), gst::BufferFlags::DELTA_UNIT); } - assert_eq!( - buffer.pts(), - Some(gst::ClockTime::from_seconds(i) + output_offset) - ); + assert_eq!(buffer.pts(), Some(i.seconds() + output_offset)); if j == 0 { - assert_eq!( - buffer.dts(), - Some(gst::ClockTime::from_seconds(i) + output_offset) - ); + assert_eq!(buffer.dts(), Some(i.seconds() + output_offset)); } else { assert!(buffer.dts().is_none()); } @@ -589,18 +532,9 @@ fn test_live_timeout() { let fragment_header = h1.pull().unwrap(); assert_eq!(fragment_header.flags(), gst::BufferFlags::HEADER); - assert_eq!( - fragment_header.pts(), - Some(gst::ClockTime::from_seconds(5) + output_offset) - ); - assert_eq!( - fragment_header.dts(), - Some(gst::ClockTime::from_seconds(5) + output_offset) - ); - assert_eq!( - fragment_header.duration(), - Some(gst::ClockTime::from_seconds(2)) - ); + assert_eq!(fragment_header.pts(), Some(5.seconds() + output_offset)); + assert_eq!(fragment_header.dts(), Some(5.seconds() + output_offset)); + assert_eq!(fragment_header.duration(), Some(2.seconds())); for i in 5..7 { for j in 0..2 { @@ -618,15 +552,9 @@ fn test_live_timeout() { } else { assert_eq!(buffer.flags(), gst::BufferFlags::DELTA_UNIT); } - assert_eq!( - buffer.pts(), - Some(gst::ClockTime::from_seconds(i) + output_offset) - ); + assert_eq!(buffer.pts(), Some(i.seconds() + output_offset)); if j == 0 { - assert_eq!( - buffer.dts(), - Some(gst::ClockTime::from_seconds(i) + output_offset) - ); + assert_eq!(buffer.dts(), Some(i.seconds() + output_offset)); } else { assert!(buffer.dts().is_none()); } @@ -656,7 +584,7 @@ fn test_gap_events() { // 5s fragment duration h1.element() .unwrap() - .set_property("fragment-duration", gst::ClockTime::from_seconds(5)); + .set_property("fragment-duration", 5.seconds()); h1.set_src_caps( gst::Caps::builder("video/x-h264") @@ -687,15 +615,15 @@ fn test_gap_events() { ); h2.play(); - let output_offset = gst::ClockTime::from_seconds(60 * 60 * 1000); + let output_offset = (60 * 60 * 1000).seconds(); // Push 7 buffers of 1s each, 1st and last buffer without DELTA_UNIT flag for i in 0..7 { let mut buffer = gst::Buffer::with_size(1).unwrap(); { let buffer = buffer.get_mut().unwrap(); - buffer.set_pts(gst::ClockTime::from_seconds(i)); - buffer.set_dts(gst::ClockTime::from_seconds(i)); + buffer.set_pts(i.seconds()); + buffer.set_dts(i.seconds()); buffer.set_duration(gst::ClockTime::SECOND); if i != 0 && i != 5 { buffer.set_flags(gst::BufferFlags::DELTA_UNIT); @@ -705,7 +633,7 @@ fn test_gap_events() { // Replace buffer 3 and 6 with a gap event if i == 3 || i == 6 { - let ev = gst::event::Gap::builder(gst::ClockTime::from_seconds(i)) + let ev = gst::event::Gap::builder(i.seconds()) .duration(gst::ClockTime::SECOND) .build(); assert!(h2.push_event(ev)); @@ -713,8 +641,8 @@ fn test_gap_events() { let mut buffer = gst::Buffer::with_size(1).unwrap(); { let buffer = buffer.get_mut().unwrap(); - buffer.set_pts(gst::ClockTime::from_seconds(i)); - buffer.set_dts(gst::ClockTime::from_seconds(i)); + buffer.set_pts(i.seconds()); + buffer.set_dts(i.seconds()); buffer.set_duration(gst::ClockTime::SECOND); } assert_eq!(h2.push(buffer), Ok(gst::FlowSuccess::Ok)); @@ -734,7 +662,7 @@ fn test_gap_events() { assert_eq!( gst_video::UpstreamForceKeyUnitEvent::parse(&ev).unwrap(), gst_video::UpstreamForceKeyUnitEvent { - running_time: Some(gst::ClockTime::from_seconds(5)), + running_time: Some(5.seconds()), all_headers: true, count: 0 } @@ -753,7 +681,7 @@ fn test_gap_events() { assert_eq!( gst_video::UpstreamForceKeyUnitEvent::parse(&ev).unwrap(), gst_video::UpstreamForceKeyUnitEvent { - running_time: Some(gst::ClockTime::from_seconds(5)), + running_time: Some(5.seconds()), all_headers: true, count: 0 } @@ -762,7 +690,7 @@ fn test_gap_events() { } // Advance time and crank the clock: this should bring us to the end of the first fragment - h1.set_time(gst::ClockTime::from_seconds(5)).unwrap(); + h1.set_time(5.seconds()).unwrap(); h1.crank_single_clock_wait().unwrap(); let header = h1.pull().unwrap(); @@ -783,10 +711,7 @@ fn test_gap_events() { fragment_header.dts(), Some(gst::ClockTime::ZERO + output_offset) ); - assert_eq!( - fragment_header.duration(), - Some(gst::ClockTime::from_seconds(5)) - ); + assert_eq!(fragment_header.duration(), Some(5.seconds())); for i in 0..5 { for j in 0..2 { @@ -805,16 +730,10 @@ fn test_gap_events() { assert_eq!(buffer.flags(), gst::BufferFlags::DELTA_UNIT); } - assert_eq!( - buffer.pts(), - Some(gst::ClockTime::from_seconds(i) + output_offset) - ); + assert_eq!(buffer.pts(), Some(i.seconds() + output_offset)); if j == 0 { - assert_eq!( - buffer.dts(), - Some(gst::ClockTime::from_seconds(i) + output_offset) - ); + assert_eq!(buffer.dts(), Some(i.seconds() + output_offset)); } else { assert!(buffer.dts().is_none()); } @@ -827,18 +746,9 @@ fn test_gap_events() { let fragment_header = h1.pull().unwrap(); assert_eq!(fragment_header.flags(), gst::BufferFlags::HEADER); - assert_eq!( - fragment_header.pts(), - Some(gst::ClockTime::from_seconds(5) + output_offset) - ); - assert_eq!( - fragment_header.dts(), - Some(gst::ClockTime::from_seconds(5) + output_offset) - ); - assert_eq!( - fragment_header.duration(), - Some(gst::ClockTime::from_seconds(2)) - ); + assert_eq!(fragment_header.pts(), Some(5.seconds() + output_offset)); + assert_eq!(fragment_header.dts(), Some(5.seconds() + output_offset)); + assert_eq!(fragment_header.duration(), Some(2.seconds())); for i in 5..7 { for j in 0..2 { @@ -856,15 +766,9 @@ fn test_gap_events() { } else { assert_eq!(buffer.flags(), gst::BufferFlags::DELTA_UNIT); } - assert_eq!( - buffer.pts(), - Some(gst::ClockTime::from_seconds(i) + output_offset) - ); + assert_eq!(buffer.pts(), Some(i.seconds() + output_offset)); if j == 0 { - assert_eq!( - buffer.dts(), - Some(gst::ClockTime::from_seconds(i) + output_offset) - ); + assert_eq!(buffer.dts(), Some(i.seconds() + output_offset)); } else { assert!(buffer.dts().is_none()); } @@ -891,7 +795,7 @@ fn test_single_stream_short_gops() { // 5s fragment duration h.element() .unwrap() - .set_property("fragment-duration", gst::ClockTime::from_seconds(5)); + .set_property("fragment-duration", 5.seconds()); h.set_src_caps( gst::Caps::builder("video/x-h264") @@ -905,15 +809,15 @@ fn test_single_stream_short_gops() { ); h.play(); - let output_offset = gst::ClockTime::from_seconds(60 * 60 * 1000); + let output_offset = (60 * 60 * 1000).seconds(); // Push 8 buffers of 1s each, 1st, 4th and 7th buffer without DELTA_UNIT flag for i in 0..8 { let mut buffer = gst::Buffer::with_size(1).unwrap(); { let buffer = buffer.get_mut().unwrap(); - buffer.set_pts(gst::ClockTime::from_seconds(i)); - buffer.set_dts(gst::ClockTime::from_seconds(i)); + buffer.set_pts(i.seconds()); + buffer.set_dts(i.seconds()); buffer.set_duration(gst::ClockTime::SECOND); if i != 0 && i != 3 && i != 6 { buffer.set_flags(gst::BufferFlags::DELTA_UNIT); @@ -931,11 +835,7 @@ fn test_single_stream_short_gops() { } }; - let fku_time = if i == 2 { - gst::ClockTime::from_seconds(5) - } else { - gst::ClockTime::from_seconds(8) - }; + let fku_time = if i == 2 { 5.seconds() } else { 8.seconds() }; assert_eq!(ev.type_(), gst::EventType::CustomUpstream); assert_eq!( @@ -967,10 +867,7 @@ fn test_single_stream_short_gops() { fragment_header.dts(), Some(gst::ClockTime::ZERO + output_offset) ); - assert_eq!( - fragment_header.duration(), - Some(gst::ClockTime::from_seconds(3)) - ); + assert_eq!(fragment_header.duration(), Some(3.seconds())); for i in 0..3 { let buffer = h.pull().unwrap(); @@ -982,14 +879,8 @@ fn test_single_stream_short_gops() { } else { assert_eq!(buffer.flags(), gst::BufferFlags::DELTA_UNIT); } - assert_eq!( - buffer.pts(), - Some(gst::ClockTime::from_seconds(i) + output_offset) - ); - assert_eq!( - buffer.dts(), - Some(gst::ClockTime::from_seconds(i) + output_offset) - ); + assert_eq!(buffer.pts(), Some(i.seconds() + output_offset)); + assert_eq!(buffer.dts(), Some(i.seconds() + output_offset)); assert_eq!(buffer.duration(), Some(gst::ClockTime::SECOND)); } @@ -997,18 +888,9 @@ fn test_single_stream_short_gops() { let fragment_header = h.pull().unwrap(); assert_eq!(fragment_header.flags(), gst::BufferFlags::HEADER); - assert_eq!( - fragment_header.pts(), - Some(gst::ClockTime::from_seconds(3) + output_offset) - ); - assert_eq!( - fragment_header.dts(), - Some(gst::ClockTime::from_seconds(3) + output_offset) - ); - assert_eq!( - fragment_header.duration(), - Some(gst::ClockTime::from_seconds(5)) - ); + assert_eq!(fragment_header.pts(), Some(3.seconds() + output_offset)); + assert_eq!(fragment_header.dts(), Some(3.seconds() + output_offset)); + assert_eq!(fragment_header.duration(), Some(5.seconds())); for i in 3..8 { let buffer = h.pull().unwrap(); @@ -1020,14 +902,8 @@ fn test_single_stream_short_gops() { } else { assert_eq!(buffer.flags(), gst::BufferFlags::DELTA_UNIT); } - assert_eq!( - buffer.pts(), - Some(gst::ClockTime::from_seconds(i) + output_offset) - ); - assert_eq!( - buffer.dts(), - Some(gst::ClockTime::from_seconds(i) + output_offset) - ); + assert_eq!(buffer.pts(), Some(i.seconds() + output_offset)); + assert_eq!(buffer.dts(), Some(i.seconds() + output_offset)); assert_eq!(buffer.duration(), Some(gst::ClockTime::SECOND)); } @@ -1050,7 +926,7 @@ fn test_single_stream_long_gops() { // 5s fragment duration h.element() .unwrap() - .set_property("fragment-duration", gst::ClockTime::from_seconds(5)); + .set_property("fragment-duration", 5.seconds()); h.set_src_caps( gst::Caps::builder("video/x-h264") @@ -1064,15 +940,15 @@ fn test_single_stream_long_gops() { ); h.play(); - let output_offset = gst::ClockTime::from_seconds(60 * 60 * 1000); + let output_offset = (60 * 60 * 1000).seconds(); // Push 10 buffers of 1s each, 1st and 7th buffer without DELTA_UNIT flag for i in 0..10 { let mut buffer = gst::Buffer::with_size(1).unwrap(); { let buffer = buffer.get_mut().unwrap(); - buffer.set_pts(gst::ClockTime::from_seconds(i)); - buffer.set_dts(gst::ClockTime::from_seconds(i)); + buffer.set_pts(i.seconds()); + buffer.set_dts(i.seconds()); buffer.set_duration(gst::ClockTime::SECOND); if i != 0 && i != 6 { buffer.set_flags(gst::BufferFlags::DELTA_UNIT); @@ -1090,11 +966,7 @@ fn test_single_stream_long_gops() { } }; - let fku_time = if i == 2 { - gst::ClockTime::from_seconds(5) - } else { - gst::ClockTime::from_seconds(11) - }; + let fku_time = if i == 2 { 5.seconds() } else { 11.seconds() }; assert_eq!(ev.type_(), gst::EventType::CustomUpstream); assert_eq!( @@ -1126,10 +998,7 @@ fn test_single_stream_long_gops() { fragment_header.dts(), Some(gst::ClockTime::ZERO + output_offset) ); - assert_eq!( - fragment_header.duration(), - Some(gst::ClockTime::from_seconds(6)) - ); + assert_eq!(fragment_header.duration(), Some(6.seconds())); for i in 0..6 { let buffer = h.pull().unwrap(); @@ -1141,14 +1010,8 @@ fn test_single_stream_long_gops() { } else { assert_eq!(buffer.flags(), gst::BufferFlags::DELTA_UNIT); } - assert_eq!( - buffer.pts(), - Some(gst::ClockTime::from_seconds(i) + output_offset) - ); - assert_eq!( - buffer.dts(), - Some(gst::ClockTime::from_seconds(i) + output_offset) - ); + assert_eq!(buffer.pts(), Some(i.seconds() + output_offset)); + assert_eq!(buffer.dts(), Some(i.seconds() + output_offset)); assert_eq!(buffer.duration(), Some(gst::ClockTime::SECOND)); } @@ -1156,18 +1019,9 @@ fn test_single_stream_long_gops() { let fragment_header = h.pull().unwrap(); assert_eq!(fragment_header.flags(), gst::BufferFlags::HEADER); - assert_eq!( - fragment_header.pts(), - Some(gst::ClockTime::from_seconds(6) + output_offset) - ); - assert_eq!( - fragment_header.dts(), - Some(gst::ClockTime::from_seconds(6) + output_offset) - ); - assert_eq!( - fragment_header.duration(), - Some(gst::ClockTime::from_seconds(4)) - ); + assert_eq!(fragment_header.pts(), Some(6.seconds() + output_offset)); + assert_eq!(fragment_header.dts(), Some(6.seconds() + output_offset)); + assert_eq!(fragment_header.duration(), Some(4.seconds())); for i in 6..10 { let buffer = h.pull().unwrap(); @@ -1179,14 +1033,8 @@ fn test_single_stream_long_gops() { } else { assert_eq!(buffer.flags(), gst::BufferFlags::DELTA_UNIT); } - assert_eq!( - buffer.pts(), - Some(gst::ClockTime::from_seconds(i) + output_offset) - ); - assert_eq!( - buffer.dts(), - Some(gst::ClockTime::from_seconds(i) + output_offset) - ); + assert_eq!(buffer.pts(), Some(i.seconds() + output_offset)); + assert_eq!(buffer.dts(), Some(i.seconds() + output_offset)); assert_eq!(buffer.duration(), Some(gst::ClockTime::SECOND)); } @@ -1210,7 +1058,7 @@ fn test_buffer_multi_stream_short_gops() { // 5s fragment duration h1.element() .unwrap() - .set_property("fragment-duration", gst::ClockTime::from_seconds(5)); + .set_property("fragment-duration", 5.seconds()); h1.set_src_caps( gst::Caps::builder("video/x-h264") @@ -1241,15 +1089,15 @@ fn test_buffer_multi_stream_short_gops() { ); h2.play(); - let output_offset = gst::ClockTime::from_seconds(60 * 60 * 1000); + let output_offset = (60 * 60 * 1000).seconds(); // Push 8 buffers of 1s each, 1st, 4th and 7th buffer without DELTA_UNIT flag for i in 0..8 { let mut buffer = gst::Buffer::with_size(1).unwrap(); { let buffer = buffer.get_mut().unwrap(); - buffer.set_pts(gst::ClockTime::from_seconds(i)); - buffer.set_dts(gst::ClockTime::from_seconds(i)); + buffer.set_pts(i.seconds()); + buffer.set_dts(i.seconds()); buffer.set_duration(gst::ClockTime::SECOND); if i != 0 && i != 3 && i != 6 { buffer.set_flags(gst::BufferFlags::DELTA_UNIT); @@ -1260,8 +1108,8 @@ fn test_buffer_multi_stream_short_gops() { let mut buffer = gst::Buffer::with_size(1).unwrap(); { let buffer = buffer.get_mut().unwrap(); - buffer.set_pts(gst::ClockTime::from_seconds(i)); - buffer.set_dts(gst::ClockTime::from_seconds(i)); + buffer.set_pts(i.seconds()); + buffer.set_dts(i.seconds()); buffer.set_duration(gst::ClockTime::SECOND); } assert_eq!(h2.push(buffer), Ok(gst::FlowSuccess::Ok)); @@ -1276,11 +1124,7 @@ fn test_buffer_multi_stream_short_gops() { } }; - let fku_time = if i == 2 { - gst::ClockTime::from_seconds(5) - } else { - gst::ClockTime::from_seconds(8) - }; + let fku_time = if i == 2 { 5.seconds() } else { 8.seconds() }; assert_eq!(ev.type_(), gst::EventType::CustomUpstream); assert_eq!( @@ -1331,10 +1175,7 @@ fn test_buffer_multi_stream_short_gops() { fragment_header.dts(), Some(gst::ClockTime::ZERO + output_offset) ); - assert_eq!( - fragment_header.duration(), - Some(gst::ClockTime::from_seconds(3)) - ); + assert_eq!(fragment_header.duration(), Some(3.seconds())); for i in 0..3 { for j in 0..2 { @@ -1348,16 +1189,10 @@ fn test_buffer_multi_stream_short_gops() { assert_eq!(buffer.flags(), gst::BufferFlags::DELTA_UNIT); } - assert_eq!( - buffer.pts(), - Some(gst::ClockTime::from_seconds(i) + output_offset) - ); + assert_eq!(buffer.pts(), Some(i.seconds() + output_offset)); if j == 0 { - assert_eq!( - buffer.dts(), - Some(gst::ClockTime::from_seconds(i) + output_offset) - ); + assert_eq!(buffer.dts(), Some(i.seconds() + output_offset)); } else { assert!(buffer.dts().is_none()); } @@ -1370,18 +1205,9 @@ fn test_buffer_multi_stream_short_gops() { let fragment_header = h1.pull().unwrap(); assert_eq!(fragment_header.flags(), gst::BufferFlags::HEADER); - assert_eq!( - fragment_header.pts(), - Some(gst::ClockTime::from_seconds(3) + output_offset) - ); - assert_eq!( - fragment_header.dts(), - Some(gst::ClockTime::from_seconds(3) + output_offset) - ); - assert_eq!( - fragment_header.duration(), - Some(gst::ClockTime::from_seconds(5)) - ); + assert_eq!(fragment_header.pts(), Some(3.seconds() + output_offset)); + assert_eq!(fragment_header.dts(), Some(3.seconds() + output_offset)); + assert_eq!(fragment_header.duration(), Some(5.seconds())); for i in 3..8 { for j in 0..2 { @@ -1394,15 +1220,9 @@ fn test_buffer_multi_stream_short_gops() { } else { assert_eq!(buffer.flags(), gst::BufferFlags::DELTA_UNIT); } - assert_eq!( - buffer.pts(), - Some(gst::ClockTime::from_seconds(i) + output_offset) - ); + assert_eq!(buffer.pts(), Some(i.seconds() + output_offset)); if j == 0 { - assert_eq!( - buffer.dts(), - Some(gst::ClockTime::from_seconds(i) + output_offset) - ); + assert_eq!(buffer.dts(), Some(i.seconds() + output_offset)); } else { assert!(buffer.dts().is_none()); } diff --git a/generic/sodium/src/decrypter/imp.rs b/generic/sodium/src/decrypter/imp.rs index f51efd1ee..ce9d638e5 100644 --- a/generic/sodium/src/decrypter/imp.rs +++ b/generic/sodium/src/decrypter/imp.rs @@ -337,7 +337,7 @@ impl Decrypter { let size = size - total_chunks * box_::MACBYTES as u64; gst::debug!(CAT, obj: pad, "Setting duration bytes: {}", size); - q.set(gst::format::Bytes::from_u64(size)); + q.set(size.bytes()); true } diff --git a/generic/sodium/src/encrypter/imp.rs b/generic/sodium/src/encrypter/imp.rs index ba511f712..fd121c2e6 100644 --- a/generic/sodium/src/encrypter/imp.rs +++ b/generic/sodium/src/encrypter/imp.rs @@ -314,7 +314,7 @@ impl Encrypter { let size = size + crate::HEADERS_SIZE as u64; gst::debug!(CAT, obj: pad, "Setting duration bytes: {}", size); - q.set(gst::format::Bytes::from_u64(size)); + q.set(size.bytes()); true } diff --git a/generic/sodium/tests/decrypter.rs b/generic/sodium/tests/decrypter.rs index 2005ade09..3243ffea7 100644 --- a/generic/sodium/tests/decrypter.rs +++ b/generic/sodium/tests/decrypter.rs @@ -190,8 +190,8 @@ fn test_pull_range() { // get the seeking capabilities let (seekable, start, stop) = q.result(); assert!(seekable); - assert_eq!(start, gst::format::Bytes::ZERO.into()); - assert_eq!(stop, gst::format::Bytes::from_u64(6043).into()); + assert_eq!(start, 0.bytes().into()); + assert_eq!(stop, 6043.bytes().into()); // do pulls let expected_array_1 = [ diff --git a/generic/threadshare/src/jitterbuffer/jitterbuffer.rs b/generic/threadshare/src/jitterbuffer/jitterbuffer.rs index 971501626..e9df2a2f0 100644 --- a/generic/threadshare/src/jitterbuffer/jitterbuffer.rs +++ b/generic/threadshare/src/jitterbuffer/jitterbuffer.rs @@ -19,6 +19,8 @@ use super::ffi; +use gst::prelude::*; + use std::ptr; use glib::translate::*; @@ -117,7 +119,7 @@ impl RTPJitterBufferItem { if item.as_ref().dts == gst::ffi::GST_CLOCK_TIME_NONE { None } else { - Some(gst::ClockTime::from_nseconds(item.as_ref().dts)) + Some(item.as_ref().dts.nseconds()) } } } @@ -128,7 +130,7 @@ impl RTPJitterBufferItem { if item.as_ref().pts == gst::ffi::GST_CLOCK_TIME_NONE { None } else { - Some(gst::ClockTime::from_nseconds(item.as_ref().pts)) + Some(item.as_ref().pts.nseconds()) } } } diff --git a/generic/threadshare/src/proxy/imp.rs b/generic/threadshare/src/proxy/imp.rs index 9cad80789..862e0730a 100644 --- a/generic/threadshare/src/proxy/imp.rs +++ b/generic/threadshare/src/proxy/imp.rs @@ -1111,8 +1111,7 @@ impl ObjectImpl for ProxySrc { settings.max_size_bytes = value.get().expect("type checked upstream"); } "max-size-time" => { - settings.max_size_time = - gst::ClockTime::from_nseconds(value.get().expect("type checked upstream")); + settings.max_size_time = value.get::<u64>().unwrap().nseconds(); } "context" => { settings.context = value diff --git a/generic/threadshare/src/queue/imp.rs b/generic/threadshare/src/queue/imp.rs index 32f6f4721..93ba22e1c 100644 --- a/generic/threadshare/src/queue/imp.rs +++ b/generic/threadshare/src/queue/imp.rs @@ -697,8 +697,7 @@ impl ObjectImpl for Queue { settings.max_size_bytes = value.get().expect("type checked upstream"); } "max-size-time" => { - settings.max_size_time = - gst::ClockTime::from_nseconds(value.get().expect("type checked upstream")); + settings.max_size_time = value.get::<u64>().unwrap().nseconds(); } "context" => { settings.context = value diff --git a/generic/threadshare/tests/proxy.rs b/generic/threadshare/tests/proxy.rs index 5097ccb0d..198889193 100644 --- a/generic/threadshare/tests/proxy.rs +++ b/generic/threadshare/tests/proxy.rs @@ -74,7 +74,7 @@ fn test_push() { let mut eos = false; let bus = pipeline.bus().unwrap(); - while let Some(msg) = bus.timed_pop(5 * gst::ClockTime::SECOND) { + while let Some(msg) = bus.timed_pop(5.seconds()) { use gst::MessageView; match msg.view() { MessageView::Eos(..) => { diff --git a/generic/threadshare/tests/queue.rs b/generic/threadshare/tests/queue.rs index 49c7c3bd6..003412ed0 100644 --- a/generic/threadshare/tests/queue.rs +++ b/generic/threadshare/tests/queue.rs @@ -68,7 +68,7 @@ fn test_push() { let mut eos = false; let bus = pipeline.bus().unwrap(); - while let Some(msg) = bus.timed_pop(5 * gst::ClockTime::SECOND) { + while let Some(msg) = bus.timed_pop(5.seconds()) { use gst::MessageView; match msg.view() { MessageView::Eos(..) => { diff --git a/generic/threadshare/tests/tcpclientsrc.rs b/generic/threadshare/tests/tcpclientsrc.rs index d76004d3b..a0d3766e7 100644 --- a/generic/threadshare/tests/tcpclientsrc.rs +++ b/generic/threadshare/tests/tcpclientsrc.rs @@ -92,7 +92,7 @@ fn test_push() { let mut eos = false; let bus = pipeline.bus().unwrap(); - while let Some(msg) = bus.timed_pop(5 * gst::ClockTime::SECOND) { + while let Some(msg) = bus.timed_pop(5.seconds()) { use gst::MessageView; match msg.view() { MessageView::Eos(..) => { |