diff --git a/README.md b/README.md index 1c77428..967d6f8 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ of dependencies in `mix.exs`: ```elixir def deps do [ - {:membrane_rtsp, "~> 0.8.0"} + {:membrane_rtsp, "~> 0.9.0"} ] end ``` diff --git a/lib/membrane_rtsp/server.ex b/lib/membrane_rtsp/server.ex index 590998b..f176038 100644 --- a/lib/membrane_rtsp/server.ex +++ b/lib/membrane_rtsp/server.ex @@ -74,6 +74,18 @@ defmodule Membrane.RTSP.Server do GenServer.start_link(__MODULE__, config, name: config[:name]) end + @doc """ + Stops the RTSP server. + + ## Options + - `timeout` - timeout of the server termination, passed to `GenServer.stop/3`. + """ + @spec stop(pid(), timeout: timeout()) :: :ok + def stop(server, opts \\ []) do + timeout = Keyword.get(opts, :timeout, :infinity) + GenServer.stop(server, :normal, timeout) + end + @doc """ Get the port number of the server. @@ -171,12 +183,16 @@ defmodule Membrane.RTSP.Server do {:noreply, state} end + @spec do_listen(:gen_tcp.socket(), pid()) :: :ok defp do_listen(socket, parent_pid) do case :gen_tcp.accept(socket) do {:ok, client_socket} -> send(parent_pid, {:new_connection, client_socket}) do_listen(socket, parent_pid) + {:error, :closed} -> + :ok + {:error, reason} -> raise("error occurred when accepting client connection: #{inspect(reason)}") end diff --git a/mix.exs b/mix.exs index 65d8ead..941fdb1 100644 --- a/mix.exs +++ b/mix.exs @@ -1,7 +1,7 @@ defmodule Membrane.RTSP.MixProject do use Mix.Project - @version "0.8.0" + @version "0.9.0" @github_url "https://github.com/membraneframework/membrane_rtsp" def project do @@ -112,7 +112,7 @@ defmodule Membrane.RTSP.MixProject do defp deps do [ {:bunch, "~> 1.6"}, - {:ex_sdp, "~> 0.15.0"}, + {:ex_sdp, "~> 0.17.0"}, {:nimble_parsec, "~> 1.4.0", runtime: false}, {:dialyxir, "~> 1.1", only: [:dev], runtime: false}, {:mockery, "~> 2.3", runtime: false}, diff --git a/mix.lock b/mix.lock index b5bca50..f7aeedc 100644 --- a/mix.lock +++ b/mix.lock @@ -7,7 +7,7 @@ "elixir_uuid": {:hex, :elixir_uuid, "1.2.1", "dce506597acb7e6b0daeaff52ff6a9043f5919a4c3315abb4143f0b00378c097", [:mix], [], "hexpm", "f7eba2ea6c3555cea09706492716b0d87397b88946e6380898c2889d68585752"}, "erlex": {:hex, :erlex, "0.2.7", "810e8725f96ab74d17aac676e748627a07bc87eb950d2b83acd29dc047a30595", [:mix], [], "hexpm", "3ed95f79d1a844c3f6bf0cea61e0d5612a42ce56da9c03f01df538685365efb0"}, "ex_doc": {:hex, :ex_doc, "0.34.2", "13eedf3844ccdce25cfd837b99bea9ad92c4e511233199440488d217c92571e8", [:mix], [{:earmark_parser, "~> 1.4.39", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.0", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1 or ~> 1.0", [hex: :makeup_erlang, repo: "hexpm", optional: false]}, {:makeup_html, ">= 0.1.0", [hex: :makeup_html, repo: "hexpm", optional: true]}], "hexpm", "5ce5f16b41208a50106afed3de6a2ed34f4acfd65715b82a0b84b49d995f95c1"}, - "ex_sdp": {:hex, :ex_sdp, "0.15.0", "53815fb5b5e4fae0f3b26de90f372446bb8e0eed62a3cc20394d3c29519698be", [:mix], [{:bunch, "~> 1.3", [hex: :bunch, repo: "hexpm", optional: false]}, {:elixir_uuid, "~> 1.2", [hex: :elixir_uuid, repo: "hexpm", optional: false]}], "hexpm", "d3f23596b73e7057521ff0f0d55b1189c6320a2f04388aa3a80a0aa97ffb379f"}, + "ex_sdp": {:hex, :ex_sdp, "0.17.0", "4c50e7814f01f149c0ccf258fba8428f8567dffecf1c416ec3f6aaaac607a161", [:mix], [{:bunch, "~> 1.3", [hex: :bunch, repo: "hexpm", optional: false]}, {:elixir_uuid, "~> 1.2", [hex: :elixir_uuid, repo: "hexpm", optional: false]}], "hexpm", "c7fe0625902be2a835b5fe6834a189f7db7639d2625c8e9d8b3564e6d704145f"}, "file_system": {:hex, :file_system, "0.2.10", "fb082005a9cd1711c05b5248710f8826b02d7d1784e7c3451f9c1231d4fc162d", [:mix], [], "hexpm", "41195edbfb562a593726eda3b3e8b103a309b733ad25f3d642ba49696bf715dc"}, "jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"}, "makeup": {:hex, :makeup, "1.1.2", "9ba8837913bdf757787e71c1581c21f9d2455f4dd04cfca785c70bbfff1a76a3", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cce1566b81fbcbd21eca8ffe808f33b221f9eee2cbc7a1706fc3da9ff18e6cac"},