Преглед изворни кода

camera: Renamed everything from "video capture" to "camera", wired to CMake.

Ryan C. Gordon пре 1 година
родитељ
комит
7ae955ce68

+ 22 - 1
CMakeLists.txt

@@ -331,7 +331,7 @@ set_option(SDL_METAL               "Enable Metal support" ${APPLE})
 set_option(SDL_KMSDRM              "Use KMS DRM video driver" ${UNIX_SYS})
 set_option(SDL_KMSDRM              "Use KMS DRM video driver" ${UNIX_SYS})
 dep_option(SDL_KMSDRM_SHARED       "Dynamically load KMS DRM support" ON "SDL_KMSDRM" OFF)
 dep_option(SDL_KMSDRM_SHARED       "Dynamically load KMS DRM support" ON "SDL_KMSDRM" OFF)
 set_option(SDL_OFFSCREEN           "Use offscreen video driver" ON)
 set_option(SDL_OFFSCREEN           "Use offscreen video driver" ON)
-dep_option(SDL_VIDEO_CAPTURE       "Enable video capturing" ON SDL_VIDEO OFF)
+dep_option(SDL_CAMERA              "Enable camera support" ON SDL_VIDEO OFF)
 option_string(SDL_BACKGROUNDING_SIGNAL "number to use for magic backgrounding signal or 'OFF'" OFF)
 option_string(SDL_BACKGROUNDING_SIGNAL "number to use for magic backgrounding signal or 'OFF'" OFF)
 option_string(SDL_FOREGROUNDING_SIGNAL "number to use for magic foregrounding signal or 'OFF'" OFF)
 option_string(SDL_FOREGROUNDING_SIGNAL "number to use for magic foregrounding signal or 'OFF'" OFF)
 dep_option(SDL_HIDAPI              "Enable the HIDAPI subsystem" ON "NOT VISIONOS" OFF)
 dep_option(SDL_HIDAPI              "Enable the HIDAPI subsystem" ON "NOT VISIONOS" OFF)
@@ -1289,6 +1289,12 @@ if(ANDROID)
     sdl_glob_sources("${SDL3_SOURCE_DIR}/src/sensor/android/*.c")
     sdl_glob_sources("${SDL3_SOURCE_DIR}/src/sensor/android/*.c")
   endif()
   endif()
 
 
+  if(SDL_CAMERA)
+    set(SDL_CAMERA_ANDROID 1)
+    set(HAVE_CAMERA TRUE)
+    sdl_glob_sources("${SDL3_SOURCE_DIR}/src/camera/android/*.c")
+  endif()
+
   if(SDL_VIDEO)
   if(SDL_VIDEO)
     set(SDL_VIDEO_DRIVER_ANDROID 1)
     set(SDL_VIDEO_DRIVER_ANDROID 1)
     sdl_glob_sources("${SDL3_SOURCE_DIR}/src/video/android/*.c")
     sdl_glob_sources("${SDL3_SOURCE_DIR}/src/video/android/*.c")
@@ -1498,6 +1504,9 @@ elseif(UNIX AND NOT APPLE AND NOT RISCOS AND NOT HAIKU)
               ioctl(0, KDGKBENT, &kbe);
               ioctl(0, KDGKBENT, &kbe);
               return 0;
               return 0;
           }" HAVE_INPUT_KD)
           }" HAVE_INPUT_KD)
+      check_c_source_compiles("
+          #include <linux/videodev2.h>
+          int main(int argc, char** argv) { return 0; }" HAVE_LINUX_VIDEODEV2_H)
     elseif(FREEBSD)
     elseif(FREEBSD)
       check_c_source_compiles("
       check_c_source_compiles("
           #include <sys/kbio.h>
           #include <sys/kbio.h>
@@ -1521,6 +1530,12 @@ elseif(UNIX AND NOT APPLE AND NOT RISCOS AND NOT HAIKU)
           }" HAVE_INPUT_WSCONS)
           }" HAVE_INPUT_WSCONS)
     endif()
     endif()
 
 
+    if(SDL_CAMERA AND HAVE_LINUX_VIDEODEV2_H)
+      set(SDL_CAMERA_V4L2 1)
+      set(HAVE_CAMERA TRUE)
+      sdl_glob_sources("${SDL3_SOURCE_DIR}/src/camera/v4l2/*.c")
+    endif()
+
     if(HAVE_LINUX_INPUT_H)
     if(HAVE_LINUX_INPUT_H)
       set(SDL_INPUT_LINUXEV 1)
       set(SDL_INPUT_LINUXEV 1)
     endif()
     endif()
@@ -2020,6 +2035,8 @@ elseif(APPLE)
   sdl_glob_sources("${SDL3_SOURCE_DIR}/src/file/cocoa/*.m")
   sdl_glob_sources("${SDL3_SOURCE_DIR}/src/file/cocoa/*.m")
 
 
   if(IOS OR TVOS OR MACOSX OR DARWIN)
   if(IOS OR TVOS OR MACOSX OR DARWIN)
+    set(SDL_CAMERA_APPLE TRUE)
+    set(HAVE_CAMERA TRUE)
     sdl_sources("${SDL3_SOURCE_DIR}/src/camera/apple/SDL_camera_apple.m")
     sdl_sources("${SDL3_SOURCE_DIR}/src/camera/apple/SDL_camera_apple.m")
   endif()
   endif()
 
 
@@ -2721,6 +2738,10 @@ if(NOT HAVE_SDL_MISC)
   set(SDL_MISC_DUMMY 1)
   set(SDL_MISC_DUMMY 1)
   sdl_glob_sources("${SDL3_SOURCE_DIR}/src/misc/dummy/*.c")
   sdl_glob_sources("${SDL3_SOURCE_DIR}/src/misc/dummy/*.c")
 endif()
 endif()
+if(NOT HAVE_CAMERA)
+  set(SDL_CAMERA_DUMMY 1)
+  sdl_glob_sources("${SDL3_SOURCE_DIR}/src/camera/dummy/*.c")
+endif()
 
 
 # We always need to have threads and timers around
 # We always need to have threads and timers around
 if(NOT HAVE_SDL_THREADS)
 if(NOT HAVE_SDL_THREADS)

+ 102 - 102
include/SDL3/SDL_camera.h

@@ -37,182 +37,182 @@ extern "C" {
 #endif
 #endif
 
 
 /**
 /**
- * This is a unique ID for a video capture device for the time it is connected to the system,
+ * This is a unique ID for a camera device for the time it is connected to the system,
  * and is never reused for the lifetime of the application. If the device is
  * and is never reused for the lifetime of the application. If the device is
  * disconnected and reconnected, it will get a new ID.
  * disconnected and reconnected, it will get a new ID.
  *
  *
  * The ID value starts at 1 and increments from there. The value 0 is an invalid ID.
  * The ID value starts at 1 and increments from there. The value 0 is an invalid ID.
  *
  *
- * \sa SDL_GetVideoCaptureDevices
+ * \sa SDL_GetCameraDevices
  */
  */
-typedef Uint32 SDL_VideoCaptureDeviceID;
+typedef Uint32 SDL_CameraDeviceID;
 
 
 
 
 /**
 /**
- * The structure used to identify an SDL video capture device
+ * The structure used to identify an SDL camera device
  */
  */
-struct SDL_VideoCaptureDevice;
-typedef struct SDL_VideoCaptureDevice SDL_VideoCaptureDevice;
+struct SDL_CameraDevice;
+typedef struct SDL_CameraDevice SDL_CameraDevice;
 
 
-#define SDL_VIDEO_CAPTURE_ALLOW_ANY_CHANGE          1
+#define SDL_CAMERA_ALLOW_ANY_CHANGE          1
 
 
 /**
 /**
- *  SDL_VideoCaptureSpec structure
+ *  SDL_CameraSpec structure
  *
  *
  *  Only those field can be 'desired' when configuring the device:
  *  Only those field can be 'desired' when configuring the device:
  *  - format
  *  - format
  *  - width
  *  - width
  *  - height
  *  - height
  *
  *
- *  \sa SDL_GetVideoCaptureFormat
- *  \sa SDL_GetVideoCaptureFrameSize
+ *  \sa SDL_GetCameraFormat
+ *  \sa SDL_GetCameraFrameSize
  *
  *
  */
  */
-typedef struct SDL_VideoCaptureSpec
+typedef struct SDL_CameraSpec
 {
 {
     Uint32 format;          /**< Frame SDL_PixelFormatEnum format */
     Uint32 format;          /**< Frame SDL_PixelFormatEnum format */
     int width;              /**< Frame width */
     int width;              /**< Frame width */
     int height;             /**< Frame height */
     int height;             /**< Frame height */
-} SDL_VideoCaptureSpec;
+} SDL_CameraSpec;
 
 
 /**
 /**
- *  SDL Video Capture Status
+ *  SDL Camera Status
  *
  *
  *  Change states but calling the function in this order:
  *  Change states but calling the function in this order:
  *
  *
- *  SDL_OpenVideoCapture()
- *  SDL_SetVideoCaptureSpec()  -> Init
- *  SDL_StartVideoCapture()    -> Playing
- *  SDL_StopVideoCapture()     -> Stopped
- *  SDL_CloseVideoCapture()
+ *  SDL_OpenCamera()
+ *  SDL_SetCameraSpec()  -> Init
+ *  SDL_StartCamera()    -> Playing
+ *  SDL_StopCamera()     -> Stopped
+ *  SDL_CloseCamera()
  *
  *
  */
  */
 typedef enum
 typedef enum
 {
 {
-    SDL_VIDEO_CAPTURE_FAIL = -1,    /**< Failed */
-    SDL_VIDEO_CAPTURE_INIT = 0,     /**< Init, spec hasn't been set */
-    SDL_VIDEO_CAPTURE_STOPPED,      /**< Stopped */
-    SDL_VIDEO_CAPTURE_PLAYING       /**< Playing */
-} SDL_VideoCaptureStatus;
+    SDL_CAMERA_FAIL = -1,    /**< Failed */
+    SDL_CAMERA_INIT = 0,     /**< Init, spec hasn't been set */
+    SDL_CAMERA_STOPPED,      /**< Stopped */
+    SDL_CAMERA_PLAYING       /**< Playing */
+} SDL_CameraStatus;
 
 
 /**
 /**
  *  SDL Video Capture Status
  *  SDL Video Capture Status
  */
  */
-typedef struct SDL_VideoCaptureFrame
+typedef struct SDL_CameraFrame
 {
 {
     Uint64 timestampNS;         /**< Frame timestamp in nanoseconds when read from the driver */
     Uint64 timestampNS;         /**< Frame timestamp in nanoseconds when read from the driver */
     int num_planes;             /**< Number of planes */
     int num_planes;             /**< Number of planes */
     Uint8 *data[3];             /**< Pointer to data of i-th plane */
     Uint8 *data[3];             /**< Pointer to data of i-th plane */
     int pitch[3];               /**< Pitch of i-th plane */
     int pitch[3];               /**< Pitch of i-th plane */
     void *internal;             /**< Private field */
     void *internal;             /**< Private field */
-} SDL_VideoCaptureFrame;
+} SDL_CameraFrame;
 
 
 
 
 /**
 /**
- * Get a list of currently connected video capture devices.
+ * Get a list of currently connected camera devices.
  *
  *
- * \param count a pointer filled in with the number of video capture devices
- * \returns a 0 terminated array of video capture instance IDs which should be
+ * \param count a pointer filled in with the number of camera devices
+ * \returns a 0 terminated array of camera instance IDs which should be
  *          freed with SDL_free(), or NULL on error; call SDL_GetError() for
  *          freed with SDL_free(), or NULL on error; call SDL_GetError() for
  *          more details.
  *          more details.
  *
  *
  * \since This function is available since SDL 3.0.0.
  * \since This function is available since SDL 3.0.0.
  *
  *
- * \sa SDL_OpenVideoCapture
+ * \sa SDL_OpenCamera
  */
  */
-extern DECLSPEC SDL_VideoCaptureDeviceID *SDLCALL SDL_GetVideoCaptureDevices(int *count);
+extern DECLSPEC SDL_CameraDeviceID *SDLCALL SDL_GetCameraDevices(int *count);
 
 
 /**
 /**
  * Open a Video Capture device
  * Open a Video Capture device
  *
  *
- * \param instance_id the video capture device instance ID
+ * \param instance_id the camera device instance ID
  * \returns device, or NULL on failure; call SDL_GetError() for more
  * \returns device, or NULL on failure; call SDL_GetError() for more
  *          information.
  *          information.
  *
  *
  * \since This function is available since SDL 3.0.0.
  * \since This function is available since SDL 3.0.0.
  *
  *
- * \sa SDL_GetVideoCaptureDeviceName
- * \sa SDL_GetVideoCaptureDevices
- * \sa SDL_OpenVideoCaptureWithSpec
+ * \sa SDL_GetCameraDeviceName
+ * \sa SDL_GetCameraDevices
+ * \sa SDL_OpenCameraWithSpec
  */
  */
-extern DECLSPEC SDL_VideoCaptureDevice *SDLCALL SDL_OpenVideoCapture(SDL_VideoCaptureDeviceID instance_id);
+extern DECLSPEC SDL_CameraDevice *SDLCALL SDL_OpenCamera(SDL_CameraDeviceID instance_id);
 
 
 /**
 /**
  * Set specification
  * Set specification
  *
  *
- * \param device opened video capture device
- * \param desired desired video capture spec
- * \param obtained obtained video capture spec
+ * \param device opened camera device
+ * \param desired desired camera spec
+ * \param obtained obtained camera spec
  * \param allowed_changes allow changes or not
  * \param allowed_changes allow changes or not
  * \returns 0 on success or a negative error code on failure; call
  * \returns 0 on success or a negative error code on failure; call
  *          SDL_GetError() for more information.
  *          SDL_GetError() for more information.
  *
  *
  * \since This function is available since SDL 3.0.0.
  * \since This function is available since SDL 3.0.0.
  *
  *
- * \sa SDL_OpenVideoCapture
- * \sa SDL_OpenVideoCaptureWithSpec
- * \sa SDL_GetVideoCaptureSpec
+ * \sa SDL_OpenCamera
+ * \sa SDL_OpenCameraWithSpec
+ * \sa SDL_GetCameraSpec
  */
  */
-extern DECLSPEC int SDLCALL SDL_SetVideoCaptureSpec(SDL_VideoCaptureDevice *device,
-                                                    const SDL_VideoCaptureSpec *desired,
-                                                    SDL_VideoCaptureSpec *obtained,
+extern DECLSPEC int SDLCALL SDL_SetCameraSpec(SDL_CameraDevice *device,
+                                                    const SDL_CameraSpec *desired,
+                                                    SDL_CameraSpec *obtained,
                                                     int allowed_changes);
                                                     int allowed_changes);
 
 
 /**
 /**
  * Open a Video Capture device and set specification
  * Open a Video Capture device and set specification
  *
  *
- * \param instance_id the video capture device instance ID
- * \param desired desired video capture spec
- * \param obtained obtained video capture spec
+ * \param instance_id the camera device instance ID
+ * \param desired desired camera spec
+ * \param obtained obtained camera spec
  * \param allowed_changes allow changes or not
  * \param allowed_changes allow changes or not
  * \returns device, or NULL on failure; call SDL_GetError() for more
  * \returns device, or NULL on failure; call SDL_GetError() for more
  *          information.
  *          information.
  *
  *
  * \since This function is available since SDL 3.0.0.
  * \since This function is available since SDL 3.0.0.
  *
  *
- * \sa SDL_OpenVideoCapture
- * \sa SDL_SetVideoCaptureSpec
- * \sa SDL_GetVideoCaptureSpec
+ * \sa SDL_OpenCamera
+ * \sa SDL_SetCameraSpec
+ * \sa SDL_GetCameraSpec
  */
  */
-extern DECLSPEC SDL_VideoCaptureDevice *SDLCALL SDL_OpenVideoCaptureWithSpec(SDL_VideoCaptureDeviceID instance_id,
-                                                                              const SDL_VideoCaptureSpec *desired,
-                                                                              SDL_VideoCaptureSpec *obtained,
+extern DECLSPEC SDL_CameraDevice *SDLCALL SDL_OpenCameraWithSpec(SDL_CameraDeviceID instance_id,
+                                                                              const SDL_CameraSpec *desired,
+                                                                              SDL_CameraSpec *obtained,
                                                                               int allowed_changes);
                                                                               int allowed_changes);
 
 
 /**
 /**
  * Get device name
  * Get device name
  *
  *
- * \param instance_id the video capture device instance ID
+ * \param instance_id the camera device instance ID
  * \returns device name, shouldn't be freed
  * \returns device name, shouldn't be freed
  *
  *
  * \since This function is available since SDL 3.0.0.
  * \since This function is available since SDL 3.0.0.
  *
  *
- * \sa SDL_GetVideoCaptureDevices
+ * \sa SDL_GetCameraDevices
  */
  */
-extern DECLSPEC const char * SDLCALL SDL_GetVideoCaptureDeviceName(SDL_VideoCaptureDeviceID instance_id);
+extern DECLSPEC const char * SDLCALL SDL_GetCameraDeviceName(SDL_CameraDeviceID instance_id);
 
 
 /**
 /**
- * Get the obtained video capture spec
+ * Get the obtained camera spec
  *
  *
- * \param device opened video capture device
- * \param spec The SDL_VideoCaptureSpec to be initialized by this function.
+ * \param device opened camera device
+ * \param spec The SDL_CameraSpec to be initialized by this function.
  * \returns 0 on success or a negative error code on failure; call
  * \returns 0 on success or a negative error code on failure; call
  *          SDL_GetError() for more information.
  *          SDL_GetError() for more information.
  *
  *
  * \since This function is available since SDL 3.0.0.
  * \since This function is available since SDL 3.0.0.
  *
  *
- * \sa SDL_SetVideoCaptureSpec
- * \sa SDL_OpenVideoCaptureWithSpec
+ * \sa SDL_SetCameraSpec
+ * \sa SDL_OpenCameraWithSpec
  */
  */
-extern DECLSPEC int SDLCALL SDL_GetVideoCaptureSpec(SDL_VideoCaptureDevice *device, SDL_VideoCaptureSpec *spec);
+extern DECLSPEC int SDLCALL SDL_GetCameraSpec(SDL_CameraDevice *device, SDL_CameraSpec *spec);
 
 
 
 
 /**
 /**
- * Get frame format of video capture device.
+ * Get frame format of camera device.
  *
  *
- * The value can be used to fill SDL_VideoCaptureSpec structure.
+ * The value can be used to fill SDL_CameraSpec structure.
  *
  *
- * \param device opened video capture device
+ * \param device opened camera device
  * \param index format between 0 and num -1
  * \param index format between 0 and num -1
  * \param format pointer output format (SDL_PixelFormatEnum)
  * \param format pointer output format (SDL_PixelFormatEnum)
  * \returns 0 on success or a negative error code on failure; call
  * \returns 0 on success or a negative error code on failure; call
@@ -220,32 +220,32 @@ extern DECLSPEC int SDLCALL SDL_GetVideoCaptureSpec(SDL_VideoCaptureDevice *devi
  *
  *
  * \since This function is available since SDL 3.0.0.
  * \since This function is available since SDL 3.0.0.
  *
  *
- * \sa SDL_GetNumVideoCaptureFormats
+ * \sa SDL_GetNumCameraFormats
  */
  */
-extern DECLSPEC int SDLCALL SDL_GetVideoCaptureFormat(SDL_VideoCaptureDevice *device,
+extern DECLSPEC int SDLCALL SDL_GetCameraFormat(SDL_CameraDevice *device,
                                                       int index,
                                                       int index,
                                                       Uint32 *format);
                                                       Uint32 *format);
 
 
 /**
 /**
  * Number of available formats for the device
  * Number of available formats for the device
  *
  *
- * \param device opened video capture device
+ * \param device opened camera device
  * \returns number of formats or a negative error code on failure; call
  * \returns number of formats or a negative error code on failure; call
  *          SDL_GetError() for more information.
  *          SDL_GetError() for more information.
  *
  *
  * \since This function is available since SDL 3.0.0.
  * \since This function is available since SDL 3.0.0.
  *
  *
- * \sa SDL_GetVideoCaptureFormat
- * \sa SDL_SetVideoCaptureSpec
+ * \sa SDL_GetCameraFormat
+ * \sa SDL_SetCameraSpec
  */
  */
-extern DECLSPEC int SDLCALL SDL_GetNumVideoCaptureFormats(SDL_VideoCaptureDevice *device);
+extern DECLSPEC int SDLCALL SDL_GetNumCameraFormats(SDL_CameraDevice *device);
 
 
 /**
 /**
  * Get frame sizes of the device and the specified input format.
  * Get frame sizes of the device and the specified input format.
  *
  *
- * The value can be used to fill SDL_VideoCaptureSpec structure.
+ * The value can be used to fill SDL_CameraSpec structure.
  *
  *
- * \param device opened video capture device
+ * \param device opened camera device
  * \param format a format that can be used by the device (SDL_PixelFormatEnum)
  * \param format a format that can be used by the device (SDL_PixelFormatEnum)
  * \param index framesize between 0 and num -1
  * \param index framesize between 0 and num -1
  * \param width output width
  * \param width output width
@@ -255,51 +255,51 @@ extern DECLSPEC int SDLCALL SDL_GetNumVideoCaptureFormats(SDL_VideoCaptureDevice
  *
  *
  * \since This function is available since SDL 3.0.0.
  * \since This function is available since SDL 3.0.0.
  *
  *
- * \sa SDL_GetNumVideoCaptureFrameSizes
+ * \sa SDL_GetNumCameraFrameSizes
  */
  */
-extern DECLSPEC int SDLCALL SDL_GetVideoCaptureFrameSize(SDL_VideoCaptureDevice *device, Uint32 format, int index, int *width, int *height);
+extern DECLSPEC int SDLCALL SDL_GetCameraFrameSize(SDL_CameraDevice *device, Uint32 format, int index, int *width, int *height);
 
 
 /**
 /**
  * Number of different framesizes available for the device and pixel format.
  * Number of different framesizes available for the device and pixel format.
  *
  *
- * \param device opened video capture device
+ * \param device opened camera device
  * \param format frame pixel format (SDL_PixelFormatEnum)
  * \param format frame pixel format (SDL_PixelFormatEnum)
  * \returns number of framesizes or a negative error code on failure; call
  * \returns number of framesizes or a negative error code on failure; call
  *          SDL_GetError() for more information.
  *          SDL_GetError() for more information.
  *
  *
  * \since This function is available since SDL 3.0.0.
  * \since This function is available since SDL 3.0.0.
  *
  *
- * \sa SDL_GetVideoCaptureFrameSize
- * \sa SDL_SetVideoCaptureSpec
+ * \sa SDL_GetCameraFrameSize
+ * \sa SDL_SetCameraSpec
  */
  */
-extern DECLSPEC int SDLCALL SDL_GetNumVideoCaptureFrameSizes(SDL_VideoCaptureDevice *device, Uint32 format);
+extern DECLSPEC int SDLCALL SDL_GetNumCameraFrameSizes(SDL_CameraDevice *device, Uint32 format);
 
 
 
 
 /**
 /**
- * Get video capture status
+ * Get camera status
  *
  *
- * \param device opened video capture device
+ * \param device opened camera device
  * \returns 0 on success or a negative error code on failure; call
  * \returns 0 on success or a negative error code on failure; call
  *          SDL_GetError() for more information.
  *          SDL_GetError() for more information.
  *
  *
  * \since This function is available since SDL 3.0.0.
  * \since This function is available since SDL 3.0.0.
  *
  *
- * \sa SDL_VideoCaptureStatus
+ * \sa SDL_CameraStatus
  */
  */
-extern DECLSPEC SDL_VideoCaptureStatus SDLCALL SDL_GetVideoCaptureStatus(SDL_VideoCaptureDevice *device);
+extern DECLSPEC SDL_CameraStatus SDLCALL SDL_GetCameraStatus(SDL_CameraDevice *device);
 
 
 /**
 /**
- * Start video capture
+ * Start camera
  *
  *
- * \param device opened video capture device
+ * \param device opened camera device
  * \returns 0 on success or a negative error code on failure; call
  * \returns 0 on success or a negative error code on failure; call
  *          SDL_GetError() for more information.
  *          SDL_GetError() for more information.
  *
  *
  * \since This function is available since SDL 3.0.0.
  * \since This function is available since SDL 3.0.0.
  *
  *
- * \sa SDL_StopVideoCapture
+ * \sa SDL_StopCamera
  */
  */
-extern DECLSPEC int SDLCALL SDL_StartVideoCapture(SDL_VideoCaptureDevice *device);
+extern DECLSPEC int SDLCALL SDL_StartCamera(SDL_CameraDevice *device);
 
 
 /**
 /**
  * Acquire a frame.
  * Acquire a frame.
@@ -311,62 +311,62 @@ extern DECLSPEC int SDLCALL SDL_StartVideoCapture(SDL_VideoCaptureDevice *device
  * 0. If frame->num_planes is 0 and returned code is 0, there is no frame at
  * 0. If frame->num_planes is 0 and returned code is 0, there is no frame at
  * that time.
  * that time.
  *
  *
- * After used, the frame should be released with SDL_ReleaseVideoCaptureFrame
+ * After used, the frame should be released with SDL_ReleaseCameraFrame
  *
  *
- * \param device opened video capture device
+ * \param device opened camera device
  * \param frame pointer to get the frame
  * \param frame pointer to get the frame
  * \returns 0 on success or a negative error code on failure; call
  * \returns 0 on success or a negative error code on failure; call
  *          SDL_GetError() for more information.
  *          SDL_GetError() for more information.
  *
  *
  * \since This function is available since SDL 3.0.0.
  * \since This function is available since SDL 3.0.0.
  *
  *
- * \sa SDL_ReleaseVideoCaptureFrame
+ * \sa SDL_ReleaseCameraFrame
  */
  */
-extern DECLSPEC int SDLCALL SDL_AcquireVideoCaptureFrame(SDL_VideoCaptureDevice *device, SDL_VideoCaptureFrame *frame);
+extern DECLSPEC int SDLCALL SDL_AcquireCameraFrame(SDL_CameraDevice *device, SDL_CameraFrame *frame);
 
 
 /**
 /**
  * Release a frame.
  * Release a frame.
  *
  *
- * Let the back-end re-use the internal buffer for video capture.
+ * Let the back-end re-use the internal buffer for camera.
  *
  *
  * All acquired frames should be released before closing the device.
  * All acquired frames should be released before closing the device.
  *
  *
- * \param device opened video capture device
+ * \param device opened camera device
  * \param frame frame pointer.
  * \param frame frame pointer.
  * \returns 0 on success or a negative error code on failure; call
  * \returns 0 on success or a negative error code on failure; call
  *          SDL_GetError() for more information.
  *          SDL_GetError() for more information.
  *
  *
  * \since This function is available since SDL 3.0.0.
  * \since This function is available since SDL 3.0.0.
  *
  *
- * \sa SDL_AcquireVideoCaptureFrame
+ * \sa SDL_AcquireCameraFrame
  */
  */
-extern DECLSPEC int SDLCALL SDL_ReleaseVideoCaptureFrame(SDL_VideoCaptureDevice *device, SDL_VideoCaptureFrame *frame);
+extern DECLSPEC int SDLCALL SDL_ReleaseCameraFrame(SDL_CameraDevice *device, SDL_CameraFrame *frame);
 
 
 /**
 /**
  * Stop Video Capture
  * Stop Video Capture
  *
  *
- * \param device opened video capture device
+ * \param device opened camera device
  * \returns 0 on success or a negative error code on failure; call
  * \returns 0 on success or a negative error code on failure; call
  *          SDL_GetError() for more information.
  *          SDL_GetError() for more information.
  *
  *
  * \since This function is available since SDL 3.0.0.
  * \since This function is available since SDL 3.0.0.
  *
  *
- * \sa SDL_StartVideoCapture
+ * \sa SDL_StartCamera
  */
  */
-extern DECLSPEC int SDLCALL SDL_StopVideoCapture(SDL_VideoCaptureDevice *device);
+extern DECLSPEC int SDLCALL SDL_StopCamera(SDL_CameraDevice *device);
 
 
 /**
 /**
  * Use this function to shut down camera processing and close the
  * Use this function to shut down camera processing and close the
  * camera device.
  * camera device.
  *
  *
- * \param device opened video capture device
+ * \param device opened camera device
  *
  *
  * \since This function is available since SDL 3.0.0.
  * \since This function is available since SDL 3.0.0.
  *
  *
- * \sa SDL_OpenVideoCaptureWithSpec
- * \sa SDL_OpenVideoCapture
+ * \sa SDL_OpenCameraWithSpec
+ * \sa SDL_OpenCamera
  */
  */
-extern DECLSPEC void SDLCALL SDL_CloseVideoCapture(SDL_VideoCaptureDevice *device);
+extern DECLSPEC void SDLCALL SDL_CloseCamera(SDL_CameraDevice *device);
 
 
 /* Ends C function definitions when using C++ */
 /* Ends C function definitions when using C++ */
 #ifdef __cplusplus
 #ifdef __cplusplus

+ 7 - 2
include/build_config/SDL_build_config.h.cmake

@@ -253,8 +253,6 @@
 #cmakedefine SDL_DEFAULT_ASSERT_LEVEL @SDL_DEFAULT_ASSERT_LEVEL@
 #cmakedefine SDL_DEFAULT_ASSERT_LEVEL @SDL_DEFAULT_ASSERT_LEVEL@
 #endif
 #endif
 
 
-#cmakedefine SDL_VIDEO_CAPTURE
-
 /* Allow disabling of major subsystems */
 /* Allow disabling of major subsystems */
 #cmakedefine SDL_AUDIO_DISABLED @SDL_AUDIO_DISABLED@
 #cmakedefine SDL_AUDIO_DISABLED @SDL_AUDIO_DISABLED@
 #cmakedefine SDL_JOYSTICK_DISABLED @SDL_JOYSTICK_DISABLED@
 #cmakedefine SDL_JOYSTICK_DISABLED @SDL_JOYSTICK_DISABLED@
@@ -265,6 +263,7 @@
 #cmakedefine SDL_THREADS_DISABLED @SDL_THREADS_DISABLED@
 #cmakedefine SDL_THREADS_DISABLED @SDL_THREADS_DISABLED@
 #cmakedefine SDL_VIDEO_DISABLED @SDL_VIDEO_DISABLED@
 #cmakedefine SDL_VIDEO_DISABLED @SDL_VIDEO_DISABLED@
 #cmakedefine SDL_POWER_DISABLED @SDL_POWER_DISABLED@
 #cmakedefine SDL_POWER_DISABLED @SDL_POWER_DISABLED@
+#cmakedefine SDL_CAMERA_DISABLED @SDL_CAMERA_DISABLED@
 
 
 /* Enable various audio drivers */
 /* Enable various audio drivers */
 #cmakedefine SDL_AUDIO_DRIVER_ALSA @SDL_AUDIO_DRIVER_ALSA@
 #cmakedefine SDL_AUDIO_DRIVER_ALSA @SDL_AUDIO_DRIVER_ALSA@
@@ -467,6 +466,12 @@
 #cmakedefine SDL_FILESYSTEM_PS2 @SDL_FILESYSTEM_PS2@
 #cmakedefine SDL_FILESYSTEM_PS2 @SDL_FILESYSTEM_PS2@
 #cmakedefine SDL_FILESYSTEM_N3DS @SDL_FILESYSTEM_N3DS@
 #cmakedefine SDL_FILESYSTEM_N3DS @SDL_FILESYSTEM_N3DS@
 
 
+/* Enable camera subsystem */
+#cmakedefine SDL_CAMERA_DUMMY @SDL_CAMERA_DUMMY@
+#cmakedefine SDL_CAMERA_V4L2 @SDL_CAMERA_V4L2@
+#cmakedefine SDL_CAMERA_APPLE @SDL_CAMERA_APPLE@
+#cmakedefine SDL_CAMERA_ANDROID @SDL_CAMERA_ANDROID@
+
 /* Enable misc subsystem */
 /* Enable misc subsystem */
 #cmakedefine SDL_MISC_DUMMY @SDL_MISC_DUMMY@
 #cmakedefine SDL_MISC_DUMMY @SDL_MISC_DUMMY@
 
 

+ 3 - 0
include/build_config/SDL_build_config_android.h

@@ -190,4 +190,7 @@
 /* Enable the filesystem driver */
 /* Enable the filesystem driver */
 #define SDL_FILESYSTEM_ANDROID   1
 #define SDL_FILESYSTEM_ANDROID   1
 
 
+/* Enable the camera driver */
+#define SDL_CAMERA_ANDROID 1
+
 #endif /* SDL_build_config_android_h_ */
 #endif /* SDL_build_config_android_h_ */

+ 3 - 0
include/build_config/SDL_build_config_emscripten.h

@@ -209,4 +209,7 @@
 /* Enable system filesystem support */
 /* Enable system filesystem support */
 #define SDL_FILESYSTEM_EMSCRIPTEN 1
 #define SDL_FILESYSTEM_EMSCRIPTEN 1
 
 
+/* Enable the camera driver (src/camera/dummy/\*.c) */  /* !!! FIXME */
+#define SDL_CAMERA_DUMMY  1
+
 #endif /* SDL_build_config_emscripten_h */
 #endif /* SDL_build_config_emscripten_h */

+ 3 - 0
include/build_config/SDL_build_config_ios.h

@@ -212,4 +212,7 @@
 /* enable filesystem support */
 /* enable filesystem support */
 #define SDL_FILESYSTEM_COCOA   1
 #define SDL_FILESYSTEM_COCOA   1
 
 
+/* enable camera support */
+#define SDL_CAMERA_APPLE 1
+
 #endif /* SDL_build_config_ios_h_ */
 #endif /* SDL_build_config_ios_h_ */

+ 3 - 0
include/build_config/SDL_build_config_macos.h

@@ -269,6 +269,9 @@
 /* enable filesystem support */
 /* enable filesystem support */
 #define SDL_FILESYSTEM_COCOA   1
 #define SDL_FILESYSTEM_COCOA   1
 
 
+/* enable camera support */
+#define SDL_CAMERA_APPLE 1
+
 /* Enable assembly routines */
 /* Enable assembly routines */
 #ifdef __ppc__
 #ifdef __ppc__
 #define SDL_ALTIVEC_BLITTERS    1
 #define SDL_ALTIVEC_BLITTERS    1

+ 3 - 0
include/build_config/SDL_build_config_minimal.h

@@ -89,4 +89,7 @@ typedef unsigned int uintptr_t;
 /* Enable the dummy filesystem driver (src/filesystem/dummy/\*.c) */
 /* Enable the dummy filesystem driver (src/filesystem/dummy/\*.c) */
 #define SDL_FILESYSTEM_DUMMY  1
 #define SDL_FILESYSTEM_DUMMY  1
 
 
+/* Enable the camera driver (src/camera/dummy/\*.c) */
+#define SDL_CAMERA_DUMMY  1
+
 #endif /* SDL_build_config_minimal_h_ */
 #endif /* SDL_build_config_minimal_h_ */

+ 3 - 0
include/build_config/SDL_build_config_ngage.h

@@ -86,4 +86,7 @@ typedef unsigned long      uintptr_t;
 /* Enable the dummy filesystem driver (src/filesystem/dummy/\*.c) */
 /* Enable the dummy filesystem driver (src/filesystem/dummy/\*.c) */
 #define SDL_FILESYSTEM_DUMMY 1
 #define SDL_FILESYSTEM_DUMMY 1
 
 
+/* Enable the camera driver (src/camera/dummy/\*.c) */
+#define SDL_CAMERA_DUMMY  1
+
 #endif /* SDL_build_config_ngage_h_ */
 #endif /* SDL_build_config_ngage_h_ */

+ 3 - 0
include/build_config/SDL_build_config_windows.h

@@ -311,4 +311,7 @@ typedef unsigned int uintptr_t;
 /* Enable filesystem support */
 /* Enable filesystem support */
 #define SDL_FILESYSTEM_WINDOWS  1
 #define SDL_FILESYSTEM_WINDOWS  1
 
 
+/* Enable the camera driver (src/camera/dummy/\*.c) */  /* !!! FIXME */
+#define SDL_CAMERA_DUMMY  1
+
 #endif /* SDL_build_config_windows_h_ */
 #endif /* SDL_build_config_windows_h_ */

+ 3 - 0
include/build_config/SDL_build_config_wingdk.h

@@ -247,6 +247,9 @@
 /* Enable filesystem support */
 /* Enable filesystem support */
 #define SDL_FILESYSTEM_WINDOWS  1
 #define SDL_FILESYSTEM_WINDOWS  1
 
 
+/* Enable the camera driver (src/camera/dummy/\*.c) */  /* !!! FIXME */
+#define SDL_CAMERA_DUMMY  1
+
 /* Use the (inferior) GDK text input method for GDK platforms */
 /* Use the (inferior) GDK text input method for GDK platforms */
 /*#define SDL_GDK_TEXTINPUT 1*/
 /*#define SDL_GDK_TEXTINPUT 1*/
 
 

+ 3 - 0
include/build_config/SDL_build_config_winrt.h

@@ -215,4 +215,7 @@
 /* Enable system power support */
 /* Enable system power support */
 #define SDL_POWER_WINRT 1
 #define SDL_POWER_WINRT 1
 
 
+/* Enable the camera driver (src/camera/dummy/\*.c) */  /* !!! FIXME */
+#define SDL_CAMERA_DUMMY  1
+
 #endif /* SDL_build_config_winrt_h_ */
 #endif /* SDL_build_config_winrt_h_ */

+ 3 - 0
include/build_config/SDL_build_config_xbox.h

@@ -236,4 +236,7 @@
 /* Use the (inferior) GDK text input method for GDK platforms */
 /* Use the (inferior) GDK text input method for GDK platforms */
 #define SDL_GDK_TEXTINPUT 1
 #define SDL_GDK_TEXTINPUT 1
 
 
+/* Enable the camera driver (src/camera/dummy/\*.c) */
+#define SDL_CAMERA_DUMMY  1
+
 #endif /* SDL_build_config_wingdk_h_ */
 #endif /* SDL_build_config_wingdk_h_ */

+ 92 - 291
src/camera/SDL_camera.c

@@ -27,20 +27,18 @@
 #include "../video/SDL_pixels_c.h"
 #include "../video/SDL_pixels_c.h"
 #include "../thread/SDL_systhread.h"
 #include "../thread/SDL_systhread.h"
 
 
-#define DEBUG_VIDEO_CAPTURE_CAPTURE 0
+#define DEBUG_CAMERA 1
 
 
-
-#ifdef SDL_VIDEO_CAPTURE
 /* list node entries to share frames between SDL and user app */
 /* list node entries to share frames between SDL and user app */
 typedef struct entry_t
 typedef struct entry_t
 {
 {
-    SDL_VideoCaptureFrame frame;
+    SDL_CameraFrame frame;
 } entry_t;
 } entry_t;
 
 
-static SDL_VideoCaptureDevice *open_devices[16];
+static SDL_CameraDevice *open_devices[16];
 
 
 static void
 static void
-close_device(SDL_VideoCaptureDevice *device)
+close_device(SDL_CameraDevice *device)
 {
 {
     if (!device) {
     if (!device) {
         return;
         return;
@@ -73,7 +71,7 @@ close_device(SDL_VideoCaptureDevice *device)
         while (device->buffer_queue != NULL) {
         while (device->buffer_queue != NULL) {
             SDL_ListPop(&device->buffer_queue, (void**)&entry);
             SDL_ListPop(&device->buffer_queue, (void**)&entry);
             if (entry) {
             if (entry) {
-                SDL_VideoCaptureFrame f = entry->frame;
+                SDL_CameraFrame f = entry->frame;
                 /* Release frames not acquired, if any */
                 /* Release frames not acquired, if any */
                 if (f.timestampNS) {
                 if (f.timestampNS) {
                     ReleaseFrame(device, &f);
                     ReleaseFrame(device, &f);
@@ -109,7 +107,7 @@ SDL_bool check_device_playing(void)
     int i, n = SDL_arraysize(open_devices);
     int i, n = SDL_arraysize(open_devices);
     for (i = 0; i < n; i++) {
     for (i = 0; i < n; i++) {
         if (open_devices[i]) {
         if (open_devices[i]) {
-            if (SDL_GetVideoCaptureStatus(open_devices[i]) == SDL_VIDEO_CAPTURE_PLAYING) {
+            if (SDL_GetCameraStatus(open_devices[i]) == SDL_CAMERA_PLAYING) {
                 return SDL_TRUE;
                 return SDL_TRUE;
             }
             }
         }
         }
@@ -117,26 +115,20 @@ SDL_bool check_device_playing(void)
     return SDL_FALSE;
     return SDL_FALSE;
 }
 }
 
 
-
-#endif /* SDL_VIDEO_CAPTURE */
-
 void
 void
-SDL_CloseVideoCapture(SDL_VideoCaptureDevice *device)
+SDL_CloseCamera(SDL_CameraDevice *device)
 {
 {
-#ifdef SDL_VIDEO_CAPTURE
     if (!device) {
     if (!device) {
         SDL_InvalidParamError("device");
         SDL_InvalidParamError("device");
         return;
         return;
     }
     }
     close_device(device);
     close_device(device);
-#endif
 }
 }
 
 
 int
 int
-SDL_StartVideoCapture(SDL_VideoCaptureDevice *device)
+SDL_StartCamera(SDL_CameraDevice *device)
 {
 {
-#ifdef SDL_VIDEO_CAPTURE
-    SDL_VideoCaptureStatus status;
+    SDL_CameraStatus status;
     int result;
     int result;
     if (!device) {
     if (!device) {
         return SDL_InvalidParamError("device");
         return SDL_InvalidParamError("device");
@@ -146,12 +138,12 @@ SDL_StartVideoCapture(SDL_VideoCaptureDevice *device)
         return SDL_SetError("no spec set");
         return SDL_SetError("no spec set");
     }
     }
 
 
-    status = SDL_GetVideoCaptureStatus(device);
-    if (status != SDL_VIDEO_CAPTURE_INIT) {
+    status = SDL_GetCameraStatus(device);
+    if (status != SDL_CAMERA_INIT) {
         return SDL_SetError("invalid state");
         return SDL_SetError("invalid state");
     }
     }
 
 
-    result = StartCapture(device);
+    result = StartCamera(device);
     if (result < 0) {
     if (result < 0) {
         return result;
         return result;
     }
     }
@@ -159,15 +151,11 @@ SDL_StartVideoCapture(SDL_VideoCaptureDevice *device)
     SDL_AtomicSet(&device->enabled, 1);
     SDL_AtomicSet(&device->enabled, 1);
 
 
     return 0;
     return 0;
-#else
-    return SDL_Unsupported();
-#endif
 }
 }
 
 
 int
 int
-SDL_GetVideoCaptureSpec(SDL_VideoCaptureDevice *device, SDL_VideoCaptureSpec *spec)
+SDL_GetCameraSpec(SDL_CameraDevice *device, SDL_CameraSpec *spec)
 {
 {
-#ifdef SDL_VIDEO_CAPTURE
     if (!device) {
     if (!device) {
         return SDL_InvalidParamError("device");
         return SDL_InvalidParamError("device");
     }
     }
@@ -179,24 +167,20 @@ SDL_GetVideoCaptureSpec(SDL_VideoCaptureDevice *device, SDL_VideoCaptureSpec *sp
     SDL_zerop(spec);
     SDL_zerop(spec);
 
 
     return GetDeviceSpec(device, spec);
     return GetDeviceSpec(device, spec);
-#else
-    return SDL_Unsupported();
-#endif
 }
 }
 
 
 int
 int
-SDL_StopVideoCapture(SDL_VideoCaptureDevice *device)
+SDL_StopCamera(SDL_CameraDevice *device)
 {
 {
-#ifdef SDL_VIDEO_CAPTURE
-    SDL_VideoCaptureStatus status;
+    SDL_CameraStatus status;
     int ret;
     int ret;
     if (!device) {
     if (!device) {
         return SDL_InvalidParamError("device");
         return SDL_InvalidParamError("device");
     }
     }
 
 
-    status = SDL_GetVideoCaptureStatus(device);
+    status = SDL_GetCameraStatus(device);
 
 
-    if (status != SDL_VIDEO_CAPTURE_PLAYING) {
+    if (status != SDL_CAMERA_PLAYING) {
         return SDL_SetError("invalid state");
         return SDL_SetError("invalid state");
     }
     }
 
 
@@ -204,7 +188,7 @@ SDL_StopVideoCapture(SDL_VideoCaptureDevice *device)
     SDL_AtomicSet(&device->shutdown, 1);
     SDL_AtomicSet(&device->shutdown, 1);
 
 
     SDL_LockMutex(device->acquiring_lock);
     SDL_LockMutex(device->acquiring_lock);
-    ret = StopCapture(device);
+    ret = StopCamera(device);
     SDL_UnlockMutex(device->acquiring_lock);
     SDL_UnlockMutex(device->acquiring_lock);
 
 
     if (ret < 0) {
     if (ret < 0) {
@@ -212,25 +196,20 @@ SDL_StopVideoCapture(SDL_VideoCaptureDevice *device)
     }
     }
 
 
     return 0;
     return 0;
-#else
-    return SDL_Unsupported();
-#endif
 }
 }
 
 
-#ifdef SDL_VIDEO_CAPTURE
-
 /* Check spec has valid format and frame size */
 /* Check spec has valid format and frame size */
 static int
 static int
-prepare_video_capturespec(SDL_VideoCaptureDevice *device, const SDL_VideoCaptureSpec *desired, SDL_VideoCaptureSpec *obtained, int allowed_changes)
+prepare_cameraspec(SDL_CameraDevice *device, const SDL_CameraSpec *desired, SDL_CameraSpec *obtained, int allowed_changes)
 {
 {
     /* Check format */
     /* Check format */
     {
     {
-        int i, num = SDL_GetNumVideoCaptureFormats(device);
+        int i, num = SDL_GetNumCameraFormats(device);
         int is_format_valid = 0;
         int is_format_valid = 0;
 
 
         for (i = 0; i < num; i++) {
         for (i = 0; i < num; i++) {
             Uint32 format;
             Uint32 format;
-            if (SDL_GetVideoCaptureFormat(device, i, &format) == 0) {
+            if (SDL_GetCameraFormat(device, i, &format) == 0) {
                 if (format == desired->format && format != SDL_PIXELFORMAT_UNKNOWN) {
                 if (format == desired->format && format != SDL_PIXELFORMAT_UNKNOWN) {
                     is_format_valid = 1;
                     is_format_valid = 1;
                     obtained->format = format;
                     obtained->format = format;
@@ -243,7 +222,7 @@ prepare_video_capturespec(SDL_VideoCaptureDevice *device, const SDL_VideoCapture
             if (allowed_changes) {
             if (allowed_changes) {
                 for (i = 0; i < num; i++) {
                 for (i = 0; i < num; i++) {
                     Uint32 format;
                     Uint32 format;
-                    if (SDL_GetVideoCaptureFormat(device, i, &format) == 0) {
+                    if (SDL_GetCameraFormat(device, i, &format) == 0) {
                         if (format != SDL_PIXELFORMAT_UNKNOWN) {
                         if (format != SDL_PIXELFORMAT_UNKNOWN) {
                             obtained->format = format;
                             obtained->format = format;
                             is_format_valid = 1;
                             is_format_valid = 1;
@@ -266,12 +245,12 @@ prepare_video_capturespec(SDL_VideoCaptureDevice *device, const SDL_VideoCapture
 
 
     /* Check frame size */
     /* Check frame size */
     {
     {
-        int i, num = SDL_GetNumVideoCaptureFrameSizes(device, obtained->format);
+        int i, num = SDL_GetNumCameraFrameSizes(device, obtained->format);
         int is_framesize_valid = 0;
         int is_framesize_valid = 0;
 
 
         for (i = 0; i < num; i++) {
         for (i = 0; i < num; i++) {
             int w, h;
             int w, h;
-            if (SDL_GetVideoCaptureFrameSize(device, obtained->format, i, &w, &h) == 0) {
+            if (SDL_GetCameraFrameSize(device, obtained->format, i, &w, &h) == 0) {
                 if (desired->width == w && desired->height == h) {
                 if (desired->width == w && desired->height == h) {
                     is_framesize_valid = 1;
                     is_framesize_valid = 1;
                     obtained->width = w;
                     obtained->width = w;
@@ -284,7 +263,7 @@ prepare_video_capturespec(SDL_VideoCaptureDevice *device, const SDL_VideoCapture
         if (!is_framesize_valid) {
         if (!is_framesize_valid) {
             if (allowed_changes) {
             if (allowed_changes) {
                 int w, h;
                 int w, h;
-                if (SDL_GetVideoCaptureFrameSize(device, obtained->format, 0, &w, &h) == 0) {
+                if (SDL_GetCameraFrameSize(device, obtained->format, 0, &w, &h) == 0) {
                     is_framesize_valid = 1;
                     is_framesize_valid = 1;
                     obtained->width = w;
                     obtained->width = w;
                     obtained->height = h;
                     obtained->height = h;
@@ -305,12 +284,9 @@ prepare_video_capturespec(SDL_VideoCaptureDevice *device, const SDL_VideoCapture
     return 0;
     return 0;
 }
 }
 
 
-#endif /* SDL_VIDEO_CAPTURE */
-
 const char *
 const char *
-SDL_GetVideoCaptureDeviceName(SDL_VideoCaptureDeviceID instance_id)
+SDL_GetCameraDeviceName(SDL_CameraDeviceID instance_id)
 {
 {
-#ifdef SDL_VIDEO_CAPTURE
     static char buf[256];
     static char buf[256];
     buf[0] = 0;
     buf[0] = 0;
     buf[255] = 0;
     buf[255] = 0;
@@ -320,26 +296,19 @@ SDL_GetVideoCaptureDeviceName(SDL_VideoCaptureDeviceID instance_id)
         return NULL;
         return NULL;
     }
     }
 
 
-    if (GetDeviceName(instance_id, buf, sizeof (buf)) < 0) {
+    if (GetCameraDeviceName(instance_id, buf, sizeof (buf)) < 0) {
         buf[0] = 0;
         buf[0] = 0;
     }
     }
     return buf;
     return buf;
-#else
-    SDL_Unsupported();
-    return NULL;
-#endif
 }
 }
 
 
 
 
-SDL_VideoCaptureDeviceID *
-SDL_GetVideoCaptureDevices(int *count)
+SDL_CameraDeviceID *
+SDL_GetCameraDevices(int *count)
 {
 {
 
 
     int num = 0;
     int num = 0;
-    SDL_VideoCaptureDeviceID *ret = NULL;
-#ifdef SDL_VIDEO_CAPTURE
-    ret = GetVideoCaptureDevices(&num);
-#endif
+    SDL_CameraDeviceID *ret = GetCameraDevices(&num);
 
 
     if (ret) {
     if (ret) {
         if (count) {
         if (count) {
@@ -350,7 +319,7 @@ SDL_GetVideoCaptureDevices(int *count)
 
 
     /* return list of 0 ID, null terminated */
     /* return list of 0 ID, null terminated */
     num = 0;
     num = 0;
-    ret = (SDL_VideoCaptureDeviceID *)SDL_malloc((num + 1) * sizeof(*ret));
+    ret = (SDL_CameraDeviceID *)SDL_malloc((num + 1) * sizeof(*ret));
 
 
     if (ret == NULL) {
     if (ret == NULL) {
         SDL_OutOfMemory();
         SDL_OutOfMemory();
@@ -368,17 +337,15 @@ SDL_GetVideoCaptureDevices(int *count)
     return ret;
     return ret;
 }
 }
 
 
-#ifdef SDL_VIDEO_CAPTURE
-
-/* Video capture thread function */
+/* Camera thread function */
 static int SDLCALL
 static int SDLCALL
-SDL_CaptureVideoThread(void *devicep)
+SDL_CameraThread(void *devicep)
 {
 {
     const int delay = 20;
     const int delay = 20;
-    SDL_VideoCaptureDevice *device = (SDL_VideoCaptureDevice *) devicep;
+    SDL_CameraDevice *device = (SDL_CameraDevice *) devicep;
 
 
-#if DEBUG_VIDEO_CAPTURE_CAPTURE
-    SDL_Log("Start thread 'SDL_CaptureVideo'");
+#if DEBUG_CAMERA
+    SDL_Log("Start thread 'SDL_CameraThread'");
 #endif
 #endif
 
 
 
 
@@ -387,11 +354,11 @@ SDL_CaptureVideoThread(void *devicep)
     /*
     /*
     {
     {
         // Set thread priority to THREAD_PRIORITY_VIDEO
         // Set thread priority to THREAD_PRIORITY_VIDEO
-        extern void Android_JNI_VideoCaptureSetThreadPriority(int, int);
-        Android_JNI_VideoCaptureSetThreadPriority(device->iscapture, device);
+        extern void Android_JNI_CameraSetThreadPriority(int, int);
+        Android_JNI_CameraSetThreadPriority(device->iscapture, device);
     }*/
     }*/
 #else
 #else
-    /* The video_capture mixing is always a high priority thread */
+    /* The camera capture is always a high priority thread */
     SDL_SetThreadPriority(SDL_THREAD_PRIORITY_HIGH);
     SDL_SetThreadPriority(SDL_THREAD_PRIORITY_HIGH);
 #endif
 #endif
 
 
@@ -403,9 +370,9 @@ SDL_CaptureVideoThread(void *devicep)
         SDL_Delay(delay);
         SDL_Delay(delay);
     }
     }
 
 
-    /* Loop, filling the video_capture buffers */
+    /* Loop, filling the camera buffers */
     while (!SDL_AtomicGet(&device->shutdown)) {
     while (!SDL_AtomicGet(&device->shutdown)) {
-        SDL_VideoCaptureFrame f;
+        SDL_CameraFrame f;
         int ret;
         int ret;
         entry_t *entry;
         entry_t *entry;
 
 
@@ -423,7 +390,7 @@ SDL_CaptureVideoThread(void *devicep)
 
 
         if (ret < 0) {
         if (ret < 0) {
             /* Flag it as an error */
             /* Flag it as an error */
-#if DEBUG_VIDEO_CAPTURE_CAPTURE
+#if DEBUG_CAMERA
             SDL_Log("dev[%p] error AcquireFrame: %d %s", (void *)device, ret, SDL_GetError());
             SDL_Log("dev[%p] error AcquireFrame: %d %s", (void *)device, ret, SDL_GetError());
 #endif
 #endif
             f.num_planes = 0;
             f.num_planes = 0;
@@ -447,28 +414,26 @@ SDL_CaptureVideoThread(void *devicep)
         }
         }
     }
     }
 
 
-#if DEBUG_VIDEO_CAPTURE_CAPTURE
-    SDL_Log("dev[%p] End thread 'SDL_CaptureVideo'", (void *)device);
+#if DEBUG_CAMERA
+    SDL_Log("dev[%p] End thread 'SDL_CameraThread'", (void *)device);
 #endif
 #endif
     return 0;
     return 0;
 
 
 error_mem:
 error_mem:
-#if DEBUG_VIDEO_CAPTURE_CAPTURE
-    SDL_Log("dev[%p] End thread 'SDL_CaptureVideo' with error: %s", (void *)device, SDL_GetError());
+#if DEBUG_CAMERA
+    SDL_Log("dev[%p] End thread 'SDL_CameraThread' with error: %s", (void *)device, SDL_GetError());
 #endif
 #endif
     SDL_AtomicSet(&device->shutdown, 1);
     SDL_AtomicSet(&device->shutdown, 1);
     SDL_OutOfMemory();
     SDL_OutOfMemory();
     return 0;
     return 0;
 }
 }
-#endif
 
 
-SDL_VideoCaptureDevice *
-SDL_OpenVideoCapture(SDL_VideoCaptureDeviceID instance_id)
+SDL_CameraDevice *
+SDL_OpenCamera(SDL_CameraDeviceID instance_id)
 {
 {
-#ifdef SDL_VIDEO_CAPTURE
     int i, n = SDL_arraysize(open_devices);
     int i, n = SDL_arraysize(open_devices);
     int id = -1;
     int id = -1;
-    SDL_VideoCaptureDevice *device = NULL;
+    SDL_CameraDevice *device = NULL;
     const char *device_name = NULL;
     const char *device_name = NULL;
 
 
     if (!SDL_WasInit(SDL_INIT_VIDEO)) {
     if (!SDL_WasInit(SDL_INIT_VIDEO)) {
@@ -486,19 +451,19 @@ SDL_OpenVideoCapture(SDL_VideoCaptureDeviceID instance_id)
     }
     }
 
 
     if (id == -1) {
     if (id == -1) {
-        SDL_SetError("Too many open video capture devices");
+        SDL_SetError("Too many open camera devices");
         goto error;
         goto error;
     }
     }
 
 
     if (instance_id != 0) {
     if (instance_id != 0) {
-        device_name = SDL_GetVideoCaptureDeviceName(instance_id);
+        device_name = SDL_GetCameraDeviceName(instance_id);
         if (device_name == NULL) {
         if (device_name == NULL) {
             goto error;
             goto error;
         }
         }
     } else {
     } else {
-        SDL_VideoCaptureDeviceID *devices = SDL_GetVideoCaptureDevices(NULL);
+        SDL_CameraDeviceID *devices = SDL_GetCameraDevices(NULL);
         if (devices && devices[0]) {
         if (devices && devices[0]) {
-            device_name = SDL_GetVideoCaptureDeviceName(devices[0]);
+            device_name = SDL_GetCameraDeviceName(devices[0]);
             SDL_free(devices);
             SDL_free(devices);
         }
         }
     }
     }
@@ -507,7 +472,7 @@ SDL_OpenVideoCapture(SDL_VideoCaptureDeviceID instance_id)
     // FIXME do we need this ?
     // FIXME do we need this ?
     /* Let the user override. */
     /* Let the user override. */
     {
     {
-        const char *dev = SDL_getenv("SDL_VIDEO_CAPTURE_DEVICE_NAME");
+        const char *dev = SDL_getenv("SDL_CAMERA_DEVICE_NAME");
         if (dev && dev[0]) {
         if (dev && dev[0]) {
             device_name = dev;
             device_name = dev;
         }
         }
@@ -518,7 +483,7 @@ SDL_OpenVideoCapture(SDL_VideoCaptureDeviceID instance_id)
         goto error;
         goto error;
     }
     }
 
 
-    device = (SDL_VideoCaptureDevice *) SDL_calloc(1, sizeof (SDL_VideoCaptureDevice));
+    device = (SDL_CameraDevice *) SDL_calloc(1, sizeof (SDL_CameraDevice));
     if (device == NULL) {
     if (device == NULL) {
         SDL_OutOfMemory();
         SDL_OutOfMemory();
         goto error;
         goto error;
@@ -550,16 +515,16 @@ SDL_OpenVideoCapture(SDL_VideoCaptureDeviceID instance_id)
     open_devices[id] = device;  /* add it to our list of open devices. */
     open_devices[id] = device;  /* add it to our list of open devices. */
 
 
 
 
-    /* Start the video_capture thread */
+    /* Start the camera thread */
     {
     {
         const size_t stacksize = 64 * 1024;
         const size_t stacksize = 64 * 1024;
         char threadname[64];
         char threadname[64];
 
 
-        SDL_snprintf(threadname, sizeof (threadname), "SDLVideoC%d", id);
-        device->thread = SDL_CreateThreadInternal(SDL_CaptureVideoThread, threadname, stacksize, device);
+        SDL_snprintf(threadname, sizeof (threadname), "SDLCamera%d", id);
+        device->thread = SDL_CreateThreadInternal(SDL_CameraThread, threadname, stacksize, device);
 
 
         if (device->thread == NULL) {
         if (device->thread == NULL) {
-            SDL_SetError("Couldn't create video_capture thread");
+            SDL_SetError("Couldn't create camera thread");
             goto error;
             goto error;
         }
         }
     }
     }
@@ -569,21 +534,16 @@ SDL_OpenVideoCapture(SDL_VideoCaptureDeviceID instance_id)
 error:
 error:
     close_device(device);
     close_device(device);
     return NULL;
     return NULL;
-#else
-    SDL_Unsupported();
-    return NULL;
-#endif /* SDL_VIDEO_CAPTURE */
 }
 }
 
 
 int
 int
-SDL_SetVideoCaptureSpec(SDL_VideoCaptureDevice *device,
-        const SDL_VideoCaptureSpec *desired,
-        SDL_VideoCaptureSpec *obtained,
+SDL_SetCameraSpec(SDL_CameraDevice *device,
+        const SDL_CameraSpec *desired,
+        SDL_CameraSpec *obtained,
         int allowed_changes)
         int allowed_changes)
 {
 {
-#ifdef SDL_VIDEO_CAPTURE
-    SDL_VideoCaptureSpec _obtained;
-    SDL_VideoCaptureSpec _desired;
+    SDL_CameraSpec _obtained;
+    SDL_CameraSpec _desired;
     int result;
     int result;
 
 
     if (!device) {
     if (!device) {
@@ -597,7 +557,7 @@ SDL_SetVideoCaptureSpec(SDL_VideoCaptureDevice *device,
     if (!desired) {
     if (!desired) {
         SDL_zero(_desired);
         SDL_zero(_desired);
         desired = &_desired;
         desired = &_desired;
-        allowed_changes = SDL_VIDEO_CAPTURE_ALLOW_ANY_CHANGE;
+        allowed_changes = SDL_CAMERA_ALLOW_ANY_CHANGE;
     } else {
     } else {
         /* in case desired == obtained */
         /* in case desired == obtained */
         _desired = *desired;
         _desired = *desired;
@@ -610,7 +570,7 @@ SDL_SetVideoCaptureSpec(SDL_VideoCaptureDevice *device,
 
 
     SDL_zerop(obtained);
     SDL_zerop(obtained);
 
 
-    if (prepare_video_capturespec(device, desired, obtained, allowed_changes) < 0) {
+    if (prepare_cameraspec(device, desired, obtained, allowed_changes) < 0) {
         return -1;
         return -1;
     }
     }
 
 
@@ -626,16 +586,11 @@ SDL_SetVideoCaptureSpec(SDL_VideoCaptureDevice *device,
     device->is_spec_set = SDL_TRUE;
     device->is_spec_set = SDL_TRUE;
 
 
     return 0;
     return 0;
-#else
-    SDL_zero(*obtained);
-    return SDL_Unsupported();
-#endif /* SDL_VIDEO_CAPTURE */
 }
 }
 
 
 int
 int
-SDL_AcquireVideoCaptureFrame(SDL_VideoCaptureDevice *device, SDL_VideoCaptureFrame *frame)
+SDL_AcquireCameraFrame(SDL_CameraDevice *device, SDL_CameraFrame *frame)
 {
 {
-#ifdef SDL_VIDEO_CAPTURE
     if (!device) {
     if (!device) {
         return SDL_InvalidParamError("device");
         return SDL_InvalidParamError("device");
     }
     }
@@ -679,15 +634,11 @@ SDL_AcquireVideoCaptureFrame(SDL_VideoCaptureDevice *device, SDL_VideoCaptureFra
     }
     }
 
 
     return 0;
     return 0;
-#else
-    return SDL_Unsupported();
-#endif /* SDL_VIDEO_CAPTURE */
 }
 }
 
 
 int
 int
-SDL_ReleaseVideoCaptureFrame(SDL_VideoCaptureDevice *device, SDL_VideoCaptureFrame *frame)
+SDL_ReleaseCameraFrame(SDL_CameraDevice *device, SDL_CameraFrame *frame)
 {
 {
-#ifdef SDL_VIDEO_CAPTURE
     if (!device) {
     if (!device) {
         return SDL_InvalidParamError("device");
         return SDL_InvalidParamError("device");
     }
     }
@@ -703,28 +654,20 @@ SDL_ReleaseVideoCaptureFrame(SDL_VideoCaptureDevice *device, SDL_VideoCaptureFra
     SDL_zerop(frame);
     SDL_zerop(frame);
 
 
     return 0;
     return 0;
-#else
-    return SDL_Unsupported();
-#endif /* SDL_VIDEO_CAPTURE */
 }
 }
 
 
 int
 int
-SDL_GetNumVideoCaptureFormats(SDL_VideoCaptureDevice *device)
+SDL_GetNumCameraFormats(SDL_CameraDevice *device)
 {
 {
-#ifdef SDL_VIDEO_CAPTURE
     if (!device) {
     if (!device) {
         return SDL_InvalidParamError("device");
         return SDL_InvalidParamError("device");
     }
     }
     return GetNumFormats(device);
     return GetNumFormats(device);
-#else
-    return 0;
-#endif /* SDL_VIDEO_CAPTURE */
 }
 }
 
 
 int
 int
-SDL_GetVideoCaptureFormat(SDL_VideoCaptureDevice *device, int index, Uint32 *format)
+SDL_GetCameraFormat(SDL_CameraDevice *device, int index, Uint32 *format)
 {
 {
-#ifdef SDL_VIDEO_CAPTURE
     if (!device) {
     if (!device) {
         return SDL_InvalidParamError("device");
         return SDL_InvalidParamError("device");
     }
     }
@@ -733,28 +676,20 @@ SDL_GetVideoCaptureFormat(SDL_VideoCaptureDevice *device, int index, Uint32 *for
     }
     }
     *format = 0;
     *format = 0;
     return GetFormat(device, index, format);
     return GetFormat(device, index, format);
-#else
-    return SDL_Unsupported();
-#endif /* SDL_VIDEO_CAPTURE */
 }
 }
 
 
 int
 int
-SDL_GetNumVideoCaptureFrameSizes(SDL_VideoCaptureDevice *device, Uint32 format)
+SDL_GetNumCameraFrameSizes(SDL_CameraDevice *device, Uint32 format)
 {
 {
-#ifdef SDL_VIDEO_CAPTURE
     if (!device) {
     if (!device) {
         return SDL_InvalidParamError("device");
         return SDL_InvalidParamError("device");
     }
     }
     return GetNumFrameSizes(device, format);
     return GetNumFrameSizes(device, format);
-#else
-    return 0;
-#endif /* SDL_VIDEO_CAPTURE */
 }
 }
 
 
 int
 int
-SDL_GetVideoCaptureFrameSize(SDL_VideoCaptureDevice *device, Uint32 format, int index, int *width, int *height)
+SDL_GetCameraFrameSize(SDL_CameraDevice *device, Uint32 format, int index, int *width, int *height)
 {
 {
-#ifdef SDL_VIDEO_CAPTURE
     if (!device) {
     if (!device) {
         return SDL_InvalidParamError("device");
         return SDL_InvalidParamError("device");
     }
     }
@@ -767,79 +702,61 @@ SDL_GetVideoCaptureFrameSize(SDL_VideoCaptureDevice *device, Uint32 format, int
     *width = 0;
     *width = 0;
     *height = 0;
     *height = 0;
     return GetFrameSize(device, format, index, width, height);
     return GetFrameSize(device, format, index, width, height);
-#else
-    return SDL_Unsupported();
-#endif
 }
 }
 
 
-SDL_VideoCaptureDevice *
-SDL_OpenVideoCaptureWithSpec(
-        SDL_VideoCaptureDeviceID instance_id,
-        const SDL_VideoCaptureSpec *desired,
-        SDL_VideoCaptureSpec *obtained,
+SDL_CameraDevice *
+SDL_OpenCameraWithSpec(
+        SDL_CameraDeviceID instance_id,
+        const SDL_CameraSpec *desired,
+        SDL_CameraSpec *obtained,
         int allowed_changes)
         int allowed_changes)
 {
 {
-#ifdef SDL_VIDEO_CAPTURE
-    SDL_VideoCaptureDevice *device;
+    SDL_CameraDevice *device;
 
 
-    if ((device = SDL_OpenVideoCapture(instance_id)) == NULL) {
+    if ((device = SDL_OpenCamera(instance_id)) == NULL) {
         return NULL;
         return NULL;
     }
     }
 
 
-    if (SDL_SetVideoCaptureSpec(device, desired, obtained, allowed_changes) < 0) {
-        SDL_CloseVideoCapture(device);
+    if (SDL_SetCameraSpec(device, desired, obtained, allowed_changes) < 0) {
+        SDL_CloseCamera(device);
         return NULL;
         return NULL;
     }
     }
     return device;
     return device;
-#else
-    SDL_Unsupported();
-    return NULL;
-#endif
 }
 }
 
 
-SDL_VideoCaptureStatus
-SDL_GetVideoCaptureStatus(SDL_VideoCaptureDevice *device)
+SDL_CameraStatus
+SDL_GetCameraStatus(SDL_CameraDevice *device)
 {
 {
-#ifdef SDL_VIDEO_CAPTURE
     if (device == NULL) {
     if (device == NULL) {
-        return SDL_VIDEO_CAPTURE_INIT;
+        return SDL_CAMERA_INIT;
     }
     }
 
 
     if (device->is_spec_set == SDL_FALSE) {
     if (device->is_spec_set == SDL_FALSE) {
-        return SDL_VIDEO_CAPTURE_INIT;
+        return SDL_CAMERA_INIT;
     }
     }
 
 
     if (SDL_AtomicGet(&device->shutdown)) {
     if (SDL_AtomicGet(&device->shutdown)) {
-        return SDL_VIDEO_CAPTURE_STOPPED;
+        return SDL_CAMERA_STOPPED;
     }
     }
 
 
     if (SDL_AtomicGet(&device->enabled)) {
     if (SDL_AtomicGet(&device->enabled)) {
-        return SDL_VIDEO_CAPTURE_PLAYING;
+        return SDL_CAMERA_PLAYING;
     }
     }
-    return SDL_VIDEO_CAPTURE_INIT;
-#else
-    SDL_Unsupported();
-    return SDL_VIDEO_CAPTURE_FAIL;
-#endif
+    return SDL_CAMERA_INIT;
 }
 }
 
 
 int
 int
-SDL_VideoCaptureInit(void)
+SDL_CameraInit(void)
 {
 {
-#ifdef SDL_VIDEO_CAPTURE
     SDL_zeroa(open_devices);
     SDL_zeroa(open_devices);
 
 
-    SDL_SYS_VideoCaptureInit();
-    return 0;
-#else
+    SDL_SYS_CameraInit();
     return 0;
     return 0;
-#endif
 }
 }
 
 
 void
 void
-SDL_QuitVideoCapture(void)
+SDL_QuitCamera(void)
 {
 {
-#ifdef SDL_VIDEO_CAPTURE
     int i, n = SDL_arraysize(open_devices);
     int i, n = SDL_arraysize(open_devices);
     for (i = 0; i < n; i++) {
     for (i = 0; i < n; i++) {
         close_device(open_devices[i]);
         close_device(open_devices[i]);
@@ -847,122 +764,6 @@ SDL_QuitVideoCapture(void)
 
 
     SDL_zeroa(open_devices);
     SDL_zeroa(open_devices);
 
 
-    SDL_SYS_VideoCaptureQuit();
-#endif
-}
-
-#ifdef SDL_VIDEO_CAPTURE
-
-#if defined(SDL_PLATFORM_LINUX) && !defined(SDL_PLATFORM_ANDROID)
-
-/* See SDL_video_capture_v4l2.c */
-
-#elif defined(SDL_PLATFORM_ANDROID) && __ANDROID_API__ >= 24
-
-/* See SDL_android_video_capture.c */
-
-#elif defined(SDL_PLATFORM_IOS) || defined(SDL_PLATFORM_MACOS)
-
-/* See SDL_video_capture_apple.m */
-#else
-
-int SDL_SYS_VideoCaptureInit(void)
-{
-    return 0;
+    SDL_SYS_CameraQuit();
 }
 }
 
 
-int SDL_SYS_VideoCaptureQuit(void)
-{
-    return 0;
-}
-
-int
-OpenDevice(SDL_VideoCaptureDevice *_this)
-{
-    return SDL_SetError("not implemented");
-}
-
-void
-CloseDevice(SDL_VideoCaptureDevice *_this)
-{
-    return;
-}
-
-int
-InitDevice(SDL_VideoCaptureDevice *_this)
-{
-    size_t size, pitch;
-    SDL_CalculateSize(_this->spec.format, _this->spec.width, _this->spec.height, &size, &pitch, SDL_FALSE);
-    SDL_Log("Buffer size: %d x %d", _this->spec.width, _this->spec.height);
-    return -1;
-}
-
-int
-GetDeviceSpec(SDL_VideoCaptureDevice *_this, SDL_VideoCaptureSpec *spec)
-{
-    return SDL_Unsupported();
-}
-
-int
-StartCapture(SDL_VideoCaptureDevice *_this)
-{
-    return SDL_Unsupported();
-}
-
-int
-StopCapture(SDL_VideoCaptureDevice *_this)
-{
-    return -1;
-}
-
-int
-AcquireFrame(SDL_VideoCaptureDevice *_this, SDL_VideoCaptureFrame *frame)
-{
-    return -1;
-}
-
-int
-ReleaseFrame(SDL_VideoCaptureDevice *_this, SDL_VideoCaptureFrame *frame)
-{
-    return -1;
-}
-
-int
-GetNumFormats(SDL_VideoCaptureDevice *_this)
-{
-    return -1;
-}
-
-int
-GetFormat(SDL_VideoCaptureDevice *_this, int index, Uint32 *format)
-{
-    return -1;
-}
-
-int
-GetNumFrameSizes(SDL_VideoCaptureDevice *_this, Uint32 format)
-{
-    return -1;
-}
-
-int
-GetFrameSize(SDL_VideoCaptureDevice *_this, Uint32 format, int index, int *width, int *height)
-{
-    return -1;
-}
-
-int
-GetDeviceName(SDL_VideoCaptureDeviceID instance_id, char *buf, int size)
-{
-    return -1;
-}
-
-SDL_VideoCaptureDeviceID *
-GetVideoCaptureDevices(int *count)
-{
-    return NULL;
-}
-
-#endif
-
-#endif /* SDL_VIDEO_CAPTURE */

+ 7 - 8
src/camera/SDL_camera_c.h

@@ -19,15 +19,14 @@
   3. This notice may not be removed or altered from any source distribution.
   3. This notice may not be removed or altered from any source distribution.
 */
 */
 #include "../SDL_internal.h"
 #include "../SDL_internal.h"
-#include "../../include/SDL3/SDL_camera.h"
 
 
-#ifndef SDL_video_capture_c_h_
-#define SDL_video_capture_c_h_
+#ifndef SDL_camera_c_h_
+#define SDL_camera_c_h_
 
 
-/* Initialize the video_capture subsystem */
-int SDL_VideoCaptureInit(void);
+/* Initialize the camera subsystem */
+int SDL_CameraInit(void);
 
 
-/* Shutdown the video_capture subsystem */
-void SDL_QuitVideoCapture(void);
+/* Shutdown the camera subsystem */
+void SDL_QuitCamera(void);
 
 
-#endif /* SDL_video_capture_c_h_ */
+#endif /* SDL_camera_c_h_ */

+ 27 - 27
src/camera/SDL_syscamera.h

@@ -20,22 +20,22 @@
 */
 */
 #include "../SDL_internal.h"
 #include "../SDL_internal.h"
 
 
-#ifndef SDL_sysvideocapture_h_
-#define SDL_sysvideocapture_h_
+#ifndef SDL_syscamera_h_
+#define SDL_syscamera_h_
 
 
 #include "../SDL_list.h"
 #include "../SDL_list.h"
 
 
-/* The SDL video_capture driver */
-typedef struct SDL_VideoCaptureDevice SDL_VideoCaptureDevice;
+/* The SDL camera driver */
+typedef struct SDL_CameraDevice SDL_CameraDevice;
 
 
-/* Define the SDL video_capture driver structure */
-struct SDL_VideoCaptureDevice
+/* Define the SDL camera driver structure */
+struct SDL_CameraDevice
 {
 {
     /* * * */
     /* * * */
     /* Data common to all devices */
     /* Data common to all devices */
 
 
-    /* The device's current video_capture specification */
-    SDL_VideoCaptureSpec spec;
+    /* The device's current camera specification */
+    SDL_CameraSpec spec;
 
 
     /* Device name */
     /* Device name */
     char *dev_name;
     char *dev_name;
@@ -49,7 +49,7 @@ struct SDL_VideoCaptureDevice
     SDL_Mutex *device_lock;
     SDL_Mutex *device_lock;
     SDL_Mutex *acquiring_lock;
     SDL_Mutex *acquiring_lock;
 
 
-    /* A thread to feed the video_capture device */
+    /* A thread to feed the camera device */
     SDL_Thread *thread;
     SDL_Thread *thread;
     SDL_ThreadID threadid;
     SDL_ThreadID threadid;
 
 
@@ -58,35 +58,35 @@ struct SDL_VideoCaptureDevice
 
 
     /* * * */
     /* * * */
     /* Data private to this driver */
     /* Data private to this driver */
-    struct SDL_PrivateVideoCaptureData *hidden;
+    struct SDL_PrivateCameraData *hidden;
 };
 };
 
 
-extern int SDL_SYS_VideoCaptureInit(void);
-extern int SDL_SYS_VideoCaptureQuit(void);
+extern int SDL_SYS_CameraInit(void);
+extern int SDL_SYS_CameraQuit(void);
 
 
-extern int OpenDevice(SDL_VideoCaptureDevice *_this);
-extern void CloseDevice(SDL_VideoCaptureDevice *_this);
+extern int OpenDevice(SDL_CameraDevice *_this);
+extern void CloseDevice(SDL_CameraDevice *_this);
 
 
-extern int InitDevice(SDL_VideoCaptureDevice *_this);
+extern int InitDevice(SDL_CameraDevice *_this);
 
 
-extern int GetDeviceSpec(SDL_VideoCaptureDevice *_this, SDL_VideoCaptureSpec *spec);
+extern int GetDeviceSpec(SDL_CameraDevice *_this, SDL_CameraSpec *spec);
 
 
-extern int StartCapture(SDL_VideoCaptureDevice *_this);
-extern int StopCapture(SDL_VideoCaptureDevice *_this);
+extern int StartCamera(SDL_CameraDevice *_this);
+extern int StopCamera(SDL_CameraDevice *_this);
 
 
-extern int AcquireFrame(SDL_VideoCaptureDevice *_this, SDL_VideoCaptureFrame *frame);
-extern int ReleaseFrame(SDL_VideoCaptureDevice *_this, SDL_VideoCaptureFrame *frame);
+extern int AcquireFrame(SDL_CameraDevice *_this, SDL_CameraFrame *frame);
+extern int ReleaseFrame(SDL_CameraDevice *_this, SDL_CameraFrame *frame);
 
 
-extern int GetNumFormats(SDL_VideoCaptureDevice *_this);
-extern int GetFormat(SDL_VideoCaptureDevice *_this, int index, Uint32 *format);
+extern int GetNumFormats(SDL_CameraDevice *_this);
+extern int GetFormat(SDL_CameraDevice *_this, int index, Uint32 *format);
 
 
-extern int GetNumFrameSizes(SDL_VideoCaptureDevice *_this, Uint32 format);
-extern int GetFrameSize(SDL_VideoCaptureDevice *_this, Uint32 format, int index, int *width, int *height);
+extern int GetNumFrameSizes(SDL_CameraDevice *_this, Uint32 format);
+extern int GetFrameSize(SDL_CameraDevice *_this, Uint32 format, int index, int *width, int *height);
 
 
-extern int GetDeviceName(SDL_VideoCaptureDeviceID instance_id, char *buf, int size);
-extern SDL_VideoCaptureDeviceID *GetVideoCaptureDevices(int *count);
+extern int GetCameraDeviceName(SDL_CameraDeviceID instance_id, char *buf, int size);
+extern SDL_CameraDeviceID *GetCameraDevices(int *count);
 
 
 extern SDL_bool check_all_device_closed(void);
 extern SDL_bool check_all_device_closed(void);
 extern SDL_bool check_device_playing(void);
 extern SDL_bool check_device_playing(void);
 
 
-#endif /* SDL_sysvideocapture_h_ */
+#endif /* SDL_syscamera_h_ */

+ 34 - 37
src/camera/android/SDL_camera_android.c

@@ -20,16 +20,14 @@
 */
 */
 #include "SDL_internal.h"
 #include "SDL_internal.h"
 
 
-#include "SDL3/SDL.h"
-#include "SDL3/SDL_video_capture.h"
-#include "../SDL_sysvideocapture.h"
-#include "../SDL_video_capture_c.h"
-#include "../SDL_pixels_c.h"
+#include "../SDL_syscamera.h"
+#include "../SDL_camera_c.h"
+#include "../../video/SDL_pixels_c.h"
 #include "../../thread/SDL_systhread.h"
 #include "../../thread/SDL_systhread.h"
 
 
-#define DEBUG_VIDEO_CAPTURE_CAPTURE 0
+#define DEBUG_CAMERA 1
 
 
-#if defined(SDL_PLATFORM_ANDROID) && __ANDROID_API__ >= 24
+#if defined(SDL_CAMERA_ANDROID) && __ANDROID_API__ >= 24
 
 
 /*
 /*
  * APP_PLATFORM=android-24
  * APP_PLATFORM=android-24
@@ -42,7 +40,7 @@
  *   <uses-feature android:name="android.hardware.camera" />
  *   <uses-feature android:name="android.hardware.camera" />
  *
  *
  *
  *
- * Add: #define SDL_VIDEO_CAPTURE 1
+ * Add: #define SDL_CAMERA 1
  * in:  include/build_config/SDL_build_config_android.h
  * in:  include/build_config/SDL_build_config_android.h
  *
  *
  *
  *
@@ -97,7 +95,7 @@ delete_cameraMgr(void)
     }
     }
 }
 }
 
 
-struct SDL_PrivateVideoCaptureData
+struct SDL_PrivateCameraData
 {
 {
     ACameraDevice *device;
     ACameraDevice *device;
     ACameraCaptureSession *session;
     ACameraCaptureSession *session;
@@ -186,14 +184,14 @@ format_sdl_2_android(Uint32 fmt)
 static void
 static void
 onDisconnected(void *context, ACameraDevice *device)
 onDisconnected(void *context, ACameraDevice *device)
 {
 {
-    // SDL_VideoCaptureDevice *_this = (SDL_VideoCaptureDevice *) context;
+    // SDL_CameraDevice *_this = (SDL_CameraDevice *) context;
     SDL_Log("CB onDisconnected");
     SDL_Log("CB onDisconnected");
 }
 }
 
 
 static void
 static void
 onError(void *context, ACameraDevice *device, int error)
 onError(void *context, ACameraDevice *device, int error)
 {
 {
-    // SDL_VideoCaptureDevice *_this = (SDL_VideoCaptureDevice *) context;
+    // SDL_CameraDevice *_this = (SDL_CameraDevice *) context;
     SDL_Log("CB onError");
     SDL_Log("CB onError");
 }
 }
 
 
@@ -201,26 +199,26 @@ onError(void *context, ACameraDevice *device, int error)
 static void
 static void
 onClosed(void* context, ACameraCaptureSession *session)
 onClosed(void* context, ACameraCaptureSession *session)
 {
 {
-    // SDL_VideoCaptureDevice *_this = (SDL_VideoCaptureDevice *) context;
+    // SDL_CameraDevice *_this = (SDL_CameraDevice *) context;
     SDL_Log("CB onClosed");
     SDL_Log("CB onClosed");
 }
 }
 
 
 static void
 static void
 onReady(void* context, ACameraCaptureSession *session)
 onReady(void* context, ACameraCaptureSession *session)
 {
 {
-    // SDL_VideoCaptureDevice *_this = (SDL_VideoCaptureDevice *) context;
+    // SDL_CameraDevice *_this = (SDL_CameraDevice *) context;
     SDL_Log("CB onReady");
     SDL_Log("CB onReady");
 }
 }
 
 
 static void
 static void
 onActive(void* context, ACameraCaptureSession *session)
 onActive(void* context, ACameraCaptureSession *session)
 {
 {
-    // SDL_VideoCaptureDevice *_this = (SDL_VideoCaptureDevice *) context;
+    // SDL_CameraDevice *_this = (SDL_CameraDevice *) context;
     SDL_Log("CB onActive");
     SDL_Log("CB onActive");
 }
 }
 
 
 int
 int
-OpenDevice(SDL_VideoCaptureDevice *_this)
+OpenDevice(SDL_CameraDevice *_this)
 {
 {
     camera_status_t res;
     camera_status_t res;
 
 
@@ -236,7 +234,7 @@ OpenDevice(SDL_VideoCaptureDevice *_this)
         return SDL_SetError("A camera is already playing");
         return SDL_SetError("A camera is already playing");
     }
     }
 
 
-    _this->hidden = (struct SDL_PrivateVideoCaptureData *) SDL_calloc(1, sizeof (struct SDL_PrivateVideoCaptureData));
+    _this->hidden = (struct SDL_PrivateCameraData *) SDL_calloc(1, sizeof (struct SDL_PrivateCameraData));
     if (_this->hidden == NULL) {
     if (_this->hidden == NULL) {
         return SDL_OutOfMemory();
         return SDL_OutOfMemory();
     }
     }
@@ -256,7 +254,7 @@ OpenDevice(SDL_VideoCaptureDevice *_this)
 }
 }
 
 
 void
 void
-CloseDevice(SDL_VideoCaptureDevice *_this)
+CloseDevice(SDL_CameraDevice *_this)
 {
 {
     if (_this && _this->hidden) {
     if (_this && _this->hidden) {
         if (_this->hidden->session) {
         if (_this->hidden->session) {
@@ -286,7 +284,7 @@ CloseDevice(SDL_VideoCaptureDevice *_this)
 }
 }
 
 
 int
 int
-InitDevice(SDL_VideoCaptureDevice *_this)
+InitDevice(SDL_CameraDevice *_this)
 {
 {
     size_t size, pitch;
     size_t size, pitch;
     SDL_CalculateSize(_this->spec.format, _this->spec.width, _this->spec.height, &size, &pitch, SDL_FALSE);
     SDL_CalculateSize(_this->spec.format, _this->spec.width, _this->spec.height, &size, &pitch, SDL_FALSE);
@@ -295,7 +293,7 @@ InitDevice(SDL_VideoCaptureDevice *_this)
 }
 }
 
 
 int
 int
-GetDeviceSpec(SDL_VideoCaptureDevice *_this, SDL_VideoCaptureSpec *spec)
+GetDeviceSpec(SDL_CameraDevice *_this, SDL_CameraSpec *spec)
 {
 {
     if (spec) {
     if (spec) {
         *spec = _this->spec;
         *spec = _this->spec;
@@ -305,7 +303,7 @@ GetDeviceSpec(SDL_VideoCaptureDevice *_this, SDL_VideoCaptureSpec *spec)
 }
 }
 
 
 int
 int
-StartCapture(SDL_VideoCaptureDevice *_this)
+StartCamera(SDL_CameraDevice *_this)
 {
 {
     camera_status_t res;
     camera_status_t res;
     media_status_t res2;
     media_status_t res2;
@@ -391,7 +389,7 @@ error:
 }
 }
 
 
 int
 int
-StopCapture(SDL_VideoCaptureDevice *_this)
+StopCamera(SDL_CameraDevice *_this)
 {
 {
     ACameraCaptureSession_close(_this->hidden->session);
     ACameraCaptureSession_close(_this->hidden->session);
     _this->hidden->session = NULL;
     _this->hidden->session = NULL;
@@ -399,7 +397,7 @@ StopCapture(SDL_VideoCaptureDevice *_this)
 }
 }
 
 
 int
 int
-AcquireFrame(SDL_VideoCaptureDevice *_this, SDL_VideoCaptureFrame *frame)
+AcquireFrame(SDL_CameraDevice *_this, SDL_CameraFrame *frame)
 {
 {
     media_status_t res;
     media_status_t res;
     AImage *image;
     AImage *image;
@@ -410,7 +408,7 @@ AcquireFrame(SDL_VideoCaptureDevice *_this, SDL_VideoCaptureFrame *frame)
     if (res == AMEDIA_IMGREADER_NO_BUFFER_AVAILABLE ) {
     if (res == AMEDIA_IMGREADER_NO_BUFFER_AVAILABLE ) {
 
 
         SDL_Delay(20); // TODO fix some delay
         SDL_Delay(20); // TODO fix some delay
-#if DEBUG_VIDEO_CAPTURE_CAPTURE
+#if DEBUG_CAMERA
 //        SDL_Log("AImageReader_acquireNextImage: AMEDIA_IMGREADER_NO_BUFFER_AVAILABLE");
 //        SDL_Log("AImageReader_acquireNextImage: AMEDIA_IMGREADER_NO_BUFFER_AVAILABLE");
 #endif
 #endif
         return 0;
         return 0;
@@ -455,7 +453,7 @@ AcquireFrame(SDL_VideoCaptureDevice *_this, SDL_VideoCaptureFrame *frame)
 }
 }
 
 
 int
 int
-ReleaseFrame(SDL_VideoCaptureDevice *_this, SDL_VideoCaptureFrame *frame)
+ReleaseFrame(SDL_CameraDevice *_this, SDL_CameraFrame *frame)
 {
 {
     if (frame->internal){
     if (frame->internal){
         AImage_delete((AImage *)frame->internal);
         AImage_delete((AImage *)frame->internal);
@@ -464,7 +462,7 @@ ReleaseFrame(SDL_VideoCaptureDevice *_this, SDL_VideoCaptureFrame *frame)
 }
 }
 
 
 int
 int
-GetNumFormats(SDL_VideoCaptureDevice *_this)
+GetNumFormats(SDL_CameraDevice *_this)
 {
 {
     camera_status_t res;
     camera_status_t res;
     int i;
     int i;
@@ -500,7 +498,7 @@ GetNumFormats(SDL_VideoCaptureDevice *_this)
         fmt = format_android_2_sdl(format);
         fmt = format_android_2_sdl(format);
         _this->hidden->count_formats[format_2_id(fmt)] += 1;
         _this->hidden->count_formats[format_2_id(fmt)] += 1;
 
 
-#if DEBUG_VIDEO_CAPTURE_CAPTURE
+#if DEBUG_CAMERA
         if (fmt != SDL_PIXELFORMAT_UNKNOWN) {
         if (fmt != SDL_PIXELFORMAT_UNKNOWN) {
             int w = entry.data.i32[i + 1];
             int w = entry.data.i32[i + 1];
             int h = entry.data.i32[i + 2];
             int h = entry.data.i32[i + 2];
@@ -511,7 +509,7 @@ GetNumFormats(SDL_VideoCaptureDevice *_this)
 #endif
 #endif
     }
     }
 
 
-#if DEBUG_VIDEO_CAPTURE_CAPTURE
+#if DEBUG_CAMERA
         if (unknown) {
         if (unknown) {
             SDL_Log("Got unknown android");
             SDL_Log("Got unknown android");
         }
         }
@@ -529,7 +527,7 @@ GetNumFormats(SDL_VideoCaptureDevice *_this)
 }
 }
 
 
 int
 int
-GetFormat(SDL_VideoCaptureDevice *_this, int index, Uint32 *format)
+GetFormat(SDL_CameraDevice *_this, int index, Uint32 *format)
 {
 {
     int i;
     int i;
     int i2 = 0;
     int i2 = 0;
@@ -558,7 +556,7 @@ GetFormat(SDL_VideoCaptureDevice *_this, int index, Uint32 *format)
 }
 }
 
 
 int
 int
-GetNumFrameSizes(SDL_VideoCaptureDevice *_this, Uint32 format)
+GetNumFrameSizes(SDL_CameraDevice *_this, Uint32 format)
 {
 {
     int i, i2 = 0, index;
     int i, i2 = 0, index;
     if (_this->hidden->num_formats == 0) {
     if (_this->hidden->num_formats == 0) {
@@ -584,7 +582,7 @@ GetNumFrameSizes(SDL_VideoCaptureDevice *_this, Uint32 format)
 }
 }
 
 
 int
 int
-GetFrameSize(SDL_VideoCaptureDevice *_this, Uint32 format, int index, int *width, int *height)
+GetFrameSize(SDL_CameraDevice *_this, Uint32 format, int index, int *width, int *height)
 {
 {
     camera_status_t res;
     camera_status_t res;
     int i, i2 = 0;
     int i, i2 = 0;
@@ -636,7 +634,7 @@ GetFrameSize(SDL_VideoCaptureDevice *_this, Uint32 format, int index, int *width
 static int GetNumDevices(void);
 static int GetNumDevices(void);
 
 
 int
 int
-GetDeviceName(SDL_VideoCaptureDeviceID instance_id, char *buf, int size)
+GetCameraDeviceName(SDL_CameraDeviceID instance_id, char *buf, int size)
 {
 {
     int index = instance_id - 1;
     int index = instance_id - 1;
     create_cameraMgr();
     create_cameraMgr();
@@ -676,14 +674,14 @@ GetNumDevices(void)
     return -1;
     return -1;
 }
 }
 
 
-SDL_VideoCaptureDeviceID *GetVideoCaptureDevices(int *count)
+SDL_CameraDeviceID *GetCameraDevices(int *count)
 {
 {
     /* hard-coded list of ID */
     /* hard-coded list of ID */
     int i;
     int i;
     int num = GetNumDevices();
     int num = GetNumDevices();
-    SDL_VideoCaptureDeviceID *ret;
+    SDL_CameraDeviceID *ret;
 
 
-    ret = (SDL_VideoCaptureDeviceID *)SDL_malloc((num + 1) * sizeof(*ret));
+    ret = (SDL_CameraDeviceID *)SDL_malloc((num + 1) * sizeof(*ret));
 
 
     if (ret == NULL) {
     if (ret == NULL) {
         SDL_OutOfMemory();
         SDL_OutOfMemory();
@@ -699,15 +697,14 @@ SDL_VideoCaptureDeviceID *GetVideoCaptureDevices(int *count)
     return ret;
     return ret;
 }
 }
 
 
-int SDL_SYS_VideoCaptureInit(void) {
+int SDL_SYS_CameraInit(void) {
     return 0;
     return 0;
 }
 }
 
 
-int SDL_SYS_VideoCaptureQuit(void) {
+int SDL_SYS_CameraQuit(void) {
     return 0;
     return 0;
 }
 }
 
 
-
 #endif
 #endif
 
 
 
 

+ 45 - 50
src/camera/apple/SDL_camera_apple.m

@@ -20,12 +20,10 @@
 */
 */
 #include "SDL_internal.h"
 #include "SDL_internal.h"
 
 
-#ifdef SDL_VIDEO_CAPTURE
+#ifdef SDL_CAMERA_APPLE
 
 
-#include "SDL3/SDL.h"
-#include "SDL3/SDL_video_capture.h"
-#include "SDL_sysvideocapture.h"
-#include "SDL_video_capture_c.h"
+#include "../SDL_syscamera.h"
+#include "../SDL_camera_c.h"
 #include "../thread/SDL_systhread.h"
 #include "../thread/SDL_systhread.h"
 
 
 #if defined(HAVE_COREMEDIA) && defined(SDL_PLATFORM_MACOS) && (__MAC_OS_X_VERSION_MAX_ALLOWED < 101500)
 #if defined(HAVE_COREMEDIA) && defined(SDL_PLATFORM_MACOS) && (__MAC_OS_X_VERSION_MAX_ALLOWED < 101500)
@@ -37,52 +35,52 @@
 #undef HAVE_COREMEDIA
 #undef HAVE_COREMEDIA
 #endif
 #endif
 
 
-#ifndef HAVE_COREMEDIA
-int InitDevice(SDL_VideoCaptureDevice *_this) {
+#ifndef HAVE_COREMEDIA  /* !!! FIXME: use the dummy driver. */
+int InitDevice(SDL_CameraDevice *_this) {
     return -1;
     return -1;
 }
 }
-int OpenDevice(SDL_VideoCaptureDevice *_this) {
+int OpenDevice(SDL_CameraDevice *_this) {
     return -1;
     return -1;
 }
 }
-int AcquireFrame(SDL_VideoCaptureDevice *_this, SDL_VideoCaptureFrame *frame) {
+int AcquireFrame(SDL_CameraDevice *_this, SDL_CameraFrame *frame) {
     return -1;
     return -1;
 }
 }
-void CloseDevice(SDL_VideoCaptureDevice *_this) {
+void CloseDevice(SDL_CameraDevice *_this) {
 }
 }
-int GetDeviceName(SDL_VideoCaptureDeviceID instance_id, char *buf, int size) {
+int GetCameraDeviceName(SDL_CameraDeviceID instance_id, char *buf, int size) {
     return -1;
     return -1;
 }
 }
-int GetDeviceSpec(SDL_VideoCaptureDevice *_this, SDL_VideoCaptureSpec *spec) {
+int GetDeviceSpec(SDL_CameraDevice *_this, SDL_CameraSpec *spec) {
     return -1;
     return -1;
 }
 }
-int GetFormat(SDL_VideoCaptureDevice *_this, int index, Uint32 *format) {
+int GetFormat(SDL_CameraDevice *_this, int index, Uint32 *format) {
     return -1;
     return -1;
 }
 }
-int GetFrameSize(SDL_VideoCaptureDevice *_this, Uint32 format, int index, int *width, int *height) {
+int GetFrameSize(SDL_CameraDevice *_this, Uint32 format, int index, int *width, int *height) {
     return -1;
     return -1;
 }
 }
-SDL_VideoCaptureDeviceID *GetVideoCaptureDevices(int *count) {
+SDL_CameraDeviceID *GetCameraDevices(int *count) {
     return NULL;
     return NULL;
 }
 }
-int GetNumFormats(SDL_VideoCaptureDevice *_this) {
+int GetNumFormats(SDL_CameraDevice *_this) {
     return 0;
     return 0;
 }
 }
-int GetNumFrameSizes(SDL_VideoCaptureDevice *_this, Uint32 format) {
+int GetNumFrameSizes(SDL_CameraDevice *_this, Uint32 format) {
     return 0;
     return 0;
 }
 }
-int ReleaseFrame(SDL_VideoCaptureDevice *_this, SDL_VideoCaptureFrame *frame) {
+int ReleaseFrame(SDL_CameraDevice *_this, SDL_CameraFrame *frame) {
     return 0;
     return 0;
 }
 }
-int StartCapture(SDL_VideoCaptureDevice *_this) {
+int StartCapture(SDL_CameraDevice *_this) {
     return 0;
     return 0;
 }
 }
-int StopCapture(SDL_VideoCaptureDevice *_this) {
+int StopCapture(SDL_CameraDevice *_this) {
     return 0;
     return 0;
 }
 }
-int SDL_SYS_VideoCaptureInit(void) {
+int SDL_SYS_CameraInit(void) {
     return 0;
     return 0;
 }
 }
-int SDL_SYS_VideoCaptureQuit(void) {
+int SDL_SYS_CameraQuit(void) {
     return 0;
     return 0;
 }
 }
 
 
@@ -107,13 +105,13 @@ int SDL_SYS_VideoCaptureQuit(void) {
  * IOS:
  * IOS:
  *
  *
  * - Need to link with:: CoreMedia CoreVideo
  * - Need to link with:: CoreMedia CoreVideo
- * - Add #define SDL_VIDEO_CAPTURE 1
+ * - Add #define SDL_CAMERA 1
  *   to SDL_build_config_ios.h
  *   to SDL_build_config_ios.h
  */
  */
 
 
 @class MySampleBufferDelegate;
 @class MySampleBufferDelegate;
 
 
-struct SDL_PrivateVideoCaptureData
+struct SDL_PrivateCameraData
 {
 {
     dispatch_queue_t queue;
     dispatch_queue_t queue;
     MySampleBufferDelegate *delegate;
     MySampleBufferDelegate *delegate;
@@ -216,13 +214,13 @@ sdlformat_to_nsfourcc(Uint32 fmt)
 
 
 
 
 @interface MySampleBufferDelegate : NSObject<AVCaptureVideoDataOutputSampleBufferDelegate>
 @interface MySampleBufferDelegate : NSObject<AVCaptureVideoDataOutputSampleBufferDelegate>
-    @property struct SDL_PrivateVideoCaptureData *hidden;
-    - (void) set: (struct SDL_PrivateVideoCaptureData *) val;
+    @property struct SDL_PrivateCameraData *hidden;
+    - (void) set: (struct SDL_PrivateCameraData *) val;
 @end
 @end
 
 
 @implementation MySampleBufferDelegate
 @implementation MySampleBufferDelegate
 
 
-    - (void) set: (struct SDL_PrivateVideoCaptureData *) val {
+    - (void) set: (struct SDL_PrivateCameraData *) val {
         _hidden = val;
         _hidden = val;
     }
     }
 
 
@@ -241,9 +239,9 @@ sdlformat_to_nsfourcc(Uint32 fmt)
 @end
 @end
 
 
 int
 int
-OpenDevice(SDL_VideoCaptureDevice *_this)
+OpenDevice(SDL_CameraDevice *_this)
 {
 {
-    _this->hidden = (struct SDL_PrivateVideoCaptureData *) SDL_calloc(1, sizeof (struct SDL_PrivateVideoCaptureData));
+    _this->hidden = (struct SDL_PrivateCameraData *) SDL_calloc(1, sizeof (struct SDL_PrivateCameraData));
     if (_this->hidden == NULL) {
     if (_this->hidden == NULL) {
         SDL_OutOfMemory();
         SDL_OutOfMemory();
         goto error;
         goto error;
@@ -256,7 +254,7 @@ error:
 }
 }
 
 
 void
 void
-CloseDevice(SDL_VideoCaptureDevice *_this)
+CloseDevice(SDL_CameraDevice *_this)
 {
 {
     if (!_this) {
     if (!_this) {
         return;
         return;
@@ -285,7 +283,7 @@ CloseDevice(SDL_VideoCaptureDevice *_this)
 }
 }
 
 
 int
 int
-InitDevice(SDL_VideoCaptureDevice *_this)
+InitDevice(SDL_CameraDevice *_this)
 {
 {
     NSString *fmt = sdlformat_to_nsfourcc(_this->spec.format);
     NSString *fmt = sdlformat_to_nsfourcc(_this->spec.format);
     int w = _this->spec.width;
     int w = _this->spec.width;
@@ -405,7 +403,7 @@ error:
 }
 }
 
 
 int
 int
-GetDeviceSpec(SDL_VideoCaptureDevice *_this, SDL_VideoCaptureSpec *spec)
+GetDeviceSpec(SDL_CameraDevice *_this, SDL_CameraSpec *spec)
 {
 {
     if (spec) {
     if (spec) {
         *spec = _this->spec;
         *spec = _this->spec;
@@ -415,21 +413,21 @@ GetDeviceSpec(SDL_VideoCaptureDevice *_this, SDL_VideoCaptureSpec *spec)
 }
 }
 
 
 int
 int
-StartCapture(SDL_VideoCaptureDevice *_this)
+StartCamera(SDL_CameraDevice *_this)
 {
 {
     [_this->hidden->session startRunning];
     [_this->hidden->session startRunning];
     return 0;
     return 0;
 }
 }
 
 
 int
 int
-StopCapture(SDL_VideoCaptureDevice *_this)
+StopCamera(SDL_CameraDevice *_this)
 {
 {
     [_this->hidden->session stopRunning];
     [_this->hidden->session stopRunning];
     return 0;
     return 0;
 }
 }
 
 
 int
 int
-AcquireFrame(SDL_VideoCaptureDevice *_this, SDL_VideoCaptureFrame *frame)
+AcquireFrame(SDL_CameraDevice *_this, SDL_CameraFrame *frame)
 {
 {
     if (CMSimpleQueueGetCount(_this->hidden->frame_queue) > 0) {
     if (CMSimpleQueueGetCount(_this->hidden->frame_queue) > 0) {
         int i, numPlanes, planar;
         int i, numPlanes, planar;
@@ -482,7 +480,7 @@ AcquireFrame(SDL_VideoCaptureDevice *_this, SDL_VideoCaptureFrame *frame)
 }
 }
 
 
 int
 int
-ReleaseFrame(SDL_VideoCaptureDevice *_this, SDL_VideoCaptureFrame *frame)
+ReleaseFrame(SDL_CameraDevice *_this, SDL_CameraFrame *frame)
 {
 {
     if (frame->internal){
     if (frame->internal){
         CMSampleBufferRef sampleBuffer = (CMSampleBufferRef) frame->internal;
         CMSampleBufferRef sampleBuffer = (CMSampleBufferRef) frame->internal;
@@ -496,7 +494,7 @@ ReleaseFrame(SDL_VideoCaptureDevice *_this, SDL_VideoCaptureFrame *frame)
 }
 }
 
 
 int
 int
-GetNumFormats(SDL_VideoCaptureDevice *_this)
+GetNumFormats(SDL_CameraDevice *_this)
 {
 {
     AVCaptureDevice *device = get_device_by_name(_this->dev_name);
     AVCaptureDevice *device = get_device_by_name(_this->dev_name);
     if (device) {
     if (device) {
@@ -517,7 +515,7 @@ GetNumFormats(SDL_VideoCaptureDevice *_this)
 }
 }
 
 
 int
 int
-GetFormat(SDL_VideoCaptureDevice *_this, int index, Uint32 *format)
+GetFormat(SDL_CameraDevice *_this, int index, Uint32 *format)
 {
 {
     AVCaptureDevice *device = get_device_by_name(_this->dev_name);
     AVCaptureDevice *device = get_device_by_name(_this->dev_name);
     if (device) {
     if (device) {
@@ -545,7 +543,7 @@ GetFormat(SDL_VideoCaptureDevice *_this, int index, Uint32 *format)
 }
 }
 
 
 int
 int
-GetNumFrameSizes(SDL_VideoCaptureDevice *_this, Uint32 format)
+GetNumFrameSizes(SDL_CameraDevice *_this, Uint32 format)
 {
 {
     AVCaptureDevice *device = get_device_by_name(_this->dev_name);
     AVCaptureDevice *device = get_device_by_name(_this->dev_name);
     if (device) {
     if (device) {
@@ -568,7 +566,7 @@ GetNumFrameSizes(SDL_VideoCaptureDevice *_this, Uint32 format)
 }
 }
 
 
 int
 int
-GetFrameSize(SDL_VideoCaptureDevice *_this, Uint32 format, int index, int *width, int *height)
+GetFrameSize(SDL_CameraDevice *_this, Uint32 format, int index, int *width, int *height)
 {
 {
     AVCaptureDevice *device = get_device_by_name(_this->dev_name);
     AVCaptureDevice *device = get_device_by_name(_this->dev_name);
     if (device) {
     if (device) {
@@ -596,7 +594,7 @@ GetFrameSize(SDL_VideoCaptureDevice *_this, Uint32 format, int index, int *width
 }
 }
 
 
 int
 int
-GetDeviceName(SDL_VideoCaptureDeviceID instance_id, char *buf, int size)
+GetCameraDeviceName(SDL_CameraDeviceID instance_id, char *buf, int size)
 {
 {
     int index = instance_id - 1;
     int index = instance_id - 1;
     NSArray<AVCaptureDevice *> *devices = discover_devices();
     NSArray<AVCaptureDevice *> *devices = discover_devices();
@@ -617,14 +615,14 @@ GetNumDevices(void)
     return [devices count];
     return [devices count];
 }
 }
 
 
-SDL_VideoCaptureDeviceID *GetVideoCaptureDevices(int *count)
+SDL_CameraDeviceID *GetCameraDevices(int *count)
 {
 {
     /* hard-coded list of ID */
     /* hard-coded list of ID */
     int i;
     int i;
     int num = GetNumDevices();
     int num = GetNumDevices();
-    SDL_VideoCaptureDeviceID *ret;
+    SDL_CameraDeviceID *ret;
 
 
-    ret = (SDL_VideoCaptureDeviceID *)SDL_malloc((num + 1) * sizeof(*ret));
+    ret = (SDL_CameraDeviceID *)SDL_malloc((num + 1) * sizeof(*ret));
 
 
     if (ret == NULL) {
     if (ret == NULL) {
         SDL_OutOfMemory();
         SDL_OutOfMemory();
@@ -640,20 +638,17 @@ SDL_VideoCaptureDeviceID *GetVideoCaptureDevices(int *count)
     return ret;
     return ret;
 }
 }
 
 
-int SDL_SYS_VideoCaptureInit(void)
+int SDL_SYS_CameraInit(void)
 {
 {
     return 0;
     return 0;
 }
 }
 
 
-int SDL_SYS_VideoCaptureQuit(void)
+int SDL_SYS_CameraQuit(void)
 {
 {
     return 0;
     return 0;
 }
 }
 
 
-
-
-
 #endif /* HAVE_COREMEDIA */
 #endif /* HAVE_COREMEDIA */
 
 
-#endif /* SDL_VIDEO_CAPTURE */
+#endif /* SDL_CAMERA_APPLE */
 
 

+ 89 - 98
src/camera/v4l2/SDL_camera_v4l2.c

@@ -20,46 +20,41 @@
 */
 */
 #include "SDL_internal.h"
 #include "SDL_internal.h"
 
 
-#ifdef SDL_VIDEO_CAPTURE
-
-#include "SDL3/SDL.h"
-#include "SDL3/SDL_video_capture.h"
-#include "SDL_sysvideocapture.h"
-#include "SDL_video_capture_c.h"
-#include "SDL_pixels_c.h"
-#include "../thread/SDL_systhread.h"
+#ifdef SDL_CAMERA_V4L2
+
+#include "../SDL_syscamera.h"
+#include "../SDL_camera_c.h"
+#include "../../video/SDL_pixels_c.h"
+#include "../../thread/SDL_systhread.h"
 #include "../../core/linux/SDL_evdev_capabilities.h"
 #include "../../core/linux/SDL_evdev_capabilities.h"
 #include "../../core/linux/SDL_udev.h"
 #include "../../core/linux/SDL_udev.h"
 #include <limits.h>      /* INT_MAX */
 #include <limits.h>      /* INT_MAX */
 
 
-#define DEBUG_VIDEO_CAPTURE_CAPTURE 0
-
-#if defined(SDL_PLATFORM_LINUX) && !defined(SDL_PLATFORM_ANDROID)
+#define DEBUG_CAMERA 1
 
 
-
-#define MAX_CAPTURE_DEVICES 128 /* It's doubtful someone has more than that */
+#define MAX_CAMERA_DEVICES 128 /* It's doubtful someone has more than that */
 
 
 static int MaybeAddDevice(const char *path);
 static int MaybeAddDevice(const char *path);
 #ifdef SDL_USE_LIBUDEV
 #ifdef SDL_USE_LIBUDEV
 static int MaybeRemoveDevice(const char *path);
 static int MaybeRemoveDevice(const char *path);
-static void capture_udev_callback(SDL_UDEV_deviceevent udev_type, int udev_class, const char *devpath);
+static void camera_udev_callback(SDL_UDEV_deviceevent udev_type, int udev_class, const char *devpath);
 #endif /* SDL_USE_LIBUDEV */
 #endif /* SDL_USE_LIBUDEV */
 
 
 /*
 /*
- * List of available capture devices.
+ * List of available camera devices.
  */
  */
-typedef struct SDL_capturelist_item
+typedef struct SDL_cameralist_item
 {
 {
     char *fname;        /* Dev path name (like /dev/video0) */
     char *fname;        /* Dev path name (like /dev/video0) */
     char *bus_info;     /* don't add two paths with same bus_info (eg /dev/video0 and /dev/video1 */
     char *bus_info;     /* don't add two paths with same bus_info (eg /dev/video0 and /dev/video1 */
-    SDL_VideoCaptureDeviceID instance_id;
-    SDL_VideoCaptureDevice *device; /* Associated device */
-    struct SDL_capturelist_item *next;
-} SDL_capturelist_item;
+    SDL_CameraDeviceID instance_id;
+    SDL_CameraDevice *device; /* Associated device */
+    struct SDL_cameralist_item *next;
+} SDL_cameralist_item;
 
 
-static SDL_capturelist_item *SDL_capturelist = NULL;
-static SDL_capturelist_item *SDL_capturelist_tail = NULL;
-static int num_video_captures = 0;
+static SDL_cameralist_item *SDL_cameralist = NULL;
+static SDL_cameralist_item *SDL_cameralist_tail = NULL;
+static int num_cameras = 0;
 
 
 
 
 
 
@@ -75,7 +70,7 @@ struct buffer {
     int available; /* Is available in userspace */
     int available; /* Is available in userspace */
 };
 };
 
 
-struct SDL_PrivateVideoCaptureData
+struct SDL_PrivateCameraData
 {
 {
     int fd;
     int fd;
     enum io_method io;
     enum io_method io;
@@ -107,7 +102,7 @@ xioctl(int fh, int request, void *arg)
 
 
 /* -1:error  1:frame 0:no frame*/
 /* -1:error  1:frame 0:no frame*/
 static int
 static int
-acquire_frame(SDL_VideoCaptureDevice *_this, SDL_VideoCaptureFrame *frame)
+acquire_frame(SDL_CameraDevice *_this, SDL_CameraFrame *frame)
 {
 {
     struct v4l2_buffer buf;
     struct v4l2_buffer buf;
     int i;
     int i;
@@ -168,7 +163,7 @@ acquire_frame(SDL_VideoCaptureDevice *_this, SDL_VideoCaptureFrame *frame)
             frame->pitch[0] = _this->hidden->driver_pitch;
             frame->pitch[0] = _this->hidden->driver_pitch;
             _this->hidden->buffers[buf.index].available = 1;
             _this->hidden->buffers[buf.index].available = 1;
 
 
-#if DEBUG_VIDEO_CAPTURE_CAPTURE
+#if DEBUG_CAMERA
             SDL_Log("debug mmap: image %d/%d  num_planes:%d data[0]=%p", buf.index, _this->hidden->nb_buffers, frame->num_planes, (void*)frame->data[0]);
             SDL_Log("debug mmap: image %d/%d  num_planes:%d data[0]=%p", buf.index, _this->hidden->nb_buffers, frame->num_planes, (void*)frame->data[0]);
 #endif
 #endif
             break;
             break;
@@ -208,7 +203,7 @@ acquire_frame(SDL_VideoCaptureDevice *_this, SDL_VideoCaptureFrame *frame)
             frame->data[0] = (void*)buf.m.userptr;
             frame->data[0] = (void*)buf.m.userptr;
             frame->pitch[0] = _this->hidden->driver_pitch;
             frame->pitch[0] = _this->hidden->driver_pitch;
             _this->hidden->buffers[i].available = 1;
             _this->hidden->buffers[i].available = 1;
-#if DEBUG_VIDEO_CAPTURE_CAPTURE
+#if DEBUG_CAMERA
             SDL_Log("debug userptr: image %d/%d  num_planes:%d data[0]=%p", buf.index, _this->hidden->nb_buffers, frame->num_planes, (void*)frame->data[0]);
             SDL_Log("debug userptr: image %d/%d  num_planes:%d data[0]=%p", buf.index, _this->hidden->nb_buffers, frame->num_planes, (void*)frame->data[0]);
 #endif
 #endif
             break;
             break;
@@ -219,7 +214,7 @@ acquire_frame(SDL_VideoCaptureDevice *_this, SDL_VideoCaptureFrame *frame)
 
 
 
 
 int
 int
-ReleaseFrame(SDL_VideoCaptureDevice *_this, SDL_VideoCaptureFrame *frame)
+ReleaseFrame(SDL_CameraDevice *_this, SDL_CameraFrame *frame)
 {
 {
     struct v4l2_buffer buf;
     struct v4l2_buffer buf;
     int i;
     int i;
@@ -274,7 +269,7 @@ ReleaseFrame(SDL_VideoCaptureDevice *_this, SDL_VideoCaptureFrame *frame)
 
 
 
 
 int
 int
-AcquireFrame(SDL_VideoCaptureDevice *_this, SDL_VideoCaptureFrame *frame)
+AcquireFrame(SDL_CameraDevice *_this, SDL_CameraFrame *frame)
 {
 {
     fd_set fds;
     fd_set fds;
     struct timeval tv;
     struct timeval tv;
@@ -293,7 +288,7 @@ AcquireFrame(SDL_VideoCaptureDevice *_this, SDL_VideoCaptureFrame *frame)
 
 
     if (ret == -1) {
     if (ret == -1) {
         if (errno == EINTR) {
         if (errno == EINTR) {
-#if DEBUG_VIDEO_CAPTURE_CAPTURE
+#if DEBUG_CAMERA
             SDL_Log("continue ..");
             SDL_Log("continue ..");
 #endif
 #endif
             return 0;
             return 0;
@@ -315,7 +310,7 @@ AcquireFrame(SDL_VideoCaptureDevice *_this, SDL_VideoCaptureFrame *frame)
     if (ret == 1){
     if (ret == 1){
         frame->timestampNS = SDL_GetTicksNS();
         frame->timestampNS = SDL_GetTicksNS();
     } else if (ret == 0) {
     } else if (ret == 0) {
-#if DEBUG_VIDEO_CAPTURE_CAPTURE
+#if DEBUG_CAMERA
         SDL_Log("No frame continue: %s", SDL_GetError());
         SDL_Log("No frame continue: %s", SDL_GetError());
 #endif
 #endif
     }
     }
@@ -326,7 +321,7 @@ AcquireFrame(SDL_VideoCaptureDevice *_this, SDL_VideoCaptureFrame *frame)
 
 
 
 
 int
 int
-StopCapture(SDL_VideoCaptureDevice *_this)
+StopCamera(SDL_CameraDevice *_this)
 {
 {
     enum v4l2_buf_type type;
     enum v4l2_buf_type type;
     int fd = _this->hidden->fd;
     int fd = _this->hidden->fd;
@@ -349,7 +344,7 @@ StopCapture(SDL_VideoCaptureDevice *_this)
 }
 }
 
 
 static int
 static int
-enqueue_buffers(SDL_VideoCaptureDevice *_this)
+enqueue_buffers(SDL_CameraDevice *_this)
 {
 {
     int i;
     int i;
     int fd = _this->hidden->fd;
     int fd = _this->hidden->fd;
@@ -398,7 +393,7 @@ enqueue_buffers(SDL_VideoCaptureDevice *_this)
 }
 }
 
 
 static int
 static int
-pre_enqueue_buffers(SDL_VideoCaptureDevice *_this)
+pre_enqueue_buffers(SDL_CameraDevice *_this)
 {
 {
     struct v4l2_requestbuffers req;
     struct v4l2_requestbuffers req;
     int fd = _this->hidden->fd;
     int fd = _this->hidden->fd;
@@ -452,7 +447,7 @@ pre_enqueue_buffers(SDL_VideoCaptureDevice *_this)
 }
 }
 
 
 int
 int
-StartCapture(SDL_VideoCaptureDevice *_this)
+StartCamera(SDL_CameraDevice *_this)
 {
 {
     enum v4l2_buf_type type;
     enum v4l2_buf_type type;
 
 
@@ -498,7 +493,7 @@ StartCapture(SDL_VideoCaptureDevice *_this)
     return 0;
     return 0;
 }
 }
 
 
-static int alloc_buffer_read(SDL_VideoCaptureDevice *_this, size_t buffer_size)
+static int alloc_buffer_read(SDL_CameraDevice *_this, size_t buffer_size)
 {
 {
     _this->hidden->buffers[0].length = buffer_size;
     _this->hidden->buffers[0].length = buffer_size;
     _this->hidden->buffers[0].start = SDL_calloc(1, buffer_size);
     _this->hidden->buffers[0].start = SDL_calloc(1, buffer_size);
@@ -510,7 +505,7 @@ static int alloc_buffer_read(SDL_VideoCaptureDevice *_this, size_t buffer_size)
 }
 }
 
 
 static int
 static int
-alloc_buffer_mmap(SDL_VideoCaptureDevice *_this)
+alloc_buffer_mmap(SDL_CameraDevice *_this)
 {
 {
     int fd = _this->hidden->fd;
     int fd = _this->hidden->fd;
     int i;
     int i;
@@ -543,7 +538,7 @@ alloc_buffer_mmap(SDL_VideoCaptureDevice *_this)
 }
 }
 
 
 static int
 static int
-alloc_buffer_userp(SDL_VideoCaptureDevice *_this, size_t buffer_size)
+alloc_buffer_userp(SDL_CameraDevice *_this, size_t buffer_size)
 {
 {
     int i;
     int i;
     for (i = 0; i < _this->hidden->nb_buffers; ++i) {
     for (i = 0; i < _this->hidden->nb_buffers; ++i) {
@@ -585,7 +580,7 @@ format_sdl_2_v4l2(Uint32 fmt)
 }
 }
 
 
 int
 int
-GetNumFormats(SDL_VideoCaptureDevice *_this)
+GetNumFormats(SDL_CameraDevice *_this)
 {
 {
     int fd = _this->hidden->fd;
     int fd = _this->hidden->fd;
     int i = 0;
     int i = 0;
@@ -601,7 +596,7 @@ GetNumFormats(SDL_VideoCaptureDevice *_this)
 }
 }
 
 
 int
 int
-GetFormat(SDL_VideoCaptureDevice *_this, int index, Uint32 *format)
+GetFormat(SDL_CameraDevice *_this, int index, Uint32 *format)
 {
 {
     int fd = _this->hidden->fd;
     int fd = _this->hidden->fd;
     struct v4l2_fmtdesc fmtdesc;
     struct v4l2_fmtdesc fmtdesc;
@@ -612,7 +607,7 @@ GetFormat(SDL_VideoCaptureDevice *_this, int index, Uint32 *format)
     if (ioctl(fd,VIDIOC_ENUM_FMT,&fmtdesc) == 0) {
     if (ioctl(fd,VIDIOC_ENUM_FMT,&fmtdesc) == 0) {
         *format = format_v4l2_2_sdl(fmtdesc.pixelformat);
         *format = format_v4l2_2_sdl(fmtdesc.pixelformat);
 
 
-#if DEBUG_VIDEO_CAPTURE_CAPTURE
+#if DEBUG_CAMERA
         if (fmtdesc.flags & V4L2_FMT_FLAG_EMULATED) {
         if (fmtdesc.flags & V4L2_FMT_FLAG_EMULATED) {
             SDL_Log("%s format emulated", SDL_GetPixelFormatName(*format));
             SDL_Log("%s format emulated", SDL_GetPixelFormatName(*format));
         }
         }
@@ -627,7 +622,7 @@ GetFormat(SDL_VideoCaptureDevice *_this, int index, Uint32 *format)
 }
 }
 
 
 int
 int
-GetNumFrameSizes(SDL_VideoCaptureDevice *_this, Uint32 format)
+GetNumFrameSizes(SDL_CameraDevice *_this, Uint32 format)
 {
 {
     int fd = _this->hidden->fd;
     int fd = _this->hidden->fd;
     int i = 0;
     int i = 0;
@@ -651,7 +646,7 @@ GetNumFrameSizes(SDL_VideoCaptureDevice *_this, Uint32 format)
 }
 }
 
 
 int
 int
-GetFrameSize(SDL_VideoCaptureDevice *_this, Uint32 format, int index, int *width, int *height)
+GetFrameSize(SDL_CameraDevice *_this, Uint32 format, int index, int *width, int *height)
 {
 {
     int fd = _this->hidden->fd;
     int fd = _this->hidden->fd;
     struct v4l2_frmsizeenum frmsizeenum;
     struct v4l2_frmsizeenum frmsizeenum;
@@ -704,7 +699,7 @@ dbg_v4l2_pixelformat(const char *str, int f) {
 #endif
 #endif
 
 
 int
 int
-GetDeviceSpec(SDL_VideoCaptureDevice *_this, SDL_VideoCaptureSpec *spec)
+GetDeviceSpec(SDL_CameraDevice *_this, SDL_CameraSpec *spec)
 {
 {
     struct v4l2_format fmt;
     struct v4l2_format fmt;
     int fd = _this->hidden->fd;
     int fd = _this->hidden->fd;
@@ -737,7 +732,7 @@ GetDeviceSpec(SDL_VideoCaptureDevice *_this, SDL_VideoCaptureSpec *spec)
 }
 }
 
 
 int
 int
-InitDevice(SDL_VideoCaptureDevice *_this)
+InitDevice(SDL_CameraDevice *_this)
 {
 {
     struct v4l2_cropcap cropcap;
     struct v4l2_cropcap cropcap;
     struct v4l2_crop crop;
     struct v4l2_crop crop;
@@ -783,7 +778,7 @@ InitDevice(SDL_VideoCaptureDevice *_this)
         //    fmt.fmt.pix.field       = V4L2_FIELD_INTERLACED;
         //    fmt.fmt.pix.field       = V4L2_FIELD_INTERLACED;
         fmt.fmt.pix.field       = V4L2_FIELD_ANY;
         fmt.fmt.pix.field       = V4L2_FIELD_ANY;
 
 
-#if DEBUG_VIDEO_CAPTURE_CAPTURE
+#if DEBUG_CAMERA
         SDL_Log("set SDL format %s", SDL_GetPixelFormatName(_this->spec.format));
         SDL_Log("set SDL format %s", SDL_GetPixelFormatName(_this->spec.format));
         dbg_v4l2_pixelformat("set format", fmt.fmt.pix.pixelformat);
         dbg_v4l2_pixelformat("set format", fmt.fmt.pix.pixelformat);
 #endif
 #endif
@@ -833,7 +828,7 @@ InitDevice(SDL_VideoCaptureDevice *_this)
 }
 }
 
 
 void
 void
-CloseDevice(SDL_VideoCaptureDevice *_this)
+CloseDevice(SDL_CameraDevice *_this)
 {
 {
     if (!_this) {
     if (!_this) {
         return;
         return;
@@ -869,7 +864,7 @@ CloseDevice(SDL_VideoCaptureDevice *_this)
 
 
         if (_this->hidden->fd != -1) {
         if (_this->hidden->fd != -1) {
             if (close(_this->hidden->fd)) {
             if (close(_this->hidden->fd)) {
-                SDL_SetError("close video capture device");
+                SDL_SetError("close camera device");
             }
             }
         }
         }
         SDL_free(_this->hidden);
         SDL_free(_this->hidden);
@@ -880,14 +875,14 @@ CloseDevice(SDL_VideoCaptureDevice *_this)
 
 
 
 
 int
 int
-OpenDevice(SDL_VideoCaptureDevice *_this)
+OpenDevice(SDL_CameraDevice *_this)
 {
 {
     struct stat st;
     struct stat st;
     struct v4l2_capability cap;
     struct v4l2_capability cap;
     int fd;
     int fd;
     enum io_method io;
     enum io_method io;
 
 
-    _this->hidden = (struct SDL_PrivateVideoCaptureData *) SDL_calloc(1, sizeof (struct SDL_PrivateVideoCaptureData));
+    _this->hidden = (struct SDL_PrivateCameraData *) SDL_calloc(1, sizeof (struct SDL_PrivateCameraData));
     if (_this->hidden == NULL) {
     if (_this->hidden == NULL) {
         SDL_OutOfMemory();
         SDL_OutOfMemory();
         return -1;
         return -1;
@@ -966,10 +961,10 @@ OpenDevice(SDL_VideoCaptureDevice *_this)
 }
 }
 
 
 int
 int
-GetDeviceName(SDL_VideoCaptureDeviceID instance_id, char *buf, int size)
+GetCameraDeviceName(SDL_CameraDeviceID instance_id, char *buf, int size)
 {
 {
-    SDL_capturelist_item *item;
-    for (item = SDL_capturelist; item; item = item->next) {
+    SDL_cameralist_item *item;
+    for (item = SDL_cameralist; item; item = item->next) {
         if (item->instance_id == instance_id) {
         if (item->instance_id == instance_id) {
             SDL_snprintf(buf, size, "%s", item->fname);
             SDL_snprintf(buf, size, "%s", item->fname);
             return 0;
             return 0;
@@ -981,15 +976,15 @@ GetDeviceName(SDL_VideoCaptureDeviceID instance_id, char *buf, int size)
 }
 }
 
 
 
 
-SDL_VideoCaptureDeviceID *GetVideoCaptureDevices(int *count)
+SDL_CameraDeviceID *GetCameraDevices(int *count)
 {
 {
     /* real list of ID */
     /* real list of ID */
     int i = 0;
     int i = 0;
-    int num = num_video_captures;
-    SDL_VideoCaptureDeviceID *ret;
-    SDL_capturelist_item *item;
+    int num = num_cameras;
+    SDL_CameraDeviceID *ret;
+    SDL_cameralist_item *item;
 
 
-    ret = (SDL_VideoCaptureDeviceID *)SDL_malloc((num + 1) * sizeof(*ret));
+    ret = (SDL_CameraDeviceID *)SDL_malloc((num + 1) * sizeof(*ret));
 
 
     if (ret == NULL) {
     if (ret == NULL) {
         SDL_OutOfMemory();
         SDL_OutOfMemory();
@@ -997,7 +992,7 @@ SDL_VideoCaptureDeviceID *GetVideoCaptureDevices(int *count)
         return NULL;
         return NULL;
     }
     }
 
 
-    for (item = SDL_capturelist; item; item = item->next) {
+    for (item = SDL_cameralist; item; item = item->next) {
         ret[i] = item->instance_id;
         ret[i] = item->instance_id;
         i++;
         i++;
     }
     }
@@ -1011,18 +1006,18 @@ SDL_VideoCaptureDeviceID *GetVideoCaptureDevices(int *count)
 /*
 /*
  * Initializes the subsystem by finding available devices.
  * Initializes the subsystem by finding available devices.
  */
  */
-int SDL_SYS_VideoCaptureInit(void)
+int SDL_SYS_CameraInit(void)
 {
 {
     const char pattern[] = "/dev/video%d";
     const char pattern[] = "/dev/video%d";
     char path[PATH_MAX];
     char path[PATH_MAX];
     int i, j;
     int i, j;
 
 
     /*
     /*
-     * Limit amount of checks to MAX_CAPTURE_DEVICES since we may or may not have
+     * Limit amount of checks to MAX_CAMERA_DEVICES since we may or may not have
      * permission to some or all devices.
      * permission to some or all devices.
      */
      */
     i = 0;
     i = 0;
-    for (j = 0; j < MAX_CAPTURE_DEVICES; ++j) {
+    for (j = 0; j < MAX_CAMERA_DEVICES; ++j) {
         (void)SDL_snprintf(path, PATH_MAX, pattern, i++);
         (void)SDL_snprintf(path, PATH_MAX, pattern, i++);
         if (MaybeAddDevice(path) == -2) {
         if (MaybeAddDevice(path) == -2) {
             break;
             break;
@@ -1034,7 +1029,7 @@ int SDL_SYS_VideoCaptureInit(void)
         return SDL_SetError("Could not initialize UDEV");
         return SDL_SetError("Could not initialize UDEV");
     }
     }
 
 
-    if (SDL_UDEV_AddCallback(capture_udev_callback) < 0) {
+    if (SDL_UDEV_AddCallback(camera_udev_callback) < 0) {
         SDL_UDEV_Quit();
         SDL_UDEV_Quit();
         return SDL_SetError("Could not setup Video Capture <-> udev callback");
         return SDL_SetError("Could not setup Video Capture <-> udev callback");
     }
     }
@@ -1043,15 +1038,15 @@ int SDL_SYS_VideoCaptureInit(void)
     SDL_UDEV_Scan();
     SDL_UDEV_Scan();
 #endif /* SDL_USE_LIBUDEV */
 #endif /* SDL_USE_LIBUDEV */
 
 
-    return num_video_captures;
+    return num_cameras;
 }
 }
 
 
 
 
-int SDL_SYS_VideoCaptureQuit(void)
+int SDL_SYS_CameraQuit(void)
 {
 {
-    SDL_capturelist_item *item;
-    for (item = SDL_capturelist; item; ) {
-        SDL_capturelist_item *tmp = item->next;
+    SDL_cameralist_item *item;
+    for (item = SDL_cameralist; item; ) {
+        SDL_cameralist_item *tmp = item->next;
 
 
         SDL_free(item->fname);
         SDL_free(item->fname);
         SDL_free(item->bus_info);
         SDL_free(item->bus_info);
@@ -1059,15 +1054,15 @@ int SDL_SYS_VideoCaptureQuit(void)
         item = tmp;
         item = tmp;
     }
     }
 
 
-    num_video_captures = 0;
-    SDL_capturelist = NULL;
-    SDL_capturelist_tail = NULL;
+    num_cameras = 0;
+    SDL_cameralist = NULL;
+    SDL_cameralist_tail = NULL;
 
 
     return SDL_FALSE;
     return SDL_FALSE;
 }
 }
 
 
 #ifdef SDL_USE_LIBUDEV
 #ifdef SDL_USE_LIBUDEV
-static void capture_udev_callback(SDL_UDEV_deviceevent udev_type, int udev_class, const char *devpath)
+static void camera_udev_callback(SDL_UDEV_deviceevent udev_type, int udev_class, const char *devpath)
 {
 {
     if (!devpath || !(udev_class & SDL_UDEV_DEVICE_VIDEO_CAPTURE)) {
     if (!devpath || !(udev_class & SDL_UDEV_DEVICE_VIDEO_CAPTURE)) {
         return;
         return;
@@ -1089,9 +1084,9 @@ static void capture_udev_callback(SDL_UDEV_deviceevent udev_type, int udev_class
 #endif /* SDL_USE_LIBUDEV */
 #endif /* SDL_USE_LIBUDEV */
 
 
 static SDL_bool DeviceExists(const char *path, const char *bus_info) {
 static SDL_bool DeviceExists(const char *path, const char *bus_info) {
-    SDL_capturelist_item *item;
+    SDL_cameralist_item *item;
 
 
-    for (item = SDL_capturelist; item; item = item->next) {
+    for (item = SDL_cameralist; item; item = item->next) {
         /* found same dev name */
         /* found same dev name */
         if (SDL_strcmp(path, item->fname) == 0) {
         if (SDL_strcmp(path, item->fname) == 0) {
             return SDL_TRUE;
             return SDL_TRUE;
@@ -1110,7 +1105,7 @@ static int MaybeAddDevice(const char *path)
     struct v4l2_capability vcap;
     struct v4l2_capability vcap;
     int err;
     int err;
     int fd;
     int fd;
-    SDL_capturelist_item *item;
+    SDL_cameralist_item *item;
 
 
     if (!path) {
     if (!path) {
         return -1;
         return -1;
@@ -1135,7 +1130,7 @@ static int MaybeAddDevice(const char *path)
 
 
 
 
     /* Add new item */
     /* Add new item */
-    item = (SDL_capturelist_item *)SDL_calloc(1, sizeof(SDL_capturelist_item));
+    item = (SDL_cameralist_item *)SDL_calloc(1, sizeof(SDL_cameralist_item));
     if (!item) {
     if (!item) {
         SDL_free(bus_info);
         SDL_free(bus_info);
         return -1;
         return -1;
@@ -1153,18 +1148,18 @@ static int MaybeAddDevice(const char *path)
     item->instance_id = SDL_GetNextObjectID();
     item->instance_id = SDL_GetNextObjectID();
 
 
 
 
-    if (!SDL_capturelist_tail) {
-        SDL_capturelist = SDL_capturelist_tail = item;
+    if (!SDL_cameralist_tail) {
+        SDL_cameralist = SDL_cameralist_tail = item;
     } else {
     } else {
-        SDL_capturelist_tail->next = item;
-        SDL_capturelist_tail = item;
+        SDL_cameralist_tail->next = item;
+        SDL_cameralist_tail = item;
     }
     }
 
 
-    ++num_video_captures;
+    ++num_cameras;
 
 
     /* !!! TODO: Send a add event? */
     /* !!! TODO: Send a add event? */
-#if DEBUG_VIDEO_CAPTURE_CAPTURE
-    SDL_Log("Added video capture ID: %d %s (%s) (total: %d)", item->instance_id, path, bus_info, num_video_captures);
+#if DEBUG_CAMERA
+    SDL_Log("Added video camera ID: %d %s (%s) (total: %d)", item->instance_id, path, bus_info, num_cameras);
 #endif
 #endif
     return 0;
     return 0;
 }
 }
@@ -1173,30 +1168,30 @@ static int MaybeAddDevice(const char *path)
 static int MaybeRemoveDevice(const char *path)
 static int MaybeRemoveDevice(const char *path)
 {
 {
 
 
-    SDL_capturelist_item *item;
-    SDL_capturelist_item *prev = NULL;
-#if DEBUG_VIDEO_CAPTURE_CAPTURE
-    SDL_Log("Remove video capture %s", path);
+    SDL_cameralist_item *item;
+    SDL_cameralist_item *prev = NULL;
+#if DEBUG_CAMERA
+    SDL_Log("Remove video camera %s", path);
 #endif
 #endif
     if (!path) {
     if (!path) {
         return -1;
         return -1;
     }
     }
 
 
-    for (item = SDL_capturelist; item; item = item->next) {
+    for (item = SDL_cameralist; item; item = item->next) {
         /* found it, remove it. */
         /* found it, remove it. */
         if (SDL_strcmp(path, item->fname) == 0) {
         if (SDL_strcmp(path, item->fname) == 0) {
             if (prev) {
             if (prev) {
                 prev->next = item->next;
                 prev->next = item->next;
             } else {
             } else {
-                SDL_assert(SDL_capturelist == item);
-                SDL_capturelist = item->next;
+                SDL_assert(SDL_cameralist == item);
+                SDL_cameralist = item->next;
             }
             }
-            if (item == SDL_capturelist_tail) {
-                SDL_capturelist_tail = prev;
+            if (item == SDL_cameralist_tail) {
+                SDL_cameralist_tail = prev;
             }
             }
 
 
             /* Need to decrement the count */
             /* Need to decrement the count */
-            --num_video_captures;
+            --num_cameras;
             /* !!! TODO: Send a remove event? */
             /* !!! TODO: Send a remove event? */
 
 
             SDL_free(item->fname);
             SDL_free(item->fname);
@@ -1210,8 +1205,4 @@ static int MaybeRemoveDevice(const char *path)
 }
 }
 #endif /* SDL_USE_LIBUDEV */
 #endif /* SDL_USE_LIBUDEV */
 
 
-
-
-#endif
-
-#endif /* SDL_VIDEO_CAPTURE */
+#endif /* SDL_CAMERA_V4L2 */

+ 16 - 16
src/dynapi/SDL_dynapi.sym

@@ -895,22 +895,6 @@ SDL3_0.0.0 {
     SDL_SetPropertyWithCleanup;
     SDL_SetPropertyWithCleanup;
     SDL_SetX11EventHook;
     SDL_SetX11EventHook;
     SDL_GetGlobalProperties;
     SDL_GetGlobalProperties;
-    SDL_OpenVideoCapture;
-    SDL_SetVideoCaptureSpec;
-    SDL_OpenVideoCaptureWithSpec;
-    SDL_GetVideoCaptureDeviceName;
-    SDL_GetVideoCaptureSpec;
-    SDL_GetVideoCaptureFormat;
-    SDL_GetNumVideoCaptureFormats;
-    SDL_GetVideoCaptureFrameSize;
-    SDL_GetNumVideoCaptureFrameSizes;
-    SDL_GetVideoCaptureStatus;
-    SDL_StartVideoCapture;
-    SDL_AcquireVideoCaptureFrame;
-    SDL_ReleaseVideoCaptureFrame;
-    SDL_StopVideoCapture;
-    SDL_CloseVideoCapture;
-    SDL_GetVideoCaptureDevices;
     SDL_GetGamepadButtonLabelForType;
     SDL_GetGamepadButtonLabelForType;
     SDL_GetGamepadButtonLabel;
     SDL_GetGamepadButtonLabel;
     SDL_GetPens;
     SDL_GetPens;
@@ -973,6 +957,22 @@ SDL3_0.0.0 {
     SDL_SetWindowShape;
     SDL_SetWindowShape;
     SDL_RenderViewportSet;
     SDL_RenderViewportSet;
     SDL_HasProperty;
     SDL_HasProperty;
+    SDL_GetCameraDevices;
+    SDL_OpenCamera;
+    SDL_SetCameraSpec;
+    SDL_OpenCameraWithSpec;
+    SDL_GetCameraDeviceName;
+    SDL_GetCameraSpec;
+    SDL_GetCameraFormat;
+    SDL_GetNumCameraFormats;
+    SDL_GetCameraFrameSize;
+    SDL_GetNumCameraFrameSizes;
+    SDL_GetCameraStatus;
+    SDL_StartCamera;
+    SDL_AcquireCameraFrame;
+    SDL_ReleaseCameraFrame;
+    SDL_StopCamera;
+    SDL_CloseCamera;
     # extra symbols go here (don't modify this line)
     # extra symbols go here (don't modify this line)
   local: *;
   local: *;
 };
 };

+ 16 - 16
src/dynapi/SDL_dynapi_overrides.h

@@ -920,22 +920,6 @@
 #define SDL_SetPropertyWithCleanup SDL_SetPropertyWithCleanup_REAL
 #define SDL_SetPropertyWithCleanup SDL_SetPropertyWithCleanup_REAL
 #define SDL_SetX11EventHook SDL_SetX11EventHook_REAL
 #define SDL_SetX11EventHook SDL_SetX11EventHook_REAL
 #define SDL_GetGlobalProperties SDL_GetGlobalProperties_REAL
 #define SDL_GetGlobalProperties SDL_GetGlobalProperties_REAL
-#define SDL_OpenVideoCapture SDL_OpenVideoCapture_REAL
-#define SDL_SetVideoCaptureSpec SDL_SetVideoCaptureSpec_REAL
-#define SDL_OpenVideoCaptureWithSpec SDL_OpenVideoCaptureWithSpec_REAL
-#define SDL_GetVideoCaptureDeviceName SDL_GetVideoCaptureDeviceName_REAL
-#define SDL_GetVideoCaptureSpec SDL_GetVideoCaptureSpec_REAL
-#define SDL_GetVideoCaptureFormat SDL_GetVideoCaptureFormat_REAL
-#define SDL_GetNumVideoCaptureFormats SDL_GetNumVideoCaptureFormats_REAL
-#define SDL_GetVideoCaptureFrameSize SDL_GetVideoCaptureFrameSize_REAL
-#define SDL_GetNumVideoCaptureFrameSizes SDL_GetNumVideoCaptureFrameSizes_REAL
-#define SDL_GetVideoCaptureStatus SDL_GetVideoCaptureStatus_REAL
-#define SDL_StartVideoCapture SDL_StartVideoCapture_REAL
-#define SDL_AcquireVideoCaptureFrame SDL_AcquireVideoCaptureFrame_REAL
-#define SDL_ReleaseVideoCaptureFrame SDL_ReleaseVideoCaptureFrame_REAL
-#define SDL_StopVideoCapture SDL_StopVideoCapture_REAL
-#define SDL_CloseVideoCapture SDL_CloseVideoCapture_REAL
-#define SDL_GetVideoCaptureDevices SDL_GetVideoCaptureDevices_REAL
 #define SDL_GetGamepadButtonLabelForType SDL_GetGamepadButtonLabelForType_REAL
 #define SDL_GetGamepadButtonLabelForType SDL_GetGamepadButtonLabelForType_REAL
 #define SDL_GetGamepadButtonLabel SDL_GetGamepadButtonLabel_REAL
 #define SDL_GetGamepadButtonLabel SDL_GetGamepadButtonLabel_REAL
 #define SDL_GetPens SDL_GetPens_REAL
 #define SDL_GetPens SDL_GetPens_REAL
@@ -998,3 +982,19 @@
 #define SDL_SetWindowShape SDL_SetWindowShape_REAL
 #define SDL_SetWindowShape SDL_SetWindowShape_REAL
 #define SDL_RenderViewportSet SDL_RenderViewportSet_REAL
 #define SDL_RenderViewportSet SDL_RenderViewportSet_REAL
 #define SDL_HasProperty SDL_HasProperty_REAL
 #define SDL_HasProperty SDL_HasProperty_REAL
+#define SDL_GetCameraDevices SDL_GetCameraDevices_REAL
+#define SDL_OpenCamera SDL_OpenCamera_REAL
+#define SDL_SetCameraSpec SDL_SetCameraSpec_REAL
+#define SDL_OpenCameraWithSpec SDL_OpenCameraWithSpec_REAL
+#define SDL_GetCameraDeviceName SDL_GetCameraDeviceName_REAL
+#define SDL_GetCameraSpec SDL_GetCameraSpec_REAL
+#define SDL_GetCameraFormat SDL_GetCameraFormat_REAL
+#define SDL_GetNumCameraFormats SDL_GetNumCameraFormats_REAL
+#define SDL_GetCameraFrameSize SDL_GetCameraFrameSize_REAL
+#define SDL_GetNumCameraFrameSizes SDL_GetNumCameraFrameSizes_REAL
+#define SDL_GetCameraStatus SDL_GetCameraStatus_REAL
+#define SDL_StartCamera SDL_StartCamera_REAL
+#define SDL_AcquireCameraFrame SDL_AcquireCameraFrame_REAL
+#define SDL_ReleaseCameraFrame SDL_ReleaseCameraFrame_REAL
+#define SDL_StopCamera SDL_StopCamera_REAL
+#define SDL_CloseCamera SDL_CloseCamera_REAL

+ 16 - 16
src/dynapi/SDL_dynapi_procs.h

@@ -953,22 +953,6 @@ SDL_DYNAPI_PROC(SDL_PropertiesID,SDL_GetDisplayProperties,(SDL_DisplayID a),(a),
 SDL_DYNAPI_PROC(int,SDL_SetPropertyWithCleanup,(SDL_PropertiesID a, const char *b, void *c, void (SDLCALL *d)(void *userdata, void *value), void *e),(a,b,c,d,e),return)
 SDL_DYNAPI_PROC(int,SDL_SetPropertyWithCleanup,(SDL_PropertiesID a, const char *b, void *c, void (SDLCALL *d)(void *userdata, void *value), void *e),(a,b,c,d,e),return)
 SDL_DYNAPI_PROC(void,SDL_SetX11EventHook,(SDL_X11EventHook a, void *b),(a,b),)
 SDL_DYNAPI_PROC(void,SDL_SetX11EventHook,(SDL_X11EventHook a, void *b),(a,b),)
 SDL_DYNAPI_PROC(SDL_PropertiesID,SDL_GetGlobalProperties,(void),(),return)
 SDL_DYNAPI_PROC(SDL_PropertiesID,SDL_GetGlobalProperties,(void),(),return)
-SDL_DYNAPI_PROC(SDL_VideoCaptureDevice*,SDL_OpenVideoCapture,(SDL_VideoCaptureDeviceID a),(a),return)
-SDL_DYNAPI_PROC(int,SDL_SetVideoCaptureSpec,(SDL_VideoCaptureDevice *a, const SDL_VideoCaptureSpec *b, SDL_VideoCaptureSpec *c, int d),(a,b,c,d),return)
-SDL_DYNAPI_PROC(SDL_VideoCaptureDevice*,SDL_OpenVideoCaptureWithSpec,(SDL_VideoCaptureDeviceID a, const SDL_VideoCaptureSpec *b, SDL_VideoCaptureSpec *c, int d),(a,b,c,d),return)
-SDL_DYNAPI_PROC(const char*,SDL_GetVideoCaptureDeviceName,(SDL_VideoCaptureDeviceID a),(a),return)
-SDL_DYNAPI_PROC(int,SDL_GetVideoCaptureSpec,(SDL_VideoCaptureDevice *a, SDL_VideoCaptureSpec *b),(a,b),return)
-SDL_DYNAPI_PROC(int,SDL_GetVideoCaptureFormat,(SDL_VideoCaptureDevice *a, int b, Uint32 *c),(a,b,c),return)
-SDL_DYNAPI_PROC(int,SDL_GetNumVideoCaptureFormats,(SDL_VideoCaptureDevice *a),(a),return)
-SDL_DYNAPI_PROC(int,SDL_GetVideoCaptureFrameSize,(SDL_VideoCaptureDevice *a, Uint32 b, int c, int *d, int *e),(a,b,c,d,e),return)
-SDL_DYNAPI_PROC(int,SDL_GetNumVideoCaptureFrameSizes,(SDL_VideoCaptureDevice *a, Uint32 b),(a,b),return)
-SDL_DYNAPI_PROC(SDL_VideoCaptureStatus,SDL_GetVideoCaptureStatus,(SDL_VideoCaptureDevice *a),(a),return)
-SDL_DYNAPI_PROC(int,SDL_StartVideoCapture,(SDL_VideoCaptureDevice *a),(a),return)
-SDL_DYNAPI_PROC(int,SDL_AcquireVideoCaptureFrame,(SDL_VideoCaptureDevice *a, SDL_VideoCaptureFrame *b),(a,b),return)
-SDL_DYNAPI_PROC(int,SDL_ReleaseVideoCaptureFrame,(SDL_VideoCaptureDevice *a, SDL_VideoCaptureFrame *b),(a,b),return)
-SDL_DYNAPI_PROC(int,SDL_StopVideoCapture,(SDL_VideoCaptureDevice *a),(a),return)
-SDL_DYNAPI_PROC(void,SDL_CloseVideoCapture,(SDL_VideoCaptureDevice *a),(a),)
-SDL_DYNAPI_PROC(SDL_VideoCaptureDeviceID*,SDL_GetVideoCaptureDevices,(int *a),(a),return)
 SDL_DYNAPI_PROC(SDL_GamepadButtonLabel,SDL_GetGamepadButtonLabelForType,(SDL_GamepadType a, SDL_GamepadButton b),(a,b),return)
 SDL_DYNAPI_PROC(SDL_GamepadButtonLabel,SDL_GetGamepadButtonLabelForType,(SDL_GamepadType a, SDL_GamepadButton b),(a,b),return)
 SDL_DYNAPI_PROC(SDL_GamepadButtonLabel,SDL_GetGamepadButtonLabel,(SDL_Gamepad *a, SDL_GamepadButton b),(a,b),return)
 SDL_DYNAPI_PROC(SDL_GamepadButtonLabel,SDL_GetGamepadButtonLabel,(SDL_Gamepad *a, SDL_GamepadButton b),(a,b),return)
 SDL_DYNAPI_PROC(SDL_PenID*,SDL_GetPens,(int *a),(a),return)
 SDL_DYNAPI_PROC(SDL_PenID*,SDL_GetPens,(int *a),(a),return)
@@ -1023,3 +1007,19 @@ SDL_DYNAPI_PROC(int,SDL_RenderGeometryRawFloat,(SDL_Renderer *a, SDL_Texture *b,
 SDL_DYNAPI_PROC(int,SDL_SetWindowShape,(SDL_Window *a, SDL_Surface *b),(a,b),return)
 SDL_DYNAPI_PROC(int,SDL_SetWindowShape,(SDL_Window *a, SDL_Surface *b),(a,b),return)
 SDL_DYNAPI_PROC(SDL_bool,SDL_RenderViewportSet,(SDL_Renderer *a),(a),return)
 SDL_DYNAPI_PROC(SDL_bool,SDL_RenderViewportSet,(SDL_Renderer *a),(a),return)
 SDL_DYNAPI_PROC(SDL_bool,SDL_HasProperty,(SDL_PropertiesID a, const char *b),(a,b),return)
 SDL_DYNAPI_PROC(SDL_bool,SDL_HasProperty,(SDL_PropertiesID a, const char *b),(a,b),return)
+SDL_DYNAPI_PROC(SDL_CameraDeviceID*,SDL_GetCameraDevices,(int *a),(a),return)
+SDL_DYNAPI_PROC(SDL_CameraDevice*,SDL_OpenCamera,(SDL_CameraDeviceID a),(a),return)
+SDL_DYNAPI_PROC(int,SDL_SetCameraSpec,(SDL_CameraDevice *a, const SDL_CameraSpec *b, SDL_CameraSpec *c, int d),(a,b,c,d),return)
+SDL_DYNAPI_PROC(SDL_CameraDevice*,SDL_OpenCameraWithSpec,(SDL_CameraDeviceID a, const SDL_CameraSpec *b, SDL_CameraSpec *c, int d),(a,b,c,d),return)
+SDL_DYNAPI_PROC(const char*,SDL_GetCameraDeviceName,(SDL_CameraDeviceID a),(a),return)
+SDL_DYNAPI_PROC(int,SDL_GetCameraSpec,(SDL_CameraDevice *a, SDL_CameraSpec *b),(a,b),return)
+SDL_DYNAPI_PROC(int,SDL_GetCameraFormat,(SDL_CameraDevice *a, int b, Uint32 *c),(a,b,c),return)
+SDL_DYNAPI_PROC(int,SDL_GetNumCameraFormats,(SDL_CameraDevice *a),(a),return)
+SDL_DYNAPI_PROC(int,SDL_GetCameraFrameSize,(SDL_CameraDevice *a, Uint32 b, int c, int *d, int *e),(a,b,c,d,e),return)
+SDL_DYNAPI_PROC(int,SDL_GetNumCameraFrameSizes,(SDL_CameraDevice *a, Uint32 b),(a,b),return)
+SDL_DYNAPI_PROC(SDL_CameraStatus,SDL_GetCameraStatus,(SDL_CameraDevice *a),(a),return)
+SDL_DYNAPI_PROC(int,SDL_StartCamera,(SDL_CameraDevice *a),(a),return)
+SDL_DYNAPI_PROC(int,SDL_AcquireCameraFrame,(SDL_CameraDevice *a, SDL_CameraFrame *b),(a,b),return)
+SDL_DYNAPI_PROC(int,SDL_ReleaseCameraFrame,(SDL_CameraDevice *a, SDL_CameraFrame *b),(a,b),return)
+SDL_DYNAPI_PROC(int,SDL_StopCamera,(SDL_CameraDevice *a),(a),return)
+SDL_DYNAPI_PROC(void,SDL_CloseCamera,(SDL_CameraDevice *a),(a),)

+ 6 - 6
src/video/SDL_video.c

@@ -458,7 +458,7 @@ int SDL_VideoInit(const char *driver_name)
     SDL_bool init_keyboard = SDL_FALSE;
     SDL_bool init_keyboard = SDL_FALSE;
     SDL_bool init_mouse = SDL_FALSE;
     SDL_bool init_mouse = SDL_FALSE;
     SDL_bool init_touch = SDL_FALSE;
     SDL_bool init_touch = SDL_FALSE;
-    SDL_bool init_video_capture = SDL_FALSE;
+    SDL_bool init_camera = SDL_FALSE;
     int i = 0;
     int i = 0;
 
 
     /* Check to make sure we don't overwrite '_this' */
     /* Check to make sure we don't overwrite '_this' */
@@ -485,10 +485,10 @@ int SDL_VideoInit(const char *driver_name)
         goto pre_driver_error;
         goto pre_driver_error;
     }
     }
     init_touch = SDL_TRUE;
     init_touch = SDL_TRUE;
-    if (SDL_VideoCaptureInit() < 0) {
+    if (SDL_CameraInit() < 0) {
         goto pre_driver_error;
         goto pre_driver_error;
     }
     }
-    init_video_capture = SDL_TRUE;
+    init_camera = SDL_TRUE;
 
 
     /* Select the proper video driver */
     /* Select the proper video driver */
     video = NULL;
     video = NULL;
@@ -590,8 +590,8 @@ int SDL_VideoInit(const char *driver_name)
 
 
 pre_driver_error:
 pre_driver_error:
     SDL_assert(_this == NULL);
     SDL_assert(_this == NULL);
-    if (init_video_capture) {
-        SDL_QuitVideoCapture();
+    if (init_camera) {
+        SDL_QuitCamera();
     }
     }
     if (init_touch) {
     if (init_touch) {
         SDL_QuitTouch();
         SDL_QuitTouch();
@@ -3784,7 +3784,7 @@ void SDL_VideoQuit(void)
     SDL_ClearClipboardData();
     SDL_ClearClipboardData();
 
 
     /* Halt event processing before doing anything else */
     /* Halt event processing before doing anything else */
-    SDL_QuitVideoCapture();
+    SDL_QuitCamera();
     SDL_QuitTouch();
     SDL_QuitTouch();
     SDL_QuitMouse();
     SDL_QuitMouse();
     SDL_QuitKeyboard();
     SDL_QuitKeyboard();

+ 2 - 2
test/CMakeLists.txt

@@ -394,8 +394,8 @@ add_sdl_test_executable(teststreaming NEEDS_RESOURCES TESTUTILS SOURCES teststre
 add_sdl_test_executable(testtimer NONINTERACTIVE NONINTERACTIVE_ARGS --no-interactive NONINTERACTIVE_TIMEOUT 60 SOURCES testtimer.c)
 add_sdl_test_executable(testtimer NONINTERACTIVE NONINTERACTIVE_ARGS --no-interactive NONINTERACTIVE_TIMEOUT 60 SOURCES testtimer.c)
 add_sdl_test_executable(testurl SOURCES testurl.c)
 add_sdl_test_executable(testurl SOURCES testurl.c)
 add_sdl_test_executable(testver NONINTERACTIVE SOURCES testver.c)
 add_sdl_test_executable(testver NONINTERACTIVE SOURCES testver.c)
-add_sdl_test_executable(testvideocapture SOURCES testvideocapture.c)
-add_sdl_test_executable(testvideocaptureminimal SOURCES testvideocaptureminimal.c)
+add_sdl_test_executable(testcamera SOURCES testcamera.c)
+add_sdl_test_executable(testcameraminimal SOURCES testcameraminimal.c)
 add_sdl_test_executable(testviewport NEEDS_RESOURCES TESTUTILS SOURCES testviewport.c)
 add_sdl_test_executable(testviewport NEEDS_RESOURCES TESTUTILS SOURCES testviewport.c)
 add_sdl_test_executable(testwm SOURCES testwm.c)
 add_sdl_test_executable(testwm SOURCES testwm.c)
 add_sdl_test_executable(testyuv NONINTERACTIVE NONINTERACTIVE_ARGS "--automated" NEEDS_RESOURCES TESTUTILS SOURCES testyuv.c testyuv_cvt.c)
 add_sdl_test_executable(testyuv NONINTERACTIVE NONINTERACTIVE_ARGS "--automated" NEEDS_RESOURCES TESTUTILS SOURCES testyuv.c testyuv_cvt.c)

+ 61 - 61
test/testcamera.c

@@ -12,7 +12,7 @@
 #include "SDL3/SDL_main.h"
 #include "SDL3/SDL_main.h"
 #include "SDL3/SDL.h"
 #include "SDL3/SDL.h"
 #include "SDL3/SDL_test.h"
 #include "SDL3/SDL_test.h"
-#include "SDL3/SDL_video_capture.h"
+#include "SDL3/SDL_camera.h"
 
 
 #ifdef SDL_PLATFORM_EMSCRIPTEN
 #ifdef SDL_PLATFORM_EMSCRIPTEN
 #include <emscripten/emscripten.h>
 #include <emscripten/emscripten.h>
@@ -25,8 +25,8 @@ static const char *usage = "\
  =========================================================================\n\
  =========================================================================\n\
  \n\
  \n\
 Use keyboards:\n\
 Use keyboards:\n\
- o: open first video capture device. (close previously opened)\n\
- l: switch to, and list video capture devices\n\
+ o: open first camera device. (close previously opened)\n\
+ l: switch to, and list camera devices\n\
  i: information about status (Init, Playing, Stopped)\n\
  i: information about status (Init, Playing, Stopped)\n\
  f: formats and resolutions available\n\
  f: formats and resolutions available\n\
  s: start / stop capture\n\
  s: start / stop capture\n\
@@ -81,10 +81,10 @@ static void load_average(float *val)
 
 
 
 
 struct data_capture_t {
 struct data_capture_t {
-    SDL_VideoCaptureDevice *device;
-    SDL_VideoCaptureSpec obtained;
+    SDL_CameraDevice *device;
+    SDL_CameraSpec obtained;
     int stopped;
     int stopped;
-    SDL_VideoCaptureFrame frame_current;
+    SDL_CameraFrame frame_current;
     measure_fps_t fps_capture;
     measure_fps_t fps_capture;
     SDL_Texture *texture;
     SDL_Texture *texture;
     int texture_updated;
     int texture_updated;
@@ -113,11 +113,11 @@ struct data_capture_t {
 
 
 
 
 
 
-static SDL_VideoCaptureDeviceID get_instance_id(int index) {
+static SDL_CameraDeviceID get_instance_id(int index) {
     int ret = 0;
     int ret = 0;
     int num = 0;
     int num = 0;
-    SDL_VideoCaptureDeviceID *devices;
-    devices = SDL_GetVideoCaptureDevices(&num);
+    SDL_CameraDeviceID *devices;
+    devices = SDL_GetCameraDevices(&num);
     if (devices) {
     if (devices) {
         if (index >= 0 && index < num) {
         if (index >= 0 && index < num) {
             ret = devices[index];
             ret = devices[index];
@@ -155,10 +155,10 @@ int main(int argc, char **argv)
     SDL_FRect r_format = { 50 + (120 + 50) * 3, 50, 120, 50 };
     SDL_FRect r_format = { 50 + (120 + 50) * 3, 50, 120, 50 };
     SDL_FRect r_listdev = { 50 + (120 + 50) * 4, 50, 120, 50 };
     SDL_FRect r_listdev = { 50 + (120 + 50) * 4, 50, 120, 50 };
 
 
-    SDL_VideoCaptureDevice *device;
-    SDL_VideoCaptureSpec obtained;
+    SDL_CameraDevice *device;
+    SDL_CameraSpec obtained;
     int stopped = 0;
     int stopped = 0;
-    SDL_VideoCaptureFrame frame_current;
+    SDL_CameraFrame frame_current;
     measure_fps_t fps_capture;
     measure_fps_t fps_capture;
     SDL_Texture *texture = NULL;
     SDL_Texture *texture = NULL;
     int texture_updated = 0;
     int texture_updated = 0;
@@ -234,24 +234,24 @@ int main(int argc, char **argv)
 
 
     SDL_LogSetAllPriority(SDL_LOG_PRIORITY_INFO);
     SDL_LogSetAllPriority(SDL_LOG_PRIORITY_INFO);
 
 
-    device = SDL_OpenVideoCapture(0);
+    device = SDL_OpenCamera(0);
 
 
     if (!device) {
     if (!device) {
-        SDL_Log("Error SDL_OpenVideoCapture: %s", SDL_GetError());
+        SDL_Log("Error SDL_OpenCamera: %s", SDL_GetError());
     }
     }
 
 
     {
     {
         /* List formats */
         /* List formats */
-        int i, num = SDL_GetNumVideoCaptureFormats(device);
+        int i, num = SDL_GetNumCameraFormats(device);
         for (i = 0; i < num; i++) {
         for (i = 0; i < num; i++) {
             Uint32 format;
             Uint32 format;
-            SDL_GetVideoCaptureFormat(device, i, &format);
+            SDL_GetCameraFormat(device, i, &format);
             SDL_Log("format %d/%d: %s", i, num, SDL_GetPixelFormatName(format));
             SDL_Log("format %d/%d: %s", i, num, SDL_GetPixelFormatName(format));
             {
             {
                 int w, h;
                 int w, h;
-                int j, num2 = SDL_GetNumVideoCaptureFrameSizes(device, format);
+                int j, num2 = SDL_GetNumCameraFrameSizes(device, format);
                 for (j = 0; j < num2; j++) {
                 for (j = 0; j < num2; j++) {
-                    SDL_GetVideoCaptureFrameSize(device, format, j, &w, &h);
+                    SDL_GetCameraFrameSize(device, format, j, &w, &h);
                     SDL_Log("  framesizes %d/%d :  %d x %d", j, num2, w, h);
                     SDL_Log("  framesizes %d/%d :  %d x %d", j, num2, w, h);
                 }
                 }
             }
             }
@@ -262,24 +262,24 @@ int main(int argc, char **argv)
     {
     {
         int ret;
         int ret;
         /* forced_format */
         /* forced_format */
-        SDL_VideoCaptureSpec desired;
+        SDL_CameraSpec desired;
         SDL_zero(desired);
         SDL_zero(desired);
         desired.width = 640 * 2;
         desired.width = 640 * 2;
         desired.height = 360 * 2;
         desired.height = 360 * 2;
         desired.format = SDL_PIXELFORMAT_NV12;
         desired.format = SDL_PIXELFORMAT_NV12;
-        ret = SDL_SetVideoCaptureSpec(device, &desired, &obtained, SDL_VIDEO_CAPTURE_ALLOW_ANY_CHANGE);
+        ret = SDL_SetCameraSpec(device, &desired, &obtained, SDL_CAMERA_ALLOW_ANY_CHANGE);
 
 
         if (ret < 0) {
         if (ret < 0) {
-            SDL_SetVideoCaptureSpec(device, NULL, &obtained, 0);
+            SDL_SetCameraSpec(device, NULL, &obtained, 0);
         }
         }
     }
     }
 
 
-    SDL_Log("Open capture video device. Obtained spec: size=%d x %d format=%s",
+    SDL_Log("Open camera device. Obtained spec: size=%d x %d format=%s",
             obtained.width, obtained.height, SDL_GetPixelFormatName(obtained.format));
             obtained.width, obtained.height, SDL_GetPixelFormatName(obtained.format));
 
 
     {
     {
-        SDL_VideoCaptureSpec spec;
-        if (SDL_GetVideoCaptureSpec(device, &spec) == 0) {
+        SDL_CameraSpec spec;
+        if (SDL_GetCameraSpec(device, &spec) == 0) {
             SDL_Log("Read spec: size=%d x %d format=%s",
             SDL_Log("Read spec: size=%d x %d format=%s",
                     spec.width, spec.height, SDL_GetPixelFormatName(spec.format));
                     spec.width, spec.height, SDL_GetPixelFormatName(spec.format));
         } else {
         } else {
@@ -287,8 +287,8 @@ int main(int argc, char **argv)
         }
         }
     }
     }
 
 
-    if (SDL_StartVideoCapture(device) < 0) {
-        SDL_Log("error SDL_StartVideoCapture(): %s", SDL_GetError());
+    if (SDL_StartCamera(device) < 0) {
+        SDL_Log("error SDL_StartCamera(): %s", SDL_GetError());
     }
     }
 
 
     while (!quit) {
     while (!quit) {
@@ -389,9 +389,9 @@ int main(int argc, char **argv)
 
 
             if (sym == SDLK_c) {
             if (sym == SDLK_c) {
                 if (frame_current.num_planes) {
                 if (frame_current.num_planes) {
-                    SDL_ReleaseVideoCaptureFrame(device, &frame_current);
+                    SDL_ReleaseCameraFrame(device, &frame_current);
                 }
                 }
-                SDL_CloseVideoCapture(device);
+                SDL_CloseCamera(device);
                 device = NULL;
                 device = NULL;
                 SDL_Log("Close");
                 SDL_Log("Close");
             }
             }
@@ -400,20 +400,20 @@ int main(int argc, char **argv)
                 if (device) {
                 if (device) {
                     SDL_Log("Close previous ..");
                     SDL_Log("Close previous ..");
                     if (frame_current.num_planes) {
                     if (frame_current.num_planes) {
-                        SDL_ReleaseVideoCaptureFrame(device, &frame_current);
+                        SDL_ReleaseCameraFrame(device, &frame_current);
                     }
                     }
-                    SDL_CloseVideoCapture(device);
+                    SDL_CloseCamera(device);
                 }
                 }
 
 
                 texture_updated = 0;
                 texture_updated = 0;
 
 
                 SDL_ClearError();
                 SDL_ClearError();
 
 
-                SDL_Log("Try to open:%s", SDL_GetVideoCaptureDeviceName(get_instance_id(current_dev)));
+                SDL_Log("Try to open:%s", SDL_GetCameraDeviceName(get_instance_id(current_dev)));
 
 
                 obtained.width = 640 * 2;
                 obtained.width = 640 * 2;
                 obtained.height = 360 * 2;
                 obtained.height = 360 * 2;
-                device = SDL_OpenVideoCaptureWithSpec(get_instance_id(current_dev), &obtained, &obtained, SDL_VIDEO_CAPTURE_ALLOW_ANY_CHANGE);
+                device = SDL_OpenCameraWithSpec(get_instance_id(current_dev), &obtained, &obtained, SDL_CAMERA_ALLOW_ANY_CHANGE);
 
 
                 /* spec may have changed because of re-open */
                 /* spec may have changed because of re-open */
                 if (texture) {
                 if (texture) {
@@ -427,13 +427,13 @@ int main(int argc, char **argv)
 
 
             if (sym == SDLK_l) {
             if (sym == SDLK_l) {
                 int num = 0;
                 int num = 0;
-                SDL_VideoCaptureDeviceID *devices;
+                SDL_CameraDeviceID *devices;
                 int i;
                 int i;
-                devices = SDL_GetVideoCaptureDevices(&num);
+                devices = SDL_GetCameraDevices(&num);
 
 
                 SDL_Log("Num devices : %d", num);
                 SDL_Log("Num devices : %d", num);
                 for (i = 0; i < num; i++) {
                 for (i = 0; i < num; i++) {
-                    SDL_Log("Device %d/%d : %s", i, num, SDL_GetVideoCaptureDeviceName(devices[i]));
+                    SDL_Log("Device %d/%d : %s", i, num, SDL_GetCameraDeviceName(devices[i]));
                 }
                 }
                 SDL_free(devices);
                 SDL_free(devices);
 
 
@@ -449,19 +449,19 @@ int main(int argc, char **argv)
             }
             }
 
 
             if (sym == SDLK_i) {
             if (sym == SDLK_i) {
-                SDL_VideoCaptureStatus status = SDL_GetVideoCaptureStatus(device);
-                if (status == SDL_VIDEO_CAPTURE_STOPPED) { SDL_Log("STOPPED"); }
-                if (status == SDL_VIDEO_CAPTURE_PLAYING) { SDL_Log("PLAYING"); }
-                if (status == SDL_VIDEO_CAPTURE_INIT) { SDL_Log("INIT"); }
+                SDL_CameraStatus status = SDL_GetCameraStatus(device);
+                if (status == SDL_CAMERA_STOPPED) { SDL_Log("STOPPED"); }
+                if (status == SDL_CAMERA_PLAYING) { SDL_Log("PLAYING"); }
+                if (status == SDL_CAMERA_INIT) { SDL_Log("INIT"); }
             }
             }
 
 
             if (sym == SDLK_s) {
             if (sym == SDLK_s) {
                 if (stopped) {
                 if (stopped) {
                     SDL_Log("Stop");
                     SDL_Log("Stop");
-                    SDL_StopVideoCapture(device);
+                    SDL_StopCamera(device);
                 } else {
                 } else {
                     SDL_Log("Start");
                     SDL_Log("Start");
-                    SDL_StartVideoCapture(device);
+                    SDL_StartCamera(device);
                 }
                 }
                 stopped = !stopped;
                 stopped = !stopped;
             }
             }
@@ -470,21 +470,21 @@ int main(int argc, char **argv)
                 SDL_Log("List formats");
                 SDL_Log("List formats");
 
 
                 if (!device) {
                 if (!device) {
-                    device = SDL_OpenVideoCapture(get_instance_id(current_dev));
+                    device = SDL_OpenCamera(get_instance_id(current_dev));
                 }
                 }
 
 
                 /* List formats */
                 /* List formats */
                 {
                 {
-                    int i, num = SDL_GetNumVideoCaptureFormats(device);
+                    int i, num = SDL_GetNumCameraFormats(device);
                     for (i = 0; i < num; i++) {
                     for (i = 0; i < num; i++) {
                         Uint32 format;
                         Uint32 format;
-                        SDL_GetVideoCaptureFormat(device, i, &format);
+                        SDL_GetCameraFormat(device, i, &format);
                         SDL_Log("format %d/%d : %s", i, num, SDL_GetPixelFormatName(format));
                         SDL_Log("format %d/%d : %s", i, num, SDL_GetPixelFormatName(format));
                         {
                         {
                             int w, h;
                             int w, h;
-                            int j, num2 = SDL_GetNumVideoCaptureFrameSizes(device, format);
+                            int j, num2 = SDL_GetNumCameraFrameSizes(device, format);
                             for (j = 0; j < num2; j++) {
                             for (j = 0; j < num2; j++) {
-                                SDL_GetVideoCaptureFrameSize(device, format, j, &w, &h);
+                                SDL_GetCameraFrameSize(device, format, j, &w, &h);
                                 SDL_Log("  framesizes %d/%d :  %d x %d", j, num2, w, h);
                                 SDL_Log("  framesizes %d/%d :  %d x %d", j, num2, w, h);
                             }
                             }
                         }
                         }
@@ -515,12 +515,12 @@ int main(int argc, char **argv)
                     texture_updated = 0;
                     texture_updated = 0;
                 } else {
                 } else {
                     int ret;
                     int ret;
-                    SDL_VideoCaptureFrame frame_next;
+                    SDL_CameraFrame frame_next;
                     SDL_zero(frame_next);
                     SDL_zero(frame_next);
 
 
-                    ret = SDL_AcquireVideoCaptureFrame(device, &frame_next);
+                    ret = SDL_AcquireCameraFrame(device, &frame_next);
                     if (ret < 0) {
                     if (ret < 0) {
-                        SDL_Log("dev[%d] err SDL_AcquireVideoCaptureFrame: %s", i, SDL_GetError());
+                        SDL_Log("dev[%d] err SDL_AcquireCameraFrame: %s", i, SDL_GetError());
                     }
                     }
 #if 1
 #if 1
                     if (frame_next.num_planes) {
                     if (frame_next.num_planes) {
@@ -533,9 +533,9 @@ int main(int argc, char **argv)
                         update_fps(&fps_capture);
                         update_fps(&fps_capture);
 
 
                         if (frame_current.num_planes) {
                         if (frame_current.num_planes) {
-                            ret = SDL_ReleaseVideoCaptureFrame(device, &frame_current);
+                            ret = SDL_ReleaseCameraFrame(device, &frame_current);
                             if (ret < 0) {
                             if (ret < 0) {
-                                SDL_Log("dev[%d] err SDL_ReleaseVideoCaptureFrame: %s", i, SDL_GetError());
+                                SDL_Log("dev[%d] err SDL_ReleaseCameraFrame: %s", i, SDL_GetError());
                             }
                             }
                         }
                         }
                         frame_current = frame_next;
                         frame_current = frame_next;
@@ -670,7 +670,7 @@ int main(int argc, char **argv)
             const float x_offset = 0;
             const float x_offset = 0;
 #endif
 #endif
             char buf[256];
             char buf[256];
-            SDL_snprintf(buf, 256, "Device %d (%s) is not opened", current_dev, SDL_GetVideoCaptureDeviceName(get_instance_id(current_dev)));
+            SDL_snprintf(buf, 256, "Device %d (%s) is not opened", current_dev, SDL_GetCameraDeviceName(get_instance_id(current_dev)));
             SDLTest_DrawString(renderer, x_offset + 10, 10, buf);
             SDLTest_DrawString(renderer, x_offset + 10, 10, buf);
         } else {
         } else {
 #ifdef SDL_PLATFORM_IOS
 #ifdef SDL_PLATFORM_IOS
@@ -682,14 +682,14 @@ int main(int argc, char **argv)
             char buf[256];
             char buf[256];
 
 
             if (device) {
             if (device) {
-                SDL_VideoCaptureStatus s = SDL_GetVideoCaptureStatus(device);
-                if (s == SDL_VIDEO_CAPTURE_INIT) {
+                SDL_CameraStatus s = SDL_GetCameraStatus(device);
+                if (s == SDL_CAMERA_INIT) {
                     status = "init";
                     status = "init";
-                } else if (s == SDL_VIDEO_CAPTURE_PLAYING) {
+                } else if (s == SDL_CAMERA_PLAYING) {
                     status = "playing";
                     status = "playing";
-                } else if (s == SDL_VIDEO_CAPTURE_STOPPED) {
+                } else if (s == SDL_CAMERA_STOPPED) {
                     status = "stopped";
                     status = "stopped";
-                } else if (s == SDL_VIDEO_CAPTURE_FAIL) {
+                } else if (s == SDL_CAMERA_FAIL) {
                     status = "failed";
                     status = "failed";
                 }
                 }
 
 
@@ -745,13 +745,13 @@ int main(int argc, char **argv)
             RESTORE_CAPTURE_STATE(i);
             RESTORE_CAPTURE_STATE(i);
 
 
             if (device) {
             if (device) {
-                if (SDL_StopVideoCapture(device) < 0) {
-                    SDL_Log("error SDL_StopVideoCapture(): %s", SDL_GetError());
+                if (SDL_StopCamera(device) < 0) {
+                    SDL_Log("error SDL_StopCamera(): %s", SDL_GetError());
                 }
                 }
                 if (frame_current.num_planes) {
                 if (frame_current.num_planes) {
-                    SDL_ReleaseVideoCaptureFrame(device, &frame_current);
+                    SDL_ReleaseCameraFrame(device, &frame_current);
                 }
                 }
-                SDL_CloseVideoCapture(device);
+                SDL_CloseCamera(device);
             }
             }
 
 
             if (texture) {
             if (texture) {

+ 16 - 16
test/testcameraminimal.c

@@ -28,10 +28,10 @@ int main(int argc, char **argv)
     int quit = 0;
     int quit = 0;
     SDLTest_CommonState  *state = NULL;
     SDLTest_CommonState  *state = NULL;
 
 
-    SDL_VideoCaptureDevice *device = NULL;
-    SDL_VideoCaptureSpec obtained;
+    SDL_CameraDevice *device = NULL;
+    SDL_CameraSpec obtained;
 
 
-    SDL_VideoCaptureFrame frame_current;
+    SDL_CameraFrame frame_current;
     SDL_Texture *texture = NULL;
     SDL_Texture *texture = NULL;
     int texture_updated = 0;
     int texture_updated = 0;
 
 
@@ -73,14 +73,14 @@ int main(int argc, char **argv)
         return 1;
         return 1;
     }
     }
 
 
-    device = SDL_OpenVideoCaptureWithSpec(0, NULL, &obtained, SDL_VIDEO_CAPTURE_ALLOW_ANY_CHANGE);
+    device = SDL_OpenCameraWithSpec(0, NULL, &obtained, SDL_CAMERA_ALLOW_ANY_CHANGE);
     if (!device) {
     if (!device) {
-        SDL_Log("No video capture? %s", SDL_GetError());
+        SDL_Log("No camera? %s", SDL_GetError());
         return 1;
         return 1;
     }
     }
 
 
-    if (SDL_StartVideoCapture(device) < 0) {
-        SDL_Log("error SDL_StartVideoCapture(): %s", SDL_GetError());
+    if (SDL_StartCamera(device) < 0) {
+        SDL_Log("error SDL_StartCamera(): %s", SDL_GetError());
         return 1;
         return 1;
     }
     }
 
 
@@ -118,11 +118,11 @@ int main(int argc, char **argv)
         }
         }
 
 
         {
         {
-            SDL_VideoCaptureFrame frame_next;
+            SDL_CameraFrame frame_next;
             SDL_zero(frame_next);
             SDL_zero(frame_next);
 
 
-            if (SDL_AcquireVideoCaptureFrame(device, &frame_next) < 0) {
-                SDL_Log("err SDL_AcquireVideoCaptureFrame: %s", SDL_GetError());
+            if (SDL_AcquireCameraFrame(device, &frame_next) < 0) {
+                SDL_Log("err SDL_AcquireCameraFrame: %s", SDL_GetError());
             }
             }
 #if 0
 #if 0
             if (frame_next.num_planes) {
             if (frame_next.num_planes) {
@@ -132,8 +132,8 @@ int main(int argc, char **argv)
 
 
             if (frame_next.num_planes) {
             if (frame_next.num_planes) {
                 if (frame_current.num_planes) {
                 if (frame_current.num_planes) {
-                    if (SDL_ReleaseVideoCaptureFrame(device, &frame_current) < 0) {
-                        SDL_Log("err SDL_ReleaseVideoCaptureFrame: %s", SDL_GetError());
+                    if (SDL_ReleaseCameraFrame(device, &frame_current) < 0) {
+                        SDL_Log("err SDL_ReleaseCameraFrame: %s", SDL_GetError());
                     }
                     }
                 }
                 }
 
 
@@ -186,13 +186,13 @@ int main(int argc, char **argv)
         SDL_RenderPresent(renderer);
         SDL_RenderPresent(renderer);
     }
     }
 
 
-    if (SDL_StopVideoCapture(device) < 0) {
-        SDL_Log("error SDL_StopVideoCapture(): %s", SDL_GetError());
+    if (SDL_StopCamera(device) < 0) {
+        SDL_Log("error SDL_StopCamera(): %s", SDL_GetError());
     }
     }
     if (frame_current.num_planes) {
     if (frame_current.num_planes) {
-        SDL_ReleaseVideoCaptureFrame(device, &frame_current);
+        SDL_ReleaseCameraFrame(device, &frame_current);
     }
     }
-    SDL_CloseVideoCapture(device);
+    SDL_CloseCamera(device);
 
 
     if (texture) {
     if (texture) {
         SDL_DestroyTexture(texture);
         SDL_DestroyTexture(texture);