我有以下代码:
BOOL success;
QTCaptureSession *session = [[QTCaptureSession alloc] init];
QTCaptureDevice *device = [QTCaptureDevice defaultInputDeviceWithMediaType: QTMediaTypeVideo];
success = [device open: &e];
if ( !success )
{
NSLog(@"error opening input device: %@", e);
return;
}
QTCaptureDeviceInput *input = [QTCaptureDeviceInput deviceInputWithDevice: device];
success = [session addInput: input error: &e];
if ( !success )
{
NSLog(@"error adding input device to session: %@", e);
return;
}
QTCaptureDecompressedVideoOutput *output = [[QTCaptureDecompressedVideoOutput alloc] init];
[output setDelegate: self];
success = [session addOutput: output error: &e];
if ( !success )
{
NSLog(@"error adding output device to session: %@", e);
return;
}
[session startRunning];
这位于运行时加载的包中,并且是作为 NSThread 选择器的方法的一部分(又名。它在后台线程中运行,而不是在主线程中运行)。
我的问题是,对 #addInput:error: 的调用永远不会返回。我在这里想念什么?