mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-04-04 00:05:38 -05:00
Add temp variable support to streaming condition
This commit is contained in:
parent
96809f76b9
commit
668bba16ea
|
|
@ -1590,6 +1590,11 @@ AdvSceneSwitcher.tempVar.display.width.description="The width of the display whi
|
|||
AdvSceneSwitcher.tempVar.display.height="Display height"
|
||||
AdvSceneSwitcher.tempVar.display.height.description="The height of the display which matched the given pattern"
|
||||
|
||||
AdvSceneSwitcher.tempVar.streaming.keyframeInterval="Stream keyframe interval"
|
||||
AdvSceneSwitcher.tempVar.streaming.keyframeInterval.description="Stream keyframe interval configured in the OBS settings."
|
||||
AdvSceneSwitcher.tempVar.streaming.durationSeconds="Stream duration"
|
||||
AdvSceneSwitcher.tempVar.streaming.durationSeconds.description="Seconds passed since the stream was started.\nThis value will be zero if the stream is stopped."
|
||||
|
||||
AdvSceneSwitcher.selectScene="--select scene--"
|
||||
AdvSceneSwitcher.selectPreviousScene="Previous Scene"
|
||||
AdvSceneSwitcher.selectCurrentScene="Current Scene"
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ bool setupStreamingEventHandler()
|
|||
return true;
|
||||
}
|
||||
|
||||
int MacroConditionStream::GetKeyFrameInterval()
|
||||
int MacroConditionStream::GetKeyFrameInterval() const
|
||||
{
|
||||
const auto configPath = GetPathInProfileDir("streamEncoder.json");
|
||||
obs_data_t *settings =
|
||||
|
|
@ -72,6 +72,7 @@ bool MacroConditionStream::CheckCondition()
|
|||
|
||||
bool streamStarting = streamStartTime != _lastStreamStartingTime;
|
||||
bool streamStopping = streamStopTime != _lastStreamStoppingTime;
|
||||
const int keyFrameInterval = GetKeyFrameInterval();
|
||||
|
||||
switch (_condition) {
|
||||
case Condition::STOP:
|
||||
|
|
@ -87,7 +88,7 @@ bool MacroConditionStream::CheckCondition()
|
|||
match = streamStopping;
|
||||
break;
|
||||
case Condition::KEYFRAME_INTERVAL:
|
||||
match = GetKeyFrameInterval() == _keyFrameInterval;
|
||||
match = keyFrameInterval == _keyFrameInterval;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
@ -99,6 +100,15 @@ bool MacroConditionStream::CheckCondition()
|
|||
if (streamStopping) {
|
||||
_lastStreamStoppingTime = streamStopTime;
|
||||
}
|
||||
|
||||
const auto seconds = std::chrono::duration_cast<std::chrono::seconds>(
|
||||
std::chrono::high_resolution_clock::now() - streamStartTime);
|
||||
const auto streamDurationSeconds =
|
||||
obs_frontend_streaming_active() ? seconds.count() : 0;
|
||||
SetTempVarValue("durationSeconds",
|
||||
std::to_string(streamDurationSeconds));
|
||||
SetTempVarValue("keyframeInterval", std::to_string(keyFrameInterval));
|
||||
|
||||
return match;
|
||||
}
|
||||
|
||||
|
|
@ -118,6 +128,23 @@ bool MacroConditionStream::Load(obs_data_t *obj)
|
|||
return true;
|
||||
}
|
||||
|
||||
void MacroConditionStream::SetupTempVars()
|
||||
{
|
||||
MacroCondition::SetupTempVars();
|
||||
AddTempvar(
|
||||
"keyframeInterval",
|
||||
obs_module_text(
|
||||
"AdvSceneSwitcher.tempVar.streaming.keyframeInterval"),
|
||||
obs_module_text(
|
||||
"AdvSceneSwitcher.tempVar.streaming.keyframeInterval.description"));
|
||||
AddTempvar(
|
||||
"durationSeconds",
|
||||
obs_module_text(
|
||||
"AdvSceneSwitcher.tempVar.streaming.durationSeconds"),
|
||||
obs_module_text(
|
||||
"AdvSceneSwitcher.tempVar.streaming.durationSeconds.description"));
|
||||
}
|
||||
|
||||
static inline void populateStateSelection(QComboBox *list)
|
||||
{
|
||||
for (auto entry : streamStates) {
|
||||
|
|
|
|||
|
|
@ -30,7 +30,8 @@ public:
|
|||
NumberVariable<int> _keyFrameInterval = 0;
|
||||
|
||||
private:
|
||||
int GetKeyFrameInterval();
|
||||
void SetupTempVars();
|
||||
int GetKeyFrameInterval() const;
|
||||
|
||||
std::chrono::high_resolution_clock::time_point _lastStreamStartingTime{};
|
||||
std::chrono::high_resolution_clock::time_point _lastStreamStoppingTime{};
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user