Skip to content

Commit 324cd3e

Browse files
Handle socket closed by client before start of stream arrives in RTMP Source Bin (#87)
* Handle unexpected socket closed by client before start of stream arrives * Bump version to 0.23.0
1 parent bd07a30 commit 324cd3e

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ The package can be installed by adding `membrane_rtmp_plugin` to your list of de
1414
```elixir
1515
def deps do
1616
[
17-
{:membrane_rtmp_plugin, "~> 0.22.1"}
17+
{:membrane_rtmp_plugin, "~> 0.23.0"}
1818
]
1919
end
2020
```

lib/membrane_rtmp_plugin/rtmp/source/bin.ex

+4
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ defmodule Membrane.RTMP.SourceBin do
105105
{[notify_parent: notification], state}
106106
end
107107

108+
def handle_child_notification(:unexpected_socket_closed, :src, _ctx, state) do
109+
{[notify_parent: :unexpected_socket_close], state}
110+
end
111+
108112
@doc """
109113
Passes the control of the socket to the `source`.
110114

mix.exs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
defmodule Membrane.RTMP.Mixfile do
22
use Mix.Project
33

4-
@version "0.22.1"
4+
@version "0.23.0"
55
@github_url "https://github.com/membraneframework/membrane_rtmp_plugin"
66

77
def project do

test/membrane_rtmp_plugin/rtmp_source_bin_test.exs

+17
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,23 @@ defmodule Membrane.RTMP.SourceBin.IntegrationTest do
184184
assert :error = Task.await(ffmpeg_task)
185185
end
186186

187+
test "Handles client socket close before start of stream" do
188+
{:ok, port} = start_tcp_server()
189+
190+
Task.async(fn ->
191+
host = @local_ip |> String.to_charlist() |> :inet.parse_address() |> elem(1)
192+
{:ok, socket} = :gen_tcp.connect(host, port, [], :infinity)
193+
:gen_tcp.close(socket)
194+
end)
195+
196+
pipeline = await_pipeline_started()
197+
198+
assert_end_of_stream(pipeline, :audio_sink, :input)
199+
assert_end_of_stream(pipeline, :video_sink, :input)
200+
201+
assert_pipeline_notified(pipeline, :src, :unexpected_socket_close)
202+
end
203+
187204
defp start_tcp_server(validator \\ %Membrane.RTMP.MessageValidator.Default{}) do
188205
test_process = self()
189206

0 commit comments

Comments
 (0)