diff libervia/cli/call_tui.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 79c8a70e1813
line wrap: on
line diff
--- a/libervia/cli/call_tui.py	Sat Apr 06 12:59:50 2024 +0200
+++ b/libervia/cli/call_tui.py	Sat Apr 06 13:43:09 2024 +0200
@@ -27,16 +27,19 @@
 from term_image import image as t_image
 
 from libervia.cli.constants import Const as C
-from libervia.frontends.tools import webrtc
+from libervia.frontends.tools import aio, webrtc
+from libervia.frontends.tools.webrtc import CallData, WebRTCCall
 
 from .call_simple import BaseAVTUI
-from .call_webrtc import CallData, WebRTCCall
 
 gi.require_versions({"Gst": "1.0", "GstWebRTC": "1.0"})
 
 from gi.repository import Gst
 
 
+aio.install_glib_asyncio_iteration()
+
+
 class AVCallUI(BaseAVTUI):
     def __init__(self, parent):
         super().__init__(parent.host, align="center")
@@ -74,7 +77,7 @@
             # we use low res by default for performance reason
             kwargs["target_size"] = (640, 380)
         webrtc_call = await WebRTCCall.make_webrtc_call(
-            self.parent.host,
+            self.parent.host.bridge,
             self.parent.profile,
             call_data,
             sinks=webrtc.SINKS_APP,
@@ -83,6 +86,12 @@
                 remote_video_cb=None,
             ),
             merge_pip=True,
+            # 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: self.parent.host.add_on_quit_callback(
+                self.parent.host.bridge.call_end, sid, "", profile
+            ),
+            on_call_ended_cb=lambda sid, profile: self.parent.host.a_quit(),
             **kwargs,
         )
         self.webrtc = webrtc_call.webrtc