mirror of
https://github.com/Aitum/obs-aitum-multistream.git
synced 2024-11-24 03:12:42 +01:00
Support OBS 31 obs_frontend_get_user_config
This commit is contained in:
parent
0c35bb340a
commit
c0b501c81a
@ -146,6 +146,33 @@ void showVerticalWarning(QVBoxLayout *verticalLayout)
|
|||||||
verticalLayout->addWidget(verticalWarning);
|
verticalLayout->addWidget(verticalWarning);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static config_t *(*get_user_config_func)(void) = nullptr;
|
||||||
|
|
||||||
|
config_t *get_user_config(void)
|
||||||
|
{
|
||||||
|
#if LIBOBS_API_VER < MAKE_SEMANTIC_VERSION(31, 0, 0)
|
||||||
|
if (!get_user_config_func) {
|
||||||
|
if (obs_get_version() < MAKE_SEMANTIC_VERSION(31, 0, 0)) {
|
||||||
|
get_user_config_func = obs_frontend_get_global_config;
|
||||||
|
blog(LOG_INFO, "[Aitum Multistream] use global config");
|
||||||
|
} else {
|
||||||
|
auto handle = os_dlopen("obs-frontend-api");
|
||||||
|
if (handle) {
|
||||||
|
get_user_config_func = (config_t * (*)(void)) os_dlsym(handle, "obs_frontend_get_user_config");
|
||||||
|
os_dlclose(handle);
|
||||||
|
if (get_user_config_func)
|
||||||
|
blog(LOG_INFO, "[Aitum Multistream] use user config");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (get_user_config_func)
|
||||||
|
return get_user_config_func();
|
||||||
|
return obs_frontend_get_global_config();
|
||||||
|
#else
|
||||||
|
return obs_frontend_get_user_config();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
MultistreamDock::MultistreamDock(QWidget *parent) : QFrame(parent)
|
MultistreamDock::MultistreamDock(QWidget *parent) : QFrame(parent)
|
||||||
{
|
{
|
||||||
// Main layout
|
// Main layout
|
||||||
@ -210,10 +237,10 @@ MultistreamDock::MultistreamDock(QWidget *parent) : QFrame(parent)
|
|||||||
outputButtonStyle(mainStreamButton);
|
outputButtonStyle(mainStreamButton);
|
||||||
|
|
||||||
connect(mainStreamButton, &QPushButton::clicked, [this] {
|
connect(mainStreamButton, &QPushButton::clicked, [this] {
|
||||||
|
const auto config = get_user_config();
|
||||||
if (obs_frontend_streaming_active()) {
|
if (obs_frontend_streaming_active()) {
|
||||||
bool stop = true;
|
bool stop = true;
|
||||||
bool warnBeforeStreamStop =
|
bool warnBeforeStreamStop = config_get_bool(config, "BasicWindow", "WarnBeforeStoppingStream");
|
||||||
config_get_bool(obs_frontend_get_global_config(), "BasicWindow", "WarnBeforeStoppingStream");
|
|
||||||
if (warnBeforeStreamStop && isVisible()) {
|
if (warnBeforeStreamStop && isVisible()) {
|
||||||
auto button = QMessageBox::question(
|
auto button = QMessageBox::question(
|
||||||
this, QString::fromUtf8(obs_frontend_get_locale_string("ConfirmStop.Title")),
|
this, QString::fromUtf8(obs_frontend_get_locale_string("ConfirmStop.Title")),
|
||||||
@ -229,8 +256,7 @@ MultistreamDock::MultistreamDock(QWidget *parent) : QFrame(parent)
|
|||||||
mainStreamButton->setChecked(true);
|
mainStreamButton->setChecked(true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
bool warnBeforeStreamStart =
|
bool warnBeforeStreamStart = config_get_bool(config, "BasicWindow", "WarnBeforeStartingStream");
|
||||||
config_get_bool(obs_frontend_get_global_config(), "BasicWindow", "WarnBeforeStartingStream");
|
|
||||||
if (warnBeforeStreamStart && isVisible()) {
|
if (warnBeforeStreamStart && isVisible()) {
|
||||||
auto button = QMessageBox::question(
|
auto button = QMessageBox::question(
|
||||||
this, QString::fromUtf8(obs_frontend_get_locale_string("ConfirmStart.Title")),
|
this, QString::fromUtf8(obs_frontend_get_locale_string("ConfirmStart.Title")),
|
||||||
@ -630,10 +656,10 @@ void MultistreamDock::LoadOutput(obs_data_t *output_data, bool vertical)
|
|||||||
struct calldata cd;
|
struct calldata cd;
|
||||||
calldata_init(&cd);
|
calldata_init(&cd);
|
||||||
calldata_set_string(&cd, "name", output_name.c_str());
|
calldata_set_string(&cd, "name", output_name.c_str());
|
||||||
|
auto config = get_user_config();
|
||||||
if (streamButton->isChecked()) {
|
if (streamButton->isChecked()) {
|
||||||
bool start = true;
|
bool start = true;
|
||||||
bool warnBeforeStreamStart = config_get_bool(obs_frontend_get_global_config(), "BasicWindow",
|
bool warnBeforeStreamStart = config_get_bool(config, "BasicWindow", "WarnBeforeStartingStream");
|
||||||
"WarnBeforeStartingStream");
|
|
||||||
if (warnBeforeStreamStart && isVisible()) {
|
if (warnBeforeStreamStart && isVisible()) {
|
||||||
auto button = QMessageBox::question(
|
auto button = QMessageBox::question(
|
||||||
this, QString::fromUtf8(obs_frontend_get_locale_string("ConfirmStart.Title")),
|
this, QString::fromUtf8(obs_frontend_get_locale_string("ConfirmStart.Title")),
|
||||||
@ -646,8 +672,7 @@ void MultistreamDock::LoadOutput(obs_data_t *output_data, bool vertical)
|
|||||||
streamButton->setChecked(false);
|
streamButton->setChecked(false);
|
||||||
} else {
|
} else {
|
||||||
bool stop = true;
|
bool stop = true;
|
||||||
bool warnBeforeStreamStop = config_get_bool(obs_frontend_get_global_config(), "BasicWindow",
|
bool warnBeforeStreamStop = config_get_bool(config, "BasicWindow", "WarnBeforeStoppingStream");
|
||||||
"WarnBeforeStoppingStream");
|
|
||||||
if (warnBeforeStreamStop && isVisible()) {
|
if (warnBeforeStreamStop && isVisible()) {
|
||||||
auto button = QMessageBox::question(
|
auto button = QMessageBox::question(
|
||||||
this, QString::fromUtf8(obs_frontend_get_locale_string("ConfirmStop.Title")),
|
this, QString::fromUtf8(obs_frontend_get_locale_string("ConfirmStop.Title")),
|
||||||
@ -675,8 +700,7 @@ void MultistreamDock::LoadOutput(obs_data_t *output_data, bool vertical)
|
|||||||
streamButton->setChecked(false);
|
streamButton->setChecked(false);
|
||||||
} else {
|
} else {
|
||||||
bool stop = true;
|
bool stop = true;
|
||||||
bool warnBeforeStreamStop = config_get_bool(obs_frontend_get_global_config(), "BasicWindow",
|
bool warnBeforeStreamStop = config_get_bool(get_user_config(), "BasicWindow", "WarnBeforeStoppingStream");
|
||||||
"WarnBeforeStoppingStream");
|
|
||||||
if (warnBeforeStreamStop && isVisible()) {
|
if (warnBeforeStreamStop && isVisible()) {
|
||||||
auto button = QMessageBox::question(
|
auto button = QMessageBox::question(
|
||||||
this, QString::fromUtf8(obs_frontend_get_locale_string("ConfirmStop.Title")),
|
this, QString::fromUtf8(obs_frontend_get_locale_string("ConfirmStop.Title")),
|
||||||
@ -797,7 +821,7 @@ bool MultistreamDock::StartOutput(obs_data_t *settings, QPushButton *streamButto
|
|||||||
if (!settings)
|
if (!settings)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
bool warnBeforeStreamStart = config_get_bool(obs_frontend_get_global_config(), "BasicWindow", "WarnBeforeStartingStream");
|
bool warnBeforeStreamStart = config_get_bool(get_user_config(), "BasicWindow", "WarnBeforeStartingStream");
|
||||||
if (warnBeforeStreamStart && isVisible()) {
|
if (warnBeforeStreamStart && isVisible()) {
|
||||||
auto button = QMessageBox::question(this, QString::fromUtf8(obs_frontend_get_locale_string("ConfirmStart.Title")),
|
auto button = QMessageBox::question(this, QString::fromUtf8(obs_frontend_get_locale_string("ConfirmStart.Title")),
|
||||||
QString::fromUtf8(obs_frontend_get_locale_string("ConfirmStart.Text")),
|
QString::fromUtf8(obs_frontend_get_locale_string("ConfirmStart.Text")),
|
||||||
|
Loading…
Reference in New Issue
Block a user