
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.
35 lines
1001 B
Lua
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
|