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

Send end of stream, even if there was no start of stream before #577

Merged
merged 17 commits into from
Aug 22, 2023

Conversation

FelonEkonom
Copy link
Member

@FelonEkonom FelonEkonom commented Jul 13, 2023

@@ -23,6 +26,7 @@ defmodule Membrane.Bin.CallbackContext do
:utility_supervisor => Membrane.UtilitySupervisor.t(),
optional(:pad_options) => map(),
optional(:members) => [Membrane.Child.name()],
optional(:crash_initiator) => Membrane.Child.name()
optional(:crash_initiator) => Membrane.Child.name(),
optional(:preceded_by_start_of_stream?) => boolean()
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
optional(:preceded_by_start_of_stream?) => boolean()
optional(:start_of_stream_received?) => boolean()

Comment on lines 119 to 131
defp stream_event_to_callback_context(%Events.StartOfStream{}, _pad_ref),
do: &CallbackContext.from_state/1

defp stream_event_to_callback_context(%Events.EndOfStream{}, pad_ref) do
&CallbackContext.from_state(&1,
preceded_by_start_of_stream?: PadModel.get_data!(&1, pad_ref, :start_of_stream?)
)
end

defp stream_event_to_parent_message_opts(%Events.StartOfStream{}, _pad_ref, _state), do: []

defp stream_event_to_parent_message_opts(%Events.EndOfStream{}, pad_ref, state),
do: [preceded_by_start_of_stream?: PadModel.get_data!(state, pad_ref, :start_of_stream?)]
Copy link
Member

Choose a reason for hiding this comment

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

extracting that to separate functions is overkill IMO

Copy link
Member Author

Choose a reason for hiding this comment

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

I have extracted it to the separate private functions, because without it do_exec_handle_event was a long serie of statements like

case event_type do
  StartOfStream ->
    this
  
  EndOfStream ->
    that
end

Copy link
Member

Choose a reason for hiding this comment

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

Now it's ok 👍

Copy link
Member

Choose a reason for hiding this comment

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

But actually, when I look at it now, I'd remove handle_special_event and move its logic to the corresponding do_handle_event clauses. I'd also call check_syncs from do_handle_event clause that matches on start of stream.

@@ -1,7 +1,7 @@
defmodule Membrane.Core.Bin.CallbackContext do
@moduledoc false

@type optional_fields :: [pad_options: map()]
@type optional_fields :: [pad_options: map()] | [preceded_by_start_of_stream?: boolean()]
Copy link
Member

Choose a reason for hiding this comment

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

seems not changed in Membrane.Core.Pipeline.CallbackContext

@FelonEkonom FelonEkonom requested a review from mat-hek July 19, 2023 11:11
@FelonEkonom FelonEkonom requested a review from varsill July 25, 2023 09:27
@FelonEkonom FelonEkonom requested a review from varsill July 25, 2023 15:30

state
end

defp do_exec_handle_event(pad_ref, event, params, state) do
:ok = check_sync(event, state)
Copy link
Member

Choose a reason for hiding this comment

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

this is only relevant for start of stream

Comment on lines 64 to 67
with %Events.EndOfStream{} <- event,
true <- PadModel.get_data!(state, pad_ref, :end_of_stream?) do
Membrane.Logger.debug("Ignoring end of stream as it has already arrived before")
state
Copy link
Member

Choose a reason for hiding this comment

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

let's handle that in the do_handle_event clause for EndOfStream

@FelonEkonom FelonEkonom merged commit 4f471c2 into master Aug 22, 2023
1 check passed
@FelonEkonom FelonEkonom deleted the eos-without-start-of-stream branch August 22, 2023 16:02
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 this pull request may close these issues.

3 participants