Compare commits

...

361 Commits

Author SHA1 Message Date
7906057440 base: Update source code to build against 27.2.4 2022-08-02 15:58:09 -07:00
96c6b03aa6 CI: Update package name to not collide with 5.0.0 2022-08-02 15:51:19 -07:00
7ea9b16b37 Events: Fix memory leak
`bfree` was missing after calling `obs_frontend_get_current_profile()`.
2022-05-31 01:03:05 +09:00
ff6b774687 CMakeLists: Don't include imageformats plugins 2022-03-01 17:20:20 -08:00
9bdaefded9 CI: Update packages version 2022-03-01 17:10:39 -08:00
4a88612693 CI: Use focal 2022-03-01 16:59:05 -08:00
f8a88c54ce CI: force use obs 27.1.3 on linux 2022-03-01 16:53:41 -08:00
df2049b751 Locale: Update start failure message 2022-01-28 15:55:30 -08:00
dc9afeb213 Config: Reuse 4.x configs directly
Since compat is not meant to run alongside real 4.x, we shouldn't
care about reusing the original settings.
2022-01-28 15:43:50 -08:00
13c1c108ea Config: Set default port back to 4444 2022-01-28 15:43:14 -08:00
16ee66e6dc Base: Add logging for compile time ASIO version 2022-01-07 23:02:05 -08:00
d563dd3146 deps: Downgrade asio to 1.12.1
Even though we statically link ASIO, it has issues with the
kqueue_reactor() on macos segfaulting when other plugins using
different ASIO versions are installed. So that means we're stuck using
1.12.1 until we can find some kind of fix for the crash issue.
2022-01-04 00:39:52 -08:00
65a17071d2 deps: Upgrade to versions used by master 2022-01-03 23:35:02 -08:00
d993ce8b1a CI: Attempt fix of directory name 2022-01-03 18:39:45 -08:00
9c4a114c94 CI: Use specific branch instead of checkout
Azure is a dumb platform, meaning `git` is randomly not found.
So we'll just use something else then.
2022-01-03 17:34:11 -08:00
7062062ec5 CI: Fix sln file location on windows 2022-01-03 17:26:51 -08:00
be7c334a72 CI: Fix binary name on macos 2022-01-03 17:20:26 -08:00
b5f267d3bb RPC: Remove usage of std::optional
Stupid 10.13 doesnt support C++17. No idea how we built 4.9.0
2022-01-03 17:06:13 -08:00
d0d89dd133 CI: Use specifically 27.1.3 for build 2022-01-03 16:48:34 -08:00
a0e8cb6b4c CI: Set target to 10.13
This was accidentally removed in 4.9.1
2022-01-03 16:44:52 -08:00
348e875969 CI: Update more versions 2022-01-03 16:30:08 -08:00
be0fb682e0 CI: Build on 4.x-compat 2022-01-03 16:28:22 -08:00
ea8f14e41b Base: Update files for compat release 2022-01-03 16:26:42 -08:00
a8a3f3aafe WSServer: Add debug logging to stop()
Some users have been having issues with OBS hanging on server stop,
so this will help troubleshoot.
2021-11-18 15:58:33 -08:00
387376e5e0 .github: Remove logo 2021-11-16 22:59:15 -08:00
80cefdcfda README: Remove logo 2021-11-16 22:58:22 -08:00
6a14110720 Merge pull request #833 from you-win/feature/add-obs-websocket-gd-to-readme
Readme: Add obs-websocket-gd to readme
2021-10-07 12:37:08 -07:00
8bfe2bf04c Readme: Add obs-websocket-gd to readme
Add the obs-websocket-gd project to the readme as an available
language API.
2021-10-07 11:11:05 -04:00
bbf4b321d7 Merge pull request #780 from Palakis/fix/obsdata-double-release
Protocol: Fix double free of obs_data_t*
2021-07-18 21:11:07 +02:00
310c297a36 docs(ci): Update protocol.md - 5d14cb7 [skip ci] 2021-07-18 19:01:49 +00:00
5d14cb7af8 Merge pull request #791 from dvangennip/4.x-current
WSRequestHandler_Sources: fix comment name for Set/GetAudioTrack
2021-07-18 12:01:08 -07:00
48291506f5 Merge pull request #792 from andreykaipov/docs/go
Docs: Add another Go client library
2021-07-08 19:20:22 -07:00
b0badd0630 Docs: Add another Go client library 2021-07-08 21:21:25 -04:00
c5ef671e0c WSRequestHandler_Sources: fix comment name for Set/GetAudioTrack
Functions were named SetTracks and GetTracks rather than SetAudioTracks and GetAudioTracks as in the actual code, so this mismatch gets picked up by the protocol docs (but not anymore).
2021-07-03 21:04:49 +10:00
ffb97aaabc Protocol: Fix double free of obs_data_t* 2021-06-20 16:26:45 -07:00
d05ff26930 docs(ci): Update protocol.md - 5350832 [skip ci] 2021-06-10 05:56:15 +00:00
535083205a Merge pull request #765 from Palakis/4.9.1-prep
4.9.1 Prep
2021-06-10 07:55:38 +02:00
9a8d283d27 base: Update plugin version to 4.9.1 2021-06-09 21:03:59 -07:00
1eb02e77e0 Docs: Mark unreleased requests with 4.9.1 2021-06-09 19:11:02 -07:00
b271cf9d32 Merge pull request #692 from Palakis/fix/obs-shutdown-crash
Events: Fix multiple shutdown crashes
2021-06-10 02:39:26 +02:00
0a084122d3 Merge pull request #764 from dnaka91/fix-leak-tbar
Requests: Fix leak in ReleaseTBar, SetTBarPosition
2021-06-08 18:31:35 -07:00
a29e0325dd Merge pull request #761 from dnaka91/fix-release-transition
Requests: Fix leak in SetSceneTransitionOverride
2021-06-08 18:30:03 -07:00
4ea010f168 Requests: Fix leak in ReleaseTBar, SetTBarPosition 2021-06-09 10:24:09 +09:00
b03ab12e45 Requests: Fix leak in SetSceneTransitionOveride 2021-06-09 09:41:46 +09:00
9311b38747 Merge pull request #760 from bobvandevijver/patch-1
Fix small pipeline typo
2021-06-07 09:30:36 -07:00
2380ba4612 Fix small pipeline typo 2021-06-07 11:39:41 +02:00
60e2f0183e Merge branch '4.x-current' into fix/obs-shutdown-crash 2021-06-06 16:25:38 -07:00
8009f65ed0 Merge pull request #758 from Palakis/fix/ci-patches
CI: Fix some various stuff getting in the way of doing 4.9.1 dev
2021-06-06 17:53:59 +02:00
393fca6aed CI: Update dirty hack to OBS 27 2021-06-01 18:34:52 -07:00
f8abe91b83 CI: Version our OBS build cache
When new OBS tags are released, we need to wipe the old cache
to get them to work properly.
2021-06-01 18:22:34 -07:00
27ab3e0ea8 CI: Allow usage of RC's for objects 2021-06-01 18:12:15 -07:00
1ca10f3e34 CI: Remove github workflows for now
It's super broken on this branch and getting in the way. Removing
it for now and I'll move everything back to gh workflows after 4.9.1
2021-06-01 18:11:13 -07:00
c1cd1adb08 WSServer: Run asio loop in std::thread and join on stop 2021-06-01 18:00:24 -07:00
1266b3f3fe Events: Various crash fixes 2021-06-01 18:00:14 -07:00
5505e0d7b5 docs(ci): Update protocol.md - a469fc5 [skip ci] 2021-06-02 00:20:15 +00:00
a469fc539a Merge pull request #708 from Meetsch/feature/virtualcam
Requests: support for new virtualcam related obs-frontend-api in upcoming OBS-Studio 27.0
2021-06-01 17:19:32 -07:00
ef36585319 Requests, Events: Mark as unreleased 2021-06-01 17:01:20 -07:00
46214eef44 docs(ci): Update protocol.md - 5f0b152 [skip ci] 2021-06-01 00:14:07 +00:00
5f0b152427 Merge pull request #751 from hanazuki/doc-ReorderSceneItems
docs: Fix type of ReorderSceneItems request parameter
2021-05-31 17:13:33 -07:00
cbc7664b78 Merge pull request #740 from Palakis/fix/createscene-release-source
Requests: Release created scene in CreateScene
2021-06-01 01:52:39 +02:00
39bc97a51c Merge pull request #745 from Palakis/add-dart-library
README: Add Dart client library
2021-06-01 01:47:10 +02:00
017e551a91 docs(ci): Update protocol.md - 19dad77 [skip ci] 2021-05-31 23:46:42 +00:00
19dad7775c Merge pull request #746 from BarRaider/docs-fix-readme-link
docs: fixed url to refer to the correct part of the readme
2021-05-31 16:45:56 -07:00
de15118872 docs: Fix type of ReorderSceneItems request parameter
The parameter `items` accepts a list of SceneItem ids/names but not Scenes.
2021-05-21 13:03:10 +00:00
bb81e1e0ab docs: fixed url to refer to the correct part of the readme 2021-05-17 16:17:07 -07:00
58b49fed85 README: Add Dart client library 2021-05-17 14:28:13 -07:00
6740e5fec7 Requests: Autorelease created scene in CreateScene
Creating the scene increments the referenced scene by one,
but we do not decrement it. This produces a memory leak which
leads to the scene never being deleted after being removed from
the UI.
2021-05-14 01:52:37 -07:00
fe9419fb8a Merge branch 'bugfix/cmake-frontend-lib' into 4.x-current 2021-04-18 23:30:03 +02:00
ba93b05efa cmake: fix frontend api message + nitpicks 2021-04-18 23:29:20 +02:00
d154e77299 Merge branch '4.x-current' into bugfix/cmake-frontend-lib 2021-04-18 23:25:44 +02:00
2f8073d548 Merge pull request #702 from Palakis/fix/imageformats
CMake: Copy other imageformats plugins too.
2021-04-18 23:15:33 +02:00
1f0c1691be cmake: simplify package step 2021-04-18 23:00:26 +02:00
50eedd11e0 cmake: fix target directory path of QImage plugins 2021-04-18 22:56:09 +02:00
6f50628172 Merge pull request #727 from ZyanKLee/feature/ZyanKLee-inline-build
allow inline build with obs-studio
2021-04-18 22:47:08 +02:00
4256f2df8b Merge branch '4.x-current' into feature/ZyanKLee-inline-build 2021-04-18 22:20:13 +02:00
344f7c33e4 Merge branch '4.x-current' into fix/imageformats 2021-04-18 21:54:05 +02:00
39454bc13e docs(ci): Update protocol.md - fcffa55 [skip ci] 2021-04-18 19:53:39 +00:00
fcffa55af1 Merge pull request #705 from Palakis/fix/addsceneitem-docs
Docs: Properly mark `setVisible` as optional
2021-04-18 21:53:01 +02:00
b74afd1033 Merge pull request #701 from Palakis/ci-qt-upgrade
CI: Various CI improvements
2021-04-18 21:50:52 +02:00
ff548589bc docs(ci): Update protocol.md - f2f80c4 [skip ci] 2021-04-13 14:04:38 +00:00
f2f80c4e7e Merge pull request #706 from dnaka91/from-scene-optional
docs: Mark from-scene as optional
2021-04-13 07:03:54 -07:00
381745dbf6 CI: Various improvements 2021-04-13 06:58:28 -07:00
1b61bd9551 Remove unnecessary files and changes 2021-04-13 22:24:20 +09:00
415fb73245 CI: Update and improve Ubuntu build 2021-04-13 05:48:50 -07:00
458d59b401 CI: Refactor much of the MacOS CI 2021-04-13 05:04:08 -07:00
ffb24da135 CI: Update MacOS Qt version to 5.15.2 2021-04-13 04:19:41 -07:00
436cec69c2 Merge https://github.com/Palakis/obs-websocket into feature/virtualcam 2021-04-13 02:27:57 -07:00
30e2a5428f CI: Update Qt windows installer download 2021-04-11 20:21:18 -07:00
1154ba5b14 docs(ci): Update protocol.md - ffd89db [skip ci] 2021-04-09 17:59:19 +00:00
ffd89dbdeb Merge pull request #718 from flut1/bugfix/docs-output-settings
Docs: fix typo in output properties
2021-04-09 10:58:21 -07:00
b61211b4cb Docs: fix typo in output properties 2021-04-08 17:42:01 +02:00
30af0cbd9a allow inline build with obs-studio
when replacing CMAKE_SOURCE_DIR with CMAKE_CURRENT_SOURCE_DIR in the CMakeLists.txt this should allow for building the plugin directly inside of obs-studio as well as separately
2021-03-29 10:06:08 +02:00
349ef5be97 [fix] getVirtualCamTime 2021-03-22 11:45:00 +01:00
7e0bc1fd10 docs: Mark from-scene as optional 2021-03-21 14:53:45 +09:00
b7bd95dcc4 CI: Use new source for Packages.pkg 2021-03-20 11:50:34 -07:00
fde1ada699 Docs: Properly mark setVisible as optional 2021-03-20 07:44:26 -07:00
7556c5f855 CMake: Copy other imageformats plugins too. 2021-03-19 01:45:52 -07:00
4505612f75 CI: Update Qt and OBS deps on Windows
- Update Qt to 5.15
- Update OBS dependencies to 2019
2021-03-19 01:21:23 -07:00
035767bbbb docs(ci): Update protocol.md - 8e43958 [skip ci] 2021-03-19 05:05:52 +00:00
8e43958f3d Merge pull request #694 from ruggi99/feature/get-source-active
Requests: Add GetSourceActive
2021-03-18 22:05:06 -07:00
2be20a9179 docs(ci): Update protocol.md - 77f6335 [skip ci] 2021-03-19 05:03:26 +00:00
77f63359f6 Merge pull request #697 from ruggi99/feature/add-volumedb
Requests: Add volumeDb field to SourceVolumeChanged Event
2021-03-18 22:03:11 -07:00
b13822db8d Requests: Add SetAudioTracks and GetAudioTracks (#690)
* Requests: Add SetAudioTracks and GetAudioTracks

* Renamed mixer to track.

* Fix: Prevent pushing track out of range

* Fix: Changed result values back to track.

* Fix: Changed source parameter to sourceName.

* Fix: Updated @param.

* Revert "Fix: Updated @param."

This reverts commit 24a5eb6fab.
2021-03-18 22:02:30 -07:00
35c524c604 [fix] obs-frontend-api calls 2021-03-18 18:15:13 +01:00
8c4374825d [fix] Missing events for virtualcam 2021-03-18 17:43:17 +01:00
687d08afa2 [fix] Missing headers for new virtualcam methods 2021-03-18 17:02:40 +01:00
8616d36204 Merge branch 'feature/virtualcam' of https://github.com/Meetsch/obs-websocket into feature/virtualcam 2021-03-18 16:51:46 +01:00
c22199b8eb [feature] support for VirtualCam 2021-03-18 16:51:27 +01:00
1deaedb7da [feature] support for VirtualCam 2021-03-18 16:06:54 +01:00
452a307b33 Requests: Add volumedb field to SourceVolumeChanged Event 2021-03-10 12:01:09 +01:00
0db1abcd2e Requests: Add GetSourceActive 2021-03-05 21:38:22 +01:00
01c898b104 docs(ci): Update protocol.md - 2344842 [skip ci] 2021-03-04 00:19:45 +00:00
2344842163 Requests: Edit PlayPauseMedia (#685)
* Request: Edit PlayPauseMedia

Removed requirement for boolean paramater from PlayPauseMedia. Changed
PlayPauseMedia to toggle play state if there is no boolean paramater.

* Docs: Edit PlayPauseMedia 

This commit also fixes some syntax

* will reset

* Add missing star to L48

Co-authored-by: tt2468 <tt2468@gmail.com>
2021-03-03 16:18:57 -08:00
b8e693c97d docs(ci): Update protocol.md - 99e66cc [skip ci] 2021-03-03 14:50:01 +00:00
99e66cc317 Merge pull request #691 from VodBox/feature/set-scale-filtering
Requests: Add scale.filter to Scene Item Properties
2021-03-03 06:48:59 -08:00
18468c17f2 Requests: Add scale.filter to Scene Item Properties 2021-03-03 20:02:01 +13:00
6f0d056059 docs(ci): Update protocol.md - 6b05d03 [skip ci] 2021-02-28 02:17:20 +00:00
6b05d0381e Merge pull request #687 from Palakis/feature/batch-delay
Requests: Add Sleep
2021-02-28 03:16:37 +01:00
e8c4d2b550 Merge pull request #674 from Palakis/fix/ubuntu-tag-releases
CI: Fix tag detection
2021-02-28 03:06:09 +01:00
7e14032d2b requests(Sleep): update parameter name 2021-02-28 03:05:42 +01:00
bb0a0acbda Requests: Add Sleep
New request to induce delay in the processing of `ExecuteBatch`
2021-02-27 09:35:37 -08:00
9bbfb73622 chore: safety-checks before accessing the result of GetConfig() 2021-02-24 19:06:08 +01:00
d45d98d536 CI: Fix tag detection 2021-02-10 16:34:37 -08:00
9e554ce527 ci(macos): update InstallAppleCertificate action to version 2 2021-02-10 13:32:13 +01:00
6217f009fd docs(ci): Update protocol.md - 4647312 [skip ci] 2021-02-04 21:53:47 +00:00
46473126d2 Merge pull request #668 from Palakis/cleanup-for-v4.9.0
Cleanup for v4.9.0
2021-02-04 22:53:01 +01:00
b6ee6e9e22 docs(ci): Update protocol.md - 1891f62 [skip ci] 2021-02-04 15:53:51 +00:00
1891f62c22 Merge pull request #657 from Palakis/feature/authentication-enabled-by-default
Config: authentication enabled by default
2021-02-04 07:53:07 -08:00
212d1cbfc2 Merge https://github.com/Palakis/obs-websocket into cleanup-for-v4.9.0 2021-02-04 07:51:47 -08:00
73d93e476f docs(ci): Update protocol.md - 80d8286 [skip ci] 2021-02-04 15:51:04 +00:00
80d82861ae Merge pull request #665 from Palakis/feature/batch-requests
Batch Requests
2021-02-04 07:50:22 -08:00
8d034f53a4 Chore: Bump version to 4.9.0 2021-02-04 07:47:36 -08:00
6d3aa3a828 Requests: Add abortOnFail to ExecuteBatch request
We do not currently have atomicy in this request, as it would be
incredibly difficult to add, but this is at least useful for avoiding
further data corruption in the case that there is a malformed request
and multiple requests depend on the success of the previous one.
2021-02-04 07:37:27 -08:00
ed23aba0ac Requests: Improve documentation of ExecuteBatch 2021-02-04 07:15:37 -08:00
3847e5d6af Revert "Remove deprecated requests"
This reverts commit e95d8d36aa.
2021-02-04 05:40:01 -08:00
f4465e2e9b requests(ExecuteBatch): documentation 2021-02-03 05:47:53 +01:00
fe2e87074a requests(ExecuteBatch): handle message-id in sub-requests 2021-02-03 05:33:08 +01:00
5b100d15d7 OBSRemoteProtocol: fix missing message id 2021-02-03 05:31:53 +01:00
87cd36673e OBSRemoteProtocol: fix memory leak 2021-02-03 04:16:04 +01:00
47b84f7316 Merge https://github.com/Palakis/obs-websocket into cleanup-for-v4.9.0 2021-02-02 08:28:41 -08:00
a18da3e6cd WSRequestHandler: Organize requests
Organize requests into their categories aphabetically, and how they appear in their appriate source files.
2021-02-02 08:26:47 -08:00
6bb33fa18b docs(ci): Update protocol.md - 59e6695 [skip ci] 2021-02-02 16:10:24 +00:00
59e6695a5d Merge pull request #666 from Palakis/feature/RefreshBrowserSource
Requests: Add RefreshBrowserSource
2021-02-02 17:09:30 +01:00
861cde7e61 Requests/Events: Use Note: for all notes
Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaah
my ocdddddddddddddddddddddddddddddddddddddd
2021-02-02 07:39:52 -08:00
e95d8d36aa Remove deprecated requests 2021-02-02 07:29:11 -08:00
04304ecf94 Requests/Events: Change all unreleased tags to 4.9.0 2021-02-02 07:23:45 -08:00
3989ea0780 Requests: Add RefreshBrowserSource 2021-02-02 06:16:49 -08:00
e39585befc Password Dialog: Only change form options and not underlying config 2021-02-02 03:04:03 -08:00
20fa14563c Settings Dialog: Don't need ShowSettingsDialog() 2021-02-02 03:03:37 -08:00
10910aa06d requests(general): ExecuteBatch WIP 2021-02-02 11:26:22 +01:00
e6c2c90677 Password Prompt: Improve english strings 2021-02-01 05:33:01 -08:00
98712c7b71 Password Prompt: Enable authRequired toggle and highlight password 2021-02-01 05:16:47 -08:00
2015d40186 docs(introduction): update authentication section 2021-01-31 01:58:22 +01:00
a8aa34529e config: simplify initial password setup 2021-01-31 01:51:19 +01:00
38cf0270b1 settings: add auth disabled warning 2021-01-31 01:26:38 +01:00
c8ca79f00b config: add locale texts for initial password setup 2021-01-31 00:58:56 +01:00
c02382b6e5 config: initial password setup prompt wip 2021-01-29 19:16:53 +01:00
cb7c77d29e docs(ci): Update protocol.md - 83e23c9 [skip ci] 2021-01-28 23:26:40 +00:00
83e23c9c41 Merge pull request #638 from Palakis/feature/getsourcedefaultsettings
Requests: Add GetSourceDefaultSettings
2021-01-29 00:25:35 +01:00
c6db90ae07 request(GetSourceDefaultSettings): add sourceKind return value + fix param spec 2021-01-29 00:08:20 +01:00
c2aa7263bd docs(ci): Update protocol.md - 25be7ee [skip ci] 2021-01-28 22:57:37 +00:00
25be7ee14e Merge pull request #628 from gdhgdhgdh/sceneitems-by-id
Request: add ID support for SetSceneItemRender
2021-01-28 23:56:53 +01:00
332876495d Utils: remove unused struct 2021-01-28 23:04:02 +01:00
6cbe50e3e7 request(SetSceneItemRender): refactor conditional 2021-01-28 22:56:01 +01:00
599eaf85ce requests(SceneItems): remove unused variables 2021-01-28 22:55:40 +01:00
c03ca47e37 Merge branch 'opencollective' into 4.x-current 2021-01-28 22:48:52 +01:00
2246ce5142 Merge branch '4.x-current' into opencollective 2021-01-28 22:48:34 +01:00
79774921e4 Merge pull request #659 from harm27/harm27-obs-java-client
readme: Added obs-java-client to the available API's
2021-01-21 13:30:43 -08:00
ab453a0322 readme: Added obs-java-client to the available API's 2021-01-21 11:06:59 +01:00
3725e400ce Merge branch 'feature/getsourcedefaultsettings' of https://github.com/Palakis/obs-websocket into feature/getsourcedefaultsettings 2021-01-20 04:22:38 -08:00
9859c7b25f Utils: Use obs_data_item_get_name in OBSDataGetDefaults 2021-01-20 04:21:43 -08:00
056c1ef1fc Merge pull request #641 from VMinute/bugfix/fix-list-scenes-collections
General: Add ScenesCollection object
2021-01-20 10:37:31 +01:00
41fbfb159a Merge branch '4.x-current' into feature/getsourcedefaultsettings 2021-01-20 10:26:34 +01:00
740a8a8d06 General: Add ScenesCollection object
Adds a ScenesCollection object in the protocol definition,
replacing the current Array<String> return  with
Array<ScenesCollection>, keeping it more coherent with
other requests that return objects in the same format.
This will help automated code generation from comment.json
that otherwise would require ad-hoc handling for that specific
request.

Signed-off-by: Valter Minute <valter.minute@gmail.com>
2021-01-20 10:22:33 +01:00
59ab9548c2 docs(ci): Update protocol.md - a1cf7f8 [skip ci] 2021-01-20 09:22:17 +00:00
a1cf7f8d32 Merge pull request #658 from Palakis/fix/tab-formatting
Misc: Fix indentation of src files
2021-01-20 10:21:24 +01:00
0d59983d1a Misc: Fix indentation of src files
Replace 4-space code with tabs to conform with the way its supposed to be.
2021-01-19 18:30:18 -08:00
488a57e2de Requests: Fix GetSourceDefaultSettings indentation and docs 2021-01-19 18:23:54 -08:00
dd9ad67e6b Config: authentication enabled by default 2021-01-20 00:44:34 +01:00
492e9d8df7 editorconfig: set indent_size for C/C++ files 2021-01-20 00:28:50 +01:00
bc3b09dce4 WSServer(stop): wait for all connections to close 2021-01-20 00:08:24 +01:00
5fd95ce374 Merge pull request #649 from dnaka91/homebrew-instructions
readme: Add Homebrew installation instructions
2021-01-19 19:08:50 +01:00
77380a098e docs(ci): Update protocol.md - afc9c54 [skip ci] 2021-01-19 18:07:43 +00:00
afc9c549d6 Merge pull request #643 from Palakis/fix/createscene-sinceversion
Requests: Fix wrong docs version for CreateScene
2021-01-19 19:06:40 +01:00
77f38bbf63 docs(ci): Update protocol.md - 853eeb2 [skip ci] 2021-01-18 10:52:53 +00:00
853eeb2e6b Merge pull request #636 from Palakis/enhancement/latest-translations
Translations: Update translations with latest from crowdin
2021-01-18 11:51:50 +01:00
6ed6b4a679 Merge pull request #637 from Palakis/fix/getstreamingstatus-docs
Docs: Add recording-paused to documentation
2021-01-18 11:51:17 +01:00
99987f9373 Merge pull request #644 from eric/stop-ws-server-on-exit
Stop WSServer on OBS exit
2021-01-18 11:49:00 +01:00
b02239f3e3 Merge pull request #650 from dnaka91/rust-api
readme: Add Rust client library
2021-01-08 04:59:14 -08:00
bc436e9ec4 Reorder library list 2021-01-08 04:58:07 -08:00
7e0874abb4 Translations: Remove dutch StartFailed message and update other translations
For some reason crowdin included it even though it is not approved.
The current unapproved translation uses the old string.
2021-01-08 04:57:03 -08:00
3d704702ba readme: Add Rust client library
I created a client library in Rust to remote control OBS with
obs-websocket. Adding my library to the list of available
language APIs.
2021-01-07 21:58:29 +09:00
2735f80637 readme: Add Homebrew installation instructions
Give a short hint that the project can be installed with Homebrew on
MacOS as alternative to installing manually.
2021-01-07 21:49:41 +09:00
9275f7c2a9 Server: Stop WSServer on OBS exit
This should fix issues with race conditions and crashes on OBS exit.
2020-12-29 11:41:47 -08:00
229641aba0 Requests: Fix wrong docs version for CreateScene 2020-12-24 13:38:58 -08:00
ba143f2636 Translations: Update translations with latest from crowdin 2020-12-24 13:28:01 -08:00
ffb34c3fd4 Requests: Add GetSourceDefaultSettings
Adds a request, mainly for development purposes, which returns an
object of default settings for a given sourceKind (eg. `vlc_source`)
2020-12-21 00:06:50 -08:00
31c717eb40 Docs: Add recording-paused to documentation [skip ci]
It wasn't included for some reason.
2020-12-20 00:29:24 -08:00
7ae016bd3b Merge pull request #627 from Palakis/bugfix/deb-file-permissions
ci(linux): fix deb package file permissions
2020-12-20 00:02:44 -08:00
501e0f63f5 ci(linux): fix deb package file permissions 2020-12-19 22:54:46 -08:00
a42398c457 Merge pull request #635 from Palakis/enhancement/codefactor-badge
README: Add codefactor badge
2020-12-20 07:20:59 +01:00
d77e4ab10d docs(ci): Update protocol.md - 8a8ea92 [skip ci] 2020-12-20 06:20:47 +00:00
8a8ea92140 Merge pull request #629 from marcan/volumes
Requests: SetVolume: allow volumes > 1.0
2020-12-19 22:20:12 -08:00
adc46a80f9 Requests: SetVolume: allow volumes > 1.0
Allow volumes > 1.0 / > 0dB, which is legal in OBS (you can do this in
Advanced Audio Properties). OBS allows up to +26dB gain, so we do the
same. This corresponds to approximately 20x linear gain (actually
19.9526231497, but 20 is easier to explain and OBS doesn't care).
2020-12-19 22:16:47 -08:00
3203f50a43 Merge pull request #609 from Palakis/remove-captions-flag
CI: Remove BUILD_CAPTIONS flag
2020-12-20 06:55:19 +01:00
3dea5fd4f4 README: Add codefactor badge
They give us an A and I think that's pretty cool so might as well display it
2020-12-19 21:51:25 -08:00
1024a2198a Merge pull request #631 from leafac/patch-1
Add link to obs-cli
2020-12-16 14:11:02 -08:00
c8f0d5a3e4 Add link to obs-cli 2020-12-16 21:57:23 +00:00
3e55b3d7bc Request: add ID support for SetSceneItemRender 2020-12-08 17:23:53 +00:00
a93c4dfbbd docs(ci): Update protocol.md - aceb437 [skip ci] 2020-11-29 11:40:39 +00:00
aceb437c5f Merge pull request #621 from Palakis/feature/current-recording-filename
Feature/current recording filename
2020-11-29 12:39:49 +01:00
a137ccd8ba requests(GetRecordingStatus): add recordingFilename property 2020-11-29 12:24:49 +01:00
96bd4141fd events: add recordingFilename property to RecordingStarted, RecordingStopping and RecordingStopped 2020-11-29 12:22:26 +01:00
e794762f72 docs(ci): Update protocol.md - 9999b30 [skip ci] 2020-11-28 04:50:08 +00:00
9999b30d1a docs(scene items): fix documentation for GetSceneItemProperties
Fixes #607
2020-11-28 05:49:09 +01:00
569e9681e5 docs(ci): Update protocol.md - 9edc3ea [skip ci] 2020-11-27 23:39:48 +00:00
9edc3eafa3 Merge pull request #589 from Palakis/feature/createsource
Requests: Add CreateSource and clean up code
2020-11-28 00:39:09 +01:00
a1fcc35fd6 requests(CreateSource): pass settings on source creation 2020-11-28 00:19:27 +01:00
80d21ce80d WSRequestHandler: fix indent 2020-11-27 23:53:39 +01:00
08178b9354 requests(CreateSource): use the OBSSourceAutoRelease container instead of manipulating refs manually 2020-11-27 19:40:02 +01:00
60ce25c689 requests(CreateSource): fix docs 2020-11-27 19:38:55 +01:00
eaf34f3c3a requests(CreateSource): simplified settings apply
obs_source_update already does that internally
2020-11-27 19:38:01 +01:00
ef0e907014 docs(ci): Update protocol.md - 9fb0f56 [skip ci] 2020-11-27 16:24:32 +00:00
9fb0f56aa0 Merge pull request #619 from Palakis/feature/events-add-target-new-state
Events: provide new state of entity (in events that don't do it already)
2020-11-27 17:23:51 +01:00
ae9ea8510c events: fix docs 2020-11-27 17:10:27 +01:00
14409dec4f events(TransitionListChanged): provide transitions list property 2020-11-27 17:09:07 +01:00
0cdea68567 events(ScenesChanged): provide scenes list property 2020-11-27 17:07:28 +01:00
542761e411 events(ProfileListChanged): add profile list property 2020-11-27 17:00:10 +01:00
0dc8e070ff events(SceneCollectionListChanged): add scene collections list property 2020-11-27 17:00:05 +01:00
fe52cd8db1 events(ProfileChanged): add new profile name 2020-11-27 16:59:57 +01:00
d87a7e896b events(SceneCollectionChanged): add new scene collection name 2020-11-27 16:59:52 +01:00
f7616ade1f docs(ci): Update protocol.md - f14379a [skip ci] 2020-11-27 15:41:27 +00:00
f14379af68 Merge pull request #439 from Palakis/feature/t-bar
T-Bar control
2020-11-27 16:39:56 +01:00
a53df39e46 requests(transitions): yet another doc fix 2020-11-27 16:15:03 +01:00
98187e2bd7 requests(transitions): documentation fixes cont. 2020-11-27 16:10:38 +01:00
3ab7de99f3 requests(transitions): documentation fixes 2020-11-27 16:03:21 +01:00
1fef0691ed Merge pull request #618 from Palakis/bugfix/output-commands-crash
requests(outputs): fix corrupted parameters object on MSVC when using findOutputOrFail
2020-11-27 15:49:43 +01:00
6b03efed42 requests(outputs): fix corrupted parameters object on MSVC when using findOutputOrFail 2020-11-27 15:33:40 +01:00
eddd4abe76 ci(linux): update frontend api headers to v26 2020-11-27 12:45:57 +01:00
e30dce8b21 Merge branch '4.x-current' into feature/createsource 2020-11-27 12:24:13 +01:00
6d12af3858 Merge branch '4.x-current' into feature/t-bar 2020-11-27 12:23:47 +01:00
b9cbd0ecd1 docs(ci): Update protocol.md - 3d7511c [skip ci] 2020-11-27 11:19:36 +00:00
3d7511ca75 Merge pull request #605 from Palakis/feature/get-set-transition-settings
Get/Set Transition Settings
2020-11-27 12:18:50 +01:00
fabf68b635 CI: Remove BUILD_CAPTIONS flag
OBS has removed the `BUILD_CAPTIONS` flag from their repo. No reason to keep it
2020-11-02 23:20:40 -08:00
11326274e0 docs(ci): Update protocol.md - acd3940 [skip ci] 2020-10-25 18:34:53 +00:00
acd3940a7b Merge pull request #593 from Palakis/feature/getsceneitemlist-default-scene
requests(GetSceneItemList): fallback to current scene if sceneName is not specified
2020-10-25 19:34:11 +01:00
8ba441da7f requests(transitions): remove TODO 2020-10-25 19:33:42 +01:00
5d9d5e0746 request(SetSourceSettings): remove redundant obs_data_apply step 2020-10-25 19:25:48 +01:00
7a31e88ed6 requests: add GetTransitionSettings and SetTransitionSettings 2020-10-25 19:25:26 +01:00
d9f35a855d docs(ci): Update protocol.md - 9678d59 [skip ci] 2020-10-01 07:56:26 +00:00
9678d59bbe Merge pull request #598 from Palakis/fix/hotkey-docs-typo
Docs: Fix typo
2020-10-01 09:55:34 +02:00
0be5564ce7 Docs: Fix typo 2020-09-30 15:57:13 -07:00
8a90051ab5 docs(ci): Update protocol.md - 02c7a7f [skip ci] 2020-09-30 22:22:57 +00:00
02c7a7f7c7 Merge pull request #595 from LorenaGdL/feature/hotkey-requests
Requests: Add hotkeys press events
2020-09-30 15:22:22 -07:00
e7c8c1d6b6 Requests: Update hotkey docs and rename some variables 2020-09-30 15:02:59 -07:00
449ad6d13c PR review changes: Modify requests names
Changes requests names to "TriggerHotkeyByName" and "TriggerHotkeyBySequence"
2020-09-30 19:15:23 +00:00
ae4ee0332c Fix macOS CI (#597)
* ci(macos): fix attempt #1

* Revert "ci(macos): fix attempt #1"

This reverts commit b846490136.

* ci(macos): provide QTDIR when building OBS

* Revert "ci(macos): provide QTDIR when building OBS"

This reverts commit 74a882fcf4.

* ci(macos): use local qt formula

* ci(macos): update qt.rb
2020-09-30 12:19:37 +02:00
4a4c97aac4 request(GetSceneItemList): provide scene name in response 2020-09-29 23:48:35 +02:00
4491da0350 requests(GetSceneItemList): fix empty/non-present parameter detection 2020-09-29 23:48:17 +02:00
32960afc1b requests(GetSceneItemList): update docs 2020-09-29 19:45:07 +02:00
46f624e3b9 requests(GetSceneItemList): fallback to current scene if sceneName is not specified 2020-09-29 19:37:28 +02:00
9daae857de Requests: Add ProcessHotkeyByCombination
Adds a new request called `ProcessHotkeyByCombination` which calls the
routine associated with a given hotkey. The hotkey is identified by the
combination of keys set by the user to trigger it. Multiple routines
are called if the same combination is bound to different hotkeys.
2020-09-29 13:43:00 +00:00
bac5b1551b Requests: Add ProcessHotkeyByName
Adds a new request called `ProcessHotkeyByName` which calls the routine
associated with a given hotkey. The hotkey is identified by the unique
name set while registering it. Works with both OBS default hotkeys and
hotkeys added by plugins/scripts.
2020-09-29 13:38:32 +00:00
f61f45fa23 Merge pull request #592 from rodrigograca31/improve-docs
docs: 📝 list multiple available web clients
2020-09-24 12:54:52 -07:00
fbc6e02ff6 docs: 📝 list multiple available web clients 2020-09-24 13:16:57 +01:00
56a17a9131 Merge pull request #560 from Palakis/enhancement/various-todos
Requests: Scene collection and profile name checking
2020-09-16 21:51:08 +02:00
a148f7fd7c requests(Profiles + SceneCollections): fix crash on change 2020-09-16 21:45:31 +02:00
0dd0d01e8f requests(Profiles + SceneCollections): don't use QString where it is not needed 2020-09-15 18:17:45 +02:00
bcd16d791c Merge pull request #559 from Palakis/enhancement/ipv4-option
Settings: Add option to lock binding to IPv4
2020-09-15 17:19:27 +02:00
539e636939 requests(SceneCollections): fix typo (profiles instead of scene collections) 2020-09-15 17:14:53 +02:00
7f1c4a1c4c Utils: simplified string list lookup 2020-09-15 17:12:34 +02:00
6b254e0ad5 Requests: Add CreateSource and clean up code 2020-09-15 02:51:03 -07:00
f36185a964 Merge pull request #583 from Palakis/fix/no
Installer: Don't show warning when obs directory is not empty
2020-09-15 11:36:54 +02:00
588487f860 docs(ci): Update protocol.md - f3ab210 [skip ci] 2020-09-15 09:36:27 +00:00
f3ab2100f0 Merge pull request #578 from Palakis/fix/request-versions
Docs: Fix requests marked as "unreleased"
2020-09-15 11:35:46 +02:00
f96b40bbf8 Merge pull request #573 from Palakis/fix/sfr-enabled
Docs: Add `enabled` field to `SourceFiltersReordered`
2020-09-15 11:35:23 +02:00
9679de097f Installer: Don't show warning when obs directory is not empty
More info here: https://jrsoftware.org/ishelp/index.php?topic=setup_direxistswarning
2020-08-21 22:43:42 -07:00
a51ad1383b Docs: Fix requests marked as "unreleased" 2020-08-12 16:54:03 -07:00
1dd96fa714 Docs: Add enabled field to SourceFiltersReordered
Was noticed in Discord that this was missing from the docs
2020-07-31 22:08:07 -07:00
8285805108 Merge pull request #571 from Palakis/bugfix/569-tray-icon-crash
Utils(GetTrayIcon): refactor with frontend API function
2020-07-29 17:06:01 +02:00
d91b3f8dd9 Utils(GetTrayIcon): refactor with frontend API function 2020-07-28 02:23:31 +02:00
6734c928a2 Merge pull request #563 from venepe/raspberry-pi
CMakeLists: Compile for arm targets
2020-07-19 12:22:15 +02:00
58448f363b CMakeLists: Compile for arm targets 2020-07-18 13:48:52 -05:00
2e32b7e299 Merge branch '4.x-current' into enhancement/various-todos 2020-07-15 15:02:00 +02:00
a651a1a69f docs(ci): Update protocol.md - c368696 [skip ci] 2020-07-15 13:01:23 +00:00
c368696ddc docs(ci): Update protocol.md - 94269c0 [skip ci] 2020-07-15 13:00:59 +00:00
94269c0640 Merge pull request #557 from julijane/feature-screenshot-default
TakeSourceScreenshot: default to current scene
2020-07-15 15:00:43 +02:00
5da6588ee6 Merge pull request #555 from Palakis/fix/docs-updates
Docs: Various docs improvements
2020-07-15 14:59:52 +02:00
ac9c6b4a1f Docs: Fix GDIPlus requests documentation
`bk-color` and `bk-opacity` are actually `bk_color` and `bk_opacity`
respectively. Issue reported in #561
2020-07-12 02:22:26 -07:00
aa8fa00811 Docs: More updates
Changes the media stuff's `@since 4.9.0` to `@since unreleased`
to reduce potential confusion on the docs. As a part of the final
4.9.0 commits, I will be changing it back to 4.9.0. We also fix the
contributing document since it was all messed up.
2020-07-11 05:26:49 -07:00
9c4bd7a487 Requests: Scene collection and profile name checking
For `SetCurrentProfile` and `SetCurrentSceneCollection`, check if it
exists before attempting to switch to it, and return an error if it
does not exist.
2020-07-11 05:00:10 -07:00
eb00294bbb Settings: Add option to lock binding to IPv4
WebsocketPP defaults to binding to an IPv6 interface. Since IPv6
is broken on so many networks, this adds an option to force WebsocketPP
to use the default IPv4 interface to bind to.
2020-07-09 22:21:48 -07:00
04c60fd1ac docs(ci): Update protocol.md - 80de8ad [skip ci] 2020-07-09 10:40:21 +00:00
80de8ada57 ci: fix Azure Pipelines not running on 4.x-current 2020-07-09 12:39:40 +02:00
9cdb32d56a Docs: Various docs improvements
I noticed that some parts of the docs were inconsistent/lacking.
Decided to go through all of them and update them.
2020-07-09 03:27:44 -07:00
31a505f4a4 Do it when sourceName is omitted 2020-07-09 00:50:29 +02:00
bfa6cd0e19 TakeSourceScreenshot: default to current scene 2020-07-09 00:43:54 +02:00
c51ecda6b4 Merge pull request #527 from Palakis/feature/component-management
Requests: Sceneitem manipulation requests
2020-07-03 18:21:01 +02:00
471d44ae11 Merge pull request #551 from Palakis/fix/mediafixes
Requests/Events: Use sourceKind instead of sourceTypeId
2020-07-03 16:22:20 +02:00
513bd1372b Docs, Requests: Fix GetSceneItemList code revisions
Replace the `sourceId` term with `sourceKind` to match everything else.
2020-07-03 07:12:28 -07:00
355cee0db9 Merge branch '4.x-current' into feature/component-management 2020-07-03 07:07:52 -07:00
38936173d1 Requests/Events: Use sourceKind instead of sourceTypeId
Left in some old terms accidentally. This fixes it.
2020-07-03 07:03:25 -07:00
eea56b4c71 Merge pull request #497 from Palakis/category-mediacontrol
Requests/Events: Media Source/VLC
2020-07-03 15:56:21 +02:00
802cc3a48f Apply suggestions from code review 2020-07-03 15:48:56 +02:00
ba4720012d Merge pull request #550 from Palakis/enhancement/readme-fix
Docs: Move ssl tunnelling guide to its own page
2020-07-03 15:30:34 +02:00
4f83b73732 Docs: Move ssl tunnelling guide to its own page [skip ci]
Having the SSL tunneling instructions on the README caused clutter and was
unnecessary.
2020-07-03 06:23:48 -07:00
68db13fc24 Merge pull request #549 from Palakis/feature/more-output-statuses
Requests: Add Replay Buffer and Recording Statuses
2020-07-03 14:29:25 +02:00
2d4dd580b4 Merge pull request #547 from WizardCM/audio-active
Requests, Events: Add support for Audio Active
2020-07-03 03:42:36 -07:00
d03e94ada8 events: Add support for audio_active, fix docs version 2020-07-03 03:30:58 -07:00
91126a59c2 Merge pull request #505 from Palakis/docs-updates
Docs: Update and split up main documentation
2020-07-03 11:47:54 +02:00
bd18aee43c Docs: Update issue template to be **better** 2020-07-03 02:42:29 -07:00
4ead1c3de5 Requests: Add Replay Buffer and Recording Statuses
Adds `GetReplayBufferStatus` and `GetRecordingStatus`.

v5.0 Will remove the recording status functionality from
`GetStreamingStatus`
2020-07-03 02:26:38 -07:00
f3b2a6eba2 Merge pull request #471 from PatTheMav/github-actions-tag
CI: Add Github Actions workflow for release tags
2020-07-03 10:22:39 +02:00
c4d9a27d2f Merge pull request #470 from PatTheMav/github-actions-pr
CI: Add Github Actions workflow for PRs and pushes to main branch
2020-07-03 10:22:09 +02:00
fdcba2734d Events, Docs: Refactor media events and improve docs
Move duplicated functionality to a helper function and added some docs
clarifying the behavior of the events, and fixed a few typos in
the request handlers.
2020-07-02 13:13:19 -07:00
981ba7b28f Merge pull request #529 from Palakis/fix/getvolumedecibel
Requests: Fix useDecibel response when volume is -infinity
2020-07-02 21:08:45 +02:00
822a1751a2 requests: Add support for audio_active 2020-07-01 22:23:22 +10:00
a4279d09a6 Merge pull request #546 from curtgrimes/bugfix/reenable-macos-captions
[Bug Fix] Reenable building with captions on MacOS
2020-07-01 04:24:40 -07:00
14d43ac05b [Bug Fix] Reenable building with captions on MacOS
OBS on MacOS supports closed caption encoding. The Windows-only dependencies [here](https://github.com/obsproject/obs-studio/blob/master/UI/frontend-plugins/frontend-tools/CMakeLists.txt#L73) are only related to audio capture, not closed caption encoding.
2020-06-29 20:24:11 -05:00
5e6c92ab16 Merge branch '4.x-current' into category-mediacontrol 2020-06-08 01:04:16 -07:00
9ced745258 Merge pull request #533 from Twasi/bugfix/Correct-position-data-type
Bugfix/correct position data type
2020-06-04 14:30:58 -07:00
948f6ccd95 Also change all other occurrences and documentation where int was used for transform position 2020-06-04 15:42:27 +02:00
1c58727ca9 Change position datatype from int to double (as it is in OBS) 2020-06-04 15:28:47 +02:00
612bd9960c readme: add TLS tunneling section 2020-06-04 10:14:58 +02:00
1474499886 Requests: Add GetSceneItemList
Adds a new `GetSceneItemList` request to get all scene items in a
specified scene.
2020-05-29 00:00:16 -07:00
cf99c68843 Requests: Fix useDecibel response when volume is -infinity
When the volume in OBS is -infinity, `GetVolume` returns a decibel value of
either 0, or in some cases no `volume` property at all. This makes `GetVolume`
return a decibel value of -100.0 if the real volume is -infinity.
2020-05-28 22:45:08 -07:00
d2865b9f4f Requests: Add AddSceneItem
New request `AddSceneItem` which allows you to add a
source to a scene. Returns an itemId which can be used
to manipulate the item further if necessary.
2020-05-28 22:20:25 -07:00
865c0c79db Docs: Rework some more of the readme 2020-05-28 16:45:05 -07:00
3462e7f50e Docs: Add new logo and update header 2020-05-28 16:35:21 -07:00
37e412e710 Docs: Add discord shield to readme 2020-05-28 16:16:31 -07:00
5822992b44 Merge pull request #524 from ProstoSanja/create-scene
Add request `CreateScene` to `scenes`
category
2020-05-27 21:21:14 -07:00
eb7787fb7d Docs: Fix param name 2020-05-27 11:18:39 +03:00
f1371034f7 Request: Add CreateScene 2020-05-27 01:03:01 +03:00
b00a93dd6b Requests: Add GetMediaSourcesList and minor refactor
Adds `GetMediaSourcesList` which returns a list of all media sources,
along with their individual media playback states. In the process I
refactored a switch which coverts the enum to a QString into its own
helper function.
2020-05-19 20:20:35 -07:00
7918438747 Events: Add media events
Adds the following events:

- `MediaPlaying`
- `MediaPaused`
- `MediaRestarted`
- `MediaStopped`
- `MediaNext`
- `MediaPrevious`
- `MediaStarted`
- `MediaEnded`
2020-05-16 12:56:42 -07:00
31a085db73 Docs: Update @since items 2020-05-16 12:11:26 -07:00
72997eaa85 Merge branch '4.x-current' into category-mediacontrol 2020-05-16 12:08:28 -07:00
a1ea84b286 Docs: Its finally complaining less 2020-05-14 04:46:12 -07:00
baba8790bc testing 2020-05-14 04:28:57 -07:00
1da7f47af9 Docs: Add pr template 2020-05-14 03:43:18 -07:00
60d9b72fea Docs: Maybe it will complain less now 2020-05-14 03:25:34 -07:00
7a7a8b7ed1 Docs: Even more changes 2020-05-14 03:19:14 -07:00
100565081c Docs: More changes 2020-05-14 03:11:17 -07:00
27f82434b6 Docs: More work on various things 2020-05-14 03:01:28 -07:00
353a9aa671 Update docs - initial pr draft commit 2020-05-14 02:13:50 -07:00
121d9f4920 Remove GetTransitionPosition
Moving it to its own PR since this PR will not make it into 4.8
2020-05-14 01:14:46 -07:00
64062cc879 Merge branch '4.x-current' into feature/t-bar 2020-05-13 20:51:23 -07:00
7ca902e39a A few formatting fixes 2020-05-13 20:48:54 -07:00
10ed2738f5 Add ReleaseTBar request and update SetTBarPosition to depend on OBS pr 2927 2020-05-13 00:10:57 -07:00
4eb7bed2ff Lots of changes
- Move `SetTBarPosition` to transitions category
- Add another check to `SetTBarPosition` so that we dont break the fabric of time with the wrong values
- Create `GetTransitionPosition` request in transitions category
2020-05-12 15:44:57 -07:00
acfdb26135 A lot more requests. 2020-05-10 23:21:24 -07:00
37cf8e9d29 Rename MediaPlayPause to PlayPauseMedia
Works better with the other upcoming media control request names
2020-05-10 21:13:48 -07:00
1c6670c9b0 Create new category and add MediaPlayPause request 2020-05-10 21:03:38 -07:00
a479f529af CI: Add Github Actions workflow for release tags 2020-04-21 17:42:07 +02:00
76635ff31b CI: Add Github Actions workflow for PRs and pushes to main branch 2020-04-21 17:29:59 +02:00
71391914ae Added financial contributors to the README 2020-04-14 11:21:57 -07:00
93c2dab634 Merge branch '4.x-current' into feature/t-bar 2020-03-28 19:23:52 +01:00
824cfd4871 Merge branch '4.x-current' into bugfix/cmake-frontend-lib 2020-03-28 19:17:19 +01:00
297d920fdc fix 2020-03-18 01:19:02 +01:00
c741a73893 request(SetTBarPosition): wip 2020-03-18 01:18:20 +01:00
a5bc979c24 cmake: fix set of OBS_FRONTEND_LIB 2019-06-23 22:58:45 +02:00
91 changed files with 9787 additions and 4155 deletions

View File

@ -3,6 +3,7 @@ insert_final_newline = true
[*.{c,cpp,h,hpp}]
indent_style = tab
indent_size = 4
[*.{yml,yaml}]
indent_style = space

View File

@ -1,22 +0,0 @@
## Contributing to obs-websocket
### Translating obs-websocket to your language
Localization happens on Crowdin: https://crowdin.com/project/obs-websocket
### Writing code for obs-websocket
#### Coding Guidelines
- Function and variable names: snake_case for C names, CamelCase for C++ names
- Tabs are 8 columns wide
- 80 columns max.
#### Commit Guidelines
- Commits follow the 50/72 standard:
- 50 characters max for the title
- One empty line after the title
- Description wrapped to 72 columns max per line.
- Commit titles:
- Use present tense
- Prefix the title with a "scope" name
- e.g: "CI: fix wrong behaviour when packaging for OS X"
- Typical scopes: CI, General, Request, Event, Server
- Look at existing commits for more examples

3
.github/FUNDING.yml vendored Normal file
View File

@ -0,0 +1,3 @@
open_collective: obs-websocket
github: Palakis
custom: https://www.paypal.me/stephanelepin

View File

@ -1,16 +1,20 @@
##### Issue type
Bug report? Feature request? Other?
<!--- Uncomment one of the two options below. -->
<!--- - Bug report -->
<!--- - Feature request -->
##### Description
*Replace this with a description of the bug encountered or feature requested.*
<!--- Describe the bug encountered or feature requested. -->
##### Steps to reproduce and other useful info
*If it's a bug, please describe the steps to reproduce it and PLEASE include an OBS log file. Otherwise, remove this section.*
<!--- If it's a bug, please describe the steps to reproduce it and PLEASE include an OBS log file. Otherwise, remove this section. -->
##### Technical information
- **Operating System** :
- **OBS Studio version** :
- **obs-websocket version** :
##### Development Environment
*If you're trying to compile obs-websocket, please describe your compiler type and version (e.g: GCC 4.7, VC2013, ...), and the CMake settings used.
Remove this section if it doesn't apply to your case.*
<!--- If you're trying to compile obs-websocket, please describe your compiler type and version (e.g: GCC 4.7, VC2013, ...), and the CMake settings used. -->
<!--- Remove this section if it does not apply. -->

35
.github/pull_request_template.md vendored Normal file
View File

@ -0,0 +1,35 @@
<!--- Please fill out the following template, which will help other contributors review your Pull Request. -->
<!--- Make sure youve read the contribution guidelines here: https://github.com/Palakis/obs-websocket/blob/4.x-current/CONTRIBUTING.md -->
### Description
<!--- Describe your changes. -->
### Motivation and Context
<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes/closes an open issue or implements feature request, -->
<!--- please link to the issue here. -->
### How Has This Been Tested?
<!--- Please describe in detail how you tested your changes, along with the OS(s) you tested with. -->
Tested OS(s):
### Types of changes
<!--- What types of changes does your PR introduce? Uncomment all that apply -->
<!--- - Bug fix (non-breaking change which fixes an issue) -->
<!--- - New request/event (non-breaking) -->
<!--- - Documentation change (a change to documentation pages) -->
<!--- - Enhancement (modification to a current event/request which adds functionality) -->
<!--- - Performance enhancement (non-breaking change which improves efficiency) -->
<!--- - Code cleanup (non-breaking change which makes code smaller or more readable) -->
### Checklist:
<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
- [ ] I have read the [**contributing** document](https://github.com/Palakis/obs-websocket/blob/4.x-current/CONTRIBUTING.md).
- [ ] My code is not on the master branch.
- [ ] The code has been tested.
- [ ] All commit messages are properly formatted and commits squashed where appropriate.
- [ ] I have included updates to all appropriate documentation.

View File

@ -2,7 +2,7 @@
## Prerequisites
You'll need [Qt 5.10.x](https://download.qt.io/official_releases/qt/5.10/),
You'll need [Qt 5.15.2](https://download.qt.io/official_releases/qt/5.15/5.15.2/),
[CMake](https://cmake.org/download/) and a working [OBS Studio development environment](https://obsproject.com/wiki/install-instructions) installed on your
computer.
@ -29,12 +29,18 @@ make -j4
sudo make install
```
On other linux OS's, use this cmake command instead:
```shell
cmake -DLIBOBS_INCLUDE_DIR="<path to the libobs sub-folder in obs-studio's source code>" -DCMAKE_INSTALL_PREFIX=/usr ..
```
## OS X
As a prerequisite, you will need Xcode for your current OSX version, the Xcode command line tools, and [Homebrew](https://brew.sh/).
Homebrew's setup will guide you in getting your system set up, you should be good to go once Homebrew is successfully up and running.
Use of the Travis macOS CI scripts is recommended. Please note that these
Use of the macOS CI scripts is recommended. Please note that these
scripts install new software and can change several settings on your system. An
existing obs-studio development environment is not required, as
`install-build-obs-macos.sh` will install it for you. If you already have a
@ -47,16 +53,14 @@ look for issues or specificities.
```shell
git clone --recursive https://github.com/Palakis/obs-websocket.git
cd obs-websocket
./CI/install-dependencies-macos.sh
./CI/install-build-obs-macos.sh
./CI/build-macos.sh
./CI/package-macos.sh
./CI/macos/install-dependencies-macos.sh
./CI/macos/install-build-obs-macos.sh
./CI/macos/build-plugin-macos.sh
./CI/macos/package-plugin-macos.sh
```
This will result in a ready-to-use `obs-websocket.pkg` installer in the `release` subfolder.
## Automated Builds
- Windows: [![Automated Build status for Windows](https://ci.appveyor.com/api/projects/status/github/Palakis/obs-websocket)](https://ci.appveyor.com/project/Palakis/obs-websocket/history)
- Linux: [![Automated Build status for Linux](https://travis-ci.org/Palakis/obs-websocket.svg?branch=master)](https://travis-ci.org/Palakis/obs-websocket)
- macOS: [![Automated Build status for macOS](https://img.shields.io/azure-devops/build/Palakis/obs-websocket/Palakis.obs-websocket.svg)](https://dev.azure.com/Palakis/obs-websocket/_build)
[![Build Status](https://dev.azure.com/Palakis/obs-websocket/_apis/build/status/Palakis.obs-websocket?branchName=4.x-current)](https://dev.azure.com/Palakis/obs-websocket/_build/latest?definitionId=2&branchName=4.x-current)

View File

@ -1,6 +0,0 @@
if not exist %DepsBasePath% (
curl -o %DepsBasePath%.zip -kLO https://obsproject.com/downloads/dependencies2017.zip -f --retry 5 -C -
7z x %DepsBasePath%.zip -o%DepsBasePath%
) else (
echo "OBS dependencies are already there. Download skipped."
)

View File

@ -1,42 +0,0 @@
#!/bin/sh
OSTYPE=$(uname)
if [ "${OSTYPE}" != "Darwin" ]; then
echo "[obs-websocket - Error] macOS obs-studio build script can be run on Darwin-type OS only."
exit 1
fi
HAS_CMAKE=$(type cmake 2>/dev/null)
HAS_GIT=$(type git 2>/dev/null)
if [ "${HAS_CMAKE}" = "" ]; then
echo "[obs-websocket - Error] CMake not installed - please run 'install-dependencies-macos.sh' first."
exit 1
fi
if [ "${HAS_GIT}" = "" ]; then
echo "[obs-websocket - Error] Git not installed - please install Xcode developer tools or via Homebrew."
exit 1
fi
echo "[obs-websocket] Downloading and unpacking OBS dependencies"
wget --quiet --retry-connrefused --waitretry=1 https://obs-nightly.s3.amazonaws.com/osx-deps-2018-08-09.tar.gz
tar -xf ./osx-deps-2018-08-09.tar.gz -C /tmp
# Build obs-studio
cd ..
echo "[obs-websocket] Cloning obs-studio from GitHub.."
git clone https://github.com/obsproject/obs-studio
cd obs-studio
OBSLatestTag=$(git describe --tags --abbrev=0)
git checkout $OBSLatestTag
mkdir build && cd build
echo "[obs-websocket] Building obs-studio.."
cmake .. \
-DCMAKE_OSX_DEPLOYMENT_TARGET=10.11 \
-DDISABLE_PLUGINS=true \
-DENABLE_SCRIPTING=0 \
-DDepsPath=/tmp/obsdeps \
-DCMAKE_PREFIX_PATH=/usr/local/opt/qt/lib/cmake \
&& make -j4

View File

@ -1,61 +0,0 @@
#!/bin/sh
OSTYPE=$(uname)
if [ "${OSTYPE}" != "Darwin" ]; then
echo "[obs-websocket - Error] macOS install dependencies script can be run on Darwin-type OS only."
exit 1
fi
HAS_BREW=$(type brew 2>/dev/null)
if [ "${HAS_BREW}" = "" ]; then
echo "[obs-websocket - Error] Please install Homebrew (https://www.brew.sh/) to build obs-websocket on macOS."
exit 1
fi
# OBS Studio deps
echo "[obs-websocket] Updating Homebrew.."
brew update >/dev/null
echo "[obs-websocket] Checking installed Homebrew formulas.."
BREW_PACKAGES=$(brew list)
BREW_DEPENDENCIES="jack speexdsp ccache swig mbedtls"
for DEPENDENCY in ${BREW_DEPENDENCIES}; do
if echo "${BREW_PACKAGES}" | grep -q "^${DEPENDENCY}\$"; then
echo "[obs-websocket] Upgrading OBS-Studio dependency '${DEPENDENCY}'.."
brew upgrade ${DEPENDENCY} 2>/dev/null
else
echo "[obs-websocket] Installing OBS-Studio dependency '${DEPENDENCY}'.."
brew install ${DEPENDENCY} 2>/dev/null
fi
done
# qtwebsockets deps
echo "[obs-websocket] Installing obs-websocket dependency 'QT 5.10.1'.."
# =!= NOTICE =!=
# When building QT5 from sources on macOS 10.13+, use local qt5 formula:
# brew install ./CI/macos/qt.rb
# Pouring from the bottle is much quicker though, so use bottle for now.
# =!= NOTICE =!=
brew install https://gist.githubusercontent.com/DDRBoxman/b3956fab6073335a4bf151db0dcbd4ad/raw/ed1342a8a86793ea8c10d8b4d712a654da121ace/qt.rb
# Pin this version of QT5 to avoid `brew upgrade`
# upgrading it to incompatible version
brew pin qt
# Fetch and install Packages app
# =!= NOTICE =!=
# Installs a LaunchDaemon under /Library/LaunchDaemons/fr.whitebox.packages.build.dispatcher.plist
# =!= NOTICE =!=
HAS_PACKAGES=$(type packagesbuild 2>/dev/null)
if [ "${HAS_PACKAGES}" = "" ]; then
echo "[obs-websocket] Installing Packaging app (might require password due to 'sudo').."
curl -o './Packages.pkg' --retry-connrefused -s --retry-delay 1 'https://s3-us-west-2.amazonaws.com/obs-nightly/Packages.pkg'
sudo installer -pkg ./Packages.pkg -target /
fi

View File

@ -1,19 +0,0 @@
#!/bin/sh
set -ex
sudo add-apt-repository -y ppa:obsproject/obs-studio
sudo apt-get -qq update
sudo apt-get install -y \
libc-dev-bin \
libc6-dev git \
build-essential \
checkinstall \
cmake \
obs-studio \
qtbase5-dev
# Dirty hack
sudo wget -O /usr/include/obs/obs-frontend-api.h https://raw.githubusercontent.com/obsproject/obs-studio/25.0.0/UI/obs-frontend-api/obs-frontend-api.h
sudo ldconfig

View File

@ -1,8 +0,0 @@
if not exist %QtBaseDir% (
curl -kLO https://cdn-fastly.obsproject.com/downloads/Qt_5.10.1.7z -f --retry 5 -z Qt_5.10.1.7z
7z x Qt_5.10.1.7z -o%QtBaseDir%
) else (
echo "Qt is already installed. Download skipped."
)
dir %QtBaseDir%

View File

@ -1,6 +1,9 @@
#!/bin/sh
set -ex
echo "[obs-websocket] Running CMake.."
mkdir build && cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr -DUSE_UBUNTU_FIX=true ..
echo "[obs-websocket] Building plugin.."
make -j4

View File

@ -0,0 +1,29 @@
#!/bin/sh
set -ex
echo "[obs-websocket] Installing obs-studio PPA and updates.."
sudo add-apt-repository -y ppa:obsproject/obs-studio
sudo apt-get -qq update
echo "[obs-websocket] Installing obs-studio and dependencies.."
sudo apt-get install -y \
libc-dev-bin \
libc6-dev git \
build-essential \
checkinstall \
cmake \
obs-studio \
qtbase5-dev
wget https://launchpad.net/~gol-d-ace/+archive/ubuntu/obs-studio/+build/22244364/+files/obs-studio_27.1.3-0obsproject1~focal_amd64.deb
sudo dpkg -i ./*.deb
echo "[obs-websocket] Installed OBS Version: $(obs --version)"
ls /usr/include/
ls /usr/include/obs/
# Dirty hack
sudo wget -O /usr/include/obs/obs-frontend-api.h https://raw.githubusercontent.com/obsproject/obs-studio/27.1.3/UI/obs-frontend-api/obs-frontend-api.h
sudo ldconfig

View File

@ -5,19 +5,20 @@ set -e
export GIT_HASH=$(git rev-parse --short HEAD)
export PKG_VERSION="1-$GIT_HASH-$BRANCH_SHORT_NAME-git"
if [[ "$BRANCH_FULL_NAME" =~ "^refs/tags/" ]]; then
if [[ $BRANCH_FULL_NAME =~ ^refs/tags/ ]]; then
export PKG_VERSION="$BRANCH_SHORT_NAME"
echo "[obs-websocket] Branch is a tag. Setting version to $PKG_VERSION."
fi
cd ./build
PAGER="cat" sudo checkinstall -y --type=debian --fstrans=no --nodoc \
--backup=no --deldoc=yes --install=no \
--pkgname=obs-websocket --pkgversion="$PKG_VERSION" \
--pkgname=obs-websocket-compat --pkgversion="$PKG_VERSION" \
--pkglicense="GPLv2.0" --maintainer="stephane.lepin@gmail.com" \
--pkggroup="video" \
--pkgsource="https://github.com/Palakis/obs-websocket" \
--requires="obs-studio \(\>= 25.0.7\), libqt5core5a, libqt5widgets5, qt5-image-formats-plugins" \
--requires="obs-studio \(\>= 26.1.0\), libqt5core5a, libqt5widgets5, qt5-image-formats-plugins" \
--pakdir="../package"
sudo chmod ao+r ../package/*

5
CI/macos/Brewfile Normal file
View File

@ -0,0 +1,5 @@
brew "jack"
brew "speexdsp"
brew "cmake"
brew "freetype"
brew "fdk-aac"

View File

@ -3,26 +3,25 @@
OSTYPE=$(uname)
if [ "${OSTYPE}" != "Darwin" ]; then
echo "[obs-websocket - Error] macOS build script can be run on Darwin-type OS only."
exit 1
echo "[obs-websocket - Error] macOS build script can be run on Darwin-type OS only."
exit 1
fi
HAS_CMAKE=$(type cmake 2>/dev/null)
if [ "${HAS_CMAKE}" = "" ]; then
echo "[obs-websocket - Error] CMake not installed - please run 'install-dependencies-macos.sh' first."
exit 1
echo "[obs-websocket - Error] CMake not installed - please run 'install-dependencies-macos.sh' first."
exit 1
fi
#export QT_PREFIX="$(find /usr/local/Cellar/qt5 -d 1 | tail -n 1)"
echo "[obs-websocket] Building 'obs-websocket' for macOS."
mkdir -p build && cd build
cmake .. \
-DQTDIR=/usr/local/opt/qt \
-DQTDIR=/tmp/obsdeps \
-DLIBOBS_INCLUDE_DIR=../../obs-studio/libobs \
-DLIBOBS_LIB=../../obs-studio/libobs \
-DOBS_FRONTEND_LIB="$(pwd)/../../obs-studio/build/UI/obs-frontend-api/libobs-frontend-api.dylib" \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_OSX_DEPLOYMENT_TARGET=10.13 \
&& make -j4

View File

@ -0,0 +1,39 @@
#!/bin/sh
OSTYPE=$(uname)
if [ "${OSTYPE}" != "Darwin" ]; then
echo "[obs-websocket - Error] macOS obs-studio build script can be run on Darwin-type OS only."
exit 1
fi
HAS_CMAKE=$(type cmake 2>/dev/null)
HAS_GIT=$(type git 2>/dev/null)
if [ "${HAS_CMAKE}" = "" ]; then
echo "[obs-websocket - Error] CMake not installed - please run 'install-dependencies-macos.sh' first."
exit 1
fi
if [ "${HAS_GIT}" = "" ]; then
echo "[obs-websocket - Error] Git not installed - please install Xcode developer tools or via Homebrew."
exit 1
fi
# Build obs-studio
cd ..
echo "[obs-websocket] Cloning obs-studio from GitHub.."
git clone https://github.com/obsproject/obs-studio
cd obs-studio
OBSLatestTag=$(git describe --tags --abbrev=0)
git checkout 27.1.3
mkdir build && cd build
echo "[obs-websocket] Building obs-studio.."
cmake .. \
-DQTDIR=/tmp/obsdeps \
-DDepsPath=/tmp/obsdeps \
-DCMAKE_OSX_DEPLOYMENT_TARGET=10.13 \
-DDISABLE_PLUGINS=true \
-DENABLE_SCRIPTING=0 \
-DCMAKE_PREFIX_PATH=/tmp/obsdeps/lib/cmake \
&& make -j4

View File

@ -0,0 +1,57 @@
#!/bin/sh
OSTYPE=$(uname)
if [ "${OSTYPE}" != "Darwin" ]; then
echo "[obs-websocket - Error] macOS install dependencies script can be run on Darwin-type OS only."
exit 1
fi
HAS_BREW=$(type brew 2>/dev/null)
if [ "${HAS_BREW}" = "" ]; then
echo "[obs-websocket - Error] Please install Homebrew (https://www.brew.sh/) to build obs-websocket on macOS."
exit 1
fi
# OBS Studio Brew Deps
echo "[obs-websocket] Updating Homebrew.."
brew update >/dev/null
echo "[obs-websocket] Checking installed Homebrew formulas.."
if [ -d /usr/local/opt/openssl@1.0.2t ]; then
brew uninstall openssl@1.0.2t
brew untap local/openssl
fi
if [ -d /usr/local/opt/python@2.7.17 ]; then
brew uninstall python@2.7.17
brew untap local/python2
fi
brew bundle --file ./CI/macos/Brewfile
# Fetch and install Packages app
# =!= NOTICE =!=
# Installs a LaunchDaemon under /Library/LaunchDaemons/fr.whitebox.packages.build.dispatcher.plist
# =!= NOTICE =!=
HAS_PACKAGES=$(type packagesbuild 2>/dev/null)
if [ "${HAS_PACKAGES}" = "" ]; then
echo "[obs-websocket] Installing Packaging app (might require password due to 'sudo').."
curl -L -O http://s.sudre.free.fr/Software/files/Packages.dmg
sudo hdiutil attach ./Packages.dmg
sudo installer -pkg /Volumes/Packages\ 1.2.10/Install\ Packages.pkg -target /
fi
# OBS Deps
echo "[obs-websocket] Installing obs-websocket dependency 'OBS Deps ${OBS_DEPS_VERSION}'.."
wget --quiet --retry-connrefused --waitretry=1 https://github.com/obsproject/obs-deps/releases/download/${OBS_DEPS_VERSION}/macos-deps-${OBS_DEPS_VERSION}.tar.gz
tar -xf ./macos-deps-${OBS_DEPS_VERSION}.tar.gz -C /tmp
# Qt deps
echo "[obs-websocket] Installing obs-websocket dependency 'Qt ${QT_VERSION}'.."
curl -L -O https://github.com/obsproject/obs-deps/releases/download/${OBS_DEPS_VERSION}/macos-qt-${QT_VERSION}-${OBS_DEPS_VERSION}.tar.gz
tar -xf ./macos-qt-${QT_VERSION}-${OBS_DEPS_VERSION}.tar.gz -C "/tmp"
xattr -r -d com.apple.quarantine /tmp/obsdeps

View File

@ -36,7 +36,7 @@
<key>GID</key>
<integer>80</integer>
<key>PATH</key>
<string>../../build/obs-websocket.so</string>
<string>../../build/obs-websocket-compat.so</string>
<key>PATH_TYPE</key>
<integer>1</integer>
<key>PERMISSIONS</key>
@ -80,7 +80,7 @@
<key>GID</key>
<integer>80</integer>
<key>PATH</key>
<string>obs-websocket</string>
<string>obs-websocket-compat</string>
<key>PATH_TYPE</key>
<integer>0</integer>
<key>PERMISSIONS</key>
@ -514,11 +514,11 @@
<key>CONCLUSION_ACTION</key>
<integer>0</integer>
<key>IDENTIFIER</key>
<string>fr.palakis.obs-websocket</string>
<string>fr.palakis.obs-websocket-compat</string>
<key>OVERWRITE_PERMISSIONS</key>
<false/>
<key>VERSION</key>
<string>4.8.0</string>
<string>4.9.1-compat</string>
</dict>
<key>PROJECT_COMMENTS</key>
<dict>
@ -715,7 +715,7 @@
</dict>
</array>
<key>NAME</key>
<string>obs-websocket</string>
<string>obs-websocket-compat</string>
</dict>
</dict>
<key>TYPE</key>

View File

@ -5,12 +5,11 @@ set -e
OSTYPE=$(uname)
if [ "${OSTYPE}" != "Darwin" ]; then
echo "[obs-websocket - Error] macOS package script can be run on Darwin-type OS only."
exit 1
echo "[obs-websocket - Error] macOS package script can be run on Darwin-type OS only."
exit 1
fi
echo "[obs-websocket] Preparing package build"
export QT_CELLAR_PREFIX="$(/usr/bin/find /usr/local/Cellar/qt -d 1 | sort -t '.' -k 1,1n -k 2,2n -k 3,3n | tail -n 1)"
GIT_HASH=$(git rev-parse --short HEAD)
GIT_BRANCH_OR_TAG=$(git name-rev --name-only HEAD | awk -F/ '{print $NF}')
@ -20,23 +19,23 @@ VERSION="$GIT_HASH-$GIT_BRANCH_OR_TAG"
FILENAME_UNSIGNED="obs-websocket-$VERSION-Unsigned.pkg"
FILENAME="obs-websocket-$VERSION.pkg"
echo "[obs-websocket] Modifying obs-websocket.so"
echo "[obs-websocket] Modifying obs-websocket-compat.so linking"
install_name_tool \
-change /usr/local/opt/qt/lib/QtWidgets.framework/Versions/5/QtWidgets \
-change /tmp/obsdeps/lib/QtWidgets.framework/Versions/5/QtWidgets \
@executable_path/../Frameworks/QtWidgets.framework/Versions/5/QtWidgets \
-change /usr/local/opt/qt/lib/QtGui.framework/Versions/5/QtGui \
-change /tmp/obsdeps/lib/QtGui.framework/Versions/5/QtGui \
@executable_path/../Frameworks/QtGui.framework/Versions/5/QtGui \
-change /usr/local/opt/qt/lib/QtCore.framework/Versions/5/QtCore \
-change /tmp/obsdeps/lib/QtCore.framework/Versions/5/QtCore \
@executable_path/../Frameworks/QtCore.framework/Versions/5/QtCore \
./build/obs-websocket.so
./build/obs-websocket-compat.so
# Check if replacement worked
echo "[obs-websocket] Dependencies for obs-websocket"
otool -L ./build/obs-websocket.so
otool -L ./build/obs-websocket-compat.so
if [[ "$RELEASE_MODE" == "True" ]]; then
echo "[obs-websocket] Signing plugin binary: obs-websocket.so"
codesign --sign "$CODE_SIGNING_IDENTITY" ./build/obs-websocket.so
echo "[obs-websocket] Signing plugin binary: obs-websocket-compat.so"
codesign --sign "$CODE_SIGNING_IDENTITY" ./build/obs-websocket-compat.so
else
echo "[obs-websocket] Skipped plugin codesigning"
fi
@ -45,7 +44,7 @@ echo "[obs-websocket] Actual package build"
packagesbuild ./CI/macos/obs-websocket.pkgproj
echo "[obs-websocket] Renaming obs-websocket.pkg to $FILENAME"
mv ./release/obs-websocket.pkg ./release/$FILENAME_UNSIGNED
mv ./release/obs-websocket-compat.pkg ./release/$FILENAME_UNSIGNED
if [[ "$RELEASE_MODE" == "True" ]]; then
echo "[obs-websocket] Signing installer: $FILENAME"

View File

@ -1,163 +0,0 @@
# Patches for Qt must be at the very least submitted to Qt's Gerrit codereview
# rather than their bug-report Jira. The latter is rarely reviewed by Qt.
class Qt < Formula
desc "Cross-platform application and UI framework"
homepage "https://www.qt.io/"
url "https://download.qt.io/archive/qt/5.10/5.10.1/single/qt-everywhere-src-5.10.1.tar.xz"
mirror "https://mirrorservice.org/sites/download.qt-project.org/official_releases/qt/5.10/5.10.1/single/qt-everywhere-src-5.10.1.tar.xz"
sha256 "05ffba7b811b854ed558abf2be2ddbd3bb6ddd0b60ea4b5da75d277ac15e740a"
head "https://code.qt.io/qt/qt5.git", :branch => "5.10.1", :shallow => false
bottle do
sha256 "8b4bad005596a5f8790150fe455db998ac2406f4e0f04140d6656205d844d266" => :high_sierra
sha256 "9c488554935fb573554a4e36d36d3c81e47245b7fefc4b61edef894e67ba1740" => :sierra
sha256 "c0407afba5951df6cc4c6f6c1c315972bd41c99cecb4e029919c4c15ab6f7bdc" => :el_capitan
end
keg_only "Qt 5 has CMake issues when linked"
option "with-docs", "Build documentation"
option "with-examples", "Build examples"
deprecated_option "with-mysql" => "with-mysql-client"
# OS X 10.7 Lion is still supported in Qt 5.5, but is no longer a reference
# configuration and thus untested in practice. Builds on OS X 10.7 have been
# reported to fail: <https://github.com/Homebrew/homebrew/issues/45284>.
depends_on :macos => :mountain_lion
depends_on "pkg-config" => :build
depends_on :xcode => :build
depends_on "mysql-client" => :optional
depends_on "postgresql" => :optional
# Restore `.pc` files for framework-based build of Qt 5 on OS X. This
# partially reverts <https://codereview.qt-project.org/#/c/140954/> merged
# between the 5.5.1 and 5.6.0 releases. (Remove this as soon as feasible!)
#
# Core formulae known to fail without this patch (as of 2016-10-15):
# * gnuplot (with `--with-qt` option)
# * mkvtoolnix (with `--with-qt` option, silent build failure)
# * poppler (with `--with-qt` option)
patch do
url "https://raw.githubusercontent.com/Homebrew/formula-patches/e8fe6567/qt5/restore-pc-files.patch"
sha256 "48ff18be2f4050de7288bddbae7f47e949512ac4bcd126c2f504be2ac701158b"
end
# Fix compile error on macOS 10.13 around QFixed:
# https://github.com/Homebrew/homebrew-core/issues/27095
# https://bugreports.qt.io/browse/QTBUG-67545
patch do
url "https://raw.githubusercontent.com/z00m1n/formula-patches/0de0e229/qt/QTBUG-67545.patch"
sha256 "4a115097c7582c7dce4207f5500d13feb8c990eb8a05a43f41953985976ebe6c"
end
# Fix compile error on macOS 10.13 caused by qtlocation dependency
# mapbox-gl-native using Boost 1.62.0 does not build with C++ 17:
# https://github.com/Homebrew/homebrew-core/issues/27095
# https://bugreports.qt.io/browse/QTBUG-67810
patch do
url "https://raw.githubusercontent.com/z00m1n/formula-patches/a1a1f0dd/qt/QTBUG-67810.patch"
sha256 "8ee0bf71df1043f08ebae3aa35036be29c4d9ebff8a27e3b0411a6bd635e9382"
end
def install
args = %W[
-verbose
-prefix #{prefix}
-release
-opensource -confirm-license
-system-zlib
-qt-libpng
-qt-libjpeg
-qt-freetype
-qt-pcre
-nomake tests
-no-rpath
-pkg-config
-dbus-runtime
-no-assimp
]
args << "-nomake" << "examples" if build.without? "examples"
if build.with? "mysql-client"
args << "-plugin-sql-mysql"
(buildpath/"brew_shim/mysql_config").write <<~EOS
#!/bin/sh
if [ x"$1" = x"--libs" ]; then
mysql_config --libs | sed "s/-lssl -lcrypto//"
else
exec mysql_config "$@"
fi
EOS
chmod 0755, "brew_shim/mysql_config"
args << "-mysql_config" << buildpath/"brew_shim/mysql_config"
end
args << "-plugin-sql-psql" if build.with? "postgresql"
system "./configure", *args
system "make"
ENV.deparallelize
system "make", "install"
if build.with? "docs"
system "make", "docs"
system "make", "install_docs"
end
# Some config scripts will only find Qt in a "Frameworks" folder
frameworks.install_symlink Dir["#{lib}/*.framework"]
# The pkg-config files installed suggest that headers can be found in the
# `include` directory. Make this so by creating symlinks from `include` to
# the Frameworks' Headers folders.
Pathname.glob("#{lib}/*.framework/Headers") do |path|
include.install_symlink path => path.parent.basename(".framework")
end
# Move `*.app` bundles into `libexec` to expose them to `brew linkapps` and
# because we don't like having them in `bin`.
# (Note: This move breaks invocation of Assistant via the Help menu
# of both Designer and Linguist as that relies on Assistant being in `bin`.)
libexec.mkpath
Pathname.glob("#{bin}/*.app") { |app| mv app, libexec }
end
def caveats; <<~EOS
We agreed to the Qt opensource license for you.
If this is unacceptable you should uninstall.
EOS
end
test do
(testpath/"hello.pro").write <<~EOS
QT += core
QT -= gui
TARGET = hello
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
EOS
(testpath/"main.cpp").write <<~EOS
#include <QCoreApplication>
#include <QDebug>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
qDebug() << "Hello World!";
return 0;
}
EOS
system bin/"qmake", testpath/"hello.pro"
system "make"
assert_predicate testpath/"hello", :exist?
assert_predicate testpath/"main.o", :exist?
system "./hello"
end
end

View File

@ -1,37 +0,0 @@
@echo off
SETLOCAL EnableDelayedExpansion
REM If obs-studio directory does not exist, clone the git repo
if not exist %OBSPath% (
echo obs-studio directory does not exist
git clone https://github.com/obsproject/obs-studio %OBSPath%
cd /D %OBSPath%\
git describe --tags --abbrev=0 --exclude="*-rc*" > "%OBSPath%\obs-studio-latest-tag.txt"
set /p OBSLatestTag=<"%OBSPath%\obs-studio-latest-tag.txt"
)
REM Prepare OBS Studio builds
echo Running CMake...
cd /D %OBSPath%
echo git checkout %OBSLatestTag%
git checkout %OBSLatestTag%
echo:
if not exist build32 mkdir build32
if not exist build64 mkdir build64
echo Running cmake for obs-studio %OBSLatestTag% 32-bit...
cd build32
cmake -G "Visual Studio 16 2019" -A Win32 -DCMAKE_SYSTEM_VERSION=10.0 -DQTDIR="%QTDIR32%" -DDepsPath="%DepsPath32%" -DBUILD_CAPTIONS=true -DDISABLE_PLUGINS=true -DCOPIED_DEPENDENCIES=false -DCOPY_DEPENDENCIES=true ..
echo:
echo:
echo Running cmake for obs-studio %OBSLatestTag% 64-bit...
cd ..\build64
cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_SYSTEM_VERSION=10.0 -DQTDIR="%QTDIR64%" -DDepsPath="%DepsPath64%" -DBUILD_CAPTIONS=true -DDISABLE_PLUGINS=true -DCOPIED_DEPENDENCIES=false -DCOPY_DEPENDENCIES=true ..
echo:
echo:
dir "%OBSPath%\libobs"

View File

@ -1,7 +0,0 @@
mkdir build32
mkdir build64
cd build32
cmake -G "Visual Studio 16 2019" -A Win32 -DCMAKE_SYSTEM_VERSION=10.0 -DQTDIR="%QTDIR32%" -DLibObs_DIR="%OBSPath%\build32\libobs" -DLIBOBS_INCLUDE_DIR="%OBSPath%\libobs" -DLIBOBS_LIB="%OBSPath%\build32\libobs\%build_config%\obs.lib" -DOBS_FRONTEND_LIB="%OBSPath%\build32\UI\obs-frontend-api\%build_config%\obs-frontend-api.lib" ..
cd ..\build64
cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_SYSTEM_VERSION=10.0 -DQTDIR="%QTDIR64%" -DLibObs_DIR="%OBSPath%\build64\libobs" -DLIBOBS_INCLUDE_DIR="%OBSPath%\libobs" -DLIBOBS_LIB="%OBSPath%\build64\libobs\%build_config%\obs.lib" -DOBS_FRONTEND_LIB="%OBSPath%\build64\UI\obs-frontend-api\%build_config%\obs-frontend-api.lib" ..

View File

@ -0,0 +1,7 @@
if exist %DEPS_BASE_PATH% (
echo "OBS dependencies found. Download skipped."
) else (
echo "OBS dependencies not found. Downloading..."
curl -o %DEPS_BASE_PATH%.zip -kLO https://cdn-fastly.obsproject.com/downloads/dependencies2019.zip -f --retry 5 -C -
7z x %DEPS_BASE_PATH%.zip -o%DEPS_BASE_PATH%
)

View File

@ -0,0 +1,8 @@
if exist %QT_BASE_DIR% (
echo "Qt directory found. Download skipped."
) else (
echo "Qt directory not found. Downloading..."
curl -kLO https://tt2468.net/dl/Qt_5.15.2.7z -f --retry 5 -C -
7z x Qt_5.15.2.7z -o%QT_BASE_DIR%
)
dir %QT_BASE_DIR%

View File

@ -0,0 +1,38 @@
@echo off
SETLOCAL EnableDelayedExpansion
REM If obs-studio directory does not exist, clone the git repo
if not exist %OBS_PATH% (
echo obs-studio directory does not exist
git clone -b 27.1.3 https://github.com/obsproject/obs-studio %OBS_PATH%
cd /D %OBS_PATH%\
git describe --tags --abbrev=0 > "%OBS_PATH%\obs-studio-latest-tag.txt"
REM set /p OBS_LATEST_TAG=<"%OBS_PATH%\obs-studio-latest-tag.txt"
set /p OBS_LATEST_TAG=<"27.1.3"
)
REM Prepare OBS Studio builds
echo Running CMake...
cd /D %OBS_PATH%
REM echo git checkout %OBS_LATEST_TAG%
REM git checkout %OBS_LATEST_TAG%
echo:
if not exist build32 mkdir build32
if not exist build64 mkdir build64
echo Running cmake for obs-studio %OBS_LATEST_TAG% 32-bit...
cd build32
cmake -G "Visual Studio 16 2019" -A Win32 -DCMAKE_SYSTEM_VERSION=10.0 -DQTDIR="%QTDIR32%" -DDepsPath="%DEPS_PATH_32%" -DDISABLE_PLUGINS=true -DCOPIED_DEPENDENCIES=false -DCOPY_DEPENDENCIES=true ..
echo:
echo:
echo Running cmake for obs-studio %OBS_LATEST_TAG% 64-bit...
cd ..\build64
cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_SYSTEM_VERSION=10.0 -DQTDIR="%QTDIR64%" -DDepsPath="%DEPS_PATH_64%" -DDISABLE_PLUGINS=true -DCOPIED_DEPENDENCIES=false -DCOPY_DEPENDENCIES=true ..
echo:
echo:
dir "%OBS_PATH%\libobs"

View File

@ -0,0 +1,7 @@
mkdir build32
mkdir build64
cd build32
cmake -G "Visual Studio 16 2019" -A Win32 -DCMAKE_SYSTEM_VERSION=10.0 -DQTDIR="%QTDIR32%" -DLibObs_DIR="%OBS_PATH%\build32\libobs" -DLIBOBS_INCLUDE_DIR="%OBS_PATH%\libobs" -DLIBOBS_LIB="%OBS_PATH%\build32\libobs\%build_config%\obs.lib" -DOBS_FRONTEND_LIB="%OBS_PATH%\build32\UI\obs-frontend-api\%build_config%\obs-frontend-api.lib" ..
cd ..\build64
cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_SYSTEM_VERSION=10.0 -DQTDIR="%QTDIR64%" -DLibObs_DIR="%OBS_PATH%\build64\libobs" -DLIBOBS_INCLUDE_DIR="%OBS_PATH%\libobs" -DLIBOBS_LIB="%OBS_PATH%\build64\libobs\%build_config%\obs.lib" -DOBS_FRONTEND_LIB="%OBS_PATH%\build64\UI\obs-frontend-api\%build_config%\obs-frontend-api.lib" ..

View File

@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.5)
project(obs-websocket VERSION 4.8.0)
project(obs-websocket-compat VERSION 4.9.1)
set(CMAKE_PREFIX_PATH "${QTDIR}")
set(CMAKE_INCLUDE_CURRENT_DIR ON)
@ -11,6 +11,10 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_definitions(-DASIO_STANDALONE)
if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm")
set(CMAKE_CXX_FLAGS "-mfpu=neon")
endif()
if (WIN32 OR APPLE)
include(external/FindLibObs.cmake)
endif()
@ -18,7 +22,7 @@ endif()
find_package(LibObs REQUIRED)
find_package(Qt5 REQUIRED COMPONENTS Core Widgets)
set(obs-websocket_SOURCES
set(obs-websocket-compat_SOURCES
src/obs-websocket.cpp
src/WSServer.cpp
src/ConnectionProperties.cpp
@ -32,9 +36,11 @@ set(obs-websocket_SOURCES
src/WSRequestHandler_SceneItems.cpp
src/WSRequestHandler_Sources.cpp
src/WSRequestHandler_Streaming.cpp
src/WSRequestHandler_VirtualCam.cpp
src/WSRequestHandler_StudioMode.cpp
src/WSRequestHandler_Transitions.cpp
src/WSRequestHandler_Outputs.cpp
src/WSRequestHandler_MediaControl.cpp
src/WSEvents.cpp
src/Config.cpp
src/Utils.cpp
@ -44,7 +50,7 @@ set(obs-websocket_SOURCES
src/protocol/OBSRemoteProtocol.cpp
src/forms/settings-dialog.cpp)
set(obs-websocket_HEADERS
set(obs-websocket-compat_HEADERS
src/obs-websocket.h
src/WSServer.h
src/ConnectionProperties.h
@ -59,18 +65,18 @@ set(obs-websocket_HEADERS
src/forms/settings-dialog.h)
# --- Platform-independent build settings ---
add_library(obs-websocket MODULE
${obs-websocket_SOURCES}
${obs-websocket_HEADERS})
add_library(obs-websocket-compat MODULE
${obs-websocket-compat_SOURCES}
${obs-websocket-compat_HEADERS})
include_directories(
"${LIBOBS_INCLUDE_DIR}/../UI/obs-frontend-api"
${Qt5Core_INCLUDES}
${Qt5Widgets_INCLUDES}
"${CMAKE_SOURCE_DIR}/deps/asio/asio/include"
"${CMAKE_SOURCE_DIR}/deps/websocketpp")
"${CMAKE_CURRENT_SOURCE_DIR}/deps/asio/asio/include"
"${CMAKE_CURRENT_SOURCE_DIR}/deps/websocketpp")
target_link_libraries(obs-websocket
target_link_libraries(obs-websocket-compat
libobs
Qt5::Core
Qt5::Widgets)
@ -79,9 +85,9 @@ target_link_libraries(obs-websocket
# --- Windows-specific build settings and tasks ---
if(WIN32)
if(NOT DEFINED OBS_FRONTEND_LIB)
set(OBS_FRONTEND_LIB "OBS_FRONTEND_LIB-NOTFOUND" CACHE FILEPATH "OBS frontend library")
message(FATAL_ERROR "Could not find OBS Frontend API's library !")
set(OBS_FRONTEND_LIB "NOTFOUND" CACHE FILEPATH "OBS frontend library")
if(OBS_FRONTEND_LIB STREQUAL "NOTFOUND")
message(FATAL_ERROR "OBS Frontend API library not found!")
endif()
if(MSVC)
@ -103,75 +109,62 @@ if(WIN32)
"${LIBOBS_INCLUDE_DIR}/../${OBS_BUILDDIR_ARCH}/UI"
)
target_link_libraries(obs-websocket
target_link_libraries(obs-websocket-compat
"${OBS_FRONTEND_LIB}")
# --- Release package helper ---
# The "release" folder has a structure similar OBS' one on Windows
set(RELEASE_DIR "${PROJECT_SOURCE_DIR}/release")
add_custom_command(TARGET obs-websocket POST_BUILD
# If config is Release, package release files
COMMAND if $<CONFIG:Release>==1 (
add_custom_command(TARGET obs-websocket-compat POST_BUILD
# If config is Release or RelWithDebInfo, package release files
COMMAND if $<OR:$<CONFIG:Release>,$<CONFIG:RelWithDebInfo>>==1 (
"${CMAKE_COMMAND}" -E make_directory
"${RELEASE_DIR}/data/obs-plugins/obs-websocket"
"${RELEASE_DIR}/obs-plugins/${ARCH_NAME}")
"${RELEASE_DIR}/obs-plugins/${ARCH_NAME}"
)
COMMAND if $<CONFIG:Release>==1 ("${CMAKE_COMMAND}" -E copy_directory
COMMAND if $<OR:$<CONFIG:Release>,$<CONFIG:RelWithDebInfo>>==1 (
"${CMAKE_COMMAND}" -E copy_directory
"${PROJECT_SOURCE_DIR}/data"
"${RELEASE_DIR}/data/obs-plugins/obs-websocket")
"${RELEASE_DIR}/data/obs-plugins/obs-websocket-compat"
)
COMMAND if $<CONFIG:Release>==1 ("${CMAKE_COMMAND}" -E copy
"$<TARGET_FILE:obs-websocket>"
"${RELEASE_DIR}/obs-plugins/${ARCH_NAME}")
# In Release mode, copy Qt image format plugins
COMMAND if $<CONFIG:Release>==1 (
COMMAND if $<OR:$<CONFIG:Release>,$<CONFIG:RelWithDebInfo>>==1 (
"${CMAKE_COMMAND}" -E copy
"${QTDIR}/plugins/imageformats/qjpeg.dll"
"${RELEASE_DIR}/bin/${ARCH_NAME}/imageformats/qjpeg.dll")
"$<TARGET_FILE:obs-websocket-compat>"
"${RELEASE_DIR}/obs-plugins/${ARCH_NAME}"
)
# If config is RelWithDebInfo, package PDB file for target
COMMAND if $<CONFIG:RelWithDebInfo>==1 (
"${CMAKE_COMMAND}" -E copy
"${QTDIR}/plugins/imageformats/qjpeg.dll"
"${RELEASE_DIR}/bin/${ARCH_NAME}/imageformats/qjpeg.dll")
"$<TARGET_PDB_FILE:obs-websocket-compat>"
"${RELEASE_DIR}/obs-plugins/${ARCH_NAME}"
)
# If config is RelWithDebInfo, package release files
COMMAND if $<CONFIG:RelWithDebInfo>==1 (
"${CMAKE_COMMAND}" -E make_directory
"${RELEASE_DIR}/data/obs-plugins/obs-websocket"
"${RELEASE_DIR}/obs-plugins/${ARCH_NAME}")
COMMAND if $<CONFIG:RelWithDebInfo>==1 ("${CMAKE_COMMAND}" -E copy_directory
"${PROJECT_SOURCE_DIR}/data"
"${RELEASE_DIR}/data/obs-plugins/obs-websocket")
COMMAND if $<CONFIG:RelWithDebInfo>==1 ("${CMAKE_COMMAND}" -E copy
"$<TARGET_FILE:obs-websocket>"
"${RELEASE_DIR}/obs-plugins/${ARCH_NAME}")
COMMAND if $<CONFIG:RelWithDebInfo>==1 ("${CMAKE_COMMAND}" -E copy
"$<TARGET_PDB_FILE:obs-websocket>"
"${RELEASE_DIR}/obs-plugins/${ARCH_NAME}")
# Copy to obs-studio dev environment for immediate testing
# In the Debug configuration, copy to obs-studio dev environment for immediate testing
COMMAND if $<CONFIG:Debug>==1 (
"${CMAKE_COMMAND}" -E copy
"$<TARGET_FILE:obs-websocket>"
"${LIBOBS_INCLUDE_DIR}/../${OBS_BUILDDIR_ARCH}/rundir/$<CONFIG>/obs-plugins/${ARCH_NAME}")
"$<TARGET_FILE:obs-websocket-compat>"
"${LIBOBS_INCLUDE_DIR}/../${OBS_BUILDDIR_ARCH}/rundir/$<CONFIG>/obs-plugins/${ARCH_NAME}"
)
COMMAND if $<CONFIG:Debug>==1 (
"${CMAKE_COMMAND}" -E copy
"$<TARGET_PDB_FILE:obs-websocket>"
"${LIBOBS_INCLUDE_DIR}/../${OBS_BUILDDIR_ARCH}/rundir/$<CONFIG>/obs-plugins/${ARCH_NAME}")
"$<TARGET_PDB_FILE:obs-websocket-compat>"
"${LIBOBS_INCLUDE_DIR}/../${OBS_BUILDDIR_ARCH}/rundir/$<CONFIG>/obs-plugins/${ARCH_NAME}"
)
COMMAND if $<CONFIG:Debug>==1 (
"${CMAKE_COMMAND}" -E make_directory
"${LIBOBS_INCLUDE_DIR}/../${OBS_BUILDDIR_ARCH}/rundir/$<CONFIG>/data/obs-plugins/obs-websocket")
"${LIBOBS_INCLUDE_DIR}/../${OBS_BUILDDIR_ARCH}/rundir/$<CONFIG>/data/obs-plugins/obs-websocket-compat"
)
COMMAND if $<CONFIG:Debug>==1 (
"${CMAKE_COMMAND}" -E copy_directory
"${PROJECT_SOURCE_DIR}/data"
"${LIBOBS_INCLUDE_DIR}/../${OBS_BUILDDIR_ARCH}/rundir/$<CONFIG>/data/obs-plugins/obs-websocket")
"${PROJECT_SOURCE_DIR}/data"
"${LIBOBS_INCLUDE_DIR}/../${OBS_BUILDDIR_ARCH}/rundir/$<CONFIG>/data/obs-plugins/obs-websocket-compat"
)
)
# --- End of sub-section ---
@ -182,20 +175,28 @@ endif()
if(UNIX AND NOT APPLE)
include(GNUInstallDirs)
set_target_properties(obs-websocket PROPERTIES PREFIX "")
target_link_libraries(obs-websocket obs-frontend-api)
set_target_properties(obs-websocket-compat PROPERTIES PREFIX "")
target_link_libraries(obs-websocket-compat obs-frontend-api)
file(GLOB locale_files data/locale/*.ini)
set(CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS
OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_WRITE GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE
)
if(${USE_UBUNTU_FIX})
install(TARGETS obs-websocket
LIBRARY DESTINATION "/usr/lib/obs-plugins")
install(TARGETS obs-websocket-compat LIBRARY
DESTINATION "/usr/lib/obs-plugins"
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
endif()
install(TARGETS obs-websocket
LIBRARY DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}/obs-plugins")
install(TARGETS obs-websocket-compat LIBRARY
DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}/obs-plugins"
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
install(FILES ${locale_files}
DESTINATION "${CMAKE_INSTALL_FULL_DATAROOTDIR}/obs/obs-plugins/obs-websocket/locale")
DESTINATION "${CMAKE_INSTALL_FULL_DATAROOTDIR}/obs/obs-plugins/obs-websocket-compat/locale")
endif()
# --- End of section ---
@ -204,7 +205,7 @@ if(APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ -fvisibility=default")
set(CMAKE_SKIP_RPATH TRUE)
set_target_properties(obs-websocket PROPERTIES PREFIX "")
target_link_libraries(obs-websocket "${OBS_FRONTEND_LIB}")
set_target_properties(obs-websocket-compat PROPERTIES PREFIX "")
target_link_libraries(obs-websocket-compat "${OBS_FRONTEND_LIB}")
endif()
# -- End of section --

82
CONTRIBUTING.md Normal file
View File

@ -0,0 +1,82 @@
# Contributing to obs-websocket
## Translating obs-websocket to your language
Localization happens on [Crowdin](https://crowdin.com/project/obs-websocket)
## Branches
**Development happens on `4.x-current`**
## Writing code for obs-websocket
### Code Formatting Guidelines
* Function and variable names: snake_case for C names, camelCase for C++ method names
* Request and Event names should use MixedCaps names
* Request and Event json properties should use camelCase. For more detailed info on property naming, see [Google's JSON Style Guide](https://google.github.io/styleguide/jsoncstyleguide.xml)
* Code is indented with Tabs. Assume they are 8 columns wide
* 80 columns max code width. (Docs can be larger)
* New and updated requests/events must always come with accompanying documentation comments (see existing protocol elements for examples).
These are required to automatically generate the [protocol specification document](docs/generated/protocol.md).
### Code Best-Practices
* Favor return-early code and avoid wrapping huge portions of code in conditionals. As an example, this:
```cpp
if (success) {
return req->SendOKResponse();
} else {
return req->SendErrorResponse("something went wrong");
}
```
is better like this:
```cpp
if (!success) {
return req->SendErrorResponse("something went wrong");
}
return req->SendOKResponse();
```
* Some example common response/request property names are:
* `sceneName` - The name of a scene
* `sourceName` - The name of a source
* `fromScene` - From a scene - scene name
### Commit Guidelines
* Commits follow the 50/72 standard:
* 50 characters max for the commit title (excluding scope name)
* One empty line after the title
* Description wrapped to 72 columns max width per line.
* Commit titles:
* Use present tense
* Prefix the title with a "scope" name
* e.g: "CI: fix wrong behaviour when packaging for OS X"
* Typical scopes: CI, General, Requests, Events, Server
**Example commit:**
```
Requests: Add GetTransitionPosition
Adds a new request called `GetTransitionPosition` which gets the current
transition's state from 0.0f to 1.0f. Works with both auto and manual
transitions.
```
### Pull Requests
* Pull Requests must never be based off your fork's main branch (in this case, `4.x-current`).
* Start your work in a newly named branch based on the upstream main one (e.g.: `feature/cool-new-feature`, `bugfix/fix-palakis-mistakes`, ...)
* Only open a pull request if you are ready to show off your work.
* If your work is not done yet, but for any reason you need to PR it (like collecting discussions, testing with CI, getting testers),
create it as a Draft Pull Request (open the little arrow menu next to the "Create pull request" button, then select "Create draft pull request").

143
README.md
View File

@ -1,19 +1,31 @@
obs-websocket
==============
# obs-websocket
WebSockets API for OBS Studio.
Follow the main author on Twitter for news & updates : [@LePalakis](https://twitter.com/LePalakis)
[![Build Status](https://dev.azure.com/Palakis/obs-websocket/_apis/build/status/Palakis.obs-websocket?branchName=4.x-current)](https://dev.azure.com/Palakis/obs-websocket/_build/latest?definitionId=2&branchName=4.x-current)
[![CodeFactor](https://www.codefactor.io/repository/github/palakis/obs-websocket/badge)](https://www.codefactor.io/repository/github/palakis/obs-websocket)
[![Twitter](https://img.shields.io/twitter/url/https/twitter.com/fold_left.svg?style=social&label=Follow%20%40LePalakis)](https://twitter.com/LePalakis)
[![Discord](https://img.shields.io/discord/715691013825364120.svg?label=&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2)](https://discord.gg/WBaSQ3A)
[![Financial Contributors on Open Collective](https://opencollective.com/obs-websocket/all/badge.svg?label=financial+contributors)](https://opencollective.com/obs-websocket)
## Downloads
Binaries for Windows, MacOS, and Linux are available in the [Releases](https://github.com/Palakis/obs-websocket/releases) section.
### Homebrew
If you're using MacOS you can use Homebrew for installation as well:
```sh
brew install obs-websocket
```
## Using obs-websocket
A web client and frontend made by [t2t2](https://github.com/t2t2/obs-tablet-remote) (compatible with tablets and other touch interfaces) is available here : http://t2t2.github.io/obs-tablet-remote/
Here is a list of available web clients: (compatible with tablets and other touch interfaces)
- [Niek/obs-web](https://github.com/Niek/obs-web)
- [t2t2/obs-tablet-remote](https://github.com/t2t2/obs-tablet-remote)
It is **highly recommended** to protect obs-websocket with a password against unauthorized control. To do this, open the "Websocket server settings" dialog under OBS' "Tools" menu. In the settings dialogs, you can enable or disable authentication and set a password for it.
@ -33,12 +45,24 @@ Here's a list of available language APIs for obs-websocket :
- C#/VB.NET: [obs-websocket-dotnet](https://github.com/Palakis/obs-websocket-dotnet)
- Python 2 and 3: [obs-websocket-py](https://github.com/Elektordi/obs-websocket-py) by Guillaume Genty a.k.a Elektordi
- Python 3.5+ with asyncio: [obs-ws-rc](https://github.com/KirillMysnik/obs-ws-rc) by Kirill Mysnik
- Python 3.6+ with asyncio: [simpleobsws](https://github.com/IRLToolkit/simpleobsws) by tt2468
- Python 3.6+ with asyncio: [simpleobsws](https://github.com/IRLToolkit/simpleobsws) by tt2468
- Java 8+: [obs-websocket-java](https://github.com/Twasi/websocket-obs-java) by TwasiNET
- Golang: [go-obs-websocket](https://github.com/christopher-dG/go-obs-websocket) by Chris de Graaf
- Java 11+: [obs-java-client](https://github.com/harm27/obs-java-client) by harm27
- Go: [go-obs-websocket](https://github.com/christopher-dG/go-obs-websocket) by Chris de Graaf
- Go: [goobs](https://github.com/andreykaipov/goobs) by Andrey Kaipov
- Rust: [obws](https://github.com/dnaka91/obws) by dnaka91
- Dart: [obs_websocket](https://pub.dev/packages/obs_websocket) by faithoflifedev
- HTTP API: [obs-websocket-http](https://github.com/IRLToolkit/obs-websocket-http) by tt2468
- CLI: [obs-cli](https://github.com/leafac/obs-cli) by leafac
- Godot: [obs-websocket-gd](https://github.com/you-win/obs-websocket-gd) by you-win
I'd like to know what you're building with or for obs-websocket. If you do something in this fashion, feel free to drop me an email at `stephane /dot/ lepin /at/ gmail /dot/ com` !
I'd like to know what you're building with or for obs-websocket. If you do something in this fashion, feel free to drop a message in `#project-showoff` in the [discord server!](https://discord.gg/WBaSQ3A)
### Securing obs-websocket (via TLS/SSL)
If you are intending to use obs-websocket outside of a LAN environment, it is highly recommended to secure the connection using a tunneling service.
See the SSL [tunnelling guide](SSL-TUNNELLING.md) for easy instructions on how to encrypt your websocket connection.
## Compiling obs-websocket
@ -46,89 +70,62 @@ See the [build instructions](BUILDING.md).
## Contributing
### Branches
Development happens on `4.x-current`
### Pull Requests
Pull Requests must never be based off your fork's main branch (in this case, `4.x-current`). Start your work in a new branch
based on the main one (e.g.: `cool-new-feature`, `fix-palakis-mistakes`, ...) and open a Pull Request once you feel ready to show your work.
**If your Pull Request is not ready to merge yet, create it as a Draft Pull Request** (open the little arrow menu next to the "Create pull request" button, then select "Create draft pull request").
### Code style & formatting
Source code is indented with tabs, with spaces allowed for alignment.
Regarding protocol changes: new and updated request types / events must always come with accompanying documentation comments (see existing protocol elements for examples).
These are required to automatically generate the [protocol specification document](docs/generated/protocol.md).
Among other recommendations: favor return-early code and avoid wrapping huge portions of code in conditionals. As an example, this:
```cpp
if (success) {
return req->SendOKResponse();
} else {
return req->SendErrorResponse("something went wrong");
}
```
is better like this:
```cpp
if (!success) {
return req->SendErrorResponse("something went wrong");
}
return req->SendOKResponse();
```
See [the contributing document](/CONTRIBUTING.md)
## Translations
**Your help is welcome on translations**. Please join the localization project on Crowdin: https://crowdin.com/project/obs-websocket
**Your help is welcome on translations.**
Please join the localization project on [Crowdin](https://crowdin.com/project/obs-websocket)
## Special thanks
In (almost) order of appearance:
- [Brendan H.](https://github.com/haganbmj): Code contributions and gooder English in the Protocol specification
- [Mikhail Swift](https://github.com/mikhailswift): Code contributions
- [Tobias Frahmer](https://github.com/Frahmer): Initial German localization
- [Genture](https://github.com/Genteure): Initial Simplified Chinese and Traditional Chinese localizations
- [Larissa Gabilan](https://github.com/laris151): Initial Portuguese localization
- [Andy Asquelt](https://github.com/asquelt): Initial Polish localization
- [Marcel Haazen](https://github.com/nekocentral): Initial Dutch localization
- [Peter Antonvich](https://github.com/pantonvich): Code contributions
- [yinzara](https://github.com/yinzara): Code contributions
- [Chris Angelico](https://github.com/Rosuav): Code contributions
- [Guillaume "Elektordi" Genty](https://github.com/Elektordi): Code contributions
- [Marwin M](https://github.com/dragonbane0): Code contributions
- [Logan S.](https://github.com/lsdaniel): Code contributions
- [RainbowEK](https://github.com/RainbowEK): Code contributions
- [RytoEX](https://github.com/RytoEX): CI script and code contributions
- [Theodore Stoddard](https://github.com/TStod): Code contributions
- [Philip Loche](https://github.com/PicoCentauri): Code contributions
- [Patrick Heyer](https://github.com/PatTheMav): Code contributions and CI fixes
- [Alex Van Camp](https://github.com/Lange): Code contributions
- [Freddie Meyer](https://github.com/DungFu): Code contributions
- [Casey Muller](https://github.com/caseymrm): CI fixes
- [Chris Angelico](https://github.com/Rosuav): Documentation fixes
Thank you so much to all of the contibutors [(here)](https://github.com/Palakis/obs-websocket/graphs/contributors) for your amazing help.
And also: special thanks to supporters of the project!
## Supporters
They have contributed financially to the project and made possible the addition of several features into obs-websocket. Many thanks to them!
These supporters have contributed financially to the project and made possible the addition of several features into obs-websocket. Many thanks to them!
---
[Support Class](http://supportclass.net) designs and develops professional livestreams, with services ranging from broadcast graphics design and integration to event organization, along many other skills.
[Support Class](http://supportclass.net) designs and develops professional livestreams, with services ranging from broadcast graphics design and integration to event organization, along many other skills.
[![Support Class](.github/images/supportclass_logo_blacktext.png)](http://supportclass.net)
---
[MediaUnit](http://www.mediaunit.no) is a Norwegian media company developing products and services for the media industry, primarly focused on web and events.
[MediaUnit](http://www.mediaunit.no) is a Norwegian media company developing products and services for the media industry, primarly focused on web and events.
[![MediaUnit](.github/images/mediaunit_logo_black.png)](http://www.mediaunit.no/)
## Contributors
### Code Contributors
This project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)].
<a href="https://github.com/Palakis/obs-websocket/graphs/contributors"><img src="https://opencollective.com/obs-websocket/contributors.svg?width=890&button=false" /></a>
### Financial Contributors
Become a financial contributor and help us sustain our community. [[Contribute](https://opencollective.com/obs-websocket/contribute)]
#### Individuals
<a href="https://opencollective.com/obs-websocket"><img src="https://opencollective.com/obs-websocket/individuals.svg?width=890"></a>
#### Organizations
Support this project with your organization. Your logo will show up here with a link to your website. [[Contribute](https://opencollective.com/obs-websocket/contribute)]
<a href="https://opencollective.com/obs-websocket/organization/0/website"><img src="https://opencollective.com/obs-websocket/organization/0/avatar.svg"></a>
<a href="https://opencollective.com/obs-websocket/organization/1/website"><img src="https://opencollective.com/obs-websocket/organization/1/avatar.svg"></a>
<a href="https://opencollective.com/obs-websocket/organization/2/website"><img src="https://opencollective.com/obs-websocket/organization/2/avatar.svg"></a>
<a href="https://opencollective.com/obs-websocket/organization/3/website"><img src="https://opencollective.com/obs-websocket/organization/3/avatar.svg"></a>
<a href="https://opencollective.com/obs-websocket/organization/4/website"><img src="https://opencollective.com/obs-websocket/organization/4/avatar.svg"></a>
<a href="https://opencollective.com/obs-websocket/organization/5/website"><img src="https://opencollective.com/obs-websocket/organization/5/avatar.svg"></a>
<a href="https://opencollective.com/obs-websocket/organization/6/website"><img src="https://opencollective.com/obs-websocket/organization/6/avatar.svg"></a>
<a href="https://opencollective.com/obs-websocket/organization/7/website"><img src="https://opencollective.com/obs-websocket/organization/7/avatar.svg"></a>
<a href="https://opencollective.com/obs-websocket/organization/8/website"><img src="https://opencollective.com/obs-websocket/organization/8/avatar.svg"></a>
<a href="https://opencollective.com/obs-websocket/organization/9/website"><img src="https://opencollective.com/obs-websocket/organization/9/avatar.svg"></a>

45
SSL-TUNNELLING.md Normal file
View File

@ -0,0 +1,45 @@
# Connecting over a TLS/secure connection (or remotely)
If you want to expose the WebSocket server of obs-websocket over a secure TLS connection (or to connect remotely), the easiest approach is to use a localhost tunneling service like [ngrok](https://ngrok.com/) or [pagekite](https://pagekite.net/).
**Before doing this, secure the WebSocket server first by enabling authentication with a strong password!**
**Please bear in mind that doing this will expose your OBS instance to the open Internet and the security risks it implies. *You've been warned!***
## ngrok
[Install the ngrok CLI tool](https://ngrok.com/download) on a linux OS, then start ngrok bound to port 4444 like this:
```bash
ngrok http 4444
```
The ngrok command will output something like this:
```text
ngrok by @inconshreveable
Tunnel Status online
Version 2.0/2.0
Web Interface http://127.0.0.1:4040
Forwarding http://TUNNEL_ID.ngrok.io -> localhost:4444
Forwarding https://TUNNEL_ID.ngrok.io -> localhost:4444
```
Where `TUNNEL_ID` is, as the name implies, the unique name of your ngrok tunnel. You'll get a new one every time you start ngrok.
Then, use `wss://TUNNEL_ID.ngrok.io` to connect to obs-websocket over TLS.
See the [ngrok documentation](https://ngrok.com/docs) for more tunneling options and settings.
## PageKite
[Install the PageKite CLI tool](http://pagekite.net/downloads), then start PageKite bound to port 4444 like this (replace NAME with one of your choosing):
```bash
python pagekite.py 4444 NAME.pagekite.me
```
Then, use `wss://NAME.pagekite.me` to connect to obs-websocket over TLS.

View File

@ -4,7 +4,8 @@ variables:
trigger:
branches:
include:
- master
- '4.x-current'
- '4.x-compat'
tags:
include:
- '*'
@ -33,84 +34,95 @@ jobs:
vmImage: 'windows-2019'
variables:
build_config: RelWithDebInfo
DepsBasePath: 'D:\obsdependencies'
DepsPath32: '$(DepsBasePath)\win32'
DepsPath64: '$(DepsBasePath)\win64'
QtBaseDir: 'D:\QtDep'
QTDIR32: '$(QtBaseDir)\5.10.1\msvc2017'
QTDIR64: '$(QtBaseDir)\5.10.1\msvc2017_64'
OBSPath: 'D:\obs-studio'
DEPS_CACHE_VERSION: '1' # Change whenever updating OBS dependencies URL, in order to force a cache reset
DEPS_BASE_PATH: 'D:\obsdependencies'
DEPS_PATH_32: '$(DEPS_BASE_PATH)\win32'
DEPS_PATH_64: '$(DEPS_BASE_PATH)\win64'
QT_CACHE_VERSION: '1' # Change whenever updating Qt dependency URL, in order to force a cache reset
QT_BASE_DIR: 'D:\QtDep'
QTDIR32: '$(QT_BASE_DIR)\5.15.2\msvc2019'
QTDIR64: '$(QT_BASE_DIR)\5.15.2\msvc2019_64'
OBS_CACHE_VERSION: '1'
OBS_PATH: 'D:\obs-studio'
steps:
- checkout: self
submodules: true
- script: ./CI/install-qt-win.cmd
- task: Cache@2
displayName: Restore cached Qt archive file
inputs:
key: 'qtdep-"$(QT_CACHE_VERSION)" | "$(Agent.OS)"'
restoreKeys: |
qtdep-"$(QT_CACHE_VERSION)" | "$(Agent.OS)"
path: $(QT_BASE_DIR)
- script: ./CI/windows/install-qt-win.cmd
displayName: 'Install Qt'
env:
QtBaseDir: $(QtBaseDir)
QT_BASE_DIR: $(QT_BASE_DIR)
- task: Cache@2
displayName: Restore cached OBS Studio dependencies
inputs:
key: 'obsdeps | "$(Agent.OS)"'
key: 'obsdeps-"$(DEPS_CACHE_VERSION)" | "$(Agent.OS)"'
restoreKeys: |
obsdeps | "$(Agent.OS)"
path: $(DepsBasePath)
obsdeps-"$(DEPS_CACHE_VERSION)" | "$(Agent.OS)"
path: $(DEPS_BASE_PATH)
- script: ./CI/download-obs-deps.cmd
- script: ./CI/windows/download-obs-deps.cmd
displayName: 'Download OBS Studio dependencies'
- task: Cache@2
displayName: Restore cached OBS Studio builds
inputs:
key: 'obs | "$(Agent.OS)"'
key: 'obs-"$(OBS_CACHE_VERSION)" | "$(Agent.OS)"'
restoreKeys: |
obs | "$(Agent.OS)"
path: $(OBSPath)
obs-"$(OBS_CACHE_VERSION)" | "$(Agent.OS)"
path: $(OBS_PATH)
- script: ./CI/prepare-obs-windows.cmd
- script: ./CI/windows/prepare-obs-windows.cmd
displayName: 'Checkout & CMake OBS Studio'
env:
build_config: $(build_config)
DepsPath32: $(DepsPath32)
DepsPath64: $(DepsPath64)
DEPS_PATH_32: $(DEPS_PATH_32)
DEPS_PATH_64: $(DEPS_PATH_64)
QTDIR32: $(QTDIR32)
QTDIR64: $(QTDIR64)
OBSPath: $(OBSPath)
OBS_PATH: $(OBS_PATH)
- task: MSBuild@1
displayName: 'Build OBS Studio 32-bit'
inputs:
msbuildArguments: '/m /p:Configuration=$(build_config)'
solution: '$(OBSPath)\build32\obs-studio.sln'
solution: '$(OBS_PATH)\build32\obs-studio.sln'
- task: MSBuild@1
displayName: 'Build OBS Studio 64-bit'
inputs:
msbuildArguments: '/m /p:Configuration=$(build_config)'
solution: '$(OBSPath)\build64\obs-studio.sln'
solution: '$(OBS_PATH)\build64\obs-studio.sln'
- script: ./CI/prepare-windows.cmd
- script: ./CI/windows/prepare-plugin-windows.cmd
displayName: 'CMake obs-websocket'
env:
build_config: $(build_config)
QTDIR32: $(QTDIR32)
QTDIR64: $(QTDIR64)
OBSPath: $(OBSPath)
OBS_PATH: $(OBS_PATH)
- task: MSBuild@1
displayName: 'Build obs-websocket 32-bit'
inputs:
msbuildArguments: '/m /p:Configuration=$(build_config)'
solution: '.\build32\obs-websocket.sln'
solution: '.\build32\obs-websocket-compat.sln'
- task: MSBuild@1
displayName: 'Build obs-websocket 64-bit'
inputs:
msbuildArguments: '/m /p:Configuration=$(build_config)'
solution: '.\build64\obs-websocket.sln'
solution: '.\build64\obs-websocket-compat.sln'
- script: ./CI/package-windows.cmd
- script: ./CI/windows/package-plugin-windows.cmd
displayName: 'Package obs-websocket'
- task: PublishBuildArtifacts@1
@ -121,22 +133,21 @@ jobs:
- job: 'Build_Linux'
pool:
vmImage: 'ubuntu-18.04'
vmImage: 'ubuntu-20.04'
variables:
BUILD_REASON: $(Build.Reason)
BRANCH_SHORT_NAME: $(Build.SourceBranchName)
BRANCH_FULL_NAME: $(Build.SourceBranch)
steps:
- checkout: self
submodules: true
- script: ./CI/install-dependencies-ubuntu.sh
- script: ./CI/linux/install-dependencies-ubuntu.sh
displayName: 'Install dependencies'
- script: ./CI/build-ubuntu.sh
- script: ./CI/linux/build-plugin-ubuntu.sh
displayName: 'Build obs-websocket'
- script: ./CI/package-ubuntu.sh
- script: ./CI/linux/package-plugin-ubuntu.sh
displayName: 'Package obs-websocket'
- task: PublishBuildArtifacts@1
@ -146,28 +157,34 @@ jobs:
- job: 'Build_macOS'
pool:
vmImage: 'macos-10.14'
vmImage: 'macOS-10.15'
variables:
OBS_DEPS_VERSION: '2020-12-22'
QT_VERSION: '5.15.2'
steps:
- checkout: self
submodules: true
- script: ./CI/install-dependencies-macos.sh
- script: ./CI/macos/install-dependencies-macos.sh
displayName: 'Install dependencies'
env:
OBS_DEPS_VERSION: $(OBS_DEPS_VERSION)
QT_VERSION: $(QT_VERSION)
- script: ./CI/install-build-obs-macos.sh
- script: ./CI/macos/install-build-obs-macos.sh
displayName: 'Build OBS'
- script: ./CI/build-macos.sh
- script: ./CI/macos/build-plugin-macos.sh
displayName: 'Build obs-websocket'
- task: InstallAppleCertificate@1
- task: InstallAppleCertificate@2
displayName: 'Install release signing certificates'
condition: eq(variables['isReleaseMode'], true)
inputs:
certSecureFile: 'Certificates.p12'
certPwd: $(secrets.macOS.certificatesImportPassword)
- script: ./CI/package-macos.sh
- script: ./CI/macos/package-plugin-macos.sh
displayName: 'Package obs-websocket'
env:
RELEASE_MODE: $(isReleaseMode)

View File

View File

@ -1,16 +0,0 @@
OBSWebsocket.Settings.DialogTitle="WebSockets-Servereinstellungen"
OBSWebsocket.Settings.ServerEnable="WebSockets-Server aktivieren"
OBSWebsocket.Settings.ServerPort="Server-Port"
OBSWebsocket.Settings.AuthRequired="Authentifizierung aktivieren"
OBSWebsocket.Settings.Password="Passwort"
OBSWebsocket.Settings.DebugEnable="Debug-Protokollierung aktivieren"
OBSWebsocket.Settings.AlertsEnable="Infobereichbenachrichtigungen aktivieren"
OBSWebsocket.NotifyConnect.Title="Neue Websocket-Verbindung"
OBSWebsocket.NotifyConnect.Message="Client %1 verbunden"
OBSWebsocket.NotifyDisconnect.Title="Websocket-Client getrennt"
OBSWebsocket.NotifyDisconnect.Message="Client %1 getrennt"
OBSWebsocket.Server.StartFailed.Title="Websocket-Serverfehler"
OBSWebsocket.Server.StartFailed.Message="Der WebSockets-Server konnte nicht gestartet werden, mögliche Gründe:\n - Der TCP-Port %1 wird möglicherweise gerade von einem anderen Programm verwendet. Versuchen Sie einen anderen Port in den Websocket-Servereinstellungen zu setzen oder alle Programme zu beenden, die den Port möglicherweise verwenden.\n - Ein unbekannter Netzwerkfehler ist aufgetreten. Versuchen Sie es mit anderen Einstellungen, einem OBS-Neustart oder einem Systemneustart erneut."
OBSWebsocket.ProfileChanged.Started="WebSockets-Server in diesem Profil aktiviert. Server gestartet."
OBSWebsocket.ProfileChanged.Stopped="WebSockets-Server in diesem Profil deaktiviert. Server gestoppt."
OBSWebsocket.ProfileChanged.Restarted="WebSockets-Server in diesem Profil geändert. Server startet neu."

View File

@ -1,16 +1,21 @@
OBSWebsocket.Settings.DialogTitle="WebSockets Server Settings"
OBSWebsocket.Settings.ServerEnable="Enable WebSockets server"
OBSWebsocket.Settings.ServerPort="Server Port"
OBSWebsocket.Settings.AuthRequired="Enable authentication"
OBSWebsocket.Settings.Password="Password"
OBSWebsocket.Settings.DebugEnable="Enable debug logging"
OBSWebsocket.Settings.AlertsEnable="Enable System Tray Alerts"
OBSWebsocket.NotifyConnect.Title="New WebSocket connection"
OBSWebsocket.NotifyConnect.Message="Client %1 connected"
OBSWebsocket.NotifyDisconnect.Title="WebSocket client disconnected"
OBSWebsocket.NotifyDisconnect.Message="Client %1 disconnected"
OBSWebsocket.Server.StartFailed.Title="WebSockets Server failure"
OBSWebsocket.Server.StartFailed.Message="The WebSockets server failed to start, maybe because:\n - TCP port %1 may currently be in use elsewhere on this system, possibly by another application. Try setting a different TCP port in the WebSocket server settings, or stop any application that could be using this port.\n - Error message: %2"
OBSWebsocket.ProfileChanged.Started="WebSockets server enabled in this profile. Server started."
OBSWebsocket.ProfileChanged.Stopped="WebSockets server disabled in this profile. Server stopped."
OBSWebsocket.ProfileChanged.Restarted="WebSockets server port changed in this profile. Server restarted."
OBSWebsocketCompat.Settings.DialogTitle="WebSockets Server Settings (4.x Compat)"
OBSWebsocketCompat.Settings.ServerEnable="Enable WebSockets server"
OBSWebsocketCompat.Settings.ServerPort="Server Port"
OBSWebsocketCompat.Settings.AuthRequired="Enable authentication"
OBSWebsocketCompat.Settings.Password="Password"
OBSWebsocketCompat.Settings.LockToIPv4="Lock server to only using IPv4"
OBSWebsocketCompat.Settings.DebugEnable="Enable debug logging"
OBSWebsocketCompat.Settings.AlertsEnable="Enable System Tray Alerts"
OBSWebsocketCompat.Settings.AuthDisabledWarning="Running obs-websocket with authentication disabled is not recommended, as it allows attackers to easily collect sensetive data. Are you sure you want to proceed?"
OBSWebsocketCompat.NotifyConnect.Title="New WebSocket connection"
OBSWebsocketCompat.NotifyConnect.Message="Client %1 connected"
OBSWebsocketCompat.NotifyDisconnect.Title="WebSocket client disconnected"
OBSWebsocketCompat.NotifyDisconnect.Message="Client %1 disconnected"
OBSWebsocketCompat.Server.StartFailed.Title="WebSockets Server failure"
OBSWebsocketCompat.Server.StartFailed.Message="The WebSockets compat server failed to start, maybe because:\n - TCP port %1 may currently be in use by the main obs-websocket plugin. Try setting a different TCP port in the obs-websocket Server Settings, or stop any application that could be using this port.\n - Error message: %2"
OBSWebsocketCompat.ProfileChanged.Started="WebSockets server enabled in this profile. Server started."
OBSWebsocketCompat.ProfileChanged.Stopped="WebSockets server disabled in this profile. Server stopped."
OBSWebsocketCompat.ProfileChanged.Restarted="WebSockets server port changed in this profile. Server restarted."
OBSWebsocketCompat.InitialPasswordSetup.Title="obs-websocket - Server Password Configuration"
OBSWebsocketCompat.InitialPasswordSetup.Text="It looks like you are running obs-websocket for the first time. Do you want to configure a password now for the WebSockets server? Setting a password is highly recommended."
OBSWebsocketCompat.InitialPasswordSetup.DismissedText="You can configure a server password later in the WebSockets Server Settings. (Under the Tools menu of OBS Studio)"

View File

@ -1,12 +0,0 @@
OBSWebsocket.Settings.ServerEnable="Habilitar el servidor WebSockets"
OBSWebsocket.Settings.ServerPort="Puerto del Servidor"
OBSWebsocket.Settings.AuthRequired="Habilitar autenticación"
OBSWebsocket.Settings.Password="Contraseña"
OBSWebsocket.Settings.DebugEnable="Habilitar registro de depuración"
OBSWebsocket.Settings.AlertsEnable="Habilitar alertas en la bandeja de sistema"
OBSWebsocket.NotifyConnect.Title="Nueva conexión WebSocket"
OBSWebsocket.NotifyConnect.Message="Cliente %1 conectado"
OBSWebsocket.NotifyDisconnect.Title="Cliente WebSocket desconectado"
OBSWebsocket.NotifyDisconnect.Message="Cliente %1 desconectado"
OBSWebsocket.Server.StartFailed.Title="Falla en el servidor WebSockets"
OBSWebsocket.Server.StartFailed.Message="El servidor obs-websocket no se pudo iniciar, tal vez porque: \n - el puerto TCP %1 podría estar actualmente siendo usado este sistema, posiblemente por otra aplicación. Intente configurar un puerto TCP diferente en la configuración del servidor WebSocket, o detenga cualquier aplicación que pudiese estar utilizando este puerto \n - Un error de red desconocido ha afectado su sistema. Inténtelo de nuevo cambiando la configuración, reiniciando OBS o reiniciando su sistema."

View File

@ -1,16 +0,0 @@
OBSWebsocket.Settings.DialogTitle="Paramètres du serveur WebSockets"
OBSWebsocket.Settings.ServerEnable="Activer le serveur WebSocket"
OBSWebsocket.Settings.ServerPort="Port du serveur"
OBSWebsocket.Settings.AuthRequired="Activer l'authentification"
OBSWebsocket.Settings.Password="Mot de passe"
OBSWebsocket.Settings.DebugEnable="Débogage dans le fichier journal"
OBSWebsocket.Settings.AlertsEnable="Notifications de connexion/déconnexion"
OBSWebsocket.NotifyConnect.Title="Nouvelle connexion WebSocket"
OBSWebsocket.NotifyConnect.Message="Le client %1 s'est connecté"
OBSWebsocket.NotifyDisconnect.Title="Déconnexion WebSocket"
OBSWebsocket.NotifyDisconnect.Message="Le client %1 s'est déconnecté"
OBSWebsocket.Server.StartFailed.Title="Impossible de démarrer le serveur WebSockets"
OBSWebsocket.Server.StartFailed.Message="Le serveur WebSockets n'a pas pu démarrer, peut-être parce que :\n - Le port TCP %1 est en cours d'utilisation sur ce système, certainement par un autre programme. Essayez un port différent dans les réglages du serveur WebSocket, ou arrêtez tout programme susceptible d'utiliser ce port.\n - Une erreur réseau inconnue est survenue. Essayez à nouveau en modifiant vos réglages, en redémarrant OBS ou en redémarrant votre ordinateur."
OBSWebsocket.ProfileChanged.Started="Serveur WebSockets actif dans ce profil."
OBSWebsocket.ProfileChanged.Stopped="Serveur WebSockets désactivé dans ce profil."
OBSWebsocket.ProfileChanged.Restarted="Le port actuel diffère du port configuré dans ce profil. Serveur WebSockets redémarré."

View File

View File

@ -1,12 +0,0 @@
OBSWebsocket.Settings.ServerEnable="Abilitare il server WebSockets"
OBSWebsocket.Settings.ServerPort="Porta del server"
OBSWebsocket.Settings.AuthRequired="Abilitare l'autenticazione"
OBSWebsocket.Settings.Password="Password"
OBSWebsocket.Settings.DebugEnable="Attivare la registrazione di debug"
OBSWebsocket.Settings.AlertsEnable="Attivare gli avvisi di vassoio di sistema"
OBSWebsocket.NotifyConnect.Title="Nuova connessione WebSocket"
OBSWebsocket.NotifyConnect.Message="%1 cliente collegato"
OBSWebsocket.NotifyDisconnect.Title="WebSocket cliente disconnesso"
OBSWebsocket.NotifyDisconnect.Message="%1 cliente disconnesso"
OBSWebsocket.Server.StartFailed.Title="Errore del WebSocket Server"
OBSWebsocket.Server.StartFailed.Message="Impossibile avviare, forse perché il server di WebSockets: \n - %1 porta TCP potrebbe essere attualmente in uso altrove su questo sistema, possibilmente da un'altra applicazione. Provare a impostare una porta TCP diversa nelle impostazioni del server di WebSockets, o arrestare tutte le applicazioni che potrebbero utilizzare questa porta. \n - è verificato un errore di rete sconosciuto sul sistema. Riprova modificando le impostazioni, riavviare OBS o riavvio del sistema."

View File

@ -1,11 +0,0 @@
OBSWebsocket.Settings.ServerEnable="WebSockets サーバーを有効にする"
OBSWebsocket.Settings.ServerPort="サーバーポート"
OBSWebsocket.Settings.AuthRequired="認証を有効にする"
OBSWebsocket.Settings.Password="パスワード"
OBSWebsocket.Settings.DebugEnable="デバッグログを有効にする"
OBSWebsocket.Settings.AlertsEnable="システムトレイ通知を有効にする"
OBSWebsocket.NotifyConnect.Title="新しい WebSocket 接続"
OBSWebsocket.NotifyConnect.Message="接続されているクライアント %1"
OBSWebsocket.NotifyDisconnect.Title="WebSocket クライアントが切断されました"
OBSWebsocket.NotifyDisconnect.Message="切断されたクライアント %1"
OBSWebsocket.Server.StartFailed.Title="WebSockets サーバー障害"

View File

View File

@ -1,9 +0,0 @@
OBSWebsocket.Settings.ServerPort="Serverpoort"
OBSWebsocket.Settings.DebugEnable="Activeer debug logs"
OBSWebsocket.Settings.AlertsEnable="Systemvak waarschuwingen inschakelen"
OBSWebsocket.NotifyConnect.Title="Nieuwe WebSocket verbinding"
OBSWebsocket.NotifyConnect.Message="Client %1 verbonden"
OBSWebsocket.NotifyDisconnect.Title="WebSocket client connectie verbroken"
OBSWebsocket.NotifyDisconnect.Message="Client %1 losgekoppeld"
OBSWebsocket.Server.StartFailed.Title="Fout in WebSocket server"
OBSWebsocket.Server.StartFailed.Message="De obs-websocket server kan niet worden gestart, misschien omdat: \n - TCP-poort %1 momenteel elders wordt gebruikt op dit systeem, eventueel door een andere toepassing. Probeer een andere TCP-poort in te stellen in de WebSocket Server-instellingen of stop elke toepassing die deze poort zou kunnen gebruiken.\n Een onbekende Netwerkfout op uw systeem. Probeer het opnieuw door de instellingen te wijzigen, OBS te herstarten of uw systeem te herstarten."

View File

@ -1,10 +0,0 @@
OBSWebsocket.Settings.ServerEnable="Włącz serwer WebSockets"
OBSWebsocket.Settings.AuthRequired="Wymagaj uwierzytelniania"
OBSWebsocket.Settings.DebugEnable="Włącz rejestrowanie debugowania"
OBSWebsocket.Settings.AlertsEnable="Włącz powiadomienia w zasobniku systemowym"
OBSWebsocket.NotifyConnect.Title="Nowe połączenie WebSocket"
OBSWebsocket.NotifyConnect.Message="Klient %1 połączony"
OBSWebsocket.NotifyDisconnect.Title="Klient WebSocket odłączony"
OBSWebsocket.NotifyDisconnect.Message="Klient %1 rozłączony"
OBSWebsocket.Server.StartFailed.Title="Awaria serwera WebSockets"
OBSWebsocket.Server.StartFailed.Message="Nie udało się uruchomić serwera WebSockets, może a powodu: \n - TCP port %1 może być obecnie używany gdzie indziej w tym systemie, możliwie przez inną aplikację. Spróbuj ustawić inny port TCP w ustawieniach serwera WebSockets, lub zatrzymać dowolną aplikację, która może używać tego portu \n -nieznany błąd sieci wydarzył się w systemie. Spróbuj ponownie, zmieniając ustawienia, ponownie uruchamiając OBS lub ponownie uruchamiając system."

View File

@ -1,12 +0,0 @@
OBSWebsocket.Settings.ServerEnable="Habilitar servidor de WebSockets"
OBSWebsocket.Settings.ServerPort="Porta do Servidor"
OBSWebsocket.Settings.AuthRequired="Activar autenticação"
OBSWebsocket.Settings.Password="Palavra passe"
OBSWebsocket.Settings.DebugEnable="Habilitar registro de debug"
OBSWebsocket.Settings.AlertsEnable="Ativar Alertas da bandeja do sistema"
OBSWebsocket.NotifyConnect.Title="Nova conexão WebSocket"
OBSWebsocket.NotifyConnect.Message="Cliente %1 conectado"
OBSWebsocket.NotifyDisconnect.Title="WebSocket cliente desconectado"
OBSWebsocket.NotifyDisconnect.Message="Cliente %1 desconectado"
OBSWebsocket.Server.StartFailed.Title="Falha do servidor de WebSocket"
OBSWebsocket.Server.StartFailed.Message="O servidor de WebSockets falhou ao iniciar, talvez porque: \n - TCP port %1 pode estar atualmente em uso em outro lugar sobre este sistema, possivelmente por outro aplicativo. Tente definir uma porta TCP diferente nas configurações do servidor de WebSockets, ou parar qualquer aplicativo que poderia estar usando este porto \n - um erro de rede desconhecido aconteceu no seu sistema. Tente novamente alterar configurações, reiniciando OBS ou reiniciando o sistema."

View File

@ -1,13 +0,0 @@
OBSWebsocket.Settings.DialogTitle="Настройки сервера WebSockets"
OBSWebsocket.Settings.ServerEnable="Включить сервер WebSockets"
OBSWebsocket.Settings.ServerPort="Порт сервера"
OBSWebsocket.Settings.AuthRequired="Включить авторизацию"
OBSWebsocket.Settings.Password="Пароль"
OBSWebsocket.Settings.DebugEnable="Включить ведение журнала отладки"
OBSWebsocket.Settings.AlertsEnable="Включить оповещения в системном трее"
OBSWebsocket.NotifyConnect.Title="Новое соединение WebSocket"
OBSWebsocket.NotifyConnect.Message="Клиент %1 подключен"
OBSWebsocket.NotifyDisconnect.Title="Клиент WebSocket отключён"
OBSWebsocket.NotifyDisconnect.Message="Клиент %1 отключен"
OBSWebsocket.Server.StartFailed.Title="Сбой сервера WebSockets"
OBSWebsocket.Server.StartFailed.Message="Ошибка запуска сервера WebSockets. Вероятные причины:\n - Возможно, TCP-порт %1 занят другим приложением в системе. Попробуйте задать другой TCP-порт в настройках сервера WebSockets или закройте приложение, которое может использовать данный порт.\n - Произошла неизвестная сетевая ошибка в системе. Попробуйте снова после изменения настроек, перезапуска OBS или системы."

View File

@ -1,12 +0,0 @@
OBSWebsocket.Settings.ServerEnable="启用 WebSockets 服务器"
OBSWebsocket.Settings.ServerPort="服务器端口"
OBSWebsocket.Settings.AuthRequired="启用身份验证"
OBSWebsocket.Settings.Password="密码"
OBSWebsocket.Settings.DebugEnable="启用调试日志"
OBSWebsocket.Settings.AlertsEnable="启用系统托盘通知"
OBSWebsocket.NotifyConnect.Title="新 WebSocket 连接"
OBSWebsocket.NotifyConnect.Message="客户端 %1 已连接"
OBSWebsocket.NotifyDisconnect.Title="WebSocket 客户端已断开"
OBSWebsocket.NotifyDisconnect.Message="客户端 %1 已断开连接"
OBSWebsocket.Server.StartFailed.Title="WebSockets 服务器错误"
OBSWebsocket.Server.StartFailed.Message="WebSockets 服务器启动失败,可能是因为:\n - TCP 端口 %1 可能被本机的另一个应用程序占用。尝试在 WebSockets 服务器设置中设置不同的 TCP 端口,或关闭任何可能使用此端口的应用程序。\n - 在您的系统上发生了未知的网络错误。请尝试更改设置、重新启动 OBS 或重新启动系统。"

View File

@ -1,9 +0,0 @@
OBSWebsocket.Settings.ServerPort="伺服器連接埠"
OBSWebsocket.Settings.DebugEnable="啟用除錯日誌"
OBSWebsocket.Settings.AlertsEnable="啟用系統列通知"
OBSWebsocket.NotifyConnect.Title="新的 WebSocket 連線"
OBSWebsocket.NotifyConnect.Message="客戶端 %1 已連線"
OBSWebsocket.NotifyDisconnect.Title="WebSocket 客戶端已離線"
OBSWebsocket.NotifyDisconnect.Message="客戶端 %1 已離線"
OBSWebsocket.Server.StartFailed.Title="WebSocket 伺服器錯誤"
OBSWebsocket.Server.StartFailed.Message="WebSockets 伺服器啟動失敗,可能的原因有:\n - TCP 連接埠 %1 被系統的其他程式所使用,試著為 WebSockets 伺服器指定不同的 TCP 連接埠,或是關閉任何可能使用此連接埠的程式。\n - 發生的未知的網路錯誤,試著更改設定、重新啟動 OBS 或是重新啟動您的系統。"

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,10 +1,12 @@
# obs-websocket 4.8.0 protocol reference
# obs-websocket 4.9.1 protocol reference
# General Introduction
Messages are exchanged between the client and the server as JSON objects.
This protocol is based on the original OBS Remote protocol created by Bill Hamilton, with new commands specific to OBS Studio.
This protocol is based on the original OBS Remote protocol created by Bill Hamilton, with new commands specific to OBS Studio. As of v5.0.0, backwards compatability with the protocol will not be kept.
# Authentication
**Starting with obs-websocket 4.9, authentication is enabled by default and users are encouraged to configure a password on first run.**
`obs-websocket` uses SHA256 to transmit credentials.
A request for [`GetAuthRequired`](#getauthrequired) returns two elements:
@ -32,3 +34,5 @@ auth_response_string = secret + challenge
auth_response_hash = binary_sha256(auth_response_string)
auth_response = base64_encode(auth_response_hash)
```
You can also refer to any of the [client libraries](https://github.com/Palakis/obs-websocket#for-developers) listed on the README for examples of how to authenticate.

View File

@ -6,6 +6,6 @@ Requests are sent by the client and require at least the following two fields:
Once a request is sent, the server will return a JSON response with at least the following fields:
- `message-id` _String_: The client defined identifier specified in the request.
- `status` _String_: Response status, will be one of the following: `ok`, `error`
- `error` _String_: An error message accompanying an `error` status.
- `error` _String (Optional)_: An error message accompanying an `error` status.
Additional information may be required/returned depending on the request type. See below for more information.

View File

@ -2,7 +2,7 @@
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "obs-websocket"
#define MyAppVersion "4.8.0"
#define MyAppVersion "4.9.1-compat"
#define MyAppPublisher "Stephane Lepin"
#define MyAppURL "http://github.com/Palakis/obs-websocket"
@ -23,6 +23,7 @@ DefaultGroupName={#MyAppName}
OutputBaseFilename=obs-websocket-Windows-Installer
Compression=lzma
SolidCompression=yes
DirExistsWarning=no
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"

View File

@ -18,19 +18,26 @@ with this program. If not, see <https://www.gnu.org/licenses/>
#include <obs-frontend-api.h>
#include <QtCore/QObject>
#include <QtCore/QCryptographicHash>
#include <QtCore/QTime>
#include <QtWidgets/QSystemTrayIcon>
#include <QtWidgets/QMainWindow>
#include <QtWidgets/QInputDialog>
#include <QtWidgets/QMessageBox>
#define SECTION_NAME "WebsocketAPI"
#define PARAM_ENABLE "ServerEnabled"
#define PARAM_PORT "ServerPort"
#define PARAM_LOCKTOIPV4 "LockToIPv4"
#define PARAM_DEBUG "DebugEnabled"
#define PARAM_ALERT "AlertsEnabled"
#define PARAM_AUTHREQUIRED "AuthRequired"
#define PARAM_SECRET "AuthSecret"
#define PARAM_SALT "AuthSalt"
#define GLOBAL_AUTH_SETUP_PROMPTED "AuthSetupPrompted"
#include "Utils.h"
#include "WSServer.h"
@ -41,9 +48,10 @@ with this program. If not, see <https://www.gnu.org/licenses/>
Config::Config() :
ServerEnabled(true),
ServerPort(4444),
LockToIPv4(false),
DebugEnabled(false),
AlertsEnabled(true),
AuthRequired(false),
AuthRequired(true),
Secret(""),
Salt(""),
SettingsLoaded(false)
@ -67,6 +75,7 @@ void Config::Load()
ServerEnabled = config_get_bool(obsConfig, SECTION_NAME, PARAM_ENABLE);
ServerPort = config_get_uint(obsConfig, SECTION_NAME, PARAM_PORT);
LockToIPv4 = config_get_bool(obsConfig, SECTION_NAME, PARAM_LOCKTOIPV4);
DebugEnabled = config_get_bool(obsConfig, SECTION_NAME, PARAM_DEBUG);
AlertsEnabled = config_get_bool(obsConfig, SECTION_NAME, PARAM_ALERT);
@ -82,6 +91,7 @@ void Config::Save()
config_set_bool(obsConfig, SECTION_NAME, PARAM_ENABLE, ServerEnabled);
config_set_uint(obsConfig, SECTION_NAME, PARAM_PORT, ServerPort);
config_set_bool(obsConfig, SECTION_NAME, PARAM_LOCKTOIPV4, LockToIPv4);
config_set_bool(obsConfig, SECTION_NAME, PARAM_DEBUG, DebugEnabled);
config_set_bool(obsConfig, SECTION_NAME, PARAM_ALERT, AlertsEnabled);
@ -104,6 +114,8 @@ void Config::SetDefaults()
SECTION_NAME, PARAM_ENABLE, ServerEnabled);
config_set_default_uint(obsConfig,
SECTION_NAME, PARAM_PORT, ServerPort);
config_set_default_bool(obsConfig,
SECTION_NAME, PARAM_LOCKTOIPV4, LockToIPv4);
config_set_default_bool(obsConfig,
SECTION_NAME, PARAM_DEBUG, DebugEnabled);
@ -124,6 +136,70 @@ config_t* Config::GetConfigStore()
return obs_frontend_get_profile_config();
}
void Config::MigrateFromGlobalSettings()
{
config_t* source = obs_frontend_get_global_config();
config_t* destination = obs_frontend_get_profile_config();
if(config_has_user_value(source, SECTION_NAME, PARAM_ENABLE)) {
bool value = config_get_bool(source, SECTION_NAME, PARAM_ENABLE);
config_set_bool(destination, SECTION_NAME, PARAM_ENABLE, value);
config_remove_value(source, SECTION_NAME, PARAM_ENABLE);
}
if(config_has_user_value(source, SECTION_NAME, PARAM_PORT)) {
uint64_t value = config_get_uint(source, SECTION_NAME, PARAM_PORT);
config_set_uint(destination, SECTION_NAME, PARAM_PORT, value);
config_remove_value(source, SECTION_NAME, PARAM_PORT);
}
if(config_has_user_value(source, SECTION_NAME, PARAM_LOCKTOIPV4)) {
bool value = config_get_bool(source, SECTION_NAME, PARAM_LOCKTOIPV4);
config_set_bool(destination, SECTION_NAME, PARAM_LOCKTOIPV4, value);
config_remove_value(source, SECTION_NAME, PARAM_LOCKTOIPV4);
}
if(config_has_user_value(source, SECTION_NAME, PARAM_DEBUG)) {
bool value = config_get_bool(source, SECTION_NAME, PARAM_DEBUG);
config_set_bool(destination, SECTION_NAME, PARAM_DEBUG, value);
config_remove_value(source, SECTION_NAME, PARAM_DEBUG);
}
if(config_has_user_value(source, SECTION_NAME, PARAM_ALERT)) {
bool value = config_get_bool(source, SECTION_NAME, PARAM_ALERT);
config_set_bool(destination, SECTION_NAME, PARAM_ALERT, value);
config_remove_value(source, SECTION_NAME, PARAM_ALERT);
}
if(config_has_user_value(source, SECTION_NAME, PARAM_AUTHREQUIRED)) {
bool value = config_get_bool(source, SECTION_NAME, PARAM_AUTHREQUIRED);
config_set_bool(destination, SECTION_NAME, PARAM_AUTHREQUIRED, value);
config_remove_value(source, SECTION_NAME, PARAM_AUTHREQUIRED);
}
if(config_has_user_value(source, SECTION_NAME, PARAM_SECRET)) {
const char* value = config_get_string(source, SECTION_NAME, PARAM_SECRET);
config_set_string(destination, SECTION_NAME, PARAM_SECRET, value);
config_remove_value(source, SECTION_NAME, PARAM_SECRET);
}
if(config_has_user_value(source, SECTION_NAME, PARAM_SALT)) {
const char* value = config_get_string(source, SECTION_NAME, PARAM_SALT);
config_set_string(destination, SECTION_NAME, PARAM_SALT, value);
config_remove_value(source, SECTION_NAME, PARAM_SALT);
}
config_save(destination);
}
QString Config::GenerateSalt()
{
// Generate 32 random chars
@ -198,23 +274,24 @@ void Config::OnFrontendEvent(enum obs_frontend_event event, void* param)
if (event == OBS_FRONTEND_EVENT_PROFILE_CHANGED) {
obs_frontend_push_ui_translation(obs_module_get_string);
QString startMessage = QObject::tr("OBSWebsocket.ProfileChanged.Started");
QString stopMessage = QObject::tr("OBSWebsocket.ProfileChanged.Stopped");
QString restartMessage = QObject::tr("OBSWebsocket.ProfileChanged.Restarted");
QString startMessage = QObject::tr("OBSWebsocketCompat.ProfileChanged.Started");
QString stopMessage = QObject::tr("OBSWebsocketCompat.ProfileChanged.Stopped");
QString restartMessage = QObject::tr("OBSWebsocketCompat.ProfileChanged.Restarted");
obs_frontend_pop_ui_translation();
bool previousEnabled = config->ServerEnabled;
uint64_t previousPort = config->ServerPort;
bool previousLock = config->LockToIPv4;
config->SetDefaults();
config->Load();
if (config->ServerEnabled != previousEnabled || config->ServerPort != previousPort) {
if (config->ServerEnabled != previousEnabled || config->ServerPort != previousPort || config->LockToIPv4 != previousLock) {
auto server = GetServer();
server->stop();
if (config->ServerEnabled) {
server->start(config->ServerPort);
server->start(config->ServerPort, config->LockToIPv4);
if (previousEnabled != config->ServerEnabled) {
Utils::SysTrayNotify(startMessage, QSystemTrayIcon::MessageIcon::Information);
@ -226,61 +303,50 @@ void Config::OnFrontendEvent(enum obs_frontend_event event, void* param)
}
}
}
else if (event == OBS_FRONTEND_EVENT_FINISHED_LOADING) {
FirstRunPasswordSetup();
}
}
void Config::MigrateFromGlobalSettings()
void Config::FirstRunPasswordSetup()
{
config_t* source = obs_frontend_get_global_config();
config_t* destination = obs_frontend_get_profile_config();
if(config_has_user_value(source, SECTION_NAME, PARAM_ENABLE)) {
bool value = config_get_bool(source, SECTION_NAME, PARAM_ENABLE);
config_set_bool(destination, SECTION_NAME, PARAM_ENABLE, value);
config_remove_value(source, SECTION_NAME, PARAM_ENABLE);
// check if we already showed the auth setup prompt to the user, independently of the current settings (tied to the current profile)
config_t* globalConfig = obs_frontend_get_global_config();
bool alreadyPrompted = config_get_bool(globalConfig, SECTION_NAME, GLOBAL_AUTH_SETUP_PROMPTED);
if (alreadyPrompted) {
return;
}
if(config_has_user_value(source, SECTION_NAME, PARAM_PORT)) {
uint64_t value = config_get_uint(source, SECTION_NAME, PARAM_PORT);
config_set_uint(destination, SECTION_NAME, PARAM_PORT, value);
// lift the flag up and save it
config_set_bool(globalConfig, SECTION_NAME, GLOBAL_AUTH_SETUP_PROMPTED, true);
config_save(globalConfig);
config_remove_value(source, SECTION_NAME, PARAM_PORT);
// check if the password is already set
auto config = GetConfig();
if (!config) {
return;
}
if(config_has_user_value(source, SECTION_NAME, PARAM_DEBUG)) {
bool value = config_get_bool(source, SECTION_NAME, PARAM_DEBUG);
config_set_bool(destination, SECTION_NAME, PARAM_DEBUG, value);
config_remove_value(source, SECTION_NAME, PARAM_DEBUG);
if (!(config->Secret.isEmpty()) && !(config->Salt.isEmpty())) {
return;
}
if(config_has_user_value(source, SECTION_NAME, PARAM_ALERT)) {
bool value = config_get_bool(source, SECTION_NAME, PARAM_ALERT);
config_set_bool(destination, SECTION_NAME, PARAM_ALERT, value);
obs_frontend_push_ui_translation(obs_module_get_string);
QString dialogTitle = QObject::tr("OBSWebsocketCompat.InitialPasswordSetup.Title");
QString dialogText = QObject::tr("OBSWebsocketCompat.InitialPasswordSetup.Text");
QString dismissedText = QObject::tr("OBSWebsocketCompat.InitialPasswordSetup.DismissedText");
obs_frontend_pop_ui_translation();
config_remove_value(source, SECTION_NAME, PARAM_ALERT);
auto mainWindow = reinterpret_cast<QMainWindow*>(
obs_frontend_get_main_window()
);
QMessageBox::StandardButton response = QMessageBox::question(mainWindow, dialogTitle, dialogText);
if (response == QMessageBox::Yes) {
ShowPasswordSetting();
}
if(config_has_user_value(source, SECTION_NAME, PARAM_AUTHREQUIRED)) {
bool value = config_get_bool(source, SECTION_NAME, PARAM_AUTHREQUIRED);
config_set_bool(destination, SECTION_NAME, PARAM_AUTHREQUIRED, value);
config_remove_value(source, SECTION_NAME, PARAM_AUTHREQUIRED);
else {
// tell the user they still can set the password later in our settings dialog
QMessageBox::information(mainWindow, dialogTitle, dismissedText);
}
if(config_has_user_value(source, SECTION_NAME, PARAM_SECRET)) {
const char* value = config_get_string(source, SECTION_NAME, PARAM_SECRET);
config_set_string(destination, SECTION_NAME, PARAM_SECRET, value);
config_remove_value(source, SECTION_NAME, PARAM_SECRET);
}
if(config_has_user_value(source, SECTION_NAME, PARAM_SALT)) {
const char* value = config_get_string(source, SECTION_NAME, PARAM_SALT);
config_set_string(destination, SECTION_NAME, PARAM_SALT, value);
config_remove_value(source, SECTION_NAME, PARAM_SALT);
}
config_save(destination);
}

View File

@ -42,6 +42,7 @@ class Config {
bool ServerEnabled;
uint64_t ServerPort;
bool LockToIPv4;
bool DebugEnabled;
bool AlertsEnabled;
@ -54,4 +55,5 @@ class Config {
private:
static void OnFrontendEvent(enum obs_frontend_event event, void* param);
static void FirstRunPasswordSetup();
};

View File

@ -19,16 +19,16 @@ with this program. If not, see <https://www.gnu.org/licenses/>
#include "ConnectionProperties.h"
ConnectionProperties::ConnectionProperties()
: _authenticated(false)
: _authenticated(false)
{
}
bool ConnectionProperties::isAuthenticated()
{
return _authenticated.load();
return _authenticated.load();
}
void ConnectionProperties::setAuthenticated(bool authenticated)
{
_authenticated.store(authenticated);
_authenticated.store(authenticated);
}

View File

@ -23,9 +23,9 @@ with this program. If not, see <https://www.gnu.org/licenses/>
class ConnectionProperties
{
public:
explicit ConnectionProperties();
bool isAuthenticated();
void setAuthenticated(bool authenticated);
explicit ConnectionProperties();
bool isAuthenticated();
void setAuthenticated(bool authenticated);
private:
std::atomic<bool> _authenticated;
std::atomic<bool> _authenticated;
};

View File

@ -24,6 +24,7 @@ with this program. If not, see <https://www.gnu.org/licenses/>
#include <obs-frontend-api.h>
#include <obs.hpp>
#include <util/platform.h>
#include <obs-data.h>
#include "obs-websocket.h"
@ -51,6 +52,43 @@ obs_bounds_type getBoundsTypeFromName(QString name) {
return boundTypeNames.key(name);
}
const QHash<obs_scale_type, QString> scaleTypeNames = {
{ OBS_SCALE_DISABLE, "OBS_SCALE_DISABLE" },
{ OBS_SCALE_POINT, "OBS_SCALE_POINT" },
{ OBS_SCALE_BICUBIC, "OBS_SCALE_BICUBIC" },
{ OBS_SCALE_BILINEAR, "OBS_SCALE_BILINEAR" },
{ OBS_SCALE_LANCZOS, "OBS_SCALE_LANCZOS" },
{ OBS_SCALE_AREA, "OBS_SCALE_AREA" },
};
QString getScaleNameFromType(obs_scale_type type) {
QString fallback = scaleTypeNames.value(OBS_SCALE_DISABLE);
return scaleTypeNames.value(type, fallback);
}
obs_scale_type getFilterTypeFromName(QString name) {
return scaleTypeNames.key(name);
}
bool Utils::StringInStringList(char** strings, const char* string) {
if (!strings) {
return false;
}
size_t index = 0;
while (strings[index] != NULL) {
char* value = strings[index];
if (strcmp(value, string) == 0) {
return true;
}
index++;
}
return false;
}
obs_data_array_t* Utils::StringListToArray(char** strings, const char* key) {
obs_data_array_t* list = obs_data_array_create();
@ -340,8 +378,7 @@ obs_source_t* Utils::GetTransitionFromName(QString searchName) {
QString transitionName = obs_source_get_name(transition);
if (transitionName == searchName) {
foundTransition = transition;
obs_source_addref(foundTransition);
foundTransition = obs_source_get_ref(transition);
break;
}
}
@ -485,16 +522,13 @@ QString Utils::OBSVersionString() {
}
QSystemTrayIcon* Utils::GetTrayIcon() {
QMainWindow* main = (QMainWindow*)obs_frontend_get_main_window();
if (!main) return nullptr;
QList<QSystemTrayIcon*> trays = main->findChildren<QSystemTrayIcon*>();
return trays.isEmpty() ? nullptr : trays.first();
void* systemTray = obs_frontend_get_system_tray();
return reinterpret_cast<QSystemTrayIcon*>(systemTray);
}
void Utils::SysTrayNotify(QString text,
QSystemTrayIcon::MessageIcon icon, QString title) {
if (!GetConfig()->AlertsEnabled ||
void Utils::SysTrayNotify(QString text, QSystemTrayIcon::MessageIcon icon, QString title) {
auto config = GetConfig();
if ((config && !config->AlertsEnabled) ||
!QSystemTrayIcon::isSystemTrayAvailable() ||
!QSystemTrayIcon::supportsMessages())
{
@ -680,16 +714,40 @@ bool Utils::SetFilenameFormatting(const char* filenameFormatting) {
return true;
}
const char* Utils::GetCurrentRecordingFilename()
{
OBSOutputAutoRelease recordingOutput = obs_frontend_get_recording_output();
if (!recordingOutput) {
return nullptr;
}
OBSDataAutoRelease settings = obs_output_get_settings(recordingOutput);
// mimicks the behavior of BasicOutputHandler::GetRecordingFilename :
// try to fetch the path from the "url" property, then try "path" if the first one
// didn't yield any result
OBSDataItemAutoRelease item = obs_data_item_byname(settings, "url");
if (!item) {
item = obs_data_item_byname(settings, "path");
if (!item) {
return nullptr;
}
}
return obs_data_item_get_string(item);
}
// Transform properties copy-pasted from WSRequestHandler_SceneItems.cpp because typedefs can't be extended yet
/**
* @typedef {Object} `SceneItemTransform`
* @property {int} `position.x` The x position of the scene item from the left.
* @property {int} `position.y` The y position of the scene item from the top.
* @property {double} `position.x` The x position of the scene item from the left.
* @property {double} `position.y` The y position of the scene item from the top.
* @property {int} `position.alignment` The point on the scene item that the item is manipulated from.
* @property {double} `rotation` The clockwise rotation of the scene item in degrees around the point of alignment.
* @property {double} `scale.x` The x-scale factor of the scene item.
* @property {double} `scale.y` The y-scale factor of the scene item.
* @property {String} `scale.filter` The scale filter of the source. Can be "OBS_SCALE_DISABLE", "OBS_SCALE_POINT", "OBS_SCALE_BICUBIC", "OBS_SCALE_BILINEAR", "OBS_SCALE_LANCZOS" or "OBS_SCALE_AREA".
* @property {int} `crop.top` The number of pixels cropped off the top of the scene item before scaling.
* @property {int} `crop.right` The number of pixels cropped off the right of the scene item before scaling.
* @property {int} `crop.bottom` The number of pixels cropped off the bottom of the scene item before scaling.
@ -733,12 +791,16 @@ obs_data_t* Utils::GetSceneItemPropertiesData(obs_sceneitem_t* sceneItem) {
uint32_t boundsAlignment = obs_sceneitem_get_bounds_alignment(sceneItem);
QString boundsTypeName = getBoundsNameFromType(boundsType);
obs_scale_type scaleFilter = obs_sceneitem_get_scale_filter(sceneItem);
QString scaleFilterName = getScaleNameFromType(scaleFilter);
OBSDataAutoRelease posData = obs_data_create();
obs_data_set_double(posData, "x", pos.x);
obs_data_set_double(posData, "y", pos.y);
obs_data_set_int(posData, "alignment", alignment);
OBSDataAutoRelease scaleData = obs_data_create();
obs_data_set_string(scaleData, "filter", scaleFilterName.toUtf8());
obs_data_set_double(scaleData, "x", scale.x);
obs_data_set_double(scaleData, "y", scale.y);
@ -859,3 +921,45 @@ QString Utils::nsToTimestamp(uint64_t ns)
return QString::asprintf("%02" PRIu64 ":%02" PRIu64 ":%02" PRIu64 ".%03" PRIu64, hoursPart, minutesPart, secsPart, msPart);
}
void Utils::AddSourceHelper(void *_data, obs_scene_t *scene)
{
auto *data = reinterpret_cast<AddSourceData*>(_data);
data->sceneItem = obs_scene_add(scene, data->source);
obs_sceneitem_set_visible(data->sceneItem, data->setVisible);
}
obs_data_t *Utils::OBSDataGetDefaults(obs_data_t *data)
{
obs_data_t *returnData = obs_data_create();
obs_data_item_t *item = NULL;
for (item = obs_data_first(data); item; obs_data_item_next(&item)) {
enum obs_data_type type = obs_data_item_gettype(item);
const char *name = obs_data_item_get_name(item);
if (type == OBS_DATA_STRING) {
const char *val = obs_data_item_get_string(item);
obs_data_set_string(returnData, name, val);
} else if (type == OBS_DATA_NUMBER) {
enum obs_data_number_type type = obs_data_item_numtype(item);
if (type == OBS_DATA_NUM_INT) {
long long val = obs_data_item_get_int(item);
obs_data_set_int(returnData, name, val);
} else {
double val = obs_data_item_get_double(item);
obs_data_set_double(returnData, name, val);
}
} else if (type == OBS_DATA_BOOLEAN) {
bool val = obs_data_item_get_bool(item);
obs_data_set_bool(returnData, name, val);
} else if (type == OBS_DATA_OBJECT) {
OBSDataAutoRelease obj = obs_data_item_get_obj(item);
obs_data_set_obj(returnData, name, obj);
} else if (type == OBS_DATA_ARRAY) {
OBSDataArrayAutoRelease array = obs_data_item_get_array(item);
obs_data_set_array(returnData, name, array);
}
}
return returnData;
}

View File

@ -35,6 +35,7 @@ typedef void(*PauseRecordingFunction)(bool);
typedef bool(*RecordingPausedFunction)();
namespace Utils {
bool StringInStringList(char** strings, const char* string);
obs_data_array_t* StringListToArray(char** strings, const char* key);
obs_data_array_t* GetSceneItems(obs_source_t* source);
obs_data_t* GetSceneItemData(obs_sceneitem_t* item);
@ -84,5 +85,15 @@ namespace Utils {
const char* GetFilenameFormatting();
bool SetFilenameFormatting(const char* filenameFormatting);
const char* GetCurrentRecordingFilename();
QString nsToTimestamp(uint64_t ns);
struct AddSourceData {
obs_source_t *source;
obs_sceneitem_t *sceneItem;
bool setVisible;
};
void AddSourceHelper(void *_data, obs_scene_t *scene);
obs_data_t *OBSDataGetDefaults(obs_data_t *data);
};

View File

@ -124,7 +124,7 @@ void WSEvents::FrontendEventHandler(enum obs_frontend_event event, void* private
case OBS_FRONTEND_EVENT_FINISHED_LOADING:
owner->hookTransitionPlaybackEvents();
break;
case OBS_FRONTEND_EVENT_SCENE_CHANGED:
owner->OnSceneChange();
break;
@ -202,6 +202,14 @@ void WSEvents::FrontendEventHandler(enum obs_frontend_event event, void* private
owner->OnRecordingResumed();
break;
case OBS_FRONTEND_EVENT_VIRTUALCAM_STARTED:
owner->OnVirtualCamStarted();
break;
case OBS_FRONTEND_EVENT_VIRTUALCAM_STOPPED:
owner->OnVirtualCamStopped();
break;
case OBS_FRONTEND_EVENT_REPLAY_BUFFER_STARTING:
owner->OnReplayStarting();
break;
@ -233,6 +241,7 @@ void WSEvents::FrontendEventHandler(enum obs_frontend_event event, void* private
case OBS_FRONTEND_EVENT_EXIT:
owner->unhookTransitionPlaybackEvents();
owner->OnExit();
owner->_srv->stop();
break;
}
}
@ -240,14 +249,17 @@ void WSEvents::FrontendEventHandler(enum obs_frontend_event event, void* private
void WSEvents::broadcastUpdate(const char* updateType,
obs_data_t* additionalFields = nullptr)
{
std::optional<uint64_t> streamTime;
if (!_srv->isListening()) {
return;
}
uint64_t streamTime = 0;
if (obs_frontend_streaming_active()) {
streamTime = std::make_optional(getStreamingTime());
streamTime = getStreamingTime();
}
std::optional<uint64_t> recordingTime;
uint64_t recordingTime;
if (obs_frontend_recording_active()) {
recordingTime = std::make_optional(getRecordingTime());
recordingTime = getRecordingTime();
}
RpcEvent event(QString(updateType), streamTime, recordingTime, additionalFields);
@ -271,11 +283,22 @@ void WSEvents::connectSourceSignals(obs_source_t* source) {
signal_handler_connect(sh, "volume", OnSourceVolumeChange, this);
signal_handler_connect(sh, "audio_sync", OnSourceAudioSyncOffsetChanged, this);
signal_handler_connect(sh, "audio_mixers", OnSourceAudioMixersChanged, this);
signal_handler_connect(sh, "audio_activate", OnSourceAudioActivated, this);
signal_handler_connect(sh, "audio_deactivate", OnSourceAudioDeactivated, this);
signal_handler_connect(sh, "filter_add", OnSourceFilterAdded, this);
signal_handler_connect(sh, "filter_remove", OnSourceFilterRemoved, this);
signal_handler_connect(sh, "reorder_filters", OnSourceFilterOrderChanged, this);
signal_handler_connect(sh, "media_play", OnMediaPlaying, this);
signal_handler_connect(sh, "media_pause", OnMediaPaused, this);
signal_handler_connect(sh, "media_restart", OnMediaRestarted, this);
signal_handler_connect(sh, "media_stopped", OnMediaStopped, this);
signal_handler_connect(sh, "media_next", OnMediaNext, this);
signal_handler_connect(sh, "media_previous", OnMediaPrevious, this);
signal_handler_connect(sh, "media_started", OnMediaStarted, this);
signal_handler_connect(sh, "media_ended", OnMediaEnded, this);
if (sourceType == OBS_SOURCE_TYPE_SCENE) {
signal_handler_connect(sh, "reorder", OnSceneReordered, this);
signal_handler_connect(sh, "item_add", OnSceneItemAdd, this);
@ -303,6 +326,8 @@ void WSEvents::disconnectSourceSignals(obs_source_t* source) {
signal_handler_disconnect(sh, "volume", OnSourceVolumeChange, this);
signal_handler_disconnect(sh, "audio_sync", OnSourceAudioSyncOffsetChanged, this);
signal_handler_disconnect(sh, "audio_mixers", OnSourceAudioMixersChanged, this);
signal_handler_disconnect(sh, "audio_activate", OnSourceAudioActivated, this);
signal_handler_disconnect(sh, "audio_deactivate", OnSourceAudioDeactivated, this);
signal_handler_disconnect(sh, "filter_add", OnSourceFilterAdded, this);
signal_handler_disconnect(sh, "filter_remove", OnSourceFilterRemoved, this);
@ -322,6 +347,15 @@ void WSEvents::disconnectSourceSignals(obs_source_t* source) {
signal_handler_disconnect(sh, "transition_start", OnTransitionBegin, this);
signal_handler_disconnect(sh, "transition_stop", OnTransitionEnd, this);
signal_handler_disconnect(sh, "transition_video_stop", OnTransitionVideoEnd, this);
signal_handler_disconnect(sh, "media_play", OnMediaPlaying, this);
signal_handler_disconnect(sh, "media_pause", OnMediaPaused, this);
signal_handler_disconnect(sh, "media_restart", OnMediaRestarted, this);
signal_handler_disconnect(sh, "media_stopped", OnMediaStopped, this);
signal_handler_disconnect(sh, "media_next", OnMediaNext, this);
signal_handler_disconnect(sh, "media_previous", OnMediaPrevious, this);
signal_handler_disconnect(sh, "media_started", OnMediaStarted, this);
signal_handler_disconnect(sh, "media_ended", OnMediaEnded, this);
}
void WSEvents::connectFilterSignals(obs_source_t* filter) {
@ -399,6 +433,11 @@ uint64_t WSEvents::getRecordingTime() {
return getOutputRunningTime(recordingOutput);
}
uint64_t WSEvents::getVirtualCamTime() {
OBSOutputAutoRelease virtualCamOutput = obs_frontend_get_virtualcam_output();
return getOutputRunningTime(virtualCamOutput);
}
QString WSEvents::getStreamingTimecode() {
return Utils::nsToTimestamp(getStreamingTime());
}
@ -407,6 +446,20 @@ QString WSEvents::getRecordingTimecode() {
return Utils::nsToTimestamp(getRecordingTime());
}
QString WSEvents::getVirtualCamTimecode() {
return Utils::nsToTimestamp(getVirtualCamTime());
}
OBSDataAutoRelease getMediaSourceData(calldata_t* data) {
OBSDataAutoRelease fields = obs_data_create();
OBSSource source = calldata_get_pointer<obs_source_t>(data, "source");
obs_data_set_string(fields, "sourceName", obs_source_get_name(source));
obs_data_set_string(fields, "sourceKind", obs_source_get_id(source));
return fields;
}
/**
* Indicates a scene change.
*
@ -433,25 +486,37 @@ void WSEvents::OnSceneChange() {
* The scene list has been modified.
* Scenes have been added, removed, or renamed.
*
* Note: This event is not fired when the scenes are reordered.
*
* @return {Array<Scene>} `scenes` Scenes list.
*
* @api events
* @name ScenesChanged
* @category scenes
* @since 0.3
*/
void WSEvents::OnSceneListChange() {
broadcastUpdate("ScenesChanged");
OBSDataArrayAutoRelease scenes = Utils::GetScenes();
OBSDataAutoRelease fields = obs_data_create();
obs_data_set_array(fields, "scenes", scenes);
broadcastUpdate("ScenesChanged", fields);
}
/**
* Triggered when switching to another scene collection or when renaming the current scene collection.
*
* @return {String} `sceneCollection` Name of the new current scene collection.
*
* @api events
* @name SceneCollectionChanged
* @category scenes
* @since 4.0.0
*/
void WSEvents::OnSceneCollectionChange() {
broadcastUpdate("SceneCollectionChanged");
OBSDataAutoRelease fields = obs_data_create();
obs_data_set_string(fields, "sceneCollection", obs_frontend_get_current_scene_collection());
broadcastUpdate("SceneCollectionChanged", fields);
OnTransitionListChange();
OnTransitionChange();
@ -463,13 +528,23 @@ void WSEvents::OnSceneCollectionChange() {
/**
* Triggered when a scene collection is created, added, renamed, or removed.
*
* @return {Array<Object>} `sceneCollections` Scene collections list.
* @return {String} `sceneCollections.*.name` Scene collection name.
*
* @api events
* @name SceneCollectionListChanged
* @category scenes
* @since 4.0.0
*/
void WSEvents::OnSceneCollectionListChange() {
broadcastUpdate("SceneCollectionListChanged");
char** sceneCollections = obs_frontend_get_scene_collections();
OBSDataArrayAutoRelease sceneCollectionsList =
Utils::StringListToArray(sceneCollections, "name");
bfree(sceneCollections);
OBSDataAutoRelease fields = obs_data_create();
obs_data_set_array(fields, "sceneCollections", sceneCollectionsList);
broadcastUpdate("SceneCollectionListChanged", fields);
}
/**
@ -496,37 +571,70 @@ void WSEvents::OnTransitionChange() {
* The list of available transitions has been modified.
* Transitions have been added, removed, or renamed.
*
* @return {Array<Object>} `transitions` Transitions list.
* @return {String} `transitions.*.name` Transition name.
*
* @api events
* @name TransitionListChanged
* @category transitions
* @since 4.0.0
*/
void WSEvents::OnTransitionListChange() {
broadcastUpdate("TransitionListChanged");
obs_frontend_source_list transitionList = {};
obs_frontend_get_transitions(&transitionList);
OBSDataArrayAutoRelease transitions = obs_data_array_create();
for (size_t i = 0; i < transitionList.sources.num; i++) {
OBSSource transition = transitionList.sources.array[i];
OBSDataAutoRelease obj = obs_data_create();
obs_data_set_string(obj, "name", obs_source_get_name(transition));
obs_data_array_push_back(transitions, obj);
}
obs_frontend_source_list_free(&transitionList);
OBSDataAutoRelease fields = obs_data_create();
obs_data_set_array(fields, "transitions", transitions);
broadcastUpdate("TransitionListChanged", fields);
}
/**
* Triggered when switching to another profile or when renaming the current profile.
*
* @return {String} `profile` Name of the new current profile.
*
* @api events
* @name ProfileChanged
* @category profiles
* @since 4.0.0
*/
void WSEvents::OnProfileChange() {
broadcastUpdate("ProfileChanged");
OBSDataAutoRelease fields = obs_data_create();
char *profile = obs_frontend_get_current_profile();
obs_data_set_string(fields, "profile", profile);
broadcastUpdate("ProfileChanged", fields);
bfree(profile);
}
/**
* Triggered when a profile is created, added, renamed, or removed.
*
* @return {Array<Object>} `profiles` Profiles list.
* @return {String} `profiles.*.name` Profile name.
*
* @api events
* @name ProfileListChanged
* @category profiles
* @since 4.0.0
*/
void WSEvents::OnProfileListChange() {
broadcastUpdate("ProfileListChanged");
char** profiles = obs_frontend_get_profiles();
OBSDataArrayAutoRelease profilesList = Utils::StringListToArray(profiles, "name");
bfree(profiles);
OBSDataAutoRelease fields = obs_data_create();
obs_data_set_array(fields, "profiles", profilesList);
broadcastUpdate("ProfileListChanged", fields);
}
/**
@ -594,6 +702,9 @@ void WSEvents::OnStreamStopped() {
/**
* A request to start recording has been issued.
*
* Note: `recordingFilename` is not provided in this event because this information
* is not available at the time this event is emitted.
*
* @api events
* @name RecordingStarting
* @category recording
@ -606,37 +717,49 @@ void WSEvents::OnRecordingStarting() {
/**
* Recording started successfully.
*
* @return {String} `recordingFilename` Absolute path to the file of the current recording.
*
* @api events
* @name RecordingStarted
* @category recording
* @since 0.3
*/
void WSEvents::OnRecordingStarted() {
broadcastUpdate("RecordingStarted");
OBSDataAutoRelease data = obs_data_create();
obs_data_set_string(data, "recordingFilename", Utils::GetCurrentRecordingFilename());
broadcastUpdate("RecordingStarted", data);
}
/**
* A request to stop recording has been issued.
*
* @return {String} `recordingFilename` Absolute path to the file of the current recording.
*
* @api events
* @name RecordingStopping
* @category recording
* @since 0.3
*/
void WSEvents::OnRecordingStopping() {
broadcastUpdate("RecordingStopping");
OBSDataAutoRelease data = obs_data_create();
obs_data_set_string(data, "recordingFilename", Utils::GetCurrentRecordingFilename());
broadcastUpdate("RecordingStopping", data);
}
/**
* Recording stopped successfully.
*
* @return {String} `recordingFilename` Absolute path to the file of the current recording.
*
* @api events
* @name RecordingStopped
* @category recording
* @since 0.3
*/
void WSEvents::OnRecordingStopped() {
broadcastUpdate("RecordingStopped");
OBSDataAutoRelease data = obs_data_create();
obs_data_set_string(data, "recordingFilename", Utils::GetCurrentRecordingFilename());
broadcastUpdate("RecordingStopped", data);
}
/**
@ -663,6 +786,30 @@ void WSEvents::OnRecordingResumed() {
broadcastUpdate("RecordingResumed");
}
/**
* Virtual cam started successfully.
*
* @api events
* @name VirtualCamStarted
* @category virtual cam
* @since 4.9.1
*/
void WSEvents::OnVirtualCamStarted() {
broadcastUpdate("VirtualCamStarted");
}
/**
* Virtual cam stopped successfully.
*
* @api events
* @name VirtualCamStopped
* @category virtual cam
* @since 4.9.1
*/
void WSEvents::OnVirtualCamStopped() {
broadcastUpdate("VirtualCamStopped");
}
/**
* A request to start the replay buffer has been issued.
*
@ -724,7 +871,7 @@ void WSEvents::OnExit() {
}
/**
* Emit every 2 seconds.
* Emitted every 2 seconds when stream is active.
*
* @return {boolean} `streaming` Current streaming state.
* @return {boolean} `recording` Current recording state.
@ -831,6 +978,7 @@ void WSEvents::StreamStatus() {
* @api events
* @name Heartbeat
* @category general
* @since v0.3
*/
void WSEvents::Heartbeat() {
@ -897,10 +1045,10 @@ void WSEvents::TransitionDurationChanged(int ms) {
*
* @return {String} `name` Transition name.
* @return {String} `type` Transition type.
* @return {int} `duration` Transition duration (in milliseconds).
* Will be -1 for any transition with a fixed duration,
* @return {int} `duration` Transition duration (in milliseconds).
* Will be -1 for any transition with a fixed duration,
* such as a Stinger, due to limitations of the OBS API.
* @return {String} `from-scene` Source scene of the transition
* @return {String (optional)} `from-scene` Source scene of the transition
* @return {String} `to-scene` Destination scene of the transition
*
* @api events
@ -922,7 +1070,7 @@ void WSEvents::OnTransitionBegin(void* param, calldata_t* data) {
/**
* A transition (other than "cut") has ended.
* Please note that the `from-scene` field is not available in TransitionEnd.
* Note: The `from-scene` field is not available in TransitionEnd.
*
* @return {String} `name` Transition name.
* @return {String} `type` Transition type.
@ -952,7 +1100,7 @@ void WSEvents::OnTransitionEnd(void* param, calldata_t* data) {
* @return {String} `name` Transition name.
* @return {String} `type` Transition type.
* @return {int} `duration` Transition duration (in milliseconds).
* @return {String} `from-scene` Source scene of the transition
* @return {String (optional)} `from-scene` Source scene of the transition
* @return {String} `to-scene` Destination scene of the transition
*
* @api events
@ -1043,6 +1191,7 @@ void WSEvents::OnSourceDestroy(void* param, calldata_t* data) {
*
* @return {String} `sourceName` Source name
* @return {float} `volume` Source volume
* @return {float} `volumeDb` Source volume in Decibel
*
* @api events
* @name SourceVolumeChanged
@ -1062,9 +1211,15 @@ void WSEvents::OnSourceVolumeChange(void* param, calldata_t* data) {
return;
}
double volumeDb = obs_mul_to_db(volume);
if (volumeDb == -INFINITY) {
volumeDb = -100.0;
}
OBSDataAutoRelease fields = obs_data_create();
obs_data_set_string(fields, "sourceName", obs_source_get_name(source));
obs_data_set_double(fields, "volume", volume);
obs_data_set_double(fields, "volumeDb", volumeDb);
self->broadcastUpdate("SourceVolumeChanged", fields);
}
@ -1098,6 +1253,52 @@ void WSEvents::OnSourceMuteStateChange(void* param, calldata_t* data) {
self->broadcastUpdate("SourceMuteStateChanged", fields);
}
/**
* A source has removed audio.
*
* @return {String} `sourceName` Source name
*
* @api events
* @name SourceAudioDeactivated
* @category sources
* @since 4.9.0
*/
void WSEvents::OnSourceAudioDeactivated(void* param, calldata_t* data) {
auto self = reinterpret_cast<WSEvents*>(param);
OBSSource source = calldata_get_pointer<obs_source_t>(data, "source");
if (!source) {
return;
}
OBSDataAutoRelease fields = obs_data_create();
obs_data_set_string(fields, "sourceName", obs_source_get_name(source));
self->broadcastUpdate("SourceAudioDeactivated", fields);
}
/**
* A source has added audio.
*
* @return {String} `sourceName` Source name
*
* @api events
* @name SourceAudioActivated
* @category sources
* @since 4.9.0
*/
void WSEvents::OnSourceAudioActivated(void* param, calldata_t* data) {
auto self = reinterpret_cast<WSEvents*>(param);
OBSSource source = calldata_get_pointer<obs_source_t>(data, "source");
if (!source) {
return;
}
OBSDataAutoRelease fields = obs_data_create();
obs_data_set_string(fields, "sourceName", obs_source_get_name(source));
self->broadcastUpdate("SourceAudioActivated", fields);
}
/**
* The audio sync offset of a source has changed.
*
@ -1232,7 +1433,7 @@ void WSEvents::OnSourceFilterAdded(void* param, calldata_t* data) {
if (!filter) {
return;
}
self->connectFilterSignals(filter);
OBSDataAutoRelease filterSettings = obs_source_get_settings(filter);
@ -1316,6 +1517,7 @@ void WSEvents::OnSourceFilterVisibilityChanged(void* param, calldata_t* data) {
* @return {Array<Object>} `filters` Ordered Filters list
* @return {String} `filters.*.name` Filter name
* @return {String} `filters.*.type` Filter type
* @return {boolean} `filters.*.enabled` Filter visibility status
*
* @api events
* @name SourceFiltersReordered
@ -1339,7 +1541,175 @@ void WSEvents::OnSourceFilterOrderChanged(void* param, calldata_t* data) {
}
/**
* Scene items have been reordered.
* A media source has started playing.
*
* Note: This event is only emitted when something actively controls the media/VLC source. In other words, the source will never emit this on its own naturally.
*
* @return {String} `sourceName` Source name
* @return {String} `sourceKind` The ID type of the source (Eg. `vlc_source` or `ffmpeg_source`)
*
* @api events
* @name MediaPlaying
* @category media
* @since 4.9.0
*/
void WSEvents::OnMediaPlaying(void* param, calldata_t* data) {
auto self = reinterpret_cast<WSEvents*>(param);
OBSDataAutoRelease fields = getMediaSourceData(data);
self->broadcastUpdate("MediaPlaying", fields);
}
/**
* A media source has been paused.
*
* Note: This event is only emitted when something actively controls the media/VLC source. In other words, the source will never emit this on its own naturally.
*
* @return {String} `sourceName` Source name
* @return {String} `sourceKind` The ID type of the source (Eg. `vlc_source` or `ffmpeg_source`)
*
* @api events
* @name MediaPaused
* @category media
* @since 4.9.0
*/
void WSEvents::OnMediaPaused(void* param, calldata_t* data) {
auto self = reinterpret_cast<WSEvents*>(param);
OBSDataAutoRelease fields = getMediaSourceData(data);
self->broadcastUpdate("MediaPaused", fields);
}
/**
* A media source has been restarted.
*
* Note: This event is only emitted when something actively controls the media/VLC source. In other words, the source will never emit this on its own naturally.
*
* @return {String} `sourceName` Source name
* @return {String} `sourceKind` The ID type of the source (Eg. `vlc_source` or `ffmpeg_source`)
*
* @api events
* @name MediaRestarted
* @category media
* @since 4.9.0
*/
void WSEvents::OnMediaRestarted(void* param, calldata_t* data) {
auto self = reinterpret_cast<WSEvents*>(param);
OBSDataAutoRelease fields = getMediaSourceData(data);
self->broadcastUpdate("MediaRestarted", fields);
}
/**
* A media source has been stopped.
*
* Note: This event is only emitted when something actively controls the media/VLC source. In other words, the source will never emit this on its own naturally.
*
* @return {String} `sourceName` Source name
* @return {String} `sourceKind` The ID type of the source (Eg. `vlc_source` or `ffmpeg_source`)
*
* @api events
* @name MediaStopped
* @category media
* @since 4.9.0
*/
void WSEvents::OnMediaStopped(void* param, calldata_t* data) {
auto self = reinterpret_cast<WSEvents*>(param);
OBSDataAutoRelease fields = getMediaSourceData(data);
self->broadcastUpdate("MediaStopped", fields);
}
/**
* A media source has gone to the next item in the playlist.
*
* Note: This event is only emitted when something actively controls the media/VLC source. In other words, the source will never emit this on its own naturally.
*
* @return {String} `sourceName` Source name
* @return {String} `sourceKind` The ID type of the source (Eg. `vlc_source` or `ffmpeg_source`)
*
* @api events
* @name MediaNext
* @category media
* @since 4.9.0
*/
void WSEvents::OnMediaNext(void* param, calldata_t* data) {
auto self = reinterpret_cast<WSEvents*>(param);
OBSDataAutoRelease fields = getMediaSourceData(data);
self->broadcastUpdate("MediaNext", fields);
}
/**
* A media source has gone to the previous item in the playlist.
*
* Note: This event is only emitted when something actively controls the media/VLC source. In other words, the source will never emit this on its own naturally.
*
* @return {String} `sourceName` Source name
* @return {String} `sourceKind` The ID type of the source (Eg. `vlc_source` or `ffmpeg_source`)
*
* @api events
* @name MediaPrevious
* @category media
* @since 4.9.0
*/
void WSEvents::OnMediaPrevious(void* param, calldata_t* data) {
auto self = reinterpret_cast<WSEvents*>(param);
OBSDataAutoRelease fields = getMediaSourceData(data);
self->broadcastUpdate("MediaPrevious", fields);
}
/**
* A media source has been started.
*
* Note: These events are emitted by the OBS sources themselves. For example when the media file starts playing. The behavior depends on the type of media source being used.
*
* @return {String} `sourceName` Source name
* @return {String} `sourceKind` The ID type of the source (Eg. `vlc_source` or `ffmpeg_source`)
*
* @api events
* @name MediaStarted
* @category media
* @since 4.9.0
*/
void WSEvents::OnMediaStarted(void* param, calldata_t* data) {
auto self = reinterpret_cast<WSEvents*>(param);
OBSDataAutoRelease fields = getMediaSourceData(data);
self->broadcastUpdate("MediaStarted", fields);
}
/**
* A media source has ended.
*
* Note: These events are emitted by the OBS sources themselves. For example when the media file ends. The behavior depends on the type of media source being used.
*
* @return {String} `sourceName` Source name
* @return {String} `sourceKind` The ID type of the source (Eg. `vlc_source` or `ffmpeg_source`)
*
* @api events
* @name MediaEnded
* @category media
* @since 4.9.0
*/
void WSEvents::OnMediaEnded(void* param, calldata_t* data) {
auto self = reinterpret_cast<WSEvents*>(param);
OBSDataAutoRelease fields = getMediaSourceData(data);
self->broadcastUpdate("MediaEnded", fields);
}
/**
* Scene items within a scene have been reordered.
*
* @return {String} `scene-name` Name of the scene where items have been reordered.
* @return {Array<Object>} `scene-items` Ordered list of scene items
@ -1382,7 +1752,7 @@ void WSEvents::OnSceneReordered(void* param, calldata_t* data) {
}
/**
* An item has been added to the current scene.
* A scene item has been added to a scene.
*
* @return {String} `scene-name` Name of the scene.
* @return {String} `item-name` Name of the item added to the scene.
@ -1415,7 +1785,7 @@ void WSEvents::OnSceneItemAdd(void* param, calldata_t* data) {
}
/**
* An item has been removed from the current scene.
* A scene item has been removed from a scene.
*
* @return {String} `scene-name` Name of the scene.
* @return {String} `item-name` Name of the item removed from the scene.
@ -1448,7 +1818,7 @@ void WSEvents::OnSceneItemDelete(void* param, calldata_t* data) {
}
/**
* An item's visibility has been toggled.
* A scene item's visibility has been toggled.
*
* @return {String} `scene-name` Name of the scene.
* @return {String} `item-name` Name of the item in the scene.
@ -1486,7 +1856,7 @@ void WSEvents::OnSceneItemVisibilityChanged(void* param, calldata_t* data) {
}
/**
* An item's locked status has been toggled.
* A scene item's locked status has been toggled.
*
* @return {String} `scene-name` Name of the scene.
* @return {String} `item-name` Name of the item in the scene.
@ -1524,7 +1894,7 @@ void WSEvents::OnSceneItemLockChanged(void* param, calldata_t* data) {
}
/**
* An item's transform has been changed.
* A scene item's transform has been changed.
*
* @return {String} `scene-name` Name of the scene.
* @return {String} `item-name` Name of the item in the scene.
@ -1675,7 +2045,7 @@ void WSEvents::OnStudioModeSwitched(bool checked) {
}
/**
* A custom broadcast message was received
* A custom broadcast message, sent by the server, requested by one of the websocket clients.
*
* @return {String} `realm` Identifier provided by the sender
* @return {Object} `data` User-defined data

View File

@ -48,9 +48,11 @@ public:
uint64_t getStreamingTime();
uint64_t getRecordingTime();
uint64_t getVirtualCamTime();
QString getStreamingTimecode();
QString getRecordingTimecode();
QString getVirtualCamTimecode();
obs_data_t* GetStats();
@ -101,6 +103,9 @@ private:
void OnRecordingStopped();
void OnRecordingPaused();
void OnRecordingResumed();
void OnVirtualCamStarted();
void OnVirtualCamStopped();
void OnReplayStarting();
void OnReplayStarted();
@ -126,6 +131,8 @@ private:
static void OnSourceMuteStateChange(void* param, calldata_t* data);
static void OnSourceAudioSyncOffsetChanged(void* param, calldata_t* data);
static void OnSourceAudioMixersChanged(void* param, calldata_t* data);
static void OnSourceAudioActivated(void* param, calldata_t* data);
static void OnSourceAudioDeactivated(void* param, calldata_t* data);
static void OnSourceRename(void* param, calldata_t* data);
@ -133,6 +140,15 @@ private:
static void OnSourceFilterRemoved(void* param, calldata_t* data);
static void OnSourceFilterVisibilityChanged(void* param, calldata_t* data);
static void OnSourceFilterOrderChanged(void* param, calldata_t* data);
static void OnMediaPlaying(void* param, calldata_t* data);
static void OnMediaPaused(void* param, calldata_t* data);
static void OnMediaRestarted(void* param, calldata_t* data);
static void OnMediaStopped(void* param, calldata_t* data);
static void OnMediaNext(void* param, calldata_t* data);
static void OnMediaPrevious(void* param, calldata_t* data);
static void OnMediaStarted(void* param, calldata_t* data);
static void OnMediaEnded(void* param, calldata_t* data);
static void OnSceneReordered(void* param, calldata_t* data);
static void OnSceneItemAdd(void* param, calldata_t* data);

View File

@ -28,84 +28,118 @@
using namespace std::placeholders;
const QHash<QString, RpcMethodHandler> WSRequestHandler::messageMap {
const QHash<QString, RpcMethodHandler> WSRequestHandler::messageMap{
// Category: General
{ "GetVersion", &WSRequestHandler::GetVersion },
{ "GetAuthRequired", &WSRequestHandler::GetAuthRequired },
{ "Authenticate", &WSRequestHandler::Authenticate },
{ "GetStats", &WSRequestHandler::GetStats },
{ "SetHeartbeat", &WSRequestHandler::SetHeartbeat },
{ "GetVideoInfo", &WSRequestHandler::GetVideoInfo },
{ "OpenProjector", &WSRequestHandler::OpenProjector },
{ "SetFilenameFormatting", &WSRequestHandler::SetFilenameFormatting },
{ "GetFilenameFormatting", &WSRequestHandler::GetFilenameFormatting },
{ "GetStats", &WSRequestHandler::GetStats },
{ "BroadcastCustomMessage", &WSRequestHandler::BroadcastCustomMessage },
{ "GetVideoInfo", &WSRequestHandler::GetVideoInfo },
{ "OpenProjector", &WSRequestHandler::OpenProjector },
{ "TriggerHotkeyByName", &WSRequestHandler::TriggerHotkeyByName },
{ "TriggerHotkeyBySequence", &WSRequestHandler::TriggerHotkeyBySequence },
{ "ExecuteBatch", &WSRequestHandler::ExecuteBatch },
{ "Sleep", &WSRequestHandler::Sleep },
{ "SetCurrentScene", &WSRequestHandler::SetCurrentScene },
{ "GetCurrentScene", &WSRequestHandler::GetCurrentScene },
{ "GetSceneList", &WSRequestHandler::GetSceneList },
{ "SetSceneTransitionOverride", &WSRequestHandler::SetSceneTransitionOverride },
{ "RemoveSceneTransitionOverride", &WSRequestHandler::RemoveSceneTransitionOverride },
{ "GetSceneTransitionOverride", &WSRequestHandler::GetSceneTransitionOverride },
// Category: Media Control
{ "PlayPauseMedia", &WSRequestHandler::PlayPauseMedia },
{ "RestartMedia", &WSRequestHandler::RestartMedia },
{ "StopMedia", &WSRequestHandler::StopMedia },
{ "NextMedia", &WSRequestHandler::NextMedia },
{ "PreviousMedia", &WSRequestHandler::PreviousMedia },
{ "GetMediaDuration", &WSRequestHandler::GetMediaDuration },
{ "GetMediaTime", &WSRequestHandler::GetMediaTime },
{ "SetMediaTime", &WSRequestHandler::SetMediaTime },
{ "ScrubMedia", &WSRequestHandler::ScrubMedia },
{ "GetMediaState", &WSRequestHandler::GetMediaState },
{ "GetMediaSourcesList", &WSRequestHandler::GetMediaSourcesList },
{ "SetSourceRender", &WSRequestHandler::SetSceneItemRender }, // Retrocompat
{ "SetSceneItemRender", &WSRequestHandler::SetSceneItemRender },
{ "SetSceneItemPosition", &WSRequestHandler::SetSceneItemPosition },
{ "SetSceneItemTransform", &WSRequestHandler::SetSceneItemTransform },
{ "SetSceneItemCrop", &WSRequestHandler::SetSceneItemCrop },
{ "GetSceneItemProperties", &WSRequestHandler::GetSceneItemProperties },
{ "SetSceneItemProperties", &WSRequestHandler::SetSceneItemProperties },
{ "ResetSceneItem", &WSRequestHandler::ResetSceneItem },
{ "DeleteSceneItem", &WSRequestHandler::DeleteSceneItem },
{ "DuplicateSceneItem", &WSRequestHandler::DuplicateSceneItem },
{ "ReorderSceneItems", &WSRequestHandler::ReorderSceneItems },
// Category: Outputs
{ "ListOutputs", &WSRequestHandler::ListOutputs },
{ "GetOutputInfo", &WSRequestHandler::GetOutputInfo },
{ "StartOutput", &WSRequestHandler::StartOutput },
{ "StopOutput", &WSRequestHandler::StopOutput },
{ "GetStreamingStatus", &WSRequestHandler::GetStreamingStatus },
{ "StartStopStreaming", &WSRequestHandler::StartStopStreaming },
// Category: Profiles
{ "SetCurrentProfile", &WSRequestHandler::SetCurrentProfile },
{ "GetCurrentProfile", &WSRequestHandler::GetCurrentProfile },
{ "ListProfiles", &WSRequestHandler::ListProfiles },
// Category: Recording
{ "GetRecordingStatus", &WSRequestHandler::GetRecordingStatus },
{ "StartStopRecording", &WSRequestHandler::StartStopRecording },
{ "StartStreaming", &WSRequestHandler::StartStreaming },
{ "StopStreaming", &WSRequestHandler::StopStreaming },
{ "StartRecording", &WSRequestHandler::StartRecording },
{ "StopRecording", &WSRequestHandler::StopRecording },
{ "PauseRecording", &WSRequestHandler::PauseRecording },
{ "ResumeRecording", &WSRequestHandler::ResumeRecording },
{ "SetRecordingFolder", &WSRequestHandler::SetRecordingFolder },
{ "GetRecordingFolder", &WSRequestHandler::GetRecordingFolder },
// Category: Replay Buffer
{ "GetReplayBufferStatus", &WSRequestHandler::GetReplayBufferStatus },
{ "StartStopReplayBuffer", &WSRequestHandler::StartStopReplayBuffer },
{ "StartReplayBuffer", &WSRequestHandler::StartReplayBuffer },
{ "StopReplayBuffer", &WSRequestHandler::StopReplayBuffer },
{ "SaveReplayBuffer", &WSRequestHandler::SaveReplayBuffer },
{ "SetRecordingFolder", &WSRequestHandler::SetRecordingFolder },
{ "GetRecordingFolder", &WSRequestHandler::GetRecordingFolder },
// Category: Scene Collections
{ "SetCurrentSceneCollection", &WSRequestHandler::SetCurrentSceneCollection },
{ "GetCurrentSceneCollection", &WSRequestHandler::GetCurrentSceneCollection },
{ "ListSceneCollections", &WSRequestHandler::ListSceneCollections },
{ "GetTransitionList", &WSRequestHandler::GetTransitionList },
{ "GetCurrentTransition", &WSRequestHandler::GetCurrentTransition },
{ "SetCurrentTransition", &WSRequestHandler::SetCurrentTransition },
{ "SetTransitionDuration", &WSRequestHandler::SetTransitionDuration },
{ "GetTransitionDuration", &WSRequestHandler::GetTransitionDuration },
{ "GetTransitionPosition", &WSRequestHandler::GetTransitionPosition },
// Category: Scene Items
{ "GetSceneItemList", &WSRequestHandler::GetSceneItemList },
{ "GetSceneItemProperties", &WSRequestHandler::GetSceneItemProperties },
{ "SetSceneItemProperties", &WSRequestHandler::SetSceneItemProperties },
{ "ResetSceneItem", &WSRequestHandler::ResetSceneItem },
{ "SetSceneItemRender", &WSRequestHandler::SetSceneItemRender },
{ "SetSceneItemPosition", &WSRequestHandler::SetSceneItemPosition },
{ "SetSceneItemTransform", &WSRequestHandler::SetSceneItemTransform },
{ "SetSceneItemCrop", &WSRequestHandler::SetSceneItemCrop },
{ "SetSourceRender", &WSRequestHandler::SetSceneItemRender }, // Retrocompat TODO: Remove in 5.0.0
{ "DeleteSceneItem", &WSRequestHandler::DeleteSceneItem },
{ "AddSceneItem", &WSRequestHandler::AddSceneItem },
{ "DuplicateSceneItem", &WSRequestHandler::DuplicateSceneItem },
{ "SetVolume", &WSRequestHandler::SetVolume },
// Category: Scenes
{ "SetCurrentScene", &WSRequestHandler::SetCurrentScene },
{ "GetCurrentScene", &WSRequestHandler::GetCurrentScene },
{ "GetSceneList", &WSRequestHandler::GetSceneList },
{ "CreateScene", &WSRequestHandler::CreateScene },
{ "ReorderSceneItems", &WSRequestHandler::ReorderSceneItems },
{ "SetSceneTransitionOverride", &WSRequestHandler::SetSceneTransitionOverride },
{ "RemoveSceneTransitionOverride", &WSRequestHandler::RemoveSceneTransitionOverride },
{ "GetSceneTransitionOverride", &WSRequestHandler::GetSceneTransitionOverride },
// Category: Sources
{ "CreateSource", &WSRequestHandler::CreateSource },
{ "GetSourcesList", &WSRequestHandler::GetSourcesList },
{ "GetSourceTypesList", &WSRequestHandler::GetSourceTypesList },
{ "GetVolume", &WSRequestHandler::GetVolume },
{ "ToggleMute", &WSRequestHandler::ToggleMute },
{ "SetMute", &WSRequestHandler::SetMute },
{ "SetVolume", &WSRequestHandler::SetVolume },
{ "SetAudioTracks", &WSRequestHandler::SetAudioTracks },
{ "GetAudioTracks", &WSRequestHandler::GetAudioTracks },
{ "GetMute", &WSRequestHandler::GetMute },
{ "SetMute", &WSRequestHandler::SetMute },
{ "ToggleMute", &WSRequestHandler::ToggleMute },
{ "GetSourceActive", &WSRequestHandler::GetSourceActive },
{ "GetAudioActive", &WSRequestHandler::GetAudioActive },
{ "SetSourceName", &WSRequestHandler::SetSourceName },
{ "SetSyncOffset", &WSRequestHandler::SetSyncOffset },
{ "GetSyncOffset", &WSRequestHandler::GetSyncOffset },
{ "GetSpecialSources", &WSRequestHandler::GetSpecialSources },
{ "GetSourcesList", &WSRequestHandler::GetSourcesList },
{ "GetSourceTypesList", &WSRequestHandler::GetSourceTypesList },
{ "GetSourceSettings", &WSRequestHandler::GetSourceSettings },
{ "SetSourceSettings", &WSRequestHandler::SetSourceSettings },
{ "GetAudioMonitorType", &WSRequestHandler::GetAudioMonitorType },
{ "SetAudioMonitorType", &WSRequestHandler::SetAudioMonitorType },
{ "TakeSourceScreenshot", &WSRequestHandler::TakeSourceScreenshot },
{ "GetTextGDIPlusProperties", &WSRequestHandler::GetTextGDIPlusProperties },
{ "SetTextGDIPlusProperties", &WSRequestHandler::SetTextGDIPlusProperties },
{ "GetTextFreetype2Properties", &WSRequestHandler::GetTextFreetype2Properties },
{ "SetTextFreetype2Properties", &WSRequestHandler::SetTextFreetype2Properties },
{ "GetBrowserSourceProperties", &WSRequestHandler::GetBrowserSourceProperties },
{ "SetBrowserSourceProperties", &WSRequestHandler::SetBrowserSourceProperties },
{ "GetSpecialSources", &WSRequestHandler::GetSpecialSources },
{ "GetSourceFilters", &WSRequestHandler::GetSourceFilters },
{ "GetSourceFilterInfo", &WSRequestHandler::GetSourceFilterInfo },
{ "AddFilterToSource", &WSRequestHandler::AddFilterToSource },
@ -114,22 +148,29 @@ const QHash<QString, RpcMethodHandler> WSRequestHandler::messageMap {
{ "MoveSourceFilter", &WSRequestHandler::MoveSourceFilter },
{ "SetSourceFilterSettings", &WSRequestHandler::SetSourceFilterSettings },
{ "SetSourceFilterVisibility", &WSRequestHandler::SetSourceFilterVisibility },
{ "GetAudioMonitorType", &WSRequestHandler::GetAudioMonitorType },
{ "SetAudioMonitorType", &WSRequestHandler::SetAudioMonitorType },
{ "GetSourceDefaultSettings", &WSRequestHandler::GetSourceDefaultSettings },
{ "TakeSourceScreenshot", &WSRequestHandler::TakeSourceScreenshot },
{ "RefreshBrowserSource", &WSRequestHandler::RefreshBrowserSource },
{ "SetCurrentSceneCollection", &WSRequestHandler::SetCurrentSceneCollection },
{ "GetCurrentSceneCollection", &WSRequestHandler::GetCurrentSceneCollection },
{ "ListSceneCollections", &WSRequestHandler::ListSceneCollections },
{ "SetCurrentProfile", &WSRequestHandler::SetCurrentProfile },
{ "GetCurrentProfile", &WSRequestHandler::GetCurrentProfile },
{ "ListProfiles", &WSRequestHandler::ListProfiles },
// Category: Streaming
{ "GetStreamingStatus", &WSRequestHandler::GetStreamingStatus },
{ "StartStopStreaming", &WSRequestHandler::StartStopStreaming },
{ "StartStreaming", &WSRequestHandler::StartStreaming },
{ "StopStreaming", &WSRequestHandler::StopStreaming },
{ "SetStreamSettings", &WSRequestHandler::SetStreamSettings },
{ "GetStreamSettings", &WSRequestHandler::GetStreamSettings },
{ "SaveStreamSettings", &WSRequestHandler::SaveStreamSettings },
#if BUILD_CAPTIONS
{ "SendCaptions", &WSRequestHandler::SendCaptions },
#endif
// Category: VirtualCam
{ "GetVirtualCamStatus", &WSRequestHandler::GetVirtualCamStatus },
{ "StartStopVirtualCam", &WSRequestHandler::StartStopVirtualCam },
{ "StartVirtualCam", &WSRequestHandler::StartVirtualCam },
{ "StopVirtualCam", &WSRequestHandler::StopVirtualCam },
// Category: Studio Mode
{ "GetStudioModeStatus", &WSRequestHandler::GetStudioModeStatus },
{ "GetPreviewScene", &WSRequestHandler::GetPreviewScene },
{ "SetPreviewScene", &WSRequestHandler::SetPreviewScene },
@ -138,19 +179,17 @@ const QHash<QString, RpcMethodHandler> WSRequestHandler::messageMap {
{ "DisableStudioMode", &WSRequestHandler::DisableStudioMode },
{ "ToggleStudioMode", &WSRequestHandler::ToggleStudioMode },
{ "SetTextGDIPlusProperties", &WSRequestHandler::SetTextGDIPlusProperties },
{ "GetTextGDIPlusProperties", &WSRequestHandler::GetTextGDIPlusProperties },
{ "SetTextFreetype2Properties", &WSRequestHandler::SetTextFreetype2Properties },
{ "GetTextFreetype2Properties", &WSRequestHandler::GetTextFreetype2Properties },
{ "GetBrowserSourceProperties", &WSRequestHandler::GetBrowserSourceProperties },
{ "SetBrowserSourceProperties", &WSRequestHandler::SetBrowserSourceProperties },
{ "ListOutputs", &WSRequestHandler::ListOutputs },
{ "GetOutputInfo", &WSRequestHandler::GetOutputInfo },
{ "StartOutput", &WSRequestHandler::StartOutput },
{ "StopOutput", &WSRequestHandler::StopOutput }
// Category: Transitions
{ "GetTransitionList", &WSRequestHandler::GetTransitionList },
{ "GetCurrentTransition", &WSRequestHandler::GetCurrentTransition },
{ "SetCurrentTransition", &WSRequestHandler::SetCurrentTransition },
{ "SetTransitionDuration", &WSRequestHandler::SetTransitionDuration },
{ "GetTransitionDuration", &WSRequestHandler::GetTransitionDuration },
{ "GetTransitionPosition", &WSRequestHandler::GetTransitionPosition },
{ "GetTransitionSettings", &WSRequestHandler::GetTransitionSettings },
{ "SetTransitionSettings", &WSRequestHandler::SetTransitionSettings },
{ "ReleaseTBar", &WSRequestHandler::ReleaseTBar },
{ "SetTBarPosition", &WSRequestHandler::SetTBarPosition }
};
const QSet<QString> WSRequestHandler::authNotRequired {
@ -164,8 +203,9 @@ WSRequestHandler::WSRequestHandler(ConnectionProperties& connProperties) :
{
}
RpcResponse WSRequestHandler::processRequest(const RpcRequest& request){
if (GetConfig()->AuthRequired
RpcResponse WSRequestHandler::processRequest(const RpcRequest& request) {
auto config = GetConfig();
if ((config && config->AuthRequired)
&& (!authNotRequired.contains(request.methodName()))
&& (!_connProperties.isAuthenticated()))
{

View File

@ -47,82 +47,116 @@ class WSRequestHandler {
static const QHash<QString, RpcMethodHandler> messageMap;
static const QSet<QString> authNotRequired;
// Category: General
RpcResponse GetVersion(const RpcRequest&);
RpcResponse GetAuthRequired(const RpcRequest&);
RpcResponse Authenticate(const RpcRequest&);
RpcResponse GetStats(const RpcRequest&);
RpcResponse SetHeartbeat(const RpcRequest&);
RpcResponse GetVideoInfo(const RpcRequest&);
RpcResponse OpenProjector(const RpcRequest&);
RpcResponse SetFilenameFormatting(const RpcRequest&);
RpcResponse GetFilenameFormatting(const RpcRequest&);
RpcResponse GetStats(const RpcRequest&);
RpcResponse BroadcastCustomMessage(const RpcRequest&);
RpcResponse GetVideoInfo(const RpcRequest&);
RpcResponse OpenProjector(const RpcRequest&);
RpcResponse TriggerHotkeyByName(const RpcRequest&);
RpcResponse TriggerHotkeyBySequence(const RpcRequest&);
RpcResponse ExecuteBatch(const RpcRequest&);
RpcResponse Sleep(const RpcRequest&);
RpcResponse SetCurrentScene(const RpcRequest&);
RpcResponse GetCurrentScene(const RpcRequest&);
RpcResponse GetSceneList(const RpcRequest&);
RpcResponse SetSceneTransitionOverride(const RpcRequest&);
RpcResponse RemoveSceneTransitionOverride(const RpcRequest&);
RpcResponse GetSceneTransitionOverride(const RpcRequest&);
// Category: Media Control
RpcResponse PlayPauseMedia(const RpcRequest&);
RpcResponse RestartMedia(const RpcRequest&);
RpcResponse StopMedia(const RpcRequest&);
RpcResponse NextMedia(const RpcRequest&);
RpcResponse PreviousMedia(const RpcRequest&);
RpcResponse GetMediaDuration(const RpcRequest&);
RpcResponse GetMediaTime(const RpcRequest&);
RpcResponse SetMediaTime(const RpcRequest&);
RpcResponse ScrubMedia(const RpcRequest&);
RpcResponse GetMediaState(const RpcRequest&);
RpcResponse GetMediaSourcesList(const RpcRequest&);
RpcResponse SetSceneItemRender(const RpcRequest&);
RpcResponse SetSceneItemPosition(const RpcRequest&);
RpcResponse SetSceneItemTransform(const RpcRequest&);
RpcResponse SetSceneItemCrop(const RpcRequest&);
RpcResponse GetSceneItemProperties(const RpcRequest&);
RpcResponse SetSceneItemProperties(const RpcRequest&);
RpcResponse ResetSceneItem(const RpcRequest&);
RpcResponse DuplicateSceneItem(const RpcRequest&);
RpcResponse DeleteSceneItem(const RpcRequest&);
RpcResponse ReorderSceneItems(const RpcRequest&);
// Category: Outputs
RpcResponse ListOutputs(const RpcRequest&);
RpcResponse GetOutputInfo(const RpcRequest&);
RpcResponse StartOutput(const RpcRequest&);
RpcResponse StopOutput(const RpcRequest&);
RpcResponse GetStreamingStatus(const RpcRequest&);
RpcResponse StartStopStreaming(const RpcRequest&);
// Category: Profiles
RpcResponse SetCurrentProfile(const RpcRequest&);
RpcResponse GetCurrentProfile(const RpcRequest&);
RpcResponse ListProfiles(const RpcRequest&);
// Category: Recording
RpcResponse GetRecordingStatus(const RpcRequest&);
RpcResponse StartStopRecording(const RpcRequest&);
RpcResponse StartStreaming(const RpcRequest&);
RpcResponse StopStreaming(const RpcRequest&);
RpcResponse StartRecording(const RpcRequest&);
RpcResponse StopRecording(const RpcRequest&);
RpcResponse PauseRecording(const RpcRequest&);
RpcResponse ResumeRecording(const RpcRequest&);
RpcResponse SetRecordingFolder(const RpcRequest&);
RpcResponse GetRecordingFolder(const RpcRequest&);
// Category: Replay Buffer
RpcResponse GetReplayBufferStatus(const RpcRequest&);
RpcResponse StartStopReplayBuffer(const RpcRequest&);
RpcResponse StartReplayBuffer(const RpcRequest&);
RpcResponse StopReplayBuffer(const RpcRequest&);
RpcResponse SaveReplayBuffer(const RpcRequest&);
RpcResponse SetRecordingFolder(const RpcRequest&);
RpcResponse GetRecordingFolder(const RpcRequest&);
// Category: Scene Collections
RpcResponse SetCurrentSceneCollection(const RpcRequest&);
RpcResponse GetCurrentSceneCollection(const RpcRequest&);
RpcResponse ListSceneCollections(const RpcRequest&);
RpcResponse GetTransitionList(const RpcRequest&);
RpcResponse GetCurrentTransition(const RpcRequest&);
RpcResponse SetCurrentTransition(const RpcRequest&);
RpcResponse SetTransitionDuration(const RpcRequest&);
RpcResponse GetTransitionDuration(const RpcRequest&);
RpcResponse GetTransitionPosition(const RpcRequest&);
// Category: Scene Items
RpcResponse GetSceneItemList(const RpcRequest&);
RpcResponse GetSceneItemProperties(const RpcRequest&);
RpcResponse SetSceneItemProperties(const RpcRequest&);
RpcResponse ResetSceneItem(const RpcRequest&);
RpcResponse SetSceneItemRender(const RpcRequest&);
RpcResponse SetSceneItemPosition(const RpcRequest&);
RpcResponse SetSceneItemTransform(const RpcRequest&);
RpcResponse SetSceneItemCrop(const RpcRequest&);
RpcResponse DeleteSceneItem(const RpcRequest&);
RpcResponse AddSceneItem(const RpcRequest&);
RpcResponse DuplicateSceneItem(const RpcRequest&);
RpcResponse SetVolume(const RpcRequest&);
// Category: Scenes
RpcResponse SetCurrentScene(const RpcRequest&);
RpcResponse GetCurrentScene(const RpcRequest&);
RpcResponse GetSceneList(const RpcRequest&);
RpcResponse CreateScene(const RpcRequest&);
RpcResponse ReorderSceneItems(const RpcRequest&);
RpcResponse SetSceneTransitionOverride(const RpcRequest&);
RpcResponse RemoveSceneTransitionOverride(const RpcRequest&);
RpcResponse GetSceneTransitionOverride(const RpcRequest&);
// Category: Sources
RpcResponse CreateSource(const RpcRequest&);
RpcResponse GetSourcesList(const RpcRequest&);
RpcResponse GetSourceTypesList(const RpcRequest&);
RpcResponse GetVolume(const RpcRequest&);
RpcResponse ToggleMute(const RpcRequest&);
RpcResponse SetMute(const RpcRequest&);
RpcResponse SetVolume(const RpcRequest&);
RpcResponse SetAudioTracks(const RpcRequest&);
RpcResponse GetAudioTracks(const RpcRequest&);
RpcResponse GetMute(const RpcRequest&);
RpcResponse SetMute(const RpcRequest&);
RpcResponse ToggleMute(const RpcRequest&);
RpcResponse GetSourceActive(const RpcRequest&);
RpcResponse GetAudioActive(const RpcRequest&);
RpcResponse SetSourceName(const RpcRequest&);
RpcResponse SetSyncOffset(const RpcRequest&);
RpcResponse GetSyncOffset(const RpcRequest&);
RpcResponse GetSpecialSources(const RpcRequest&);
RpcResponse GetSourcesList(const RpcRequest&);
RpcResponse GetSourceTypesList(const RpcRequest&);
RpcResponse GetSourceSettings(const RpcRequest&);
RpcResponse SetSourceSettings(const RpcRequest&);
RpcResponse GetAudioMonitorType(const RpcRequest&);
RpcResponse SetAudioMonitorType(const RpcRequest&);
RpcResponse TakeSourceScreenshot(const RpcRequest&);
RpcResponse GetTextGDIPlusProperties(const RpcRequest&);
RpcResponse SetTextGDIPlusProperties(const RpcRequest&);
RpcResponse GetTextFreetype2Properties(const RpcRequest&);
RpcResponse SetTextFreetype2Properties(const RpcRequest&);
RpcResponse GetBrowserSourceProperties(const RpcRequest&);
RpcResponse SetBrowserSourceProperties(const RpcRequest&);
RpcResponse GetSpecialSources(const RpcRequest&);
RpcResponse GetSourceFilters(const RpcRequest&);
RpcResponse GetSourceFilterInfo(const RpcRequest&);
RpcResponse AddFilterToSource(const RpcRequest&);
@ -131,22 +165,29 @@ class WSRequestHandler {
RpcResponse MoveSourceFilter(const RpcRequest&);
RpcResponse SetSourceFilterSettings(const RpcRequest&);
RpcResponse SetSourceFilterVisibility(const RpcRequest&);
RpcResponse GetAudioMonitorType(const RpcRequest&);
RpcResponse SetAudioMonitorType(const RpcRequest&);
RpcResponse GetSourceDefaultSettings(const RpcRequest&);
RpcResponse TakeSourceScreenshot(const RpcRequest&);
RpcResponse RefreshBrowserSource(const RpcRequest&);
RpcResponse SetCurrentSceneCollection(const RpcRequest&);
RpcResponse GetCurrentSceneCollection(const RpcRequest&);
RpcResponse ListSceneCollections(const RpcRequest&);
RpcResponse SetCurrentProfile(const RpcRequest&);
RpcResponse GetCurrentProfile(const RpcRequest&);
RpcResponse ListProfiles(const RpcRequest&);
// Category: Streaming
RpcResponse GetStreamingStatus(const RpcRequest&);
RpcResponse StartStopStreaming(const RpcRequest&);
RpcResponse StartStreaming(const RpcRequest&);
RpcResponse StopStreaming(const RpcRequest&);
RpcResponse SetStreamSettings(const RpcRequest&);
RpcResponse GetStreamSettings(const RpcRequest&);
RpcResponse SaveStreamSettings(const RpcRequest&);
#if BUILD_CAPTIONS
RpcResponse SendCaptions(const RpcRequest&);
#endif
// Category: Virtual Cam
RpcResponse GetVirtualCamStatus(const RpcRequest&);
RpcResponse StartStopVirtualCam(const RpcRequest&);
RpcResponse StartVirtualCam(const RpcRequest&);
RpcResponse StopVirtualCam(const RpcRequest&);
// Category: Studio Mode
RpcResponse GetStudioModeStatus(const RpcRequest&);
RpcResponse GetPreviewScene(const RpcRequest&);
RpcResponse SetPreviewScene(const RpcRequest&);
@ -155,17 +196,15 @@ class WSRequestHandler {
RpcResponse DisableStudioMode(const RpcRequest&);
RpcResponse ToggleStudioMode(const RpcRequest&);
RpcResponse SetTextGDIPlusProperties(const RpcRequest&);
RpcResponse GetTextGDIPlusProperties(const RpcRequest&);
RpcResponse SetTextFreetype2Properties(const RpcRequest&);
RpcResponse GetTextFreetype2Properties(const RpcRequest&);
RpcResponse SetBrowserSourceProperties(const RpcRequest&);
RpcResponse GetBrowserSourceProperties(const RpcRequest&);
RpcResponse ListOutputs(const RpcRequest&);
RpcResponse GetOutputInfo(const RpcRequest&);
RpcResponse StartOutput(const RpcRequest&);
RpcResponse StopOutput(const RpcRequest&);
// Category: Transitions
RpcResponse GetTransitionList(const RpcRequest&);
RpcResponse GetCurrentTransition(const RpcRequest&);
RpcResponse SetCurrentTransition(const RpcRequest&);
RpcResponse SetTransitionDuration(const RpcRequest&);
RpcResponse GetTransitionDuration(const RpcRequest&);
RpcResponse GetTransitionPosition(const RpcRequest&);
RpcResponse GetTransitionSettings(const RpcRequest&);
RpcResponse SetTransitionSettings(const RpcRequest&);
RpcResponse ReleaseTBar(const RpcRequest&);
RpcResponse SetTBarPosition(const RpcRequest&);
};

View File

@ -7,6 +7,7 @@
#include "Config.h"
#include "Utils.h"
#include "WSEvents.h"
#include "protocol/OBSRemoteProtocol.h"
#define CASE(x) case x: return #x;
const char *describe_output_format(int format) {
@ -114,13 +115,13 @@ RpcResponse WSRequestHandler::GetVersion(const RpcRequest& request) {
* @since 0.3
*/
RpcResponse WSRequestHandler::GetAuthRequired(const RpcRequest& request) {
bool authRequired = GetConfig()->AuthRequired;
auto config = GetConfig();
bool authRequired = (config && config->AuthRequired);
OBSDataAutoRelease data = obs_data_create();
obs_data_set_bool(data, "authRequired", authRequired);
if (authRequired) {
auto config = GetConfig();
obs_data_set_string(data, "challenge",
config->SessionChallenge.toUtf8());
obs_data_set_string(data, "salt",
@ -154,7 +155,8 @@ RpcResponse WSRequestHandler::Authenticate(const RpcRequest& request) {
return request.failed("auth not specified!");
}
if (GetConfig()->CheckAuth(auth) == false) {
auto config = GetConfig();
if (!config || (config->CheckAuth(auth) == false)) {
return request.failed("Authentication Failed.");
}
@ -171,6 +173,7 @@ RpcResponse WSRequestHandler::Authenticate(const RpcRequest& request) {
* @name SetHeartbeat
* @category general
* @since 4.3.0
* @deprecated Since 4.9.0. Please poll the appropriate data using requests. Will be removed in v5.0.0.
*/
RpcResponse WSRequestHandler::SetHeartbeat(const RpcRequest& request) {
if (!request.hasField("enable")) {
@ -231,7 +234,7 @@ RpcResponse WSRequestHandler::GetFilenameFormatting(const RpcRequest& request) {
/**
* Get OBS stats (almost the same info as provided in OBS' stats window)
*
* @return {OBSStats} `stats` OBS stats
* @return {OBSStats} `stats` [OBS stats](#obsstats)
*
* @api requests
* @name GetStats
@ -319,12 +322,12 @@ RpcResponse WSRequestHandler::GetVideoInfo(const RpcRequest& request) {
/**
* Open a projector window or create a projector on a monitor. Requires OBS v24.0.4 or newer.
*
* @param {String (Optional)} `type` Type of projector: Preview (default), Source, Scene, StudioProgram, or Multiview (case insensitive).
*
* @param {String (Optional)} `type` Type of projector: `Preview` (default), `Source`, `Scene`, `StudioProgram`, or `Multiview` (case insensitive).
* @param {int (Optional)} `monitor` Monitor to open the projector on. If -1 or omitted, opens a window.
* @param {String (Optional)} `geometry` Size and position of the projector window (only if monitor is -1). Encoded in Base64 using Qt's geometry encoding (https://doc.qt.io/qt-5/qwidget.html#saveGeometry). Corresponds to OBS's saved projectors.
* @param {String (Optional)} `geometry` Size and position of the projector window (only if monitor is -1). Encoded in Base64 using [Qt's geometry encoding](https://doc.qt.io/qt-5/qwidget.html#saveGeometry). Corresponds to OBS's saved projectors.
* @param {String (Optional)} `name` Name of the source or scene to be displayed (ignored for other projector types).
*
*
* @api requests
* @name OpenProjector
* @category general
@ -344,3 +347,151 @@ RpcResponse WSRequestHandler::OpenProjector(const RpcRequest& request) {
obs_frontend_open_projector(type, monitor, geometry, name);
return request.success();
}
/**
* Executes hotkey routine, identified by hotkey unique name
*
* @param {String} `hotkeyName` Unique name of the hotkey, as defined when registering the hotkey (e.g. "ReplayBuffer.Save")
*
* @api requests
* @name TriggerHotkeyByName
* @category general
* @since 4.9.0
*/
RpcResponse WSRequestHandler::TriggerHotkeyByName(const RpcRequest& request) {
const char* name = obs_data_get_string(request.parameters(), "hotkeyName");
obs_hotkey_t* hk = Utils::FindHotkeyByName(name);
if (!hk) {
return request.failed("hotkey not found");
}
obs_hotkey_trigger_routed_callback(obs_hotkey_get_id(hk), true);
return request.success();
}
/**
* Executes hotkey routine, identified by bound combination of keys. A single key combination might trigger multiple hotkey routines depending on user settings
*
* @param {String} `keyId` Main key identifier (e.g. `OBS_KEY_A` for key "A"). Available identifiers [here](https://github.com/obsproject/obs-studio/blob/master/libobs/obs-hotkeys.h)
* @param {Object (Optional)} `keyModifiers` Optional key modifiers object. False entries can be ommitted
* @param {boolean} `keyModifiers.shift` Trigger Shift Key
* @param {boolean} `keyModifiers.alt` Trigger Alt Key
* @param {boolean} `keyModifiers.control` Trigger Control (Ctrl) Key
* @param {boolean} `keyModifiers.command` Trigger Command Key (Mac)
*
* @api requests
* @name TriggerHotkeyBySequence
* @category general
* @since 4.9.0
*/
RpcResponse WSRequestHandler::TriggerHotkeyBySequence(const RpcRequest& request) {
if (!request.hasField("keyId")) {
return request.failed("missing request keyId parameter");
}
OBSDataAutoRelease data = obs_data_get_obj(request.parameters(), "keyModifiers");
obs_key_combination_t combo = {0};
uint32_t modifiers = 0;
if (obs_data_get_bool(data, "shift"))
modifiers |= INTERACT_SHIFT_KEY;
if (obs_data_get_bool(data, "control"))
modifiers |= INTERACT_CONTROL_KEY;
if (obs_data_get_bool(data, "alt"))
modifiers |= INTERACT_ALT_KEY;
if (obs_data_get_bool(data, "command"))
modifiers |= INTERACT_COMMAND_KEY;
combo.modifiers = modifiers;
combo.key = obs_key_from_name(obs_data_get_string(request.parameters(), "keyId"));
if (!modifiers
&& (combo.key == OBS_KEY_NONE || combo.key >= OBS_KEY_LAST_VALUE)) {
return request.failed("invalid key-modifier combination");
}
// Inject hotkey press-release sequence
obs_hotkey_inject_event(combo, false);
obs_hotkey_inject_event(combo, true);
obs_hotkey_inject_event(combo, false);
return request.success();
}
/**
* Executes a list of requests sequentially (one-by-one on the same thread).
*
* @param {Array<Object>} `requests` Array of requests to perform. Executed in order.
* @param {String} `requests.*.request-type` Request type. Eg. `GetVersion`.
* @param {String (Optional)} `requests.*.message-id` ID of the individual request. Can be any string and not required to be unique. Defaults to empty string if not specified.
* @param {boolean (Optional)} `abortOnFail` Stop processing batch requests if one returns a failure.
*
* @return {Array<Object>} `results` Batch requests results, ordered sequentially.
* @return {String} `results.*.message-id` ID of the individual request which was originally provided by the client.
* @return {String} `results.*.status` Status response as string. Either `ok` or `error`.
* @return {String (Optional)} `results.*.error` Error message accompanying an `error` status.
*
* @api requests
* @name ExecuteBatch
* @category general
* @since 4.9.0
*/
RpcResponse WSRequestHandler::ExecuteBatch(const RpcRequest& request) {
if (!request.hasField("requests")) {
return request.failed("missing request parameters");
}
bool abortOnFail = obs_data_get_bool(request.parameters(), "abortOnFail");
OBSDataArrayAutoRelease results = obs_data_array_create();
OBSDataArrayAutoRelease requests = obs_data_get_array(request.parameters(), "requests");
size_t requestsCount = obs_data_array_count(requests);
for (size_t i = 0; i < requestsCount; i++) {
OBSDataAutoRelease requestData = obs_data_array_item(requests, i);
QString messageId = obs_data_get_string(requestData, "message-id");
QString methodName = obs_data_get_string(requestData, "request-type");
obs_data_unset_user_value(requestData, "request-type");
obs_data_unset_user_value(requestData, "message-id");
// build RpcRequest from json data object
RpcRequest subRequest(messageId, methodName, requestData);
// execute the request
RpcResponse subResponse = processRequest(subRequest);
// transform response into json data
OBSDataAutoRelease subResponseData = OBSRemoteProtocol::rpcResponseToJsonData(subResponse);
obs_data_array_push_back(results, subResponseData);
// if told to abort on fail and a failure occurs, stop request processing and return the progress
if (abortOnFail && (subResponse.status() == RpcResponse::Status::Error))
break;
}
OBSDataAutoRelease response = obs_data_create();
obs_data_set_array(response, "results", results);
return request.success(response);
}
/**
* Waits for the specified duration. Designed to be used in `ExecuteBatch` operations.
*
* @param {int} `sleepMillis` Delay in milliseconds to wait before continuing.
*
* @api requests
* @name Sleep
* @category general
* @since 4.9.1
*/
RpcResponse WSRequestHandler::Sleep(const RpcRequest& request) {
if (!request.hasField("sleepMillis")) {
return request.failed("missing request parameters");
}
long long sleepMillis = obs_data_get_int(request.parameters(), "sleepMillis");
std::this_thread::sleep_for(std::chrono::milliseconds(sleepMillis));
return request.success();
}

View File

@ -0,0 +1,405 @@
#include "Utils.h"
#include "WSRequestHandler.h"
bool isMediaSource(const QString& sourceKind)
{
return (sourceKind == "vlc_source" || sourceKind == "ffmpeg_source");
}
QString getSourceMediaState(obs_source_t *source)
{
QString mediaState;
enum obs_media_state mstate = obs_source_media_get_state(source);
switch (mstate) {
case OBS_MEDIA_STATE_NONE:
mediaState = "none";
break;
case OBS_MEDIA_STATE_PLAYING:
mediaState = "playing";
break;
case OBS_MEDIA_STATE_OPENING:
mediaState = "opening";
break;
case OBS_MEDIA_STATE_BUFFERING:
mediaState = "buffering";
break;
case OBS_MEDIA_STATE_PAUSED:
mediaState = "paused";
break;
case OBS_MEDIA_STATE_STOPPED:
mediaState = "stopped";
break;
case OBS_MEDIA_STATE_ENDED:
mediaState = "ended";
break;
case OBS_MEDIA_STATE_ERROR:
mediaState = "error";
break;
default:
mediaState = "unknown";
}
return mediaState;
}
/**
* Pause or play a media source. Supports ffmpeg and vlc media sources (as of OBS v25.0.8)
* Note :Leaving out `playPause` toggles the current pause state
*
* @param {String} `sourceName` Source name.
* @param {boolean} `playPause` (optional) Whether to pause or play the source. `false` for play, `true` for pause.
*
* @api requests
* @name PlayPauseMedia
* @category media control
* @since 4.9.0
*/
RpcResponse WSRequestHandler::PlayPauseMedia(const RpcRequest& request) {
if (!request.hasField("sourceName")) {
return request.failed("missing request parameters");
}
QString sourceName = obs_data_get_string(request.parameters(), "sourceName");
bool playPause = obs_data_get_bool(request.parameters(), "playPause");
if (sourceName.isEmpty()) {
return request.failed("invalid request parameters");
}
OBSSourceAutoRelease source = obs_get_source_by_name(sourceName.toUtf8());
if (!source) {
return request.failed("specified source doesn't exist");
}
if (!request.hasField("playPause")) {
if (obs_source_media_get_state(source) == obs_media_state::OBS_MEDIA_STATE_PLAYING) {
obs_source_media_play_pause(source, true);
} else {
obs_source_media_play_pause(source, false);
}
} else {
bool playPause = obs_data_get_bool(request.parameters(), "playPause");
obs_source_media_play_pause(source, playPause);
}
return request.success();
}
/**
* Restart a media source. Supports ffmpeg and vlc media sources (as of OBS v25.0.8)
*
* @param {String} `sourceName` Source name.
*
* @api requests
* @name RestartMedia
* @category media control
* @since 4.9.0
*/
RpcResponse WSRequestHandler::RestartMedia(const RpcRequest& request) {
if (!request.hasField("sourceName")) {
return request.failed("missing request parameters");
}
QString sourceName = obs_data_get_string(request.parameters(), "sourceName");
if (sourceName.isEmpty()) {
return request.failed("invalid request parameters");
}
OBSSourceAutoRelease source = obs_get_source_by_name(sourceName.toUtf8());
if (!source) {
return request.failed("specified source doesn't exist");
}
obs_source_media_restart(source);
return request.success();
}
/**
* Stop a media source. Supports ffmpeg and vlc media sources (as of OBS v25.0.8)
*
* @param {String} `sourceName` Source name.
*
* @api requests
* @name StopMedia
* @category media control
* @since 4.9.0
*/
RpcResponse WSRequestHandler::StopMedia(const RpcRequest& request) {
if (!request.hasField("sourceName")) {
return request.failed("missing request parameters");
}
QString sourceName = obs_data_get_string(request.parameters(), "sourceName");
if (sourceName.isEmpty()) {
return request.failed("invalid request parameters");
}
OBSSourceAutoRelease source = obs_get_source_by_name(sourceName.toUtf8());
if (!source) {
return request.failed("specified source doesn't exist");
}
obs_source_media_stop(source);
return request.success();
}
/**
* Skip to the next media item in the playlist. Supports only vlc media source (as of OBS v25.0.8)
*
* @param {String} `sourceName` Source name.
*
* @api requests
* @name NextMedia
* @category media control
* @since 4.9.0
*/
RpcResponse WSRequestHandler::NextMedia(const RpcRequest& request) {
if (!request.hasField("sourceName")) {
return request.failed("missing request parameters");
}
QString sourceName = obs_data_get_string(request.parameters(), "sourceName");
if (sourceName.isEmpty()) {
return request.failed("invalid request parameters");
}
OBSSourceAutoRelease source = obs_get_source_by_name(sourceName.toUtf8());
if (!source) {
return request.failed("specified source doesn't exist");
}
obs_source_media_next(source);
return request.success();
}
/**
* Go to the previous media item in the playlist. Supports only vlc media source (as of OBS v25.0.8)
*
* @param {String} `sourceName` Source name.
*
* @api requests
* @name PreviousMedia
* @category media control
* @since 4.9.0
*/
RpcResponse WSRequestHandler::PreviousMedia(const RpcRequest& request) {
if (!request.hasField("sourceName")) {
return request.failed("missing request parameters");
}
QString sourceName = obs_data_get_string(request.parameters(), "sourceName");
if (sourceName.isEmpty()) {
return request.failed("invalid request parameters");
}
OBSSourceAutoRelease source = obs_get_source_by_name(sourceName.toUtf8());
if (!source) {
return request.failed("specified source doesn't exist");
}
obs_source_media_previous(source);
return request.success();
}
/**
* Get the length of media in milliseconds. Supports ffmpeg and vlc media sources (as of OBS v25.0.8)
* Note: For some reason, for the first 5 or so seconds that the media is playing, the total duration can be off by upwards of 50ms.
*
* @param {String} `sourceName` Source name.
*
* @return {int} `mediaDuration` The total length of media in milliseconds..
*
* @api requests
* @name GetMediaDuration
* @category media control
* @since 4.9.0
*/
RpcResponse WSRequestHandler::GetMediaDuration(const RpcRequest& request) {
if (!request.hasField("sourceName")) {
return request.failed("missing request parameters");
}
QString sourceName = obs_data_get_string(request.parameters(), "sourceName");
if (sourceName.isEmpty()) {
return request.failed("invalid request parameters");
}
OBSSourceAutoRelease source = obs_get_source_by_name(sourceName.toUtf8());
if (!source) {
return request.failed("specified source doesn't exist");
}
OBSDataAutoRelease response = obs_data_create();
obs_data_set_int(response, "mediaDuration", obs_source_media_get_duration(source));
return request.success(response);
}
/**
* Get the current timestamp of media in milliseconds. Supports ffmpeg and vlc media sources (as of OBS v25.0.8)
*
* @param {String} `sourceName` Source name.
*
* @return {int} `timestamp` The time in milliseconds since the start of the media.
*
* @api requests
* @name GetMediaTime
* @category media control
* @since 4.9.0
*/
RpcResponse WSRequestHandler::GetMediaTime(const RpcRequest& request) {
if (!request.hasField("sourceName")) {
return request.failed("missing request parameters");
}
QString sourceName = obs_data_get_string(request.parameters(), "sourceName");
if (sourceName.isEmpty()) {
return request.failed("invalid request parameters");
}
OBSSourceAutoRelease source = obs_get_source_by_name(sourceName.toUtf8());
if (!source) {
return request.failed("specified source doesn't exist");
}
OBSDataAutoRelease response = obs_data_create();
obs_data_set_int(response, "timestamp", obs_source_media_get_time(source));
return request.success(response);
}
/**
* Set the timestamp of a media source. Supports ffmpeg and vlc media sources (as of OBS v25.0.8)
*
* @param {String} `sourceName` Source name.
* @param {int} `timestamp` Milliseconds to set the timestamp to.
*
* @api requests
* @name SetMediaTime
* @category media control
* @since 4.9.0
*/
RpcResponse WSRequestHandler::SetMediaTime(const RpcRequest& request) {
if (!request.hasField("sourceName") || !request.hasField("timestamp")) {
return request.failed("missing request parameters");
}
QString sourceName = obs_data_get_string(request.parameters(), "sourceName");
int64_t timestamp = (int64_t)obs_data_get_int(request.parameters(), "timestamp");
if (sourceName.isEmpty()) {
return request.failed("invalid request parameters");
}
OBSSourceAutoRelease source = obs_get_source_by_name(sourceName.toUtf8());
if (!source) {
return request.failed("specified source doesn't exist");
}
obs_source_media_set_time(source, timestamp);
return request.success();
}
/**
* Scrub media using a supplied offset. Supports ffmpeg and vlc media sources (as of OBS v25.0.8)
* Note: Due to processing/network delays, this request is not perfect. The processing rate of this request has also not been tested.
*
* @param {String} `sourceName` Source name.
* @param {int} `timeOffset` Millisecond offset (positive or negative) to offset the current media position.
*
* @api requests
* @name ScrubMedia
* @category media control
* @since 4.9.0
*/
RpcResponse WSRequestHandler::ScrubMedia(const RpcRequest& request) {
if (!request.hasField("sourceName") || !request.hasField("timeOffset")) {
return request.failed("missing request parameters");
}
QString sourceName = obs_data_get_string(request.parameters(), "sourceName");
int64_t timeOffset = (int64_t)obs_data_get_int(request.parameters(), "timeOffset");
if (sourceName.isEmpty()) {
return request.failed("invalid request parameters");
}
OBSSourceAutoRelease source = obs_get_source_by_name(sourceName.toUtf8());
if (!source) {
return request.failed("specified source doesn't exist");
}
int64_t newTime = obs_source_media_get_time(source) + timeOffset;
if (newTime < 0) {
newTime = 0;
}
obs_source_media_set_time(source, newTime);
return request.success();
}
/**
* Get the current playing state of a media source. Supports ffmpeg and vlc media sources (as of OBS v25.0.8)
*
* @param {String} `sourceName` Source name.
*
* @return {String} `mediaState` The media state of the provided source. States: `none`, `playing`, `opening`, `buffering`, `paused`, `stopped`, `ended`, `error`, `unknown`
*
* @api requests
* @name GetMediaState
* @category media control
* @since 4.9.0
*/
RpcResponse WSRequestHandler::GetMediaState(const RpcRequest& request) {
if (!request.hasField("sourceName")) {
return request.failed("missing request parameters");
}
QString sourceName = obs_data_get_string(request.parameters(), "sourceName");
if (sourceName.isEmpty()) {
return request.failed("invalid request parameters");
}
OBSSourceAutoRelease source = obs_get_source_by_name(sourceName.toUtf8());
if (!source) {
return request.failed("specified source doesn't exist");
}
OBSDataAutoRelease response = obs_data_create();
obs_data_set_string(response, "mediaState", getSourceMediaState(source).toUtf8());
return request.success(response);
}
/**
* List the media state of all media sources (vlc and media source)
*
* @return {Array<Object>} `mediaSources` Array of sources
* @return {String} `mediaSources.*.sourceName` Unique source name
* @return {String} `mediaSources.*.sourceKind` Unique source internal type (a.k.a `ffmpeg_source` or `vlc_source`)
* @return {String} `mediaSources.*.mediaState` The current state of media for that source. States: `none`, `playing`, `opening`, `buffering`, `paused`, `stopped`, `ended`, `error`, `unknown`
*
* @api requests
* @name GetMediaSourcesList
* @category sources
* @since 4.9.0
*/
RpcResponse WSRequestHandler::GetMediaSourcesList(const RpcRequest& request)
{
OBSDataArrayAutoRelease sourcesArray = obs_data_array_create();
auto sourceEnumProc = [](void* privateData, obs_source_t* source) -> bool {
obs_data_array_t* sourcesArray = (obs_data_array_t*)privateData;
QString sourceKind = obs_source_get_id(source);
if (isMediaSource(sourceKind)) {
OBSDataAutoRelease sourceData = obs_data_create();
obs_data_set_string(sourceData, "sourceName", obs_source_get_name(source));
obs_data_set_string(sourceData, "sourceKind", sourceKind.toUtf8());
QString mediaState = getSourceMediaState(source);
obs_data_set_string(sourceData, "mediaState", mediaState.toUtf8());
obs_data_array_push_back(sourcesArray, sourceData);
}
return true;
};
obs_enum_sources(sourceEnumProc, sourcesArray);
OBSDataAutoRelease response = obs_data_create();
obs_data_set_array(response, "mediaSources", sourcesArray);
return request.success(response);
}

View File

@ -15,7 +15,7 @@
* @property {boolean} `flags.encoded` Output is encoded
* @property {boolean} `flags.multiTrack` Output uses several audio tracks
* @property {boolean} `flags.service` Output uses a service
* @property {Object} `settings` Output name
* @property {Object} `settings` Output settings
* @property {boolean} `active` Output status (active or not)
* @property {boolean} `reconnecting` Output reconnection status (reconnecting or not)
* @property {double} `congestion` Output congestion
@ -59,7 +59,7 @@ obs_data_t* getOutputInfo(obs_output_t* output)
return data;
}
RpcResponse findOutputOrFail(const RpcRequest& request, std::function<RpcResponse (obs_output_t*)> callback)
RpcResponse findOutputOrFail(const RpcRequest& request, std::function<RpcResponse (obs_output_t*, const RpcRequest&)> callback)
{
if (!request.hasField("outputName")) {
return request.failed("missing request parameters");
@ -71,7 +71,7 @@ RpcResponse findOutputOrFail(const RpcRequest& request, std::function<RpcRespons
return request.failed("specified output doesn't exist");
}
return callback(output);
return callback(output, request);
}
/**
@ -117,7 +117,7 @@ RpcResponse WSRequestHandler::ListOutputs(const RpcRequest& request)
*/
RpcResponse WSRequestHandler::GetOutputInfo(const RpcRequest& request)
{
return findOutputOrFail(request, [request](obs_output_t* output) {
return findOutputOrFail(request, [](obs_output_t* output, const RpcRequest& request) {
OBSDataAutoRelease outputInfo = getOutputInfo(output);
OBSDataAutoRelease fields = obs_data_create();
@ -129,6 +129,8 @@ RpcResponse WSRequestHandler::GetOutputInfo(const RpcRequest& request)
/**
* Start an output
*
* Note: Controlling outputs is an experimental feature of obs-websocket. Some plugins which add outputs to OBS may not function properly when they are controlled in this way.
*
* @param {String} `outputName` Output name
*
* @api requests
@ -138,7 +140,7 @@ RpcResponse WSRequestHandler::GetOutputInfo(const RpcRequest& request)
*/
RpcResponse WSRequestHandler::StartOutput(const RpcRequest& request)
{
return findOutputOrFail(request, [request](obs_output_t* output) {
return findOutputOrFail(request, [](obs_output_t* output, const RpcRequest& request) {
if (obs_output_active(output)) {
return request.failed("output already active");
}
@ -157,6 +159,8 @@ RpcResponse WSRequestHandler::StartOutput(const RpcRequest& request)
/**
* Stop an output
*
* Note: Controlling outputs is an experimental feature of obs-websocket. Some plugins which add outputs to OBS may not function properly when they are controlled in this way.
*
* @param {String} `outputName` Output name
* @param {boolean (optional)} `force` Force stop (default: false)
*
@ -167,11 +171,11 @@ RpcResponse WSRequestHandler::StartOutput(const RpcRequest& request)
*/
RpcResponse WSRequestHandler::StopOutput(const RpcRequest& request)
{
return findOutputOrFail(request, [request](obs_output_t* output) {
return findOutputOrFail(request, [](obs_output_t* output, const RpcRequest& request) {
if (!obs_output_active(output)) {
return request.failed("output not active");
}
bool forceStop = obs_data_get_bool(request.parameters(), "force");
if (forceStop) {
obs_output_force_stop(output);

View File

@ -4,7 +4,7 @@
/**
* Set the currently active profile.
*
*
* @param {String} `profile-name` Name of the desired profile.
*
* @api requests
@ -17,19 +17,28 @@ RpcResponse WSRequestHandler::SetCurrentProfile(const RpcRequest& request) {
return request.failed("missing request parameters");
}
QString profileName = obs_data_get_string(request.parameters(), "profile-name");
if (profileName.isEmpty()) {
const char* profileName = obs_data_get_string(request.parameters(), "profile-name");
if (!profileName) {
return request.failed("invalid request parameters");
}
// TODO : check if profile exists
obs_frontend_set_current_profile(profileName.toUtf8());
char** profiles = obs_frontend_get_profiles();
bool profileExists = Utils::StringInStringList(profiles, profileName);
bfree(profiles);
if (!profileExists) {
return request.failed("profile does not exist");
}
obs_queue_task(OBS_TASK_UI, [](void* param) {
obs_frontend_set_current_profile(reinterpret_cast<const char*>(param));
}, (void*)profileName, true);
return request.success();
}
/**
* Get the name of the current profile.
*
*
* @return {String} `profile-name` Name of the currently active profile.
*
* @api requests
@ -49,6 +58,7 @@ RpcResponse WSRequestHandler::GetCurrentProfile(const RpcRequest& request) {
* Get a list of available profiles.
*
* @return {Array<Object>} `profiles` List of available profiles.
* @return {String} `profiles.*.profile-name` Filter name
*
* @api requests
* @name ListProfiles

View File

@ -1,20 +1,42 @@
#include "obs-websocket.h"
#include "WSRequestHandler.h"
#include <functional>
#include <util/platform.h>
#include "Utils.h"
#include "WSEvents.h"
RpcResponse ifCanPause(const RpcRequest& request, std::function<RpcResponse()> callback)
{
if (!obs_frontend_recording_active()) {
return request.failed("recording is not active");
}
/**
* Get current recording status.
*
* @return {boolean} `isRecording` Current recording status.
* @return {boolean} `isRecordingPaused` Whether the recording is paused or not.
* @return {String (optional)} `recordTimecode` Time elapsed since recording started (only present if currently recording).
* @return {String (optional)} `recordingFilename` Absolute path to the recording file (only present if currently recording).
*
* @api requests
* @name GetRecordingStatus
* @category recording
* @since 4.9.0
*/
RpcResponse WSRequestHandler::GetRecordingStatus(const RpcRequest& request) {
auto events = GetEventsSystem();
return callback();
OBSDataAutoRelease data = obs_data_create();
obs_data_set_bool(data, "isRecording", obs_frontend_recording_active());
obs_data_set_bool(data, "isRecordingPaused", obs_frontend_recording_paused());
if (obs_frontend_recording_active()) {
QString recordingTimecode = events->getRecordingTimecode();
obs_data_set_string(data, "recordTimecode", recordingTimecode.toUtf8().constData());
obs_data_set_string(data, "recordingFilename", Utils::GetCurrentRecordingFilename());
}
return request.success(data);
}
/**
* Toggle recording on or off.
* Toggle recording on or off (depending on the current recording state).
*
* @api requests
* @name StartStopRecording
@ -72,14 +94,14 @@ RpcResponse WSRequestHandler::StartRecording(const RpcRequest& request) {
* @since 4.7.0
*/
RpcResponse WSRequestHandler::PauseRecording(const RpcRequest& request) {
return ifCanPause(request, [request]() {
if (obs_frontend_recording_paused()) {
return request.failed("recording already paused");
}
if (!obs_frontend_recording_active())
return request.failed("recording is not active");
obs_frontend_recording_pause(true);
return request.success();
});
if (obs_frontend_recording_paused())
return request.failed("recording already paused");
obs_frontend_recording_pause(true);
return request.success();
}
/**
@ -92,21 +114,21 @@ RpcResponse WSRequestHandler::PauseRecording(const RpcRequest& request) {
* @since 4.7.0
*/
RpcResponse WSRequestHandler::ResumeRecording(const RpcRequest& request) {
return ifCanPause(request, [request]() {
if (!obs_frontend_recording_paused()) {
return request.failed("recording is not paused");
}
if (!obs_frontend_recording_active())
return request.failed("recording is not active");
obs_frontend_recording_pause(false);
return request.success();
});
if (!obs_frontend_recording_paused())
return request.failed("recording is not paused");
obs_frontend_recording_pause(false);
return request.success();
}
/**
* In the current profile, sets the recording folder of the Simple and Advanced
* output modes to the specified value.
*
* Please note: if `SetRecordingFolder` is called while a recording is
* Note: If `SetRecordingFolder` is called while a recording is
* in progress, the change won't be applied immediately and will be
* effective on the next recording.
*

View File

@ -1,9 +1,29 @@
#include "obs-websocket.h"
#include "WSEvents.h"
#include "Utils.h"
#include "WSRequestHandler.h"
/**
* Get the status of the OBS replay buffer.
*
* @return {boolean} `isReplayBufferActive` Current recording status.
*
* @api requests
* @name GetReplayBufferStatus
* @category replay buffer
* @since 4.9.0
*/
RpcResponse WSRequestHandler::GetReplayBufferStatus(const RpcRequest& request) {
OBSDataAutoRelease data = obs_data_create();
obs_data_set_bool(data, "isReplayBufferActive", obs_frontend_replay_buffer_active());
return request.success(data);
}
/**
* Toggle the Replay Buffer on/off.
* Toggle the Replay Buffer on/off (depending on the current state of the replay buffer).
*
* @api requests
* @name StartStopReplayBuffer

View File

@ -2,6 +2,11 @@
#include "WSRequestHandler.h"
/**
* @typedef {Object} `ScenesCollection`
* @property {String} `sc-name` Name of the scene collection
*/
/**
* Change the active scene collection.
*
@ -17,13 +22,22 @@ RpcResponse WSRequestHandler::SetCurrentSceneCollection(const RpcRequest& reques
return request.failed("missing request parameters");
}
QString sceneCollection = obs_data_get_string(request.parameters(), "sc-name");
if (sceneCollection.isEmpty()) {
const char* sceneCollection = obs_data_get_string(request.parameters(), "sc-name");
if (!sceneCollection) {
return request.failed("invalid request parameters");
}
// TODO : Check if specified profile exists and if changing is allowed
obs_frontend_set_current_scene_collection(sceneCollection.toUtf8());
char** collections = obs_frontend_get_scene_collections();
bool collectionExists = Utils::StringInStringList(collections, sceneCollection);
bfree(collections);
if (!collectionExists) {
return request.failed("scene collection does not exist");
}
obs_queue_task(OBS_TASK_UI, [](void* param) {
obs_frontend_set_current_scene_collection(reinterpret_cast<const char*>(param));
}, (void*)sceneCollection, true);
return request.success();
}
@ -50,7 +64,7 @@ RpcResponse WSRequestHandler::GetCurrentSceneCollection(const RpcRequest& reques
/**
* List available scene collections
*
* @return {Array<String>} `scene-collections` Scene collections list
* @return {Array<ScenesCollection>} `scene-collections` Scene collections list
*
* @api requests
* @name ListSceneCollections

View File

@ -2,6 +2,78 @@
#include "WSRequestHandler.h"
/**
* Get a list of all scene items in a scene.
*
* @param {String (optional)} `sceneName` Name of the scene to get the list of scene items from. Defaults to the current scene if not specified.
*
* @return {String} `sceneName` Name of the requested (or current) scene
* @return {Array<Object>} `sceneItems` Array of scene items
* @return {int} `sceneItems.*.itemId` Unique item id of the source item
* @return {String} `sceneItems.*.sourceKind` ID if the scene item's source. For example `vlc_source` or `image_source`
* @return {String} `sceneItems.*.sourceName` Name of the scene item's source
* @return {String} `sceneItems.*.sourceType` Type of the scene item's source. Either `input`, `group`, or `scene`
*
* @api requests
* @name GetSceneItemList
* @category scene items
* @since 4.9.0
*/
RpcResponse WSRequestHandler::GetSceneItemList(const RpcRequest& request) {
const char* sceneName = obs_data_get_string(request.parameters(), "sceneName");
OBSSourceAutoRelease sceneSource;
if (sceneName && strcmp(sceneName, "") != 0) {
sceneSource = obs_get_source_by_name(sceneName);
} else {
sceneSource = obs_frontend_get_current_scene();
}
OBSScene scene = obs_scene_from_source(sceneSource);
if (!scene) {
return request.failed("requested scene is invalid or doesnt exist");
}
OBSDataArrayAutoRelease sceneItemArray = obs_data_array_create();
auto sceneItemEnumProc = [](obs_scene_t *, obs_sceneitem_t* item, void* privateData) -> bool {
obs_data_array_t* sceneItemArray = (obs_data_array_t*)privateData;
OBSDataAutoRelease sceneItemData = obs_data_create();
obs_data_set_int(sceneItemData, "itemId", obs_sceneitem_get_id(item));
OBSSource source = obs_sceneitem_get_source(item);
obs_data_set_string(sceneItemData, "sourceKind", obs_source_get_id(source));
obs_data_set_string(sceneItemData, "sourceName", obs_source_get_name(source));
QString typeString = "";
enum obs_source_type sourceType = obs_source_get_type(source);
switch (sourceType) {
case OBS_SOURCE_TYPE_INPUT:
typeString = "input";
break;
case OBS_SOURCE_TYPE_SCENE:
typeString = "scene";
break;
default:
typeString = "unknown";
break;
}
obs_data_set_string(sceneItemData, "sourceType", typeString.toUtf8());
obs_data_array_push_back(sceneItemArray, sceneItemData);
return true;
};
obs_scene_enum_items(scene, sceneItemEnumProc, sceneItemArray);
OBSDataAutoRelease response = obs_data_create();
obs_data_set_string(response, "sceneName", obs_source_get_name(sceneSource));
obs_data_set_array(response, "sceneItems", sceneItemArray);
return request.success(response);
}
/**
* Gets the scene specific properties of the specified source item.
* Coordinates are relative to the item's parent (the scene or group it belongs to).
@ -13,12 +85,13 @@
*
* @return {String} `name` Scene Item name.
* @return {int} `itemId` Scene Item ID.
* @return {int} `position.x` The x position of the source from the left.
* @return {int} `position.y` The y position of the source from the top.
* @return {int} `position.alignment` The point on the source that the item is manipulated from.
* @return {double} `position.x` The x position of the source from the left.
* @return {double} `position.y` The y position of the source from the top.
* @return {int} `position.alignment` The point on the source that the item is manipulated from. The sum of 1=Left or 2=Right, and 4=Top or 8=Bottom, or omit to center on that axis.
* @return {double} `rotation` The clockwise rotation of the item in degrees around the point of alignment.
* @return {double} `scale.x` The x-scale factor of the source.
* @return {double} `scale.y` The y-scale factor of the source.
* @return {String} `scale.filter` The scale filter of the source. Can be "OBS_SCALE_DISABLE", "OBS_SCALE_POINT", "OBS_SCALE_BICUBIC", "OBS_SCALE_BILINEAR", "OBS_SCALE_LANCZOS" or "OBS_SCALE_AREA".
* @return {int} `crop.top` The number of pixels cropped off the top of the source before scaling.
* @return {int} `crop.right` The number of pixels cropped off the right of the source before scaling.
* @return {int} `crop.bottom` The number of pixels cropped off the bottom of the source before scaling.
@ -34,10 +107,9 @@
* @return {int} `sourceHeight` Base source (without scaling) of the source
* @return {double} `width` Scene item width (base source width multiplied by the horizontal scaling factor)
* @return {double} `height` Scene item height (base source height multiplied by the vertical scaling factor)
* @return {int} `alignment` The point on the source that the item is manipulated from. The sum of 1=Left or 2=Right, and 4=Top or 8=Bottom, or omit to center on that axis.
* @return {String (optional)} `parentGroupName` Name of the item's parent (if this item belongs to a group)
* @return {Array<SceneItemTransform> (optional)} `groupChildren` List of children (if this item is a group)
*
*
* @api requests
* @name GetSceneItemProperties
* @category scene items
@ -79,12 +151,13 @@ RpcResponse WSRequestHandler::GetSceneItemProperties(const RpcRequest& request)
* @param {String | Object} `item` Scene Item name (if this field is a string) or specification (if it is an object).
* @param {String (optional)} `item.name` Scene Item name (if the `item` field is an object)
* @param {int (optional)} `item.id` Scene Item ID (if the `item` field is an object)
* @param {int (optional)} `position.x` The new x position of the source.
* @param {int (optional)} `position.y` The new y position of the source.
* @param {double (optional)} `position.x` The new x position of the source.
* @param {double (optional)} `position.y` The new y position of the source.
* @param {int (optional)} `position.alignment` The new alignment of the source.
* @param {double (optional)} `rotation` The new clockwise rotation of the item in degrees.
* @param {double (optional)} `scale.x` The new x scale of the item.
* @param {double (optional)} `scale.y` The new y scale of the item.
* @param {String (optional)} `scale.filter` The new scale filter of the source. Can be "OBS_SCALE_DISABLE", "OBS_SCALE_POINT", "OBS_SCALE_BICUBIC", "OBS_SCALE_BILINEAR", "OBS_SCALE_LANCZOS" or "OBS_SCALE_AREA".
* @param {int (optional)} `crop.top` The new amount of pixels cropped off the top of the source before scaling.
* @param {int (optional)} `crop.bottom` The new amount of pixels cropped off the bottom of the source before scaling.
* @param {int (optional)} `crop.left` The new amount of pixels cropped off the left of the source before scaling.
@ -134,10 +207,10 @@ RpcResponse WSRequestHandler::SetSceneItemProperties(const RpcRequest& request)
vec2 newPosition = oldPosition;
if (obs_data_has_user_value(reqPosition, "x")) {
newPosition.x = obs_data_get_int(reqPosition, "x");
newPosition.x = obs_data_get_double(reqPosition, "x");
}
if (obs_data_has_user_value(reqPosition, "y")) {
newPosition.y = obs_data_get_int(reqPosition, "y");
newPosition.y = obs_data_get_double(reqPosition, "y");
}
if (obs_data_has_user_value(reqPosition, "alignment")) {
@ -159,12 +232,34 @@ RpcResponse WSRequestHandler::SetSceneItemProperties(const RpcRequest& request)
}
if (request.hasField("scale")) {
OBSDataAutoRelease reqScale = obs_data_get_obj(params, "scale");
if (obs_data_has_user_value(reqScale, "filter")) {
QString newScaleFilter = obs_data_get_string(reqScale, "filter");
if (newScaleFilter == "OBS_SCALE_DISABLE") {
obs_sceneitem_set_scale_filter(sceneItem, OBS_SCALE_DISABLE);
}
else if (newScaleFilter == "OBS_SCALE_POINT") {
obs_sceneitem_set_scale_filter(sceneItem, OBS_SCALE_POINT);
}
else if (newScaleFilter == "OBS_SCALE_BICUBIC") {
obs_sceneitem_set_scale_filter(sceneItem, OBS_SCALE_BICUBIC);
}
else if (newScaleFilter == "OBS_SCALE_BILINEAR") {
obs_sceneitem_set_scale_filter(sceneItem, OBS_SCALE_BICUBIC);
}
else if (newScaleFilter == "OBS_SCALE_LANCZOS") {
obs_sceneitem_set_scale_filter(sceneItem, OBS_SCALE_LANCZOS);
}
else if (newScaleFilter == "OBS_SCALE_AREA") {
obs_sceneitem_set_scale_filter(sceneItem, OBS_SCALE_AREA);
}
}
vec2 oldScale;
obs_sceneitem_get_scale(sceneItem, &oldScale);
vec2 newScale = oldScale;
OBSDataAutoRelease reqScale = obs_data_get_obj(params, "scale");
if (obs_data_has_user_value(reqScale, "x")) {
newScale.x = obs_data_get_double(reqScale, "x");
}
@ -252,7 +347,7 @@ RpcResponse WSRequestHandler::SetSceneItemProperties(const RpcRequest& request)
}
obs_sceneitem_set_bounds(sceneItem, &newBounds);
if (obs_data_has_user_value(reqBounds, "alignment")) {
const uint32_t bounds_alignment = obs_data_get_int(reqBounds, "alignment");
if (Utils::IsValidAlignment(bounds_alignment)) {
@ -322,26 +417,27 @@ RpcResponse WSRequestHandler::ResetSceneItem(const RpcRequest& request) {
* Show or hide a specified source item in a specified scene.
*
* @param {String (optional)} `scene-name` Name of the scene the scene item belongs to. Defaults to the currently active scene.
* @param {String} `source` Scene Item name.
* @param {String (optional)} `source` Scene Item name.
* @param {int (optional)} `item` Scene Item id
* @param {boolean} `render` true = shown ; false = hidden
*
* @api requests
* @name SetSceneItemRender
* @category scene items
* @since 0.3
* @deprecated Since 4.3.0. Prefer the use of SetSceneItemProperties.
*/
RpcResponse WSRequestHandler::SetSceneItemRender(const RpcRequest& request) {
if (!request.hasField("source") ||
!request.hasField("render"))
bool doesntHaveSourceOrItemParameter = !(request.hasField("source") || request.hasField("item"));
if (!request.hasField("render") || doesntHaveSourceOrItemParameter)
{
return request.failed("missing request parameters");
}
const char* itemName = obs_data_get_string(request.parameters(), "source");
int64_t itemId = obs_data_get_int(request.parameters(), "item");
bool isVisible = obs_data_get_bool(request.parameters(), "render");
if (!itemName) {
if (!itemName && !itemId) {
return request.failed("invalid request parameters");
}
@ -351,12 +447,19 @@ RpcResponse WSRequestHandler::SetSceneItemRender(const RpcRequest& request) {
return request.failed("requested scene doesn't exist");
}
OBSSceneItemAutoRelease sceneItem =
Utils::GetSceneItemFromName(scene, itemName);
if (!sceneItem) {
return request.failed("specified scene item doesn't exist");
}
OBSSceneItemAutoRelease sceneItem;
if (strlen(itemName)) {
sceneItem = Utils::GetSceneItemFromName(scene, itemName);
if (!sceneItem) {
return request.failed("specified scene item name doesn't exist");
}
} else {
sceneItem = Utils::GetSceneItemFromId(scene, itemId);
if (!sceneItem) {
return request.failed("specified scene item ID doesn't exist");
}
}
obs_sceneitem_set_visible(sceneItem, isVisible);
return request.success();
}
@ -455,7 +558,7 @@ RpcResponse WSRequestHandler::SetSceneItemTransform(const RpcRequest& request) {
obs_sceneitem_set_scale(sceneItem, &scale);
obs_sceneitem_set_rot(sceneItem, rotation);
obs_sceneitem_defer_update_end(sceneItem);
return request.success();
@ -544,6 +647,59 @@ RpcResponse WSRequestHandler::DeleteSceneItem(const RpcRequest& request) {
return request.success();
}
/**
* Creates a scene item in a scene. In other words, this is how you add a source into a scene.
*
* @param {String} `sceneName` Name of the scene to create the scene item in
* @param {String} `sourceName` Name of the source to be added
* @param {boolean (optional)} `setVisible` Whether to make the sceneitem visible on creation or not. Default `true`
*
* @return {int} `itemId` Numerical ID of the created scene item
*
* @api requests
* @name AddSceneItem
* @category scene items
* @since 4.9.0
*/
RpcResponse WSRequestHandler::AddSceneItem(const RpcRequest& request) {
if (!request.hasField("sceneName") || !request.hasField("sourceName")) {
return request.failed("missing request parameters");
}
const char* sceneName = obs_data_get_string(request.parameters(), "sceneName");
OBSSourceAutoRelease sceneSource = obs_get_source_by_name(sceneName);
OBSScene scene = obs_scene_from_source(sceneSource);
if (!scene) {
return request.failed("requested scene is invalid or doesnt exist");
}
const char* sourceName = obs_data_get_string(request.parameters(), "sourceName");
OBSSourceAutoRelease source = obs_get_source_by_name(sourceName);
if (!source) {
return request.failed("requested source does not exist");
}
if (source == sceneSource) {
return request.failed("you cannot add a scene as a sceneitem to itself");
}
Utils::AddSourceData data;
data.source = source;
data.setVisible = true;
if (request.hasField("setVisible")) {
data.setVisible = obs_data_get_bool(request.parameters(), "setVisible");
}
obs_enter_graphics();
obs_scene_atomic_update(scene, Utils::AddSourceHelper, &data);
obs_leave_graphics();
OBSDataAutoRelease responseData = obs_data_create();
obs_data_set_int(responseData, "itemId", obs_sceneitem_get_id(data.sceneItem));
return request.success(responseData);
}
/**
* Duplicates a scene item.
*

View File

@ -36,7 +36,7 @@ RpcResponse WSRequestHandler::SetCurrentScene(const RpcRequest& request) {
/**
* Get the current scene's name and source items.
*
*
* @return {String} `name` Name of the currently active scene.
* @return {Array<SceneItem>} `sources` Ordered list of the current scene's source items.
*
@ -58,7 +58,7 @@ RpcResponse WSRequestHandler::GetCurrentScene(const RpcRequest& request) {
/**
* Get a list of scenes in the currently active profile.
*
*
* @return {String} `current-scene` Name of the currently active scene.
* @return {Array<Scene>} `scenes` Ordered list of the current profile's scenes (See [GetCurrentScene](#getcurrentscene) for more information).
*
@ -79,13 +79,39 @@ RpcResponse WSRequestHandler::GetSceneList(const RpcRequest& request) {
return request.success(data);
}
/**
* Create a new scene scene.
*
* @param {String} `sceneName` Name of the scene to create.
*
* @api requests
* @name CreateScene
* @category scenes
* @since 4.9.0
*/
RpcResponse WSRequestHandler::CreateScene(const RpcRequest& request) {
if (!request.hasField("sceneName")) {
return request.failed("missing request parameters");
}
const char* sceneName = obs_data_get_string(request.parameters(), "sceneName");
OBSSourceAutoRelease source = obs_get_source_by_name(sceneName);
if (source) {
return request.failed("scene with this name already exists");
}
obs_scene_t *createdScene = obs_scene_create(sceneName);
obs_scene_release(createdScene);
return request.success();
}
/**
* Changes the order of scene items in the requested scene.
*
* @param {String (optional)} `scene` Name of the scene to reorder (defaults to current).
* @param {Array<Scene>} `items` Ordered list of objects with name and/or id specified. Id preferred due to uniqueness per scene
* @param {int (optional)} `items[].id` Id of a specific scene item. Unique on a scene by scene basis.
* @param {String (optional)} `items[].name` Name of a scene item. Sufficiently unique if no scene items share sources within the scene.
* @param {Array<Object>} `items` Ordered list of objects with name and/or id specified. Id preferred due to uniqueness per scene
* @param {int (optional)} `items.*.id` Id of a specific scene item. Unique on a scene by scene basis.
* @param {String (optional)} `items.*.name` Name of a scene item. Sufficiently unique if no scene items share sources within the scene.
*
* @api requests
* @name ReorderSceneItems
@ -159,7 +185,7 @@ RpcResponse WSRequestHandler::ReorderSceneItems(const RpcRequest& request) {
* @api requests
* @name SetSceneTransitionOverride
* @category scenes
* @since 4.9.0
* @since 4.8.0
*/
RpcResponse WSRequestHandler::SetSceneTransitionOverride(const RpcRequest& request) {
if (!request.hasField("sceneName") || !request.hasField("transitionName")) {
@ -171,14 +197,15 @@ RpcResponse WSRequestHandler::SetSceneTransitionOverride(const RpcRequest& reque
if (!source) {
return request.failed("requested scene does not exist");
}
enum obs_source_type sourceType = obs_source_get_type(source);
if (sourceType != OBS_SOURCE_TYPE_SCENE) {
return request.failed("requested scene is invalid");
}
QString transitionName = obs_data_get_string(request.parameters(), "transitionName");
if (!Utils::GetTransitionFromName(transitionName)) {
OBSSourceAutoRelease transition = Utils::GetTransitionFromName(transitionName);
if (!transition) {
return request.failed("requested transition does not exist");
}
@ -193,7 +220,7 @@ RpcResponse WSRequestHandler::SetSceneTransitionOverride(const RpcRequest& reque
obs_frontend_get_transition_duration()
);
}
return request.success();
}
@ -205,7 +232,7 @@ RpcResponse WSRequestHandler::SetSceneTransitionOverride(const RpcRequest& reque
* @api requests
* @name RemoveSceneTransitionOverride
* @category scenes
* @since 4.9.0
* @since 4.8.0
*/
RpcResponse WSRequestHandler::RemoveSceneTransitionOverride(const RpcRequest& request) {
if (!request.hasField("sceneName")) {
@ -217,7 +244,7 @@ RpcResponse WSRequestHandler::RemoveSceneTransitionOverride(const RpcRequest& re
if (!source) {
return request.failed("requested scene does not exist");
}
enum obs_source_type sourceType = obs_source_get_type(source);
if (sourceType != OBS_SOURCE_TYPE_SCENE) {
return request.failed("requested scene is invalid");
@ -241,7 +268,7 @@ RpcResponse WSRequestHandler::RemoveSceneTransitionOverride(const RpcRequest& re
* @api requests
* @name GetSceneTransitionOverride
* @category scenes
* @since 4.9.0
* @since 4.8.0
*/
RpcResponse WSRequestHandler::GetSceneTransitionOverride(const RpcRequest& request) {
if (!request.hasField("sceneName")) {
@ -253,7 +280,7 @@ RpcResponse WSRequestHandler::GetSceneTransitionOverride(const RpcRequest& reque
if (!source) {
return request.failed("requested scene does not exist");
}
enum obs_source_type sourceType = obs_source_get_type(source);
if (sourceType != OBS_SOURCE_TYPE_SCENE) {
return request.failed("requested scene is invalid");

View File

@ -18,12 +18,81 @@ bool isTextFreeType2Source(const QString& sourceKind)
return (sourceKind == "text_ft2_source" || sourceKind == "text_ft2_source_v2");
}
/**
* Create a source and add it as a sceneitem to a scene.
*
* @param {String} `sourceName` Source name.
* @param {String} `sourceKind` Source kind, Eg. `vlc_source`.
* @param {String} `sceneName` Scene to add the new source to.
* @param {Object (optional)} `sourceSettings` Source settings data.
* @param {boolean (optional)} `setVisible` Set the created SceneItem as visible or not. Defaults to true
*
* @return {int} `itemId` ID of the SceneItem in the scene.
*
* @api requests
* @name CreateSource
* @category sources
* @since 4.9.0
*/
RpcResponse WSRequestHandler::CreateSource(const RpcRequest& request)
{
if (!request.hasField("sourceName") || !request.hasField("sourceKind") || !request.hasField("sceneName")) {
return request.failed("missing request parameters");
}
QString sourceName = obs_data_get_string(request.parameters(), "sourceName");
QString sourceKind = obs_data_get_string(request.parameters(), "sourceKind");
if (sourceName.isEmpty() || sourceKind.isEmpty()) {
return request.failed("empty sourceKind or sourceName parameters");
}
OBSSourceAutoRelease source = obs_get_source_by_name(sourceName.toUtf8());
if (source) {
return request.failed("a source with that name already exists");
}
const char* sceneName = obs_data_get_string(request.parameters(), "sceneName");
OBSSourceAutoRelease sceneSource = obs_get_source_by_name(sceneName);
OBSScene scene = obs_scene_from_source(sceneSource);
if (!scene) {
return request.failed("requested scene is invalid or doesnt exist");
}
OBSDataAutoRelease sourceSettings = nullptr;
if (request.hasField("sourceSettings")) {
sourceSettings = obs_data_get_obj(request.parameters(), "sourceSettings");
}
OBSSourceAutoRelease newSource = obs_source_create(sourceKind.toUtf8(), sourceName.toUtf8(), sourceSettings, nullptr);
if (!newSource) {
return request.failed("failed to create the source");
}
obs_source_set_enabled(newSource, true);
Utils::AddSourceData data;
data.source = newSource;
data.setVisible = true;
if (request.hasField("setVisible")) {
data.setVisible = obs_data_get_bool(request.parameters(), "setVisible");
}
obs_enter_graphics();
obs_scene_atomic_update(scene, Utils::AddSourceHelper, &data);
obs_leave_graphics();
OBSDataAutoRelease responseData = obs_data_create();
obs_data_set_int(responseData, "itemId", obs_sceneitem_get_id(data.sceneItem));
return request.success(responseData);
}
/**
* List all sources available in the running OBS instance
*
* @return {Array<Object>} `sources` Array of sources
* @return {String} `sources.*.name` Unique source name
* @return {String} `sources.*.typeId` Non-unique source internal type (a.k.a type id)
* @return {String} `sources.*.typeId` Non-unique source internal type (a.k.a kind)
* @return {String} `sources.*.type` Source type. Value is one of the following: "input", "filter", "transition", "scene" or "unknown"
*
* @api requests
@ -162,7 +231,7 @@ RpcResponse WSRequestHandler::GetSourceTypesList(const RpcRequest& request)
* @param {boolean (optional)} `useDecibel` Output volume in decibels of attenuation instead of amplitude/mul.
*
* @return {String} `name` Source name.
* @return {double} `volume` Volume of the source. Between `0.0` and `1.0` if using mul, under `0.0` if using dB (since it is attenuating).
* @return {double} `volume` Volume of the source. Between `0.0` and `20.0` if using mul, under `26.0` if using dB.
* @return {boolean} `muted` Indicates whether the source is muted.
*
* @api requests
@ -192,6 +261,10 @@ RpcResponse WSRequestHandler::GetVolume(const RpcRequest& request)
if (useDecibel) {
volume = obs_mul_to_db(volume);
}
if (volume == -INFINITY) {
volume = -100.0;
}
OBSDataAutoRelease response = obs_data_create();
obs_data_set_string(response, "name", obs_source_get_name(source));
@ -204,7 +277,7 @@ RpcResponse WSRequestHandler::GetVolume(const RpcRequest& request)
* Set the volume of the specified source. Default request format uses mul, NOT SLIDER PERCENTAGE.
*
* @param {String} `source` Source name.
* @param {double} `volume` Desired volume. Must be between `0.0` and `1.0` for mul, and under 0.0 for dB. Note: OBS will interpret dB values under -100.0 as Inf.
* @param {double} `volume` Desired volume. Must be between `0.0` and `20.0` for mul, and under 26.0 for dB. OBS will interpret dB values under -100.0 as Inf. Note: The OBS volume sliders only reach a maximum of 1.0mul/0.0dB, however OBS actually supports larger values.
* @param {boolean (optional)} `useDecibel` Interperet `volume` data as decibels instead of amplitude/mul.
*
* @api requests
@ -223,8 +296,8 @@ RpcResponse WSRequestHandler::SetVolume(const RpcRequest& request)
QString sourceName = obs_data_get_string(request.parameters(), "source");
float sourceVolume = obs_data_get_double(request.parameters(), "volume");
bool isNotValidDecibel = (useDecibel && sourceVolume > 0.0);
bool isNotValidMul = (!useDecibel && (sourceVolume < 0.0 || sourceVolume > 1.0));
bool isNotValidDecibel = (useDecibel && sourceVolume > 26.0);
bool isNotValidMul = (!useDecibel && (sourceVolume < 0.0 || sourceVolume > 20.0));
if (sourceName.isEmpty() || isNotValidDecibel || isNotValidMul) {
return request.failed("invalid request parameters");
}
@ -242,6 +315,96 @@ RpcResponse WSRequestHandler::SetVolume(const RpcRequest& request)
return request.success();
}
/**
* Changes whether an audio track is active for a source.
*
* @param {String} `sourceName` Source name.
* @param {int} `track` Audio tracks 1-6.
* @param {boolean} `active` Whether audio track is active or not.
*
* @api requests
* @name SetAudioTracks
* @category sources
* @since 4.9.1
*/
RpcResponse WSRequestHandler::SetAudioTracks(const RpcRequest& request)
{
if (!request.hasField("sourceName") || !request.hasField("track") || !request.hasField("active")) {
return request.failed("missing request parameters");
}
QString sourceName = obs_data_get_string(request.parameters(), "sourceName");
bool active = obs_data_get_bool(request.parameters(), "active");
int track = obs_data_get_int(request.parameters(), "track")-1;
if (sourceName.isEmpty() || track > 5 || track < 0) {
return request.failed("invalid request parameters");
}
OBSSourceAutoRelease source = obs_get_source_by_name(sourceName.toUtf8());
if (!source) {
return request.failed("specified source doesn't exist");
}
uint32_t mixers = obs_source_get_audio_mixers(source);
if (active && !(mixers & (1 << track)))
mixers |= (1 << track);
else if (mixers & (1 << track))
mixers &= ~(1 << track);
obs_source_set_audio_mixers(source, mixers);
return request.success();
}
/**
* Gets whether an audio track is active for a source.
*
* @param {String} `sourceName` Source name.
*
* @return {boolean} `track1`
* @return {boolean} `track2`
* @return {boolean} `track3`
* @return {boolean} `track4`
* @return {boolean} `track5`
* @return {boolean} `track6`
*
* @api requests
* @name GetAudioTracks
* @category sources
* @since 4.9.1
*/
RpcResponse WSRequestHandler::GetAudioTracks(const RpcRequest& request)
{
if (!request.hasField("sourceName")) {
return request.failed("missing request parameters");
}
QString sourceName = obs_data_get_string(request.parameters(), "sourceName");
if (sourceName.isEmpty()) {
return request.failed("invalid request parameters");
}
OBSSourceAutoRelease source = obs_get_source_by_name(sourceName.toUtf8());
if (!source) {
return request.failed("specified source doesn't exist");
}
uint32_t mixers = obs_source_get_audio_mixers(source);
OBSDataAutoRelease response = obs_data_create();
obs_data_set_string(response, "name", obs_source_get_name(source));
obs_data_set_bool(response, "track1", mixers & (1 << 0));
obs_data_set_bool(response, "track2", mixers & (1 << 1));
obs_data_set_bool(response, "track3", mixers & (1 << 2));
obs_data_set_bool(response, "track4", mixers & (1 << 3));
obs_data_set_bool(response, "track5", mixers & (1 << 4));
obs_data_set_bool(response, "track6", mixers & (1 << 5));
return request.success(response);
}
/**
* Get the mute status of a specified source.
*
@ -341,10 +504,78 @@ RpcResponse WSRequestHandler::ToggleMute(const RpcRequest& request)
return request.success();
}
/**
* Get the source's active status of a specified source (if it is showing in the final mix).
*
* @param {String} `sourceName` Source name.
*
* @return {boolean} `sourceActive` Source active status of the source.
*
* @api requests
* @name GetSourceActive
* @category sources
* @since 4.9.1
*/
RpcResponse WSRequestHandler::GetSourceActive(const RpcRequest& request)
{
if (!request.hasField("sourceName")) {
return request.failed("missing request parameters");
}
QString sourceName = obs_data_get_string(request.parameters(), "sourceName");
if (sourceName.isEmpty()) {
return request.failed("invalid request parameters");
}
OBSSourceAutoRelease source = obs_get_source_by_name(sourceName.toUtf8());
if (!source) {
return request.failed("specified source doesn't exist");
}
OBSDataAutoRelease response = obs_data_create();
obs_data_set_bool(response, "sourceActive", obs_source_active(source));
return request.success(response);
}
/**
* Get the audio's active status of a specified source.
*
* @param {String} `sourceName` Source name.
*
* @return {boolean} `audioActive` Audio active status of the source.
*
* @api requests
* @name GetAudioActive
* @category sources
* @since 4.9.0
*/
RpcResponse WSRequestHandler::GetAudioActive(const RpcRequest& request)
{
if (!request.hasField("sourceName")) {
return request.failed("missing request parameters");
}
QString sourceName = obs_data_get_string(request.parameters(), "sourceName");
if (sourceName.isEmpty()) {
return request.failed("invalid request parameters");
}
OBSSourceAutoRelease source = obs_get_source_by_name(sourceName.toUtf8());
if (!source) {
return request.failed("specified source doesn't exist");
}
OBSDataAutoRelease response = obs_data_create();
obs_data_set_bool(response, "audioActive", obs_source_audio_active(source));
return request.success(response);
}
/**
* Sets (aka rename) the name of a source. Also works with scenes since scenes are technically sources in OBS.
*
* Note: If the new name already exists as a source, OBS will automatically modify the name to not interfere.
* Note: If the new name already exists as a source, obs-websocket will return an error.
*
* @param {String} `sourceName` Source name.
* @param {String} `newName` New source name.
@ -377,7 +608,7 @@ RpcResponse WSRequestHandler::SetSourceName(const RpcRequest& request)
return request.success();
} else {
return request.failed("a source with that newSourceName already exists");
return request.failed("a source with that name already exists");
}
}
@ -473,6 +704,7 @@ RpcResponse WSRequestHandler::GetSourceSettings(const RpcRequest& request)
const char* sourceName = obs_data_get_string(request.parameters(), "sourceName");
OBSSourceAutoRelease source = obs_get_source_by_name(sourceName);
if (!source) {
return request.failed("specified source doesn't exist");
}
@ -533,21 +765,17 @@ RpcResponse WSRequestHandler::SetSourceSettings(const RpcRequest& request)
}
}
OBSDataAutoRelease currentSettings = obs_source_get_settings(source);
OBSDataAutoRelease newSettings = obs_data_get_obj(request.parameters(), "sourceSettings");
OBSDataAutoRelease sourceSettings = obs_data_create();
obs_data_apply(sourceSettings, currentSettings);
obs_data_apply(sourceSettings, newSettings);
obs_source_update(source, sourceSettings);
obs_source_update(source, newSettings);
obs_source_update_properties(source);
OBSDataAutoRelease updatedSettings = obs_source_get_settings(source);
OBSDataAutoRelease response = obs_data_create();
obs_data_set_string(response, "sourceName", obs_source_get_name(source));
obs_data_set_string(response, "sourceType", obs_source_get_id(source));
obs_data_set_obj(response, "sourceSettings", sourceSettings);
obs_data_set_obj(response, "sourceSettings", updatedSettings);
return request.success(response);
}
@ -558,8 +786,8 @@ RpcResponse WSRequestHandler::SetSourceSettings(const RpcRequest& request)
*
* @return {String} `source` Source name.
* @return {String} `align` Text Alignment ("left", "center", "right").
* @return {int} `bk-color` Background color.
* @return {int} `bk-opacity` Background opacity (0-100).
* @return {int} `bk_color` Background color.
* @return {int} `bk_opacity` Background opacity (0-100).
* @return {boolean} `chatlog` Chat log.
* @return {int} `chatlog_lines` Chat log lines.
* @return {int} `color` Text color.
@ -618,8 +846,8 @@ RpcResponse WSRequestHandler::GetTextGDIPlusProperties(const RpcRequest& request
*
* @param {String} `source` Name of the source.
* @param {String (optional)} `align` Text Alignment ("left", "center", "right").
* @param {int (optional)} `bk-color` Background color.
* @param {int (optional)} `bk-opacity` Background opacity (0-100).
* @param {int (optional)} `bk_color` Background color.
* @param {int (optional)} `bk_opacity` Background opacity (0-100).
* @param {boolean (optional)} `chatlog` Chat log.
* @param {int (optional)} `chatlog_lines` Chat log lines.
* @param {int (optional)} `color` Text color.
@ -871,10 +1099,10 @@ RpcResponse WSRequestHandler::GetTextFreetype2Properties(const RpcRequest& reque
*/
RpcResponse WSRequestHandler::SetTextFreetype2Properties(const RpcRequest& request)
{
const char* sourceName = obs_data_get_string(request.parameters(), "source");
if (!sourceName) {
const char* sourceName = obs_data_get_string(request.parameters(), "source");
if (!sourceName) {
return request.failed("invalid request parameters");
}
}
OBSSourceAutoRelease source = obs_get_source_by_name(sourceName);
if (!source) {
@ -975,7 +1203,7 @@ RpcResponse WSRequestHandler::SetTextFreetype2Properties(const RpcRequest& reque
* @name GetBrowserSourceProperties
* @category sources
* @since 4.1.0
* @deprecated Since 4.8.0. Prefer the use of GetSourceSettings.
* @deprecated Since 4.8.0. Prefer the use of GetSourceSettings. Will be removed in v5.0.0
*/
RpcResponse WSRequestHandler::GetBrowserSourceProperties(const RpcRequest& request)
{
@ -1017,7 +1245,7 @@ RpcResponse WSRequestHandler::GetBrowserSourceProperties(const RpcRequest& reque
* @api requests
* @name SetBrowserSourceProperties
* @category sources
* @deprecated Since 4.8.0. Prefer the use of SetSourceSettings.
* @deprecated Since 4.8.0. Prefer the use of SetSourceSettings. Will be removed in v5.0.0
* @since 4.1.0
*/
RpcResponse WSRequestHandler::SetBrowserSourceProperties(const RpcRequest& request)
@ -1575,17 +1803,54 @@ RpcResponse WSRequestHandler::SetAudioMonitorType(const RpcRequest& request)
return request.success();
}
/**
* Get the default settings for a given source type.
*
* @param {String} `sourceKind` Source kind. Also called "source id" in libobs terminology.
*
* @return {String} `sourceKind` Source kind. Same value as the `sourceKind` parameter.
* @return {Object} `defaultSettings` Settings object for source.
*
* @api requests
* @name GetSourceDefaultSettings
* @category sources
* @since 4.9.0
*/
RpcResponse WSRequestHandler::GetSourceDefaultSettings(const RpcRequest& request)
{
if (!request.hasField("sourceKind")) {
return request.failed("missing request parameters");
}
QString sourceKind = obs_data_get_string(request.parameters(), "sourceKind");
if (sourceKind.isEmpty()) {
return request.failed("invalid request parameters");
}
OBSDataAutoRelease defaultData = obs_get_source_defaults(sourceKind.toUtf8());
if (!defaultData) {
return request.failed("invalid sourceKind");
}
OBSDataAutoRelease defaultSettings = Utils::OBSDataGetDefaults(defaultData);
OBSDataAutoRelease response = obs_data_create();
obs_data_set_string(response, "sourceKind", sourceKind.toUtf8().constData());
obs_data_set_obj(response, "defaultSettings", defaultSettings);
return request.success(response);
}
/**
* Takes a picture snapshot of a source and then can either or both:
* - Send it over as a Data URI (base64-encoded data) in the response (by specifying `embedPictureFormat` in the request)
* - Save it to disk (by specifying `saveToFilePath` in the request)
* - Send it over as a Data URI (base64-encoded data) in the response (by specifying `embedPictureFormat` in the request)
* - Save it to disk (by specifying `saveToFilePath` in the request)
*
* At least `embedPictureFormat` or `saveToFilePath` must be specified.
*
* Clients can specify `width` and `height` parameters to receive scaled pictures. Aspect ratio is
* preserved if only one of these two parameters is specified.
*
* @param {String} `sourceName` Source name. Note that, since scenes are also sources, you can also provide a scene name.
* @param {String (optional)} `sourceName` Source name. Note: Since scenes are also sources, you can also provide a scene name. If not provided, the currently active scene is used.
* @param {String (optional)} `embedPictureFormat` Format of the Data URI encoded picture. Can be "png", "jpg", "jpeg" or "bmp" (or any other value supported by Qt's Image module)
* @param {String (optional)} `saveToFilePath` Full file path (file extension included) where the captured image is to be saved. Can be in a format different from `pictureFormat`. Can be a relative path.
* @param {String (optional)} `fileFormat` Format to save the image file as (one of the values provided in the `supported-image-export-formats` response field of `GetVersion`). If not specified, tries to guess based on file extension.
@ -1603,18 +1868,19 @@ RpcResponse WSRequestHandler::SetAudioMonitorType(const RpcRequest& request)
* @since 4.6.0
*/
RpcResponse WSRequestHandler::TakeSourceScreenshot(const RpcRequest& request) {
if (!request.hasField("sourceName")) {
return request.failed("missing request parameters");
}
if (!request.hasField("embedPictureFormat") && !request.hasField("saveToFilePath")) {
return request.failed("At least 'embedPictureFormat' or 'saveToFilePath' must be specified");
}
const char* sourceName = obs_data_get_string(request.parameters(), "sourceName");
OBSSourceAutoRelease source = obs_get_source_by_name(sourceName);
if (!source) {
return request.failed("specified source doesn't exist");;
OBSSourceAutoRelease source;
if (!request.hasField("sourceName")) {
source = obs_frontend_get_current_scene();
} else {
const char* sourceName = obs_data_get_string(request.parameters(), "sourceName");
source = obs_get_source_by_name(sourceName);
if (!source) {
return request.failed("specified source doesn't exist");;
}
}
const uint32_t sourceWidth = obs_source_get_base_width(source);
@ -1752,3 +2018,38 @@ RpcResponse WSRequestHandler::TakeSourceScreenshot(const RpcRequest& request) {
obs_data_set_string(response, "sourceName", obs_source_get_name(source));
return request.success(response);
}
/**
* Refreshes the specified browser source.
*
* @param {String} `sourceName` Source name.
*
* @api requests
* @name RefreshBrowserSource
* @category sources
* @since 4.9.0
*/
RpcResponse WSRequestHandler::RefreshBrowserSource(const RpcRequest& request)
{
if (!request.hasField("sourceName")) {
return request.failed("missing request parameters");
}
QString sourceName = obs_data_get_string(request.parameters(), "sourceName");
OBSSourceAutoRelease source = obs_get_source_by_name(sourceName.toUtf8());
if (!source) {
return request.failed("specified source doesn't exist");
}
if (strcmp(obs_source_get_id(source), "browser_source") != 0) {
return request.failed("specified source is not a browser");
}
obs_properties_t *sourceProperties = obs_source_properties(source);
obs_property_t *property = obs_properties_get(sourceProperties, "refreshnocache");
obs_property_button_clicked(property, source); // This returns a boolean but we ignore it because the browser plugin always returns `false`.
obs_properties_destroy(sourceProperties);
return request.success();
}

View File

@ -11,9 +11,12 @@
*
* @return {boolean} `streaming` Current streaming status.
* @return {boolean} `recording` Current recording status.
* @return {boolean} `recording-paused` If recording is paused.
* @return {boolean} `virtualcam` Current virtual cam status.
* @return {boolean} `preview-only` Always false. Retrocompatibility with OBSRemote.
* @return {String (optional)} `stream-timecode` Time elapsed since streaming started (only present if currently streaming).
* @return {String (optional)} `rec-timecode` Time elapsed since recording started (only present if currently recording).
* @return {boolean} `preview-only` Always false. Retrocompatibility with OBSRemote.
* @return {String (optional)} `virtualcam-timecode` Time elapsed since virtual cam started (only present if virtual cam currently active).
*
* @api requests
* @name GetStreamingStatus
@ -27,6 +30,7 @@ RpcResponse WSRequestHandler::GetStreamingStatus(const RpcRequest& request) {
obs_data_set_bool(data, "streaming", obs_frontend_streaming_active());
obs_data_set_bool(data, "recording", obs_frontend_recording_active());
obs_data_set_bool(data, "recording-paused", obs_frontend_recording_paused());
obs_data_set_bool(data, "virtualcam", obs_frontend_virtualcam_active());
obs_data_set_bool(data, "preview-only", false);
if (obs_frontend_streaming_active()) {
@ -39,11 +43,16 @@ RpcResponse WSRequestHandler::GetStreamingStatus(const RpcRequest& request) {
obs_data_set_string(data, "rec-timecode", recordingTimecode.toUtf8().constData());
}
if (obs_frontend_virtualcam_active()) {
QString virtualCamTimecode = events->getVirtualCamTimecode();
obs_data_set_string(data, "virtualcam-timecode", virtualCamTimecode.toUtf8().constData());
}
return request.success(data);
}
/**
* Toggle streaming on or off.
* Toggle streaming on or off (depending on the current stream state).
*
* @api requests
* @name StartStopStreaming
@ -61,7 +70,7 @@ RpcResponse WSRequestHandler::StartStopStreaming(const RpcRequest& request) {
* Start streaming.
* Will return an `error` if streaming is already active.
*
* @param {Object (optional)} `stream` Special stream configuration. Please note: these won't be saved to OBS' configuration.
* @param {Object (optional)} `stream` Special stream configuration. Note: these won't be saved to OBS' configuration.
* @param {String (optional)} `stream.type` If specified ensures the type of stream matches the given type (usually 'rtmp_custom' or 'rtmp_common'). If the currently configured stream type does not match the given stream type, all settings must be specified in the `settings` object or an error will occur when starting the stream.
* @param {Object (optional)} `stream.metadata` Adds the given object parameters as encoded query string parameters to the 'key' of the RTMP stream. Used to pass data to the RTMP service about the streaming. May be any String, Numeric, or Boolean field.
* @param {Object (optional)} `stream.settings` Settings for the stream.
@ -292,7 +301,6 @@ RpcResponse WSRequestHandler::SaveStreamSettings(const RpcRequest& request) {
/**
* Send the provided text as embedded CEA-608 caption data.
* As of OBS Studio 23.1, captions are not yet available on Linux.
*
* @param {String} `text` Captions text
*
@ -301,7 +309,6 @@ RpcResponse WSRequestHandler::SaveStreamSettings(const RpcRequest& request) {
* @category streaming
* @since 4.6.0
*/
#if BUILD_CAPTIONS
RpcResponse WSRequestHandler::SendCaptions(const RpcRequest& request) {
if (!request.hasField("text")) {
return request.failed("missing request parameters");
@ -316,5 +323,4 @@ RpcResponse WSRequestHandler::SendCaptions(const RpcRequest& request) {
return request.success();
}
#endif

View File

@ -166,7 +166,7 @@ RpcResponse WSRequestHandler::DisableStudioMode(const RpcRequest& request) {
}
/**
* Toggles Studio Mode.
* Toggles Studio Mode (depending on the current state of studio mode).
*
* @api requests
* @name ToggleStudioMode
@ -182,4 +182,4 @@ RpcResponse WSRequestHandler::ToggleStudioMode(const RpcRequest& request) {
}, nullptr, true);
return request.success();
}
}

View File

@ -81,7 +81,7 @@ RpcResponse WSRequestHandler::SetCurrentTransition(const RpcRequest& request) {
if (!success) {
return request.failed("requested transition does not exist");
}
return request.success();
}
@ -129,7 +129,7 @@ RpcResponse WSRequestHandler::GetTransitionDuration(const RpcRequest& request) {
* @api requests
* @name GetTransitionPosition
* @category transitions
* @since 4.8.0
* @since 4.9.0
*/
RpcResponse WSRequestHandler::GetTransitionPosition(const RpcRequest& request) {
OBSSourceAutoRelease currentTransition = obs_frontend_get_current_transition();
@ -139,3 +139,138 @@ RpcResponse WSRequestHandler::GetTransitionPosition(const RpcRequest& request) {
return request.success(response);
}
/**
* Get the current settings of a transition
*
* @param {String} `transitionName` Transition name
*
* @return {Object} `transitionSettings` Current transition settings
*
* @api requests
* @name GetTransitionSettings
* @category transitions
* @since 4.9.0
*/
RpcResponse WSRequestHandler::GetTransitionSettings(const RpcRequest& request) {
if (!request.hasField("transitionName")) {
return request.failed("missing request parameters");
}
const char* transitionName = obs_data_get_string(request.parameters(), "transitionName");
OBSSourceAutoRelease transition = Utils::GetTransitionFromName(transitionName);
if (!transition) {
return request.failed("specified transition doesn't exist");
}
OBSDataAutoRelease transitionSettings = obs_source_get_settings(transition);
OBSDataAutoRelease response = obs_data_create();
obs_data_set_obj(response, "transitionSettings", transitionSettings);
return request.success(response);
}
/**
* Change the current settings of a transition
*
* @param {String} `transitionName` Transition name
* @param {Object} `transitionSettings` Transition settings (they can be partial)
*
* @return {Object} `transitionSettings` Updated transition settings
*
* @api requests
* @name SetTransitionSettings
* @category transitions
* @since 4.9.0
*/
RpcResponse WSRequestHandler::SetTransitionSettings(const RpcRequest& request) {
if (!request.hasField("transitionName") || !request.hasField("transitionSettings")) {
return request.failed("missing request parameters");
}
const char* transitionName = obs_data_get_string(request.parameters(), "transitionName");
OBSSourceAutoRelease transition = Utils::GetTransitionFromName(transitionName);
if (!transition) {
return request.failed("specified transition doesn't exist");
}
OBSDataAutoRelease newSettings = obs_data_get_obj(request.parameters(), "transitionSettings");
obs_source_update(transition, newSettings);
obs_source_update_properties(transition);
OBSDataAutoRelease updatedSettings = obs_source_get_settings(transition);
OBSDataAutoRelease response = obs_data_create();
obs_data_set_obj(response, "transitionSettings", updatedSettings);
return request.success(response);
}
/**
* Release the T-Bar (like a user releasing their mouse button after moving it).
* *YOU MUST CALL THIS if you called `SetTBarPosition` with the `release` parameter set to `false`.*
*
* @api requests
* @name ReleaseTBar
* @category transitions
* @since 4.9.0
*/
RpcResponse WSRequestHandler::ReleaseTBar(const RpcRequest& request) {
if (!obs_frontend_preview_program_mode_active()) {
return request.failed("studio mode not enabled");
}
OBSSourceAutoRelease transition = obs_frontend_get_current_transition();
if (obs_transition_fixed(transition)) {
return request.failed("current transition doesn't support t-bar control");
}
obs_frontend_release_tbar();
return request.success();
}
/**
* Set the manual position of the T-Bar (in Studio Mode) to the specified value. Will return an error if OBS is not in studio mode
* or if the current transition doesn't support T-Bar control.
*
* If your code needs to perform multiple successive T-Bar moves (e.g. : in an animation, or in response to a user moving a T-Bar control in your User Interface), set `release` to false and call `ReleaseTBar` later once the animation/interaction is over.
*
* @param {double} `position` T-Bar position. This value must be between 0.0 and 1.0.
* @param {boolean (optional)} `release` Whether or not the T-Bar gets released automatically after setting its new position (like a user releasing their mouse button after moving the T-Bar). Call `ReleaseTBar` manually if you set `release` to false. Defaults to true.
*
* @api requests
* @name SetTBarPosition
* @category transitions
* @since 4.9.0
*/
RpcResponse WSRequestHandler::SetTBarPosition(const RpcRequest& request) {
if (!obs_frontend_preview_program_mode_active()) {
return request.failed("studio mode not enabled");
}
OBSSourceAutoRelease transition = obs_frontend_get_current_transition();
if (obs_transition_fixed(transition)) {
return request.failed("current transition doesn't support t-bar control");
}
if (!request.hasField("position")) {
return request.failed("missing request parameters");
}
double position = obs_data_get_double(request.parameters(), "position");
if (position < 0.0 || position > 1.0) {
return request.failed("position is out of range");
}
bool release = true;
if (request.hasField("release")) {
release = obs_data_get_bool(request.parameters(), "release");
}
obs_frontend_set_tbar_position((int)((float)position * 1024.0));
if (release) {
obs_frontend_release_tbar();
}
return request.success();
}

View File

@ -0,0 +1,79 @@
#include "obs-websocket.h"
#include "Utils.h"
#include "WSEvents.h"
#include "WSRequestHandler.h"
/**
* Get current virtual cam status.
*
* @return {boolean} `isVirtualCam` Current virtual camera status.
* @return {String (optional)} `virtualCamTimecode` Time elapsed since virtual cam started (only present if virtual cam currently active).
*
* @api requests
* @name GetVirtualCamStatus
* @category virtual cam
* @since 4.9.1
*/
RpcResponse WSRequestHandler::GetVirtualCamStatus(const RpcRequest& request) {
auto events = GetEventsSystem();
OBSDataAutoRelease data = obs_data_create();
obs_data_set_bool(data, "isVirtualCam", obs_frontend_virtualcam_active());
if (obs_frontend_virtualcam_active()) {
QString virtualCamTimecode = events->getVirtualCamTimecode();
obs_data_set_string(data, "virtualCamTimecode", virtualCamTimecode.toUtf8().constData());
}
return request.success(data);
}
/**
* Toggle virtual cam on or off (depending on the current virtual cam state).
*
* @api requests
* @name StartStopVirtualCam
* @category virtual cam
* @since 4.9.1
*/
RpcResponse WSRequestHandler::StartStopVirtualCam(const RpcRequest& request) {
(obs_frontend_virtualcam_active() ? obs_frontend_stop_virtualcam() : obs_frontend_start_virtualcam());
return request.success();
}
/**
* Start virtual cam.
* Will return an `error` if virtual cam is already active.
*
* @api requests
* @name StartVirtualCam
* @category virtual cam
* @since 4.9.1
*/
RpcResponse WSRequestHandler::StartVirtualCam(const RpcRequest& request) {
if (obs_frontend_virtualcam_active()) {
return request.failed("virtual cam already active");
}
obs_frontend_start_virtualcam();
return request.success();
}
/**
* Stop virtual cam.
* Will return an `error` if virtual cam is not active.
*
* @api requests
* @name StopVirtualCam
* @category virtual cam
* @since 4.9.1
*/
RpcResponse WSRequestHandler::StopVirtualCam(const RpcRequest& request) {
if (!obs_frontend_virtualcam_active()) {
return request.failed("virtual cam not active");
}
obs_frontend_stop_virtualcam();
return request.success();
}

View File

@ -44,7 +44,7 @@ WSServer::WSServer()
_connections(),
_clMutex(QMutex::Recursive)
{
_server.get_alog().clear_channels(websocketpp::log::alevel::frame_header | websocketpp::log::alevel::frame_payload | websocketpp::log::alevel::control);
_server.get_alog().clear_channels(websocketpp::log::alevel::frame_header | websocketpp::log::alevel::frame_payload | websocketpp::log::alevel::control);
_server.init_asio();
#ifndef _WIN32
_server.set_reuse_addr(true);
@ -60,10 +60,25 @@ WSServer::~WSServer()
stop();
}
void WSServer::start(quint16 port)
void WSServer::serverRunner()
{
if (_server.is_listening() && port == _serverPort) {
blog(LOG_INFO, "WSServer::start: server already on this port. no restart needed");
blog(LOG_INFO, "IO thread started.");
try {
_server.run();
} catch (websocketpp::exception const & e) {
blog(LOG_ERROR, "websocketpp instance returned an error: %s", e.what());
} catch (const std::exception & e) {
blog(LOG_ERROR, "websocketpp instance returned an error: %s", e.what());
} catch (...) {
blog(LOG_ERROR, "websocketpp instance returned an error");
}
blog(LOG_INFO, "IO thread exited.");
}
void WSServer::start(quint16 port, bool lockToIPv4)
{
if (_server.is_listening() && (port == _serverPort && _lockToIPv4 == lockToIPv4)) {
blog(LOG_INFO, "WSServer::start: server already on this port and protocol mode. no restart needed");
return;
}
@ -74,17 +89,24 @@ void WSServer::start(quint16 port)
_server.reset();
_serverPort = port;
_lockToIPv4 = lockToIPv4;
websocketpp::lib::error_code errorCode;
_server.listen(_serverPort, errorCode);
if (lockToIPv4) {
blog(LOG_INFO, "WSServer::start: Locked to IPv4 bindings");
_server.listen(websocketpp::lib::asio::ip::tcp::v4(), _serverPort, errorCode);
} else {
blog(LOG_INFO, "WSServer::start: Not locked to IPv4 bindings");
_server.listen(_serverPort, errorCode);
}
if (errorCode) {
std::string errorCodeMessage = errorCode.message();
blog(LOG_INFO, "server: listen failed: %s", errorCodeMessage.c_str());
obs_frontend_push_ui_translation(obs_module_get_string);
QString errorTitle = tr("OBSWebsocket.Server.StartFailed.Title");
QString errorMessage = tr("OBSWebsocket.Server.StartFailed.Message").arg(_serverPort).arg(errorCodeMessage.c_str());
QString errorTitle = tr("OBSWebsocketCompat.Server.StartFailed.Title");
QString errorMessage = tr("OBSWebsocketCompat.Server.StartFailed.Message").arg(_serverPort).arg(errorCodeMessage.c_str());
obs_frontend_pop_ui_translation();
QMainWindow* mainWindow = reinterpret_cast<QMainWindow*>(obs_frontend_get_main_window());
@ -95,49 +117,71 @@ void WSServer::start(quint16 port)
_server.start_accept();
QtConcurrent::run([=]() {
blog(LOG_INFO, "io thread started");
_server.run();
blog(LOG_INFO, "io thread exited");
});
_serverThread = std::thread(&WSServer::serverRunner, this);
blog(LOG_INFO, "server started successfully on port %d", _serverPort);
}
void WSServer::stop()
{
auto config = GetConfig();
if (config && config->DebugEnabled)
blog(LOG_INFO, "[WSServer::stop] Stopping...");
if (!_server.is_listening()) {
if (config && config->DebugEnabled)
blog(LOG_INFO, "[WSServer::stop] Server not listening.");
return;
}
_server.stop_listening();
for (connection_hdl hdl : _connections) {
_server.close(hdl, websocketpp::close::status::going_away, "Server stopping");
}
_connections.clear();
_connectionProperties.clear();
if (config && config->DebugEnabled)
blog(LOG_INFO, "[WSServer::stop] Closing an active connection...");
websocketpp::lib::error_code errorCode;
_server.pause_reading(hdl, errorCode);
if (errorCode) {
blog(LOG_ERROR, "Error: %s", errorCode.message().c_str());
continue;
}
_server.close(hdl, websocketpp::close::status::going_away, "Server stopping", errorCode);
if (errorCode) {
blog(LOG_ERROR, "Error: %s", errorCode.message().c_str());
continue;
}
if (config && config->DebugEnabled)
blog(LOG_INFO, "[WSServer::stop] Finished closing connection.");
}
if (config && config->DebugEnabled)
blog(LOG_INFO, "[WSServer::stop] Stopping thread pool...");
_threadPool.waitForDone();
while (!_server.stopped()) {
std::this_thread::sleep_for(std::chrono::milliseconds(1));
}
if (config && config->DebugEnabled)
blog(LOG_INFO, "[WSServer::stop] Waiting for all connections to close...");
while (_connections.size() > 0)
std::this_thread::sleep_for(std::chrono::milliseconds(10));
blog(LOG_INFO, "server stopped successfully");
if (config && config->DebugEnabled)
blog(LOG_INFO, "[WSServer::stop] Performing join on IO thread...");
_serverThread.join();
blog(LOG_INFO, "Server stopped successfully.");
}
void WSServer::broadcast(const RpcEvent& event)
{
OBSRemoteProtocol protocol;
std::string message = protocol.encodeEvent(event);
std::string message = OBSRemoteProtocol::encodeEvent(event);
if (GetConfig()->DebugEnabled) {
auto config = GetConfig();
if (config && config->DebugEnabled) {
blog(LOG_INFO, "Update << '%s'", message.c_str());
}
QMutexLocker locker(&_clMutex);
for (connection_hdl hdl : _connections) {
if (GetConfig()->AuthRequired) {
if (config && config->AuthRequired) {
bool authenticated = _connectionProperties[hdl].isAuthenticated();
if (!authenticated) {
continue;
@ -155,6 +199,11 @@ void WSServer::broadcast(const RpcEvent& event)
}
}
bool WSServer::isListening()
{
return _server.is_listening();
}
void WSServer::onOpen(connection_hdl hdl)
{
QMutexLocker locker(&_clMutex);
@ -180,15 +229,15 @@ void WSServer::onMessage(connection_hdl hdl, server::message_ptr message)
ConnectionProperties& connProperties = _connectionProperties[hdl];
locker.unlock();
if (GetConfig()->DebugEnabled) {
auto config = GetConfig();
if (config && config->DebugEnabled) {
blog(LOG_INFO, "Request >> '%s'", payload.c_str());
}
WSRequestHandler requestHandler(connProperties);
OBSRemoteProtocol protocol;
std::string response = protocol.processMessage(requestHandler, payload);
std::string response = OBSRemoteProtocol::processMessage(requestHandler, payload);
if (GetConfig()->DebugEnabled) {
if (config && config->DebugEnabled) {
blog(LOG_INFO, "Response << '%s'", response.c_str());
}
@ -212,11 +261,12 @@ void WSServer::onClose(connection_hdl hdl)
auto conn = _server.get_con_from_hdl(hdl);
auto localCloseCode = conn->get_local_close_code();
auto localCloseReason = conn->get_local_close_reason();
QString clientIp = getRemoteEndpoint(hdl);
if (localCloseCode != websocketpp::close::status::going_away) {
QString clientIp = getRemoteEndpoint(hdl);
blog(LOG_INFO, "Websocket connection with client '%s' closed (disconnected). Code is %d, reason is: '%s'", clientIp.toUtf8().constData(), localCloseCode, localCloseReason.c_str());
if (localCloseCode != websocketpp::close::status::going_away && _server.is_listening()) {
notifyDisconnection(clientIp);
blog(LOG_INFO, "client %s disconnected", clientIp.toUtf8().constData());
}
}
@ -229,8 +279,8 @@ QString WSServer::getRemoteEndpoint(connection_hdl hdl)
void WSServer::notifyConnection(QString clientIp)
{
obs_frontend_push_ui_translation(obs_module_get_string);
QString title = tr("OBSWebsocket.NotifyConnect.Title");
QString msg = tr("OBSWebsocket.NotifyConnect.Message").arg(clientIp);
QString title = tr("OBSWebsocketCompat.NotifyConnect.Title");
QString msg = tr("OBSWebsocketCompat.NotifyConnect.Message").arg(clientIp);
obs_frontend_pop_ui_translation();
Utils::SysTrayNotify(msg, QSystemTrayIcon::Information, title);
@ -239,8 +289,8 @@ void WSServer::notifyConnection(QString clientIp)
void WSServer::notifyDisconnection(QString clientIp)
{
obs_frontend_push_ui_translation(obs_module_get_string);
QString title = tr("OBSWebsocket.NotifyDisconnect.Title");
QString msg = tr("OBSWebsocket.NotifyDisconnect.Message").arg(clientIp);
QString title = tr("OBSWebsocketCompat.NotifyDisconnect.Title");
QString msg = tr("OBSWebsocketCompat.NotifyDisconnect.Message").arg(clientIp);
obs_frontend_pop_ui_translation();
Utils::SysTrayNotify(msg, QSystemTrayIcon::Information, title);

View File

@ -26,6 +26,7 @@ with this program. If not, see <https://www.gnu.org/licenses/>
#include <QtCore/QVariantHash>
#include <QtCore/QThreadPool>
#include <asio.hpp>
#include <websocketpp/config/asio_no_tls.hpp>
#include <websocketpp/server.hpp>
@ -44,14 +45,17 @@ Q_OBJECT
public:
explicit WSServer();
virtual ~WSServer();
void start(quint16 port);
void start(quint16 port, bool lockToIPv4);
void stop();
void broadcast(const RpcEvent& event);
bool isListening();
QThreadPool* threadPool() {
return &_threadPool;
}
private:
void serverRunner();
void onOpen(connection_hdl hdl);
void onMessage(connection_hdl hdl, server::message_ptr message);
void onClose(connection_hdl hdl);
@ -60,8 +64,10 @@ private:
void notifyConnection(QString clientIp);
void notifyDisconnection(QString clientIp);
std::thread _serverThread;
server _server;
quint16 _serverPort;
bool _lockToIPv4;
std::set<connection_hdl, std::owner_less<connection_hdl>> _connections;
std::map<connection_hdl, ConnectionProperties, std::owner_less<connection_hdl>> _connectionProperties;
QMutex _clMutex;

View File

@ -16,12 +16,16 @@ You should have received a copy of the GNU General Public License along
with this program. If not, see <https://www.gnu.org/licenses/>
*/
#include "settings-dialog.h"
#include <obs-frontend-api.h>
#include <obs-module.h>
#include <QtWidgets/QMessageBox>
#include "../obs-websocket.h"
#include "../Config.h"
#include "../WSServer.h"
#include "settings-dialog.h"
#define CHANGE_ME "changeme"
@ -35,22 +39,25 @@ SettingsDialog::SettingsDialog(QWidget* parent) :
this, &SettingsDialog::AuthCheckboxChanged);
connect(ui->buttonBox, &QDialogButtonBox::accepted,
this, &SettingsDialog::FormAccepted);
AuthCheckboxChanged();
}
void SettingsDialog::showEvent(QShowEvent* event) {
auto conf = GetConfig();
if (conf) {
ui->serverEnabled->setChecked(conf->ServerEnabled);
ui->serverPort->setValue(conf->ServerPort);
ui->lockToIPv4->setChecked(conf->LockToIPv4);
ui->serverEnabled->setChecked(conf->ServerEnabled);
ui->serverPort->setValue(conf->ServerPort);
ui->debugEnabled->setChecked(conf->DebugEnabled);
ui->alertsEnabled->setChecked(conf->AlertsEnabled);
ui->debugEnabled->setChecked(conf->DebugEnabled);
ui->alertsEnabled->setChecked(conf->AlertsEnabled);
ui->authRequired->blockSignals(true);
ui->authRequired->setChecked(conf->AuthRequired);
ui->authRequired->blockSignals(false);
}
ui->authRequired->setChecked(conf->AuthRequired);
ui->password->setText(CHANGE_ME);
ui->password->setEnabled(ui->authRequired->isChecked());
}
void SettingsDialog::ToggleShowHide() {
@ -60,18 +67,41 @@ void SettingsDialog::ToggleShowHide() {
setVisible(false);
}
void SettingsDialog::PreparePasswordEntry() {
ui->authRequired->blockSignals(true);
ui->authRequired->setChecked(true);
ui->authRequired->blockSignals(false);
ui->password->setEnabled(true);
ui->password->setFocus();
}
void SettingsDialog::AuthCheckboxChanged() {
if (ui->authRequired->isChecked())
if (ui->authRequired->isChecked()) {
ui->password->setEnabled(true);
else
ui->password->setEnabled(false);
}
else {
obs_frontend_push_ui_translation(obs_module_get_string);
QString authDisabledWarning = QObject::tr("OBSWebsocketCompat.Settings.AuthDisabledWarning");
obs_frontend_pop_ui_translation();
QMessageBox::StandardButton response = QMessageBox::question(this, "obs-websocket 4.9.1-compat", authDisabledWarning);
if (response == QMessageBox::Yes) {
ui->password->setEnabled(false);
} else {
ui->authRequired->setChecked(true);
}
}
}
void SettingsDialog::FormAccepted() {
auto conf = GetConfig();
if (!conf) {
return;
}
conf->ServerEnabled = ui->serverEnabled->isChecked();
conf->ServerPort = ui->serverPort->value();
conf->LockToIPv4 = ui->lockToIPv4->isChecked();
conf->DebugEnabled = ui->debugEnabled->isChecked();
conf->AlertsEnabled = ui->alertsEnabled->isChecked();
@ -81,7 +111,7 @@ void SettingsDialog::FormAccepted() {
conf->SetPassword(ui->password->text());
}
if (!GetConfig()->Secret.isEmpty())
if (!conf->Secret.isEmpty())
conf->AuthRequired = true;
else
conf->AuthRequired = false;
@ -95,7 +125,7 @@ void SettingsDialog::FormAccepted() {
auto server = GetServer();
if (conf->ServerEnabled) {
server->start(conf->ServerPort);
server->start(conf->ServerPort, conf->LockToIPv4);
} else {
server->stop();
}

View File

@ -31,6 +31,7 @@ public:
~SettingsDialog();
void showEvent(QShowEvent* event);
void ToggleShowHide();
void PreparePasswordEntry();
private Q_SLOTS:
void AuthCheckboxChanged();

View File

@ -2,150 +2,157 @@
<ui version="4.0">
<class>SettingsDialog</class>
<widget class="QDialog" name="SettingsDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>407</width>
<height>195</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>OBSWebsocket.Settings.DialogTitle</string>
</property>
<property name="sizeGripEnabled">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<layout class="QFormLayout" name="formLayout">
<item row="3" column="1">
<widget class="QCheckBox" name="authRequired">
<property name="text">
<string>OBSWebsocket.Settings.AuthRequired</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="lbl_password">
<property name="text">
<string>OBSWebsocket.Settings.Password</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="password">
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="serverEnabled">
<property name="text">
<string>OBSWebsocket.Settings.ServerEnable</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="lbl_serverPort">
<property name="text">
<string>OBSWebsocket.Settings.ServerPort</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="serverPort">
<property name="minimum">
<number>1024</number>
</property>
<property name="maximum">
<number>65535</number>
</property>
<property name="value">
<number>4444</number>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QCheckBox" name="alertsEnabled">
<property name="text">
<string>OBSWebsocket.Settings.AlertsEnable</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QCheckBox" name="debugEnabled">
<property name="text">
<string>OBSWebsocket.Settings.DebugEnable</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>407</width>
<height>216</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>OBSWebsocketCompat.Settings.DialogTitle</string>
</property>
<property name="sizeGripEnabled">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<layout class="QFormLayout" name="formLayout">
<item row="3" column="1">
<widget class="QCheckBox" name="authRequired">
<property name="text">
<string>OBSWebsocketCompat.Settings.AuthRequired</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="lbl_password">
<property name="text">
<string>OBSWebsocketCompat.Settings.Password</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="password">
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="serverEnabled">
<property name="text">
<string>OBSWebsocketCompat.Settings.ServerEnable</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="lbl_serverPort">
<property name="text">
<string>OBSWebsocketCompat.Settings.ServerPort</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="serverPort">
<property name="minimum">
<number>1024</number>
</property>
<property name="maximum">
<number>65535</number>
</property>
<property name="value">
<number>4444</number>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QCheckBox" name="alertsEnabled">
<property name="text">
<string>OBSWebsocketCompat.Settings.AlertsEnable</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QCheckBox" name="debugEnabled">
<property name="text">
<string>OBSWebsocketCompat.Settings.DebugEnable</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QCheckBox" name="lockToIPv4">
<property name="text">
<string>OBSWebsocketCompat.Settings.LockToIPv4</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>SettingsDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>294</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>314</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>SettingsDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>300</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>314</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>SettingsDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>294</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>314</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>SettingsDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>300</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>314</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -30,12 +30,6 @@ with this program. If not, see <https://www.gnu.org/licenses/>
#include "Config.h"
#include "forms/settings-dialog.h"
void ___source_dummy_addref(obs_source_t*) {}
void ___sceneitem_dummy_addref(obs_sceneitem_t*) {}
void ___data_dummy_addref(obs_data_t*) {}
void ___data_array_dummy_addref(obs_data_array_t*) {}
void ___output_dummy_addref(obs_output_t*) {}
void ___data_item_dummy_addref(obs_data_item_t*) {}
void ___data_item_release(obs_data_item_t* dataItem) {
obs_data_item_release(&dataItem);
@ -47,11 +41,13 @@ OBS_MODULE_USE_DEFAULT_LOCALE("obs-websocket", "en-US")
ConfigPtr _config;
WSServerPtr _server;
WSEventsPtr _eventsSystem;
SettingsDialog* settingsDialog = nullptr;
bool obs_module_load(void) {
blog(LOG_INFO, "you can haz websockets (version %s)", OBS_WEBSOCKET_VERSION);
blog(LOG_INFO, "qt version (compile-time): %s ; qt version (run-time): %s",
QT_VERSION_STR, qVersion());
blog(LOG_INFO, "[obs_module_load] Linked ASIO Version: %d", ASIO_VERSION);
// Core setup
_config = ConfigPtr(new Config());
@ -64,14 +60,14 @@ bool obs_module_load(void) {
// UI setup
obs_frontend_push_ui_translation(obs_module_get_string);
QMainWindow* mainWindow = (QMainWindow*)obs_frontend_get_main_window();
SettingsDialog* settingsDialog = new SettingsDialog(mainWindow);
settingsDialog = new SettingsDialog(mainWindow);
obs_frontend_pop_ui_translation();
const char* menuActionText =
obs_module_text("OBSWebsocket.Settings.DialogTitle");
obs_module_text("OBSWebsocketCompat.Settings.DialogTitle");
QAction* menuAction =
(QAction*)obs_frontend_add_tools_menu_qaction(menuActionText);
QObject::connect(menuAction, &QAction::triggered, [settingsDialog] {
QObject::connect(menuAction, &QAction::triggered, [] {
// The settings dialog belongs to the main window. Should be ok
// to pass the pointer to this QAction belonging to the main window
settingsDialog->ToggleShowHide();
@ -81,7 +77,7 @@ bool obs_module_load(void) {
auto eventCallback = [](enum obs_frontend_event event, void *param) {
if (event == OBS_FRONTEND_EVENT_FINISHED_LOADING) {
if (_config->ServerEnabled) {
_server->start(_config->ServerPort);
_server->start(_config->ServerPort, _config->LockToIPv4);
}
obs_frontend_remove_event_callback((obs_frontend_event_cb)param, nullptr);
}
@ -115,3 +111,10 @@ WSServerPtr GetServer() {
WSEventsPtr GetEventsSystem() {
return _eventsSystem;
}
void ShowPasswordSetting() {
if (settingsDialog) {
settingsDialog->PreparePasswordEntry();
settingsDialog->setVisible(true);
}
}

View File

@ -21,23 +21,6 @@ with this program. If not, see <https://www.gnu.org/licenses/>
#include <obs.hpp>
#include <memory>
void ___source_dummy_addref(obs_source_t*);
void ___sceneitem_dummy_addref(obs_sceneitem_t*);
void ___data_dummy_addref(obs_data_t*);
void ___data_array_dummy_addref(obs_data_array_t*);
void ___output_dummy_addref(obs_output_t*);
using OBSSourceAutoRelease =
OBSRef<obs_source_t*, ___source_dummy_addref, obs_source_release>;
using OBSSceneItemAutoRelease =
OBSRef<obs_sceneitem_t*, ___sceneitem_dummy_addref, obs_sceneitem_release>;
using OBSDataAutoRelease =
OBSRef<obs_data_t*, ___data_dummy_addref, obs_data_release>;
using OBSDataArrayAutoRelease =
OBSRef<obs_data_array_t*, ___data_array_dummy_addref, obs_data_array_release>;
using OBSOutputAutoRelease =
OBSRef<obs_output_t*, ___output_dummy_addref, obs_output_release>;
void ___data_item_dummy_addref(obs_data_item_t*);
void ___data_item_release(obs_data_item_t*);
using OBSDataItemAutoRelease =
@ -55,7 +38,8 @@ typedef std::shared_ptr<WSEvents> WSEventsPtr;
ConfigPtr GetConfig();
WSServerPtr GetServer();
WSEventsPtr GetEventsSystem();
void ShowPasswordSetting();
#define OBS_WEBSOCKET_VERSION "4.8.0"
#define OBS_WEBSOCKET_VERSION "4.9.1-compat"
#define blog(level, msg, ...) blog(level, "[obs-websocket] " msg, ##__VA_ARGS__)
#define blog(level, msg, ...) blog(level, "[obs-websocket 4.9.1-compat] " msg, ##__VA_ARGS__)

View File

@ -0,0 +1,31 @@
/*
obs-websocket
Copyright (C) 2016-2021 Stephane Lepin <stephane.lepin@gmail.com>
Copyright (C) 2020-2021 Kyle Manning <tt2468@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program. If not, see <https://www.gnu.org/licenses/>
*/
#pragma once
#include <util/base.h>
#define blog(level, msg, ...) blog(level, "[obs-websocket] " msg, ##__VA_ARGS__)
#define blog_debug(msg, ...) if (IsDebugEnabled()) blog(LOG_INFO, "[debug] " msg, ##__VA_ARGS__)
#define OBS_WEBSOCKET_VERSION "5.0.0"
#define OBS_WEBSOCKET_RPC_VERSION 1
#define QT_TO_UTF8(str) str.toUtf8().constData()

View File

@ -31,11 +31,15 @@ std::string OBSRemoteProtocol::processMessage(WSRequestHandler& requestHandler,
OBSDataAutoRelease data = obs_data_create_from_json(msg);
if (!data) {
blog(LOG_ERROR, "invalid JSON payload received for '%s'", msg);
return errorResponse(QString::Null(), "invalid JSON payload");
return jsonDataToString(
errorResponse(nullptr, "invalid JSON payload")
);
}
if (!obs_data_has_user_value(data, "request-type") || !obs_data_has_user_value(data, "message-id")) {
return errorResponse(QString::Null(), "missing request parameters");
return jsonDataToString(
errorResponse(nullptr, "missing request parameters")
);
}
QString methodName = obs_data_get_string(data, "request-type");
@ -49,15 +53,8 @@ std::string OBSRemoteProtocol::processMessage(WSRequestHandler& requestHandler,
RpcRequest request(messageId, methodName, params);
RpcResponse response = requestHandler.processRequest(request);
OBSData additionalFields = response.additionalFields();
switch (response.status()) {
case RpcResponse::Status::Ok:
return successResponse(messageId, additionalFields);
case RpcResponse::Status::Error:
return errorResponse(messageId, response.errorMessage(), additionalFields);
}
return std::string();
OBSDataAutoRelease responseData = rpcResponseToJsonData(response);
return jsonDataToString(responseData);
}
std::string OBSRemoteProtocol::encodeEvent(const RpcEvent& event)
@ -67,15 +64,15 @@ std::string OBSRemoteProtocol::encodeEvent(const RpcEvent& event)
QString updateType = event.updateType();
obs_data_set_string(eventData, "update-type", updateType.toUtf8().constData());
std::optional<uint64_t> streamTime = event.streamTime();
if (streamTime.has_value()) {
QString streamingTimecode = Utils::nsToTimestamp(streamTime.value());
auto streamTime = event.streamTime();
if (streamTime) {
QString streamingTimecode = Utils::nsToTimestamp(streamTime);
obs_data_set_string(eventData, "stream-timecode", streamingTimecode.toUtf8().constData());
}
std::optional<uint64_t> recordingTime = event.recordingTime();
if (recordingTime.has_value()) {
QString recordingTimecode = Utils::nsToTimestamp(recordingTime.value());
auto recordingTime = event.recordingTime();
if (recordingTime) {
QString recordingTimecode = Utils::nsToTimestamp(recordingTime);
obs_data_set_string(eventData, "rec-timecode", recordingTimecode.toUtf8().constData());
}
@ -87,33 +84,56 @@ std::string OBSRemoteProtocol::encodeEvent(const RpcEvent& event)
return std::string(obs_data_get_json(eventData));
}
std::string OBSRemoteProtocol::buildResponse(QString messageId, QString status, obs_data_t* fields)
obs_data_t* OBSRemoteProtocol::rpcResponseToJsonData(const RpcResponse& response)
{
OBSDataAutoRelease response = obs_data_create();
if (!messageId.isNull()) {
obs_data_set_string(response, "message-id", messageId.toUtf8().constData());
}
obs_data_set_string(response, "status", status.toUtf8().constData());
QByteArray messageIdBytes = response.messageId().toUtf8();
const char* messageId = messageIdBytes.constData();
if (fields) {
obs_data_apply(response, fields);
OBSData additionalFields = response.additionalFields();
switch (response.status()) {
case RpcResponse::Status::Ok:
return successResponse(messageId, additionalFields);
case RpcResponse::Status::Error:
return errorResponse(messageId, response.errorMessage().toUtf8().constData(), additionalFields);
default:
assert(false);
}
std::string responseString = obs_data_get_json(response);
return responseString;
return nullptr;
}
std::string OBSRemoteProtocol::successResponse(QString messageId, obs_data_t* fields)
obs_data_t* OBSRemoteProtocol::successResponse(const char* messageId, obs_data_t* fields)
{
return buildResponse(messageId, "ok", fields);
}
std::string OBSRemoteProtocol::errorResponse(QString messageId, QString errorMessage, obs_data_t* additionalFields)
obs_data_t* OBSRemoteProtocol::errorResponse(const char* messageId, const char* errorMessage, obs_data_t* additionalFields)
{
OBSDataAutoRelease fields = obs_data_create();
if (additionalFields) {
obs_data_apply(fields, additionalFields);
}
obs_data_set_string(fields, "error", errorMessage.toUtf8().constData());
obs_data_set_string(fields, "error", errorMessage);
return buildResponse(messageId, "error", fields);
}
obs_data_t* OBSRemoteProtocol::buildResponse(const char* messageId, const char* status, obs_data_t* fields)
{
obs_data_t* response = obs_data_create();
if (messageId) {
obs_data_set_string(response, "message-id", messageId);
}
obs_data_set_string(response, "status", status);
if (fields) {
obs_data_apply(response, fields);
}
return response;
}
std::string OBSRemoteProtocol::jsonDataToString(obs_data_t *data)
{
std::string responseString = obs_data_get_json(data);
return responseString;
}

View File

@ -20,7 +20,8 @@ with this program. If not, see <https://www.gnu.org/licenses/>
#include <string>
#include <obs-data.h>
#include <QtCore/QString>
#include "../rpc/RpcResponse.h"
class WSRequestHandler;
class RpcEvent;
@ -28,11 +29,13 @@ class RpcEvent;
class OBSRemoteProtocol
{
public:
std::string processMessage(WSRequestHandler& requestHandler, std::string message);
std::string encodeEvent(const RpcEvent& event);
static std::string processMessage(WSRequestHandler& requestHandler, std::string message);
static std::string encodeEvent(const RpcEvent& event);
static obs_data_t* rpcResponseToJsonData(const RpcResponse& response);
private:
std::string buildResponse(QString messageId, QString status, obs_data_t* fields = nullptr);
std::string successResponse(QString messageId, obs_data_t* fields = nullptr);
std::string errorResponse(QString messageId, QString errorMessage, obs_data_t* additionalFields = nullptr);
static obs_data_t* successResponse(const char* messageId, obs_data_t* fields = nullptr);
static obs_data_t* errorResponse(const char* messageId, const char* errorMessage, obs_data_t* additionalFields = nullptr);
static obs_data_t* buildResponse(const char* messageId, const char*, obs_data_t* fields = nullptr);
static std::string jsonDataToString(obs_data_t *data);
};

View File

@ -20,7 +20,7 @@ with this program. If not, see <https://www.gnu.org/licenses/>
RpcEvent::RpcEvent(
const QString& updateType,
std::optional<uint64_t> streamTime, std::optional<uint64_t> recordingTime,
uint64_t streamTime, uint64_t recordingTime,
obs_data_t* additionalFields
) :
_updateType(updateType),

View File

@ -18,7 +18,6 @@ with this program. If not, see <https://www.gnu.org/licenses/>
#pragma once
#include <optional>
#include <obs-data.h>
#include <QtCore/QString>
@ -29,7 +28,7 @@ class RpcEvent
public:
explicit RpcEvent(
const QString& updateType,
std::optional<uint64_t> streamTime, std::optional<uint64_t> recordingTime,
uint64_t streamTime, uint64_t recordingTime,
obs_data_t* additionalFields = nullptr
);
@ -38,12 +37,12 @@ public:
return _updateType;
}
const std::optional<uint64_t> streamTime() const
const uint64_t streamTime() const
{
return _streamTime;
}
const std::optional<uint64_t> recordingTime() const
const uint64_t recordingTime() const
{
return _recordingTime;
}
@ -55,7 +54,7 @@ public:
private:
QString _updateType;
std::optional<uint64_t> _streamTime;
std::optional<uint64_t> _recordingTime;
uint64_t _streamTime;
uint64_t _recordingTime;
OBSDataAutoRelease _additionalFields;
};

View File

@ -36,7 +36,7 @@ public:
obs_data_t* additionalFields = nullptr
);
Status status() {
const Status status() const {
return _status;
}