Skip to content

Commit ecc14a4

Browse files
committed
Add recorder opts
1 parent cdb57ee commit ecc14a4

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/live_ex_webrtc/publisher.ex

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ defmodule LiveExWebRTC.Publisher do
147147
recordings?: true,
148148
# recorder instance
149149
recorder: nil,
150+
recorder_opts: [],
150151
audio_track: nil,
151152
video_track: nil,
152153
on_packet: nil,
@@ -195,6 +196,7 @@ defmodule LiveExWebRTC.Publisher do
195196
* `pubsub` - a pubsub that publisher live view will use for broadcasting audio and video packets received from a browser. See module doc for more info.
196197
* `recordings?` - whether to allow for recordings or not. Defaults to true.
197198
See module doc and `t:on_disconnected/0` for more info.
199+
* `recorder_opts` - a list of options that will be passed to the recorder. In particular, they can contain S3 config where recordings will be uploaded. See `t:ExWebRTC.Recorder.option/0` for more.
198200
* `on_connected` - callback called when the underlying peer connection changes its state to the `:connected`. See `t:on_connected/0`.
199201
* `on_disconnected` - callback called when the underlying peer connection process terminates. See `t:on_disconnected/0`.
200202
* `on_recording_finished` - callback called when the stream recording has finised. See `t:on_recording_finished/0`.
@@ -214,6 +216,7 @@ defmodule LiveExWebRTC.Publisher do
214216
:name,
215217
:pubsub,
216218
:recordings?,
219+
:recorder_opts,
217220
:on_packet,
218221
:on_connected,
219222
:on_disconnected,
@@ -230,6 +233,7 @@ defmodule LiveExWebRTC.Publisher do
230233
id: Keyword.fetch!(opts, :id),
231234
pubsub: Keyword.fetch!(opts, :pubsub),
232235
recordings?: Keyword.get(opts, :recordings?, true),
236+
recorder_opts: Keyword.get(opts, :recorder_opts, []),
233237
on_packet: Keyword.get(opts, :on_packet),
234238
on_connected: Keyword.get(opts, :on_connected),
235239
on_disconnected: Keyword.get(opts, :on_disconnected),
@@ -243,7 +247,7 @@ defmodule LiveExWebRTC.Publisher do
243247
}
244248

245249
# Check the "Record stream?" checkbox by default if recordings are allowed
246-
record? = publisher.recordings? != nil
250+
record? = publisher.recordings? == true
247251

248252
socket
249253
|> assign(publisher: %Publisher{publisher | record?: record?})
@@ -658,7 +662,7 @@ defmodule LiveExWebRTC.Publisher do
658662

659663
recorder =
660664
if publisher.record? == true and publisher.recorder == nil do
661-
{:ok, recorder} = Recorder.start_link()
665+
{:ok, recorder} = Recorder.start_link(socket.assigns.publisher.recorder_opts)
662666
recorder
663667
else
664668
publisher.recorder

0 commit comments

Comments
 (0)