From 5c2c2b3b108c8fb926e73b51a1f3f18eb5af055e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=96R=C3=96K=20Attila?= Date: Wed, 16 Apr 2025 12:54:35 +0200 Subject: [PATCH] Make BoxType, BoxHeader, BMFFBox, BoxIter, and read_moov pub --- mp4parse/src/lib.rs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/mp4parse/src/lib.rs b/mp4parse/src/lib.rs index e71069f4..8416e7f7 100644 --- a/mp4parse/src/lib.rs +++ b/mp4parse/src/lib.rs @@ -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)] @@ -920,16 +920,16 @@ pub type Result = std::result::Result; /// /// 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 { @@ -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 BoxIter<'_, T> { - fn new(src: &mut T) -> BoxIter { + pub fn new(src: &mut T) -> BoxIter { BoxIter { src } } - fn next_box(&mut self) -> Result>> { + pub fn next_box(&mut self) -> Result>> { let r = read_box_header(self.src); match r { Ok(h) => Ok(Some(BMFFBox { @@ -4133,7 +4133,7 @@ fn parse_mvhd(f: &mut BMFFBox) -> Result> { /// 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(f: &mut BMFFBox, context: Option) -> Result { +pub fn read_moov(f: &mut BMFFBox, context: Option) -> Result { let MediaContext { mut timescale, mut tracks,