I looked high and low how to create a VTCompressionSession (in fast ), as summarized in 2014 WWDC Video - “Direct access to video encoding and decoding” .
The following code works in Objective-C:
#import <Foundation/Foundation.h>
#import <VideoToolbox/VideoToolbox.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
VTCompressionSessionRef session;
VTCompressionSessionCreate(NULL, 500, 500, kCMVideoCodecType_H264, NULL, NULL, NULL, NULL, NULL, &session);
NSLog(@"created VTCompressionSession");
}
return 0;
}
But no matter what I tried, I cannot find a way to import VTCompressionSessionCreateinto swift .
import Foundation
import VideoToolbox
VideoToolbox.VTCompressionSessionCreate()
println("created VTCompressionSession")
This code, for example, is broken down into: Module 'VideoToolbox' has no member named 'VTCompressionSessionCreate'.
Just a call VTCompressionSessionCreatecreates an error message Use of unresolved identifier 'VTCompressionSessionCreate'.
It seems that the API does not appear in quickly , as I can just call methods like VTCompressionSessionEncodeFrame. Am I missing something?