FFmpeg and AVFoundation AVMediaType conflict

In Xcode9, my porject have a compile error, as title describe.


The iOS AVFoundation framework file AVMediaFormat.h line 14 have below typedef.


typedef NSString * AVMediaType NS_EXTENSIBLE_STRING_ENUM;


The AVMediaType is same as FFmpeg enum AVMediaType.

The above picture is the error in my project FFmpeg framework file.


I want to know how can I fix this error.

You must avoid #import or #include of AVFoundation and ffmpeg header files in the same source file.


Note that AVFoundation (well, the header files) are Objective-C, whil ffmpeg is pure C. That means your source files are naturally separated. In general, you would #include ffmpeg header files in C source, and #import AVFoundation in Obj-C source.


The only exception is where your Obj-C makes a top-level call into ffmpeg. In that case, you will need to #include at least one ffmpeg header into Obj-C source. You can try:


— Limit what you #include, so that header files don't drag the ffmpeg AVMediaType declartion into Obj-C.


— Split your Obj-C into separate files, one that #includes ffmpeg, and the other that #includes AVFoundation.


— Write a wrapper function around some of the main ffmpeg functions, so that its use of AVMediaType is "hidden" inside.


— If you're compiling ffmpeg from source, you can fiddle with its source by using a #define internall to change its AVMediaType into a different type name. (This may or may not be easy to do, depending on how well you know the C language.)

FFmpeg and AVFoundation AVMediaType conflict
 
 
Q