New request types to get and set the status of Studio Mode

This commit is contained in:
Palakis 2017-04-19 11:34:37 +02:00
parent 07c868edcd
commit 8c4bd91c78
3 changed files with 46 additions and 0 deletions

View File

@ -262,6 +262,7 @@ bool Utils::IsPreviewModeActive()
// Clue 2 : Preview layout has more than one item
int previewChildCount = GetPreviewLayout()->children().count();
blog(LOG_INFO, "preview layout children count : %d", previewChildCount);
return buttonToggledOn || (previewChildCount >= 2);
}

View File

@ -71,6 +71,11 @@ WSRequestHandler::WSRequestHandler(QWebSocket *client) :
messageMap["GetCurrentProfile"] = WSRequestHandler::HandleGetCurrentProfile;
messageMap["ListProfiles"] = WSRequestHandler::HandleListProfiles;
messageMap["GetStudioModeStatus"] = WSRequestHandler::HandleGetStudioModeStatus;
messageMap["EnableStudioMode"] = WSRequestHandler::HandleEnableStudioMode;
messageMap["DisableStudioMode"] = WSRequestHandler::HandleDisableStudioMode;
messageMap["ToggleStudioMode"] = WSRequestHandler::HandleToggleStudioMode;
authNotRequired.insert("GetVersion");
authNotRequired.insert("GetAuthRequired");
authNotRequired.insert("Authenticate");
@ -746,6 +751,41 @@ void WSRequestHandler::HandleListProfiles(WSRequestHandler *owner)
obs_data_array_release(profiles);
}
void WSRequestHandler::HandleGetStudioModeStatus(WSRequestHandler *owner)
{
bool previewActive = Utils::IsPreviewModeActive();
obs_data_t* response = obs_data_create();
obs_data_set_bool(response, "studio-mode", previewActive);
if (previewActive) {
//const char* currentPreviewScene = Utils::GetPreviewSceneName();
//obs_data_set_string(response, "preview-scene", currentPreviewScene);
}
owner->SendOKResponse(response);
obs_data_release(response);
}
void WSRequestHandler::HandleEnableStudioMode(WSRequestHandler *owner)
{
Utils::EnablePreviewMode();
owner->SendOKResponse();
}
void WSRequestHandler::HandleDisableStudioMode(WSRequestHandler *owner)
{
Utils::DisablePreviewMode();
owner->SendOKResponse();
}
void WSRequestHandler::HandleToggleStudioMode(WSRequestHandler *owner)
{
Utils::TogglePreviewMode();
owner->SendOKResponse();
}
void WSRequestHandler::ErrNotImplemented(WSRequestHandler *owner)
{
owner->SendErrorResponse("not implemented");

View File

@ -87,6 +87,11 @@ class WSRequestHandler : public QObject
static void HandleSetTransitionDuration(WSRequestHandler *owner);
static void HandleGetTransitionDuration(WSRequestHandler *owner);
static void HandleGetStudioModeStatus(WSRequestHandler *owner);
static void HandleEnableStudioMode(WSRequestHandler *owner);
static void HandleDisableStudioMode(WSRequestHandler *owner);
static void HandleToggleStudioMode(WSRequestHandler *owner);
};
#endif // WSPROTOCOL_H