pub struct SegmentClock { /* private fields */ }Available on crate features
hls or record only.Expand description
Tracks segment boundaries from a frame stream’s keyframes and timestamps.
use arcly_stream::segment::SegmentClock;
use arcly_stream::{CodecId, MediaFrame};
use bytes::Bytes;
let key = |pts| MediaFrame::new_video(pts, pts, Bytes::new(), CodecId::H264, true);
let mut clock = SegmentClock::new(2); // 2-second target
// First keyframe opens segment 0.
let d = clock.observe(&key(0));
assert!(d.open_new && !d.skip && d.cut_previous.is_none());
// A keyframe before the target does not cut.
assert_eq!(clock.observe(&key(1000)).cut_previous, None);
// A keyframe at/after the target cuts the previous segment.
let d = clock.observe(&key(2000));
assert_eq!(d.cut_previous, Some(2.0));
assert!(d.open_new);Implementations§
Source§impl SegmentClock
impl SegmentClock
Sourcepub fn new(target_secs: u64) -> Self
pub fn new(target_secs: u64) -> Self
A clock targeting target_secs-long segments (minimum 1 second).
Sourcepub fn observe(&mut self, frame: &MediaFrame) -> SegmentDecision
pub fn observe(&mut self, frame: &MediaFrame) -> SegmentDecision
Feed one frame and learn what to do with it (call before writing it).
Trait Implementations§
Source§impl Clone for SegmentClock
impl Clone for SegmentClock
Source§fn clone(&self) -> SegmentClock
fn clone(&self) -> SegmentClock
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for SegmentClock
impl RefUnwindSafe for SegmentClock
impl Send for SegmentClock
impl Sync for SegmentClock
impl Unpin for SegmentClock
impl UnsafeUnpin for SegmentClock
impl UnwindSafe for SegmentClock
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more