Mercurial > libervia-backend
comparison 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 |
comparison
equal
deleted
inserted
replaced
4209:fe29fbdabce6 | 4210:9218d4331bb2 |
---|---|
45 QPushButton, | 45 QPushButton, |
46 QSizePolicy, | 46 QSizePolicy, |
47 QVBoxLayout, | 47 QVBoxLayout, |
48 QWidget, | 48 QWidget, |
49 ) | 49 ) |
50 import gi | |
51 | |
52 from libervia.backend.core.i18n import _ | |
53 from libervia.cli.call_webrtc import WebRTCCall | |
54 from libervia.frontends.tools import aio, display_servers, webrtc | |
55 gi.require_versions({ | |
56 "Gst": "1.0", | |
57 "GstWebRTC": "1.0" | |
58 }) | |
50 from gi.repository import Gst | 59 from gi.repository import Gst |
51 | 60 |
52 from libervia.backend.core.i18n import _ | |
53 from libervia.frontends.tools import aio, display_servers, webrtc | |
54 | 61 |
55 | 62 |
56 ICON_SIZE = QSize(45, 45) | 63 ICON_SIZE = QSize(45, 45) |
57 BUTTON_SIZE = QSize(50, 50) | 64 BUTTON_SIZE = QSize(50, 50) |
58 running = False | 65 running = False |
179 async def a_show(self) -> dict | None: | 186 async def a_show(self) -> dict | None: |
180 self.open() | 187 self.open() |
181 return await self.__a_result | 188 return await self.__a_result |
182 | 189 |
183 | 190 |
184 class AVCallGUI(QMainWindow): | 191 class AVCallUI(QMainWindow): |
185 def __init__(self, host, icons_path: Path): | 192 def __init__(self, host, icons_path: Path): |
186 super().__init__() | 193 super().__init__() |
187 self.host = host | 194 self.host = host |
188 self.webrtc_call = None | 195 self.webrtc_call = None |
189 self.icons_path = icons_path | 196 self.icons_path = icons_path |
194 while running: | 201 while running: |
195 app.sendPostedEvents() | 202 app.sendPostedEvents() |
196 await asyncio.sleep(0.1) | 203 await asyncio.sleep(0.1) |
197 | 204 |
198 @classmethod | 205 @classmethod |
199 async def run(cls, parent, call_data, icons_path: Path): | 206 async def run(cls, parent, call_data): |
200 """Run PyQt loop and show the app""" | 207 """Run PyQt loop and show the app""" |
201 print("Starting GUI...") | 208 media_dir = Path(await parent.host.bridge.config_get("", "media_dir")) |
209 icons_path = media_dir / "fonts/fontello/svg" | |
202 app = QApplication([]) | 210 app = QApplication([]) |
203 av_call_gui = cls(parent.host, icons_path) | 211 av_call_gui = cls(parent.host, icons_path) |
204 av_call_gui.show() | 212 av_call_gui.show() |
205 webrtc_call = await parent.make_webrtc_call( | 213 webrtc_call = await WebRTCCall.make_webrtc_call( |
214 parent.host, | |
215 parent.profile, | |
206 call_data, | 216 call_data, |
207 sinks=webrtc.SINKS_APP, | 217 sinks=webrtc.SINKS_APP, |
208 appsink_data=webrtc.AppSinkData( | 218 appsink_data=webrtc.AppSinkData( |
209 local_video_cb=partial(av_call_gui.on_new_sample, video_stream="local"), | 219 local_video_cb=partial(av_call_gui.on_new_sample, video_stream="local"), |
210 remote_video_cb=partial(av_call_gui.on_new_sample, video_stream="remote"), | 220 remote_video_cb=partial(av_call_gui.on_new_sample, video_stream="remote"), |
370 self.showFullScreen() | 380 self.showFullScreen() |
371 else: | 381 else: |
372 self.fullscreen_btn.setIcon(self.fullscreen_icon_normal) | 382 self.fullscreen_btn.setIcon(self.fullscreen_icon_normal) |
373 self.showNormal() | 383 self.showNormal() |
374 | 384 |
375 def closeEvent(self, a0: QCloseEvent) -> None: | 385 def closeEvent(self, a0: QCloseEvent|None) -> None: |
376 super().closeEvent(a0) | 386 super().closeEvent(a0) |
377 global running | 387 global running |
378 running = False | 388 running = False |
379 | 389 |
380 def toggle_video(self): | 390 def toggle_video(self): |
397 else: | 407 else: |
398 self.webrtc_call.webrtc.desktop_sharing = True | 408 self.webrtc_call.webrtc.desktop_sharing = True |
399 | 409 |
400 def hang_up(self): | 410 def hang_up(self): |
401 self.close() | 411 self.close() |
412 | |
413 @staticmethod | |
414 def can_run(): | |
415 # if a known display server is detected, we should be able to run | |
416 return display_servers.detect() is not None | |
402 | 417 |
403 async def show_X11_screen_dialog(self): | 418 async def show_X11_screen_dialog(self): |
404 assert self.webrtc_call is not None | 419 assert self.webrtc_call is not None |
405 windows_data = display_servers.x11_list_windows() | 420 windows_data = display_servers.x11_list_windows() |
406 dialog = X11DesktopScreenDialog(windows_data, self) | 421 dialog = X11DesktopScreenDialog(windows_data, self) |