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
|
|
@ -1,5 +1,6 @@
|
|||
V4L2Input="جهاز التقاط الفيديو (V4L2)"
|
||||
Device="الجهاز"
|
||||
Input="الوارد"
|
||||
VideoFormat="تنسيق الفيديو"
|
||||
VideoStandard="معيار الفيديو"
|
||||
DVTiming="توقيت DV"
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ FrameRate="Fotogrames per segon"
|
|||
LeaveUnchanged="No ho canviïs"
|
||||
UseBuffering="Usa memòria intermèdia"
|
||||
ColorRange="Gamma de colors"
|
||||
ColorRange.Default="Per defecte"
|
||||
ColorRange.Partial="Parcial"
|
||||
ColorRange.Full="Complet"
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ FrameRate="Snímkovací frekvence"
|
|||
LeaveUnchanged="Ponechat nezměněné"
|
||||
UseBuffering="Použít vyrovnávací paměť"
|
||||
ColorRange="Rozsah barev"
|
||||
ColorRange.Default="Výchozí"
|
||||
ColorRange.Partial="Částečný"
|
||||
ColorRange.Full="Plný"
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ FrameRate="Billedhastighed"
|
|||
LeaveUnchanged="Behold uændret"
|
||||
UseBuffering="Benyt buffering"
|
||||
ColorRange="Farveområde"
|
||||
ColorRange.Default="Standard"
|
||||
ColorRange.Partial="Delvist"
|
||||
ColorRange.Full="Fuldt"
|
||||
|
||||
|
|
|
|||
|
|
@ -3,12 +3,13 @@ Device="Gerät"
|
|||
Input="Eingabe"
|
||||
VideoFormat="Videoformat"
|
||||
VideoStandard="Videostandard"
|
||||
DVTiming="DV-Timing"
|
||||
DVTiming="DV‐Timing"
|
||||
Resolution="Auflösung"
|
||||
FrameRate="Bildrate"
|
||||
LeaveUnchanged="Unverändert lassen"
|
||||
UseBuffering="Puffern benutzen"
|
||||
ColorRange="Farbbereich"
|
||||
ColorRange.Default="Standard"
|
||||
ColorRange.Partial="Begrenzt"
|
||||
ColorRange.Full="Voll"
|
||||
|
||||
|
|
|
|||
|
|
@ -9,5 +9,6 @@ FrameRate="Frame Rate"
|
|||
LeaveUnchanged="Leave Unchanged"
|
||||
UseBuffering="Use Buffering"
|
||||
ColorRange="Color Range"
|
||||
ColorRange.Default="Default"
|
||||
ColorRange.Partial="Partial"
|
||||
ColorRange.Full="Full"
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ FrameRate="Frecuencia de imágenes"
|
|||
LeaveUnchanged="Dejar sin cambios"
|
||||
UseBuffering="Utilizar el almacenamiento en búfer"
|
||||
ColorRange="Gama de Colores"
|
||||
ColorRange.Default="Predeterminado"
|
||||
ColorRange.Partial="Parcial"
|
||||
ColorRange.Full="Completo"
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ FrameRate="Fotograma emaria"
|
|||
LeaveUnchanged="Utzi aldatu gabe"
|
||||
UseBuffering="Erabili bufferreratzea"
|
||||
ColorRange="Kolore tartea"
|
||||
ColorRange.Default="Lehenetsia"
|
||||
ColorRange.Partial="Partziala"
|
||||
ColorRange.Full="Osoa"
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ FrameRate="Kuvanopeus"
|
|||
LeaveUnchanged="Jätä ennalleen"
|
||||
UseBuffering="Käytä puskurointia"
|
||||
ColorRange="Värialue"
|
||||
ColorRange.Default="Oletus"
|
||||
ColorRange.Partial="Osittainen"
|
||||
ColorRange.Full="Täysi"
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ FrameRate="Images par seconde"
|
|||
LeaveUnchanged="Annuler les modifications"
|
||||
UseBuffering="Utiliser le tampon mémoire"
|
||||
ColorRange="Gamme de couleurs"
|
||||
ColorRange.Default="Par défaut"
|
||||
ColorRange.Partial="Partielle"
|
||||
ColorRange.Full="Complète"
|
||||
|
||||
|
|
|
|||
|
|
@ -3,9 +3,13 @@ Device="Dispositivo"
|
|||
Input="Entrada"
|
||||
VideoFormat="Formato de vídeo"
|
||||
VideoStandard="Vídeo estándar"
|
||||
DVTiming="Axuste DV"
|
||||
DVTiming="Sincronización do vídeo dixital (DV)"
|
||||
Resolution="Resolución"
|
||||
FrameRate="Velocidade de fotogramas"
|
||||
FrameRate="Taxa de fotogramas"
|
||||
LeaveUnchanged="Deixar sen cambios"
|
||||
UseBuffering="Utilizar o almacenamento no búfer"
|
||||
UseBuffering="Utilizar o almacenamento na memoria temporal"
|
||||
ColorRange="Gama de cores"
|
||||
ColorRange.Default="Predeterminado"
|
||||
ColorRange.Partial="Parcial"
|
||||
ColorRange.Full="Total"
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ FrameRate="Képkockasebesség"
|
|||
LeaveUnchanged="Változatlanul hagyni"
|
||||
UseBuffering="Pufferelés használata"
|
||||
ColorRange="Színtartomány"
|
||||
ColorRange.Default="Alapértelmezett"
|
||||
ColorRange.Partial="Részleges"
|
||||
ColorRange.Full="Teljes"
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ FrameRate="Velocità dei fotogrammi"
|
|||
LeaveUnchanged="Lascia invariato"
|
||||
UseBuffering="Utilizza il buffering"
|
||||
ColorRange="Gamma di colori"
|
||||
ColorRange.Default="Predefinito"
|
||||
ColorRange.Partial="Parziale"
|
||||
ColorRange.Full="Intero"
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ FrameRate="フレームレート"
|
|||
LeaveUnchanged="変更せずに戻る"
|
||||
UseBuffering="バッファリングを使用する"
|
||||
ColorRange="色範囲"
|
||||
ColorRange.Default="既定"
|
||||
ColorRange.Partial="一部"
|
||||
ColorRange.Full="全部"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
V4L2Input="ვიდეოს გადამღები მოწყობილობა (V4L2)"
|
||||
V4L2Input="ვიდეოჩამწერი მოწყობილობა (V4L2)"
|
||||
Device="მოწყობილობა"
|
||||
Input="შემავალი"
|
||||
Input="შეტანა"
|
||||
VideoFormat="ვიდეოს ფორმატი"
|
||||
VideoStandard="ვიდეოს სტანდარტი"
|
||||
DVTiming="ციფრული ვიდეოს სინქრონიზაცია"
|
||||
|
|
@ -9,6 +9,7 @@ FrameRate="კადრის სიხშირე"
|
|||
LeaveUnchanged="უცვლელად დატოვება"
|
||||
UseBuffering="ბუფერიზაციის გამოყენება"
|
||||
ColorRange="ფერთა გამა"
|
||||
ColorRange.Default="ნაგულისხმევი"
|
||||
ColorRange.Partial="ნაწილობრივი"
|
||||
ColorRange.Full="სრული"
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ FrameRate="프레임 레이트"
|
|||
LeaveUnchanged="저장하지 않고 두기"
|
||||
UseBuffering="버퍼링 사용"
|
||||
ColorRange="색상 범위"
|
||||
ColorRange.Default="기본값"
|
||||
ColorRange.Partial="부분"
|
||||
ColorRange.Full="전체"
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ FrameRate="Frame Rate"
|
|||
LeaveUnchanged="Ongewijzigd Laten"
|
||||
UseBuffering="Buffering Gebruiken"
|
||||
ColorRange="Kleurbereik"
|
||||
ColorRange.Default="Standaard"
|
||||
ColorRange.Partial="Gedeeltelijk"
|
||||
ColorRange.Full="Volledig"
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ FrameRate="Klatki na sekundę"
|
|||
LeaveUnchanged="Pozostaw bez zmian"
|
||||
UseBuffering="Użyj buforowania"
|
||||
ColorRange="Zakres kolorów"
|
||||
ColorRange.Default="Domyślny"
|
||||
ColorRange.Partial="Częściowy"
|
||||
ColorRange.Full="Pełny"
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ FrameRate="Taxa de quadros"
|
|||
LeaveUnchanged="Deixar inalterado"
|
||||
UseBuffering="Utilizar Buffering"
|
||||
ColorRange="Intervalo de Cor"
|
||||
ColorRange.Default="Padrão"
|
||||
ColorRange.Partial="Parcial"
|
||||
ColorRange.Full="Completo"
|
||||
|
||||
|
|
|
|||
|
|
@ -8,4 +8,8 @@ Resolution="Rezoluție"
|
|||
FrameRate="Frecvență de cadre"
|
||||
LeaveUnchanged="Lasă neschimbat"
|
||||
UseBuffering="Folosește zona tampon"
|
||||
ColorRange="Gamă de culori"
|
||||
ColorRange.Default="Implicită"
|
||||
ColorRange.Partial="Parțială"
|
||||
ColorRange.Full="Completă"
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ FrameRate="Частота кадров"
|
|||
LeaveUnchanged="Оставить без изменений"
|
||||
UseBuffering="Использовать буферизацию"
|
||||
ColorRange="Цветовой диапазон"
|
||||
ColorRange.Default="По умолчанию"
|
||||
ColorRange.Partial="Частичный"
|
||||
ColorRange.Full="Полный"
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ FrameRate="Bildhastighet"
|
|||
LeaveUnchanged="Lämna oförändrat"
|
||||
UseBuffering="Använd buffer"
|
||||
ColorRange="Färgintervall"
|
||||
ColorRange.Default="Standard"
|
||||
ColorRange.Partial="Delvis"
|
||||
ColorRange.Full="Full"
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ FrameRate="Kare Hızı"
|
|||
LeaveUnchanged="Değişmeden Bırak"
|
||||
UseBuffering="Arabelleğe Almayı Kullan"
|
||||
ColorRange="Renk Aralığı"
|
||||
ColorRange.Default="Varsayılan"
|
||||
ColorRange.Partial="Kısmi"
|
||||
ColorRange.Full="Tam"
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ FrameRate="Частота кадрів"
|
|||
LeaveUnchanged="Залишити без змін"
|
||||
UseBuffering="Увімкнути буферизацію"
|
||||
ColorRange="Колірний діапазон"
|
||||
ColorRange.Default="За замовчанням"
|
||||
ColorRange.Partial="Частковий"
|
||||
ColorRange.Full="Повний"
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ FrameRate="帧率"
|
|||
LeaveUnchanged="保持不变"
|
||||
UseBuffering="使用缓冲"
|
||||
ColorRange="颜色范围"
|
||||
ColorRange.Default="默认"
|
||||
ColorRange.Partial="部分"
|
||||
ColorRange.Full="全部"
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ FrameRate="影格率"
|
|||
LeaveUnchanged="不改變並離開"
|
||||
UseBuffering="使用緩衝"
|
||||
ColorRange="顏色範圍"
|
||||
ColorRange.Default="預設"
|
||||
ColorRange.Partial="部分"
|
||||
ColorRange.Full="完整"
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ int_fast32_t v4l2_start_capture(int_fast32_t dev, struct v4l2_buffer_data *buf)
|
|||
struct v4l2_buffer enq;
|
||||
|
||||
memset(&enq, 0, sizeof(enq));
|
||||
enq.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
enq.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
enq.memory = V4L2_MEMORY_MMAP;
|
||||
|
||||
for (enq.index = 0; enq.index < buf->count; ++enq.index) {
|
||||
|
|
@ -67,8 +67,8 @@ int_fast32_t v4l2_create_mmap(int_fast32_t dev, struct v4l2_buffer_data *buf)
|
|||
struct v4l2_buffer map;
|
||||
|
||||
memset(&req, 0, sizeof(req));
|
||||
req.count = 4;
|
||||
req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
req.count = 4;
|
||||
req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
req.memory = V4L2_MEMORY_MMAP;
|
||||
|
||||
if (v4l2_ioctl(dev, VIDIOC_REQBUFS, &req) < 0) {
|
||||
|
|
@ -82,10 +82,10 @@ int_fast32_t v4l2_create_mmap(int_fast32_t dev, struct v4l2_buffer_data *buf)
|
|||
}
|
||||
|
||||
buf->count = req.count;
|
||||
buf->info = bzalloc(req.count * sizeof(struct v4l2_mmap_info));
|
||||
buf->info = bzalloc(req.count * sizeof(struct v4l2_mmap_info));
|
||||
|
||||
memset(&map, 0, sizeof(map));
|
||||
map.type = req.type;
|
||||
map.type = req.type;
|
||||
map.memory = req.memory;
|
||||
|
||||
for (map.index = 0; map.index < req.count; ++map.index) {
|
||||
|
|
@ -95,9 +95,9 @@ int_fast32_t v4l2_create_mmap(int_fast32_t dev, struct v4l2_buffer_data *buf)
|
|||
}
|
||||
|
||||
buf->info[map.index].length = map.length;
|
||||
buf->info[map.index].start = v4l2_mmap(NULL, map.length,
|
||||
PROT_READ | PROT_WRITE, MAP_SHARED,
|
||||
dev, map.m.offset);
|
||||
buf->info[map.index].start =
|
||||
v4l2_mmap(NULL, map.length, PROT_READ | PROT_WRITE,
|
||||
MAP_SHARED, dev, map.m.offset);
|
||||
|
||||
if (buf->info[map.index].start == MAP_FAILED) {
|
||||
blog(LOG_ERROR, "mmap for buffer failed");
|
||||
|
|
@ -110,7 +110,7 @@ int_fast32_t v4l2_create_mmap(int_fast32_t dev, struct v4l2_buffer_data *buf)
|
|||
|
||||
int_fast32_t v4l2_destroy_mmap(struct v4l2_buffer_data *buf)
|
||||
{
|
||||
for(uint_fast32_t i = 0; i < buf->count; ++i) {
|
||||
for (uint_fast32_t i = 0; i < buf->count; ++i) {
|
||||
if (buf->info[i].start != MAP_FAILED && buf->info[i].start != 0)
|
||||
v4l2_munmap(buf->info[i].start, buf->info[i].length);
|
||||
}
|
||||
|
|
@ -128,9 +128,8 @@ int_fast32_t v4l2_set_input(int_fast32_t dev, int *input)
|
|||
if (!dev || !input)
|
||||
return -1;
|
||||
|
||||
return (*input == -1)
|
||||
? v4l2_ioctl(dev, VIDIOC_G_INPUT, input)
|
||||
: v4l2_ioctl(dev, VIDIOC_S_INPUT, input);
|
||||
return (*input == -1) ? v4l2_ioctl(dev, VIDIOC_G_INPUT, input)
|
||||
: v4l2_ioctl(dev, VIDIOC_S_INPUT, input);
|
||||
}
|
||||
|
||||
int_fast32_t v4l2_get_input_caps(int_fast32_t dev, int input, uint32_t *caps)
|
||||
|
|
@ -155,7 +154,7 @@ int_fast32_t v4l2_get_input_caps(int_fast32_t dev, int input, uint32_t *caps)
|
|||
}
|
||||
|
||||
int_fast32_t v4l2_set_format(int_fast32_t dev, int *resolution,
|
||||
int *pixelformat, int *bytesperline)
|
||||
int *pixelformat, int *bytesperline)
|
||||
{
|
||||
bool set = false;
|
||||
int width, height;
|
||||
|
|
@ -172,7 +171,7 @@ int_fast32_t v4l2_set_format(int_fast32_t dev, int *resolution,
|
|||
|
||||
if (*resolution != -1) {
|
||||
v4l2_unpack_tuple(&width, &height, *resolution);
|
||||
fmt.fmt.pix.width = width;
|
||||
fmt.fmt.pix.width = width;
|
||||
fmt.fmt.pix.height = height;
|
||||
set = true;
|
||||
}
|
||||
|
|
@ -185,8 +184,8 @@ int_fast32_t v4l2_set_format(int_fast32_t dev, int *resolution,
|
|||
if (set && (v4l2_ioctl(dev, VIDIOC_S_FMT, &fmt) < 0))
|
||||
return -1;
|
||||
|
||||
*resolution = v4l2_pack_tuple(fmt.fmt.pix.width, fmt.fmt.pix.height);
|
||||
*pixelformat = fmt.fmt.pix.pixelformat;
|
||||
*resolution = v4l2_pack_tuple(fmt.fmt.pix.width, fmt.fmt.pix.height);
|
||||
*pixelformat = fmt.fmt.pix.pixelformat;
|
||||
*bytesperline = fmt.fmt.pix.bytesperline;
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -208,7 +207,7 @@ int_fast32_t v4l2_set_framerate(int_fast32_t dev, int *framerate)
|
|||
|
||||
if (*framerate != -1) {
|
||||
v4l2_unpack_tuple(&num, &denom, *framerate);
|
||||
par.parm.capture.timeperframe.numerator = num;
|
||||
par.parm.capture.timeperframe.numerator = num;
|
||||
par.parm.capture.timeperframe.denominator = denom;
|
||||
set = true;
|
||||
}
|
||||
|
|
@ -217,7 +216,7 @@ int_fast32_t v4l2_set_framerate(int_fast32_t dev, int *framerate)
|
|||
return -1;
|
||||
|
||||
*framerate = v4l2_pack_tuple(par.parm.capture.timeperframe.numerator,
|
||||
par.parm.capture.timeperframe.denominator);
|
||||
par.parm.capture.timeperframe.denominator);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -238,7 +237,7 @@ int_fast32_t v4l2_set_standard(int_fast32_t dev, int *standard)
|
|||
}
|
||||
|
||||
int_fast32_t v4l2_enum_dv_timing(int_fast32_t dev, struct v4l2_dv_timings *dvt,
|
||||
int index)
|
||||
int index)
|
||||
{
|
||||
#if !defined(VIDIOC_ENUM_DV_TIMINGS) || !defined(V4L2_IN_CAP_DV_TIMINGS)
|
||||
UNUSED_PARAMETER(dev);
|
||||
|
|
@ -251,7 +250,7 @@ int_fast32_t v4l2_enum_dv_timing(int_fast32_t dev, struct v4l2_dv_timings *dvt,
|
|||
|
||||
struct v4l2_enum_dv_timings iter;
|
||||
memset(&iter, 0, sizeof(iter));
|
||||
iter.index = index;
|
||||
iter.index = index;
|
||||
|
||||
if (v4l2_ioctl(dev, VIDIOC_ENUM_DV_TIMINGS, &iter) < 0)
|
||||
return -1;
|
||||
|
|
|
|||
|
|
@ -57,19 +57,30 @@ struct v4l2_buffer_data {
|
|||
static inline enum video_format v4l2_to_obs_video_format(uint_fast32_t format)
|
||||
{
|
||||
switch (format) {
|
||||
case V4L2_PIX_FMT_YVYU: return VIDEO_FORMAT_YVYU;
|
||||
case V4L2_PIX_FMT_YUYV: return VIDEO_FORMAT_YUY2;
|
||||
case V4L2_PIX_FMT_UYVY: return VIDEO_FORMAT_UYVY;
|
||||
case V4L2_PIX_FMT_NV12: return VIDEO_FORMAT_NV12;
|
||||
case V4L2_PIX_FMT_YUV420: return VIDEO_FORMAT_I420;
|
||||
case V4L2_PIX_FMT_YVU420: return VIDEO_FORMAT_I420;
|
||||
case V4L2_PIX_FMT_YVYU:
|
||||
return VIDEO_FORMAT_YVYU;
|
||||
case V4L2_PIX_FMT_YUYV:
|
||||
return VIDEO_FORMAT_YUY2;
|
||||
case V4L2_PIX_FMT_UYVY:
|
||||
return VIDEO_FORMAT_UYVY;
|
||||
case V4L2_PIX_FMT_NV12:
|
||||
return VIDEO_FORMAT_NV12;
|
||||
case V4L2_PIX_FMT_YUV420:
|
||||
return VIDEO_FORMAT_I420;
|
||||
case V4L2_PIX_FMT_YVU420:
|
||||
return VIDEO_FORMAT_I420;
|
||||
#ifdef V4L2_PIX_FMT_XBGR32
|
||||
case V4L2_PIX_FMT_XBGR32: return VIDEO_FORMAT_BGRX;
|
||||
case V4L2_PIX_FMT_XBGR32:
|
||||
return VIDEO_FORMAT_BGRX;
|
||||
#endif
|
||||
#ifdef V4L2_PIX_FMT_ABGR32
|
||||
case V4L2_PIX_FMT_ABGR32: return VIDEO_FORMAT_BGRA;
|
||||
case V4L2_PIX_FMT_ABGR32:
|
||||
return VIDEO_FORMAT_BGRA;
|
||||
#endif
|
||||
default: return VIDEO_FORMAT_NONE;
|
||||
case V4L2_PIX_FMT_BGR24:
|
||||
return VIDEO_FORMAT_BGR3;
|
||||
default:
|
||||
return VIDEO_FORMAT_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -80,48 +91,26 @@ static inline enum video_format v4l2_to_obs_video_format(uint_fast32_t format)
|
|||
* and the height in the low word.
|
||||
* The array is terminated with a zero.
|
||||
*/
|
||||
static const int v4l2_framesizes[] =
|
||||
{
|
||||
static const int v4l2_framesizes[] = {
|
||||
/* 4:3 */
|
||||
160<<16 | 120,
|
||||
320<<16 | 240,
|
||||
480<<16 | 320,
|
||||
640<<16 | 480,
|
||||
800<<16 | 600,
|
||||
1024<<16 | 768,
|
||||
1280<<16 | 960,
|
||||
1440<<16 | 1050,
|
||||
1440<<16 | 1080,
|
||||
1600<<16 | 1200,
|
||||
160 << 16 | 120, 320 << 16 | 240, 480 << 16 | 320, 640 << 16 | 480,
|
||||
800 << 16 | 600, 1024 << 16 | 768, 1280 << 16 | 960, 1440 << 16 | 1050,
|
||||
1440 << 16 | 1080, 1600 << 16 | 1200,
|
||||
|
||||
/* 16:9 */
|
||||
640<<16 | 360,
|
||||
960<<16 | 540,
|
||||
1280<<16 | 720,
|
||||
1600<<16 | 900,
|
||||
1920<<16 | 1080,
|
||||
1920<<16 | 1200,
|
||||
2560<<16 | 1440,
|
||||
3840<<16 | 2160,
|
||||
640 << 16 | 360, 960 << 16 | 540, 1280 << 16 | 720, 1600 << 16 | 900,
|
||||
1920 << 16 | 1080, 1920 << 16 | 1200, 2560 << 16 | 1440,
|
||||
3840 << 16 | 2160,
|
||||
|
||||
/* 21:9 */
|
||||
2560<<16 | 1080,
|
||||
3440<<16 | 1440,
|
||||
5120<<16 | 2160,
|
||||
2560 << 16 | 1080, 3440 << 16 | 1440, 5120 << 16 | 2160,
|
||||
|
||||
/* tv */
|
||||
432<<16 | 520,
|
||||
480<<16 | 320,
|
||||
480<<16 | 530,
|
||||
486<<16 | 440,
|
||||
576<<16 | 310,
|
||||
576<<16 | 520,
|
||||
576<<16 | 570,
|
||||
720<<16 | 576,
|
||||
1024<<16 | 576,
|
||||
432 << 16 | 520, 480 << 16 | 320, 480 << 16 | 530, 486 << 16 | 440,
|
||||
576 << 16 | 310, 576 << 16 | 520, 576 << 16 | 570, 720 << 16 | 576,
|
||||
1024 << 16 | 576,
|
||||
|
||||
0
|
||||
};
|
||||
0};
|
||||
|
||||
/**
|
||||
* Fixed framerates for devices that don't support enumerating discrete values.
|
||||
|
|
@ -130,19 +119,16 @@ static const int v4l2_framesizes[] =
|
|||
* word and the denominator in the low word.
|
||||
* The array is terminated with a zero.
|
||||
*/
|
||||
static const int v4l2_framerates[] =
|
||||
{
|
||||
1<<16 | 60,
|
||||
1<<16 | 50,
|
||||
1<<16 | 30,
|
||||
1<<16 | 25,
|
||||
1<<16 | 20,
|
||||
1<<16 | 15,
|
||||
1<<16 | 10,
|
||||
1<<16 | 5,
|
||||
static const int v4l2_framerates[] = {1 << 16 | 60,
|
||||
1 << 16 | 50,
|
||||
1 << 16 | 30,
|
||||
1 << 16 | 25,
|
||||
1 << 16 | 20,
|
||||
1 << 16 | 15,
|
||||
1 << 16 | 10,
|
||||
1 << 16 | 5,
|
||||
|
||||
0
|
||||
};
|
||||
0};
|
||||
|
||||
/**
|
||||
* Pack two integer values into one
|
||||
|
|
@ -256,7 +242,7 @@ int_fast32_t v4l2_get_input_caps(int_fast32_t dev, int input, uint32_t *caps);
|
|||
* @return negative on failure
|
||||
*/
|
||||
int_fast32_t v4l2_set_format(int_fast32_t dev, int *resolution,
|
||||
int *pixelformat, int *bytesperline);
|
||||
int *pixelformat, int *bytesperline);
|
||||
|
||||
/**
|
||||
* Set the framerate on the device.
|
||||
|
|
@ -292,7 +278,7 @@ int_fast32_t v4l2_set_standard(int_fast32_t dev, int *standard);
|
|||
* @return negative on failure
|
||||
*/
|
||||
int_fast32_t v4l2_enum_dv_timing(int_fast32_t dev, struct v4l2_dv_timings *dvt,
|
||||
int index);
|
||||
int index);
|
||||
/**
|
||||
* Set a dv timing on the device
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -30,14 +30,12 @@ enum udev_action {
|
|||
UDEV_ACTION_UNKNOWN
|
||||
};
|
||||
|
||||
static const char *udev_signals[] = {
|
||||
"void device_added(string device)",
|
||||
"void device_removed(string device)",
|
||||
NULL
|
||||
};
|
||||
static const char *udev_signals[] = {"void device_added(string device)",
|
||||
"void device_removed(string device)",
|
||||
NULL};
|
||||
|
||||
/* global data */
|
||||
static uint_fast32_t udev_refs = 0;
|
||||
static uint_fast32_t udev_refs = 0;
|
||||
static pthread_mutex_t udev_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
static pthread_t udev_thread;
|
||||
|
|
@ -77,7 +75,7 @@ static inline void udev_signal_event(struct udev_device *dev)
|
|||
|
||||
pthread_mutex_lock(&udev_mutex);
|
||||
|
||||
node = udev_device_get_devnode(dev);
|
||||
node = udev_device_get_devnode(dev);
|
||||
action = udev_action_to_enum(udev_device_get_action(dev));
|
||||
|
||||
calldata_init(&data);
|
||||
|
|
@ -86,12 +84,12 @@ static inline void udev_signal_event(struct udev_device *dev)
|
|||
|
||||
switch (action) {
|
||||
case UDEV_ACTION_ADDED:
|
||||
signal_handler_signal(udev_signalhandler,
|
||||
"device_added", &data);
|
||||
signal_handler_signal(udev_signalhandler, "device_added",
|
||||
&data);
|
||||
break;
|
||||
case UDEV_ACTION_REMOVED:
|
||||
signal_handler_signal(udev_signalhandler,
|
||||
"device_removed", &data);
|
||||
signal_handler_signal(udev_signalhandler, "device_removed",
|
||||
&data);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
@ -118,9 +116,9 @@ static void *udev_event_thread(void *vptr)
|
|||
|
||||
/* set up udev monitoring */
|
||||
udev = udev_new();
|
||||
mon = udev_monitor_new_from_netlink(udev, "udev");
|
||||
udev_monitor_filter_add_match_subsystem_devtype(
|
||||
mon, "video4linux", NULL);
|
||||
mon = udev_monitor_new_from_netlink(udev, "udev");
|
||||
udev_monitor_filter_add_match_subsystem_devtype(mon, "video4linux",
|
||||
NULL);
|
||||
if (udev_monitor_enable_receiving(mon) < 0)
|
||||
return NULL;
|
||||
|
||||
|
|
@ -130,7 +128,7 @@ static void *udev_event_thread(void *vptr)
|
|||
while (os_event_try(udev_event) == EAGAIN) {
|
||||
FD_ZERO(&fds);
|
||||
FD_SET(fd, &fds);
|
||||
tv.tv_sec = 1;
|
||||
tv.tv_sec = 1;
|
||||
tv.tv_usec = 0;
|
||||
|
||||
if (select(fd + 1, &fds, NULL, NULL, &tv) <= 0)
|
||||
|
|
@ -160,14 +158,13 @@ void v4l2_init_udev(void)
|
|||
if (os_event_init(&udev_event, OS_EVENT_TYPE_MANUAL) != 0)
|
||||
goto fail;
|
||||
if (pthread_create(&udev_thread, NULL, udev_event_thread,
|
||||
NULL) != 0)
|
||||
NULL) != 0)
|
||||
goto fail;
|
||||
|
||||
udev_signalhandler = signal_handler_create();
|
||||
if (!udev_signalhandler)
|
||||
goto fail;
|
||||
signal_handler_add_array(udev_signalhandler, udev_signals);
|
||||
|
||||
}
|
||||
udev_refs++;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue