[FFmpeg-devel] [PATCH] libavdevice: fix compilation for Mac OS X 10.7-10.12, iOS < 11

Erik Bråthen Solem erikbsolem at hotmail.com
Wed Aug 21 22:23:40 EEST 2024


avfoundation.m uses constants prefixed with AVMediaType on Mac OS X > 10.6.
In 10.7 through 10.12 their type was NSString*, but starting with 10.13 a
new type alias AVMediaType was introduced. In avfoundation.m, the function
getDevicesWithMediaType takes this type as parameter, which breaks support
for Mac OS X 10.7 through 10.12. By typedef-ing AVMediaType to NSString*
when targetting SDK 10.12 or older, the code compiles. Prior to 10.15 the
value is passed to a function that takes AVMediaType on 10.13+ and
NSString* on <= 10.12. The same API change was introduced in iOS starting
with iOS 11. The AVMediaType alias is itself typedef-ed to NSString* with
an extra specifier in the newer SDKs.

Signed-off-by: Erik Bråthen Solem <erikbsolem at hotmail.com>
---
libavdevice/avfoundation.m | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/libavdevice/avfoundation.m b/libavdevice/avfoundation.m
index c5a09c6563..1367b06ae2 100644
--- a/libavdevice/avfoundation.m
+++ b/libavdevice/avfoundation.m
@@ -763,6 +763,10 @@ static int get_audio_config(AVFormatContext *s)
    return 0;
}

+#if ((TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MAX_ALLOWED < 110000) || (TARGET_OS_OSX && __MAC_OS_X_VERSION_MAX_ALLOWED < 101300))
+typedef NSString* AVMediaType;
+#endif
+
static NSArray* getDevicesWithMediaType(AVMediaType mediaType) {
#if ((TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000) || (TARGET_OS_OSX && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500))
    NSMutableArray *deviceTypes = nil;
-- 
2.46.0



More information about the ffmpeg-devel mailing list