Commit Graph

366 Commits

Author SHA1 Message Date
tt2468
16ea2c82e1 Requests: Verify current program scene
Crashes can occur if there is no current program scene. Currently
caused by connecting to obs-websocket and calling `GetSceneList`
before OBS has actually finished loading.
2021-10-01 17:20:38 -07:00
tt2468
981538aa2a Base: Make some items atomic 2021-09-30 19:14:17 -07:00
tt2468
9f71e4af2c
Merge pull request #829 from dnaka91/add-obws-reference
README: Add Rust obws to library list
2021-09-28 11:52:34 -07:00
Dominik Nakamura
0fc813f48b
README: Add Rust obws to library list 2021-09-28 23:34:30 +09:00
tt2468
df7af451a7 Requests: Fix some parameter validation
Thanks to t2t2 for the report over Discord
2021-09-26 03:54:16 -07: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
45854e2949 Config: Properly add more logging, fix bug 2021-09-26 03:10:43 -07:00
tt2468
181003af89 Utils: Use emplace_back instead of push_back
Saves copy operations
2021-09-25 19:34:05 -07:00
tt2468
2218b7956c Requests: Support groups in most of the scene item requests
Tested each request to the fullest reasonable extent. Requests performed properly without errors or leaks
2021-09-25 18:59:04 -07:00
tt2468
0e8650dbd2 Requests: Support groups in GetSceneItemId 2021-09-25 18:45:37 -07:00
tt2468
da4297ee88 Request: Clarify error messages 2021-09-25 18:45:00 -07:00
tt2468
5350c115bf Requests: Improve more request checks 2021-09-25 18:29:27 -07:00
tt2468
d09571f0e3 Requests: Improve some check logic in GetSourceActive 2021-09-25 18:20:01 -07:00
tt2468
d04d42240a Request: Fix scene filter functionality
Previous functionality did not support groups.
2021-09-25 18:14:25 -07:00
tt2468
9ca83e7570 Requests: Make GetSceneItemId scene only 2021-09-25 17:54:39 -07:00
tt2468
aa0ba78e46 Base: Use more refcounts
Use refcounts more effectively
2021-09-25 17:52:08 -07:00
tt2468
b91ad0f790 Requests: Add GetSceneItemId
I realized that it was not entirely fair to expect users to fetch a
scene's item list, then search the list on the client in order to find
an item ID, so this is a compromise. This will also help developers
move from the 4.x scene item functionality to 5.x's

Operating on scene items by relying on source name can be dangerous
and in some cases exhibit what would be considered undefinied behavior.
Operating on scene items using IDs is best practice.
2021-09-25 17:21:06 -07:00
tt2468
4e0b8c5f11 Utils/Obs: Add GetSceneItemByName
Simple, didn't really need to be a util tbh. But I added it anyway
and there's nothing you can do to stop me
2021-09-25 17:21:00 -07:00
tt2468
ea948766a5 Events: Fix conversion warning
Thanks micolous for the report.
2021-09-24 18:54:48 -07:00
tt2468
c73a153c9a Utils/Crypto: Use better method for GenerateSecret
Thanks to micolous for the suggestion
2021-09-24 18:39:46 -07:00
tt2468
61973e75dc Revert "CI: Build against OBSProject Qt distribution"
This reverts commit 59e1083557.
2021-09-24 18:26:34 -07:00
tt2468
59e1083557 CI: Build against OBSProject Qt distribution 2021-09-24 18:14:26 -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
78d02696d0 Utils: Add retrocompatability header
QRunnable::create was added in Qt 5.15, but Ubuntu still uses 5.12.
This reimplements that functionality until Ubuntu moves to >= 5.15
2021-09-24 18:10:17 -07:00
tt2468
7a888c2f92 Config: Add more logging
Good to have
2021-09-24 18:09:46 -07:00
tt2468
342164dfb5 Forms: Use QHideEvent instead of QCloseEvent
QCloseEvent is the wrong event to use here. If the `Ok` button is
pressed for example, QCloseEvent is not emitted. QHideEvent is
always called when the dialog is hidden.
2021-09-17 03:00:33 -07:00
tt2468
a4e62acf25 Forms: Update ConnectInfo on settings apply instead of close
Just for better usability
2021-09-17 02:54:29 -07:00
tt2468
d811c95e10 Requests: Add some more failure checks and improve response codes 2021-09-17 02:43:20 -07:00
tt2468
eebcc25115 Requests: Add unpublished RemoveInput
The functionality depends on obs-studio#5276 to be merged and released,
so we can add it but not enable it for now.
2021-09-17 02:42:58 -07:00
tt2468
c9fa09edc4 Config/Base: Refactor with fixes
Fixes these things:
- Websocket password is not generated if FirstLoad and overridden
- Save generated password immediately if FirstLoad
- Do not generate new password if FirstLoad and password already exists
- More logging
2021-09-17 02:25:30 -07:00
tt2468
69ccc99921 Utils/UI: Make GeneratePassword() use std::string
Just for consistency
2021-09-17 02:09:44 -07:00
tt2468
a5a19b9952 Utils/Crypto: Use QRandomGenerator instead of qrand()
qrand() is obsolete, and QRandomGenerator produces numbers seeded from
the platform's RNG source. Makes our authentication system way more
secure too.
2021-09-17 02:00:30 -07:00
tt2468
66ff329da4
Config: Fix typo 2021-09-15 03:46:52 -07:00
tt2468
af0ac63f2c Installer: Fail if OBS is not installed 2021-09-12 00:22:11 -07:00
tt2468
802cb38ff6
README: Move simpleobsws to the correct section 2021-09-10 01:37:59 -07:00
tt2468
117dcb9567
Merge pull request #815 from dnaka91/fix-validate-basic
Requests: Fix wrong validation in ValidateBasic
2021-09-06 06:43:38 -07:00
Dominik Nakamura
d20c0d0da7
Reqeusts: Fix wrong validation in ValidateBasic 2021-09-06 10:48:01 +09:00
Github Actions
a9d86ce35c docs(ci): Update generated docs - b9b8e38 [skip ci] 2021-09-04 17:58:05 +00:00
tt2468
b9b8e38998 WebSocketServer: Remove ignoreNonFatalRequestChecks from session params 2021-09-04 10:57:00 -07:00
tt2468
e89c0c2b05 Base: More code cleanup and fixes 2021-09-04 10:47:51 -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
537595658d Requests: Add GetSceneItemTransform 2021-09-03 15:59:09 -07:00
tt2468
c43d829845 Events: Complete SceneItemTransformChanged 2021-09-03 15:58:50 -07:00
tt2468
3d2fb65357 Utils: Add GetSceneItemTransform 2021-09-03 15:58:34 -07:00
tt2468
96dcc49adb Requests: More requests and code cleanup
(plus very slight performance improvement)
2021-09-03 12:52:50 -07:00
tt2468
25b3bd44ba RequestHandler/RPC: Improve code efficiency and add optionals 2021-09-03 12:52:15 -07:00
tt2468
bcdb8ee352 Events: Fix SceneItemListReindexed event name 2021-09-03 08:59:09 -07:00
tt2468
333737f400 Requests: Additions and code cleanup 2021-09-02 19:29:13 -07:00
tt2468
82d8a3d7ce Utils: Add stuff to Obs 2021-09-02 19:28:55 -07:00
tt2468
d7f96b6dea Revert "Request: Minor code cleanup"
This reverts commit c16669c7b0.
2021-09-02 13:33:20 -07:00