0

私は疑似リアルタイムで画面をキャプチャする OSX 上の Cocoa アプリに取り組んでいます。

何らかの理由で、次のようなスクリーン キャプチャ コールバック:

- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection

ディスプレイがスリープ状態になった後 ([システム設定] -> [省エネルギー])、かつディスプレイがユーザーによって再び「スリープ モード」から解除された後に呼び出されません。その理由はありますか?そして、どうすればそれを防ぐことができますか (つまり、修正できますか!) ???

私は次のように設定しました:

/****** This code snippet is used to set up the capture callbacks********************** */
    /* Create a capture session. */
    captureSession = [[AVCaptureSession alloc] init];
    if ([captureSession canSetSessionPreset:AVCaptureSessionPresetHigh])
    {
        /* Specifies capture settings suitable for high quality video and audio output. */
        [captureSession setSessionPreset:AVCaptureSessionPresetHigh];
    }

    /* Add display as a capture input. */
    // selectedDisplayId is defined prior to calling this code snippet */
    captureScreenInput = [[AVCaptureScreenInput alloc] initWithDisplayID:selectedDisplayId];
    if ([captureSession canAddInput:captureScreenInput])
    {
        [captureSession addInput:captureScreenInput];
    }
    else
    {
        NSLog(@"Could not add main display to capture input\n");
    }

    AVCaptureVideoDataOutput *output = [[AVCaptureVideoDataOutput alloc] init];

    [captureSession addOutput:output];

    dispatch_queue_t queue = dispatch_queue_create("myQueue", NULL);
    [output setSampleBufferDelegate:self queue:queue];

    output.alwaysDiscardsLateVideoFrames = TRUE;

    output.videoSettings = [NSDictionary dictionaryWithObject: [NSNumber numberWithInt:kCVPixelFormatType_32BGRA] forKey:(id)kCVPixelBufferPixelFormatTypeKey];

    /* Start the capture session. */
    printf("*** Start capture session ***\n");
    [captureSession startRunning];
    /****** ********* This code snippet is used to set up the capture callbacks **********************/

つまり、ディスプレイがオンになっている間、画面キャプチャのコールバックが期待どおりに繰り返し呼び出されます。ディスプレイがスリープ状態になり、ユーザーがディスプレイを再び「スリープ モード」から解除すると、コールバックの呼び出しが再開されません。どうすれば解決できますか?

ありがとう

私はMAC OSX 10.8.5を使用しています

4

0 に答える 0