We parse the locationID out of the AVCaptureDevice.uniqueID and then find the IORegistry node with that locationID.
Is there's a document declares how AVFoundation generate the unique_id for USB camera,
no
so I can assume this convert will always work?
you can't
Or is there's a way to send a PTZ control request to AVCaptureDevice?
not that I know of. As far as I know, the only way is what you're doing.
It looks that the unique_id provided is (locationID<<32|VendorID<<16|ProductID) as hex string, but I'm not sure if I can always assume this behavior won't change.
Correct - it has changed in the past, it might change at any time in the future. Not all AVCaptureDevices are UVC, but they all have uniqueIDs.
If you would like an API to clearly identify an AVCapture device in the IORegistry, please file a bug. I already did (in 2019, FB6146541)
Topic:
Media Technologies
SubTopic:
Photos & Camera
Tags: