From 263f1b15ceddac5b3fc091a4341ddf8458b452d2 Mon Sep 17 00:00:00 2001 From: wang-bin Date: Thu, 23 May 2019 20:42:22 +0800 Subject: [PATCH] ios: do not use private iosurface api #1201 --- src/codec/video/SurfaceInteropCV.cpp | 9 ++++++--- src/codec/video/SurfaceInteropIOSurface.mm | 8 ++++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/codec/video/SurfaceInteropCV.cpp b/src/codec/video/SurfaceInteropCV.cpp index 63492c123..09c4e1623 100644 --- a/src/codec/video/SurfaceInteropCV.cpp +++ b/src/codec/video/SurfaceInteropCV.cpp @@ -61,10 +61,13 @@ extern InteropResource* CreateInteropCVOpenGLES(); InteropResource* InteropResource::create(InteropType type) { if (type == InteropAuto) { -#if defined(Q_OS_MACX) || defined(__IPHONE_11_0) - type = InteropIOSurface; -#else type = InteropCVOpenGLES; +#if defined(Q_OS_MACX) + type = InteropIOSurface; +#endif +#if defined(__builtin_available) + if (__builtin_available(iOS 11, macOS 10.6, *)) + type = InteropIOSurface; #endif } switch (type) { diff --git a/src/codec/video/SurfaceInteropIOSurface.mm b/src/codec/video/SurfaceInteropIOSurface.mm index 9da129fbc..259aacd09 100644 --- a/src/codec/video/SurfaceInteropIOSurface.mm +++ b/src/codec/video/SurfaceInteropIOSurface.mm @@ -18,7 +18,7 @@ License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ******************************************************************************/ - +#define IOS_USE_PRIVATE 0 // private symbols are forbidden by app store #include "SurfaceInteropCV.h" #ifdef Q_OS_IOS #import @@ -26,7 +26,7 @@ # ifdef __IPHONE_11_0 // always defined in new sdk # import # endif //__IPHONE_11_0 -# if COREVIDEO_SUPPORTS_IOSURFACE +# if COREVIDEO_SUPPORTS_IOSURFACE && IOS_USE_PRIVATE // declare the private API if IOSurface is supported in SDK. Thus we can use IOSurface on any iOS version even with old SDK and compiler @interface EAGLContext() - (BOOL)texImageIOSurface:(IOSurfaceRef)ioSurface target:(NSUInteger)target internalFormat:(NSUInteger)internalFormat width:(uint32_t)width height:(uint32_t)height format:(NSUInteger)format type:(NSUInteger)type plane:(uint32_t)plane invert:(BOOL)invert NS_AVAILABLE_IOS(4_0); // confirmed in iOS5.1 @@ -142,7 +142,11 @@ GLuint createTexture(CVPixelBufferRef, const VideoFormat &fmt, int plane, int pl ok = [[EAGLContext currentContext] texImageIOSurface:surface target:target internalFormat:iformat width:planeW height:planeH format:format type:dtype plane:plane]; else // fallback to old private api if runtime version < 11 # endif //__IPHONE_11_0 + { +#if IOS_USE_PRIVATE ok = [[EAGLContext currentContext] texImageIOSurface:surface target:target internalFormat:iformat width:planeW height:planeH format:format type:dtype plane:plane invert:NO]; +#endif //IOS_USE_PRIVATE + } if (!ok) { qWarning("error creating IOSurface texture at plane %d", plane); }