mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
base: Apply latest clang-format changes from upstream
Minus, some customizations, of course
This commit is contained in:
parent
74719ce502
commit
5fc39ef054
131
.clang-format
131
.clang-format
@ -1,6 +1,6 @@
|
||||
# please use clang-format version 8 or later
|
||||
# please use clang-format version 16 or later
|
||||
|
||||
Standard: Cpp11
|
||||
Standard: c++17
|
||||
AccessModifierOffset: -8
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignConsecutiveAssignments: false
|
||||
@ -8,14 +8,14 @@ AlignConsecutiveDeclarations: false
|
||||
AlignEscapedNewlines: Left
|
||||
AlignOperands: true
|
||||
AlignTrailingComments: true
|
||||
#AllowAllArgumentsOnNextLine: false # requires clang-format 9
|
||||
#AllowAllConstructorInitializersOnNextLine: false # requires clang-format 9
|
||||
AllowAllArgumentsOnNextLine: false
|
||||
AllowAllConstructorInitializersOnNextLine: false
|
||||
AllowAllParametersOfDeclarationOnNextLine: false
|
||||
AllowShortBlocksOnASingleLine: false
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: Inline
|
||||
AllowShortIfStatementsOnASingleLine: false
|
||||
#AllowShortLambdasOnASingleLine: Inline # requires clang-format 9
|
||||
AllowShortLambdasOnASingleLine: Inline
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
AlwaysBreakAfterDefinitionReturnType: None
|
||||
AlwaysBreakAfterReturnType: None
|
||||
@ -53,10 +53,11 @@ Cpp11BracedListStyle: true
|
||||
DerivePointerAlignment: false
|
||||
DisableFormat: false
|
||||
FixNamespaceComments: false
|
||||
ForEachMacros:
|
||||
ForEachMacros:
|
||||
- 'json_object_foreach'
|
||||
- 'json_object_foreach_safe'
|
||||
- 'json_array_foreach'
|
||||
- 'HASH_ITER'
|
||||
IncludeBlocks: Preserve
|
||||
IndentCaseLabels: false
|
||||
IndentPPDirectives: None
|
||||
@ -65,7 +66,7 @@ IndentWrappedFunctionNames: false
|
||||
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||
MaxEmptyLinesToKeep: 1
|
||||
NamespaceIndentation: All
|
||||
#ObjCBinPackProtocolList: Auto # requires clang-format 7
|
||||
ObjCBinPackProtocolList: Auto
|
||||
ObjCBlockIndentWidth: 8
|
||||
ObjCSpaceAfterProperty: true
|
||||
ObjCSpaceBeforeProtocolList: true
|
||||
@ -83,13 +84,13 @@ ReflowComments: false
|
||||
SortIncludes: false
|
||||
SortUsingDeclarations: false
|
||||
SpaceAfterCStyleCast: false
|
||||
#SpaceAfterLogicalNot: false # requires clang-format 9
|
||||
SpaceAfterLogicalNot: false
|
||||
SpaceAfterTemplateKeyword: false
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
#SpaceBeforeCtorInitializerColon: true # requires clang-format 7
|
||||
#SpaceBeforeInheritanceColon: true # requires clang-format 7
|
||||
SpaceBeforeCtorInitializerColon: true
|
||||
SpaceBeforeInheritanceColon: true
|
||||
SpaceBeforeParens: ControlStatements
|
||||
#SpaceBeforeRangeBasedForLoopColon: true # requires clang-format 7
|
||||
SpaceBeforeRangeBasedForLoopColon: true
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 1
|
||||
SpacesInAngles: false
|
||||
@ -97,11 +98,111 @@ SpacesInCStyleCastParentheses: false
|
||||
SpacesInContainerLiterals: false
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
#StatementMacros: # requires clang-format 8
|
||||
# - 'Q_OBJECT'
|
||||
StatementMacros:
|
||||
- 'Q_OBJECT'
|
||||
TabWidth: 8
|
||||
#TypenameMacros: # requires clang-format 9
|
||||
# - 'DARRAY'
|
||||
TypenameMacros:
|
||||
- 'DARRAY'
|
||||
UseTab: ForContinuationAndIndentation
|
||||
---
|
||||
Language: ObjC
|
||||
AccessModifierOffset: 2
|
||||
AlignArrayOfStructures: Right
|
||||
AlignConsecutiveAssignments: None
|
||||
AlignConsecutiveBitFields: None
|
||||
AlignConsecutiveDeclarations: None
|
||||
AlignConsecutiveMacros:
|
||||
Enabled: true
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: true
|
||||
AllowShortBlocksOnASingleLine: Never
|
||||
AllowShortEnumsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: Empty
|
||||
AllowShortIfStatementsOnASingleLine: Never
|
||||
AllowShortLambdasOnASingleLine: None
|
||||
AttributeMacros: ['__unused', '__autoreleasing', '_Nonnull', '__bridge']
|
||||
BitFieldColonSpacing: Both
|
||||
#BreakBeforeBraces: Webkit
|
||||
BreakBeforeBraces: Custom
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: false
|
||||
AfterClass: true
|
||||
AfterControlStatement: Never
|
||||
AfterEnum: false
|
||||
AfterFunction: true
|
||||
AfterNamespace: false
|
||||
AfterObjCDeclaration: false
|
||||
AfterStruct: false
|
||||
AfterUnion: false
|
||||
AfterExternBlock: false
|
||||
BeforeCatch: false
|
||||
BeforeElse: false
|
||||
BeforeLambdaBody: false
|
||||
BeforeWhile: false
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: false
|
||||
SplitEmptyRecord: false
|
||||
SplitEmptyNamespace: true
|
||||
BreakAfterAttributes: Never
|
||||
BreakArrays: false
|
||||
BreakBeforeConceptDeclarations: Allowed
|
||||
BreakBeforeInlineASMColon: OnlyMultiline
|
||||
BreakConstructorInitializers: AfterColon
|
||||
BreakInheritanceList: AfterComma
|
||||
ColumnLimit: 120
|
||||
ConstructorInitializerIndentWidth: 4
|
||||
ContinuationIndentWidth: 4
|
||||
EmptyLineAfterAccessModifier: Never
|
||||
EmptyLineBeforeAccessModifier: LogicalBlock
|
||||
ExperimentalAutoDetectBinPacking: false
|
||||
FixNamespaceComments: true
|
||||
IndentAccessModifiers: false
|
||||
IndentCaseBlocks: false
|
||||
IndentCaseLabels: true
|
||||
IndentExternBlock: Indent
|
||||
IndentGotoLabels: false
|
||||
IndentRequiresClause: true
|
||||
IndentWidth: 4
|
||||
IndentWrappedFunctionNames: true
|
||||
InsertBraces: false
|
||||
InsertNewlineAtEOF: true
|
||||
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||
LambdaBodyIndentation: Signature
|
||||
NamespaceIndentation: All
|
||||
ObjCBinPackProtocolList: Auto
|
||||
ObjCBlockIndentWidth: 4
|
||||
ObjCBreakBeforeNestedBlockParam: false
|
||||
ObjCSpaceAfterProperty: true
|
||||
ObjCSpaceBeforeProtocolList: true
|
||||
PPIndentWidth: -1
|
||||
PackConstructorInitializers: NextLine
|
||||
QualifierAlignment: Leave
|
||||
ReferenceAlignment: Right
|
||||
RemoveSemicolon: false
|
||||
RequiresClausePosition: WithPreceding
|
||||
RequiresExpressionIndentation: OuterScope
|
||||
SeparateDefinitionBlocks: Always
|
||||
ShortNamespaceLines: 1
|
||||
SortIncludes: false
|
||||
#SortUsingDeclarations: LexicographicNumeric
|
||||
SortUsingDeclarations: true
|
||||
SpaceAfterCStyleCast: true
|
||||
SpaceAfterLogicalNot: false
|
||||
SpaceAroundPointerQualifiers: Default
|
||||
SpaceBeforeCaseColon: false
|
||||
SpaceBeforeCpp11BracedList: true
|
||||
SpaceBeforeCtorInitializerColon: true
|
||||
SpaceBeforeInheritanceColon: true
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceBeforeRangeBasedForLoopColon: true
|
||||
SpaceBeforeSquareBrackets: false
|
||||
SpaceInEmptyBlock: false
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 2
|
||||
SpacesInConditionalStatement: false
|
||||
SpacesInLineCommentPrefix:
|
||||
Minimum: 1
|
||||
Maximum: -1
|
||||
Standard: c++17
|
||||
TabWidth: 4
|
||||
UseTab: Never
|
||||
|
@ -195,12 +195,14 @@ bool MigratePersistentData()
|
||||
if (!std::filesystem::exists(moduleConfigDirectory, ec))
|
||||
std::filesystem::create_directories(moduleConfigDirectory, ec);
|
||||
if (ec) {
|
||||
blog(LOG_ERROR, "[MigratePersistentData] Failed to create directory `%s`: %s", moduleConfigDirectory.c_str(), ec.message().c_str());
|
||||
blog(LOG_ERROR, "[MigratePersistentData] Failed to create directory `%s`: %s", moduleConfigDirectory.c_str(),
|
||||
ec.message().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
// Move any existing persistent data to module config directory, then delete old file
|
||||
std::string oldPersistentDataPath = Utils::Obs::StringHelper::GetCurrentProfilePath() + "/../../../obsWebSocketPersistentData.json";
|
||||
std::string oldPersistentDataPath =
|
||||
Utils::Obs::StringHelper::GetCurrentProfilePath() + "/../../../obsWebSocketPersistentData.json";
|
||||
if (std::filesystem::exists(oldPersistentDataPath, ec)) {
|
||||
std::string persistentDataPath = Utils::Obs::StringHelper::GetModuleConfigPath("persistent_data.json");
|
||||
std::filesystem::copy_file(oldPersistentDataPath, persistentDataPath, ec);
|
||||
|
@ -80,7 +80,8 @@ void EventHandler::ProcessSubscriptionChange(bool type, uint64_t eventSubscripti
|
||||
if ((eventSubscriptions & EventSubscription::InputVolumeMeters) != 0) {
|
||||
if (_inputVolumeMetersRef.fetch_add(1) == 0) {
|
||||
if (_inputVolumeMetersHandler)
|
||||
blog(LOG_WARNING, "[EventHandler::ProcessSubscription] Input volume meter handler already exists!");
|
||||
blog(LOG_WARNING,
|
||||
"[EventHandler::ProcessSubscription] Input volume meter handler already exists!");
|
||||
else
|
||||
_inputVolumeMetersHandler = std::make_unique<Utils::Obs::VolumeMeter::Handler>(
|
||||
std::bind(&EventHandler::HandleInputVolumeMeters, this, std::placeholders::_1));
|
||||
|
@ -36,16 +36,10 @@ public:
|
||||
|
||||
typedef std::function<void(uint64_t, std::string, json, uint8_t)>
|
||||
BroadcastCallback; // uint64_t requiredIntent, std::string eventType, json eventData, uint8_t rpcVersion
|
||||
inline void SetBroadcastCallback(BroadcastCallback cb)
|
||||
{
|
||||
_broadcastCallback = cb;
|
||||
}
|
||||
inline void SetBroadcastCallback(BroadcastCallback cb) { _broadcastCallback = cb; }
|
||||
|
||||
typedef std::function<void(bool)> ObsReadyCallback; // bool ready
|
||||
inline void SetObsReadyCallback(ObsReadyCallback cb)
|
||||
{
|
||||
_obsReadyCallback = cb;
|
||||
}
|
||||
inline void SetObsReadyCallback(ObsReadyCallback cb) { _obsReadyCallback = cb; }
|
||||
|
||||
void ProcessSubscriptionChange(bool type, uint64_t eventSubscriptions);
|
||||
|
||||
@ -130,7 +124,7 @@ private:
|
||||
calldata_t *data); // Direct callback
|
||||
static void HandleInputAudioMonitorTypeChanged(void *param,
|
||||
calldata_t *data); // Direct callback
|
||||
void HandleInputVolumeMeters(std::vector<json> inputs); // AudioMeter::Handler callback
|
||||
void HandleInputVolumeMeters(std::vector<json> inputs); // AudioMeter::Handler callback
|
||||
|
||||
// Transitions
|
||||
void HandleCurrentSceneTransitionChanged();
|
||||
@ -152,7 +146,7 @@ private:
|
||||
void HandleSourceFilterCreated(obs_source_t *source, obs_source_t *filter);
|
||||
void HandleSourceFilterRemoved(obs_source_t *source, obs_source_t *filter);
|
||||
static void HandleSourceFilterNameChanged(void *param,
|
||||
calldata_t *data); // Direct callback
|
||||
calldata_t *data); // Direct callback
|
||||
void HandleSourceFilterSettingsChanged(obs_source_t *source);
|
||||
static void HandleSourceFilterEnableStateChanged(void *param, calldata_t *data); // Direct callback
|
||||
|
||||
|
@ -177,10 +177,10 @@ void SettingsDialog::SaveFormData()
|
||||
}
|
||||
}
|
||||
|
||||
bool needsRestart =
|
||||
(conf->ServerEnabled != ui->enableWebSocketServerCheckBox->isChecked()) ||
|
||||
(conf->ServerPort != ui->serverPortSpinBox->value()) ||
|
||||
(ui->enableAuthenticationCheckBox->isChecked() && conf->ServerPassword != ui->serverPasswordLineEdit->text().toStdString());
|
||||
bool needsRestart = (conf->ServerEnabled != ui->enableWebSocketServerCheckBox->isChecked()) ||
|
||||
(conf->ServerPort != ui->serverPortSpinBox->value()) ||
|
||||
(ui->enableAuthenticationCheckBox->isChecked() &&
|
||||
conf->ServerPassword != ui->serverPasswordLineEdit->text().toStdString());
|
||||
|
||||
conf->ServerEnabled = ui->enableWebSocketServerCheckBox->isChecked();
|
||||
conf->AlertsEnabled = ui->enableSystemTrayAlertsCheckBox->isChecked();
|
||||
|
@ -82,9 +82,12 @@ bool obs_module_load(void)
|
||||
_webSocketServer = std::make_shared<WebSocketServer>();
|
||||
|
||||
// Attach event handlers between WebSocket server and event handler
|
||||
_eventHandler->SetBroadcastCallback(std::bind(&WebSocketServer::BroadcastEvent, _webSocketServer.get(), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4));
|
||||
_eventHandler->SetBroadcastCallback(std::bind(&WebSocketServer::BroadcastEvent, _webSocketServer.get(),
|
||||
std::placeholders::_1, std::placeholders::_2, std::placeholders::_3,
|
||||
std::placeholders::_4));
|
||||
_eventHandler->SetObsReadyCallback(std::bind(&WebSocketServer::SetObsReady, _webSocketServer.get(), std::placeholders::_1));
|
||||
_webSocketServer->SetClientSubscriptionCallback(std::bind(&EventHandler::ProcessSubscriptionChange, _eventHandler.get(), std::placeholders::_1, std::placeholders::_2));
|
||||
_webSocketServer->SetClientSubscriptionCallback(std::bind(&EventHandler::ProcessSubscriptionChange, _eventHandler.get(),
|
||||
std::placeholders::_1, std::placeholders::_2));
|
||||
|
||||
// Initialize the settings dialog
|
||||
obs_frontend_push_ui_translation(obs_module_get_string);
|
||||
|
@ -37,7 +37,9 @@ struct SerialFrameBatch {
|
||||
std::condition_variable condition;
|
||||
|
||||
SerialFrameBatch(RequestHandler &requestHandler, json &variables, bool haltOnFailure)
|
||||
: requestHandler(requestHandler), variables(variables), haltOnFailure(haltOnFailure)
|
||||
: requestHandler(requestHandler),
|
||||
variables(variables),
|
||||
haltOnFailure(haltOnFailure)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
@ -106,8 +106,7 @@ RequestResult RequestHandler::GetSceneItemId(const Request &request)
|
||||
{
|
||||
RequestStatus::RequestStatus statusCode;
|
||||
std::string comment;
|
||||
OBSSceneAutoRelease scene =
|
||||
request.ValidateScene2(statusCode, comment, OBS_WEBSOCKET_SCENE_FILTER_SCENE_OR_GROUP);
|
||||
OBSSceneAutoRelease scene = request.ValidateScene2(statusCode, comment, OBS_WEBSOCKET_SCENE_FILTER_SCENE_OR_GROUP);
|
||||
if (!(scene && request.ValidateString("sourceName", statusCode, comment))) // TODO: Source UUID support
|
||||
return RequestResult::Error(statusCode, comment);
|
||||
|
||||
@ -280,7 +279,8 @@ RequestResult RequestHandler::DuplicateSceneItem(const Request &request)
|
||||
// Get destination scene
|
||||
obs_scene_t *destinationScene;
|
||||
if (request.Contains("destinationSceneName")) {
|
||||
OBSSourceAutoRelease destinationSceneSource = request.ValidateSource("destinationSceneName", "destinationSceneUuid", statusCode, comment);
|
||||
OBSSourceAutoRelease destinationSceneSource =
|
||||
request.ValidateSource("destinationSceneName", "destinationSceneUuid", statusCode, comment);
|
||||
if (!destinationSceneSource)
|
||||
return RequestResult::Error(statusCode, comment);
|
||||
|
||||
@ -288,7 +288,8 @@ RequestResult RequestHandler::DuplicateSceneItem(const Request &request)
|
||||
if (obs_source_get_type(destinationSceneSource) != OBS_SOURCE_TYPE_SCENE)
|
||||
return RequestResult::Error(RequestStatus::InvalidResourceType, "The specified source is not a scene.");
|
||||
if (obs_source_is_group(destinationSceneSource))
|
||||
return RequestResult::Error(RequestStatus::InvalidResourceType, "The specified source is not a scene. (Is group)");
|
||||
return RequestResult::Error(RequestStatus::InvalidResourceType,
|
||||
"The specified source is not a scene. (Is group)");
|
||||
|
||||
destinationScene = obs_scene_get_ref(obs_scene_from_source(destinationSceneSource));
|
||||
} else {
|
||||
@ -346,7 +347,8 @@ RequestResult RequestHandler::GetSceneItemTransform(const Request &request)
|
||||
{
|
||||
RequestStatus::RequestStatus statusCode;
|
||||
std::string comment;
|
||||
OBSSceneItemAutoRelease sceneItem = request.ValidateSceneItem(statusCode, comment, OBS_WEBSOCKET_SCENE_FILTER_SCENE_OR_GROUP);
|
||||
OBSSceneItemAutoRelease sceneItem =
|
||||
request.ValidateSceneItem(statusCode, comment, OBS_WEBSOCKET_SCENE_FILTER_SCENE_OR_GROUP);
|
||||
if (!sceneItem)
|
||||
return RequestResult::Error(statusCode, comment);
|
||||
|
||||
@ -375,7 +377,8 @@ RequestResult RequestHandler::SetSceneItemTransform(const Request &request)
|
||||
{
|
||||
RequestStatus::RequestStatus statusCode;
|
||||
std::string comment;
|
||||
OBSSceneItemAutoRelease sceneItem = request.ValidateSceneItem(statusCode, comment, OBS_WEBSOCKET_SCENE_FILTER_SCENE_OR_GROUP);
|
||||
OBSSceneItemAutoRelease sceneItem =
|
||||
request.ValidateSceneItem(statusCode, comment, OBS_WEBSOCKET_SCENE_FILTER_SCENE_OR_GROUP);
|
||||
if (!(sceneItem && request.ValidateObject("sceneItemTransform", statusCode, comment)))
|
||||
return RequestResult::Error(statusCode, comment);
|
||||
|
||||
@ -533,7 +536,8 @@ RequestResult RequestHandler::GetSceneItemEnabled(const Request &request)
|
||||
{
|
||||
RequestStatus::RequestStatus statusCode;
|
||||
std::string comment;
|
||||
OBSSceneItemAutoRelease sceneItem = request.ValidateSceneItem(statusCode, comment, OBS_WEBSOCKET_SCENE_FILTER_SCENE_OR_GROUP);
|
||||
OBSSceneItemAutoRelease sceneItem =
|
||||
request.ValidateSceneItem(statusCode, comment, OBS_WEBSOCKET_SCENE_FILTER_SCENE_OR_GROUP);
|
||||
if (!sceneItem)
|
||||
return RequestResult::Error(statusCode, comment);
|
||||
|
||||
@ -564,7 +568,8 @@ RequestResult RequestHandler::SetSceneItemEnabled(const Request &request)
|
||||
{
|
||||
RequestStatus::RequestStatus statusCode;
|
||||
std::string comment;
|
||||
OBSSceneItemAutoRelease sceneItem = request.ValidateSceneItem(statusCode, comment, OBS_WEBSOCKET_SCENE_FILTER_SCENE_OR_GROUP);
|
||||
OBSSceneItemAutoRelease sceneItem =
|
||||
request.ValidateSceneItem(statusCode, comment, OBS_WEBSOCKET_SCENE_FILTER_SCENE_OR_GROUP);
|
||||
if (!(sceneItem && request.ValidateBoolean("sceneItemEnabled", statusCode, comment)))
|
||||
return RequestResult::Error(statusCode, comment);
|
||||
|
||||
@ -597,7 +602,8 @@ RequestResult RequestHandler::GetSceneItemLocked(const Request &request)
|
||||
{
|
||||
RequestStatus::RequestStatus statusCode;
|
||||
std::string comment;
|
||||
OBSSceneItemAutoRelease sceneItem = request.ValidateSceneItem(statusCode, comment, OBS_WEBSOCKET_SCENE_FILTER_SCENE_OR_GROUP);
|
||||
OBSSceneItemAutoRelease sceneItem =
|
||||
request.ValidateSceneItem(statusCode, comment, OBS_WEBSOCKET_SCENE_FILTER_SCENE_OR_GROUP);
|
||||
if (!sceneItem)
|
||||
return RequestResult::Error(statusCode, comment);
|
||||
|
||||
@ -628,7 +634,8 @@ RequestResult RequestHandler::SetSceneItemLocked(const Request &request)
|
||||
{
|
||||
RequestStatus::RequestStatus statusCode;
|
||||
std::string comment;
|
||||
OBSSceneItemAutoRelease sceneItem = request.ValidateSceneItem(statusCode, comment, OBS_WEBSOCKET_SCENE_FILTER_SCENE_OR_GROUP);
|
||||
OBSSceneItemAutoRelease sceneItem =
|
||||
request.ValidateSceneItem(statusCode, comment, OBS_WEBSOCKET_SCENE_FILTER_SCENE_OR_GROUP);
|
||||
if (!(sceneItem && request.ValidateBoolean("sceneItemLocked", statusCode, comment)))
|
||||
return RequestResult::Error(statusCode, comment);
|
||||
|
||||
@ -663,7 +670,8 @@ RequestResult RequestHandler::GetSceneItemIndex(const Request &request)
|
||||
{
|
||||
RequestStatus::RequestStatus statusCode;
|
||||
std::string comment;
|
||||
OBSSceneItemAutoRelease sceneItem = request.ValidateSceneItem(statusCode, comment, OBS_WEBSOCKET_SCENE_FILTER_SCENE_OR_GROUP);
|
||||
OBSSceneItemAutoRelease sceneItem =
|
||||
request.ValidateSceneItem(statusCode, comment, OBS_WEBSOCKET_SCENE_FILTER_SCENE_OR_GROUP);
|
||||
if (!sceneItem)
|
||||
return RequestResult::Error(statusCode, comment);
|
||||
|
||||
@ -694,7 +702,8 @@ RequestResult RequestHandler::SetSceneItemIndex(const Request &request)
|
||||
{
|
||||
RequestStatus::RequestStatus statusCode;
|
||||
std::string comment;
|
||||
OBSSceneItemAutoRelease sceneItem = request.ValidateSceneItem(statusCode, comment, OBS_WEBSOCKET_SCENE_FILTER_SCENE_OR_GROUP);
|
||||
OBSSceneItemAutoRelease sceneItem =
|
||||
request.ValidateSceneItem(statusCode, comment, OBS_WEBSOCKET_SCENE_FILTER_SCENE_OR_GROUP);
|
||||
if (!(sceneItem && request.ValidateNumber("sceneItemIndex", statusCode, comment, 0, 8192)))
|
||||
return RequestResult::Error(statusCode, comment);
|
||||
|
||||
@ -737,7 +746,8 @@ RequestResult RequestHandler::GetSceneItemBlendMode(const Request &request)
|
||||
{
|
||||
RequestStatus::RequestStatus statusCode;
|
||||
std::string comment;
|
||||
OBSSceneItemAutoRelease sceneItem = request.ValidateSceneItem(statusCode, comment, OBS_WEBSOCKET_SCENE_FILTER_SCENE_OR_GROUP);
|
||||
OBSSceneItemAutoRelease sceneItem =
|
||||
request.ValidateSceneItem(statusCode, comment, OBS_WEBSOCKET_SCENE_FILTER_SCENE_OR_GROUP);
|
||||
if (!sceneItem)
|
||||
return RequestResult::Error(statusCode, comment);
|
||||
|
||||
@ -770,7 +780,8 @@ RequestResult RequestHandler::SetSceneItemBlendMode(const Request &request)
|
||||
{
|
||||
RequestStatus::RequestStatus statusCode;
|
||||
std::string comment;
|
||||
OBSSceneItemAutoRelease sceneItem = request.ValidateSceneItem(statusCode, comment, OBS_WEBSOCKET_SCENE_FILTER_SCENE_OR_GROUP);
|
||||
OBSSceneItemAutoRelease sceneItem =
|
||||
request.ValidateSceneItem(statusCode, comment, OBS_WEBSOCKET_SCENE_FILTER_SCENE_OR_GROUP);
|
||||
if (!(sceneItem && request.ValidateString("sceneItemBlendMode", statusCode, comment)))
|
||||
return RequestResult::Error(statusCode, comment);
|
||||
|
||||
@ -789,7 +800,8 @@ RequestResult RequestHandler::GetSceneItemPrivateSettings(const Request &request
|
||||
{
|
||||
RequestStatus::RequestStatus statusCode;
|
||||
std::string comment;
|
||||
OBSSceneItemAutoRelease sceneItem = request.ValidateSceneItem(statusCode, comment, OBS_WEBSOCKET_SCENE_FILTER_SCENE_OR_GROUP);
|
||||
OBSSceneItemAutoRelease sceneItem =
|
||||
request.ValidateSceneItem(statusCode, comment, OBS_WEBSOCKET_SCENE_FILTER_SCENE_OR_GROUP);
|
||||
if (!sceneItem)
|
||||
return RequestResult::Error(statusCode, comment);
|
||||
|
||||
@ -806,7 +818,8 @@ RequestResult RequestHandler::SetSceneItemPrivateSettings(const Request &request
|
||||
{
|
||||
RequestStatus::RequestStatus statusCode;
|
||||
std::string comment;
|
||||
OBSSceneItemAutoRelease sceneItem = request.ValidateSceneItem(statusCode, comment, OBS_WEBSOCKET_SCENE_FILTER_SCENE_OR_GROUP);
|
||||
OBSSceneItemAutoRelease sceneItem =
|
||||
request.ValidateSceneItem(statusCode, comment, OBS_WEBSOCKET_SCENE_FILTER_SCENE_OR_GROUP);
|
||||
if (!sceneItem || !request.ValidateObject("sceneItemSettings", statusCode, comment, true))
|
||||
return RequestResult::Error(statusCode, comment);
|
||||
|
||||
|
@ -211,8 +211,8 @@ bool Request::ValidateArray(const std::string &keyName, RequestStatus::RequestSt
|
||||
return true;
|
||||
}
|
||||
|
||||
obs_source_t *Request::ValidateSource(const std::string &nameKeyName, const std::string &uuidKeyName, RequestStatus::RequestStatus &statusCode,
|
||||
std::string &comment) const
|
||||
obs_source_t *Request::ValidateSource(const std::string &nameKeyName, const std::string &uuidKeyName,
|
||||
RequestStatus::RequestStatus &statusCode, std::string &comment) const
|
||||
{
|
||||
if (ValidateString(nameKeyName, statusCode, comment)) {
|
||||
std::string sourceName = RequestData[nameKeyName];
|
||||
@ -237,11 +237,13 @@ obs_source_t *Request::ValidateSource(const std::string &nameKeyName, const std:
|
||||
}
|
||||
|
||||
statusCode = RequestStatus::MissingRequestField;
|
||||
comment = std::string("Your request must contain at least one of the following fields: `") + nameKeyName + "` or `" + uuidKeyName + "`.";
|
||||
comment = std::string("Your request must contain at least one of the following fields: `") + nameKeyName + "` or `" +
|
||||
uuidKeyName + "`.";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
obs_source_t *Request::ValidateScene(RequestStatus::RequestStatus &statusCode, std::string &comment, const ObsWebSocketSceneFilter filter) const
|
||||
obs_source_t *Request::ValidateScene(RequestStatus::RequestStatus &statusCode, std::string &comment,
|
||||
const ObsWebSocketSceneFilter filter) const
|
||||
{
|
||||
obs_source_t *ret = ValidateSource("sceneName", "sceneUuid", statusCode, comment);
|
||||
if (!ret)
|
||||
@ -270,7 +272,8 @@ obs_source_t *Request::ValidateScene(RequestStatus::RequestStatus &statusCode, s
|
||||
return ret;
|
||||
}
|
||||
|
||||
obs_scene_t *Request::ValidateScene2(RequestStatus::RequestStatus &statusCode, std::string &comment, const ObsWebSocketSceneFilter filter) const
|
||||
obs_scene_t *Request::ValidateScene2(RequestStatus::RequestStatus &statusCode, std::string &comment,
|
||||
const ObsWebSocketSceneFilter filter) const
|
||||
{
|
||||
OBSSourceAutoRelease sceneSource = ValidateSource("sceneName", "sceneUuid", statusCode, comment);
|
||||
if (!sceneSource)
|
||||
@ -338,7 +341,8 @@ FilterPair Request::ValidateFilter(RequestStatus::RequestStatus &statusCode, std
|
||||
return FilterPair{source, filter};
|
||||
}
|
||||
|
||||
obs_sceneitem_t *Request::ValidateSceneItem(RequestStatus::RequestStatus &statusCode, std::string &comment, const ObsWebSocketSceneFilter filter) const
|
||||
obs_sceneitem_t *Request::ValidateSceneItem(RequestStatus::RequestStatus &statusCode, std::string &comment,
|
||||
const ObsWebSocketSceneFilter filter) const
|
||||
{
|
||||
OBSSceneAutoRelease scene = ValidateScene2(statusCode, comment, filter);
|
||||
if (!scene)
|
||||
@ -353,7 +357,8 @@ obs_sceneitem_t *Request::ValidateSceneItem(RequestStatus::RequestStatus &status
|
||||
if (!sceneItem) {
|
||||
std::string sceneName = obs_source_get_name(obs_scene_get_source(scene));
|
||||
statusCode = RequestStatus::ResourceNotFound;
|
||||
comment = std::string("No scene items were found in scene `") + sceneName + "` with the ID `" + std::to_string(sceneItemId) + "`.";
|
||||
comment = std::string("No scene items were found in scene `") + sceneName + "` with the ID `" +
|
||||
std::to_string(sceneItemId) + "`.";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -64,13 +64,18 @@ struct Request {
|
||||
const bool allowEmpty = false) const;
|
||||
|
||||
// All return values have incremented refcounts
|
||||
obs_source_t *ValidateSource(const std::string &nameKeyName, const std::string &uuidKeyName, RequestStatus::RequestStatus &statusCode, std::string &comment) const;
|
||||
obs_source_t *ValidateScene(RequestStatus::RequestStatus &statusCode, std::string &comment, const ObsWebSocketSceneFilter filter = OBS_WEBSOCKET_SCENE_FILTER_SCENE_ONLY) const;
|
||||
obs_scene_t *ValidateScene2(RequestStatus::RequestStatus &statusCode, std::string &comment, const ObsWebSocketSceneFilter filter = OBS_WEBSOCKET_SCENE_FILTER_SCENE_ONLY) const;
|
||||
obs_source_t *ValidateSource(const std::string &nameKeyName, const std::string &uuidKeyName,
|
||||
RequestStatus::RequestStatus &statusCode, std::string &comment) const;
|
||||
obs_source_t *ValidateScene(RequestStatus::RequestStatus &statusCode, std::string &comment,
|
||||
const ObsWebSocketSceneFilter filter = OBS_WEBSOCKET_SCENE_FILTER_SCENE_ONLY) const;
|
||||
obs_scene_t *ValidateScene2(RequestStatus::RequestStatus &statusCode, std::string &comment,
|
||||
const ObsWebSocketSceneFilter filter = OBS_WEBSOCKET_SCENE_FILTER_SCENE_ONLY) const;
|
||||
obs_source_t *ValidateInput(RequestStatus::RequestStatus &statusCode, std::string &comment) const;
|
||||
FilterPair ValidateFilter(RequestStatus::RequestStatus &statusCode, std::string &comment) const;
|
||||
obs_sceneitem_t *ValidateSceneItem(RequestStatus::RequestStatus &statusCode, std::string &comment, const ObsWebSocketSceneFilter filter = OBS_WEBSOCKET_SCENE_FILTER_SCENE_ONLY) const;
|
||||
obs_output_t *ValidateOutput(const std::string &keyName, RequestStatus::RequestStatus &statusCode, std::string &comment) const;
|
||||
obs_sceneitem_t *ValidateSceneItem(RequestStatus::RequestStatus &statusCode, std::string &comment,
|
||||
const ObsWebSocketSceneFilter filter = OBS_WEBSOCKET_SCENE_FILTER_SCENE_ONLY) const;
|
||||
obs_output_t *ValidateOutput(const std::string &keyName, RequestStatus::RequestStatus &statusCode,
|
||||
std::string &comment) const;
|
||||
|
||||
std::string RequestType;
|
||||
bool HasRequestData;
|
||||
|
@ -21,6 +21,8 @@ with this program. If not, see <https://www.gnu.org/licenses/>
|
||||
RequestBatchRequest::RequestBatchRequest(const std::string &requestType, const json &requestData,
|
||||
RequestBatchExecutionType::RequestBatchExecutionType executionType,
|
||||
const json &inputVariables, const json &outputVariables)
|
||||
: Request(requestType, requestData, executionType), InputVariables(inputVariables), OutputVariables(outputVariables)
|
||||
: Request(requestType, requestData, executionType),
|
||||
InputVariables(inputVariables),
|
||||
OutputVariables(outputVariables)
|
||||
{
|
||||
}
|
||||
|
@ -20,7 +20,10 @@ with this program. If not, see <https://www.gnu.org/licenses/>
|
||||
#include "RequestResult.h"
|
||||
|
||||
RequestResult::RequestResult(RequestStatus::RequestStatus statusCode, json responseData, std::string comment)
|
||||
: StatusCode(statusCode), ResponseData(responseData), Comment(comment), SleepFrames(0)
|
||||
: StatusCode(statusCode),
|
||||
ResponseData(responseData),
|
||||
Comment(comment),
|
||||
SleepFrames(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -77,5 +77,8 @@ namespace RequestBatchExecutionType {
|
||||
Parallel = 2,
|
||||
};
|
||||
|
||||
inline bool IsValid(int8_t executionType) { return executionType >= None && executionType <= Parallel; }
|
||||
inline bool IsValid(int8_t executionType)
|
||||
{
|
||||
return executionType >= None && executionType <= Parallel;
|
||||
}
|
||||
}
|
||||
|
@ -185,7 +185,8 @@ bool Utils::Json::GetJsonFileContent(std::string fileName, json &content)
|
||||
try {
|
||||
content = json::parse(f);
|
||||
} catch (json::parse_error &e) {
|
||||
blog(LOG_WARNING, "[Utils::Json::GetJsonFileContent] Failed to decode content of JSON file `%s`. Error: %s", fileName.c_str(), e.what());
|
||||
blog(LOG_WARNING, "[Utils::Json::GetJsonFileContent] Failed to decode content of JSON file `%s`. Error: %s",
|
||||
fileName.c_str(), e.what());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -200,7 +201,8 @@ bool Utils::Json::SetJsonFileContent(std::string fileName, const json &content,
|
||||
if (!ec && !std::filesystem::exists(p, ec))
|
||||
std::filesystem::create_directories(p, ec);
|
||||
if (ec) {
|
||||
blog(LOG_ERROR, "[Utils::Json::SetJsonFileContent] Failed to create path directories: %s", ec.message().c_str());
|
||||
blog(LOG_ERROR, "[Utils::Json::SetJsonFileContent] Failed to create path directories: %s",
|
||||
ec.message().c_str());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -77,6 +77,9 @@ namespace Utils {
|
||||
json ObsDataToJson(obs_data_t *d, bool includeDefault = false);
|
||||
bool GetJsonFileContent(std::string fileName, json &content);
|
||||
bool SetJsonFileContent(std::string fileName, const json &content, bool makeDirs = true);
|
||||
static inline bool Contains(const json &j, std::string key) { return j.contains(key) && !j[key].is_null(); }
|
||||
static inline bool Contains(const json &j, std::string key)
|
||||
{
|
||||
return j.contains(key) && !j[key].is_null();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -32,40 +32,43 @@ obs_hotkey_t *Utils::Obs::SearchHelper::GetHotkeyByName(std::string name, std::s
|
||||
|
||||
if (context.empty())
|
||||
return hotkey;
|
||||
|
||||
|
||||
auto type = obs_hotkey_get_registerer_type(hotkey);
|
||||
if (type == OBS_HOTKEY_REGISTERER_SOURCE) {
|
||||
OBSSourceAutoRelease source = obs_weak_source_get_source((obs_weak_source_t *)obs_hotkey_get_registerer(hotkey));
|
||||
OBSSourceAutoRelease source =
|
||||
obs_weak_source_get_source((obs_weak_source_t *)obs_hotkey_get_registerer(hotkey));
|
||||
if (!source)
|
||||
continue;
|
||||
|
||||
if (context != obs_source_get_name(source))
|
||||
if (context != obs_source_get_name(source))
|
||||
continue;
|
||||
|
||||
} else if (type == OBS_HOTKEY_REGISTERER_OUTPUT) {
|
||||
OBSOutputAutoRelease output = obs_weak_output_get_output((obs_weak_output_t *)obs_hotkey_get_registerer(hotkey));
|
||||
OBSOutputAutoRelease output =
|
||||
obs_weak_output_get_output((obs_weak_output_t *)obs_hotkey_get_registerer(hotkey));
|
||||
if (!output)
|
||||
continue;
|
||||
|
||||
if (context != obs_output_get_name(output))
|
||||
continue;
|
||||
|
||||
|
||||
} else if (type == OBS_HOTKEY_REGISTERER_ENCODER) {
|
||||
OBSEncoderAutoRelease encoder = obs_weak_encoder_get_encoder((obs_weak_encoder_t *)obs_hotkey_get_registerer(hotkey));
|
||||
OBSEncoderAutoRelease encoder =
|
||||
obs_weak_encoder_get_encoder((obs_weak_encoder_t *)obs_hotkey_get_registerer(hotkey));
|
||||
if (!encoder)
|
||||
continue;
|
||||
|
||||
if (context != obs_encoder_get_name(encoder))
|
||||
if (context != obs_encoder_get_name(encoder))
|
||||
continue;
|
||||
|
||||
|
||||
} else if (type == OBS_HOTKEY_REGISTERER_SERVICE) {
|
||||
OBSServiceAutoRelease service = obs_weak_service_get_service((obs_weak_service_t *)obs_hotkey_get_registerer(hotkey));
|
||||
OBSServiceAutoRelease service =
|
||||
obs_weak_service_get_service((obs_weak_service_t *)obs_hotkey_get_registerer(hotkey));
|
||||
if (!service)
|
||||
continue;
|
||||
|
||||
if (context != obs_service_get_name(service))
|
||||
continue;
|
||||
|
||||
}
|
||||
return hotkey;
|
||||
}
|
||||
|
@ -238,7 +238,9 @@ void Utils::Obs::VolumeMeter::Meter::InputVolumeCallback(void *priv_data, callda
|
||||
}
|
||||
|
||||
Utils::Obs::VolumeMeter::Handler::Handler(UpdateCallback cb, uint64_t updatePeriod)
|
||||
: _updateCallback(cb), _updatePeriod(updatePeriod), _running(false)
|
||||
: _updateCallback(cb),
|
||||
_updatePeriod(updatePeriod),
|
||||
_running(false)
|
||||
{
|
||||
signal_handler_t *sh = obs_get_signal_handler();
|
||||
if (!sh)
|
||||
|
@ -61,10 +61,7 @@ public:
|
||||
|
||||
// Callback for when a client subscribes or unsubscribes. `true` for sub, `false` for unsub
|
||||
typedef std::function<void(bool, uint64_t)> ClientSubscriptionCallback; // bool type, uint64_t eventSubscriptions
|
||||
inline void SetClientSubscriptionCallback(ClientSubscriptionCallback cb)
|
||||
{
|
||||
_clientSubscriptionCallback = cb;
|
||||
}
|
||||
inline void SetClientSubscriptionCallback(ClientSubscriptionCallback cb) { _clientSubscriptionCallback = cb; }
|
||||
|
||||
inline bool IsListening() { return _server.is_listening(); }
|
||||
|
||||
|
@ -122,5 +122,8 @@ namespace WebSocketOpCode {
|
||||
RequestBatchResponse = 9,
|
||||
};
|
||||
|
||||
inline bool IsValid(uint8_t opCode) { return opCode >= Hello && opCode <= RequestBatchResponse; }
|
||||
inline bool IsValid(uint8_t opCode)
|
||||
{
|
||||
return opCode >= Hello && opCode <= RequestBatchResponse;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user