如何使用AVCaptureConnnections?
|
我是AVFoundation的新手,我正在尝试使用AVFoundation实现摄像机,这是我的基本设置。基本上,当您单击按钮时,它将调用showCamera方法。在这里,我创建会话,然后添加音频输入和视频输入,然后添加视频输出。
我在哪里添加AVCaptureConnection,该怎么做?是否有一些教程显示如何使用连接?任何帮助表示赞赏。
- (IBAction) showCamera
{
//Add the camview to the current view ontop of controller
[[[[[UIApplication sharedApplication] delegate] self] window] addSubview:camView];
session = [[AVCaptureSession alloc] init];
//Set preset on session to make recording scale high
if ([session canSetSessionPreset:AVCaptureSessionPresetHigh]) {
session.sessionPreset = AVCaptureSessionPresetHigh;
}
// Add inputs and outputs.
NSArray *devices = [AVCaptureDevice devices];
//Print out all devices on phone
for (AVCaptureDevice *device in devices)
{
if ([device hasMediaType:AVMediaTypeVideo])
{
if ([device position] == AVCaptureDevicePositionBack)
{
//Add Rear Video input to session
[self addRearCameraInputToSession:session withDevice:device];
}
}
else if ([device hasMediaType:AVMediaTypeAudio])
{
//Add Microphone input to session
[self addMicrophoneInputToSession:session withDevice:device];
}
else
{
//Show error that your camera does not have a phone
}
}
//Add movie output
[self addMovieOutputToSession:session];
//Construct preview layer
[self constructPreviewLayerWithSession:session onView:camView];
}
没有找到相关结果
已邀请:
2 个回复
温拎凯玛
或
属性,否则根本不必担心它们。
枫湃揩乾纲