Mercurial > libervia-backend
comparison sat/plugins/plugin_xep_0167/__init__.py @ 4070:d10748475025
plugin XEP-0167: method to end a call, and corresponding signal:
rel 422
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 01 Jun 2023 21:37:34 +0200 |
parents | adb9dc9c8114 |
children |
comparison
equal
deleted
inserted
replaced
4069:3d91d0aa68db | 4070:d10748475025 |
---|---|
86 out_sign="s", | 86 out_sign="s", |
87 method=self._call_start, | 87 method=self._call_start, |
88 async_=True, | 88 async_=True, |
89 ) | 89 ) |
90 host.bridge.add_method( | 90 host.bridge.add_method( |
91 "call_end", | |
92 ".plugin", | |
93 in_sign="sss", | |
94 out_sign="", | |
95 method=self._call_end, | |
96 async_=True, | |
97 ) | |
98 host.bridge.add_method( | |
91 "call_info", | 99 "call_info", |
92 ".plugin", | 100 ".plugin", |
93 in_sign="ssss", | 101 in_sign="ssss", |
94 out_sign="", | 102 out_sign="", |
95 method=self._call_start, | 103 method=self._call_start, |
96 ) | 104 ) |
97 host.bridge.add_signal( | 105 host.bridge.add_signal( |
98 "call_accepted", ".plugin", signature="sss" | 106 "call_accepted", ".plugin", signature="sss" |
99 ) # args: session_id, answer_sdp, profile | 107 ) # args: session_id, answer_sdp, profile |
108 host.bridge.add_signal( | |
109 "call_ended", ".plugin", signature="sss" | |
110 ) # args: session_id, data, profile | |
100 host.bridge.add_signal( | 111 host.bridge.add_signal( |
101 "call_info", ".plugin", signature="ssss" | 112 "call_info", ".plugin", signature="ssss" |
102 ) # args: session_id, info_type, extra, profile | 113 ) # args: session_id, info_type, extra, profile |
103 | 114 |
104 def get_handler(self, client): | 115 def get_handler(self, client): |
122 async def call_start( | 133 async def call_start( |
123 self, | 134 self, |
124 client: SatXMPPEntity, | 135 client: SatXMPPEntity, |
125 peer_jid: jid.JID, | 136 peer_jid: jid.JID, |
126 call_data: dict, | 137 call_data: dict, |
127 media: str = "video", | |
128 ) -> None: | 138 ) -> None: |
129 """Temporary method to test RTP session""" | 139 """Temporary method to test RTP session""" |
130 contents = [] | 140 contents = [] |
131 metadata = call_data.get("metadata") or {} | 141 metadata = call_data.get("metadata") or {} |
132 | 142 |
198 call_type=call_type, | 208 call_type=call_type, |
199 metadata=metadata, | 209 metadata=metadata, |
200 peer_metadata={}, | 210 peer_metadata={}, |
201 ) | 211 ) |
202 | 212 |
213 def _call_end( | |
214 self, | |
215 session_id: str, | |
216 data_s: str, | |
217 profile_key: str, | |
218 ): | |
219 client = self.host.get_client(profile_key) | |
220 return defer.ensureDeferred( | |
221 self.call_end( | |
222 client, session_id, data_format.deserialise(data_s) | |
223 ) | |
224 ) | |
225 | |
226 async def call_end( | |
227 self, | |
228 client: SatXMPPEntity, | |
229 session_id: str, | |
230 data: dict, | |
231 ) -> None: | |
232 """End a call | |
233 | |
234 @param session_id: Jingle session ID of the call | |
235 @param data: optional extra data, may be used to indicate the reason to end the | |
236 call | |
237 """ | |
238 session = self._j.get_session(client, session_id) | |
239 await self._j.terminate(client, self._j.REASON_SUCCESS, session) | |
240 | |
203 # jingle callbacks | 241 # jingle callbacks |
204 | 242 |
205 def jingle_session_init( | 243 def jingle_session_init( |
206 self, | 244 self, |
207 client: SatXMPPEntity, | 245 client: SatXMPPEntity, |
383 action: str, | 421 action: str, |
384 session: dict, | 422 session: dict, |
385 content_name: str, | 423 content_name: str, |
386 reason_elt: domish.Element, | 424 reason_elt: domish.Element, |
387 ) -> None: | 425 ) -> None: |
388 pass | 426 self.host.bridge.call_ended(session["id"], "", client.profile) |
389 | 427 |
390 | 428 |
391 @implementer(iwokkel.IDisco) | 429 @implementer(iwokkel.IDisco) |
392 class XEP_0167_handler(XMPPHandler): | 430 class XEP_0167_handler(XMPPHandler): |
393 def getDiscoInfo(self, requestor, target, nodeIdentifier=""): | 431 def getDiscoInfo(self, requestor, target, nodeIdentifier=""): |