Skip to content

Commit

Permalink
ios: do not use private iosurface api wang-bin#1201
Browse files Browse the repository at this point in the history
  • Loading branch information
wang-bin committed May 23, 2019
1 parent c2837e1 commit 263f1b1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
9 changes: 6 additions & 3 deletions src/codec/video/SurfaceInteropCV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
8 changes: 6 additions & 2 deletions src/codec/video/SurfaceInteropIOSurface.mm
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
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 <OpenGLES/EAGL.h>
#include <CoreVideo/CVOpenGLESTextureCache.h>
# ifdef __IPHONE_11_0 // always defined in new sdk
# import <OpenGLES/EAGLIOSurface.h>
# 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
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 263f1b1

Please sign in to comment.