annotate libervia/backend/plugins/plugin_xep_0167/__init__.py @ 4335:430d5d99a740

plugin XEP-0358: "Publishing Available Jingle Sessions" implementation: rel 453
author Goffi <goffi@goffi.org>
date Tue, 03 Dec 2024 00:13:07 +0100
parents a0ed5c976bf8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4056
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/env python3
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
2
4058
adb9dc9c8114 plugin XEP-0167: fix wrong copy/pasted header
Goffi <goffi@goffi.org>
parents: 4056
diff changeset
3 # Libervia: an XMPP client
4056
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
4 # Copyright (C) 2009-2023 Jérôme Poisson (goffi@goffi.org)
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
5
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
6 # This program is free software: you can redistribute it and/or modify
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
7 # it under the terms of the GNU Affero General Public License as published by
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
8 # the Free Software Foundation, either version 3 of the License, or
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
9 # (at your option) any later version.
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
10
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
11 # This program is distributed in the hope that it will be useful,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
14 # GNU Affero General Public License for more details.
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
15
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
16 # You should have received a copy of the GNU Affero General Public License
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
18
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
19 from typing import Optional
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
20
4112
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
21 from twisted.internet import reactor
4056
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
22 from twisted.internet import defer
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
23 from twisted.words.protocols.jabber import jid
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
24 from twisted.words.protocols.jabber.xmlstream import XMPPHandler
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
25 from twisted.words.xish import domish
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
26 from wokkel import disco, iwokkel
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
27 from zope.interface import implementer
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
28
4071
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4070
diff changeset
29 from libervia.backend.core import exceptions
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4070
diff changeset
30 from libervia.backend.core.constants import Const as C
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4070
diff changeset
31 from libervia.backend.core.core_types import SatXMPPEntity
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4070
diff changeset
32 from libervia.backend.core.i18n import D_, _
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4070
diff changeset
33 from libervia.backend.core.log import getLogger
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4070
diff changeset
34 from libervia.backend.tools import xml_tools
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4070
diff changeset
35 from libervia.backend.tools.common import data_format
4056
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
36
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
37 from . import mapping
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
38 from ..plugin_xep_0166 import BaseApplicationHandler
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
39 from .constants import (
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
40 NS_JINGLE_RTP,
4112
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
41 NS_JINGLE_RTP_AUDIO,
4056
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
42 NS_JINGLE_RTP_INFO,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
43 NS_JINGLE_RTP_VIDEO,
4294
a0ed5c976bf8 component conferences, plugin XEP-0167, XEP-0298: add stream user metadata:
Goffi <goffi@goffi.org>
parents: 4291
diff changeset
44 NS_AV_CONFERENCES,
4056
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
45 )
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
46
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
47
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
48 log = getLogger(__name__)
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
49
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
50
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
51 PLUGIN_INFO = {
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
52 C.PI_NAME: "Jingle RTP Sessions",
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
53 C.PI_IMPORT_NAME: "XEP-0167",
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
54 C.PI_TYPE: "XEP",
4277
b4b4ea8c5c87 plugin XEP-0167: Let use a `call_setup_cb` method in session:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
55 C.PI_MODES: C.PLUG_MODE_BOTH,
4056
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
56 C.PI_PROTOCOLS: ["XEP-0167"],
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
57 C.PI_DEPENDENCIES: ["XEP-0166"],
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
58 C.PI_MAIN: "XEP_0167",
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
59 C.PI_HANDLER: "yes",
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
60 C.PI_DESCRIPTION: _("""Real-time Transport Protocol (RTP) is used for A/V calls"""),
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
61 }
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
62
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
63 CONFIRM = D_("{peer} wants to start a call ({call_type}) with you, do you accept?")
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
64 CONFIRM_TITLE = D_("Incoming Call")
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
65 SECURITY_LIMIT = 0
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
66
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
67 ALLOWED_ACTIONS = (
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
68 "active",
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
69 "hold",
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
70 "unhold",
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
71 "mute",
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
72 "unmute",
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
73 "ringing",
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
74 )
4240
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
75 ANSWER_SDP_SENT_KEY = "answer_sdp_sent"
4056
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
76
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
77
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
78 class XEP_0167(BaseApplicationHandler):
4240
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
79 namespace = NS_JINGLE_RTP
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
80
4056
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
81 def __init__(self, host):
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
82 log.info(f'Plugin "{PLUGIN_INFO[C.PI_NAME]}" initialization')
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
83 self.host = host
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
84 # FIXME: to be removed once host is accessible from global var
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
85 mapping.host = host
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
86 self._j = host.plugins["XEP-0166"]
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
87 self._j.register_application(NS_JINGLE_RTP, self)
4231
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4120
diff changeset
88 host.register_namespace("jingle-rtp", NS_JINGLE_RTP)
4056
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
89 host.bridge.add_method(
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
90 "call_start",
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
91 ".plugin",
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
92 in_sign="sss",
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
93 out_sign="s",
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
94 method=self._call_start,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
95 async_=True,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
96 )
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
97 host.bridge.add_method(
4291
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
98 "call_update",
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
99 ".plugin",
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
100 in_sign="sss",
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
101 out_sign="",
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
102 method=self._call_update,
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
103 async_=True,
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
104 )
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
105 host.bridge.add_method(
4112
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
106 "call_answer_sdp",
4070
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
107 ".plugin",
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
108 in_sign="sss",
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
109 out_sign="",
4112
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
110 method=self._call_answer_sdp,
4291
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
111 async_=False,
4070
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
112 )
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
113 host.bridge.add_method(
4056
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
114 "call_info",
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
115 ".plugin",
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
116 in_sign="ssss",
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
117 out_sign="",
4112
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
118 method=self._call_info,
4056
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
119 )
4112
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
120 host.bridge.add_method(
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
121 "call_end",
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
122 ".plugin",
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
123 in_sign="sss",
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
124 out_sign="",
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
125 method=self._call_end,
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
126 async_=True,
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
127 )
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
128
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
129 # args: session_id, serialised setup data (dict with keys "role" and "sdp"),
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
130 # profile
4116
23fa52acf72c plugin XEP-0167, XEP-0176: transport-info and ICE candidate sending are delayed if session is not active yet
Goffi <goffi@goffi.org>
parents: 4115
diff changeset
131 host.bridge.add_signal("call_setup", ".plugin", signature="sss")
4112
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
132
4291
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
133 # args: session_id, serialised update data, profile
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
134 host.bridge.add_signal("call_update", ".plugin", signature="sss")
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
135
4112
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
136 # args: session_id, data, profile
4116
23fa52acf72c plugin XEP-0167, XEP-0176: transport-info and ICE candidate sending are delayed if session is not active yet
Goffi <goffi@goffi.org>
parents: 4115
diff changeset
137 host.bridge.add_signal("call_ended", ".plugin", signature="sss")
4112
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
138
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
139 # args: session_id, info_type, extra, profile
4116
23fa52acf72c plugin XEP-0167, XEP-0176: transport-info and ICE candidate sending are delayed if session is not active yet
Goffi <goffi@goffi.org>
parents: 4115
diff changeset
140 host.bridge.add_signal("call_info", ".plugin", signature="ssss")
4056
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
141
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
142 def get_handler(self, client):
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
143 return XEP_0167_handler()
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
144
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
145 # bridge methods
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
146
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
147 def _call_start(
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
148 self,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
149 entity_s: str,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
150 call_data_s: str,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
151 profile_key: str,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
152 ):
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
153 client = self.host.get_client(profile_key)
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
154 return defer.ensureDeferred(
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
155 self.call_start(
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
156 client, jid.JID(entity_s), data_format.deserialise(call_data_s)
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
157 )
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
158 )
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
159
4291
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
160 def _call_update(
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
161 self,
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
162 session_id: str,
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
163 call_data_s: str,
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
164 profile_key: str,
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
165 ):
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
166 client = self.host.get_client(profile_key)
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
167 return defer.ensureDeferred(
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
168 self.call_update(client, session_id, data_format.deserialise(call_data_s))
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
169 )
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
170
4231
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4120
diff changeset
171 def parse_call_data(self, call_data: dict) -> dict:
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4120
diff changeset
172 """Parse ``call_data`` and return corresponding contents end metadata"""
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4120
diff changeset
173 metadata = call_data.get("metadata") or {}
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4120
diff changeset
174
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4120
diff changeset
175 if "sdp" in call_data:
4240
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
176 sdp_data = mapping.parse_sdp(call_data["sdp"], self._j.ROLE_INITIATOR)
4231
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4120
diff changeset
177 to_delete = set()
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4120
diff changeset
178 for media, data in sdp_data.items():
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4120
diff changeset
179 if media not in ("audio", "video", "application"):
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4120
diff changeset
180 continue
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4120
diff changeset
181 to_delete.add(media)
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4120
diff changeset
182 media_type, media_data = media, data
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4120
diff changeset
183 call_data[media_type] = media_data["application_data"]
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4120
diff changeset
184 transport_data = media_data["transport_data"]
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4120
diff changeset
185 try:
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4120
diff changeset
186 call_data[media_type]["fingerprint"] = transport_data["fingerprint"]
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4120
diff changeset
187 except KeyError:
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4120
diff changeset
188 log.warning("fingerprint is missing")
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4120
diff changeset
189 pass
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4120
diff changeset
190 try:
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4120
diff changeset
191 call_data[media_type]["id"] = media_data["id"]
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4120
diff changeset
192 except KeyError:
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4120
diff changeset
193 log.warning(f"no media ID found for {media_type}: {media_data}")
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4120
diff changeset
194 # FIXME: the 2 values below are linked to XEP-0343, they should be added
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4120
diff changeset
195 # there instead, maybe with some new trigger?
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4245
diff changeset
196 for key in ("sctp-port", "max-message-size"):
4231
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4120
diff changeset
197 value = transport_data.get(key)
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4120
diff changeset
198 if value is not None:
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4120
diff changeset
199 metadata[key] = value
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4120
diff changeset
200 try:
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4120
diff changeset
201 call_data[media_type]["ice-candidates"] = transport_data.get(
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4120
diff changeset
202 "candidates", []
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4120
diff changeset
203 )
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4120
diff changeset
204 metadata["ice-ufrag"] = transport_data["ufrag"]
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4120
diff changeset
205 metadata["ice-pwd"] = transport_data["pwd"]
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4120
diff changeset
206 except KeyError:
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4120
diff changeset
207 log.warning("ICE data are missing from SDP")
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4120
diff changeset
208 continue
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4120
diff changeset
209 for media in to_delete:
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4120
diff changeset
210 del sdp_data[media]
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4120
diff changeset
211 metadata.update(sdp_data.get("metadata", {}))
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4120
diff changeset
212
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4120
diff changeset
213 return metadata
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4120
diff changeset
214
4240
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
215 def get_contents(self, call_data: dict, metadata: dict) -> list[dict]:
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
216 """Generate call related contents.
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
217
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
218 @param call_data: Call data after being parsed by [parse_call_data]
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
219 @param metadata: Metadata as returned by [parse_call_data]
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
220 @return: List of contents to be used with [jingle.initiate].
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
221
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
222 """
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
223 contents = []
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
224 seen_names = set()
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
225
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
226 for media, media_data in call_data.items():
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
227 if media not in ("audio", "video"):
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
228 continue
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
229 content = {
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
230 "app_ns": NS_JINGLE_RTP,
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
231 "senders": media_data["senders"],
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
232 "transport_type": self._j.TRANSPORT_DATAGRAM,
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
233 "app_kwargs": {"media": media, "media_data": media_data},
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
234 "transport_data": {
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
235 "local_ice_data": {
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
236 "ufrag": metadata["ice-ufrag"],
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
237 "pwd": metadata["ice-pwd"],
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
238 "candidates": media_data.pop("ice-candidates"),
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
239 "fingerprint": media_data.pop("fingerprint", {}),
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
240 }
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
241 },
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
242 }
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
243 if "id" in media_data:
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
244 name = media_data.pop("id")
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
245 if name in seen_names:
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
246 raise exceptions.DataError(
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
247 f"Content name (mid) seen multiple times: {name}"
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
248 )
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
249 content["name"] = name
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
250 contents.append(content)
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
251 return contents
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
252
4056
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
253 async def call_start(
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
254 self,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
255 client: SatXMPPEntity,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
256 peer_jid: jid.JID,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
257 call_data: dict,
4291
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
258 session_id: str | None = None,
4112
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
259 ) -> str:
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
260 """Initiate a call session with the given peer.
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
261
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
262 @param peer_jid: JID of the peer to initiate a call session with.
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
263 @param call_data: Dictionary containing data for the call. Must include SDP information.
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
264 The dict can have the following keys:
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
265 - sdp (str): SDP data for the call.
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
266 - metadata (dict): Additional metadata for the call (optional).
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
267 Each media type ("audio" and "video") in the SDP should have:
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
268 - application_data (dict): Data about the media.
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
269 - fingerprint (str): Security fingerprint data (optional).
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
270 - id (str): Identifier for the media (optional).
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
271 - ice-candidates: ICE candidates for media transport.
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
272 - And other transport specific data.
4291
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
273 @param session_id: ID of the Jingle session. If None, an ID will be automatically
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
274 generated.
4112
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
275
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
276 @return: Session ID (SID) for the initiated call session.
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
277
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
278 @raises exceptions.DataError: If media data is invalid or duplicate content name
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
279 (mid) is found.
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
280 """
4231
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4120
diff changeset
281 metadata = self.parse_call_data(call_data)
4240
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
282 contents = self.get_contents(call_data, metadata)
4056
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
283 if not contents:
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
284 raise exceptions.DataError("no valid media data found: {call_data}")
4231
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4120
diff changeset
285
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4120
diff changeset
286 call_type = (
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4245
diff changeset
287 C.META_SUBTYPE_CALL_VIDEO
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4245
diff changeset
288 if "video" in call_data
4231
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4120
diff changeset
289 else C.META_SUBTYPE_CALL_AUDIO
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4120
diff changeset
290 )
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4120
diff changeset
291
4240
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
292 sid = await self._j.initiate(
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4245
diff changeset
293 client,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4245
diff changeset
294 peer_jid,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4245
diff changeset
295 contents,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4245
diff changeset
296 call_type=call_type,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4245
diff changeset
297 metadata=metadata,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4245
diff changeset
298 peer_metadata={},
4291
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
299 sid=session_id,
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4245
diff changeset
300 )
4112
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
301 return sid
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
302
4291
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
303 async def call_update(
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
304 self,
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
305 client: SatXMPPEntity,
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
306 session_id: str,
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
307 call_data: dict,
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
308 ) -> None:
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
309 """Update a running call session.
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
310
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
311 @param session_id: ID of the Jingle session to update.
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
312 @param call_data: Dictionary containing updated data for the call. Must include SDP information.
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
313 The dict can have the following keys:
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
314 - sdp (str): SDP data for the call.
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
315 - metadata (dict): Additional metadata for the call (optional).
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
316 Each media type ("audio" and "video") in the SDP should have:
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
317 - application_data (dict): Data about the media.
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
318 - fingerprint (str): Security fingerprint data (optional).
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
319 - id (str): Identifier for the media (optional).
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
320 - ice-candidates: ICE candidates for media transport.
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
321 - And other transport specific data.
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
322
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
323
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
324 @raises exceptions.DataError: If media data is invalid or duplicate content name
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
325 (mid) is found.
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
326 """
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
327 session = self._j.get_session(client, session_id)
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
328 try:
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
329 new_offer_sdp = call_data["sdp"]
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
330 except KeyError:
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
331 raise exceptions.DataError(f"New SDP offer is missing: {call_data}")
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
332 metadata = self.parse_call_data(call_data)
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
333 contents = self.get_contents(call_data, metadata)
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
334 if not contents:
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
335 raise exceptions.DataError("no valid media data found: {call_data}")
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
336
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
337 call_type = (
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
338 C.META_SUBTYPE_CALL_VIDEO
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
339 if "video" in call_data
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
340 else C.META_SUBTYPE_CALL_AUDIO
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
341 )
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
342 for content_args in contents:
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
343 content = content_args["app_kwargs"]
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
344 content["app_ns"] = NS_JINGLE_RTP
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
345 content["name"] = (content_args["name"],)
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
346 content["transport_type"] = self._j.TRANSPORT_DATAGRAM
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
347 media = content["media"]
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
348 media_data = content["media_data"].copy()
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
349 media_data["transport_data"] = content_args["transport_data"][
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
350 "local_ice_data"
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
351 ]
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
352 desc_elt = mapping.build_description(media, media_data, {})
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
353 iq_elt, __ = self._j.build_action(
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
354 client,
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
355 self._j.A_CONTENT_ADD,
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
356 session,
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
357 content_args["name"],
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
358 context_elt=desc_elt,
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
359 )
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
360 content_data = self._j.get_content_data(content)
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
361 transport = self._j.get_transport(client, content, content_data)
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
362 transport_elt = transport.handler.build_transport(
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
363 media_data["transport_data"]
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
364 )
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
365 iq_elt.jingle.content.addChild(transport_elt)
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
366 await iq_elt.send()
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
367
4116
23fa52acf72c plugin XEP-0167, XEP-0176: transport-info and ICE candidate sending are delayed if session is not active yet
Goffi <goffi@goffi.org>
parents: 4115
diff changeset
368 def _call_answer_sdp(self, session_id: str, answer_sdp: str, profile: str) -> None:
4112
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
369 client = self.host.get_client(profile)
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
370 session = self._j.get_session(client, session_id)
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
371 try:
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
372 answer_sdp_d = session.pop("answer_sdp_d")
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
373 except KeyError:
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
374 raise exceptions.NotFound(
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
375 f"No answer SDP expected for session {session_id!r}"
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
376 )
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
377 answer_sdp_d.callback(answer_sdp)
4056
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
378
4070
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
379 def _call_end(
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
380 self,
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
381 session_id: str,
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
382 data_s: str,
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
383 profile_key: str,
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
384 ):
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
385 client = self.host.get_client(profile_key)
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
386 return defer.ensureDeferred(
4116
23fa52acf72c plugin XEP-0167, XEP-0176: transport-info and ICE candidate sending are delayed if session is not active yet
Goffi <goffi@goffi.org>
parents: 4115
diff changeset
387 self.call_end(client, session_id, data_format.deserialise(data_s))
4070
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
388 )
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
389
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
390 async def call_end(
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
391 self,
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
392 client: SatXMPPEntity,
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
393 session_id: str,
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
394 data: dict,
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
395 ) -> None:
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
396 """End a call
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
397
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
398 @param session_id: Jingle session ID of the call
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
399 @param data: optional extra data, may be used to indicate the reason to end the
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
400 call
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
401 """
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
402 session = self._j.get_session(client, session_id)
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
403 await self._j.terminate(client, self._j.REASON_SUCCESS, session)
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
404
4056
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
405 # jingle callbacks
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
406
4112
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
407 async def confirm_incoming_call(
4116
23fa52acf72c plugin XEP-0167, XEP-0176: transport-info and ICE candidate sending are delayed if session is not active yet
Goffi <goffi@goffi.org>
parents: 4115
diff changeset
408 self, client: SatXMPPEntity, session: dict, call_type: str
4112
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
409 ) -> bool:
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
410 """Prompt the user for a call confirmation.
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
411
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
412 @param client: The client entity.
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
413 @param session: The Jingle session.
4231
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4120
diff changeset
414 @param call_type: Type of media (audio or video).
4112
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
415
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
416 @return: True if the call has been accepted
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
417 """
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
418 peer_jid = session["peer_jid"]
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
419
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
420 session["call_type"] = call_type
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
421 cancellable_deferred = session.setdefault("cancellable_deferred", [])
4294
a0ed5c976bf8 component conferences, plugin XEP-0167, XEP-0298: add stream user metadata:
Goffi <goffi@goffi.org>
parents: 4291
diff changeset
422 action_extra = {
a0ed5c976bf8 component conferences, plugin XEP-0167, XEP-0298: add stream user metadata:
Goffi <goffi@goffi.org>
parents: 4291
diff changeset
423 "session_id": session["id"],
a0ed5c976bf8 component conferences, plugin XEP-0167, XEP-0298: add stream user metadata:
Goffi <goffi@goffi.org>
parents: 4291
diff changeset
424 "from_jid": peer_jid.full(),
a0ed5c976bf8 component conferences, plugin XEP-0167, XEP-0298: add stream user metadata:
Goffi <goffi@goffi.org>
parents: 4291
diff changeset
425 "type": C.META_TYPE_CALL,
a0ed5c976bf8 component conferences, plugin XEP-0167, XEP-0298: add stream user metadata:
Goffi <goffi@goffi.org>
parents: 4291
diff changeset
426 "sub_type": call_type,
a0ed5c976bf8 component conferences, plugin XEP-0167, XEP-0298: add stream user metadata:
Goffi <goffi@goffi.org>
parents: 4291
diff changeset
427 }
a0ed5c976bf8 component conferences, plugin XEP-0167, XEP-0298: add stream user metadata:
Goffi <goffi@goffi.org>
parents: 4291
diff changeset
428 try:
a0ed5c976bf8 component conferences, plugin XEP-0167, XEP-0298: add stream user metadata:
Goffi <goffi@goffi.org>
parents: 4291
diff changeset
429 action_extra["metadata"] = {"user": session["metadata"]["peer_user"].full()}
a0ed5c976bf8 component conferences, plugin XEP-0167, XEP-0298: add stream user metadata:
Goffi <goffi@goffi.org>
parents: 4291
diff changeset
430 except KeyError:
a0ed5c976bf8 component conferences, plugin XEP-0167, XEP-0298: add stream user metadata:
Goffi <goffi@goffi.org>
parents: 4291
diff changeset
431 pass
4112
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
432
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
433 dialog_d = xml_tools.defer_dialog(
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
434 self.host,
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
435 _(CONFIRM).format(peer=peer_jid.userhost(), call_type=call_type),
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
436 _(CONFIRM_TITLE),
4294
a0ed5c976bf8 component conferences, plugin XEP-0167, XEP-0298: add stream user metadata:
Goffi <goffi@goffi.org>
parents: 4291
diff changeset
437 action_extra=action_extra,
4112
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
438 security_limit=SECURITY_LIMIT,
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
439 profile=client.profile,
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
440 )
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
441
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
442 cancellable_deferred.append(dialog_d)
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
443
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
444 resp_data = await dialog_d
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
445
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
446 accepted = not resp_data.get("cancelled", False)
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
447
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
448 if accepted:
4240
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
449 session["pre_accepted"] = True
4112
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
450
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
451 return accepted
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
452
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
453 async def jingle_preflight(
4116
23fa52acf72c plugin XEP-0167, XEP-0176: transport-info and ICE candidate sending are delayed if session is not active yet
Goffi <goffi@goffi.org>
parents: 4115
diff changeset
454 self, client: SatXMPPEntity, session: dict, description_elt: domish.Element
4112
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
455 ) -> None:
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
456 """Perform preflight checks for an incoming call session.
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
457
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
458 Check if the calls is audio only or audio/video, then, prompts the user for
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
459 confirmation.
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
460
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
461 @param client: The client instance.
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
462 @param session: Jingle session.
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
463 @param description_elt: The description element. It's parent attribute is used to
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
464 determine check siblings to see if it's an audio only or audio/video call.
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
465
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
466 @raises exceptions.CancelError: If the user doesn't accept the incoming call.
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
467 """
4240
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
468 if session.get("pre_accepted", False):
4112
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
469 # the call is already accepted, nothing to do
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
470 return
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
471
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
472 parent_elt = description_elt.parent
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
473 assert parent_elt is not None
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
474
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
475 assert description_elt.parent is not None
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
476 for desc_elt in parent_elt.elements(NS_JINGLE_RTP, "description"):
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
477 if desc_elt.getAttribute("media") == "video":
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
478 call_type = C.META_SUBTYPE_CALL_VIDEO
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
479 break
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
480 else:
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
481 call_type = C.META_SUBTYPE_CALL_AUDIO
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
482
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
483 try:
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
484 accepted = await self.confirm_incoming_call(client, session, call_type)
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
485 except defer.CancelledError as e:
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
486 # raised when call is retracted before user has answered or rejected
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
487 self.host.bridge.call_ended(
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
488 session["id"],
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
489 data_format.serialise({"reason": "retracted"}),
4116
23fa52acf72c plugin XEP-0167, XEP-0176: transport-info and ICE candidate sending are delayed if session is not active yet
Goffi <goffi@goffi.org>
parents: 4115
diff changeset
490 client.profile,
4112
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
491 )
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
492 raise e
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
493
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
494 if not accepted:
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
495 raise exceptions.CancelError("User declined the incoming call.")
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
496
4115
0da563780ffc plugin XEP-0167, XEP-0353: handle ringing:
Goffi <goffi@goffi.org>
parents: 4112
diff changeset
497 async def jingle_preflight_info(
0da563780ffc plugin XEP-0167, XEP-0353: handle ringing:
Goffi <goffi@goffi.org>
parents: 4112
diff changeset
498 self,
0da563780ffc plugin XEP-0167, XEP-0353: handle ringing:
Goffi <goffi@goffi.org>
parents: 4112
diff changeset
499 client: SatXMPPEntity,
0da563780ffc plugin XEP-0167, XEP-0353: handle ringing:
Goffi <goffi@goffi.org>
parents: 4112
diff changeset
500 session: dict,
0da563780ffc plugin XEP-0167, XEP-0353: handle ringing:
Goffi <goffi@goffi.org>
parents: 4112
diff changeset
501 info_type: str,
4116
23fa52acf72c plugin XEP-0167, XEP-0176: transport-info and ICE candidate sending are delayed if session is not active yet
Goffi <goffi@goffi.org>
parents: 4115
diff changeset
502 info_data: dict | None = None,
4115
0da563780ffc plugin XEP-0167, XEP-0353: handle ringing:
Goffi <goffi@goffi.org>
parents: 4112
diff changeset
503 ) -> None:
0da563780ffc plugin XEP-0167, XEP-0353: handle ringing:
Goffi <goffi@goffi.org>
parents: 4112
diff changeset
504 if info_type == "ringing":
0da563780ffc plugin XEP-0167, XEP-0353: handle ringing:
Goffi <goffi@goffi.org>
parents: 4112
diff changeset
505 if not session.get("ringing", False):
4116
23fa52acf72c plugin XEP-0167, XEP-0176: transport-info and ICE candidate sending are delayed if session is not active yet
Goffi <goffi@goffi.org>
parents: 4115
diff changeset
506 self.host.bridge.call_info(session["id"], "ringing", "", client.profile)
4115
0da563780ffc plugin XEP-0167, XEP-0353: handle ringing:
Goffi <goffi@goffi.org>
parents: 4112
diff changeset
507 # we indicate that the ringing has started, to avoid sending several times
0da563780ffc plugin XEP-0167, XEP-0353: handle ringing:
Goffi <goffi@goffi.org>
parents: 4112
diff changeset
508 # the signal
0da563780ffc plugin XEP-0167, XEP-0353: handle ringing:
Goffi <goffi@goffi.org>
parents: 4112
diff changeset
509 session["ringing"] = True
0da563780ffc plugin XEP-0167, XEP-0353: handle ringing:
Goffi <goffi@goffi.org>
parents: 4112
diff changeset
510 else:
0da563780ffc plugin XEP-0167, XEP-0353: handle ringing:
Goffi <goffi@goffi.org>
parents: 4112
diff changeset
511 log.warning(f"Unknown preflight info type: {info_type!r}")
0da563780ffc plugin XEP-0167, XEP-0353: handle ringing:
Goffi <goffi@goffi.org>
parents: 4112
diff changeset
512
4112
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
513 async def jingle_preflight_cancel(
4116
23fa52acf72c plugin XEP-0167, XEP-0176: transport-info and ICE candidate sending are delayed if session is not active yet
Goffi <goffi@goffi.org>
parents: 4115
diff changeset
514 self, client: SatXMPPEntity, session: dict, cancel_error: exceptions.CancelError
4112
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
515 ) -> None:
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
516 """The call has been rejected"""
4231
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4120
diff changeset
517 # call_ended is used to send the signal only once even if there are audio and
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4120
diff changeset
518 # video contents
4112
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
519 call_ended = session.get("call_ended", False)
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
520 if call_ended:
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
521 return
4231
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4120
diff changeset
522 data = {"reason": getattr(cancel_error, "reason", None) or "cancelled"}
e11b13418ba6 plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation:
Goffi <goffi@goffi.org>
parents: 4120
diff changeset
523 data["text"] = str(cancel_error)
4112
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
524 self.host.bridge.call_ended(
4116
23fa52acf72c plugin XEP-0167, XEP-0176: transport-info and ICE candidate sending are delayed if session is not active yet
Goffi <goffi@goffi.org>
parents: 4115
diff changeset
525 session["id"], data_format.serialise(data), client.profile
4112
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
526 )
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
527 session["call_ended"] = True
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
528
4056
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
529 def jingle_session_init(
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
530 self,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
531 client: SatXMPPEntity,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
532 session: dict,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
533 content_name: str,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
534 media: str,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
535 media_data: dict,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
536 ) -> domish.Element:
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
537 if media not in ("audio", "video"):
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
538 raise ValueError('only "audio" and "video" media types are supported')
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
539 content_data = session["contents"][content_name]
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
540 application_data = content_data["application_data"]
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
541 application_data["media"] = media
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
542 application_data["local_data"] = media_data
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
543 desc_elt = mapping.build_description(media, media_data, session)
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
544 self.host.trigger.point(
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
545 "XEP-0167_jingle_session_init",
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
546 client,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
547 session,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
548 content_name,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
549 media,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
550 media_data,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
551 desc_elt,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
552 triggers_no_cancel=True,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
553 )
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
554 return desc_elt
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
555
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
556 async def jingle_request_confirmation(
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
557 self,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
558 client: SatXMPPEntity,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
559 action: str,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
560 session: dict,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
561 content_name: str,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
562 desc_elt: domish.Element,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
563 ) -> bool:
4112
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
564 """Requests confirmation from the user for a Jingle session's incoming call.
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
565
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
566 This method checks the content type of the Jingle session (audio or video)
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
567 based on the session's contents. Confirmation is requested only for the first
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
568 content; subsequent contents are automatically accepted. This means, in practice,
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
569 that the call confirmation is prompted only once for both audio and video contents.
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
570
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
571 @param client: The client instance.
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
572 @param action: The action type associated with the Jingle session.
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
573 @param session: Jingle session.
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
574 @param content_name: Name of the content being checked.
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
575 @param desc_elt: The description element associated with the content.
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
576
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
577 @return: True if the call is accepted by the user, False otherwise.
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
578 """
4056
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
579 if content_name != next(iter(session["contents"])):
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
580 # we request confirmation only for the first content, all others are
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
581 # automatically accepted. In practice, that means that the call confirmation
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
582 # is requested only once for audio and video contents.
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
583 return True
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
584
4240
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
585 if not session.get("pre_accepted", False):
4112
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
586 if any(
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
587 c["desc_elt"].getAttribute("media") == "video"
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
588 for c in session["contents"].values()
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
589 ):
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
590 call_type = session["call_type"] = C.META_SUBTYPE_CALL_VIDEO
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
591 else:
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
592 call_type = session["call_type"] = C.META_SUBTYPE_CALL_AUDIO
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
593
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
594 accepted = await self.confirm_incoming_call(client, session, call_type)
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
595 if not accepted:
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
596 return False
4056
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
597
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
598 sdp = mapping.generate_sdp_from_session(session)
4112
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
599 session["answer_sdp_d"] = answer_sdp_d = defer.Deferred()
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
600 # we should have the answer long before 2 min
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
601 answer_sdp_d.addTimeout(2 * 60, reactor)
4056
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
602
4277
b4b4ea8c5c87 plugin XEP-0167: Let use a `call_setup_cb` method in session:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
603 call_setup = session.get("call_setup_cb")
4294
a0ed5c976bf8 component conferences, plugin XEP-0167, XEP-0298: add stream user metadata:
Goffi <goffi@goffi.org>
parents: 4291
diff changeset
604 call_data = {
a0ed5c976bf8 component conferences, plugin XEP-0167, XEP-0298: add stream user metadata:
Goffi <goffi@goffi.org>
parents: 4291
diff changeset
605 "role": session["role"],
a0ed5c976bf8 component conferences, plugin XEP-0167, XEP-0298: add stream user metadata:
Goffi <goffi@goffi.org>
parents: 4291
diff changeset
606 "sdp": sdp,
a0ed5c976bf8 component conferences, plugin XEP-0167, XEP-0298: add stream user metadata:
Goffi <goffi@goffi.org>
parents: 4291
diff changeset
607 }
4277
b4b4ea8c5c87 plugin XEP-0167: Let use a `call_setup_cb` method in session:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
608
b4b4ea8c5c87 plugin XEP-0167: Let use a `call_setup_cb` method in session:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
609 if call_setup is None:
b4b4ea8c5c87 plugin XEP-0167: Let use a `call_setup_cb` method in session:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
610 self.host.bridge.call_setup(
b4b4ea8c5c87 plugin XEP-0167: Let use a `call_setup_cb` method in session:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
611 session["id"],
4294
a0ed5c976bf8 component conferences, plugin XEP-0167, XEP-0298: add stream user metadata:
Goffi <goffi@goffi.org>
parents: 4291
diff changeset
612 data_format.serialise(call_data),
4277
b4b4ea8c5c87 plugin XEP-0167: Let use a `call_setup_cb` method in session:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
613 client.profile,
b4b4ea8c5c87 plugin XEP-0167: Let use a `call_setup_cb` method in session:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
614 )
b4b4ea8c5c87 plugin XEP-0167: Let use a `call_setup_cb` method in session:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
615 else:
b4b4ea8c5c87 plugin XEP-0167: Let use a `call_setup_cb` method in session:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
616 await call_setup(
b4b4ea8c5c87 plugin XEP-0167: Let use a `call_setup_cb` method in session:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
617 client,
b4b4ea8c5c87 plugin XEP-0167: Let use a `call_setup_cb` method in session:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
618 session,
4294
a0ed5c976bf8 component conferences, plugin XEP-0167, XEP-0298: add stream user metadata:
Goffi <goffi@goffi.org>
parents: 4291
diff changeset
619 call_data,
4277
b4b4ea8c5c87 plugin XEP-0167: Let use a `call_setup_cb` method in session:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
620 )
4056
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
621
4112
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
622 answer_sdp = await answer_sdp_d
4240
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
623 parsed_answer = mapping.parse_sdp(answer_sdp, session["role"])
4119
ece304ec7077 plugin XEP-0167: fix key used to store metadata:
Goffi <goffi@goffi.org>
parents: 4118
diff changeset
624 session["metadata"].update(parsed_answer["metadata"])
4240
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
625 self.propagate_data(session, parsed_answer)
4056
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
626
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
627 return True
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
628
4240
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
629 def propagate_data(self, session: dict, parsed_answer: dict) -> None:
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
630 """Propagate local SDP data to other contents"""
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
631 for media in ("audio", "video", "application"):
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
632 for content in session["contents"].values():
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
633 try:
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
634 application_data = content["application_data"]
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
635 content_media = application_data["media"]
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
636 except KeyError:
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
637 pass
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
638 else:
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
639 if content_media == media:
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
640 media_data = parsed_answer[media]
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
641 application_data["local_data"] = media_data["application_data"]
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
642 transport_data = content["transport_data"]
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
643 local_ice_data = media_data["transport_data"]
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
644 transport_data["local_ice_data"] = local_ice_data
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
645
4291
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
646 async def send_answer_sdp(self, client: SatXMPPEntity, session: dict) -> None:
4240
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
647 """Send answer SDP to frontend"""
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
648 if not session.get(ANSWER_SDP_SENT_KEY, False):
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
649 # we only send the signal once, as it means that the whole session is
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
650 # accepted
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
651 answer_sdp = mapping.generate_sdp_from_session(session)
4291
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
652
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
653 call_setup = session.get("call_setup_cb")
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
654
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
655 if call_setup is None:
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
656 self.host.bridge.call_setup(
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
657 session["id"],
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
658 data_format.serialise(
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
659 {
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
660 "role": session["role"],
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
661 "sdp": answer_sdp,
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
662 }
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
663 ),
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
664 client.profile,
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
665 )
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
666 else:
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
667 await call_setup(
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
668 client,
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
669 session,
4240
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
670 {
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
671 "role": session["role"],
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
672 "sdp": answer_sdp,
4291
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
673 },
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
674 )
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
675
4240
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
676 session[ANSWER_SDP_SENT_KEY] = True
79c8a70e1813 backend, frontend: prepare remote control:
Goffi <goffi@goffi.org>
parents: 4231
diff changeset
677
4056
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
678 async def jingle_handler(self, client, action, session, content_name, desc_elt):
4291
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
679 if action == self._j.A_CONTENT_ADD:
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
680 content_data = session["contents_new"][content_name]
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
681 else:
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
682 content_data = session["contents"][content_name]
4056
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
683 application_data = content_data["application_data"]
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
684 if action == self._j.A_PREPARE_CONFIRMATION:
4294
a0ed5c976bf8 component conferences, plugin XEP-0167, XEP-0298: add stream user metadata:
Goffi <goffi@goffi.org>
parents: 4291
diff changeset
685 session.setdefault("metadata", {})
4120
832a7bdb3aea plugin XEP-0167: don't override existing metadata when preparing confirmation:
Goffi <goffi@goffi.org>
parents: 4119
diff changeset
686 session.setdefault("peer_metadata", {})
4056
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
687 try:
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
688 media = application_data["media"] = desc_elt["media"]
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
689 except KeyError:
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
690 raise exceptions.DataError('"media" key is missing in {desc_elt.toXml()}')
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
691 if media not in ("audio", "video"):
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
692 raise exceptions.DataError(f"invalid media: {media!r}")
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
693 application_data["peer_data"] = mapping.parse_description(desc_elt)
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
694 elif action == self._j.A_SESSION_INITIATE:
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
695 application_data["peer_data"] = mapping.parse_description(desc_elt)
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
696 desc_elt = mapping.build_description(
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
697 application_data["media"], application_data["local_data"], session
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
698 )
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
699 elif action == self._j.A_ACCEPTED_ACK:
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
700 pass
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
701 elif action == self._j.A_PREPARE_INITIATOR:
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
702 application_data["peer_data"] = mapping.parse_description(desc_elt)
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
703 elif action == self._j.A_SESSION_ACCEPT:
4291
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
704 await self.send_answer_sdp(client, session)
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
705 elif action == self._j.A_CONTENT_ADD:
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
706 current_contents = session["contents"]
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
707 if content_name in current_contents:
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
708 raise exceptions.ConflictError(
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
709 f"There is already a {content_name!r} content."
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
710 )
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
711 current_contents[content_name] = content_data
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
712 application_data["media"] = desc_elt["media"]
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
713 application_data["peer_data"] = mapping.parse_description(desc_elt)
4056
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
714 else:
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
715 log.warning(f"FIXME: unmanaged action {action}")
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
716
4277
b4b4ea8c5c87 plugin XEP-0167: Let use a `call_setup_cb` method in session:
Goffi <goffi@goffi.org>
parents: 4270
diff changeset
717 await self.host.trigger.async_point(
4056
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
718 "XEP-0167_jingle_handler",
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
719 client,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
720 action,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
721 session,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
722 content_name,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
723 desc_elt,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
724 triggers_no_cancel=True,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
725 )
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
726 return desc_elt
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
727
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
728 def jingle_session_info(
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
729 self,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
730 client: SatXMPPEntity,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
731 action: str,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
732 session: dict,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
733 content_name: str,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
734 jingle_elt: domish.Element,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
735 ) -> None:
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
736 """Informational messages"""
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
737 for elt in jingle_elt.elements():
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
738 if elt.uri == NS_JINGLE_RTP_INFO:
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
739 info_type = elt.name
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
740 if info_type not in ALLOWED_ACTIONS:
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
741 log.warning("ignoring unknow info type: {info_type!r}")
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
742 continue
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
743 extra = {}
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
744 if info_type in ("mute", "unmute"):
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
745 name = elt.getAttribute("name")
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
746 if name:
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
747 extra["name"] = name
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
748 log.debug(f"{info_type} call info received (extra: {extra})")
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
749 self.host.bridge.call_info(
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
750 session["id"], info_type, data_format.serialise(extra), client.profile
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
751 )
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
752
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
753 def _call_info(self, session_id, info_type, extra_s, profile_key):
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
754 client = self.host.get_client(profile_key)
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
755 extra = data_format.deserialise(extra_s)
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
756 return self.send_info(client, session_id, info_type, extra)
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
757
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
758 def send_info(
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
759 self,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
760 client: SatXMPPEntity,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
761 session_id: str,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
762 info_type: str,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
763 extra: Optional[dict],
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
764 ) -> None:
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
765 """Send information on the call"""
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
766 if info_type not in ALLOWED_ACTIONS:
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
767 raise ValueError(f"Unkown info type {info_type!r}")
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
768 session = self._j.get_session(client, session_id)
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
769 iq_elt, jingle_elt = self._j.build_session_info(client, session)
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
770 info_elt = jingle_elt.addElement((NS_JINGLE_RTP_INFO, info_type))
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
771 if extra and info_type in ("mute", "unmute") and "name" in extra:
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
772 info_elt["name"] = extra["name"]
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
773 iq_elt.send()
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
774
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
775 def jingle_terminate(
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
776 self,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
777 client: SatXMPPEntity,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
778 action: str,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
779 session: dict,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
780 content_name: str,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
781 reason_elt: domish.Element,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
782 ) -> None:
4112
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
783 reason, text = self._j.parse_reason_elt(reason_elt)
4116
23fa52acf72c plugin XEP-0167, XEP-0176: transport-info and ICE candidate sending are delayed if session is not active yet
Goffi <goffi@goffi.org>
parents: 4115
diff changeset
784 data = {"reason": reason}
4112
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
785 if text:
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
786 data["text"] = text
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
787 self.host.bridge.call_ended(
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
788 session["id"], data_format.serialise(data), client.profile
bc60875cb3b8 plugin XEP-0166, XEP-0167, XEP-0234, XEP-0353: call events management to prepare for UI:
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
789 )
4056
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
790
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
791
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
792 @implementer(iwokkel.IDisco)
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
793 class XEP_0167_handler(XMPPHandler):
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
794 def getDiscoInfo(self, requestor, target, nodeIdentifier=""):
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
795 return [
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
796 disco.DiscoFeature(NS_JINGLE_RTP),
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
797 disco.DiscoFeature(NS_JINGLE_RTP_AUDIO),
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
798 disco.DiscoFeature(NS_JINGLE_RTP_VIDEO),
4291
39ac821ebbdb plugin XEP-0167: handle conferences:
Goffi <goffi@goffi.org>
parents: 4286
diff changeset
799 disco.DiscoFeature(NS_AV_CONFERENCES),
4056
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
800 ]
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
801
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
802 def getDiscoItems(self, requestor, target, nodeIdentifier=""):
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
803 return []