Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove empty_sample_boxes. #89

Merged
merged 2 commits into from
Apr 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions mp4parse/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,22 +437,6 @@ impl <T> std::ops::Add for TrackScaledTime<T> where T: Num {
}
}

/// A fragmented file contains no sample data in stts, stsc, and stco.
#[derive(Debug, Default)]
pub struct EmptySampleTableBoxes {
// TODO: Track has stts, stsc and stco, this structure can be discarded.
pub empty_stts: bool,
pub empty_stsc: bool,
pub empty_stco: bool,
}

/// Check boxes contain data.
impl EmptySampleTableBoxes {
pub fn all_empty(&self) -> bool {
self.empty_stts & self.empty_stsc & self.empty_stco
}
}

#[derive(Debug, Default)]
pub struct Track {
pub id: usize,
Expand All @@ -463,7 +447,6 @@ pub struct Track {
pub duration: Option<TrackScaledTime<u64>>,
pub track_id: Option<u32>,
pub codec_type: CodecType,
pub empty_sample_boxes: EmptySampleTableBoxes,
pub data: Option<SampleEntry>,
pub tkhd: Option<TrackHeaderBox>, // TODO(kinetik): find a nicer way to export this.
pub stts: Option<TimeToSampleBox>,
Expand Down Expand Up @@ -892,13 +875,11 @@ fn read_stbl<T: Read>(f: &mut BMFFBox<T>, track: &mut Track) -> Result<()> {
BoxType::TimeToSampleBox => {
let stts = read_stts(&mut b)?;
log!("{:?}", stts);
track.empty_sample_boxes.empty_stts = stts.samples.is_empty();
track.stts = Some(stts);
}
BoxType::SampleToChunkBox => {
let stsc = read_stsc(&mut b)?;
log!("{:?}", stsc);
track.empty_sample_boxes.empty_stsc = stsc.samples.is_empty();
track.stsc = Some(stsc);
}
BoxType::SampleSizeBox => {
Expand All @@ -908,7 +889,6 @@ fn read_stbl<T: Read>(f: &mut BMFFBox<T>, track: &mut Track) -> Result<()> {
}
BoxType::ChunkOffsetBox => {
let stco = read_stco(&mut b)?;
track.empty_sample_boxes.empty_stco = stco.offsets.is_empty();
log!("{:?}", stco);
track.stco = Some(stco);
}
Expand Down
15 changes: 8 additions & 7 deletions mp4parse_capi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1049,13 +1049,14 @@ pub unsafe extern fn mp4parse_is_fragmented(parser: *mut mp4parse_parser, track_

// check sample tables.
let mut iter = tracks.iter();
match iter.find(|track| track.track_id == Some(track_id)) {
Some(track) if track.empty_sample_boxes.all_empty() => (*fragmented) = true as u8,
Some(_) => {},
None => return mp4parse_status::BAD_ARG,
}

mp4parse_status::OK
iter.find(|track| track.track_id == Some(track_id)).map_or(mp4parse_status::BAD_ARG, |track| {
match (&track.stsc, &track.stco, &track.stts) {
(&Some(ref stsc), &Some(ref stco), &Some(ref stts))
if stsc.samples.is_empty() && stco.offsets.is_empty() && stts.samples.is_empty() => (*fragmented) = true as u8,
_ => {},
};
mp4parse_status::OK
})
}

/// Get 'pssh' system id and 'pssh' box content for eme playback.
Expand Down