plugin XEP-0167: method to end a call, and corresponding signal:

rel 422
This commit is contained in:
Goffi 2023-06-01 21:37:34 +02:00
commit a15648d682

View file

@ -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)