mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-26 02:00:33 +00:00
v4l2: Fix support for caps without width, height, framerate or format
For format like mpegts, width and height is rarely in the negotiated caps. This patch fixes failure when setting format, and prevent introducing width, height, framerate and format to the caps when fixating. https://bugzilla.gnome.org/show_bug.cgi?id=725860
This commit is contained in:
parent
b95d9cfb21
commit
e5ef2db489
2 changed files with 25 additions and 17 deletions
|
@ -2334,17 +2334,6 @@ gst_v4l2_object_set_format (GstV4l2Object * v4l2object, GstCaps * caps)
|
||||||
"%" GST_FOURCC_FORMAT " stride: %d", width, height,
|
"%" GST_FOURCC_FORMAT " stride: %d", width, height,
|
||||||
GST_FOURCC_ARGS (pixelformat), v4l2object->bytesperline[0]);
|
GST_FOURCC_ARGS (pixelformat), v4l2object->bytesperline[0]);
|
||||||
|
|
||||||
/* MPEG-TS source cameras don't get their format set for some reason.
|
|
||||||
* It looks wrong and we weren't able to track down the reason for that code
|
|
||||||
* so it is disabled until someone who has an mpeg-ts camera complains...
|
|
||||||
*/
|
|
||||||
#if 0
|
|
||||||
/* Only unconditionally accept mpegts for sources */
|
|
||||||
if ((v4l2object->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) &&
|
|
||||||
(pixelformat == GST_MAKE_FOURCC ('M', 'P', 'E', 'G')))
|
|
||||||
goto done;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
memset (&format, 0x00, sizeof (struct v4l2_format));
|
memset (&format, 0x00, sizeof (struct v4l2_format));
|
||||||
format.type = v4l2object->type;
|
format.type = v4l2object->type;
|
||||||
|
|
||||||
|
@ -2360,6 +2349,12 @@ gst_v4l2_object_set_format (GstV4l2Object * v4l2object, GstCaps * caps)
|
||||||
GST_FOURCC_ARGS (format.fmt.pix.pixelformat),
|
GST_FOURCC_ARGS (format.fmt.pix.pixelformat),
|
||||||
format.fmt.pix_mp.colorspace, format.fmt.pix_mp.num_planes);
|
format.fmt.pix_mp.colorspace, format.fmt.pix_mp.num_planes);
|
||||||
|
|
||||||
|
/* If no size in caps, use configured size */
|
||||||
|
if (width == 0 && height == 0) {
|
||||||
|
width = format.fmt.pix_mp.width;
|
||||||
|
height = format.fmt.pix_mp.height;
|
||||||
|
}
|
||||||
|
|
||||||
if (format.type != v4l2object->type ||
|
if (format.type != v4l2object->type ||
|
||||||
format.fmt.pix_mp.width != width ||
|
format.fmt.pix_mp.width != width ||
|
||||||
format.fmt.pix_mp.height != height ||
|
format.fmt.pix_mp.height != height ||
|
||||||
|
@ -2439,6 +2434,12 @@ gst_v4l2_object_set_format (GstV4l2Object * v4l2object, GstCaps * caps)
|
||||||
GST_FOURCC_ARGS (format.fmt.pix.pixelformat),
|
GST_FOURCC_ARGS (format.fmt.pix.pixelformat),
|
||||||
format.fmt.pix.bytesperline, format.fmt.pix.colorspace);
|
format.fmt.pix.bytesperline, format.fmt.pix.colorspace);
|
||||||
|
|
||||||
|
/* If no size in caps, use configured size */
|
||||||
|
if (width == 0 && height == 0) {
|
||||||
|
width = format.fmt.pix_mp.width;
|
||||||
|
height = format.fmt.pix_mp.height;
|
||||||
|
}
|
||||||
|
|
||||||
if (format.type != v4l2object->type ||
|
if (format.type != v4l2object->type ||
|
||||||
format.fmt.pix.width != width ||
|
format.fmt.pix.width != width ||
|
||||||
format.fmt.pix.height != height ||
|
format.fmt.pix.height != height ||
|
||||||
|
|
|
@ -260,13 +260,20 @@ gst_v4l2src_fixate (GstBaseSrc * basesrc, GstCaps * caps)
|
||||||
for (i = 0; i < gst_caps_get_size (caps); ++i) {
|
for (i = 0; i < gst_caps_get_size (caps); ++i) {
|
||||||
structure = gst_caps_get_structure (caps, i);
|
structure = gst_caps_get_structure (caps, i);
|
||||||
|
|
||||||
/* We are fixating to a resonable 320x200 resolution
|
/* We are fixating to a reasonable 320x200 resolution
|
||||||
and the maximum framerate resolution for that size */
|
and the maximum framerate resolution for that size */
|
||||||
gst_structure_fixate_field_nearest_int (structure, "width", 320);
|
if (gst_structure_has_field (structure, "width"))
|
||||||
gst_structure_fixate_field_nearest_int (structure, "height", 200);
|
gst_structure_fixate_field_nearest_int (structure, "width", 320);
|
||||||
gst_structure_fixate_field_nearest_fraction (structure, "framerate",
|
|
||||||
G_MAXINT, 1);
|
if (gst_structure_has_field (structure, "height"))
|
||||||
gst_structure_fixate_field (structure, "format");
|
gst_structure_fixate_field_nearest_int (structure, "height", 200);
|
||||||
|
|
||||||
|
if (gst_structure_has_field (structure, "framerate"))
|
||||||
|
gst_structure_fixate_field_nearest_fraction (structure, "framerate",
|
||||||
|
G_MAXINT, 1);
|
||||||
|
|
||||||
|
if (gst_structure_has_field (structure, "format"))
|
||||||
|
gst_structure_fixate_field (structure, "format");
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (basesrc, "fixated caps %" GST_PTR_FORMAT, caps);
|
GST_DEBUG_OBJECT (basesrc, "fixated caps %" GST_PTR_FORMAT, caps);
|
||||||
|
|
Loading…
Reference in a new issue