The H.264 video compressor ignores properties set with VTSessionSetProperty

Originator:iosdeveloperzone
Number:rdar://19930069 Date Originated:23-Feb-2015 04:11 PM
Status:Closed Resolved:iOS 9.0 beta (13A4254v)
Product:iOS SDK Product Version:iOS 8.1.2 (12B440), iOS 8.2 (12D5480a)
Classification:Serious bug Reproducible:Always
 
Summary:
The H.264 video compressor on iOS devices (silently) ignores properties set with VTSessionSetProperty. The output bitstream seems unaffected and VTSessionCopyProperty copies a NULL value. No error is returned in either case.

Steps to Reproduce:
The attached project contains two targets. The iOS target demonstrates the problem, while the Mac target demonstrates the expected results. [OpenRadar note I will upload the sample project to github and add a link as soon as I get a chance.]

1. Create a compression session:
VTCompressionSessionRef CompressionSessionCreate(CMVideoCodecType codecType)
{
    NSDictionary* encoderSpecification = nil;
    CFDictionaryRef sourceImageBufferAttributes = NULL;
    CMTimebaseRef timebase;
    OSStatus status = CMTimebaseCreateWithMasterClock(kCFAllocatorDefault, CMClockGetHostTimeClock(), &timebase);
    // CIF: 352x288
    int32_t width = 352;
    int32_t height = 288;
    VTCompressionSessionRef compressionSession;
    void *outputCallbackRefCon = NULL;
    status = VTCompressionSessionCreate(kCFAllocatorDefault,
                                        width, height,
                                        codecType,  (__bridge CFDictionaryRef)encoderSpecification,
                                        sourceImageBufferAttributes, NULL,
                                        CompressionOutputTestCallback, outputCallbackRefCon, &compressionSession);
    NSCAssert(status == noErr, @"Created compression session successfully (%d).", status);
    return compressionSession;
}

2. Attempt to set and read back some supported properties:
void H264CompressionPropertiesTest()
{
    OSStatus status;
    
    CMVideoCodecType codecType = kCMVideoCodecType_H264;
    VTCompressionSessionRef compressionSession = CompressionSessionCreate(codecType);
    
    CFDictionaryRef supportedProperties;
    status = VTSessionCopySupportedPropertyDictionary(compressionSession, &supportedProperties);
    NSCAssert(status == noErr, @"Retrieved supported properties successfully.");
    //NSLog(@"Supported properties: %@", supportedProperties);
    
    CFStringRef propertyKey = kVTCompressionPropertyKey_ProfileLevel;
    status = VTSessionSetProperty(compressionSession, propertyKey, kVTProfileLevel_H264_High_AutoLevel);
    NSCAssert(status == noErr, @"Allegedly set property.");
    
    CFTypeRef value = NULL;
    status = VTSessionCopyProperty(compressionSession, propertyKey, kCFAllocatorDefault, &value);
    NSCAssert(status == noErr, @"Allegedly copied property.");
    
    NSLog(@"H264: %@: %@", propertyKey, value);
    
    propertyKey = kVTCompressionPropertyKey_MaxKeyFrameInterval;
    status = VTSessionSetProperty(compressionSession, propertyKey, (__bridge CFNumberRef)@(1.0));
    NSCAssert(status == noErr, @"Allegedly set property.");
    
    value = NULL;
    status = VTSessionCopyProperty(compressionSession, propertyKey, kCFAllocatorDefault, &value);
    NSCAssert(status == noErr, @"Allegedly copied property.");
    
    NSLog(@"H264: %@: %@", propertyKey, value);
}

Expected Results:
The read back values of the properties should match those set:

H263: MaxKeyFrameInterval: 1
H264: ProfileLevel: H264_High_AutoLevel
H264: MaxKeyFrameInterval: 1

Actual Results:
The read back properties for H.264 are null:

H263: MaxKeyFrameInterval: 1
H264: ProfileLevel: (null)
H264: MaxKeyFrameInterval: (null)

Version:
iOS 8.1.2 (12B440), iOS 8.2 (12D5480a)

Notes:


Configuration:
iPhone 6 iOS 8.1.2 (12B440), iPhone 6 iOS 8.2 (12D5480a)

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!