annotate libervia/backend/plugins/plugin_comp_conferences/__init__.py @ 4286:96fdf4891747

component conferences: fix session management and init: - jingle session management is now correctly handled, with id of the Galène client used as prefix when necessary. - Galène is now run only when component session is started, avoiding systematic run on __init__. - Galène ICE logs are displayed with high verbosity. - Fix disco identity handling rel 447
author Goffi <goffi@goffi.org>
date Mon, 29 Jul 2024 03:29:14 +0200
parents 240d8b7ad906
children a0ed5c976bf8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4278
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/env python3
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
2
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
3 # Libervia A/V Conferences Component
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
4 # Copyright (C) 2009-2024 Jérôme Poisson (goffi@goffi.org)
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
5
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
6 # This program is free software: you can redistribute it and/or modify
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
7 # it under the terms of the GNU Affero General Public License as published by
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
8 # the Free Software Foundation, either version 3 of the License, or
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
9 # (at your option) any later version.
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
10
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
11 # This program is distributed in the hope that it will be useful,
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
14 # GNU Affero General Public License for more details.
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
15
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
16 # You should have received a copy of the GNU Affero General Public License
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
18
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
19 import json
4286
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
20 import os
4278
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
21 from pathlib import Path
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
22 from urllib.parse import quote
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
23
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
24 from autobahn.twisted.websocket import WebSocketClientFactory, WebSocketClientProtocol
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
25 from shortuuid import uuid
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
26 import treq
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
27 from twisted.internet import defer, reactor
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
28 from twisted.internet.error import ConnectionDone
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
29 from twisted.python import failure
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
30 from twisted.python.failure import Failure
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
31 from twisted.python.procutils import which
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
32 from twisted.words.protocols.jabber import jid
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
33 from twisted.words.protocols.jabber.error import StanzaError
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
34 from twisted.words.protocols.jabber.xmlstream import XMPPHandler
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
35 from twisted.words.xish import domish
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
36 from wokkel import disco, iwokkel
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
37 from zope.interface import implementer
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
38
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
39 from libervia.backend.core import exceptions
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
40 from libervia.backend.core.constants import Const as C
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
41 from libervia.backend.core.core_types import SatXMPPEntity
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
42 from libervia.backend.core.i18n import _
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
43 from libervia.backend.core.log import getLogger
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
44 from libervia.backend.plugins.plugin_xep_0106 import XEP_0106
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
45 from libervia.backend.plugins.plugin_xep_0166 import XEP_0166
4286
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
46 from libervia.backend.plugins.plugin_xep_0167 import XEP_0167, mapping, NS_AV_CONFERENCES
4278
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
47 from libervia.backend.plugins.plugin_xep_0176 import XEP_0176
4286
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
48 from libervia.backend.plugins.plugin_xep_0298 import XEP_0298
4278
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
49 from libervia.backend.tools.common import async_process, regex
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
50
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
51
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
52 log = getLogger(__name__)
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
53
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
54 IMPORT_NAME = "conferences"
4286
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
55 NAME = "Libervia A/V Conferences"
4278
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
56
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
57 PLUGIN_INFO = {
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
58 C.PI_NAME: "A/V Conferences Component",
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
59 C.PI_IMPORT_NAME: IMPORT_NAME,
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
60 C.PI_MODES: [C.PLUG_MODE_COMPONENT],
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
61 C.PI_TYPE: C.PLUG_TYPE_ENTRY_POINT,
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
62 C.PI_PROTOCOLS: [],
4286
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
63 C.PI_DEPENDENCIES: ["XEP-0106", "XEP-0166", "XEP-0167", "XEP-0176", "XEP-0298"],
4278
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
64 C.PI_RECOMMENDATIONS: [],
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
65 C.PI_MAIN: "ConferencesComponent",
4286
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
66 C.PI_HANDLER: C.BOOL_TRUE,
4278
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
67 C.PI_DESCRIPTION: _(
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
68 "Handle multiparty audio/video conferences, using a Selective Forwarding Unit.\n"
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
69 "The Galène project (https://galene.org) is currently the only supported backend."
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
70 ),
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
71 }
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
72
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
73 CONF_SECTION = f"component {IMPORT_NAME}"
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
74
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
75
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
76 class Conference:
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
77
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
78 def __init__(
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
79 self,
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
80 parent: "ConferencesComponent",
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
81 group_name: str,
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
82 data_file: Path,
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
83 endpoint: str,
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
84 status_url: str,
4286
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
85 session: dict,
4278
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
86 ) -> None:
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
87 self.parent = parent
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
88 self.group_name = group_name
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
89 self.data_file = data_file
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
90 self.endpoint = endpoint
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
91 self.status_url = status_url
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
92 self._protocol: "GaleneProtocol|None" = None
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
93 self.connected = defer.Deferred()
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
94 self.ready = defer.Deferred()
4286
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
95 self.session = session
4278
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
96
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
97 def __str__(self):
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
98 return f"conference {self.group_name!r}"
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
99
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
100 @property
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
101 def protocol(self) -> "GaleneProtocol":
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
102 assert self._protocol is not None
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
103 return self._protocol
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
104
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
105 @protocol.setter
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
106 def protocol(self, protocol: "GaleneProtocol") -> None:
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
107 self._protocol = protocol
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
108 self.connected.callback(None)
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
109
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
110 @property
4286
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
111 def client_id(self) -> str:
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
112 return self.protocol.client_id
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
113
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
114 @property
4278
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
115 def _j(self) -> XEP_0166:
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
116 return self.parent._j
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
117
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
118 @property
4286
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
119 def _rtp(self) -> XEP_0167:
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
120 return self.parent._rtp
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
121
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
122 @property
4278
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
123 def _ice_udp(self) -> XEP_0176:
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
124 return self.parent._ice_udp
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
125
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
126 @property
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
127 def client(self) -> SatXMPPEntity:
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
128 client = self.parent.client
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
129 assert client is not None
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
130 return client
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
131
4286
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
132 @property
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
133 def galene_id(self) -> str:
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
134 """ID to use with Galène API."""
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
135 return f"{self.client_id}-{self.session['id']}"
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
136
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
137 async def on_call_setup(
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
138 self,
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
139 client: SatXMPPEntity,
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
140 session: dict,
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
141 call_data: dict,
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
142 ) -> None:
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
143 if call_data["role"] == self._j.ROLE_INITIATOR:
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
144 self.send_answer(session["id"], call_data["sdp"])
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
145 else:
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
146 raise exceptions.InternalError(
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
147 '"role" should be "{self._j.ROLE_INITIATOR}" here.'
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
148 )
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
149
4278
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
150 def join(self, user_jid: jid.JID) -> None:
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
151 self.protocol.send_data(
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
152 {
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
153 "type": "join",
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
154 "kind": "join",
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
155 "group": self.data_file.stem,
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
156 "username": user_jid.userhost(),
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
157 "password": "",
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
158 }
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
159 )
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
160
4286
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
161 def send_request(self, requested: dict | None = None) -> None:
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
162 if requested is None:
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
163 requested = {"": ["audio", "video"]}
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
164 self.protocol.send_data({"type": "request", "request": requested})
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
165
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
166 def send_offer(self, sdp: str) -> None:
4278
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
167 self.protocol.send_data(
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
168 {
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
169 "type": "offer",
4286
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
170 "id": self.galene_id,
4278
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
171 "label": "camera",
4286
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
172 "username": self.session["peer_jid"].userhost(),
4278
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
173 "sdp": sdp,
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
174 }
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
175 )
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
176
4286
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
177 def send_answer(self, session_id: str, sdp: str) -> None:
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
178 data_id = session_id[len(self.client_id) + 1 :]
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
179 self.protocol.send_data(
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
180 {
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
181 "type": "answer",
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
182 "id": data_id,
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
183 "label": "camera",
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
184 "username": self.session["peer_jid"].userhost(),
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
185 "sdp": sdp,
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
186 }
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
187 )
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
188
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
189 def add_candidate(self, candidate: dict, sdp_mid: str, sdp_mline_index: int) -> None:
4278
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
190 """Add an ICE candidate.
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
191
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
192 @param candidate: ICE candidate, SDP format.
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
193 """
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
194 self.protocol.send_data(
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
195 {
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
196 "type": "ice",
4286
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
197 "id": self.galene_id,
4278
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
198 "candidate": {
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
199 "candidate": mapping.generate_candidate_line(candidate),
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
200 "sdpMid": sdp_mid,
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
201 "sdpMLineIndex": sdp_mline_index,
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
202 },
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
203 }
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
204 )
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
205
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
206 def on_joined(self, data: dict) -> None:
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
207 user_jid = jid.JID(data["username"])
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
208 match data["kind"]:
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
209 case "join":
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
210 log.info(f"{user_jid} has joined {self}.")
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
211 case "fail":
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
212 log.warning(f"{user_jid} can't join {self}: {data}")
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
213 case "change":
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
214 log.debug(f"Change for {user_jid} in {self}.")
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
215 case "leave":
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
216 log.info(f"{user_jid} has left {self}.")
4286
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
217 self.send_request()
4278
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
218
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
219 def on_answer(self, data: dict) -> None:
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
220 """Called when SDP answer has been received
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
221
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
222 Send the SDP to ``answer_sdp_d`` to continue workflow.
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
223 """
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
224 try:
4286
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
225 answer_sdp_d = self.session.pop("answer_sdp_d")
4278
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
226 except KeyError:
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
227 raise exceptions.InternalError(
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
228 '"answer_sdp_d" should be available in session.'
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
229 )
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
230 else:
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
231 answer_sdp_d.callback(data["sdp"])
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
232
4286
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
233 def on_offer(self, data: dict) -> None:
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
234 """Called when a new SFP offer has been received"""
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
235 defer.ensureDeferred(self.a_on_offer(data))
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
236
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
237 async def a_on_offer(self, data: dict) -> None:
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
238 client: SatXMPPEntity = self.client.get_virtual_client(self.session["local_jid"])
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
239 sid = await self._rtp.call_start(
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
240 client,
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
241 self.session["peer_jid"],
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
242 {"sdp": data["sdp"]},
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
243 session_id=f"{self.client_id}-{data['id']}",
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
244 )
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
245 session = self._j.get_session(client, sid)
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
246 session["call_setup_cb"] = self.on_call_setup
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
247
4278
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
248 def on_ice(self, data: dict) -> None:
4286
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
249 if data["id"] == self.galene_id:
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
250 session = self.session
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
251 else:
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
252 session = self._j.get_session(self.client, f"{self.client_id}-{data['id']}")
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
253 log.debug(
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
254 f"ICE candidate for session {session['id']}, peer_jid={session['peer_jid']}."
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
255 )
4278
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
256 candidate_data = data["candidate"]
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
257 contents = session["contents"]
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
258 try:
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
259 content_id = list(contents)[candidate_data["sdpMLineIndex"]]
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
260 except IndexError:
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
261 log.error(
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
262 f"Can't find any content at index {candidate_data['sdpMLineIndex']}."
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
263 )
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
264 return
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
265 content = contents[content_id]
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
266 local_ice_data = content["transport_data"]["local_ice_data"]
4286
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
267
4278
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
268 media = content["application_data"]["media"]
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
269 client: SatXMPPEntity = self.client.get_virtual_client(session["local_jid"])
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
270 candidate = mapping.parse_candidate(candidate_data["candidate"][10:].split())
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
271 defer.ensureDeferred(
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
272 self._ice_udp.ice_candidates_add(
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
273 client,
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
274 session["id"],
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
275 {
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
276 media: {
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
277 "candidates": [candidate],
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
278 "ufrag": local_ice_data["ufrag"],
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
279 "pwd": local_ice_data["pwd"],
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
280 }
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
281 },
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
282 )
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
283 )
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
284
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
285
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
286 class GaleneClientFactory(WebSocketClientFactory):
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
287
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
288 def __init__(self, conference: Conference) -> None:
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
289 self.conference = conference
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
290 super().__init__(conference.endpoint)
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
291
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
292
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
293 class GaleneProtocol(WebSocketClientProtocol):
4286
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
294
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
295 def __init__(self, *args, **kwargs):
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
296 super().__init__(*args, **kwargs)
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
297 self.client_id = str(uuid())
4278
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
298
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
299 @property
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
300 def conference(self) -> Conference:
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
301 conference: Conference = self.factory.conference
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
302 assert conference is not None
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
303 return conference
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
304
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
305 def connectionMade(self) -> None:
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
306 super().connectionMade()
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
307 self.conference.protocol = self
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
308
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
309 def connectionLost(self, reason: failure.Failure = ConnectionDone) -> None:
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
310 super().connectionLost(reason)
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
311
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
312 def onOpen(self):
4286
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
313 handshake_data = {"type": "handshake", "version": ["2"], "id": self.client_id}
4278
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
314 self.send_data(handshake_data)
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
315
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
316 def send_data(self, data: dict) -> None:
4286
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
317 if ConferencesComponent.verbose:
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
318 log.debug(f"=> DATA SENT [{self.client_id}]: {data}")
4278
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
319 self.sendMessage(json.dumps(data).encode())
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
320
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
321 def onMessage(self, payload, isBinary):
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
322 if isBinary:
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
323 raise exceptions.DataError("Unexpected binary payload: {payload!r}")
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
324 try:
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
325 data = json.loads(payload)
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
326 except json.JSONDecodeError:
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
327 log.warning(f"Can't decode data: {payload!r}")
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
328 return
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
329
4286
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
330 if ConferencesComponent.verbose:
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
331 log.debug(f"<= DATA RECEIVED [{self.client_id}]: {data}")
4278
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
332 try:
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
333 match data.get("type"):
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
334 case None:
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
335 log.warning(f'"type" is missing in data: {data!r}')
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
336 case "handshake":
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
337 version = data["version"][0]
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
338
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
339 log.debug(
4286
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
340 f"Handshake for group {self.conference.group_name!r}. Galène "
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
341 f"protocol v{version}."
4278
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
342 )
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
343 self.conference.ready.callback(None)
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
344 case "ping":
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
345 log.debug("pong")
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
346 self.send_data({"type": "pong"})
4286
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
347 case "joined" | "answer" | "ice" | "offer" as data_type:
4278
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
348 method = getattr(self.conference, f"on_{data_type}")
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
349 method(data)
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
350 case _:
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
351 log.debug(f"Unhandled message: {data}")
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
352 except (KeyError, IndexError):
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
353 log.exception(f"Unexpected data format: {data!r}")
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
354
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
355
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
356 class ConferencesComponent:
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
357 IMPORT_NAME = IMPORT_NAME
4286
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
358 verbose = 0
4278
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
359
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
360 def __init__(self, host):
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
361 self.host = host
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
362 self.client: SatXMPPEntity | None = None
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
363 self._e: XEP_0106 = host.plugins["XEP-0106"]
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
364 self._j: XEP_0166 = host.plugins["XEP-0166"]
4286
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
365 self._rtp: XEP_0167 = host.plugins["XEP-0167"]
4278
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
366 self._ice_udp: XEP_0176 = host.plugins["XEP-0176"]
4286
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
367 self._coin: XEP_0298 = host.plugins["XEP-0298"]
4278
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
368 host.trigger.add("XEP-0167_jingle_handler", self._jingle_handler_trigger)
4286
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
369 self.initalized = False
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
370
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
371 def _init(self) -> None:
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
372 """Initialisation done after profile is connected"""
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
373 assert self.client is not None
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
374 self.client.identities.append(
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
375 disco.DiscoIdentity("conference", "audio-video", NAME)
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
376 )
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
377
4278
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
378 try:
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
379 galene_path = Path(
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
380 self.host.memory.config_get(CONF_SECTION, "galene_path")
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
381 or which("galene")[0]
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
382 )
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
383 except IndexError:
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
384 raise exceptions.NotFound(
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
385 'Can\'t find "galene" executable, "conferences" component can\'t be '
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
386 "started without it. Please install it in location accessible in PATH, "
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
387 'or use "galene_path" setting.'
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
388 )
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
389 self.galene_http_port = self.host.memory.config_get(
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
390 CONF_SECTION, "http_port", "9443"
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
391 )
4286
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
392 galene_data_path = self.host.memory.get_cache_path(IMPORT_NAME, "galene")
4278
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
393 galene_static_path = galene_path.parent / "static"
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
394 self.galene_group_path = galene_data_path / "groups"
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
395 self.galene_group_path.mkdir(0o700, parents=True, exist_ok=True)
4286
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
396 env = os.environ
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
397 if self.verbose >= 2:
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
398 # We activate Galène debug logs on ICE candidates.
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
399 env["PION_LOG_TRACE"] = "ice"
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
400
4278
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
401 try:
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
402 d = self._process = async_process.run(
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
403 str(galene_path),
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
404 "-static",
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
405 str(galene_static_path),
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
406 "-http",
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
407 f"127.0.0.1:{self.galene_http_port}",
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
408 # We don't want HTTPS here, it's only used for local interactions
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
409 "-insecure",
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
410 path=str(galene_data_path),
4286
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
411 verbose=bool(self.verbose),
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
412 env=env,
4278
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
413 )
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
414 except Exception:
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
415 log.exception("Can't start Galene.")
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
416 else:
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
417 d.addErrback(self._galene_process_errback)
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
418 log.info(f"Galene instance started on port {self.galene_http_port}.")
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
419
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
420 def get_handler(self, __):
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
421 return ConferencesHandler()
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
422
4286
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
423 def profile_connecting(self, client: SatXMPPEntity) -> None:
4278
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
424 self.client = client
4286
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
425 if not self.initalized:
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
426 self._init()
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
427 self.initalized = True
4278
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
428
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
429 async def attach_to_group(self, session: dict, group_name: str) -> Conference:
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
430 """Attach to a Galène group.
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
431
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
432 Create a group data file if it doesn't exist.
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
433 Create and attach a Galene client.
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
434
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
435 @param session: Jingle session data.
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
436 @param group_name: name of the conference group.
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
437 @return conference: Data of the conference.
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
438 """
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
439 stem = regex.path_escape(group_name)
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
440 filename = f"{stem}.json"
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
441 data_file = self.galene_group_path / filename
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
442 if not data_file.exists():
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
443 group_data = {
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
444 "wildcard-user": {
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
445 "password": {"type": "wildcard"},
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
446 "permissions": "present",
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
447 },
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
448 }
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
449 with data_file.open("w") as f:
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
450 json.dump(group_data, f)
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
451 log.debug(f"Conference data for {group_name!r} created at " f"{data_file} .")
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
452
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
453 url = f"http://localhost:{self.galene_http_port}/group/{quote(stem)}"
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
454 status_url = f"{url}/.status"
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
455
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
456 log.debug(f"Attaching to Galene.\n{url=}\n{status_url=}")
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
457 resp = await treq.get(status_url)
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
458 group_status = await resp.json()
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
459 log.debug(f"{group_status=}")
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
460 endpoint = group_status["endpoint"]
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
461 conference = Conference(
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
462 parent=self,
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
463 group_name=group_name,
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
464 data_file=data_file,
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
465 endpoint=endpoint,
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
466 status_url=status_url,
4286
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
467 session=session,
4278
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
468 )
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
469
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
470 factory = GaleneClientFactory(conference)
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
471 # factory.setProtocolOptions(logOctets=True)
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
472 factory.protocol = GaleneProtocol
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
473 reactor.connectTCP("127.0.0.1", int(self.galene_http_port), factory)
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
474
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
475 return conference
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
476
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
477 async def _jingle_handler_trigger(
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
478 self,
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
479 client: SatXMPPEntity,
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
480 action: str,
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
481 session: dict,
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
482 content_name: str,
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
483 desc_elt: domish.Element,
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
484 ) -> None:
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
485 if client != self.client:
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
486 return
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
487 if action == self._j.A_PREPARE_CONFIRMATION:
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
488 if "conference" in session:
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
489 # We have already set up the conference.
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
490 return
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
491 local_jid: jid.JID = session["local_jid"]
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
492 if not local_jid.user:
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
493 raise StanzaError("forbidden", "A room name must be specified.")
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
494 group_name = self._e.unescape(local_jid.user)
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
495
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
496 session["conference"] = await self.attach_to_group(session, group_name)
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
497 session["pre_accepted"] = True
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
498 session["call_setup_cb"] = self.on_call_setup
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
499 session["ice_candidates_new_cb"] = self.on_ice_candidates_new
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
500
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
501 async def on_call_setup(
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
502 self,
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
503 client: SatXMPPEntity,
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
504 session: dict,
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
505 call_data: dict,
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
506 ) -> None:
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
507 if self.client is None or client != self.client:
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
508 raise exceptions.InternalError(f"Unexpected client: {client}")
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
509 try:
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
510 conference = session["conference"]
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
511 except KeyError:
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
512 raise exceptions.InternalError("Conference data is missing.")
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
513
4286
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
514 if call_data["role"] == self._j.ROLE_RESPONDER:
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
515 await conference.ready
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
516 conference.join(session["peer_jid"])
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
517 conference.send_offer(call_data["sdp"])
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
518 else:
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
519 raise exceptions.InternalError(
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
520 '"role" should be "{self._j.ROLE_RESPONDER}" here.'
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
521 )
4278
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
522
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
523 def on_ice_candidates_new(
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
524 self,
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
525 client: SatXMPPEntity,
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
526 session: dict,
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
527 ice_candidates_data: dict[str, dict],
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
528 ) -> None:
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
529 try:
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
530 conference = session["conference"]
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
531 except KeyError:
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
532 raise exceptions.InternalError("Conference data is missing.")
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
533 for media, media_data in ice_candidates_data.items():
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
534 for idx, (content_id, content) in enumerate(session["contents"].items()):
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
535 if content["application_data"]["media"] == media:
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
536 break
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
537 else:
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
538 log.error(f"Can't find corresponding content for {media!r}")
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
539 continue
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
540 sdp_mline_index: int = idx
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
541 sdp_mid: str = content_id
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
542
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
543 for candidate in media_data["candidates"]:
4286
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
544 conference.add_candidate(candidate, sdp_mid, sdp_mline_index)
4278
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
545
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
546 def _galene_process_errback(self, failure_: Failure) -> None:
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
547 log.error(f"Can't run Galene process: {failure_.value}")
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
548
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
549
4286
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
550
4278
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
551 @implementer(iwokkel.IDisco)
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
552 class ConferencesHandler(XMPPHandler):
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
553
240d8b7ad906 component Conferences: implementation of SFU component to make multi-party A/V conferences:
Goffi <goffi@goffi.org>
parents:
diff changeset
554 def getDiscoInfo(self, requestor, target, nodeIdentifier=""):
4286
96fdf4891747 component conferences: fix session management and init:
Goffi <goffi@goffi.org>
parents: 4278
diff changeset
555 return [disco.DiscoFeature(NS_AV_CONFERENCES)]