Skip to content

Commit 50c3ad6

Browse files
authored
Allow for specifying client_timeout option in Source and SourceBin. Bump to v0.28.0 (#109)
* Add client timeout option in the RTMP Source * Add client_timeout option in source_bin * Bump to v0.28.0
1 parent de85843 commit 50c3ad6

File tree

5 files changed

+22
-6
lines changed

5 files changed

+22
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
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.27.3"}
17+
{:membrane_rtmp_plugin, "~> 0.28.0"}
1818
]
1919
end
2020
```

lib/membrane_rtmp_plugin/rtmp/source/source.ex

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ defmodule Membrane.RTMP.Source do
3636
An URL on which the client is expected to connect, for example:
3737
rtmp://127.0.0.1:1935/app/stream_key
3838
"""
39+
],
40+
client_timeout: [
41+
default: Membrane.Time.seconds(5),
42+
spec: Membrane.Time.t(),
43+
description: """
44+
Time after which an unused client connection is automatically closed, expressed in `Membrane.Time.t()` units. Defaults to 5 seconds.
45+
"""
3946
]
4047

4148
defguardp is_builtin_server(opts)
@@ -54,7 +61,8 @@ defmodule Membrane.RTMP.Source do
5461
url: opts.url,
5562
mode: :builtin_server,
5663
client_ref: nil,
57-
use_ssl?: nil
64+
use_ssl?: nil,
65+
client_timeout: opts.client_timeout
5866
}
5967

6068
{[], state}
@@ -94,7 +102,7 @@ defmodule Membrane.RTMP.Source do
94102
port: port,
95103
use_ssl?: use_ssl?,
96104
handle_new_client: handle_new_client,
97-
client_timeout: Membrane.Time.milliseconds(100)
105+
client_timeout: state.client_timeout
98106
)
99107

100108
state = %{state | app: app, stream_key: stream_key, server: server_pid}

lib/membrane_rtmp_plugin/rtmp/source/source_bin.ex

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,22 @@ defmodule Membrane.RTMP.SourceBin do
3939
An URL on which the client is expected to connect, for example:
4040
rtmp://127.0.0.1:1935/app/stream_key
4141
"""
42+
],
43+
client_timeout: [
44+
default: Membrane.Time.seconds(5),
45+
spec: Membrane.Time.t(),
46+
description: """
47+
Time after which an unused client connection is automatically closed, expressed in `Membrane.Time.t()` units. Defaults to 5 seconds.
48+
"""
4249
]
4350

4451
@impl true
4552
def handle_init(_ctx, %__MODULE__{} = opts) do
4653
spec =
4754
child(:src, %RTMP.Source{
4855
client_ref: opts.client_ref,
49-
url: opts.url
56+
url: opts.url,
57+
client_timeout: opts.client_timeout
5058
})
5159
|> child(:demuxer, Membrane.FLV.Demuxer)
5260

lib/membrane_rtmp_plugin/rtmp_server.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ defmodule Membrane.RTMPServer do
1111
which defines how the client should behave.
1212
- port: Port on which RTMP server will listen. Defaults to 1935.
1313
- use_ssl?: If true, SSL socket (for RTMPS) will be used. Othwerwise, TCP socket (for RTMP) will be used. Defaults to false.
14-
- client_timeout: Time after which an unused client connection is automatically closed. Defaults to 5 seconds.
14+
- client_timeout: Time after which an unused client connection is automatically closed, expressed in `Membrane.Time.t()` units. Defaults to 5 seconds.
1515
- name: If not nil, value of this field will be used as a name under which the server's process will be registered. Defaults to nil.
1616
"""
1717
use GenServer

mix.exs

Lines changed: 1 addition & 1 deletion
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.27.3"
4+
@version "0.28.0"
55
@github_url "https://github.com/membraneframework/membrane_rtmp_plugin"
66

77
def project do

0 commit comments

Comments
 (0)