camera: Reworked to operate with a driver interface, like other subsystems.

This commit is contained in:
Ryan C. Gordon 2023-12-01 10:59:13 -05:00
parent 2ad44bd162
commit cb10c80aaf
25 changed files with 608 additions and 332 deletions

View file

@ -108,6 +108,71 @@ typedef struct SDL_CameraFrame
} SDL_CameraFrame;
/**
* Use this function to get the number of built-in camera drivers.
*
* This function returns a hardcoded number. This never returns a negative
* value; if there are no drivers compiled into this build of SDL, this
* function returns zero. The presence of a driver in this list does not mean
* it will function, it just means SDL is capable of interacting with that
* interface. For example, a build of SDL might have v4l2 support, but if
* there's no kernel support available, SDL's v4l2 driver would fail if used.
*
* By default, SDL tries all drivers, in its preferred order, until one is
* found to be usable.
*
* \returns the number of built-in camera drivers.
*
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetCameraDriver
*/
extern DECLSPEC int SDLCALL SDL_GetNumCameraDrivers(void);
/**
* Use this function to get the name of a built in camera driver.
*
* The list of camera drivers is given in the order that they are normally
* initialized by default; the drivers that seem more reasonable to choose
* first (as far as the SDL developers believe) are earlier in the list.
*
* The names of drivers are all simple, low-ASCII identifiers, like "v4l2",
* "coremedia" or "android". These never have Unicode characters, and are not
* meant to be proper names.
*
* \param index the index of the camera driver; the value ranges from 0 to
* SDL_GetNumCameraDrivers() - 1
* \returns the name of the camera driver at the requested index, or NULL if an
* invalid index was specified.
*
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetNumCameraDrivers
*/
extern DECLSPEC const char *SDLCALL SDL_GetCameraDriver(int index);
/**
* Get the name of the current camera driver.
*
* The returned string points to internal static memory and thus never becomes
* invalid, even if you quit the camera subsystem and initialize a new driver
* (although such a case would return a different static string from another
* call to this function, of course). As such, you should not modify or free
* the returned string.
*
* \returns the name of the current camera driver or NULL if no driver has been
* initialized.
*
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL 3.0.0.
*/
extern DECLSPEC const char *SDLCALL SDL_GetCurrentCameraDriver(void);
/**
* Get a list of currently connected camera devices.
*

View file

@ -355,6 +355,22 @@ extern "C" {
*/
#define SDL_HINT_BMP_SAVE_LEGACY_FORMAT "SDL_BMP_SAVE_LEGACY_FORMAT"
/**
* A variable that decides what camera backend to use.
*
* By default, SDL will try all available camera backends in a reasonable
* order until it finds one that can work, but this hint allows the app
* or user to force a specific target, such as "directshow" if, say, you are
* on Windows Media Foundations but want to try DirectShow instead.
*
* The default value is unset, in which case SDL will try to figure out
* the best camera backend on your behalf. This hint needs to be set
* before SDL_Init() is called to be useful.
*
* This hint is available since SDL 3.0.0.
*/
#define SDL_HINT_CAMERA_DRIVER "SDL_CAMERA_DRIVER"
/**
* A variable controlling whether DirectInput should be used for controllers
*
@ -2478,7 +2494,6 @@ extern "C" {
*/
#define SDL_HINT_XINPUT_ENABLED "SDL_XINPUT_ENABLED"
/**
* An enumeration of hint priorities
*/

View file

@ -59,7 +59,8 @@ typedef enum
SDL_INIT_HAPTIC = 0x00001000,
SDL_INIT_GAMEPAD = 0x00002000, /**< `SDL_INIT_GAMEPAD` implies `SDL_INIT_JOYSTICK` */
SDL_INIT_EVENTS = 0x00004000,
SDL_INIT_SENSOR = 0x00008000
SDL_INIT_SENSOR = 0x00008000,
SDL_INIT_CAMERA = 0x00010000 /**< `SDL_INIT_CAMERA` implies `SDL_INIT_EVENTS` */
} SDL_InitFlags;
/**