From 5b8fd096d55eff2d8ee85ccfef73413856be78bd Mon Sep 17 00:00:00 2001 From: tt2468 Date: Wed, 8 Jun 2022 00:37:04 -0700 Subject: [PATCH] clang-format: Indent namespaces --- .clang-format | 2 +- src/eventhandler/types/EventSubscription.h | 73 +++++----- src/requesthandler/RequestBatchHandler.h | 7 +- .../types/RequestBatchExecutionType.h | 25 ++-- src/requesthandler/types/RequestStatus.h | 136 +++++++++--------- src/utils/Compat.h | 20 +-- src/utils/Crypto.h | 12 +- src/utils/Json.h | 19 ++- src/utils/Obs.h | 107 +++++++------- src/utils/Obs_VolumeMeter.h | 105 +++++++------- src/utils/Platform.h | 16 +-- .../types/WebSocketCloseCode.h | 56 ++++---- src/websocketserver/types/WebSocketOpCode.h | 45 +++--- 13 files changed, 310 insertions(+), 313 deletions(-) diff --git a/.clang-format b/.clang-format index 4a702125..d32a6451 100644 --- a/.clang-format +++ b/.clang-format @@ -64,7 +64,7 @@ IndentWidth: 8 IndentWrappedFunctionNames: false KeepEmptyLinesAtTheStartOfBlocks: true MaxEmptyLinesToKeep: 1 -NamespaceIndentation: None +NamespaceIndentation: All #ObjCBinPackProtocolList: Auto # requires clang-format 7 ObjCBlockIndentWidth: 8 ObjCSpaceAfterProperty: true diff --git a/src/eventhandler/types/EventSubscription.h b/src/eventhandler/types/EventSubscription.h index 8110b664..e996bddf 100644 --- a/src/eventhandler/types/EventSubscription.h +++ b/src/eventhandler/types/EventSubscription.h @@ -20,8 +20,8 @@ with this program. If not, see #pragma once namespace EventSubscription { -enum EventSubscription { - /** + enum EventSubscription { + /** * Subcription value used to disable all events. * * @enumIdentifier None @@ -31,8 +31,8 @@ enum EventSubscription { * @initialVersion 5.0.0 * @api enums */ - None = 0, - /** + None = 0, + /** * Subscription value to receive events in the `General` category. * * @enumIdentifier General @@ -42,8 +42,8 @@ enum EventSubscription { * @initialVersion 5.0.0 * @api enums */ - General = (1 << 0), - /** + General = (1 << 0), + /** * Subscription value to receive events in the `Config` category. * * @enumIdentifier Config @@ -53,8 +53,8 @@ enum EventSubscription { * @initialVersion 5.0.0 * @api enums */ - Config = (1 << 1), - /** + Config = (1 << 1), + /** * Subscription value to receive events in the `Scenes` category. * * @enumIdentifier Scenes @@ -64,8 +64,8 @@ enum EventSubscription { * @initialVersion 5.0.0 * @api enums */ - Scenes = (1 << 2), - /** + Scenes = (1 << 2), + /** * Subscription value to receive events in the `Inputs` category. * * @enumIdentifier Inputs @@ -75,8 +75,8 @@ enum EventSubscription { * @initialVersion 5.0.0 * @api enums */ - Inputs = (1 << 3), - /** + Inputs = (1 << 3), + /** * Subscription value to receive events in the `Transitions` category. * * @enumIdentifier Transitions @@ -86,8 +86,8 @@ enum EventSubscription { * @initialVersion 5.0.0 * @api enums */ - Transitions = (1 << 4), - /** + Transitions = (1 << 4), + /** * Subscription value to receive events in the `Filters` category. * * @enumIdentifier Filters @@ -97,8 +97,8 @@ enum EventSubscription { * @initialVersion 5.0.0 * @api enums */ - Filters = (1 << 5), - /** + Filters = (1 << 5), + /** * Subscription value to receive events in the `Outputs` category. * * @enumIdentifier Outputs @@ -108,8 +108,8 @@ enum EventSubscription { * @initialVersion 5.0.0 * @api enums */ - Outputs = (1 << 6), - /** + Outputs = (1 << 6), + /** * Subscription value to receive events in the `SceneItems` category. * * @enumIdentifier SceneItems @@ -119,8 +119,8 @@ enum EventSubscription { * @initialVersion 5.0.0 * @api enums */ - SceneItems = (1 << 7), - /** + SceneItems = (1 << 7), + /** * Subscription value to receive events in the `MediaInputs` category. * * @enumIdentifier MediaInputs @@ -130,8 +130,8 @@ enum EventSubscription { * @initialVersion 5.0.0 * @api enums */ - MediaInputs = (1 << 8), - /** + MediaInputs = (1 << 8), + /** * Subscription value to receive the `VendorEvent` event. * * @enumIdentifier Vendors @@ -141,8 +141,8 @@ enum EventSubscription { * @initialVersion 5.0.0 * @api enums */ - Vendors = (1 << 9), - /** + Vendors = (1 << 9), + /** * Subscription value to receive events in the `Ui` category. * * @enumIdentifier Ui @@ -152,8 +152,8 @@ enum EventSubscription { * @initialVersion 5.0.0 * @api enums */ - Ui = (1 << 10), - /** + Ui = (1 << 10), + /** * Helper to receive all non-high-volume events. * * @enumIdentifier All @@ -163,8 +163,9 @@ enum EventSubscription { * @initialVersion 5.0.0 * @api enums */ - All = (General | Config | Scenes | Inputs | Transitions | Filters | Outputs | SceneItems | MediaInputs | Vendors | Ui), - /** + All = (General | Config | Scenes | Inputs | Transitions | Filters | Outputs | SceneItems | MediaInputs | Vendors | + Ui), + /** * Subscription value to receive the `InputVolumeMeters` high-volume event. * * @enumIdentifier InputVolumeMeters @@ -174,8 +175,8 @@ enum EventSubscription { * @initialVersion 5.0.0 * @api enums */ - InputVolumeMeters = (1 << 16), - /** + InputVolumeMeters = (1 << 16), + /** * Subscription value to receive the `InputActiveStateChanged` high-volume event. * * @enumIdentifier InputActiveStateChanged @@ -185,8 +186,8 @@ enum EventSubscription { * @initialVersion 5.0.0 * @api enums */ - InputActiveStateChanged = (1 << 17), - /** + InputActiveStateChanged = (1 << 17), + /** * Subscription value to receive the `InputShowStateChanged` high-volume event. * * @enumIdentifier InputShowStateChanged @@ -196,8 +197,8 @@ enum EventSubscription { * @initialVersion 5.0.0 * @api enums */ - InputShowStateChanged = (1 << 18), - /** + InputShowStateChanged = (1 << 18), + /** * Subscription value to receive the `SceneItemTransformChanged` high-volume event. * * @enumIdentifier SceneItemTransformChanged @@ -207,6 +208,6 @@ enum EventSubscription { * @initialVersion 5.0.0 * @api enums */ - SceneItemTransformChanged = (1 << 19), -}; + SceneItemTransformChanged = (1 << 19), + }; } diff --git a/src/requesthandler/RequestBatchHandler.h b/src/requesthandler/RequestBatchHandler.h index 10ac2a5a..be47a926 100644 --- a/src/requesthandler/RequestBatchHandler.h +++ b/src/requesthandler/RequestBatchHandler.h @@ -24,7 +24,8 @@ with this program. If not, see #include "rpc/RequestBatchRequest.h" namespace RequestBatchHandler { -std::vector ProcessRequestBatch(QThreadPool &threadPool, SessionPtr session, - RequestBatchExecutionType::RequestBatchExecutionType executionType, - std::vector &requests, json &variables, bool haltOnFailure); + std::vector ProcessRequestBatch(QThreadPool &threadPool, SessionPtr session, + RequestBatchExecutionType::RequestBatchExecutionType executionType, + std::vector &requests, json &variables, + bool haltOnFailure); } diff --git a/src/requesthandler/types/RequestBatchExecutionType.h b/src/requesthandler/types/RequestBatchExecutionType.h index a1871f53..6bd65fa8 100644 --- a/src/requesthandler/types/RequestBatchExecutionType.h +++ b/src/requesthandler/types/RequestBatchExecutionType.h @@ -22,8 +22,8 @@ with this program. If not, see #include namespace RequestBatchExecutionType { -enum RequestBatchExecutionType : int8_t { - /** + enum RequestBatchExecutionType : int8_t { + /** * Not a request batch. * * @enumIdentifier None @@ -33,8 +33,8 @@ enum RequestBatchExecutionType : int8_t { * @initialVersion 5.0.0 * @api enums */ - None = -1, - /** + None = -1, + /** * A request batch which processes all requests serially, as fast as possible. * * Note: To introduce artificial delay, use the `Sleep` request and the `sleepMillis` request field. @@ -46,8 +46,8 @@ enum RequestBatchExecutionType : int8_t { * @initialVersion 5.0.0 * @api enums */ - SerialRealtime = 0, - /** + SerialRealtime = 0, + /** * A request batch type which processes all requests serially, in sync with the graphics thread. Designed to * provide high accuracy for animations. * @@ -60,8 +60,8 @@ enum RequestBatchExecutionType : int8_t { * @initialVersion 5.0.0 * @api enums */ - SerialFrame = 1, - /** + SerialFrame = 1, + /** * A request batch type which processes all requests using all available threads in the thread pool. * * Note: This is mainly experimental, and only really shows its colors during requests which require lots of @@ -74,11 +74,8 @@ enum RequestBatchExecutionType : int8_t { * @initialVersion 5.0.0 * @api enums */ - Parallel = 2, -}; + 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/requesthandler/types/RequestStatus.h b/src/requesthandler/types/RequestStatus.h index e6616e5b..604863c8 100644 --- a/src/requesthandler/types/RequestStatus.h +++ b/src/requesthandler/types/RequestStatus.h @@ -20,8 +20,8 @@ with this program. If not, see #pragma once namespace RequestStatus { -enum RequestStatus { - /** + enum RequestStatus { + /** * Unknown status, should never be used. * * @enumIdentifier Unknown @@ -31,9 +31,9 @@ enum RequestStatus { * @initialVersion 5.0.0 * @api enums */ - Unknown = 0, + Unknown = 0, - /** + /** * For internal use to signify a successful field check. * * @enumIdentifier NoError @@ -43,9 +43,9 @@ enum RequestStatus { * @initialVersion 5.0.0 * @api enums */ - NoError = 10, + NoError = 10, - /** + /** * The request has succeeded. * * @enumIdentifier Success @@ -55,9 +55,9 @@ enum RequestStatus { * @initialVersion 5.0.0 * @api enums */ - Success = 100, + Success = 100, - /** + /** * The `requestType` field is missing from the request data. * * @enumIdentifier MissingRequestType @@ -67,8 +67,8 @@ enum RequestStatus { * @initialVersion 5.0.0 * @api enums */ - MissingRequestType = 203, - /** + MissingRequestType = 203, + /** * The request type is invalid or does not exist. * * @enumIdentifier UnknownRequestType @@ -78,8 +78,8 @@ enum RequestStatus { * @initialVersion 5.0.0 * @api enums */ - UnknownRequestType = 204, - /** + UnknownRequestType = 204, + /** * Generic error code. * * Note: A comment is required to be provided by obs-websocket. @@ -91,8 +91,8 @@ enum RequestStatus { * @initialVersion 5.0.0 * @api enums */ - GenericError = 205, - /** + GenericError = 205, + /** * The request batch execution type is not supported. * * @enumIdentifier UnsupportedRequestBatchExecutionType @@ -102,9 +102,9 @@ enum RequestStatus { * @initialVersion 5.0.0 * @api enums */ - UnsupportedRequestBatchExecutionType = 206, + UnsupportedRequestBatchExecutionType = 206, - /** + /** * A required request field is missing. * * @enumIdentifier MissingRequestField @@ -114,8 +114,8 @@ enum RequestStatus { * @initialVersion 5.0.0 * @api enums */ - MissingRequestField = 300, - /** + MissingRequestField = 300, + /** * The request does not have a valid requestData object. * * @enumIdentifier MissingRequestData @@ -125,9 +125,9 @@ enum RequestStatus { * @initialVersion 5.0.0 * @api enums */ - MissingRequestData = 301, + MissingRequestData = 301, - /** + /** * Generic invalid request field message. * * Note: A comment is required to be provided by obs-websocket. @@ -139,8 +139,8 @@ enum RequestStatus { * @initialVersion 5.0.0 * @api enums */ - InvalidRequestField = 400, - /** + InvalidRequestField = 400, + /** * A request field has the wrong data type. * * @enumIdentifier InvalidRequestFieldType @@ -150,8 +150,8 @@ enum RequestStatus { * @initialVersion 5.0.0 * @api enums */ - InvalidRequestFieldType = 401, - /** + InvalidRequestFieldType = 401, + /** * A request field (number) is outside of the allowed range. * * @enumIdentifier RequestFieldOutOfRange @@ -161,8 +161,8 @@ enum RequestStatus { * @initialVersion 5.0.0 * @api enums */ - RequestFieldOutOfRange = 402, - /** + RequestFieldOutOfRange = 402, + /** * A request field (string or array) is empty and cannot be. * * @enumIdentifier RequestFieldEmpty @@ -172,8 +172,8 @@ enum RequestStatus { * @initialVersion 5.0.0 * @api enums */ - RequestFieldEmpty = 403, - /** + RequestFieldEmpty = 403, + /** * There are too many request fields (eg. a request takes two optionals, where only one is allowed at a time). * * @enumIdentifier TooManyRequestFields @@ -183,9 +183,9 @@ enum RequestStatus { * @initialVersion 5.0.0 * @api enums */ - TooManyRequestFields = 404, + TooManyRequestFields = 404, - /** + /** * An output is running and cannot be in order to perform the request. * * @enumIdentifier OutputRunning @@ -195,8 +195,8 @@ enum RequestStatus { * @initialVersion 5.0.0 * @api enums */ - OutputRunning = 500, - /** + OutputRunning = 500, + /** * An output is not running and should be. * * @enumIdentifier OutputNotRunning @@ -206,8 +206,8 @@ enum RequestStatus { * @initialVersion 5.0.0 * @api enums */ - OutputNotRunning = 501, - /** + OutputNotRunning = 501, + /** * An output is paused and should not be. * * @enumIdentifier OutputPaused @@ -217,8 +217,8 @@ enum RequestStatus { * @initialVersion 5.0.0 * @api enums */ - OutputPaused = 502, - /** + OutputPaused = 502, + /** * An output is not paused and should be. * * @enumIdentifier OutputNotPaused @@ -228,8 +228,8 @@ enum RequestStatus { * @initialVersion 5.0.0 * @api enums */ - OutputNotPaused = 503, - /** + OutputNotPaused = 503, + /** * An output is disabled and should not be. * * @enumIdentifier OutputDisabled @@ -239,8 +239,8 @@ enum RequestStatus { * @initialVersion 5.0.0 * @api enums */ - OutputDisabled = 504, - /** + OutputDisabled = 504, + /** * Studio mode is active and cannot be. * * @enumIdentifier StudioModeActive @@ -250,8 +250,8 @@ enum RequestStatus { * @initialVersion 5.0.0 * @api enums */ - StudioModeActive = 505, - /** + StudioModeActive = 505, + /** * Studio mode is not active and should be. * * @enumIdentifier StudioModeNotActive @@ -261,9 +261,9 @@ enum RequestStatus { * @initialVersion 5.0.0 * @api enums */ - StudioModeNotActive = 506, + StudioModeNotActive = 506, - /** + /** * The resource was not found. * * Note: Resources are any kind of object in obs-websocket, like inputs, profiles, outputs, etc. @@ -275,8 +275,8 @@ enum RequestStatus { * @initialVersion 5.0.0 * @api enums */ - ResourceNotFound = 600, - /** + ResourceNotFound = 600, + /** * The resource already exists. * * @enumIdentifier ResourceAlreadyExists @@ -286,8 +286,8 @@ enum RequestStatus { * @initialVersion 5.0.0 * @api enums */ - ResourceAlreadyExists = 601, - /** + ResourceAlreadyExists = 601, + /** * The type of resource found is invalid. * * @enumIdentifier InvalidResourceType @@ -297,8 +297,8 @@ enum RequestStatus { * @initialVersion 5.0.0 * @api enums */ - InvalidResourceType = 602, - /** + InvalidResourceType = 602, + /** * There are not enough instances of the resource in order to perform the request. * * @enumIdentifier NotEnoughResources @@ -308,8 +308,8 @@ enum RequestStatus { * @initialVersion 5.0.0 * @api enums */ - NotEnoughResources = 603, - /** + NotEnoughResources = 603, + /** * The state of the resource is invalid. For example, if the resource is blocked from being accessed. * * @enumIdentifier InvalidResourceState @@ -319,8 +319,8 @@ enum RequestStatus { * @initialVersion 5.0.0 * @api enums */ - InvalidResourceState = 604, - /** + InvalidResourceState = 604, + /** * The specified input (obs_source_t-OBS_SOURCE_TYPE_INPUT) had the wrong kind. * * @enumIdentifier InvalidInputKind @@ -330,8 +330,8 @@ enum RequestStatus { * @initialVersion 5.0.0 * @api enums */ - InvalidInputKind = 605, - /** + InvalidInputKind = 605, + /** * The resource does not support being configured. * * This is particularly relevant to transitions, where they do not always have changeable settings. @@ -343,8 +343,8 @@ enum RequestStatus { * @initialVersion 5.0.0 * @api enums */ - ResourceNotConfigurable = 606, - /** + ResourceNotConfigurable = 606, + /** * The specified filter (obs_source_t-OBS_SOURCE_TYPE_FILTER) had the wrong kind. * * @enumIdentifier InvalidFilterKind @@ -354,9 +354,9 @@ enum RequestStatus { * @initialVersion 5.0.0 * @api enums */ - InvalidFilterKind = 607, + InvalidFilterKind = 607, - /** + /** * Creating the resource failed. * * @enumIdentifier ResourceCreationFailed @@ -366,8 +366,8 @@ enum RequestStatus { * @initialVersion 5.0.0 * @api enums */ - ResourceCreationFailed = 700, - /** + ResourceCreationFailed = 700, + /** * Performing an action on the resource failed. * * @enumIdentifier ResourceActionFailed @@ -377,8 +377,8 @@ enum RequestStatus { * @initialVersion 5.0.0 * @api enums */ - ResourceActionFailed = 701, - /** + ResourceActionFailed = 701, + /** * Processing the request failed unexpectedly. * * Note: A comment is required to be provided by obs-websocket. @@ -390,8 +390,8 @@ enum RequestStatus { * @initialVersion 5.0.0 * @api enums */ - RequestProcessingFailed = 702, - /** + RequestProcessingFailed = 702, + /** * The combination of request fields cannot be used to perform an action. * * @enumIdentifier CannotAct @@ -401,6 +401,6 @@ enum RequestStatus { * @initialVersion 5.0.0 * @api enums */ - CannotAct = 703, -}; + CannotAct = 703, + }; } diff --git a/src/utils/Compat.h b/src/utils/Compat.h index 201c1574..087d76c2 100644 --- a/src/utils/Compat.h +++ b/src/utils/Compat.h @@ -23,16 +23,16 @@ with this program. If not, see #include namespace Utils { -namespace Compat { -// Reimplement QRunnable for std::function. Retrocompatability for Qt < 5.15 -class StdFunctionRunnable : public QRunnable { - std::function cb; + namespace Compat { + // Reimplement QRunnable for std::function. Retrocompatability for Qt < 5.15 + class StdFunctionRunnable : public QRunnable { + std::function cb; -public: - StdFunctionRunnable(std::function func); - void run() override; -}; + public: + StdFunctionRunnable(std::function func); + void run() override; + }; -QRunnable *CreateFunctionRunnable(std::function func); -} + QRunnable *CreateFunctionRunnable(std::function func); + } } diff --git a/src/utils/Crypto.h b/src/utils/Crypto.h index a2780b2a..a86319bb 100644 --- a/src/utils/Crypto.h +++ b/src/utils/Crypto.h @@ -23,10 +23,10 @@ with this program. If not, see #include namespace Utils { -namespace Crypto { -std::string GenerateSalt(); -std::string GenerateSecret(std::string password, std::string salt); -bool CheckAuthenticationString(std::string secret, std::string challenge, std::string authenticationString); -std::string GeneratePassword(size_t length = 16); -} + namespace Crypto { + std::string GenerateSalt(); + std::string GenerateSecret(std::string password, std::string salt); + bool CheckAuthenticationString(std::string secret, std::string challenge, std::string authenticationString); + std::string GeneratePassword(size_t length = 16); + } } diff --git a/src/utils/Json.h b/src/utils/Json.h index 0d930d4e..6fadb15b 100644 --- a/src/utils/Json.h +++ b/src/utils/Json.h @@ -71,15 +71,12 @@ NLOHMANN_JSON_SERIALIZE_ENUM(obs_blending_type, { }) namespace Utils { -namespace Json { -bool JsonArrayIsValidObsArray(const json &j); -obs_data_t *JsonToObsData(json j); -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 createNew = true); -static inline bool Contains(const json &j, std::string key) -{ - return j.contains(key) && !j[key].is_null(); -} -} + namespace Json { + bool JsonArrayIsValidObsArray(const json &j); + obs_data_t *JsonToObsData(json j); + 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 createNew = true); + static inline bool Contains(const json &j, std::string key) { return j.contains(key) && !j[key].is_null(); } + } } diff --git a/src/utils/Obs.h b/src/utils/Obs.h index 2b891214..a599bfd2 100644 --- a/src/utils/Obs.h +++ b/src/utils/Obs.h @@ -172,61 +172,64 @@ NLOHMANN_JSON_SERIALIZE_ENUM(ObsMediaInputAction, }) namespace Utils { -namespace Obs { -namespace StringHelper { -std::string GetObsVersion(); -std::string GetCurrentSceneCollection(); -std::string GetCurrentProfile(); -std::string GetCurrentProfilePath(); -std::string GetCurrentRecordOutputPath(); -std::string GetLastReplayBufferFilePath(); -std::string DurationToTimecode(uint64_t); -} + namespace Obs { + namespace StringHelper { + std::string GetObsVersion(); + std::string GetCurrentSceneCollection(); + std::string GetCurrentProfile(); + std::string GetCurrentProfilePath(); + std::string GetCurrentRecordOutputPath(); + std::string GetLastReplayBufferFilePath(); + std::string DurationToTimecode(uint64_t); + } -namespace NumberHelper { -uint64_t GetOutputDuration(obs_output_t *output); -size_t GetSceneCount(); -size_t GetSourceFilterIndex(obs_source_t *source, obs_source_t *filter); -} + namespace NumberHelper { + uint64_t GetOutputDuration(obs_output_t *output); + size_t GetSceneCount(); + size_t GetSourceFilterIndex(obs_source_t *source, obs_source_t *filter); + } -namespace ArrayHelper { -std::vector GetSceneCollectionList(); -std::vector GetProfileList(); -std::vector GetHotkeyList(); -std::vector GetHotkeyNameList(); -std::vector GetSceneList(); -std::vector GetGroupList(); -std::vector GetSceneItemList(obs_scene_t *scene, bool basic = false); -std::vector GetInputList(std::string inputKind = ""); -std::vector GetInputKindList(bool unversioned = false, bool includeDisabled = false); -std::vector GetListPropertyItems(obs_property_t *property); -std::vector GetTransitionKindList(); -std::vector GetSceneTransitionList(); -std::vector GetSourceFilterList(obs_source_t *source); -std::vector GetFilterKindList(); -} + namespace ArrayHelper { + std::vector GetSceneCollectionList(); + std::vector GetProfileList(); + std::vector GetHotkeyList(); + std::vector GetHotkeyNameList(); + std::vector GetSceneList(); + std::vector GetGroupList(); + std::vector GetSceneItemList(obs_scene_t *scene, bool basic = false); + std::vector GetInputList(std::string inputKind = ""); + std::vector GetInputKindList(bool unversioned = false, bool includeDisabled = false); + std::vector GetListPropertyItems(obs_property_t *property); + std::vector GetTransitionKindList(); + std::vector GetSceneTransitionList(); + std::vector GetSourceFilterList(obs_source_t *source); + std::vector GetFilterKindList(); + } -namespace ObjectHelper { -json GetStats(); -json GetSceneItemTransform(obs_sceneitem_t *item); -} + namespace ObjectHelper { + json GetStats(); + json GetSceneItemTransform(obs_sceneitem_t *item); + } -namespace SearchHelper { -obs_hotkey_t *GetHotkeyByName(std::string name); -obs_source_t *GetSceneTransitionByName(std::string name); // Increments source ref. Use OBSSourceAutoRelease -obs_sceneitem_t *GetSceneItemByName(obs_scene_t *scene, std::string name, - int offset = 0); // Increments ref. Use OBSSceneItemAutoRelease -} + namespace SearchHelper { + obs_hotkey_t *GetHotkeyByName(std::string name); + obs_source_t *GetSceneTransitionByName(std::string name); // Increments source ref. Use OBSSourceAutoRelease + obs_sceneitem_t *GetSceneItemByName(obs_scene_t *scene, std::string name, + int offset = 0); // Increments ref. Use OBSSceneItemAutoRelease + } -namespace ActionHelper { -obs_sceneitem_t *CreateSceneItem(obs_source_t *source, obs_scene_t *scene, bool sceneItemEnabled = true, - obs_transform_info *sceneItemTransform = nullptr, - obs_sceneitem_crop *sceneItemCrop = nullptr); // Increments ref. Use OBSSceneItemAutoRelease -obs_sceneitem_t *CreateInput(std::string inputName, std::string inputKind, obs_data_t *inputSettings, obs_scene_t *scene, - bool sceneItemEnabled = true); // Increments ref. Use OBSSceneItemAutoRelease -obs_source_t *CreateSourceFilter(obs_source_t *source, std::string filterName, std::string filterKind, - obs_data_t *filterSettings); // Increments source ref. Use OBSSourceAutoRelease -void SetSourceFilterIndex(obs_source_t *source, obs_source_t *filter, size_t index); -} -} + namespace ActionHelper { + obs_sceneitem_t * + CreateSceneItem(obs_source_t *source, obs_scene_t *scene, bool sceneItemEnabled = true, + obs_transform_info *sceneItemTransform = nullptr, + obs_sceneitem_crop *sceneItemCrop = nullptr); // Increments ref. Use OBSSceneItemAutoRelease + obs_sceneitem_t *CreateInput(std::string inputName, std::string inputKind, obs_data_t *inputSettings, + obs_scene_t *scene, + bool sceneItemEnabled = true); // Increments ref. Use OBSSceneItemAutoRelease + obs_source_t * + CreateSourceFilter(obs_source_t *source, std::string filterName, std::string filterKind, + obs_data_t *filterSettings); // Increments source ref. Use OBSSourceAutoRelease + void SetSourceFilterIndex(obs_source_t *source, obs_source_t *filter, size_t index); + } + } } diff --git a/src/utils/Obs_VolumeMeter.h b/src/utils/Obs_VolumeMeter.h index ee10e715..e5e29947 100644 --- a/src/utils/Obs_VolumeMeter.h +++ b/src/utils/Obs_VolumeMeter.h @@ -31,69 +31,70 @@ with this program. If not, see #include "Json.h" namespace Utils { -namespace Obs { -namespace VolumeMeter { -// Some code copied from https://github.com/obsproject/obs-studio/blob/master/libobs/obs-audio-controls.c -// Keeps a running tally of the current audio levels, for a specific input -class Meter { -public: - Meter(obs_source_t *input); - ~Meter(); + namespace Obs { + namespace VolumeMeter { + // Some code copied from https://github.com/obsproject/obs-studio/blob/master/libobs/obs-audio-controls.c + // Keeps a running tally of the current audio levels, for a specific input + class Meter { + public: + Meter(obs_source_t *input); + ~Meter(); - bool InputValid(); - obs_weak_source_t *GetWeakInput() { return _input; } - json GetMeterData(); + bool InputValid(); + obs_weak_source_t *GetWeakInput() { return _input; } + json GetMeterData(); - std::atomic PeakMeterType; + std::atomic PeakMeterType; -private: - OBSWeakSourceAutoRelease _input; + private: + OBSWeakSourceAutoRelease _input; - // All values in mul - std::mutex _mutex; - bool _muted; - int _channels; - float _magnitude[MAX_AUDIO_CHANNELS]; - float _peak[MAX_AUDIO_CHANNELS]; - float _previousSamples[MAX_AUDIO_CHANNELS][4]; + // All values in mul + std::mutex _mutex; + bool _muted; + int _channels; + float _magnitude[MAX_AUDIO_CHANNELS]; + float _peak[MAX_AUDIO_CHANNELS]; + float _previousSamples[MAX_AUDIO_CHANNELS][4]; - std::atomic _lastUpdate; - std::atomic _volume; + std::atomic _lastUpdate; + std::atomic _volume; - void ResetAudioLevels(); - void ProcessAudioChannels(const struct audio_data *data); - void ProcessPeak(const struct audio_data *data); - void ProcessMagnitude(const struct audio_data *data); + void ResetAudioLevels(); + void ProcessAudioChannels(const struct audio_data *data); + void ProcessPeak(const struct audio_data *data); + void ProcessMagnitude(const struct audio_data *data); - static void InputAudioCaptureCallback(void *priv_data, obs_source_t *source, const struct audio_data *data, bool muted); - static void InputVolumeCallback(void *priv_data, calldata_t *cd); -}; + static void InputAudioCaptureCallback(void *priv_data, obs_source_t *source, + const struct audio_data *data, bool muted); + static void InputVolumeCallback(void *priv_data, calldata_t *cd); + }; -// Maintains an array of active inputs -class Handler { - typedef std::function)> UpdateCallback; - typedef std::unique_ptr MeterPtr; + // Maintains an array of active inputs + class Handler { + typedef std::function)> UpdateCallback; + typedef std::unique_ptr MeterPtr; -public: - Handler(UpdateCallback cb, uint64_t updatePeriod = 50); - ~Handler(); + public: + Handler(UpdateCallback cb, uint64_t updatePeriod = 50); + ~Handler(); -private: - UpdateCallback _updateCallback; + private: + UpdateCallback _updateCallback; - std::mutex _meterMutex; - std::vector _meters; - uint64_t _updatePeriod; + std::mutex _meterMutex; + std::vector _meters; + uint64_t _updatePeriod; - std::mutex _mutex; - std::condition_variable _cond; - std::atomic _running; - std::thread _updateThread; + std::mutex _mutex; + std::condition_variable _cond; + std::atomic _running; + std::thread _updateThread; - void UpdateThread(); - static void InputActivateCallback(void *priv_data, calldata_t *cd); - static void InputDeactivateCallback(void *priv_data, calldata_t *cd); -}; -} -} + void UpdateThread(); + static void InputActivateCallback(void *priv_data, calldata_t *cd); + static void InputDeactivateCallback(void *priv_data, calldata_t *cd); + }; + } + } } diff --git a/src/utils/Platform.h b/src/utils/Platform.h index 22d52626..aee2213d 100644 --- a/src/utils/Platform.h +++ b/src/utils/Platform.h @@ -24,12 +24,12 @@ with this program. If not, see #include namespace Utils { -namespace Platform { -std::string GetLocalAddress(); -QString GetCommandLineArgument(QString arg); -bool GetCommandLineFlagSet(QString arg); -void SendTrayNotification(QSystemTrayIcon::MessageIcon icon, QString title, QString body); -bool GetTextFileContent(std::string fileName, std::string &content); -bool SetTextFileContent(std::string filePath, std::string content, bool createNew = true); -} + namespace Platform { + std::string GetLocalAddress(); + QString GetCommandLineArgument(QString arg); + bool GetCommandLineFlagSet(QString arg); + void SendTrayNotification(QSystemTrayIcon::MessageIcon icon, QString title, QString body); + bool GetTextFileContent(std::string fileName, std::string &content); + bool SetTextFileContent(std::string filePath, std::string content, bool createNew = true); + } } diff --git a/src/websocketserver/types/WebSocketCloseCode.h b/src/websocketserver/types/WebSocketCloseCode.h index 79c13d0d..51904140 100644 --- a/src/websocketserver/types/WebSocketCloseCode.h +++ b/src/websocketserver/types/WebSocketCloseCode.h @@ -20,8 +20,8 @@ with this program. If not, see #pragma once namespace WebSocketCloseCode { -enum WebSocketCloseCode { - /** + enum WebSocketCloseCode { + /** * For internal use only to tell the request handler not to perform any close action. * * @enumIdentifier DontClose @@ -31,8 +31,8 @@ enum WebSocketCloseCode { * @initialVersion 5.0.0 * @api enums */ - DontClose = 0, - /** + DontClose = 0, + /** * Unknown reason, should never be used. * * @enumIdentifier UnknownReason @@ -42,8 +42,8 @@ enum WebSocketCloseCode { * @initialVersion 5.0.0 * @api enums */ - UnknownReason = 4000, - /** + UnknownReason = 4000, + /** * The server was unable to decode the incoming websocket message. * * @enumIdentifier MessageDecodeError @@ -53,8 +53,8 @@ enum WebSocketCloseCode { * @initialVersion 5.0.0 * @api enums */ - MessageDecodeError = 4002, - /** + MessageDecodeError = 4002, + /** * A data field is required but missing from the payload. * * @enumIdentifier MissingDataField @@ -64,8 +64,8 @@ enum WebSocketCloseCode { * @initialVersion 5.0.0 * @api enums */ - MissingDataField = 4003, - /** + MissingDataField = 4003, + /** * A data field's value type is invalid. * * @enumIdentifier InvalidDataFieldType @@ -75,8 +75,8 @@ enum WebSocketCloseCode { * @initialVersion 5.0.0 * @api enums */ - InvalidDataFieldType = 4004, - /** + InvalidDataFieldType = 4004, + /** * A data field's value is invalid. * * @enumIdentifier InvalidDataFieldValue @@ -86,8 +86,8 @@ enum WebSocketCloseCode { * @initialVersion 5.0.0 * @api enums */ - InvalidDataFieldValue = 4005, - /** + InvalidDataFieldValue = 4005, + /** * The specified `op` was invalid or missing. * * @enumIdentifier UnknownOpCode @@ -97,8 +97,8 @@ enum WebSocketCloseCode { * @initialVersion 5.0.0 * @api enums */ - UnknownOpCode = 4006, - /** + UnknownOpCode = 4006, + /** * The client sent a websocket message without first sending `Identify` message. * * @enumIdentifier NotIdentified @@ -108,8 +108,8 @@ enum WebSocketCloseCode { * @initialVersion 5.0.0 * @api enums */ - NotIdentified = 4007, - /** + NotIdentified = 4007, + /** * The client sent an `Identify` message while already identified. * * Note: Once a client has identified, only `Reidentify` may be used to change session parameters. @@ -121,8 +121,8 @@ enum WebSocketCloseCode { * @initialVersion 5.0.0 * @api enums */ - AlreadyIdentified = 4008, - /** + AlreadyIdentified = 4008, + /** * The authentication attempt (via `Identify`) failed. * * @enumIdentifier AuthenticationFailed @@ -132,8 +132,8 @@ enum WebSocketCloseCode { * @initialVersion 5.0.0 * @api enums */ - AuthenticationFailed = 4009, - /** + AuthenticationFailed = 4009, + /** * The server detected the usage of an old version of the obs-websocket RPC protocol. * * @enumIdentifier UnsupportedRpcVersion @@ -143,8 +143,8 @@ enum WebSocketCloseCode { * @initialVersion 5.0.0 * @api enums */ - UnsupportedRpcVersion = 4010, - /** + UnsupportedRpcVersion = 4010, + /** * The websocket session has been invalidated by the obs-websocket server. * * Note: This is the code used by the `Kick` button in the UI Session List. If you receive this code, you must not automatically reconnect. @@ -156,8 +156,8 @@ enum WebSocketCloseCode { * @initialVersion 5.0.0 * @api enums */ - SessionInvalidated = 4011, - /** + SessionInvalidated = 4011, + /** * A requested feature is not supported due to hardware/software limitations. * * @enumIdentifier UnsupportedFeature @@ -167,6 +167,6 @@ enum WebSocketCloseCode { * @initialVersion 5.0.0 * @api enums */ - UnsupportedFeature = 4012, -}; + UnsupportedFeature = 4012, + }; } diff --git a/src/websocketserver/types/WebSocketOpCode.h b/src/websocketserver/types/WebSocketOpCode.h index 614bc7e0..152456b8 100644 --- a/src/websocketserver/types/WebSocketOpCode.h +++ b/src/websocketserver/types/WebSocketOpCode.h @@ -20,8 +20,8 @@ with this program. If not, see #pragma once namespace WebSocketOpCode { -enum WebSocketOpCode : uint8_t { - /** + enum WebSocketOpCode : uint8_t { + /** * The initial message sent by obs-websocket to newly connected clients. * * @enumIdentifier Hello @@ -31,8 +31,8 @@ enum WebSocketOpCode : uint8_t { * @initialVersion 5.0.0 * @api enums */ - Hello = 0, - /** + Hello = 0, + /** * The message sent by a newly connected client to obs-websocket in response to a `Hello`. * * @enumIdentifier Identify @@ -42,8 +42,8 @@ enum WebSocketOpCode : uint8_t { * @initialVersion 5.0.0 * @api enums */ - Identify = 1, - /** + Identify = 1, + /** * The response sent by obs-websocket to a client after it has successfully identified with obs-websocket. * * @enumIdentifier Identified @@ -53,8 +53,8 @@ enum WebSocketOpCode : uint8_t { * @initialVersion 5.0.0 * @api enums */ - Identified = 2, - /** + Identified = 2, + /** * The message sent by an already-identified client to update identification parameters. * * @enumIdentifier Reidentify @@ -64,8 +64,8 @@ enum WebSocketOpCode : uint8_t { * @initialVersion 5.0.0 * @api enums */ - Reidentify = 3, - /** + Reidentify = 3, + /** * The message sent by obs-websocket containing an event payload. * * @enumIdentifier Event @@ -75,8 +75,8 @@ enum WebSocketOpCode : uint8_t { * @initialVersion 5.0.0 * @api enums */ - Event = 5, - /** + Event = 5, + /** * The message sent by a client to obs-websocket to perform a request. * * @enumIdentifier Request @@ -86,8 +86,8 @@ enum WebSocketOpCode : uint8_t { * @initialVersion 5.0.0 * @api enums */ - Request = 6, - /** + Request = 6, + /** * The message sent by obs-websocket in response to a particular request from a client. * * @enumIdentifier RequestResponse @@ -97,8 +97,8 @@ enum WebSocketOpCode : uint8_t { * @initialVersion 5.0.0 * @api enums */ - RequestResponse = 7, - /** + RequestResponse = 7, + /** * The message sent by a client to obs-websocket to perform a batch of requests. * * @enumIdentifier RequestBatch @@ -108,8 +108,8 @@ enum WebSocketOpCode : uint8_t { * @initialVersion 5.0.0 * @api enums */ - RequestBatch = 8, - /** + RequestBatch = 8, + /** * The message sent by obs-websocket in response to a particular batch of requests from a client. * * @enumIdentifier RequestBatchResponse @@ -119,11 +119,8 @@ enum WebSocketOpCode : uint8_t { * @initialVersion 5.0.0 * @api enums */ - RequestBatchResponse = 9, -}; + RequestBatchResponse = 9, + }; -inline bool IsValid(uint8_t opCode) -{ - return opCode >= Hello && opCode <= RequestBatchResponse; -} + inline bool IsValid(uint8_t opCode) { return opCode >= Hello && opCode <= RequestBatchResponse; } }