diff libervia/backend/plugins/plugin_xep_0167/__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 39ac821ebbdb
children
line wrap: on
line diff
--- a/libervia/backend/plugins/plugin_xep_0167/__init__.py	Mon Jul 29 03:49:26 2024 +0200
+++ b/libervia/backend/plugins/plugin_xep_0167/__init__.py	Tue Aug 06 23:43:11 2024 +0200
@@ -41,7 +41,7 @@
     NS_JINGLE_RTP_AUDIO,
     NS_JINGLE_RTP_INFO,
     NS_JINGLE_RTP_VIDEO,
-    NS_AV_CONFERENCES
+    NS_AV_CONFERENCES,
 )
 
 
@@ -419,17 +419,22 @@
 
         session["call_type"] = call_type
         cancellable_deferred = session.setdefault("cancellable_deferred", [])
+        action_extra = {
+            "session_id": session["id"],
+            "from_jid": peer_jid.full(),
+            "type": C.META_TYPE_CALL,
+            "sub_type": call_type,
+        }
+        try:
+            action_extra["metadata"] = {"user": session["metadata"]["peer_user"].full()}
+        except KeyError:
+            pass
 
         dialog_d = xml_tools.defer_dialog(
             self.host,
             _(CONFIRM).format(peer=peer_jid.userhost(), call_type=call_type),
             _(CONFIRM_TITLE),
-            action_extra={
-                "session_id": session["id"],
-                "from_jid": peer_jid.full(),
-                "type": C.META_TYPE_CALL,
-                "sub_type": call_type,
-            },
+            action_extra=action_extra,
             security_limit=SECURITY_LIMIT,
             profile=client.profile,
         )
@@ -596,26 +601,22 @@
         answer_sdp_d.addTimeout(2 * 60, reactor)
 
         call_setup = session.get("call_setup_cb")
+        call_data = {
+            "role": session["role"],
+            "sdp": sdp,
+        }
 
         if call_setup is None:
             self.host.bridge.call_setup(
                 session["id"],
-                data_format.serialise(
-                    {
-                        "role": session["role"],
-                        "sdp": sdp,
-                    }
-                ),
+                data_format.serialise(call_data),
                 client.profile,
             )
         else:
             await call_setup(
                 client,
                 session,
-                {
-                    "role": session["role"],
-                    "sdp": sdp,
-                },
+                call_data,
             )
 
         answer_sdp = await answer_sdp_d
@@ -681,7 +682,7 @@
             content_data = session["contents"][content_name]
         application_data = content_data["application_data"]
         if action == self._j.A_PREPARE_CONFIRMATION:
-            session["metadata"] = {}
+            session.setdefault("metadata", {})
             session.setdefault("peer_metadata", {})
             try:
                 media = application_data["media"] = desc_elt["media"]