Browse Source

camera: Public API functions should say "Format" not "Spec" to match audio.

Ryan C. Gordon 1 year ago
parent
commit
87e7046fca

+ 5 - 5
include/SDL3/SDL_camera.h

@@ -57,8 +57,8 @@ typedef struct SDL_Camera SDL_Camera;
 /**
  *  SDL_CameraSpec structure
  *
- * \sa SDL_GetCameraDeviceSupportedSpecs
- * \sa SDL_GetCameraSpec
+ * \sa SDL_GetCameraDeviceSupportedFormats
+ * \sa SDL_GetCameraFormat
  *
  */
 typedef struct SDL_CameraSpec
@@ -182,7 +182,7 @@ extern DECLSPEC SDL_CameraDeviceID *SDLCALL SDL_GetCameraDevices(int *count);
  * \sa SDL_GetCameraDevices
  * \sa SDL_OpenCameraDevice
  */
-extern DECLSPEC SDL_CameraSpec *SDLCALL SDL_GetCameraDeviceSupportedSpecs(SDL_CameraDeviceID devid, int *count);
+extern DECLSPEC SDL_CameraSpec *SDLCALL SDL_GetCameraDeviceSupportedFormats(SDL_CameraDeviceID devid, int *count);
 
 /**
  * Get human-readable device name for a camera.
@@ -212,7 +212,7 @@ extern DECLSPEC char * SDLCALL SDL_GetCameraDeviceName(SDL_CameraDeviceID instan
  * pass a NULL spec here and it will choose one for you (and you can use
  * SDL_Surface's conversion/scaling functions directly if necessary).
  *
- * You can call SDL_GetCameraSpec() to get the actual data format if
+ * You can call SDL_GetCameraFormat() to get the actual data format if
  * passing a NULL spec here. You can see the exact specs a device can
  * support without conversion with SDL_GetCameraSupportedSpecs().
  *
@@ -279,7 +279,7 @@ extern DECLSPEC SDL_PropertiesID SDLCALL SDL_GetCameraProperties(SDL_Camera *cam
  *
  * \sa SDL_OpenCameraDevice
  */
-extern DECLSPEC int SDLCALL SDL_GetCameraSpec(SDL_Camera *camera, SDL_CameraSpec *spec);
+extern DECLSPEC int SDLCALL SDL_GetCameraFormat(SDL_Camera *camera, SDL_CameraSpec *spec);
 
 /**
  * Acquire a frame.

+ 2 - 2
src/camera/SDL_camera.c

@@ -407,7 +407,7 @@ void SDL_CloseCamera(SDL_Camera *camera)
     ClosePhysicalCameraDevice(device);
 }
 
-int SDL_GetCameraSpec(SDL_Camera *camera, SDL_CameraSpec *spec)
+int SDL_GetCameraFormat(SDL_Camera *camera, SDL_CameraSpec *spec)
 {
     if (!camera) {
         return SDL_InvalidParamError("camera");
@@ -469,7 +469,7 @@ SDL_CameraDeviceID *SDL_GetCameraDevices(int *count)
 
 }
 
-SDL_CameraSpec *SDL_GetCameraDeviceSupportedSpecs(SDL_CameraDeviceID instance_id, int *count)
+SDL_CameraSpec *SDL_GetCameraDeviceSupportedFormats(SDL_CameraDeviceID instance_id, int *count)
 {
     if (count) {
         *count = 0;

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

@@ -611,14 +611,14 @@ static SDL_bool FindV4L2CameraDeviceByBusInfoCallback(SDL_CameraDevice *device,
     return (SDL_strcmp(handle->bus_info, (const char *) userdata) == 0);
 }
 
-typedef struct SpecAddData
+typedef struct FormatAddData
 {
     SDL_CameraSpec *specs;
     int num_specs;
     int allocated_specs;
-} SpecAddData;
+} FormatAddData;
 
-static int AddCameraSpec(SpecAddData *data, Uint32 fmt, int w, int h)
+static int AddCameraFormat(FormatAddData *data, Uint32 fmt, int w, int h)
 {
     SDL_assert(data != NULL);
     if (data->allocated_specs <= data->num_specs) {
@@ -676,7 +676,7 @@ static void MaybeAddDevice(const char *path)
     SDL_Log("CAMERA: V4L2 camera path='%s' bus_info='%s' name='%s'", path, (const char *) vcap.bus_info, vcap.card);
     #endif
 
-    SpecAddData add_data;
+    FormatAddData add_data;
     SDL_zero(add_data);
 
     struct v4l2_fmtdesc fmtdesc;
@@ -709,7 +709,7 @@ static void MaybeAddDevice(const char *path)
                 #if DEBUG_CAMERA
                 SDL_Log("CAMERA:     * Has discrete size %dx%d", w, h);
                 #endif
-                if (AddCameraSpec(&add_data, sdlfmt, w, h) == -1) {
+                if (AddCameraFormat(&add_data, sdlfmt, w, h) == -1) {
                     break;  // Probably out of memory; we'll go with what we have, if anything.
                 }
                 frmsizeenum.index++;  // set up for the next one.
@@ -725,7 +725,7 @@ static void MaybeAddDevice(const char *path)
                         #if DEBUG_CAMERA
                         SDL_Log("CAMERA:     * Has %s size %dx%d", (frmsizeenum.type == V4L2_FRMSIZE_TYPE_STEPWISE) ? "stepwise" : "continuous", w, h);
                         #endif
-                        if (AddCameraSpec(&add_data, sdlfmt, w, h) == -1) {
+                        if (AddCameraFormat(&add_data, sdlfmt, w, h) == -1) {
                             break;  // Probably out of memory; we'll go with what we have, if anything.
                         }
 

+ 2 - 2
src/dynapi/SDL_dynapi.sym

@@ -961,12 +961,12 @@ SDL3_0.0.0 {
     SDL_GetCameraDriver;
     SDL_GetCurrentCameraDriver;
     SDL_GetCameraDevices;
-    SDL_GetCameraDeviceSupportedSpecs;
+    SDL_GetCameraDeviceSupportedFormats;
     SDL_GetCameraDeviceName;
     SDL_OpenCameraDevice;
     SDL_GetCameraInstanceID;
     SDL_GetCameraProperties;
-    SDL_GetCameraSpec;
+    SDL_GetCameraFormat;
     SDL_AcquireCameraFrame;
     SDL_ReleaseCameraFrame;
     SDL_CloseCamera;

+ 2 - 2
src/dynapi/SDL_dynapi_overrides.h

@@ -986,12 +986,12 @@
 #define SDL_GetCameraDriver SDL_GetCameraDriver_REAL
 #define SDL_GetCurrentCameraDriver SDL_GetCurrentCameraDriver_REAL
 #define SDL_GetCameraDevices SDL_GetCameraDevices_REAL
-#define SDL_GetCameraDeviceSupportedSpecs SDL_GetCameraDeviceSupportedSpecs_REAL
+#define SDL_GetCameraDeviceSupportedFormats SDL_GetCameraDeviceSupportedFormats_REAL
 #define SDL_GetCameraDeviceName SDL_GetCameraDeviceName_REAL
 #define SDL_OpenCameraDevice SDL_OpenCameraDevice_REAL
 #define SDL_GetCameraInstanceID SDL_GetCameraInstanceID_REAL
 #define SDL_GetCameraProperties SDL_GetCameraProperties_REAL
-#define SDL_GetCameraSpec SDL_GetCameraSpec_REAL
+#define SDL_GetCameraFormat SDL_GetCameraFormat_REAL
 #define SDL_AcquireCameraFrame SDL_AcquireCameraFrame_REAL
 #define SDL_ReleaseCameraFrame SDL_ReleaseCameraFrame_REAL
 #define SDL_CloseCamera SDL_CloseCamera_REAL

+ 2 - 2
src/dynapi/SDL_dynapi_procs.h

@@ -1011,12 +1011,12 @@ SDL_DYNAPI_PROC(int,SDL_GetNumCameraDrivers,(void),(),return)
 SDL_DYNAPI_PROC(const char*,SDL_GetCameraDriver,(int a),(a),return)
 SDL_DYNAPI_PROC(const char*,SDL_GetCurrentCameraDriver,(void),(),return)
 SDL_DYNAPI_PROC(SDL_CameraDeviceID*,SDL_GetCameraDevices,(int *a),(a),return)
-SDL_DYNAPI_PROC(SDL_CameraSpec*,SDL_GetCameraDeviceSupportedSpecs,(SDL_CameraDeviceID a, int *b),(a,b),return)
+SDL_DYNAPI_PROC(SDL_CameraSpec*,SDL_GetCameraDeviceSupportedFormats,(SDL_CameraDeviceID a, int *b),(a,b),return)
 SDL_DYNAPI_PROC(char*,SDL_GetCameraDeviceName,(SDL_CameraDeviceID a),(a),return)
 SDL_DYNAPI_PROC(SDL_Camera*,SDL_OpenCameraDevice,(SDL_CameraDeviceID a, const SDL_CameraSpec *b),(a,b),return)
 SDL_DYNAPI_PROC(SDL_CameraDeviceID,SDL_GetCameraInstanceID,(SDL_Camera *a),(a),return)
 SDL_DYNAPI_PROC(SDL_PropertiesID,SDL_GetCameraProperties,(SDL_Camera *a),(a),return)
-SDL_DYNAPI_PROC(int,SDL_GetCameraSpec,(SDL_Camera *a, SDL_CameraSpec *b),(a,b),return)
+SDL_DYNAPI_PROC(int,SDL_GetCameraFormat,(SDL_Camera *a, SDL_CameraSpec *b),(a,b),return)
 SDL_DYNAPI_PROC(SDL_Surface*,SDL_AcquireCameraFrame,(SDL_Camera *a, Uint64 *b),(a,b),return)
 SDL_DYNAPI_PROC(int,SDL_ReleaseCameraFrame,(SDL_Camera *a, SDL_Surface *b),(a,b),return)
 SDL_DYNAPI_PROC(void,SDL_CloseCamera,(SDL_Camera *a),(a),)

+ 1 - 1
test/testcamera.c

@@ -284,7 +284,7 @@ int main(int argc, char **argv)
 
     {
         SDL_CameraSpec spec;
-        if (SDL_GetCameraSpec(device, &spec) == 0) {
+        if (SDL_GetCameraFormat(device, &spec) == 0) {
             SDL_Log("Read spec: size=%d x %d format=%s",
                     spec.width, spec.height, SDL_GetPixelFormatName(spec.format));
         } else {

+ 1 - 1
test/testcameraminimal.c

@@ -94,7 +94,7 @@ int main(int argc, char **argv)
         return 1;
     }
 
-   if (SDL_GetCameraSpec(camera, &spec) < 0) {
+   if (SDL_GetCameraFormat(camera, &spec) < 0) {
         SDL_Log("Couldn't get camera spec: %s", SDL_GetError());
         return 1;
     }