Ich versuche, eine Funktion in meiner App zu implementieren, die den Bildschirm aufzeichnen wird. Ich habe Code-Bits, die ich in einem Beispielcode und einem WWDC 2012-Video gefunden habe.Bildschirm mit CGDisplayStream erfassen
Bisher habe ich das.
- (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);
}
}
Das Problem, das mir begegnet ist, ist, dass der Callback-Block für die DisplayStream nicht aufgerufen werden. Ich bekomme keine Fehler oder Warnungen. Gibt es etwas, das ich vermisse oder das ich falsch gemacht habe?
Könnten Sie bitte die Probe und Video, das Sie als Referenz verwendet zeigen? –