mirror of
https://github.com/libretro/RetroArch
synced 2025-02-22 12:40:09 +00:00
Split up camera driver code into separate file camera_driver.c
This commit is contained in:
parent
36d68b98b2
commit
4b0bd67d8d
@ -101,6 +101,7 @@ OBJ += frontend/frontend.o \
|
|||||||
input/input_driver.o \
|
input/input_driver.o \
|
||||||
gfx/video_driver.o \
|
gfx/video_driver.o \
|
||||||
osk/osk_driver.o \
|
osk/osk_driver.o \
|
||||||
|
camera_driver.o \
|
||||||
driver.o \
|
driver.o \
|
||||||
settings.o \
|
settings.o \
|
||||||
settings_list.o \
|
settings_list.o \
|
||||||
|
217
camera_driver.c
Normal file
217
camera_driver.c
Normal file
@ -0,0 +1,217 @@
|
|||||||
|
/* RetroArch - A frontend for libretro.
|
||||||
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
||||||
|
* Copyright (C) 2011-2015 - 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>
|
||||||
|
#include <string/string_list.h>
|
||||||
|
#include "camera_driver.h"
|
||||||
|
#include "driver.h"
|
||||||
|
#include "general.h"
|
||||||
|
|
||||||
|
static const camera_driver_t *camera_drivers[] = {
|
||||||
|
#ifdef HAVE_V4L2
|
||||||
|
&camera_v4l2,
|
||||||
|
#endif
|
||||||
|
#ifdef EMSCRIPTEN
|
||||||
|
&camera_rwebcam,
|
||||||
|
#endif
|
||||||
|
#ifdef ANDROID
|
||||||
|
&camera_android,
|
||||||
|
#endif
|
||||||
|
#if defined(MAC_OS_X_VERSION_10_7) || defined(__IPHONE_4_0)
|
||||||
|
&camera_apple,
|
||||||
|
#endif
|
||||||
|
&camera_null,
|
||||||
|
NULL,
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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)
|
||||||
|
{
|
||||||
|
const void *drv = camera_drivers[index];
|
||||||
|
if (!drv)
|
||||||
|
return NULL;
|
||||||
|
return drv;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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)
|
||||||
|
{
|
||||||
|
const camera_driver_t *drv = camera_drivers[index];
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
union string_list_elem_attr attr;
|
||||||
|
unsigned i;
|
||||||
|
char *options = NULL;
|
||||||
|
int options_len = 0;
|
||||||
|
struct string_list *options_l = string_list_new();
|
||||||
|
|
||||||
|
attr.i = 0;
|
||||||
|
|
||||||
|
for (i = 0; camera_driver_find_handle(i); i++)
|
||||||
|
{
|
||||||
|
const char *opt = camera_driver_find_ident(i);
|
||||||
|
options_len += strlen(opt) + 1;
|
||||||
|
string_list_append(options_l, opt, attr);
|
||||||
|
}
|
||||||
|
|
||||||
|
options = (char*)calloc(options_len, sizeof(char));
|
||||||
|
|
||||||
|
string_list_join_concat(options, options_len, options_l, "|");
|
||||||
|
|
||||||
|
string_list_free(options_l);
|
||||||
|
options_l = NULL;
|
||||||
|
|
||||||
|
return options;
|
||||||
|
}
|
||||||
|
|
||||||
|
void find_camera_driver(void)
|
||||||
|
{
|
||||||
|
int i = find_driver_index("camera_driver", g_settings.camera.driver);
|
||||||
|
if (i >= 0)
|
||||||
|
driver.camera = camera_driver_find_handle(i);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
unsigned d;
|
||||||
|
RARCH_ERR("Couldn't find any camera driver named \"%s\"\n",
|
||||||
|
g_settings.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");
|
||||||
|
|
||||||
|
driver.camera = camera_driver_find_handle(0);
|
||||||
|
|
||||||
|
if (!driver.camera)
|
||||||
|
rarch_fail(1, "find_camera_driver()");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* driver_camera_start:
|
||||||
|
*
|
||||||
|
* Starts camera driver interface.
|
||||||
|
* Used by RETRO_ENVIRONMENT_GET_CAMERA_INTERFACE.
|
||||||
|
*
|
||||||
|
* Returns: true (1) if successful, otherwise false (0).
|
||||||
|
**/
|
||||||
|
bool driver_camera_start(void)
|
||||||
|
{
|
||||||
|
if (driver.camera && driver.camera_data && driver.camera->start)
|
||||||
|
{
|
||||||
|
if (g_settings.camera.allow)
|
||||||
|
return driver.camera->start(driver.camera_data);
|
||||||
|
|
||||||
|
msg_queue_push(g_extern.msg_queue,
|
||||||
|
"Camera is explicitly disabled.\n", 1, 180);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* driver_camera_stop:
|
||||||
|
*
|
||||||
|
* Stops camera driver.
|
||||||
|
* Used by RETRO_ENVIRONMENT_GET_CAMERA_INTERFACE.
|
||||||
|
*
|
||||||
|
* Returns: true (1) if successful, otherwise false (0).
|
||||||
|
**/
|
||||||
|
void driver_camera_stop(void)
|
||||||
|
{
|
||||||
|
if (driver.camera && driver.camera->stop && driver.camera_data)
|
||||||
|
driver.camera->stop(driver.camera_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* driver_camera_poll:
|
||||||
|
*
|
||||||
|
* Call camera driver's poll function.
|
||||||
|
* Used by RETRO_ENVIRONMENT_GET_CAMERA_INTERFACE.
|
||||||
|
*
|
||||||
|
* Returns: true (1) if successful, otherwise false (0).
|
||||||
|
**/
|
||||||
|
void driver_camera_poll(void)
|
||||||
|
{
|
||||||
|
if (driver.camera && driver.camera->poll && driver.camera_data)
|
||||||
|
driver.camera->poll(driver.camera_data,
|
||||||
|
g_extern.system.camera_callback.frame_raw_framebuffer,
|
||||||
|
g_extern.system.camera_callback.frame_opengl_texture);
|
||||||
|
}
|
||||||
|
|
||||||
|
void init_camera(void)
|
||||||
|
{
|
||||||
|
/* Resource leaks will follow if camera is initialized twice. */
|
||||||
|
if (driver.camera_data)
|
||||||
|
return;
|
||||||
|
|
||||||
|
find_camera_driver();
|
||||||
|
|
||||||
|
driver.camera_data = driver.camera->init(
|
||||||
|
*g_settings.camera.device ? g_settings.camera.device : NULL,
|
||||||
|
g_extern.system.camera_callback.caps,
|
||||||
|
g_settings.camera.width ?
|
||||||
|
g_settings.camera.width : g_extern.system.camera_callback.width,
|
||||||
|
g_settings.camera.height ?
|
||||||
|
g_settings.camera.height : g_extern.system.camera_callback.height);
|
||||||
|
|
||||||
|
if (!driver.camera_data)
|
||||||
|
{
|
||||||
|
RARCH_ERR("Failed to initialize camera driver. Will continue without camera.\n");
|
||||||
|
driver.camera_active = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (g_extern.system.camera_callback.initialized)
|
||||||
|
g_extern.system.camera_callback.initialized();
|
||||||
|
}
|
||||||
|
|
||||||
|
void uninit_camera(void)
|
||||||
|
{
|
||||||
|
if (driver.camera_data && driver.camera)
|
||||||
|
{
|
||||||
|
if (g_extern.system.camera_callback.deinitialized)
|
||||||
|
g_extern.system.camera_callback.deinitialized();
|
||||||
|
|
||||||
|
if (driver.camera->free)
|
||||||
|
driver.camera->free(driver.camera_data);
|
||||||
|
}
|
||||||
|
driver.camera_data = NULL;
|
||||||
|
}
|
125
camera_driver.h
Normal file
125
camera_driver.h
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
/* RetroArch - A frontend for libretro.
|
||||||
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
||||||
|
* Copyright (C) 2011-2015 - 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 "libretro.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* driver_camera_start:
|
||||||
|
*
|
||||||
|
* Starts camera driver.
|
||||||
|
* Used by RETRO_ENVIRONMENT_GET_CAMERA_INTERFACE.
|
||||||
|
*
|
||||||
|
* Returns: true (1) if successful, otherwise false (0).
|
||||||
|
**/
|
||||||
|
bool driver_camera_start(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* driver_camera_stop:
|
||||||
|
*
|
||||||
|
* Stops camera driver.
|
||||||
|
* Used by RETRO_ENVIRONMENT_GET_CAMERA_INTERFACE.
|
||||||
|
*
|
||||||
|
* Returns: true (1) if successful, otherwise false (0).
|
||||||
|
**/
|
||||||
|
void driver_camera_stop(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* driver_camera_poll:
|
||||||
|
*
|
||||||
|
* Call camera driver's poll function.
|
||||||
|
* Used by RETRO_ENVIRONMENT_GET_CAMERA_INTERFACE.
|
||||||
|
*
|
||||||
|
* Returns: true (1) if successful, otherwise false (0).
|
||||||
|
**/
|
||||||
|
void driver_camera_poll(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 find_camera_driver(void);
|
||||||
|
|
||||||
|
void init_camera(void);
|
||||||
|
|
||||||
|
void uninit_camera(void);
|
||||||
|
|
||||||
|
extern camera_driver_t camera_v4l2;
|
||||||
|
extern camera_driver_t camera_android;
|
||||||
|
extern camera_driver_t camera_rwebcam;
|
||||||
|
extern camera_driver_t camera_apple;
|
||||||
|
extern camera_driver_t camera_null;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
196
driver.c
196
driver.c
@ -40,89 +40,6 @@
|
|||||||
|
|
||||||
driver_t driver;
|
driver_t driver;
|
||||||
|
|
||||||
static const camera_driver_t *camera_drivers[] = {
|
|
||||||
#ifdef HAVE_V4L2
|
|
||||||
&camera_v4l2,
|
|
||||||
#endif
|
|
||||||
#ifdef EMSCRIPTEN
|
|
||||||
&camera_rwebcam,
|
|
||||||
#endif
|
|
||||||
#ifdef ANDROID
|
|
||||||
&camera_android,
|
|
||||||
#endif
|
|
||||||
#if defined(MAC_OS_X_VERSION_10_7) || defined(__IPHONE_4_0)
|
|
||||||
&camera_apple,
|
|
||||||
#endif
|
|
||||||
&camera_null,
|
|
||||||
NULL,
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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.
|
|
||||||
**/
|
|
||||||
static const void *camera_driver_find_handle(int index)
|
|
||||||
{
|
|
||||||
const void *drv = camera_drivers[index];
|
|
||||||
if (!drv)
|
|
||||||
return NULL;
|
|
||||||
return drv;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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.
|
|
||||||
**/
|
|
||||||
static const char *camera_driver_find_ident(int index)
|
|
||||||
{
|
|
||||||
const camera_driver_t *drv = camera_drivers[index];
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
union string_list_elem_attr attr;
|
|
||||||
unsigned i;
|
|
||||||
char *options = NULL;
|
|
||||||
int options_len = 0;
|
|
||||||
struct string_list *options_l = string_list_new();
|
|
||||||
|
|
||||||
attr.i = 0;
|
|
||||||
|
|
||||||
for (i = 0; camera_driver_find_handle(i); i++)
|
|
||||||
{
|
|
||||||
const char *opt = camera_driver_find_ident(i);
|
|
||||||
options_len += strlen(opt) + 1;
|
|
||||||
string_list_append(options_l, opt, attr);
|
|
||||||
}
|
|
||||||
|
|
||||||
options = (char*)calloc(options_len, sizeof(char));
|
|
||||||
|
|
||||||
string_list_join_concat(options, options_len, options_l, "|");
|
|
||||||
|
|
||||||
string_list_free(options_l);
|
|
||||||
options_l = NULL;
|
|
||||||
|
|
||||||
return options;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const location_driver_t *location_drivers[] = {
|
static const location_driver_t *location_drivers[] = {
|
||||||
#ifdef ANDROID
|
#ifdef ANDROID
|
||||||
&location_android,
|
&location_android,
|
||||||
@ -463,119 +380,6 @@ void find_next_driver(const char *label, char *str, size_t sizeof_str)
|
|||||||
RARCH_WARN("Couldn't find any next driver (current one: \"%s\").\n", str);
|
RARCH_WARN("Couldn't find any next driver (current one: \"%s\").\n", str);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void find_camera_driver(void)
|
|
||||||
{
|
|
||||||
int i = find_driver_index("camera_driver", g_settings.camera.driver);
|
|
||||||
if (i >= 0)
|
|
||||||
driver.camera = camera_driver_find_handle(i);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
unsigned d;
|
|
||||||
RARCH_ERR("Couldn't find any camera driver named \"%s\"\n",
|
|
||||||
g_settings.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");
|
|
||||||
|
|
||||||
driver.camera = camera_driver_find_handle(0);
|
|
||||||
|
|
||||||
if (!driver.camera)
|
|
||||||
rarch_fail(1, "find_camera_driver()");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* driver_camera_start:
|
|
||||||
*
|
|
||||||
* Starts camera driver interface.
|
|
||||||
* Used by RETRO_ENVIRONMENT_GET_CAMERA_INTERFACE.
|
|
||||||
*
|
|
||||||
* Returns: true (1) if successful, otherwise false (0).
|
|
||||||
**/
|
|
||||||
bool driver_camera_start(void)
|
|
||||||
{
|
|
||||||
if (driver.camera && driver.camera_data && driver.camera->start)
|
|
||||||
{
|
|
||||||
if (g_settings.camera.allow)
|
|
||||||
return driver.camera->start(driver.camera_data);
|
|
||||||
|
|
||||||
msg_queue_push(g_extern.msg_queue,
|
|
||||||
"Camera is explicitly disabled.\n", 1, 180);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* driver_camera_stop:
|
|
||||||
*
|
|
||||||
* Stops camera driver.
|
|
||||||
* Used by RETRO_ENVIRONMENT_GET_CAMERA_INTERFACE.
|
|
||||||
*
|
|
||||||
* Returns: true (1) if successful, otherwise false (0).
|
|
||||||
**/
|
|
||||||
void driver_camera_stop(void)
|
|
||||||
{
|
|
||||||
if (driver.camera && driver.camera->stop && driver.camera_data)
|
|
||||||
driver.camera->stop(driver.camera_data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* driver_camera_poll:
|
|
||||||
*
|
|
||||||
* Call camera driver's poll function.
|
|
||||||
* Used by RETRO_ENVIRONMENT_GET_CAMERA_INTERFACE.
|
|
||||||
*
|
|
||||||
* Returns: true (1) if successful, otherwise false (0).
|
|
||||||
**/
|
|
||||||
void driver_camera_poll(void)
|
|
||||||
{
|
|
||||||
if (driver.camera && driver.camera->poll && driver.camera_data)
|
|
||||||
driver.camera->poll(driver.camera_data,
|
|
||||||
g_extern.system.camera_callback.frame_raw_framebuffer,
|
|
||||||
g_extern.system.camera_callback.frame_opengl_texture);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void init_camera(void)
|
|
||||||
{
|
|
||||||
/* Resource leaks will follow if camera is initialized twice. */
|
|
||||||
if (driver.camera_data)
|
|
||||||
return;
|
|
||||||
|
|
||||||
find_camera_driver();
|
|
||||||
|
|
||||||
driver.camera_data = driver.camera->init(
|
|
||||||
*g_settings.camera.device ? g_settings.camera.device : NULL,
|
|
||||||
g_extern.system.camera_callback.caps,
|
|
||||||
g_settings.camera.width ?
|
|
||||||
g_settings.camera.width : g_extern.system.camera_callback.width,
|
|
||||||
g_settings.camera.height ?
|
|
||||||
g_settings.camera.height : g_extern.system.camera_callback.height);
|
|
||||||
|
|
||||||
if (!driver.camera_data)
|
|
||||||
{
|
|
||||||
RARCH_ERR("Failed to initialize camera driver. Will continue without camera.\n");
|
|
||||||
driver.camera_active = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (g_extern.system.camera_callback.initialized)
|
|
||||||
g_extern.system.camera_callback.initialized();
|
|
||||||
}
|
|
||||||
|
|
||||||
static void uninit_camera(void)
|
|
||||||
{
|
|
||||||
if (driver.camera_data && driver.camera)
|
|
||||||
{
|
|
||||||
if (g_extern.system.camera_callback.deinitialized)
|
|
||||||
g_extern.system.camera_callback.deinitialized();
|
|
||||||
|
|
||||||
if (driver.camera->free)
|
|
||||||
driver.camera->free(driver.camera_data);
|
|
||||||
}
|
|
||||||
driver.camera_data = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void find_location_driver(void)
|
static void find_location_driver(void)
|
||||||
{
|
{
|
||||||
int i = find_driver_index("location_driver", g_settings.location.driver);
|
int i = find_driver_index("location_driver", g_settings.location.driver);
|
||||||
|
69
driver.h
69
driver.h
@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
#include "menu/menu_driver.h"
|
#include "menu/menu_driver.h"
|
||||||
#include "osk/osk_driver.h"
|
#include "osk/osk_driver.h"
|
||||||
|
#include "camera_driver.h"
|
||||||
#include "audio/resamplers/resampler.h"
|
#include "audio/resamplers/resampler.h"
|
||||||
#include "record/ffemu.h"
|
#include "record/ffemu.h"
|
||||||
|
|
||||||
@ -161,27 +162,6 @@ enum analog_dpad_mode
|
|||||||
ANALOG_DPAD_LAST
|
ANALOG_DPAD_LAST
|
||||||
};
|
};
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
typedef struct location_driver
|
typedef struct location_driver
|
||||||
{
|
{
|
||||||
@ -491,36 +471,6 @@ float driver_sensor_get_input(unsigned port, unsigned action);
|
|||||||
**/
|
**/
|
||||||
void *driver_video_resolve(const video_driver_t **drv);
|
void *driver_video_resolve(const video_driver_t **drv);
|
||||||
|
|
||||||
/**
|
|
||||||
* driver_camera_start:
|
|
||||||
*
|
|
||||||
* Starts camera driver.
|
|
||||||
* Used by RETRO_ENVIRONMENT_GET_CAMERA_INTERFACE.
|
|
||||||
*
|
|
||||||
* Returns: true (1) if successful, otherwise false (0).
|
|
||||||
**/
|
|
||||||
bool driver_camera_start(void);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* driver_camera_stop:
|
|
||||||
*
|
|
||||||
* Stops camera driver.
|
|
||||||
* Used by RETRO_ENVIRONMENT_GET_CAMERA_INTERFACE.
|
|
||||||
*
|
|
||||||
* Returns: true (1) if successful, otherwise false (0).
|
|
||||||
**/
|
|
||||||
void driver_camera_stop(void);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* driver_camera_poll:
|
|
||||||
*
|
|
||||||
* Call camera driver's poll function.
|
|
||||||
* Used by RETRO_ENVIRONMENT_GET_CAMERA_INTERFACE.
|
|
||||||
*
|
|
||||||
* Returns: true (1) if successful, otherwise false (0).
|
|
||||||
**/
|
|
||||||
void driver_camera_poll(void);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* driver_location_start:
|
* driver_location_start:
|
||||||
*
|
*
|
||||||
@ -582,17 +532,6 @@ bool driver_update_system_av_info(const struct retro_system_av_info *info);
|
|||||||
|
|
||||||
extern driver_t driver;
|
extern driver_t driver;
|
||||||
|
|
||||||
/**
|
|
||||||
* 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);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* config_get_video_driver_options:
|
* config_get_video_driver_options:
|
||||||
*
|
*
|
||||||
@ -638,12 +577,6 @@ const char* config_get_menu_driver_options(void);
|
|||||||
**/
|
**/
|
||||||
int find_driver_index(const char * label, const char *drv);
|
int find_driver_index(const char * label, const char *drv);
|
||||||
|
|
||||||
extern camera_driver_t camera_v4l2;
|
|
||||||
extern camera_driver_t camera_android;
|
|
||||||
extern camera_driver_t camera_rwebcam;
|
|
||||||
extern camera_driver_t camera_apple;
|
|
||||||
extern camera_driver_t camera_null;
|
|
||||||
|
|
||||||
extern location_driver_t location_apple;
|
extern location_driver_t location_apple;
|
||||||
extern location_driver_t location_android;
|
extern location_driver_t location_android;
|
||||||
extern location_driver_t location_null;
|
extern location_driver_t location_null;
|
||||||
|
@ -500,6 +500,7 @@ DRIVERS
|
|||||||
#include "../input/input_driver.c"
|
#include "../input/input_driver.c"
|
||||||
#include "../audio/audio_driver.c"
|
#include "../audio/audio_driver.c"
|
||||||
#include "../osk/osk_driver.c"
|
#include "../osk/osk_driver.c"
|
||||||
|
#include "../camera_driver.c"
|
||||||
#include "../driver.c"
|
#include "../driver.c"
|
||||||
|
|
||||||
/*============================================================
|
/*============================================================
|
||||||
|
Loading…
x
Reference in New Issue
Block a user