It is not possible to run host system executables like modinfo, pkexec,
and modprobe inside a Flatpak sandbox. However, Flatpak provides a way
to run command on the host system: the flatpak-spawn executable.
flatpak-spawn is a tiny helper that, when executed with the '--host'
parameter, talks to the org.freedesktop.Flatpak D-Bus interface to run
and retrieve the return value of the executable. This provides OBS Studio
a way to escape this sandbox limitation without opening large holes in
the sandbox.
Make v4l2's implementation of VirtualCam run system commands using
flatpak-spawn when inside a Flatpak sandbox. The detection of the sandbox
is done by checking the existence of the /.flatpak-info file, which is
created by Flatpak itself, and only exists inside the sandbox. If OBS
Studio is not running inside a Flatpak sandbox, run the exact same command
it used to run before this commit.
Add the permission to talk to the org.freedesktop.Flatpak D-Bus interface
to the Flatpak manifest, so we can run flatpak-spawn with the '--host'
parameter.
Notice that the same constraints apply with and without Flatpak: the host
system needs to have the v4l2loopback kernel module available for the v4l2
implementation of VirtualCam to work.