int check_capture_capabilities_v4l2(int fd, char *file) { struct v4l2_capability cap; dprint(LIBV4L_LOG_SOURCE_CAPTURE, LIBV4L_LOG_LEVEL_DEBUG, "CAP: Checking capture device\n"); CLEAR(cap); if (-1 == check_v4l2(fd, &cap)) { dprint(LIBV4L_LOG_SOURCE_CAPTURE, LIBV4L_LOG_LEVEL_ERR, "CAP: Not a V4L2 device.\n"); return -1; } if (!(cap.capabilities & V4L2_CAP_VIDEO_CAPTURE)) { info("The device %s seems to be a valid V4L2 device but without capture capability.\n", file); info("Please let the author know about this error.\n"); info("See the ISSUES section in the libv4l README file.\n"); info("Listing the reported capabilities:\n"); list_cap_v4l2(fd); return -1; } if (!(cap.capabilities & V4L2_CAP_STREAMING)) { info("The device %s seems to be a valid V4L2 device with capture capability, but\n", file); info("the device does NOT support streaming. Please let the author know about this error.\n"); info("See the ISSUES section in the libv4l README file.\n"); info("Listing the reported capabilities:\n"); list_cap_v4l2(fd); return -1; } return 0; }
int set_cap_param_v4l2(struct video_device *vdev, int *palettes, int nb) { struct capture_device *c = vdev->capture; int ret = 0; int def[NB_SUPPORTED_PALETTE] = DEFAULT_PALETTE_ORDER; dprint(LIBVIDEO_SOURCE_CAP, LIBVIDEO_LOG_DEBUG, "CAP: Setting capture parameters on device %s.\n", vdev->file); if(nb<0 || nb>=NB_SUPPORTED_PALETTE) { dprint(LIBVIDEO_SOURCE_CAP, LIBVIDEO_LOG_ERR, "CAP: Incorrect number of palettes (%d)\n", nb); return LIBVIDEO_ERR_FORMAT; } if(nb==0 || palettes==NULL) { dprint(LIBVIDEO_SOURCE_CAP, LIBVIDEO_LOG_DEBUG, "CAP: No palettes supplied, trying default order.\n"); palettes = def; nb = NB_SUPPORTED_PALETTE; } //set desired standard if (set_std(c, vdev->fd) !=0 ) { ret = LIBVIDEO_ERR_STD; goto fail; } //set desired input if (set_input(c, vdev->fd) != 0) { ret = LIBVIDEO_ERR_CHANNEL; goto fail; } //Set image format if (set_image_format(c, palettes, nb, vdev->fd) != 0) { ret = LIBVIDEO_ERR_FORMAT; goto fail; } //Set crop format if (set_crop(c, vdev->fd) != 0) { info("Listing the reported capabilities:\n"); ret = LIBVIDEO_ERR_CROP; goto fail; } //set FPS set_param(c, vdev->fd); return ret; fail: info("Listing the reported capabilities:\n"); list_cap_v4l2(vdev->fd); return ret; }