Overriding the default USB video class extension
Create a simple DriverKit extension to override the default driver-matching behavior for USB devices.
Overview
Starting in macOS 12.3, the operating system provides a class-compliant Core Media I/O (CMIO) extension that enables the use of USB cameras and other video capture devices. When you connect a USB camera, the system finds its default driver and connects it with the camera. To override the system’s default matching behavior so that you can load a custom CMIO extension instead, create a simple DriverKit extension.
Create a DriverKit extension
In a standalone Xcode project, or as a target within an existing project, create a new DriverKit extension. In Xcode’s menu, select File > New and choose either the Project or Target menu items as appropriate. In the dialog that appears, select the DriverKit tab and the Driver template, and click the Next button.
[Image]
In the dialog that follows, give the driver an appropriate Product Name and click the Finish button to create it.
The default IOKit interface generator (.iig) and C++ implementation files that the template creates provide the sufficient implementation for your driver. The driver is effectively codeless, but the system requires a minimal binary for entitlement purposes.
Configure the Info.plist file
Specify your matching parameters as one or more entries in the IOKitPersonalities dictionary inside the DriverKit extension’s Info.plist file. The following example shows the standard configuration to provide within this file.
<key>IOKitPersonalities</key>
<dict>
<key>Camera-Identifier</key>
<dict>
<key>CFBundleIdentifierKernel</key>
<string>com.apple.UVCService</string>
<key>IOClass</key>
<string>UVCService</string>
<key>IOProviderClass</key>
<string>IOUSBHostInterface</string>
<key>bConfigurationValue</key>
<string>*</string>
<key>bInterfaceNumber</key>
<string>*</string>
<integer>14</integer>
<key>bInterfaceSubClass</key>
<string>*</string>
<key>IOUserClass</key>
<string>[DRIVERKIT CLASS NAME]</string>
<key>IOUserServerName</key>
<string>[DRIVERKIT SERVER NAME]</string>
<key>IOProbeScore</key>
<integer>9999</integer>
<key>idVendor</key>
<integer>123</integer>
<key>idProduct</key>
<integer>123</integer>
<key>IOProviderMergeProperties</key>
<dict>
<key>CameraAssistantBundleID</key>
<string>[YOUR CMIO EXTENSION ID]</string>
</dict>
</dict>
</dict>Set IOUserClass and IOUserServerName values as appropriate for your newly created extension. Set a high IOProbeScore value to give priority to your driver, and set the identifiers of the vendor and product to match. In the IOProviderMergeProperties, specify the identifier of your custom CMIO extension to load in place of the default driver.
With the configuration of your DriverKit extension complete, refer to Installing System Extensions and Drivers for information on how to package and install your extension.