vsd_mp4/boxes/tfdt.rs
1use crate::{ParsedBox, Result};
2
3/// Track Fragment Base Media Decode Time Box (tfdt) - absolute decode time of the first sample.
4///
5/// This box provides the absolute decode time, measured on the media timeline,
6/// of the first sample in decode order in the track fragment.
7#[derive(Debug, Clone)]
8pub struct TfdtBox {
9 /// The absolute decode time, measured on the media timeline, of the first sample in decode order in the track fragment.
10 pub base_media_decode_time: u64,
11}
12
13impl TfdtBox {
14 /// Parses a `tfdt` box from a `ParsedBox`.
15 pub fn new(box_: &mut ParsedBox) -> Result<Self> {
16 let reader = &mut box_.reader;
17 let version = box_.version.unwrap();
18
19 Ok(Self {
20 base_media_decode_time: if version == 1 {
21 reader.read_u64()?
22 } else {
23 reader.read_u32()? as u64
24 },
25 })
26 }
27}