clang-format: Indent namespaces

This commit is contained in:
tt2468
2022-06-08 00:37:04 -07:00
parent 22fee0312d
commit 5b8fd096d5
13 changed files with 310 additions and 313 deletions

View File

@ -64,7 +64,7 @@ IndentWidth: 8
IndentWrappedFunctionNames: false IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: true KeepEmptyLinesAtTheStartOfBlocks: true
MaxEmptyLinesToKeep: 1 MaxEmptyLinesToKeep: 1
NamespaceIndentation: None NamespaceIndentation: All
#ObjCBinPackProtocolList: Auto # requires clang-format 7 #ObjCBinPackProtocolList: Auto # requires clang-format 7
ObjCBlockIndentWidth: 8 ObjCBlockIndentWidth: 8
ObjCSpaceAfterProperty: true ObjCSpaceAfterProperty: true

View File

@ -20,8 +20,8 @@ with this program. If not, see <https://www.gnu.org/licenses/>
#pragma once #pragma once
namespace EventSubscription { namespace EventSubscription {
enum EventSubscription { enum EventSubscription {
/** /**
* Subcription value used to disable all events. * Subcription value used to disable all events.
* *
* @enumIdentifier None * @enumIdentifier None
@ -31,8 +31,8 @@ enum EventSubscription {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
None = 0, None = 0,
/** /**
* Subscription value to receive events in the `General` category. * Subscription value to receive events in the `General` category.
* *
* @enumIdentifier General * @enumIdentifier General
@ -42,8 +42,8 @@ enum EventSubscription {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
General = (1 << 0), General = (1 << 0),
/** /**
* Subscription value to receive events in the `Config` category. * Subscription value to receive events in the `Config` category.
* *
* @enumIdentifier Config * @enumIdentifier Config
@ -53,8 +53,8 @@ enum EventSubscription {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
Config = (1 << 1), Config = (1 << 1),
/** /**
* Subscription value to receive events in the `Scenes` category. * Subscription value to receive events in the `Scenes` category.
* *
* @enumIdentifier Scenes * @enumIdentifier Scenes
@ -64,8 +64,8 @@ enum EventSubscription {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
Scenes = (1 << 2), Scenes = (1 << 2),
/** /**
* Subscription value to receive events in the `Inputs` category. * Subscription value to receive events in the `Inputs` category.
* *
* @enumIdentifier Inputs * @enumIdentifier Inputs
@ -75,8 +75,8 @@ enum EventSubscription {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
Inputs = (1 << 3), Inputs = (1 << 3),
/** /**
* Subscription value to receive events in the `Transitions` category. * Subscription value to receive events in the `Transitions` category.
* *
* @enumIdentifier Transitions * @enumIdentifier Transitions
@ -86,8 +86,8 @@ enum EventSubscription {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
Transitions = (1 << 4), Transitions = (1 << 4),
/** /**
* Subscription value to receive events in the `Filters` category. * Subscription value to receive events in the `Filters` category.
* *
* @enumIdentifier Filters * @enumIdentifier Filters
@ -97,8 +97,8 @@ enum EventSubscription {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
Filters = (1 << 5), Filters = (1 << 5),
/** /**
* Subscription value to receive events in the `Outputs` category. * Subscription value to receive events in the `Outputs` category.
* *
* @enumIdentifier Outputs * @enumIdentifier Outputs
@ -108,8 +108,8 @@ enum EventSubscription {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
Outputs = (1 << 6), Outputs = (1 << 6),
/** /**
* Subscription value to receive events in the `SceneItems` category. * Subscription value to receive events in the `SceneItems` category.
* *
* @enumIdentifier SceneItems * @enumIdentifier SceneItems
@ -119,8 +119,8 @@ enum EventSubscription {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
SceneItems = (1 << 7), SceneItems = (1 << 7),
/** /**
* Subscription value to receive events in the `MediaInputs` category. * Subscription value to receive events in the `MediaInputs` category.
* *
* @enumIdentifier MediaInputs * @enumIdentifier MediaInputs
@ -130,8 +130,8 @@ enum EventSubscription {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
MediaInputs = (1 << 8), MediaInputs = (1 << 8),
/** /**
* Subscription value to receive the `VendorEvent` event. * Subscription value to receive the `VendorEvent` event.
* *
* @enumIdentifier Vendors * @enumIdentifier Vendors
@ -141,8 +141,8 @@ enum EventSubscription {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
Vendors = (1 << 9), Vendors = (1 << 9),
/** /**
* Subscription value to receive events in the `Ui` category. * Subscription value to receive events in the `Ui` category.
* *
* @enumIdentifier Ui * @enumIdentifier Ui
@ -152,8 +152,8 @@ enum EventSubscription {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
Ui = (1 << 10), Ui = (1 << 10),
/** /**
* Helper to receive all non-high-volume events. * Helper to receive all non-high-volume events.
* *
* @enumIdentifier All * @enumIdentifier All
@ -163,8 +163,9 @@ enum EventSubscription {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @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. * Subscription value to receive the `InputVolumeMeters` high-volume event.
* *
* @enumIdentifier InputVolumeMeters * @enumIdentifier InputVolumeMeters
@ -174,8 +175,8 @@ enum EventSubscription {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
InputVolumeMeters = (1 << 16), InputVolumeMeters = (1 << 16),
/** /**
* Subscription value to receive the `InputActiveStateChanged` high-volume event. * Subscription value to receive the `InputActiveStateChanged` high-volume event.
* *
* @enumIdentifier InputActiveStateChanged * @enumIdentifier InputActiveStateChanged
@ -185,8 +186,8 @@ enum EventSubscription {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
InputActiveStateChanged = (1 << 17), InputActiveStateChanged = (1 << 17),
/** /**
* Subscription value to receive the `InputShowStateChanged` high-volume event. * Subscription value to receive the `InputShowStateChanged` high-volume event.
* *
* @enumIdentifier InputShowStateChanged * @enumIdentifier InputShowStateChanged
@ -196,8 +197,8 @@ enum EventSubscription {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
InputShowStateChanged = (1 << 18), InputShowStateChanged = (1 << 18),
/** /**
* Subscription value to receive the `SceneItemTransformChanged` high-volume event. * Subscription value to receive the `SceneItemTransformChanged` high-volume event.
* *
* @enumIdentifier SceneItemTransformChanged * @enumIdentifier SceneItemTransformChanged
@ -207,6 +208,6 @@ enum EventSubscription {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
SceneItemTransformChanged = (1 << 19), SceneItemTransformChanged = (1 << 19),
}; };
} }

View File

@ -24,7 +24,8 @@ with this program. If not, see <https://www.gnu.org/licenses/>
#include "rpc/RequestBatchRequest.h" #include "rpc/RequestBatchRequest.h"
namespace RequestBatchHandler { namespace RequestBatchHandler {
std::vector<RequestResult> ProcessRequestBatch(QThreadPool &threadPool, SessionPtr session, std::vector<RequestResult> ProcessRequestBatch(QThreadPool &threadPool, SessionPtr session,
RequestBatchExecutionType::RequestBatchExecutionType executionType, RequestBatchExecutionType::RequestBatchExecutionType executionType,
std::vector<RequestBatchRequest> &requests, json &variables, bool haltOnFailure); std::vector<RequestBatchRequest> &requests, json &variables,
bool haltOnFailure);
} }

View File

@ -22,8 +22,8 @@ with this program. If not, see <https://www.gnu.org/licenses/>
#include <stdint.h> #include <stdint.h>
namespace RequestBatchExecutionType { namespace RequestBatchExecutionType {
enum RequestBatchExecutionType : int8_t { enum RequestBatchExecutionType : int8_t {
/** /**
* Not a request batch. * Not a request batch.
* *
* @enumIdentifier None * @enumIdentifier None
@ -33,8 +33,8 @@ enum RequestBatchExecutionType : int8_t {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
None = -1, None = -1,
/** /**
* A request batch which processes all requests serially, as fast as possible. * 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. * 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 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
SerialRealtime = 0, SerialRealtime = 0,
/** /**
* A request batch type which processes all requests serially, in sync with the graphics thread. Designed to * A request batch type which processes all requests serially, in sync with the graphics thread. Designed to
* provide high accuracy for animations. * provide high accuracy for animations.
* *
@ -60,8 +60,8 @@ enum RequestBatchExecutionType : int8_t {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
SerialFrame = 1, SerialFrame = 1,
/** /**
* A request batch type which processes all requests using all available threads in the thread pool. * 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 * 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 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
Parallel = 2, Parallel = 2,
}; };
inline bool IsValid(int8_t executionType) inline bool IsValid(int8_t executionType) { return executionType >= None && executionType <= Parallel; }
{
return executionType >= None && executionType <= Parallel;
}
} }

View File

@ -20,8 +20,8 @@ with this program. If not, see <https://www.gnu.org/licenses/>
#pragma once #pragma once
namespace RequestStatus { namespace RequestStatus {
enum RequestStatus { enum RequestStatus {
/** /**
* Unknown status, should never be used. * Unknown status, should never be used.
* *
* @enumIdentifier Unknown * @enumIdentifier Unknown
@ -31,9 +31,9 @@ enum RequestStatus {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
Unknown = 0, Unknown = 0,
/** /**
* For internal use to signify a successful field check. * For internal use to signify a successful field check.
* *
* @enumIdentifier NoError * @enumIdentifier NoError
@ -43,9 +43,9 @@ enum RequestStatus {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
NoError = 10, NoError = 10,
/** /**
* The request has succeeded. * The request has succeeded.
* *
* @enumIdentifier Success * @enumIdentifier Success
@ -55,9 +55,9 @@ enum RequestStatus {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
Success = 100, Success = 100,
/** /**
* The `requestType` field is missing from the request data. * The `requestType` field is missing from the request data.
* *
* @enumIdentifier MissingRequestType * @enumIdentifier MissingRequestType
@ -67,8 +67,8 @@ enum RequestStatus {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
MissingRequestType = 203, MissingRequestType = 203,
/** /**
* The request type is invalid or does not exist. * The request type is invalid or does not exist.
* *
* @enumIdentifier UnknownRequestType * @enumIdentifier UnknownRequestType
@ -78,8 +78,8 @@ enum RequestStatus {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
UnknownRequestType = 204, UnknownRequestType = 204,
/** /**
* Generic error code. * Generic error code.
* *
* Note: A comment is required to be provided by obs-websocket. * Note: A comment is required to be provided by obs-websocket.
@ -91,8 +91,8 @@ enum RequestStatus {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
GenericError = 205, GenericError = 205,
/** /**
* The request batch execution type is not supported. * The request batch execution type is not supported.
* *
* @enumIdentifier UnsupportedRequestBatchExecutionType * @enumIdentifier UnsupportedRequestBatchExecutionType
@ -102,9 +102,9 @@ enum RequestStatus {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
UnsupportedRequestBatchExecutionType = 206, UnsupportedRequestBatchExecutionType = 206,
/** /**
* A required request field is missing. * A required request field is missing.
* *
* @enumIdentifier MissingRequestField * @enumIdentifier MissingRequestField
@ -114,8 +114,8 @@ enum RequestStatus {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
MissingRequestField = 300, MissingRequestField = 300,
/** /**
* The request does not have a valid requestData object. * The request does not have a valid requestData object.
* *
* @enumIdentifier MissingRequestData * @enumIdentifier MissingRequestData
@ -125,9 +125,9 @@ enum RequestStatus {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
MissingRequestData = 301, MissingRequestData = 301,
/** /**
* Generic invalid request field message. * Generic invalid request field message.
* *
* Note: A comment is required to be provided by obs-websocket. * Note: A comment is required to be provided by obs-websocket.
@ -139,8 +139,8 @@ enum RequestStatus {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
InvalidRequestField = 400, InvalidRequestField = 400,
/** /**
* A request field has the wrong data type. * A request field has the wrong data type.
* *
* @enumIdentifier InvalidRequestFieldType * @enumIdentifier InvalidRequestFieldType
@ -150,8 +150,8 @@ enum RequestStatus {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
InvalidRequestFieldType = 401, InvalidRequestFieldType = 401,
/** /**
* A request field (number) is outside of the allowed range. * A request field (number) is outside of the allowed range.
* *
* @enumIdentifier RequestFieldOutOfRange * @enumIdentifier RequestFieldOutOfRange
@ -161,8 +161,8 @@ enum RequestStatus {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
RequestFieldOutOfRange = 402, RequestFieldOutOfRange = 402,
/** /**
* A request field (string or array) is empty and cannot be. * A request field (string or array) is empty and cannot be.
* *
* @enumIdentifier RequestFieldEmpty * @enumIdentifier RequestFieldEmpty
@ -172,8 +172,8 @@ enum RequestStatus {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @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). * There are too many request fields (eg. a request takes two optionals, where only one is allowed at a time).
* *
* @enumIdentifier TooManyRequestFields * @enumIdentifier TooManyRequestFields
@ -183,9 +183,9 @@ enum RequestStatus {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
TooManyRequestFields = 404, TooManyRequestFields = 404,
/** /**
* An output is running and cannot be in order to perform the request. * An output is running and cannot be in order to perform the request.
* *
* @enumIdentifier OutputRunning * @enumIdentifier OutputRunning
@ -195,8 +195,8 @@ enum RequestStatus {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
OutputRunning = 500, OutputRunning = 500,
/** /**
* An output is not running and should be. * An output is not running and should be.
* *
* @enumIdentifier OutputNotRunning * @enumIdentifier OutputNotRunning
@ -206,8 +206,8 @@ enum RequestStatus {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
OutputNotRunning = 501, OutputNotRunning = 501,
/** /**
* An output is paused and should not be. * An output is paused and should not be.
* *
* @enumIdentifier OutputPaused * @enumIdentifier OutputPaused
@ -217,8 +217,8 @@ enum RequestStatus {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
OutputPaused = 502, OutputPaused = 502,
/** /**
* An output is not paused and should be. * An output is not paused and should be.
* *
* @enumIdentifier OutputNotPaused * @enumIdentifier OutputNotPaused
@ -228,8 +228,8 @@ enum RequestStatus {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
OutputNotPaused = 503, OutputNotPaused = 503,
/** /**
* An output is disabled and should not be. * An output is disabled and should not be.
* *
* @enumIdentifier OutputDisabled * @enumIdentifier OutputDisabled
@ -239,8 +239,8 @@ enum RequestStatus {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
OutputDisabled = 504, OutputDisabled = 504,
/** /**
* Studio mode is active and cannot be. * Studio mode is active and cannot be.
* *
* @enumIdentifier StudioModeActive * @enumIdentifier StudioModeActive
@ -250,8 +250,8 @@ enum RequestStatus {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
StudioModeActive = 505, StudioModeActive = 505,
/** /**
* Studio mode is not active and should be. * Studio mode is not active and should be.
* *
* @enumIdentifier StudioModeNotActive * @enumIdentifier StudioModeNotActive
@ -261,9 +261,9 @@ enum RequestStatus {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
StudioModeNotActive = 506, StudioModeNotActive = 506,
/** /**
* The resource was not found. * The resource was not found.
* *
* Note: Resources are any kind of object in obs-websocket, like inputs, profiles, outputs, etc. * 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 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
ResourceNotFound = 600, ResourceNotFound = 600,
/** /**
* The resource already exists. * The resource already exists.
* *
* @enumIdentifier ResourceAlreadyExists * @enumIdentifier ResourceAlreadyExists
@ -286,8 +286,8 @@ enum RequestStatus {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
ResourceAlreadyExists = 601, ResourceAlreadyExists = 601,
/** /**
* The type of resource found is invalid. * The type of resource found is invalid.
* *
* @enumIdentifier InvalidResourceType * @enumIdentifier InvalidResourceType
@ -297,8 +297,8 @@ enum RequestStatus {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
InvalidResourceType = 602, InvalidResourceType = 602,
/** /**
* There are not enough instances of the resource in order to perform the request. * There are not enough instances of the resource in order to perform the request.
* *
* @enumIdentifier NotEnoughResources * @enumIdentifier NotEnoughResources
@ -308,8 +308,8 @@ enum RequestStatus {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
NotEnoughResources = 603, NotEnoughResources = 603,
/** /**
* The state of the resource is invalid. For example, if the resource is blocked from being accessed. * The state of the resource is invalid. For example, if the resource is blocked from being accessed.
* *
* @enumIdentifier InvalidResourceState * @enumIdentifier InvalidResourceState
@ -319,8 +319,8 @@ enum RequestStatus {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
InvalidResourceState = 604, InvalidResourceState = 604,
/** /**
* The specified input (obs_source_t-OBS_SOURCE_TYPE_INPUT) had the wrong kind. * The specified input (obs_source_t-OBS_SOURCE_TYPE_INPUT) had the wrong kind.
* *
* @enumIdentifier InvalidInputKind * @enumIdentifier InvalidInputKind
@ -330,8 +330,8 @@ enum RequestStatus {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
InvalidInputKind = 605, InvalidInputKind = 605,
/** /**
* The resource does not support being configured. * The resource does not support being configured.
* *
* This is particularly relevant to transitions, where they do not always have changeable settings. * This is particularly relevant to transitions, where they do not always have changeable settings.
@ -343,8 +343,8 @@ enum RequestStatus {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
ResourceNotConfigurable = 606, ResourceNotConfigurable = 606,
/** /**
* The specified filter (obs_source_t-OBS_SOURCE_TYPE_FILTER) had the wrong kind. * The specified filter (obs_source_t-OBS_SOURCE_TYPE_FILTER) had the wrong kind.
* *
* @enumIdentifier InvalidFilterKind * @enumIdentifier InvalidFilterKind
@ -354,9 +354,9 @@ enum RequestStatus {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
InvalidFilterKind = 607, InvalidFilterKind = 607,
/** /**
* Creating the resource failed. * Creating the resource failed.
* *
* @enumIdentifier ResourceCreationFailed * @enumIdentifier ResourceCreationFailed
@ -366,8 +366,8 @@ enum RequestStatus {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
ResourceCreationFailed = 700, ResourceCreationFailed = 700,
/** /**
* Performing an action on the resource failed. * Performing an action on the resource failed.
* *
* @enumIdentifier ResourceActionFailed * @enumIdentifier ResourceActionFailed
@ -377,8 +377,8 @@ enum RequestStatus {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
ResourceActionFailed = 701, ResourceActionFailed = 701,
/** /**
* Processing the request failed unexpectedly. * Processing the request failed unexpectedly.
* *
* Note: A comment is required to be provided by obs-websocket. * Note: A comment is required to be provided by obs-websocket.
@ -390,8 +390,8 @@ enum RequestStatus {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
RequestProcessingFailed = 702, RequestProcessingFailed = 702,
/** /**
* The combination of request fields cannot be used to perform an action. * The combination of request fields cannot be used to perform an action.
* *
* @enumIdentifier CannotAct * @enumIdentifier CannotAct
@ -401,6 +401,6 @@ enum RequestStatus {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
CannotAct = 703, CannotAct = 703,
}; };
} }

View File

@ -23,16 +23,16 @@ with this program. If not, see <https://www.gnu.org/licenses/>
#include <QRunnable> #include <QRunnable>
namespace Utils { namespace Utils {
namespace Compat { namespace Compat {
// Reimplement QRunnable for std::function. Retrocompatability for Qt < 5.15 // Reimplement QRunnable for std::function. Retrocompatability for Qt < 5.15
class StdFunctionRunnable : public QRunnable { class StdFunctionRunnable : public QRunnable {
std::function<void()> cb; std::function<void()> cb;
public: public:
StdFunctionRunnable(std::function<void()> func); StdFunctionRunnable(std::function<void()> func);
void run() override; void run() override;
}; };
QRunnable *CreateFunctionRunnable(std::function<void()> func); QRunnable *CreateFunctionRunnable(std::function<void()> func);
} }
} }

View File

@ -23,10 +23,10 @@ with this program. If not, see <https://www.gnu.org/licenses/>
#include <QString> #include <QString>
namespace Utils { namespace Utils {
namespace Crypto { namespace Crypto {
std::string GenerateSalt(); std::string GenerateSalt();
std::string GenerateSecret(std::string password, std::string salt); std::string GenerateSecret(std::string password, std::string salt);
bool CheckAuthenticationString(std::string secret, std::string challenge, std::string authenticationString); bool CheckAuthenticationString(std::string secret, std::string challenge, std::string authenticationString);
std::string GeneratePassword(size_t length = 16); std::string GeneratePassword(size_t length = 16);
} }
} }

View File

@ -71,15 +71,12 @@ NLOHMANN_JSON_SERIALIZE_ENUM(obs_blending_type, {
}) })
namespace Utils { namespace Utils {
namespace Json { namespace Json {
bool JsonArrayIsValidObsArray(const json &j); bool JsonArrayIsValidObsArray(const json &j);
obs_data_t *JsonToObsData(json j); obs_data_t *JsonToObsData(json j);
json ObsDataToJson(obs_data_t *d, bool includeDefault = false); json ObsDataToJson(obs_data_t *d, bool includeDefault = false);
bool GetJsonFileContent(std::string fileName, json &content); bool GetJsonFileContent(std::string fileName, json &content);
bool SetJsonFileContent(std::string fileName, const json &content, bool createNew = true); bool SetJsonFileContent(std::string fileName, const json &content, bool createNew = true);
static inline bool Contains(const json &j, std::string key) static inline bool Contains(const json &j, std::string key) { return j.contains(key) && !j[key].is_null(); }
{ }
return j.contains(key) && !j[key].is_null();
}
}
} }

View File

@ -172,61 +172,64 @@ NLOHMANN_JSON_SERIALIZE_ENUM(ObsMediaInputAction,
}) })
namespace Utils { namespace Utils {
namespace Obs { namespace Obs {
namespace StringHelper { namespace StringHelper {
std::string GetObsVersion(); std::string GetObsVersion();
std::string GetCurrentSceneCollection(); std::string GetCurrentSceneCollection();
std::string GetCurrentProfile(); std::string GetCurrentProfile();
std::string GetCurrentProfilePath(); std::string GetCurrentProfilePath();
std::string GetCurrentRecordOutputPath(); std::string GetCurrentRecordOutputPath();
std::string GetLastReplayBufferFilePath(); std::string GetLastReplayBufferFilePath();
std::string DurationToTimecode(uint64_t); std::string DurationToTimecode(uint64_t);
} }
namespace NumberHelper { namespace NumberHelper {
uint64_t GetOutputDuration(obs_output_t *output); uint64_t GetOutputDuration(obs_output_t *output);
size_t GetSceneCount(); size_t GetSceneCount();
size_t GetSourceFilterIndex(obs_source_t *source, obs_source_t *filter); size_t GetSourceFilterIndex(obs_source_t *source, obs_source_t *filter);
} }
namespace ArrayHelper { namespace ArrayHelper {
std::vector<std::string> GetSceneCollectionList(); std::vector<std::string> GetSceneCollectionList();
std::vector<std::string> GetProfileList(); std::vector<std::string> GetProfileList();
std::vector<obs_hotkey_t *> GetHotkeyList(); std::vector<obs_hotkey_t *> GetHotkeyList();
std::vector<std::string> GetHotkeyNameList(); std::vector<std::string> GetHotkeyNameList();
std::vector<json> GetSceneList(); std::vector<json> GetSceneList();
std::vector<std::string> GetGroupList(); std::vector<std::string> GetGroupList();
std::vector<json> GetSceneItemList(obs_scene_t *scene, bool basic = false); std::vector<json> GetSceneItemList(obs_scene_t *scene, bool basic = false);
std::vector<json> GetInputList(std::string inputKind = ""); std::vector<json> GetInputList(std::string inputKind = "");
std::vector<std::string> GetInputKindList(bool unversioned = false, bool includeDisabled = false); std::vector<std::string> GetInputKindList(bool unversioned = false, bool includeDisabled = false);
std::vector<json> GetListPropertyItems(obs_property_t *property); std::vector<json> GetListPropertyItems(obs_property_t *property);
std::vector<std::string> GetTransitionKindList(); std::vector<std::string> GetTransitionKindList();
std::vector<json> GetSceneTransitionList(); std::vector<json> GetSceneTransitionList();
std::vector<json> GetSourceFilterList(obs_source_t *source); std::vector<json> GetSourceFilterList(obs_source_t *source);
std::vector<std::string> GetFilterKindList(); std::vector<std::string> GetFilterKindList();
} }
namespace ObjectHelper { namespace ObjectHelper {
json GetStats(); json GetStats();
json GetSceneItemTransform(obs_sceneitem_t *item); json GetSceneItemTransform(obs_sceneitem_t *item);
} }
namespace SearchHelper { namespace SearchHelper {
obs_hotkey_t *GetHotkeyByName(std::string name); obs_hotkey_t *GetHotkeyByName(std::string name);
obs_source_t *GetSceneTransitionByName(std::string name); // Increments source ref. Use OBSSourceAutoRelease obs_source_t *GetSceneTransitionByName(std::string name); // Increments source ref. Use OBSSourceAutoRelease
obs_sceneitem_t *GetSceneItemByName(obs_scene_t *scene, std::string name, obs_sceneitem_t *GetSceneItemByName(obs_scene_t *scene, std::string name,
int offset = 0); // Increments ref. Use OBSSceneItemAutoRelease int offset = 0); // Increments ref. Use OBSSceneItemAutoRelease
} }
namespace ActionHelper { namespace ActionHelper {
obs_sceneitem_t *CreateSceneItem(obs_source_t *source, obs_scene_t *scene, bool sceneItemEnabled = true, obs_sceneitem_t *
obs_transform_info *sceneItemTransform = nullptr, CreateSceneItem(obs_source_t *source, obs_scene_t *scene, bool sceneItemEnabled = true,
obs_sceneitem_crop *sceneItemCrop = nullptr); // Increments ref. Use OBSSceneItemAutoRelease obs_transform_info *sceneItemTransform = nullptr,
obs_sceneitem_t *CreateInput(std::string inputName, std::string inputKind, obs_data_t *inputSettings, obs_scene_t *scene, obs_sceneitem_crop *sceneItemCrop = nullptr); // Increments ref. Use OBSSceneItemAutoRelease
bool sceneItemEnabled = true); // Increments ref. Use OBSSceneItemAutoRelease obs_sceneitem_t *CreateInput(std::string inputName, std::string inputKind, obs_data_t *inputSettings,
obs_source_t *CreateSourceFilter(obs_source_t *source, std::string filterName, std::string filterKind, obs_scene_t *scene,
obs_data_t *filterSettings); // Increments source ref. Use OBSSourceAutoRelease bool sceneItemEnabled = true); // Increments ref. Use OBSSceneItemAutoRelease
void SetSourceFilterIndex(obs_source_t *source, obs_source_t *filter, size_t index); 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);
}
}
} }

View File

@ -31,69 +31,70 @@ with this program. If not, see <https://www.gnu.org/licenses/>
#include "Json.h" #include "Json.h"
namespace Utils { namespace Utils {
namespace Obs { namespace Obs {
namespace VolumeMeter { namespace VolumeMeter {
// Some code copied from https://github.com/obsproject/obs-studio/blob/master/libobs/obs-audio-controls.c // 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 // Keeps a running tally of the current audio levels, for a specific input
class Meter { class Meter {
public: public:
Meter(obs_source_t *input); Meter(obs_source_t *input);
~Meter(); ~Meter();
bool InputValid(); bool InputValid();
obs_weak_source_t *GetWeakInput() { return _input; } obs_weak_source_t *GetWeakInput() { return _input; }
json GetMeterData(); json GetMeterData();
std::atomic<enum obs_peak_meter_type> PeakMeterType; std::atomic<enum obs_peak_meter_type> PeakMeterType;
private: private:
OBSWeakSourceAutoRelease _input; OBSWeakSourceAutoRelease _input;
// All values in mul // All values in mul
std::mutex _mutex; std::mutex _mutex;
bool _muted; bool _muted;
int _channels; int _channels;
float _magnitude[MAX_AUDIO_CHANNELS]; float _magnitude[MAX_AUDIO_CHANNELS];
float _peak[MAX_AUDIO_CHANNELS]; float _peak[MAX_AUDIO_CHANNELS];
float _previousSamples[MAX_AUDIO_CHANNELS][4]; float _previousSamples[MAX_AUDIO_CHANNELS][4];
std::atomic<uint64_t> _lastUpdate; std::atomic<uint64_t> _lastUpdate;
std::atomic<float> _volume; std::atomic<float> _volume;
void ResetAudioLevels(); void ResetAudioLevels();
void ProcessAudioChannels(const struct audio_data *data); void ProcessAudioChannels(const struct audio_data *data);
void ProcessPeak(const struct audio_data *data); void ProcessPeak(const struct audio_data *data);
void ProcessMagnitude(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 InputAudioCaptureCallback(void *priv_data, obs_source_t *source,
static void InputVolumeCallback(void *priv_data, calldata_t *cd); const struct audio_data *data, bool muted);
}; static void InputVolumeCallback(void *priv_data, calldata_t *cd);
};
// Maintains an array of active inputs // Maintains an array of active inputs
class Handler { class Handler {
typedef std::function<void(std::vector<json>)> UpdateCallback; typedef std::function<void(std::vector<json>)> UpdateCallback;
typedef std::unique_ptr<Meter> MeterPtr; typedef std::unique_ptr<Meter> MeterPtr;
public: public:
Handler(UpdateCallback cb, uint64_t updatePeriod = 50); Handler(UpdateCallback cb, uint64_t updatePeriod = 50);
~Handler(); ~Handler();
private: private:
UpdateCallback _updateCallback; UpdateCallback _updateCallback;
std::mutex _meterMutex; std::mutex _meterMutex;
std::vector<MeterPtr> _meters; std::vector<MeterPtr> _meters;
uint64_t _updatePeriod; uint64_t _updatePeriod;
std::mutex _mutex; std::mutex _mutex;
std::condition_variable _cond; std::condition_variable _cond;
std::atomic<bool> _running; std::atomic<bool> _running;
std::thread _updateThread; std::thread _updateThread;
void UpdateThread(); void UpdateThread();
static void InputActivateCallback(void *priv_data, calldata_t *cd); static void InputActivateCallback(void *priv_data, calldata_t *cd);
static void InputDeactivateCallback(void *priv_data, calldata_t *cd); static void InputDeactivateCallback(void *priv_data, calldata_t *cd);
}; };
} }
} }
} }

View File

@ -24,12 +24,12 @@ with this program. If not, see <https://www.gnu.org/licenses/>
#include <QSystemTrayIcon> #include <QSystemTrayIcon>
namespace Utils { namespace Utils {
namespace Platform { namespace Platform {
std::string GetLocalAddress(); std::string GetLocalAddress();
QString GetCommandLineArgument(QString arg); QString GetCommandLineArgument(QString arg);
bool GetCommandLineFlagSet(QString arg); bool GetCommandLineFlagSet(QString arg);
void SendTrayNotification(QSystemTrayIcon::MessageIcon icon, QString title, QString body); void SendTrayNotification(QSystemTrayIcon::MessageIcon icon, QString title, QString body);
bool GetTextFileContent(std::string fileName, std::string &content); bool GetTextFileContent(std::string fileName, std::string &content);
bool SetTextFileContent(std::string filePath, std::string content, bool createNew = true); bool SetTextFileContent(std::string filePath, std::string content, bool createNew = true);
} }
} }

View File

@ -20,8 +20,8 @@ with this program. If not, see <https://www.gnu.org/licenses/>
#pragma once #pragma once
namespace WebSocketCloseCode { namespace WebSocketCloseCode {
enum WebSocketCloseCode { enum WebSocketCloseCode {
/** /**
* For internal use only to tell the request handler not to perform any close action. * For internal use only to tell the request handler not to perform any close action.
* *
* @enumIdentifier DontClose * @enumIdentifier DontClose
@ -31,8 +31,8 @@ enum WebSocketCloseCode {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
DontClose = 0, DontClose = 0,
/** /**
* Unknown reason, should never be used. * Unknown reason, should never be used.
* *
* @enumIdentifier UnknownReason * @enumIdentifier UnknownReason
@ -42,8 +42,8 @@ enum WebSocketCloseCode {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
UnknownReason = 4000, UnknownReason = 4000,
/** /**
* The server was unable to decode the incoming websocket message. * The server was unable to decode the incoming websocket message.
* *
* @enumIdentifier MessageDecodeError * @enumIdentifier MessageDecodeError
@ -53,8 +53,8 @@ enum WebSocketCloseCode {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
MessageDecodeError = 4002, MessageDecodeError = 4002,
/** /**
* A data field is required but missing from the payload. * A data field is required but missing from the payload.
* *
* @enumIdentifier MissingDataField * @enumIdentifier MissingDataField
@ -64,8 +64,8 @@ enum WebSocketCloseCode {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
MissingDataField = 4003, MissingDataField = 4003,
/** /**
* A data field's value type is invalid. * A data field's value type is invalid.
* *
* @enumIdentifier InvalidDataFieldType * @enumIdentifier InvalidDataFieldType
@ -75,8 +75,8 @@ enum WebSocketCloseCode {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
InvalidDataFieldType = 4004, InvalidDataFieldType = 4004,
/** /**
* A data field's value is invalid. * A data field's value is invalid.
* *
* @enumIdentifier InvalidDataFieldValue * @enumIdentifier InvalidDataFieldValue
@ -86,8 +86,8 @@ enum WebSocketCloseCode {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
InvalidDataFieldValue = 4005, InvalidDataFieldValue = 4005,
/** /**
* The specified `op` was invalid or missing. * The specified `op` was invalid or missing.
* *
* @enumIdentifier UnknownOpCode * @enumIdentifier UnknownOpCode
@ -97,8 +97,8 @@ enum WebSocketCloseCode {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
UnknownOpCode = 4006, UnknownOpCode = 4006,
/** /**
* The client sent a websocket message without first sending `Identify` message. * The client sent a websocket message without first sending `Identify` message.
* *
* @enumIdentifier NotIdentified * @enumIdentifier NotIdentified
@ -108,8 +108,8 @@ enum WebSocketCloseCode {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
NotIdentified = 4007, NotIdentified = 4007,
/** /**
* The client sent an `Identify` message while already identified. * The client sent an `Identify` message while already identified.
* *
* Note: Once a client has identified, only `Reidentify` may be used to change session parameters. * 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 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
AlreadyIdentified = 4008, AlreadyIdentified = 4008,
/** /**
* The authentication attempt (via `Identify`) failed. * The authentication attempt (via `Identify`) failed.
* *
* @enumIdentifier AuthenticationFailed * @enumIdentifier AuthenticationFailed
@ -132,8 +132,8 @@ enum WebSocketCloseCode {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
AuthenticationFailed = 4009, AuthenticationFailed = 4009,
/** /**
* The server detected the usage of an old version of the obs-websocket RPC protocol. * The server detected the usage of an old version of the obs-websocket RPC protocol.
* *
* @enumIdentifier UnsupportedRpcVersion * @enumIdentifier UnsupportedRpcVersion
@ -143,8 +143,8 @@ enum WebSocketCloseCode {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
UnsupportedRpcVersion = 4010, UnsupportedRpcVersion = 4010,
/** /**
* The websocket session has been invalidated by the obs-websocket server. * 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. * 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 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
SessionInvalidated = 4011, SessionInvalidated = 4011,
/** /**
* A requested feature is not supported due to hardware/software limitations. * A requested feature is not supported due to hardware/software limitations.
* *
* @enumIdentifier UnsupportedFeature * @enumIdentifier UnsupportedFeature
@ -167,6 +167,6 @@ enum WebSocketCloseCode {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
UnsupportedFeature = 4012, UnsupportedFeature = 4012,
}; };
} }

View File

@ -20,8 +20,8 @@ with this program. If not, see <https://www.gnu.org/licenses/>
#pragma once #pragma once
namespace WebSocketOpCode { namespace WebSocketOpCode {
enum WebSocketOpCode : uint8_t { enum WebSocketOpCode : uint8_t {
/** /**
* The initial message sent by obs-websocket to newly connected clients. * The initial message sent by obs-websocket to newly connected clients.
* *
* @enumIdentifier Hello * @enumIdentifier Hello
@ -31,8 +31,8 @@ enum WebSocketOpCode : uint8_t {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
Hello = 0, Hello = 0,
/** /**
* The message sent by a newly connected client to obs-websocket in response to a `Hello`. * The message sent by a newly connected client to obs-websocket in response to a `Hello`.
* *
* @enumIdentifier Identify * @enumIdentifier Identify
@ -42,8 +42,8 @@ enum WebSocketOpCode : uint8_t {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
Identify = 1, Identify = 1,
/** /**
* The response sent by obs-websocket to a client after it has successfully identified with obs-websocket. * The response sent by obs-websocket to a client after it has successfully identified with obs-websocket.
* *
* @enumIdentifier Identified * @enumIdentifier Identified
@ -53,8 +53,8 @@ enum WebSocketOpCode : uint8_t {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
Identified = 2, Identified = 2,
/** /**
* The message sent by an already-identified client to update identification parameters. * The message sent by an already-identified client to update identification parameters.
* *
* @enumIdentifier Reidentify * @enumIdentifier Reidentify
@ -64,8 +64,8 @@ enum WebSocketOpCode : uint8_t {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
Reidentify = 3, Reidentify = 3,
/** /**
* The message sent by obs-websocket containing an event payload. * The message sent by obs-websocket containing an event payload.
* *
* @enumIdentifier Event * @enumIdentifier Event
@ -75,8 +75,8 @@ enum WebSocketOpCode : uint8_t {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
Event = 5, Event = 5,
/** /**
* The message sent by a client to obs-websocket to perform a request. * The message sent by a client to obs-websocket to perform a request.
* *
* @enumIdentifier Request * @enumIdentifier Request
@ -86,8 +86,8 @@ enum WebSocketOpCode : uint8_t {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
Request = 6, Request = 6,
/** /**
* The message sent by obs-websocket in response to a particular request from a client. * The message sent by obs-websocket in response to a particular request from a client.
* *
* @enumIdentifier RequestResponse * @enumIdentifier RequestResponse
@ -97,8 +97,8 @@ enum WebSocketOpCode : uint8_t {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
RequestResponse = 7, RequestResponse = 7,
/** /**
* The message sent by a client to obs-websocket to perform a batch of requests. * The message sent by a client to obs-websocket to perform a batch of requests.
* *
* @enumIdentifier RequestBatch * @enumIdentifier RequestBatch
@ -108,8 +108,8 @@ enum WebSocketOpCode : uint8_t {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
RequestBatch = 8, RequestBatch = 8,
/** /**
* The message sent by obs-websocket in response to a particular batch of requests from a client. * The message sent by obs-websocket in response to a particular batch of requests from a client.
* *
* @enumIdentifier RequestBatchResponse * @enumIdentifier RequestBatchResponse
@ -119,11 +119,8 @@ enum WebSocketOpCode : uint8_t {
* @initialVersion 5.0.0 * @initialVersion 5.0.0
* @api enums * @api enums
*/ */
RequestBatchResponse = 9, RequestBatchResponse = 9,
}; };
inline bool IsValid(uint8_t opCode) inline bool IsValid(uint8_t opCode) { return opCode >= Hello && opCode <= RequestBatchResponse; }
{
return opCode >= Hello && opCode <= RequestBatchResponse;
}
} }