From fb1daa0bf2a6abc32cb737b1234a1dfa33c8815b Mon Sep 17 00:00:00 2001
From: Julian Bouzas <julian.bouzas@collabora.com>
Date: Fri, 2 Apr 2021 11:22:22 -0400
Subject: [PATCH] modules: use dots instead of dashes for session item
 properties

Keeps consistency with PipeWire
---
 lib/wp/endpoint.c                  |  6 +++---
 modules/module-si-audio-adapter.c  | 18 +++++++++---------
 modules/module-si-audio-convert.c  | 20 ++++++++++----------
 modules/module-si-audio-endpoint.c | 14 +++++++-------
 modules/module-si-node.c           |  6 +++---
 modules/module-si-standard-link.c  | 18 +++++++++---------
 src/scripts/policy-node.lua        | 18 +++++++++---------
 tests/modules/si-audio-adapter.c   | 10 +++++-----
 tests/modules/si-audio-convert.c   |  4 ++--
 tests/modules/si-audio-endpoint.c  |  2 +-
 tests/modules/si-node.c            | 10 +++++-----
 tests/modules/si-standard-link.c   |  2 +-
 12 files changed, 64 insertions(+), 64 deletions(-)

diff --git a/lib/wp/endpoint.c b/lib/wp/endpoint.c
index 833b8498..86e6b20d 100644
--- a/lib/wp/endpoint.c
+++ b/lib/wp/endpoint.c
@@ -436,10 +436,10 @@ impl_create_link (void *object, const struct spa_dict *props)
     }
 
     props = wp_properties_new_empty ();
-    wp_properties_setf (props, "out-item", "%p", out_endpoint);
-    wp_properties_setf (props, "in-item", "%p", in_endpoint);
+    wp_properties_setf (props, "out.item", "%p", out_endpoint);
+    wp_properties_setf (props, "in.item", "%p", in_endpoint);
     wp_properties_setf (props, "session", "%p", session);
-    wp_properties_setf (props, "manage-lifetime", "%u", TRUE);
+    wp_properties_setf (props, "manage.lifetime", "%u", TRUE);
 
     if (G_UNLIKELY (!wp_session_item_configure (link, props))) {
       g_critical ("si-standard-link configuration failed");
diff --git a/modules/module-si-audio-adapter.c b/modules/module-si-audio-adapter.c
index 699148fd..82e3150d 100644
--- a/modules/module-si-audio-adapter.c
+++ b/modules/module-si-audio-adapter.c
@@ -103,7 +103,7 @@ si_audio_adapter_configure (WpSessionItem * item, WpProperties *p)
     wp_properties_set (si_props, "name", self->name);
   }
 
-  str = wp_properties_get (si_props, "media-class");
+  str = wp_properties_get (si_props, "media.class");
   if (str) {
     strncpy (self->media_class, str, sizeof (self->media_class) - 1);
   } else {
@@ -112,7 +112,7 @@ si_audio_adapter_configure (WpSessionItem * item, WpProperties *p)
       strncpy (self->media_class, str, sizeof (self->media_class) - 1);
     else
       strncpy (self->media_class, "Unknown", sizeof (self->media_class) - 1);
-    wp_properties_set (si_props, "media-class", self->media_class);
+    wp_properties_set (si_props, "media.class", self->media_class);
   }
 
   str = wp_properties_get (si_props, "role");
@@ -138,29 +138,29 @@ si_audio_adapter_configure (WpSessionItem * item, WpProperties *p)
   if (!str)
     wp_properties_setf (si_props, "priority", "%u", self->priority);
 
-  str = wp_properties_get (si_props, "preferred-n-channels");
+  str = wp_properties_get (si_props, "preferred.n.channels");
   if (str && sscanf(str, "%u", &self->preferred_n_channels) != 1)
     return FALSE;
   if (!str)
-    wp_properties_setf (si_props, "preferred-n-channels", "%u",
+    wp_properties_setf (si_props, "preferred.n.channels", "%u",
         self->preferred_n_channels);
 
-  str = wp_properties_get (si_props, "enable-control-port");
+  str = wp_properties_get (si_props, "enable.control.port");
   if (str && sscanf(str, "%u", &self->control_port) != 1)
     return FALSE;
   if (!str)
-    wp_properties_setf (si_props, "enable-control-port", "%u",
+    wp_properties_setf (si_props, "enable.control.port", "%u",
         self->control_port);
 
-  str = wp_properties_get (si_props, "enable-monitor");
+  str = wp_properties_get (si_props, "enable.monitor");
   if (str && sscanf(str, "%u", &self->monitor) != 1)
     return FALSE;
   if (!str)
-    wp_properties_setf (si_props, "enable-monitor", "%u", self->monitor);
+    wp_properties_setf (si_props, "enable.monitor", "%u", self->monitor);
 
   self->node = g_object_ref (node);
 
-  wp_properties_set (si_props, "si-factory-name", SI_FACTORY_NAME);
+  wp_properties_set (si_props, "si.factory.name", SI_FACTORY_NAME);
   wp_session_item_set_properties (WP_SESSION_ITEM (self),
       g_steal_pointer (&si_props));
   return TRUE;
diff --git a/modules/module-si-audio-convert.c b/modules/module-si-audio-convert.c
index 0ad51120..ed36e4bc 100644
--- a/modules/module-si-audio-convert.c
+++ b/modules/module-si-audio-convert.c
@@ -95,16 +95,16 @@ si_audio_convert_configure (WpSessionItem * item, WpProperties *p)
   if (!str || sscanf(str, "%u", &self->direction) != 1)
     return FALSE;
 
-  str = wp_properties_get (si_props, "enable-control-port");
+  str = wp_properties_get (si_props, "enable.control.port");
   if (str && sscanf(str, "%u", &self->control_port) != 1)
     return FALSE;
   if (!str)
-    wp_properties_setf (si_props, "enable-control-port", "%u",
+    wp_properties_setf (si_props, "enable.control.port", "%u",
         self->control_port);
 
   self->target = g_object_ref (target);
 
-  wp_properties_set (si_props, "si-factory-name", SI_FACTORY_NAME);
+  wp_properties_set (si_props, "si.factory.name", SI_FACTORY_NAME);
   wp_session_item_set_properties (WP_SESSION_ITEM (self),
       g_steal_pointer (&si_props));
   return TRUE;
@@ -159,14 +159,14 @@ do_link_to_target (WpSiAudioConvert *self)
   props = wp_properties_new_empty ();
   if (self->direction == WP_DIRECTION_INPUT) {
       /* Playback */
-      wp_properties_setf (props, "out-item", "%p", self);
-      wp_properties_setf (props, "in-item", "%p", self->target);
-      wp_properties_set (props, "out-item-port-context", "reverse");
+      wp_properties_setf (props, "out.item", "%p", self);
+      wp_properties_setf (props, "in.item", "%p", self->target);
+      wp_properties_set (props, "out.item.port.context", "reverse");
   } else {
       /* Capture */
-      wp_properties_setf (props, "out-item", "%p", self->target);
-      wp_properties_setf (props, "in-item", "%p", self);
-      wp_properties_set (props, "in-item-port-context", "reverse");
+      wp_properties_setf (props, "out.item", "%p", self->target);
+      wp_properties_setf (props, "in.item", "%p", self);
+      wp_properties_set (props, "in.item.port.context", "reverse");
   }
 
   /* always create passive links; that means that they won't hold the graph
@@ -275,7 +275,7 @@ si_audio_convert_enable_active (WpSessionItem *si, WpTransition *transition)
 
   /* set channels & rate */
   target_props = wp_session_item_get_properties (self->target);
-  str = wp_properties_get (target_props, "preferred-n-channels");
+  str = wp_properties_get (target_props, "preferred.n.channels");
   if (!str || sscanf(str, "%u", &channels) != 1)
     channels = 2;
   rate = ({
diff --git a/modules/module-si-audio-endpoint.c b/modules/module-si-audio-endpoint.c
index 2528b0eb..e771f9e9 100644
--- a/modules/module-si-audio-endpoint.c
+++ b/modules/module-si-audio-endpoint.c
@@ -127,7 +127,7 @@ si_audio_endpoint_configure (WpSessionItem * item, WpProperties *p)
   if (session)
     self->session = g_object_ref (session);
 
-  wp_properties_set (si_props, "si-factory-name", SI_FACTORY_NAME);
+  wp_properties_set (si_props, "si.factory.name", SI_FACTORY_NAME);
   wp_session_item_set_properties (WP_SESSION_ITEM (self),
       g_steal_pointer (&si_props));
   return TRUE;
@@ -196,14 +196,14 @@ link_to_target (WpSiAudioEndpoint * self)
   props = wp_properties_new_empty ();
   if (self->direction == WP_DIRECTION_INPUT) {
       /* Playback */
-      wp_properties_setf (props, "out-item", "%p", self);
-      wp_properties_setf (props, "in-item", "%p", self->target);
-      wp_properties_set (props, "out-item-port-context", "reverse");
+      wp_properties_setf (props, "out.item", "%p", self);
+      wp_properties_setf (props, "in.item", "%p", self->target);
+      wp_properties_set (props, "out.item.port.context", "reverse");
   } else {
       /* Capture */
-      wp_properties_setf (props, "out-item", "%p", self->target);
-      wp_properties_setf (props, "in-item", "%p", self);
-      wp_properties_set (props, "in-item-port-context", "reverse");
+      wp_properties_setf (props, "out.item", "%p", self->target);
+      wp_properties_setf (props, "in.item", "%p", self);
+      wp_properties_set (props, "in.item.port.context", "reverse");
   }
 
   /* always create passive links; that means that they won't hold the graph
diff --git a/modules/module-si-node.c b/modules/module-si-node.c
index b1822b63..1db0dfe9 100644
--- a/modules/module-si-node.c
+++ b/modules/module-si-node.c
@@ -86,7 +86,7 @@ si_node_configure (WpSessionItem * item, WpProperties *p)
     wp_properties_set (si_props, "name", self->name);
   }
 
-  str = wp_properties_get (si_props, "media-class");
+  str = wp_properties_get (si_props, "media.class");
   if (str) {
     strncpy (self->media_class, str, sizeof (self->media_class) - 1);
   } else {
@@ -95,7 +95,7 @@ si_node_configure (WpSessionItem * item, WpProperties *p)
       strncpy (self->media_class, str, sizeof (self->media_class) - 1);
     else
       strncpy (self->media_class, "Unknown", sizeof (self->media_class) - 1);
-    wp_properties_set (si_props, "media-class", self->media_class);
+    wp_properties_set (si_props, "media.class", self->media_class);
   }
 
   str = wp_properties_get (si_props, "role");
@@ -123,7 +123,7 @@ si_node_configure (WpSessionItem * item, WpProperties *p)
 
   self->node = g_object_ref (node);
 
-  wp_properties_set (si_props, "si-factory-name", SI_FACTORY_NAME);
+  wp_properties_set (si_props, "si.factory.name", SI_FACTORY_NAME);
   wp_session_item_set_properties (WP_SESSION_ITEM (self),
       g_steal_pointer (&si_props));
   return TRUE;
diff --git a/modules/module-si-standard-link.c b/modules/module-si-standard-link.c
index 9eac5caf..d6926f25 100644
--- a/modules/module-si-standard-link.c
+++ b/modules/module-si-standard-link.c
@@ -140,29 +140,29 @@ si_standard_link_configure (WpSessionItem * item, WpProperties * p)
   /* reset previous config */
   si_standard_link_reset (item);
 
-  out_item = get_and_validate_item (si_props, "out-item");
+  out_item = get_and_validate_item (si_props, "out.item");
   if (!out_item)
     return FALSE;
-  wp_properties_setf (si_props, "out-item-id", "%u",
+  wp_properties_setf (si_props, "out.item.id", "%u",
       wp_session_item_get_id (out_item));
 
-  in_item = get_and_validate_item (si_props, "in-item");
+  in_item = get_and_validate_item (si_props, "in.item");
   if (!in_item)
     return FALSE;
-  wp_properties_setf (si_props, "in-item-id", "%u",
+  wp_properties_setf (si_props, "in.item.id", "%u",
       wp_session_item_get_id (in_item));
 
   self->out_item_port_context = wp_properties_get (si_props,
-      "out-item-port-context");
+      "out.item.port.context");
 
   self->out_item_port_context = wp_properties_get (si_props,
-      "in-item-port-context");
+      "in.item.port.context");
 
-  str = wp_properties_get (si_props, "manage-lifetime");
+  str = wp_properties_get (si_props, "manage.lifetime");
   if (str && sscanf(str, "%u", &self->manage_lifetime) != 1)
     return FALSE;
   if (!str)
-    wp_properties_setf (si_props, "manage-lifetime", "%u",
+    wp_properties_setf (si_props, "manage.lifetime", "%u",
         self->manage_lifetime);
 
   str = wp_properties_get (si_props, "passive");
@@ -193,7 +193,7 @@ si_standard_link_configure (WpSessionItem * item, WpProperties * p)
   if (session)
     self->session = g_object_ref (session);
 
-  wp_properties_set (si_props, "si-factory-name", SI_FACTORY_NAME);
+  wp_properties_set (si_props, "si.factory.name", SI_FACTORY_NAME);
   wp_session_item_set_properties (WP_SESSION_ITEM (self),
       g_steal_pointer (&si_props));
   return TRUE;
diff --git a/src/scripts/policy-node.lua b/src/scripts/policy-node.lua
index 1ae2035c..3bdb9a6c 100644
--- a/src/scripts/policy-node.lua
+++ b/src/scripts/policy-node.lua
@@ -52,11 +52,11 @@ function createLink (si, si_target)
   -- create and configure link
   local si_link = SessionItem ( "si-standard-link" )
   if not si_link:configure {
-    ["out-item"] = out_item,
-    ["in-item"] = in_item,
-    ["out-item-port-context"] = out_context,
-    ["in-item-port-context"] = in_context,
-    ["manage-lifetime"] = false,
+    ["out.item"] = out_item,
+    ["in.item"] = in_item,
+    ["out.item.port.context"] = out_context,
+    ["in.item.port.context"] = in_context,
+    ["manage.lifetime"] = false,
   } then
     Log.warning (si_link, "failed to configure si-standard-link")
   end
@@ -137,8 +137,8 @@ end
 
 function getSiLinkAndSiPeer (si)
   for silink in silinks_om:iterate() do
-    local out_id = tonumber(silink.properties["out-item-id"])
-    local in_id = tonumber(silink.properties["in-item-id"])
+    local out_id = tonumber(silink.properties["out.item.id"])
+    local in_id = tonumber(silink.properties["in.item.id"])
     if out_id == si.id then
       return silink, siportinfos_om:lookup {
         Constraint { "id", "=", in_id, type = "gobject" }
@@ -201,8 +201,8 @@ function reevaluateLinks ()
   for silink in silinks_om:iterate() do
     local used = false
     for si in siportinfos_om:iterate() do
-      local out_id_str = silink.properties["out-item-id"]
-      local in_id_str = silink.properties["out-item-id"]
+      local out_id_str = silink.properties["out.item.id"]
+      local in_id_str = silink.properties["out.item.id"]
       if tonumber (out_id_str) == si.id or tonumber (in_id_str) == si.id then
         used = true
         break
diff --git a/tests/modules/si-audio-adapter.c b/tests/modules/si-audio-adapter.c
index 21bf1c73..5b551b62 100644
--- a/tests/modules/si-audio-adapter.c
+++ b/tests/modules/si-audio-adapter.c
@@ -86,7 +86,7 @@ test_si_audio_adapter_configure_activate (TestFixture * f,
     str = wp_properties_get (props, "name");
     g_assert_nonnull (str);
     g_assert_cmpstr ("audiotestsrc.adapter", ==, str);
-    str = wp_properties_get (props, "media-class");
+    str = wp_properties_get (props, "media.class");
     g_assert_nonnull (str);
     g_assert_cmpstr ("Audio/Source", ==, str);
     str = wp_properties_get (props, "role");
@@ -98,16 +98,16 @@ test_si_audio_adapter_configure_activate (TestFixture * f,
     str = wp_properties_get (props, "priority");
     g_assert_nonnull (str);
     g_assert_cmpstr ("0", ==, str);
-    str = wp_properties_get (props, "preferred-n-channels");
+    str = wp_properties_get (props, "preferred.n.channels");
     g_assert_nonnull (str);
     g_assert_cmpstr ("0", ==, str);
-    str = wp_properties_get (props, "enable-control-port");
+    str = wp_properties_get (props, "enable.control.port");
     g_assert_nonnull (str);
     g_assert_cmpstr ("0", ==, str);
-    str = wp_properties_get (props, "enable-monitor");
+    str = wp_properties_get (props, "enable.monitor");
     g_assert_nonnull (str);
     g_assert_cmpstr ("0", ==, str);
-    str = wp_properties_get (props, "si-factory-name");
+    str = wp_properties_get (props, "si.factory.name");
     g_assert_nonnull (str);
     g_assert_cmpstr ("si-audio-adapter", ==, str);
   }
diff --git a/tests/modules/si-audio-convert.c b/tests/modules/si-audio-convert.c
index a3e8b3c3..6fc6e03c 100644
--- a/tests/modules/si-audio-convert.c
+++ b/tests/modules/si-audio-convert.c
@@ -116,10 +116,10 @@ test_si_audio_convert_configure_activate (TestFixture * f,
     str = wp_properties_get (props, "direction");
     g_assert_nonnull (str);
     g_assert_cmpstr ("1", ==, str);
-    str = wp_properties_get (props, "enable-control-port");
+    str = wp_properties_get (props, "enable.control.port");
     g_assert_nonnull (str);
     g_assert_cmpstr ("0", ==, str);
-    str = wp_properties_get (props, "si-factory-name");
+    str = wp_properties_get (props, "si.factory.name");
     g_assert_nonnull (str);
     g_assert_cmpstr ("si-audio-convert", ==, str);
   }
diff --git a/tests/modules/si-audio-endpoint.c b/tests/modules/si-audio-endpoint.c
index 73e9dc38..4773ed4c 100644
--- a/tests/modules/si-audio-endpoint.c
+++ b/tests/modules/si-audio-endpoint.c
@@ -116,7 +116,7 @@ test_si_audio_endpoint_configure_activate (TestFixture * f,
     str = wp_properties_get (props, "direction");
     g_assert_nonnull (str);
     g_assert_cmpstr ("1", ==, str);
-    str = wp_properties_get (props, "si-factory-name");
+    str = wp_properties_get (props, "si.factory.name");
     g_assert_nonnull (str);
     g_assert_cmpstr ("si-audio-endpoint", ==, str);
   }
diff --git a/tests/modules/si-node.c b/tests/modules/si-node.c
index 8f1165f5..68885a2e 100644
--- a/tests/modules/si-node.c
+++ b/tests/modules/si-node.c
@@ -81,7 +81,7 @@ test_si_node_configure_activate (TestFixture * f, gconstpointer user_data)
   {
     WpProperties *props = wp_properties_new_empty ();
     wp_properties_setf (props, "node", "%p", node);
-    wp_properties_set (props, "media-class", data->media_class);
+    wp_properties_set (props, "media.class", data->media_class);
     g_assert_true (wp_session_item_configure (item, props));
     g_assert_true (wp_session_item_is_configured (item));
   }
@@ -93,13 +93,13 @@ test_si_node_configure_activate (TestFixture * f, gconstpointer user_data)
     str = wp_properties_get (props, "name");
     g_assert_nonnull (str);
     g_assert_cmpstr (data->name, ==, str);
-    str = wp_properties_get (props, "media-class");
+    str = wp_properties_get (props, "media.class");
     g_assert_nonnull (str);
     g_assert_cmpstr (data->expected_media_class, ==, str);
     str = wp_properties_get (props, "direction");
     g_assert_nonnull (str);
     g_assert_cmpstr (data->expected_direction == 0 ? "0" : "1", ==, str);
-    str = wp_properties_get (props, "si-factory-name");
+    str = wp_properties_get (props, "si.factory.name");
     g_assert_nonnull (str);
     g_assert_cmpstr ("si-node", ==, str);
   }
@@ -158,13 +158,13 @@ test_si_node_configure_activate (TestFixture * f, gconstpointer user_data)
     str = wp_properties_get (props, "name");
     g_assert_nonnull (str);
     g_assert_cmpstr (data->name, ==, str);
-    str = wp_properties_get (props, "media-class");
+    str = wp_properties_get (props, "media.class");
     g_assert_nonnull (str);
     g_assert_cmpstr (data->expected_media_class, ==, str);
     str = wp_properties_get (props, "direction");
     g_assert_nonnull (str);
     g_assert_cmpstr (data->expected_direction == 0 ? "0" : "1", ==, str);
-    str = wp_properties_get (props, "si-factory-name");
+    str = wp_properties_get (props, "si.factory.name");
     g_assert_nonnull (str);
     g_assert_cmpstr ("si-node", ==, str);
   }
diff --git a/tests/modules/si-standard-link.c b/tests/modules/si-standard-link.c
index 27d111da..56ebe311 100644
--- a/tests/modules/si-standard-link.c
+++ b/tests/modules/si-standard-link.c
@@ -47,7 +47,7 @@ load_endpoint (TestFixture * f, const gchar * factory, const gchar * media_class
     WpProperties *props = wp_properties_new_empty ();
     wp_properties_setf (props, "node", "%p", target_node);
     wp_properties_set (props, "name", factory);
-    wp_properties_set (props, "media-class", media_class);
+    wp_properties_set (props, "media.class", media_class);
     wp_properties_set (props, "role", "role");
     g_assert_true (wp_session_item_configure (target, props));
     g_assert_true (wp_session_item_is_configured (target));
-- 
GitLab