-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
117 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
use super::*; | ||
|
||
#[derive(Clone, Debug, Default, Eq, PartialEq)] | ||
pub struct Stts { | ||
pub table_pos: u64, | ||
pub items: Vec<SttsItem>, | ||
} | ||
|
||
#[derive(Clone, Debug, Default, Eq, PartialEq)] | ||
pub struct SttsItem { | ||
pub sample_count: u32, | ||
pub sample_duration: u32, | ||
} | ||
|
||
impl Atom for Stts { | ||
const FOURCC: Fourcc = SAMPLE_TABLE_TIME_TO_SAMPLE; | ||
} | ||
|
||
impl ParseAtom for Stts { | ||
fn parse_atom(reader: &mut (impl Read + Seek), size: Size) -> crate::Result<Self> { | ||
let (version, _) = parse_full_head(reader)?; | ||
|
||
if version != 0 { | ||
return Err(crate::Error::new( | ||
crate::ErrorKind::UnknownVersion(version), | ||
"Unknown sample table time to sample (stts) version", | ||
)); | ||
} | ||
|
||
let entries = reader.read_be_u32()?; | ||
if 8 + 8 * entries as u64 != size.content_len() { | ||
return Err(crate::Error::new( | ||
crate::ErrorKind::Parsing, | ||
"Sample table time to sample (stts) table size doesn't match atom length", | ||
)); | ||
} | ||
|
||
let table_pos = reader.seek(SeekFrom::Current(0))?; | ||
let mut items = Vec::with_capacity(entries as usize); | ||
for _ in 0..entries { | ||
items.push(SttsItem { | ||
sample_count: reader.read_be_u32()?, | ||
sample_duration: reader.read_be_u32()?, | ||
}); | ||
} | ||
|
||
Ok(Self { table_pos, items }) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters