Skip to content

Commit

Permalink
Add separate config to sync stop
Browse files Browse the repository at this point in the history
Resolves #307
  • Loading branch information
mabrowning authored and sorayuki committed Feb 24, 2024
1 parent ce64ccc commit e373c19
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions data/locale/en-GB.ini
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Btn.NewTarget="Add new target"
Ques.DropDelay="Do you want to discard delay?"
OtherSettings="Other Settings"
SyncStart="Sync start with OBS"
SyncStop="Sync stop with OBS"
EncoderShare="Shared with "
Btn.EncoderShare="Share from"
NoShare="Not shared"
Expand Down
1 change: 1 addition & 0 deletions data/locale/en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Btn.NewTarget="Add new target"
Ques.DropDelay="Do you want to discard delay?"
OtherSettings="Other Settings"
SyncStart="Sync start with OBS"
SyncStop="Sync stop with OBS"
EncoderShare="Shared with "
Btn.EncoderShare="Share from"
NoShare="Not shared"
Expand Down
1 change: 1 addition & 0 deletions data/locale/ja-JP.ini
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Btn.NewTarget="新規ターゲットを追加"
Ques.DropDelay="遅延を破棄しますか?"
OtherSettings="その他の設定"
SyncStart="OBSとの同期を開始"
SyncStop="OBSとの同期を停止"
EncoderShare="共有:"
Btn.EncoderShare="共有"
NoShare="共有しない"
Expand Down
1 change: 1 addition & 0 deletions data/locale/zh-CN.ini
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Btn.NewTarget="新建推流目标"
Ques.DropDelay="放弃所有延迟推流数据吗?"
OtherSettings="杂项"
SyncStart="自动开关"
SyncStop="自动停止"
EncoderShare="共用中:"
Btn.EncoderShare="共用自"
NoShare="不共用"
Expand Down
1 change: 1 addition & 0 deletions data/locale/zh-TW.ini
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Btn.NewTarget="建立新串流目標"
Ques.DropDelay="丟棄所有延遲串流數據嗎?"
OtherSettings="Other Settings"
SyncStart="Sync start with OBS"
SyncStop="Sync stop with OBS"
EncoderShare="共用中:"
Btn.EncoderShare="共用自"
NoShare="不共用"
Expand Down
4 changes: 4 additions & 0 deletions src/edit-widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ class EditOutputWidgetImpl : public EditOutputWidget
QLabel* a_share_notify_ = 0;

QCheckBox* syncStart_ = 0;
QCheckBox *syncStop_ = 0;

std::vector<std::string> EnumEncodersByCodec(const char* codec)
{
Expand Down Expand Up @@ -400,6 +401,7 @@ class EditOutputWidgetImpl : public EditOutputWidget
sub_grid->addWidget(gp, 1, 1, 1, 1);
auto otherLayout = new QGridLayout();
otherLayout->addWidget(syncStart_ = new QCheckBox(obs_module_text("SyncStart"), gp), 0, 0);
otherLayout->addWidget(syncStop_ = new QCheckBox(obs_module_text("SyncStop"), gp), 1, 0);
gp->setLayout(otherLayout);
}
}
Expand Down Expand Up @@ -632,6 +634,7 @@ class EditOutputWidgetImpl : public EditOutputWidget

config_->name = tostdu8(name_->text());
config_->syncStart = syncStart_->isChecked();
config_->syncStop = syncStop_->isChecked();
config_->outputParam = outputSettings_->Save();
config_->serviceParam = serviceSettings_->Save();

Expand Down Expand Up @@ -660,6 +663,7 @@ class EditOutputWidgetImpl : public EditOutputWidget
void LoadTargetConfig(OutputTargetConfig& target) {
name_->setText(QString::fromUtf8(target.name));
syncStart_->setChecked(target.syncStart);
syncStop_->setChecked(target.syncStop);
}

void LoadVideoConfig(VideoEncoderConfig& config) {
Expand Down
2 changes: 2 additions & 0 deletions src/output-config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ static nlohmann::json SaveTarget(OutputTargetConfig& config) {
json["service-param"] = config.serviceParam;
json["output-param"] = config.outputParam;
json["sync-start"] = config.syncStart;
json["sync-stop"] = config.syncStop;
if (config.videoConfig.has_value())
json["video-config"] = *config.videoConfig;
if (config.audioConfig.has_value())
Expand Down Expand Up @@ -107,6 +108,7 @@ static OutputTargetConfigPtr LoadTargetConfig(nlohmann::json& json) {
config->id = *id;
config->name = GetJsonField<std::string>(json, "name").value_or("");
config->syncStart = GetJsonField<bool>(json, "sync-start").value_or(false);
config->syncStop = GetJsonField<bool>(json, "sync-stop").value_or(config->syncStart);
config->serviceParam = GetJsonField<nlohmann::json>(json, "service-param").value_or(nlohmann::json{});
config->outputParam = GetJsonField<nlohmann::json>(json, "output-param").value_or(nlohmann::json{});
config->videoConfig = GetJsonField<std::string>(json, "video-config");
Expand Down
1 change: 1 addition & 0 deletions src/output-config.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ struct OutputTargetConfig {
std::string id;
std::string name;
bool syncStart = false;
bool syncStop = false;

nlohmann::json serviceParam;
nlohmann::json outputParam;
Expand Down
2 changes: 1 addition & 1 deletion src/push-widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ class PushWidgetImpl : public PushWidget, public IOBSOutputEventHanlder
StartStop();
}
} else if (ev == obs_frontend_event::OBS_FRONTEND_EVENT_STREAMING_STOPPING) {
if (IsRunning() && config_->syncStart) {
if (IsRunning() && config_->syncStop) {
StartStop();
}
}
Expand Down

0 comments on commit e373c19

Please sign in to comment.