diff libervia/cli/call_gui.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_gui.py	Sat Apr 06 12:59:50 2024 +0200
+++ b/libervia/cli/call_gui.py	Sat Apr 06 13:43:09 2024 +0200
@@ -50,7 +50,6 @@
 import gi
 
 from libervia.backend.core.i18n import _
-from libervia.cli.call_webrtc import WebRTCCall
 from libervia.frontends.tools import aio, display_servers, webrtc
 gi.require_versions({
     "Gst": "1.0",
@@ -65,6 +64,9 @@
 running = False
 
 
+aio.install_glib_asyncio_iteration()
+
+
 class ActivableButton(QPushButton):
     def __init__(self, text, parent=None):
         super().__init__(parent)
@@ -210,8 +212,8 @@
         app = QApplication([])
         av_call_gui = cls(parent.host, icons_path)
         av_call_gui.show()
-        webrtc_call = await WebRTCCall.make_webrtc_call(
-            parent.host,
+        webrtc_call = await webrtc.WebRTCCall.make_webrtc_call(
+            parent.host.bridge,
             parent.profile,
             call_data,
             sinks=webrtc.SINKS_APP,
@@ -219,6 +221,12 @@
                 local_video_cb=partial(av_call_gui.on_new_sample, video_stream="local"),
                 remote_video_cb=partial(av_call_gui.on_new_sample, video_stream="remote"),
             ),
+            # 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(),
         )
         av_call_gui.webrtc_call = webrtc_call