浏览代码

linux-v4l2: Add function to list dv timings

Add a helper function to enumerate dv timings supported by the
selected input and add them to a property.
fryshorts 10 年之前
父节点
当前提交
bf27d4c1cb
共有 1 个文件被更改,包括 37 次插入0 次删除
  1. 37 0
      plugins/linux-v4l2/v4l2-input.c

+ 37 - 0
plugins/linux-v4l2/v4l2-input.c

@@ -399,6 +399,43 @@ static void v4l2_standard_list(int dev, obs_property_t *prop)
 	}
 	}
 }
 }
 
 
+/*
+ * List dv timings for the device
+ */
+static void v4l2_dv_timing_list(int dev, obs_property_t *prop)
+{
+	struct v4l2_dv_timings dvt;
+	struct dstr buf;
+	int index = 0;
+	dstr_init(&buf);
+
+	obs_property_list_clear(prop);
+
+	obs_property_list_add_int(prop, obs_module_text("LeaveUnchanged"), -1);
+
+	while (v4l2_enum_dv_timing(dev, &dvt, index) == 0) {
+		/* i do not pretend to understand, this is from qv4l2 ... */
+		double h    = (double) dvt.bt.height + dvt.bt.vfrontporch +
+				dvt.bt.vsync + dvt.bt.vbackporch +
+				dvt.bt.il_vfrontporch + dvt.bt.il_vsync +
+				dvt.bt.il_vbackporch;
+		double w    = (double) dvt.bt.width + dvt.bt.hfrontporch +
+				dvt.bt.hsync + dvt.bt.hbackporch;
+		double i    = (dvt.bt.interlaced) ? 2.0f : 1.0f;
+		double rate = (double) dvt.bt.pixelclock / (w * (h / i));
+
+		dstr_printf(&buf, "%ux%u%c %.2f",
+				dvt.bt.width, dvt.bt.height,
+				(dvt.bt.interlaced) ? 'i' : 'p', rate);
+
+		obs_property_list_add_int(prop, buf.array, index);
+
+		index++;
+	}
+
+	dstr_free(&buf);
+}
+
 /*
 /*
  * List resolutions for device and format
  * List resolutions for device and format
  */
  */