I'm working on a macOS application that captures audio and video. When the user selects a video capture source (most likely an elgato box), I would like the application to automatically select the audio input from the same device. I was achieving this by pairing video and audio sources that had the same name, but this doesn't work when the user plugs in two capture devices of the same make and model.
With the command system_profiler SPUSBDataType
I can list all the USB devices, and I can see that the two elgato boxes have different serial numbers. If I could find this serial number, then I could figure out which AVCaptureDevices
come from the same hardware.
Is there a way to get the manufacturer's serial number from the AVCaptureDevice
object? Or a way to identify the USB device for an AVCaptureDevice,
and from there I could get the serial or some other unique ID?
AVCaptureDevice
does not have a property that returns the device's serial number, but it does have a uniqueID property that you can store to recall a specific device. This property persists across connections and disconnections, application restarts, and system reboots. When the user plugs in a device, you can store its IDs, then use them when comparing devices that have the same modelID.