mirror of
https://github.com/libretro/RetroArch
synced 2025-02-06 09:40:06 +00:00
(Apple) Start making camera driver OSX-compatible (OSX 10.7 and up/requires AVFoundation)
This commit is contained in:
parent
9ea4a0d182
commit
0f43deb6d2
@ -11,6 +11,9 @@
|
|||||||
50351E7F192E5EC100668AB1 /* platform.m in Sources */ = {isa = PBXBuildFile; fileRef = 50351E7E192E5EC100668AB1 /* platform.m */; };
|
50351E7F192E5EC100668AB1 /* platform.m in Sources */ = {isa = PBXBuildFile; fileRef = 50351E7E192E5EC100668AB1 /* platform.m */; };
|
||||||
50535530185E0F4000926C26 /* CoreLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5053552F185E0F4000926C26 /* CoreLocation.framework */; };
|
50535530185E0F4000926C26 /* CoreLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5053552F185E0F4000926C26 /* CoreLocation.framework */; };
|
||||||
50C374A919F04F7A00984F8D /* CFExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 50C374A819F04F7A00984F8D /* CFExtensions.m */; };
|
50C374A919F04F7A00984F8D /* CFExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 50C374A819F04F7A00984F8D /* CFExtensions.m */; };
|
||||||
|
50C61C251A1BB10300A48DD3 /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50C61C241A1BB10300A48DD3 /* AVFoundation.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
|
||||||
|
50C61C271A1BB11D00A48DD3 /* CoreMedia.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50C61C261A1BB11D00A48DD3 /* CoreMedia.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
|
||||||
|
50C61C291A1BB12F00A48DD3 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50C61C281A1BB12F00A48DD3 /* CoreVideo.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
|
||||||
50D66298199F344700CF54E3 /* Cg.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50D66297199F344700CF54E3 /* Cg.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
|
50D66298199F344700CF54E3 /* Cg.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50D66297199F344700CF54E3 /* Cg.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
|
||||||
962EE0E2178B3DF6004224FF /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 962EE0E1178B3DF6004224FF /* IOKit.framework */; };
|
962EE0E2178B3DF6004224FF /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 962EE0E1178B3DF6004224FF /* IOKit.framework */; };
|
||||||
96355CE31788E72A0010DBFA /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96355CE21788E72A0010DBFA /* Cocoa.framework */; };
|
96355CE31788E72A0010DBFA /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96355CE21788E72A0010DBFA /* Cocoa.framework */; };
|
||||||
@ -34,6 +37,9 @@
|
|||||||
50351E7E192E5EC100668AB1 /* platform.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = platform.m; path = ../platform.m; sourceTree = "<group>"; };
|
50351E7E192E5EC100668AB1 /* platform.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = platform.m; path = ../platform.m; sourceTree = "<group>"; };
|
||||||
5053552F185E0F4000926C26 /* CoreLocation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreLocation.framework; path = System/Library/Frameworks/CoreLocation.framework; sourceTree = SDKROOT; };
|
5053552F185E0F4000926C26 /* CoreLocation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreLocation.framework; path = System/Library/Frameworks/CoreLocation.framework; sourceTree = SDKROOT; };
|
||||||
50C374A819F04F7A00984F8D /* CFExtensions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CFExtensions.m; path = ../../common/CFExtensions.m; sourceTree = SOURCE_ROOT; };
|
50C374A819F04F7A00984F8D /* CFExtensions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CFExtensions.m; path = ../../common/CFExtensions.m; sourceTree = SOURCE_ROOT; };
|
||||||
|
50C61C241A1BB10300A48DD3 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; };
|
||||||
|
50C61C261A1BB11D00A48DD3 /* CoreMedia.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMedia.framework; path = System/Library/Frameworks/CoreMedia.framework; sourceTree = SDKROOT; };
|
||||||
|
50C61C281A1BB12F00A48DD3 /* CoreVideo.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreVideo.framework; path = System/Library/Frameworks/CoreVideo.framework; sourceTree = SDKROOT; };
|
||||||
50D66295199F28AC00CF54E3 /* Cg.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Cg.framework; sourceTree = "<group>"; };
|
50D66295199F28AC00CF54E3 /* Cg.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Cg.framework; sourceTree = "<group>"; };
|
||||||
50D66297199F344700CF54E3 /* Cg.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cg.framework; path = ../../../../../../../Library/Frameworks/Cg.framework; sourceTree = "<group>"; };
|
50D66297199F344700CF54E3 /* Cg.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cg.framework; path = ../../../../../../../Library/Frameworks/Cg.framework; sourceTree = "<group>"; };
|
||||||
962EE0E1178B3DF6004224FF /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = ../../../../../../../System/Library/Frameworks/IOKit.framework; sourceTree = "<group>"; };
|
962EE0E1178B3DF6004224FF /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = ../../../../../../../System/Library/Frameworks/IOKit.framework; sourceTree = "<group>"; };
|
||||||
@ -63,6 +69,9 @@
|
|||||||
isa = PBXFrameworksBuildPhase;
|
isa = PBXFrameworksBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
|
50C61C291A1BB12F00A48DD3 /* CoreVideo.framework in Frameworks */,
|
||||||
|
50C61C271A1BB11D00A48DD3 /* CoreMedia.framework in Frameworks */,
|
||||||
|
50C61C251A1BB10300A48DD3 /* AVFoundation.framework in Frameworks */,
|
||||||
50D66298199F344700CF54E3 /* Cg.framework in Frameworks */,
|
50D66298199F344700CF54E3 /* Cg.framework in Frameworks */,
|
||||||
50535530185E0F4000926C26 /* CoreLocation.framework in Frameworks */,
|
50535530185E0F4000926C26 /* CoreLocation.framework in Frameworks */,
|
||||||
962EE0E2178B3DF6004224FF /* IOKit.framework in Frameworks */,
|
962EE0E2178B3DF6004224FF /* IOKit.framework in Frameworks */,
|
||||||
@ -115,6 +124,9 @@
|
|||||||
96355CE11788E72A0010DBFA /* Frameworks */ = {
|
96355CE11788E72A0010DBFA /* Frameworks */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
50C61C281A1BB12F00A48DD3 /* CoreVideo.framework */,
|
||||||
|
50C61C261A1BB11D00A48DD3 /* CoreMedia.framework */,
|
||||||
|
50C61C241A1BB10300A48DD3 /* AVFoundation.framework */,
|
||||||
50D66297199F344700CF54E3 /* Cg.framework */,
|
50D66297199F344700CF54E3 /* Cg.framework */,
|
||||||
50D66295199F28AC00CF54E3 /* Cg.framework */,
|
50D66295199F28AC00CF54E3 /* Cg.framework */,
|
||||||
5053552F185E0F4000926C26 /* CoreLocation.framework */,
|
5053552F185E0F4000926C26 /* CoreLocation.framework */,
|
||||||
|
@ -20,26 +20,27 @@
|
|||||||
|
|
||||||
/* Define compatibility symbols and categories. */
|
/* Define compatibility symbols and categories. */
|
||||||
|
|
||||||
#ifdef IOS
|
#if defined(MAC_OS_X_VERSION_10_7) || defined(__IPHONE_3_0)
|
||||||
|
|
||||||
#ifdef HAVE_CAMERA
|
|
||||||
#include <AVFoundation/AVCaptureSession.h>
|
#include <AVFoundation/AVCaptureSession.h>
|
||||||
#include <AVFoundation/AVCaptureDevice.h>
|
#include <AVFoundation/AVCaptureDevice.h>
|
||||||
#include <AVFoundation/AVCaptureOutput.h>
|
#include <AVFoundation/AVCaptureOutput.h>
|
||||||
#include <AVFoundation/AVCaptureInput.h>
|
#include <AVFoundation/AVCaptureInput.h>
|
||||||
#include <AVFoundation/AVMediaFormat.h>
|
#include <AVFoundation/AVMediaFormat.h>
|
||||||
|
#ifdef HAVE_OPENGLES
|
||||||
#include <CoreVideo/CVOpenGLESTextureCache.h>
|
#include <CoreVideo/CVOpenGLESTextureCache.h>
|
||||||
|
#else
|
||||||
|
#include <CoreVideo/CVOpenGLTexture.h>
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#elif defined(OSX)
|
#if defined(OSX)
|
||||||
|
|
||||||
/* RAGameView is a container on iOS;
|
/* RAGameView is a container on iOS;
|
||||||
* on OSX these are both the same object
|
* on OSX these are both the same object
|
||||||
*/
|
*/
|
||||||
#define g_view g_instance
|
#define g_view g_instance
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef IOS
|
#elif defined(IOS)
|
||||||
|
|
||||||
#include <GLKit/GLKit.h>
|
#include <GLKit/GLKit.h>
|
||||||
#include "../iOS/views.h"
|
#include "../iOS/views.h"
|
||||||
@ -173,10 +174,10 @@ static void apple_gfx_ctx_update(void);
|
|||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_CAMERA
|
|
||||||
#include "contentview_camera_ios.m.inl"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(MAC_OS_X_VERSION_10_7) || defined(__IPHONE_3_0)
|
||||||
|
#include "contentview_camera_ios.m.inl"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_LOCATION
|
#ifdef HAVE_LOCATION
|
||||||
@ -185,7 +186,7 @@ static void apple_gfx_ctx_update(void);
|
|||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
#if defined(HAVE_CAMERA) && defined(IOS)
|
#if defined(MAC_OS_X_VERSION_10_7) || defined(__IPHONE_3_0)
|
||||||
#include "apple_camera_ios.c.inl"
|
#include "apple_camera_ios.c.inl"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1,39 +1,39 @@
|
|||||||
typedef struct ios_camera
|
typedef struct apple_camera
|
||||||
{
|
{
|
||||||
void *empty;
|
void *empty;
|
||||||
} ioscamera_t;
|
} applecamera_t;
|
||||||
|
|
||||||
static void *ios_camera_init(const char *device, uint64_t caps, unsigned width, unsigned height)
|
static void *apple_camera_init(const char *device, uint64_t caps, unsigned width, unsigned height)
|
||||||
{
|
{
|
||||||
ioscamera_t *ioscamera;
|
applecamera_t *applecamera;
|
||||||
|
|
||||||
if ((caps & (1ULL << RETRO_CAMERA_BUFFER_OPENGL_TEXTURE)) == 0)
|
if ((caps & (1ULL << RETRO_CAMERA_BUFFER_OPENGL_TEXTURE)) == 0)
|
||||||
{
|
{
|
||||||
RARCH_ERR("ioscamera returns OpenGL texture.\n");
|
RARCH_ERR("applecamera returns OpenGL texture.\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ioscamera = (ioscamera_t*)calloc(1, sizeof(ioscamera_t));
|
applecamera = (applecamera_t*)calloc(1, sizeof(applecamera_t));
|
||||||
if (!ioscamera)
|
if (!applecamera)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
[[RAGameView get] onCameraInit];
|
[[RAGameView get] onCameraInit];
|
||||||
|
|
||||||
return ioscamera;
|
return applecamera;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ios_camera_free(void *data)
|
static void apple_camera_free(void *data)
|
||||||
{
|
{
|
||||||
ioscamera_t *ioscamera = (ioscamera_t*)data;
|
applecamera_t *applecamera = (applecamera_t*)data;
|
||||||
|
|
||||||
[[RAGameView get] onCameraFree];
|
[[RAGameView get] onCameraFree];
|
||||||
|
|
||||||
if (ioscamera)
|
if (applecamera)
|
||||||
free(ioscamera);
|
free(applecamera);
|
||||||
ioscamera = NULL;
|
applecamera = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool ios_camera_start(void *data)
|
static bool apple_camera_start(void *data)
|
||||||
{
|
{
|
||||||
(void)data;
|
(void)data;
|
||||||
|
|
||||||
@ -42,12 +42,12 @@ static bool ios_camera_start(void *data)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ios_camera_stop(void *data)
|
static void apple_camera_stop(void *data)
|
||||||
{
|
{
|
||||||
[[RAGameView get] onCameraStop];
|
[[RAGameView get] onCameraStop];
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool ios_camera_poll(void *data, retro_camera_frame_raw_framebuffer_t frame_raw_cb,
|
static bool apple_camera_poll(void *data, retro_camera_frame_raw_framebuffer_t frame_raw_cb,
|
||||||
retro_camera_frame_opengl_texture_t frame_gl_cb)
|
retro_camera_frame_opengl_texture_t frame_gl_cb)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -70,11 +70,11 @@ static bool ios_camera_poll(void *data, retro_camera_frame_raw_framebuffer_t fra
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
camera_driver_t camera_ios = {
|
camera_driver_t camera_apple = {
|
||||||
ios_camera_init,
|
apple_camera_init,
|
||||||
ios_camera_free,
|
apple_camera_free,
|
||||||
ios_camera_start,
|
apple_camera_start,
|
||||||
ios_camera_stop,
|
apple_camera_stop,
|
||||||
ios_camera_poll,
|
apple_camera_poll,
|
||||||
"ios",
|
"apple",
|
||||||
};
|
};
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
#define RCVOpenGLTextureCacheCreate CVOpenGLTextureCacheCreate
|
#define RCVOpenGLTextureCacheCreate CVOpenGLTextureCacheCreate
|
||||||
#define RCVOpenGLTextureRef CVOpenGLTextureRef
|
#define RCVOpenGLTextureRef CVOpenGLTextureRef
|
||||||
#define RCVOpenGLTextureCacheRef CVOpenGLTextureCacheRef
|
#define RCVOpenGLTextureCacheRef CVOpenGLTextureCacheRef
|
||||||
#define RCVOpenGLGetCurrentContext() CGLGetCurrentContext()
|
#define RCVOpenGLGetCurrentContext() CGLGetCurrentContext(), CGLGetPixelFormat(CGLGetCurrentContext())
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static AVCaptureSession *_session;
|
static AVCaptureSession *_session;
|
||||||
@ -30,6 +30,8 @@ RCVOpenGLTextureCacheRef textureCache;
|
|||||||
GLuint outputTexture;
|
GLuint outputTexture;
|
||||||
static bool newFrame = false;
|
static bool newFrame = false;
|
||||||
|
|
||||||
|
extern void event_process_camera_frame(void* pixelBufferPtr);
|
||||||
|
|
||||||
void event_process_camera_frame(void* pixelBufferPtr)
|
void event_process_camera_frame(void* pixelBufferPtr)
|
||||||
{
|
{
|
||||||
CVReturn ret;
|
CVReturn ret;
|
||||||
@ -40,15 +42,24 @@ void event_process_camera_frame(void* pixelBufferPtr)
|
|||||||
|
|
||||||
CVPixelBufferLockBaseAddress(pixelBuffer, 0);
|
CVPixelBufferLockBaseAddress(pixelBuffer, 0);
|
||||||
|
|
||||||
|
(void)width;
|
||||||
|
(void)height;
|
||||||
|
|
||||||
/*TODO - rewrite all this.
|
/*TODO - rewrite all this.
|
||||||
*
|
*
|
||||||
* create a texture from our render target.
|
* create a texture from our render target.
|
||||||
* textureCache will be what you previously
|
* textureCache will be what you previously
|
||||||
* made with RCVOpenGLTextureCacheCreate.
|
* made with RCVOpenGLTextureCacheCreate.
|
||||||
*/
|
*/
|
||||||
|
#ifdef HAVE_OPENGLES
|
||||||
ret = RCVOpenGLTextureCacheCreateTextureFromImage(kCFAllocatorDefault,
|
ret = RCVOpenGLTextureCacheCreateTextureFromImage(kCFAllocatorDefault,
|
||||||
textureCache, pixelBuffer, NULL, GL_TEXTURE_2D,
|
textureCache, pixelBuffer, NULL, GL_TEXTURE_2D,
|
||||||
GL_RGBA, (GLsizei)width, (GLsizei)height, GL_BGRA, GL_UNSIGNED_BYTE, 0, &renderTexture);
|
GL_RGBA, (GLsizei)width, (GLsizei)height,
|
||||||
|
GL_BGRA, GL_UNSIGNED_BYTE, 0, &renderTexture);
|
||||||
|
#else
|
||||||
|
ret = RCVOpenGLTextureCacheCreateTextureFromImage(kCFAllocatorDefault,
|
||||||
|
textureCache, pixelBuffer, 0, &renderTexture);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!renderTexture || ret)
|
if (!renderTexture || ret)
|
||||||
{
|
{
|
||||||
|
@ -106,7 +106,7 @@ enum
|
|||||||
CAMERA_V4L2,
|
CAMERA_V4L2,
|
||||||
CAMERA_RWEBCAM,
|
CAMERA_RWEBCAM,
|
||||||
CAMERA_ANDROID,
|
CAMERA_ANDROID,
|
||||||
CAMERA_IOS,
|
CAMERA_APPLE,
|
||||||
CAMERA_NULL,
|
CAMERA_NULL,
|
||||||
|
|
||||||
LOCATION_ANDROID,
|
LOCATION_ANDROID,
|
||||||
@ -275,8 +275,8 @@ enum
|
|||||||
#define CAMERA_DEFAULT_DRIVER CAMERA_RWEBCAM
|
#define CAMERA_DEFAULT_DRIVER CAMERA_RWEBCAM
|
||||||
#elif defined(ANDROID)
|
#elif defined(ANDROID)
|
||||||
#define CAMERA_DEFAULT_DRIVER CAMERA_ANDROID
|
#define CAMERA_DEFAULT_DRIVER CAMERA_ANDROID
|
||||||
#elif defined(IOS)
|
#elif defined(MAC_OS_X_VERSION_10_7) || defined(__IPHONE_3_0)
|
||||||
#define CAMERA_DEFAULT_DRIVER CAMERA_IOS
|
#define CAMERA_DEFAULT_DRIVER CAMERA_APPLE
|
||||||
#else
|
#else
|
||||||
#define CAMERA_DEFAULT_DRIVER CAMERA_NULL
|
#define CAMERA_DEFAULT_DRIVER CAMERA_NULL
|
||||||
#endif
|
#endif
|
||||||
|
4
driver.c
4
driver.c
@ -242,8 +242,8 @@ static const camera_driver_t *camera_drivers[] = {
|
|||||||
#ifdef ANDROID
|
#ifdef ANDROID
|
||||||
&camera_android,
|
&camera_android,
|
||||||
#endif
|
#endif
|
||||||
#ifdef IOS
|
#if defined(MAC_OS_X_VERSION_10_7) || defined(__IPHONE_3_0)
|
||||||
&camera_ios,
|
&camera_apple,
|
||||||
#endif
|
#endif
|
||||||
&camera_null,
|
&camera_null,
|
||||||
NULL,
|
NULL,
|
||||||
|
2
driver.h
2
driver.h
@ -680,7 +680,7 @@ extern input_driver_t input_null;
|
|||||||
extern camera_driver_t camera_v4l2;
|
extern camera_driver_t camera_v4l2;
|
||||||
extern camera_driver_t camera_android;
|
extern camera_driver_t camera_android;
|
||||||
extern camera_driver_t camera_rwebcam;
|
extern camera_driver_t camera_rwebcam;
|
||||||
extern camera_driver_t camera_ios;
|
extern camera_driver_t camera_apple;
|
||||||
extern camera_driver_t camera_null;
|
extern camera_driver_t camera_null;
|
||||||
|
|
||||||
extern location_driver_t location_apple;
|
extern location_driver_t location_apple;
|
||||||
|
@ -265,8 +265,8 @@ const char *config_get_default_camera(void)
|
|||||||
return "rwebcam";
|
return "rwebcam";
|
||||||
case CAMERA_ANDROID:
|
case CAMERA_ANDROID:
|
||||||
return "android";
|
return "android";
|
||||||
case CAMERA_IOS:
|
case CAMERA_APPLE:
|
||||||
return "ios";
|
return "apple";
|
||||||
case CAMERA_NULL:
|
case CAMERA_NULL:
|
||||||
return "null";
|
return "null";
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user