I created a camera extension project that required interaction via custom properties. I originally coded it on macOS 14.x. In the camera extension code, receiving and returning NSNumber values as shown in the code at the bottom.
The app was working perfectly until I went to test on mac 12.7.6. Under that version of macOS, the custom properties weren't working at all. I also saw lines in the logs like this:
CMIO_DAL_CMIOExtension_Stream.mm:1165:GetPropertyData 50 wrong 4cc format for key 4cc_back_glob_0000
which was totally perplexiing, because it was clear that the 4cc codes were fine under 13.x, especially given that the documentation for CMIOExtensionPropertyState
clearly says that NSNumbers should be OK.
On a hunch, I changed the code to use NSString instead of NSNumber, and it started working again under 12.7.6.
So, my experience is that macOS 12.x doesn't allow you to use NSNumbers, but it happy with NSStrings.
Hope that saves someone else some time.
And here is is the code that worked on 14.x, but not on 12.x.
// 4cc constant
const CMIOExtensionProperty CMIOExtensionPropertyCustomPropertyData_BackgroundOption = @"4cc_back_glob_0000";
- (nullable CMIOExtensionDeviceProperties *)devicePropertiesForProperties:(NSSet<CMIOExtensionProperty> *)properties error:(NSError * _Nullable *)outError
{
// doesn't work on macOS 12.x, works on 14.x
CMIOExtensionDeviceProperties *deviceProperties = [CMIOExtensionDeviceProperties devicePropertiesWithDictionary:@{}];
if ([properties containsObject:CMIOExtensionPropertyCustomPropertyData_BackgroundOption]) {
NSNumber* nsBackgroundOption = [NSNumber numberWithUnsignedInt:(unsigned int)_backgroundOption];
CMIOExtensionPropertyState* state = [CMIOExtensionPropertyState propertyStateWithValue:nsBackgroundOption];
[deviceProperties setPropertyState:state forProperty:CMIOExtensionPropertyCustomPropertyData_BackgroundOption];
}
return deviceProperties;
}
- (BOOL)setDeviceProperties:(CMIOExtensionDeviceProperties *)deviceProperties error:(NSError * _Nullable *)outError
{
// doesn't work on macOS 12.x, works on 14.x
NSDictionary* devicePropertiesDict = [deviceProperties propertiesDictionary];
CMIOExtensionPropertyState* propState = nil;
propState = [devicePropertiesDict objectForKey:CMIOExtensionPropertyCustomPropertyData_BackgroundOption];
if (propState != NULL) {
NSNumber* nsBackgroundOption = [propState value];
if (nsBackgroundOption != NULL) {
uint32_t newBackgroundOption = [nsBackgroundOption unsignedIntValue];
if (newBackgroundOption != _backgroundOption) {
log_info(@"##### Set Background Option to %d", (int) newBackgroundOption);
}
_backgroundOption = newBackgroundOption;
}
}
return YES;
}
Hello,
Thanks for bringing this to the attention of the community!
Indeed this should work as expected on macOS 13 and up.
You are welcome to file a bug report for the issue on macOS 12 using Feedback Assistant.
Best regards,
Greg