I'm fairly new to macOS development. I decided to create a CoreMedia DAL plugin to try to create a virtual camera and learn more about the Objective C ecosystem.
There are two components to the application:
The bundle plugin that gets installed into the
/Library/CoreMediaIO/Plug-Ins/DAL/directory and emulates a hardware deviceA simple server that serves video frames from an actual hardware device to the plugin. The idea is that this server will apply filtering/compositing to the frame data before forwarding it onto the virtual camera.
I have successfully created a virtual device that just serves a static image. But to communicate from the plugin → server to get the dynamics frames, I'm using Mach ports (I know they're deprecated).
The server is running an NSMachBootstrapServer instance which has registered a service "com.vcamera.server". The plugin is referencing this service as it runs with the following code.
NSPort * port = [NSMachBootstrapServer sharedInstance] portForName:@"com.vcamera.server";
Problem
When I start an application that uses the virtual camera plugin (e.g. OBS in my case), the plugin prints that it successfully finds the registered server Mach port (the server port is not nil) but it cannot actually send data to it. The NSPortMessage instance sendBeforeDate fails with a timeout. For the life of me, I can't figure out why the Mach IPC doesn't transfer data when it processes that a service has registered on the port.
What I've tried
To isolate the issue, I created two distinct client and server applications that are NOT plugins by compiling directly with GCC. I was able to reproduce the timeout from the client to the server when I did not codesign the binaries, but once I did a simple codesign using my Apple developer account the two binaries were able to communicate.
But what's strange is that the OBS application that loads the virtual camera plugin is clearly codesigned but the connection from the plugin to the server does not complete successfully. Also, I read online that any application that loads virtual camera plugins needs to have the "Disable Library Validation" entitlement, but I confirmed that it was available in the application property list with this command.
codesign -d --entitlements :- /Applications/OBS.app
A few questions:
- Is there anything obvious that's sticking out that I'm doing wrong?
- Am I fundamentally misunderstanding the permissioning that's necessary to do Mach IPC?
- Do bundle plugins need to be signed somehow or does the application (OBS in this case) itself need to have its code signature changed to match my developer ID?
I'd really appreciate any assistance that you can give! More than happy to give more information.