Skip to content

Commit

Permalink
Update BUILDING.md
Browse files Browse the repository at this point in the history
  • Loading branch information
WarmUpTill committed Mar 2, 2024
1 parent 073866a commit 8352516
Showing 1 changed file with 26 additions and 22 deletions.
48 changes: 26 additions & 22 deletions BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ You have the option to ...
- either add the plugin to the OBS source tree directly and build the plugin while building OBS itself. (**in tree**)
- or you can move the sources of this plugin outside of the OBS source tree and build it separately from OBS. (**out of tree**)

As both methods require you to have a working [OBS Studio development environment](https://obsproject.com/wiki/Building-OBS-Studio) and [CMake](https://cmake.org/download/) it is recommended to build the plugin in tree as it is easier to set up and will enable straightforward debugging.
Both methods require [CMake](https://cmake.org/download/).

The plugin can be compiled for OBS 25 and above, although using the latest version of OBS is recommended to support all features.
The plugin can be compiled for OBS 27 and above, although using the latest version of OBS is recommended to support all features.

## Compiling in tree (recommended for development)
This section assumes that you have a working [OBS Studio development environment](https://obsproject.com/wiki/Building-OBS-Studio).

Add the "SceneSwitcher" source directory to your obs-studio source directory under obs-studio/UI/frontend-plugins/:
```
cd obs-studio/UI/frontend-plugins/
Expand Down Expand Up @@ -46,12 +48,12 @@ cmake -DOpenCV_DIR="C:/Users/BuildUser/Documents/OBS/opencv/build/" -DLeptonica_
First you will need to clone the plugin sources by running the following command:
```
git clone --recursive https://github.com/WarmUpTill/SceneSwitcher.git
cd SceneSwitcher
```

Next you will need [CMake](https://cmake.org/download/) and run the command with suitable arguments for your particular platform.
Next you will need [CMake](https://cmake.org/download/) and run it with suitable arguments for your particular platform.
For example, on Windows you might want to run this command:
```
cd SceneSwitcher
cmake --preset windows-x64
```
Next, you can build the plugin and install the files into a folder named release using the following commands:
Expand All @@ -72,7 +74,7 @@ cd SceneSwitcher
cmake -DOpenCV_DIR="C:/Users/BuildUser/Documents/OBS/opencv/build/" -DLeptonica_DIR="C:/Users/BuildUser/Documents/OBS/leptonica/build" -DTesseract_DIR="C:/Users/BuildUser/Documents/OBS/tesseract/build/lib/cmake/tesseract" --preset windows-x64
```

You can rely on the CI scripts to build the dependencies for you, although it is not guaranteed that they will work in every environment:
You can rely on the CI scripts to build the dependencies for you, although it is not guaranteed that they will function in every environment:

| Platform | Command |
| ----------- | ----------- |
Expand All @@ -83,10 +85,10 @@ You can rely on the CI scripts to build the dependencies for you, although it is

# Contributing

Contributions to the plugin are always welcome and if you need any assistance do not hesitate to reach out.
Contributions to the plugin are always welcome and if you need any assistance do not hesitate to reach out!

If you would like to expand upon the macro system by adding a new condition or action type have a look at the examples in `plugins/base`.
In general changes in the `lib/legacy` folder should be avoided.
In general changes in the `lib/legacy` folder should be avoided, if possible.

## Macro condition
Macro conditions should inherit from the `MacroCondition` class and must implement the following functions:
Expand All @@ -97,12 +99,12 @@ public:
MacroConditionExample(Macro *m) : MacroCondition(m) {}
// This function should perform the condition check
bool CheckCondition();
// This function should store the required condition data to "obj"
// This function should store the required condition data to "data"
// For example called on OBS shutdown
bool Save(obs_data_t *obj);
// This function should load the condition data from "obj"
bool Save(obs_data_t *data);
// This function should load the condition data from "data"
// For example called on OBS startup
bool Load(obs_data_t *obj);
bool Load(obs_data_t *data);
// This function should return a unique id for this condition type
// The _id is defined below
std::string GetId() { return _id; };
Expand All @@ -120,7 +122,7 @@ private:
static const std::string _id;
};
```
When defining the widget used to control the settings of the condition type, it is important to add a static `Create()` method.
When defining the widget used to control the settings of the condition type, a static `Create()` method is required.
It will be called whenever a new condition MacroConditionExample is created. (See `MacroConditionFactory::Register()`)
```
class MacroConditionExampleEdit : public QWidget {
Expand Down Expand Up @@ -151,7 +153,7 @@ bool MacroConditionExample::_registered = MacroConditionFactory::Register(
MacroConditionExample::id, // Unique string identifying this condition type
{
MacroConditionExample::Create, // Function called to create the object performing the condition
MacroConditionExampleEdit::Create, // Function called to create the widget configure the condition
MacroConditionExampleEdit::Create, // Function called to create the widget to configure the settings
"AdvSceneSwitcher.condition.example", // User facing name of the condition type (will be translated)
true // Condition type supports duration modifiers (default true)
}
Expand All @@ -167,16 +169,18 @@ The differences are highlighted in the comments below.
class MacroActionExample : public MacroAction {
public:
MacroActionExample(Macro *m) : MacroAction(m) {}
static std::shared_ptr<MacroAction> Create(Macro *m);
// Used to create a copy of the action (used for action queues)
std::shared_ptr<MacroAction> Copy() const;
// This function should perform the action
// If false is returned the macro will aborted
bool PerformAction();
bool Save(obs_data_t *obj);
bool Load(obs_data_t *obj);
bool Save(obs_data_t *data);
bool Load(obs_data_t *data);
std::string GetId() { return _id; };
static std::shared_ptr<MacroAction> Create(Macro *m)
{
return std::make_shared<MacroActionExample>(m);
}
// Optional:
// Might be called when action is inserted to action queue
void ResolveVariablesToFixedValues();
private:
static bool _registered;
Expand Down Expand Up @@ -207,11 +211,11 @@ MacroActionFactory::Register(
MacroActionExample::id, // Unique string identifying this action type
{
MacroActionExample::Create, // Function called to create the object performing the action
MacroActionExampleEdit::Create, // Function called to create the widget configure the action
MacroActionExampleEdit::Create, // Function called to create the widget to configure the settings
"AdvSceneSwitcher.action.example" // User facing name of the action type
}
);
```
## External dependencies
If your intention is to add macro functionality which depends on external libraries, which is likely not to exist on all user setups, have a look at the folders in the `plugins/` directory, which are not named base.
For example `plugins/video` will only be loaded if the `OpenCV` dependencies are met.
If your intention is to add macro functionality which depends on external libraries, which might not exist on all user environments, have a look at the folders in the `plugins/` directory, which are not named `base`.
For example, `plugins/video` will only be loaded if the `OpenCV` dependencies are met.

0 comments on commit 8352516

Please sign in to comment.