私は、画面を記録する私のアプリで機能を実装しようとしています。私はいくつかのサンプルコードとWWDC 2012ビデオで見つけたコードを持っています。CGDisplayStreamで画面をキャプチャ
これまでのところ私はこれを持っています。
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// Get a list of displays. Copied from working apple source code.
[self getDisplayList];
DisplayRegistrationCallBackSuccessful = NO;
// Register the event for modifying displays.
CGError err = CGDisplayRegisterReconfigurationCallback(DisplayRegisterReconfigurationCallback, NULL);
if (err == kCGErrorSuccess) {
DisplayRegistrationCallBackSuccessful = YES;
}
// Insert code here to initialize your application
const void *keys[1] = { kCGDisplayStreamSourceRect };
const void *values[1] = { CGRectCreateDictionaryRepresentation(CGRectMake(0, 0, 100, 100)) };
CFDictionaryRef properties = CFDictionaryCreate(NULL, keys, values, 1, NULL, NULL);
stream = CGDisplayStreamCreate(displays[0], 100, 100, '420f', properties,
^(CGDisplayStreamFrameStatus status, uint64_t displayTime, IOSurfaceRef frameSurface, CGDisplayStreamUpdateRef updateRef) {
NSLog(@"Next Frame"); // This line is never called.
});
runLoop = CGDisplayStreamGetRunLoopSource(stream);
CGError err = CGDisplayStreamStart(stream);
if (err == CGDisplayNoErr) {
NSLog(@"Works");
} else {
NSLog(@"Error: %d", err);
}
}
私が遭遇している問題は、DisplayStreamのコールバックブロックが呼び出されていないことです。エラーや警告が表示されません。私が紛失しているか、間違っていたことはありますか?
は、あなたが参照として使用したサンプルやビデオを示していただけますか? –