Mercurial > libervia-backend
comparison 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 |
comparison
equal
deleted
inserted
replaced
4232:0fbe5c605eb6 | 4233:d01b8d002619 |
---|---|
48 QWidget, | 48 QWidget, |
49 ) | 49 ) |
50 import gi | 50 import gi |
51 | 51 |
52 from libervia.backend.core.i18n import _ | 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 | 53 from libervia.frontends.tools import aio, display_servers, webrtc |
55 gi.require_versions({ | 54 gi.require_versions({ |
56 "Gst": "1.0", | 55 "Gst": "1.0", |
57 "GstWebRTC": "1.0" | 56 "GstWebRTC": "1.0" |
58 }) | 57 }) |
61 | 60 |
62 | 61 |
63 ICON_SIZE = QSize(45, 45) | 62 ICON_SIZE = QSize(45, 45) |
64 BUTTON_SIZE = QSize(50, 50) | 63 BUTTON_SIZE = QSize(50, 50) |
65 running = False | 64 running = False |
65 | |
66 | |
67 aio.install_glib_asyncio_iteration() | |
66 | 68 |
67 | 69 |
68 class ActivableButton(QPushButton): | 70 class ActivableButton(QPushButton): |
69 def __init__(self, text, parent=None): | 71 def __init__(self, text, parent=None): |
70 super().__init__(parent) | 72 super().__init__(parent) |
208 media_dir = Path(await parent.host.bridge.config_get("", "media_dir")) | 210 media_dir = Path(await parent.host.bridge.config_get("", "media_dir")) |
209 icons_path = media_dir / "fonts/fontello/svg" | 211 icons_path = media_dir / "fonts/fontello/svg" |
210 app = QApplication([]) | 212 app = QApplication([]) |
211 av_call_gui = cls(parent.host, icons_path) | 213 av_call_gui = cls(parent.host, icons_path) |
212 av_call_gui.show() | 214 av_call_gui.show() |
213 webrtc_call = await WebRTCCall.make_webrtc_call( | 215 webrtc_call = await webrtc.WebRTCCall.make_webrtc_call( |
214 parent.host, | 216 parent.host.bridge, |
215 parent.profile, | 217 parent.profile, |
216 call_data, | 218 call_data, |
217 sinks=webrtc.SINKS_APP, | 219 sinks=webrtc.SINKS_APP, |
218 appsink_data=webrtc.AppSinkData( | 220 appsink_data=webrtc.AppSinkData( |
219 local_video_cb=partial(av_call_gui.on_new_sample, video_stream="local"), | 221 local_video_cb=partial(av_call_gui.on_new_sample, video_stream="local"), |
220 remote_video_cb=partial(av_call_gui.on_new_sample, video_stream="remote"), | 222 remote_video_cb=partial(av_call_gui.on_new_sample, video_stream="remote"), |
221 ), | 223 ), |
224 # we want to be sure that call is ended if user presses `Ctrl + c` or anything | |
225 # else stops the session. | |
226 on_call_setup_cb=lambda sid, profile: parent.host.add_on_quit_callback( | |
227 parent.host.bridge.call_end, sid, "", profile | |
228 ), | |
229 on_call_ended_cb=lambda sid, profile: parent.host.a_quit(), | |
222 ) | 230 ) |
223 av_call_gui.webrtc_call = webrtc_call | 231 av_call_gui.webrtc_call = webrtc_call |
224 | 232 |
225 global running | 233 global running |
226 running = True | 234 running = True |