Opened 3 months ago

Last modified 3 weeks ago

#70519 assigned defect

ffmpeg7 @7.0.1 does not build on macOS 10.12 with Xcode 9.2 due to "AVMediaType" type conflict

Reported by: andlabs (Pietro Gagliardi) Owned by: mascguy (Christopher Nielsen)
Priority: Normal Milestone:
Component: ports Version:
Keywords: Cc: mrkapqa, tehcog (tehcog), Randrianasulu (Andrew Randrianasulu), barracuda156
Port: ffmpeg7

Description

Thanks for adding ffmpeg 7! On macOS 10.12 with Xcode 9.2, it fails to build with a bunch of confusing errors related to AVMediaType:

:info:build libavdevice/avfoundation.m:765:41: error: must use 'enum' tag to refer to type 'AVMediaType'
:info:build static NSArray* getDevicesWithMediaType(AVMediaType mediaType) {
:info:build                                         ^
:info:build                                         enum 
:info:build libavdevice/avfoundation.m:816:50: warning: incompatible integer to pointer conversion sending 'enum AVMediaType' to parameter of type 'NSString *' [-Wint-conversion]
:info:build     return [AVCaptureDevice devicesWithMediaType:mediaType];
:info:build                                                  ^~~~~~~~~
:info:build /System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureDevice.h:110:47: note: passing argument to parameter 'mediaType' here
:info:build + (NSArray *)devicesWithMediaType:(NSString *)mediaType;
:info:build                                               ^
:info:build libavdevice/avfoundation.m:829:54: warning: incompatible pointer to integer conversion passing 'NSString *const' to parameter of type 'enum AVMediaType' [-Wint-conversion]
(snip; see attached log)

I am guessing that the AVFoundation.framework AVMediaType was introduced in a later version of Xcode's macOS SDK and its lack of presence on my headers means ffmpeg defined its own enum with that name? When I tried building ffmpeg 7 a few months ago I just manually changed the function parameters to all be NSString * instead; I don't know if that's the correct fix or not though, so I'm opening this bug.

Attachments (1)

main.log (409.3 KB) - added by andlabs (Pietro Gagliardi) 3 months ago.
build log

Download all attachments as: .zip

Change History (7)

Changed 3 months ago by andlabs (Pietro Gagliardi)

Attachment: main.log added

build log

comment:1 Changed 3 months ago by andlabs (Pietro Gagliardi)

Summary: ffmpeg7: does not build on macOS 10.12 with Xcode 9.2 due to "AVMediaType" type conflictffmpeg7 @7.0.1 does not build on macOS 10.12 with Xcode 9.2 due to "AVMediaType" type conflict

comment:2 Changed 3 months ago by erikbs

I think your analysis is correct. Unaware of this ticket I arrived at the same conclusion. In fact, in the 10.13 SDK, AVMediaType is typedef-ed to NSString* (with some extra specifier that does not seem to matter). The constants themselves (AVMediaTypeVideo etc.) were introduced in 10.7, where they were declared as NSString*. When the AVMediaType alias was introduced, the constant definitions were updated to use the new type alias. Ffmpeg7 fails because AVMediaType is not defined. Rather than patching the function to take an NSString* as parameter I created a patch that defines AVMediaType as an alias for NSString* (without the extra specifier) when targeting the OS X 10.12 SDK and older.

I have submitted the patch to FFmpeg and also opened a PR to have it included in MacPorts until the issue is fixed upstream: https://github.com/macports/macports-ports/pull/25416

comment:3 Changed 8 weeks ago by ryandesign (Ryan Carsten Schmidt)

Cc: mrkapqa added

Has duplicate #70921.

comment:4 Changed 4 weeks ago by tehcog (tehcog)

Cc: tehcog added

comment:5 Changed 4 weeks ago by tehcog (tehcog)

fyi: ffmpeg7 @7.0.2_2 still fails on mavericks

comment:6 Changed 3 weeks ago by ryandesign (Ryan Carsten Schmidt)

Cc: Randrianasulu barracuda156 added

Has duplicate #71218.

Note: See TracTickets for help on using tickets.