(import foreign) (require-extension foreigners) (require-extension srfi-13) #> #include #include #include #include #include #include #include #include <# (define-foreign-enum-type (v4l2_buf_type int) (v4l2_buf_type->int int->v4l2_buf_type) (V4L2_BUF_TYPE_VIDEO_CAPTURE V4L2_BUF_TYPE_VIDEO_CAPTURE 1) (V4L2_BUF_TYPE_VIDEO_OUTPUT V4L2_BUF_TYPE_VIDEO_OUTPUT 2) (V4L2_BUF_TYPE_VIDEO_OVERLAY V4L2_BUF_TYPE_VIDEO_OVERLAY 3) (V4L2_BUF_TYPE_VBI_CAPTURE V4L2_BUF_TYPE_VBI_CAPTURE 4) (V4L2_BUF_TYPE_VBI_OUTPUT V4L2_BUF_TYPE_VBI_OUTPUT 5) (V4L2_BUF_TYPE_SLICED_VBI_CAPTURE V4L2_BUF_TYPE_SLICED_VBI_CAPTURE 6) (V4L2_BUF_TYPE_SLICED_VBI_OUTPUT V4L2_BUF_TYPE_SLICED_VBI_OUTPUT 7) (V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY 8) (V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE 9) (V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE 10) (V4L2_BUF_TYPE_SDR_CAPTURE V4L2_BUF_TYPE_SDR_CAPTURE 11) (V4L2_BUF_TYPE_SDR_OUTPUT V4L2_BUF_TYPE_SDR_OUTPUT 12)) (define-foreign-enum-type (v4l2_memory int) (v4l2_memory->int int->v4l2_memory) (V4L2_MEMORY_MMAP V4L2_MEMORY_MMAP 1) (V4L2_MEMORY_USERPTR V4L2_MEMORY_USERPTR 2) (V4L2_MEMORY_OVERLAY V4L2_MEMORY_OVERLAY 3) (V4L2_MEMORY_DMABUF V4L2_MEMORY_DMABUF 4)) (define-foreign-record-type buffer ((c-pointer void) start get-buffer-start set-buffer-start!) (size_t length get-buffer-length set-buffer-length!)) (define-foreign-record-type (v4l2-rect "struct v4l2_rect") (int32 left v4l2-rect-left set-v4l2-rect-left!) (int32 top v4l2-rect-top set-v4l2-rect-top!) (unsigned-int32 width v4l2-rect-width set-v4l2-rect-width!) (unsigned-int32 height v4l2-rect-height set-v4l2-rect-height!)) (define-foreign-record-type (v4l2-fract "struct v4l2_fract") (unsigned-int32 numerator v4l2-fract-numerator set-v4l2-fract-numerator!) (unsigned-int32 denominator v4l2-fract-denominator set-v4l2-fract-denominator!)) (define-foreign-record-type (v4l2-pix-format "struct v4l2_pix_format") (unsigned-int32 width v4l2-pix-format-width set-v4l2-pix-format-width!) (unsigned-int32 height v4l2-pix-format-height set-v4l2-pix-format-height!) (unsigned-int32 pixelformat v4l2-pix-format-pixelformat set-v4l2-pix-format-pixelformat!) (unsigned-int32 field v4l2-pix-format-field set-v4l2-pix-format-field!) (unsigned-int32 bytesperline v4l2-pix-fomat-bytesperline set-v4l2-pix-format-bytesperline!) (unsigned-int32 sizeimage v4l2-pix-format-sizeimage set-v4l2-pix-format-sizeimage!) (unsigned-int32 colorspace v4l2-pix-format-colorspace set-v4l2-pix-format-colorspace!) (unsigned-int32 priv v4l2-pix-format-priv set-v4l2-pix-format-priv!) (unsigned-int32 flags v4l2-pix-format-flags set-v4l2-pix-format-flags!) (unsigned-int32 ycbcr_enc v4l2-pix-format-ycbcr-enc set-v4l2-pix-format-ycbcr-enc!) (unsigned-int32 quantization v4l2-pix-format-quantization set-v4l2-pix-format-quantization!) (unsigned-int32 xfer_func v4l2-pix-format-xfer-func set-v4l2-pix-format-xfer-func!)) (define v4l2-format-fmt-pix (foreign-lambda* v4l2-pix-format ((c-pointer format)) "C_return(((struct v4l2_format *)format)->fmt.pix);")) (define-foreign-record-type (v4l2-format "struct v4l2_format") ((union "fmt") fmt v4l2-format-fmt) (unsigned-int32 type v4l2-format-type set-v4l2-format-type!)) (define-foreign-record-type (v4l2-capability "struct v4l2_capability") ((c-pointer u8vector) driver v4l2-capability-driver) ((c-pointer u8vector) card v4l2-capability-card) ((c-pointer u8vector) bus_info v4l2-capability-bus-info) (unsigned-int32 version v4l2-capability-version) (unsigned-int32 capabilities v4l2-capability-capabilities) (unsigned-int32 device_caps v4l2-capability-device-caps)) (define-foreign-record-type (v4l2-cropcap "struct v4l2_cropcap") (unsigned-int32 type v4l2-cropcap-type set-v4l2-cropcap-type!) ((struct v4l2-rect) bounds v4l2-cropcap-bounds set-v4l2-cropcap-bounds!) ((struct v4l2-rect) defrect v4l2-cropcap-defrect set-v4l2-cropcap-defrect!) ((struct v4l2-fract) pixelaspect v4l2-cropcap-pixelaspect set-v4l2-copcap-pixelaspect!)) (define-foreign-record-type (v4l2-crop "struct v4l2_crop") (unsigned-int32 type v4l2-crop-type set-v4l2-type!) ((struct v4l2-rect) c v4l2-crop-c set-v4l2-crop-c!)) (define-foreign-record-type (v4l2-requestbuffers "struct v4l2_requestbuffers") (unsigned-int32 count v4l2-requestbuffers-count set-v4l2-requestbuffers-count!) (unsigned-int32 type v4l2-requestbuffers-type set-v4l2-requestbuffers-type!) (unsigned-int32 memory v4l2-requestbuffers-memory set-v4l2-requestbuffers-memory!)) (define v4l2-buffer-m-offset (foreign-lambda* unsigned-int32 ((v4l2-buffer buf)) "C_return(buf->m.offset);")) (define-foreign-record-type (v4l2-buffer "struct v4l2_buffer") (unsigned-int32 index v4l2-buffer-index set-v4l2-buffer-index!) (unsigned-int32 type v4l2-buffer-type set-v4l2-buffer-type!) (unsigned-int32 bytesused v4l2-buffer-bytesused) (unsigned-int32 flags v4l2-buffer-flags set-v4l2-buffer-flags!) (unsigned-int32 field v4l2-buffer-field) ((struct timeval) timestamp v4l2-buffer-timestamp) ((struct v4l2-timecode) timecode v4l2-buffer-timecode) (unsigned-int32 memory v4l2-buffer-memory) (unsigned-int32 length v4l2-buffer-length))