From 63b50a2d27a268b01eef8a60b1cb92520daf8b8b Mon Sep 17 00:00:00 2001 From: Goffi Date: Fri, 5 Jul 2024 17:18:37 +0200 Subject: [PATCH] plugin XEP-0167: Let use a `call_setup_cb` method in session: when set, the `call_setup_cb` method will be used instead of calling the `call_setup` bridge signal. This will be useful to incoming `Conferences` component to handle the signaling internally. rel 445 --- .../plugins/plugin_xep_0167/__init__.py | 30 +++++++++++++------ libervia/backend/plugins/plugin_xep_0338.py | 2 +- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/libervia/backend/plugins/plugin_xep_0167/__init__.py b/libervia/backend/plugins/plugin_xep_0167/__init__.py index fc4ede4a..57c153aa 100644 --- a/libervia/backend/plugins/plugin_xep_0167/__init__.py +++ b/libervia/backend/plugins/plugin_xep_0167/__init__.py @@ -51,6 +51,7 @@ PLUGIN_INFO = { C.PI_NAME: "Jingle RTP Sessions", C.PI_IMPORT_NAME: "XEP-0167", C.PI_TYPE: "XEP", + C.PI_MODES: C.PLUG_MODE_BOTH, C.PI_PROTOCOLS: ["XEP-0167"], C.PI_DEPENDENCIES: ["XEP-0166"], C.PI_MAIN: "XEP_0167", @@ -502,19 +503,30 @@ class XEP_0167(BaseApplicationHandler): # we should have the answer long before 2 min answer_sdp_d.addTimeout(2 * 60, reactor) - self.host.bridge.call_setup( - session["id"], - data_format.serialise( + call_setup = session.get("call_setup_cb") + + if call_setup is None: + self.host.bridge.call_setup( + session["id"], + data_format.serialise( + { + "role": session["role"], + "sdp": sdp, + } + ), + client.profile, + ) + else: + await call_setup( + client, + session, { "role": session["role"], "sdp": sdp, - } - ), - client.profile, - ) + }, + ) answer_sdp = await answer_sdp_d - parsed_answer = mapping.parse_sdp(answer_sdp, session["role"]) session["metadata"].update(parsed_answer["metadata"]) self.propagate_data(session, parsed_answer) @@ -583,7 +595,7 @@ class XEP_0167(BaseApplicationHandler): else: log.warning(f"FIXME: unmanaged action {action}") - self.host.trigger.point( + await self.host.trigger.async_point( "XEP-0167_jingle_handler", client, action, diff --git a/libervia/backend/plugins/plugin_xep_0338.py b/libervia/backend/plugins/plugin_xep_0338.py index 98bfd91f..afa2da3f 100644 --- a/libervia/backend/plugins/plugin_xep_0338.py +++ b/libervia/backend/plugins/plugin_xep_0338.py @@ -132,7 +132,7 @@ class XEP_0338: jingle_elt = session["jingle_elt"] self.add_group_element(jingle_elt, session) - def _jingle_handler_trigger( + async def _jingle_handler_trigger( self, client: SatXMPPEntity, action: str,