lua monitors: switch to wpsetttings

- switch alsa.lua, v4l2.lua & libcamera.lua
- remove the config/lua references for these scripts
- fix the wpsettings deps parsing bug.
This commit is contained in:
Ashok Sidipotu
2022-05-02 12:49:50 +05:30
committed by Julian Bouzas
parent 7d304096e5
commit 161c43b71a
15 changed files with 227 additions and 447 deletions

View File

@@ -5,34 +5,15 @@
--
-- SPDX-License-Identifier: MIT
local config = ... or {}
local config_settings = {}
-- preprocess rules and create Interest objects
for _, r in ipairs(config.rules or {}) do
r.interests = {}
for _, i in ipairs(r.matches) do
local interest_desc = { type = "properties" }
for _, c in ipairs(i) do
c.type = "pw"
table.insert(interest_desc, Constraint(c))
end
local interest = Interest(interest_desc)
table.insert(r.interests, interest)
end
r.matches = nil
end
-- applies properties from config.rules when asked to
-- apply properties from rules defined in JSON .conf file
function rulesApplyProperties(properties)
for _, r in ipairs(config.rules or {}) do
if r.apply_properties then
for _, interest in ipairs(r.interests) do
if interest:matches(properties) then
for k, v in pairs(r.apply_properties) do
properties[k] = v
end
end
end
local matched, mprops = Settings.apply_rule ("libcamera_monitor", properties)
if (matched and mprops) then
for k, v in pairs(mprops) do
properties[k] = v
end
end
end
@@ -112,7 +93,7 @@ function createNode(parent, id, type, factory, properties)
properties["priority.session"] = priority
end
-- apply properties from config.rules
-- apply properties from rules defined in JSON .conf file
rulesApplyProperties(properties)
if properties ["node.disabled"] then
return
@@ -149,7 +130,7 @@ function createDevice(parent, id, type, factory, properties)
or properties["device.product.name"]
or "Unknown device"
-- apply properties from config.rules
-- apply properties from rules defined in JSON .conf file
rulesApplyProperties(properties)
if properties ["device.disabled"] then
return
@@ -165,7 +146,7 @@ function createDevice(parent, id, type, factory, properties)
end
end
monitor = SpaDevice("api.libcamera.enum.manager", config.properties or {})
monitor = SpaDevice("api.libcamera.enum.manager", config_settings or {})
if monitor then
monitor:connect("create-object", createDevice)
monitor:activate(Feature.SpaDevice.ENABLED)