diff --git a/mp4parse/src/lib.rs b/mp4parse/src/lib.rs index 4278bccb..653a62ca 100644 --- a/mp4parse/src/lib.rs +++ b/mp4parse/src/lib.rs @@ -437,22 +437,6 @@ impl std::ops::Add for TrackScaledTime 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, @@ -463,7 +447,6 @@ pub struct Track { pub duration: Option>, pub track_id: Option, pub codec_type: CodecType, - pub empty_sample_boxes: EmptySampleTableBoxes, pub data: Option, pub tkhd: Option, // TODO(kinetik): find a nicer way to export this. pub stts: Option, @@ -892,13 +875,11 @@ fn read_stbl(f: &mut BMFFBox, 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 => { @@ -908,7 +889,6 @@ fn read_stbl(f: &mut BMFFBox, 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); } diff --git a/mp4parse_capi/src/lib.rs b/mp4parse_capi/src/lib.rs index e1a31ca8..632c32b9 100644 --- a/mp4parse_capi/src/lib.rs +++ b/mp4parse_capi/src/lib.rs @@ -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.