mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-23 07:59:42 +00:00
Merge camera_driver.c with retroarch.c
This commit is contained in:
parent
f88e6c75d5
commit
3581786708
@ -216,7 +216,6 @@ OBJ += frontend/frontend.o \
|
||||
gfx/video_display_server.o \
|
||||
gfx/video_driver.o \
|
||||
gfx/video_crt_switch.o \
|
||||
camera/camera_driver.o \
|
||||
wifi/wifi_driver.o \
|
||||
location/location_driver.o \
|
||||
configuration.o \
|
||||
|
@ -1,237 +0,0 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2011-2017 - Daniel De Matteis
|
||||
*
|
||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "../config.h"
|
||||
#endif
|
||||
|
||||
#include "camera_driver.h"
|
||||
|
||||
#include "../configuration.h"
|
||||
#include "../driver.h"
|
||||
#include "../retroarch.h"
|
||||
#include "../list_special.h"
|
||||
#include "../verbosity.h"
|
||||
|
||||
static const camera_driver_t *camera_drivers[] = {
|
||||
#ifdef HAVE_V4L2
|
||||
&camera_v4l2,
|
||||
#endif
|
||||
#ifdef EMSCRIPTEN
|
||||
&camera_rwebcam,
|
||||
#endif
|
||||
#ifdef ANDROID
|
||||
&camera_android,
|
||||
#endif
|
||||
&camera_null,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static struct retro_camera_callback camera_cb;
|
||||
static const camera_driver_t *camera_driver = NULL;
|
||||
static void *camera_data = NULL;
|
||||
static bool camera_driver_active = false;
|
||||
|
||||
/**
|
||||
* camera_driver_find_handle:
|
||||
* @idx : index of driver to get handle to.
|
||||
*
|
||||
* Returns: handle to camera driver at index. Can be NULL
|
||||
* if nothing found.
|
||||
**/
|
||||
const void *camera_driver_find_handle(int idx)
|
||||
{
|
||||
const void *drv = camera_drivers[idx];
|
||||
if (!drv)
|
||||
return NULL;
|
||||
return drv;
|
||||
}
|
||||
|
||||
/**
|
||||
* camera_driver_find_ident:
|
||||
* @idx : index of driver to get handle to.
|
||||
*
|
||||
* Returns: Human-readable identifier of camera driver at index. Can be NULL
|
||||
* if nothing found.
|
||||
**/
|
||||
const char *camera_driver_find_ident(int idx)
|
||||
{
|
||||
const camera_driver_t *drv = camera_drivers[idx];
|
||||
if (!drv)
|
||||
return NULL;
|
||||
return drv->ident;
|
||||
}
|
||||
|
||||
/**
|
||||
* config_get_camera_driver_options:
|
||||
*
|
||||
* Get an enumerated list of all camera driver names,
|
||||
* separated by '|'.
|
||||
*
|
||||
* Returns: string listing of all camera driver names,
|
||||
* separated by '|'.
|
||||
**/
|
||||
const char* config_get_camera_driver_options(void)
|
||||
{
|
||||
return char_list_new_special(STRING_LIST_CAMERA_DRIVERS, NULL);
|
||||
}
|
||||
|
||||
void driver_camera_stop(void)
|
||||
{
|
||||
camera_driver_ctl(RARCH_CAMERA_CTL_START, NULL);
|
||||
}
|
||||
|
||||
bool driver_camera_start(void)
|
||||
{
|
||||
return camera_driver_ctl(RARCH_CAMERA_CTL_START, NULL);
|
||||
}
|
||||
|
||||
void camera_driver_poll(void)
|
||||
{
|
||||
if (!camera_cb.caps)
|
||||
return;
|
||||
if (!camera_driver || !camera_driver->poll || !camera_data)
|
||||
return;
|
||||
camera_driver->poll(camera_data,
|
||||
camera_cb.frame_raw_framebuffer,
|
||||
camera_cb.frame_opengl_texture);
|
||||
}
|
||||
|
||||
bool camera_driver_ctl(enum rarch_camera_ctl_state state, void *data)
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case RARCH_CAMERA_CTL_DESTROY:
|
||||
camera_driver_active = false;
|
||||
camera_driver = NULL;
|
||||
camera_data = NULL;
|
||||
break;
|
||||
case RARCH_CAMERA_CTL_SET_ACTIVE:
|
||||
camera_driver_active = true;
|
||||
break;
|
||||
case RARCH_CAMERA_CTL_FIND_DRIVER:
|
||||
{
|
||||
int i;
|
||||
driver_ctx_info_t drv;
|
||||
|
||||
drv.label = "camera_driver";
|
||||
drv.s = settings->arrays.camera_driver;
|
||||
|
||||
driver_ctl(RARCH_DRIVER_CTL_FIND_INDEX, &drv);
|
||||
|
||||
i = (int)drv.len;
|
||||
|
||||
if (i >= 0)
|
||||
camera_driver = (const camera_driver_t*)camera_driver_find_handle(i);
|
||||
else
|
||||
{
|
||||
if (verbosity_is_enabled())
|
||||
{
|
||||
unsigned d;
|
||||
RARCH_ERR("Couldn't find any camera driver named \"%s\"\n",
|
||||
settings->arrays.camera_driver);
|
||||
RARCH_LOG_OUTPUT("Available camera drivers are:\n");
|
||||
for (d = 0; camera_driver_find_handle(d); d++)
|
||||
RARCH_LOG_OUTPUT("\t%s\n", camera_driver_find_ident(d));
|
||||
|
||||
RARCH_WARN("Going to default to first camera driver...\n");
|
||||
}
|
||||
|
||||
camera_driver = (const camera_driver_t*)camera_driver_find_handle(0);
|
||||
|
||||
if (!camera_driver)
|
||||
retroarch_fail(1, "find_camera_driver()");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case RARCH_CAMERA_CTL_UNSET_ACTIVE:
|
||||
camera_driver_active = false;
|
||||
break;
|
||||
case RARCH_CAMERA_CTL_IS_ACTIVE:
|
||||
return camera_driver_active;
|
||||
case RARCH_CAMERA_CTL_DEINIT:
|
||||
if (camera_data && camera_driver)
|
||||
{
|
||||
if (camera_cb.deinitialized)
|
||||
camera_cb.deinitialized();
|
||||
|
||||
if (camera_driver->free)
|
||||
camera_driver->free(camera_data);
|
||||
}
|
||||
|
||||
camera_data = NULL;
|
||||
break;
|
||||
case RARCH_CAMERA_CTL_STOP:
|
||||
if ( camera_driver
|
||||
&& camera_driver->stop
|
||||
&& camera_data)
|
||||
camera_driver->stop(camera_data);
|
||||
break;
|
||||
case RARCH_CAMERA_CTL_START:
|
||||
if (camera_driver && camera_data && camera_driver->start)
|
||||
{
|
||||
if (settings->bools.camera_allow)
|
||||
return camera_driver->start(camera_data);
|
||||
|
||||
runloop_msg_queue_push(
|
||||
"Camera is explicitly disabled.\n", 1, 180, false,
|
||||
NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
||||
}
|
||||
break;
|
||||
case RARCH_CAMERA_CTL_SET_CB:
|
||||
{
|
||||
struct retro_camera_callback *cb =
|
||||
(struct retro_camera_callback*)data;
|
||||
camera_cb = *cb;
|
||||
}
|
||||
break;
|
||||
case RARCH_CAMERA_CTL_INIT:
|
||||
/* Resource leaks will follow if camera is initialized twice. */
|
||||
if (camera_data)
|
||||
return false;
|
||||
|
||||
camera_driver_ctl(RARCH_CAMERA_CTL_FIND_DRIVER, NULL);
|
||||
|
||||
if (!camera_driver)
|
||||
return false;
|
||||
|
||||
camera_data = camera_driver->init(
|
||||
*settings->arrays.camera_device ? settings->arrays.camera_device : NULL,
|
||||
camera_cb.caps,
|
||||
settings->uints.camera_width ?
|
||||
settings->uints.camera_width : camera_cb.width,
|
||||
settings->uints.camera_height ?
|
||||
settings->uints.camera_height : camera_cb.height);
|
||||
|
||||
if (!camera_data)
|
||||
{
|
||||
RARCH_ERR("Failed to initialize camera driver. Will continue without camera.\n");
|
||||
camera_driver_ctl(RARCH_CAMERA_CTL_UNSET_ACTIVE, NULL);
|
||||
}
|
||||
|
||||
if (camera_cb.initialized)
|
||||
camera_cb.initialized();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
@ -1,110 +0,0 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2011-2017 - Daniel De Matteis
|
||||
*
|
||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __CAMERA_DRIVER__H
|
||||
#define __CAMERA_DRIVER__H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <boolean.h>
|
||||
#include <retro_common_api.h>
|
||||
#include <libretro.h>
|
||||
|
||||
RETRO_BEGIN_DECLS
|
||||
|
||||
enum rarch_camera_ctl_state
|
||||
{
|
||||
RARCH_CAMERA_CTL_NONE = 0,
|
||||
RARCH_CAMERA_CTL_DESTROY,
|
||||
RARCH_CAMERA_CTL_DEINIT,
|
||||
RARCH_CAMERA_CTL_SET_ACTIVE,
|
||||
RARCH_CAMERA_CTL_UNSET_ACTIVE,
|
||||
RARCH_CAMERA_CTL_IS_ACTIVE,
|
||||
RARCH_CAMERA_CTL_FIND_DRIVER,
|
||||
RARCH_CAMERA_CTL_SET_CB,
|
||||
RARCH_CAMERA_CTL_STOP,
|
||||
RARCH_CAMERA_CTL_START,
|
||||
RARCH_CAMERA_CTL_INIT
|
||||
};
|
||||
|
||||
typedef struct camera_driver
|
||||
{
|
||||
/* FIXME: params for initialization - queries for resolution,
|
||||
* framerate, color format which might or might not be honored. */
|
||||
void *(*init)(const char *device, uint64_t buffer_types,
|
||||
unsigned width, unsigned height);
|
||||
|
||||
void (*free)(void *data);
|
||||
|
||||
bool (*start)(void *data);
|
||||
void (*stop)(void *data);
|
||||
|
||||
/* Polls the camera driver.
|
||||
* Will call the appropriate callback if a new frame is ready.
|
||||
* Returns true if a new frame was handled. */
|
||||
bool (*poll)(void *data,
|
||||
retro_camera_frame_raw_framebuffer_t frame_raw_cb,
|
||||
retro_camera_frame_opengl_texture_t frame_gl_cb);
|
||||
|
||||
const char *ident;
|
||||
} camera_driver_t;
|
||||
|
||||
extern camera_driver_t camera_v4l2;
|
||||
extern camera_driver_t camera_android;
|
||||
extern camera_driver_t camera_rwebcam;
|
||||
extern camera_driver_t camera_avfoundation;
|
||||
extern camera_driver_t camera_null;
|
||||
|
||||
/**
|
||||
* config_get_camera_driver_options:
|
||||
*
|
||||
* Get an enumerated list of all camera driver names,
|
||||
* separated by '|'.
|
||||
*
|
||||
* Returns: string listing of all camera driver names,
|
||||
* separated by '|'.
|
||||
**/
|
||||
const char* config_get_camera_driver_options(void);
|
||||
|
||||
/**
|
||||
* camera_driver_find_handle:
|
||||
* @index : index of driver to get handle to.
|
||||
*
|
||||
* Returns: handle to camera driver at index. Can be NULL
|
||||
* if nothing found.
|
||||
**/
|
||||
const void *camera_driver_find_handle(int index);
|
||||
|
||||
/**
|
||||
* camera_driver_find_ident:
|
||||
* @index : index of driver to get handle to.
|
||||
*
|
||||
* Returns: Human-readable identifier of camera driver at index. Can be NULL
|
||||
* if nothing found.
|
||||
**/
|
||||
const char *camera_driver_find_ident(int index);
|
||||
|
||||
void driver_camera_stop(void);
|
||||
|
||||
bool driver_camera_start(void);
|
||||
|
||||
void camera_driver_poll(void);
|
||||
|
||||
bool camera_driver_ctl(enum rarch_camera_ctl_state state, void *data);
|
||||
|
||||
RETRO_END_DECLS
|
||||
|
||||
#endif
|
@ -17,7 +17,7 @@
|
||||
|
||||
#include <glsym/glsym.h>
|
||||
|
||||
#include "../camera_driver.h"
|
||||
#include "../../retroarch.h"
|
||||
|
||||
typedef struct android_camera
|
||||
{
|
||||
|
@ -14,7 +14,7 @@
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "../camera_driver.h"
|
||||
#include "../../retroarch.h"
|
||||
|
||||
static void *nullcamera_init(const char *device, uint64_t caps,
|
||||
unsigned width, unsigned height)
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
#include <boolean.h>
|
||||
|
||||
#include "../camera_driver.h"
|
||||
#include "../../retroarch.h"
|
||||
|
||||
/* forward declarations */
|
||||
void *RWebCamInit(uint64_t caps, unsigned width, unsigned height);
|
||||
|
@ -45,7 +45,7 @@
|
||||
|
||||
#include <compat/strl.h>
|
||||
|
||||
#include "../camera_driver.h"
|
||||
#include "../../retroarch.h"
|
||||
#include "../../verbosity.h"
|
||||
|
||||
struct buffer
|
||||
|
@ -53,7 +53,6 @@
|
||||
#include "command.h"
|
||||
|
||||
#include "audio/audio_driver.h"
|
||||
#include "camera/camera_driver.h"
|
||||
#include "location/location_driver.h"
|
||||
#include "record/record_driver.h"
|
||||
#include "driver.h"
|
||||
|
@ -892,7 +892,6 @@ DRIVERS
|
||||
#include "../input/input_driver.c"
|
||||
#include "../audio/audio_driver.c"
|
||||
#include "../libretro-common/audio/audio_mixer.c"
|
||||
#include "../camera/camera_driver.c"
|
||||
#include "../location/location_driver.c"
|
||||
|
||||
/*============================================================
|
||||
|
@ -31,8 +31,6 @@
|
||||
#include "menu/menu_driver.h"
|
||||
#endif
|
||||
|
||||
#include "camera/camera_driver.h"
|
||||
|
||||
#ifdef HAVE_WIFI
|
||||
#include "wifi/wifi_driver.h"
|
||||
#endif
|
||||
@ -48,6 +46,7 @@
|
||||
#include "record/record_driver.h"
|
||||
#include "midi/midi_driver.h"
|
||||
#include "configuration.h"
|
||||
#include "retroarch.h"
|
||||
|
||||
struct string_list *dir_list_new_special(const char *input_dir,
|
||||
enum dir_list_type type, const char *filter)
|
||||
|
@ -74,7 +74,6 @@
|
||||
#include "../paths.h"
|
||||
#include "../dynamic.h"
|
||||
#include "../list_special.h"
|
||||
#include "../camera/camera_driver.h"
|
||||
#include "../wifi/wifi_driver.h"
|
||||
#include "../location/location_driver.h"
|
||||
#include "../record/record_driver.h"
|
||||
|
209
retroarch.c
209
retroarch.c
@ -120,7 +120,6 @@
|
||||
#include "../gfx/video_thread_wrapper.h"
|
||||
#endif
|
||||
#include "gfx/video_driver.h"
|
||||
#include "camera/camera_driver.h"
|
||||
#include "record/record_driver.h"
|
||||
#include "location/location_driver.h"
|
||||
#include "wifi/wifi_driver.h"
|
||||
@ -303,6 +302,8 @@ extern bool input_driver_flushing_input;
|
||||
|
||||
static char launch_arguments[4096];
|
||||
|
||||
/* BSV Movie */
|
||||
|
||||
struct bsv_state
|
||||
{
|
||||
bool movie_start_recording;
|
||||
@ -805,6 +806,207 @@ bool bsv_movie_check(void)
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Camera */
|
||||
|
||||
static const camera_driver_t *camera_drivers[] = {
|
||||
#ifdef HAVE_V4L2
|
||||
&camera_v4l2,
|
||||
#endif
|
||||
#ifdef EMSCRIPTEN
|
||||
&camera_rwebcam,
|
||||
#endif
|
||||
#ifdef ANDROID
|
||||
&camera_android,
|
||||
#endif
|
||||
&camera_null,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static struct retro_camera_callback camera_cb;
|
||||
static const camera_driver_t *camera_driver = NULL;
|
||||
static void *camera_data = NULL;
|
||||
static bool camera_driver_active = false;
|
||||
|
||||
/**
|
||||
* camera_driver_find_handle:
|
||||
* @idx : index of driver to get handle to.
|
||||
*
|
||||
* Returns: handle to camera driver at index. Can be NULL
|
||||
* if nothing found.
|
||||
**/
|
||||
const void *camera_driver_find_handle(int idx)
|
||||
{
|
||||
const void *drv = camera_drivers[idx];
|
||||
if (!drv)
|
||||
return NULL;
|
||||
return drv;
|
||||
}
|
||||
|
||||
/**
|
||||
* camera_driver_find_ident:
|
||||
* @idx : index of driver to get handle to.
|
||||
*
|
||||
* Returns: Human-readable identifier of camera driver at index. Can be NULL
|
||||
* if nothing found.
|
||||
**/
|
||||
const char *camera_driver_find_ident(int idx)
|
||||
{
|
||||
const camera_driver_t *drv = camera_drivers[idx];
|
||||
if (!drv)
|
||||
return NULL;
|
||||
return drv->ident;
|
||||
}
|
||||
|
||||
/**
|
||||
* config_get_camera_driver_options:
|
||||
*
|
||||
* Get an enumerated list of all camera driver names,
|
||||
* separated by '|'.
|
||||
*
|
||||
* Returns: string listing of all camera driver names,
|
||||
* separated by '|'.
|
||||
**/
|
||||
const char* config_get_camera_driver_options(void)
|
||||
{
|
||||
return char_list_new_special(STRING_LIST_CAMERA_DRIVERS, NULL);
|
||||
}
|
||||
|
||||
void driver_camera_stop(void)
|
||||
{
|
||||
camera_driver_ctl(RARCH_CAMERA_CTL_START, NULL);
|
||||
}
|
||||
|
||||
bool driver_camera_start(void)
|
||||
{
|
||||
return camera_driver_ctl(RARCH_CAMERA_CTL_START, NULL);
|
||||
}
|
||||
|
||||
bool camera_driver_ctl(enum rarch_camera_ctl_state state, void *data)
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case RARCH_CAMERA_CTL_DESTROY:
|
||||
camera_driver_active = false;
|
||||
camera_driver = NULL;
|
||||
camera_data = NULL;
|
||||
break;
|
||||
case RARCH_CAMERA_CTL_SET_ACTIVE:
|
||||
camera_driver_active = true;
|
||||
break;
|
||||
case RARCH_CAMERA_CTL_FIND_DRIVER:
|
||||
{
|
||||
int i;
|
||||
driver_ctx_info_t drv;
|
||||
|
||||
drv.label = "camera_driver";
|
||||
drv.s = settings->arrays.camera_driver;
|
||||
|
||||
driver_ctl(RARCH_DRIVER_CTL_FIND_INDEX, &drv);
|
||||
|
||||
i = (int)drv.len;
|
||||
|
||||
if (i >= 0)
|
||||
camera_driver = (const camera_driver_t*)camera_driver_find_handle(i);
|
||||
else
|
||||
{
|
||||
if (verbosity_is_enabled())
|
||||
{
|
||||
unsigned d;
|
||||
RARCH_ERR("Couldn't find any camera driver named \"%s\"\n",
|
||||
settings->arrays.camera_driver);
|
||||
RARCH_LOG_OUTPUT("Available camera drivers are:\n");
|
||||
for (d = 0; camera_driver_find_handle(d); d++)
|
||||
RARCH_LOG_OUTPUT("\t%s\n", camera_driver_find_ident(d));
|
||||
|
||||
RARCH_WARN("Going to default to first camera driver...\n");
|
||||
}
|
||||
|
||||
camera_driver = (const camera_driver_t*)camera_driver_find_handle(0);
|
||||
|
||||
if (!camera_driver)
|
||||
retroarch_fail(1, "find_camera_driver()");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case RARCH_CAMERA_CTL_UNSET_ACTIVE:
|
||||
camera_driver_active = false;
|
||||
break;
|
||||
case RARCH_CAMERA_CTL_IS_ACTIVE:
|
||||
return camera_driver_active;
|
||||
case RARCH_CAMERA_CTL_DEINIT:
|
||||
if (camera_data && camera_driver)
|
||||
{
|
||||
if (camera_cb.deinitialized)
|
||||
camera_cb.deinitialized();
|
||||
|
||||
if (camera_driver->free)
|
||||
camera_driver->free(camera_data);
|
||||
}
|
||||
|
||||
camera_data = NULL;
|
||||
break;
|
||||
case RARCH_CAMERA_CTL_STOP:
|
||||
if ( camera_driver
|
||||
&& camera_driver->stop
|
||||
&& camera_data)
|
||||
camera_driver->stop(camera_data);
|
||||
break;
|
||||
case RARCH_CAMERA_CTL_START:
|
||||
if (camera_driver && camera_data && camera_driver->start)
|
||||
{
|
||||
if (settings->bools.camera_allow)
|
||||
return camera_driver->start(camera_data);
|
||||
|
||||
runloop_msg_queue_push(
|
||||
"Camera is explicitly disabled.\n", 1, 180, false,
|
||||
NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
||||
}
|
||||
break;
|
||||
case RARCH_CAMERA_CTL_SET_CB:
|
||||
{
|
||||
struct retro_camera_callback *cb =
|
||||
(struct retro_camera_callback*)data;
|
||||
camera_cb = *cb;
|
||||
}
|
||||
break;
|
||||
case RARCH_CAMERA_CTL_INIT:
|
||||
/* Resource leaks will follow if camera is initialized twice. */
|
||||
if (camera_data)
|
||||
return false;
|
||||
|
||||
camera_driver_ctl(RARCH_CAMERA_CTL_FIND_DRIVER, NULL);
|
||||
|
||||
if (!camera_driver)
|
||||
return false;
|
||||
|
||||
camera_data = camera_driver->init(
|
||||
*settings->arrays.camera_device ? settings->arrays.camera_device : NULL,
|
||||
camera_cb.caps,
|
||||
settings->uints.camera_width ?
|
||||
settings->uints.camera_width : camera_cb.width,
|
||||
settings->uints.camera_height ?
|
||||
settings->uints.camera_height : camera_cb.height);
|
||||
|
||||
if (!camera_data)
|
||||
{
|
||||
RARCH_ERR("Failed to initialize camera driver. Will continue without camera.\n");
|
||||
camera_driver_ctl(RARCH_CAMERA_CTL_UNSET_ACTIVE, NULL);
|
||||
}
|
||||
|
||||
if (camera_cb.initialized)
|
||||
camera_cb.initialized();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Drivers */
|
||||
|
||||
/**
|
||||
* find_driver_nonempty:
|
||||
* @label : string of driver type to be found.
|
||||
@ -4824,7 +5026,10 @@ int runloop_iterate(unsigned *sleep_ms)
|
||||
bsv_movie_state_handle->frame_pos[bsv_movie_state_handle->frame_ptr]
|
||||
= intfstream_tell(bsv_movie_state_handle->file);
|
||||
|
||||
camera_driver_poll();
|
||||
if (camera_cb.caps && camera_driver && camera_driver->poll && camera_data)
|
||||
camera_driver->poll(camera_data,
|
||||
camera_cb.frame_raw_framebuffer,
|
||||
camera_cb.frame_opengl_texture);
|
||||
|
||||
/* Update binds for analog dpad modes. */
|
||||
for (i = 0; i < max_users; i++)
|
||||
|
82
retroarch.h
82
retroarch.h
@ -433,6 +433,8 @@ void rarch_log_file_deinit(void);
|
||||
|
||||
enum retro_language rarch_get_language_from_iso(const char *lang);
|
||||
|
||||
/* BSV Movie */
|
||||
|
||||
enum rarch_movie_type
|
||||
{
|
||||
RARCH_MOVIE_PLAYBACK = 0,
|
||||
@ -462,6 +464,86 @@ bool bsv_movie_ctl(enum bsv_ctl_state state, void *data);
|
||||
|
||||
bool bsv_movie_check(void);
|
||||
|
||||
/* Camera */
|
||||
|
||||
enum rarch_camera_ctl_state
|
||||
{
|
||||
RARCH_CAMERA_CTL_NONE = 0,
|
||||
RARCH_CAMERA_CTL_DESTROY,
|
||||
RARCH_CAMERA_CTL_DEINIT,
|
||||
RARCH_CAMERA_CTL_SET_ACTIVE,
|
||||
RARCH_CAMERA_CTL_UNSET_ACTIVE,
|
||||
RARCH_CAMERA_CTL_IS_ACTIVE,
|
||||
RARCH_CAMERA_CTL_FIND_DRIVER,
|
||||
RARCH_CAMERA_CTL_SET_CB,
|
||||
RARCH_CAMERA_CTL_STOP,
|
||||
RARCH_CAMERA_CTL_START,
|
||||
RARCH_CAMERA_CTL_INIT
|
||||
};
|
||||
|
||||
typedef struct camera_driver
|
||||
{
|
||||
/* FIXME: params for initialization - queries for resolution,
|
||||
* framerate, color format which might or might not be honored. */
|
||||
void *(*init)(const char *device, uint64_t buffer_types,
|
||||
unsigned width, unsigned height);
|
||||
|
||||
void (*free)(void *data);
|
||||
|
||||
bool (*start)(void *data);
|
||||
void (*stop)(void *data);
|
||||
|
||||
/* Polls the camera driver.
|
||||
* Will call the appropriate callback if a new frame is ready.
|
||||
* Returns true if a new frame was handled. */
|
||||
bool (*poll)(void *data,
|
||||
retro_camera_frame_raw_framebuffer_t frame_raw_cb,
|
||||
retro_camera_frame_opengl_texture_t frame_gl_cb);
|
||||
|
||||
const char *ident;
|
||||
} camera_driver_t;
|
||||
|
||||
extern camera_driver_t camera_v4l2;
|
||||
extern camera_driver_t camera_android;
|
||||
extern camera_driver_t camera_rwebcam;
|
||||
extern camera_driver_t camera_avfoundation;
|
||||
extern camera_driver_t camera_null;
|
||||
|
||||
/**
|
||||
* config_get_camera_driver_options:
|
||||
*
|
||||
* Get an enumerated list of all camera driver names,
|
||||
* separated by '|'.
|
||||
*
|
||||
* Returns: string listing of all camera driver names,
|
||||
* separated by '|'.
|
||||
**/
|
||||
const char* config_get_camera_driver_options(void);
|
||||
|
||||
/**
|
||||
* camera_driver_find_handle:
|
||||
* @index : index of driver to get handle to.
|
||||
*
|
||||
* Returns: handle to camera driver at index. Can be NULL
|
||||
* if nothing found.
|
||||
**/
|
||||
const void *camera_driver_find_handle(int index);
|
||||
|
||||
/**
|
||||
* camera_driver_find_ident:
|
||||
* @index : index of driver to get handle to.
|
||||
*
|
||||
* Returns: Human-readable identifier of camera driver at index. Can be NULL
|
||||
* if nothing found.
|
||||
**/
|
||||
const char *camera_driver_find_ident(int index);
|
||||
|
||||
void driver_camera_stop(void);
|
||||
|
||||
bool driver_camera_start(void);
|
||||
|
||||
bool camera_driver_ctl(enum rarch_camera_ctl_state state, void *data);
|
||||
|
||||
RETRO_END_DECLS
|
||||
|
||||
#endif
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
#include "../../../input/drivers/cocoa_input.h"
|
||||
#include "../../../location/location_driver.h"
|
||||
#include "../../../camera/camera_driver.h"
|
||||
#include "../../../retroarch.h"
|
||||
|
||||
#ifdef HAVE_COCOATOUCH
|
||||
#import "GCDWebUploader.h"
|
||||
|
Loading…
Reference in New Issue
Block a user