akvirtualcamera icon indicating copy to clipboard operation
akvirtualcamera copied to clipboard

Idea: move xpc_connection_create_mach_service to NSXPCConnection so that it works with QuickTime

Open demiantres opened this issue 2 years ago • 12 comments

QuickTime does not work with the webcam because it does not allow accessing xpc_connection_create_mach_service. Moving to NSXPCConnection (sorry, I don't know the C++ equivalent) fixes the problem:

https://github.com/obsproject/obs-studio/blob/dde4d57d726ed6d9e244ffbac093d8ef54e29f44/plugins/mac-virtualcam/src/obs-plugin/OBSDALMachServer.mm https://stackoverflow.com/questions/54188295/nsmachbootstrapserver-is-deprecated-how-can-nsxpcconnection-be-used-to-register

demiantres avatar Feb 21 '22 06:02 demiantres

I was looking all information about NSXPCConnection, and did not found any evidence that using the CoreFoudation libraries instead of libxpc makes any difference, libxpc hasn't been deprecated, and libxpc is still the base library for CoreFoudation libraries. If the virtual camera doesn't works with QuickTime, is most probably because the virtual camera isn't signed, which I won't do.

hipersayanX avatar Feb 22 '22 15:02 hipersayanX

I had closed this issue because I am not entirely sure why it does not work in QuickTime. I signed the plugin but this did not help. Interestingly other cameras (for instance https://github.com/johnboiles/coremediaio-dal-minimal-example) show up in QuickTime (even if not signed).

The problem is that debugging is very hard because the plugin cannot write to a log file in (/tmp) nor send debug XPC messages to the server.

demiantres avatar Feb 22 '22 15:02 demiantres

The problem is that debugging is very hard because the plugin cannot write to a log file in (/tmp) nor send debug XPC messages to the server.

You can debug both, the plugin and the service, setting the loglevel:

AkVcamManager set-loglevel 7

and the StandardOutPath and the StandardErrorPath variables in org.webcamoid.cmio.AkVCam.Assistant.plist.
It's all documented in the wiki.

hipersayanX avatar Feb 22 '22 15:02 hipersayanX

I know, but this does not work when the plugin is loaded by QuickTime.

demiantres avatar Feb 22 '22 15:02 demiantres

I tried to write to a logging file using the working camera from the link above, and even there logging does not work (though the camera itself shows up in QuickTime).

demiantres avatar Feb 22 '22 15:02 demiantres

I suspect that the QuickTime sandbox prevents all file access (and possibly some XPC stuff).

demiantres avatar Feb 22 '22 15:02 demiantres

Running QuickTime from terminal throw some messages?

hipersayanX avatar Feb 22 '22 15:02 hipersayanX

I re-opened the issue because you said it was working with the other virtual camera. I'm right now quite busy working with Webcamoid, I won't come back to this issue until much later, but it would be useful if you can continue debugging it and give me some updates.

hipersayanX avatar Feb 22 '22 15:02 hipersayanX

Ok, I will keep you posted. But at the moment I have run out of ideas.

demiantres avatar Feb 22 '22 16:02 demiantres

I found the problem: QuickTime does not allow accessing the preferences file which is used by the plugin (Preferences.h). XPC seems to work fine but no devices are shown due to lack of access to the preferences file.

demiantres avatar Feb 22 '22 16:02 demiantres

Ok, then the idea would be reading the preferences from the service, similar to what I did with the DirectShow plugin.

hipersayanX avatar Feb 22 '22 17:02 hipersayanX

I did some testing. When using XPC for getting the device info instead of the preferences file then QuickTime works (even without signing).

demiantres avatar Feb 22 '22 19:02 demiantres