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
KeepEmptyLinesAtTheStartOfBlocks: true
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
NamespaceIndentation: All
#ObjCBinPackProtocolList: Auto # requires clang-format 7
ObjCBlockIndentWidth: 8
ObjCSpaceAfterProperty: true

View File

@ -20,8 +20,8 @@ with this program. If not, see <https://www.gnu.org/licenses/>
#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),
};
}

View File

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

View File

@ -20,8 +20,8 @@ with this program. If not, see <https://www.gnu.org/licenses/>
#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,
};
}

View File

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

View File

@ -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(); }
}
}

View File

@ -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<std::string> GetSceneCollectionList();
std::vector<std::string> GetProfileList();
std::vector<obs_hotkey_t *> GetHotkeyList();
std::vector<std::string> GetHotkeyNameList();
std::vector<json> GetSceneList();
std::vector<std::string> GetGroupList();
std::vector<json> GetSceneItemList(obs_scene_t *scene, bool basic = false);
std::vector<json> GetInputList(std::string inputKind = "");
std::vector<std::string> GetInputKindList(bool unversioned = false, bool includeDisabled = false);
std::vector<json> GetListPropertyItems(obs_property_t *property);
std::vector<std::string> GetTransitionKindList();
std::vector<json> GetSceneTransitionList();
std::vector<json> GetSourceFilterList(obs_source_t *source);
std::vector<std::string> GetFilterKindList();
}
namespace ArrayHelper {
std::vector<std::string> GetSceneCollectionList();
std::vector<std::string> GetProfileList();
std::vector<obs_hotkey_t *> GetHotkeyList();
std::vector<std::string> GetHotkeyNameList();
std::vector<json> GetSceneList();
std::vector<std::string> GetGroupList();
std::vector<json> GetSceneItemList(obs_scene_t *scene, bool basic = false);
std::vector<json> GetInputList(std::string inputKind = "");
std::vector<std::string> GetInputKindList(bool unversioned = false, bool includeDisabled = false);
std::vector<json> GetListPropertyItems(obs_property_t *property);
std::vector<std::string> GetTransitionKindList();
std::vector<json> GetSceneTransitionList();
std::vector<json> GetSourceFilterList(obs_source_t *source);
std::vector<std::string> 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);
}
}
}

View File

@ -31,69 +31,70 @@ with this program. If not, see <https://www.gnu.org/licenses/>
#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<enum obs_peak_meter_type> PeakMeterType;
std::atomic<enum obs_peak_meter_type> 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<uint64_t> _lastUpdate;
std::atomic<float> _volume;
std::atomic<uint64_t> _lastUpdate;
std::atomic<float> _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<void(std::vector<json>)> UpdateCallback;
typedef std::unique_ptr<Meter> MeterPtr;
// Maintains an array of active inputs
class Handler {
typedef std::function<void(std::vector<json>)> UpdateCallback;
typedef std::unique_ptr<Meter> 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<MeterPtr> _meters;
uint64_t _updatePeriod;
std::mutex _meterMutex;
std::vector<MeterPtr> _meters;
uint64_t _updatePeriod;
std::mutex _mutex;
std::condition_variable _cond;
std::atomic<bool> _running;
std::thread _updateThread;
std::mutex _mutex;
std::condition_variable _cond;
std::atomic<bool> _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);
};
}
}
}

View File

@ -24,12 +24,12 @@ with this program. If not, see <https://www.gnu.org/licenses/>
#include <QSystemTrayIcon>
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);
}
}

View File

@ -20,8 +20,8 @@ with this program. If not, see <https://www.gnu.org/licenses/>
#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,
};
}

View File

@ -20,8 +20,8 @@ with this program. If not, see <https://www.gnu.org/licenses/>
#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; }
}