Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/ex_libsrt/client.ex
Original file line number Diff line number Diff line change
Expand Up @@ -149,5 +149,5 @@ defmodule ExLibSRT.Client do
end
end

defp validate_password(_), do: {:error, "Password must be a string"}
defp validate_password(_password), do: {:error, "Password must be a string"}
end
2 changes: 1 addition & 1 deletion lib/ex_libsrt/connection.ex
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ defmodule ExLibSRT.Connection do
GenServer.start(__MODULE__, handler, [])
end

@spec stop(t()) :: GenServer.on_stop()
@spec stop(t()) :: :ok
def stop(handler) do
GenServer.stop(handler)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/ex_libsrt/server.ex
Original file line number Diff line number Diff line change
Expand Up @@ -213,5 +213,5 @@ defmodule ExLibSRT.Server do
end
end

defp validate_password(_), do: {:error, "Password must be a string"}
defp validate_password(_password), do: {:error, "Password must be a string"}
end
4 changes: 2 additions & 2 deletions mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
"bunch_native": {:hex, :bunch_native, "0.5.0", "8ac1536789a597599c10b652e0b526d8833348c19e4739a0759a2bedfd924e63", [:mix], [{:bundlex, "~> 1.0", [hex: :bundlex, repo: "hexpm", optional: false]}], "hexpm", "24190c760e32b23b36edeb2dc4852515c7c5b3b8675b1a864e0715bdd1c8f80d"},
"bundlex": {:hex, :bundlex, "1.5.4", "3726acd463f4d31894a59bbc177c17f3b574634a524212f13469f41c4834a1d9", [:mix], [{:bunch, "~> 1.0", [hex: :bunch, repo: "hexpm", optional: false]}, {:elixir_uuid, "~> 1.2", [hex: :elixir_uuid, repo: "hexpm", optional: false]}, {:qex, "~> 0.5", [hex: :qex, repo: "hexpm", optional: false]}, {:req, ">= 0.4.0", [hex: :req, repo: "hexpm", optional: false]}, {:zarex, "~> 1.0", [hex: :zarex, repo: "hexpm", optional: false]}], "hexpm", "e745726606a560275182a8ac1c8ebd5e11a659bb7460d8abf30f397e59b4c5d2"},
"bunt": {:hex, :bunt, "1.0.0", "081c2c665f086849e6d57900292b3a161727ab40431219529f13c4ddcf3e7a44", [:mix], [], "hexpm", "dc5f86aa08a5f6fa6b8096f0735c4e76d54ae5c9fa2c143e5a1fc7c1cd9bb6b5"},
"credo": {:hex, :credo, "1.7.5", "643213503b1c766ec0496d828c90c424471ea54da77c8a168c725686377b9545", [:mix], [{:bunt, "~> 0.2.1 or ~> 1.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "f799e9b5cd1891577d8c773d245668aa74a2fcd15eb277f51a0131690ebfb3fd"},
"credo": {:hex, :credo, "1.7.12", "9e3c20463de4b5f3f23721527fcaf16722ec815e70ff6c60b86412c695d426c1", [:mix], [{:bunt, "~> 0.2.1 or ~> 1.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "8493d45c656c5427d9c729235b99d498bd133421f3e0a683e5c1b561471291e5"},
"dialyxir": {:hex, :dialyxir, "1.4.3", "edd0124f358f0b9e95bfe53a9fcf806d615d8f838e2202a9f430d59566b6b53b", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "bf2cfb75cd5c5006bec30141b131663299c661a864ec7fbbc72dfa557487a986"},
"earmark_parser": {:hex, :earmark_parser, "1.4.39", "424642f8335b05bb9eb611aa1564c148a8ee35c9c8a8bba6e129d51a3e3c6769", [:mix], [], "hexpm", "06553a88d1f1846da9ef066b87b57c6f605552cfbe40d20bd8d59cc6bde41944"},
"elixir_uuid": {:hex, :elixir_uuid, "1.2.1", "dce506597acb7e6b0daeaff52ff6a9043f5919a4c3315abb4143f0b00378c097", [:mix], [], "hexpm", "f7eba2ea6c3555cea09706492716b0d87397b88946e6380898c2889d68585752"},
"erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"},
"ex_doc": {:hex, :ex_doc, "0.31.2", "8b06d0a5ac69e1a54df35519c951f1f44a7b7ca9a5bb7a260cd8a174d6322ece", [:mix], [{:earmark_parser, "~> 1.4.39", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.1", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "317346c14febaba9ca40fd97b5b5919f7751fb85d399cc8e7e8872049f37e0af"},
"file_system": {:hex, :file_system, "1.0.0", "b689cc7dcee665f774de94b5a832e578bd7963c8e637ef940cd44327db7de2cd", [:mix], [], "hexpm", "6752092d66aec5a10e662aefeed8ddb9531d79db0bc145bb8c40325ca1d8536d"},
"file_system": {:hex, :file_system, "1.1.0", "08d232062284546c6c34426997dd7ef6ec9f8bbd090eb91780283c9016840e8f", [:mix], [], "hexpm", "bfcf81244f416871f2a2e15c1b515287faa5db9c6bcf290222206d120b3d43f6"},
"finch": {:hex, :finch, "0.20.0", "5330aefb6b010f424dcbbc4615d914e9e3deae40095e73ab0c1bb0968933cadf", [:mix], [{:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:mint, "~> 1.6.2 or ~> 1.7", [hex: :mint, repo: "hexpm", optional: false]}, {:nimble_options, "~> 0.4 or ~> 1.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:nimble_pool, "~> 1.1", [hex: :nimble_pool, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "2658131a74d051aabfcba936093c903b8e89da9a1b63e430bee62045fa9b2ee2"},
"hpax": {:hex, :hpax, "1.0.3", "ed67ef51ad4df91e75cc6a1494f851850c0bd98ebc0be6e81b026e765ee535aa", [:mix], [], "hexpm", "8eab6e1cfa8d5918c2ce4ba43588e894af35dbd8e91e6e55c817bca5847df34a"},
"jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"},
Expand Down
5 changes: 5 additions & 0 deletions test/ex_libsrt/client_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ defmodule ExLibSRT.ClientTest do

setup :prepare_streaming

@tag :srt_tools_required
test "connect to the server", ctx do
_proxy = Transmit.start_receiving_proxy(ctx.srt_port, ctx.udp_port)

Expand All @@ -14,6 +15,7 @@ defmodule ExLibSRT.ClientTest do
assert_receive :srt_client_connected
end

@tag :srt_tools_required
test "send data to a server", ctx do
_proxy = Transmit.start_receiving_proxy(ctx.srt_port, ctx.udp_port)
receiver = Transmit.start_stream_receiver(ctx.udp_port)
Expand All @@ -29,6 +31,7 @@ defmodule ExLibSRT.ClientTest do
end
end

@tag :srt_tools_required
test "disconnect from the server", ctx do
_proxy = Transmit.start_receiving_proxy(ctx.srt_port, ctx.udp_port)

Expand All @@ -41,6 +44,7 @@ defmodule ExLibSRT.ClientTest do
assert {:error, "Client is not active"} = Client.send_data("test payload", client)
end

@tag :srt_tools_required
test "get disconnected notification when servers closes", ctx do
proxy = Transmit.start_receiving_proxy(ctx.srt_port, ctx.udp_port)

Expand All @@ -55,6 +59,7 @@ defmodule ExLibSRT.ClientTest do
assert {:error, "Client is not active"} = Client.send_data("some payload", client)
end

@tag :srt_tools_required
test "read socket stats", ctx do
_proxy = Transmit.start_receiving_proxy(ctx.srt_port, ctx.udp_port)
receiver = Transmit.start_stream_receiver(ctx.udp_port)
Expand Down
9 changes: 9 additions & 0 deletions test/ex_libsrt/server_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ defmodule ExLibSRT.ServerTest do
describe "server" do
setup :prepare_streaming

@tag :srt_tools_required
test "accept a new connection", ctx do
stream_id = "random_stream_id"

Expand All @@ -27,6 +28,7 @@ defmodule ExLibSRT.ServerTest do
Transmit.stop_proxy(proxy)
end

@tag :srt_tools_required
test "decline the connection", ctx do
stream_id = "forbidden_stream_id"
_proxy = Transmit.start_streaming_proxy(ctx.udp_port, ctx.srt_port, stream_id)
Expand All @@ -39,6 +41,7 @@ defmodule ExLibSRT.ServerTest do
refute_receive {:srt_server_conn, _conn_id, _stream_id}, 1_000
end

@tag :srt_tools_required
test "receive data over connection", ctx do
proxy =
Transmit.start_streaming_proxy(ctx.udp_port, ctx.srt_port, "data_stream_id")
Expand Down Expand Up @@ -66,6 +69,7 @@ defmodule ExLibSRT.ServerTest do
Transmit.stop_proxy(proxy)
end

@tag :srt_tools_required
test "can handle multiple connections", ctx do
streams =
for udp_port <- ctx.udp_port..(ctx.udp_port + 10), into: %{} do
Expand Down Expand Up @@ -93,6 +97,7 @@ defmodule ExLibSRT.ServerTest do
end
end

@tag :srt_tools_required
test "send closed connection notification", ctx do
proxy =
Transmit.start_streaming_proxy(
Expand All @@ -111,6 +116,7 @@ defmodule ExLibSRT.ServerTest do
assert_receive {:srt_server_conn_closed, ^conn_id}, 2_000
end

@tag :srt_tools_required
test "close an ongoing connection", ctx do
_proxy =
Transmit.start_streaming_proxy(
Expand All @@ -128,6 +134,7 @@ defmodule ExLibSRT.ServerTest do
assert_receive {:srt_server_conn_closed, ^conn_id}, 1_000
end

@tag :srt_tools_required
test "read socket stats", ctx do
_proxy =
Transmit.start_streaming_proxy(
Expand Down Expand Up @@ -159,6 +166,7 @@ defmodule ExLibSRT.ServerTest do
assert {:error, "Socket not found"} = Server.read_socket_stats(2137, ctx.server)
end

@tag :srt_tools_required
test "starts a separate connection process", ctx do
:persistent_term.put(:srt_receiver, self())

Expand All @@ -170,6 +178,7 @@ defmodule ExLibSRT.ServerTest do
:persistent_term.get(:srt_receiver)
end

@impl true
def handle_connected(conn_id, stream_id, receiver) do
send(receiver, {:srt_handler_connected, conn_id, stream_id})

Expand Down
18 changes: 16 additions & 2 deletions test/support/srt_live_transmit.ex
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ defmodule ExLibSRT.SRTLiveTransmit do
]}
]

port = Port.open({:spawn_executable, System.find_executable("srt-live-transmit")}, args)
port = Port.open({:spawn_executable, find_executable("srt-live-transmit")}, args)

wait_for_port(udp_port)

Expand Down Expand Up @@ -51,13 +51,27 @@ defmodule ExLibSRT.SRTLiveTransmit do
]}
]

port = Port.open({:spawn_executable, System.find_executable("srt-live-transmit")}, args)
port = Port.open({:spawn_executable, find_executable("srt-live-transmit")}, args)

wait_for_port(udp_port)

port
end

defp find_executable(executable_name) do
case System.find_executable(executable_name) do
nil ->
raise """
Couldn't find #{executable_name} in your system.
Make sure you have `srt-tools` in your system or
exclude tests that require it with `--exclude srt_tools_required`.
"""

executable ->
executable
end
end

@spec stop_proxy(streaming_proxy() | receiving_proxy()) :: :ok
def stop_proxy(proxy) do
{:os_pid, os_pid} = :erlang.port_info(proxy, :os_pid)
Expand Down