From a15648d6821afed307b123f9f1e060863440b7cf Mon Sep 17 00:00:00 2001 From: Goffi Date: Thu, 1 Jun 2023 21:37:34 +0200 Subject: [PATCH] plugin XEP-0167: method to end a call, and corresponding signal: rel 422 --- sat/plugins/plugin_xep_0167/__init__.py | 42 +++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/sat/plugins/plugin_xep_0167/__init__.py b/sat/plugins/plugin_xep_0167/__init__.py index 1d265941..7c927dd8 100644 --- a/sat/plugins/plugin_xep_0167/__init__.py +++ b/sat/plugins/plugin_xep_0167/__init__.py @@ -87,6 +87,14 @@ class XEP_0167(BaseApplicationHandler): method=self._call_start, async_=True, ) + host.bridge.add_method( + "call_end", + ".plugin", + in_sign="sss", + out_sign="", + method=self._call_end, + async_=True, + ) host.bridge.add_method( "call_info", ".plugin", @@ -97,6 +105,9 @@ class XEP_0167(BaseApplicationHandler): host.bridge.add_signal( "call_accepted", ".plugin", signature="sss" ) # args: session_id, answer_sdp, profile + host.bridge.add_signal( + "call_ended", ".plugin", signature="sss" + ) # args: session_id, data, profile host.bridge.add_signal( "call_info", ".plugin", signature="ssss" ) # args: session_id, info_type, extra, profile @@ -124,7 +135,6 @@ class XEP_0167(BaseApplicationHandler): client: SatXMPPEntity, peer_jid: jid.JID, call_data: dict, - media: str = "video", ) -> None: """Temporary method to test RTP session""" contents = [] @@ -200,6 +210,34 @@ class XEP_0167(BaseApplicationHandler): peer_metadata={}, ) + def _call_end( + self, + session_id: str, + data_s: str, + profile_key: str, + ): + client = self.host.get_client(profile_key) + return defer.ensureDeferred( + self.call_end( + client, session_id, data_format.deserialise(data_s) + ) + ) + + async def call_end( + self, + client: SatXMPPEntity, + session_id: str, + data: dict, + ) -> None: + """End a call + + @param session_id: Jingle session ID of the call + @param data: optional extra data, may be used to indicate the reason to end the + call + """ + session = self._j.get_session(client, session_id) + await self._j.terminate(client, self._j.REASON_SUCCESS, session) + # jingle callbacks def jingle_session_init( @@ -385,7 +423,7 @@ class XEP_0167(BaseApplicationHandler): content_name: str, reason_elt: domish.Element, ) -> None: - pass + self.host.bridge.call_ended(session["id"], "", client.profile) @implementer(iwokkel.IDisco)