mirror of
https://github.com/libretro/RetroArch.git
synced 2026-11-22 01:33:23 -10:00
RETRO_CAMERA_BUFFER_PLANAR hands a core the capture device's own 4:2:0 planes, untouched, for the duration of the callback; the frame callback sits past the end of retro_camera_callback and is read only when its caps bit is set, so older cores are never read past. The Android driver picks the cheapest delivery the core accepts: the SurfaceTexture for a GL hardware context, the planes for a planar core, and XRGB8888 converted once by image_yuv_blit only for a core that takes nothing else. Planes come from Camera2 through the NDK (resolved at runtime, the HAL buffer mapped where it lies) and fall back to the legacy Camera's NV21 preview buffers, rotated between the camera and the reader without a copy. No permission is declared: a port that declares CAMERA gets the prompt, others get no camera.
102 lines
3.0 KiB
C
102 lines
3.0 KiB
C
/* RetroArch - A frontend for libretro.
|
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
|
* Copyright (C) 2011-2021 - 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 "../gfx/video_defines.h"
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
#include "../config.h"
|
|
#endif /* HAVE_CONFIG_H */
|
|
|
|
RETRO_BEGIN_DECLS
|
|
|
|
struct string_list;
|
|
|
|
typedef struct camera_driver
|
|
{
|
|
/* FIXME: params for initialization - queries for resolution,
|
|
* framerate, color format which might or might not be honored. */
|
|
/* @dims is the requested frame size, packed with VIDEO_SCALE_PACK;
|
|
* an axis of 0 leaves it to the device. */
|
|
void *(*init)(const char *device, uint64_t buffer_types,
|
|
unsigned dims);
|
|
|
|
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: the
|
|
* one the driver was initialised for, among those the core gave.
|
|
* 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,
|
|
retro_camera_frame_planar_t frame_planar_cb);
|
|
|
|
const char *ident;
|
|
} camera_driver_t;
|
|
|
|
typedef struct
|
|
{
|
|
struct retro_camera_callback cb; /* uint64_t alignment */
|
|
const camera_driver_t *driver;
|
|
void *data;
|
|
bool active;
|
|
} camera_driver_state_t;
|
|
|
|
extern const camera_driver_t *camera_drivers[];
|
|
|
|
|
|
extern camera_driver_t camera_v4l2;
|
|
extern camera_driver_t camera_pipewire;
|
|
extern camera_driver_t camera_android;
|
|
extern camera_driver_t camera_rwebcam;
|
|
extern camera_driver_t camera_avfoundation;
|
|
extern camera_driver_t camera_ffmpeg;
|
|
|
|
/**
|
|
* 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);
|
|
|
|
bool driver_camera_start(void);
|
|
|
|
void driver_camera_stop(void);
|
|
|
|
bool camera_driver_find_driver(const char *prefix,
|
|
bool verbosity_enabled);
|
|
|
|
camera_driver_state_t *camera_state_get_ptr(void);
|
|
|
|
RETRO_END_DECLS
|
|
|
|
#endif
|