New upstream version 25.0.3+dfsg1
This commit is contained in:
parent
04fe0efc67
commit
8b2e5f2130
569 changed files with 62491 additions and 5875 deletions
|
|
@ -31,6 +31,7 @@ include_directories(
|
|||
|
||||
set(linux-v4l2_SOURCES
|
||||
linux-v4l2.c
|
||||
v4l2-controls.c
|
||||
v4l2-input.c
|
||||
v4l2-helpers.c
|
||||
${linux-v4l2-udev_SOURCES}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ DVTiming="DV‐Timing"
|
|||
Resolution="Auflösung"
|
||||
FrameRate="Bildrate"
|
||||
LeaveUnchanged="Unverändert lassen"
|
||||
UseBuffering="Puffern benutzen"
|
||||
UseBuffering="Pufferung benutzen"
|
||||
ColorRange="Farbbereich"
|
||||
ColorRange.Default="Standard"
|
||||
ColorRange.Partial="Begrenzt"
|
||||
|
|
|
|||
|
|
@ -1,14 +1,15 @@
|
|||
V4L2Input="دستگاه ضبط ویدئویی (V4L2)"
|
||||
Device="دستگاه"
|
||||
Input="ورودی"
|
||||
VideoFormat="فرمت های تصویری"
|
||||
VideoStandard="استاندارد های تصویری"
|
||||
DVTiming="زمان بندی دی وی"
|
||||
Resolution="اندازه تصویر"
|
||||
VideoFormat="فرمت ویدئو"
|
||||
VideoStandard="استاندارد ویدئو"
|
||||
DVTiming="زمان بندی فیلم دیجیتال"
|
||||
Resolution="وضوح"
|
||||
FrameRate="نرخ فریم"
|
||||
LeaveUnchanged="ترک بدون تغییر"
|
||||
UseBuffering="استفاده از بافرینگ"
|
||||
ColorRange="طیف رنگ"
|
||||
LeaveUnchanged="رفتن بدون تغییر"
|
||||
UseBuffering="استفاده از بافر کردن"
|
||||
ColorRange="محدوده رنگ"
|
||||
ColorRange.Default="پیش فرض"
|
||||
ColorRange.Partial="جزئی"
|
||||
ColorRange.Full="کامل"
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ FrameRate="Bildefrekvens"
|
|||
LeaveUnchanged="La stå uendret"
|
||||
UseBuffering="Bruk bufring"
|
||||
ColorRange="Fargespekter"
|
||||
ColorRange.Default="Standard"
|
||||
ColorRange.Partial="Delvis"
|
||||
ColorRange.Full="Full"
|
||||
|
||||
|
|
|
|||
|
|
@ -8,4 +8,8 @@ Resolution="Resolução"
|
|||
FrameRate="Taxa de fotogramas"
|
||||
LeaveUnchanged="Deixar inalterado"
|
||||
UseBuffering="Utilizar Buffering"
|
||||
ColorRange="Gama de Cores"
|
||||
ColorRange.Default="Pré-definido"
|
||||
ColorRange.Partial="Parcial"
|
||||
ColorRange.Full="Completo"
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ FrameRate="Frekvencia snímok"
|
|||
LeaveUnchanged="Ponechať bez zmeny"
|
||||
UseBuffering="Použiť vyrovnávaciu pamäť"
|
||||
ColorRange="Farebný rozsah"
|
||||
ColorRange.Default="Predvolený"
|
||||
ColorRange.Partial="Čiastočný"
|
||||
ColorRange.Full="Plný"
|
||||
|
||||
|
|
|
|||
|
|
@ -8,4 +8,8 @@ Resolution="Resolucija"
|
|||
FrameRate="Slike na sekundo"
|
||||
LeaveUnchanged="Pusti nespremenjeno"
|
||||
UseBuffering="Uporabi medpomnilnik"
|
||||
ColorRange="Barvni razpon"
|
||||
ColorRange.Default="Privzeti"
|
||||
ColorRange.Partial="Delni"
|
||||
ColorRange.Full="Polni"
|
||||
|
||||
|
|
|
|||
153
plugins/linux-v4l2/v4l2-controls.c
Normal file
153
plugins/linux-v4l2/v4l2-controls.c
Normal file
|
|
@ -0,0 +1,153 @@
|
|||
/*
|
||||
Copyright (C) 2019 by Gary Kramlich <grim@reaperworld.com>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <linux/videodev2.h>
|
||||
#include <libv4l2.h>
|
||||
|
||||
#include "v4l2-controls.h"
|
||||
|
||||
#define blog(level, msg, ...) blog(level, "v4l2-controls: " msg, ##__VA_ARGS__)
|
||||
|
||||
#if defined(__LP64__)
|
||||
#define UINT_TO_POINTER(val) ((void *)(unsigned long)(val))
|
||||
#define POINTER_TO_UINT(p) ((unsigned int)(unsigned long)(p))
|
||||
#else
|
||||
#define UINT_TO_POINTER(val) ((void *)(unsigned int)(val))
|
||||
#define POINTER_TO_UINT(p) ((unsigned int)(unsigned int)(p))
|
||||
#endif
|
||||
|
||||
static bool v4l2_control_changed(void *data, obs_properties_t *props,
|
||||
obs_property_t *prop, obs_data_t *settings)
|
||||
{
|
||||
int dev = v4l2_open(obs_data_get_string(settings, "device_id"),
|
||||
O_RDWR | O_NONBLOCK);
|
||||
bool ret = false;
|
||||
|
||||
(void)props;
|
||||
|
||||
if (dev == -1)
|
||||
return false;
|
||||
|
||||
struct v4l2_control control;
|
||||
control.id = POINTER_TO_UINT(data);
|
||||
control.value = obs_data_get_int(settings, obs_property_name(prop));
|
||||
|
||||
if (0 != v4l2_ioctl(dev, VIDIOC_S_CTRL, &control)) {
|
||||
ret = true;
|
||||
}
|
||||
|
||||
v4l2_close(dev);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int_fast32_t v4l2_update_controls_menu(int_fast32_t dev,
|
||||
obs_properties_t *props,
|
||||
struct v4l2_queryctrl *qctrl)
|
||||
{
|
||||
obs_property_t *prop;
|
||||
struct v4l2_querymenu qmenu;
|
||||
|
||||
prop = obs_properties_add_list(props, (char *)qctrl->name,
|
||||
(char *)qctrl->name, OBS_COMBO_TYPE_LIST,
|
||||
OBS_COMBO_FORMAT_INT);
|
||||
|
||||
obs_property_set_modified_callback2(prop, v4l2_control_changed,
|
||||
UINT_TO_POINTER(qctrl->id));
|
||||
|
||||
memset(&qmenu, 0, sizeof(qmenu));
|
||||
qmenu.id = qctrl->id;
|
||||
|
||||
for (qmenu.index = qctrl->minimum;
|
||||
qmenu.index <= (uint32_t)qctrl->maximum;
|
||||
qmenu.index += qctrl->step) {
|
||||
if (0 == v4l2_ioctl(dev, VIDIOC_QUERYMENU, &qmenu)) {
|
||||
obs_property_list_add_int(prop, (char *)qmenu.name,
|
||||
qmenu.value);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define INVALID_CONTROL_FLAGS \
|
||||
(V4L2_CTRL_FLAG_DISABLED | V4L2_CTRL_FLAG_READ_ONLY | \
|
||||
V4L2_CTRL_FLAG_VOLATILE)
|
||||
|
||||
static inline bool valid_control(struct v4l2_queryctrl *qctrl)
|
||||
{
|
||||
return (qctrl->flags & INVALID_CONTROL_FLAGS) == 0;
|
||||
}
|
||||
|
||||
static inline bool add_control_property(obs_properties_t *props,
|
||||
obs_data_t *settings, int_fast32_t dev,
|
||||
struct v4l2_queryctrl *qctrl)
|
||||
{
|
||||
obs_property_t *prop = NULL;
|
||||
|
||||
if (!valid_control(qctrl)) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (qctrl->type) {
|
||||
case V4L2_CTRL_TYPE_INTEGER:
|
||||
prop = obs_properties_add_int_slider(
|
||||
props, (char *)qctrl->name, (char *)qctrl->name,
|
||||
qctrl->minimum, qctrl->maximum, qctrl->step);
|
||||
obs_data_set_default_int(settings, (char *)qctrl->name,
|
||||
qctrl->default_value);
|
||||
obs_property_set_modified_callback2(prop, v4l2_control_changed,
|
||||
UINT_TO_POINTER(qctrl->id));
|
||||
break;
|
||||
case V4L2_CTRL_TYPE_BOOLEAN:
|
||||
prop = obs_properties_add_bool(props, (char *)qctrl->name,
|
||||
(char *)qctrl->name);
|
||||
obs_data_set_default_bool(settings, (char *)qctrl->name,
|
||||
qctrl->default_value);
|
||||
obs_property_set_modified_callback2(prop, v4l2_control_changed,
|
||||
UINT_TO_POINTER(qctrl->id));
|
||||
break;
|
||||
case V4L2_CTRL_TYPE_MENU:
|
||||
case V4L2_CTRL_TYPE_INTEGER_MENU:
|
||||
v4l2_update_controls_menu(dev, props, qctrl);
|
||||
obs_data_set_default_int(settings, (char *)qctrl->name,
|
||||
qctrl->default_value);
|
||||
blog(LOG_INFO, "setting default for %s to %d",
|
||||
(char *)qctrl->name, qctrl->default_value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int_fast32_t v4l2_update_controls(int_fast32_t dev, obs_properties_t *props,
|
||||
obs_data_t *settings)
|
||||
{
|
||||
struct v4l2_queryctrl qctrl;
|
||||
|
||||
if (!dev || !props)
|
||||
return -1;
|
||||
|
||||
memset(&qctrl, 0, sizeof(qctrl));
|
||||
qctrl.id = V4L2_CTRL_FLAG_NEXT_CTRL;
|
||||
while (0 == v4l2_ioctl(dev, VIDIOC_QUERYCTRL, &qctrl)) {
|
||||
add_control_property(props, settings, dev, &qctrl);
|
||||
qctrl.id |= V4L2_CTRL_FLAG_NEXT_CTRL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
40
plugins/linux-v4l2/v4l2-controls.h
Normal file
40
plugins/linux-v4l2/v4l2-controls.h
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
Copyright (C) 2019 by Gary Kramlich <grim@reaperworld.com>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <obs-module.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Update a devices properties to include all v4l controls that it supports.
|
||||
*
|
||||
* @param dev handle to the v4l2 device
|
||||
* @param props properties for the device
|
||||
* @param data the settings for the source
|
||||
*
|
||||
* @return negative on failure
|
||||
*/
|
||||
int_fast32_t v4l2_update_controls(int_fast32_t dev, obs_properties_t *props,
|
||||
obs_data_t *settings);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
@ -35,6 +35,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include <util/platform.h>
|
||||
#include <obs-module.h>
|
||||
|
||||
#include "v4l2-controls.h"
|
||||
#include "v4l2-helpers.h"
|
||||
|
||||
#if HAVE_UDEV
|
||||
|
|
@ -579,6 +580,7 @@ static bool device_selected(obs_properties_t *props, obs_property_t *p,
|
|||
|
||||
obs_property_t *prop = obs_properties_get(props, "input");
|
||||
v4l2_input_list(dev, prop);
|
||||
v4l2_update_controls(dev, props, settings);
|
||||
v4l2_close(dev);
|
||||
|
||||
obs_property_modified(prop, settings);
|
||||
|
|
@ -1005,4 +1007,5 @@ struct obs_source_info v4l2_input = {
|
|||
.update = v4l2_update,
|
||||
.get_defaults = v4l2_defaults,
|
||||
.get_properties = v4l2_properties,
|
||||
.icon_type = OBS_ICON_TYPE_CAMERA,
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue