Skip to content

Commit 1e0f75d

Browse files
authored
Add a function to stop a RTSP server (#43)
* Add a function to stop a RTSP server
1 parent 4084f7a commit 1e0f75d

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ of dependencies in `mix.exs`:
1818
```elixir
1919
def deps do
2020
[
21-
{:membrane_rtsp, "~> 0.8.0"}
21+
{:membrane_rtsp, "~> 0.9.0"}
2222
]
2323
end
2424
```

lib/membrane_rtsp/server.ex

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,18 @@ defmodule Membrane.RTSP.Server do
7474
GenServer.start_link(__MODULE__, config, name: config[:name])
7575
end
7676

77+
@doc """
78+
Stops the RTSP server.
79+
80+
## Options
81+
- `timeout` - timeout of the server termination, passed to `GenServer.stop/3`.
82+
"""
83+
@spec stop(pid(), timeout: timeout()) :: :ok
84+
def stop(server, opts \\ []) do
85+
timeout = Keyword.get(opts, :timeout, :infinity)
86+
GenServer.stop(server, :normal, timeout)
87+
end
88+
7789
@doc """
7890
Get the port number of the server.
7991
@@ -171,12 +183,16 @@ defmodule Membrane.RTSP.Server do
171183
{:noreply, state}
172184
end
173185

186+
@spec do_listen(:gen_tcp.socket(), pid()) :: :ok
174187
defp do_listen(socket, parent_pid) do
175188
case :gen_tcp.accept(socket) do
176189
{:ok, client_socket} ->
177190
send(parent_pid, {:new_connection, client_socket})
178191
do_listen(socket, parent_pid)
179192

193+
{:error, :closed} ->
194+
:ok
195+
180196
{:error, reason} ->
181197
raise("error occurred when accepting client connection: #{inspect(reason)}")
182198
end

mix.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
defmodule Membrane.RTSP.MixProject do
22
use Mix.Project
33

4-
@version "0.8.0"
4+
@version "0.9.0"
55
@github_url "https://github.com/membraneframework/membrane_rtsp"
66

77
def project do
@@ -112,7 +112,7 @@ defmodule Membrane.RTSP.MixProject do
112112
defp deps do
113113
[
114114
{:bunch, "~> 1.6"},
115-
{:ex_sdp, "~> 0.15.0"},
115+
{:ex_sdp, "~> 0.17.0"},
116116
{:nimble_parsec, "~> 1.4.0", runtime: false},
117117
{:dialyxir, "~> 1.1", only: [:dev], runtime: false},
118118
{:mockery, "~> 2.3", runtime: false},

mix.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"elixir_uuid": {:hex, :elixir_uuid, "1.2.1", "dce506597acb7e6b0daeaff52ff6a9043f5919a4c3315abb4143f0b00378c097", [:mix], [], "hexpm", "f7eba2ea6c3555cea09706492716b0d87397b88946e6380898c2889d68585752"},
88
"erlex": {:hex, :erlex, "0.2.7", "810e8725f96ab74d17aac676e748627a07bc87eb950d2b83acd29dc047a30595", [:mix], [], "hexpm", "3ed95f79d1a844c3f6bf0cea61e0d5612a42ce56da9c03f01df538685365efb0"},
99
"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"},
10-
"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"},
10+
"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"},
1111
"file_system": {:hex, :file_system, "0.2.10", "fb082005a9cd1711c05b5248710f8826b02d7d1784e7c3451f9c1231d4fc162d", [:mix], [], "hexpm", "41195edbfb562a593726eda3b3e8b103a309b733ad25f3d642ba49696bf715dc"},
1212
"jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"},
1313
"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"},

0 commit comments

Comments
 (0)