v4l2: select best camera option by default

Display all camera options in --info and --list-v4l2-devices.
Add camera_width, camera_height and camera_fps v4l2 capture options.
This commit is contained in:
dec05eba
2026-01-15 20:03:23 +01:00
parent b2f0d13512
commit 8af761f9bd
5 changed files with 406 additions and 70 deletions

View File

@@ -10,21 +10,35 @@ typedef enum {
} gsr_capture_v4l2_pixfmt;
typedef struct {
bool yuyv;
bool mjpeg;
} gsr_capture_v4l2_supported_pixfmts;
uint32_t width;
uint32_t height;
} gsr_capture_v4l2_resolution;
typedef struct {
uint32_t denominator;
uint32_t numerator;
} gsr_capture_v4l2_framerate;
typedef struct {
gsr_capture_v4l2_pixfmt pixfmt;
gsr_capture_v4l2_resolution resolution;
gsr_capture_v4l2_framerate framerate;
} gsr_capture_v4l2_supported_setup;
typedef struct {
gsr_egl *egl;
vec2i output_resolution;
const char *device_path;
gsr_capture_v4l2_pixfmt pixfmt;
int fps;
uint32_t camera_fps; /* Set to 0 if the best option should be chosen */
gsr_capture_v4l2_resolution camera_resolution; /* Set to 0, 0 if the best option should be chosen */
} gsr_capture_v4l2_params;
gsr_capture* gsr_capture_v4l2_create(const gsr_capture_v4l2_params *params);
typedef void (*v4l2_devices_query_callback)(const char *path, gsr_capture_v4l2_supported_pixfmts supported_pixfmts, vec2i size, void *userdata);
const char* gsr_capture_v4l2_pixfmt_to_string(gsr_capture_v4l2_pixfmt pixfmt);
uint32_t gsr_capture_v4l2_framerate_to_number(gsr_capture_v4l2_framerate framerate);
typedef void (*v4l2_devices_query_callback)(const char *path, const gsr_capture_v4l2_supported_setup *supported_setup, void *userdata);
void gsr_capture_v4l2_list_devices(v4l2_devices_query_callback callback, void *userdata);
#endif /* GSR_CAPTURE_V4L2_H */