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

New parser #10

Merged
merged 15 commits into from
Aug 28, 2023
Merged

New parser #10

merged 15 commits into from
Aug 28, 2023

Conversation

jessa0
Copy link
Contributor

@jessa0 jessa0 commented Jul 16, 2023

This merges @oftheforest's new proc-macro-based parser to replace the manually written (de)serialization code in ParseBox/ParsedBox impls with derived impls. This leaves room to be able to parse more types of boxes in a less error-prone way for upcoming (de)muxing (#9) and sanitization features.

To use the new parser in mp4san, the Mp4Box trait in @oftheforest's new parser implementation was replaced with mp4san's existing ParseBox/ParsedBox, which means using Buf/BytesMut for parsing instead of std::io for now. The isom_parse module was merged into mp4san::parse for tighter integration for now, but the entire parse module can be split off to a new crate in the future when it's more stable.

Closes #4.

@jessa0 jessa0 requested a review from oftheforest July 16, 2023 22:47
@jessa0 jessa0 self-assigned this Jul 16, 2023
oftheforest and others added 15 commits August 28, 2023 10:29
This version of the Mp4Box trait only has a size() item. In particular, it is
missing a getter for the box's type. Furthermore, size() does not include the
size of the type field. All of this should be fixed.

The proc-macro crate is of primary interest: the main library crate so far
contains only the Mp4Box trait declaration, and nonsense/fake box type
declarations used to test that the proc macro works. The latter should be
replaced with some (simple) actual box types from the standard once the proc
macro is functional enough to handle them.
Add a type_() method to the trait and derive macro. Fix size() to include the
size of the type field.

Extra changes:
* Write docs for the Mp4Box trait
* Mark the generated trait impls as #[automatically_derived]
* Emit a compiler error instead of panicking in the derive macro
* Make the test names better
Treating box sizes as a plain u64 is error-prone (speaking from experience);
having a separate type like this helps ensure that the special cases (`size:
0`, `size: 1`) are handled correctly and helps prevent invalid states from
being constructed.
…plus some convenience functions; and derive them in the derive macro.

Drop derive support for enums for now: there is currently no way to use
attributes to indicate how enum discriminants are serialized. This will be
added later, and enum support can be restored then.
@jessa0 jessa0 merged commit 53b6a83 into master Aug 28, 2023
@jessa0 jessa0 temporarily deployed to gh-pages August 28, 2023 17:33 — with GitHub Actions Inactive
@jessa0 jessa0 deleted the new-parser branch August 28, 2023 17:33
@jessa0 jessa0 linked an issue Aug 28, 2023 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Write a more robust but fully featured parser Replace mp4 crate with simpler parser
2 participants