New upstream version 19.0.3+dfsg1
This commit is contained in:
parent
3708b8e092
commit
1f1bbb3518
534 changed files with 13862 additions and 2459 deletions
|
|
@ -5,16 +5,10 @@ if(APPLE)
|
|||
include_directories(${COCOA})
|
||||
endif()
|
||||
|
||||
if(WIN32 OR APPLE)
|
||||
set(frontend-tools_HEADERS
|
||||
auto-scene-switcher.hpp
|
||||
)
|
||||
set(frontend-tools_SOURCES
|
||||
auto-scene-switcher.cpp
|
||||
)
|
||||
set(frontend-tools_UI
|
||||
forms/auto-scene-switcher.ui
|
||||
)
|
||||
if(UNIX)
|
||||
find_package(X11 REQUIRED)
|
||||
link_libraries(${X11_LIBRARIES})
|
||||
include_directories(${X11_INCLUDE_DIR})
|
||||
endif()
|
||||
|
||||
configure_file(
|
||||
|
|
@ -24,16 +18,19 @@ configure_file(
|
|||
set(frontend-tools_HEADERS
|
||||
${frontend-tools_HEADERS}
|
||||
"${CMAKE_BINARY_DIR}/config/frontend-tools-config.h"
|
||||
auto-scene-switcher.hpp
|
||||
output-timer.hpp
|
||||
tool-helpers.hpp
|
||||
)
|
||||
set(frontend-tools_SOURCES
|
||||
${frontend-tools_SOURCES}
|
||||
auto-scene-switcher.cpp
|
||||
frontend-tools.c
|
||||
output-timer.cpp
|
||||
)
|
||||
set(frontend-tools_UI
|
||||
${frontend-tools_UI}
|
||||
forms/auto-scene-switcher.ui
|
||||
forms/output-timer.ui
|
||||
)
|
||||
|
||||
|
|
@ -45,10 +42,14 @@ if(WIN32)
|
|||
set(frontend-tools_PLATFORM_SOURCES
|
||||
${frontend-tools_PLATFORM_SOURCES}
|
||||
captions.cpp
|
||||
captions-stream.cpp)
|
||||
captions-handler.cpp
|
||||
captions-mssapi.cpp
|
||||
captions-mssapi-stream.cpp)
|
||||
set(frontend-tools_PLATFORM_HEADERS
|
||||
captions.hpp
|
||||
captions-stream.hpp)
|
||||
captions-handler.hpp
|
||||
captions-mssapi.hpp
|
||||
captions-mssapi-stream.hpp)
|
||||
set(frontend-tools_PLATFORM_UI
|
||||
forms/captions.ui)
|
||||
endif()
|
||||
|
|
@ -60,6 +61,9 @@ elseif(APPLE)
|
|||
|
||||
set(frontend-tools_PLATFORM_LIBS
|
||||
${COCOA})
|
||||
else()
|
||||
set(frontend-tools_PLATFORM_SOURCES
|
||||
auto-scene-switcher-nix.cpp)
|
||||
endif()
|
||||
|
||||
qt5_wrap_ui(frontend-tools_UI_HEADERS
|
||||
|
|
|
|||
211
UI/frontend-plugins/frontend-tools/auto-scene-switcher-nix.cpp
Normal file
211
UI/frontend-plugins/frontend-tools/auto-scene-switcher-nix.cpp
Normal file
|
|
@ -0,0 +1,211 @@
|
|||
#include <X11/Xlib.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/Xutil.h>
|
||||
#undef Bool
|
||||
#undef CursorShape
|
||||
#undef Expose
|
||||
#undef KeyPress
|
||||
#undef KeyRelease
|
||||
#undef FocusIn
|
||||
#undef FocusOut
|
||||
#undef FontChange
|
||||
#undef None
|
||||
#undef Status
|
||||
#undef Unsorted
|
||||
#include <util/platform.h>
|
||||
#include "auto-scene-switcher.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
static Display* xdisplay = 0;
|
||||
|
||||
Display *disp()
|
||||
{
|
||||
if (!xdisplay)
|
||||
xdisplay = XOpenDisplay(NULL);
|
||||
|
||||
return xdisplay;
|
||||
}
|
||||
|
||||
void cleanupDisplay()
|
||||
{
|
||||
if (!xdisplay)
|
||||
return;
|
||||
|
||||
XCloseDisplay(xdisplay);
|
||||
xdisplay = 0;
|
||||
}
|
||||
|
||||
static bool ewmhIsSupported()
|
||||
{
|
||||
Display *display = disp();
|
||||
Atom netSupportingWmCheck = XInternAtom(display,
|
||||
"_NET_SUPPORTING_WM_CHECK", true);
|
||||
Atom actualType;
|
||||
int format = 0;
|
||||
unsigned long num = 0, bytes = 0;
|
||||
unsigned char *data = NULL;
|
||||
Window ewmh_window = 0;
|
||||
|
||||
int status = XGetWindowProperty(
|
||||
display,
|
||||
DefaultRootWindow(display),
|
||||
netSupportingWmCheck,
|
||||
0L,
|
||||
1L,
|
||||
false,
|
||||
XA_WINDOW,
|
||||
&actualType,
|
||||
&format,
|
||||
&num,
|
||||
&bytes,
|
||||
&data);
|
||||
|
||||
if (status == Success) {
|
||||
if (num > 0) {
|
||||
ewmh_window = ((Window*)data)[0];
|
||||
}
|
||||
if (data) {
|
||||
XFree(data);
|
||||
data = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (ewmh_window) {
|
||||
status = XGetWindowProperty(
|
||||
display,
|
||||
ewmh_window,
|
||||
netSupportingWmCheck,
|
||||
0L,
|
||||
1L,
|
||||
false,
|
||||
XA_WINDOW,
|
||||
&actualType,
|
||||
&format,
|
||||
&num,
|
||||
&bytes,
|
||||
&data);
|
||||
if (status != Success || num == 0 ||
|
||||
ewmh_window != ((Window*)data)[0]) {
|
||||
ewmh_window = 0;
|
||||
}
|
||||
if (status == Success && data) {
|
||||
XFree(data);
|
||||
}
|
||||
}
|
||||
|
||||
return ewmh_window != 0;
|
||||
}
|
||||
|
||||
static std::vector<Window> getTopLevelWindows()
|
||||
{
|
||||
std::vector<Window> res;
|
||||
|
||||
res.resize(0);
|
||||
|
||||
if (!ewmhIsSupported()) {
|
||||
return res;
|
||||
}
|
||||
|
||||
Atom netClList = XInternAtom(disp(), "_NET_CLIENT_LIST", true);
|
||||
Atom actualType;
|
||||
int format;
|
||||
unsigned long num, bytes;
|
||||
Window* data = 0;
|
||||
|
||||
for (int i = 0; i < ScreenCount(disp()); ++i) {
|
||||
Window rootWin = RootWindow(disp(), i);
|
||||
|
||||
int status = XGetWindowProperty(
|
||||
disp(),
|
||||
rootWin,
|
||||
netClList,
|
||||
0L,
|
||||
~0L,
|
||||
false,
|
||||
AnyPropertyType,
|
||||
&actualType,
|
||||
&format,
|
||||
&num,
|
||||
&bytes,
|
||||
(uint8_t**)&data);
|
||||
|
||||
if (status != Success) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (unsigned long i = 0; i < num; ++i)
|
||||
res.emplace_back(data[i]);
|
||||
|
||||
XFree(data);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static std::string GetWindowTitle(size_t i)
|
||||
{
|
||||
Window w = getTopLevelWindows().at(i);
|
||||
std::string windowTitle;
|
||||
char* name;
|
||||
|
||||
int status = XFetchName(disp(), w, &name);
|
||||
if (status >= Success && name != nullptr)
|
||||
{
|
||||
std::string str(name);
|
||||
windowTitle = str;
|
||||
}
|
||||
|
||||
XFree(name);
|
||||
|
||||
return windowTitle;
|
||||
}
|
||||
|
||||
void GetWindowList(vector<string> &windows)
|
||||
{
|
||||
windows.resize(0);
|
||||
|
||||
for (size_t i = 0; i < getTopLevelWindows().size(); ++i){
|
||||
if (GetWindowTitle(i) != "")
|
||||
windows.emplace_back(GetWindowTitle(i));
|
||||
}
|
||||
}
|
||||
|
||||
void GetCurrentWindowTitle(string &title)
|
||||
{
|
||||
if (!ewmhIsSupported()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Atom active = XInternAtom(disp(), "_NET_ACTIVE_WINDOW", true);
|
||||
Atom actualType;
|
||||
int format;
|
||||
unsigned long num, bytes;
|
||||
Window* data = 0;
|
||||
char* name;
|
||||
|
||||
Window rootWin = RootWindow(disp(), 0);
|
||||
|
||||
XGetWindowProperty(
|
||||
disp(),
|
||||
rootWin,
|
||||
active,
|
||||
0L,
|
||||
~0L,
|
||||
false,
|
||||
AnyPropertyType,
|
||||
&actualType,
|
||||
&format,
|
||||
&num,
|
||||
&bytes,
|
||||
(uint8_t**)&data);
|
||||
|
||||
int status = XFetchName(disp(), data[0], &name);
|
||||
|
||||
if (status >= Success && name != nullptr) {
|
||||
std::string str(name);
|
||||
title = str;
|
||||
}
|
||||
|
||||
XFree(name);
|
||||
}
|
||||
54
UI/frontend-plugins/frontend-tools/captions-handler.cpp
Normal file
54
UI/frontend-plugins/frontend-tools/captions-handler.cpp
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
#include "captions-handler.hpp"
|
||||
|
||||
captions_handler::captions_handler(
|
||||
captions_cb callback,
|
||||
enum audio_format format,
|
||||
uint32_t sample_rate)
|
||||
: cb(callback)
|
||||
{
|
||||
if (!reset_resampler(format, sample_rate))
|
||||
throw CAPTIONS_ERROR_GENERIC_FAIL;
|
||||
}
|
||||
|
||||
bool captions_handler::reset_resampler(
|
||||
enum audio_format format,
|
||||
uint32_t sample_rate)
|
||||
try {
|
||||
obs_audio_info ai;
|
||||
if (!obs_get_audio_info(&ai))
|
||||
throw std::string("Failed to get OBS audio info");
|
||||
|
||||
resample_info src = {
|
||||
ai.samples_per_sec,
|
||||
AUDIO_FORMAT_FLOAT_PLANAR,
|
||||
ai.speakers
|
||||
};
|
||||
resample_info dst = {
|
||||
sample_rate,
|
||||
format,
|
||||
SPEAKERS_MONO
|
||||
};
|
||||
|
||||
if (!resampler.reset(dst, src))
|
||||
throw std::string("Failed to create audio resampler");
|
||||
|
||||
return true;
|
||||
|
||||
} catch (std::string text) {
|
||||
blog(LOG_WARNING, "%s: %s", __FUNCTION__, text.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
void captions_handler::push_audio(const audio_data *audio)
|
||||
{
|
||||
uint8_t *out[MAX_AV_PLANES];
|
||||
uint32_t frames;
|
||||
uint64_t ts_offset;
|
||||
bool success;
|
||||
|
||||
success = audio_resampler_resample(resampler,
|
||||
out, &frames, &ts_offset,
|
||||
(const uint8_t *const *)audio->data, audio->frames);
|
||||
if (success)
|
||||
pcm_data(out[0], frames);
|
||||
}
|
||||
67
UI/frontend-plugins/frontend-tools/captions-handler.hpp
Normal file
67
UI/frontend-plugins/frontend-tools/captions-handler.hpp
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
#pragma once
|
||||
|
||||
#include <media-io/audio-resampler.h>
|
||||
#include <obs-module.h>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
class resampler_obj {
|
||||
audio_resampler_t *resampler = nullptr;
|
||||
|
||||
public:
|
||||
inline ~resampler_obj()
|
||||
{
|
||||
audio_resampler_destroy(resampler);
|
||||
}
|
||||
|
||||
inline bool reset(const resample_info &dst, const resample_info &src)
|
||||
{
|
||||
audio_resampler_destroy(resampler);
|
||||
resampler = audio_resampler_create(&dst, &src);
|
||||
return !!resampler;
|
||||
}
|
||||
|
||||
inline operator audio_resampler_t*() {return resampler;}
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
typedef std::function<void (const std::string &)> captions_cb;
|
||||
|
||||
#define captions_error(s) std::string(obs_module_text("Captions.Error." ## s))
|
||||
#define CAPTIONS_ERROR_GENERIC_FAIL captions_error("GenericFail")
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
class captions_handler {
|
||||
captions_cb cb;
|
||||
resampler_obj resampler;
|
||||
|
||||
protected:
|
||||
inline void callback(const std::string &text)
|
||||
{
|
||||
cb(text);
|
||||
}
|
||||
|
||||
virtual void pcm_data(const void *data, size_t frames)=0;
|
||||
|
||||
/* always resamples to 1 channel */
|
||||
bool reset_resampler(enum audio_format format, uint32_t sample_rate);
|
||||
|
||||
public:
|
||||
/* throw std::string for errors shown to users */
|
||||
captions_handler(
|
||||
captions_cb callback,
|
||||
enum audio_format format,
|
||||
uint32_t sample_rate);
|
||||
virtual ~captions_handler() {}
|
||||
|
||||
void push_audio(const audio_data *audio);
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
struct captions_handler_info {
|
||||
std::string (*name)(void);
|
||||
captions_handler *(*create)(captions_cb cb, const std::string &lang);
|
||||
};
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
#include "captions-stream.hpp"
|
||||
#include "captions-mssapi-stream.hpp"
|
||||
#include "captions-mssapi.hpp"
|
||||
#include <mmreg.h>
|
||||
#include <util/windows/CoTaskMemPtr.hpp>
|
||||
#include <util/threading.h>
|
||||
|
|
@ -13,7 +14,8 @@ using namespace std;
|
|||
#define debugfunc(format, ...)
|
||||
#endif
|
||||
|
||||
CaptionStream::CaptionStream(DWORD samplerate_) :
|
||||
CaptionStream::CaptionStream(DWORD samplerate_, mssapi_captions *handler_) :
|
||||
handler(handler_),
|
||||
samplerate(samplerate_),
|
||||
event(CreateEvent(nullptr, false, false, nullptr))
|
||||
{
|
||||
|
|
@ -28,8 +30,6 @@ CaptionStream::CaptionStream(DWORD samplerate_) :
|
|||
format.nBlockAlign = 2;
|
||||
format.wBitsPerSample = 16;
|
||||
format.cbSize = sizeof(format);
|
||||
|
||||
resampler.Reset(&format);
|
||||
}
|
||||
|
||||
void CaptionStream::Stop()
|
||||
|
|
@ -42,28 +42,16 @@ void CaptionStream::Stop()
|
|||
cv.notify_one();
|
||||
}
|
||||
|
||||
void CaptionStream::PushAudio(const struct audio_data *data, bool muted)
|
||||
void CaptionStream::PushAudio(const void *data, size_t frames)
|
||||
{
|
||||
uint8_t *output[MAX_AV_PLANES] = {};
|
||||
uint32_t frames = data->frames;
|
||||
uint64_t ts_offset;
|
||||
bool ready = false;
|
||||
|
||||
audio_resampler_resample(resampler, output, &frames, &ts_offset,
|
||||
data->data, data->frames);
|
||||
|
||||
if (output[0]) {
|
||||
if (muted)
|
||||
memset(output[0], 0, frames * sizeof(int16_t));
|
||||
|
||||
lock_guard<mutex> lock(m);
|
||||
circlebuf_push_back(buf, output[0], frames * sizeof(int16_t));
|
||||
write_pos += frames * sizeof(int16_t);
|
||||
|
||||
if (wait_size && buf->size >= wait_size)
|
||||
ready = true;
|
||||
}
|
||||
lock_guard<mutex> lock(m);
|
||||
circlebuf_push_back(buf, data, frames * sizeof(int16_t));
|
||||
write_pos += frames * sizeof(int16_t);
|
||||
|
||||
if (wait_size && buf->size >= wait_size)
|
||||
ready = true;
|
||||
if (ready)
|
||||
cv.notify_one();
|
||||
}
|
||||
|
|
@ -316,7 +304,9 @@ STDMETHODIMP CaptionStream::SetFormat(REFGUID guid_ref,
|
|||
if (guid_ref == SPDFID_WaveFormatEx) {
|
||||
lock_guard<mutex> lock(m);
|
||||
memcpy(&format, wfex, sizeof(format));
|
||||
resampler.Reset(wfex);
|
||||
if (!handler->reset_resampler(AUDIO_FORMAT_16BIT,
|
||||
wfex->nSamplesPerSec))
|
||||
return E_FAIL;
|
||||
|
||||
/* 50 msec */
|
||||
DWORD size = format.nSamplesPerSec / 20;
|
||||
|
|
@ -1,10 +1,11 @@
|
|||
#pragma once
|
||||
|
||||
#include <windows.h>
|
||||
#include <sapi.h>
|
||||
#include <condition_variable>
|
||||
#include <mutex>
|
||||
#include <vector>
|
||||
#include <obs.h>
|
||||
#include <media-io/audio-resampler.h>
|
||||
#include <util/circlebuf.h>
|
||||
#include <util/windows/WinHandle.hpp>
|
||||
|
||||
|
|
@ -18,37 +19,12 @@ public:
|
|||
inline circlebuf *operator->() {return &buf;}
|
||||
};
|
||||
|
||||
class Resampler {
|
||||
audio_resampler_t *resampler = nullptr;
|
||||
|
||||
public:
|
||||
inline void Reset(const WAVEFORMATEX *wfex)
|
||||
{
|
||||
const struct audio_output_info *aoi =
|
||||
audio_output_get_info(obs_get_audio());
|
||||
|
||||
struct resample_info src;
|
||||
src.samples_per_sec = aoi->samples_per_sec;
|
||||
src.format = aoi->format;
|
||||
src.speakers = aoi->speakers;
|
||||
|
||||
struct resample_info dst;
|
||||
dst.samples_per_sec = uint32_t(wfex->nSamplesPerSec);
|
||||
dst.format = AUDIO_FORMAT_16BIT;
|
||||
dst.speakers = (enum speaker_layout)wfex->nChannels;
|
||||
|
||||
if (resampler)
|
||||
audio_resampler_destroy(resampler);
|
||||
resampler = audio_resampler_create(&dst, &src);
|
||||
}
|
||||
|
||||
inline ~Resampler() {audio_resampler_destroy(resampler);}
|
||||
inline operator audio_resampler_t*() {return resampler;}
|
||||
};
|
||||
class mssapi_captions;
|
||||
|
||||
class CaptionStream : public ISpAudio {
|
||||
volatile long refs = 1;
|
||||
SPAUDIOBUFFERINFO buf_info = {};
|
||||
mssapi_captions *handler;
|
||||
ULONG notify_size = 0;
|
||||
SPAUDIOSTATE state;
|
||||
WinHandle event;
|
||||
|
|
@ -58,7 +34,6 @@ class CaptionStream : public ISpAudio {
|
|||
std::mutex m;
|
||||
std::vector<int16_t> temp_buf;
|
||||
WAVEFORMATEX format = {};
|
||||
Resampler resampler;
|
||||
|
||||
CircleBuf buf;
|
||||
ULONG wait_size = 0;
|
||||
|
|
@ -67,10 +42,10 @@ class CaptionStream : public ISpAudio {
|
|||
ULONGLONG write_pos = 0;
|
||||
|
||||
public:
|
||||
CaptionStream(DWORD samplerate);
|
||||
CaptionStream(DWORD samplerate, mssapi_captions *handler_);
|
||||
|
||||
void Stop();
|
||||
void PushAudio(const struct audio_data *audio_data, bool muted);
|
||||
void PushAudio(const void *data, size_t frames);
|
||||
|
||||
// IUnknown methods
|
||||
STDMETHODIMP QueryInterface(REFIID riid, void **ppv) override;
|
||||
179
UI/frontend-plugins/frontend-tools/captions-mssapi.cpp
Normal file
179
UI/frontend-plugins/frontend-tools/captions-mssapi.cpp
Normal file
|
|
@ -0,0 +1,179 @@
|
|||
#include "captions-mssapi.hpp"
|
||||
|
||||
#define do_log(type, format, ...) blog(type, "[Captions] " format, \
|
||||
##__VA_ARGS__)
|
||||
|
||||
#define error(format, ...) do_log(LOG_ERROR, format, ##__VA_ARGS__)
|
||||
#define debug(format, ...) do_log(LOG_DEBUG, format, ##__VA_ARGS__)
|
||||
|
||||
mssapi_captions::mssapi_captions(
|
||||
captions_cb callback,
|
||||
const std::string &lang) try
|
||||
: captions_handler(callback, AUDIO_FORMAT_16BIT, 16000)
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
std::wstring wlang;
|
||||
wlang.resize(lang.size());
|
||||
|
||||
for (size_t i = 0; i < lang.size(); i++)
|
||||
wlang[i] = (wchar_t)lang[i];
|
||||
|
||||
LCID lang_id = LocaleNameToLCID(wlang.c_str(), 0);
|
||||
|
||||
wchar_t lang_str[32];
|
||||
_snwprintf(lang_str, 31, L"language=%x", (int)lang_id);
|
||||
|
||||
stop = CreateEvent(nullptr, false, false, nullptr);
|
||||
if (!stop.Valid())
|
||||
throw "Failed to create event";
|
||||
|
||||
hr = SpFindBestToken(SPCAT_RECOGNIZERS, lang_str, nullptr, &token);
|
||||
if (FAILED(hr))
|
||||
throw HRError("SpFindBestToken failed", hr);
|
||||
|
||||
hr = CoCreateInstance(CLSID_SpInprocRecognizer, nullptr, CLSCTX_ALL,
|
||||
__uuidof(ISpRecognizer), (void**)&recognizer);
|
||||
if (FAILED(hr))
|
||||
throw HRError("CoCreateInstance for recognizer failed", hr);
|
||||
|
||||
hr = recognizer->SetRecognizer(token);
|
||||
if (FAILED(hr))
|
||||
throw HRError("SetRecognizer failed", hr);
|
||||
|
||||
hr = recognizer->SetRecoState(SPRST_INACTIVE);
|
||||
if (FAILED(hr))
|
||||
throw HRError("SetRecoState(SPRST_INACTIVE) failed", hr);
|
||||
|
||||
hr = recognizer->CreateRecoContext(&context);
|
||||
if (FAILED(hr))
|
||||
throw HRError("CreateRecoContext failed", hr);
|
||||
|
||||
ULONGLONG interest = SPFEI(SPEI_RECOGNITION) |
|
||||
SPFEI(SPEI_END_SR_STREAM);
|
||||
hr = context->SetInterest(interest, interest);
|
||||
if (FAILED(hr))
|
||||
throw HRError("SetInterest failed", hr);
|
||||
|
||||
hr = context->SetNotifyWin32Event();
|
||||
if (FAILED(hr))
|
||||
throw HRError("SetNotifyWin32Event", hr);
|
||||
|
||||
notify = context->GetNotifyEventHandle();
|
||||
if (notify == INVALID_HANDLE_VALUE)
|
||||
throw HRError("GetNotifyEventHandle failed", E_NOINTERFACE);
|
||||
|
||||
size_t sample_rate = audio_output_get_sample_rate(obs_get_audio());
|
||||
audio = new CaptionStream((DWORD)sample_rate, this);
|
||||
audio->Release();
|
||||
|
||||
hr = recognizer->SetInput(audio, false);
|
||||
if (FAILED(hr))
|
||||
throw HRError("SetInput failed", hr);
|
||||
|
||||
hr = context->CreateGrammar(1, &grammar);
|
||||
if (FAILED(hr))
|
||||
throw HRError("CreateGrammar failed", hr);
|
||||
|
||||
hr = grammar->LoadDictation(nullptr, SPLO_STATIC);
|
||||
if (FAILED(hr))
|
||||
throw HRError("LoadDictation failed", hr);
|
||||
|
||||
try {
|
||||
t = std::thread([this] () {main_thread();});
|
||||
} catch (...) {
|
||||
throw "Failed to create thread";
|
||||
}
|
||||
|
||||
} catch (const char *err) {
|
||||
blog(LOG_WARNING, "%s: %s", __FUNCTION__, err);
|
||||
throw CAPTIONS_ERROR_GENERIC_FAIL;
|
||||
|
||||
} catch (HRError err) {
|
||||
blog(LOG_WARNING, "%s: %s (%lX)", __FUNCTION__, err.str, err.hr);
|
||||
throw CAPTIONS_ERROR_GENERIC_FAIL;
|
||||
}
|
||||
|
||||
mssapi_captions::~mssapi_captions()
|
||||
{
|
||||
if (t.joinable()) {
|
||||
SetEvent(stop);
|
||||
t.join();
|
||||
}
|
||||
}
|
||||
|
||||
void mssapi_captions::main_thread()
|
||||
try {
|
||||
HRESULT hr;
|
||||
|
||||
os_set_thread_name(__FUNCTION__);
|
||||
|
||||
hr = grammar->SetDictationState(SPRS_ACTIVE);
|
||||
if (FAILED(hr))
|
||||
throw HRError("SetDictationState failed", hr);
|
||||
|
||||
hr = recognizer->SetRecoState(SPRST_ACTIVE);
|
||||
if (FAILED(hr))
|
||||
throw HRError("SetRecoState(SPRST_ACTIVE) failed", hr);
|
||||
|
||||
HANDLE events[] = {notify, stop};
|
||||
|
||||
started = true;
|
||||
|
||||
for (;;) {
|
||||
DWORD ret = WaitForMultipleObjects(2, events, false, INFINITE);
|
||||
if (ret != WAIT_OBJECT_0)
|
||||
break;
|
||||
|
||||
CSpEvent event;
|
||||
bool exit = false;
|
||||
|
||||
while (event.GetFrom(context) == S_OK) {
|
||||
if (event.eEventId == SPEI_RECOGNITION) {
|
||||
ISpRecoResult *result = event.RecoResult();
|
||||
|
||||
CoTaskMemPtr<wchar_t> text;
|
||||
hr = result->GetText((ULONG)-1, (ULONG)-1,
|
||||
true, &text, nullptr);
|
||||
if (FAILED(hr))
|
||||
continue;
|
||||
|
||||
char text_utf8[512];
|
||||
os_wcs_to_utf8(text, 0, text_utf8, 512);
|
||||
|
||||
callback(text_utf8);
|
||||
|
||||
blog(LOG_DEBUG, "\"%s\"", text_utf8);
|
||||
|
||||
} else if (event.eEventId == SPEI_END_SR_STREAM) {
|
||||
exit = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (exit)
|
||||
break;
|
||||
}
|
||||
|
||||
audio->Stop();
|
||||
|
||||
} catch (HRError err) {
|
||||
blog(LOG_WARNING, "%s failed: %s (%lX)", __FUNCTION__, err.str, err.hr);
|
||||
}
|
||||
|
||||
void mssapi_captions::pcm_data(const void *data, size_t frames)
|
||||
{
|
||||
if (started)
|
||||
audio->PushAudio(data, frames);
|
||||
}
|
||||
|
||||
captions_handler_info mssapi_info = {
|
||||
[] () -> std::string
|
||||
{
|
||||
return "Microsoft Speech-to-Text";
|
||||
},
|
||||
[] (captions_cb cb, const std::string &lang) -> captions_handler *
|
||||
{
|
||||
return new mssapi_captions(cb, lang);
|
||||
}
|
||||
};
|
||||
37
UI/frontend-plugins/frontend-tools/captions-mssapi.hpp
Normal file
37
UI/frontend-plugins/frontend-tools/captions-mssapi.hpp
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
#pragma once
|
||||
|
||||
#include "captions-handler.hpp"
|
||||
#include "captions-mssapi-stream.hpp"
|
||||
#include <util/windows/HRError.hpp>
|
||||
#include <util/windows/ComPtr.hpp>
|
||||
#include <util/windows/WinHandle.hpp>
|
||||
#include <util/windows/CoTaskMemPtr.hpp>
|
||||
#include <util/threading.h>
|
||||
#include <util/platform.h>
|
||||
#include <sphelper.h>
|
||||
|
||||
#include <obs.hpp>
|
||||
|
||||
#include <thread>
|
||||
|
||||
class mssapi_captions : public captions_handler {
|
||||
friend class CaptionStream;
|
||||
|
||||
ComPtr<CaptionStream> audio;
|
||||
ComPtr<ISpObjectToken> token;
|
||||
ComPtr<ISpRecoGrammar> grammar;
|
||||
ComPtr<ISpRecognizer> recognizer;
|
||||
ComPtr<ISpRecoContext> context;
|
||||
|
||||
HANDLE notify;
|
||||
WinHandle stop;
|
||||
std::thread t;
|
||||
bool started = false;
|
||||
|
||||
void main_thread();
|
||||
|
||||
public:
|
||||
mssapi_captions(captions_cb callback, const std::string &lang);
|
||||
virtual ~mssapi_captions();
|
||||
virtual void pcm_data(const void *data, size_t frames) override;
|
||||
};
|
||||
|
|
@ -1,47 +1,54 @@
|
|||
#include <QMessageBox>
|
||||
|
||||
#include <windows.h>
|
||||
#include <obs-frontend-api.h>
|
||||
#include "captions-stream.hpp"
|
||||
#include "captions.hpp"
|
||||
#include "captions-handler.hpp"
|
||||
#include "tool-helpers.hpp"
|
||||
#include <sphelper.h>
|
||||
#include <util/dstr.hpp>
|
||||
#include <util/platform.h>
|
||||
#include <util/windows/HRError.hpp>
|
||||
#include <util/windows/WinHandle.hpp>
|
||||
#include <util/windows/ComPtr.hpp>
|
||||
#include <util/windows/CoTaskMemPtr.hpp>
|
||||
#include <util/threading.h>
|
||||
#include <obs-module.h>
|
||||
#include <sphelper.h>
|
||||
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
|
||||
#include "captions-mssapi.hpp"
|
||||
|
||||
#define do_log(type, format, ...) blog(type, "[Captions] " format, \
|
||||
##__VA_ARGS__)
|
||||
|
||||
#define error(format, ...) do_log(LOG_ERROR, format, ##__VA_ARGS__)
|
||||
#define warn(format, ...) do_log(LOG_WARNING, format, ##__VA_ARGS__)
|
||||
#define debug(format, ...) do_log(LOG_DEBUG, format, ##__VA_ARGS__)
|
||||
|
||||
using namespace std;
|
||||
|
||||
struct obs_captions {
|
||||
thread th;
|
||||
recursive_mutex m;
|
||||
WinHandle stop_event;
|
||||
#define DEFAULT_HANDLER "mssapi"
|
||||
|
||||
struct obs_captions {
|
||||
string handler_id = DEFAULT_HANDLER;
|
||||
string source_name;
|
||||
OBSWeakSource source;
|
||||
LANGID lang_id;
|
||||
unique_ptr<captions_handler> handler;
|
||||
LANGID lang_id = GetUserDefaultUILanguage();
|
||||
|
||||
std::unordered_map<std::string, captions_handler_info&> handler_types;
|
||||
|
||||
inline void register_handler(const char *id,
|
||||
captions_handler_info &info)
|
||||
{
|
||||
handler_types.emplace(id, info);
|
||||
}
|
||||
|
||||
void main_thread();
|
||||
void start();
|
||||
void stop();
|
||||
|
||||
inline obs_captions() :
|
||||
stop_event(CreateEvent(nullptr, false, false, nullptr)),
|
||||
lang_id(GetUserDefaultUILanguage())
|
||||
{
|
||||
}
|
||||
|
||||
obs_captions();
|
||||
inline ~obs_captions() {stop();}
|
||||
};
|
||||
|
||||
|
|
@ -72,8 +79,6 @@ CaptionsDialog::CaptionsDialog(QWidget *parent) :
|
|||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
lock_guard<recursive_mutex> lock(captions->m);
|
||||
|
||||
auto cb = [this] (obs_source_t *source)
|
||||
{
|
||||
uint32_t caps = obs_source_get_output_flags(source);
|
||||
|
|
@ -97,8 +102,19 @@ CaptionsDialog::CaptionsDialog(QWidget *parent) :
|
|||
return (*static_cast<cb_t*>(data))(source);}, &cb);
|
||||
ui->source->blockSignals(false);
|
||||
|
||||
for (auto &ht : captions->handler_types) {
|
||||
QString name = ht.second.name().c_str();
|
||||
QString id = ht.first.c_str();
|
||||
ui->provider->addItem(name, id);
|
||||
}
|
||||
|
||||
QString qhandler_id = captions->handler_id.c_str();
|
||||
int idx = ui->provider->findData(qhandler_id);
|
||||
if (idx != -1)
|
||||
ui->provider->setCurrentIndex(idx);
|
||||
|
||||
ui->enable->blockSignals(true);
|
||||
ui->enable->setChecked(captions->th.joinable());
|
||||
ui->enable->setChecked(!!captions->handler);
|
||||
ui->enable->blockSignals(false);
|
||||
|
||||
vector<locale_info> locales;
|
||||
|
|
@ -129,13 +145,11 @@ CaptionsDialog::CaptionsDialog(QWidget *parent) :
|
|||
ui->language->setEnabled(false);
|
||||
|
||||
} else if (!set_language) {
|
||||
bool started = captions->th.joinable();
|
||||
bool started = !!captions->handler;
|
||||
if (started)
|
||||
captions->stop();
|
||||
|
||||
captions->m.lock();
|
||||
captions->lang_id = locales[0].id;
|
||||
captions->m.unlock();
|
||||
|
||||
if (started)
|
||||
captions->start();
|
||||
|
|
@ -144,14 +158,12 @@ CaptionsDialog::CaptionsDialog(QWidget *parent) :
|
|||
|
||||
void CaptionsDialog::on_source_currentIndexChanged(int)
|
||||
{
|
||||
bool started = captions->th.joinable();
|
||||
bool started = !!captions->handler;
|
||||
if (started)
|
||||
captions->stop();
|
||||
|
||||
captions->m.lock();
|
||||
captions->source_name = ui->source->currentText().toUtf8().constData();
|
||||
captions->source = GetWeakSourceByName(captions->source_name.c_str());
|
||||
captions->m.unlock();
|
||||
|
||||
if (started)
|
||||
captions->start();
|
||||
|
|
@ -159,21 +171,38 @@ void CaptionsDialog::on_source_currentIndexChanged(int)
|
|||
|
||||
void CaptionsDialog::on_enable_clicked(bool checked)
|
||||
{
|
||||
if (checked)
|
||||
if (checked) {
|
||||
captions->start();
|
||||
else
|
||||
if (!captions->handler) {
|
||||
ui->enable->blockSignals(true);
|
||||
ui->enable->setChecked(false);
|
||||
ui->enable->blockSignals(false);
|
||||
}
|
||||
} else {
|
||||
captions->stop();
|
||||
}
|
||||
}
|
||||
|
||||
void CaptionsDialog::on_language_currentIndexChanged(int)
|
||||
{
|
||||
bool started = captions->th.joinable();
|
||||
bool started = !!captions->handler;
|
||||
if (started)
|
||||
captions->stop();
|
||||
|
||||
captions->m.lock();
|
||||
captions->lang_id = (LANGID)ui->language->currentData().toInt();
|
||||
captions->m.unlock();
|
||||
|
||||
if (started)
|
||||
captions->start();
|
||||
}
|
||||
|
||||
void CaptionsDialog::on_provider_currentIndexChanged(int idx)
|
||||
{
|
||||
bool started = !!captions->handler;
|
||||
if (started)
|
||||
captions->stop();
|
||||
|
||||
captions->handler_id =
|
||||
ui->provider->itemData(idx).toString().toUtf8().constData();
|
||||
|
||||
if (started)
|
||||
captions->start();
|
||||
|
|
@ -181,183 +210,83 @@ void CaptionsDialog::on_language_currentIndexChanged(int)
|
|||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
void obs_captions::main_thread()
|
||||
try {
|
||||
ComPtr<CaptionStream> audio;
|
||||
ComPtr<ISpObjectToken> token;
|
||||
ComPtr<ISpRecoGrammar> grammar;
|
||||
ComPtr<ISpRecognizer> recognizer;
|
||||
ComPtr<ISpRecoContext> context;
|
||||
HRESULT hr;
|
||||
|
||||
auto cb = [&] (const struct audio_data *audio_data,
|
||||
bool muted)
|
||||
{
|
||||
audio->PushAudio(audio_data, muted);
|
||||
};
|
||||
|
||||
using cb_t = decltype(cb);
|
||||
|
||||
auto pre_cb = [] (void *param, obs_source_t*,
|
||||
const struct audio_data *audio_data, bool muted)
|
||||
{
|
||||
return (*static_cast<cb_t*>(param))(audio_data, muted);
|
||||
};
|
||||
|
||||
os_set_thread_name(__FUNCTION__);
|
||||
|
||||
CoInitialize(nullptr);
|
||||
|
||||
wchar_t lang_str[32];
|
||||
_snwprintf(lang_str, 31, L"language=%x", (int)captions->lang_id);
|
||||
|
||||
hr = SpFindBestToken(SPCAT_RECOGNIZERS, lang_str, nullptr, &token);
|
||||
if (FAILED(hr))
|
||||
throw HRError("SpFindBestToken failed", hr);
|
||||
|
||||
hr = CoCreateInstance(CLSID_SpInprocRecognizer, nullptr, CLSCTX_ALL,
|
||||
__uuidof(ISpRecognizer), (void**)&recognizer);
|
||||
if (FAILED(hr))
|
||||
throw HRError("CoCreateInstance for recognizer failed", hr);
|
||||
|
||||
hr = recognizer->SetRecognizer(token);
|
||||
if (FAILED(hr))
|
||||
throw HRError("SetRecognizer failed", hr);
|
||||
|
||||
hr = recognizer->SetRecoState(SPRST_INACTIVE);
|
||||
if (FAILED(hr))
|
||||
throw HRError("SetRecoState(SPRST_INACTIVE) failed", hr);
|
||||
|
||||
hr = recognizer->CreateRecoContext(&context);
|
||||
if (FAILED(hr))
|
||||
throw HRError("CreateRecoContext failed", hr);
|
||||
|
||||
ULONGLONG interest = SPFEI(SPEI_RECOGNITION) |
|
||||
SPFEI(SPEI_END_SR_STREAM);
|
||||
hr = context->SetInterest(interest, interest);
|
||||
if (FAILED(hr))
|
||||
throw HRError("SetInterest failed", hr);
|
||||
|
||||
HANDLE notify;
|
||||
|
||||
hr = context->SetNotifyWin32Event();
|
||||
if (FAILED(hr))
|
||||
throw HRError("SetNotifyWin32Event", hr);
|
||||
|
||||
notify = context->GetNotifyEventHandle();
|
||||
if (notify == INVALID_HANDLE_VALUE)
|
||||
throw HRError("GetNotifyEventHandle failed", E_NOINTERFACE);
|
||||
|
||||
size_t sample_rate = audio_output_get_sample_rate(obs_get_audio());
|
||||
audio = new CaptionStream((DWORD)sample_rate);
|
||||
audio->Release();
|
||||
|
||||
hr = recognizer->SetInput(audio, false);
|
||||
if (FAILED(hr))
|
||||
throw HRError("SetInput failed", hr);
|
||||
|
||||
hr = context->CreateGrammar(1, &grammar);
|
||||
if (FAILED(hr))
|
||||
throw HRError("CreateGrammar failed", hr);
|
||||
|
||||
hr = grammar->LoadDictation(nullptr, SPLO_STATIC);
|
||||
if (FAILED(hr))
|
||||
throw HRError("LoadDictation failed", hr);
|
||||
|
||||
hr = grammar->SetDictationState(SPRS_ACTIVE);
|
||||
if (FAILED(hr))
|
||||
throw HRError("SetDictationState failed", hr);
|
||||
|
||||
hr = recognizer->SetRecoState(SPRST_ACTIVE);
|
||||
if (FAILED(hr))
|
||||
throw HRError("SetRecoState(SPRST_ACTIVE) failed", hr);
|
||||
|
||||
HANDLE events[] = {notify, stop_event};
|
||||
|
||||
{
|
||||
captions->source = GetWeakSourceByName(
|
||||
captions->source_name.c_str());
|
||||
OBSSource strong = OBSGetStrongRef(source);
|
||||
if (strong)
|
||||
obs_source_add_audio_capture_callback(strong,
|
||||
pre_cb, &cb);
|
||||
static void caption_text(const std::string &text)
|
||||
{
|
||||
obs_output *output = obs_frontend_get_streaming_output();
|
||||
if (output) {
|
||||
obs_output_output_caption_text1(output, text.c_str());
|
||||
obs_output_release(output);
|
||||
}
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
DWORD ret = WaitForMultipleObjects(2, events, false, INFINITE);
|
||||
if (ret != WAIT_OBJECT_0)
|
||||
break;
|
||||
|
||||
CSpEvent event;
|
||||
bool exit = false;
|
||||
|
||||
while (event.GetFrom(context) == S_OK) {
|
||||
if (event.eEventId == SPEI_RECOGNITION) {
|
||||
ISpRecoResult *result = event.RecoResult();
|
||||
|
||||
CoTaskMemPtr<wchar_t> text;
|
||||
hr = result->GetText((ULONG)-1, (ULONG)-1,
|
||||
true, &text, nullptr);
|
||||
if (FAILED(hr))
|
||||
continue;
|
||||
|
||||
char text_utf8[512];
|
||||
os_wcs_to_utf8(text, 0, text_utf8, 512);
|
||||
|
||||
obs_output_t *output =
|
||||
obs_frontend_get_streaming_output();
|
||||
if (output)
|
||||
obs_output_output_caption_text1(output,
|
||||
text_utf8);
|
||||
|
||||
debug("\"%s\"", text_utf8);
|
||||
|
||||
obs_output_release(output);
|
||||
|
||||
} else if (event.eEventId == SPEI_END_SR_STREAM) {
|
||||
exit = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (exit)
|
||||
break;
|
||||
}
|
||||
|
||||
{
|
||||
OBSSource strong = OBSGetStrongRef(source);
|
||||
if (strong)
|
||||
obs_source_remove_audio_capture_callback(strong,
|
||||
pre_cb, &cb);
|
||||
}
|
||||
|
||||
audio->Stop();
|
||||
|
||||
CoUninitialize();
|
||||
|
||||
} catch (HRError err) {
|
||||
error("%s failed: %s (%lX)", __FUNCTION__, err.str, err.hr);
|
||||
CoUninitialize();
|
||||
captions->th.detach();
|
||||
static void audio_capture(void*, obs_source_t*,
|
||||
const struct audio_data *audio, bool)
|
||||
{
|
||||
captions->handler->push_audio(audio);
|
||||
}
|
||||
|
||||
void obs_captions::start()
|
||||
{
|
||||
if (!captions->th.joinable()) {
|
||||
ResetEvent(captions->stop_event);
|
||||
if (!captions->handler && valid_lang(lang_id)) {
|
||||
wchar_t wname[256];
|
||||
|
||||
if (valid_lang(captions->lang_id))
|
||||
captions->th = thread([] () {captions->main_thread();});
|
||||
auto pair = handler_types.find(handler_id);
|
||||
if (pair == handler_types.end()) {
|
||||
warn("Failed to find handler '%s'",
|
||||
handler_id.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!LCIDToLocaleName(lang_id, wname, 256, 0)) {
|
||||
warn("Failed to get locale name: %d",
|
||||
(int)GetLastError());
|
||||
return;
|
||||
}
|
||||
|
||||
size_t len = (size_t)wcslen(wname);
|
||||
|
||||
string lang_name;
|
||||
lang_name.resize(len);
|
||||
|
||||
for (size_t i = 0; i < len; i++)
|
||||
lang_name[i] = (char)wname[i];
|
||||
|
||||
OBSSource s = OBSGetStrongRef(source);
|
||||
if (!s) {
|
||||
warn("Source invalid");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
captions_handler *h = pair->second.create(caption_text,
|
||||
lang_name);
|
||||
handler.reset(h);
|
||||
|
||||
OBSSource s = OBSGetStrongRef(source);
|
||||
obs_source_add_audio_capture_callback(s,
|
||||
audio_capture, nullptr);
|
||||
|
||||
} catch (std::string text) {
|
||||
QWidget *window =
|
||||
(QWidget*)obs_frontend_get_main_window();
|
||||
|
||||
warn("Failed to create handler: %s", text.c_str());
|
||||
|
||||
QMessageBox::warning(window,
|
||||
obs_module_text("Captions.Error.GenericFail"),
|
||||
text.c_str());
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void obs_captions::stop()
|
||||
{
|
||||
if (!captions->th.joinable())
|
||||
return;
|
||||
|
||||
SetEvent(captions->stop_event);
|
||||
captions->th.join();
|
||||
OBSSource s = OBSGetStrongRef(source);
|
||||
if (s)
|
||||
obs_source_remove_audio_capture_callback(s,
|
||||
audio_capture, nullptr);
|
||||
handler.reset();
|
||||
}
|
||||
|
||||
static bool get_locale_name(LANGID id, char *out)
|
||||
|
|
@ -455,6 +384,15 @@ static void get_valid_locale_names(vector<locale_info> &locales)
|
|||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
extern captions_handler_info mssapi_info;
|
||||
|
||||
obs_captions::obs_captions()
|
||||
{
|
||||
register_handler("mssapi", mssapi_info);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
extern "C" void FreeCaptions()
|
||||
{
|
||||
delete captions;
|
||||
|
|
@ -470,37 +408,36 @@ static void obs_event(enum obs_frontend_event event, void *)
|
|||
static void save_caption_data(obs_data_t *save_data, bool saving, void*)
|
||||
{
|
||||
if (saving) {
|
||||
lock_guard<recursive_mutex> lock(captions->m);
|
||||
obs_data_t *obj = obs_data_create();
|
||||
|
||||
obs_data_set_string(obj, "source",
|
||||
captions->source_name.c_str());
|
||||
obs_data_set_bool(obj, "enabled", captions->th.joinable());
|
||||
obs_data_set_bool(obj, "enabled", !!captions->handler);
|
||||
obs_data_set_int(obj, "lang_id", captions->lang_id);
|
||||
obs_data_set_string(obj, "provider",
|
||||
captions->handler_id.c_str());
|
||||
|
||||
obs_data_set_obj(save_data, "captions", obj);
|
||||
obs_data_release(obj);
|
||||
} else {
|
||||
captions->stop();
|
||||
|
||||
captions->m.lock();
|
||||
|
||||
obs_data_t *obj = obs_data_get_obj(save_data, "captions");
|
||||
if (!obj)
|
||||
obj = obs_data_create();
|
||||
|
||||
obs_data_set_default_int(obj, "lang_id",
|
||||
GetUserDefaultUILanguage());
|
||||
obs_data_set_default_string(obj, "provider", DEFAULT_HANDLER);
|
||||
|
||||
bool enabled = obs_data_get_bool(obj, "enabled");
|
||||
captions->source_name = obs_data_get_string(obj, "source");
|
||||
captions->lang_id = (int)obs_data_get_int(obj, "lang_id");
|
||||
captions->handler_id = obs_data_get_string(obj, "provider");
|
||||
captions->source = GetWeakSourceByName(
|
||||
captions->source_name.c_str());
|
||||
obs_data_release(obj);
|
||||
|
||||
captions->m.unlock();
|
||||
|
||||
if (enabled)
|
||||
captions->start();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,4 +17,5 @@ public slots:
|
|||
void on_source_currentIndexChanged(int idx);
|
||||
void on_enable_clicked(bool checked);
|
||||
void on_language_currentIndexChanged(int idx);
|
||||
void on_provider_currentIndexChanged(int idx);
|
||||
};
|
||||
|
|
|
|||
13
UI/frontend-plugins/frontend-tools/data/locale/bn-BD.ini
Normal file
13
UI/frontend-plugins/frontend-tools/data/locale/bn-BD.ini
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
SceneSwitcher="স্বয়ংক্রিয় দৃশ্য পরিবর্তক"
|
||||
SceneSwitcher.OnNoMatch.SwitchTo="পরিবর্তন করুন:"
|
||||
SceneSwitcher.CheckInterval="সক্রিয় উইন্ডো শিরোনাম চেক করুন প্রতি:"
|
||||
InvalidRegex.Text="এক্সপ্রেশন প্রবেশ করিয়েছেন তা অবৈধ।."
|
||||
Active="সক্রিয়"
|
||||
Inactive="নিষ্ক্রিয়"
|
||||
|
||||
Captions.AudioSource="অডিও উৎস"
|
||||
Captions.CurrentSystemLanguage="বর্তমান সিস্টেমের ভাষা (%1)"
|
||||
|
||||
OutputTimer="আউটপুট টাইমার"
|
||||
OutputTimer.Stream="এর পরে বন্ধ।:"
|
||||
|
||||
|
|
@ -14,6 +14,8 @@ Stop="Atura"
|
|||
Captions="Subtítols (Experimental)"
|
||||
Captions.AudioSource="Font d'àudio"
|
||||
Captions.CurrentSystemLanguage="Idioma actual del sistema (%1)"
|
||||
Captions.Provider="Proveïdor"
|
||||
Captions.Error.GenericFail="No s'ha pogut iniciar els subtítols"
|
||||
|
||||
OutputTimer="Temporitzador de sortida"
|
||||
OutputTimer.Stream="Atura la transmissió després de:"
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ Stop="Zastavit"
|
|||
Captions="Titulky (experiment.)"
|
||||
Captions.AudioSource="Zdroj zvuku"
|
||||
Captions.CurrentSystemLanguage="Aktuální systémový jazyk (%1)"
|
||||
Captions.Provider="Zprostředkovatel"
|
||||
Captions.Error.GenericFail="Nezdařilo se spuštění titulků"
|
||||
|
||||
OutputTimer="Časovač"
|
||||
OutputTimer.Stream="Přestat vysílat po:"
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ Stop="Stop"
|
|||
Captions="Undertekster (eksperimentel)"
|
||||
Captions.AudioSource="Lydkilde"
|
||||
Captions.CurrentSystemLanguage="Aktuelt systemsprog (%1)"
|
||||
Captions.Provider="Leverandør"
|
||||
Captions.Error.GenericFail="Kunne ikke starte tekster"
|
||||
|
||||
OutputTimer="Output-timer"
|
||||
OutputTimer.Stream="Stands streaming efter:"
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ Stop="Stop"
|
|||
Captions="Untertitel (experimentell)"
|
||||
Captions.AudioSource="Audioquelle"
|
||||
Captions.CurrentSystemLanguage="Aktuelle Systemsprache (%1)"
|
||||
Captions.Provider="Service"
|
||||
Captions.Error.GenericFail="Fehler beim Starten der Untertitel"
|
||||
|
||||
OutputTimer="Ausgabetimer"
|
||||
OutputTimer.Stream="Stoppe Stream nach:"
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ Stop="Stop"
|
|||
Captions="Captions (Experimental)"
|
||||
Captions.AudioSource="Audio source"
|
||||
Captions.CurrentSystemLanguage="Current System Language (%1)"
|
||||
Captions.Provider="Provider"
|
||||
Captions.Error.GenericFail="Failed to start captions"
|
||||
|
||||
OutputTimer="Output Timer"
|
||||
OutputTimer.Stream="Stop streaming after:"
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ Stop="Detener"
|
|||
Captions="Subtítulos (Experimental)"
|
||||
Captions.AudioSource="Fuente de audio"
|
||||
Captions.CurrentSystemLanguage="Idioma actual del sistema (%1)"
|
||||
Captions.Provider="Proveedor"
|
||||
Captions.Error.GenericFail="Fallo al iniciar los subtítulos"
|
||||
|
||||
OutputTimer="Temporizador de salida"
|
||||
OutputTimer.Stream="Detener la transmisión después de:"
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ SceneSwitcher.OnNoMatch.DontSwitch="Ära vaheta"
|
|||
SceneSwitcher.OnNoMatch.SwitchTo="Lülitu ümber:"
|
||||
SceneSwitcher.CheckInterval="Kontrollige aktiivse akna pealkiri iga:"
|
||||
SceneSwitcher.ActiveOrNotActive="Stseen vahetaja on:"
|
||||
InvalidRegex.Title="Kehtetu regulaaravaldis"
|
||||
InvalidRegex.Text="Sisestatud regulaaravaldis on kehtetu."
|
||||
Active="Aktiivne"
|
||||
Inactive="Inaktiivne"
|
||||
Start="Alusta"
|
||||
|
|
@ -18,4 +20,6 @@ OutputTimer.Stream="Lõpeta voogedastus pärast:"
|
|||
OutputTimer.Record="Lõpeta voogedastus pärast:"
|
||||
OutputTimer.Stream.StoppingIn="Voogedastus lõppeb:"
|
||||
OutputTimer.Record.StoppingIn="Salvestamine lõppeb:"
|
||||
OutputTimer.Stream.EnableEverytime="Lülita voogedastuse taimer alati sisse"
|
||||
OutputTimer.Record.EnableEverytime="Lülita salvestus taimer alati sisse"
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ Stop="Gelditu"
|
|||
Captions="Epigrafeak (esperimentala)"
|
||||
Captions.AudioSource="Audio-iturburua"
|
||||
Captions.CurrentSystemLanguage="Sistemaren hizkuntza (%1)"
|
||||
Captions.Provider="Hornitzailea"
|
||||
Captions.Error.GenericFail="Huts egin du grabazioak"
|
||||
|
||||
OutputTimer="Irteera tenporizadorea"
|
||||
OutputTimer.Stream="Gelditu transmisioa hau pasata:"
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ Stop="Pysäytä"
|
|||
Captions="Kuvatekstit (Experimental)"
|
||||
Captions.AudioSource="Äänilähde"
|
||||
Captions.CurrentSystemLanguage="Järjestelmän kieli (%1)"
|
||||
Captions.Provider="Tarjoaja"
|
||||
Captions.Error.GenericFail="Kuvatekstityksen aloittaminen epäonnistui"
|
||||
|
||||
OutputTimer="Ulostulo-ajastin"
|
||||
OutputTimer.Stream="Pysäyttää lähetyksen:"
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ SceneSwitcher="Sélecteur automatique de scène"
|
|||
SceneSwitcher.OnNoMatch="Si aucune fenêtre ne correspond :"
|
||||
SceneSwitcher.OnNoMatch.DontSwitch="Ne rien faire"
|
||||
SceneSwitcher.OnNoMatch.SwitchTo="Basculer vers :"
|
||||
SceneSwitcher.CheckInterval="Détecter le titre de la fenêtre active toutes les :"
|
||||
SceneSwitcher.CheckInterval="Vérifier le titre de la fenêtre active toutes les :"
|
||||
SceneSwitcher.ActiveOrNotActive="Etat du sélecteur automatique :"
|
||||
InvalidRegex.Title="Expression invalide"
|
||||
InvalidRegex.Text="L'expression régulière saisie est invalide."
|
||||
|
|
@ -14,6 +14,8 @@ Stop="Arrêter"
|
|||
Captions="Sous-titres (expérimental)"
|
||||
Captions.AudioSource="Source audio"
|
||||
Captions.CurrentSystemLanguage="Langue du système (%1)"
|
||||
Captions.Provider="Sous-Titres"
|
||||
Captions.Error.GenericFail="Impossible de démarrer les sous-titres"
|
||||
|
||||
OutputTimer="Minuterie des sorties"
|
||||
OutputTimer.Stream="Arrêter le streaming dans :"
|
||||
|
|
|
|||
25
UI/frontend-plugins/frontend-tools/data/locale/he-IL.ini
Normal file
25
UI/frontend-plugins/frontend-tools/data/locale/he-IL.ini
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
SceneSwitcher.OnNoMatch="כאשר אין חלון מתאים:"
|
||||
SceneSwitcher.OnNoMatch.DontSwitch="אל תעבור"
|
||||
SceneSwitcher.OnNoMatch.SwitchTo="עבור ל:"
|
||||
SceneSwitcher.CheckInterval="בדוק כותרת חלון פעיל בכל:"
|
||||
InvalidRegex.Title="ביטוי רגולרי לא חוקי"
|
||||
InvalidRegex.Text="הביטוי הרגולרי שהזנת אינו חוקי."
|
||||
Active="פעיל"
|
||||
Inactive="לא פעיל"
|
||||
Start="התחל"
|
||||
Stop="עצור"
|
||||
|
||||
Captions="כיתובים (ניסיוני)"
|
||||
Captions.AudioSource="מקור שמע"
|
||||
Captions.CurrentSystemLanguage="שפת המערכת הנוכחי (%1)"
|
||||
Captions.Provider="ספק"
|
||||
Captions.Error.GenericFail="נכשלה הפעלת כיתובים"
|
||||
|
||||
OutputTimer="פלט טיימר"
|
||||
OutputTimer.Stream="הפסק הזרמה לאחר:"
|
||||
OutputTimer.Record="עצור את הקלטה לאחר:"
|
||||
OutputTimer.Stream.StoppingIn="הזרמה עוצרת ב:"
|
||||
OutputTimer.Record.StoppingIn="הקלטה עוצרת ב:"
|
||||
OutputTimer.Stream.EnableEverytime="הפעל טיימר הזרמה כל פעם"
|
||||
OutputTimer.Record.EnableEverytime="הפעל טיימר הקלטה כל פעם"
|
||||
|
||||
|
|
@ -14,6 +14,8 @@ Stop="Stop"
|
|||
Captions="Feliratok (Kísérleti)"
|
||||
Captions.AudioSource="Audio forrás"
|
||||
Captions.CurrentSystemLanguage="Rendszer aktuális nyelve (%1)"
|
||||
Captions.Provider="Szolgáltató"
|
||||
Captions.Error.GenericFail="Felirat indítása sikertelen"
|
||||
|
||||
OutputTimer="Kimeneti időzítő"
|
||||
OutputTimer.Stream="Stream leállítása:"
|
||||
|
|
|
|||
|
|
@ -11,9 +11,11 @@ Inactive="非アクティブ"
|
|||
Start="開始"
|
||||
Stop="停止"
|
||||
|
||||
Captions="見出し (実験的)"
|
||||
Captions="字幕 (実験的)"
|
||||
Captions.AudioSource="音声ソース"
|
||||
Captions.CurrentSystemLanguage="現在のシステム言語 (%1)"
|
||||
Captions.Provider="プロバイダ"
|
||||
Captions.Error.GenericFail="字幕の開始に失敗しました"
|
||||
|
||||
OutputTimer="出力タイマー"
|
||||
OutputTimer.Stream="配信停止の時間設定:"
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ Stop="중단"
|
|||
Captions="자막 (실험적 기능)"
|
||||
Captions.AudioSource="오디오 소스"
|
||||
Captions.CurrentSystemLanguage="현재 시스템 언어 (%1)"
|
||||
Captions.Provider="공급자"
|
||||
Captions.Error.GenericFail="자막을 시작하지 못했습니다"
|
||||
|
||||
OutputTimer="출력 시간 설정"
|
||||
OutputTimer.Stream="이 시간 이후 방송 중단:"
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ Stop="Stop"
|
|||
Captions="Ondertiteling (Experimenteel)"
|
||||
Captions.AudioSource="Audiobron"
|
||||
Captions.CurrentSystemLanguage="Huidige Systeemtaal (%1)"
|
||||
Captions.Provider="Provider"
|
||||
Captions.Error.GenericFail="Kon de ondertitelingen niet starten"
|
||||
|
||||
OutputTimer="Uitvoertimer"
|
||||
OutputTimer.Stream="Stop met streamen na:"
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ Stop="Stop"
|
|||
Captions="Podpisy (eksperymentalne)"
|
||||
Captions.AudioSource="Źródła dźwięku"
|
||||
Captions.CurrentSystemLanguage="Obecny język systemu (%1)"
|
||||
Captions.Provider="Silnik"
|
||||
Captions.Error.GenericFail="Uruchomienie napisów nie powiodło się"
|
||||
|
||||
OutputTimer="Wyłącznik czasowy"
|
||||
OutputTimer.Stream="Zatrzymaj stream po:"
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ Stop="Parar"
|
|||
Captions="Legendas (Experimental)"
|
||||
Captions.AudioSource="Fonte de Áudio"
|
||||
Captions.CurrentSystemLanguage="Idioma Atual do Sistema (%1)"
|
||||
Captions.Provider="Provedor"
|
||||
Captions.Error.GenericFail="Falha ao iniciar legendas"
|
||||
|
||||
OutputTimer="Temporizador de saída"
|
||||
OutputTimer.Stream="Parar a transmissão após:"
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ Stop="Остановить"
|
|||
Captions="Субтитры (экспериментально)"
|
||||
Captions.AudioSource="Источник звука"
|
||||
Captions.CurrentSystemLanguage="Текущий язык системы (%1)"
|
||||
Captions.Provider="Поставщик"
|
||||
Captions.Error.GenericFail="Не удалось запустить субтитры"
|
||||
|
||||
OutputTimer="Таймер записи и стрима"
|
||||
OutputTimer.Stream="Завершить стрим через:"
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ Stop="Stoppa"
|
|||
Captions="Undertexter (experimentell)"
|
||||
Captions.AudioSource="Ljudkälla"
|
||||
Captions.CurrentSystemLanguage="Aktuellt systemspråk (%1)"
|
||||
Captions.Provider="Tillhandahållare"
|
||||
Captions.Error.GenericFail="Det gick inte att starta undertexter"
|
||||
|
||||
OutputTimer="Utdatatimer"
|
||||
OutputTimer.Stream="Sluta streama efter:"
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ Stop="Durdur"
|
|||
Captions="Altyazı (Deneysel)"
|
||||
Captions.AudioSource="Ses kaynağı"
|
||||
Captions.CurrentSystemLanguage="Geçerli Sistem Dili (%1)"
|
||||
Captions.Provider="Sağlayıcı"
|
||||
Captions.Error.GenericFail="Altyazı başlatılamadı"
|
||||
|
||||
OutputTimer="Çıkış Zamanlayıcısı"
|
||||
OutputTimer.Stream="Şuradan sonra yayını durdur:"
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ Stop="Зупинити"
|
|||
Captions="Субтитри (експериментально)"
|
||||
Captions.AudioSource="Джерело Аудіо"
|
||||
Captions.CurrentSystemLanguage="Поточна мова Системи (%1)"
|
||||
Captions.Provider="Постачальник"
|
||||
Captions.Error.GenericFail="Не вдалося запустити субтитри"
|
||||
|
||||
OutputTimer="Таймер для Виводу"
|
||||
OutputTimer.Stream="Закінчити трансляцію за:"
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ Stop="停止"
|
|||
Captions="标题(实验)"
|
||||
Captions.AudioSource="音频源"
|
||||
Captions.CurrentSystemLanguage="当前系统语言 (%1)"
|
||||
Captions.Provider="供应商"
|
||||
Captions.Error.GenericFail="启动捕获失败"
|
||||
|
||||
OutputTimer="输出计时器"
|
||||
OutputTimer.Stream="停止流处理后:"
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ Stop="停止"
|
|||
Captions="標題 (實驗)"
|
||||
Captions.AudioSource="音訊源"
|
||||
Captions.CurrentSystemLanguage="目前系統語言 (%1)"
|
||||
Captions.Provider="提供程式"
|
||||
Captions.Error.GenericFail="啟動標題失敗"
|
||||
|
||||
OutputTimer="輸出計時器"
|
||||
OutputTimer.Stream="在下面時間後停止串流:"
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>519</width>
|
||||
<height>140</height>
|
||||
<height>152</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
|
@ -56,6 +56,20 @@
|
|||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="language"/>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QComboBox" name="provider">
|
||||
<property name="insertPolicy">
|
||||
<enum>QComboBox::InsertAlphabetically</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Captions.Provider</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
|
|
|
|||
|
|
@ -201,6 +201,13 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="8">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Close</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources />
|
||||
|
|
|
|||
|
|
@ -4,10 +4,8 @@
|
|||
OBS_DECLARE_MODULE()
|
||||
OBS_MODULE_USE_DEFAULT_LOCALE("frontend-tools", "en-US")
|
||||
|
||||
#if defined(_WIN32) || defined(__APPLE__)
|
||||
void InitSceneSwitcher();
|
||||
void FreeSceneSwitcher();
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) && BUILD_CAPTIONS
|
||||
void InitCaptions();
|
||||
|
|
@ -19,23 +17,19 @@ void FreeOutputTimer();
|
|||
|
||||
bool obs_module_load(void)
|
||||
{
|
||||
#if defined(_WIN32) || defined(__APPLE__)
|
||||
InitSceneSwitcher();
|
||||
#endif
|
||||
#if defined(_WIN32) && BUILD_CAPTIONS
|
||||
InitCaptions();
|
||||
#endif
|
||||
InitSceneSwitcher();
|
||||
InitOutputTimer();
|
||||
return true;
|
||||
}
|
||||
|
||||
void obs_module_unload(void)
|
||||
{
|
||||
#if defined(_WIN32) || defined(__APPLE__)
|
||||
FreeSceneSwitcher();
|
||||
#endif
|
||||
#if defined(_WIN32) && BUILD_CAPTIONS
|
||||
FreeCaptions();
|
||||
#endif
|
||||
FreeSceneSwitcher();
|
||||
FreeOutputTimer();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ OutputTimer::OutputTimer(QWidget *parent)
|
|||
SLOT(StreamingTimerButton()));
|
||||
QObject::connect(ui->outputTimerRecord, SIGNAL(clicked()), this,
|
||||
SLOT(RecordingTimerButton()));
|
||||
QObject::connect(ui->buttonBox->button(QDialogButtonBox::Close),
|
||||
SIGNAL(clicked()), this, SLOT(hide()));
|
||||
|
||||
streamingTimer = new QTimer(this);
|
||||
streamingTimerDisplay = new QTimer(this);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue