当我将 Xcode 从 4.6 更新到 5.1 时,ios7 中不推荐使用“videoMinnFrameDuration”
- (void)setFrameRate:(NSInteger)frameRate;
{
_frameRate = frameRate;
if (_frameRate > 0)
{
for (AVCaptureConnection *connection in videoOutput.connections)
{
if ([connection respondsToSelector:@selector(setVideoMinFrameDuration:)])
connection.videoMinFrameDuration = CMTimeMake(1,_frameRate);
一方面,您使用的是过时版本的 GPUImage,因为该问题已在框架代码中修复了近一年。更新本地框架版本。
由于我仍然需要对旧的 iOS 版本使用此方法,因此我在 GPUImage 中解决此问题的方法是禁用相关代码周围的弃用检查:
if ([_inputCamera respondsToSelector:@selector(setActiveVideoMinFrameDuration:)] &&
[_inputCamera respondsToSelector:@selector(setActiveVideoMaxFrameDuration:)]) {
NSError *error;
[_inputCamera lockForConfiguration:&error];
if (error == nil) {
#if defined(__IPHONE_7_0)
[_inputCamera setActiveVideoMinFrameDuration:CMTimeMake(1, _frameRate)];
[_inputCamera setActiveVideoMaxFrameDuration:CMTimeMake(1, _frameRate)];
#endif
}
[_inputCamera unlockForConfiguration];
} else {
for (AVCaptureConnection *connection in videoOutput.connections)
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
if ([connection respondsToSelector:@selector(setVideoMinFrameDuration:)])
connection.videoMinFrameDuration = CMTimeMake(1, _frameRate);
if ([connection respondsToSelector:@selector(setVideoMaxFrameDuration:)])
connection.videoMaxFrameDuration = CMTimeMake(1, _frameRate);
#pragma clang diagnostic pop
}
}
如果新财产(activeVideoMinFrameDuration
)可用,我们使用它。如果没有,它将回退到现已弃用的方法。因为我们知道它已被弃用,所以不需要编译器警告我们这一点。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)