Esempio n. 1
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;
}
Esempio n. 2
0
/* open Video4Linux2 device and try to set up certain parameters */
MjpegCamera::MjpegCamera(const char *device) {
	buffers = NULL;
	n_buffers = 0;

	fd = open(device, O_RDWR);
	if (fd == -1) {
		throw POSIXError("open v4l device");
	}

	set_image_format( );
	set_frame_rate( );
	map_frame_buffers( );
	queue_all_buffers( );
	
}
Esempio n. 3
0
/* open Video4Linux2 device and try to set up certain parameters */
V4L2UpscaledInputAdapter::V4L2UpscaledInputAdapter(const char *device) 
        : out_pipe(256) {
    buffers = NULL;
    n_buffers = 0;

    fd = open(device, O_RDWR);
    if (fd == -1) {
        throw POSIXError("open v4l device");
    }

    set_image_format( );
    map_frame_buffers( );
    queue_all_buffers( );
    stream_on( );
    start_thread( );    
}