AVCaptureConnection在第二次通话时冻结我的应用程序

时间:2012-06-24 08:21:38

标签: iphone ios

这是冻结我的应用的代码

 AVCaptureConnection *videoConnection = [videoOutput connectionWithMediaType:AVMediaTypeVideo];


if ([videoConnection isVideoOrientationSupported] )
{
    [videoConnection setVideoOrientation:AVCaptureVideoOrientationPortrait];

}

这是我的videoOutput init

// Setup video capture
videoInput = [[AVCaptureDeviceInput deviceInputWithDevice: front? frontVideoDevice: rearVideoDevice error: &error] retain];
videoOutput = [[AVCaptureVideoDataOutput alloc] init];
[videoOutput setAlwaysDiscardsLateVideoFrames: YES];
// Set the video output to store frame in BGRA (It is supposed to be faster)
NSString* key = (NSString*)kCVPixelBufferPixelFormatTypeKey; 
NSNumber* value = [NSNumber numberWithUnsignedInt:kCVPixelFormatType_32BGRA]; 
NSDictionary* videoSettings = [NSDictionary dictionaryWithObject:value forKey:key]; 
[videoOutput setVideoSettings:videoSettings]; 

当我第二次初始化会话时,我的应用程序停止响应 但如果我删除avcaptureconnection的代码一切都很好

1 个答案:

答案 0 :(得分:0)

...!

我打过电话 [session startRunning]

之前
AVCaptureConnection *videoConnection = [videoOutput connectionWithMediaType:AVMediaTypeVideo];


if ([videoConnection isVideoOrientationSupported] )
{
    [videoConnection setVideoOrientation:AVCaptureVideoOrientationPortrait];

}

我的坏事:)。