diff libervia/cli/call_simple.py @ 4233:d01b8d002619

cli (call, file), frontends: implement webRTC data channel transfer: - file send/receive commands now supports webRTC transfer. In `send` command, the `--webrtc` flags is currenty used to activate it. - WebRTC related code have been factorized and moved to `libervia.frontends.tools.webrtc*` modules. rel 442
author Goffi <goffi@goffi.org>
date Sat, 06 Apr 2024 13:43:09 +0200
parents 9218d4331bb2
children 0d7bb4df2343
line wrap: on
line diff
--- a/libervia/cli/call_simple.py	Sat Apr 06 12:59:50 2024 +0200
+++ b/libervia/cli/call_simple.py	Sat Apr 06 13:43:09 2024 +0200
@@ -29,7 +29,11 @@
 from rich.panel import Panel
 from rich.text import Text
 
-from .call_webrtc import CallData, WebRTCCall
+from libervia.frontends.tools import aio
+from libervia.frontends.tools.webrtc import CallData, WebRTCCall
+
+
+aio.install_glib_asyncio_iteration()
 
 
 class BaseAVTUI:
@@ -157,10 +161,16 @@
         merge_pip = False if "split" in parent.args.output_opts else None
 
         webrtc_call = await WebRTCCall.make_webrtc_call(
-            parent.host,
+            parent.host.bridge,
             parent.profile,
             call_data,
             merge_pip=merge_pip,
+            # we want to be sure that call is ended if user presses `Ctrl + c` or anything
+            # else stops the session.
+            on_call_setup_cb=lambda sid, profile: parent.host.add_on_quit_callback(
+                parent.host.bridge.call_end, sid, "", profile
+            ),
+            on_call_ended_cb=lambda sid, profile: parent.host.a_quit(),
             **kwargs,
         )
         if not parent.args.no_ui: