Skip to content

Commit

Permalink
Send notification on socket closed when the stream hasn't started
Browse files Browse the repository at this point in the history
  • Loading branch information
Qizot committed Jan 4, 2023
1 parent 02f38e1 commit e6cc284
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions lib/membrane_rtmp_plugin/rtmp/source/source.ex
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ defmodule Membrane.RTMP.Source do
@type stream_validation_failed_t() ::
{:stream_validation_failed, validation_stage_t(), reason :: any()}

@typedoc """
Notification sent when the socket has been closed but no media data has flown through it.
This notification is only sent when the `:output` pad never reaches `:start_of_stream`.
"""
@type unexpected_socket_closed_t() :: :unexpected_socket_closed

@impl true
def handle_init(%__MODULE__{} = opts) do
{{:ok, [notify: {:socket_control_needed, opts.socket, self()}]},
Expand Down Expand Up @@ -156,8 +163,12 @@ defmodule Membrane.RTMP.Source do
end

@impl true
def handle_other({:tcp_closed, _port}, _ctx, state) do
{{:ok, end_of_stream: :output}, state}
def handle_other({:tcp_closed, _socket}, ctx, state) do
if ctx.pads.output.start_of_stream? do
{{:ok, end_of_stream: :output}, state}
else
{{:ok, notify: :unexpected_socket_closed}, state}
end
end

@impl true
Expand Down

0 comments on commit e6cc284

Please sign in to comment.