comparison libervia/cli/call_simple.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 0d7bb4df2343
comparison
equal deleted inserted replaced
4232:0fbe5c605eb6 4233:d01b8d002619
27 from rich.console import group 27 from rich.console import group
28 from rich.live import Live 28 from rich.live import Live
29 from rich.panel import Panel 29 from rich.panel import Panel
30 from rich.text import Text 30 from rich.text import Text
31 31
32 from .call_webrtc import CallData, WebRTCCall 32 from libervia.frontends.tools import aio
33 from libervia.frontends.tools.webrtc import CallData, WebRTCCall
34
35
36 aio.install_glib_asyncio_iteration()
33 37
34 38
35 class BaseAVTUI: 39 class BaseAVTUI:
36 def __init__(self, host, webrtc=None, align: str = "left"): 40 def __init__(self, host, webrtc=None, align: str = "left"):
37 self.host = host 41 self.host = host
155 async def run(cls, parent, call_data: CallData) -> None: 159 async def run(cls, parent, call_data: CallData) -> None:
156 kwargs = cls.parse_output_opts(parent) 160 kwargs = cls.parse_output_opts(parent)
157 merge_pip = False if "split" in parent.args.output_opts else None 161 merge_pip = False if "split" in parent.args.output_opts else None
158 162
159 webrtc_call = await WebRTCCall.make_webrtc_call( 163 webrtc_call = await WebRTCCall.make_webrtc_call(
160 parent.host, 164 parent.host.bridge,
161 parent.profile, 165 parent.profile,
162 call_data, 166 call_data,
163 merge_pip=merge_pip, 167 merge_pip=merge_pip,
168 # we want to be sure that call is ended if user presses `Ctrl + c` or anything
169 # else stops the session.
170 on_call_setup_cb=lambda sid, profile: parent.host.add_on_quit_callback(
171 parent.host.bridge.call_end, sid, "", profile
172 ),
173 on_call_ended_cb=lambda sid, profile: parent.host.a_quit(),
164 **kwargs, 174 **kwargs,
165 ) 175 )
166 if not parent.args.no_ui: 176 if not parent.args.no_ui:
167 ui = cls(parent.host, webrtc_call.webrtc) 177 ui = cls(parent.host, webrtc_call.webrtc)
168 await ui.start() 178 await ui.start()