mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-12-01 20:37:18 -06:00
Group streaming, recording and replay buffer action options
Some checks failed
debian-build / build (push) Has been cancelled
Check locale / ubuntu64 (push) Has been cancelled
Push to master / Check Formatting 🔍 (push) Has been cancelled
Push to master / Build Project 🧱 (push) Has been cancelled
Push to master / Create Release 🛫 (push) Has been cancelled
Some checks failed
debian-build / build (push) Has been cancelled
Check locale / ubuntu64 (push) Has been cancelled
Push to master / Check Formatting 🔍 (push) Has been cancelled
Push to master / Build Project 🧱 (push) Has been cancelled
Push to master / Create Release 🛫 (push) Has been cancelled
This commit is contained in:
@@ -13,31 +13,53 @@ bool MacroActionRecord::_registered = MacroActionFactory::Register(
|
||||
{MacroActionRecord::Create, MacroActionRecordEdit::Create,
|
||||
"AdvSceneSwitcher.action.recording"});
|
||||
|
||||
const static std::map<MacroActionRecord::Action, std::string> actionTypes = {
|
||||
{MacroActionRecord::Action::STOP,
|
||||
"AdvSceneSwitcher.action.recording.type.stop"},
|
||||
{MacroActionRecord::Action::START,
|
||||
"AdvSceneSwitcher.action.recording.type.start"},
|
||||
{MacroActionRecord::Action::PAUSE,
|
||||
"AdvSceneSwitcher.action.recording.type.pause"},
|
||||
{MacroActionRecord::Action::UNPAUSE,
|
||||
"AdvSceneSwitcher.action.recording.type.unpause"},
|
||||
const static std::vector<
|
||||
std::vector<std::pair<MacroActionRecord::Action, const char *>>>
|
||||
actionGroups = {
|
||||
{
|
||||
{MacroActionRecord::Action::START,
|
||||
"AdvSceneSwitcher.action.recording.type.start"},
|
||||
{MacroActionRecord::Action::STOP,
|
||||
"AdvSceneSwitcher.action.recording.type.stop"},
|
||||
{MacroActionRecord::Action::TOGGLE,
|
||||
"AdvSceneSwitcher.action.recording.type.toggle"},
|
||||
},
|
||||
{
|
||||
{MacroActionRecord::Action::PAUSE,
|
||||
"AdvSceneSwitcher.action.recording.type.pause"},
|
||||
{MacroActionRecord::Action::UNPAUSE,
|
||||
"AdvSceneSwitcher.action.recording.type.unpause"},
|
||||
},
|
||||
{
|
||||
#if LIBOBS_API_VER >= MAKE_SEMANTIC_VERSION(28, 0, 0)
|
||||
{MacroActionRecord::Action::SPLIT,
|
||||
"AdvSceneSwitcher.action.recording.type.split"},
|
||||
{MacroActionRecord::Action::SPLIT,
|
||||
"AdvSceneSwitcher.action.recording.type.split"},
|
||||
#endif
|
||||
{MacroActionRecord::Action::FOLDER,
|
||||
"AdvSceneSwitcher.action.recording.type.changeOutputFolder"},
|
||||
{MacroActionRecord::Action::FILE_FORMAT,
|
||||
"AdvSceneSwitcher.action.recording.type.changeOutputFileFormat"},
|
||||
#if LIBOBS_API_VER >= MAKE_SEMANTIC_VERSION(30, 2, 0)
|
||||
{MacroActionRecord::Action::ADD_CHAPTER,
|
||||
"AdvSceneSwitcher.action.recording.type.addChapter"},
|
||||
{MacroActionRecord::Action::ADD_CHAPTER,
|
||||
"AdvSceneSwitcher.action.recording.type.addChapter"},
|
||||
#endif
|
||||
{MacroActionRecord::Action::TOGGLE,
|
||||
"AdvSceneSwitcher.action.recording.type.toggle"},
|
||||
},
|
||||
{
|
||||
{MacroActionRecord::Action::FOLDER,
|
||||
"AdvSceneSwitcher.action.recording.type.changeOutputFolder"},
|
||||
{MacroActionRecord::Action::FILE_FORMAT,
|
||||
"AdvSceneSwitcher.action.recording.type.changeOutputFileFormat"},
|
||||
},
|
||||
};
|
||||
|
||||
static const char *getActionName(MacroActionRecord::Action action)
|
||||
{
|
||||
for (const auto &group : actionGroups) {
|
||||
for (const auto &[value, name] : group) {
|
||||
if (value == action) {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool MacroActionRecord::PerformAction()
|
||||
{
|
||||
switch (_action) {
|
||||
@@ -117,9 +139,9 @@ bool MacroActionRecord::PerformAction()
|
||||
|
||||
void MacroActionRecord::LogAction() const
|
||||
{
|
||||
auto it = actionTypes.find(_action);
|
||||
if (it != actionTypes.end()) {
|
||||
ablog(LOG_INFO, "performed action \"%s\"", it->second.c_str());
|
||||
const char *name = getActionName(_action);
|
||||
if (name) {
|
||||
ablog(LOG_INFO, "performed action \"%s\"", name);
|
||||
} else {
|
||||
blog(LOG_WARNING, "ignored unknown recording action %d",
|
||||
static_cast<int>(_action));
|
||||
@@ -165,9 +187,17 @@ void MacroActionRecord::ResolveVariablesToFixedValues()
|
||||
|
||||
static inline void populateActionSelection(QComboBox *list)
|
||||
{
|
||||
for (const auto &[action, name] : actionTypes) {
|
||||
list->addItem(obs_module_text(name.c_str()),
|
||||
static_cast<int>(action));
|
||||
for (const auto &group : actionGroups) {
|
||||
if (group.empty()) {
|
||||
continue;
|
||||
}
|
||||
if (list->count() > 0) {
|
||||
list->insertSeparator(list->count());
|
||||
}
|
||||
for (const auto &[action, name] : group) {
|
||||
list->addItem(obs_module_text(name),
|
||||
static_cast<int>(action));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,20 +13,39 @@ bool MacroActionReplayBuffer::_registered = MacroActionFactory::Register(
|
||||
{MacroActionReplayBuffer::Create, MacroActionReplayBufferEdit::Create,
|
||||
"AdvSceneSwitcher.action.replay"});
|
||||
|
||||
static const std::map<MacroActionReplayBuffer::Action, std::string>
|
||||
actionTypes = {
|
||||
{MacroActionReplayBuffer::Action::STOP,
|
||||
"AdvSceneSwitcher.action.replay.type.stop"},
|
||||
{MacroActionReplayBuffer::Action::START,
|
||||
"AdvSceneSwitcher.action.replay.type.start"},
|
||||
{MacroActionReplayBuffer::Action::SAVE,
|
||||
"AdvSceneSwitcher.action.replay.type.save"},
|
||||
{MacroActionReplayBuffer::Action::DURATION,
|
||||
"AdvSceneSwitcher.action.replay.type.duration"},
|
||||
{MacroActionReplayBuffer::Action::TOGGLE,
|
||||
"AdvSceneSwitcher.action.replay.type.toggle"},
|
||||
static const std::vector<
|
||||
std::vector<std::pair<MacroActionReplayBuffer::Action, const char *>>>
|
||||
actionGroups = {
|
||||
{
|
||||
{MacroActionReplayBuffer::Action::START,
|
||||
"AdvSceneSwitcher.action.replay.type.start"},
|
||||
{MacroActionReplayBuffer::Action::STOP,
|
||||
"AdvSceneSwitcher.action.replay.type.stop"},
|
||||
{MacroActionReplayBuffer::Action::TOGGLE,
|
||||
"AdvSceneSwitcher.action.replay.type.toggle"},
|
||||
},
|
||||
{
|
||||
{MacroActionReplayBuffer::Action::SAVE,
|
||||
"AdvSceneSwitcher.action.replay.type.save"},
|
||||
},
|
||||
{
|
||||
{MacroActionReplayBuffer::Action::DURATION,
|
||||
"AdvSceneSwitcher.action.replay.type.duration"},
|
||||
},
|
||||
};
|
||||
|
||||
static const char *getActionName(MacroActionReplayBuffer::Action action)
|
||||
{
|
||||
for (const auto &group : actionGroups) {
|
||||
for (const auto &[value, name] : group) {
|
||||
if (value == action) {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool MacroActionReplayBuffer::PerformAction()
|
||||
{
|
||||
switch (_action) {
|
||||
@@ -73,9 +92,9 @@ bool MacroActionReplayBuffer::PerformAction()
|
||||
|
||||
void MacroActionReplayBuffer::LogAction() const
|
||||
{
|
||||
auto it = actionTypes.find(_action);
|
||||
if (it != actionTypes.end()) {
|
||||
ablog(LOG_INFO, "performed action \"%s\"", it->second.c_str());
|
||||
const char *name = getActionName(_action);
|
||||
if (name) {
|
||||
ablog(LOG_INFO, "performed action \"%s\"", name);
|
||||
} else {
|
||||
blog(LOG_WARNING, "ignored unknown replay buffer action %d",
|
||||
static_cast<int>(_action));
|
||||
@@ -110,9 +129,14 @@ std::shared_ptr<MacroAction> MacroActionReplayBuffer::Copy() const
|
||||
|
||||
static inline void populateActionSelection(QComboBox *list)
|
||||
{
|
||||
for (const auto &[action, name] : actionTypes) {
|
||||
list->addItem(obs_module_text(name.c_str()),
|
||||
static_cast<int>(action));
|
||||
for (const auto &group : actionGroups) {
|
||||
if (list->count() > 0) {
|
||||
list->insertSeparator(list->count());
|
||||
}
|
||||
for (const auto &[action, name] : group) {
|
||||
list->addItem(obs_module_text(name),
|
||||
static_cast<int>(action));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,25 +16,45 @@ bool MacroActionStream::_registered = MacroActionFactory::Register(
|
||||
{MacroActionStream::Create, MacroActionStreamEdit::Create,
|
||||
"AdvSceneSwitcher.action.streaming"});
|
||||
|
||||
const static std::map<MacroActionStream::Action, std::string> actionTypes = {
|
||||
{MacroActionStream::Action::STOP,
|
||||
"AdvSceneSwitcher.action.streaming.type.stop"},
|
||||
{MacroActionStream::Action::START,
|
||||
"AdvSceneSwitcher.action.streaming.type.start"},
|
||||
{MacroActionStream::Action::KEYFRAME_INTERVAL,
|
||||
"AdvSceneSwitcher.action.streaming.type.keyFrameInterval"},
|
||||
{MacroActionStream::Action::SERVER,
|
||||
"AdvSceneSwitcher.action.streaming.type.server"},
|
||||
{MacroActionStream::Action::STREAM_KEY,
|
||||
"AdvSceneSwitcher.action.streaming.type.streamKey"},
|
||||
{MacroActionStream::Action::USERNAME,
|
||||
"AdvSceneSwitcher.action.streaming.type.username"},
|
||||
{MacroActionStream::Action::PASSWORD,
|
||||
"AdvSceneSwitcher.action.streaming.type.password"},
|
||||
{MacroActionStream::Action::TOGGLE,
|
||||
"AdvSceneSwitcher.action.streaming.type.toggle"},
|
||||
const static std::vector<
|
||||
std::vector<std::pair<MacroActionStream::Action, const char *>>>
|
||||
actionGroups = {
|
||||
{
|
||||
{MacroActionStream::Action::START,
|
||||
"AdvSceneSwitcher.action.streaming.type.start"},
|
||||
{MacroActionStream::Action::STOP,
|
||||
"AdvSceneSwitcher.action.streaming.type.stop"},
|
||||
{MacroActionStream::Action::TOGGLE,
|
||||
"AdvSceneSwitcher.action.streaming.type.toggle"},
|
||||
},
|
||||
{
|
||||
{MacroActionStream::Action::KEYFRAME_INTERVAL,
|
||||
"AdvSceneSwitcher.action.streaming.type.keyFrameInterval"},
|
||||
},
|
||||
{
|
||||
{MacroActionStream::Action::SERVER,
|
||||
"AdvSceneSwitcher.action.streaming.type.server"},
|
||||
{MacroActionStream::Action::STREAM_KEY,
|
||||
"AdvSceneSwitcher.action.streaming.type.streamKey"},
|
||||
{MacroActionStream::Action::USERNAME,
|
||||
"AdvSceneSwitcher.action.streaming.type.username"},
|
||||
{MacroActionStream::Action::PASSWORD,
|
||||
"AdvSceneSwitcher.action.streaming.type.password"},
|
||||
},
|
||||
};
|
||||
|
||||
static const char *getActionName(MacroActionStream::Action action)
|
||||
{
|
||||
for (const auto &group : actionGroups) {
|
||||
for (const auto &[value, name] : group) {
|
||||
if (value == action) {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
constexpr int streamStartCooldown = 5;
|
||||
std::chrono::high_resolution_clock::time_point MacroActionStream::s_lastAttempt =
|
||||
std::chrono::high_resolution_clock::now();
|
||||
@@ -142,9 +162,9 @@ bool MacroActionStream::PerformAction()
|
||||
|
||||
void MacroActionStream::LogAction() const
|
||||
{
|
||||
auto it = actionTypes.find(_action);
|
||||
if (it != actionTypes.end()) {
|
||||
ablog(LOG_INFO, "performed action \"%s\"", it->second.c_str());
|
||||
const char *name = getActionName(_action);
|
||||
if (name) {
|
||||
ablog(LOG_INFO, "performed action \"%s\"", name);
|
||||
} else {
|
||||
blog(LOG_WARNING, "ignored unknown streaming action %d",
|
||||
static_cast<int>(_action));
|
||||
@@ -187,9 +207,14 @@ void MacroActionStream::ResolveVariablesToFixedValues()
|
||||
|
||||
static inline void populateActionSelection(QComboBox *list)
|
||||
{
|
||||
for (const auto &[action, name] : actionTypes) {
|
||||
list->addItem(obs_module_text(name.c_str()),
|
||||
static_cast<int>(action));
|
||||
for (const auto &group : actionGroups) {
|
||||
if (list->count() > 0) {
|
||||
list->insertSeparator(list->count());
|
||||
}
|
||||
for (const auto &[action, name] : group) {
|
||||
list->addItem(obs_module_text(name),
|
||||
static_cast<int>(action));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user