Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use PTP API of macOS (ImageCaptureCore) as backend #351

Open
jannschu opened this issue Jan 13, 2019 · 5 comments
Open

Use PTP API of macOS (ImageCaptureCore) as backend #351

jannschu opened this issue Jan 13, 2019 · 5 comments

Comments

@jannschu
Copy link

jannschu commented Jan 13, 2019

Hi,

as you might know macOS has its own implemetation of PTP (in the ImageCaptureCore framework), but it only covers basic features. The API though provides a way to send custom mesages.

I am interested in implementing this API as a PTP transport backend for libgphoto2 on macOS. The single advantage would be, that it is no longer necessary to kill the PTPCamera processes. According to the API documentation of Canon, this is also the way EDSDK is implemented.

What do you think? I would try to bridge the current libgphoto2 PTP API to ImageCaptureCore. Do you support this idea? How can I start?

Edit: My first idea is to add a compile flag for macOS, which marks certain ptp functions as weak. Also, a library is linked, which replaces the weak functions with implementations for the macOS backend. This would involve minimal code changes on the core library and reflect the experimental quality of this feature. A cleaner solution would separate the ptp functions into their own object files and then link to the corresponding version. I still have to figure out how painful the bridge code will be.

@msmeissn
Copy link
Contributor

As begin,
You could hook it as a replacement for usb.c or ptpip.c in camlibs/ptp2/ , or as a ptp_transaction replacement , depending on how lowlevel the macos version goes.

@jannschu
Copy link
Author

A little update. I looked through the code. It seems to me a new port type (added to libgphoto2_port) for ImageCaptureCore (ICC) seems more appropiate. The reason is that in order to communicate with the camera with ICC one has to connect to the camera through the API. You can not specify a USB port or something like this. Then, in camera_init of ptp2 one checks for the ICC port and sets up the low level IO function pointers to use ICC, which I would add in a new file, similar to ptp2/usb.c.

I will also enable the port by default on macOS and prefer it over USB if available. It seems the USB port can not be deactivated.

I am not sure if I made this clear in my issue: Are you interested in adding the code to libgphoto2? It will involve a few lines of Objective-C code.

@hmeine
Copy link

hmeine commented Jan 1, 2024

I just wanted to file a similar issue, but found that this might be more or less a duplicate: I just wanted to add that on recent MacOS version, there is a /usr/libexec/ptpcamerad running through launchctl that cannot be killed anymore (it will automatically re-spawn, and at least with my limited launchctl knowledge, it did not seem to be stoppable while my camera was connected). Googling for workarounds, I found the explicit statement that one should access PTP cameras through IOKit, which is probably not only the cleaner solution, but nowadays the only available one.

@msmeissn
Copy link
Contributor

msmeissn commented Jan 2, 2024

so far I have no access to a Mac , so its hard to do for me.

@hfiguiere
Copy link
Member

I don't think it's in scope for libgphoto2 anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants