Imported Upstream version 0.13.2+dsfg1
This commit is contained in:
commit
fb3990e9e5
2036 changed files with 287360 additions and 0 deletions
44
plugins/mac-capture/CMakeLists.txt
Normal file
44
plugins/mac-capture/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
project(mac-capture)
|
||||
|
||||
find_library(COREAUDIO CoreAudio)
|
||||
find_library(AUDIOUNIT AudioUnit)
|
||||
find_library(COREFOUNDATION CoreFoundation)
|
||||
find_library(IOSURF IOSurface)
|
||||
find_library(COCOA Cocoa)
|
||||
|
||||
include_directories(${COREAUDIO}
|
||||
${AUDIOUNIT}
|
||||
${COREFOUNDATION}
|
||||
${IOSURF}
|
||||
${COCOA})
|
||||
|
||||
set(mac-capture_HEADERS
|
||||
audio-device-enum.h
|
||||
mac-helpers.h
|
||||
window-utils.h)
|
||||
|
||||
set(mac-capture_SOURCES
|
||||
plugin-main.c
|
||||
audio-device-enum.c
|
||||
mac-audio.c
|
||||
mac-display-capture.m
|
||||
mac-window-capture.m
|
||||
window-utils.m)
|
||||
|
||||
set_source_files_properties(mac-display-capture.m
|
||||
mac-window-capture.m
|
||||
window-utils.m
|
||||
PROPERTIES LANGUAGE C)
|
||||
|
||||
add_library(mac-capture MODULE
|
||||
${mac-capture_SOURCES}
|
||||
${mac-capture_HEADERS})
|
||||
target_link_libraries(mac-capture
|
||||
libobs
|
||||
${COREAUDIO}
|
||||
${AUDIOUNIT}
|
||||
${COREFOUNDATION}
|
||||
${IOSURF}
|
||||
${COCOA})
|
||||
|
||||
install_obs_plugin_with_data(mac-capture data)
|
||||
164
plugins/mac-capture/audio-device-enum.c
Normal file
164
plugins/mac-capture/audio-device-enum.c
Normal file
|
|
@ -0,0 +1,164 @@
|
|||
#include <CoreFoundation/CFString.h>
|
||||
#include <CoreAudio/CoreAudio.h>
|
||||
|
||||
#include "mac-helpers.h"
|
||||
#include "audio-device-enum.h"
|
||||
|
||||
/* ugh, because mac has no means of capturing output, we have to basically
|
||||
* mark soundflower, wavtap and sound siphon as output devices. */
|
||||
static inline bool device_is_input(char *device)
|
||||
{
|
||||
return astrstri(device, "soundflower") == NULL &&
|
||||
astrstri(device, "wavtap") == NULL &&
|
||||
astrstri(device, "soundsiphon") == NULL;
|
||||
}
|
||||
|
||||
static inline bool enum_success(OSStatus stat, const char *msg)
|
||||
{
|
||||
if (stat != noErr) {
|
||||
blog(LOG_WARNING, "[coreaudio_enum_devices] %s failed: %d",
|
||||
msg, (int)stat);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
typedef bool (*enum_device_proc_t)(void *param, CFStringRef cf_name,
|
||||
CFStringRef cf_uid, AudioDeviceID id);
|
||||
|
||||
static bool coreaudio_enum_device(enum_device_proc_t proc, void *param,
|
||||
AudioDeviceID id)
|
||||
{
|
||||
UInt32 size = 0;
|
||||
CFStringRef cf_name = NULL;
|
||||
CFStringRef cf_uid = NULL;
|
||||
bool enum_next = true;
|
||||
OSStatus stat;
|
||||
|
||||
AudioObjectPropertyAddress addr = {
|
||||
kAudioDevicePropertyStreams,
|
||||
kAudioDevicePropertyScopeInput,
|
||||
kAudioObjectPropertyElementMaster
|
||||
};
|
||||
|
||||
/* check to see if it's a mac input device */
|
||||
AudioObjectGetPropertyDataSize(id, &addr, 0, NULL, &size);
|
||||
if (!size)
|
||||
return true;
|
||||
|
||||
size = sizeof(CFStringRef);
|
||||
|
||||
addr.mSelector = kAudioDevicePropertyDeviceUID;
|
||||
stat = AudioObjectGetPropertyData(id, &addr, 0, NULL, &size, &cf_uid);
|
||||
if (!enum_success(stat, "get audio device UID"))
|
||||
return true;
|
||||
|
||||
addr.mSelector = kAudioDevicePropertyDeviceNameCFString;
|
||||
stat = AudioObjectGetPropertyData(id, &addr, 0, NULL, &size, &cf_name);
|
||||
if (!enum_success(stat, "get audio device name"))
|
||||
goto fail;
|
||||
|
||||
enum_next = proc(param, cf_name, cf_uid, id);
|
||||
|
||||
fail:
|
||||
if (cf_name)
|
||||
CFRelease(cf_name);
|
||||
if (cf_uid)
|
||||
CFRelease(cf_uid);
|
||||
return enum_next;
|
||||
}
|
||||
|
||||
static void enum_devices(enum_device_proc_t proc, void *param)
|
||||
{
|
||||
AudioObjectPropertyAddress addr = {
|
||||
kAudioHardwarePropertyDevices,
|
||||
kAudioObjectPropertyScopeGlobal,
|
||||
kAudioObjectPropertyElementMaster
|
||||
};
|
||||
|
||||
UInt32 size = 0;
|
||||
UInt32 count;
|
||||
OSStatus stat;
|
||||
AudioDeviceID *ids;
|
||||
|
||||
stat = AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &addr,
|
||||
0, NULL, &size);
|
||||
if (!enum_success(stat, "get kAudioObjectSystemObject data size"))
|
||||
return;
|
||||
|
||||
ids = bmalloc(size);
|
||||
count = size / sizeof(AudioDeviceID);
|
||||
|
||||
stat = AudioObjectGetPropertyData(kAudioObjectSystemObject, &addr,
|
||||
0, NULL, &size, ids);
|
||||
|
||||
if (enum_success(stat, "get kAudioObjectSystemObject data"))
|
||||
for (UInt32 i = 0; i < count; i++)
|
||||
if (!coreaudio_enum_device(proc, param, ids[i]))
|
||||
break;
|
||||
|
||||
bfree(ids);
|
||||
}
|
||||
|
||||
struct add_data {
|
||||
struct device_list *list;
|
||||
bool input;
|
||||
};
|
||||
|
||||
static bool coreaudio_enum_add_device(void *param, CFStringRef cf_name,
|
||||
CFStringRef cf_uid, AudioDeviceID id)
|
||||
{
|
||||
struct add_data *data = param;
|
||||
struct device_item item;
|
||||
|
||||
memset(&item, 0, sizeof(item));
|
||||
|
||||
if (!cf_to_dstr(cf_name, &item.name))
|
||||
goto fail;
|
||||
if (!cf_to_dstr(cf_uid, &item.value))
|
||||
goto fail;
|
||||
|
||||
if (data->input || !device_is_input(item.value.array))
|
||||
device_list_add(data->list, &item);
|
||||
|
||||
fail:
|
||||
device_item_free(&item);
|
||||
|
||||
UNUSED_PARAMETER(id);
|
||||
return true;
|
||||
}
|
||||
|
||||
void coreaudio_enum_devices(struct device_list *list, bool input)
|
||||
{
|
||||
struct add_data data = {list, input};
|
||||
enum_devices(coreaudio_enum_add_device, &data);
|
||||
}
|
||||
|
||||
struct device_id_data {
|
||||
CFStringRef uid;
|
||||
AudioDeviceID *id;
|
||||
bool found;
|
||||
};
|
||||
|
||||
static bool get_device_id(void *param, CFStringRef cf_name, CFStringRef cf_uid,
|
||||
AudioDeviceID id)
|
||||
{
|
||||
struct device_id_data *data = param;
|
||||
|
||||
if (CFStringCompare(cf_uid, data->uid, 0) == 0) {
|
||||
*data->id = id;
|
||||
data->found = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
UNUSED_PARAMETER(cf_name);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool coreaudio_get_device_id(CFStringRef uid, AudioDeviceID *id)
|
||||
{
|
||||
struct device_id_data data = {uid, id, false};
|
||||
enum_devices(get_device_id, &data);
|
||||
return data.found;
|
||||
}
|
||||
36
plugins/mac-capture/audio-device-enum.h
Normal file
36
plugins/mac-capture/audio-device-enum.h
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
#pragma once
|
||||
|
||||
#include <util/darray.h>
|
||||
#include <util/dstr.h>
|
||||
|
||||
struct device_item {
|
||||
struct dstr name, value;
|
||||
};
|
||||
|
||||
static inline void device_item_free(struct device_item *item)
|
||||
{
|
||||
dstr_free(&item->name);
|
||||
dstr_free(&item->value);
|
||||
}
|
||||
|
||||
struct device_list {
|
||||
DARRAY(struct device_item) items;
|
||||
};
|
||||
|
||||
static inline void device_list_free(struct device_list *list)
|
||||
{
|
||||
for (size_t i = 0; i < list->items.num; i++)
|
||||
device_item_free(list->items.array+i);
|
||||
|
||||
da_free(list->items);
|
||||
}
|
||||
|
||||
static inline void device_list_add(struct device_list *list,
|
||||
struct device_item *item)
|
||||
{
|
||||
da_push_back(list->items, item);
|
||||
memset(item, 0, sizeof(struct device_item));
|
||||
}
|
||||
|
||||
extern void coreaudio_enum_devices(struct device_list *list, bool input);
|
||||
extern bool coreaudio_get_device_id(CFStringRef uid, AudioDeviceID *id);
|
||||
8
plugins/mac-capture/data/locale/ar-SA.ini
Normal file
8
plugins/mac-capture/data/locale/ar-SA.ini
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
CoreAudio.InputCapture="التقاط مدخل الصوت"
|
||||
CoreAudio.OutputCapture="التقاط مخرج الصوت"
|
||||
CoreAudio.Device="الجهاز"
|
||||
CoreAudio.Device.Default="الافتراضي"
|
||||
DisplayCapture="التقاط الشاشة"
|
||||
DisplayCapture.Display="عرض"
|
||||
DisplayCapture.ShowCursor="إظهار المؤشر"
|
||||
|
||||
21
plugins/mac-capture/data/locale/ca-ES.ini
Normal file
21
plugins/mac-capture/data/locale/ca-ES.ini
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
CoreAudio.InputCapture="Captura l'àudio d'entrada"
|
||||
CoreAudio.OutputCapture="Captura l'àudio de sortida"
|
||||
CoreAudio.Device="Dispositiu"
|
||||
CoreAudio.Device.Default="Per defecte"
|
||||
DisplayCapture="Captura de pantalla"
|
||||
DisplayCapture.Display="Pantalla"
|
||||
DisplayCapture.ShowCursor="Mostra el cursor"
|
||||
WindowCapture="Captura de finestra"
|
||||
WindowCapture.ShowShadow="Mostra l'ombra de la finestra"
|
||||
WindowUtils.Window="Finestra"
|
||||
WindowUtils.ShowEmptyNames="Mostra les finestres amb noms buits"
|
||||
CropMode="Escapça"
|
||||
CropMode.None="Cap"
|
||||
CropMode.Manual="Manual"
|
||||
CropMode.ToWindow="A la finestra"
|
||||
CropMode.ToWindowAndManual="A la finestra i manual"
|
||||
Crop.origin.x="Espaçament esquerre"
|
||||
Crop.origin.y="Escapçament superior"
|
||||
Crop.size.width="Escapçament dret"
|
||||
Crop.size.height="Escapçament inferior"
|
||||
|
||||
21
plugins/mac-capture/data/locale/cs-CZ.ini
Normal file
21
plugins/mac-capture/data/locale/cs-CZ.ini
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
CoreAudio.InputCapture="Záznam zvukového vstupu"
|
||||
CoreAudio.OutputCapture="Záznam zvukového výstupu"
|
||||
CoreAudio.Device="Zařízení"
|
||||
CoreAudio.Device.Default="Výchozí"
|
||||
DisplayCapture="Záznam obrazovky"
|
||||
DisplayCapture.Display="Obrazovka"
|
||||
DisplayCapture.ShowCursor="Zobrazit kurzor"
|
||||
WindowCapture="Záznam okna"
|
||||
WindowCapture.ShowShadow="Zobrazit stín okna"
|
||||
WindowUtils.Window="Okno"
|
||||
WindowUtils.ShowEmptyNames="Zobrazit okna s prázdnými názvy"
|
||||
CropMode="Oříznout"
|
||||
CropMode.None="Žádné"
|
||||
CropMode.Manual="Manuální"
|
||||
CropMode.ToWindow="Do okna"
|
||||
CropMode.ToWindowAndManual="Do okna a manuálně"
|
||||
Crop.origin.x="Oříznout vlevo"
|
||||
Crop.origin.y="Oříznout nahoře"
|
||||
Crop.size.width="Oříznout vpravo"
|
||||
Crop.size.height="Oříznout spodek"
|
||||
|
||||
21
plugins/mac-capture/data/locale/da-DK.ini
Normal file
21
plugins/mac-capture/data/locale/da-DK.ini
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
CoreAudio.InputCapture="Indfang Lyd Ind"
|
||||
CoreAudio.OutputCapture="Indfang Lyd Ud"
|
||||
CoreAudio.Device="Enhed"
|
||||
CoreAudio.Device.Default="Standard"
|
||||
DisplayCapture="Indfang Display"
|
||||
DisplayCapture.Display="Display"
|
||||
DisplayCapture.ShowCursor="Vis markøren"
|
||||
WindowCapture="Vindue indfang"
|
||||
WindowCapture.ShowShadow="Vis vinduesskygge"
|
||||
WindowUtils.Window="Vindue"
|
||||
WindowUtils.ShowEmptyNames="Vis vinduer med tomme navne"
|
||||
CropMode="Beskær"
|
||||
CropMode.None="Ingen"
|
||||
CropMode.Manual="Manuelt"
|
||||
CropMode.ToWindow="Til vindue"
|
||||
CropMode.ToWindowAndManual="Til vindue og manuelt"
|
||||
Crop.origin.x="Beskær venstre"
|
||||
Crop.origin.y="Beskær top"
|
||||
Crop.size.width="Beskær højre"
|
||||
Crop.size.height="Beskær bund"
|
||||
|
||||
21
plugins/mac-capture/data/locale/de-DE.ini
Normal file
21
plugins/mac-capture/data/locale/de-DE.ini
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
CoreAudio.InputCapture="Audio Eingabe Aufnahme"
|
||||
CoreAudio.OutputCapture="Audio Ausgabe Aufnahme"
|
||||
CoreAudio.Device="Gerät"
|
||||
CoreAudio.Device.Default="Standard"
|
||||
DisplayCapture="Monitoraufnahme"
|
||||
DisplayCapture.Display="Monitor"
|
||||
DisplayCapture.ShowCursor="Mauszeiger anzeigen"
|
||||
WindowCapture="Fensteraufnahme"
|
||||
WindowCapture.ShowShadow="Zeige Fensterschatten"
|
||||
WindowUtils.Window="Fenster"
|
||||
WindowUtils.ShowEmptyNames="Zeige Fenster mit leeren Namen"
|
||||
CropMode="Zuschneiden"
|
||||
CropMode.None="Keine"
|
||||
CropMode.Manual="Manuell"
|
||||
CropMode.ToWindow="Zum Fenster"
|
||||
CropMode.ToWindowAndManual="Zum Fenster und Manuell"
|
||||
Crop.origin.x="Links abschneiden"
|
||||
Crop.origin.y="Oben abschneiden"
|
||||
Crop.size.width="Rechts abschneiden"
|
||||
Crop.size.height="Unten abschneiden"
|
||||
|
||||
21
plugins/mac-capture/data/locale/el-GR.ini
Normal file
21
plugins/mac-capture/data/locale/el-GR.ini
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
CoreAudio.InputCapture="Σύλληψη Εισόδου Ήχου"
|
||||
CoreAudio.OutputCapture="Σύλληψη Εξόδου Ήχου"
|
||||
CoreAudio.Device="Συσκευή"
|
||||
CoreAudio.Device.Default="Προεπιλογή"
|
||||
DisplayCapture="Σύλληψη Οθόνης"
|
||||
DisplayCapture.Display="Οθόνη"
|
||||
DisplayCapture.ShowCursor="Εμφάνιση Δρομέα"
|
||||
WindowCapture="Σύλληψη Παραθύρου"
|
||||
WindowCapture.ShowShadow="Εμφάνιση Σκιάς Παραθύρου"
|
||||
WindowUtils.Window="Παράθυρο"
|
||||
WindowUtils.ShowEmptyNames="Εμφάνιση παραθύρων με άδεια ονόματα"
|
||||
CropMode="Περικοπή"
|
||||
CropMode.None="Κανένα"
|
||||
CropMode.Manual="Χειροκίνητο"
|
||||
CropMode.ToWindow="Σε παράθυρο"
|
||||
CropMode.ToWindowAndManual="Σε παράθυρο και χειροκίνητα"
|
||||
Crop.origin.x="Περικοπή αριστερά"
|
||||
Crop.origin.y="Περικοπή πάνω"
|
||||
Crop.size.width="Περικοπή δεξιά"
|
||||
Crop.size.height="Περικοπή κάτω"
|
||||
|
||||
20
plugins/mac-capture/data/locale/en-US.ini
Normal file
20
plugins/mac-capture/data/locale/en-US.ini
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
CoreAudio.InputCapture="Audio Input Capture"
|
||||
CoreAudio.OutputCapture="Audio Output Capture"
|
||||
CoreAudio.Device="Device"
|
||||
CoreAudio.Device.Default="Default"
|
||||
DisplayCapture="Display Capture"
|
||||
DisplayCapture.Display="Display"
|
||||
DisplayCapture.ShowCursor="Show Cursor"
|
||||
WindowCapture="Window Capture"
|
||||
WindowCapture.ShowShadow="Show Window shadow"
|
||||
WindowUtils.Window="Window"
|
||||
WindowUtils.ShowEmptyNames="Show Windows with empty names"
|
||||
CropMode="Crop"
|
||||
CropMode.None="None"
|
||||
CropMode.Manual="Manual"
|
||||
CropMode.ToWindow="To Window"
|
||||
CropMode.ToWindowAndManual="To Window and Manual"
|
||||
Crop.origin.x="Crop left"
|
||||
Crop.origin.y="Crop top"
|
||||
Crop.size.width="Crop right"
|
||||
Crop.size.height="Crop bottom"
|
||||
21
plugins/mac-capture/data/locale/es-ES.ini
Normal file
21
plugins/mac-capture/data/locale/es-ES.ini
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
CoreAudio.InputCapture="Captura de entrada audio"
|
||||
CoreAudio.OutputCapture="Captura de salida de audio"
|
||||
CoreAudio.Device="Dispositivo"
|
||||
CoreAudio.Device.Default="Por defecto"
|
||||
DisplayCapture="Captura de pantalla"
|
||||
DisplayCapture.Display="Pantalla"
|
||||
DisplayCapture.ShowCursor="Mostrar cursor"
|
||||
WindowCapture="Captura de ventana"
|
||||
WindowCapture.ShowShadow="Mostrar sombra de ventana"
|
||||
WindowUtils.Window="Ventana"
|
||||
WindowUtils.ShowEmptyNames="Mostrar ventanas con nombres vacíos"
|
||||
CropMode="Recortar"
|
||||
CropMode.None="Ninguno"
|
||||
CropMode.Manual="Manual"
|
||||
CropMode.ToWindow="A ventana"
|
||||
CropMode.ToWindowAndManual="A ventana y manual"
|
||||
Crop.origin.x="Recortar a la izquierda"
|
||||
Crop.origin.y="Recortar arriba"
|
||||
Crop.size.width="Recortar a la derecha"
|
||||
Crop.size.height="Recortar abajo"
|
||||
|
||||
21
plugins/mac-capture/data/locale/eu-ES.ini
Normal file
21
plugins/mac-capture/data/locale/eu-ES.ini
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
CoreAudio.InputCapture="Audio Sarrera Harpena"
|
||||
CoreAudio.OutputCapture="Audio Irteera Harpena"
|
||||
CoreAudio.Device="Gailua"
|
||||
CoreAudio.Device.Default="Berezkoa"
|
||||
DisplayCapture="Erakusleiho Harpena"
|
||||
DisplayCapture.Display="Erakusleihoa"
|
||||
DisplayCapture.ShowCursor="Erakutsi Kurtsorea"
|
||||
WindowCapture="Leiho Harpena"
|
||||
WindowCapture.ShowShadow="Erakutsi Leiho Itzala"
|
||||
WindowUtils.Window="Leihoa"
|
||||
WindowUtils.ShowEmptyNames="Erakutsi izen gabeko Leihoak"
|
||||
CropMode="Moztu"
|
||||
CropMode.None="Ezer ez"
|
||||
CropMode.Manual="Eskuz"
|
||||
CropMode.ToWindow="Leihora"
|
||||
CropMode.ToWindowAndManual="Leihora eta Eskuz"
|
||||
Crop.origin.x="Moztu ezkerra"
|
||||
Crop.origin.y="Moztu goia"
|
||||
Crop.size.width="Moztu eskuina"
|
||||
Crop.size.height="Moztu behea"
|
||||
|
||||
21
plugins/mac-capture/data/locale/fi-FI.ini
Normal file
21
plugins/mac-capture/data/locale/fi-FI.ini
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
CoreAudio.InputCapture="Äänen sisääntulon kaappaus"
|
||||
CoreAudio.OutputCapture="Äänen ulostulon kaappaus"
|
||||
CoreAudio.Device="Laite"
|
||||
CoreAudio.Device.Default="Oletusarvo"
|
||||
DisplayCapture="Ruudunkaappaus"
|
||||
DisplayCapture.Display="Näyttö"
|
||||
DisplayCapture.ShowCursor="Näytä kursori"
|
||||
WindowCapture="Ikkunakaappaus"
|
||||
WindowCapture.ShowShadow="Näytä ikkunan varjo"
|
||||
WindowUtils.Window="Ikkuna"
|
||||
WindowUtils.ShowEmptyNames="Näytä ikkunat joilla on tyhjä nimi"
|
||||
CropMode="Rajaa"
|
||||
CropMode.None="Ei mitään"
|
||||
CropMode.Manual="Manuaalinen"
|
||||
CropMode.ToWindow="Ikkunaan"
|
||||
CropMode.ToWindowAndManual="Ikkunaan ja manuaalinen"
|
||||
Crop.origin.x="Rajaa vasemmalta"
|
||||
Crop.origin.y="Rajaa ylhäältä"
|
||||
Crop.size.width="Rajaa oikealta"
|
||||
Crop.size.height="Rajaa alhaalta"
|
||||
|
||||
21
plugins/mac-capture/data/locale/fr-FR.ini
Normal file
21
plugins/mac-capture/data/locale/fr-FR.ini
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
CoreAudio.InputCapture="Capture d'Audio Entrant"
|
||||
CoreAudio.OutputCapture="Capture d'Audio Sortant"
|
||||
CoreAudio.Device="Appareil"
|
||||
CoreAudio.Device.Default="Par défaut"
|
||||
DisplayCapture="Afficher la Capture"
|
||||
DisplayCapture.Display="Affichage"
|
||||
DisplayCapture.ShowCursor="Afficher le curseur"
|
||||
WindowCapture="Capture de Fenêtre"
|
||||
WindowCapture.ShowShadow="Afficher l'ombre de la fenêtre"
|
||||
WindowUtils.Window="Fenêtre"
|
||||
WindowUtils.ShowEmptyNames="Afficher les fenêtres avec des noms vides"
|
||||
CropMode="Découper"
|
||||
CropMode.None="Aucune"
|
||||
CropMode.Manual="Manuel"
|
||||
CropMode.ToWindow="À la fenêtre"
|
||||
CropMode.ToWindowAndManual="À la fenêtre et manuel"
|
||||
Crop.origin.x="Rogner à gauche"
|
||||
Crop.origin.y="Rogner en haut"
|
||||
Crop.size.width="Rogner à droite"
|
||||
Crop.size.height="Rogner en bas"
|
||||
|
||||
21
plugins/mac-capture/data/locale/gl-ES.ini
Normal file
21
plugins/mac-capture/data/locale/gl-ES.ini
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
CoreAudio.InputCapture="Captura de entrada de audio"
|
||||
CoreAudio.OutputCapture="Captura de saída de audio"
|
||||
CoreAudio.Device="Dispositivo"
|
||||
CoreAudio.Device.Default="Por defecto"
|
||||
DisplayCapture="Captura de pantalla"
|
||||
DisplayCapture.Display="Pantalla"
|
||||
DisplayCapture.ShowCursor="Mostrar o cursor"
|
||||
WindowCapture="Capturar xanela"
|
||||
WindowCapture.ShowShadow="Mostrar sombra da xanela"
|
||||
WindowUtils.Window="Xanela"
|
||||
WindowUtils.ShowEmptyNames="Mostrar xanelas con nomes baleiros"
|
||||
CropMode="Recortar"
|
||||
CropMode.None="Ningún"
|
||||
CropMode.Manual="Manual"
|
||||
CropMode.ToWindow="Á xanela"
|
||||
CropMode.ToWindowAndManual="Á xanela e manual"
|
||||
Crop.origin.x="Recortar á esquerda"
|
||||
Crop.origin.y="Recortar arriba"
|
||||
Crop.size.width="Recortar á dereita"
|
||||
Crop.size.height="Recortar abaixo"
|
||||
|
||||
21
plugins/mac-capture/data/locale/hr-HR.ini
Normal file
21
plugins/mac-capture/data/locale/hr-HR.ini
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
CoreAudio.InputCapture="Ulaz zvuka"
|
||||
CoreAudio.OutputCapture="Izlaz zvuka"
|
||||
CoreAudio.Device="Uređaj"
|
||||
CoreAudio.Device.Default="Podrazumevano"
|
||||
DisplayCapture="Prikaži ulaz"
|
||||
DisplayCapture.Display="Ekran"
|
||||
DisplayCapture.ShowCursor="Prikaži kursor"
|
||||
WindowCapture="Snimanje sa prozora"
|
||||
WindowCapture.ShowShadow="Prikaži senku na prozoru"
|
||||
WindowUtils.Window="Prozor"
|
||||
WindowUtils.ShowEmptyNames="Prikaži i prozore bez imena"
|
||||
CropMode="Odseci"
|
||||
CropMode.None="Nijedno"
|
||||
CropMode.Manual="Ručno"
|
||||
CropMode.ToWindow="Prema prozoru"
|
||||
CropMode.ToWindowAndManual="Prema prozoru i ručno"
|
||||
Crop.origin.x="Odseci s leva"
|
||||
Crop.origin.y="Odseci odozgo"
|
||||
Crop.size.width="Odseci s desna"
|
||||
Crop.size.height="Odseci odozdo"
|
||||
|
||||
21
plugins/mac-capture/data/locale/hu-HU.ini
Normal file
21
plugins/mac-capture/data/locale/hu-HU.ini
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
CoreAudio.InputCapture="Bemeneti Hangrögzítés"
|
||||
CoreAudio.OutputCapture="Kimeneti Hangrögzítés"
|
||||
CoreAudio.Device="Eszköz"
|
||||
CoreAudio.Device.Default="Alapértelmezett"
|
||||
DisplayCapture="Kijelző Felvétel"
|
||||
DisplayCapture.Display="Kijelző"
|
||||
DisplayCapture.ShowCursor="Kurzor Megjelenítése"
|
||||
WindowCapture="Ablak Felvétel"
|
||||
WindowCapture.ShowShadow="Ablak árnyékának megjelenítése"
|
||||
WindowUtils.Window="Ablak"
|
||||
WindowUtils.ShowEmptyNames="Ablakok üres névvel való megjelenítése"
|
||||
CropMode="Vágás"
|
||||
CropMode.None="Egyik sem"
|
||||
CropMode.Manual="Kézikönyv"
|
||||
CropMode.ToWindow="Ablakhoz"
|
||||
CropMode.ToWindowAndManual="Ablakhoz és Kézikönyvhöz"
|
||||
Crop.origin.x="Levágás balra"
|
||||
Crop.origin.y="Levágás fent"
|
||||
Crop.size.width="Levágás jobbra"
|
||||
Crop.size.height="Levágás alul"
|
||||
|
||||
21
plugins/mac-capture/data/locale/it-IT.ini
Normal file
21
plugins/mac-capture/data/locale/it-IT.ini
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
CoreAudio.InputCapture="Cattura l'audio in ingresso"
|
||||
CoreAudio.OutputCapture="Cattura l'audio in uscita"
|
||||
CoreAudio.Device="Dispositivo"
|
||||
CoreAudio.Device.Default="Predefinito"
|
||||
DisplayCapture="Cattura schermo"
|
||||
DisplayCapture.Display="Display"
|
||||
DisplayCapture.ShowCursor="Mostra il cursore"
|
||||
WindowCapture="Cattura finestra"
|
||||
WindowCapture.ShowShadow="Visualizza ombra finestra"
|
||||
WindowUtils.Window="Finestra"
|
||||
WindowUtils.ShowEmptyNames="Visualizza finestre con senza nomi"
|
||||
CropMode="Ritaglia"
|
||||
CropMode.None="Nessuno"
|
||||
CropMode.Manual="Manuale"
|
||||
CropMode.ToWindow="Alla finestra"
|
||||
CropMode.ToWindowAndManual="Alla finestra manualmente"
|
||||
Crop.origin.x="Ritaglia a sinistra"
|
||||
Crop.origin.y="Ritaglia dall'alto"
|
||||
Crop.size.width="Ritaglia a destra"
|
||||
Crop.size.height="Ritaglia dal basso"
|
||||
|
||||
21
plugins/mac-capture/data/locale/ja-JP.ini
Normal file
21
plugins/mac-capture/data/locale/ja-JP.ini
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
CoreAudio.InputCapture="音声入力キャプチャ"
|
||||
CoreAudio.OutputCapture="音声出力キャプチャ"
|
||||
CoreAudio.Device="デバイス"
|
||||
CoreAudio.Device.Default="既定"
|
||||
DisplayCapture="画面キャプチャ"
|
||||
DisplayCapture.Display="ディスプレイ"
|
||||
DisplayCapture.ShowCursor="カーソルを表示"
|
||||
WindowCapture="ウィンドウキャプチャ"
|
||||
WindowCapture.ShowShadow="ウインドウの影を表示"
|
||||
WindowUtils.Window="ウィンドウ"
|
||||
WindowUtils.ShowEmptyNames="空の名前でウィンドウを表示"
|
||||
CropMode="クロップ"
|
||||
CropMode.None="未設定"
|
||||
CropMode.Manual="手動"
|
||||
CropMode.ToWindow="ウィンドウにあわせる"
|
||||
CropMode.ToWindowAndManual="ウインドウに合わせて手動"
|
||||
Crop.origin.x="左をクロップ"
|
||||
Crop.origin.y="上をクロップ"
|
||||
Crop.size.width="右をクロップ"
|
||||
Crop.size.height="下をクロップ"
|
||||
|
||||
21
plugins/mac-capture/data/locale/ko-KR.ini
Normal file
21
plugins/mac-capture/data/locale/ko-KR.ini
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
CoreAudio.InputCapture="오디오 입력 캡쳐"
|
||||
CoreAudio.OutputCapture="오디오 출력 캡쳐"
|
||||
CoreAudio.Device="장치"
|
||||
CoreAudio.Device.Default="기본 장치"
|
||||
DisplayCapture="디스플레이 캡쳐"
|
||||
DisplayCapture.Display="디스플레이"
|
||||
DisplayCapture.ShowCursor="커서 표시"
|
||||
WindowCapture="윈도우 캡쳐"
|
||||
WindowCapture.ShowShadow="윈도우 그림자 표시"
|
||||
WindowUtils.Window="윈도우"
|
||||
WindowUtils.ShowEmptyNames="빈 이름으로 윈도우 표시"
|
||||
CropMode="자르기"
|
||||
CropMode.None="없음"
|
||||
CropMode.Manual="수동"
|
||||
CropMode.ToWindow="윈도우에 맞추기"
|
||||
CropMode.ToWindowAndManual="윈도우에 맞추고 수동"
|
||||
Crop.origin.x="왼쪽 자르기"
|
||||
Crop.origin.y="위쪽 자르기"
|
||||
Crop.size.width="우측 자르기"
|
||||
Crop.size.height="아래 자르기"
|
||||
|
||||
21
plugins/mac-capture/data/locale/nb-NO.ini
Normal file
21
plugins/mac-capture/data/locale/nb-NO.ini
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
CoreAudio.InputCapture="Lydinngangsopptak"
|
||||
CoreAudio.OutputCapture="Lydutgangsopptak"
|
||||
CoreAudio.Device="Enhet"
|
||||
CoreAudio.Device.Default="Standard"
|
||||
DisplayCapture="Skjermopptak"
|
||||
DisplayCapture.Display="Skjerm"
|
||||
DisplayCapture.ShowCursor="Vis musepeker"
|
||||
WindowCapture="Vinduopptak"
|
||||
WindowCapture.ShowShadow="Vis vinduskygge"
|
||||
WindowUtils.Window="Vindu"
|
||||
WindowUtils.ShowEmptyNames="Vis vinduer uten navn"
|
||||
CropMode="Beskjær"
|
||||
CropMode.None="Ingen"
|
||||
CropMode.Manual="Manuelt"
|
||||
CropMode.ToWindow="Etter vindu"
|
||||
CropMode.ToWindowAndManual="Etter vindu og manuelt"
|
||||
Crop.origin.x="Beskjær venstre"
|
||||
Crop.origin.y="Beskjær topp"
|
||||
Crop.size.width="Beskjær høyre"
|
||||
Crop.size.height="Beskjær bunn"
|
||||
|
||||
21
plugins/mac-capture/data/locale/nl-NL.ini
Normal file
21
plugins/mac-capture/data/locale/nl-NL.ini
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
CoreAudio.InputCapture="Audioinvoer Capture"
|
||||
CoreAudio.OutputCapture="Audiouitvoer Capture"
|
||||
CoreAudio.Device="Apparaat"
|
||||
CoreAudio.Device.Default="Standaardinstellingen"
|
||||
DisplayCapture="Beeldschermcapture"
|
||||
DisplayCapture.Display="Beeldscherm"
|
||||
DisplayCapture.ShowCursor="Cursor Weergeven"
|
||||
WindowCapture="Venstercapture"
|
||||
WindowCapture.ShowShadow="Toon vensterschaduw"
|
||||
WindowUtils.Window="Venster"
|
||||
WindowUtils.ShowEmptyNames="Toon vensters met lege namen"
|
||||
CropMode="Bijsnijden"
|
||||
CropMode.None="Geen"
|
||||
CropMode.Manual="Handmatig"
|
||||
CropMode.ToWindow="Naar venster"
|
||||
CropMode.ToWindowAndManual="Naar Venster en Handmatig"
|
||||
Crop.origin.x="Links bijsnijden"
|
||||
Crop.origin.y="Boven bijsnijden"
|
||||
Crop.size.width="Rechts bijsnijden"
|
||||
Crop.size.height="Onder bijsnijden"
|
||||
|
||||
21
plugins/mac-capture/data/locale/pl-PL.ini
Normal file
21
plugins/mac-capture/data/locale/pl-PL.ini
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
CoreAudio.InputCapture="Przechwytywanie wejścia dźwięku"
|
||||
CoreAudio.OutputCapture="Przechwytywanie wyjścia dźwięku"
|
||||
CoreAudio.Device="Urządzenie"
|
||||
CoreAudio.Device.Default="Domyślne"
|
||||
DisplayCapture="Przechwytywanie obrazu"
|
||||
DisplayCapture.Display="Wyświetlacz"
|
||||
DisplayCapture.ShowCursor="Pokaż kursor"
|
||||
WindowCapture="Przechwytywanie okna"
|
||||
WindowCapture.ShowShadow="Pokaż cień okna"
|
||||
WindowUtils.Window="Okno"
|
||||
WindowUtils.ShowEmptyNames="Pokazuj okna z pustą nazwą"
|
||||
CropMode="Przytnij"
|
||||
CropMode.None="Brak"
|
||||
CropMode.Manual="Ręcznie"
|
||||
CropMode.ToWindow="Do okna"
|
||||
CropMode.ToWindowAndManual="Do okna i ręcznie"
|
||||
Crop.origin.x="Przytnij z lewej"
|
||||
Crop.origin.y="Przytnij od góry"
|
||||
Crop.size.width="Przytnij od prawej"
|
||||
Crop.size.height="Przytnij od spodu"
|
||||
|
||||
21
plugins/mac-capture/data/locale/pt-BR.ini
Normal file
21
plugins/mac-capture/data/locale/pt-BR.ini
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
CoreAudio.InputCapture="Captura de Entrada de Áudio"
|
||||
CoreAudio.OutputCapture="Captura de Saída de Áudio"
|
||||
CoreAudio.Device="Dispositivo"
|
||||
CoreAudio.Device.Default="Padrão"
|
||||
DisplayCapture="Captura de Exposição"
|
||||
DisplayCapture.Display="Exposição"
|
||||
DisplayCapture.ShowCursor="Mostrar o Cursor"
|
||||
WindowCapture="Captura de Janela"
|
||||
WindowCapture.ShowShadow="Mostrar sombra da Janela"
|
||||
WindowUtils.Window="Janela"
|
||||
WindowUtils.ShowEmptyNames="Mostrar janelas com nomes vazios"
|
||||
CropMode="Recortar"
|
||||
CropMode.None="Nenhum"
|
||||
CropMode.Manual="Manual"
|
||||
CropMode.ToWindow="à Janela"
|
||||
CropMode.ToWindowAndManual="à Janela e Manual"
|
||||
Crop.origin.x="Recortar à Esquerda"
|
||||
Crop.origin.y="Recortar para Cima"
|
||||
Crop.size.width="Recortar à Direita"
|
||||
Crop.size.height="Recordar para Baixo"
|
||||
|
||||
21
plugins/mac-capture/data/locale/pt-PT.ini
Normal file
21
plugins/mac-capture/data/locale/pt-PT.ini
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
CoreAudio.InputCapture="Captura de entrada de áudio"
|
||||
CoreAudio.OutputCapture="Captura de saída de áudio"
|
||||
CoreAudio.Device="Dispositivo"
|
||||
CoreAudio.Device.Default="Predefinição"
|
||||
DisplayCapture="Captura de Ecrã"
|
||||
DisplayCapture.Display="Ecrã"
|
||||
DisplayCapture.ShowCursor="Mostrar o Cursor"
|
||||
WindowCapture="Captura de janela"
|
||||
WindowCapture.ShowShadow="Mostrar sombra da janela"
|
||||
WindowUtils.Window="Janela"
|
||||
WindowUtils.ShowEmptyNames="Mostrar janelas com nomes vazios"
|
||||
CropMode="Cortar"
|
||||
CropMode.None="Nenhum"
|
||||
CropMode.Manual="Manual"
|
||||
CropMode.ToWindow="Para janela"
|
||||
CropMode.ToWindowAndManual="Para janela e manual"
|
||||
Crop.origin.x="Cortar à esquerda"
|
||||
Crop.origin.y="Cortar em cima"
|
||||
Crop.size.width="Cortar à direita"
|
||||
Crop.size.height="Cortar em baixo"
|
||||
|
||||
21
plugins/mac-capture/data/locale/ro-RO.ini
Normal file
21
plugins/mac-capture/data/locale/ro-RO.ini
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
CoreAudio.InputCapture="Captură de intrare audio"
|
||||
CoreAudio.OutputCapture="Captură de Ieşire Audio"
|
||||
CoreAudio.Device="Dispozitiv"
|
||||
CoreAudio.Device.Default="Prestabilit"
|
||||
DisplayCapture="Captura de ecran"
|
||||
DisplayCapture.Display="Afişare"
|
||||
DisplayCapture.ShowCursor="Arată cursorul"
|
||||
WindowCapture="Captura Fereastră"
|
||||
WindowCapture.ShowShadow="Arată umbra fereastrei"
|
||||
WindowUtils.Window="Fereastră"
|
||||
WindowUtils.ShowEmptyNames="Arată ferestrele cu numele gol"
|
||||
CropMode="Taie (redimensionează prin tăierea imaginii)"
|
||||
CropMode.None="Nici unul"
|
||||
CropMode.Manual="Manual"
|
||||
CropMode.ToWindow="La fereastră"
|
||||
CropMode.ToWindowAndManual="La fereastră și Manual"
|
||||
Crop.origin.x="Taie stânga"
|
||||
Crop.origin.y="Taie sus"
|
||||
Crop.size.width="Taie dreapta"
|
||||
Crop.size.height="Taie jos"
|
||||
|
||||
21
plugins/mac-capture/data/locale/ru-RU.ini
Normal file
21
plugins/mac-capture/data/locale/ru-RU.ini
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
CoreAudio.InputCapture="Захват входного аудиопотока"
|
||||
CoreAudio.OutputCapture="Захват выходного аудиопотока"
|
||||
CoreAudio.Device="Устройство"
|
||||
CoreAudio.Device.Default="По умолчанию"
|
||||
DisplayCapture="Захват экрана"
|
||||
DisplayCapture.Display="Экран"
|
||||
DisplayCapture.ShowCursor="Показывать курсор"
|
||||
WindowCapture="Захват окна"
|
||||
WindowCapture.ShowShadow="Показывать тень окна"
|
||||
WindowUtils.Window="Окно"
|
||||
WindowUtils.ShowEmptyNames="Показывать окна с пустыми названиями"
|
||||
CropMode="Обрезать"
|
||||
CropMode.None="Нет"
|
||||
CropMode.Manual="Вручную"
|
||||
CropMode.ToWindow="По окну"
|
||||
CropMode.ToWindowAndManual="По окну и вручную"
|
||||
Crop.origin.x="Обрезка слева"
|
||||
Crop.origin.y="Обрезка сверху"
|
||||
Crop.size.width="Обрезка справа"
|
||||
Crop.size.height="Обрезка снизу"
|
||||
|
||||
21
plugins/mac-capture/data/locale/sk-SK.ini
Normal file
21
plugins/mac-capture/data/locale/sk-SK.ini
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
CoreAudio.InputCapture="Zachytávanie audio vstupu"
|
||||
CoreAudio.OutputCapture="Zachytávanie audio výstupu"
|
||||
CoreAudio.Device="Zariadenie"
|
||||
CoreAudio.Device.Default="Predvolené"
|
||||
DisplayCapture="Zachytávanie monitora"
|
||||
DisplayCapture.Display="Monitor"
|
||||
DisplayCapture.ShowCursor="Zobraziť kurzor"
|
||||
WindowCapture="Zachytávanie okna"
|
||||
WindowCapture.ShowShadow="Zobraziť tieň okna"
|
||||
WindowUtils.Window="Okno"
|
||||
WindowUtils.ShowEmptyNames="Zobraziť okná bez názvu"
|
||||
CropMode="Orezať"
|
||||
CropMode.None="Žiadny"
|
||||
CropMode.Manual="Manuálne"
|
||||
CropMode.ToWindow="Do okna"
|
||||
CropMode.ToWindowAndManual="Do okna a manuálne"
|
||||
Crop.origin.x="Orezanie vľavo"
|
||||
Crop.origin.y="Orezanie hore"
|
||||
Crop.size.width="Orezanie vpravo"
|
||||
Crop.size.height="Orezanie dole"
|
||||
|
||||
21
plugins/mac-capture/data/locale/sl-SI.ini
Normal file
21
plugins/mac-capture/data/locale/sl-SI.ini
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
CoreAudio.InputCapture="Zajemanje zvoka"
|
||||
CoreAudio.OutputCapture="Izhod zvoka zajemanja"
|
||||
CoreAudio.Device="Naprava"
|
||||
CoreAudio.Device.Default="Privzeto"
|
||||
DisplayCapture="Zajemanje zaslona"
|
||||
DisplayCapture.Display="Zaslon"
|
||||
DisplayCapture.ShowCursor="Prikaži kazalec"
|
||||
WindowCapture="Zajem Okna"
|
||||
WindowCapture.ShowShadow="Prikaži senco okna"
|
||||
WindowUtils.Window="Okno"
|
||||
WindowUtils.ShowEmptyNames="Prikaži okna z praznimi imeni"
|
||||
CropMode="Obreži"
|
||||
CropMode.None="Nič"
|
||||
CropMode.Manual="Ročno"
|
||||
CropMode.ToWindow="K oknu"
|
||||
CropMode.ToWindowAndManual="K oknu in ročno"
|
||||
Crop.origin.x="Obreži levo"
|
||||
Crop.origin.y="Obreži vrh"
|
||||
Crop.size.width="Obreži desno"
|
||||
Crop.size.height="Obreži spodaj"
|
||||
|
||||
21
plugins/mac-capture/data/locale/sr-CS.ini
Normal file
21
plugins/mac-capture/data/locale/sr-CS.ini
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
CoreAudio.InputCapture="Ulaz zvuka"
|
||||
CoreAudio.OutputCapture="Izlaz zvuka"
|
||||
CoreAudio.Device="Uređaj"
|
||||
CoreAudio.Device.Default="Podrazumevano"
|
||||
DisplayCapture="Prikaži ulaz"
|
||||
DisplayCapture.Display="Ekran"
|
||||
DisplayCapture.ShowCursor="Prikaži kursor"
|
||||
WindowCapture="Snimanje sa prozora"
|
||||
WindowCapture.ShowShadow="Prikaži senku na prozoru"
|
||||
WindowUtils.Window="Prozor"
|
||||
WindowUtils.ShowEmptyNames="Prikaži i prozore bez imena"
|
||||
CropMode="Odseci"
|
||||
CropMode.None="Nijedno"
|
||||
CropMode.Manual="Ručno"
|
||||
CropMode.ToWindow="Prema prozoru"
|
||||
CropMode.ToWindowAndManual="Prema prozoru i ručno"
|
||||
Crop.origin.x="Odseci s leva"
|
||||
Crop.origin.y="Odseci odozgo"
|
||||
Crop.size.width="Odseci s desna"
|
||||
Crop.size.height="Odseci odozdo"
|
||||
|
||||
21
plugins/mac-capture/data/locale/sr-SP.ini
Normal file
21
plugins/mac-capture/data/locale/sr-SP.ini
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
CoreAudio.InputCapture="Улаз звука"
|
||||
CoreAudio.OutputCapture="Излаз звука"
|
||||
CoreAudio.Device="Уређај"
|
||||
CoreAudio.Device.Default="Подразумевано"
|
||||
DisplayCapture="Прикажи улаз"
|
||||
DisplayCapture.Display="Екран"
|
||||
DisplayCapture.ShowCursor="Прикажи курсор"
|
||||
WindowCapture="Снимање са прозора"
|
||||
WindowCapture.ShowShadow="Прикажи сенку на прозору"
|
||||
WindowUtils.Window="Прозор"
|
||||
WindowUtils.ShowEmptyNames="Прикажи и прозоре без имена"
|
||||
CropMode="Одсеци"
|
||||
CropMode.None="Ниједно"
|
||||
CropMode.Manual="Ручно"
|
||||
CropMode.ToWindow="Према прозору"
|
||||
CropMode.ToWindowAndManual="Према прозору и ручно"
|
||||
Crop.origin.x="Одсеци с лева"
|
||||
Crop.origin.y="Одсеци одозго"
|
||||
Crop.size.width="Одсеци с десна"
|
||||
Crop.size.height="Одсеци одоздо"
|
||||
|
||||
21
plugins/mac-capture/data/locale/sv-SE.ini
Normal file
21
plugins/mac-capture/data/locale/sv-SE.ini
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
CoreAudio.InputCapture="Ljudinmatningsenhet"
|
||||
CoreAudio.OutputCapture="Ljudppspelningssenhet"
|
||||
CoreAudio.Device="Enhet"
|
||||
CoreAudio.Device.Default="Standard"
|
||||
DisplayCapture="Bildskärmskälla"
|
||||
DisplayCapture.Display="Bildskärm"
|
||||
DisplayCapture.ShowCursor="Visa muspekaren"
|
||||
WindowCapture="Fönsterkälla"
|
||||
WindowCapture.ShowShadow="Visa fönsterskugga"
|
||||
WindowUtils.Window="Fönster"
|
||||
WindowUtils.ShowEmptyNames="Visa fönster utan namn"
|
||||
CropMode="Beskär"
|
||||
CropMode.None="Ingen"
|
||||
CropMode.Manual="Manuellt"
|
||||
CropMode.ToWindow="Till fönster"
|
||||
CropMode.ToWindowAndManual="Till fönster och manuellt"
|
||||
Crop.origin.x="Beskär vänster"
|
||||
Crop.origin.y="Beskär topp"
|
||||
Crop.size.width="Beskär höger"
|
||||
Crop.size.height="Beskär botten"
|
||||
|
||||
4
plugins/mac-capture/data/locale/th-TH.ini
Normal file
4
plugins/mac-capture/data/locale/th-TH.ini
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
CoreAudio.Device="อุปกรณ์"
|
||||
CoreAudio.Device.Default="ค่าเริ่มต้น"
|
||||
CropMode.None="ไม่มี"
|
||||
|
||||
21
plugins/mac-capture/data/locale/tr-TR.ini
Normal file
21
plugins/mac-capture/data/locale/tr-TR.ini
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
CoreAudio.InputCapture="Ses Giriş Yakalayıcısı"
|
||||
CoreAudio.OutputCapture="Ses Çıkış Yakalayıcısı"
|
||||
CoreAudio.Device="Aygıt"
|
||||
CoreAudio.Device.Default="Varsayılan"
|
||||
DisplayCapture="Ekran Yakalama"
|
||||
DisplayCapture.Display="Görüntüleme"
|
||||
DisplayCapture.ShowCursor="İmleci Göster"
|
||||
WindowCapture="Pencere Yakalama"
|
||||
WindowCapture.ShowShadow="Pencere gölgesini göster"
|
||||
WindowUtils.Window="Pencere"
|
||||
WindowUtils.ShowEmptyNames="İsimsiz pencereleri göster"
|
||||
CropMode="Kırp"
|
||||
CropMode.None="Hiçbiri"
|
||||
CropMode.Manual="Elle"
|
||||
CropMode.ToWindow="Pencereye"
|
||||
CropMode.ToWindowAndManual="Pencereye ve Elle"
|
||||
Crop.origin.x="Soldan kırp"
|
||||
Crop.origin.y="Üstten kırp"
|
||||
Crop.size.width="Sağdan kırp"
|
||||
Crop.size.height="Alttan kırp"
|
||||
|
||||
21
plugins/mac-capture/data/locale/zh-CN.ini
Normal file
21
plugins/mac-capture/data/locale/zh-CN.ini
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
CoreAudio.InputCapture="音频输入捕获"
|
||||
CoreAudio.OutputCapture="音频输出捕获"
|
||||
CoreAudio.Device="设备"
|
||||
CoreAudio.Device.Default="默认"
|
||||
DisplayCapture="显示捕获"
|
||||
DisplayCapture.Display="显示"
|
||||
DisplayCapture.ShowCursor="显示光标"
|
||||
WindowCapture="窗口捕获"
|
||||
WindowCapture.ShowShadow="显示窗口阴影"
|
||||
WindowUtils.Window="窗口"
|
||||
WindowUtils.ShowEmptyNames="显示窗口名称为空"
|
||||
CropMode="裁剪"
|
||||
CropMode.None="无"
|
||||
CropMode.Manual="手动"
|
||||
CropMode.ToWindow="到窗口"
|
||||
CropMode.ToWindowAndManual="到窗口和手动"
|
||||
Crop.origin.x="裁剪左侧"
|
||||
Crop.origin.y="裁剪顶部"
|
||||
Crop.size.width="裁剪右侧"
|
||||
Crop.size.height="裁剪底部"
|
||||
|
||||
19
plugins/mac-capture/data/locale/zh-TW.ini
Normal file
19
plugins/mac-capture/data/locale/zh-TW.ini
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
CoreAudio.InputCapture="截取音效輸入"
|
||||
CoreAudio.OutputCapture="截取音效輸出"
|
||||
CoreAudio.Device="裝置"
|
||||
CoreAudio.Device.Default="預設"
|
||||
DisplayCapture="截取螢幕輸出"
|
||||
DisplayCapture.Display="螢幕"
|
||||
DisplayCapture.ShowCursor="顯示游標"
|
||||
WindowCapture="視窗擷取"
|
||||
WindowCapture.ShowShadow="顯示視窗陰影"
|
||||
WindowUtils.Window="視窗"
|
||||
WindowUtils.ShowEmptyNames="顯示無標題視窗"
|
||||
CropMode="裁剪"
|
||||
CropMode.None="無"
|
||||
CropMode.Manual="手動"
|
||||
Crop.origin.x="左邊界"
|
||||
Crop.origin.y="上邊界"
|
||||
Crop.size.width="右邊界"
|
||||
Crop.size.height="下邊界"
|
||||
|
||||
807
plugins/mac-capture/mac-audio.c
Normal file
807
plugins/mac-capture/mac-audio.c
Normal file
|
|
@ -0,0 +1,807 @@
|
|||
#include <AudioUnit/AudioUnit.h>
|
||||
#include <CoreFoundation/CFString.h>
|
||||
#include <CoreAudio/CoreAudio.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <obs-module.h>
|
||||
#include <util/threading.h>
|
||||
#include <util/c99defs.h>
|
||||
|
||||
#include "mac-helpers.h"
|
||||
#include "audio-device-enum.h"
|
||||
|
||||
#define PROPERTY_DEFAULT_DEVICE kAudioHardwarePropertyDefaultInputDevice
|
||||
#define PROPERTY_FORMATS kAudioStreamPropertyAvailablePhysicalFormats
|
||||
|
||||
#define SCOPE_OUTPUT kAudioUnitScope_Output
|
||||
#define SCOPE_INPUT kAudioUnitScope_Input
|
||||
#define SCOPE_GLOBAL kAudioUnitScope_Global
|
||||
|
||||
#define BUS_OUTPUT 0
|
||||
#define BUS_INPUT 1
|
||||
|
||||
#define MAX_DEVICES 20
|
||||
|
||||
#define set_property AudioUnitSetProperty
|
||||
#define get_property AudioUnitGetProperty
|
||||
|
||||
#define TEXT_AUDIO_INPUT obs_module_text("CoreAudio.InputCapture");
|
||||
#define TEXT_AUDIO_OUTPUT obs_module_text("CoreAudio.OutputCapture");
|
||||
#define TEXT_DEVICE obs_module_text("CoreAudio.Device")
|
||||
#define TEXT_DEVICE_DEFAULT obs_module_text("CoreAudio.Device.Default")
|
||||
|
||||
struct coreaudio_data {
|
||||
char *device_name;
|
||||
char *device_uid;
|
||||
AudioUnit unit;
|
||||
AudioDeviceID device_id;
|
||||
AudioBufferList *buf_list;
|
||||
bool au_initialized;
|
||||
bool active;
|
||||
bool default_device;
|
||||
bool input;
|
||||
bool no_devices;
|
||||
|
||||
uint32_t sample_rate;
|
||||
enum audio_format format;
|
||||
enum speaker_layout speakers;
|
||||
|
||||
pthread_t reconnect_thread;
|
||||
os_event_t *exit_event;
|
||||
volatile bool reconnecting;
|
||||
unsigned long retry_time;
|
||||
|
||||
obs_source_t *source;
|
||||
};
|
||||
|
||||
static bool get_default_output_device(struct coreaudio_data *ca)
|
||||
{
|
||||
struct device_list list;
|
||||
|
||||
memset(&list, 0, sizeof(struct device_list));
|
||||
coreaudio_enum_devices(&list, false);
|
||||
|
||||
if (!list.items.num)
|
||||
return false;
|
||||
|
||||
bfree(ca->device_uid);
|
||||
ca->device_uid = bstrdup(list.items.array[0].value.array);
|
||||
|
||||
device_list_free(&list);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool find_device_id_by_uid(struct coreaudio_data *ca)
|
||||
{
|
||||
UInt32 size = sizeof(AudioDeviceID);
|
||||
CFStringRef cf_uid = NULL;
|
||||
CFStringRef qual = NULL;
|
||||
UInt32 qual_size = 0;
|
||||
OSStatus stat;
|
||||
bool success;
|
||||
|
||||
AudioObjectPropertyAddress addr = {
|
||||
.mScope = kAudioObjectPropertyScopeGlobal,
|
||||
.mElement = kAudioObjectPropertyElementMaster
|
||||
};
|
||||
|
||||
if (!ca->device_uid)
|
||||
ca->device_uid = bstrdup("default");
|
||||
|
||||
/* have to do this because mac output devices don't actually exist */
|
||||
if (astrcmpi(ca->device_uid, "default") == 0) {
|
||||
if (ca->input) {
|
||||
ca->default_device = true;
|
||||
} else {
|
||||
if (!get_default_output_device(ca)) {
|
||||
ca->no_devices = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cf_uid = CFStringCreateWithCString(NULL, ca->device_uid,
|
||||
kCFStringEncodingUTF8);
|
||||
|
||||
if (ca->default_device) {
|
||||
addr.mSelector = PROPERTY_DEFAULT_DEVICE;
|
||||
stat = AudioObjectGetPropertyData(kAudioObjectSystemObject,
|
||||
&addr, qual_size, &qual, &size, &ca->device_id);
|
||||
success = (stat == noErr);
|
||||
} else {
|
||||
success = coreaudio_get_device_id(cf_uid, &ca->device_id);
|
||||
}
|
||||
|
||||
if (cf_uid)
|
||||
CFRelease(cf_uid);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
static inline void ca_warn(struct coreaudio_data *ca, const char *func,
|
||||
const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
struct dstr str = {0};
|
||||
|
||||
va_start(args, format);
|
||||
|
||||
dstr_printf(&str, "[%s]:[device '%s'] ", func, ca->device_name);
|
||||
dstr_vcatf(&str, format, args);
|
||||
blog(LOG_WARNING, "%s", str.array);
|
||||
dstr_free(&str);
|
||||
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
static inline bool ca_success(OSStatus stat, struct coreaudio_data *ca,
|
||||
const char *func, const char *action)
|
||||
{
|
||||
if (stat != noErr) {
|
||||
blog(LOG_WARNING, "[%s]:[device '%s'] %s failed: %d",
|
||||
func, ca->device_name, action, (int)stat);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
enum coreaudio_io_type {
|
||||
IO_TYPE_INPUT,
|
||||
IO_TYPE_OUTPUT,
|
||||
};
|
||||
|
||||
static inline bool enable_io(struct coreaudio_data *ca,
|
||||
enum coreaudio_io_type type, bool enable)
|
||||
{
|
||||
UInt32 enable_int = enable;
|
||||
return set_property(ca->unit, kAudioOutputUnitProperty_EnableIO,
|
||||
(type == IO_TYPE_INPUT) ? SCOPE_INPUT : SCOPE_OUTPUT,
|
||||
(type == IO_TYPE_INPUT) ? BUS_INPUT : BUS_OUTPUT,
|
||||
&enable_int, sizeof(enable_int));
|
||||
}
|
||||
|
||||
static inline enum audio_format convert_ca_format(UInt32 format_flags,
|
||||
UInt32 bits)
|
||||
{
|
||||
bool planar = (format_flags & kAudioFormatFlagIsNonInterleaved) != 0;
|
||||
|
||||
if (format_flags & kAudioFormatFlagIsFloat)
|
||||
return planar ? AUDIO_FORMAT_FLOAT_PLANAR : AUDIO_FORMAT_FLOAT;
|
||||
|
||||
if (!(format_flags & kAudioFormatFlagIsSignedInteger) && bits == 8)
|
||||
return planar ? AUDIO_FORMAT_U8BIT_PLANAR : AUDIO_FORMAT_U8BIT;
|
||||
|
||||
/* not float? not signed int? no clue, fail */
|
||||
if ((format_flags & kAudioFormatFlagIsSignedInteger) == 0)
|
||||
return AUDIO_FORMAT_UNKNOWN;
|
||||
|
||||
if (bits == 16)
|
||||
return planar ? AUDIO_FORMAT_16BIT_PLANAR : AUDIO_FORMAT_16BIT;
|
||||
else if (bits == 32)
|
||||
return planar ? AUDIO_FORMAT_32BIT_PLANAR : AUDIO_FORMAT_32BIT;
|
||||
|
||||
return AUDIO_FORMAT_UNKNOWN;
|
||||
}
|
||||
|
||||
static inline enum speaker_layout convert_ca_speaker_layout(UInt32 channels)
|
||||
{
|
||||
/* directly map channel count to enum values */
|
||||
if (channels >= 1 && channels <= 8 && channels != 7)
|
||||
return (enum speaker_layout)channels;
|
||||
|
||||
return SPEAKERS_UNKNOWN;
|
||||
}
|
||||
|
||||
static bool coreaudio_init_format(struct coreaudio_data *ca)
|
||||
{
|
||||
AudioStreamBasicDescription desc;
|
||||
OSStatus stat;
|
||||
UInt32 size = sizeof(desc);
|
||||
|
||||
stat = get_property(ca->unit, kAudioUnitProperty_StreamFormat,
|
||||
SCOPE_INPUT, BUS_INPUT, &desc, &size);
|
||||
if (!ca_success(stat, ca, "coreaudio_init_format", "get input format"))
|
||||
return false;
|
||||
|
||||
/* Certain types of devices have no limit on channel count, and
|
||||
* there's no way to know the actual number of channels it's using,
|
||||
* so if we encounter this situation just force to stereo */
|
||||
if (desc.mChannelsPerFrame > 8) {
|
||||
desc.mChannelsPerFrame = 2;
|
||||
desc.mBytesPerFrame = 2 * desc.mBitsPerChannel / 8;
|
||||
desc.mBytesPerPacket =
|
||||
desc.mFramesPerPacket * desc.mBytesPerFrame;
|
||||
}
|
||||
|
||||
stat = set_property(ca->unit, kAudioUnitProperty_StreamFormat,
|
||||
SCOPE_OUTPUT, BUS_INPUT, &desc, size);
|
||||
if (!ca_success(stat, ca, "coreaudio_init_format", "set output format"))
|
||||
return false;
|
||||
|
||||
if (desc.mFormatID != kAudioFormatLinearPCM) {
|
||||
ca_warn(ca, "coreaudio_init_format", "format is not PCM");
|
||||
return false;
|
||||
}
|
||||
|
||||
ca->format = convert_ca_format(desc.mFormatFlags, desc.mBitsPerChannel);
|
||||
if (ca->format == AUDIO_FORMAT_UNKNOWN) {
|
||||
ca_warn(ca, "coreaudio_init_format", "unknown format flags: "
|
||||
"%u, bits: %u",
|
||||
(unsigned int)desc.mFormatFlags,
|
||||
(unsigned int)desc.mBitsPerChannel);
|
||||
return false;
|
||||
}
|
||||
|
||||
ca->sample_rate = (uint32_t)desc.mSampleRate;
|
||||
ca->speakers = convert_ca_speaker_layout(desc.mChannelsPerFrame);
|
||||
|
||||
if (ca->speakers == SPEAKERS_UNKNOWN) {
|
||||
ca_warn(ca, "coreaudio_init_format", "unknown speaker layout: "
|
||||
"%u channels",
|
||||
(unsigned int)desc.mChannelsPerFrame);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool coreaudio_init_buffer(struct coreaudio_data *ca)
|
||||
{
|
||||
UInt32 buf_size = 0;
|
||||
UInt32 size = 0;
|
||||
UInt32 frames = 0;
|
||||
OSStatus stat;
|
||||
|
||||
AudioObjectPropertyAddress addr = {
|
||||
kAudioDevicePropertyStreamConfiguration,
|
||||
kAudioDevicePropertyScopeInput,
|
||||
kAudioObjectPropertyElementMaster
|
||||
};
|
||||
|
||||
stat = AudioObjectGetPropertyDataSize(ca->device_id, &addr, 0, NULL,
|
||||
&buf_size);
|
||||
if (!ca_success(stat, ca, "coreaudio_init_buffer", "get list size"))
|
||||
return false;
|
||||
|
||||
size = sizeof(frames);
|
||||
stat = get_property(ca->unit, kAudioDevicePropertyBufferFrameSize,
|
||||
SCOPE_GLOBAL, 0, &frames, &size);
|
||||
if (!ca_success(stat, ca, "coreaudio_init_buffer", "get frame size"))
|
||||
return false;
|
||||
|
||||
/* ---------------------- */
|
||||
|
||||
ca->buf_list = bmalloc(buf_size);
|
||||
|
||||
stat = AudioObjectGetPropertyData(ca->device_id, &addr, 0, NULL,
|
||||
&buf_size, ca->buf_list);
|
||||
if (!ca_success(stat, ca, "coreaudio_init_buffer", "allocate")) {
|
||||
bfree(ca->buf_list);
|
||||
ca->buf_list = NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
for (UInt32 i = 0; i < ca->buf_list->mNumberBuffers; i++) {
|
||||
size = ca->buf_list->mBuffers[i].mDataByteSize;
|
||||
ca->buf_list->mBuffers[i].mData = bmalloc(size);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void buf_list_free(AudioBufferList *buf_list)
|
||||
{
|
||||
if (buf_list) {
|
||||
for (UInt32 i = 0; i < buf_list->mNumberBuffers; i++)
|
||||
bfree(buf_list->mBuffers[i].mData);
|
||||
|
||||
bfree(buf_list);
|
||||
}
|
||||
}
|
||||
|
||||
static OSStatus input_callback(
|
||||
void *data,
|
||||
AudioUnitRenderActionFlags *action_flags,
|
||||
const AudioTimeStamp *ts_data,
|
||||
UInt32 bus_num,
|
||||
UInt32 frames,
|
||||
AudioBufferList *ignored_buffers)
|
||||
{
|
||||
struct coreaudio_data *ca = data;
|
||||
OSStatus stat;
|
||||
struct obs_source_audio audio;
|
||||
|
||||
stat = AudioUnitRender(ca->unit, action_flags, ts_data, bus_num, frames,
|
||||
ca->buf_list);
|
||||
if (!ca_success(stat, ca, "input_callback", "audio retrieval"))
|
||||
return noErr;
|
||||
|
||||
for (UInt32 i = 0; i < ca->buf_list->mNumberBuffers; i++)
|
||||
audio.data[i] = ca->buf_list->mBuffers[i].mData;
|
||||
|
||||
audio.frames = frames;
|
||||
audio.speakers = ca->speakers;
|
||||
audio.format = ca->format;
|
||||
audio.samples_per_sec = ca->sample_rate;
|
||||
audio.timestamp = ts_data->mHostTime;
|
||||
|
||||
obs_source_output_audio(ca->source, &audio);
|
||||
|
||||
UNUSED_PARAMETER(ignored_buffers);
|
||||
return noErr;
|
||||
}
|
||||
|
||||
static void coreaudio_stop(struct coreaudio_data *ca);
|
||||
static bool coreaudio_init(struct coreaudio_data *ca);
|
||||
static void coreaudio_uninit(struct coreaudio_data *ca);
|
||||
|
||||
static void *reconnect_thread(void *param)
|
||||
{
|
||||
struct coreaudio_data *ca = param;
|
||||
|
||||
ca->reconnecting = true;
|
||||
|
||||
while (os_event_timedwait(ca->exit_event, ca->retry_time) == ETIMEDOUT) {
|
||||
if (coreaudio_init(ca))
|
||||
break;
|
||||
}
|
||||
|
||||
blog(LOG_DEBUG, "coreaudio: exit the reconnect thread");
|
||||
ca->reconnecting = false;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void coreaudio_begin_reconnect(struct coreaudio_data *ca)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (ca->reconnecting)
|
||||
return;
|
||||
|
||||
ret = pthread_create(&ca->reconnect_thread, NULL, reconnect_thread, ca);
|
||||
if (ret != 0)
|
||||
blog(LOG_WARNING, "[coreaudio_begin_reconnect] failed to "
|
||||
"create thread, error code: %d", ret);
|
||||
}
|
||||
|
||||
static OSStatus notification_callback(
|
||||
AudioObjectID id,
|
||||
UInt32 num_addresses,
|
||||
const AudioObjectPropertyAddress addresses[],
|
||||
void *data)
|
||||
{
|
||||
struct coreaudio_data *ca = data;
|
||||
|
||||
coreaudio_stop(ca);
|
||||
coreaudio_uninit(ca);
|
||||
|
||||
if (addresses[0].mSelector == PROPERTY_DEFAULT_DEVICE)
|
||||
ca->retry_time = 300;
|
||||
else
|
||||
ca->retry_time = 2000;
|
||||
|
||||
blog(LOG_INFO, "coreaudio: device '%s' disconnected or changed. "
|
||||
"attempting to reconnect", ca->device_name);
|
||||
|
||||
coreaudio_begin_reconnect(ca);
|
||||
|
||||
UNUSED_PARAMETER(id);
|
||||
UNUSED_PARAMETER(num_addresses);
|
||||
|
||||
return noErr;
|
||||
}
|
||||
|
||||
static OSStatus add_listener(struct coreaudio_data *ca, UInt32 property)
|
||||
{
|
||||
AudioObjectPropertyAddress addr = {
|
||||
property,
|
||||
kAudioObjectPropertyScopeGlobal,
|
||||
kAudioObjectPropertyElementMaster
|
||||
};
|
||||
|
||||
return AudioObjectAddPropertyListener(ca->device_id, &addr,
|
||||
notification_callback, ca);
|
||||
}
|
||||
|
||||
static bool coreaudio_init_hooks(struct coreaudio_data *ca)
|
||||
{
|
||||
OSStatus stat;
|
||||
AURenderCallbackStruct callback_info = {
|
||||
.inputProc = input_callback,
|
||||
.inputProcRefCon = ca
|
||||
};
|
||||
|
||||
stat = add_listener(ca, kAudioDevicePropertyDeviceIsAlive);
|
||||
if (!ca_success(stat, ca, "coreaudio_init_hooks",
|
||||
"set disconnect callback"))
|
||||
return false;
|
||||
|
||||
stat = add_listener(ca, PROPERTY_FORMATS);
|
||||
if (!ca_success(stat, ca, "coreaudio_init_hooks",
|
||||
"set format change callback"))
|
||||
return false;
|
||||
|
||||
if (ca->default_device) {
|
||||
AudioObjectPropertyAddress addr = {
|
||||
PROPERTY_DEFAULT_DEVICE,
|
||||
kAudioObjectPropertyScopeGlobal,
|
||||
kAudioObjectPropertyElementMaster
|
||||
};
|
||||
|
||||
stat = AudioObjectAddPropertyListener(kAudioObjectSystemObject,
|
||||
&addr, notification_callback, ca);
|
||||
if (!ca_success(stat, ca, "coreaudio_init_hooks",
|
||||
"set device change callback"))
|
||||
return false;
|
||||
}
|
||||
|
||||
stat = set_property(ca->unit, kAudioOutputUnitProperty_SetInputCallback,
|
||||
SCOPE_GLOBAL, 0, &callback_info, sizeof(callback_info));
|
||||
if (!ca_success(stat, ca, "coreaudio_init_hooks", "set input callback"))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void coreaudio_remove_hooks(struct coreaudio_data *ca)
|
||||
{
|
||||
AURenderCallbackStruct callback_info = {
|
||||
.inputProc = NULL,
|
||||
.inputProcRefCon = NULL
|
||||
};
|
||||
|
||||
AudioObjectPropertyAddress addr = {
|
||||
kAudioDevicePropertyDeviceIsAlive,
|
||||
kAudioObjectPropertyScopeGlobal,
|
||||
kAudioObjectPropertyElementMaster
|
||||
};
|
||||
|
||||
AudioObjectRemovePropertyListener(ca->device_id, &addr,
|
||||
notification_callback, ca);
|
||||
|
||||
addr.mSelector = PROPERTY_FORMATS;
|
||||
AudioObjectRemovePropertyListener(ca->device_id, &addr,
|
||||
notification_callback, ca);
|
||||
|
||||
if (ca->default_device) {
|
||||
addr.mSelector = PROPERTY_DEFAULT_DEVICE;
|
||||
AudioObjectRemovePropertyListener(kAudioObjectSystemObject,
|
||||
&addr, notification_callback, ca);
|
||||
}
|
||||
|
||||
set_property(ca->unit, kAudioOutputUnitProperty_SetInputCallback,
|
||||
SCOPE_GLOBAL, 0, &callback_info, sizeof(callback_info));
|
||||
}
|
||||
|
||||
static bool coreaudio_get_device_name(struct coreaudio_data *ca)
|
||||
{
|
||||
CFStringRef cf_name = NULL;
|
||||
UInt32 size = sizeof(CFStringRef);
|
||||
char name[1024];
|
||||
|
||||
const AudioObjectPropertyAddress addr = {
|
||||
kAudioDevicePropertyDeviceNameCFString,
|
||||
kAudioObjectPropertyScopeInput,
|
||||
kAudioObjectPropertyElementMaster
|
||||
};
|
||||
|
||||
OSStatus stat = AudioObjectGetPropertyData(ca->device_id, &addr,
|
||||
0, NULL, &size, &cf_name);
|
||||
if (stat != noErr) {
|
||||
blog(LOG_WARNING, "[coreaudio_get_device_name] failed to "
|
||||
"get name: %d", (int)stat);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!cf_to_cstr(cf_name, name, 1024)) {
|
||||
blog(LOG_WARNING, "[coreaudio_get_device_name] failed to "
|
||||
"convert name to cstr for some reason");
|
||||
return false;
|
||||
}
|
||||
|
||||
bfree(ca->device_name);
|
||||
ca->device_name = bstrdup(name);
|
||||
|
||||
if (cf_name)
|
||||
CFRelease(cf_name);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool coreaudio_start(struct coreaudio_data *ca)
|
||||
{
|
||||
OSStatus stat;
|
||||
|
||||
if (ca->active)
|
||||
return true;
|
||||
|
||||
stat = AudioOutputUnitStart(ca->unit);
|
||||
return ca_success(stat, ca, "coreaudio_start", "start audio");
|
||||
}
|
||||
|
||||
static void coreaudio_stop(struct coreaudio_data *ca)
|
||||
{
|
||||
OSStatus stat;
|
||||
|
||||
if (!ca->active)
|
||||
return;
|
||||
|
||||
ca->active = false;
|
||||
|
||||
stat = AudioOutputUnitStop(ca->unit);
|
||||
ca_success(stat, ca, "coreaudio_stop", "stop audio");
|
||||
}
|
||||
|
||||
static bool coreaudio_init_unit(struct coreaudio_data *ca)
|
||||
{
|
||||
AudioComponentDescription desc = {
|
||||
.componentType = kAudioUnitType_Output,
|
||||
.componentSubType = kAudioUnitSubType_HALOutput
|
||||
};
|
||||
|
||||
AudioComponent component = AudioComponentFindNext(NULL, &desc);
|
||||
if (!component) {
|
||||
ca_warn(ca, "coreaudio_init_unit", "find component failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
OSStatus stat = AudioComponentInstanceNew(component, &ca->unit);
|
||||
if (!ca_success(stat, ca, "coreaudio_init_unit", "instance unit"))
|
||||
return false;
|
||||
|
||||
ca->au_initialized = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool coreaudio_init(struct coreaudio_data *ca)
|
||||
{
|
||||
OSStatus stat;
|
||||
|
||||
if (ca->au_initialized)
|
||||
return true;
|
||||
|
||||
if (!find_device_id_by_uid(ca))
|
||||
return false;
|
||||
if (!coreaudio_get_device_name(ca))
|
||||
return false;
|
||||
if (!coreaudio_init_unit(ca))
|
||||
return false;
|
||||
|
||||
stat = enable_io(ca, IO_TYPE_INPUT, true);
|
||||
if (!ca_success(stat, ca, "coreaudio_init", "enable input io"))
|
||||
goto fail;
|
||||
|
||||
stat = enable_io(ca, IO_TYPE_OUTPUT, false);
|
||||
if (!ca_success(stat, ca, "coreaudio_init", "disable output io"))
|
||||
goto fail;
|
||||
|
||||
stat = set_property(ca->unit, kAudioOutputUnitProperty_CurrentDevice,
|
||||
SCOPE_GLOBAL, 0, &ca->device_id, sizeof(ca->device_id));
|
||||
if (!ca_success(stat, ca, "coreaudio_init", "set current device"))
|
||||
goto fail;
|
||||
|
||||
if (!coreaudio_init_format(ca))
|
||||
goto fail;
|
||||
if (!coreaudio_init_buffer(ca))
|
||||
goto fail;
|
||||
if (!coreaudio_init_hooks(ca))
|
||||
goto fail;
|
||||
|
||||
stat = AudioUnitInitialize(ca->unit);
|
||||
if (!ca_success(stat, ca, "coreaudio_initialize", "initialize"))
|
||||
goto fail;
|
||||
|
||||
if (!coreaudio_start(ca))
|
||||
goto fail;
|
||||
|
||||
blog(LOG_INFO, "coreaudio: device '%s' initialized", ca->device_name);
|
||||
return ca->au_initialized;
|
||||
|
||||
fail:
|
||||
coreaudio_uninit(ca);
|
||||
return false;
|
||||
}
|
||||
|
||||
static void coreaudio_try_init(struct coreaudio_data *ca)
|
||||
{
|
||||
if (!coreaudio_init(ca)) {
|
||||
blog(LOG_INFO, "coreaudio: failed to find device "
|
||||
"uid: %s, waiting for connection",
|
||||
ca->device_uid);
|
||||
|
||||
ca->retry_time = 2000;
|
||||
|
||||
if (ca->no_devices)
|
||||
blog(LOG_INFO, "coreaudio: no device found");
|
||||
else
|
||||
coreaudio_begin_reconnect(ca);
|
||||
}
|
||||
}
|
||||
|
||||
static void coreaudio_uninit(struct coreaudio_data *ca)
|
||||
{
|
||||
if (!ca->au_initialized)
|
||||
return;
|
||||
|
||||
if (ca->unit) {
|
||||
coreaudio_stop(ca);
|
||||
|
||||
OSStatus stat = AudioUnitUninitialize(ca->unit);
|
||||
ca_success(stat, ca, "coreaudio_uninit", "uninitialize");
|
||||
|
||||
coreaudio_remove_hooks(ca);
|
||||
|
||||
stat = AudioComponentInstanceDispose(ca->unit);
|
||||
ca_success(stat, ca, "coreaudio_uninit", "dispose");
|
||||
|
||||
ca->unit = NULL;
|
||||
}
|
||||
|
||||
ca->au_initialized = false;
|
||||
|
||||
buf_list_free(ca->buf_list);
|
||||
ca->buf_list = NULL;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
static const char *coreaudio_input_getname(void *unused)
|
||||
{
|
||||
UNUSED_PARAMETER(unused);
|
||||
return TEXT_AUDIO_INPUT;
|
||||
}
|
||||
|
||||
static const char *coreaudio_output_getname(void *unused)
|
||||
{
|
||||
UNUSED_PARAMETER(unused);
|
||||
return TEXT_AUDIO_OUTPUT;
|
||||
}
|
||||
|
||||
static void coreaudio_shutdown(struct coreaudio_data *ca)
|
||||
{
|
||||
if (ca->reconnecting) {
|
||||
os_event_signal(ca->exit_event);
|
||||
pthread_join(ca->reconnect_thread, NULL);
|
||||
os_event_reset(ca->exit_event);
|
||||
}
|
||||
|
||||
coreaudio_uninit(ca);
|
||||
|
||||
if (ca->unit)
|
||||
AudioComponentInstanceDispose(ca->unit);
|
||||
}
|
||||
|
||||
static void coreaudio_destroy(void *data)
|
||||
{
|
||||
struct coreaudio_data *ca = data;
|
||||
|
||||
if (ca) {
|
||||
coreaudio_shutdown(ca);
|
||||
|
||||
os_event_destroy(ca->exit_event);
|
||||
bfree(ca->device_name);
|
||||
bfree(ca->device_uid);
|
||||
bfree(ca);
|
||||
}
|
||||
}
|
||||
|
||||
static void coreaudio_update(void *data, obs_data_t *settings)
|
||||
{
|
||||
struct coreaudio_data *ca = data;
|
||||
|
||||
coreaudio_shutdown(ca);
|
||||
|
||||
bfree(ca->device_uid);
|
||||
ca->device_uid = bstrdup(obs_data_get_string(settings, "device_id"));
|
||||
|
||||
coreaudio_try_init(ca);
|
||||
}
|
||||
|
||||
static void coreaudio_defaults(obs_data_t *settings)
|
||||
{
|
||||
obs_data_set_default_string(settings, "device_id", "default");
|
||||
}
|
||||
|
||||
static void *coreaudio_create(obs_data_t *settings, obs_source_t *source,
|
||||
bool input)
|
||||
{
|
||||
struct coreaudio_data *ca = bzalloc(sizeof(struct coreaudio_data));
|
||||
|
||||
if (os_event_init(&ca->exit_event, OS_EVENT_TYPE_MANUAL) != 0) {
|
||||
blog(LOG_ERROR, "[coreaudio_create] failed to create "
|
||||
"semephore: %d", errno);
|
||||
bfree(ca);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ca->device_uid = bstrdup(obs_data_get_string(settings, "device_id"));
|
||||
ca->source = source;
|
||||
ca->input = input;
|
||||
|
||||
if (!ca->device_uid)
|
||||
ca->device_uid = bstrdup("default");
|
||||
|
||||
coreaudio_try_init(ca);
|
||||
return ca;
|
||||
}
|
||||
|
||||
static void *coreaudio_create_input_capture(obs_data_t *settings,
|
||||
obs_source_t *source)
|
||||
{
|
||||
return coreaudio_create(settings, source, true);
|
||||
}
|
||||
|
||||
static void *coreaudio_create_output_capture(obs_data_t *settings,
|
||||
obs_source_t *source)
|
||||
{
|
||||
return coreaudio_create(settings, source, false);
|
||||
}
|
||||
|
||||
static obs_properties_t *coreaudio_properties(bool input)
|
||||
{
|
||||
obs_properties_t *props = obs_properties_create();
|
||||
obs_property_t *property;
|
||||
struct device_list devices;
|
||||
|
||||
memset(&devices, 0, sizeof(struct device_list));
|
||||
|
||||
property = obs_properties_add_list(props, "device_id", TEXT_DEVICE,
|
||||
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING);
|
||||
|
||||
coreaudio_enum_devices(&devices, input);
|
||||
|
||||
if (devices.items.num)
|
||||
obs_property_list_add_string(property, TEXT_DEVICE_DEFAULT,
|
||||
"default");
|
||||
|
||||
for (size_t i = 0; i < devices.items.num; i++) {
|
||||
struct device_item *item = devices.items.array+i;
|
||||
obs_property_list_add_string(property,
|
||||
item->name.array, item->value.array);
|
||||
}
|
||||
|
||||
device_list_free(&devices);
|
||||
return props;
|
||||
}
|
||||
|
||||
static obs_properties_t *coreaudio_input_properties(void *unused)
|
||||
{
|
||||
UNUSED_PARAMETER(unused);
|
||||
|
||||
return coreaudio_properties(true);
|
||||
}
|
||||
|
||||
static obs_properties_t *coreaudio_output_properties(void *unused)
|
||||
{
|
||||
UNUSED_PARAMETER(unused);
|
||||
|
||||
return coreaudio_properties(false);
|
||||
}
|
||||
|
||||
struct obs_source_info coreaudio_input_capture_info = {
|
||||
.id = "coreaudio_input_capture",
|
||||
.type = OBS_SOURCE_TYPE_INPUT,
|
||||
.output_flags = OBS_SOURCE_AUDIO |
|
||||
OBS_SOURCE_DO_NOT_DUPLICATE,
|
||||
.get_name = coreaudio_input_getname,
|
||||
.create = coreaudio_create_input_capture,
|
||||
.destroy = coreaudio_destroy,
|
||||
.update = coreaudio_update,
|
||||
.get_defaults = coreaudio_defaults,
|
||||
.get_properties = coreaudio_input_properties
|
||||
};
|
||||
|
||||
struct obs_source_info coreaudio_output_capture_info = {
|
||||
.id = "coreaudio_output_capture",
|
||||
.type = OBS_SOURCE_TYPE_INPUT,
|
||||
.output_flags = OBS_SOURCE_AUDIO |
|
||||
OBS_SOURCE_DO_NOT_DUPLICATE,
|
||||
.get_name = coreaudio_output_getname,
|
||||
.create = coreaudio_create_output_capture,
|
||||
.destroy = coreaudio_destroy,
|
||||
.update = coreaudio_update,
|
||||
.get_defaults = coreaudio_defaults,
|
||||
.get_properties = coreaudio_output_properties
|
||||
};
|
||||
671
plugins/mac-capture/mac-display-capture.m
Normal file
671
plugins/mac-capture/mac-display-capture.m
Normal file
|
|
@ -0,0 +1,671 @@
|
|||
#include <stdlib.h>
|
||||
#include <obs-module.h>
|
||||
#include <util/threading.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#import <CoreGraphics/CGDisplayStream.h>
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#include "window-utils.h"
|
||||
|
||||
enum crop_mode {
|
||||
CROP_NONE,
|
||||
CROP_MANUAL,
|
||||
CROP_TO_WINDOW,
|
||||
CROP_TO_WINDOW_AND_MANUAL,
|
||||
CROP_INVALID
|
||||
};
|
||||
|
||||
static inline bool requires_window(enum crop_mode mode)
|
||||
{
|
||||
return mode == CROP_TO_WINDOW || mode == CROP_TO_WINDOW_AND_MANUAL;
|
||||
}
|
||||
|
||||
struct display_capture {
|
||||
obs_source_t *source;
|
||||
|
||||
gs_samplerstate_t *sampler;
|
||||
gs_effect_t *effect;
|
||||
gs_texture_t *tex;
|
||||
gs_vertbuffer_t *vertbuf;
|
||||
|
||||
NSScreen *screen;
|
||||
unsigned display;
|
||||
NSRect frame;
|
||||
bool hide_cursor;
|
||||
|
||||
enum crop_mode crop;
|
||||
CGRect crop_rect;
|
||||
|
||||
struct cocoa_window window;
|
||||
CGRect window_rect;
|
||||
bool on_screen;
|
||||
bool hide_when_minimized;
|
||||
|
||||
os_event_t *disp_finished;
|
||||
CGDisplayStreamRef disp;
|
||||
IOSurfaceRef current, prev;
|
||||
|
||||
pthread_mutex_t mutex;
|
||||
};
|
||||
|
||||
static inline bool crop_mode_valid(enum crop_mode mode)
|
||||
{
|
||||
return CROP_NONE <= mode && mode < CROP_INVALID;
|
||||
}
|
||||
|
||||
static void destroy_display_stream(struct display_capture *dc)
|
||||
{
|
||||
if (dc->disp) {
|
||||
CGDisplayStreamStop(dc->disp);
|
||||
os_event_wait(dc->disp_finished);
|
||||
}
|
||||
|
||||
if (dc->tex) {
|
||||
gs_texture_destroy(dc->tex);
|
||||
dc->tex = NULL;
|
||||
}
|
||||
|
||||
if (dc->current) {
|
||||
IOSurfaceDecrementUseCount(dc->current);
|
||||
CFRelease(dc->current);
|
||||
dc->current = NULL;
|
||||
}
|
||||
|
||||
if (dc->prev) {
|
||||
IOSurfaceDecrementUseCount(dc->prev);
|
||||
CFRelease(dc->prev);
|
||||
dc->prev = NULL;
|
||||
}
|
||||
|
||||
if (dc->disp) {
|
||||
CFRelease(dc->disp);
|
||||
dc->disp = NULL;
|
||||
}
|
||||
|
||||
if (dc->screen) {
|
||||
[dc->screen release];
|
||||
dc->screen = nil;
|
||||
}
|
||||
|
||||
os_event_destroy(dc->disp_finished);
|
||||
}
|
||||
|
||||
static void display_capture_destroy(void *data)
|
||||
{
|
||||
struct display_capture *dc = data;
|
||||
|
||||
if (!dc)
|
||||
return;
|
||||
|
||||
obs_enter_graphics();
|
||||
|
||||
destroy_display_stream(dc);
|
||||
|
||||
if (dc->sampler)
|
||||
gs_samplerstate_destroy(dc->sampler);
|
||||
if (dc->vertbuf)
|
||||
gs_vertexbuffer_destroy(dc->vertbuf);
|
||||
|
||||
obs_leave_graphics();
|
||||
|
||||
destroy_window(&dc->window);
|
||||
|
||||
pthread_mutex_destroy(&dc->mutex);
|
||||
bfree(dc);
|
||||
}
|
||||
|
||||
static inline void update_window_params(struct display_capture *dc)
|
||||
{
|
||||
if (!requires_window(dc->crop))
|
||||
return;
|
||||
|
||||
NSArray *arr = (NSArray*)CGWindowListCopyWindowInfo(
|
||||
kCGWindowListOptionIncludingWindow,
|
||||
dc->window.window_id);
|
||||
|
||||
if (arr.count) {
|
||||
NSDictionary *dict = arr[0];
|
||||
NSDictionary *ref = dict[(NSString*)kCGWindowBounds];
|
||||
CGRectMakeWithDictionaryRepresentation((CFDictionaryRef)ref,
|
||||
&dc->window_rect);
|
||||
dc->on_screen = dict[(NSString*)kCGWindowIsOnscreen] != nil;
|
||||
dc->window_rect =
|
||||
[dc->screen convertRectToBacking:dc->window_rect];
|
||||
|
||||
} else {
|
||||
if (find_window(&dc->window, NULL, false))
|
||||
update_window_params(dc);
|
||||
else
|
||||
dc->on_screen = false;
|
||||
}
|
||||
|
||||
[arr release];
|
||||
}
|
||||
|
||||
static inline void display_stream_update(struct display_capture *dc,
|
||||
CGDisplayStreamFrameStatus status, uint64_t display_time,
|
||||
IOSurfaceRef frame_surface, CGDisplayStreamUpdateRef update_ref)
|
||||
{
|
||||
UNUSED_PARAMETER(display_time);
|
||||
UNUSED_PARAMETER(update_ref);
|
||||
|
||||
if (status == kCGDisplayStreamFrameStatusStopped) {
|
||||
os_event_signal(dc->disp_finished);
|
||||
return;
|
||||
}
|
||||
|
||||
IOSurfaceRef prev_current = NULL;
|
||||
|
||||
if (frame_surface && !pthread_mutex_lock(&dc->mutex)) {
|
||||
prev_current = dc->current;
|
||||
dc->current = frame_surface;
|
||||
CFRetain(dc->current);
|
||||
IOSurfaceIncrementUseCount(dc->current);
|
||||
|
||||
update_window_params(dc);
|
||||
|
||||
pthread_mutex_unlock(&dc->mutex);
|
||||
}
|
||||
|
||||
if (prev_current) {
|
||||
IOSurfaceDecrementUseCount(prev_current);
|
||||
CFRelease(prev_current);
|
||||
}
|
||||
|
||||
size_t dropped_frames = CGDisplayStreamUpdateGetDropCount(update_ref);
|
||||
if (dropped_frames > 0)
|
||||
blog(LOG_INFO, "%s: Dropped %zu frames",
|
||||
obs_source_get_name(dc->source),
|
||||
dropped_frames);
|
||||
}
|
||||
|
||||
static bool init_display_stream(struct display_capture *dc)
|
||||
{
|
||||
if (dc->display >= [NSScreen screens].count)
|
||||
return false;
|
||||
|
||||
dc->screen = [[NSScreen screens][dc->display] retain];
|
||||
|
||||
dc->frame = [dc->screen convertRectToBacking:dc->screen.frame];
|
||||
|
||||
NSNumber *screen_num = dc->screen.deviceDescription[@"NSScreenNumber"];
|
||||
CGDirectDisplayID disp_id = (CGDirectDisplayID)screen_num.pointerValue;
|
||||
|
||||
NSDictionary *rect_dict = CFBridgingRelease(
|
||||
CGRectCreateDictionaryRepresentation(
|
||||
CGRectMake(0, 0,
|
||||
dc->screen.frame.size.width,
|
||||
dc->screen.frame.size.height)));
|
||||
|
||||
CFBooleanRef show_cursor_cf =
|
||||
dc->hide_cursor ? kCFBooleanFalse : kCFBooleanTrue;
|
||||
|
||||
NSDictionary *dict = @{
|
||||
(__bridge NSString*)kCGDisplayStreamSourceRect: rect_dict,
|
||||
(__bridge NSString*)kCGDisplayStreamQueueDepth: @5,
|
||||
(__bridge NSString*)kCGDisplayStreamShowCursor:
|
||||
(id)show_cursor_cf,
|
||||
};
|
||||
|
||||
os_event_init(&dc->disp_finished, OS_EVENT_TYPE_MANUAL);
|
||||
|
||||
const CGSize *size = &dc->frame.size;
|
||||
dc->disp = CGDisplayStreamCreateWithDispatchQueue(disp_id,
|
||||
size->width, size->height, 'BGRA',
|
||||
(__bridge CFDictionaryRef)dict,
|
||||
dispatch_queue_create(NULL, NULL),
|
||||
^(CGDisplayStreamFrameStatus status,
|
||||
uint64_t displayTime,
|
||||
IOSurfaceRef frameSurface,
|
||||
CGDisplayStreamUpdateRef updateRef)
|
||||
{
|
||||
display_stream_update(dc, status, displayTime,
|
||||
frameSurface, updateRef);
|
||||
}
|
||||
);
|
||||
|
||||
return !CGDisplayStreamStart(dc->disp);
|
||||
}
|
||||
|
||||
bool init_vertbuf(struct display_capture *dc)
|
||||
{
|
||||
struct gs_vb_data *vb_data = gs_vbdata_create();
|
||||
vb_data->num = 4;
|
||||
vb_data->points = bzalloc(sizeof(struct vec3) * 4);
|
||||
if (!vb_data->points)
|
||||
return false;
|
||||
|
||||
vb_data->num_tex = 1;
|
||||
vb_data->tvarray = bzalloc(sizeof(struct gs_tvertarray));
|
||||
if (!vb_data->tvarray)
|
||||
return false;
|
||||
|
||||
vb_data->tvarray[0].width = 2;
|
||||
vb_data->tvarray[0].array = bzalloc(sizeof(struct vec2) * 4);
|
||||
if (!vb_data->tvarray[0].array)
|
||||
return false;
|
||||
|
||||
dc->vertbuf = gs_vertexbuffer_create(vb_data, GS_DYNAMIC);
|
||||
return dc->vertbuf != NULL;
|
||||
}
|
||||
|
||||
void load_crop(struct display_capture *dc, obs_data_t *settings);
|
||||
|
||||
static void *display_capture_create(obs_data_t *settings,
|
||||
obs_source_t *source)
|
||||
{
|
||||
UNUSED_PARAMETER(source);
|
||||
UNUSED_PARAMETER(settings);
|
||||
|
||||
struct display_capture *dc = bzalloc(sizeof(struct display_capture));
|
||||
|
||||
dc->source = source;
|
||||
dc->hide_cursor = !obs_data_get_bool(settings, "show_cursor");
|
||||
|
||||
dc->effect = obs_get_base_effect(OBS_EFFECT_DEFAULT_RECT);
|
||||
if (!dc->effect)
|
||||
goto fail;
|
||||
|
||||
obs_enter_graphics();
|
||||
|
||||
struct gs_sampler_info info = {
|
||||
.filter = GS_FILTER_LINEAR,
|
||||
.address_u = GS_ADDRESS_CLAMP,
|
||||
.address_v = GS_ADDRESS_CLAMP,
|
||||
.address_w = GS_ADDRESS_CLAMP,
|
||||
.max_anisotropy = 1,
|
||||
};
|
||||
dc->sampler = gs_samplerstate_create(&info);
|
||||
if (!dc->sampler)
|
||||
goto fail;
|
||||
|
||||
if (!init_vertbuf(dc))
|
||||
goto fail;
|
||||
|
||||
obs_leave_graphics();
|
||||
|
||||
init_window(&dc->window, settings);
|
||||
load_crop(dc, settings);
|
||||
|
||||
dc->display = obs_data_get_int(settings, "display");
|
||||
pthread_mutex_init(&dc->mutex, NULL);
|
||||
|
||||
if (!init_display_stream(dc))
|
||||
goto fail;
|
||||
|
||||
return dc;
|
||||
|
||||
fail:
|
||||
obs_leave_graphics();
|
||||
display_capture_destroy(dc);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void build_sprite(struct gs_vb_data *data, float fcx, float fcy,
|
||||
float start_u, float end_u, float start_v, float end_v)
|
||||
{
|
||||
struct vec2 *tvarray = data->tvarray[0].array;
|
||||
|
||||
vec3_set(data->points+1, fcx, 0.0f, 0.0f);
|
||||
vec3_set(data->points+2, 0.0f, fcy, 0.0f);
|
||||
vec3_set(data->points+3, fcx, fcy, 0.0f);
|
||||
vec2_set(tvarray, start_u, start_v);
|
||||
vec2_set(tvarray+1, end_u, start_v);
|
||||
vec2_set(tvarray+2, start_u, end_v);
|
||||
vec2_set(tvarray+3, end_u, end_v);
|
||||
}
|
||||
|
||||
static inline void build_sprite_rect(struct gs_vb_data *data,
|
||||
float origin_x, float origin_y, float end_x, float end_y)
|
||||
{
|
||||
build_sprite(data, fabs(end_x - origin_x), fabs(end_y - origin_y),
|
||||
origin_x, end_x,
|
||||
origin_y, end_y);
|
||||
}
|
||||
|
||||
static void display_capture_video_tick(void *data, float seconds)
|
||||
{
|
||||
UNUSED_PARAMETER(seconds);
|
||||
|
||||
struct display_capture *dc = data;
|
||||
|
||||
if (!dc->current)
|
||||
return;
|
||||
if (!obs_source_showing(dc->source))
|
||||
return;
|
||||
|
||||
IOSurfaceRef prev_prev = dc->prev;
|
||||
if (pthread_mutex_lock(&dc->mutex))
|
||||
return;
|
||||
dc->prev = dc->current;
|
||||
dc->current = NULL;
|
||||
pthread_mutex_unlock(&dc->mutex);
|
||||
|
||||
if (prev_prev == dc->prev)
|
||||
return;
|
||||
|
||||
if (requires_window(dc->crop) && !dc->on_screen)
|
||||
goto cleanup;
|
||||
|
||||
CGPoint origin = { 0.f };
|
||||
CGPoint end = { 0.f };
|
||||
|
||||
switch (dc->crop) {
|
||||
float x, y;
|
||||
case CROP_INVALID:
|
||||
break;
|
||||
|
||||
case CROP_MANUAL:
|
||||
origin.x += dc->crop_rect.origin.x;
|
||||
origin.y += dc->crop_rect.origin.y;
|
||||
end.y -= dc->crop_rect.size.height;
|
||||
end.x -= dc->crop_rect.size.width;
|
||||
case CROP_NONE:
|
||||
end.y += dc->frame.size.height;
|
||||
end.x += dc->frame.size.width;
|
||||
break;
|
||||
|
||||
case CROP_TO_WINDOW_AND_MANUAL:
|
||||
origin.x += dc->crop_rect.origin.x;
|
||||
origin.y += dc->crop_rect.origin.y;
|
||||
end.y -= dc->crop_rect.size.height;
|
||||
end.x -= dc->crop_rect.size.width;
|
||||
case CROP_TO_WINDOW:
|
||||
origin.x += x = dc->window_rect.origin.x - dc->frame.origin.x;
|
||||
origin.y += y = dc->window_rect.origin.y - dc->frame.origin.y;
|
||||
end.y += dc->window_rect.size.height + y;
|
||||
end.x += dc->window_rect.size.width + x;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
obs_enter_graphics();
|
||||
build_sprite_rect(gs_vertexbuffer_get_data(dc->vertbuf),
|
||||
origin.x, origin.y, end.x, end.y);
|
||||
|
||||
if (dc->tex)
|
||||
gs_texture_rebind_iosurface(dc->tex, dc->prev);
|
||||
else
|
||||
dc->tex = gs_texture_create_from_iosurface(dc->prev);
|
||||
obs_leave_graphics();
|
||||
|
||||
cleanup:
|
||||
if (prev_prev) {
|
||||
IOSurfaceDecrementUseCount(prev_prev);
|
||||
CFRelease(prev_prev);
|
||||
}
|
||||
}
|
||||
|
||||
static void display_capture_video_render(void *data, gs_effect_t *effect)
|
||||
{
|
||||
UNUSED_PARAMETER(effect);
|
||||
|
||||
struct display_capture *dc = data;
|
||||
|
||||
if (!dc->tex || (requires_window(dc->crop) && !dc->on_screen))
|
||||
return;
|
||||
|
||||
gs_vertexbuffer_flush(dc->vertbuf);
|
||||
gs_load_vertexbuffer(dc->vertbuf);
|
||||
gs_load_indexbuffer(NULL);
|
||||
gs_load_samplerstate(dc->sampler, 0);
|
||||
gs_technique_t *tech = gs_effect_get_technique(dc->effect, "Draw");
|
||||
gs_effect_set_texture(gs_effect_get_param_by_name(dc->effect, "image"),
|
||||
dc->tex);
|
||||
gs_technique_begin(tech);
|
||||
gs_technique_begin_pass(tech, 0);
|
||||
|
||||
gs_draw(GS_TRISTRIP, 0, 4);
|
||||
|
||||
gs_technique_end_pass(tech);
|
||||
gs_technique_end(tech);
|
||||
}
|
||||
|
||||
static const char *display_capture_getname(void *unused)
|
||||
{
|
||||
UNUSED_PARAMETER(unused);
|
||||
return obs_module_text("DisplayCapture");
|
||||
}
|
||||
|
||||
#define CROPPED_LENGTH(rect, origin_, length) \
|
||||
fabs((rect ## .size. ## length - dc->crop_rect.size. ## length) - \
|
||||
(rect ## .origin. ## origin_ + dc->crop_rect.origin. ## origin_))
|
||||
|
||||
static uint32_t display_capture_getwidth(void *data)
|
||||
{
|
||||
struct display_capture *dc = data;
|
||||
|
||||
float crop = dc->crop_rect.origin.x + dc->crop_rect.size.width;
|
||||
switch (dc->crop) {
|
||||
case CROP_NONE:
|
||||
return dc->frame.size.width;
|
||||
|
||||
case CROP_MANUAL:
|
||||
return fabs(dc->frame.size.width - crop);
|
||||
|
||||
case CROP_TO_WINDOW:
|
||||
return dc->window_rect.size.width;
|
||||
|
||||
case CROP_TO_WINDOW_AND_MANUAL:
|
||||
return fabs(dc->window_rect.size.width - crop);
|
||||
|
||||
case CROP_INVALID:
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static uint32_t display_capture_getheight(void *data)
|
||||
{
|
||||
struct display_capture *dc = data;
|
||||
|
||||
float crop = dc->crop_rect.origin.y + dc->crop_rect.size.height;
|
||||
switch (dc->crop) {
|
||||
case CROP_NONE:
|
||||
return dc->frame.size.height;
|
||||
|
||||
case CROP_MANUAL:
|
||||
return fabs(dc->frame.size.height - crop);
|
||||
|
||||
case CROP_TO_WINDOW:
|
||||
return dc->window_rect.size.height;
|
||||
|
||||
case CROP_TO_WINDOW_AND_MANUAL:
|
||||
return fabs(dc->window_rect.size.height - crop);
|
||||
|
||||
case CROP_INVALID:
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void display_capture_defaults(obs_data_t *settings)
|
||||
{
|
||||
obs_data_set_default_int(settings, "display", 0);
|
||||
obs_data_set_default_bool(settings, "show_cursor", true);
|
||||
obs_data_set_default_int(settings, "crop_mode", CROP_NONE);
|
||||
|
||||
window_defaults(settings);
|
||||
}
|
||||
|
||||
void load_crop_mode(enum crop_mode *mode, obs_data_t *settings)
|
||||
{
|
||||
*mode = obs_data_get_int(settings, "crop_mode");
|
||||
if (!crop_mode_valid(*mode))
|
||||
*mode = CROP_NONE;
|
||||
}
|
||||
|
||||
void load_crop(struct display_capture *dc, obs_data_t *settings)
|
||||
{
|
||||
load_crop_mode(&dc->crop, settings);
|
||||
|
||||
#define CROP_VAR_NAME(var, mode) (mode "." #var)
|
||||
#define LOAD_CROP_VAR(var, mode) \
|
||||
dc->crop_rect.var = obs_data_get_double(settings, \
|
||||
CROP_VAR_NAME(var, mode));
|
||||
switch (dc->crop) {
|
||||
case CROP_MANUAL:
|
||||
LOAD_CROP_VAR(origin.x, "manual");
|
||||
LOAD_CROP_VAR(origin.y, "manual");
|
||||
LOAD_CROP_VAR(size.width, "manual");
|
||||
LOAD_CROP_VAR(size.height, "manual");
|
||||
break;
|
||||
|
||||
case CROP_TO_WINDOW_AND_MANUAL:
|
||||
LOAD_CROP_VAR(origin.x, "window");
|
||||
LOAD_CROP_VAR(origin.y, "window");
|
||||
LOAD_CROP_VAR(size.width, "window");
|
||||
LOAD_CROP_VAR(size.height, "window");
|
||||
break;
|
||||
|
||||
case CROP_NONE:
|
||||
case CROP_TO_WINDOW:
|
||||
case CROP_INVALID:
|
||||
break;
|
||||
}
|
||||
#undef LOAD_CROP_VAR
|
||||
}
|
||||
|
||||
static void display_capture_update(void *data, obs_data_t *settings)
|
||||
{
|
||||
struct display_capture *dc = data;
|
||||
|
||||
load_crop(dc, settings);
|
||||
|
||||
if (requires_window(dc->crop))
|
||||
update_window(&dc->window, settings);
|
||||
|
||||
unsigned display = obs_data_get_int(settings, "display");
|
||||
bool show_cursor = obs_data_get_bool(settings, "show_cursor");
|
||||
if (dc->display == display && dc->hide_cursor != show_cursor)
|
||||
return;
|
||||
|
||||
obs_enter_graphics();
|
||||
|
||||
destroy_display_stream(dc);
|
||||
dc->display = display;
|
||||
dc->hide_cursor = !show_cursor;
|
||||
init_display_stream(dc);
|
||||
|
||||
obs_leave_graphics();
|
||||
}
|
||||
|
||||
static bool switch_crop_mode(obs_properties_t *props, obs_property_t *p,
|
||||
obs_data_t *settings)
|
||||
{
|
||||
UNUSED_PARAMETER(p);
|
||||
|
||||
enum crop_mode crop;
|
||||
load_crop_mode(&crop, settings);
|
||||
|
||||
const char *name;
|
||||
bool visible;
|
||||
#define LOAD_CROP_VAR(var, mode) \
|
||||
name = CROP_VAR_NAME(var, mode); \
|
||||
obs_property_set_visible(obs_properties_get(props, name), visible);
|
||||
|
||||
visible = crop == CROP_MANUAL;
|
||||
LOAD_CROP_VAR(origin.x, "manual");
|
||||
LOAD_CROP_VAR(origin.y, "manual");
|
||||
LOAD_CROP_VAR(size.width, "manual");
|
||||
LOAD_CROP_VAR(size.height, "manual");
|
||||
|
||||
visible = crop == CROP_TO_WINDOW_AND_MANUAL;
|
||||
LOAD_CROP_VAR(origin.x, "window");
|
||||
LOAD_CROP_VAR(origin.y, "window");
|
||||
LOAD_CROP_VAR(size.width, "window");
|
||||
LOAD_CROP_VAR(size.height, "window");
|
||||
#undef LOAD_CROP_VAR
|
||||
|
||||
show_window_properties(props, visible || crop == CROP_TO_WINDOW);
|
||||
return true;
|
||||
}
|
||||
|
||||
static const char *crop_names[] = {
|
||||
"CropMode.None",
|
||||
"CropMode.Manual",
|
||||
"CropMode.ToWindow",
|
||||
"CropMode.ToWindowAndManual"
|
||||
};
|
||||
|
||||
#ifndef COUNTOF
|
||||
#define COUNTOF(x) (sizeof(x)/sizeof(x[0]))
|
||||
#endif
|
||||
static obs_properties_t *display_capture_properties(void *unused)
|
||||
{
|
||||
UNUSED_PARAMETER(unused);
|
||||
|
||||
obs_properties_t *props = obs_properties_create();
|
||||
|
||||
obs_property_t *list = obs_properties_add_list(props,
|
||||
"display", obs_module_text("DisplayCapture.Display"),
|
||||
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
|
||||
|
||||
for (unsigned i = 0; i < [NSScreen screens].count; i++) {
|
||||
char buf[10];
|
||||
sprintf(buf, "%u", i);
|
||||
obs_property_list_add_int(list, buf, i);
|
||||
}
|
||||
|
||||
obs_properties_add_bool(props, "show_cursor",
|
||||
obs_module_text("DisplayCapture.ShowCursor"));
|
||||
|
||||
obs_property_t *crop = obs_properties_add_list(props, "crop_mode",
|
||||
obs_module_text("CropMode"),
|
||||
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
|
||||
obs_property_set_modified_callback(crop, switch_crop_mode);
|
||||
|
||||
for (unsigned i = 0; i < COUNTOF(crop_names); i++) {
|
||||
const char *name = obs_module_text(crop_names[i]);
|
||||
obs_property_list_add_int(crop, name, i);
|
||||
}
|
||||
|
||||
add_window_properties(props);
|
||||
show_window_properties(props, false);
|
||||
|
||||
obs_property_t *p;
|
||||
const char *name;
|
||||
float min;
|
||||
#define LOAD_CROP_VAR(var, mode) \
|
||||
name = CROP_VAR_NAME(var, mode); \
|
||||
p = obs_properties_add_float(props, name, \
|
||||
obs_module_text("Crop."#var), min, 4096.f, .5f); \
|
||||
obs_property_set_visible(p, false);
|
||||
|
||||
min = 0.f;
|
||||
LOAD_CROP_VAR(origin.x, "manual");
|
||||
LOAD_CROP_VAR(origin.y, "manual");
|
||||
LOAD_CROP_VAR(size.width, "manual");
|
||||
LOAD_CROP_VAR(size.height, "manual");
|
||||
|
||||
min = -4096.f;
|
||||
LOAD_CROP_VAR(origin.x, "window");
|
||||
LOAD_CROP_VAR(origin.y, "window");
|
||||
LOAD_CROP_VAR(size.width, "window");
|
||||
LOAD_CROP_VAR(size.height, "window");
|
||||
#undef LOAD_CROP_VAR
|
||||
|
||||
return props;
|
||||
}
|
||||
|
||||
struct obs_source_info display_capture_info = {
|
||||
.id = "display_capture",
|
||||
.type = OBS_SOURCE_TYPE_INPUT,
|
||||
.get_name = display_capture_getname,
|
||||
|
||||
.create = display_capture_create,
|
||||
.destroy = display_capture_destroy,
|
||||
|
||||
.output_flags = OBS_SOURCE_VIDEO | OBS_SOURCE_CUSTOM_DRAW |
|
||||
OBS_SOURCE_DO_NOT_DUPLICATE,
|
||||
.video_tick = display_capture_video_tick,
|
||||
.video_render = display_capture_video_render,
|
||||
|
||||
.get_width = display_capture_getwidth,
|
||||
.get_height = display_capture_getheight,
|
||||
|
||||
.get_defaults = display_capture_defaults,
|
||||
.get_properties = display_capture_properties,
|
||||
.update = display_capture_update,
|
||||
};
|
||||
34
plugins/mac-capture/mac-helpers.h
Normal file
34
plugins/mac-capture/mac-helpers.h
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
#pragma once
|
||||
|
||||
#include <util/dstr.h>
|
||||
|
||||
static inline bool mac_success(OSStatus stat, const char *action)
|
||||
{
|
||||
if (stat != noErr) {
|
||||
blog(LOG_WARNING, "%s failed: %d", action, (int)stat);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static inline bool cf_to_cstr(CFStringRef ref, char *buf, size_t size)
|
||||
{
|
||||
if (!ref) return false;
|
||||
return (bool)CFStringGetCString(ref, buf, size, kCFStringEncodingUTF8);
|
||||
}
|
||||
|
||||
static inline bool cf_to_dstr(CFStringRef ref, struct dstr *str)
|
||||
{
|
||||
size_t size;
|
||||
if (!ref) return false;
|
||||
|
||||
size = (size_t)CFStringGetLength(ref);
|
||||
if (!size)
|
||||
return false;
|
||||
|
||||
dstr_resize(str, size);
|
||||
|
||||
return (bool)CFStringGetCString(ref, str->array, size+1,
|
||||
kCFStringEncodingUTF8);
|
||||
}
|
||||
228
plugins/mac-capture/mac-window-capture.m
Normal file
228
plugins/mac-capture/mac-window-capture.m
Normal file
|
|
@ -0,0 +1,228 @@
|
|||
#include <obs-module.h>
|
||||
#include <util/darray.h>
|
||||
#include <util/threading.h>
|
||||
#include <util/platform.h>
|
||||
|
||||
#import <CoreGraphics/CGWindow.h>
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#include "window-utils.h"
|
||||
|
||||
struct window_capture {
|
||||
obs_source_t *source;
|
||||
|
||||
struct cocoa_window window;
|
||||
|
||||
//CGRect bounds;
|
||||
//CGWindowListOption window_option;
|
||||
CGWindowImageOption image_option;
|
||||
|
||||
CGColorSpaceRef color_space;
|
||||
|
||||
DARRAY(uint8_t) buffer;
|
||||
|
||||
pthread_t capture_thread;
|
||||
os_event_t *capture_event;
|
||||
os_event_t *stop_event;
|
||||
};
|
||||
|
||||
static CGImageRef get_image(struct window_capture *wc)
|
||||
{
|
||||
NSArray *arr = (NSArray*)CGWindowListCreate(
|
||||
kCGWindowListOptionIncludingWindow,
|
||||
wc->window.window_id);
|
||||
[arr autorelease];
|
||||
|
||||
if (arr.count)
|
||||
return CGWindowListCreateImage(CGRectNull,
|
||||
kCGWindowListOptionIncludingWindow,
|
||||
wc->window.window_id, wc->image_option);
|
||||
|
||||
if (!find_window(&wc->window, NULL, false))
|
||||
return NULL;
|
||||
|
||||
return CGWindowListCreateImage(CGRectNull,
|
||||
kCGWindowListOptionIncludingWindow,
|
||||
wc->window.window_id, wc->image_option);
|
||||
}
|
||||
|
||||
static inline void capture_frame(struct window_capture *wc)
|
||||
{
|
||||
uint64_t ts = os_gettime_ns();
|
||||
CGImageRef img = get_image(wc);
|
||||
if (!img)
|
||||
return;
|
||||
|
||||
size_t width = CGImageGetWidth(img);
|
||||
size_t height = CGImageGetHeight(img);
|
||||
|
||||
CGRect rect = {{0, 0}, {width, height}};
|
||||
da_reserve(wc->buffer, width * height * 4);
|
||||
uint8_t *data = wc->buffer.array;
|
||||
|
||||
CGContextRef cg_context = CGBitmapContextCreate(data, width, height,
|
||||
8, width * 4, wc->color_space,
|
||||
kCGBitmapByteOrder32Host |
|
||||
kCGImageAlphaPremultipliedFirst);
|
||||
CGContextSetBlendMode(cg_context, kCGBlendModeCopy);
|
||||
CGContextDrawImage(cg_context, rect, img);
|
||||
CGContextRelease(cg_context);
|
||||
CGImageRelease(img);
|
||||
|
||||
struct obs_source_frame frame = {
|
||||
.format = VIDEO_FORMAT_BGRA,
|
||||
.width = width,
|
||||
.height = height,
|
||||
.data[0] = data,
|
||||
.linesize[0] = width * 4,
|
||||
.timestamp = ts,
|
||||
};
|
||||
|
||||
obs_source_output_video(wc->source, &frame);
|
||||
}
|
||||
|
||||
static void *capture_thread(void *data)
|
||||
{
|
||||
struct window_capture *wc = data;
|
||||
|
||||
for (;;) {
|
||||
os_event_wait(wc->capture_event);
|
||||
if (os_event_try(wc->stop_event) != EAGAIN)
|
||||
break;
|
||||
|
||||
@autoreleasepool {
|
||||
capture_frame(wc);
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline void *window_capture_create_internal(obs_data_t *settings,
|
||||
obs_source_t *source)
|
||||
{
|
||||
struct window_capture *wc = bzalloc(sizeof(struct window_capture));
|
||||
|
||||
wc->source = source;
|
||||
|
||||
wc->color_space = CGColorSpaceCreateDeviceRGB();
|
||||
|
||||
da_init(wc->buffer);
|
||||
|
||||
init_window(&wc->window, settings);
|
||||
|
||||
wc->image_option = obs_data_get_bool(settings, "show_shadow") ?
|
||||
kCGWindowImageDefault : kCGWindowImageBoundsIgnoreFraming;
|
||||
|
||||
os_event_init(&wc->capture_event, OS_EVENT_TYPE_AUTO);
|
||||
os_event_init(&wc->stop_event, OS_EVENT_TYPE_MANUAL);
|
||||
|
||||
pthread_create(&wc->capture_thread, NULL, capture_thread, wc);
|
||||
|
||||
return wc;
|
||||
}
|
||||
|
||||
static void *window_capture_create(obs_data_t *settings, obs_source_t *source)
|
||||
{
|
||||
@autoreleasepool {
|
||||
return window_capture_create_internal(settings, source);
|
||||
}
|
||||
}
|
||||
|
||||
static void window_capture_destroy(void *data)
|
||||
{
|
||||
struct window_capture *cap = data;
|
||||
|
||||
os_event_signal(cap->stop_event);
|
||||
os_event_signal(cap->capture_event);
|
||||
|
||||
pthread_join(cap->capture_thread, NULL);
|
||||
|
||||
CGColorSpaceRelease(cap->color_space);
|
||||
|
||||
da_free(cap->buffer);
|
||||
|
||||
os_event_destroy(cap->capture_event);
|
||||
os_event_destroy(cap->stop_event);
|
||||
|
||||
destroy_window(&cap->window);
|
||||
|
||||
bfree(cap);
|
||||
}
|
||||
|
||||
static void window_capture_defaults(obs_data_t *settings)
|
||||
{
|
||||
obs_data_set_default_bool(settings, "show_shadow", false);
|
||||
window_defaults(settings);
|
||||
}
|
||||
|
||||
static obs_properties_t *window_capture_properties(void *unused)
|
||||
{
|
||||
UNUSED_PARAMETER(unused);
|
||||
|
||||
obs_properties_t *props = obs_properties_create();
|
||||
|
||||
add_window_properties(props);
|
||||
|
||||
obs_properties_add_bool(props, "show_shadow",
|
||||
obs_module_text("WindowCapture.ShowShadow"));
|
||||
|
||||
return props;
|
||||
}
|
||||
|
||||
static inline void window_capture_update_internal(struct window_capture *wc,
|
||||
obs_data_t *settings)
|
||||
{
|
||||
wc->image_option = obs_data_get_bool(settings, "show_shadow") ?
|
||||
kCGWindowImageDefault : kCGWindowImageBoundsIgnoreFraming;
|
||||
|
||||
update_window(&wc->window, settings);
|
||||
}
|
||||
|
||||
static void window_capture_update(void *data, obs_data_t *settings)
|
||||
{
|
||||
@autoreleasepool {
|
||||
return window_capture_update_internal(data, settings);
|
||||
}
|
||||
}
|
||||
|
||||
static const char *window_capture_getname(void *unused)
|
||||
{
|
||||
UNUSED_PARAMETER(unused);
|
||||
return obs_module_text("WindowCapture");
|
||||
}
|
||||
|
||||
static inline void window_capture_tick_internal(struct window_capture *wc,
|
||||
float seconds)
|
||||
{
|
||||
UNUSED_PARAMETER(seconds);
|
||||
os_event_signal(wc->capture_event);
|
||||
}
|
||||
|
||||
static void window_capture_tick(void *data, float seconds)
|
||||
{
|
||||
struct window_capture *wc = data;
|
||||
|
||||
if (!obs_source_showing(wc->source))
|
||||
return;
|
||||
|
||||
@autoreleasepool {
|
||||
return window_capture_tick_internal(data, seconds);
|
||||
}
|
||||
}
|
||||
|
||||
struct obs_source_info window_capture_info = {
|
||||
.id = "window_capture",
|
||||
.type = OBS_SOURCE_TYPE_INPUT,
|
||||
.get_name = window_capture_getname,
|
||||
|
||||
.create = window_capture_create,
|
||||
.destroy = window_capture_destroy,
|
||||
|
||||
.output_flags = OBS_SOURCE_ASYNC_VIDEO,
|
||||
.video_tick = window_capture_tick,
|
||||
|
||||
.get_defaults = window_capture_defaults,
|
||||
.get_properties = window_capture_properties,
|
||||
.update = window_capture_update,
|
||||
};
|
||||
18
plugins/mac-capture/plugin-main.c
Normal file
18
plugins/mac-capture/plugin-main.c
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#include <obs-module.h>
|
||||
|
||||
OBS_DECLARE_MODULE()
|
||||
OBS_MODULE_USE_DEFAULT_LOCALE("mac-capture", "en-US")
|
||||
|
||||
extern struct obs_source_info coreaudio_input_capture_info;
|
||||
extern struct obs_source_info coreaudio_output_capture_info;
|
||||
extern struct obs_source_info display_capture_info;
|
||||
extern struct obs_source_info window_capture_info;
|
||||
|
||||
bool obs_module_load(void)
|
||||
{
|
||||
obs_register_source(&coreaudio_input_capture_info);
|
||||
obs_register_source(&coreaudio_output_capture_info);
|
||||
obs_register_source(&display_capture_info);
|
||||
obs_register_source(&window_capture_info);
|
||||
return true;
|
||||
}
|
||||
32
plugins/mac-capture/window-utils.h
Normal file
32
plugins/mac-capture/window-utils.h
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
#import <CoreGraphics/CGWindow.h>
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#include <util/threading.h>
|
||||
#include <obs-module.h>
|
||||
|
||||
struct cocoa_window {
|
||||
CGWindowID window_id;
|
||||
|
||||
pthread_mutex_t name_lock;
|
||||
NSString *owner_name;
|
||||
NSString *window_name;
|
||||
|
||||
uint64_t next_search_time;
|
||||
};
|
||||
typedef struct cocoa_window *cocoa_window_t;
|
||||
|
||||
NSArray *enumerate_cocoa_windows(void);
|
||||
|
||||
bool find_window(cocoa_window_t cw, obs_data_t *settings, bool force);
|
||||
|
||||
void init_window(cocoa_window_t cw, obs_data_t *settings);
|
||||
|
||||
void destroy_window(cocoa_window_t cw);
|
||||
|
||||
void update_window(cocoa_window_t cw, obs_data_t *settings);
|
||||
|
||||
void window_defaults(obs_data_t *settings);
|
||||
|
||||
void add_window_properties(obs_properties_t *props);
|
||||
|
||||
void show_window_properties(obs_properties_t *props, bool show);
|
||||
233
plugins/mac-capture/window-utils.m
Normal file
233
plugins/mac-capture/window-utils.m
Normal file
|
|
@ -0,0 +1,233 @@
|
|||
#include "window-utils.h"
|
||||
|
||||
#include <util/platform.h>
|
||||
|
||||
#define WINDOW_NAME ((NSString*)kCGWindowName)
|
||||
#define WINDOW_NUMBER ((NSString*)kCGWindowNumber)
|
||||
#define OWNER_NAME ((NSString*)kCGWindowOwnerName)
|
||||
#define OWNER_PID ((NSNumber*)kCGWindowOwnerPID)
|
||||
|
||||
static NSComparator win_info_cmp = ^(NSDictionary *o1, NSDictionary *o2)
|
||||
{
|
||||
NSComparisonResult res = [o1[OWNER_NAME] compare:o2[OWNER_NAME]];
|
||||
if (res != NSOrderedSame)
|
||||
return res;
|
||||
|
||||
res = [o1[OWNER_PID] compare:o2[OWNER_PID]];
|
||||
if (res != NSOrderedSame)
|
||||
return res;
|
||||
|
||||
res = [o1[WINDOW_NAME] compare:o2[WINDOW_NAME]];
|
||||
if (res != NSOrderedSame)
|
||||
return res;
|
||||
|
||||
return [o1[WINDOW_NUMBER] compare:o2[WINDOW_NUMBER]];
|
||||
};
|
||||
|
||||
NSArray *enumerate_windows(void)
|
||||
{
|
||||
NSArray *arr = (NSArray*)CGWindowListCopyWindowInfo(
|
||||
kCGWindowListOptionOnScreenOnly,
|
||||
kCGNullWindowID);
|
||||
|
||||
[arr autorelease];
|
||||
|
||||
return [arr sortedArrayUsingComparator:win_info_cmp];
|
||||
}
|
||||
|
||||
#define WAIT_TIME_MS 500
|
||||
#define WAIT_TIME_US WAIT_TIME_MS * 1000
|
||||
#define WAIT_TIME_NS WAIT_TIME_US * 1000
|
||||
|
||||
bool find_window(cocoa_window_t cw, obs_data_t *settings, bool force)
|
||||
{
|
||||
if (!force && cw->next_search_time > os_gettime_ns())
|
||||
return false;
|
||||
|
||||
cw->next_search_time = os_gettime_ns() + WAIT_TIME_NS;
|
||||
|
||||
pthread_mutex_lock(&cw->name_lock);
|
||||
|
||||
if (!cw->window_name.length && !cw->owner_name.length)
|
||||
goto invalid_name;
|
||||
|
||||
for (NSDictionary *dict in enumerate_windows()) {
|
||||
if (![cw->owner_name isEqualToString:dict[OWNER_NAME]])
|
||||
continue;
|
||||
|
||||
if (![cw->window_name isEqualToString:dict[WINDOW_NAME]])
|
||||
continue;
|
||||
|
||||
pthread_mutex_unlock(&cw->name_lock);
|
||||
|
||||
NSNumber *window_id = (NSNumber*)dict[WINDOW_NUMBER];
|
||||
cw->window_id = window_id.intValue;
|
||||
|
||||
obs_data_set_int(settings, "window", cw->window_id);
|
||||
return true;
|
||||
}
|
||||
|
||||
invalid_name:
|
||||
pthread_mutex_unlock(&cw->name_lock);
|
||||
return false;
|
||||
}
|
||||
|
||||
void init_window(cocoa_window_t cw, obs_data_t *settings)
|
||||
{
|
||||
pthread_mutex_init(&cw->name_lock, NULL);
|
||||
|
||||
cw->owner_name = @(obs_data_get_string(settings, "owner_name"));
|
||||
cw->window_name = @(obs_data_get_string(settings, "window_name"));
|
||||
[cw->owner_name retain];
|
||||
[cw->window_name retain];
|
||||
find_window(cw, settings, true);
|
||||
}
|
||||
|
||||
void destroy_window(cocoa_window_t cw)
|
||||
{
|
||||
pthread_mutex_destroy(&cw->name_lock);
|
||||
[cw->owner_name release];
|
||||
[cw->window_name release];
|
||||
}
|
||||
|
||||
void update_window(cocoa_window_t cw, obs_data_t *settings)
|
||||
{
|
||||
pthread_mutex_lock(&cw->name_lock);
|
||||
[cw->owner_name release];
|
||||
[cw->window_name release];
|
||||
cw->owner_name = @(obs_data_get_string(settings, "owner_name"));
|
||||
cw->window_name = @(obs_data_get_string(settings, "window_name"));
|
||||
[cw->owner_name retain];
|
||||
[cw->window_name retain];
|
||||
pthread_mutex_unlock(&cw->name_lock);
|
||||
|
||||
cw->window_id = obs_data_get_int(settings, "window");
|
||||
}
|
||||
|
||||
static inline const char *make_name(NSString *owner, NSString *name)
|
||||
{
|
||||
if (!owner.length)
|
||||
return "";
|
||||
|
||||
NSString *str = [NSString stringWithFormat:@"[%@] %@", owner, name];
|
||||
return str.UTF8String;
|
||||
}
|
||||
|
||||
static inline NSDictionary *find_window_dict(NSArray *arr, int window_id)
|
||||
{
|
||||
for (NSDictionary *dict in arr) {
|
||||
NSNumber *wid = (NSNumber*)dict[WINDOW_NUMBER];
|
||||
if (wid.intValue == window_id)
|
||||
return dict;
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
static inline bool window_changed_internal(obs_property_t *p,
|
||||
obs_data_t *settings)
|
||||
{
|
||||
int window_id = obs_data_get_int(settings, "window");
|
||||
NSString *window_owner = @(obs_data_get_string(settings, "owner_name"));
|
||||
NSString *window_name =
|
||||
@(obs_data_get_string(settings, "window_name"));
|
||||
|
||||
NSDictionary *win_info = @{
|
||||
OWNER_NAME: window_owner,
|
||||
WINDOW_NAME: window_name,
|
||||
};
|
||||
|
||||
NSArray *arr = enumerate_windows();
|
||||
|
||||
bool show_empty_names = obs_data_get_bool(settings, "show_empty_names");
|
||||
|
||||
NSDictionary *cur = find_window_dict(arr, window_id);
|
||||
bool window_found = cur != nil;
|
||||
bool window_added = window_found;
|
||||
|
||||
obs_property_list_clear(p);
|
||||
for (NSDictionary *dict in arr) {
|
||||
NSString *owner = (NSString*)dict[OWNER_NAME];
|
||||
NSString *name = (NSString*)dict[WINDOW_NAME];
|
||||
NSNumber *wid = (NSNumber*)dict[WINDOW_NUMBER];
|
||||
|
||||
if (!window_added &&
|
||||
win_info_cmp(win_info, dict) == NSOrderedAscending) {
|
||||
window_added = true;
|
||||
size_t idx = obs_property_list_add_int(p,
|
||||
make_name(window_owner, window_name),
|
||||
window_id);
|
||||
obs_property_list_item_disable(p, idx, true);
|
||||
}
|
||||
|
||||
if (!show_empty_names && !name.length &&
|
||||
window_id != wid.intValue)
|
||||
continue;
|
||||
|
||||
obs_property_list_add_int(p, make_name(owner, name),
|
||||
wid.intValue);
|
||||
}
|
||||
|
||||
if (!window_added) {
|
||||
size_t idx = obs_property_list_add_int(p,
|
||||
make_name(window_owner, window_name),
|
||||
window_id);
|
||||
obs_property_list_item_disable(p, idx, true);
|
||||
}
|
||||
|
||||
if (!window_found)
|
||||
return true;
|
||||
|
||||
NSString *owner = (NSString*)cur[OWNER_NAME];
|
||||
NSString *window = (NSString*)cur[WINDOW_NAME];
|
||||
|
||||
obs_data_set_string(settings, "owner_name", owner.UTF8String);
|
||||
obs_data_set_string(settings, "window_name", window.UTF8String);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool window_changed(obs_properties_t *props, obs_property_t *p,
|
||||
obs_data_t *settings)
|
||||
{
|
||||
UNUSED_PARAMETER(props);
|
||||
|
||||
@autoreleasepool {
|
||||
return window_changed_internal(p, settings);
|
||||
}
|
||||
}
|
||||
|
||||
static bool toggle_empty_names(obs_properties_t *props, obs_property_t *p,
|
||||
obs_data_t *settings)
|
||||
{
|
||||
UNUSED_PARAMETER(p);
|
||||
|
||||
return window_changed(props, obs_properties_get(props, "window"),
|
||||
settings);
|
||||
}
|
||||
|
||||
void window_defaults(obs_data_t *settings)
|
||||
{
|
||||
obs_data_set_default_int(settings, "window", kCGNullWindowID);
|
||||
obs_data_set_default_bool(settings, "show_empty_names", false);
|
||||
}
|
||||
|
||||
void add_window_properties(obs_properties_t *props)
|
||||
{
|
||||
obs_property_t *window_list = obs_properties_add_list(props,
|
||||
"window", obs_module_text("WindowUtils.Window"),
|
||||
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
|
||||
obs_property_set_modified_callback(window_list, window_changed);
|
||||
|
||||
obs_property_t *empty = obs_properties_add_bool(props,
|
||||
"show_empty_names",
|
||||
obs_module_text("WindowUtils.ShowEmptyNames"));
|
||||
obs_property_set_modified_callback(empty, toggle_empty_names);
|
||||
}
|
||||
|
||||
void show_window_properties(obs_properties_t *props, bool show)
|
||||
{
|
||||
obs_property_set_visible(obs_properties_get(props, "window"), show);
|
||||
obs_property_set_visible(
|
||||
obs_properties_get(props, "show_empty_names"), show);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue