pub struct MediaDuration(pub u64);Expand description
A duration in 90 kHz ticks.
Tuple Fields§
§0: u64Implementations§
Source§impl MediaDuration
impl MediaDuration
Sourcepub fn as_seconds_f64(self) -> f64
pub fn as_seconds_f64(self) -> f64
The duration in seconds.
Examples found in repository?
examples/scte35_to_hls.rs (line 41)
14fn main() {
15 // Real Unified Streaming splice: ID 2002, out-of-network, break_duration 24 s.
16 let hex = "FC302100000000000000FFF01005000007D27FEF7F7E0020F580C0000000000088B9661D";
17 let raw: Vec<u8> = (0..hex.len())
18 .step_by(2)
19 .map(|i| u8::from_str_radix(&hex[i..i + 2], 16).unwrap())
20 .collect();
21
22 // Wall-clock anchor: assume PTS 0 == 2024-01-15T12:00:00.000Z (ms since epoch).
23 let utc_epoch_ms: i64 = 1_705_320_000_000; // 2024-01-15 12:00:00 UTC
24 let anchor = TimeAnchor {
25 pts_90k: 0,
26 utc_epoch_ms,
27 };
28
29 let mut timeline = Timeline::with_anchor(anchor);
30
31 // Parse the SCTE-35 section and unroll PTS wrap.
32 let event = timeline.push_scte35(&raw).expect("valid splice");
33
34 // Convert to a DATERANGE.
35 let daterange = timeline.to_daterange(&event).expect("anchor is set");
36
37 println!("Event kind : {}", event.kind);
38 println!("Event id : {:?}", event.id);
39 println!(
40 "Duration : {:?}s",
41 event.duration.map(|d| d.as_seconds_f64())
42 );
43 println!();
44 println!("{}", daterange.to_tag_line());
45}Trait Implementations§
Source§impl Clone for MediaDuration
impl Clone for MediaDuration
Source§fn clone(&self) -> MediaDuration
fn clone(&self) -> MediaDuration
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 moreimpl Copy for MediaDuration
Source§impl Debug for MediaDuration
impl Debug for MediaDuration
Source§impl<'de> Deserialize<'de> for MediaDuration
impl<'de> Deserialize<'de> for MediaDuration
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for MediaDuration
Source§impl PartialEq for MediaDuration
impl PartialEq for MediaDuration
Source§fn eq(&self, other: &MediaDuration) -> bool
fn eq(&self, other: &MediaDuration) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl Serialize for MediaDuration
impl Serialize for MediaDuration
impl StructuralPartialEq for MediaDuration
Auto Trait Implementations§
impl Freeze for MediaDuration
impl RefUnwindSafe for MediaDuration
impl Send for MediaDuration
impl Sync for MediaDuration
impl Unpin for MediaDuration
impl UnsafeUnpin for MediaDuration
impl UnwindSafe for MediaDuration
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