annotate libervia/backend/plugins/plugin_xep_0167/__init__.py @ 4091:4eb7a5ecbd9d

build: explicitely set `packages` so `doc` is not accidentaly included
author Goffi <goffi@goffi.org>
date Thu, 08 Jun 2023 21:30:57 +0200
parents 4b842c1fb686
children bc60875cb3b8
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
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
21 from twisted.internet import defer
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
22 from twisted.words.protocols.jabber import jid
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
23 from twisted.words.protocols.jabber.xmlstream import XMPPHandler
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
24 from twisted.words.xish import domish
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
25 from wokkel import disco, iwokkel
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
26 from zope.interface import implementer
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
27
4071
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4070
diff changeset
28 from libervia.backend.core import exceptions
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4070
diff changeset
29 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
30 from libervia.backend.core.core_types import SatXMPPEntity
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4070
diff changeset
31 from libervia.backend.core.i18n import D_, _
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4070
diff changeset
32 from libervia.backend.core.log import getLogger
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4070
diff changeset
33 from libervia.backend.tools import xml_tools
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4070
diff changeset
34 from libervia.backend.tools.common import data_format
4056
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
35
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
36 from . import mapping
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
37 from ..plugin_xep_0166 import BaseApplicationHandler
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
38 from .constants import (
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
39 NS_JINGLE_RTP,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
40 NS_JINGLE_RTP_INFO,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
41 NS_JINGLE_RTP_AUDIO,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
42 NS_JINGLE_RTP_VIDEO,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
43 )
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
44
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 log = getLogger(__name__)
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
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
49 PLUGIN_INFO = {
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
50 C.PI_NAME: "Jingle RTP Sessions",
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
51 C.PI_IMPORT_NAME: "XEP-0167",
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
52 C.PI_TYPE: "XEP",
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
53 C.PI_PROTOCOLS: ["XEP-0167"],
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
54 C.PI_DEPENDENCIES: ["XEP-0166"],
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
55 C.PI_MAIN: "XEP_0167",
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
56 C.PI_HANDLER: "yes",
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
57 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
58 }
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
59
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
60 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
61 CONFIRM_TITLE = D_("Incoming Call")
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
62 SECURITY_LIMIT = 0
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
63
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
64 ALLOWED_ACTIONS = (
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
65 "active",
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
66 "hold",
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
67 "unhold",
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
68 "mute",
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
69 "unmute",
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
70 "ringing",
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
71 )
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
72
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
73
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
74 class XEP_0167(BaseApplicationHandler):
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
75 def __init__(self, host):
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
76 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
77 self.host = host
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
78 # 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
79 mapping.host = host
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
80 self._j = host.plugins["XEP-0166"]
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
81 self._j.register_application(NS_JINGLE_RTP, self)
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
82 host.bridge.add_method(
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
83 "call_start",
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
84 ".plugin",
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
85 in_sign="sss",
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
86 out_sign="s",
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
87 method=self._call_start,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
88 async_=True,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
89 )
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
90 host.bridge.add_method(
4070
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
91 "call_end",
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
92 ".plugin",
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
93 in_sign="sss",
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
94 out_sign="",
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
95 method=self._call_end,
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
96 async_=True,
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
97 )
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
98 host.bridge.add_method(
4056
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
99 "call_info",
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
100 ".plugin",
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
101 in_sign="ssss",
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
102 out_sign="",
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
103 method=self._call_start,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
104 )
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
105 host.bridge.add_signal(
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
106 "call_accepted", ".plugin", signature="sss"
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
107 ) # args: session_id, answer_sdp, profile
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
108 host.bridge.add_signal(
4070
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
109 "call_ended", ".plugin", signature="sss"
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
110 ) # args: session_id, data, profile
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
111 host.bridge.add_signal(
4056
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
112 "call_info", ".plugin", signature="ssss"
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
113 ) # args: session_id, info_type, extra, profile
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
114
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
115 def get_handler(self, client):
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
116 return XEP_0167_handler()
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
117
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
118 # bridge methods
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
119
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
120 def _call_start(
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
121 self,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
122 entity_s: str,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
123 call_data_s: str,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
124 profile_key: str,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
125 ):
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
126 client = self.host.get_client(profile_key)
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
127 return defer.ensureDeferred(
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
128 self.call_start(
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
129 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
130 )
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
131 )
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
132
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
133 async def call_start(
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
134 self,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
135 client: SatXMPPEntity,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
136 peer_jid: jid.JID,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
137 call_data: dict,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
138 ) -> None:
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
139 """Temporary method to test RTP session"""
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
140 contents = []
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
141 metadata = call_data.get("metadata") or {}
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
142
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
143 if "sdp" in call_data:
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
144 sdp_data = mapping.parse_sdp(call_data["sdp"])
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
145 for media_type in ("audio", "video"):
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
146 try:
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
147 media_data = sdp_data.pop(media_type)
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
148 except KeyError:
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
149 continue
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
150 call_data[media_type] = media_data["application_data"]
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
151 transport_data = media_data["transport_data"]
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
152 try:
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
153 call_data[media_type]["fingerprint"] = transport_data["fingerprint"]
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
154 except KeyError:
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
155 log.warning("fingerprint is missing")
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
156 pass
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
157 try:
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
158 call_data[media_type]["id"] = media_data["id"]
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
159 except KeyError:
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
160 log.warning(f"no media ID found for {media_type}: {media_data}")
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
161 try:
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
162 call_data[media_type]["ice-candidates"] = transport_data["candidates"]
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
163 metadata["ice-ufrag"] = transport_data["ufrag"]
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
164 metadata["ice-pwd"] = transport_data["pwd"]
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
165 except KeyError:
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
166 log.warning("ICE data are missing from SDP")
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
167 continue
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
168 metadata.update(sdp_data.get("metadata", {}))
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
169
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
170 call_type = (
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
171 C.META_SUBTYPE_CALL_VIDEO
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
172 if "video" in call_data
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
173 else C.META_SUBTYPE_CALL_AUDIO
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
174 )
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
175 seen_names = set()
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
176
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
177 for media in ("audio", "video"):
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
178 media_data = call_data.get(media)
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
179 if media_data is not None:
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
180 content = {
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
181 "app_ns": NS_JINGLE_RTP,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
182 "senders": "both",
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
183 "transport_type": self._j.TRANSPORT_DATAGRAM,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
184 "app_kwargs": {"media": media, "media_data": media_data},
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
185 "transport_data": {
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
186 "local_ice_data": {
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
187 "ufrag": metadata["ice-ufrag"],
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
188 "pwd": metadata["ice-pwd"],
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
189 "candidates": media_data.pop("ice-candidates"),
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
190 "fingerprint": media_data.pop("fingerprint", {}),
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
191 }
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
192 },
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
193 }
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
194 if "id" in media_data:
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
195 name = media_data.pop("id")
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
196 if name in seen_names:
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
197 raise exceptions.DataError(
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
198 f"Content name (mid) seen multiple times: {name}"
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
199 )
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
200 content["name"] = name
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
201 contents.append(content)
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
202 if not contents:
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
203 raise exceptions.DataError("no valid media data found: {call_data}")
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
204 return await self._j.initiate(
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
205 client,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
206 peer_jid,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
207 contents,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
208 call_type=call_type,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
209 metadata=metadata,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
210 peer_metadata={},
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
211 )
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
212
4070
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
213 def _call_end(
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
214 self,
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
215 session_id: str,
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
216 data_s: str,
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
217 profile_key: str,
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
218 ):
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
219 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
220 return defer.ensureDeferred(
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
221 self.call_end(
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
222 client, session_id, data_format.deserialise(data_s)
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
223 )
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
224 )
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
225
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
226 async def call_end(
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
227 self,
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
228 client: SatXMPPEntity,
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
229 session_id: str,
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
230 data: dict,
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
231 ) -> None:
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
232 """End a call
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
233
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
234 @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
235 @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
236 call
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
237 """
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
238 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
239 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
240
4056
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
241 # jingle callbacks
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
242
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
243 def jingle_session_init(
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
244 self,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
245 client: SatXMPPEntity,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
246 session: dict,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
247 content_name: str,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
248 media: str,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
249 media_data: dict,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
250 ) -> domish.Element:
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
251 if media not in ("audio", "video"):
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
252 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
253 content_data = session["contents"][content_name]
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
254 application_data = content_data["application_data"]
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
255 application_data["media"] = media
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
256 application_data["local_data"] = media_data
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
257 desc_elt = mapping.build_description(media, media_data, session)
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
258 self.host.trigger.point(
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
259 "XEP-0167_jingle_session_init",
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
260 client,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
261 session,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
262 content_name,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
263 media,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
264 media_data,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
265 desc_elt,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
266 triggers_no_cancel=True,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
267 )
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
268 return desc_elt
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
269
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
270 async def jingle_request_confirmation(
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
271 self,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
272 client: SatXMPPEntity,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
273 action: str,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
274 session: dict,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
275 content_name: str,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
276 desc_elt: domish.Element,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
277 ) -> bool:
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
278 if content_name != next(iter(session["contents"])):
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
279 # 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
280 # 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
281 # is requested only once for audio and video contents.
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
282 return True
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
283 peer_jid = session["peer_jid"]
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
284
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
285 if any(
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
286 c["desc_elt"].getAttribute("media") == "video"
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
287 for c in session["contents"].values()
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
288 ):
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
289 call_type = session["call_type"] = C.META_SUBTYPE_CALL_VIDEO
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
290 else:
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
291 call_type = session["call_type"] = C.META_SUBTYPE_CALL_AUDIO
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
292
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
293 sdp = mapping.generate_sdp_from_session(session)
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
294
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
295 resp_data = await xml_tools.defer_dialog(
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
296 self.host,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
297 _(CONFIRM).format(peer=peer_jid.userhost(), call_type=call_type),
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
298 _(CONFIRM_TITLE),
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
299 action_extra={
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
300 "session_id": session["id"],
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
301 "from_jid": peer_jid.full(),
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
302 "type": C.META_TYPE_CALL,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
303 "sub_type": call_type,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
304 "sdp": sdp,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
305 },
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
306 security_limit=SECURITY_LIMIT,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
307 profile=client.profile,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
308 )
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
309
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
310 if resp_data.get("cancelled", False):
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
311 return False
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
312
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
313 answer_sdp = resp_data["sdp"]
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
314 parsed_answer = mapping.parse_sdp(answer_sdp)
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
315 session["peer_metadata"].update(parsed_answer["metadata"])
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
316 for media in ("audio", "video"):
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
317 for content in session["contents"].values():
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
318 if content["desc_elt"].getAttribute("media") == media:
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
319 media_data = parsed_answer[media]
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
320 application_data = content["application_data"]
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
321 application_data["local_data"] = media_data["application_data"]
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
322 transport_data = content["transport_data"]
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
323 local_ice_data = media_data["transport_data"]
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
324 transport_data["local_ice_data"] = local_ice_data
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
325
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
326 return True
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
327
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
328 async def jingle_handler(self, client, action, session, content_name, desc_elt):
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
329 content_data = session["contents"][content_name]
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
330 application_data = content_data["application_data"]
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
331 if action == self._j.A_PREPARE_CONFIRMATION:
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
332 session["metadata"] = {}
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
333 session["peer_metadata"] = {}
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
334 try:
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
335 media = application_data["media"] = desc_elt["media"]
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
336 except KeyError:
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
337 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
338 if media not in ("audio", "video"):
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
339 raise exceptions.DataError(f"invalid media: {media!r}")
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
340 application_data["peer_data"] = mapping.parse_description(desc_elt)
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
341 elif action == self._j.A_SESSION_INITIATE:
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
342 application_data["peer_data"] = mapping.parse_description(desc_elt)
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
343 desc_elt = mapping.build_description(
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
344 application_data["media"], application_data["local_data"], session
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
345 )
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
346 elif action == self._j.A_ACCEPTED_ACK:
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
347 pass
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
348 elif action == self._j.A_PREPARE_INITIATOR:
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
349 application_data["peer_data"] = mapping.parse_description(desc_elt)
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
350 elif action == self._j.A_SESSION_ACCEPT:
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
351 if content_name == next(iter(session["contents"])):
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
352 # we only send the signal for first content, as it means that the whole
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
353 # session is accepted
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
354 answer_sdp = mapping.generate_sdp_from_session(session)
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
355 self.host.bridge.call_accepted(session["id"], answer_sdp, client.profile)
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
356 else:
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
357 log.warning(f"FIXME: unmanaged action {action}")
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
358
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
359 self.host.trigger.point(
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
360 "XEP-0167_jingle_handler",
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
361 client,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
362 action,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
363 session,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
364 content_name,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
365 desc_elt,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
366 triggers_no_cancel=True,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
367 )
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
368 return desc_elt
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
369
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
370 def jingle_session_info(
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
371 self,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
372 client: SatXMPPEntity,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
373 action: str,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
374 session: dict,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
375 content_name: str,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
376 jingle_elt: domish.Element,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
377 ) -> None:
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
378 """Informational messages"""
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
379 for elt in jingle_elt.elements():
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
380 if elt.uri == NS_JINGLE_RTP_INFO:
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
381 info_type = elt.name
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
382 if info_type not in ALLOWED_ACTIONS:
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
383 log.warning("ignoring unknow info type: {info_type!r}")
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
384 continue
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
385 extra = {}
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
386 if info_type in ("mute", "unmute"):
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
387 name = elt.getAttribute("name")
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
388 if name:
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
389 extra["name"] = name
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
390 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
391 self.host.bridge.call_info(
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
392 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
393 )
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
394
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
395 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
396 client = self.host.get_client(profile_key)
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
397 extra = data_format.deserialise(extra_s)
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
398 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
399
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
400
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
401 def send_info(
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
402 self,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
403 client: SatXMPPEntity,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
404 session_id: str,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
405 info_type: str,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
406 extra: Optional[dict],
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
407 ) -> None:
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
408 """Send information on the call"""
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
409 if info_type not in ALLOWED_ACTIONS:
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
410 raise ValueError(f"Unkown info type {info_type!r}")
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
411 session = self._j.get_session(client, session_id)
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
412 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
413 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
414 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
415 info_elt["name"] = extra["name"]
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
416 iq_elt.send()
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
417
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
418 def jingle_terminate(
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
419 self,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
420 client: SatXMPPEntity,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
421 action: str,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
422 session: dict,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
423 content_name: str,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
424 reason_elt: domish.Element,
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
425 ) -> None:
4070
d10748475025 plugin XEP-0167: method to end a call, and corresponding signal:
Goffi <goffi@goffi.org>
parents: 4058
diff changeset
426 self.host.bridge.call_ended(session["id"], "", client.profile)
4056
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
427
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
428
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
429 @implementer(iwokkel.IDisco)
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
430 class XEP_0167_handler(XMPPHandler):
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
431 def getDiscoInfo(self, requestor, target, nodeIdentifier=""):
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
432 return [
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
433 disco.DiscoFeature(NS_JINGLE_RTP),
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
434 disco.DiscoFeature(NS_JINGLE_RTP_AUDIO),
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
435 disco.DiscoFeature(NS_JINGLE_RTP_VIDEO),
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
436 ]
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
437
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
438 def getDiscoItems(self, requestor, target, nodeIdentifier=""):
1c4f4aa36d98 plugin XEP-0167: Jingle RTP Sessions implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
439 return []