Skip to content

Make BoxType, BoxHeader, BMFFBox, BoxIter, and read_moov pub #427

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
26 changes: 13 additions & 13 deletions mp4parse/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use std::io::{Read, Take};
mod macros;

mod boxes;
use crate::boxes::{BoxType, FourCC};
pub use crate::boxes::{BoxType, FourCC};

// Unit tests.
#[cfg(test)]
Expand Down Expand Up @@ -920,16 +920,16 @@ pub type Result<T, E = Error> = std::result::Result<T, E>;
///
/// See ISOBMFF (ISO 14496-12:2020) § 4.2
#[derive(Debug, Clone, Copy)]
struct BoxHeader {
pub struct BoxHeader {
/// Box type.
name: BoxType,
pub name: BoxType,
/// Size of the box in bytes.
size: u64,
pub size: u64,
/// Offset to the start of the contained data (or header size).
offset: u64,
pub offset: u64,
/// Uuid for extended type.
#[allow(dead_code)] // See https://github.com/mozilla/mp4parse-rust/issues/340
uuid: Option<[u8; 16]>,
pub uuid: Option<[u8; 16]>,
}

impl BoxHeader {
Expand Down Expand Up @@ -2130,21 +2130,21 @@ impl Track {
}

/// See ISOBMFF (ISO 14496-12:2020) § 4.2
struct BMFFBox<'a, T: 'a> {
head: BoxHeader,
content: Take<&'a mut T>,
pub struct BMFFBox<'a, T: 'a> {
pub head: BoxHeader,
pub content: Take<&'a mut T>,
}

struct BoxIter<'a, T: 'a> {
pub struct BoxIter<'a, T: 'a> {
src: &'a mut T,
}

impl<T: Read> BoxIter<'_, T> {
fn new(src: &mut T) -> BoxIter<T> {
pub fn new(src: &mut T) -> BoxIter<T> {
BoxIter { src }
}

fn next_box(&mut self) -> Result<Option<BMFFBox<T>>> {
pub fn next_box(&mut self) -> Result<Option<BMFFBox<T>>> {
let r = read_box_header(self.src);
match r {
Ok(h) => Ok(Some(BMFFBox {
Expand Down Expand Up @@ -4133,7 +4133,7 @@ fn parse_mvhd<T: Read>(f: &mut BMFFBox<T>) -> Result<Option<MediaTimeScale>> {
/// Note that despite the spec indicating "exactly one" moov box should exist at
/// the file container level, we support reading and merging multiple moov boxes
/// such as with tests/test_case_1185230.mp4.
fn read_moov<T: Read>(f: &mut BMFFBox<T>, context: Option<MediaContext>) -> Result<MediaContext> {
pub fn read_moov<T: Read>(f: &mut BMFFBox<T>, context: Option<MediaContext>) -> Result<MediaContext> {
let MediaContext {
mut timescale,
mut tracks,
Expand Down