How to use camera extension with external app

Hi,

I'm new to coding for MacOS but I'm building a Godot app that I wish to be able to have create a virtual camera on MacOS via button click.

I plan to use the GDExtension feature to interface with code for MacOS to do this. I was looking into what would be involved with this and came across the Camera Extension that can be bundled with MacOS apps that can be used to create a virtual camera.

Is it possible to bundle this extension with a library or framework that I can then interact with using C++ in a GDExtension (an external app). I realise the extensions can only be registered from within the Application folder so the assumption is that the Godot app would be installed there.

Answered by DTS Engineer in 788848022

Recent versions of macOS support Core Media I/O system extensions, which allow you to publish a custom camera. This can drive a physical camera or be completely virtual.

CMIO isn’t really my field, so I’m going to defer to the docs on that front. Oh, and WWDC 2022 Session 10022 Create camera extensions with Core Media IO, which is a great intro to the system as a whole.

In terms of packaging, you wrote:

Is it possible to bundle this extension with a library or framework that I can then interact with using C++ in a GDExtension (an external app).

A CMIO system extension is embedded within a GUI container app. The top level of the sysex must be written in Objective-C or Swift, but that code can defer the real work to something written in another language.

It’s possible to embed frameworks in your sysex. There’s one gotcha there, namely that, on install, the sysex is copied to a custom location, so any frameworks that the sysex uses must be embedded in the sysex, not in the container app. If the container app also needs to use those frameworks, you have tweak its rpath to access them where they’re embedded in the sysex.

Finally, remember that your sysex and your container app are running in different processes. If you need to coordinate work between them, that’s an IPC operation. See here.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Recent versions of macOS support Core Media I/O system extensions, which allow you to publish a custom camera. This can drive a physical camera or be completely virtual.

CMIO isn’t really my field, so I’m going to defer to the docs on that front. Oh, and WWDC 2022 Session 10022 Create camera extensions with Core Media IO, which is a great intro to the system as a whole.

In terms of packaging, you wrote:

Is it possible to bundle this extension with a library or framework that I can then interact with using C++ in a GDExtension (an external app).

A CMIO system extension is embedded within a GUI container app. The top level of the sysex must be written in Objective-C or Swift, but that code can defer the real work to something written in another language.

It’s possible to embed frameworks in your sysex. There’s one gotcha there, namely that, on install, the sysex is copied to a custom location, so any frameworks that the sysex uses must be embedded in the sysex, not in the container app. If the container app also needs to use those frameworks, you have tweak its rpath to access them where they’re embedded in the sysex.

Finally, remember that your sysex and your container app are running in different processes. If you need to coordinate work between them, that’s an IPC operation. See here.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

How to use camera extension with external app
 
 
Q