2021-03-23 15:08:03 -04:00
|
|
|
-- WirePlumber
|
|
|
|
|
--
|
|
|
|
|
-- Copyright © 2021 Collabora Ltd.
|
|
|
|
|
-- @author Julian Bouzas <julian.bouzas@collabora.com>
|
|
|
|
|
--
|
|
|
|
|
-- SPDX-License-Identifier: MIT
|
|
|
|
|
|
|
|
|
|
items = {}
|
|
|
|
|
|
|
|
|
|
function addItem (node, item_type)
|
|
|
|
|
local id = node["bound-id"]
|
|
|
|
|
|
|
|
|
|
-- create item
|
|
|
|
|
items[id] = SessionItem ( item_type )
|
|
|
|
|
|
|
|
|
|
-- configure item
|
|
|
|
|
if not items[id]:configure {
|
|
|
|
|
["node"] = node,
|
2021-05-10 11:49:44 -04:00
|
|
|
["enable.monitor"] = true,
|
2021-09-29 13:31:22 -04:00
|
|
|
["disable.dsp"] = false,
|
2021-04-13 19:35:10 +03:00
|
|
|
["item.plugged.usec"] = GLib.get_monotonic_time(),
|
2021-03-23 15:08:03 -04:00
|
|
|
} then
|
|
|
|
|
Log.warning(items[id], "failed to configure item for node " .. tostring(id))
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- activate item
|
2021-03-29 18:35:35 +03:00
|
|
|
items[id]:activate (Features.ALL, function (item)
|
2021-03-23 15:08:03 -04:00
|
|
|
Log.info(item, "activated item for node " .. tostring(id))
|
|
|
|
|
item:register ()
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
2021-06-10 16:38:34 +03:00
|
|
|
nodes_om = ObjectManager {
|
|
|
|
|
Interest {
|
|
|
|
|
type = "node",
|
|
|
|
|
Constraint { "media.class", "#", "Stream/*", type = "pw-global" },
|
|
|
|
|
},
|
|
|
|
|
Interest {
|
|
|
|
|
type = "node",
|
|
|
|
|
Constraint { "media.class", "#", "Video/*", type = "pw-global" },
|
|
|
|
|
},
|
|
|
|
|
Interest {
|
|
|
|
|
type = "node",
|
|
|
|
|
Constraint { "media.class", "#", "Audio/*", type = "pw-global" },
|
|
|
|
|
Constraint { "wireplumber.is-endpoint", "-", type = "pw" },
|
|
|
|
|
},
|
|
|
|
|
}
|
2021-03-23 15:08:03 -04:00
|
|
|
|
|
|
|
|
nodes_om:connect("object-added", function (om, node)
|
|
|
|
|
local media_class = node.properties['media.class']
|
|
|
|
|
if string.find (media_class, "Audio") then
|
|
|
|
|
addItem (node, "si-audio-adapter")
|
|
|
|
|
else
|
|
|
|
|
addItem (node, "si-node")
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
nodes_om:connect("object-removed", function (om, node)
|
|
|
|
|
local id = node["bound-id"]
|
|
|
|
|
if items[id] then
|
|
|
|
|
items[id]:remove ()
|
|
|
|
|
items[id] = nil
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
nodes_om:activate()
|