New upstream version 26.1.0+dfsg1
This commit is contained in:
parent
040dcc3fc2
commit
013818c4af
594 changed files with 19576 additions and 4478 deletions
|
|
@ -39,6 +39,7 @@ set(linux-v4l2_SOURCES
|
|||
v4l2-controls.c
|
||||
v4l2-input.c
|
||||
v4l2-helpers.c
|
||||
v4l2-output.c
|
||||
${linux-v4l2-udev_SOURCES}
|
||||
)
|
||||
|
||||
|
|
|
|||
16
plugins/linux-v4l2/data/locale/az-AZ.ini
Normal file
16
plugins/linux-v4l2/data/locale/az-AZ.ini
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
V4L2Input="Video Yaxalama Cihazı (V4L2)"
|
||||
Device="Cihaz"
|
||||
Input="Giriş"
|
||||
VideoFormat="Video formatı"
|
||||
VideoStandard="Video standartı"
|
||||
DVTiming="DV zamanlama"
|
||||
Resolution="Ölçülər"
|
||||
FrameRate="Kadr sürəti"
|
||||
LeaveUnchanged="Dəyişmədən çıx"
|
||||
UseBuffering="Bufferləməni istifadə et"
|
||||
ColorRange="Rəng aralığı"
|
||||
ColorRange.Default="İlkin"
|
||||
ColorRange.Partial="Hissəli"
|
||||
ColorRange.Full="Tam"
|
||||
CameraCtrls="Kamera nəzarəti"
|
||||
|
||||
|
|
@ -3,7 +3,7 @@ Device="Gerät"
|
|||
Input="Eingabe"
|
||||
VideoFormat="Videoformat"
|
||||
VideoStandard="Videostandard"
|
||||
DVTiming="DV‐Timing"
|
||||
DVTiming="DV-Timing"
|
||||
Resolution="Auflösung"
|
||||
FrameRate="Bildrate"
|
||||
LeaveUnchanged="Unverändert lassen"
|
||||
|
|
|
|||
|
|
@ -8,4 +8,9 @@ Resolution="Ανάλυση"
|
|||
FrameRate="Ρυθμός καρέ"
|
||||
LeaveUnchanged="Αφήστε αμετάβλητο"
|
||||
UseBuffering="Χρήση ενδιάμεσης μνήμης"
|
||||
ColorRange="Εύρος Χρωμάτων"
|
||||
ColorRange.Default="Προεπιλογή"
|
||||
ColorRange.Partial="Μερικό"
|
||||
ColorRange.Full="Πλήρες"
|
||||
CameraCtrls="Έλεγχοι φωτογραφικής μηχανής"
|
||||
|
||||
|
|
|
|||
|
|
@ -8,4 +8,9 @@ Resolution="Resolutsioon"
|
|||
FrameRate="Kaadrisagedus"
|
||||
LeaveUnchanged="Jäta muutmata"
|
||||
UseBuffering="Kasuta puhverdamist"
|
||||
ColorRange="Värviruumi vahemik"
|
||||
ColorRange.Default="Vaikeseade"
|
||||
ColorRange.Partial="Osaline"
|
||||
ColorRange.Full="Täielik"
|
||||
CameraCtrls="Kaamera juhtnupud"
|
||||
|
||||
|
|
|
|||
|
|
@ -12,4 +12,5 @@ ColorRange="محدوده رنگ"
|
|||
ColorRange.Default="پیش فرض"
|
||||
ColorRange.Partial="جزئی"
|
||||
ColorRange.Full="کامل"
|
||||
CameraCtrls="کنترل دوربین"
|
||||
|
||||
|
|
|
|||
16
plugins/linux-v4l2/data/locale/kab-KAB.ini
Normal file
16
plugins/linux-v4l2/data/locale/kab-KAB.ini
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
V4L2Input="Ibenk n tuṭṭfa n uvidyu (V4L2)"
|
||||
Device="Ibenk"
|
||||
Input="Anekcum"
|
||||
VideoFormat="Amasal n uvidyu"
|
||||
VideoStandard="Alugen n uvidyu"
|
||||
DVTiming="Akud DV"
|
||||
Resolution="Tabadut"
|
||||
FrameRate="Atug n yikataren"
|
||||
LeaveUnchanged="Eǧǧ-it s war abeddel"
|
||||
UseBuffering="Seqdec ajmaɛ di tkatut n weḥraz"
|
||||
ColorRange="Tagrumma n yini"
|
||||
ColorRange.Default="Amezwar"
|
||||
ColorRange.Partial="Abruyan"
|
||||
ColorRange.Full="Ummid"
|
||||
CameraCtrls="Isenqaden n tkamiṛat"
|
||||
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
V4L2Input="Dispositivo de Captura de Vídeo (V4L2)"
|
||||
V4L2Input="Dispositivo de captura de vídeo (V4L2)"
|
||||
Device="Dispositivo"
|
||||
Input="Entrada"
|
||||
VideoFormat="Formato de Vídeo"
|
||||
VideoFormat="Formato de vídeo"
|
||||
VideoStandard="Padrão de vídeo"
|
||||
DVTiming="Sincronismo DV"
|
||||
Resolution="Resolução"
|
||||
|
|
|
|||
|
|
@ -12,5 +12,5 @@ ColorRange="Gamă de culori"
|
|||
ColorRange.Default="Implicită"
|
||||
ColorRange.Partial="Parțială"
|
||||
ColorRange.Full="Completă"
|
||||
CameraCtrls="Controale cameră foto"
|
||||
CameraCtrls="Comenzi pentru cameră"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,15 @@
|
|||
V4L2Input="Thiết bị quay video (V4L2)"
|
||||
Device="Thiết bị"
|
||||
Input="Đầu vào"
|
||||
VideoFormat="Định dạng video"
|
||||
VideoStandard="Video Tiêu chuẩn"
|
||||
Resolution="Độ phân giải"
|
||||
FrameRate="Tốc độ khung"
|
||||
LeaveUnchanged="Giữ nguyên"
|
||||
UseBuffering="Dùng đệm"
|
||||
ColorRange="Dải màu"
|
||||
ColorRange.Default="Mặc định"
|
||||
ColorRange.Partial="Một phần"
|
||||
ColorRange.Full="Toàn phần"
|
||||
CameraCtrls="Điều khiển máy quay"
|
||||
|
||||
|
|
|
|||
|
|
@ -15,18 +15,47 @@ 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 <obs-module.h>
|
||||
#include <util/platform.h>
|
||||
|
||||
OBS_DECLARE_MODULE()
|
||||
OBS_MODULE_USE_DEFAULT_LOCALE("linux-v4l2", "en-US")
|
||||
MODULE_EXPORT const char *obs_module_description(void)
|
||||
{
|
||||
return "Video4Linux2(V4L2) sources";
|
||||
return "Video4Linux2(V4L2) sources/virtual camera";
|
||||
}
|
||||
|
||||
extern struct obs_source_info v4l2_input;
|
||||
extern struct obs_output_info virtualcam_info;
|
||||
|
||||
static bool v4l2loopback_installed()
|
||||
{
|
||||
bool loaded = false;
|
||||
|
||||
int ret = system("modinfo v4l2loopback >/dev/null 2>&1");
|
||||
|
||||
if (ret == 0)
|
||||
loaded = true;
|
||||
|
||||
return loaded;
|
||||
}
|
||||
|
||||
bool obs_module_load(void)
|
||||
{
|
||||
obs_register_source(&v4l2_input);
|
||||
|
||||
obs_data_t *obs_settings = obs_data_create();
|
||||
|
||||
if (v4l2loopback_installed()) {
|
||||
obs_register_output(&virtualcam_info);
|
||||
obs_data_set_bool(obs_settings, "vcamEnabled", true);
|
||||
} else {
|
||||
obs_data_set_bool(obs_settings, "vcamEnabled", false);
|
||||
blog(LOG_WARNING,
|
||||
"v4l2loopback not installed, virtual camera disabled");
|
||||
}
|
||||
|
||||
obs_apply_private_data(obs_settings);
|
||||
obs_data_release(obs_settings);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
176
plugins/linux-v4l2/v4l2-output.c
Normal file
176
plugins/linux-v4l2/v4l2-output.c
Normal file
|
|
@ -0,0 +1,176 @@
|
|||
#include <obs-module.h>
|
||||
#include <util/platform.h>
|
||||
#include <linux/videodev2.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define MAX_DEVICES 64
|
||||
|
||||
struct virtualcam_data {
|
||||
obs_output_t *output;
|
||||
int device;
|
||||
uint32_t frame_size;
|
||||
};
|
||||
|
||||
static const char *virtualcam_name(void *unused)
|
||||
{
|
||||
UNUSED_PARAMETER(unused);
|
||||
return "Virtual Camera Output";
|
||||
}
|
||||
|
||||
static void virtualcam_destroy(void *data)
|
||||
{
|
||||
struct virtualcam_data *vcam = (struct virtualcam_data *)data;
|
||||
close(vcam->device);
|
||||
bfree(data);
|
||||
}
|
||||
|
||||
static bool loopback_module_loaded()
|
||||
{
|
||||
bool loaded = false;
|
||||
|
||||
char temp[512];
|
||||
|
||||
FILE *fp = fopen("/proc/modules", "r");
|
||||
|
||||
if (!fp)
|
||||
return false;
|
||||
|
||||
while (fgets(temp, sizeof(temp), fp)) {
|
||||
if (strstr(temp, "v4l2loopback")) {
|
||||
loaded = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (fp)
|
||||
fclose(fp);
|
||||
|
||||
return loaded;
|
||||
}
|
||||
|
||||
static int loopback_module_load()
|
||||
{
|
||||
return system(
|
||||
"pkexec modprobe v4l2loopback exclusive_caps=1 card_label='OBS Virtual Camera' && sleep 0.5");
|
||||
}
|
||||
|
||||
static void *virtualcam_create(obs_data_t *settings, obs_output_t *output)
|
||||
{
|
||||
struct virtualcam_data *vcam =
|
||||
(struct virtualcam_data *)bzalloc(sizeof(*vcam));
|
||||
vcam->output = output;
|
||||
|
||||
UNUSED_PARAMETER(settings);
|
||||
return vcam;
|
||||
}
|
||||
|
||||
static bool try_connect(void *data, int device)
|
||||
{
|
||||
struct virtualcam_data *vcam = (struct virtualcam_data *)data;
|
||||
struct v4l2_format format;
|
||||
struct v4l2_capability capability;
|
||||
struct v4l2_streamparm parm;
|
||||
|
||||
uint32_t width = obs_output_get_width(vcam->output);
|
||||
uint32_t height = obs_output_get_height(vcam->output);
|
||||
|
||||
vcam->frame_size = width * height * 2;
|
||||
|
||||
char new_device[16];
|
||||
sprintf(new_device, "/dev/video%d", device);
|
||||
|
||||
vcam->device = open(new_device, O_RDWR);
|
||||
|
||||
if (vcam->device < 0)
|
||||
return false;
|
||||
|
||||
if (ioctl(vcam->device, VIDIOC_QUERYCAP, &capability) < 0)
|
||||
return false;
|
||||
|
||||
format.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
|
||||
|
||||
if (ioctl(vcam->device, VIDIOC_G_FMT, &format) < 0)
|
||||
return false;
|
||||
|
||||
struct obs_video_info ovi;
|
||||
obs_get_video_info(&ovi);
|
||||
|
||||
memset(&parm, 0, sizeof(parm));
|
||||
parm.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
|
||||
|
||||
parm.parm.output.capability = V4L2_CAP_TIMEPERFRAME;
|
||||
parm.parm.output.timeperframe.numerator = ovi.fps_den;
|
||||
parm.parm.output.timeperframe.denominator = ovi.fps_num;
|
||||
|
||||
if (ioctl(vcam->device, VIDIOC_S_PARM, &parm) < 0)
|
||||
return false;
|
||||
|
||||
format.fmt.pix.width = width;
|
||||
format.fmt.pix.height = height;
|
||||
format.fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV;
|
||||
format.fmt.pix.sizeimage = vcam->frame_size;
|
||||
|
||||
if (ioctl(vcam->device, VIDIOC_S_FMT, &format) < 0)
|
||||
return false;
|
||||
|
||||
struct video_scale_info vsi = {0};
|
||||
vsi.format = VIDEO_FORMAT_YUY2;
|
||||
vsi.width = width;
|
||||
vsi.height = height;
|
||||
obs_output_set_video_conversion(vcam->output, &vsi);
|
||||
|
||||
blog(LOG_INFO, "Virtual camera started");
|
||||
obs_output_begin_data_capture(vcam->output, 0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool virtualcam_start(void *data)
|
||||
{
|
||||
struct virtualcam_data *vcam = (struct virtualcam_data *)data;
|
||||
|
||||
if (!loopback_module_loaded()) {
|
||||
if (loopback_module_load() != 0)
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < MAX_DEVICES; i++) {
|
||||
if (!try_connect(vcam, i))
|
||||
continue;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
blog(LOG_WARNING, "Failed to start virtual camera");
|
||||
return false;
|
||||
}
|
||||
|
||||
static void virtualcam_stop(void *data, uint64_t ts)
|
||||
{
|
||||
struct virtualcam_data *vcam = (struct virtualcam_data *)data;
|
||||
obs_output_end_data_capture(vcam->output);
|
||||
close(vcam->device);
|
||||
|
||||
blog(LOG_INFO, "Virtual camera stopped");
|
||||
|
||||
UNUSED_PARAMETER(ts);
|
||||
}
|
||||
|
||||
static void virtual_video(void *param, struct video_data *frame)
|
||||
{
|
||||
struct virtualcam_data *vcam = (struct virtualcam_data *)param;
|
||||
write(vcam->device, frame->data[0], vcam->frame_size);
|
||||
}
|
||||
|
||||
struct obs_output_info virtualcam_info = {
|
||||
.id = "virtualcam_output",
|
||||
.flags = OBS_OUTPUT_VIDEO,
|
||||
.get_name = virtualcam_name,
|
||||
.create = virtualcam_create,
|
||||
.destroy = virtualcam_destroy,
|
||||
.start = virtualcam_start,
|
||||
.stop = virtualcam_stop,
|
||||
.raw_video = virtual_video,
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue