2014-07-07 163 views
2

當我從4.6到5.1'「videoMinnFrameDuration」 Xcode更新在ios7videoMinFrameDuration已被棄用

- (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); 
+0

已棄用的方法意味着它由於安全問題已過時,因爲新方法執行相同的事情或任何其他原因。它僅包含在運行舊版xcode的設備中,仍然可以運行你的代碼。爲了代碼安全和便攜性的目的,你不應該再使用它了。請參閱文檔以瞭解替代使用哪種方法。 – Aserre

回答

5

一件事,你使用GPUImage過時的版本,因爲這是一直固定在框架代碼將近一年了。更新您的本地框架版本。

我解決這個問題的GPUImage,因爲我還需要使用此方法用於舊的iOS版本的方式,是禁用圍繞相關代碼棄用檢查:

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)是可用,我們使用它。如果不是,則回退到現在已棄用的方法。由於我們知道它已被棄用,所以沒有必要讓編譯器警告我們這一點。

+0

非常感謝 –

0

棄用AVCaptureSession.h類AVFoundation它由以下注釋提及。

@property supportsVideoMinFrameDuration 
@abstract 
    Indicates whether the connection supports setting the videoMinFrameDuration property. 

@discussion 
    This property is only applicable to AVCaptureConnection instances involving 
    video. In such connections, the videoMinFrameDuration property may only be set if 
    -isVideoMinFrameDurationSupported returns YES. 

    This property is deprecated on iOS, where min and max frame rate adjustments are applied 
    exclusively at the AVCaptureDevice using the activeVideoMinFrameDuration and activeVideoMaxFrameDuration 
    properties. On Mac OS X, frame rate adjustments are supported both at the AVCaptureDevice 
    and at AVCaptureConnection, enabling connections to output different frame rates.