77}
88
99{ *
10- * # CategoryCamera
11- *
12- * Video capture for the SDL library.
13- *
14- * This API lets apps read input from video sources, like webcams. Camera
15- * devices can be enumerated, queried, and opened. Once opened, it will
16- * provide SDL_Surface objects as new frames of video come in. These surfaces
17- * can be uploaded to an SDL_Texture or processed as pixels in memory.
10+ * # CategoryCamera
11+ *
12+ * Video capture for the SDL library.
13+ *
14+ * This API lets apps read input from video sources, like webcams. Camera
15+ * devices can be enumerated, queried, and opened. Once opened, it will
16+ * provide SDL_Surface objects as new frames of video come in. These surfaces
17+ * can be uploaded to an SDL_Texture or processed as pixels in memory.
18+ *
19+ * Several platforms will alert the user if an app tries to access a camera,
20+ * and some will present a UI asking the user if your application should be
21+ * allowed to obtain images at all, which they can deny. A successfully opened
22+ * camera will not provide images until permission is granted. Applications,
23+ * after opening a camera device, can see if they were granted access by
24+ * either polling with the SDL_GetCameraPermissionState() function, or waiting
25+ * for an SDL_EVENT_CAMERA_DEVICE_APPROVED or SDL_EVENT_CAMERA_DEVICE_DENIED
26+ * event. Platforms that don't have any user approval process will report
27+ * approval immediately.
28+ *
29+ * Note that SDL cameras only provide video as individual frames; they will
30+ * not provide full-motion video encoded in a movie file format, although an
31+ * app is free to encode the acquired frames into any format it likes. It also
32+ * does not provide audio from the camera hardware through this API; not only
33+ * do many webcams not have microphones at all, many people--from streamers to
34+ * people on Zoom calls--will want to use a separate microphone regardless of
35+ * the camera. In any case, recorded audio will be available through SDL's
36+ * audio API no matter what hardware provides the microphone.
37+ *
38+ * ## Camera gotchas
39+ *
40+ * Consumer-level camera hardware tends to take a little while to warm up,
41+ * once the device has been opened. Generally most camera apps have some sort
42+ * of UI to take a picture (a button to snap a pic while a preview is showing,
43+ * some sort of multi-second countdown for the user to pose, like a photo
44+ * booth), which puts control in the users' hands, or they are intended to
45+ * stay on for long times (Pokemon Go, etc).
46+ *
47+ * It's not uncommon that a newly-opened camera will provide a couple of
48+ * completely black frames, maybe followed by some under-exposed images. If
49+ * taking a single frame automatically, or recording video from a camera's
50+ * input without the user initiating it from a preview, it could be wise to
51+ * drop the first several frames (if not the first several _seconds_ worth of
52+ * frames!) before using images from a camera.
1853 }
1954
2055{ *
2560 *
2661 * The value 0 is an invalid ID.
2762 *
28- * \since This datatype is available since SDL 3.1.3 .
63+ * \since This datatype is available since SDL 3.2.0 .
2964 *
3065 * \sa SDL_GetCameras
3166 }
3772{ *
3873 * The opaque structure used to identify an opened SDL camera.
3974 *
40- * \since This struct is available since SDL 3.1.3 .
75+ * \since This struct is available since SDL 3.2.0 .
4176 }
4277type
4378 PPSDL_Camera = ^PSDL_Camera;
4984 * Cameras often support multiple formats; each one will be encapsulated in
5085 * this struct.
5186 *
52- * \since This struct is available since SDL 3.1.3 .
87+ * \since This struct is available since SDL 3.2.0 .
5388 *
5489 * \sa SDL_GetCameraSupportedFormats
5590 * \sa SDL_GetCameraFormat
69104{ *
70105 * The position of camera in relation to system device.
71106 *
72- * \since This enum is available since SDL 3.1.3 .
107+ * \since This enum is available since SDL 3.2.0 .
73108 *
74109 * \sa SDL_GetCameraPosition
75110 }
@@ -82,6 +117,22 @@ const
82117 SDL_CAMERA_POSITION_FRONT_FACING = TSDL_CameraPosition(1 );
83118 SDL_CAMERA_POSITION_BACK_FACING = TSDL_CameraPosition(2 );
84119
120+ { *
121+ * The current state of a request for camera access.
122+ *
123+ * \since This enum is available since SDL 3.4.0.
124+ *
125+ * \sa SDL_GetCameraPermissionState
126+ }
127+ type
128+ PPSDL_CameraPermissionState = ^PSDL_CameraPermissionState;
129+ PSDL_CameraPermissionState = ^TSDL_CameraPermissionState;
130+ TSDL_CameraPermissionState = type cint;
131+ const
132+ SDL_CAMERA_PERMISSION_STATE_DENIED = TSDL_CameraPermissionState(-1 );
133+ SDL_CAMERA_PERMISSION_STATE_PENDING = TSDL_CameraPermissionState(0 );
134+ SDL_CAMERA_PERMISSION_STATE_APPROVED = TSDL_CameraPermissionState(1 );
135+
85136{ *
86137 * Use this function to get the number of built-in camera drivers.
87138 *
99150 *
100151 * \threadsafety It is safe to call this function from any thread.
101152 *
102- * \since This function is available since SDL 3.1.3 .
153+ * \since This function is available since SDL 3.2.0 .
103154 *
104155 * \sa SDL_GetCameraDriver
105156 }
@@ -124,7 +175,7 @@ function SDL_GetNumCameraDrivers: cint; cdecl;
124175 *
125176 * \threadsafety It is safe to call this function from any thread.
126177 *
127- * \since This function is available since SDL 3.1.3 .
178+ * \since This function is available since SDL 3.2.0 .
128179 *
129180 * \sa SDL_GetNumCameraDrivers
130181 }
@@ -143,7 +194,7 @@ function SDL_GetCameraDriver(index: cint): PAnsiChar; cdecl;
143194 *
144195 * \threadsafety It is safe to call this function from any thread.
145196 *
146- * \since This function is available since SDL 3.1.3 .
197+ * \since This function is available since SDL 3.2.0 .
147198 }
148199function SDL_GetCurrentCameraDriver : PAnsiChar; cdecl;
149200 external SDL_LibName { $IFDEF DELPHI} { $IFDEF MACOS} name ' _SDL_GetCurrentCameraDriver' { $ENDIF} { $ENDIF} ;
@@ -159,7 +210,7 @@ function SDL_GetCurrentCameraDriver: PAnsiChar; cdecl;
159210 *
160211 * \threadsafety It is safe to call this function from any thread.
161212 *
162- * \since This function is available since SDL 3.1.3 .
213+ * \since This function is available since SDL 3.2.0 .
163214 *
164215 * \sa SDL_OpenCamera
165216 }
@@ -188,7 +239,7 @@ function SDL_GetCameras(count: pcint): PSDL_CameraID; cdecl;
188239 * there _is_ a camera until the user has given you permission to check
189240 * through a scary warning popup.
190241 *
191- * \param devid the camera device instance ID to query .
242+ * \param instance_id the camera device instance ID.
192243 * \param count a Pointer filled in with the number of elements in the list,
193244 * may be nil.
194245 * \returns a nil terminated array of pointers to SDL_CameraSpec or nil on
@@ -198,12 +249,12 @@ function SDL_GetCameras(count: pcint): PSDL_CameraID; cdecl;
198249 *
199250 * \threadsafety It is safe to call this function from any thread.
200251 *
201- * \since This function is available since SDL 3.1.3 .
252+ * \since This function is available since SDL 3.2.0 .
202253 *
203254 * \sa SDL_GetCameras
204255 * \sa SDL_OpenCamera
205256 }
206- function SDL_GetCameraSupportedFormats (devid : TSDL_CameraID; count: pcint):PPSDL_CameraSpec; cdecl;
257+ function SDL_GetCameraSupportedFormats (instance_id : TSDL_CameraID; count: pcint):PPSDL_CameraSpec; cdecl;
207258 external SDL_LibName { $IFDEF DELPHI} { $IFDEF MACOS} name ' _SDL_GetCameraSupportedFormats' { $ENDIF} { $ENDIF} ;
208259
209260{ *
@@ -215,7 +266,7 @@ function SDL_GetCameraSupportedFormats(devid: TSDL_CameraID; count: pcint):PPSDL
215266 *
216267 * \threadsafety It is safe to call this function from any thread.
217268 *
218- * \since This function is available since SDL 3.1.3 .
269+ * \since This function is available since SDL 3.2.0 .
219270 *
220271 * \sa SDL_GetCameras
221272 }
@@ -235,7 +286,7 @@ function SDL_GetCameraName(instance_id: TSDL_CameraID): PAnsiChar; cdecl;
235286 *
236287 * \threadsafety It is safe to call this function from any thread.
237288 *
238- * \since This function is available since SDL 3.1.3 .
289+ * \since This function is available since SDL 3.2.0 .
239290 *
240291 * \sa SDL_GetCameras
241292 }
@@ -282,7 +333,7 @@ function SDL_GetCameraPosition(instance_id: TSDL_CameraID): TSDL_CameraPosition;
282333 *
283334 * \threadsafety It is safe to call this function from any thread.
284335 *
285- * \since This function is available since SDL 3.1.3 .
336+ * \since This function is available since SDL 3.2.0 .
286337 *
287338 * \sa SDL_GetCameras
288339 * \sa SDL_GetCameraFormat
@@ -299,8 +350,9 @@ function SDL_OpenCamera(instance_id: TSDL_CameraID; spec: PSDL_CameraSpec): PSDL
299350 * on others the approval might be implicit and not alert the user at all.
300351 *
301352 * This function can be used to check the status of that approval. It will
302- * return 0 if still waiting for user response, 1 if the camera is approved
303- * for use, and -1 if the user denied access.
353+ * return SDL_CAMERA_PERMISSION_STATE_PENDING if waiting for user response,
354+ * SDL_CAMERA_PERMISSION_STATE_APPROVED if the camera is approved for use, and
355+ * SDL_CAMERA_PERMISSION_STATE_DENIED if the user denied access.
304356 *
305357 * Instead of polling with this function, you can wait for a
306358 * SDL_EVENT_CAMERA_DEVICE_APPROVED (or SDL_EVENT_CAMERA_DEVICE_DENIED) event
@@ -311,17 +363,18 @@ function SDL_OpenCamera(instance_id: TSDL_CameraID; spec: PSDL_CameraSpec): PSDL
311363 * SDL_CloseCamera() to dispose of it.
312364 *
313365 * \param camera the opened camera device to query.
314- * \returns -1 if user denied access to the camera, 1 if user approved access,
315- * 0 if no decision has been made yet.
366+ * \returns an SDL_CameraPermissionState value indicating if access is
367+ * granted, or `SDL_CAMERA_PERMISSION_STATE_PENDING` if the decision
368+ * is still pending.
316369 *
317370 * \threadsafety It is safe to call this function from any thread.
318371 *
319- * \since This function is available since SDL 3.1.3 .
372+ * \since This function is available since SDL 3.2.0 .
320373 *
321374 * \sa SDL_OpenCamera
322375 * \sa SDL_CloseCamera
323376 }
324- function SDL_GetCameraPermissionState (camera: PSDL_Camera): cint ; cdecl;
377+ function SDL_GetCameraPermissionState (camera: PSDL_Camera): TSDL_CameraPermissionState ; cdecl;
325378 external SDL_LibName { $IFDEF DELPHI} { $IFDEF MACOS} name ' _SDL_GetCameraPermissionState' { $ENDIF} { $ENDIF} ;
326379
327380{ *
@@ -333,7 +386,7 @@ function SDL_GetCameraPermissionState(camera: PSDL_Camera): cint; cdecl;
333386 *
334387 * \threadsafety It is safe to call this function from any thread.
335388 *
336- * \since This function is available since SDL 3.1.3 .
389+ * \since This function is available since SDL 3.2.0 .
337390 *
338391 * \sa SDL_OpenCamera
339392 }
@@ -349,7 +402,7 @@ function SDL_GetCameraID(camera: PSDL_Camera): TSDL_CameraID; cdecl;
349402 *
350403 * \threadsafety It is safe to call this function from any thread.
351404 *
352- * \since This function is available since SDL 3.1.3 .
405+ * \since This function is available since SDL 3.2.0 .
353406 }
354407function SDL_GetCameraProperties (camera: PSDL_Camera): TSDL_PropertiesID; cdecl;
355408 external SDL_LibName { $IFDEF DELPHI} { $IFDEF MACOS} name ' _SDL_GetCameraProperties' { $ENDIF} { $ENDIF} ;
@@ -374,7 +427,7 @@ function SDL_GetCameraProperties(camera: PSDL_Camera): TSDL_PropertiesID; cdecl;
374427 *
375428 * \threadsafety It is safe to call this function from any thread.
376429 *
377- * \since This function is available since SDL 3.1.3 .
430+ * \since This function is available since SDL 3.2.0 .
378431 *
379432 * \sa SDL_OpenCamera
380433 }
@@ -401,7 +454,7 @@ function SDL_GetCameraFormat(camera: PSDL_Camera; spec: PSDL_CameraSpec): Boolea
401454 * After use, the frame should be released with SDL_ReleaseCameraFrame(). If
402455 * you don't do this, the system may stop providing more video!
403456 *
404- * Do not call SDL_FreeSurface () on the returned surface! It must be given
457+ * Do not call SDL_DestroySurface () on the returned surface! It must be given
405458 * back to the camera subsystem with SDL_ReleaseCameraFrame!
406459 *
407460 * If the system is waiting for the user to approve access to the camera, as
@@ -418,7 +471,7 @@ function SDL_GetCameraFormat(camera: PSDL_Camera; spec: PSDL_CameraSpec): Boolea
418471 *
419472 * \threadsafety It is safe to call this function from any thread.
420473 *
421- * \since This function is available since SDL 3.1.3 .
474+ * \since This function is available since SDL 3.2.0 .
422475 *
423476 * \sa SDL_ReleaseCameraFrame
424477 }
@@ -447,7 +500,7 @@ function SDL_AcquireCameraFrame(camera: PSDL_Camera; timestampNS: pcuint64): PSD
447500 *
448501 * \threadsafety It is safe to call this function from any thread.
449502 *
450- * \since This function is available since SDL 3.1.3 .
503+ * \since This function is available since SDL 3.2.0 .
451504 *
452505 * \sa SDL_AcquireCameraFrame
453506 }
@@ -463,9 +516,8 @@ procedure SDL_ReleaseCameraFrame(camera: PSDL_Camera; frame: PSDL_Surface); cdec
463516 * \threadsafety It is safe to call this function from any thread, but no
464517 * thread may reference `device` once this function is called.
465518 *
466- * \since This function is available since SDL 3.1.3 .
519+ * \since This function is available since SDL 3.2.0 .
467520 *
468- * \sa SDL_OpenCameraWithSpec
469521 * \sa SDL_OpenCamera
470522 }
471523procedure SDL_CloseCamera (camera: PSDL_Camera); cdecl;
0 commit comments