webcamoid / akvirtualcamera

akvirtualcamera, virtual camera for Mac and Windows
GNU General Public License v3.0
393 stars 51 forks source link

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

Open demiantres opened 2 years ago

demiantres commented 2 years ago

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

hipersayanX commented 2 years ago

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.

demiantres commented 2 years ago

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.

hipersayanX commented 2 years ago

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.

demiantres commented 2 years ago

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

demiantres commented 2 years ago

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 commented 2 years ago

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

hipersayanX commented 2 years ago

Running QuickTime from terminal throw some messages?

hipersayanX commented 2 years ago

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.

demiantres commented 2 years ago

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

demiantres commented 2 years ago

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.

hipersayanX commented 2 years ago

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

demiantres commented 2 years ago

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