Mercurial > libervia-desktop-kivy
comparison libervia/desktop_kivy/plugins/plugin_wid_calls.py @ 510:97ab236e8f20
plugin calls: implement desktop sharing:
rel 433
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 16 Jan 2024 10:41:38 +0100 |
parents | f0ce49b360c8 |
children | 644a8d165e5a |
comparison
equal
deleted
inserted
replaced
509:f0ce49b360c8 | 510:97ab236e8f20 |
---|---|
3 from typing import Optional, Callable | 3 from typing import Optional, Callable |
4 from functools import partial | 4 from functools import partial |
5 | 5 |
6 # from gi.repository import GLib | 6 # from gi.repository import GLib |
7 from gi.repository import GObject, Gst, GstWebRTC, GstSdp | 7 from gi.repository import GObject, Gst, GstWebRTC, GstSdp |
8 from kivy.metrics import dp | |
8 | 9 |
9 try: | 10 try: |
10 from gi.overrides import Gst as _ | 11 from gi.overrides import Gst as _ |
11 except ImportError: | 12 except ImportError: |
12 print( | 13 print( |
25 ReferenceListProperty, | 26 ReferenceListProperty, |
26 ) | 27 ) |
27 from kivy.support import install_gobject_iteration | 28 from kivy.support import install_gobject_iteration |
28 from kivy.uix.button import Button | 29 from kivy.uix.button import Button |
29 from kivy.uix.image import Image | 30 from kivy.uix.image import Image |
31 from kivy.uix.popup import Popup | |
30 from kivy.uix.screenmanager import Screen | 32 from kivy.uix.screenmanager import Screen |
31 from kivy.uix.widget import Widget | 33 from kivy.uix.widget import Widget |
32 from libervia.backend.core.constants import Const as C | 34 from libervia.backend.core.constants import Const as C |
33 from libervia.backend.core import log as logging | 35 from libervia.backend.core import log as logging |
34 from libervia.backend.core.i18n import _ | 36 from libervia.backend.core.i18n import _ |
35 from libervia.backend.core import exceptions | 37 from libervia.backend.core import exceptions |
36 from libervia.backend.tools.common import data_format | 38 from libervia.backend.tools.common import data_format |
37 from libervia.frontends.quick_frontend import quick_widgets | 39 from libervia.frontends.quick_frontend import quick_widgets |
38 from libervia.frontends.tools import aio, jid, webrtc | 40 from libervia.frontends.tools import aio, display_servers, jid, webrtc |
39 | 41 |
40 from libervia.desktop_kivy import G | 42 from libervia.desktop_kivy import G |
41 | 43 |
42 from ..core import cagou_widget | 44 from ..core import cagou_widget |
43 from ..core import common | 45 from ..core import common |
99 microphone available will be used. | 101 microphone available will be used. |
100 """ | 102 """ |
101 | 103 |
102 test_mode: bool = False | 104 test_mode: bool = False |
103 | 105 |
104 PROXIED_PROPERTIES = {'audio_muted', 'callee', 'sid', 'video_muted'} | 106 PROXIED_PROPERTIES = { |
107 'audio_muted', 'callee', 'desktop_sharing', 'sid', 'video_muted', 'desktop_sharing_data' | |
108 } | |
105 PROXIED_METHODS = {'answer_call', 'end_call', 'on_accepted_call', 'on_ice_candidates_new', 'setup_call', 'start_pipeline'} | 109 PROXIED_METHODS = {'answer_call', 'end_call', 'on_accepted_call', 'on_ice_candidates_new', 'setup_call', 'start_pipeline'} |
106 | 110 |
107 def __init__(self, parent_calls: "Calls", profile: str) -> None: | 111 def __init__(self, parent_calls: "Calls", profile: str) -> None: |
108 self.parent_calls = parent_calls | 112 self.parent_calls = parent_calls |
109 self.profile = profile | 113 self.profile = profile |
237 buf.unmap(mapinfo) | 241 buf.unmap(mapinfo) |
238 finally: | 242 finally: |
239 if buf is not None and mapinfo is not None: | 243 if buf is not None and mapinfo is not None: |
240 buf.unmap(mapinfo) | 244 buf.unmap(mapinfo) |
241 | 245 |
246 class WindowSelectButton(Button): | |
247 pass | |
248 | |
249 | |
250 class DesktopScreenDialog(Popup): | |
251 windows_buttons = ObjectProperty() | |
252 | |
253 def __init__(self, calls: "Calls", **kwargs): | |
254 super().__init__(**kwargs) | |
255 self.calls = calls | |
256 if display_servers.detect() == display_servers.X11: | |
257 windows_data = display_servers.x11_list_windows() | |
258 for window_data in windows_data: | |
259 log.debug(f"- X11 windows found: {window_data}") | |
260 button = WindowSelectButton( | |
261 text = window_data["title"], | |
262 on_press=partial(self.on_window_selected, xid=window_data["id"]) | |
263 ) | |
264 self.windows_buttons.add_widget(button) | |
265 | |
266 def on_window_selected(self, instance, xid: str) -> None: | |
267 if xid is not None: | |
268 self.calls.webrtc.desktop_sharing_data = {"xid": xid} | |
269 else: | |
270 self.calls.webrtc.desktop_sharing_data = None | |
271 self.calls.desktop_sharing = True | |
272 self.dismiss() | |
273 | |
242 | 274 |
243 class Calls( | 275 class Calls( |
244 quick_widgets.QuickWidget, | 276 quick_widgets.QuickWidget, |
245 cagou_widget.LiberviaDesktopKivyWidget, | 277 cagou_widget.LiberviaDesktopKivyWidget, |
246 FilterBehavior | 278 FilterBehavior |
247 ): | 279 ): |
248 audio_muted = BooleanProperty(False) | 280 audio_muted = BooleanProperty(False) |
249 call_layout = ObjectProperty() | 281 call_layout = ObjectProperty() |
250 call_screen = ObjectProperty() | 282 call_screen = ObjectProperty() |
251 fullscreen = BooleanProperty(False) | 283 fullscreen = BooleanProperty(False) |
257 ringtone: Sound | None = None | 289 ringtone: Sound | None = None |
258 screen_manager = ObjectProperty() | 290 screen_manager = ObjectProperty() |
259 signals_registered = False | 291 signals_registered = False |
260 use_header_input = True | 292 use_header_input = True |
261 video_muted = BooleanProperty(False) | 293 video_muted = BooleanProperty(False) |
294 desktop_sharing = BooleanProperty(False) | |
262 | 295 |
263 def __init__(self, host, target, profiles): | 296 def __init__(self, host, target, profiles): |
264 quick_widgets.QuickWidget.__init__(self, G.host, target, profiles) | 297 quick_widgets.QuickWidget.__init__(self, G.host, target, profiles) |
265 cagou_widget.LiberviaDesktopKivyWidget.__init__(self) | 298 cagou_widget.LiberviaDesktopKivyWidget.__init__(self) |
266 call_btn = CallButton( | 299 call_btn = CallButton( |
380 self.webrtc.audio_muted = muted | 413 self.webrtc.audio_muted = muted |
381 | 414 |
382 def on_video_muted(self, instance, muted: bool) -> None: | 415 def on_video_muted(self, instance, muted: bool) -> None: |
383 self.webrtc.video_muted = muted | 416 self.webrtc.video_muted = muted |
384 | 417 |
418 def on_desktop_btn_press(self) -> None: | |
419 if self.desktop_sharing: | |
420 self.desktop_sharing = False | |
421 else: | |
422 DesktopScreenDialog(self).open() | |
423 | |
424 def on_desktop_sharing(self, instance, active: bool) -> None: | |
425 self.webrtc.desktop_sharing = active | |
426 | |
385 def on_fullscreen(self, instance, fullscreen: bool) -> None: | 427 def on_fullscreen(self, instance, fullscreen: bool) -> None: |
386 if fullscreen: | 428 if fullscreen: |
387 G.host.app.show_head_widget(False, animation=False) | 429 G.host.app.show_head_widget(False, animation=False) |
388 self.call_layout.parent.remove_widget(self.call_layout) | 430 self.call_layout.parent.remove_widget(self.call_layout) |
389 G.host.show_extra_ui(self.call_layout) | 431 G.host.show_extra_ui(self.call_layout) |