comparison libervia/desktop_kivy/plugins/plugin_wid_calls.py @ 514:d78728d7fd6a

plugin wid calls, core: implements WebRTC DataChannel file transfer: - Add a new "file" icon in call UI to send a file via WebRTC. - Handle new preflight mechanism, and WebRTC file transfer. - Native file chooser handling has been moved to new `core.file_chooser` module, and now supports "save" and "dir" modes (based on `plyer`). rel 442
author Goffi <goffi@goffi.org>
date Sat, 06 Apr 2024 13:37:27 +0200
parents 644a8d165e5a
children 11851162dd4c
comparison
equal deleted inserted replaced
513:0fdf3e59aaad 514:d78728d7fd6a
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 from kivy.metrics import dp
9 from libervia.desktop_kivy.core.file_chooser import FileChooser
9 10
10 try: 11 try:
11 from gi.overrides import Gst as _ 12 from gi.overrides import Gst as _
12 except ImportError: 13 except ImportError:
13 print( 14 print(
36 from libervia.backend.core.i18n import _ 37 from libervia.backend.core.i18n import _
37 from libervia.backend.core import exceptions 38 from libervia.backend.core import exceptions
38 from libervia.backend.tools.common import data_format 39 from libervia.backend.tools.common import data_format
39 from libervia.frontends.quick_frontend import quick_widgets 40 from libervia.frontends.quick_frontend import quick_widgets
40 from libervia.frontends.tools import aio, display_servers, jid, webrtc 41 from libervia.frontends.tools import aio, display_servers, jid, webrtc
42 from libervia.frontends.tools.webrtc_file import WebRTCFileSender
41 43
42 from libervia.desktop_kivy import G 44 from libervia.desktop_kivy import G
43 45
44 from ..core import cagou_widget 46 from ..core import cagou_widget
45 from ..core import common 47 from ..core import common
429 self.desktop_sharing = True 431 self.desktop_sharing = True
430 432
431 def on_desktop_sharing(self, instance, active: bool) -> None: 433 def on_desktop_sharing(self, instance, active: bool) -> None:
432 self.webrtc.desktop_sharing = active 434 self.webrtc.desktop_sharing = active
433 435
436 def on_file_btn_press(self) -> None:
437 aio.run_async(self.on_file_press())
438
439 async def on_file_press(self):
440 callee = self.webrtc.callee
441 if callee is None:
442 return
443 file_to_send = await FileChooser.a_open()
444 if file_to_send is None:
445 return
446 file_sender = WebRTCFileSender(
447 G.host.a_bridge,
448 self.profile
449 )
450 await file_sender.send_file_webrtc(file_to_send, self.webrtc.callee)
451
434 def on_fullscreen(self, instance, fullscreen: bool) -> None: 452 def on_fullscreen(self, instance, fullscreen: bool) -> None:
435 if fullscreen: 453 if fullscreen:
436 G.host.app.show_head_widget(False, animation=False) 454 G.host.app.show_head_widget(False, animation=False)
437 self.call_layout.parent.remove_widget(self.call_layout) 455 self.call_layout.parent.remove_widget(self.call_layout)
438 G.host.show_extra_ui(self.call_layout) 456 G.host.show_extra_ui(self.call_layout)