mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-18 15:51:11 +00:00
Fix set_caps to set width and height to the values the driver is really working with.
Original commit message from CVS: Fix set_caps to set width and height to the values the driver is really working with.
This commit is contained in:
parent
e91b76790c
commit
d7ef60b0c4
3 changed files with 44 additions and 12 deletions
|
@ -807,12 +807,15 @@ gst_v4l2src_set_caps (GstBaseSrc * src, GstCaps * caps)
|
|||
GST_DEBUG_OBJECT (v4l2src, "trying to set_capture %dx%d, format %s",
|
||||
w, h, format->description);
|
||||
/* this only fills in v4l2src->mmap values */
|
||||
if (!gst_v4l2src_set_capture (v4l2src, format, w, h)) {
|
||||
if (!gst_v4l2src_set_capture (v4l2src, format, &w, &h)) {
|
||||
GST_WARNING_OBJECT (v4l2src, "could not set_capture %dx%d, format %s",
|
||||
w, h, format->description);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gst_structure_set (structure, "width", G_TYPE_INT, w, "height", G_TYPE_INT, h,
|
||||
NULL);
|
||||
|
||||
if (!gst_v4l2src_capture_init (v4l2src))
|
||||
return FALSE;
|
||||
|
||||
|
@ -881,8 +884,9 @@ gst_v4l2src_get_read (GstV4l2Src * v4l2src, GstBuffer ** buf)
|
|||
continue;
|
||||
} else {
|
||||
GST_ELEMENT_ERROR (v4l2src, RESOURCE, SYNC, (NULL),
|
||||
("error read()ing a buffer on device %s: %s",
|
||||
v4l2src->v4l2object->videodev, g_strerror (errno)));
|
||||
("error read()ing %d bytes on device %s: %d - %s",
|
||||
buffersize, v4l2src->v4l2object->videodev, errno,
|
||||
g_strerror (errno)));
|
||||
gst_buffer_unref (*buf);
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
|
|
|
@ -219,6 +219,7 @@ gst_v4l2src_get_capture (GstV4l2Src * v4l2src)
|
|||
|
||||
GST_V4L2_CHECK_OPEN (v4l2src->v4l2object);
|
||||
|
||||
memset (&v4l2src->format, 0, sizeof (struct v4l2_format));
|
||||
v4l2src->format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
if (ioctl (v4l2src->v4l2object->video_fd, VIDIOC_G_FMT, &v4l2src->format) < 0) {
|
||||
GST_ELEMENT_ERROR (v4l2src, RESOURCE, SETTINGS, (NULL),
|
||||
|
@ -239,17 +240,20 @@ gst_v4l2src_get_capture (GstV4l2Src * v4l2src)
|
|||
|
||||
gboolean
|
||||
gst_v4l2src_set_capture (GstV4l2Src * v4l2src,
|
||||
struct v4l2_fmtdesc * fmt, gint width, gint height)
|
||||
struct v4l2_fmtdesc * fmt, gint * width, gint * height)
|
||||
{
|
||||
DEBUG ("Setting capture format to %dx%d, format %s",
|
||||
width, height, fmt->description);
|
||||
*width, *height, fmt->description);
|
||||
|
||||
GST_V4L2_CHECK_OPEN (v4l2src->v4l2object);
|
||||
GST_V4L2_CHECK_NOT_ACTIVE (v4l2src->v4l2object);
|
||||
|
||||
memset (&v4l2src->format, 0, sizeof (struct v4l2_format));
|
||||
v4l2src->format.fmt.pix.width = width;
|
||||
v4l2src->format.fmt.pix.height = height;
|
||||
if (!gst_v4l2src_get_capture (v4l2src)) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
v4l2src->format.fmt.pix.width = *width;
|
||||
v4l2src->format.fmt.pix.height = *height;
|
||||
v4l2src->format.fmt.pix.pixelformat = fmt->pixelformat;
|
||||
v4l2src->format.fmt.pix.field = V4L2_FIELD_INTERLACED;
|
||||
v4l2src->format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
|
@ -257,13 +261,36 @@ gst_v4l2src_set_capture (GstV4l2Src * v4l2src,
|
|||
if (ioctl (v4l2src->v4l2object->video_fd, VIDIOC_S_FMT, &v4l2src->format) < 0) {
|
||||
GST_ELEMENT_ERROR (v4l2src, RESOURCE, SETTINGS, (NULL),
|
||||
("failed to set pixelformat to %s @ %dx%d for device %s: %s",
|
||||
fmt->description, width, height,
|
||||
fmt->description, *width, *height,
|
||||
v4l2src->v4l2object->videodev, g_strerror (errno)));
|
||||
return FALSE;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (*width != v4l2src->format.fmt.pix.width ||
|
||||
*height != v4l2src->format.fmt.pix.height) {
|
||||
DEBUG ("Updating size from %dx%d to %dx%d, format %s",
|
||||
*width, *height, v4l2src->format.fmt.pix.width,
|
||||
v4l2src->format.fmt.pix.height, fmt->description);
|
||||
}
|
||||
|
||||
/* update internal info */
|
||||
return gst_v4l2src_get_capture (v4l2src);
|
||||
if (!gst_v4l2src_get_capture (v4l2src)) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (fmt->pixelformat != v4l2src->format.fmt.pix.pixelformat) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
*width = v4l2src->format.fmt.pix.width;
|
||||
*height = v4l2src->format.fmt.pix.height;
|
||||
|
||||
return TRUE;
|
||||
|
||||
fail:
|
||||
|
||||
return FALSE;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -568,6 +595,7 @@ gst_v4l2src_get_size_limits (GstV4l2Src * v4l2src,
|
|||
struct v4l2_fmtdesc * format,
|
||||
gint * min_w, gint * max_w, gint * min_h, gint * max_h)
|
||||
{
|
||||
|
||||
struct v4l2_format fmt;
|
||||
|
||||
GST_LOG_OBJECT (v4l2src,
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
gboolean gst_v4l2src_get_capture (GstV4l2Src * v4l2src);
|
||||
gboolean gst_v4l2src_set_capture (GstV4l2Src * v4l2src,
|
||||
struct v4l2_fmtdesc *fmt,
|
||||
gint width, gint height);
|
||||
gint * width, gint * height);
|
||||
gboolean gst_v4l2src_capture_init (GstV4l2Src * v4l2src);
|
||||
gboolean gst_v4l2src_capture_start (GstV4l2Src * v4l2src);
|
||||
gint gst_v4l2src_grab_frame (GstV4l2Src * v4l2src);
|
||||
|
|
Loading…
Reference in a new issue