Allow only for boxes names which are already in the schema. Release v0.36.9 - #138
Merged
Conversation
varsill
marked this pull request as ready for review
June 12, 2026 08:38
mat-hek
reviewed
Jun 12, 2026
| if schema_def[:black_box?] do | ||
| Map.new(schema_def) | ||
| else | ||
| {schema, children} = schema_def |> Keyword.split([:version, :fields, :black_box?]) |
Member
There was a problem hiding this comment.
Suggested change
| {schema, children} = schema_def |> Keyword.split([:version, :fields, :black_box?]) | |
| {schema, children} = schema_def |> Keyword.split(@non_box_keys) |
| @@ -0,0 +1,517 @@ | |||
| defmodule Membrane.MP4.Container.Schema.Default do | |||
Member
There was a problem hiding this comment.
Suggested change
| defmodule Membrane.MP4.Container.Schema.Default do | |
| defmodule Membrane.MP4.Container.Schema.Default do | |
| # Moduledoc is below the schema definition |
| children: map | ||
| } | ||
| }, | ||
| know_box_names: MapSet.t(String.t()) |
Member
There was a problem hiding this comment.
Suggested change
| know_box_names: MapSet.t(String.t()) | |
| known_box_names: MapSet.t(String.t()) |
|
|
||
| @doc """ | ||
| Parses binary data to MP4 according to `#{inspect(Schema)}.schema/0`. | ||
| Parses binary data to MP4 according to `#{inspect(Schema)}.Default.schema/0`. |
Member
There was a problem hiding this comment.
Suggested change
| Parses binary data to MP4 according to `#{inspect(Schema)}.Default.schema/0`. | |
| Parses binary data to MP4 according to `#{inspect(Schema.Default)}.schema/0`. |
|
|
||
| @doc """ | ||
| Serializes MP4 to a binary according to `#{inspect(Schema)}.schema/0`. | ||
| Serializes MP4 to a binary according to `#{inspect(Schema)}.Default.schema/0`. |
Member
There was a problem hiding this comment.
Suggested change
| Serializes MP4 to a binary according to `#{inspect(Schema)}.Default.schema/0`. | |
| Serializes MP4 to a binary according to `#{inspect(Schema.Default)}.schema/0`. |
| content: <<content::binary-size(^content_size), data::binary>> <- rest, | ||
| do: box_schema = schema[name], | ||
| do: box_schema = boxes[name], | ||
| known?: true <- box_schema && not box_schema.black_box?, |
Member
There was a problem hiding this comment.
Here we don't distinguish unknown boxes and black boxes, shouldn't we?
| try: | ||
| {:ok, children, rest, context} <- parse_boxes(rest, box_schema.children, context, []), | ||
| {:ok, children, rest, context} <- | ||
| do_parse_boxes(rest, box_schema.children, known_box_names, context, []), |
Member
There was a problem hiding this comment.
I'd prefer do_parse_boxes to accept schema as before and here do
Suggested change
| do_parse_boxes(rest, box_schema.children, known_box_names, context, []), | |
| do_parse_boxes(rest, %Schema{schema | schema: box_schema.children}, context, []), |
Then Header.parse could also accept schema. Similarly in the serialize_helper.
mat-hek
approved these changes
Jun 15, 2026
| with {{:ok, data}, context} <- | ||
| Bunch.Enum.try_map_reduce(mp4, context, fn {box_name, box}, context -> | ||
| serialize_box(box_name, box, Map.fetch(schema, box_name), context) | ||
| serialize_box(box_name, box, Map.fetch(boxes_layout, box_name), context) |
Member
There was a problem hiding this comment.
let's pass the full schema down to be on par with the parser
Co-authored-by: Mateusz Front <mateusz.front@swmansion.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.