table of contents
- trixie 3.2.10+ds-1
- testing 3.2.22+ds-1
- unstable 3.2.24+ds-1
- experimental 3.3~git20251006~f90c179+ds-1
| SDL_GetCameraPermissionState(3) | SDL3 FUNCTIONS | SDL_GetCameraPermissionState(3) |
NAME¶
SDL_GetCameraPermissionState - Query if camera access has been approved by the user.
SYNOPSIS¶
#include <SDL3/SDL_camera.h>
SDL_CameraPermissionState SDL_GetCameraPermissionState(SDL_Camera *camera);
DESCRIPTION¶
Cameras will not function between when the device is opened by the app and when the user permits access to the hardware. On some platforms, this presents as a popup dialog where the user has to explicitly approve access; on others the approval might be implicit and not alert the user at all.
This function can be used to check the status of that approval. It will return SDL_CAMERA_PERMISSION_STATE_PENDING if waiting for user response, SDL_CAMERA_PERMISSION_STATE_APPROVED if the camera is approved for use, and SDL_CAMERA_PERMISSION_STATE_DENIED if the user denied access.
Instead of polling with this function, you can wait for a SDL_EVENT_CAMERA_DEVICE_APPROVED (or SDL_EVENT_CAMERA_DEVICE_DENIED) event in the standard SDL event loop, which is guaranteed to be sent once when permission to use the camera is decided.
If a camera is declined, there's nothing to be done but call SDL_CloseCamera() to dispose of it.
FUNCTION PARAMETERS¶
- camera
- the opened camera device to query.
RETURN VALUE¶
Returns an SDL_CameraPermissionState value indicating if access is granted, or SDL_CAMERA_PERMISSION_STATE_PENDING if the decision is still pending.
THREAD SAFETY¶
It is safe to call this function from any thread.
AVAILABILITY¶
This function is available since SDL 3.2.0.
SEE ALSO¶
| SDL 3.3.0 | Simple Directmedia Layer |