diff libervia/cli/call_gui.py @ 4210:9218d4331bb2

cli (call): `tui` output implementation: - Moved original UI to a separated class, and use if with the `simple` output - By default, best output is automatically selected. For now `gui` is selected if possible, and `simple` is used as fallback. - The new `tui` output can be used to have the videos directly embedded in the terminal, either with real videos for compatible terminal emulators, or with Unicode blocks. - Text contrôls are used for both `simple` and `tui` outputs - several options can be used with `--oo` (will be documented in next commit). rel 428
author Goffi <goffi@goffi.org>
date Fri, 16 Feb 2024 18:46:06 +0100
parents 0f8ea0768a3b
children d01b8d002619
line wrap: on
line diff
--- a/libervia/cli/call_gui.py	Fri Feb 16 18:46:02 2024 +0100
+++ b/libervia/cli/call_gui.py	Fri Feb 16 18:46:06 2024 +0100
@@ -47,10 +47,17 @@
     QVBoxLayout,
     QWidget,
 )
+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",
+    "GstWebRTC": "1.0"
+})
 from gi.repository import Gst
 
-from libervia.backend.core.i18n import _
-from libervia.frontends.tools import aio, display_servers, webrtc
 
 
 ICON_SIZE = QSize(45, 45)
@@ -181,7 +188,7 @@
         return await self.__a_result
 
 
-class AVCallGUI(QMainWindow):
+class AVCallUI(QMainWindow):
     def __init__(self, host, icons_path: Path):
         super().__init__()
         self.host = host
@@ -196,13 +203,16 @@
             await asyncio.sleep(0.1)
 
     @classmethod
-    async def run(cls, parent, call_data, icons_path: Path):
+    async def run(cls, parent, call_data):
         """Run PyQt loop and show the app"""
-        print("Starting GUI...")
+        media_dir = Path(await parent.host.bridge.config_get("", "media_dir"))
+        icons_path = media_dir / "fonts/fontello/svg"
         app = QApplication([])
         av_call_gui = cls(parent.host, icons_path)
         av_call_gui.show()
-        webrtc_call = await parent.make_webrtc_call(
+        webrtc_call = await WebRTCCall.make_webrtc_call(
+            parent.host,
+            parent.profile,
             call_data,
             sinks=webrtc.SINKS_APP,
             appsink_data=webrtc.AppSinkData(
@@ -372,7 +382,7 @@
             self.fullscreen_btn.setIcon(self.fullscreen_icon_normal)
             self.showNormal()
 
-    def closeEvent(self, a0: QCloseEvent) -> None:
+    def closeEvent(self, a0: QCloseEvent|None) -> None:
         super().closeEvent(a0)
         global running
         running = False
@@ -400,6 +410,11 @@
     def hang_up(self):
         self.close()
 
+    @staticmethod
+    def can_run():
+        # if a known display server is detected, we should be able to run
+        return display_servers.detect() is not None
+
     async def show_X11_screen_dialog(self):
         assert self.webrtc_call is not None
         windows_data = display_servers.x11_list_windows()