annotate libervia/cli/cmd_call.py @ 4206:0f8ea0768a3b

cli (call): implement GUI output: ``call`` commands now handle various output. Beside the original one (now named ``simple``), a new ``gui`` one display a full featured GUI (make with Qt). PyQt 6 or more needs to be installed. rel 427
author Goffi <goffi@goffi.org>
date Sun, 11 Feb 2024 23:20:24 +0100
parents 849721e1563b
children 9218d4331bb2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4143
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/env python3
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
2
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
3
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
4 # Libervia CLI
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
5 # Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
6
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
7 # This program is free software: you can redistribute it and/or modify
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
8 # it under the terms of the GNU Affero General Public License as published by
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
9 # the Free Software Foundation, either version 3 of the License, or
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
10 # (at your option) any later version.
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
11
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
12 # This program is distributed in the hope that it will be useful,
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
15 # GNU Affero General Public License for more details.
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
16
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
17 # You should have received a copy of the GNU Affero General Public License
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
19
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
20
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
21 from argparse import ArgumentParser
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
22 import asyncio
4206
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
23 from dataclasses import dataclass
4143
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
24 from functools import partial
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
25 import logging
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
26 import os
4206
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
27 from pathlib import Path
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
28 from typing import Callable
4143
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
29
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
30 from prompt_toolkit.input import create_input
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
31 from prompt_toolkit.keys import Keys
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
32
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
33 from libervia.backend.core.i18n import _
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
34 from libervia.backend.tools.common import data_format
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
35 from libervia.cli.constants import Const as C
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
36 from libervia.frontends.tools import aio, jid
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
37 from rich.columns import Columns
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
38 from rich.console import group
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
39 from rich.live import Live
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
40 from rich.panel import Panel
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
41 from rich.text import Text
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
42
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
43 from . import base
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
44
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
45 __commands__ = ["Call"]
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
46
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
47
4206
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
48 @dataclass
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
49 class CallData:
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
50 callee: jid.JID
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
51 sid: str|None = None
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
52 action_id: str|None = None
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
53
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
54
4143
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
55 class WebRTCCall:
4206
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
56 def __init__(self, host, profile: str, callee: jid.JID, **kwargs):
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
57 """Create and setup a webRTC instance
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
58
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
59 @param profile: profile making or receiving the call
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
60 @param callee: peer jid
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
61 @param kwargs: extra kw args to use when instantiating WebRTC
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
62 """
4143
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
63 from libervia.frontends.tools import webrtc
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
64
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
65 aio.install_glib_asyncio_iteration()
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
66 self.host = host
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
67 self.profile = profile
4206
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
68 self.webrtc = webrtc.WebRTC(host.bridge, profile, **kwargs)
4143
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
69 self.webrtc.callee = callee
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
70 host.bridge.register_signal(
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
71 "ice_candidates_new", self.on_ice_candidates_new, "plugin"
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
72 )
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
73 host.bridge.register_signal("call_setup", self.on_call_setup, "plugin")
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
74 host.bridge.register_signal("call_ended", self.on_call_ended, "plugin")
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
75
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
76 @property
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
77 def sid(self) -> str | None:
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
78 return self.webrtc.sid
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
79
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
80 @sid.setter
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
81 def sid(self, new_sid: str | None) -> None:
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
82 self.webrtc.sid = new_sid
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
83
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
84 async def on_ice_candidates_new(
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
85 self, sid: str, candidates_s: str, profile: str
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
86 ) -> None:
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
87 if sid != self.webrtc.sid or profile != self.profile:
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
88 return
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
89 self.webrtc.on_ice_candidates_new(
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
90 data_format.deserialise(candidates_s),
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
91 )
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
92
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
93 async def on_call_setup(self, sid: str, setup_data_s: str, profile: str) -> None:
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
94 if sid != self.webrtc.sid or profile != self.profile:
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
95 return
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
96 setup_data = data_format.deserialise(setup_data_s)
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
97 try:
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
98 role = setup_data["role"]
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
99 sdp = setup_data["sdp"]
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
100 except KeyError:
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
101 self.host.disp(f"Invalid setup data received: {setup_data}", error=True)
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
102 return
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
103 if role == "initiator":
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
104 self.webrtc.on_accepted_call(sdp, profile)
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
105 elif role == "responder":
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
106 await self.webrtc.answer_call(sdp, profile)
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
107 else:
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
108 self.host.disp(
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
109 f"Invalid role received during setup: {setup_data}", error=True
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
110 )
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
111 # we want to be sure that call is ended if user presses `Ctrl + c` or anything
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
112 # else stops the session.
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
113 self.host.add_on_quit_callback(
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
114 lambda: self.host.bridge.call_end(sid, "", profile)
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
115 )
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
116
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
117 async def on_call_ended(self, sid: str, data_s: str, profile: str) -> None:
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
118 if sid != self.webrtc.sid or profile != self.profile:
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
119 return
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
120 await self.webrtc.end_call()
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
121 await self.host.a_quit()
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
122
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
123 async def start(self):
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
124 """Start a call.
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
125
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
126 To be used only if we are initiator
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
127 """
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
128 await self.webrtc.setup_call("initiator")
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
129 self.webrtc.start_pipeline()
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
130
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
131
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
132 class UI:
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
133 def __init__(self, host, webrtc):
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
134 self.host = host
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
135 self.webrtc = webrtc
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
136
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
137 def styled_shortcut_key(self, word: str, key: str | None = None) -> Text:
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
138 """Return a word with the specified key or the first letter underlined."""
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
139 if key is None:
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
140 key = word[0]
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
141 index = word.find(key)
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
142 before, keyword, after = word[:index], word[index], word[index + 1 :]
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
143 return Text(before) + Text(keyword, style="shortcut") + Text(after)
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
144
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
145 def get_micro_display(self):
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
146 if self.webrtc.audio_muted:
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
147 return Panel(Text("🔇 ") + self.styled_shortcut_key("Muted"), expand=False)
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
148 else:
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
149 return Panel(
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
150 Text("🎤 ") + self.styled_shortcut_key("Unmuted", "m"), expand=False
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
151 )
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
152
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
153 def get_video_display(self):
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
154 if self.webrtc.video_muted:
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
155 return Panel(Text("❌ ") + self.styled_shortcut_key("Video Off"), expand=False)
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
156 else:
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
157 return Panel(Text("🎥 ") + self.styled_shortcut_key("Video On"), expand=False)
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
158
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
159 def get_phone_display(self):
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
160 return Panel(Text("📞 ") + self.styled_shortcut_key("Hang up"), expand=False)
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
161
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
162 @group()
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
163 def generate_control_bar(self):
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
164 """Return the full interface display."""
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
165 yield Columns(
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
166 [
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
167 self.get_micro_display(),
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
168 self.get_video_display(),
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
169 self.get_phone_display(),
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
170 ],
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
171 expand=False,
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
172 title="Calling [bold center]{}[/]".format(self.webrtc.callee),
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
173 )
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
174
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
175 async def start(self):
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
176 done = asyncio.Event()
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
177 input = create_input()
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
178
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
179 def keys_ready(live):
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
180 for key_press in input.read_keys():
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
181 char = key_press.key.lower()
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
182 if char == "m":
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
183 # audio mute
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
184 self.webrtc.audio_muted = not self.webrtc.audio_muted
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
185 live.update(self.generate_control_bar(), refresh=True)
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
186 elif char == "v":
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
187 # video mute
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
188 self.webrtc.video_muted = not self.webrtc.video_muted
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
189 live.update(self.generate_control_bar(), refresh=True)
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
190 elif char == "h" or key_press.key == Keys.ControlC:
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
191 # Hang up
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
192 done.set()
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
193 elif char == "d":
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
194 # generate dot file for debugging. Only available if
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
195 # ``GST_DEBUG_DUMP_DOT_DIR`` is set. Filename is "pipeline.dot" with a
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
196 # timestamp.
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
197 if os.getenv("GST_DEBUG_DUMP_DOT_DIR"):
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
198 self.webrtc.generate_dot_file()
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
199 self.host.disp("Dot file generated.")
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
200
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
201 with Live(
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
202 self.generate_control_bar(),
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
203 console=self.host.console,
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
204 auto_refresh=False
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
205 ) as live:
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
206 with input.raw_mode():
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
207 with input.attach(partial(keys_ready, live)):
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
208 await done.wait()
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
209
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
210 await self.webrtc.end_call()
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
211 await self.host.a_quit()
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
212
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
213
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
214 class Common(base.CommandBase):
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
215
4206
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
216
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
217 def __init__(self, *args, **kwargs):
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
218 super().__init__(
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
219 *args,
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
220 use_output=C.OUTPUT_CUSTOM,
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
221 extra_outputs={
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
222 "default": self.auto_output,
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
223 "simple": self.simple_output,
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
224 "gui": self.gui_output,
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
225 },
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
226 **kwargs
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
227 )
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
228
4143
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
229 def add_parser_options(self):
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
230 self.parser.add_argument(
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
231 "--no-ui", action="store_true", help=_("disable user interface")
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
232 )
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
233
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
234 async def start(self):
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
235 root_logger = logging.getLogger()
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
236 # we don't want any formatting for messages from webrtc
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
237 for handler in root_logger.handlers:
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
238 handler.setFormatter(None)
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
239 if self.verbosity == 0:
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
240 root_logger.setLevel(logging.ERROR)
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
241 if self.verbosity >= 1:
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
242 root_logger.setLevel(logging.WARNING)
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
243 if self.verbosity >= 2:
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
244 root_logger.setLevel(logging.DEBUG)
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
245
4206
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
246 async def make_webrtc_call(self, call_data: CallData, **kwargs) -> WebRTCCall:
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
247 """Create the webrtc_call instance
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
248
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
249 @param call_data: Call data of the command
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
250 @param kwargs: extra args used to instanciate WebRTCCall
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
251
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
252 """
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
253 webrtc_call = WebRTCCall(self.host, self.profile, call_data.callee, **kwargs)
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
254 if call_data.sid is None:
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
255 # we are making the call
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
256 await webrtc_call.start()
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
257 else:
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
258 # we are receiving the call
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
259 webrtc_call.sid = call_data.sid
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
260 if call_data.action_id is not None:
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
261 await self.host.bridge.action_launch(
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
262 call_data.action_id,
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
263 data_format.serialise({"cancelled": False}),
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
264 self.profile
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
265 )
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
266 return webrtc_call
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
267
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
268 async def auto_output(self, call_data: CallData):
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
269 """Make a guess on the best output to use on current platform"""
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
270 # For now we just use simple output
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
271 await self.simple_output(call_data)
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
272
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
273 async def simple_output(self, call_data: CallData):
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
274 """Run simple output, with GStreamer ``autovideosink``"""
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
275 webrtc_call = await self.make_webrtc_call(call_data)
4143
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
276 if not self.args.no_ui:
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
277 ui = UI(self.host, webrtc_call.webrtc)
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
278 await ui.start()
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
279
4206
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
280 async def gui_output(self, call_data: CallData):
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
281 """Run GUI output"""
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
282 media_dir = Path(await self.host.bridge.config_get("", "media_dir"))
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
283 icons_path = media_dir / "fonts/fontello/svg"
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
284 try:
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
285 from .call_gui import AVCallGUI
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
286 await AVCallGUI.run(self, call_data, icons_path)
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
287 except Exception as e:
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
288 self.disp(f"Error starting GUI: {e}", error=True)
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
289 self.host.quit(C.EXIT_ERROR)
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
290
4143
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
291
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
292 class Make(Common):
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
293 def __init__(self, host):
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
294 super().__init__(
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
295 host,
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
296 "make",
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
297 use_verbose=True,
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
298 help=_("start a call"),
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
299 )
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
300
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
301 def add_parser_options(self):
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
302 super().add_parser_options()
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
303 self.parser.add_argument(
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
304 "entity",
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
305 metavar="JID",
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
306 help=_("JIDs of entity to call"),
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
307 )
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
308
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
309 async def start(self):
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
310 await super().start()
4206
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
311 await super().output(CallData(
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
312 callee=jid.JID(self.args.entity),
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
313 ))
4143
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
314
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
315
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
316 class Receive(Common):
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
317 def __init__(self, host):
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
318 super().__init__(
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
319 host,
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
320 "receive",
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
321 use_verbose=True,
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
322 help=_("wait for a call"),
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
323 )
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
324
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
325 def add_parser_options(self):
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
326 super().add_parser_options()
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
327 auto_accept_group = self.parser.add_mutually_exclusive_group()
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
328 auto_accept_group.add_argument(
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
329 "-a",
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
330 "--auto-accept",
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
331 action="append",
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
332 metavar="JID",
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
333 default=[],
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
334 help=_("automatically accept call from this jid (can be used multiple times)")
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
335 )
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
336 auto_accept_group.add_argument(
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
337 "--auto-accept-all",
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
338 action="store_true",
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
339 help=_("automatically accept call from anybody")
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
340 )
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
341
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
342 async def on_action_new(
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
343 self, action_data_s: str, action_id: str, security_limit: int, profile: str
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
344 ) -> None:
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
345 if profile != self.profile:
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
346 return
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
347 action_data = data_format.deserialise(action_data_s)
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
348 if action_data.get("type") != C.META_TYPE_CALL:
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
349 return
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
350 peer_jid = jid.JID(action_data["from_jid"]).bare
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
351 caller = peer_jid.bare
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
352 if (
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
353 not self.args.auto_accept_all
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
354 and caller not in self.args.auto_accept
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
355 and not await self.host.confirm(
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
356 _("📞 Incoming call from {caller}, do you accept?").format(
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
357 caller=caller
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
358 )
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
359 )
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
360 ):
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
361 await self.host.bridge.action_launch(
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
362 action_id, data_format.serialise({"cancelled": True}), profile
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
363 )
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
364 return
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
365
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
366 self.disp(_("✅ Incoming call from {caller} accepted.").format(caller=caller))
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
367
4206
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
368 await super().output(CallData(
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
369 callee=peer_jid,
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
370 sid=action_data["session_id"],
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
371 action_id=action_id
0f8ea0768a3b cli (call): implement GUI output:
Goffi <goffi@goffi.org>
parents: 4143
diff changeset
372 ))
4143
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
373
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
374 async def start(self):
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
375 await super().start()
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
376 self.host.bridge.register_signal("action_new", self.on_action_new, "core")
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
377
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
378
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
379 class Call(base.CommandBase):
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
380 subcommands = (Make, Receive)
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
381
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
382 def __init__(self, host):
849721e1563b cli: `call` command:
Goffi <goffi@goffi.org>
parents:
diff changeset
383 super().__init__(host, "call", use_profile=False, help=_("A/V calls and related"))