Skip to content

Commit

Permalink
Merge pull request #46 from OPENSPHERE-Inc/patch-0.9.18
Browse files Browse the repository at this point in the history
0.9.18
  • Loading branch information
hanatyan128 authored Dec 15, 2024
2 parents a06a862 + af434fc commit 61fe69f
Show file tree
Hide file tree
Showing 16 changed files with 169 additions and 1 deletion.
2 changes: 1 addition & 1 deletion buildspec.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
},
"name": "osi-branch-output",
"displayName": "Branch Output Plugin",
"version": "0.9.17",
"version": "0.9.18",
"author": "OPENSPHERE Inc.",
"website": "https://opensphere.co.jp/",
"email": "[email protected]",
Expand Down
4 changes: 4 additions & 0 deletions data/locale/ca-ES.ini
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,7 @@ DownscaleFilter.Bilinear="Bilineal (més ràpida, però borrós si s'escala)"
DownscaleFilter.Bicubic="Bicubic (escalat accentuat, 16 mostres)"
DownscaleFilter.Lanczos="Lanczos (escalat accentuat, 36 mostres)"
DownscaleFilter.Area="Àrea (suma ponderada, 4/6/9 mostres)"
EnableAllHotkey="Activa totes les sortides de la branca"
DisableAllHotkey="Desactiva totes les sortides de la branca"
EnableHotkey="Activa '%1'"
DisableHotkey="Desactiva '%1'"
4 changes: 4 additions & 0 deletions data/locale/de-DE.ini
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,7 @@ DownscaleFilter.Bilinear="Bilinear (am schnellsten, bei Skalierung aber unscharf
DownscaleFilter.Bicubic="Bikubisch (geschärfte Skalierung, 16 Stichproben)"
DownscaleFilter.Lanczos="Lanczos (geschärfte Skalierung, 36 Stichproben)"
DownscaleFilter.Area="Bereich (gewichtete Summe, 4/6/9 Stichproben)"
EnableAllHotkey="Aktivieren Sie alle Zweigausgänge"
DisableAllHotkey="Deaktivieren Sie alle Zweigausgänge"
EnableHotkey="Aktivieren Sie '%1'"
DisableHotkey="Deaktivieren Sie '%1'"
4 changes: 4 additions & 0 deletions data/locale/en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,7 @@ DownscaleFilter.Bilinear="Bilinear (Fastest, but blurry if scaling)"
DownscaleFilter.Bicubic="Bicubic (Sharpened scaling, 16 samples)"
DownscaleFilter.Lanczos="Lanczos (Sharpened scaling, 36 samples)"
DownscaleFilter.Area="Area (Weighted sum, 4/6/9 samples)"
EnableAllHotkey="Enable All Branch Outputs"
DisableAllHotkey="Disable All Branch Outputs"
EnableHotkey="Enable '%1'"
DisableHotkey="Disable '%1'"
4 changes: 4 additions & 0 deletions data/locale/fr-FR.ini
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,7 @@ DownscaleFilter.Bilinear="Bilinéaire (le plus rapide, mais flou en cas de mise
DownscaleFilter.Bicubic="Bicubique (mise à l'échelle avec netteté accentuée, 16 échantillons)"
DownscaleFilter.Lanczos="Lanczos (mise à l'échelle avec netteté accentuée, 36 échantillons)"
DownscaleFilter.Area="Zone (somme pondérée, 4/6/9 échantillons)"
EnableAllHotkey="Activer toutes les sorties de branche"
DisableAllHotkey="Désactiver toutes les sorties de branche"
EnableHotkey="Activer '%1'"
DisableHotkey="Désactiver '%1'"
4 changes: 4 additions & 0 deletions data/locale/ja-JP.ini
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,7 @@ DownscaleFilter.Bilinear="バイリニア (最速だが、スケーリングす
DownscaleFilter.Bicubic="バイキュービック (先鋭化スケーリング、16サンプル)"
DownscaleFilter.Lanczos="ランチョス (先鋭化スケーリング、36サンプル)"
DownscaleFilter.Area="エリア (加重合計、4/6/9サンプル)"
EnableAllHotkey="全ての Branch Outputs を有効化"
DisableAllHotkey="全ての Branch Outputs を無効化"
EnableHotkey="'%1' を有効化"
DisableHotkey="'%1' を無効化"
4 changes: 4 additions & 0 deletions data/locale/ko-KR.ini
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,7 @@ DownscaleFilter.Bilinear="이중선형 (빠름, 크기가 바뀌면 흐려짐)"
DownscaleFilter.Bicubic="바이큐빅 (조금 더 날카롭게 처리, 16 샘플)"
DownscaleFilter.Lanczos="란초스 (조금 더 날카롭게 처리, 36 샘플)"
DownscaleFilter.Area="영역 (가중치 합, 4/6/9 샘플)"
EnableAllHotkey="모든 Branch Output 활성화"
DisableAllHotkey="모든 Branch Output 비활성화"
EnableHotkey="'%1' 활성화"
DisableHotkey="'%1' 비활성화"
4 changes: 4 additions & 0 deletions data/locale/ro-RO.ini
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,7 @@ DownscaleFilter.Bilinear="Biliniar (cel mai rapid, dar neclar la scalare)"
DownscaleFilter.Bicubic="Bicubic (Scalare ascuțită, 16 mostre)"
DownscaleFilter.Lanczos="Lanczos (Scalare ascuțită, 36 de mostre)"
DownscaleFilter.Area="Zonă (Sumă ponderată, 4/6/9 mostre)"
EnableAllHotkey="Activați toate ieșirile de ramuri"
DisableAllHotkey="Dezactivați toate ieșirile de ramuri"
EnableHotkey="Activați '%1'"
DisableHotkey="Dezactivează '%1'"
4 changes: 4 additions & 0 deletions data/locale/ru-RU.ini
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,7 @@ DownscaleFilter.Bilinear="Билинейный (быстрейший, но ра
DownscaleFilter.Bicubic="Бикубический (чёткое масштабирование, 16 выборок)"
DownscaleFilter.Lanczos="Метод Ланцоша (чёткое масштабирование, 36 выборок)"
DownscaleFilter.Area="Область (взвешенная сумма, 4/6/9 выборок)"
EnableAllHotkey="Включить все выходы ветвей"
DisableAllHotkey="Отключить все выходы ветвей"
EnableHotkey="Включить '%1'"
DisableHotkey="Отключить '%1'"
4 changes: 4 additions & 0 deletions data/locale/uk-UA.ini
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,7 @@ DownscaleFilter.Bilinear="Білінійний (найшвидший, але р
DownscaleFilter.Bicubic="Бікубічний (чітке масштабування, 16 зразків)"
DownscaleFilter.Lanczos="Ланцош (чітке масштабування, 36 зразків)"
DownscaleFilter.Area="Усереднення площ (зважена сума, 4/6/9 зразків)"
EnableAllHotkey="Увімкнути всі виходи розгалужень"
DisableAllHotkey="Вимкнути всі розгалужені виходи"
EnableHotkey="Увімкнути '%1'"
DisableHotkey="Вимкнути '%1'"
4 changes: 4 additions & 0 deletions data/locale/zh-CN.ini
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,7 @@ DownscaleFilter.Bilinear="双线性插值(最快, 但会变模糊)"
DownscaleFilter.Bicubic="双三次插值(锐化缩放, 16 个样本)"
DownscaleFilter.Lanczos="Lanczos插值(锐化缩放, 36 个样本)"
DownscaleFilter.Area="区域(加权和, 4/6/9个样本)"
EnableAllHotkey="启用所有分支输出"
DisableAllHotkey="禁用所有分支输出"
EnableHotkey="启用 '%1'"
DisableHotkey="禁用 '%1'"
30 changes: 30 additions & 0 deletions src/UI/output-status-dock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,17 @@ BranchOutputStatusDock::BranchOutputStatusDock(QWidget *parent) : QFrame(parent)
outputContainerLayout->addLayout(buttonsContainerLayout);
this->setLayout(outputContainerLayout);

// Register hotkeys
enableAllHotkey = obs_hotkey_register_frontend(
"EnableAllBranchOutputsHotkey", obs_module_text("EnableAllHotkey"), onEanbleAllHotkeyPressed, this
);
disableAllHotkey = obs_hotkey_register_frontend(
"DisableAllBranchOutputsHotkey", obs_module_text("DisableAllHotkey"), onDisableAllHotkeyPressed, this
);

loadSettings();
loadHotkey(enableAllHotkey, "EnableAllBranchOutputsHotkey");
loadHotkey(disableAllHotkey, "DisableAllBranchOutputsHotkey");

obs_log(LOG_DEBUG, "BranchOutputStatusDock created");
}
Expand All @@ -114,6 +124,10 @@ BranchOutputStatusDock::~BranchOutputStatusDock()
{
saveSettings();

// Unregister hotkeys
obs_hotkey_unregister(enableAllHotkey);
obs_hotkey_unregister(disableAllHotkey);

obs_log(LOG_DEBUG, "BranchOutputStatusDock destroyed");
}

Expand Down Expand Up @@ -273,6 +287,22 @@ BranchOutputFilter *BranchOutputStatusDock::findFilter(const QString &parentName
return nullptr;
}

void BranchOutputStatusDock::onEanbleAllHotkeyPressed(void *data, obs_hotkey_id, obs_hotkey *, bool pressed)
{
auto dock = (BranchOutputStatusDock *)data;
if (pressed) {
dock->setEabnleAll(true);
}
}

void BranchOutputStatusDock::onDisableAllHotkeyPressed(void *data, obs_hotkey_id, obs_hotkey *, bool pressed)
{
auto dock = (BranchOutputStatusDock *)data;
if (pressed) {
dock->setEabnleAll(false);
}
}

//--- OutputTableRow class ---//

OutputTableRow::OutputTableRow(QObject *parent) : QObject(parent) {}
Expand Down
5 changes: 5 additions & 0 deletions src/UI/output-status-dock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,16 @@ class BranchOutputStatusDock : public QFrame {
QLabel *interlockLabel = nullptr;
QComboBox *interlockComboBox = nullptr;
OBSSignal sourceAddedSignal;
obs_hotkey_id enableAllHotkey;
obs_hotkey_id disableAllHotkey;

void update();
void saveSettings();
void loadSettings();

static void onEanbleAllHotkeyPressed(void *data, obs_hotkey_id id, obs_hotkey *hotkey, bool pressed);
static void onDisableAllHotkeyPressed(void *data, obs_hotkey_id id, obs_hotkey *hotkey, bool pressed);

protected:
virtual void showEvent(QShowEvent *event) override;
virtual void hideEvent(QHideEvent *event) override;
Expand Down
67 changes: 67 additions & 0 deletions src/plugin-main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,36 @@ void intervalTask(BranchOutputFilter *filter)
}
}

bool onEnableFilterHotkeyPressed(void *data, obs_hotkey_pair_id, obs_hotkey *, bool pressed)
{
if (!pressed) {
return false;
}

BranchOutputFilter *filter = (BranchOutputFilter *)data;
if (obs_source_enabled(filter->filterSource)) {
return false;
}

obs_source_set_enabled(filter->filterSource, true);
return true;
}

bool onDisableFilterHotkeyPressed(void *data, obs_hotkey_pair_id, obs_hotkey *, bool pressed)
{
if (!pressed) {
return false;
}

BranchOutputFilter *filter = (BranchOutputFilter *)data;
if (!obs_source_enabled(filter->filterSource)) {
return false;
}

obs_source_set_enabled(filter->filterSource, false);
return true;
}

//--- OBS Plugin Callbacks ---//

void *create(obs_data_t *settings, obs_source_t *source)
Expand All @@ -896,6 +926,7 @@ void *create(obs_data_t *settings, obs_source_t *source)

auto filter = (BranchOutputFilter *)bzalloc(sizeof(BranchOutputFilter));
pthread_mutex_init(&filter->outputMutex, nullptr);
filter->filterRenamedSignal = new OBSSignal();

filter->filterSource = source;

Expand Down Expand Up @@ -923,6 +954,24 @@ void *create(obs_data_t *settings, obs_source_t *source)
return filter;
}

inline void registerHotkey(BranchOutputFilter *filter)
{
if (filter->hotkeyPairId != OBS_INVALID_HOTKEY_PAIR_ID) {
// Unregsiter previous
obs_hotkey_pair_unregister(filter->hotkeyPairId);
}

auto name0 = QString("EnableFilter.%1").arg(obs_source_get_uuid(filter->filterSource));
auto description0 = QString(obs_module_text("EnableHotkey")).arg(obs_source_get_name(filter->filterSource));
auto name1 = QString("DisableFilter.%1").arg(obs_source_get_uuid(filter->filterSource));
auto description1 = QString(obs_module_text("DisableHotkey")).arg(obs_source_get_name(filter->filterSource));
filter->hotkeyPairId = obs_hotkey_pair_register_source(
obs_filter_get_parent(filter->filterSource), qUtf8Printable(name0), qUtf8Printable(description0),
qUtf8Printable(name1), qUtf8Printable(description1), onEnableFilterHotkeyPressed, onDisableFilterHotkeyPressed,
filter, filter
);
}

void filterAdd(void *data, obs_source_t *source)
{
// Register to output status dock
Expand Down Expand Up @@ -953,6 +1002,18 @@ void filterAdd(void *data, obs_source_t *source)
QMetaObject::invokeMethod(statusDock, "addFilter", Qt::QueuedConnection, Q_ARG(BranchOutputFilter *, filter));
}

// Register hotkeys
registerHotkey(filter);
// Track filter renames for hotkey settings
filter->filterRenamedSignal->Connect(
obs_source_get_signal_handler(filter->filterSource), "rename",
[](void *_data, calldata_t *) {
auto _filter = (BranchOutputFilter *)_data;
registerHotkey(_filter);
},
filter
);

obs_log(
LOG_INFO, "%s: Filter added to '%s'", obs_source_get_name(filter->filterSource), obs_source_get_name(source)
);
Expand Down Expand Up @@ -1008,6 +1069,11 @@ void filterRemove(void *data, obs_source_t *source)
QMetaObject::invokeMethod(statusDock, "removeFilter", Qt::QueuedConnection, Q_ARG(BranchOutputFilter *, filter));
}

if (filter->hotkeyPairId != OBS_INVALID_HOTKEY_PAIR_ID) {
// Unregsiter hotkeys
obs_hotkey_pair_unregister(filter->hotkeyPairId);
}

obs_log(
LOG_INFO, "%s: Filter removed from '%s'", obs_source_get_name(filter->filterSource), obs_source_get_name(source)
);
Expand All @@ -1026,6 +1092,7 @@ void destroy(void *data)

stopOutput(filter);
pthread_mutex_destroy(&filter->outputMutex);
delete filter->filterRenamedSignal;
bfree(filter);

obs_log(LOG_INFO, "%s: Filter destroyed", obs_source_get_name(source));
Expand Down
4 changes: 4 additions & 0 deletions src/plugin-main.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ struct BranchOutputFilter {
// Stream context
pthread_mutex_t outputMutex;
uint64_t connectAttemptingAt;

// Hotkey context
obs_hotkey_pair_id hotkeyPairId;
OBSSignal *filterRenamedSignal;
};

// The type must be registered for Linux platform
Expand Down
22 changes: 22 additions & 0 deletions src/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ with this program. If not, see <https://www.gnu.org/licenses/>
#include <obs.hpp>
#include <obs-frontend-api.h>
#include <util/threading.h>
#include <util/config-file.h>

#include <QString>
#include <QWidget>
Expand Down Expand Up @@ -123,3 +124,24 @@ inline void setAudioDestListName(char *name, size_t len, size_t track)
snprintf(name, len, "audio_dest");
}
}

// Return value must be obs_data_release() after use
inline obs_data_t *loadHotkeyData(const char *name)
{
auto config = obs_frontend_get_profile_config();
auto info = config_get_string(config, "Hotkeys", name);
if (!info) {
return nullptr;
}

return obs_data_create_from_json(info);
}

inline void loadHotkey(obs_hotkey_id id, const char *name)
{
OBSDataAutoRelease data = loadHotkeyData(name);
if (data) {
OBSDataArrayAutoRelease array = obs_data_get_array(data, "bindings");
obs_hotkey_load(id, array);
}
}

0 comments on commit 61fe69f

Please sign in to comment.