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

wip

parent 63b546bf
Pipeline #265484 passed with stages
in 1 minute and 25 seconds
......@@ -99,9 +99,9 @@ on_device_enum_profile_done (WpPipewireObject *proxy, GAsyncResult *res,
}
/* Bluez5 */
else if (api && g_str_has_prefix (api, "bluez5")) {
index = 1;
}
//else if (api && g_str_has_prefix (api, "bluez5")) {
// index = 1;
//}
}
/* Set the profile */
......
......@@ -40,6 +40,6 @@ function createDevice(parent, id, type, factory, properties)
parent:store_managed_object(id, device)
end
monitor = SpaDevice("api.bluez5.enum.dbus")
monitor = SpaDevice("api.bluez5.enum.dbus", {})
monitor:connect("create-object", createDevice)
monitor:activate(Feature.SpaDevice.ENABLED)
......@@ -91,7 +91,7 @@ nodes_om = ObjectManager { Interest { type = "node" } }
nodes_om:connect("object-added", function (om, node)
local media_class = node.properties['media.class']
-- skip nodes without media class
-- skip nodes without media class or bluez5 api
if media_class == nil then
return
end
......@@ -116,3 +116,81 @@ end)
sessions_om:activate()
nodes_om:activate()
-- BLUEZ5
bluez5_data = {
nodes_om = {},
endpoints = {
input = {},
output = {}
},
avail_profiles = {
input = {
},
output = {
},
}
}
function updateAvailableProfiles (device, profile_iterator)
for profile in profile_iterator:iterate() do
local p = profile:get()
Log.info (device, "Profile (" .. tostring (p.index) .. ") '" .. tostring (p.name) .. "': " .. p.description);
if p.index == 1 or p.index == 2 then
for class_k, class_v in pairs(p.classes) do
if type (class_v) == "table" then
local media_class = nil
local n_nodes = nil
for k, v in pairs(class_v) do
if type (v) == "string" then -- media class
media_class = v
elseif type (v) == "number" then -- n nodes
n_nodes = v
end
end
Log.info (device, " -> " .. tostring (media_class) .. " | " .. tostring (n_nodes));
if media_class == "Audio/Sink" then
bluez5_data.avail_profiles["input"]
else
bluez5_data.avail_profiles["output"]
end
end
end
end
end
end
devices_om = ObjectManager { Interest {type = "device"} }
devices_om:connect("object-added", function (om, device)
local id = device["bound-id"]
local device_api = device.properties["device.api"]
-- if (device_api ~= "bluez5")
-- return
-- end
-- get the supported bluez5 profiles
device:enum_params ("EnumProfile", nil, function (dev, profile_iterator)
updateAvailableProfiles (device, profile_iterator)
-- create the nodes object manager
bluez5_data.nodes_om[id] = ObjectManager { Interest { type = "node",
Constraint { "device.id", "=", id, type = "pw-global"}
}}
-- handle objects changed
devices_om:connect("objects-changed", function (om)
-- TODO
end)
end)
end)
devices_om:connect("object-removed", function (om, device)
local id = device["bound-id"]
bluez5_data.nodes_om[id] = nil
end)
devices_om:activate()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment