diff libervia/backend/plugins/plugin_comp_conferences/__init__.py @ 4294:a0ed5c976bf8

component conferences, plugin XEP-0167, XEP-0298: add stream user metadata: A/V conference now adds user metadata about the stream it is forwarding through XEP-0298. This is parsed and added to metadata during confirmation on client side. rel 448
author Goffi <goffi@goffi.org>
date Tue, 06 Aug 2024 23:43:11 +0200
parents 96fdf4891747
children
line wrap: on
line diff
--- a/libervia/backend/plugins/plugin_comp_conferences/__init__.py	Mon Jul 29 03:49:26 2024 +0200
+++ b/libervia/backend/plugins/plugin_comp_conferences/__init__.py	Tue Aug 06 23:43:11 2024 +0200
@@ -236,10 +236,22 @@
 
     async def a_on_offer(self, data: dict) -> None:
         client: SatXMPPEntity = self.client.get_virtual_client(self.session["local_jid"])
+        call_data = {"sdp": data["sdp"]}
+        try:
+            # FIXME: This assume that all username are coming from XMPP, "source" should
+            #   be used instead to be sure to match XMPP users, and other ones should use
+            #   a non "xmpp:" URL scheme.
+            user_jid = jid.JID(data["username"])
+            if not user_jid.user:
+                raise ValueError("Missing user part.")
+        except Exception as e:
+            log.warning("Username is not a JID: {data['username']=}, {e}")
+        else:
+            call_data["metadata"] = {"user": user_jid}
         sid = await self._rtp.call_start(
             client,
             self.session["peer_jid"],
-            {"sdp": data["sdp"]},
+            call_data,
             session_id=f"{self.client_id}-{data['id']}",
         )
         session = self._j.get_session(client, sid)
@@ -547,7 +559,6 @@
         log.error(f"Can't run Galene process: {failure_.value}")
 
 
-
 @implementer(iwokkel.IDisco)
 class ConferencesHandler(XMPPHandler):