camera: Add an optional property that reports if a camera is back or front.

This is useful for iOS and Android, so an app can find the camera it cares
about in the list of devices.
This commit is contained in:
Ryan C. Gordon 2024-02-07 09:17:01 -05:00
parent 0b8617f71d
commit 8db2a3b27a
3 changed files with 37 additions and 6 deletions

View file

@ -305,6 +305,16 @@ extern DECLSPEC SDL_CameraDeviceID SDLCALL SDL_GetCameraInstanceID(SDL_Camera *c
/**
* Get the properties associated with an opened camera.
*
* The following read-only properties are provided by SDL:
*
* - `SDL_PROP_CAMERA_POSITION_STRING`: the position of the camera in
* relation to the hardware it is connected to. This is currently either
* the string "front" or "back", to signify which side of the user's
* device a camera is on. Future versions of SDL may add other position
* strings. This property is only set if this information can be
* determined by SDL. Most platforms do not set this attribute at all,
* but mobile devices tend to.
*
* \param camera the SDL_Camera obtained from SDL_OpenCameraDevice()
* \returns a valid property ID on success or 0 on failure; call
* SDL_GetError() for more information.
@ -318,6 +328,8 @@ extern DECLSPEC SDL_CameraDeviceID SDLCALL SDL_GetCameraInstanceID(SDL_Camera *c
*/
extern DECLSPEC SDL_PropertiesID SDLCALL SDL_GetCameraProperties(SDL_Camera *camera);
#define SDL_PROP_CAMERA_POSITION_STRING "SDL.camera.position"
/**
* Get the spec that a camera is using when generating images.
*