Skip to content

Publish nested types #104

@kixelated

Description

@kixelated

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)?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions