Am 05.12.23 um 15:19 schrieb Thilo Borgmann via ffmpeg-devel:
Am 05.12.23 um 15:16 schrieb Thilo Borgmann via ffmpeg-devel:
Hi,

Am 05.12.23 um 14:33 schrieb xufuji456 via ffmpeg-devel:
Building with iOS platform, the compiler has a warning: "'devicesWithMediaType:' is 
deprecated: first deprecated in iOS 10.0 - Use AVCaptureDeviceDiscoverySession 
instead"

Signed-off-by: xufuji456 <839789...@qq.com>
---
  libavdevice/avfoundation.m | 25 ++++++++++++++++++++-----
  1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/libavdevice/avfoundation.m b/libavdevice/avfoundation.m
index 36ad834753..1bc99d543a 100644
--- a/libavdevice/avfoundation.m
+++ b/libavdevice/avfoundation.m
@@ -761,6 +761,21 @@ static int get_audio_config(AVFormatContext *s)
      return 0;
  }
+static NSArray* getDevicesWithMediaType(AVMediaType mediaType) {


+#if ((TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MAX_ALLOWED >= 100000) || (TARGET_OS_OSX 
&& __MAC_OS_X_VERSION_MAX_ALLOWED >= 101500))
+    if (@available(macOS 10.15, iOS 10.0, *)) {

The preprocessor guard is meant to void the @available condition.

Also something appears not yet to achieve what you want, as on MacOS 13.4 I 
still get the deprication warning:

libavdevice/avfoundation.m:776:29: warning: 'devicesWithMediaType:' is 
deprecated: first deprecated in macOS 10.15 - Use 
AVCaptureDeviceDiscoverySession instead. [-Wdeprecated-declarations]
     return [AVCaptureDevice devicesWithMediaType:mediaType];



+        AVCaptureDeviceDiscoverySession *captureDeviceDiscoverySession =
+            [AVCaptureDeviceDiscoverySession
+            
discoverySessionWithDeviceTypes:@[AVCaptureDeviceTypeBuiltInWideAngleCamera]
+                                  mediaType:mediaType
+                                   
position:AVCaptureDevicePositionUnspecified];
+        return [captureDeviceDiscoverySession devices];
+    }

+#endif

why not #else... #endif ?

#elif
... of course.

#else
... writing faster than thinking is no good...



Also using it, would remove the deprication warning on capable systems. 
Otherwise it is still in the code and warned about.


+    // fallback
+    return [AVCaptureDevice devicesWithMediaType:mediaType];
+}
+

-Thilo

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to