Ejemplo n.º 1
0
static int _open_setup(VideoPhonePlugin * video)
{
	int ret;
	struct v4l2_cropcap cropcap;
	struct v4l2_crop crop;
	GError * error = NULL;

	/* check for capabilities */
	if(_video_ioctl(video, VIDIOC_QUERYCAP, &video->cap) == -1)
		return -error_set_code(1, "%s: %s (%s)", video->device,
				"Could not obtain the capabilities",
				strerror(errno));
	if((video->cap.capabilities & V4L2_CAP_VIDEO_CAPTURE) == 0)
		return -error_set_code(1, "%s: %s", video->device,
				"Not a video capture device");
	/* reset cropping */
	memset(&cropcap, 0, sizeof(cropcap));
	cropcap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
	if(_video_ioctl(video, VIDIOC_CROPCAP, &cropcap) == 0)
	{
		/* reset to default */
		crop.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
		crop.c = cropcap.defrect;
		if(_video_ioctl(video, VIDIOC_S_CROP, &crop) == -1
				&& errno == EINVAL)
			/* XXX ignore this error for now */
			error_set_code(1, "%s: %s", video->device,
					"Cropping not supported");
	}
	/* obtain the current format */
	if(_video_ioctl(video, VIDIOC_G_FMT, &video->format) == -1)
		return -error_set_code(1, "%s: %s", video->device,
				"Could not obtain the video capture format");
	/* check the current format */
	if(video->format.type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
		return -error_set_code(1, "%s: %s", video->device,
				"Unsupported video capture type");
	if((video->cap.capabilities & V4L2_CAP_STREAMING) != 0)
#ifdef NOTYET
		ret = _open_setup_mmap(video);
#else
		ret = _open_setup_read(video);
#endif
	else if((video->cap.capabilities & V4L2_CAP_READWRITE) != 0)
Ejemplo n.º 2
0
	/* obtain the current format */
	if(_video_ioctl(video, VIDIOC_G_FMT, &video->format) == -1)
		return -error_set_code(1, "%s: %s", video->device,
				"Could not obtain the video capture format");
	/* check the current format */
	if(video->format.type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
		return -error_set_code(1, "%s: %s", video->device,
				"Unsupported video capture type");
	if((video->cap.capabilities & V4L2_CAP_STREAMING) != 0)
#ifdef NOTYET
		ret = _open_setup_mmap(video);
#else
		ret = _open_setup_read(video);
#endif
	else if((video->cap.capabilities & V4L2_CAP_READWRITE) != 0)
		ret = _open_setup_read(video);
	else
		ret = -error_set_code(1, "%s: %s", video->device,
				"Unsupported capabilities");
	if(ret != 0)
		return ret;
	/* setup a IO channel */
	video->channel = g_io_channel_unix_new(video->fd);
	if(g_io_channel_set_encoding(video->channel, NULL, &error)
			!= G_IO_STATUS_NORMAL)
	{
		error_set_code(1, "%s", error->message);
		g_error_free(error);
		return -1;
	}
	g_io_channel_set_buffered(video->channel, FALSE);
Ejemplo n.º 3
0
	/* obtain the current format */
	if(_camera_ioctl(camera, VIDIOC_G_FMT, &camera->format) == -1)
		return -error_set_code(1, "%s: %s", camera->device,
				_("Could not obtain the video capture format"));
	/* check the current format */
	if(camera->format.type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
		return -error_set_code(1, "%s: %s", camera->device,
				_("Unsupported video capture type"));
	if((camera->cap.capabilities & V4L2_CAP_STREAMING) != 0)
#ifdef NOTYET
		ret = _open_setup_mmap(camera);
#else
		ret = _open_setup_read(camera);
#endif
	else if((camera->cap.capabilities & V4L2_CAP_READWRITE) != 0)
		ret = _open_setup_read(camera);
	else
		ret = -error_set_code(1, "%s: %s", camera->device,
				_("Unsupported capabilities"));
	if(ret != 0)
		return ret;
	/* setup an I/O channel */
	camera->channel = g_io_channel_unix_new(camera->fd);
	if(g_io_channel_set_encoding(camera->channel, NULL, &error)
			!= G_IO_STATUS_NORMAL)
	{
		error_set_code(1, "%s", error->message);
		g_error_free(error);
		return -1;
	}
	g_io_channel_set_buffered(camera->channel, FALSE);