Browse Source

Renamed CameraDevice to Camera

This is consistent with the rest of the SDL API
Sam Lantinga 9 months ago
parent
commit
9797c5d0c0

+ 20 - 20
include/SDL3/SDL_camera.h

@@ -53,9 +53,9 @@ extern "C" {
  *
  * \since This datatype is available since SDL 3.0.0.
  *
- * \sa SDL_GetCameraDevices
+ * \sa SDL_GetCameras
  */
-typedef Uint32 SDL_CameraDeviceID;
+typedef Uint32 SDL_CameraID;
 
 /**
  * The opaque structure used to identify an opened SDL camera.
@@ -72,7 +72,7 @@ typedef struct SDL_Camera SDL_Camera;
  *
  * \since This struct is available since SDL 3.0.0.
  *
- * \sa SDL_GetCameraDeviceSupportedFormats
+ * \sa SDL_GetCameraSupportedFormats
  * \sa SDL_GetCameraFormat
  */
 typedef struct SDL_CameraSpec
@@ -90,7 +90,7 @@ typedef struct SDL_CameraSpec
  *
  * \since This enum is available since SDL 3.0.0.
  *
- * \sa SDL_GetCameraDevicePosition
+ * \sa SDL_GetCameraPosition
  */
 typedef enum SDL_CameraPosition
 {
@@ -182,7 +182,7 @@ extern SDL_DECLSPEC const char *SDLCALL SDL_GetCurrentCameraDriver(void);
  *
  * \sa SDL_OpenCamera
  */
-extern SDL_DECLSPEC SDL_CameraDeviceID *SDLCALL SDL_GetCameraDevices(int *count);
+extern SDL_DECLSPEC SDL_CameraID *SDLCALL SDL_GetCameras(int *count);
 
 /**
  * Get the list of native formats/sizes a camera supports.
@@ -192,7 +192,7 @@ extern SDL_DECLSPEC SDL_CameraDeviceID *SDLCALL SDL_GetCameraDevices(int *count)
  * and sizes and so want to find the optimal spec that doesn't require
  * conversion.
  *
- * This function isn't strictly required; if you call SDL_OpenCameraDevice
+ * This function isn't strictly required; if you call SDL_OpenCamera
  * with a NULL spec, SDL will choose a native format for you, and if you
  * instead specify a desired format, it will transparently convert to the
  * requested format on your behalf.
@@ -222,10 +222,10 @@ extern SDL_DECLSPEC SDL_CameraDeviceID *SDLCALL SDL_GetCameraDevices(int *count)
  *
  * \since This function is available since SDL 3.0.0.
  *
- * \sa SDL_GetCameraDevices
- * \sa SDL_OpenCameraDevice
+ * \sa SDL_GetCameras
+ * \sa SDL_OpenCamera
  */
-extern SDL_DECLSPEC SDL_CameraSpec *SDLCALL SDL_GetCameraDeviceSupportedFormats(SDL_CameraDeviceID devid, int *count);
+extern SDL_DECLSPEC SDL_CameraSpec *SDLCALL SDL_GetCameraSupportedFormats(SDL_CameraID devid, int *count);
 
 /**
  * Get the human-readable device name for a camera.
@@ -240,9 +240,9 @@ extern SDL_DECLSPEC SDL_CameraSpec *SDLCALL SDL_GetCameraDeviceSupportedFormats(
  *
  * \since This function is available since SDL 3.0.0.
  *
- * \sa SDL_GetCameraDevices
+ * \sa SDL_GetCameras
  */
-extern SDL_DECLSPEC const char * SDLCALL SDL_GetCameraDeviceName(SDL_CameraDeviceID instance_id);
+extern SDL_DECLSPEC const char * SDLCALL SDL_GetCameraName(SDL_CameraID instance_id);
 
 /**
  * Get the position of the camera in relation to the system.
@@ -259,9 +259,9 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetCameraDeviceName(SDL_CameraDevic
  *
  * \since This function is available since SDL 3.0.0.
  *
- * \sa SDL_GetCameraDevices
+ * \sa SDL_GetCameras
  */
-extern SDL_DECLSPEC SDL_CameraPosition SDLCALL SDL_GetCameraDevicePosition(SDL_CameraDeviceID instance_id);
+extern SDL_DECLSPEC SDL_CameraPosition SDLCALL SDL_GetCameraPosition(SDL_CameraID instance_id);
 
 /**
  * Open a video recording device (a "camera").
@@ -304,10 +304,10 @@ extern SDL_DECLSPEC SDL_CameraPosition SDLCALL SDL_GetCameraDevicePosition(SDL_C
  *
  * \since This function is available since SDL 3.0.0.
  *
- * \sa SDL_GetCameraDevices
+ * \sa SDL_GetCameras
  * \sa SDL_GetCameraFormat
  */
-extern SDL_DECLSPEC SDL_Camera *SDLCALL SDL_OpenCameraDevice(SDL_CameraDeviceID instance_id, const SDL_CameraSpec *spec);
+extern SDL_DECLSPEC SDL_Camera *SDLCALL SDL_OpenCamera(SDL_CameraID instance_id, const SDL_CameraSpec *spec);
 
 /**
  * Query if camera access has been approved by the user.
@@ -337,7 +337,7 @@ extern SDL_DECLSPEC SDL_Camera *SDLCALL SDL_OpenCameraDevice(SDL_CameraDeviceID
  *
  * \since This function is available since SDL 3.0.0.
  *
- * \sa SDL_OpenCameraDevice
+ * \sa SDL_OpenCamera
  * \sa SDL_CloseCamera
  */
 extern SDL_DECLSPEC int SDLCALL SDL_GetCameraPermissionState(SDL_Camera *camera);
@@ -353,14 +353,14 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetCameraPermissionState(SDL_Camera *camera)
  *
  * \since This function is available since SDL 3.0.0.
  *
- * \sa SDL_OpenCameraDevice
+ * \sa SDL_OpenCamera
  */
-extern SDL_DECLSPEC SDL_CameraDeviceID SDLCALL SDL_GetCameraInstanceID(SDL_Camera *camera);
+extern SDL_DECLSPEC SDL_CameraID SDLCALL SDL_GetCameraID(SDL_Camera *camera);
 
 /**
  * Get the properties associated with an opened camera.
  *
- * \param camera the SDL_Camera obtained from SDL_OpenCameraDevice().
+ * \param camera the SDL_Camera obtained from SDL_OpenCamera().
  * \returns a valid property ID on success or 0 on failure; call
  *          SDL_GetError() for more information.
  *
@@ -391,7 +391,7 @@ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetCameraProperties(SDL_Camera
  *
  * \since This function is available since SDL 3.0.0.
  *
- * \sa SDL_OpenCameraDevice
+ * \sa SDL_OpenCamera
  */
 extern SDL_DECLSPEC int SDLCALL SDL_GetCameraFormat(SDL_Camera *camera, SDL_CameraSpec *spec);
 

+ 1 - 1
include/SDL3/SDL_events.h

@@ -695,7 +695,7 @@ typedef struct SDL_CameraDeviceEvent
     SDL_EventType type; /**< SDL_EVENT_CAMERA_DEVICE_ADDED, SDL_EVENT_CAMERA_DEVICE_REMOVED, SDL_EVENT_CAMERA_DEVICE_APPROVED, SDL_EVENT_CAMERA_DEVICE_DENIED */
     Uint32 reserved;
     Uint64 timestamp;   /**< In nanoseconds, populated using SDL_GetTicksNS() */
-    SDL_CameraDeviceID which;       /**< SDL_CameraDeviceID for the device being added or removed or changing */
+    SDL_CameraID which;       /**< SDL_CameraID for the device being added or removed or changing */
 } SDL_CameraDeviceEvent;
 
 /**

+ 105 - 105
src/camera/SDL_camera.c

@@ -78,7 +78,7 @@ const char *SDL_GetCurrentCameraDriver(void)
     return camera_driver.name;
 }
 
-char *SDL_GetCameraThreadName(SDL_CameraDevice *device, char *buf, size_t buflen)
+char *SDL_GetCameraThreadName(SDL_Camera *device, char *buf, size_t buflen)
 {
     (void)SDL_snprintf(buf, buflen, "SDLCamera%d", (int) device->instance_id);
     return buf;
@@ -115,7 +115,7 @@ int SDL_AddCameraFormat(CameraFormatAddData *data, SDL_PixelFormat format, SDL_C
 
 // These get used when a device is disconnected or fails. Apps that ignore the
 //  loss notifications will get black frames but otherwise keep functioning.
-static int ZombieWaitDevice(SDL_CameraDevice *device)
+static int ZombieWaitDevice(SDL_Camera *device)
 {
     if (!SDL_AtomicGet(&device->shutdown)) {
         // !!! FIXME: this is bad for several reasons (uses double, could be precalculated, doesn't track elasped time).
@@ -147,7 +147,7 @@ static size_t GetFrameBufLen(const SDL_CameraSpec *spec)
     return wxh * SDL_BYTESPERPIXEL(fmt);
 }
 
-static int ZombieAcquireFrame(SDL_CameraDevice *device, SDL_Surface *frame, Uint64 *timestampNS)
+static int ZombieAcquireFrame(SDL_Camera *device, SDL_Surface *frame, Uint64 *timestampNS)
 {
     const SDL_CameraSpec *spec = &device->actual_spec;
 
@@ -217,7 +217,7 @@ static int ZombieAcquireFrame(SDL_CameraDevice *device, SDL_Surface *frame, Uint
     return 1;  // frame is available.
 }
 
-static void ZombieReleaseFrame(SDL_CameraDevice *device, SDL_Surface *frame) // Reclaim frame->pixels and frame->pitch!
+static void ZombieReleaseFrame(SDL_Camera *device, SDL_Surface *frame) // Reclaim frame->pixels and frame->pitch!
 {
     if (frame->pixels != device->zombie_pixels) {
         // this was a frame from before the disconnect event; let the backend make an attempt to free it.
@@ -226,7 +226,7 @@ static void ZombieReleaseFrame(SDL_CameraDevice *device, SDL_Surface *frame) //
     // we just leave zombie_pixels alone, as we'll reuse it for every new frame until the camera is closed.
 }
 
-static void ClosePhysicalCameraDevice(SDL_CameraDevice *device)
+static void ClosePhysicalCamera(SDL_Camera *device)
 {
     if (!device) {
         return;
@@ -278,22 +278,22 @@ static void ClosePhysicalCameraDevice(SDL_CameraDevice *device)
 }
 
 // this must not be called while `device` is still in a device list, or while a device's camera thread is still running.
-static void DestroyPhysicalCameraDevice(SDL_CameraDevice *device)
+static void DestroyPhysicalCamera(SDL_Camera *device)
 {
     if (device) {
         // Destroy any logical devices that still exist...
-        ClosePhysicalCameraDevice(device);
+        ClosePhysicalCamera(device);
         camera_driver.impl.FreeDeviceHandle(device);
         SDL_DestroyMutex(device->lock);
         SDL_free(device->all_specs);
-        SDL_FreeLater(device->name);  // this is returned in SDL_GetCameraDeviceName.
+        SDL_FreeLater(device->name);  // this is returned in SDL_GetCameraName.
         SDL_free(device);
     }
 }
 
 
 // Don't hold the device lock when calling this, as we may destroy the device!
-void UnrefPhysicalCameraDevice(SDL_CameraDevice *device)
+void UnrefPhysicalCamera(SDL_Camera *device)
 {
     if (SDL_AtomicDecRef(&device->refcount)) {
         // take it out of the device list.
@@ -302,47 +302,47 @@ void UnrefPhysicalCameraDevice(SDL_CameraDevice *device)
             SDL_AtomicAdd(&camera_driver.device_count, -1);
         }
         SDL_UnlockRWLock(camera_driver.device_hash_lock);
-        DestroyPhysicalCameraDevice(device);  // ...and nuke it.
+        DestroyPhysicalCamera(device);  // ...and nuke it.
     }
 }
 
-void RefPhysicalCameraDevice(SDL_CameraDevice *device)
+void RefPhysicalCamera(SDL_Camera *device)
 {
     SDL_AtomicIncRef(&device->refcount);
 }
 
-static void ObtainPhysicalCameraDeviceObj(SDL_CameraDevice *device) SDL_NO_THREAD_SAFETY_ANALYSIS  // !!! FIXMEL SDL_ACQUIRE
+static void ObtainPhysicalCameraObj(SDL_Camera *device) SDL_NO_THREAD_SAFETY_ANALYSIS  // !!! FIXMEL SDL_ACQUIRE
 {
     if (device) {
-        RefPhysicalCameraDevice(device);
+        RefPhysicalCamera(device);
         SDL_LockMutex(device->lock);
     }
 }
 
-static SDL_CameraDevice *ObtainPhysicalCameraDevice(SDL_CameraDeviceID devid)  // !!! FIXME: SDL_ACQUIRE
+static SDL_Camera *ObtainPhysicalCamera(SDL_CameraID devid)  // !!! FIXME: SDL_ACQUIRE
 {
     if (!SDL_GetCurrentCameraDriver()) {
         SDL_SetError("Camera subsystem is not initialized");
         return NULL;
     }
 
-    SDL_CameraDevice *device = NULL;
+    SDL_Camera *device = NULL;
     SDL_LockRWLockForReading(camera_driver.device_hash_lock);
     SDL_FindInHashTable(camera_driver.device_hash, (const void *) (uintptr_t) devid, (const void **) &device);
     SDL_UnlockRWLock(camera_driver.device_hash_lock);
     if (!device) {
         SDL_SetError("Invalid camera device instance ID");
     } else {
-        ObtainPhysicalCameraDeviceObj(device);
+        ObtainPhysicalCameraObj(device);
     }
     return device;
 }
 
-static void ReleaseCameraDevice(SDL_CameraDevice *device) SDL_NO_THREAD_SAFETY_ANALYSIS  // !!! FIXME: SDL_RELEASE
+static void ReleaseCamera(SDL_Camera *device) SDL_NO_THREAD_SAFETY_ANALYSIS  // !!! FIXME: SDL_RELEASE
 {
     if (device) {
         SDL_UnlockMutex(device->lock);
-        UnrefPhysicalCameraDevice(device);
+        UnrefPhysicalCamera(device);
     }
 }
 
@@ -415,7 +415,7 @@ static int SDLCALL CameraSpecCmp(const void *vpa, const void *vpb)
 }
 
 // The camera backends call this when a new device is plugged in.
-SDL_CameraDevice *SDL_AddCameraDevice(const char *name, SDL_CameraPosition position, int num_specs, const SDL_CameraSpec *specs, void *handle)
+SDL_Camera *SDL_AddCamera(const char *name, SDL_CameraPosition position, int num_specs, const SDL_CameraSpec *specs, void *handle)
 {
     SDL_assert(name != NULL);
     SDL_assert(num_specs >= 0);
@@ -429,7 +429,7 @@ SDL_CameraDevice *SDL_AddCameraDevice(const char *name, SDL_CameraPosition posit
         return NULL;  // we're shutting down, don't add any devices that are hotplugged at the last possible moment.
     }
 
-    SDL_CameraDevice *device = (SDL_CameraDevice *)SDL_calloc(1, sizeof(SDL_CameraDevice));
+    SDL_Camera *device = (SDL_Camera *)SDL_calloc(1, sizeof(SDL_Camera));
     if (!device) {
         return NULL;
     }
@@ -492,7 +492,7 @@ SDL_CameraDevice *SDL_AddCameraDevice(const char *name, SDL_CameraPosition posit
     device->instance_id = SDL_GetNextObjectID();
     SDL_AtomicSet(&device->shutdown, 0);
     SDL_AtomicSet(&device->zombie, 0);
-    RefPhysicalCameraDevice(device);
+    RefPhysicalCamera(device);
 
     SDL_LockRWLockForWriting(camera_driver.device_hash_lock);
     if (SDL_InsertIntoHashTable(camera_driver.device_hash, (const void *) (uintptr_t) device->instance_id, device)) {
@@ -507,7 +507,7 @@ SDL_CameraDevice *SDL_AddCameraDevice(const char *name, SDL_CameraPosition posit
 
     // Add a device add event to the pending list, to be pushed when the event queue is pumped (away from any of our internal threads).
     if (device) {
-        SDL_PendingCameraDeviceEvent *p = (SDL_PendingCameraDeviceEvent *) SDL_malloc(sizeof (SDL_PendingCameraDeviceEvent));
+        SDL_PendingCameraEvent *p = (SDL_PendingCameraEvent *) SDL_malloc(sizeof (SDL_PendingCameraEvent));
         if (p) {  // if allocation fails, you won't get an event, but we can't help that.
             p->type = SDL_EVENT_CAMERA_DEVICE_ADDED;
             p->devid = device->instance_id;
@@ -524,7 +524,7 @@ SDL_CameraDevice *SDL_AddCameraDevice(const char *name, SDL_CameraPosition posit
 }
 
 // Called when a device is removed from the system, or it fails unexpectedly, from any thread, possibly even the camera device's thread.
-void SDL_CameraDeviceDisconnected(SDL_CameraDevice *device)
+void SDL_CameraDisconnected(SDL_Camera *device)
 {
     if (!device) {
         return;
@@ -538,11 +538,11 @@ void SDL_CameraDeviceDisconnected(SDL_CameraDevice *device)
     //  time the event queue pumps, in case something tries to close a device
     //  from an event filter, as this would risk deadlocks and other disasters
     //  if done from the device thread.
-    SDL_PendingCameraDeviceEvent pending;
+    SDL_PendingCameraEvent pending;
     pending.next = NULL;
-    SDL_PendingCameraDeviceEvent *pending_tail = &pending;
+    SDL_PendingCameraEvent *pending_tail = &pending;
 
-    ObtainPhysicalCameraDeviceObj(device);
+    ObtainPhysicalCameraObj(device);
 
     const SDL_bool first_disconnect = SDL_AtomicCompareAndSwap(&device->zombie, 0, 1);
     if (first_disconnect) {   // if already disconnected this device, don't do it twice.
@@ -558,7 +558,7 @@ void SDL_CameraDeviceDisconnected(SDL_CameraDevice *device)
         device->adjust_timestamp = 0;
         device->base_timestamp = 0;
 
-        SDL_PendingCameraDeviceEvent *p = (SDL_PendingCameraDeviceEvent *) SDL_malloc(sizeof (SDL_PendingCameraDeviceEvent));
+        SDL_PendingCameraEvent *p = (SDL_PendingCameraEvent *) SDL_malloc(sizeof (SDL_PendingCameraEvent));
         if (p) {  // if this failed, no event for you, but you have deeper problems anyhow.
             p->type = SDL_EVENT_CAMERA_DEVICE_REMOVED;
             p->devid = device->instance_id;
@@ -568,7 +568,7 @@ void SDL_CameraDeviceDisconnected(SDL_CameraDevice *device)
         }
     }
 
-    ReleaseCameraDevice(device);
+    ReleaseCamera(device);
 
     if (first_disconnect) {
         if (pending.next) {  // NULL if event is disabled or disaster struck.
@@ -582,22 +582,22 @@ void SDL_CameraDeviceDisconnected(SDL_CameraDevice *device)
     }
 }
 
-void SDL_CameraDevicePermissionOutcome(SDL_CameraDevice *device, SDL_bool approved)
+void SDL_CameraPermissionOutcome(SDL_Camera *device, SDL_bool approved)
 {
     if (!device) {
         return;
     }
 
-    SDL_PendingCameraDeviceEvent pending;
+    SDL_PendingCameraEvent pending;
     pending.next = NULL;
-    SDL_PendingCameraDeviceEvent *pending_tail = &pending;
+    SDL_PendingCameraEvent *pending_tail = &pending;
 
     const int permission = approved ? 1 : -1;
 
-    ObtainPhysicalCameraDeviceObj(device);
+    ObtainPhysicalCameraObj(device);
     if (device->permission != permission) {
         device->permission = permission;
-        SDL_PendingCameraDeviceEvent *p = (SDL_PendingCameraDeviceEvent *) SDL_malloc(sizeof (SDL_PendingCameraDeviceEvent));
+        SDL_PendingCameraEvent *p = (SDL_PendingCameraEvent *) SDL_malloc(sizeof (SDL_PendingCameraEvent));
         if (p) {  // if this failed, no event for you, but you have deeper problems anyhow.
             p->type = approved ? SDL_EVENT_CAMERA_DEVICE_APPROVED : SDL_EVENT_CAMERA_DEVICE_DENIED;
             p->devid = device->instance_id;
@@ -607,7 +607,7 @@ void SDL_CameraDevicePermissionOutcome(SDL_CameraDevice *device, SDL_bool approv
         }
     }
 
-    ReleaseCameraDevice(device);
+    ReleaseCamera(device);
 
     if (pending.next) {  // NULL if event is disabled or disaster struck.
         SDL_LockRWLockForWriting(camera_driver.device_hash_lock);
@@ -620,7 +620,7 @@ void SDL_CameraDevicePermissionOutcome(SDL_CameraDevice *device, SDL_bool approv
 }
 
 
-SDL_CameraDevice *SDL_FindPhysicalCameraDeviceByCallback(SDL_bool (*callback)(SDL_CameraDevice *device, void *userdata), void *userdata)
+SDL_Camera *SDL_FindPhysicalCameraByCallback(SDL_bool (*callback)(SDL_Camera *device, void *userdata), void *userdata)
 {
     if (!SDL_GetCurrentCameraDriver()) {
         SDL_SetError("Camera subsystem is not initialized");
@@ -633,7 +633,7 @@ SDL_CameraDevice *SDL_FindPhysicalCameraDeviceByCallback(SDL_bool (*callback)(SD
 
     SDL_LockRWLockForReading(camera_driver.device_hash_lock);
     while (SDL_IterateHashTable(camera_driver.device_hash, &key, &value, &iter)) {
-        SDL_CameraDevice *device = (SDL_CameraDevice *) value;
+        SDL_Camera *device = (SDL_Camera *) value;
         if (callback(device, userdata)) {  // found it?
             SDL_UnlockRWLock(camera_driver.device_hash_lock);
             return device;
@@ -648,8 +648,8 @@ SDL_CameraDevice *SDL_FindPhysicalCameraDeviceByCallback(SDL_bool (*callback)(SD
 
 void SDL_CloseCamera(SDL_Camera *camera)
 {
-    SDL_CameraDevice *device = (SDL_CameraDevice *) camera;  // currently there's no separation between physical and logical device.
-    ClosePhysicalCameraDevice(device);
+    SDL_Camera *device = (SDL_Camera *) camera;  // currently there's no separation between physical and logical device.
+    ClosePhysicalCamera(device);
 }
 
 int SDL_GetCameraFormat(SDL_Camera *camera, SDL_CameraSpec *spec)
@@ -660,42 +660,42 @@ int SDL_GetCameraFormat(SDL_Camera *camera, SDL_CameraSpec *spec)
         return SDL_InvalidParamError("spec");
     }
 
-    SDL_CameraDevice *device = (SDL_CameraDevice *) camera;  // currently there's no separation between physical and logical device.
-    ObtainPhysicalCameraDeviceObj(device);
+    SDL_Camera *device = (SDL_Camera *) camera;  // currently there's no separation between physical and logical device.
+    ObtainPhysicalCameraObj(device);
     const int retval = (device->permission > 0) ? 0 : SDL_SetError("Camera permission has not been granted");
     if (retval == 0) {
         SDL_copyp(spec, &device->spec);
     } else {
         SDL_zerop(spec);
     }
-    ReleaseCameraDevice(device);
+    ReleaseCamera(device);
     return 0;
 }
 
-const char *SDL_GetCameraDeviceName(SDL_CameraDeviceID instance_id)
+const char *SDL_GetCameraName(SDL_CameraID instance_id)
 {
     char *retval = NULL;
-    SDL_CameraDevice *device = ObtainPhysicalCameraDevice(instance_id);
+    SDL_Camera *device = ObtainPhysicalCamera(instance_id);
     if (device) {
         retval = device->name;
-        ReleaseCameraDevice(device);
+        ReleaseCamera(device);
     }
     return retval;
 }
 
-SDL_CameraPosition SDL_GetCameraDevicePosition(SDL_CameraDeviceID instance_id)
+SDL_CameraPosition SDL_GetCameraPosition(SDL_CameraID instance_id)
 {
     SDL_CameraPosition retval = SDL_CAMERA_POSITION_UNKNOWN;
-    SDL_CameraDevice *device = ObtainPhysicalCameraDevice(instance_id);
+    SDL_Camera *device = ObtainPhysicalCamera(instance_id);
     if (device) {
         retval = device->position;
-        ReleaseCameraDevice(device);
+        ReleaseCamera(device);
     }
     return retval;
 }
 
 
-SDL_CameraDeviceID *SDL_GetCameraDevices(int *count)
+SDL_CameraID *SDL_GetCameras(int *count)
 {
     int dummy_count;
     if (!count) {
@@ -708,11 +708,11 @@ SDL_CameraDeviceID *SDL_GetCameraDevices(int *count)
         return NULL;
     }
 
-    SDL_CameraDeviceID *retval = NULL;
+    SDL_CameraID *retval = NULL;
 
     SDL_LockRWLockForReading(camera_driver.device_hash_lock);
     int num_devices = SDL_AtomicGet(&camera_driver.device_count);
-    retval = (SDL_CameraDeviceID *) SDL_malloc((num_devices + 1) * sizeof (SDL_CameraDeviceID));
+    retval = (SDL_CameraID *) SDL_malloc((num_devices + 1) * sizeof (SDL_CameraID));
     if (!retval) {
         num_devices = 0;
     } else {
@@ -721,7 +721,7 @@ SDL_CameraDeviceID *SDL_GetCameraDevices(int *count)
         const void *value;
         void *iter = NULL;
         while (SDL_IterateHashTable(camera_driver.device_hash, &key, &value, &iter)) {
-            retval[devs_seen++] = (SDL_CameraDeviceID) (uintptr_t) key;
+            retval[devs_seen++] = (SDL_CameraID) (uintptr_t) key;
         }
 
         SDL_assert(devs_seen == num_devices);
@@ -734,13 +734,13 @@ SDL_CameraDeviceID *SDL_GetCameraDevices(int *count)
     return retval;
 }
 
-SDL_CameraSpec *SDL_GetCameraDeviceSupportedFormats(SDL_CameraDeviceID instance_id, int *count)
+SDL_CameraSpec *SDL_GetCameraSupportedFormats(SDL_CameraID instance_id, int *count)
 {
     if (count) {
         *count = 0;
     }
 
-    SDL_CameraDevice *device = ObtainPhysicalCameraDevice(instance_id);
+    SDL_Camera *device = ObtainPhysicalCamera(instance_id);
     if (!device) {
         return NULL;
     }
@@ -753,7 +753,7 @@ SDL_CameraSpec *SDL_GetCameraDeviceSupportedFormats(SDL_CameraDeviceID instance_
         }
     }
 
-    ReleaseCameraDevice(device);
+    ReleaseCamera(device);
 
     return retval;
 }
@@ -761,7 +761,7 @@ SDL_CameraSpec *SDL_GetCameraDeviceSupportedFormats(SDL_CameraDeviceID instance_
 
 // Camera device thread. This is split into chunks, so drivers that need to control this directly can use the pieces they need without duplicating effort.
 
-void SDL_CameraThreadSetup(SDL_CameraDevice *device)
+void SDL_CameraThreadSetup(SDL_Camera *device)
 {
     //camera_driver.impl.ThreadInit(device);
 #ifdef SDL_VIDEO_DRIVER_ANDROID
@@ -778,7 +778,7 @@ void SDL_CameraThreadSetup(SDL_CameraDevice *device)
 #endif
 }
 
-SDL_bool SDL_CameraThreadIterate(SDL_CameraDevice *device)
+SDL_bool SDL_CameraThreadIterate(SDL_Camera *device)
 {
     SDL_LockMutex(device->lock);
 
@@ -855,7 +855,7 @@ SDL_bool SDL_CameraThreadIterate(SDL_CameraDevice *device)
     if (failed) {
         SDL_assert(slist == NULL);
         SDL_assert(acquired == NULL);
-        SDL_CameraDeviceDisconnected(device);  // doh.
+        SDL_CameraDisconnected(device);  // doh.
     } else if (acquired) {  // we have a new frame, scale/convert if necessary and queue it for the app!
         SDL_assert(slist != NULL);
         if (!device->needs_scaling && !device->needs_conversion) {  // no conversion needed? Just move the pointer/pitch into the output surface.
@@ -905,7 +905,7 @@ SDL_bool SDL_CameraThreadIterate(SDL_CameraDevice *device)
     return SDL_TRUE;  // always go on if not shutting down, even if device failed.
 }
 
-void SDL_CameraThreadShutdown(SDL_CameraDevice *device)
+void SDL_CameraThreadShutdown(SDL_Camera *device)
 {
     //device->FlushRecording(device);
     //camera_driver.impl.ThreadDeinit(device);
@@ -915,7 +915,7 @@ void SDL_CameraThreadShutdown(SDL_CameraDevice *device)
 // Actual thread entry point, if driver didn't handle this itself.
 static int SDLCALL CameraThread(void *devicep)
 {
-    SDL_CameraDevice *device = (SDL_CameraDevice *) devicep;
+    SDL_Camera *device = (SDL_Camera *) devicep;
 
     #if DEBUG_CAMERA
     SDL_Log("CAMERA: dev[%p] Start thread 'CameraThread'", devicep);
@@ -926,7 +926,7 @@ static int SDLCALL CameraThread(void *devicep)
 
     do {
         if (device->WaitDevice(device) < 0) {
-            SDL_CameraDeviceDisconnected(device);  // doh. (but don't break out of the loop, just be a zombie for now!)
+            SDL_CameraDisconnected(device);  // doh. (but don't break out of the loop, just be a zombie for now!)
         }
     } while (SDL_CameraThreadIterate(device));
 
@@ -939,7 +939,7 @@ static int SDLCALL CameraThread(void *devicep)
     return 0;
 }
 
-static void ChooseBestCameraSpec(SDL_CameraDevice *device, const SDL_CameraSpec *spec, SDL_CameraSpec *closest)
+static void ChooseBestCameraSpec(SDL_Camera *device, const SDL_CameraSpec *spec, SDL_CameraSpec *closest)
 {
     // Find the closest available native format/size...
     //
@@ -1056,15 +1056,15 @@ static void ChooseBestCameraSpec(SDL_CameraDevice *device, const SDL_CameraSpec
     SDL_assert(closest->format != SDL_PIXELFORMAT_UNKNOWN);
 }
 
-SDL_Camera *SDL_OpenCameraDevice(SDL_CameraDeviceID instance_id, const SDL_CameraSpec *spec)
+SDL_Camera *SDL_OpenCamera(SDL_CameraID instance_id, const SDL_CameraSpec *spec)
 {
-    SDL_CameraDevice *device = ObtainPhysicalCameraDevice(instance_id);
+    SDL_Camera *device = ObtainPhysicalCamera(instance_id);
     if (!device) {
         return NULL;
     }
 
     if (device->hidden != NULL) {
-        ReleaseCameraDevice(device);
+        ReleaseCamera(device);
         SDL_SetError("Camera already opened");  // we may remove this limitation at some point.
         return NULL;
     }
@@ -1086,8 +1086,8 @@ SDL_Camera *SDL_OpenCameraDevice(SDL_CameraDeviceID instance_id, const SDL_Camer
     #endif
 
     if (camera_driver.impl.OpenDevice(device, &closest) < 0) {
-        ClosePhysicalCameraDevice(device);  // in case anything is half-initialized.
-        ReleaseCameraDevice(device);
+        ClosePhysicalCamera(device);  // in case anything is half-initialized.
+        ReleaseCamera(device);
         return NULL;
     }
 
@@ -1126,8 +1126,8 @@ SDL_Camera *SDL_OpenCameraDevice(SDL_CameraDeviceID instance_id, const SDL_Camer
 
     device->acquire_surface = SDL_CreateSurfaceFrom(closest.width, closest.height, closest.format, NULL, 0);
     if (!device->acquire_surface) {
-        ClosePhysicalCameraDevice(device);
-        ReleaseCameraDevice(device);
+        ClosePhysicalCamera(device);
+        ReleaseCamera(device);
         return NULL;
     }
     SDL_SetSurfaceColorspace(device->acquire_surface, closest.colorspace);
@@ -1139,8 +1139,8 @@ SDL_Camera *SDL_OpenCameraDevice(SDL_CameraDeviceID instance_id, const SDL_Camer
         const SDL_PixelFormat fmt = downsampling_first ? closest.format : device->spec.format;
         device->conversion_surface = SDL_CreateSurface(s->width, s->height, fmt);
         if (!device->conversion_surface) {
-            ClosePhysicalCameraDevice(device);
-            ReleaseCameraDevice(device);
+            ClosePhysicalCamera(device);
+            ReleaseCamera(device);
             return NULL;
         }
         SDL_SetSurfaceColorspace(device->conversion_surface, closest.colorspace);
@@ -1163,8 +1163,8 @@ SDL_Camera *SDL_OpenCameraDevice(SDL_CameraDeviceID instance_id, const SDL_Camer
             surf = SDL_CreateSurfaceFrom(device->spec.width, device->spec.height, device->spec.format, NULL, 0);
         }
         if (!surf) {
-            ClosePhysicalCameraDevice(device);
-            ReleaseCameraDevice(device);
+            ClosePhysicalCamera(device);
+            ReleaseCamera(device);
             return NULL;
         }
         SDL_SetSurfaceColorspace(surf, closest.colorspace);
@@ -1180,14 +1180,14 @@ SDL_Camera *SDL_OpenCameraDevice(SDL_CameraDeviceID instance_id, const SDL_Camer
         SDL_GetCameraThreadName(device, threadname, sizeof (threadname));
         device->thread = SDL_CreateThread(CameraThread, threadname, device);
         if (!device->thread) {
-            ClosePhysicalCameraDevice(device);
-            ReleaseCameraDevice(device);
+            ClosePhysicalCamera(device);
+            ReleaseCamera(device);
             SDL_SetError("Couldn't create camera thread");
             return NULL;
         }
     }
 
-    ReleaseCameraDevice(device);  // unlock, we're good to go!
+    ReleaseCamera(device);  // unlock, we're good to go!
 
     return (SDL_Camera *) device;  // currently there's no separation between physical and logical device.
 }
@@ -1203,12 +1203,12 @@ SDL_Surface *SDL_AcquireCameraFrame(SDL_Camera *camera, Uint64 *timestampNS)
         return NULL;
     }
 
-    SDL_CameraDevice *device = (SDL_CameraDevice *) camera;  // currently there's no separation between physical and logical device.
+    SDL_Camera *device = (SDL_Camera *) camera;  // currently there's no separation between physical and logical device.
 
-    ObtainPhysicalCameraDeviceObj(device);
+    ObtainPhysicalCameraObj(device);
 
     if (device->permission <= 0) {
-        ReleaseCameraDevice(device);
+        ReleaseCamera(device);
         SDL_SetError("Camera permission has not been granted");
         return NULL;
     }
@@ -1234,7 +1234,7 @@ SDL_Surface *SDL_AcquireCameraFrame(SDL_Camera *camera, Uint64 *timestampNS)
         device->app_held_output_surfaces.next = slist;
     }
 
-    ReleaseCameraDevice(device);
+    ReleaseCamera(device);
 
     return retval;
 }
@@ -1247,8 +1247,8 @@ int SDL_ReleaseCameraFrame(SDL_Camera *camera, SDL_Surface *frame)
         return SDL_InvalidParamError("frame");
     }
 
-    SDL_CameraDevice *device = (SDL_CameraDevice *) camera;  // currently there's no separation between physical and logical device.
-    ObtainPhysicalCameraDeviceObj(device);
+    SDL_Camera *device = (SDL_Camera *) camera;  // currently there's no separation between physical and logical device.
+    ObtainPhysicalCameraObj(device);
 
     SurfaceList *slistprev = &device->app_held_output_surfaces;
     SurfaceList *slist;
@@ -1260,7 +1260,7 @@ int SDL_ReleaseCameraFrame(SDL_Camera *camera, SDL_Surface *frame)
     }
 
     if (!slist) {
-        ReleaseCameraDevice(device);
+        ReleaseCamera(device);
         return SDL_SetError("Surface was not acquired from this camera, or was already released");
     }
 
@@ -1280,21 +1280,21 @@ int SDL_ReleaseCameraFrame(SDL_Camera *camera, SDL_Surface *frame)
     slist->next = device->empty_output_surfaces.next;
     device->empty_output_surfaces.next = slist;
 
-    ReleaseCameraDevice(device);
+    ReleaseCamera(device);
 
     return 0;
 }
 
-SDL_CameraDeviceID SDL_GetCameraInstanceID(SDL_Camera *camera)
+SDL_CameraID SDL_GetCameraID(SDL_Camera *camera)
 {
-    SDL_CameraDeviceID retval = 0;
+    SDL_CameraID retval = 0;
     if (!camera) {
         SDL_InvalidParamError("camera");
     } else {
-        SDL_CameraDevice *device = (SDL_CameraDevice *) camera;  // currently there's no separation between physical and logical device.
-        ObtainPhysicalCameraDeviceObj(device);
+        SDL_Camera *device = (SDL_Camera *) camera;  // currently there's no separation between physical and logical device.
+        ObtainPhysicalCameraObj(device);
         retval = device->instance_id;
-        ReleaseCameraDevice(device);
+        ReleaseCamera(device);
     }
 
     return retval;
@@ -1306,13 +1306,13 @@ SDL_PropertiesID SDL_GetCameraProperties(SDL_Camera *camera)
     if (!camera) {
         SDL_InvalidParamError("camera");
     } else {
-        SDL_CameraDevice *device = (SDL_CameraDevice *) camera;  // currently there's no separation between physical and logical device.
-        ObtainPhysicalCameraDeviceObj(device);
+        SDL_Camera *device = (SDL_Camera *) camera;  // currently there's no separation between physical and logical device.
+        ObtainPhysicalCameraObj(device);
         if (device->props == 0) {
             device->props = SDL_CreateProperties();
         }
         retval = device->props;
-        ReleaseCameraDevice(device);
+        ReleaseCamera(device);
     }
 
     return retval;
@@ -1324,10 +1324,10 @@ int SDL_GetCameraPermissionState(SDL_Camera *camera)
     if (!camera) {
         retval = SDL_InvalidParamError("camera");
     } else {
-        SDL_CameraDevice *device = (SDL_CameraDevice *) camera;  // currently there's no separation between physical and logical device.
-        ObtainPhysicalCameraDeviceObj(device);
+        SDL_Camera *device = (SDL_Camera *) camera;  // currently there's no separation between physical and logical device.
+        ObtainPhysicalCameraObj(device);
         retval = device->permission;
-        ReleaseCameraDevice(device);
+        ReleaseCamera(device);
     }
 
     return retval;
@@ -1358,13 +1358,13 @@ void SDL_QuitCamera(void)
     SDL_AtomicSet(&camera_driver.shutting_down, 1);
     SDL_HashTable *device_hash = camera_driver.device_hash;
     camera_driver.device_hash = NULL;
-    SDL_PendingCameraDeviceEvent *pending_events = camera_driver.pending_events.next;
+    SDL_PendingCameraEvent *pending_events = camera_driver.pending_events.next;
     camera_driver.pending_events.next = NULL;
     SDL_AtomicSet(&camera_driver.device_count, 0);
     SDL_UnlockRWLock(camera_driver.device_hash_lock);
 
-    SDL_PendingCameraDeviceEvent *pending_next = NULL;
-    for (SDL_PendingCameraDeviceEvent *i = pending_events; i; i = pending_next) {
+    SDL_PendingCameraEvent *pending_next = NULL;
+    for (SDL_PendingCameraEvent *i = pending_events; i; i = pending_next) {
         pending_next = i->next;
         SDL_free(i);
     }
@@ -1373,7 +1373,7 @@ void SDL_QuitCamera(void)
     const void *value;
     void *iter = NULL;
     while (SDL_IterateHashTable(device_hash, &key, &value, &iter)) {
-        DestroyPhysicalCameraDevice((SDL_CameraDevice *) value);
+        DestroyPhysicalCamera((SDL_Camera *) value);
     }
 
     // Free the driver data
@@ -1386,18 +1386,18 @@ void SDL_QuitCamera(void)
 }
 
 
-static Uint32 HashCameraDeviceID(const void *key, void *data)
+static Uint32 HashCameraID(const void *key, void *data)
 {
     // The values are unique incrementing integers, starting at 1, so just return minus 1 to start with bucket zero.
     return ((Uint32) ((uintptr_t) key)) - 1;
 }
 
-static SDL_bool MatchCameraDeviceID(const void *a, const void *b, void *data)
+static SDL_bool MatchCameraID(const void *a, const void *b, void *data)
 {
     return (a == b);  // simple integers, just compare them as pointer values.
 }
 
-static void NukeCameraDeviceHashItem(const void *key, const void *value, void *data)
+static void NukeCameraHashItem(const void *key, const void *value, void *data)
 {
     // no-op, keys and values in this hashtable are treated as Plain Old Data and don't get freed here.
 }
@@ -1413,7 +1413,7 @@ int SDL_CameraInit(const char *driver_name)
         return -1;
     }
 
-    SDL_HashTable *device_hash = SDL_CreateHashTable(NULL, 8, HashCameraDeviceID, MatchCameraDeviceID, NukeCameraDeviceHashItem, SDL_FALSE);
+    SDL_HashTable *device_hash = SDL_CreateHashTable(NULL, 8, HashCameraID, MatchCameraID, NukeCameraHashItem, SDL_FALSE);
     if (!device_hash) {
         SDL_DestroyRWLock(device_hash_lock);
         return -1;
@@ -1511,7 +1511,7 @@ int SDL_CameraInit(const char *driver_name)
 void SDL_UpdateCamera(void)
 {
     SDL_LockRWLockForReading(camera_driver.device_hash_lock);
-    SDL_PendingCameraDeviceEvent *pending_events = camera_driver.pending_events.next;
+    SDL_PendingCameraEvent *pending_events = camera_driver.pending_events.next;
     SDL_UnlockRWLock(camera_driver.device_hash_lock);
 
     if (!pending_events) {
@@ -1525,8 +1525,8 @@ void SDL_UpdateCamera(void)
     camera_driver.pending_events_tail = &camera_driver.pending_events;
     SDL_UnlockRWLock(camera_driver.device_hash_lock);
 
-    SDL_PendingCameraDeviceEvent *pending_next = NULL;
-    for (SDL_PendingCameraDeviceEvent *i = pending_events; i; i = pending_next) {
+    SDL_PendingCameraEvent *pending_next = NULL;
+    for (SDL_PendingCameraEvent *i = pending_events; i; i = pending_next) {
         pending_next = i->next;
         if (SDL_EventEnabled(i->type)) {
             SDL_Event event;

+ 29 - 29
src/camera/SDL_syscamera.h

@@ -27,34 +27,34 @@
 
 #define DEBUG_CAMERA 0
 
-typedef struct SDL_CameraDevice SDL_CameraDevice;
+typedef struct SDL_Camera SDL_Camera;
 
 /* Backends should call this as devices are added to the system (such as
    a USB camera being plugged in), and should also be called for
    for every device found during DetectDevices(). */
-extern SDL_CameraDevice *SDL_AddCameraDevice(const char *name, SDL_CameraPosition position, int num_specs, const SDL_CameraSpec *specs, void *handle);
+extern SDL_Camera *SDL_AddCamera(const char *name, SDL_CameraPosition position, int num_specs, const SDL_CameraSpec *specs, void *handle);
 
 /* Backends should call this if an opened camera device is lost.
    This can happen due to i/o errors, or a device being unplugged, etc. */
-extern void SDL_CameraDeviceDisconnected(SDL_CameraDevice *device);
+extern void SDL_CameraDisconnected(SDL_Camera *device);
 
-// Find an SDL_CameraDevice, selected by a callback. NULL if not found. DOES NOT LOCK THE DEVICE.
-extern SDL_CameraDevice *SDL_FindPhysicalCameraDeviceByCallback(SDL_bool (*callback)(SDL_CameraDevice *device, void *userdata), void *userdata);
+// Find an SDL_Camera, selected by a callback. NULL if not found. DOES NOT LOCK THE DEVICE.
+extern SDL_Camera *SDL_FindPhysicalCameraByCallback(SDL_bool (*callback)(SDL_Camera *device, void *userdata), void *userdata);
 
 // Backends should call this when the user has approved/denied access to a camera.
-extern void SDL_CameraDevicePermissionOutcome(SDL_CameraDevice *device, SDL_bool approved);
+extern void SDL_CameraPermissionOutcome(SDL_Camera *device, SDL_bool approved);
 
 // Backends can call this to get a standardized name for a thread to power a specific camera device.
-extern char *SDL_GetCameraThreadName(SDL_CameraDevice *device, char *buf, size_t buflen);
+extern char *SDL_GetCameraThreadName(SDL_Camera *device, char *buf, size_t buflen);
 
 // Backends can call these to change a device's refcount.
-extern void RefPhysicalCameraDevice(SDL_CameraDevice *device);
-extern void UnrefPhysicalCameraDevice(SDL_CameraDevice *device);
+extern void RefPhysicalCamera(SDL_Camera *device);
+extern void UnrefPhysicalCamera(SDL_Camera *device);
 
 // These functions are the heart of the camera threads. Backends can call them directly if they aren't using the SDL-provided thread.
-extern void SDL_CameraThreadSetup(SDL_CameraDevice *device);
-extern SDL_bool SDL_CameraThreadIterate(SDL_CameraDevice *device);
-extern void SDL_CameraThreadShutdown(SDL_CameraDevice *device);
+extern void SDL_CameraThreadSetup(SDL_Camera *device);
+extern SDL_bool SDL_CameraThreadIterate(SDL_Camera *device);
+extern void SDL_CameraThreadShutdown(SDL_Camera *device);
 
 // common utility functionality to gather up camera specs. Not required!
 typedef struct CameraFormatAddData
@@ -74,7 +74,7 @@ typedef struct SurfaceList
 } SurfaceList;
 
 // Define the SDL camera driver structure
-struct SDL_CameraDevice
+struct SDL_Camera
 {
     // A mutex for locking
     SDL_Mutex *lock;
@@ -89,9 +89,9 @@ struct SDL_CameraDevice
     SDL_AtomicInt refcount;
 
     // These are, initially, set from camera_driver, but we might swap them out with Zombie versions on disconnect/failure.
-    int (*WaitDevice)(SDL_CameraDevice *device);
-    int (*AcquireFrame)(SDL_CameraDevice *device, SDL_Surface *frame, Uint64 *timestampNS);
-    void (*ReleaseFrame)(SDL_CameraDevice *device, SDL_Surface *frame);
+    int (*WaitDevice)(SDL_Camera *device);
+    int (*AcquireFrame)(SDL_Camera *device, SDL_Surface *frame, Uint64 *timestampNS);
+    void (*ReleaseFrame)(SDL_Camera *device, SDL_Surface *frame);
 
     // All supported formats/dimensions for this device.
     SDL_CameraSpec *all_specs;
@@ -106,7 +106,7 @@ struct SDL_CameraDevice
     SDL_CameraSpec spec;
 
     // Unique value assigned at creation time.
-    SDL_CameraDeviceID instance_id;
+    SDL_CameraID instance_id;
 
     // Driver-specific hardware data on how to open device (`hidden` is driver-specific data _when opened_).
     void *handle;
@@ -161,23 +161,23 @@ struct SDL_CameraDevice
 typedef struct SDL_CameraDriverImpl
 {
     void (*DetectDevices)(void);
-    int (*OpenDevice)(SDL_CameraDevice *device, const SDL_CameraSpec *spec);
-    void (*CloseDevice)(SDL_CameraDevice *device);
-    int (*WaitDevice)(SDL_CameraDevice *device);
-    int (*AcquireFrame)(SDL_CameraDevice *device, SDL_Surface *frame, Uint64 *timestampNS); // set frame->pixels, frame->pitch, and *timestampNS!
-    void (*ReleaseFrame)(SDL_CameraDevice *device, SDL_Surface *frame); // Reclaim frame->pixels and frame->pitch!
-    void (*FreeDeviceHandle)(SDL_CameraDevice *device); // SDL is done with this device; free the handle from SDL_AddCameraDevice()
+    int (*OpenDevice)(SDL_Camera *device, const SDL_CameraSpec *spec);
+    void (*CloseDevice)(SDL_Camera *device);
+    int (*WaitDevice)(SDL_Camera *device);
+    int (*AcquireFrame)(SDL_Camera *device, SDL_Surface *frame, Uint64 *timestampNS); // set frame->pixels, frame->pitch, and *timestampNS!
+    void (*ReleaseFrame)(SDL_Camera *device, SDL_Surface *frame); // Reclaim frame->pixels and frame->pitch!
+    void (*FreeDeviceHandle)(SDL_Camera *device); // SDL is done with this device; free the handle from SDL_AddCamera()
     void (*Deinitialize)(void);
 
     SDL_bool ProvidesOwnCallbackThread;
 } SDL_CameraDriverImpl;
 
-typedef struct SDL_PendingCameraDeviceEvent
+typedef struct SDL_PendingCameraEvent
 {
     Uint32 type;
-    SDL_CameraDeviceID devid;
-    struct SDL_PendingCameraDeviceEvent *next;
-} SDL_PendingCameraDeviceEvent;
+    SDL_CameraID devid;
+    struct SDL_PendingCameraEvent *next;
+} SDL_PendingCameraEvent;
 
 typedef struct SDL_CameraDriver
 {
@@ -187,8 +187,8 @@ typedef struct SDL_CameraDriver
 
     SDL_RWLock *device_hash_lock;  // A rwlock that protects `device_hash`
     SDL_HashTable *device_hash;  // the collection of currently-available camera devices
-    SDL_PendingCameraDeviceEvent pending_events;
-    SDL_PendingCameraDeviceEvent *pending_events_tail;
+    SDL_PendingCameraEvent pending_events;
+    SDL_PendingCameraEvent *pending_events_tail;
 
     SDL_AtomicInt device_count;
     SDL_AtomicInt shutting_down;  // non-zero during SDL_Quit, so we known not to accept any last-minute device hotplugs.

+ 27 - 27
src/camera/android/SDL_camera_android.c

@@ -289,12 +289,12 @@ static Uint32 format_sdl_to_android(SDL_PixelFormat fmt)
     }
 }
 
-static int ANDROIDCAMERA_WaitDevice(SDL_CameraDevice *device)
+static int ANDROIDCAMERA_WaitDevice(SDL_Camera *device)
 {
     return 0;  // this isn't used atm, since we run our own thread via onImageAvailable callbacks.
 }
 
-static int ANDROIDCAMERA_AcquireFrame(SDL_CameraDevice *device, SDL_Surface *frame, Uint64 *timestampNS)
+static int ANDROIDCAMERA_AcquireFrame(SDL_Camera *device, SDL_Surface *frame, Uint64 *timestampNS)
 {
     int retval = 1;
     media_status_t res;
@@ -358,7 +358,7 @@ static int ANDROIDCAMERA_AcquireFrame(SDL_CameraDevice *device, SDL_Surface *fra
     return retval;
 }
 
-static void ANDROIDCAMERA_ReleaseFrame(SDL_CameraDevice *device, SDL_Surface *frame)
+static void ANDROIDCAMERA_ReleaseFrame(SDL_Camera *device, SDL_Surface *frame)
 {
     // !!! FIXME: this currently copies the data to the surface, but in theory we could just keep the AImage until ReleaseFrame...
     SDL_aligned_free(frame->pixels);
@@ -369,7 +369,7 @@ static void onImageAvailable(void *context, AImageReader *reader)
     #if DEBUG_CAMERA
     SDL_Log("CAMERA: CB onImageAvailable");
     #endif
-    SDL_CameraDevice *device = (SDL_CameraDevice *) context;
+    SDL_Camera *device = (SDL_Camera *) context;
     SDL_CameraThreadIterate(device);
 }
 
@@ -378,7 +378,7 @@ static void onDisconnected(void *context, ACameraDevice *device)
     #if DEBUG_CAMERA
     SDL_Log("CAMERA: CB onDisconnected");
     #endif
-    SDL_CameraDeviceDisconnected((SDL_CameraDevice *) context);
+    SDL_CameraDisconnected((SDL_Camera *) context);
 }
 
 static void onError(void *context, ACameraDevice *device, int error)
@@ -386,12 +386,12 @@ static void onError(void *context, ACameraDevice *device, int error)
     #if DEBUG_CAMERA
     SDL_Log("CAMERA: CB onError");
     #endif
-    SDL_CameraDeviceDisconnected((SDL_CameraDevice *) context);
+    SDL_CameraDisconnected((SDL_Camera *) context);
 }
 
 static void onClosed(void* context, ACameraCaptureSession *session)
 {
-    // SDL_CameraDevice *_this = (SDL_CameraDevice *) context;
+    // SDL_Camera *_this = (SDL_Camera *) context;
     #if DEBUG_CAMERA
     SDL_Log("CAMERA: CB onClosed");
     #endif
@@ -399,7 +399,7 @@ static void onClosed(void* context, ACameraCaptureSession *session)
 
 static void onReady(void* context, ACameraCaptureSession *session)
 {
-    // SDL_CameraDevice *_this = (SDL_CameraDevice *) context;
+    // SDL_Camera *_this = (SDL_Camera *) context;
     #if DEBUG_CAMERA
     SDL_Log("CAMERA: CB onReady");
     #endif
@@ -407,13 +407,13 @@ static void onReady(void* context, ACameraCaptureSession *session)
 
 static void onActive(void* context, ACameraCaptureSession *session)
 {
-    // SDL_CameraDevice *_this = (SDL_CameraDevice *) context;
+    // SDL_Camera *_this = (SDL_Camera *) context;
     #if DEBUG_CAMERA
     SDL_Log("CAMERA: CB onActive");
     #endif
 }
 
-static void ANDROIDCAMERA_CloseDevice(SDL_CameraDevice *device)
+static void ANDROIDCAMERA_CloseDevice(SDL_Camera *device)
 {
     if (device && device->hidden) {
         struct SDL_PrivateCameraData *hidden = device->hidden;
@@ -458,7 +458,7 @@ static void ANDROIDCAMERA_CloseDevice(SDL_CameraDevice *device)
 }
 
 // this is where the "opening" of the camera happens, after permission is granted.
-static int PrepareCamera(SDL_CameraDevice *device)
+static int PrepareCamera(SDL_Camera *device)
 {
     SDL_assert(device->hidden != NULL);
 
@@ -483,7 +483,7 @@ static int PrepareCamera(SDL_CameraDevice *device)
     imglistener.context = device;
     imglistener.onImageAvailable = onImageAvailable;
 
-    // just in case SDL_OpenCameraDevice is overwriting device->spec as CameraPermissionCallback runs, we work from a different copy.
+    // just in case SDL_OpenCamera is overwriting device->spec as CameraPermissionCallback runs, we work from a different copy.
     const SDL_CameraSpec *spec = &device->hidden->requested_spec;
 
     if ((res = pACameraManager_openCamera(cameraMgr, (const char *) device->handle, &dev_callbacks, &device->hidden->device)) != ACAMERA_OK) {
@@ -517,24 +517,24 @@ static int PrepareCamera(SDL_CameraDevice *device)
 
 static void SDLCALL CameraPermissionCallback(void *userdata, const char *permission, SDL_bool granted)
 {
-    SDL_CameraDevice *device = (SDL_CameraDevice *) userdata;
+    SDL_Camera *device = (SDL_Camera *) userdata;
     if (device->hidden != NULL) {   // if device was already closed, don't send an event.
         if (!granted) {
-            SDL_CameraDevicePermissionOutcome(device, SDL_FALSE);  // sorry, permission denied.
+            SDL_CameraPermissionOutcome(device, SDL_FALSE);  // sorry, permission denied.
         } else if (PrepareCamera(device) < 0) {  // permission given? Actually open the camera now.
             // uhoh, setup failed; since the app thinks we already "opened" the device, mark it as disconnected and don't report the permission.
-            SDL_CameraDeviceDisconnected(device);
+            SDL_CameraDisconnected(device);
         } else {
             // okay! We have permission to use the camera _and_ opening the hardware worked out, report that the camera is usable!
-            SDL_CameraDevicePermissionOutcome(device, SDL_TRUE);  // go go go!
+            SDL_CameraPermissionOutcome(device, SDL_TRUE);  // go go go!
         }
     }
 
-    UnrefPhysicalCameraDevice(device);   // we ref'd this in OpenDevice, release the extra reference.
+    UnrefPhysicalCamera(device);   // we ref'd this in OpenDevice, release the extra reference.
 }
 
 
-static int ANDROIDCAMERA_OpenDevice(SDL_CameraDevice *device, const SDL_CameraSpec *spec)
+static int ANDROIDCAMERA_OpenDevice(SDL_Camera *device, const SDL_CameraSpec *spec)
 {
 #if 0  // !!! FIXME: for now, we'll just let this fail if it is going to fail, without checking for this
     /* Cannot open a second camera, while the first one is opened.
@@ -555,19 +555,19 @@ static int ANDROIDCAMERA_OpenDevice(SDL_CameraDevice *device, const SDL_CameraSp
         return -1;
     }
 
-    RefPhysicalCameraDevice(device);  // ref'd until permission callback fires.
+    RefPhysicalCamera(device);  // ref'd until permission callback fires.
 
-    // just in case SDL_OpenCameraDevice is overwriting device->spec as CameraPermissionCallback runs, we work from a different copy.
+    // just in case SDL_OpenCamera is overwriting device->spec as CameraPermissionCallback runs, we work from a different copy.
     SDL_copyp(&device->hidden->requested_spec, spec);
     if (SDL_AndroidRequestPermission("android.permission.CAMERA", CameraPermissionCallback, device) < 0) {
-        UnrefPhysicalCameraDevice(device);
+        UnrefPhysicalCamera(device);
         return -1;
     }
 
     return 0;  // we don't open the camera until permission is granted, so always succeed for now.
 }
 
-static void ANDROIDCAMERA_FreeDeviceHandle(SDL_CameraDevice *device)
+static void ANDROIDCAMERA_FreeDeviceHandle(SDL_Camera *device)
 {
     if (device) {
         SDL_free(device->handle);
@@ -666,7 +666,7 @@ static void GatherCameraSpecs(const char *devid, CameraFormatAddData *add_data,
     pACameraMetadata_free(metadata);
 }
 
-static SDL_bool FindAndroidCameraDeviceByID(SDL_CameraDevice *device, void *userdata)
+static SDL_bool FindAndroidCameraByID(SDL_Camera *device, void *userdata)
 {
     const char *devid = (const char *) userdata;
     return (SDL_strcmp(devid, (const char *) device->handle) == 0);
@@ -678,7 +678,7 @@ static void MaybeAddDevice(const char *devid)
     SDL_Log("CAMERA: MaybeAddDevice('%s')", devid);
     #endif
 
-    if (SDL_FindPhysicalCameraDeviceByCallback(FindAndroidCameraDeviceByID, (void *) devid)) {
+    if (SDL_FindPhysicalCameraByCallback(FindAndroidCameraByID, (void *) devid)) {
         return;  // already have this one.
     }
 
@@ -689,7 +689,7 @@ static void MaybeAddDevice(const char *devid)
     if (add_data.num_specs > 0) {
         char *namecpy = SDL_strdup(devid);
         if (namecpy) {
-            SDL_CameraDevice *device = SDL_AddCameraDevice(fullname, position, add_data.num_specs, add_data.specs, namecpy);
+            SDL_Camera *device = SDL_AddCamera(fullname, position, add_data.num_specs, add_data.specs, namecpy);
             if (!device) {
                 SDL_free(namecpy);
             }
@@ -725,9 +725,9 @@ static void onCameraUnavailable(void *context, const char *cameraId)
 
     // THIS CALLBACK FIRES WHEN YOU OPEN THE DEVICE YOURSELF.  :(
     // Make sure we don't have the device opened, in which case onDisconnected will fire instead if actually lost.
-    SDL_CameraDevice *device = SDL_FindPhysicalCameraDeviceByCallback(FindAndroidCameraDeviceByID, (void *) cameraId);
+    SDL_Camera *device = SDL_FindPhysicalCameraByCallback(FindAndroidCameraByID, (void *) cameraId);
     if (device && !device->hidden) {
-        SDL_CameraDeviceDisconnected(device);
+        SDL_CameraDisconnected(device);
     }
 }
 

+ 16 - 16
src/camera/coremedia/SDL_camera_coremedia.m

@@ -83,16 +83,16 @@ static void CoreMediaFormatToSDL(FourCharCode fmt, SDL_PixelFormat *pixel_format
 @end
 
 
-static SDL_bool CheckCameraPermissions(SDL_CameraDevice *device)
+static SDL_bool CheckCameraPermissions(SDL_Camera *device)
 {
     if (device->permission == 0) {  // still expecting a permission result.
         if (@available(macOS 14, *)) {
             const AVAuthorizationStatus status = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
             if (status != AVAuthorizationStatusNotDetermined) {   // NotDetermined == still waiting for an answer from the user.
-                SDL_CameraDevicePermissionOutcome(device, (status == AVAuthorizationStatusAuthorized) ? SDL_TRUE : SDL_FALSE);
+                SDL_CameraPermissionOutcome(device, (status == AVAuthorizationStatusAuthorized) ? SDL_TRUE : SDL_FALSE);
             }
         } else {
-            SDL_CameraDevicePermissionOutcome(device, SDL_TRUE);  // always allowed (or just unqueryable...?) on older macOS.
+            SDL_CameraPermissionOutcome(device, SDL_TRUE);  // always allowed (or just unqueryable...?) on older macOS.
         }
     }
 
@@ -102,14 +102,14 @@ static SDL_bool CheckCameraPermissions(SDL_CameraDevice *device)
 // this delegate just receives new video frames on a Grand Central Dispatch queue, and fires off the
 // main device thread iterate function directly to consume it.
 @interface SDLCaptureVideoDataOutputSampleBufferDelegate : NSObject<AVCaptureVideoDataOutputSampleBufferDelegate>
-    @property SDL_CameraDevice *device;
-    -(id) init:(SDL_CameraDevice *) dev;
+    @property SDL_Camera *device;
+    -(id) init:(SDL_Camera *) dev;
     -(void) captureOutput:(AVCaptureOutput *)output didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection;
 @end
 
 @implementation SDLCaptureVideoDataOutputSampleBufferDelegate
 
-    -(id) init:(SDL_CameraDevice *) dev {
+    -(id) init:(SDL_Camera *) dev {
         if ( self = [super init] ) {
             _device = dev;
         }
@@ -118,7 +118,7 @@ static SDL_bool CheckCameraPermissions(SDL_CameraDevice *device)
 
     - (void) captureOutput:(AVCaptureOutput *)output didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection
     {
-        SDL_CameraDevice *device = self.device;
+        SDL_Camera *device = self.device;
         if (!device || !device->hidden) {
             return;  // oh well.
         }
@@ -141,12 +141,12 @@ static SDL_bool CheckCameraPermissions(SDL_CameraDevice *device)
     }
 @end
 
-static int COREMEDIA_WaitDevice(SDL_CameraDevice *device)
+static int COREMEDIA_WaitDevice(SDL_Camera *device)
 {
     return 0;  // this isn't used atm, since we run our own thread out of Grand Central Dispatch.
 }
 
-static int COREMEDIA_AcquireFrame(SDL_CameraDevice *device, SDL_Surface *frame, Uint64 *timestampNS)
+static int COREMEDIA_AcquireFrame(SDL_Camera *device, SDL_Surface *frame, Uint64 *timestampNS)
 {
     int retval = 1;
     SDLPrivateCameraData *hidden = (__bridge SDLPrivateCameraData *) device->hidden;
@@ -222,13 +222,13 @@ static int COREMEDIA_AcquireFrame(SDL_CameraDevice *device, SDL_Surface *frame,
     return retval;
 }
 
-static void COREMEDIA_ReleaseFrame(SDL_CameraDevice *device, SDL_Surface *frame)
+static void COREMEDIA_ReleaseFrame(SDL_Camera *device, SDL_Surface *frame)
 {
     // !!! FIXME: this currently copies the data to the surface, but in theory we could just keep this locked until ReleaseFrame...
     SDL_aligned_free(frame->pixels);
 }
 
-static void COREMEDIA_CloseDevice(SDL_CameraDevice *device)
+static void COREMEDIA_CloseDevice(SDL_Camera *device)
 {
     if (device && device->hidden) {
         SDLPrivateCameraData *hidden = (SDLPrivateCameraData *) CFBridgingRelease(device->hidden);
@@ -248,7 +248,7 @@ static void COREMEDIA_CloseDevice(SDL_CameraDevice *device)
     }
 }
 
-static int COREMEDIA_OpenDevice(SDL_CameraDevice *device, const SDL_CameraSpec *spec)
+static int COREMEDIA_OpenDevice(SDL_Camera *device, const SDL_CameraSpec *spec)
 {
     AVCaptureDevice *avdevice = (__bridge AVCaptureDevice *) device->handle;
 
@@ -367,7 +367,7 @@ static int COREMEDIA_OpenDevice(SDL_CameraDevice *device, const SDL_CameraSpec *
     return 0;
 }
 
-static void COREMEDIA_FreeDeviceHandle(SDL_CameraDevice *device)
+static void COREMEDIA_FreeDeviceHandle(SDL_Camera *device)
 {
     if (device && device->handle) {
         CFBridgingRelease(device->handle);
@@ -408,7 +408,7 @@ static void GatherCameraSpecs(AVCaptureDevice *device, CameraFormatAddData *add_
     }
 }
 
-static SDL_bool FindCoreMediaCameraDeviceByUniqueID(SDL_CameraDevice *device, void *userdata)
+static SDL_bool FindCoreMediaCameraByUniqueID(SDL_Camera *device, void *userdata)
 {
     NSString *uniqueid = (__bridge NSString *) userdata;
     AVCaptureDevice *avdev = (__bridge AVCaptureDevice *) device->handle;
@@ -421,7 +421,7 @@ static void MaybeAddDevice(AVCaptureDevice *avdevice)
         return;  // not connected.
     } else if (![avdevice hasMediaType:AVMediaTypeVideo]) {
         return;  // not a camera.
-    } else if (SDL_FindPhysicalCameraDeviceByCallback(FindCoreMediaCameraDeviceByUniqueID, (__bridge void *) avdevice.uniqueID)) {
+    } else if (SDL_FindPhysicalCameraByCallback(FindCoreMediaCameraByUniqueID, (__bridge void *) avdevice.uniqueID)) {
         return;  // already have this one.
     }
 
@@ -434,7 +434,7 @@ static void MaybeAddDevice(AVCaptureDevice *avdevice)
         } else if (avdevice.position == AVCaptureDevicePositionBack) {
             position = SDL_CAMERA_POSITION_BACK_FACING;
         }
-        SDL_AddCameraDevice(avdevice.localizedName.UTF8String, position, add_data.num_specs, add_data.specs, (void *) CFBridgingRetain(avdevice));
+        SDL_AddCamera(avdevice.localizedName.UTF8String, position, add_data.num_specs, add_data.specs, (void *) CFBridgingRetain(avdevice));
     }
 
     SDL_free(add_data.specs);

+ 6 - 6
src/camera/dummy/SDL_camera_dummy.c

@@ -24,26 +24,26 @@
 
 #include "../SDL_syscamera.h"
 
-static int DUMMYCAMERA_OpenDevice(SDL_CameraDevice *device, const SDL_CameraSpec *spec)
+static int DUMMYCAMERA_OpenDevice(SDL_Camera *device, const SDL_CameraSpec *spec)
 {
     return SDL_Unsupported();
 }
 
-static void DUMMYCAMERA_CloseDevice(SDL_CameraDevice *device)
+static void DUMMYCAMERA_CloseDevice(SDL_Camera *device)
 {
 }
 
-static int DUMMYCAMERA_WaitDevice(SDL_CameraDevice *device)
+static int DUMMYCAMERA_WaitDevice(SDL_Camera *device)
 {
     return SDL_Unsupported();
 }
 
-static int DUMMYCAMERA_AcquireFrame(SDL_CameraDevice *device, SDL_Surface *frame, Uint64 *timestampNS)
+static int DUMMYCAMERA_AcquireFrame(SDL_Camera *device, SDL_Surface *frame, Uint64 *timestampNS)
 {
     return SDL_Unsupported();
 }
 
-static void DUMMYCAMERA_ReleaseFrame(SDL_CameraDevice *device, SDL_Surface *frame)
+static void DUMMYCAMERA_ReleaseFrame(SDL_Camera *device, SDL_Surface *frame)
 {
 }
 
@@ -51,7 +51,7 @@ static void DUMMYCAMERA_DetectDevices(void)
 {
 }
 
-static void DUMMYCAMERA_FreeDeviceHandle(SDL_CameraDevice *device)
+static void DUMMYCAMERA_FreeDeviceHandle(SDL_Camera *device)
 {
 }
 

+ 10 - 10
src/camera/emscripten/SDL_camera_emscripten.c

@@ -34,13 +34,13 @@
 
 EM_JS_DEPS(sdlcamera, "$dynCall");
 
-static int EMSCRIPTENCAMERA_WaitDevice(SDL_CameraDevice *device)
+static int EMSCRIPTENCAMERA_WaitDevice(SDL_Camera *device)
 {
     SDL_assert(!"This shouldn't be called");  // we aren't using SDL's internal thread.
     return -1;
 }
 
-static int EMSCRIPTENCAMERA_AcquireFrame(SDL_CameraDevice *device, SDL_Surface *frame, Uint64 *timestampNS)
+static int EMSCRIPTENCAMERA_AcquireFrame(SDL_Camera *device, SDL_Surface *frame, Uint64 *timestampNS)
 {
     void *rgba = SDL_malloc(device->actual_spec.width * device->actual_spec.height * 4);
     if (!rgba) {
@@ -76,12 +76,12 @@ static int EMSCRIPTENCAMERA_AcquireFrame(SDL_CameraDevice *device, SDL_Surface *
     return 1;
 }
 
-static void EMSCRIPTENCAMERA_ReleaseFrame(SDL_CameraDevice *device, SDL_Surface *frame)
+static void EMSCRIPTENCAMERA_ReleaseFrame(SDL_Camera *device, SDL_Surface *frame)
 {
     SDL_free(frame->pixels);
 }
 
-static void EMSCRIPTENCAMERA_CloseDevice(SDL_CameraDevice *device)
+static void EMSCRIPTENCAMERA_CloseDevice(SDL_Camera *device)
 {
     if (device) {
         MAIN_THREAD_EM_ASM({
@@ -98,16 +98,16 @@ static void EMSCRIPTENCAMERA_CloseDevice(SDL_CameraDevice *device)
     }
 }
 
-static void SDLEmscriptenCameraDevicePermissionOutcome(SDL_CameraDevice *device, int approved, int w, int h, int fps)
+static void SDLEmscriptenCameraPermissionOutcome(SDL_Camera *device, int approved, int w, int h, int fps)
 {
     device->spec.width = device->actual_spec.width = w;
     device->spec.height = device->actual_spec.height = h;
     device->spec.framerate_numerator = device->actual_spec.framerate_numerator = fps;
     device->spec.framerate_denominator = device->actual_spec.framerate_denominator = 1;
-    SDL_CameraDevicePermissionOutcome(device, approved ? SDL_TRUE : SDL_FALSE);
+    SDL_CameraPermissionOutcome(device, approved ? SDL_TRUE : SDL_FALSE);
 }
 
-static int EMSCRIPTENCAMERA_OpenDevice(SDL_CameraDevice *device, const SDL_CameraSpec *spec)
+static int EMSCRIPTENCAMERA_OpenDevice(SDL_Camera *device, const SDL_CameraSpec *spec)
 {
     MAIN_THREAD_EM_ASM({
         // Since we can't get actual specs until we make a move that prompts the user for
@@ -199,12 +199,12 @@ static int EMSCRIPTENCAMERA_OpenDevice(SDL_CameraDevice *device, const SDL_Camer
                 console.error("Tried to open camera but it threw an error! " + err.name + ": " +  err.message);
                 dynCall('viiiii', outcome, [device, 0, 0, 0, 0]);   // we call this a permission error, because it probably is.
             });
-    }, device, spec->width, spec->height, spec->framerate_numerator, spec->framerate_denominator, SDLEmscriptenCameraDevicePermissionOutcome, SDL_CameraThreadIterate);
+    }, device, spec->width, spec->height, spec->framerate_numerator, spec->framerate_denominator, SDLEmscriptenCameraPermissionOutcome, SDL_CameraThreadIterate);
 
     return 0;  // the real work waits until the user approves a camera.
 }
 
-static void EMSCRIPTENCAMERA_FreeDeviceHandle(SDL_CameraDevice *device)
+static void EMSCRIPTENCAMERA_FreeDeviceHandle(SDL_Camera *device)
 {
     // no-op.
 }
@@ -228,7 +228,7 @@ static void EMSCRIPTENCAMERA_DetectDevices(void)
     //  will pop up a user permission dialog warning them we're trying to access the camera, and we generally
     //  don't want that during SDL_Init().
     if (supported) {
-        SDL_AddCameraDevice("Web browser's camera", SDL_CAMERA_POSITION_UNKNOWN, 0, NULL, (void *) (size_t) 0x1);
+        SDL_AddCamera("Web browser's camera", SDL_CAMERA_POSITION_UNKNOWN, 0, NULL, (void *) (size_t) 0x1);
     }
 }
 

+ 12 - 12
src/camera/mediafoundation/SDL_camera_mediafoundation.c

@@ -347,7 +347,7 @@ typedef struct SDL_PrivateCameraData
     int pitch;
 } SDL_PrivateCameraData;
 
-static int MEDIAFOUNDATION_WaitDevice(SDL_CameraDevice *device)
+static int MEDIAFOUNDATION_WaitDevice(SDL_Camera *device)
 {
     SDL_assert(device->hidden->current_sample == NULL);
 
@@ -421,7 +421,7 @@ static void SDLCALL CleanupIMFMediaBuffer(void *userdata, void *value)
     SDL_free(objs);
 }
 
-static int MEDIAFOUNDATION_AcquireFrame(SDL_CameraDevice *device, SDL_Surface *frame, Uint64 *timestampNS)
+static int MEDIAFOUNDATION_AcquireFrame(SDL_Camera *device, SDL_Surface *frame, Uint64 *timestampNS)
 {
     SDL_assert(device->hidden->current_sample != NULL);
 
@@ -511,7 +511,7 @@ static int MEDIAFOUNDATION_AcquireFrame(SDL_CameraDevice *device, SDL_Surface *f
     return retval;
 }
 
-static void MEDIAFOUNDATION_ReleaseFrame(SDL_CameraDevice *device, SDL_Surface *frame)
+static void MEDIAFOUNDATION_ReleaseFrame(SDL_Camera *device, SDL_Surface *frame)
 {
     const SDL_PropertiesID surfprops = SDL_GetSurfaceProperties(frame);
     if (surfprops) {
@@ -522,7 +522,7 @@ static void MEDIAFOUNDATION_ReleaseFrame(SDL_CameraDevice *device, SDL_Surface *
 
 #else
 
-static int MEDIAFOUNDATION_AcquireFrame(SDL_CameraDevice *device, SDL_Surface *frame, Uint64 *timestampNS)
+static int MEDIAFOUNDATION_AcquireFrame(SDL_Camera *device, SDL_Surface *frame, Uint64 *timestampNS)
 {
     SDL_assert(device->hidden->current_sample != NULL);
 
@@ -627,14 +627,14 @@ static int MEDIAFOUNDATION_AcquireFrame(SDL_CameraDevice *device, SDL_Surface *f
     return retval;
 }
 
-static void MEDIAFOUNDATION_ReleaseFrame(SDL_CameraDevice *device, SDL_Surface *frame)
+static void MEDIAFOUNDATION_ReleaseFrame(SDL_Camera *device, SDL_Surface *frame)
 {
     SDL_aligned_free(frame->pixels);
 }
 
 #endif
 
-static void MEDIAFOUNDATION_CloseDevice(SDL_CameraDevice *device)
+static void MEDIAFOUNDATION_CloseDevice(SDL_Camera *device)
 {
     if (device && device->hidden) {
         if (device->hidden->srcreader) {
@@ -695,7 +695,7 @@ done:
 }
 
 
-static int MEDIAFOUNDATION_OpenDevice(SDL_CameraDevice *device, const SDL_CameraSpec *spec)
+static int MEDIAFOUNDATION_OpenDevice(SDL_Camera *device, const SDL_CameraSpec *spec)
 {
     const char *utf8symlink = (const char *) device->handle;
     IMFAttributes *attrs = NULL;
@@ -821,7 +821,7 @@ static int MEDIAFOUNDATION_OpenDevice(SDL_CameraDevice *device, const SDL_Camera
     IMFMediaSource_Release(source);  // srcreader is holding a reference to this.
 
     // There is no user permission prompt for camera access (I think?)
-    SDL_CameraDevicePermissionOutcome(device, SDL_TRUE);
+    SDL_CameraPermissionOutcome(device, SDL_TRUE);
 
     #undef CHECK_HRESULT
 
@@ -864,7 +864,7 @@ failed:
     return -1;
 }
 
-static void MEDIAFOUNDATION_FreeDeviceHandle(SDL_CameraDevice *device)
+static void MEDIAFOUNDATION_FreeDeviceHandle(SDL_Camera *device)
 {
     if (device) {
         SDL_free(device->handle);  // the device's symlink string.
@@ -962,7 +962,7 @@ static void GatherCameraSpecs(IMFMediaSource *source, CameraFormatAddData *add_d
     IMFPresentationDescriptor_Release(presentdesc);
 }
 
-static SDL_bool FindMediaFoundationCameraDeviceBySymlink(SDL_CameraDevice *device, void *userdata)
+static SDL_bool FindMediaFoundationCameraBySymlink(SDL_Camera *device, void *userdata)
 {
     return (SDL_strcmp((const char *) device->handle, (const char *) userdata) == 0);
 }
@@ -971,7 +971,7 @@ static void MaybeAddDevice(IMFActivate *activation)
 {
     char *symlink = QueryActivationObjectString(activation, &SDL_MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_SYMBOLIC_LINK);
 
-    if (SDL_FindPhysicalCameraDeviceByCallback(FindMediaFoundationCameraDeviceBySymlink, symlink)) {
+    if (SDL_FindPhysicalCameraByCallback(FindMediaFoundationCameraBySymlink, symlink)) {
         SDL_free(symlink);
         return;  // already have this one.
     }
@@ -985,7 +985,7 @@ static void MaybeAddDevice(IMFActivate *activation)
             CameraFormatAddData add_data;
             GatherCameraSpecs(source, &add_data);
             if (add_data.num_specs > 0) {
-                SDL_AddCameraDevice(name, SDL_CAMERA_POSITION_UNKNOWN, add_data.num_specs, add_data.specs, symlink);
+                SDL_AddCamera(name, SDL_CAMERA_POSITION_UNKNOWN, add_data.num_specs, add_data.specs, symlink);
             }
             SDL_free(add_data.specs);
             IMFActivate_ShutdownObject(activation);

+ 11 - 11
src/camera/pipewire/SDL_camera_pipewire.c

@@ -429,12 +429,12 @@ static void on_process(void *data)
 static void on_stream_state_changed(void *data, enum pw_stream_state old,
                 enum pw_stream_state state, const char *error)
 {
-    SDL_CameraDevice *device = data;
+    SDL_Camera *device = data;
     switch (state) {
     case PW_STREAM_STATE_UNCONNECTED:
         break;
     case PW_STREAM_STATE_STREAMING:
-        SDL_CameraDevicePermissionOutcome(device, SDL_TRUE);
+        SDL_CameraPermissionOutcome(device, SDL_TRUE);
         break;
     default:
         break;
@@ -447,13 +447,13 @@ static void on_stream_param_changed(void *data, uint32_t id, const struct spa_po
 
 static void on_add_buffer(void *data, struct pw_buffer *buffer)
 {
-    SDL_CameraDevice *device = data;
+    SDL_Camera *device = data;
     pw_array_add_ptr(&device->hidden->buffers, buffer);
 }
 
 static void on_remove_buffer(void *data, struct pw_buffer *buffer)
 {
-    SDL_CameraDevice *device = data;
+    SDL_Camera *device = data;
     struct pw_buffer **p;
     pw_array_for_each(p, &device->hidden->buffers) {
         if (*p == buffer) {
@@ -472,7 +472,7 @@ static const struct pw_stream_events stream_events = {
     .process = on_process,
 };
 
-static int PIPEWIRECAMERA_OpenDevice(SDL_CameraDevice *device, const SDL_CameraSpec *spec)
+static int PIPEWIRECAMERA_OpenDevice(SDL_Camera *device, const SDL_CameraSpec *spec)
 {
     struct pw_properties *props;
     const struct spa_pod *params[3];
@@ -533,7 +533,7 @@ static int PIPEWIRECAMERA_OpenDevice(SDL_CameraDevice *device, const SDL_CameraS
     return 0;
 }
 
-static void PIPEWIRECAMERA_CloseDevice(SDL_CameraDevice *device)
+static void PIPEWIRECAMERA_CloseDevice(SDL_Camera *device)
 {
     if (!device) {
         return;
@@ -550,7 +550,7 @@ static void PIPEWIRECAMERA_CloseDevice(SDL_CameraDevice *device)
     PIPEWIRE_pw_thread_loop_unlock(hotplug.loop);
 }
 
-static int PIPEWIRECAMERA_WaitDevice(SDL_CameraDevice *device)
+static int PIPEWIRECAMERA_WaitDevice(SDL_Camera *device)
 {
     PIPEWIRE_pw_thread_loop_lock(hotplug.loop);
     PIPEWIRE_pw_thread_loop_wait(hotplug.loop);
@@ -558,7 +558,7 @@ static int PIPEWIRECAMERA_WaitDevice(SDL_CameraDevice *device)
     return 0;
 }
 
-static int PIPEWIRECAMERA_AcquireFrame(SDL_CameraDevice *device, SDL_Surface *frame, Uint64 *timestampNS)
+static int PIPEWIRECAMERA_AcquireFrame(SDL_Camera *device, SDL_Surface *frame, Uint64 *timestampNS)
 {
     struct pw_buffer *b;
 
@@ -590,7 +590,7 @@ static int PIPEWIRECAMERA_AcquireFrame(SDL_CameraDevice *device, SDL_Surface *fr
     return 1;
 }
 
-static void PIPEWIRECAMERA_ReleaseFrame(SDL_CameraDevice *device, SDL_Surface *frame)
+static void PIPEWIRECAMERA_ReleaseFrame(SDL_Camera *device, SDL_Surface *frame)
 {
     struct pw_buffer **p;
     PIPEWIRE_pw_thread_loop_lock(hotplug.loop);
@@ -717,7 +717,7 @@ static void add_device(struct global *g)
         collect_format(&data, p);
     }
     if (data.num_specs > 0) {
-        SDL_AddCameraDevice(g->name, SDL_CAMERA_POSITION_UNKNOWN,
+        SDL_AddCamera(g->name, SDL_CAMERA_POSITION_UNKNOWN,
 				    data.num_specs, data.specs, g);
     }
     SDL_free(data.specs);
@@ -747,7 +747,7 @@ static void PIPEWIRECAMERA_DetectDevices(void)
     PIPEWIRE_pw_thread_loop_unlock(hotplug.loop);
 }
 
-static void PIPEWIRECAMERA_FreeDeviceHandle(SDL_CameraDevice *device)
+static void PIPEWIRECAMERA_FreeDeviceHandle(SDL_Camera *device)
 {
 }
 

+ 16 - 16
src/camera/v4l2/SDL_camera_v4l2.c

@@ -88,7 +88,7 @@ static int xioctl(int fh, int request, void *arg)
     return r;
 }
 
-static int V4L2_WaitDevice(SDL_CameraDevice *device)
+static int V4L2_WaitDevice(SDL_Camera *device)
 {
     const int fd = device->hidden->fd;
 
@@ -118,7 +118,7 @@ static int V4L2_WaitDevice(SDL_CameraDevice *device)
     return retval;
 }
 
-static int V4L2_AcquireFrame(SDL_CameraDevice *device, SDL_Surface *frame, Uint64 *timestampNS)
+static int V4L2_AcquireFrame(SDL_Camera *device, SDL_Surface *frame, Uint64 *timestampNS)
 {
     const int fd = device->hidden->fd;
     const io_method io = device->hidden->io;
@@ -232,7 +232,7 @@ static int V4L2_AcquireFrame(SDL_CameraDevice *device, SDL_Surface *frame, Uint6
     return 1;
 }
 
-static void V4L2_ReleaseFrame(SDL_CameraDevice *device, SDL_Surface *frame)
+static void V4L2_ReleaseFrame(SDL_Camera *device, SDL_Surface *frame)
 {
     struct v4l2_buffer buf;
     const int fd = device->hidden->fd;
@@ -289,7 +289,7 @@ static void V4L2_ReleaseFrame(SDL_CameraDevice *device, SDL_Surface *frame)
     }
 }
 
-static int EnqueueBuffers(SDL_CameraDevice *device)
+static int EnqueueBuffers(SDL_Camera *device)
 {
     const int fd = device->hidden->fd;
     const io_method io = device->hidden->io;
@@ -338,14 +338,14 @@ static int EnqueueBuffers(SDL_CameraDevice *device)
     return 0;
 }
 
-static int AllocBufferRead(SDL_CameraDevice *device, size_t buffer_size)
+static int AllocBufferRead(SDL_Camera *device, size_t buffer_size)
 {
     device->hidden->buffers[0].length = buffer_size;
     device->hidden->buffers[0].start = SDL_calloc(1, buffer_size);
     return device->hidden->buffers[0].start ? 0 : -1;
 }
 
-static int AllocBufferMmap(SDL_CameraDevice *device)
+static int AllocBufferMmap(SDL_Camera *device)
 {
     const int fd = device->hidden->fd;
     int i;
@@ -377,7 +377,7 @@ static int AllocBufferMmap(SDL_CameraDevice *device)
     return 0;
 }
 
-static int AllocBufferUserPtr(SDL_CameraDevice *device, size_t buffer_size)
+static int AllocBufferUserPtr(SDL_Camera *device, size_t buffer_size)
 {
     int i;
     for (i = 0; i < device->hidden->nb_buffers; ++i) {
@@ -419,7 +419,7 @@ static Uint32 format_sdl_to_v4l2(SDL_PixelFormat fmt)
     }
 }
 
-static void V4L2_CloseDevice(SDL_CameraDevice *device)
+static void V4L2_CloseDevice(SDL_Camera *device)
 {
     if (!device) {
         return;
@@ -470,7 +470,7 @@ static void V4L2_CloseDevice(SDL_CameraDevice *device)
     }
 }
 
-static int V4L2_OpenDevice(SDL_CameraDevice *device, const SDL_CameraSpec *spec)
+static int V4L2_OpenDevice(SDL_Camera *device, const SDL_CameraSpec *spec)
 {
     const V4L2DeviceHandle *handle = (const V4L2DeviceHandle *) device->handle;
     struct stat st;
@@ -634,12 +634,12 @@ static int V4L2_OpenDevice(SDL_CameraDevice *device, const SDL_CameraSpec *spec)
     }
 
     // Currently there is no user permission prompt for camera access, but maybe there will be a D-Bus portal interface at some point.
-    SDL_CameraDevicePermissionOutcome(device, SDL_TRUE);
+    SDL_CameraPermissionOutcome(device, SDL_TRUE);
 
     return 0;
 }
 
-static SDL_bool FindV4L2CameraDeviceByBusInfoCallback(SDL_CameraDevice *device, void *userdata)
+static SDL_bool FindV4L2CameraByBusInfoCallback(SDL_Camera *device, void *userdata)
 {
     const V4L2DeviceHandle *handle = (const V4L2DeviceHandle *) device->handle;
     return (SDL_strcmp(handle->bus_info, (const char *) userdata) == 0);
@@ -713,7 +713,7 @@ static void MaybeAddDevice(const char *path)
     } else if ((vcap.device_caps & V4L2_CAP_VIDEO_CAPTURE) == 0) {
         close(fd);
         return;  // not a video capture device.
-    } else if (SDL_FindPhysicalCameraDeviceByCallback(FindV4L2CameraDeviceByBusInfoCallback, vcap.bus_info)) {
+    } else if (SDL_FindPhysicalCameraByCallback(FindV4L2CameraByBusInfoCallback, vcap.bus_info)) {
         close(fd);
         return;  // already have it.
     }
@@ -795,7 +795,7 @@ static void MaybeAddDevice(const char *path)
             if (handle->path) {
                 handle->bus_info = SDL_strdup((char *)vcap.bus_info);
                 if (handle->bus_info) {
-                    if (SDL_AddCameraDevice((const char *) vcap.card, SDL_CAMERA_POSITION_UNKNOWN, add_data.num_specs, add_data.specs, handle)) {
+                    if (SDL_AddCamera((const char *) vcap.card, SDL_CAMERA_POSITION_UNKNOWN, add_data.num_specs, add_data.specs, handle)) {
                         SDL_free(add_data.specs);
                         return;  // good to go.
                     }
@@ -809,7 +809,7 @@ static void MaybeAddDevice(const char *path)
     SDL_free(add_data.specs);
 }
 
-static void V4L2_FreeDeviceHandle(SDL_CameraDevice *device)
+static void V4L2_FreeDeviceHandle(SDL_Camera *device)
 {
     if (device) {
         V4L2DeviceHandle *handle = (V4L2DeviceHandle *) device->handle;
@@ -820,7 +820,7 @@ static void V4L2_FreeDeviceHandle(SDL_CameraDevice *device)
 }
 
 #ifdef SDL_USE_LIBUDEV
-static SDL_bool FindV4L2CameraDeviceByPathCallback(SDL_CameraDevice *device, void *userdata)
+static SDL_bool FindV4L2CameraByPathCallback(SDL_Camera *device, void *userdata)
 {
     const V4L2DeviceHandle *handle = (const V4L2DeviceHandle *) device->handle;
     return (SDL_strcmp(handle->path, (const char *) userdata) == 0);
@@ -829,7 +829,7 @@ static SDL_bool FindV4L2CameraDeviceByPathCallback(SDL_CameraDevice *device, voi
 static void MaybeRemoveDevice(const char *path)
 {
     if (path) {
-        SDL_CameraDeviceDisconnected(SDL_FindPhysicalCameraDeviceByCallback(FindV4L2CameraDeviceByPathCallback, (void *) path));
+        SDL_CameraDisconnected(SDL_FindPhysicalCameraByCallback(FindV4L2CameraByPathCallback, (void *) path));
     }
 }
 

+ 6 - 6
src/dynapi/SDL_dynapi.sym

@@ -186,13 +186,13 @@ SDL3_0.0.0 {
     SDL_GetBooleanProperty;
     SDL_GetCPUCacheLineSize;
     SDL_GetCPUCount;
-    SDL_GetCameraDeviceName;
-    SDL_GetCameraDevicePosition;
-    SDL_GetCameraDeviceSupportedFormats;
-    SDL_GetCameraDevices;
+    SDL_GetCameraName;
+    SDL_GetCameraPosition;
+    SDL_GetCameraSupportedFormats;
+    SDL_GetCameras;
     SDL_GetCameraDriver;
     SDL_GetCameraFormat;
-    SDL_GetCameraInstanceID;
+    SDL_GetCameraID;
     SDL_GetCameraPermissionState;
     SDL_GetCameraProperties;
     SDL_GetClipboardData;
@@ -591,7 +591,7 @@ SDL3_0.0.0 {
     SDL_OnApplicationWillTerminate;
     SDL_OpenAudioDevice;
     SDL_OpenAudioDeviceStream;
-    SDL_OpenCameraDevice;
+    SDL_OpenCamera;
     SDL_OpenFileStorage;
     SDL_OpenGamepad;
     SDL_OpenHaptic;

+ 6 - 6
src/dynapi/SDL_dynapi_overrides.h

@@ -211,13 +211,13 @@
 #define SDL_GetBooleanProperty SDL_GetBooleanProperty_REAL
 #define SDL_GetCPUCacheLineSize SDL_GetCPUCacheLineSize_REAL
 #define SDL_GetCPUCount SDL_GetCPUCount_REAL
-#define SDL_GetCameraDeviceName SDL_GetCameraDeviceName_REAL
-#define SDL_GetCameraDevicePosition SDL_GetCameraDevicePosition_REAL
-#define SDL_GetCameraDeviceSupportedFormats SDL_GetCameraDeviceSupportedFormats_REAL
-#define SDL_GetCameraDevices SDL_GetCameraDevices_REAL
+#define SDL_GetCameraName SDL_GetCameraName_REAL
+#define SDL_GetCameraPosition SDL_GetCameraPosition_REAL
+#define SDL_GetCameraSupportedFormats SDL_GetCameraSupportedFormats_REAL
+#define SDL_GetCameras SDL_GetCameras_REAL
 #define SDL_GetCameraDriver SDL_GetCameraDriver_REAL
 #define SDL_GetCameraFormat SDL_GetCameraFormat_REAL
-#define SDL_GetCameraInstanceID SDL_GetCameraInstanceID_REAL
+#define SDL_GetCameraID SDL_GetCameraID_REAL
 #define SDL_GetCameraPermissionState SDL_GetCameraPermissionState_REAL
 #define SDL_GetCameraProperties SDL_GetCameraProperties_REAL
 #define SDL_GetClipboardData SDL_GetClipboardData_REAL
@@ -616,7 +616,7 @@
 #define SDL_OnApplicationWillTerminate SDL_OnApplicationWillTerminate_REAL
 #define SDL_OpenAudioDevice SDL_OpenAudioDevice_REAL
 #define SDL_OpenAudioDeviceStream SDL_OpenAudioDeviceStream_REAL
-#define SDL_OpenCameraDevice SDL_OpenCameraDevice_REAL
+#define SDL_OpenCamera SDL_OpenCamera_REAL
 #define SDL_OpenFileStorage SDL_OpenFileStorage_REAL
 #define SDL_OpenGamepad SDL_OpenGamepad_REAL
 #define SDL_OpenHaptic SDL_OpenHaptic_REAL

+ 6 - 6
src/dynapi/SDL_dynapi_procs.h

@@ -231,13 +231,13 @@ SDL_DYNAPI_PROC(char*,SDL_GetBasePath,(void),(),return)
 SDL_DYNAPI_PROC(SDL_bool,SDL_GetBooleanProperty,(SDL_PropertiesID a, const char *b, SDL_bool c),(a,b,c),return)
 SDL_DYNAPI_PROC(int,SDL_GetCPUCacheLineSize,(void),(),return)
 SDL_DYNAPI_PROC(int,SDL_GetCPUCount,(void),(),return)
-SDL_DYNAPI_PROC(const char*,SDL_GetCameraDeviceName,(SDL_CameraDeviceID a),(a),return)
-SDL_DYNAPI_PROC(SDL_CameraPosition,SDL_GetCameraDevicePosition,(SDL_CameraDeviceID a),(a),return)
-SDL_DYNAPI_PROC(SDL_CameraSpec*,SDL_GetCameraDeviceSupportedFormats,(SDL_CameraDeviceID a, int *b),(a,b),return)
-SDL_DYNAPI_PROC(SDL_CameraDeviceID*,SDL_GetCameraDevices,(int *a),(a),return)
+SDL_DYNAPI_PROC(const char*,SDL_GetCameraName,(SDL_CameraID a),(a),return)
+SDL_DYNAPI_PROC(SDL_CameraPosition,SDL_GetCameraPosition,(SDL_CameraID a),(a),return)
+SDL_DYNAPI_PROC(SDL_CameraSpec*,SDL_GetCameraSupportedFormats,(SDL_CameraID a, int *b),(a,b),return)
+SDL_DYNAPI_PROC(SDL_CameraID*,SDL_GetCameras,(int *a),(a),return)
 SDL_DYNAPI_PROC(const char*,SDL_GetCameraDriver,(int a),(a),return)
 SDL_DYNAPI_PROC(int,SDL_GetCameraFormat,(SDL_Camera *a, SDL_CameraSpec *b),(a,b),return)
-SDL_DYNAPI_PROC(SDL_CameraDeviceID,SDL_GetCameraInstanceID,(SDL_Camera *a),(a),return)
+SDL_DYNAPI_PROC(SDL_CameraID,SDL_GetCameraID,(SDL_Camera *a),(a),return)
 SDL_DYNAPI_PROC(int,SDL_GetCameraPermissionState,(SDL_Camera *a),(a),return)
 SDL_DYNAPI_PROC(SDL_PropertiesID,SDL_GetCameraProperties,(SDL_Camera *a),(a),return)
 SDL_DYNAPI_PROC(void*,SDL_GetClipboardData,(const char *a, size_t *b),(a,b),return)
@@ -627,7 +627,7 @@ SDL_DYNAPI_PROC(void,SDL_OnApplicationWillResignActive,(void),(),)
 SDL_DYNAPI_PROC(void,SDL_OnApplicationWillTerminate,(void),(),)
 SDL_DYNAPI_PROC(SDL_AudioDeviceID,SDL_OpenAudioDevice,(SDL_AudioDeviceID a, const SDL_AudioSpec *b),(a,b),return)
 SDL_DYNAPI_PROC(SDL_AudioStream*,SDL_OpenAudioDeviceStream,(SDL_AudioDeviceID a, const SDL_AudioSpec *b, SDL_AudioStreamCallback c, void *d),(a,b,c,d),return)
-SDL_DYNAPI_PROC(SDL_Camera*,SDL_OpenCameraDevice,(SDL_CameraDeviceID a, const SDL_CameraSpec *b),(a,b),return)
+SDL_DYNAPI_PROC(SDL_Camera*,SDL_OpenCamera,(SDL_CameraID a, const SDL_CameraSpec *b),(a,b),return)
 SDL_DYNAPI_PROC(SDL_Storage*,SDL_OpenFileStorage,(const char *a),(a),return)
 SDL_DYNAPI_PROC(SDL_Gamepad*,SDL_OpenGamepad,(SDL_JoystickID a),(a),return)
 SDL_DYNAPI_PROC(SDL_Haptic*,SDL_OpenHaptic,(SDL_HapticID a),(a),return)

+ 13 - 13
test/testcamera.c

@@ -23,8 +23,8 @@ static SDL_CameraSpec spec;
 static SDL_Texture *texture = NULL;
 static SDL_bool texture_updated = SDL_FALSE;
 static SDL_Surface *frame_current = NULL;
-static SDL_CameraDeviceID front_camera = 0;
-static SDL_CameraDeviceID back_camera = 0;
+static SDL_CameraID front_camera = 0;
+static SDL_CameraID back_camera = 0;
 
 int SDL_AppInit(void **appstate, int argc, char *argv[])
 {
@@ -87,19 +87,19 @@ int SDL_AppInit(void **appstate, int argc, char *argv[])
         return SDL_APP_FAILURE;
     }
 
-    SDL_CameraDeviceID *devices = SDL_GetCameraDevices(&devcount);
+    SDL_CameraID *devices = SDL_GetCameras(&devcount);
     if (!devices) {
-        SDL_Log("SDL_GetCameraDevices failed: %s", SDL_GetError());
+        SDL_Log("SDL_GetCameras failed: %s", SDL_GetError());
         return SDL_APP_FAILURE;
     }
 
-    SDL_CameraDeviceID camera_id = 0;
+    SDL_CameraID camera_id = 0;
 
     SDL_Log("Saw %d camera devices.", devcount);
     for (i = 0; i < devcount; i++) {
-        const SDL_CameraDeviceID device = devices[i];
-        const char *name = SDL_GetCameraDeviceName(device);
-        const SDL_CameraPosition position = SDL_GetCameraDevicePosition(device);
+        const SDL_CameraID device = devices[i];
+        const char *name = SDL_GetCameraName(device);
+        const SDL_CameraPosition position = SDL_GetCameraPosition(device);
         const char *posstr = "";
         if (position == SDL_CAMERA_POSITION_FRONT_FACING) {
             front_camera = device;
@@ -137,13 +137,13 @@ int SDL_AppInit(void **appstate, int argc, char *argv[])
     spec.framerate_numerator = 1000;
     spec.framerate_denominator = 1;
 
-    camera = SDL_OpenCameraDevice(camera_id, pspec);
+    camera = SDL_OpenCamera(camera_id, pspec);
     if (!camera) {
         SDL_Log("Failed to open camera device: %s", SDL_GetError());
         return SDL_APP_FAILURE;
     }
 
-    SDL_snprintf(window_title, sizeof (window_title), "testcamera: %s (%s)", SDL_GetCameraDeviceName(camera_id), SDL_GetCurrentCameraDriver());
+    SDL_snprintf(window_title, sizeof (window_title), "testcamera: %s (%s)", SDL_GetCameraName(camera_id), SDL_GetCurrentCameraDriver());
     SDL_SetWindowTitle(window, window_title);
 
     return SDL_APP_CONTINUE;
@@ -158,8 +158,8 @@ static int FlipCamera(void)
     }
 
     if (camera) {
-        const SDL_CameraDeviceID current = SDL_GetCameraInstanceID(camera);
-        SDL_CameraDeviceID nextcam = 0;
+        const SDL_CameraID current = SDL_GetCameraID(camera);
+        SDL_CameraID nextcam = 0;
         if (current == front_camera) {
             nextcam = back_camera;
         } else if (current == back_camera) {
@@ -181,7 +181,7 @@ static int FlipCamera(void)
                 texture = NULL;  /* will rebuild when new camera is approved. */
             }
 
-            camera = SDL_OpenCameraDevice(nextcam, NULL);
+            camera = SDL_OpenCamera(nextcam, NULL);
             if (!camera) {
                 SDL_Log("Failed to open camera device: %s", SDL_GetError());
                 return SDL_APP_FAILURE;