Próbuję zaimplementować funkcję w mojej aplikacji, która będzie nagrywać ekran. Mam fragmenty kodu, które znalazłem w przykładowym kodzie i wideo WWDC 2012.Ekran Przechwyć z CGDisplayStream
Do tej pory mam to.
- (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);
}
}
Problem, który napotykam, polega na tym, że blok wywołania dla DisplayStream nie jest wywoływany. Nie otrzymuję żadnych błędów ani ostrzeżeń. Czy jest coś, czego mi brakuje lub źle zrobiłem?
mógłbyś wskazać próbki i wideo użyty jako punkt odniesienia? –