From 5fc39ef054db4a5976b903921fb8965c100ee31e Mon Sep 17 00:00:00 2001 From: tt2468 Date: Mon, 22 Apr 2024 23:44:04 -0700 Subject: [PATCH] base: Apply latest clang-format changes from upstream Minus, some customizations, of course --- .clang-format | 131 ++++++++++++++++-- src/Config.cpp | 6 +- src/eventhandler/EventHandler.cpp | 3 +- src/eventhandler/EventHandler.h | 14 +- src/forms/SettingsDialog.cpp | 8 +- src/obs-websocket.cpp | 7 +- src/requesthandler/RequestBatchHandler.cpp | 4 +- .../RequestHandler_SceneItems.cpp | 45 +++--- src/requesthandler/rpc/Request.cpp | 19 ++- src/requesthandler/rpc/Request.h | 15 +- .../rpc/RequestBatchRequest.cpp | 4 +- src/requesthandler/rpc/RequestResult.cpp | 5 +- .../types/RequestBatchExecutionType.h | 5 +- src/utils/Json.cpp | 6 +- src/utils/Json.h | 5 +- src/utils/Obs_SearchHelper.cpp | 23 +-- src/utils/Obs_VolumeMeter.cpp | 4 +- src/websocketserver/WebSocketServer.h | 5 +- src/websocketserver/types/WebSocketOpCode.h | 5 +- 19 files changed, 229 insertions(+), 85 deletions(-) diff --git a/.clang-format b/.clang-format index d32a64517..870fb4a5d 100644 --- a/.clang-format +++ b/.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 diff --git a/src/Config.cpp b/src/Config.cpp index 55e5c761c..7af55b434 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -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); diff --git a/src/eventhandler/EventHandler.cpp b/src/eventhandler/EventHandler.cpp index ae8a796d3..874878a5a 100644 --- a/src/eventhandler/EventHandler.cpp +++ b/src/eventhandler/EventHandler.cpp @@ -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( std::bind(&EventHandler::HandleInputVolumeMeters, this, std::placeholders::_1)); diff --git a/src/eventhandler/EventHandler.h b/src/eventhandler/EventHandler.h index 6d52932da..163879e1c 100644 --- a/src/eventhandler/EventHandler.h +++ b/src/eventhandler/EventHandler.h @@ -36,16 +36,10 @@ class EventHandler { typedef std::function 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 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 @@ class EventHandler { calldata_t *data); // Direct callback static void HandleInputAudioMonitorTypeChanged(void *param, calldata_t *data); // Direct callback - void HandleInputVolumeMeters(std::vector inputs); // AudioMeter::Handler callback + void HandleInputVolumeMeters(std::vector inputs); // AudioMeter::Handler callback // Transitions void HandleCurrentSceneTransitionChanged(); @@ -152,7 +146,7 @@ class EventHandler { 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 diff --git a/src/forms/SettingsDialog.cpp b/src/forms/SettingsDialog.cpp index 5e8ff8f9d..c59d5fb9b 100644 --- a/src/forms/SettingsDialog.cpp +++ b/src/forms/SettingsDialog.cpp @@ -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(); diff --git a/src/obs-websocket.cpp b/src/obs-websocket.cpp index 589f8bf92..e399abc43 100644 --- a/src/obs-websocket.cpp +++ b/src/obs-websocket.cpp @@ -82,9 +82,12 @@ bool obs_module_load(void) _webSocketServer = std::make_shared(); // 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); diff --git a/src/requesthandler/RequestBatchHandler.cpp b/src/requesthandler/RequestBatchHandler.cpp index 21e28c4f7..15302aa6b 100644 --- a/src/requesthandler/RequestBatchHandler.cpp +++ b/src/requesthandler/RequestBatchHandler.cpp @@ -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) { } }; diff --git a/src/requesthandler/RequestHandler_SceneItems.cpp b/src/requesthandler/RequestHandler_SceneItems.cpp index 410ae9f29..67c5333ac 100644 --- a/src/requesthandler/RequestHandler_SceneItems.cpp +++ b/src/requesthandler/RequestHandler_SceneItems.cpp @@ -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); diff --git a/src/requesthandler/rpc/Request.cpp b/src/requesthandler/rpc/Request.cpp index d131e506b..dc9320a95 100644 --- a/src/requesthandler/rpc/Request.cpp +++ b/src/requesthandler/rpc/Request.cpp @@ -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; } diff --git a/src/requesthandler/rpc/Request.h b/src/requesthandler/rpc/Request.h index ef96e5bb5..77eb2c5ca 100644 --- a/src/requesthandler/rpc/Request.h +++ b/src/requesthandler/rpc/Request.h @@ -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; diff --git a/src/requesthandler/rpc/RequestBatchRequest.cpp b/src/requesthandler/rpc/RequestBatchRequest.cpp index c89fd3a0d..b0bbf0336 100644 --- a/src/requesthandler/rpc/RequestBatchRequest.cpp +++ b/src/requesthandler/rpc/RequestBatchRequest.cpp @@ -21,6 +21,8 @@ with this program. If not, see 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) { } diff --git a/src/requesthandler/rpc/RequestResult.cpp b/src/requesthandler/rpc/RequestResult.cpp index 00f79f112..2714838ec 100644 --- a/src/requesthandler/rpc/RequestResult.cpp +++ b/src/requesthandler/rpc/RequestResult.cpp @@ -20,7 +20,10 @@ with this program. If not, see #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) { } diff --git a/src/requesthandler/types/RequestBatchExecutionType.h b/src/requesthandler/types/RequestBatchExecutionType.h index 6bd65fa87..1ce6d92a0 100644 --- a/src/requesthandler/types/RequestBatchExecutionType.h +++ b/src/requesthandler/types/RequestBatchExecutionType.h @@ -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; + } } diff --git a/src/utils/Json.cpp b/src/utils/Json.cpp index 9211b3dca..68f058810 100644 --- a/src/utils/Json.cpp +++ b/src/utils/Json.cpp @@ -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; } } diff --git a/src/utils/Json.h b/src/utils/Json.h index b9f013c1c..9e1349d94 100644 --- a/src/utils/Json.h +++ b/src/utils/Json.h @@ -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(); + } } } diff --git a/src/utils/Obs_SearchHelper.cpp b/src/utils/Obs_SearchHelper.cpp index 7b98512af..861e254b5 100644 --- a/src/utils/Obs_SearchHelper.cpp +++ b/src/utils/Obs_SearchHelper.cpp @@ -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; } diff --git a/src/utils/Obs_VolumeMeter.cpp b/src/utils/Obs_VolumeMeter.cpp index 0aa718b4d..1afa2c9e6 100644 --- a/src/utils/Obs_VolumeMeter.cpp +++ b/src/utils/Obs_VolumeMeter.cpp @@ -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) diff --git a/src/websocketserver/WebSocketServer.h b/src/websocketserver/WebSocketServer.h index 23fea7aac..091a4fbe2 100644 --- a/src/websocketserver/WebSocketServer.h +++ b/src/websocketserver/WebSocketServer.h @@ -61,10 +61,7 @@ class WebSocketServer : QObject { // Callback for when a client subscribes or unsubscribes. `true` for sub, `false` for unsub typedef std::function 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(); } diff --git a/src/websocketserver/types/WebSocketOpCode.h b/src/websocketserver/types/WebSocketOpCode.h index 152456b83..3ae1e3ab7 100644 --- a/src/websocketserver/types/WebSocketOpCode.h +++ b/src/websocketserver/types/WebSocketOpCode.h @@ -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; + } }