New upstream version 24.0.1+dfsg1
This commit is contained in:
parent
b14f9eae6d
commit
5a730d6ec3
842 changed files with 42245 additions and 33385 deletions
|
|
@ -50,15 +50,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#define V4L2_DATA(voidptr) struct v4l2_data *data = voidptr;
|
||||
|
||||
#define timeval2ns(tv) \
|
||||
(((uint64_t) tv.tv_sec * 1000000000) + ((uint64_t) tv.tv_usec * 1000))
|
||||
(((uint64_t)tv.tv_sec * 1000000000) + ((uint64_t)tv.tv_usec * 1000))
|
||||
|
||||
#define V4L2_FOURCC_STR(code) \
|
||||
(char[5]) { \
|
||||
(code >> 24) & 0xFF, \
|
||||
(code >> 16) & 0xFF, \
|
||||
(code >> 8) & 0xFF, \
|
||||
code & 0xFF, \
|
||||
0 \
|
||||
#define V4L2_FOURCC_STR(code) \
|
||||
(char[5]) \
|
||||
{ \
|
||||
(code >> 24) & 0xFF, (code >> 16) & 0xFF, (code >> 8) & 0xFF, \
|
||||
code & 0xFF, 0 \
|
||||
}
|
||||
|
||||
#define blog(level, msg, ...) blog(level, "v4l2-input: " msg, ##__VA_ARGS__)
|
||||
|
|
@ -105,7 +103,8 @@ static void v4l2_terminate(struct v4l2_data *data);
|
|||
* pointers for the individual planes.
|
||||
*/
|
||||
static void v4l2_prep_obs_frame(struct v4l2_data *data,
|
||||
struct obs_source_frame *frame, size_t *plane_offsets)
|
||||
struct obs_source_frame *frame,
|
||||
size_t *plane_offsets)
|
||||
{
|
||||
memset(frame, 0, sizeof(struct obs_source_frame));
|
||||
memset(plane_offsets, 0, sizeof(size_t) * MAX_AV_PLANES);
|
||||
|
|
@ -114,10 +113,10 @@ static void v4l2_prep_obs_frame(struct v4l2_data *data,
|
|||
frame->height = data->height;
|
||||
frame->format = v4l2_to_obs_video_format(data->pixfmt);
|
||||
video_format_get_parameters(VIDEO_CS_DEFAULT, data->color_range,
|
||||
frame->color_matrix, frame->color_range_min,
|
||||
frame->color_range_max);
|
||||
frame->color_matrix, frame->color_range_min,
|
||||
frame->color_range_max);
|
||||
|
||||
switch(data->pixfmt) {
|
||||
switch (data->pixfmt) {
|
||||
case V4L2_PIX_FMT_NV12:
|
||||
frame->linesize[0] = data->linesize;
|
||||
frame->linesize[1] = data->linesize / 2;
|
||||
|
|
@ -162,7 +161,7 @@ static void *v4l2_thread(void *vptr)
|
|||
if (v4l2_start_capture(data->dev, &data->buffers) < 0)
|
||||
goto exit;
|
||||
|
||||
frames = 0;
|
||||
frames = 0;
|
||||
first_ts = 0;
|
||||
v4l2_prep_obs_frame(data, &out, plane_offsets);
|
||||
|
||||
|
|
@ -198,7 +197,7 @@ static void *v4l2_thread(void *vptr)
|
|||
first_ts = out.timestamp;
|
||||
out.timestamp -= first_ts;
|
||||
|
||||
start = (uint8_t *) data->buffers.info[buf.index].start;
|
||||
start = (uint8_t *)data->buffers.info[buf.index].start;
|
||||
for (uint_fast32_t i = 0; i < MAX_AV_PLANES; ++i)
|
||||
out.data[i] = start + plane_offsets[i];
|
||||
obs_source_output_video(data->source, &out);
|
||||
|
|
@ -211,14 +210,14 @@ static void *v4l2_thread(void *vptr)
|
|||
frames++;
|
||||
}
|
||||
|
||||
blog(LOG_INFO, "Stopped capture after %"PRIu64" frames", frames);
|
||||
blog(LOG_INFO, "Stopped capture after %" PRIu64 " frames", frames);
|
||||
|
||||
exit:
|
||||
v4l2_stop_capture(data->dev);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static const char* v4l2_getname(void *unused)
|
||||
static const char *v4l2_getname(void *unused)
|
||||
{
|
||||
UNUSED_PARAMETER(unused);
|
||||
return obs_module_text("V4L2Input");
|
||||
|
|
@ -232,7 +231,7 @@ static void v4l2_defaults(obs_data_t *settings)
|
|||
obs_data_set_default_int(settings, "dv_timing", -1);
|
||||
obs_data_set_default_int(settings, "resolution", -1);
|
||||
obs_data_set_default_int(settings, "framerate", -1);
|
||||
obs_data_set_default_int(settings, "color_range", VIDEO_RANGE_PARTIAL);
|
||||
obs_data_set_default_int(settings, "color_range", VIDEO_RANGE_DEFAULT);
|
||||
obs_data_set_default_bool(settings, "buffering", true);
|
||||
}
|
||||
|
||||
|
|
@ -246,13 +245,13 @@ static void v4l2_defaults(obs_data_t *settings)
|
|||
* @param enable enable/disable all properties
|
||||
*/
|
||||
static void v4l2_props_set_enabled(obs_properties_t *props,
|
||||
obs_property_t *ignore, bool enable)
|
||||
obs_property_t *ignore, bool enable)
|
||||
{
|
||||
if (!props)
|
||||
return;
|
||||
|
||||
for (obs_property_t *prop = obs_properties_first(props); prop != NULL;
|
||||
obs_property_next(&prop)) {
|
||||
obs_property_next(&prop)) {
|
||||
if (prop == ignore)
|
||||
continue;
|
||||
|
||||
|
|
@ -281,7 +280,7 @@ static void v4l2_device_list(obs_property_t *prop, obs_data_t *settings)
|
|||
return;
|
||||
|
||||
cur_device_found = false;
|
||||
cur_device_name = obs_data_get_string(settings, "device_id");
|
||||
cur_device_name = obs_data_get_string(settings, "device_id");
|
||||
|
||||
obs_property_list_clear(prop);
|
||||
|
||||
|
|
@ -320,8 +319,8 @@ static void v4l2_device_list(obs_property_t *prop, obs_data_t *settings)
|
|||
#else
|
||||
/* ... since Linux 3.3 */
|
||||
caps = (video_cap.capabilities & V4L2_CAP_DEVICE_CAPS)
|
||||
? video_cap.device_caps
|
||||
: video_cap.capabilities;
|
||||
? video_cap.device_caps
|
||||
: video_cap.capabilities;
|
||||
#endif
|
||||
|
||||
if (!(caps & V4L2_CAP_VIDEO_CAPTURE)) {
|
||||
|
|
@ -334,11 +333,11 @@ static void v4l2_device_list(obs_property_t *prop, obs_data_t *settings)
|
|||
/* make sure device names are unique */
|
||||
char unique_device_name[68];
|
||||
sprintf(unique_device_name, "%s (%s)", video_cap.card,
|
||||
video_cap.bus_info);
|
||||
video_cap.bus_info);
|
||||
obs_property_list_add_string(prop, unique_device_name,
|
||||
device.array);
|
||||
device.array);
|
||||
blog(LOG_INFO, "Found device '%s' at %s", video_cap.card,
|
||||
device.array);
|
||||
device.array);
|
||||
|
||||
/* check if this is the currently used device */
|
||||
if (cur_device_name && !strcmp(cur_device_name, device.array))
|
||||
|
|
@ -349,8 +348,8 @@ static void v4l2_device_list(obs_property_t *prop, obs_data_t *settings)
|
|||
|
||||
/* add currently selected device if not present, but disable it ... */
|
||||
if (!cur_device_found && cur_device_name && strlen(cur_device_name)) {
|
||||
cur_device_index = obs_property_list_add_string(prop,
|
||||
cur_device_name, cur_device_name);
|
||||
cur_device_index = obs_property_list_add_string(
|
||||
prop, cur_device_name, cur_device_name);
|
||||
obs_property_list_item_disable(prop, cur_device_index, true);
|
||||
}
|
||||
|
||||
|
|
@ -369,9 +368,9 @@ static void v4l2_input_list(int_fast32_t dev, obs_property_t *prop)
|
|||
obs_property_list_clear(prop);
|
||||
|
||||
while (v4l2_ioctl(dev, VIDIOC_ENUMINPUT, &in) == 0) {
|
||||
obs_property_list_add_int(prop, (char *) in.name, in.index);
|
||||
obs_property_list_add_int(prop, (char *)in.name, in.index);
|
||||
blog(LOG_INFO, "Found input '%s' (Index %d)", in.name,
|
||||
in.index);
|
||||
in.index);
|
||||
in.index++;
|
||||
}
|
||||
}
|
||||
|
|
@ -390,14 +389,14 @@ static void v4l2_format_list(int dev, obs_property_t *prop)
|
|||
obs_property_list_clear(prop);
|
||||
|
||||
while (v4l2_ioctl(dev, VIDIOC_ENUM_FMT, &fmt) == 0) {
|
||||
dstr_copy(&buffer, (char *) fmt.description);
|
||||
dstr_copy(&buffer, (char *)fmt.description);
|
||||
if (fmt.flags & V4L2_FMT_FLAG_EMULATED)
|
||||
dstr_cat(&buffer, " (Emulated)");
|
||||
|
||||
if (v4l2_to_obs_video_format(fmt.pixelformat)
|
||||
!= VIDEO_FORMAT_NONE) {
|
||||
if (v4l2_to_obs_video_format(fmt.pixelformat) !=
|
||||
VIDEO_FORMAT_NONE) {
|
||||
obs_property_list_add_int(prop, buffer.array,
|
||||
fmt.pixelformat);
|
||||
fmt.pixelformat);
|
||||
blog(LOG_INFO, "Pixelformat: %s (available)",
|
||||
buffer.array);
|
||||
} else {
|
||||
|
|
@ -423,7 +422,7 @@ static void v4l2_standard_list(int dev, obs_property_t *prop)
|
|||
obs_property_list_add_int(prop, obs_module_text("LeaveUnchanged"), -1);
|
||||
|
||||
while (v4l2_ioctl(dev, VIDIOC_ENUMSTD, &std) == 0) {
|
||||
obs_property_list_add_int(prop, (char *) std.name, std.id);
|
||||
obs_property_list_add_int(prop, (char *)std.name, std.id);
|
||||
std.index++;
|
||||
}
|
||||
}
|
||||
|
|
@ -444,18 +443,17 @@ static void v4l2_dv_timing_list(int dev, obs_property_t *prop)
|
|||
|
||||
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));
|
||||
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);
|
||||
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);
|
||||
|
||||
|
|
@ -469,7 +467,7 @@ static void v4l2_dv_timing_list(int dev, obs_property_t *prop)
|
|||
* List resolutions for device and format
|
||||
*/
|
||||
static void v4l2_resolution_list(int dev, uint_fast32_t pixelformat,
|
||||
obs_property_t *prop)
|
||||
obs_property_t *prop)
|
||||
{
|
||||
struct v4l2_frmsizeenum frmsize;
|
||||
frmsize.pixel_format = pixelformat;
|
||||
|
|
@ -483,20 +481,21 @@ static void v4l2_resolution_list(int dev, uint_fast32_t pixelformat,
|
|||
|
||||
v4l2_ioctl(dev, VIDIOC_ENUM_FRAMESIZES, &frmsize);
|
||||
|
||||
switch(frmsize.type) {
|
||||
switch (frmsize.type) {
|
||||
case V4L2_FRMSIZE_TYPE_DISCRETE:
|
||||
while (v4l2_ioctl(dev, VIDIOC_ENUM_FRAMESIZES, &frmsize) == 0) {
|
||||
dstr_printf(&buffer, "%dx%d", frmsize.discrete.width,
|
||||
frmsize.discrete.height);
|
||||
obs_property_list_add_int(prop, buffer.array,
|
||||
v4l2_pack_tuple(frmsize.discrete.width,
|
||||
frmsize.discrete.height));
|
||||
frmsize.discrete.height);
|
||||
obs_property_list_add_int(
|
||||
prop, buffer.array,
|
||||
v4l2_pack_tuple(frmsize.discrete.width,
|
||||
frmsize.discrete.height));
|
||||
frmsize.index++;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
blog(LOG_INFO, "Stepwise and Continuous framesizes "
|
||||
"are currently hardcoded");
|
||||
"are currently hardcoded");
|
||||
|
||||
for (const int *packed = v4l2_framesizes; *packed; ++packed) {
|
||||
int width;
|
||||
|
|
@ -515,7 +514,8 @@ static void v4l2_resolution_list(int dev, uint_fast32_t pixelformat,
|
|||
* List framerates for device and resolution
|
||||
*/
|
||||
static void v4l2_framerate_list(int dev, uint_fast32_t pixelformat,
|
||||
uint_fast32_t width, uint_fast32_t height, obs_property_t *prop)
|
||||
uint_fast32_t width, uint_fast32_t height,
|
||||
obs_property_t *prop)
|
||||
{
|
||||
struct v4l2_frmivalenum frmival;
|
||||
frmival.pixel_format = pixelformat;
|
||||
|
|
@ -531,14 +531,15 @@ static void v4l2_framerate_list(int dev, uint_fast32_t pixelformat,
|
|||
|
||||
v4l2_ioctl(dev, VIDIOC_ENUM_FRAMEINTERVALS, &frmival);
|
||||
|
||||
switch(frmival.type) {
|
||||
switch (frmival.type) {
|
||||
case V4L2_FRMIVAL_TYPE_DISCRETE:
|
||||
while (v4l2_ioctl(dev, VIDIOC_ENUM_FRAMEINTERVALS,
|
||||
&frmival) == 0) {
|
||||
float fps = (float) frmival.discrete.denominator /
|
||||
frmival.discrete.numerator;
|
||||
int pack = v4l2_pack_tuple(frmival.discrete.numerator,
|
||||
frmival.discrete.denominator);
|
||||
while (v4l2_ioctl(dev, VIDIOC_ENUM_FRAMEINTERVALS, &frmival) ==
|
||||
0) {
|
||||
float fps = (float)frmival.discrete.denominator /
|
||||
frmival.discrete.numerator;
|
||||
int pack =
|
||||
v4l2_pack_tuple(frmival.discrete.numerator,
|
||||
frmival.discrete.denominator);
|
||||
dstr_printf(&buffer, "%.2f", fps);
|
||||
obs_property_list_add_int(prop, buffer.array, pack);
|
||||
frmival.index++;
|
||||
|
|
@ -546,13 +547,13 @@ static void v4l2_framerate_list(int dev, uint_fast32_t pixelformat,
|
|||
break;
|
||||
default:
|
||||
blog(LOG_INFO, "Stepwise and Continuous framerates "
|
||||
"are currently hardcoded");
|
||||
"are currently hardcoded");
|
||||
|
||||
for (const int *packed = v4l2_framerates; *packed; ++packed) {
|
||||
int num;
|
||||
int denom;
|
||||
v4l2_unpack_tuple(&num, &denom, *packed);
|
||||
float fps = (float) denom / num;
|
||||
float fps = (float)denom / num;
|
||||
dstr_printf(&buffer, "%.2f", fps);
|
||||
obs_property_list_add_int(prop, buffer.array, *packed);
|
||||
}
|
||||
|
|
@ -566,10 +567,10 @@ static void v4l2_framerate_list(int dev, uint_fast32_t pixelformat,
|
|||
* Device selected callback
|
||||
*/
|
||||
static bool device_selected(obs_properties_t *props, obs_property_t *p,
|
||||
obs_data_t *settings)
|
||||
obs_data_t *settings)
|
||||
{
|
||||
int dev = v4l2_open(obs_data_get_string(settings, "device_id"),
|
||||
O_RDWR | O_NONBLOCK);
|
||||
O_RDWR | O_NONBLOCK);
|
||||
|
||||
v4l2_props_set_enabled(props, p, (dev == -1) ? false : true);
|
||||
|
||||
|
|
@ -589,11 +590,11 @@ static bool device_selected(obs_properties_t *props, obs_property_t *p,
|
|||
* Input selected callback
|
||||
*/
|
||||
static bool input_selected(obs_properties_t *props, obs_property_t *p,
|
||||
obs_data_t *settings)
|
||||
obs_data_t *settings)
|
||||
{
|
||||
UNUSED_PARAMETER(p);
|
||||
int dev = v4l2_open(obs_data_get_string(settings, "device_id"),
|
||||
O_RDWR | O_NONBLOCK);
|
||||
O_RDWR | O_NONBLOCK);
|
||||
if (dev == -1)
|
||||
return false;
|
||||
|
||||
|
|
@ -610,35 +611,36 @@ static bool input_selected(obs_properties_t *props, obs_property_t *p,
|
|||
* Format selected callback
|
||||
*/
|
||||
static bool format_selected(obs_properties_t *props, obs_property_t *p,
|
||||
obs_data_t *settings)
|
||||
obs_data_t *settings)
|
||||
{
|
||||
UNUSED_PARAMETER(p);
|
||||
int dev = v4l2_open(obs_data_get_string(settings, "device_id"),
|
||||
O_RDWR | O_NONBLOCK);
|
||||
O_RDWR | O_NONBLOCK);
|
||||
if (dev == -1)
|
||||
return false;
|
||||
|
||||
int input = (int) obs_data_get_int(settings, "input");
|
||||
int input = (int)obs_data_get_int(settings, "input");
|
||||
uint32_t caps = 0;
|
||||
if (v4l2_get_input_caps(dev, input, &caps) < 0)
|
||||
return false;
|
||||
caps &= V4L2_IN_CAP_STD | V4L2_IN_CAP_DV_TIMINGS;
|
||||
|
||||
obs_property_t *resolution = obs_properties_get(props, "resolution");
|
||||
obs_property_t *framerate = obs_properties_get(props, "framerate");
|
||||
obs_property_t *standard = obs_properties_get(props, "standard");
|
||||
obs_property_t *dv_timing = obs_properties_get(props, "dv_timing");
|
||||
obs_property_t *framerate = obs_properties_get(props, "framerate");
|
||||
obs_property_t *standard = obs_properties_get(props, "standard");
|
||||
obs_property_t *dv_timing = obs_properties_get(props, "dv_timing");
|
||||
|
||||
obs_property_set_visible(resolution, (!caps) ? true : false);
|
||||
obs_property_set_visible(framerate, (!caps) ? true : false);
|
||||
obs_property_set_visible(framerate, (!caps) ? true : false);
|
||||
obs_property_set_visible(standard,
|
||||
(caps & V4L2_IN_CAP_STD) ? true : false);
|
||||
obs_property_set_visible(dv_timing,
|
||||
(caps & V4L2_IN_CAP_DV_TIMINGS) ? true : false);
|
||||
(caps & V4L2_IN_CAP_STD) ? true : false);
|
||||
obs_property_set_visible(
|
||||
dv_timing, (caps & V4L2_IN_CAP_DV_TIMINGS) ? true : false);
|
||||
|
||||
if (!caps) {
|
||||
v4l2_resolution_list(dev, obs_data_get_int(
|
||||
settings, "pixelformat"), resolution);
|
||||
v4l2_resolution_list(dev,
|
||||
obs_data_get_int(settings, "pixelformat"),
|
||||
resolution);
|
||||
}
|
||||
if (caps & V4L2_IN_CAP_STD)
|
||||
v4l2_standard_list(dev, standard);
|
||||
|
|
@ -661,20 +663,20 @@ static bool format_selected(obs_properties_t *props, obs_property_t *p,
|
|||
* Resolution selected callback
|
||||
*/
|
||||
static bool resolution_selected(obs_properties_t *props, obs_property_t *p,
|
||||
obs_data_t *settings)
|
||||
obs_data_t *settings)
|
||||
{
|
||||
UNUSED_PARAMETER(p);
|
||||
int width, height;
|
||||
int dev = v4l2_open(obs_data_get_string(settings, "device_id"),
|
||||
O_RDWR | O_NONBLOCK);
|
||||
O_RDWR | O_NONBLOCK);
|
||||
if (dev == -1)
|
||||
return false;
|
||||
|
||||
obs_property_t *prop = obs_properties_get(props, "framerate");
|
||||
v4l2_unpack_tuple(&width, &height, obs_data_get_int(settings,
|
||||
"resolution"));
|
||||
v4l2_unpack_tuple(&width, &height,
|
||||
obs_data_get_int(settings, "resolution"));
|
||||
v4l2_framerate_list(dev, obs_data_get_int(settings, "pixelformat"),
|
||||
width, height, prop);
|
||||
width, height, prop);
|
||||
v4l2_close(dev);
|
||||
|
||||
obs_property_modified(prop, settings);
|
||||
|
|
@ -735,44 +737,51 @@ static obs_properties_t *v4l2_properties(void *vptr)
|
|||
|
||||
obs_properties_t *props = obs_properties_create();
|
||||
|
||||
obs_property_t *device_list = obs_properties_add_list(props,
|
||||
"device_id", obs_module_text("Device"),
|
||||
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING);
|
||||
obs_property_t *device_list = obs_properties_add_list(
|
||||
props, "device_id", obs_module_text("Device"),
|
||||
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING);
|
||||
|
||||
obs_property_t *input_list = obs_properties_add_list(props,
|
||||
"input", obs_module_text("Input"),
|
||||
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
|
||||
obs_property_t *input_list = obs_properties_add_list(
|
||||
props, "input", obs_module_text("Input"), OBS_COMBO_TYPE_LIST,
|
||||
OBS_COMBO_FORMAT_INT);
|
||||
|
||||
obs_property_t *format_list = obs_properties_add_list(props,
|
||||
"pixelformat", obs_module_text("VideoFormat"),
|
||||
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
|
||||
obs_property_t *format_list = obs_properties_add_list(
|
||||
props, "pixelformat", obs_module_text("VideoFormat"),
|
||||
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
|
||||
|
||||
obs_property_t *standard_list = obs_properties_add_list(props,
|
||||
"standard", obs_module_text("VideoStandard"),
|
||||
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
|
||||
obs_property_t *standard_list = obs_properties_add_list(
|
||||
props, "standard", obs_module_text("VideoStandard"),
|
||||
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
|
||||
obs_property_set_visible(standard_list, false);
|
||||
|
||||
obs_property_t *dv_timing_list = obs_properties_add_list(props,
|
||||
"dv_timing", obs_module_text("DVTiming"),
|
||||
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
|
||||
obs_property_t *dv_timing_list = obs_properties_add_list(
|
||||
props, "dv_timing", obs_module_text("DVTiming"),
|
||||
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
|
||||
obs_property_set_visible(dv_timing_list, false);
|
||||
|
||||
obs_property_t *resolution_list = obs_properties_add_list(props,
|
||||
"resolution", obs_module_text("Resolution"),
|
||||
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
|
||||
obs_property_t *resolution_list = obs_properties_add_list(
|
||||
props, "resolution", obs_module_text("Resolution"),
|
||||
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
|
||||
|
||||
obs_properties_add_list(props,
|
||||
"framerate", obs_module_text("FrameRate"),
|
||||
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
|
||||
obs_properties_add_list(props, "framerate",
|
||||
obs_module_text("FrameRate"),
|
||||
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
|
||||
|
||||
obs_property_t *color_range_list = obs_properties_add_list(props,
|
||||
"color_range", obs_module_text("ColorRange"),
|
||||
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
|
||||
obs_property_list_add_int(color_range_list, obs_module_text("ColorRange.Partial"), VIDEO_RANGE_PARTIAL);
|
||||
obs_property_list_add_int(color_range_list, obs_module_text("ColorRange.Full"), VIDEO_RANGE_FULL);
|
||||
obs_property_t *color_range_list = obs_properties_add_list(
|
||||
props, "color_range", obs_module_text("ColorRange"),
|
||||
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
|
||||
obs_property_list_add_int(color_range_list,
|
||||
obs_module_text("ColorRange.Default"),
|
||||
VIDEO_RANGE_DEFAULT);
|
||||
obs_property_list_add_int(color_range_list,
|
||||
obs_module_text("ColorRange.Partial"),
|
||||
VIDEO_RANGE_PARTIAL);
|
||||
obs_property_list_add_int(color_range_list,
|
||||
obs_module_text("ColorRange.Full"),
|
||||
VIDEO_RANGE_FULL);
|
||||
|
||||
obs_properties_add_bool(props,
|
||||
"buffering", obs_module_text("UseBuffering"));
|
||||
obs_properties_add_bool(props, "buffering",
|
||||
obs_module_text("UseBuffering"));
|
||||
|
||||
obs_data_t *settings = obs_source_get_settings(data->source);
|
||||
v4l2_device_list(device_list, settings);
|
||||
|
|
@ -782,7 +791,7 @@ static obs_properties_t *v4l2_properties(void *vptr)
|
|||
obs_property_set_modified_callback(input_list, input_selected);
|
||||
obs_property_set_modified_callback(format_list, format_selected);
|
||||
obs_property_set_modified_callback(resolution_list,
|
||||
resolution_selected);
|
||||
resolution_selected);
|
||||
|
||||
return props;
|
||||
}
|
||||
|
|
@ -868,7 +877,7 @@ static void v4l2_init(struct v4l2_data *data)
|
|||
goto fail;
|
||||
}
|
||||
data->resolution = -1;
|
||||
data->framerate = -1;
|
||||
data->framerate = -1;
|
||||
}
|
||||
/* set dv timing if supported */
|
||||
if (input_caps & V4L2_IN_CAP_DV_TIMINGS) {
|
||||
|
|
@ -877,12 +886,12 @@ static void v4l2_init(struct v4l2_data *data)
|
|||
goto fail;
|
||||
}
|
||||
data->resolution = -1;
|
||||
data->framerate = -1;
|
||||
data->framerate = -1;
|
||||
}
|
||||
|
||||
/* set pixel format and resolution */
|
||||
if (v4l2_set_format(data->dev, &data->resolution, &data->pixfmt,
|
||||
&data->linesize) < 0) {
|
||||
&data->linesize) < 0) {
|
||||
blog(LOG_ERROR, "Unable to set format");
|
||||
goto fail;
|
||||
}
|
||||
|
|
@ -901,7 +910,7 @@ static void v4l2_init(struct v4l2_data *data)
|
|||
goto fail;
|
||||
}
|
||||
v4l2_unpack_tuple(&fps_num, &fps_denom, data->framerate);
|
||||
blog(LOG_INFO, "Framerate: %.2f fps", (float) fps_denom / fps_num);
|
||||
blog(LOG_INFO, "Framerate: %.2f fps", (float)fps_denom / fps_num);
|
||||
|
||||
/* map buffers */
|
||||
if (v4l2_create_mmap(data->dev, &data->buffers) < 0) {
|
||||
|
|
@ -922,10 +931,10 @@ fail:
|
|||
|
||||
/** Update source flags depending on the settings */
|
||||
static void v4l2_update_source_flags(struct v4l2_data *data,
|
||||
obs_data_t *settings)
|
||||
obs_data_t *settings)
|
||||
{
|
||||
obs_source_set_async_unbuffered(data->source,
|
||||
!obs_data_get_bool(settings, "buffering"));
|
||||
obs_source_set_async_unbuffered(
|
||||
data->source, !obs_data_get_bool(settings, "buffering"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -945,14 +954,14 @@ static void v4l2_update(void *vptr, obs_data_t *settings)
|
|||
if (data->device_id)
|
||||
bfree(data->device_id);
|
||||
|
||||
data->device_id = bstrdup(obs_data_get_string(settings, "device_id"));
|
||||
data->input = obs_data_get_int(settings, "input");
|
||||
data->pixfmt = obs_data_get_int(settings, "pixelformat");
|
||||
data->standard = obs_data_get_int(settings, "standard");
|
||||
data->dv_timing = obs_data_get_int(settings, "dv_timing");
|
||||
data->device_id = bstrdup(obs_data_get_string(settings, "device_id"));
|
||||
data->input = obs_data_get_int(settings, "input");
|
||||
data->pixfmt = obs_data_get_int(settings, "pixelformat");
|
||||
data->standard = obs_data_get_int(settings, "standard");
|
||||
data->dv_timing = obs_data_get_int(settings, "dv_timing");
|
||||
data->resolution = obs_data_get_int(settings, "resolution");
|
||||
data->framerate = obs_data_get_int(settings, "framerate");
|
||||
data->color_range = obs_data_get_int(settings, "color_range");
|
||||
data->framerate = obs_data_get_int(settings, "framerate");
|
||||
data->color_range = obs_data_get_int(settings, "color_range");
|
||||
|
||||
v4l2_update_source_flags(data, settings);
|
||||
|
||||
|
|
@ -987,14 +996,13 @@ static void *v4l2_create(obs_data_t *settings, obs_source_t *source)
|
|||
}
|
||||
|
||||
struct obs_source_info v4l2_input = {
|
||||
.id = "v4l2_input",
|
||||
.type = OBS_SOURCE_TYPE_INPUT,
|
||||
.output_flags = OBS_SOURCE_ASYNC_VIDEO |
|
||||
OBS_SOURCE_DO_NOT_DUPLICATE,
|
||||
.get_name = v4l2_getname,
|
||||
.create = v4l2_create,
|
||||
.destroy = v4l2_destroy,
|
||||
.update = v4l2_update,
|
||||
.get_defaults = v4l2_defaults,
|
||||
.get_properties = v4l2_properties
|
||||
.id = "v4l2_input",
|
||||
.type = OBS_SOURCE_TYPE_INPUT,
|
||||
.output_flags = OBS_SOURCE_ASYNC_VIDEO | OBS_SOURCE_DO_NOT_DUPLICATE,
|
||||
.get_name = v4l2_getname,
|
||||
.create = v4l2_create,
|
||||
.destroy = v4l2_destroy,
|
||||
.update = v4l2_update,
|
||||
.get_defaults = v4l2_defaults,
|
||||
.get_properties = v4l2_properties,
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue