Skip to content

Commit 162ec98

Browse files
committed
Add simulcast form
1 parent a1e3818 commit 162ec98

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

lib/live_ex_webrtc/publisher.ex

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ defmodule LiveExWebRTC.Publisher do
8989
defstruct id: nil,
9090
pc: nil,
9191
streaming?: false,
92+
form:
93+
to_form(%{"simulcast" => "false"},
94+
id: "lex-form"
95+
),
9296
audio_track: nil,
9397
video_track: nil,
9498
on_packet: nil,
@@ -332,17 +336,16 @@ defmodule LiveExWebRTC.Publisher do
332336
class="rounded-lg disabled:text-gray-400 disabled:border-gray-400 focus:border-brand focus:outline-none focus:ring-0"
333337
/>
334338
</div>
335-
<div class="flex gap-2.5 items-center">
336-
<label for="lex-simulcast">Simulcast</label>
337-
<input type="checkbox" id="lex-simulcast" class="rounded-full" checked />
338-
</div>
339339
<button
340340
id="lex-video-apply-button"
341341
class="rounded-lg px-10 py-2.5 bg-brand disabled:bg-brand/50 hover:bg-brand/90 text-white font-bold"
342342
disabled
343343
>
344344
Apply
345345
</button>
346+
<.form for={@publisher.form} phx-change="change_simulcast" phx-update="replace">
347+
<.input type="checkbox" field={@publisher.form[:simulcast]} label="Simulcast" />
348+
</.form>
346349
</div>
347350
</div>
348351
<div id="lex-videoplayer-wrapper" class="flex flex-1 flex-col min-h-0 pt-2.5">
@@ -572,6 +575,23 @@ defmodule LiveExWebRTC.Publisher do
572575
end
573576
end
574577

578+
@impl true
579+
def handle_event("change_simulcast", params, socket) do
580+
publisher = %Publisher{
581+
socket.assigns.publisher
582+
| form:
583+
to_form(params,
584+
id: "lex-form",
585+
errors: [
586+
simulcast: {"Server must be configured with H264 codec to support simulcast", []}
587+
]
588+
)
589+
}
590+
591+
socket = assign(socket, publisher: publisher)
592+
{:noreply, socket}
593+
end
594+
575595
defp spawn_peer_connection(socket) do
576596
%{publisher: publisher} = socket.assigns
577597

0 commit comments

Comments
 (0)