Параметр CMSampleBufferRef в обратном вызове делегата пуст
Я использую этот код для создания AVCaptureSession, но когда -(void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection
вызывается, размер sampleBuffer равен 0
- (BOOL)createCaptureSession:(NSError **)outError{
/* Create a capture session. */
self.captureSession = [[AVCaptureSession alloc] init];
if ([self.captureSession canSetSessionPreset:AVCaptureSessionPresetHigh])
{
/* Specifies capture settings suitable for high quality video and audio output. */
[self.captureSession setSessionPreset:AVCaptureSessionPresetHigh];
}
/* Add the main display as a capture input. */
display = CGMainDisplayID();
self.captureScreenInput = [[AVCaptureScreenInput alloc] initWithDisplayID:display];
if ([self.captureSession canAddInput:self.captureScreenInput])
{
[self.captureSession addInput:self.captureScreenInput];
}
else
{ NSLog(@"nevyslo");
return NO;
}
/* Register for notifications of errors during the capture session so we can display an alert. */
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(captureSessionRuntimeErrorDidOccur:) name:AVCaptureSessionRuntimeErrorNotification object:self.captureSession];
AVCaptureVideoDataOutput *output = [[AVCaptureVideoDataOutput alloc] init];
[self.captureSession addOutput:output];
dispatch_queue_t queue = dispatch_queue_create("myQueue", NULL);
[output setSampleBufferDelegate:self queue:queue];
[self.captureSession startRunning];
return YES;
}
Is there anything wrong in my method? Is it possible that mistake could be somewhere else? Я использую ARC.
EDIT Buffer was not empty, but it got deallocated imediatelly. Solved by retaining buffer. Спасибо