#import <VideoToolbox/VTDecompressionSession.h> #import <Foundation/Foundation.h> OSStatus TestDecoder( CFStringRef hw_spec_str, const char* comment ) { NSLog( @"TestDecoder: hw_spec_str = %@ (%s)", hw_spec_str, comment ); const uint8_t sps[] = { 0x67, 0x4d, 0x40, 0x28, 0x95, 0xa8, 0x1e, 0x00, 0x89, 0xf9, 0x70, 0x11, 0x00, 0x00, 0x03, 0xe9, 0x00, 0x00, 0xea, 0x60, 0xe0, 0x00, 0x00, 0x11, 0x94, 0x00, 0x00, 0x00, 0xbe, 0xbc, 0x22, 0xef, 0x2e, 0xa }; const uint8_t pps[] = { 0x68, 0xce, 0x3c, 0x80, 0x52, 0xc0, 0x1, 0x0 }; CFMutableDictionaryRef spec = CFDictionaryCreateMutable( nil, 0, nil, nil ); CFDictionarySetValue( spec, hw_spec_str, kCFBooleanTrue ); const uint8_t* const data[2] = { sps, pps }; const size_t sz[2] = { sizeof( sps ), sizeof( pps ) }; CMVideoFormatDescriptionRef format; OSStatus status = 0; status = CMVideoFormatDescriptionCreateFromH264ParameterSets( nil, 2, data, sz, 4, &format ); if( status == 0 ) { VTDecompressionSessionRef vt_dec; status = VTDecompressionSessionCreate( 0, format, spec, 0, 0, &vt_dec ); if( status == 0 ) { CFRelease( vt_dec ); } } CFRelease( spec ); NSLog( @"TestDecoder: result = %d", (int)status ); return status; } int main( int argc, const char* argv[] ) { @autoreleasepool { const OSStatus status_0 = TestDecoder( kVTVideoDecoderSpecification_RequireHardwareAcceleratedVideoDecoder, "kVTVideoDecoderSpecification_RequireHardwareAcceleratedVideoDecoder" ); const OSStatus status_1 = TestDecoder( CFSTR( "RequireHardwareAcceleratedVideoDecoder" ), "CFSTR( \"RequireHardwareAcceleratedVideoDecoder\" )" ); return status_0 == 0 && status_1 == 0 ? 0 : 1; } }