Commit f63bdd04 authored by Tim-Philipp Müller's avatar Tim-Philipp Müller
Browse files

v4l2src: avoid lists with one single framerate in probed caps

Simplify framerate field if possible, so we don't end up with
e.g. framerate = (fraction) { 30/1 }. Maybe the helper function
should be moved to core, but we can do this later.
parent 420661bd
......@@ -1557,6 +1557,25 @@ cropcap_failed:
goto done;
/* returns TRUE if the value was changed in place, otherwise FALSE */
static gboolean
gst_v4l2src_value_simplify (GValue * val)
/* simplify list of one value to one value */
if (GST_VALUE_HOLDS_LIST (val) && gst_value_list_get_size (val) == 1) {
const GValue *list_val;
GValue new_val = G_VALUE_INIT;
list_val = gst_value_list_get_value (val, 0);
g_value_init (&new_val, G_VALUE_TYPE (list_val));
g_value_copy (list_val, &new_val);
g_value_unset (val);
*val = new_val;
return TRUE;
return FALSE;
/* The frame interval enumeration code first appeared in Linux 2.6.19. */
static GstStructure *
......@@ -1745,6 +1764,7 @@ return_data:
(interlaced ? "mixed" : "progressive"), NULL);
if (G_IS_VALUE (&rates)) {
gst_v4l2src_value_simplify (&rates);
/* only change the framerate on the template when we have a valid probed new
* value */
gst_structure_set_value (s, "framerate", &rates);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment