Commit d68636f9 authored by Julian Bouzas's avatar Julian Bouzas
Browse files

si-interfaces: rename WpSiPortInfo to WpSiLinkable

parent ee121e30
......@@ -395,8 +395,8 @@ wp_impl_endpoint_link_constructed (GObject * object)
g_autoptr (GVariant) info = NULL;
g_autoptr (GVariantIter) immutable_props = NULL;
const gchar *key, *value;
g_autoptr (WpSiPortInfo) si_out = NULL;
g_autoptr (WpSiPortInfo) si_in = NULL;
g_autoptr (WpSiLinkable) si_out = NULL;
g_autoptr (WpSiLinkable) si_in = NULL;
self->info.version = PW_VERSION_ENDPOINT_LINK_INFO;
self->info.error = NULL;
......
......@@ -76,27 +76,27 @@ wp_si_endpoint_get_properties (WpSiEndpoint * self)
}
/**
* WpSiPortInfo:
* WpSiLinkable:
*
* An interface for retrieving PipeWire port information from a session item.
* This information is used to create links in the nodes graph.
*/
G_DEFINE_INTERFACE (WpSiPortInfo, wp_si_port_info, WP_TYPE_SESSION_ITEM)
G_DEFINE_INTERFACE (WpSiLinkable, wp_si_linkable, WP_TYPE_SESSION_ITEM)
static WpSiAcquisition *
wp_si_port_info_default_get_acquisition (WpSiPortInfo * self)
wp_si_linkable_default_get_acquisition (WpSiLinkable * self)
{
return NULL;
}
static void
wp_si_port_info_default_init (WpSiPortInfoInterface * iface)
wp_si_linkable_default_init (WpSiLinkableInterface * iface)
{
iface->get_acquisition = wp_si_port_info_default_get_acquisition;
iface->get_acquisition = wp_si_linkable_default_get_acquisition;
}
/**
* wp_si_port_info_get_ports: (virtual get_ports)
* wp_si_linkable_get_ports: (virtual get_ports)
* @self: the session item
* @context: (nullable): an optional context for the ports
*
......@@ -123,12 +123,12 @@ wp_si_port_info_default_init (WpSiPortInfoInterface * iface)
* Contexts other than %NULL may only be used internally to ease the
* implementation of more complex item relationships. For example, a
* #WpSessionItem that is in control of an input (sink) adapter node may
* implement #WpSiPortInfo where the %NULL context will return the standard
* implement #WpSiLinkable where the %NULL context will return the standard
* input ports and the "monitor" context will return the adapter's monitor
* ports. When linking this item to another item, the %NULL context
* will always be used, but the item may internally spawn a secondary
* #WpSessionItem that implements the "monitor" item. That secondary
* item may implement #WpSiPortInfo, chaining calls to the #WpSiPortInfo
* item may implement #WpSiLinkable, chaining calls to the #WpSiLinkable
* of the original item using the "monitor" context. This way, the monitor
* #WpSessionItem does not need to share control of the underlying node; it
* only proxies calls to satisfy the API.
......@@ -137,16 +137,16 @@ wp_si_port_info_default_init (WpSiPortInfoInterface * iface)
* ports of this item
*/
GVariant *
wp_si_port_info_get_ports (WpSiPortInfo * self, const gchar * context)
wp_si_linkable_get_ports (WpSiLinkable * self, const gchar * context)
{
g_return_val_if_fail (WP_IS_SI_PORT_INFO (self), NULL);
g_return_val_if_fail (WP_SI_PORT_INFO_GET_IFACE (self)->get_ports, NULL);
g_return_val_if_fail (WP_IS_SI_LINKABLE (self), NULL);
g_return_val_if_fail (WP_SI_LINKABLE_GET_IFACE (self)->get_ports, NULL);
return WP_SI_PORT_INFO_GET_IFACE (self)->get_ports (self, context);
return WP_SI_LINKABLE_GET_IFACE (self)->get_ports (self, context);
}
/**
* wp_si_port_info_get_acquisition: (virtual get_acquisition)
* wp_si_linkable_get_acquisition: (virtual get_acquisition)
* @self: the session item
*
* Returns: (transfer none) (nullable): the acquisition interface associated
......@@ -154,13 +154,13 @@ wp_si_port_info_get_ports (WpSiPortInfo * self, const gchar * context)
* before linking them
*/
WpSiAcquisition *
wp_si_port_info_get_acquisition (WpSiPortInfo * self)
wp_si_linkable_get_acquisition (WpSiLinkable * self)
{
g_return_val_if_fail (WP_IS_SI_PORT_INFO (self), NULL);
g_return_val_if_fail (WP_IS_SI_LINKABLE (self), NULL);
g_return_val_if_fail (
WP_SI_PORT_INFO_GET_IFACE (self)->get_acquisition, NULL);
WP_SI_LINKABLE_GET_IFACE (self)->get_acquisition, NULL);
return WP_SI_PORT_INFO_GET_IFACE (self)->get_acquisition (self);
return WP_SI_LINKABLE_GET_IFACE (self)->get_acquisition (self);
}
/**
......@@ -225,7 +225,7 @@ wp_si_link_get_properties (WpSiLink * self)
*
* Returns: (transfer none): the output item that is linked by this link
*/
WpSiPortInfo *
WpSiLinkable *
wp_si_link_get_out_item (WpSiLink * self)
{
g_return_val_if_fail (WP_IS_SI_LINK (self), NULL);
......@@ -240,7 +240,7 @@ wp_si_link_get_out_item (WpSiLink * self)
*
* Returns: (transfer none): the input item that is linked by this link
*/
WpSiPortInfo *
WpSiLinkable *
wp_si_link_get_in_item (WpSiLink * self)
{
g_return_val_if_fail (WP_IS_SI_LINK (self), NULL);
......@@ -255,8 +255,8 @@ wp_si_link_get_in_item (WpSiLink * self)
* This interface provides a way to request an item for linking before doing
* so. This allows item implementations to apply internal policy rules.
*
* A #WpSiAcquisition is associated directly with a #WpSiPortInfo via
* wp_si_port_info_get_acquisition(). In order to allow switching policies, it
* A #WpSiAcquisition is associated directly with a #WpSiLinkable via
* wp_si_linkable_get_acquisition(). In order to allow switching policies, it
* is recommended that port info implementations use a separate
* session item to implement this interface and allow replacing it.
*/
......@@ -287,7 +287,7 @@ wp_si_acquisition_default_init (WpSiAcquisitionInterface * iface)
*/
void
wp_si_acquisition_acquire (WpSiAcquisition * self, WpSiLink * acquisitor,
WpSiPortInfo * item, GAsyncReadyCallback callback, gpointer data)
WpSiLinkable * item, GAsyncReadyCallback callback, gpointer data)
{
g_return_if_fail (WP_IS_SI_ACQUISITION (self));
g_return_if_fail (WP_SI_ACQUISITION_GET_IFACE (self)->acquire);
......@@ -328,7 +328,7 @@ wp_si_acquisition_acquire_finish (WpSiAcquisition * self, GAsyncResult * res,
*/
void
wp_si_acquisition_release (WpSiAcquisition * self, WpSiLink * acquisitor,
WpSiPortInfo * item)
WpSiLinkable * item)
{
g_return_if_fail (WP_IS_SI_ACQUISITION (self));
g_return_if_fail (WP_SI_ACQUISITION_GET_IFACE (self)->release);
......
......@@ -41,29 +41,29 @@ WP_API
WpProperties * wp_si_endpoint_get_properties (WpSiEndpoint * self);
/**
* WP_TYPE_SI_PORT_INFO:
* WP_TYPE_SI_LINKABLE:
*
* The #WpSiPortInfo #GType
* The #WpSiLinkable #GType
*/
#define WP_TYPE_SI_PORT_INFO (wp_si_port_info_get_type ())
#define WP_TYPE_SI_LINKABLE (wp_si_linkable_get_type ())
WP_API
G_DECLARE_INTERFACE (WpSiPortInfo, wp_si_port_info,
WP, SI_PORT_INFO, WpSessionItem)
G_DECLARE_INTERFACE (WpSiLinkable, wp_si_linkable,
WP, SI_LINKABLE, WpSessionItem)
struct _WpSiPortInfoInterface
struct _WpSiLinkableInterface
{
GTypeInterface interface;
GVariant * (*get_ports) (WpSiPortInfo * self, const gchar * context);
WpSiAcquisition * (*get_acquisition) (WpSiPortInfo * self);
GVariant * (*get_ports) (WpSiLinkable * self, const gchar * context);
WpSiAcquisition * (*get_acquisition) (WpSiLinkable * self);
};
WP_API
GVariant * wp_si_port_info_get_ports (WpSiPortInfo * self,
GVariant * wp_si_linkable_get_ports (WpSiLinkable * self,
const gchar * context);
WP_API
WpSiAcquisition * wp_si_port_info_get_acquisition (WpSiPortInfo * self);
WpSiAcquisition * wp_si_linkable_get_acquisition (WpSiLinkable * self);
/**
* WP_TYPE_SI_LINK:
......@@ -82,8 +82,8 @@ struct _WpSiLinkInterface
GVariant * (*get_registration_info) (WpSiLink * self);
WpProperties * (*get_properties) (WpSiLink * self);
WpSiPortInfo * (*get_out_item) (WpSiLink * self);
WpSiPortInfo * (*get_in_item) (WpSiLink * self);
WpSiLinkable * (*get_out_item) (WpSiLink * self);
WpSiLinkable * (*get_in_item) (WpSiLink * self);
};
WP_API
......@@ -93,10 +93,10 @@ WP_API
WpProperties * wp_si_link_get_properties (WpSiLink * self);
WP_API
WpSiPortInfo * wp_si_link_get_out_item (WpSiLink * self);
WpSiLinkable * wp_si_link_get_out_item (WpSiLink * self);
WP_API
WpSiPortInfo * wp_si_link_get_in_item (WpSiLink * self);
WpSiLinkable * wp_si_link_get_in_item (WpSiLink * self);
/**
* WP_TYPE_SI_ACQUISITION:
......@@ -113,17 +113,17 @@ struct _WpSiAcquisitionInterface
GTypeInterface interface;
void (*acquire) (WpSiAcquisition * self, WpSiLink * acquisitor,
WpSiPortInfo * item, GAsyncReadyCallback callback, gpointer data);
WpSiLinkable * item, GAsyncReadyCallback callback, gpointer data);
gboolean (*acquire_finish) (WpSiAcquisition * self, GAsyncResult * res,
GError ** error);
void (*release) (WpSiAcquisition * self, WpSiLink * acquisitor,
WpSiPortInfo * item);
WpSiLinkable * item);
};
WP_API
void wp_si_acquisition_acquire (WpSiAcquisition * self, WpSiLink * acquisitor,
WpSiPortInfo * item, GAsyncReadyCallback callback, gpointer data);
WpSiLinkable * item, GAsyncReadyCallback callback, gpointer data);
WP_API
gboolean wp_si_acquisition_acquire_finish (
......@@ -131,7 +131,7 @@ gboolean wp_si_acquisition_acquire_finish (
WP_API
void wp_si_acquisition_release (WpSiAcquisition * self, WpSiLink * acquisitor,
WpSiPortInfo * item);
WpSiLinkable * item);
G_END_DECLS
......
......@@ -38,13 +38,13 @@ struct _WpSiAudioAdapter
struct spa_audio_info_raw format;
};
static void si_audio_adapter_port_info_init (WpSiPortInfoInterface * iface);
static void si_audio_adapter_linkable_init (WpSiLinkableInterface * iface);
G_DECLARE_FINAL_TYPE(WpSiAudioAdapter, si_audio_adapter, WP, SI_AUDIO_ADAPTER,
WpSessionItem)
G_DEFINE_TYPE_WITH_CODE (WpSiAudioAdapter, si_audio_adapter,
WP_TYPE_SESSION_ITEM,
G_IMPLEMENT_INTERFACE (WP_TYPE_SI_PORT_INFO, si_audio_adapter_port_info_init))
G_IMPLEMENT_INTERFACE (WP_TYPE_SI_LINKABLE, si_audio_adapter_linkable_init))
static void
si_audio_adapter_init (WpSiAudioAdapter * self)
......@@ -384,7 +384,7 @@ si_audio_adapter_class_init (WpSiAudioAdapterClass * klass)
}
static GVariant *
si_audio_adapter_get_ports (WpSiPortInfo * item, const gchar * context)
si_audio_adapter_get_ports (WpSiLinkable * item, const gchar * context)
{
WpSiAudioAdapter *self = WP_SI_AUDIO_ADAPTER (item);
g_auto (GVariantBuilder) b = G_VARIANT_BUILDER_INIT (G_VARIANT_TYPE_ARRAY);
......@@ -438,7 +438,7 @@ si_audio_adapter_get_ports (WpSiPortInfo * item, const gchar * context)
}
static void
si_audio_adapter_port_info_init (WpSiPortInfoInterface * iface)
si_audio_adapter_linkable_init (WpSiLinkableInterface * iface)
{
iface->get_ports = si_audio_adapter_get_ports;
}
......
......@@ -33,15 +33,15 @@ struct _WpSiAudioEndpoint
};
static void si_audio_endpoint_endpoint_init (WpSiEndpointInterface * iface);
static void si_audio_endpoint_port_info_init (WpSiPortInfoInterface * iface);
static void si_audio_endpoint_linkable_init (WpSiLinkableInterface * iface);
G_DECLARE_FINAL_TYPE(WpSiAudioEndpoint, si_audio_endpoint, WP,
SI_AUDIO_ENDPOINT, WpSessionItem)
G_DEFINE_TYPE_WITH_CODE (WpSiAudioEndpoint, si_audio_endpoint,
WP_TYPE_SESSION_ITEM,
G_IMPLEMENT_INTERFACE (WP_TYPE_SI_ENDPOINT, si_audio_endpoint_endpoint_init)
G_IMPLEMENT_INTERFACE (WP_TYPE_SI_PORT_INFO,
si_audio_endpoint_port_info_init))
G_IMPLEMENT_INTERFACE (WP_TYPE_SI_LINKABLE,
si_audio_endpoint_linkable_init))
static void
si_audio_endpoint_init (WpSiAudioEndpoint * self)
......@@ -341,7 +341,7 @@ si_audio_endpoint_endpoint_init (WpSiEndpointInterface * iface)
}
static GVariant *
si_audio_endpoint_get_ports (WpSiPortInfo * item, const gchar * context)
si_audio_endpoint_get_ports (WpSiLinkable * item, const gchar * context)
{
WpSiAudioEndpoint *self = WP_SI_AUDIO_ENDPOINT (item);
g_auto (GVariantBuilder) b = G_VARIANT_BUILDER_INIT (G_VARIANT_TYPE_ARRAY);
......@@ -395,7 +395,7 @@ si_audio_endpoint_get_ports (WpSiPortInfo * item, const gchar * context)
}
static void
si_audio_endpoint_port_info_init (WpSiPortInfoInterface * iface)
si_audio_endpoint_linkable_init (WpSiLinkableInterface * iface)
{
iface->get_ports = si_audio_endpoint_get_ports;
}
......
......@@ -26,11 +26,11 @@ struct _WpSiNode
WpDirection direction;
};
static void si_node_port_info_init (WpSiPortInfoInterface * iface);
static void si_node_linkable_init (WpSiLinkableInterface * iface);
G_DECLARE_FINAL_TYPE(WpSiNode, si_node, WP, SI_NODE, WpSessionItem)
G_DEFINE_TYPE_WITH_CODE (WpSiNode, si_node, WP_TYPE_SESSION_ITEM,
G_IMPLEMENT_INTERFACE (WP_TYPE_SI_PORT_INFO, si_node_port_info_init))
G_IMPLEMENT_INTERFACE (WP_TYPE_SI_LINKABLE, si_node_linkable_init))
static void
si_node_init (WpSiNode * self)
......@@ -204,7 +204,7 @@ si_node_class_init (WpSiNodeClass * klass)
}
static GVariant *
si_node_get_ports (WpSiPortInfo * item, const gchar * context)
si_node_get_ports (WpSiLinkable * item, const gchar * context)
{
WpSiNode *self = WP_SI_NODE (item);
g_auto (GVariantBuilder) b = G_VARIANT_BUILDER_INIT (G_VARIANT_TYPE_ARRAY);
......@@ -258,7 +258,7 @@ si_node_get_ports (WpSiPortInfo * item, const gchar * context)
}
static void
si_node_port_info_init (WpSiPortInfoInterface * iface)
si_node_linkable_init (WpSiLinkableInterface * iface)
{
iface->get_ports = si_node_get_ports;
}
......
......@@ -120,7 +120,7 @@ get_and_validate_item (WpProperties * props, const gchar *key)
const gchar *str = NULL;
str = wp_properties_get (props, key);
if (!str || sscanf(str, "%p", &res) != 1 || !WP_IS_SI_PORT_INFO (res) ||
if (!str || sscanf(str, "%p", &res) != 1 || !WP_IS_SI_LINKABLE (res) ||
!(wp_object_get_active_features (WP_OBJECT (res)) &
WP_SESSION_ITEM_FEATURE_ACTIVE))
return NULL;
......@@ -222,17 +222,17 @@ si_standard_link_disable_active (WpSessionItem *si)
WpSiAcquisition *out_acquisition, *in_acquisition;
if (si_out) {
out_acquisition = wp_si_port_info_get_acquisition (
WP_SI_PORT_INFO (si_out));
out_acquisition = wp_si_linkable_get_acquisition (
WP_SI_LINKABLE (si_out));
if (out_acquisition)
wp_si_acquisition_release (out_acquisition, WP_SI_LINK (self),
WP_SI_PORT_INFO (si_out));
WP_SI_LINKABLE (si_out));
}
if (si_in) {
in_acquisition = wp_si_port_info_get_acquisition (WP_SI_PORT_INFO (si_in));
in_acquisition = wp_si_linkable_get_acquisition (WP_SI_LINKABLE (si_in));
if (in_acquisition)
wp_si_acquisition_release (in_acquisition, WP_SI_LINK (self),
WP_SI_PORT_INFO (si_in));
WP_SI_LINKABLE (si_in));
}
g_clear_pointer (&self->node_links, g_ptr_array_unref);
......@@ -412,9 +412,9 @@ si_standard_link_do_link (WpSiStandardLink *self, WpTransition *transition)
g_autoptr (GVariant) out_ports = NULL;
g_autoptr (GVariant) in_ports = NULL;
out_ports = wp_si_port_info_get_ports (WP_SI_PORT_INFO (si_out),
out_ports = wp_si_linkable_get_ports (WP_SI_LINKABLE (si_out),
self->out_item_port_context);
in_ports = wp_si_port_info_get_ports (WP_SI_PORT_INFO (si_in),
in_ports = wp_si_linkable_get_ports (WP_SI_LINKABLE (si_in),
self->in_item_port_context);
if (!create_links (self, transition, out_ports, in_ports))
......@@ -449,8 +449,8 @@ si_standard_link_enable_active (WpSessionItem *si, WpTransition *transition)
}
/* acquire */
out_acquisition = wp_si_port_info_get_acquisition (WP_SI_PORT_INFO (si_out));
in_acquisition = wp_si_port_info_get_acquisition (WP_SI_PORT_INFO (si_in));
out_acquisition = wp_si_linkable_get_acquisition (WP_SI_LINKABLE (si_out));
in_acquisition = wp_si_linkable_get_acquisition (WP_SI_LINKABLE (si_in));
if (out_acquisition && in_acquisition)
self->n_async_ops_wait = 2;
else if (out_acquisition || in_acquisition)
......@@ -463,12 +463,12 @@ si_standard_link_enable_active (WpSessionItem *si, WpTransition *transition)
if (out_acquisition) {
wp_si_acquisition_acquire (out_acquisition, WP_SI_LINK (self),
WP_SI_PORT_INFO (si_out), (GAsyncReadyCallback) on_item_acquired,
WP_SI_LINKABLE (si_out), (GAsyncReadyCallback) on_item_acquired,
transition);
}
if (in_acquisition) {
wp_si_acquisition_acquire (in_acquisition, WP_SI_LINK (self),
WP_SI_PORT_INFO (si_in), (GAsyncReadyCallback) on_item_acquired,
WP_SI_LINKABLE (si_in), (GAsyncReadyCallback) on_item_acquired,
transition);
}
}
......@@ -542,18 +542,18 @@ si_standard_link_get_registration_info (WpSiLink * item)
return g_variant_builder_end (&b);
}
static WpSiPortInfo *
static WpSiLinkable *
si_standard_link_get_out_item (WpSiLink * item)
{
WpSiStandardLink *self = WP_SI_STANDARD_LINK (item);
return WP_SI_PORT_INFO (g_weak_ref_get (&self->out_item));
return WP_SI_LINKABLE (g_weak_ref_get (&self->out_item));
}
static WpSiPortInfo *
static WpSiLinkable *
si_standard_link_get_in_item (WpSiLink * item)
{
WpSiStandardLink *self = WP_SI_STANDARD_LINK (item);
return WP_SI_PORT_INFO (g_weak_ref_get (&self->in_item));
return WP_SI_LINKABLE (g_weak_ref_get (&self->in_item));
}
static void
......
......@@ -128,7 +128,8 @@ function getSiLinkAndSiPeerEndpoint (si)
return nil, nil
end
function isSiPortInfoValid (si)
function isSiLinkableValid (si)
-- only handle session items that has a node associated proxy
local node = si:get_associated_proxy ("node")
if not node or not node.properties then
......@@ -151,9 +152,9 @@ function isSiPortInfoValid (si)
return true
end
function handleSiPortInfo (si)
function handleSiLinkable (si)
-- check if item is valid
if not isSiPortInfoValid (si) then
if not isSiLinkableValid (si) then
return
end
......@@ -186,9 +187,9 @@ function handleSiPortInfo (si)
createLink (si, si_target_ep)
end
function unhandleSiPortInfo (si)
function unhandleSiLinkable (si)
-- check if item is valid
if not isSiPortInfoValid (si) then
if not isSiLinkableValid (si) then
return
end
......@@ -199,7 +200,7 @@ function unhandleSiPortInfo (si)
for silink in silinks_om:iterate() do
local out_id = tostring (silink.properties["out.item.id"])
local in_id = tostring (silink.properties["in.item.id"])
for si in siportinfos_om:iterate() do
for si in silinkables_om:iterate() do
if out_id == si.id or in_id == si.id then
silink:remove ()
Log.info (silink, "link removed")
......@@ -209,7 +210,7 @@ function unhandleSiPortInfo (si)
end
siendpoints_om = ObjectManager { Interest { type = "SiEndpoint" }}
siportinfos_om = ObjectManager { Interest { type = "SiPortInfo",
silinkables_om = ObjectManager { Interest { type = "SiLinkable",
-- only handle si-audio-adapter and si-node
Constraint {
"si.factory.name", "c", "si-audio-adapter", "si-node", type = "pw-global" },
......@@ -220,14 +221,14 @@ silinks_om = ObjectManager { Interest { type = "SiLink",
Constraint { "is.policy.endpoint.client.link", "=", true, type = "pw-global" },
} }
siportinfos_om:connect("object-added", function (om, si)
handleSiPortInfo (si)
silinkables_om:connect("object-added", function (om, si)
handleSiLinkable (si)
end)
siportinfos_om:connect("object-removed", function (om, si)
unhandleSiPortInfo (si)
silinkables_om:connect("object-removed", function (om, si)
unhandleSiLinkable (si)
end)
siendpoints_om:activate()
siportinfos_om:activate()
silinkables_om:activate()
silinks_om:activate()
......@@ -108,7 +108,7 @@ function getSiLinkAndSiPeer (si_ep, target_media_class)
local in_id = tonumber(silink.properties["in.item.id"])
if out_id == si_ep.id or in_id == si_ep.id then
local is_out = out_id == si_ep.id and true or false
for peer in siportinfos_om:iterate() do
for peer in silinkables_om:iterate() do
if peer.id == (is_out and in_id or out_id) then
local peer_node = peer:get_associated_proxy ("node")
local peer_media_class = peer_node.properties["media.class"]
......@@ -133,7 +133,7 @@ function handleSiEndpoint (si_ep)
Log.info (si_ep, "handling endpoint " .. si_ep.properties["name"])
-- find proper target item
local si_target = findUndefinedTarget (target_media_class, siportinfos_om)
local si_target = findUndefinedTarget (target_media_class, silinkables_om)
if not si_target then
Log.info (si_ep, "target item not found")
return
......@@ -165,8 +165,8 @@ function reevaluateLinks ()
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"])
if (getSessionItemById (out_id, siendpoints_om) and not getSessionItemById (in_id, siportinfos_om)) or
(getSessionItemById (in_id, siendpoints_om) and not getSessionItemById (out_id, siportinfos_om)) then
if (getSessionItemById (out_id, siendpoints_om) and not getSessionItemById (in_id, silinkables_om)) or
(getSessionItemById (in_id, siendpoints_om) and not getSessionItemById (out_id, silinkables_om)) then
silink:remove ()
Log.info (silink, "link removed")
end
......@@ -175,7 +175,7 @@ end
default_nodes = Plugin.find("default-nodes-api")
siendpoints_om = ObjectManager { Interest { type = "SiEndpoint" }}
siportinfos_om = ObjectManager { Interest { type = "SiPortInfo",
silinkables_om = ObjectManager { Interest { type = "SiLinkable",
-- only handle si-audio-adapter and si-node
Constraint {
"si.factory.name", "c", "si-audio-adapter", "si-node", type = "pw-global" },
......@@ -193,10 +193,10 @@ if config.follow then
end)
end
siportinfos_om:connect("objects-changed", function (om)
silinkables_om:connect("objects-changed", function (om)
reevaluateLinks ()
end)
siendpoints_om:activate()
siportinfos_om:activate()
silinkables_om:activate()
silinks_om:activate()
......@@ -72,7 +72,7 @@ function findTargetByTargetNodeMetadata (node)
if metadata then
local value = metadata:find(node_id, "target.node")
if value then
for si_target in siportinfos_om:iterate() do
for si_target in silinkables_om:iterate() do
local target_node = si_target:get_associated_proxy ("node")
if target_node["bound-id"] == tonumber(value) then
return si_target
......@@ -86,7 +86,7 @@ end
function findTargetByNodeTargetProperty (node)
local target_id_str = node.properties["node.target"]
if target_id_str then
for si_target in siportinfos_om:iterate() do
for si_target in silinkables_om:iterate() do
local target_node = si_target:get_associated_proxy ("node")
local target_props = target_node.properties
if target_node["bound-id"] == tonumber(target_id_str) or
......@@ -102,7 +102,7 @@ end
function findTargetByDefaultNode (target_media_class)
local def_id = default_nodes:call("get-default-node", target_media_class)
if def_id ~= Id.INVALID then
for si_target in siportinfos_om:iterate() do
for si_target in silinkables_om:iterate() do
local target_node = si_target:get_associated_proxy ("node")
if target_node["bound-id"] == def_id then
return si_target
......@@ -113,7 +113,7 @@ function findTargetByDefaultNode (target_media_class)
end
function findTargetByFirstAvailable (target_media_class)
for si_target in siportinfos_om:iterate() do
for si_target in silinkables_om:iterate() do
local target_node = si_target:get_associated_proxy ("node")
if target_node.properties["media.class"] == target_media_class then
return si_target
......@@ -154,7 +154,7 @@ function getSiLinkAndSiPeer (si, target_media_class)
local in_id = tonumber(silink.properties["in.item.id"])
if out_id == si.id or in_id == si.id then
local is_out = out_id == si.id and true or false
for peer in siportinfos_om:iterate() do
for peer in silinkables_om:iterate() do
if peer.id == (is_out and in_id or out_id) then
local peer_node = peer:get_associated_proxy ("node")
local peer_media_class = peer_node.properties["media.class"]
......@@ -168,7 +168,7 @@ function getSiLinkAndSiPeer (si, target_media_class)
return nil, nil
end
function isSiPortInfoValid (si)
function isSiLinkableValid (si)
-- only handle session items that has a node associated proxy
local node = si:get_associated_proxy ("node")
if not node or not node.properties then
......@@ -190,9 +190,9 @@ function isSiPortInfoValid (si)
return true
end
function handleSiPortInfo (si)
function handleSiLinkable (si)
-- check if item is valid
if not isSiPortInfoValid (si) then
if not isSiLinkableValid (si) then
return
end
......@@ -228,9 +228,9 @@ function handleSiPortInfo (si)
createLink (si, si_target)