Commit Graph

49 Commits

Author SHA1 Message Date
tt2468
fcbe11616d
docs: Overhaul documentation (#863)
More docs-related commits will follow, but this needs to be merged in order to continue with other development.

* Docs: Overhaul docs generator (beginning)

* docs: Rename comments file

* docs: Move comments gitignore

* docs: Initial request documentation

* docs: Improvements to comment processing

* docs: More improvements

* docs: Add enum functionality for protocol.json

* WebSocketServer: Document enums

* RequestHandler: Document RequestStatus enum

* Base: Move ObsWebSocketRequestBatchExecutionType to its own file

Moves it to its own file, renaming it to `RequestBatchExecutionType`.
Changes the RPC to use integer values for selecting execution type
instead of strings.

* docs: Update introduction header

Removes the enum section, and documents RequestBatchExecutionType.

* WebSocketCloseCode: Shuffle a bit

* Base: Use `field` instead of `key` or `parameter` in most places

* RequestStatus: Mild shuffle

It was really bothering me that OutputPaused and OutputNotPaused
had to be separated, so we're breaking it while we're breaking
other stuff.

* docs: Delete old files

They may be added back in some form, but for now I'm getting them
out of the way.

* docs: Add enum identifier value

Forgot to add this before, oops

* docs: Document more enums

* docs: Add basic protocol.md generator

* docs: More work on MD generator

* docs: MD generator should be finished now

* docs: More fixes

* docs: More fixes

* docs: More tweaks + add readme

* docs: Update readme and add inputs docs

* docs: More documentation
2021-12-10 21:38:18 -08:00
tt2468
d48ddef031 EventHandler: Implement InputVolumeMeters
This is probably one of the most requested features for obs-websocket.
This currently works by firing an event to all explicit subscribers
with an array of all active audio sources every **60 milliseconds.**

The `inputLevelsMul` field follows this data format:

Base: [Channel, Channel]
Channel: [magnitude (mul), peak (mul), input_peak (mul)]

           *Not Muted*         *Muted*
Example: [[0.3, 0.5, 0.9], [0.0, 0.0, 0.0]]

(input_peak is the actual peak value, before volume adjustment.)

You may notice that the values are only in mul. This is because we are
trying to cut down on bandwidth. dB values can be calculated using this
formula:

`dB = 20.0 * log10(mul)`
2021-11-22 03:37:56 -08:00
tt2468
bc7b8d330a RequestHandler: Move RequestStatus.h to types directory 2021-11-21 03:13:53 -08:00
tt2468
0a294a558e WebSocketServer: Move enums to types directory
Code cleanup, makes WebSocketServer match how enums are handled in
other parts of the plugin
2021-11-21 01:37:21 -08:00
tt2468
4ca259b790 Base: Enforce -Wall and fix compiler warnings
That was *a lot* of warnings.
2021-11-20 02:34:48 -08:00
tt2468
99cbaaf34c Base: Implement ObsWebSocketApi + cleanup
- Implements a WIP ObsWebSocketApi, for obs-websocket-api.h. Events are
finished, but requests are not.
- Some logging improvements
- A bit of code cleanup around the plugin
2021-11-20 01:26:50 -08:00
tt2468
5ab091a40b Base: Move WebSocketServer to its own directory
Just helps with organization
2021-11-18 00:29:28 -08:00
tt2468
08eb2defbc Requests: Add GetMediaInputState 2021-11-17 01:17:40 -08:00
tt2468
0671ded7d1 Requests: Add recording requests 2021-11-17 00:30:17 -08:00
tt2468
a8d27ede9e Base: Add request batch execution types
A new `executionType` field has been added to the `RequestBatch` Op

Types added:
- `OBS_WEBSOCKET_REQUEST_BATCH_EXECUTION_TYPE_SERIAL_REALTIME`(default)
- `OBS_WEBSOCKET_REQUEST_BATCH_EXECUTION_TYPE_SERIAL_FRAME`
- `OBS_WEBSOCKET_REQUEST_BATCH_EXECUTION_TYPE_PARALLEL`

`OBS_WEBSOCKET_REQUEST_BATCH_EXECUTION_TYPE_SERIAL_REALTIME`:
- Same as how request batches have always worked.
- Requests are processed in-order
- Requests are processed as soon as possible by one worker thread
- The `Sleep` request blocks execution for a specified amount of real
world time

`OBS_WEBSOCKET_REQUEST_BATCH_EXECUTION_TYPE_SERIAL_FRAME`:
- New!
- Requests are processed in-order
- Requests are processed on the graphics thread. BE VERY CAREFUL NOT
TO OVERLOAD THE GRAPHICS THREAD WITH LARGE REQUESTS. A general rule
of thumb is for your request batches to take a maximum of 2ms per
frame of processing.
- Requests processing starts right before the next frame is composited.
This functionality is perfect for things like `SetSceneItemTransform`
- The `Sleep` request will halt processing of the request batch for
a specified number of frames (ticks)
- To be clear: If you do not have any sleep requests, all requests in
the batch will be processed in the span of a single frame
- For developers: The execution of requests gets profiled by the OBS
profiler under the `obs-websocket-request-batch-frame-tick` name.
This value (shown in the OBS log after OBS shutdown) represents the
amount of time that the graphics thread spent actively processing
requests per frame. This tool can be used to determine the amount of
load that your request batches are placing on the graphics thread.

`OBS_WEBSOCKET_REQUEST_BATCH_EXECUTION_TYPE_PARALLEL`:
- New!
- Requests are processed asynchronously at the soonest possible time.
- Requests are processed by the core obs-websocket thread pool, where
the number of workers == the number of threads on your machine.
  - If you have 12 threads on your machine, obs-websocket will be able
to process 12 requests at any given moment.
- The `results` array is populated by order of request completion.
Consider the order to be random.
- The `Sleep` request will return an error if attempted to be used in
this mode.
- Note: This feature is experimental and can increase the chances of
causing race conditions (crashes). While the implementation is fully
thread-safe, OBS itself is not. Usage of this is only recommended if
you are processing very large batches and need the performance benefit.
- Example use case: Performing `SaveSourceScreenshot` on 8 sources
at once.
2021-09-26 03:12:29 -07:00
tt2468
0c2e40263a WebSocketServer: Remove QtConcurrent dependency
We can avoid requiring QtConcurrent by using QRunnables. Thanks to
micolous for the idea.
2021-09-24 18:11:31 -07:00
tt2468
7e1e1bc33c Base: Large plugin refactor
- Merge WebSocketProtocol into WebSocketServer
  - Having them separated was not doing anything productive
- Request: Move SessionPtr to RequestHandler
  - Less copying to do for batch requests
- Fully modularize EventHandler
  - Make BroadcastEvent a stored callback that WebSocketServer sets
- Return early on high volume events to avoid unnecessary compute
  - These events will only generate a json object when it is actually
needed
2021-09-04 10:04:00 -07:00
tt2468
333737f400 Requests: Additions and code cleanup 2021-09-02 19:29:13 -07:00
tt2468
a3d0ff5eea CMakeLists: More changes for version suffix 2021-08-30 03:08:09 -07:00
tt2468
1ecf2a4fdb CMakeLists: Allow specifying version suffix string 2021-08-30 02:50:02 -07:00
tt2468
96ab90eea1 CMakeLists: Fix indentations 2021-08-26 19:09:52 -07:00
tt2468
43a889c1d4 Utils: Refactor into dedicated components 2021-08-26 19:00:48 -07:00
tt2468
d0e05ae45c Requests: Add more requests
- GetStreamServiceSettings
- SetStreamServiceSettings
- CreateInput
- GetStreamStatus
- StartStream
- StopStream
2021-07-22 16:26:04 -07:00
tt2468
aac06b101e RequestHandler: Add GetInputList 2021-06-16 00:49:07 -07:00
tt2468
39f2db8723 CMakeLists: Convert spaces to tabs 2021-06-14 23:00:33 -07:00
tt2468
cb5ee53956 RequestHandler: Add GetSceneList 2021-06-14 22:52:23 -07:00
tt2468
80b9732f94 RequestHandler: Some source stuff 2021-06-13 07:14:40 -07:00
tt2468
4a00d169e1 RequestHandler: Add some config requests 2021-06-07 01:14:32 -07:00
tt2468
6a325e4c94 CMakeLists: Link Qt5::Svg
Fixes help icon not showing on Windows
2021-06-06 00:15:43 -07:00
tt2468
a7c4f98ffa SettingsDialog: Add tooltip icon to debug checkbox 2021-06-05 23:06:36 -07:00
tt2468
6c03b86514 EventHandler: Add Outputs events and other files 2021-05-31 18:51:56 -07:00
tt2468
9077ac911d EventHandler: Add some transition stuff
Transitions in OBS are implemented badly.
Not sure what will reasonably be possible with them.
I'll probably save implementing them for last
2021-05-14 03:59:00 -07:00
tt2468
45d62e5ce0 EventHandler: General, Config, Scenes, Inputs 2021-05-14 01:13:27 -07:00
tt2468
ab12d5f39f EventHandler: Add some events 2021-05-13 19:11:19 -07:00
tt2468
11d28d17f1 EventHandler: Add EventSubscriptions enum 2021-05-13 17:34:57 -07:00
tt2468
c0accd9cde base: Add EventHandler files 2021-05-10 15:48:41 -07:00
tt2468
ee751edf54 SettingsDialog: Mild refactor and add Connect Info dialog
Among lots of stuff:

- Generate a random password on first load

- Add `ConnectInfo` dialog including QR code display

- Add `Generate Password` button to generate a new random
password

- Delete `Copy Password to Clipboard` button

- Delete `GetConnectString` or whatever from WebSocketServer
(reimplemented the functionality directly into ConnectInfo)

- Added `GeneratePassword()` to Utils

Todo: Show warning when users specify their own passwords
2021-05-08 04:29:03 -07:00
tt2468
600505b60a Utils: Add Obs utils namespace 2021-05-08 00:54:35 -07:00
tt2468
807a1501b7 base: Refactor request stuff and finish more logic 2021-05-03 13:31:22 -07:00
tt2468
36af7f6f58 base: Lots of stuff, including RequestHandler progress 2021-05-02 19:48:44 -07:00
tt2468
ad8b13606f Base: Add WebSocketProtocol
Will be used to handle incoming websocket messages. Initially I was
going to handle messages within WebSocketServer, but the file is
starting to get very large and so it's only fair to split it up.
2021-04-29 10:52:29 -07:00
tt2468
1dcf6460f1 Utils: Add Platform helpers 2021-04-28 14:24:05 -07:00
tt2468
948750da6a WebSocketServer: Start and stop 2021-04-28 10:27:32 -07:00
tt2468
98bc18cedd utils: Create Utils namespace and add Crypto utils 2021-04-27 17:55:23 -07:00
tt2468
d9ee288cf1 base: cmake is fucking retarded 2021-04-27 16:33:47 -07:00
tt2468
8067cfb686 Base: Tons more shit 2021-04-27 14:52:48 -07:00
tt2468
c4b27ed340 cmakelists: Fix formatting 2021-04-27 12:51:58 -07:00
tt2468
fb8e520d10 utils: Create JsonUtils
Utility functions for converting from obs_data_t to json and back
2021-04-27 12:50:42 -07:00
tt2468
107d3cce09 deps: Add nlohmann json
I decided to go with nlohmann::json because it supports both JSON and
msgpack. I'm likely going to have to write some conversion utils to
convert between obs_data_t and json, but the advantages of what
nlohmann::json brings to the table are just too attractive.
2021-04-27 09:46:00 -07:00
tt2468
a0162caad1 base: Add base RequestHandler and rpc files 2021-04-27 09:29:51 -07:00
tt2468
f0dfe72aca base: Add starting WebSocketServer files 2021-04-27 09:18:06 -07:00
tt2468
a8ca912044 generic: Add SettingsDialog and Config 2021-04-26 19:59:50 -07:00
tt2468
dd597f1ad6 everything: Massive amount of changes who knows 2021-04-26 08:46:11 -07:00
tt2468
f3d5cfbd18 Initial commit for attempted rewrite 2021-03-08 03:56:43 -08:00