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

Publish nested types #104

Closed
kixelated opened this issue May 2, 2023 · 0 comments · Fixed by #108
Closed

Publish nested types #104

kixelated opened this issue May 2, 2023 · 0 comments · Fixed by #108

Comments

@kixelated
Copy link

Hey there,

The top level box types from the mp4box module are public: MoovBox, MoofBox, MdatBox. However, with the exception of EMsgBox, none of the nested types are public. This makes it difficult to initialize these structs.

For example, here's my awful code to fragment a MoovBox:

// We need to create a brand new moov atom for each track.
let mut toov = mp4::MoovBox{
  mvhd: moov.mvhd.clone(),
  meta: moov.meta.clone(),
  mvex: Some(Default::default()),
  traks: vec![trak.clone()],
  udta: moov.udta.clone(),
};

// TODO someone who knows Rust, please double check that I'm not dumb.
// MvexBox and TrexBox are not exported by the mp4 crate, so we have to construct them using Default.
toov.mvex.as_mut().map(|mvex| {
  mvex.trex = Default::default();
  mvex.trex.track_id = track_id;
});

If these types didn't derive Default, I'm not even sure that it would be possible to set them. Could you export these nested types, or change the mp4box box so it uses pub instead of pub(crate)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant