Files
wireplumber/src/scripts/monitors/libcamera/enumerate-device.lua
George Kiagiadakis 43aa2d4952 scripts: don't use 'local' for file-wide scoped variables
Since all scripts run in a sandbox with their own global environment,
it means that they don't interfere with each other's global variables.
Therefore, all file-wide variables can be declared global without
any change in behavior. In my understanding, it is better to do so
because this means that any code accessing those variables is going
to access them directly from the global environment table with a simple
lookup rather than having each variable referenced in the local closure
of each function separately.
2023-09-29 23:13:28 +03:00

35 lines
1001 B
Lua

-- WirePlumber
--
-- Copyright © 2023 Collabora Ltd.
-- @author Ashok Sidipotu <ashok.sidipotu@collabora.com>
--
-- SPDX-License-Identifier: MIT
log = Log.open_topic ("s-monitors-libcam")
defaults = {}
defaults.properties = Json.Object {}
config = {}
config.properties = Conf.get_section (
"monitor.libcamera.properties", defaults.properties):parse ()
function createCamDevice (parent, id, type, factory, properties)
source = source or Plugin.find ("standard-event-source")
local e = source:call ("create-event", "create-libcam-device", parent, nil)
e:set_data ("device-properties", properties)
e:set_data ("factory", factory)
e:set_data ("device-sub-id", id)
EventDispatcher.push_event (e)
end
monitor = SpaDevice ("api.libcamera.enum.manager", config.properties)
if monitor then
monitor:connect ("create-object", createCamDevice)
monitor:activate (Feature.SpaDevice.ENABLED)
else
log:notice ("PipeWire's libcamera SPA missing or broken. libcamera not supported.")
end