libcamera/monitors: rebase libcamera monitor into a bunch of hooks
This commit is contained in:

committed by
George Kiagiadakis

parent
6596d71c4f
commit
bb0e15e631
37
src/scripts/monitors/libcamera/create-node.lua
Normal file
37
src/scripts/monitors/libcamera/create-node.lua
Normal file
@@ -0,0 +1,37 @@
|
||||
-- WirePlumber
|
||||
--
|
||||
-- Copyright © 2023 Collabora Ltd.
|
||||
-- @author Ashok Sidipotu <ashok.sidipotu@collabora.com>
|
||||
--
|
||||
-- SPDX-License-Identifier: MIT
|
||||
|
||||
local cutils = require ("common-utils")
|
||||
local mutils = require ("monitor-utils")
|
||||
|
||||
log = Log.open_topic ("s-monitors-libcam")
|
||||
|
||||
SimpleEventHook {
|
||||
name = "monitor/libcam/create-node",
|
||||
after = "monitor/libcam/name-node",
|
||||
interests = {
|
||||
EventInterest {
|
||||
Constraint { "event.type", "=", "create-libcam-device-node" },
|
||||
},
|
||||
},
|
||||
execute = function(event)
|
||||
local properties = event:get_data ("node-properties")
|
||||
local parent = event:get_subject ()
|
||||
local id = event:get_data ("node-sub-id")
|
||||
|
||||
-- apply properties from rules defined in JSON .conf file
|
||||
cutils.evaluateRulesApplyProperties (properties, "monitor.libcamera.rules")
|
||||
if properties["node.disabled"] then
|
||||
log:warning ("lib cam device node" .. properties["device.name"] .. " disabled")
|
||||
return
|
||||
end
|
||||
-- create the node
|
||||
local node = Node ("spa-node-factory", properties)
|
||||
node:activate (Feature.Proxy.BOUND)
|
||||
parent:store_managed_object (id, node)
|
||||
end
|
||||
}:register ()
|
Reference in New Issue
Block a user