Skip to content

Allow only for boxes names which are already in the schema. Release v0.36.9 - #138

Merged
varsill merged 13 commits into
masterfrom
atoms_whitelist
Jun 15, 2026
Merged

Allow only for boxes names which are already in the schema. Release v0.36.9#138
varsill merged 13 commits into
masterfrom
atoms_whitelist

Conversation

@varsill

@varsill varsill commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@varsill
varsill marked this pull request as ready for review June 12, 2026 08:38
@varsill
varsill requested a review from mat-hek as a code owner June 12, 2026 08:38
@varsill varsill changed the title Allow only for boxes names which are already in the schema Allow only for boxes names which are already in the schema. Release v0.36.9 Jun 12, 2026
@varsill
varsill changed the base branch from master to refactor June 12, 2026 12:38
@varsill
varsill changed the base branch from refactor to master June 12, 2026 13:43
Comment thread lib/membrane_mp4/container/schema.ex Outdated
if schema_def[:black_box?] do
Map.new(schema_def)
else
{schema, children} = schema_def |> Keyword.split([:version, :fields, :black_box?])

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
defmodule Membrane.MP4.Container.Schema.Default do
defmodule Membrane.MP4.Container.Schema.Default do
# Moduledoc is below the schema definition

Comment thread lib/membrane_mp4/container/schema.ex Outdated
children: map
}
},
know_box_names: MapSet.t(String.t())

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
know_box_names: MapSet.t(String.t())
known_box_names: MapSet.t(String.t())

Comment thread lib/membrane_mp4/container.ex Outdated

@doc """
Parses binary data to MP4 according to `#{inspect(Schema)}.schema/0`.
Parses binary data to MP4 according to `#{inspect(Schema)}.Default.schema/0`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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`.

Comment thread lib/membrane_mp4/container.ex Outdated

@doc """
Serializes MP4 to a binary according to `#{inspect(Schema)}.schema/0`.
Serializes MP4 to a binary according to `#{inspect(Schema)}.Default.schema/0`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, []),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@varsill
varsill requested a review from mat-hek June 15, 2026 11:32
Comment thread lib/membrane_mp4/container/schema.ex Outdated
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)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's pass the full schema down to be on par with the parser

varsill and others added 4 commits June 15, 2026 13:44
@varsill
varsill merged commit 5b42c1e into master Jun 15, 2026
7 of 8 checks passed
@varsill
varsill deleted the atoms_whitelist branch June 15, 2026 12:29
@varsill varsill self-assigned this Jun 18, 2026
@varsill varsill added this to Smackore Jun 18, 2026
@varsill varsill moved this to Done in Smackore Jun 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants