mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
Compare commits
1039 Commits
4.3.3
...
4.x-compat
Author | SHA1 | Date | |
---|---|---|---|
7906057440 | |||
96c6b03aa6 | |||
7ea9b16b37 | |||
ff6b774687 | |||
9bdaefded9 | |||
4a88612693 | |||
f8a88c54ce | |||
df2049b751 | |||
dc9afeb213 | |||
13c1c108ea | |||
16ee66e6dc | |||
d563dd3146 | |||
65a17071d2 | |||
d993ce8b1a | |||
9c4a114c94 | |||
7062062ec5 | |||
be7c334a72 | |||
b5f267d3bb | |||
d0d89dd133 | |||
a0e8cb6b4c | |||
348e875969 | |||
be0fb682e0 | |||
ea8f14e41b | |||
a8a3f3aafe | |||
387376e5e0 | |||
80cefdcfda | |||
6a14110720 | |||
8bfe2bf04c | |||
bbf4b321d7 | |||
310c297a36 | |||
5d14cb7af8 | |||
48291506f5 | |||
b0badd0630 | |||
c5ef671e0c | |||
ffb97aaabc | |||
d05ff26930 | |||
535083205a | |||
9a8d283d27 | |||
1eb02e77e0 | |||
b271cf9d32 | |||
0a084122d3 | |||
a29e0325dd | |||
4ea010f168 | |||
b03ab12e45 | |||
9311b38747 | |||
2380ba4612 | |||
60e2f0183e | |||
8009f65ed0 | |||
393fca6aed | |||
f8abe91b83 | |||
27ab3e0ea8 | |||
1ca10f3e34 | |||
c1cd1adb08 | |||
1266b3f3fe | |||
5505e0d7b5 | |||
a469fc539a | |||
ef36585319 | |||
46214eef44 | |||
5f0b152427 | |||
cbc7664b78 | |||
39bc97a51c | |||
017e551a91 | |||
19dad7775c | |||
de15118872 | |||
bb81e1e0ab | |||
58b49fed85 | |||
6740e5fec7 | |||
fe9419fb8a | |||
ba93b05efa | |||
d154e77299 | |||
2f8073d548 | |||
1f0c1691be | |||
50eedd11e0 | |||
6f50628172 | |||
4256f2df8b | |||
344f7c33e4 | |||
39454bc13e | |||
fcffa55af1 | |||
b74afd1033 | |||
ff548589bc | |||
f2f80c4e7e | |||
381745dbf6 | |||
1b61bd9551 | |||
415fb73245 | |||
458d59b401 | |||
ffb24da135 | |||
436cec69c2 | |||
30e2a5428f | |||
1154ba5b14 | |||
ffd89dbdeb | |||
b61211b4cb | |||
30af0cbd9a | |||
349ef5be97 | |||
7e0bc1fd10 | |||
b7bd95dcc4 | |||
fde1ada699 | |||
7556c5f855 | |||
4505612f75 | |||
035767bbbb | |||
8e43958f3d | |||
2be20a9179 | |||
77f63359f6 | |||
b13822db8d | |||
35c524c604 | |||
8c4374825d | |||
687d08afa2 | |||
8616d36204 | |||
c22199b8eb | |||
1deaedb7da | |||
452a307b33 | |||
0db1abcd2e | |||
01c898b104 | |||
2344842163 | |||
b8e693c97d | |||
99e66cc317 | |||
18468c17f2 | |||
6f0d056059 | |||
6b05d0381e | |||
e8c4d2b550 | |||
7e14032d2b | |||
bb0a0acbda | |||
9bbfb73622 | |||
d45d98d536 | |||
9e554ce527 | |||
6217f009fd | |||
46473126d2 | |||
b6ee6e9e22 | |||
1891f62c22 | |||
212d1cbfc2 | |||
73d93e476f | |||
80d82861ae | |||
8d034f53a4 | |||
6d3aa3a828 | |||
ed23aba0ac | |||
3847e5d6af | |||
f4465e2e9b | |||
fe2e87074a | |||
5b100d15d7 | |||
87cd36673e | |||
47b84f7316 | |||
a18da3e6cd | |||
6bb33fa18b | |||
59e6695a5d | |||
861cde7e61 | |||
e95d8d36aa | |||
04304ecf94 | |||
3989ea0780 | |||
e39585befc | |||
20fa14563c | |||
10910aa06d | |||
e6c2c90677 | |||
98712c7b71 | |||
2015d40186 | |||
a8aa34529e | |||
38cf0270b1 | |||
c8ca79f00b | |||
c02382b6e5 | |||
cb7c77d29e | |||
83e23c9c41 | |||
c6db90ae07 | |||
c2aa7263bd | |||
25be7ee14e | |||
332876495d | |||
6cbe50e3e7 | |||
599eaf85ce | |||
c03ca47e37 | |||
2246ce5142 | |||
79774921e4 | |||
ab453a0322 | |||
3725e400ce | |||
9859c7b25f | |||
056c1ef1fc | |||
41fbfb159a | |||
740a8a8d06 | |||
59ab9548c2 | |||
a1cf7f8d32 | |||
0d59983d1a | |||
488a57e2de | |||
dd9ad67e6b | |||
492e9d8df7 | |||
bc3b09dce4 | |||
5fd95ce374 | |||
77380a098e | |||
afc9c549d6 | |||
77f38bbf63 | |||
853eeb2e6b | |||
6ed6b4a679 | |||
99987f9373 | |||
b02239f3e3 | |||
bc436e9ec4 | |||
7e0874abb4 | |||
3d704702ba | |||
2735f80637 | |||
9275f7c2a9 | |||
229641aba0 | |||
ba143f2636 | |||
ffb34c3fd4 | |||
31c717eb40 | |||
7ae016bd3b | |||
501e0f63f5 | |||
a42398c457 | |||
d77e4ab10d | |||
8a8ea92140 | |||
adc46a80f9 | |||
3203f50a43 | |||
3dea5fd4f4 | |||
1024a2198a | |||
c8f0d5a3e4 | |||
3e55b3d7bc | |||
a93c4dfbbd | |||
aceb437c5f | |||
a137ccd8ba | |||
96bd4141fd | |||
e794762f72 | |||
9999b30d1a | |||
569e9681e5 | |||
9edc3eafa3 | |||
a1fcc35fd6 | |||
80d21ce80d | |||
08178b9354 | |||
60ce25c689 | |||
eaf34f3c3a | |||
ef0e907014 | |||
9fb0f56aa0 | |||
ae9ea8510c | |||
14409dec4f | |||
0cdea68567 | |||
542761e411 | |||
0dc8e070ff | |||
fe52cd8db1 | |||
d87a7e896b | |||
f7616ade1f | |||
f14379af68 | |||
a53df39e46 | |||
98187e2bd7 | |||
3ab7de99f3 | |||
1fef0691ed | |||
6b03efed42 | |||
eddd4abe76 | |||
e30dce8b21 | |||
6d12af3858 | |||
b9cbd0ecd1 | |||
3d7511ca75 | |||
fabf68b635 | |||
11326274e0 | |||
acd3940a7b | |||
8ba441da7f | |||
5d9d5e0746 | |||
7a31e88ed6 | |||
d9f35a855d | |||
9678d59bbe | |||
0be5564ce7 | |||
8a90051ab5 | |||
02c7a7f7c7 | |||
e7c8c1d6b6 | |||
449ad6d13c | |||
ae4ee0332c | |||
4a4c97aac4 | |||
4491da0350 | |||
32960afc1b | |||
46f624e3b9 | |||
9daae857de | |||
bac5b1551b | |||
f61f45fa23 | |||
fbc6e02ff6 | |||
56a17a9131 | |||
a148f7fd7c | |||
0dd0d01e8f | |||
bcd16d791c | |||
539e636939 | |||
7f1c4a1c4c | |||
6b254e0ad5 | |||
f36185a964 | |||
588487f860 | |||
f3ab2100f0 | |||
f96b40bbf8 | |||
9679de097f | |||
a51ad1383b | |||
1dd96fa714 | |||
8285805108 | |||
d91b3f8dd9 | |||
6734c928a2 | |||
58448f363b | |||
2e32b7e299 | |||
a651a1a69f | |||
c368696ddc | |||
94269c0640 | |||
5da6588ee6 | |||
ac9c6b4a1f | |||
aa8fa00811 | |||
9c4bd7a487 | |||
eb00294bbb | |||
04c60fd1ac | |||
80de8ada57 | |||
9cdb32d56a | |||
31a505f4a4 | |||
bfa6cd0e19 | |||
c51ecda6b4 | |||
471d44ae11 | |||
513bd1372b | |||
355cee0db9 | |||
38936173d1 | |||
eea56b4c71 | |||
802cc3a48f | |||
ba4720012d | |||
4f83b73732 | |||
68db13fc24 | |||
2d4dd580b4 | |||
d03e94ada8 | |||
91126a59c2 | |||
bd18aee43c | |||
4ead1c3de5 | |||
f3b2a6eba2 | |||
c4d9a27d2f | |||
fdcba2734d | |||
981ba7b28f | |||
822a1751a2 | |||
a4279d09a6 | |||
14d43ac05b | |||
5e6c92ab16 | |||
9ced745258 | |||
948f6ccd95 | |||
1c58727ca9 | |||
612bd9960c | |||
1474499886 | |||
cf99c68843 | |||
d2865b9f4f | |||
865c0c79db | |||
3462e7f50e | |||
37e412e710 | |||
5822992b44 | |||
eb7787fb7d | |||
f1371034f7 | |||
5d12dfa368 | |||
c4282011fa | |||
9ddc22fa94 | |||
517788e86a | |||
ed29ec528d | |||
481b26d09d | |||
da66ad6d41 | |||
1f75b305c3 | |||
0802d03d74 | |||
3970674003 | |||
b00a93dd6b | |||
19b33a8558 | |||
7918438747 | |||
31a085db73 | |||
72997eaa85 | |||
7bb91da1d0 | |||
e3e62c3903 | |||
631ed022ed | |||
590943ed95 | |||
e9c17c9a1d | |||
f8c8e42ae9 | |||
0b0560019a | |||
133d3fdda7 | |||
53e98dbe15 | |||
0eaa9187ea | |||
344f5bda69 | |||
33b080b3b8 | |||
1c85894472 | |||
ba4e5959b1 | |||
5534f9a248 | |||
eb206549ff | |||
0852f32b05 | |||
a1ea84b286 | |||
baba8790bc | |||
1da7f47af9 | |||
60d9b72fea | |||
7a7a8b7ed1 | |||
100565081c | |||
27f82434b6 | |||
353a9aa671 | |||
00da210365 | |||
bce6c86e60 | |||
bed6a1b1e2 | |||
497443f012 | |||
75a06afab0 | |||
121d9f4920 | |||
56371a7d80 | |||
2810787156 | |||
6b53cb59a5 | |||
64062cc879 | |||
7ca902e39a | |||
10ed2738f5 | |||
71392613b2 | |||
4eb7bed2ff | |||
ff21f5b357 | |||
98db248776 | |||
ed4872b94c | |||
8c5c6958cf | |||
f9c81f99f2 | |||
acfdb26135 | |||
37cf8e9d29 | |||
1c6670c9b0 | |||
88c72cd80a | |||
728ea16701 | |||
a3bc9f768a | |||
8d88bc19ed | |||
333ffa0e89 | |||
4ded810ba9 | |||
b2aa54f3f8 | |||
97836cc5eb | |||
b1df0dca97 | |||
4a6816575a | |||
31e2937b8d | |||
0f434004a8 | |||
ba75c45cee | |||
47492c3fa2 | |||
819917c4bf | |||
1ce0fd643c | |||
a7d02a79a9 | |||
645cbf9888 | |||
b2d39ab2d7 | |||
5843521cf1 | |||
4fbc45b40b | |||
2719da3685 | |||
f61bc809dd | |||
19f9593ac1 | |||
a479f529af | |||
76635ff31b | |||
e277cae799 | |||
05baf6b8ac | |||
758441d65d | |||
631a008fa0 | |||
71391914ae | |||
54e79936e5 | |||
a833822eae | |||
cfa8d8d180 | |||
b692756260 | |||
dbc62ad63a | |||
2ac97dea35 | |||
9451814299 | |||
5e01283018 | |||
f7512c3cc0 | |||
f4997375e9 | |||
fbad54795e | |||
2ca85d05f0 | |||
67e89e79be | |||
e4676668bb | |||
3604995c2f | |||
8b731f3ba4 | |||
83f702fbab | |||
fbebf1c7d3 | |||
be14947668 | |||
0fcf770043 | |||
51ec3ede1f | |||
4e2302936f | |||
a6c6a42669 | |||
c486bc64c4 | |||
3709ea1a95 | |||
be7fa79327 | |||
c1660f8ca2 | |||
5e41eaf3dd | |||
898e761988 | |||
846d52ebe5 | |||
77ac6a7a26 | |||
93c2dab634 | |||
f23ba0c513 | |||
824cfd4871 | |||
6a733bbb13 | |||
297d920fdc | |||
c741a73893 | |||
540e1f562f | |||
bfcd16ea28 | |||
3a8703de87 | |||
247ca71bf9 | |||
88d39ab47a | |||
a5af45fb31 | |||
dc04cb54ab | |||
c9fa82f073 | |||
c418cbf4ef | |||
3450c6b9a3 | |||
1ada33a4f0 | |||
a669852694 | |||
a5b6ea6c4c | |||
fe217ef5df | |||
e0a25dbf48 | |||
86191aff7f | |||
6bed39e4fa | |||
2a7aa432a9 | |||
4e19e41460 | |||
061f5d5099 | |||
796bdebd90 | |||
010102da25 | |||
d8f2aeb004 | |||
5173338949 | |||
a8b00b026e | |||
d4db0bdfe5 | |||
b26cd901ca | |||
1e2fc783e5 | |||
8667333416 | |||
5088d7dd86 | |||
e78f26e9c0 | |||
be10227829 | |||
ef47c172c5 | |||
053faa1661 | |||
6d63779c70 | |||
62ad1a483c | |||
f4f760a231 | |||
0eaef1ac3b | |||
27245cca1a | |||
afcc11af57 | |||
9fc41e4245 | |||
a0e0910117 | |||
8a7d7a41a4 | |||
45d5f4a760 | |||
101b795c0a | |||
8311bd3fd9 | |||
ec1926f7a6 | |||
e1c92956f8 | |||
9233d4f6dc | |||
f2f5661625 | |||
4338cf57e6 | |||
a0dce77a2f | |||
ca93882870 | |||
22fbb4262c | |||
2845fd07a7 | |||
c02f40beb6 | |||
79a7b444a2 | |||
9c11bbc7a1 | |||
e1cb57563a | |||
1057d765f7 | |||
30db1a8a63 | |||
c7b49b28c2 | |||
40ea7cfe15 | |||
b3b2ae267a | |||
88176f4d2b | |||
6917ac48a3 | |||
c326d65ad3 | |||
e1a2f0c0f4 | |||
6953bc6105 | |||
209555d36d | |||
e65958f33e | |||
02fea8938a | |||
f5277e4931 | |||
d78ed32df5 | |||
8447395482 | |||
915a7b6e15 | |||
b70c39789e | |||
865cb4857b | |||
774abd66fa | |||
e52d86e6f9 | |||
3c0b5b0b43 | |||
46068573c5 | |||
06c29b7810 | |||
631452567d | |||
6c34f00cfe | |||
208c7f18b2 | |||
5e393ed3c4 | |||
8b16abd370 | |||
94c232d78e | |||
4b41c52522 | |||
6bfe533a20 | |||
f0b8aad4b1 | |||
796cf36a7f | |||
7706d66754 | |||
d992536914 | |||
286b76672c | |||
f0d1b5a1e4 | |||
71ad8930d8 | |||
0f6cbb0c5c | |||
78584b3194 | |||
c0eb4d652b | |||
edbb28038f | |||
3b7e9b4eba | |||
6d0d07abfe | |||
e9f90b4990 | |||
d25b65c124 | |||
5864864123 | |||
2f244ae37e | |||
f83317f7c8 | |||
973b4b9f70 | |||
9389ceaf4f | |||
928dc30810 | |||
c9d6d10995 | |||
9323e1cf59 | |||
93a456ca82 | |||
f6693d5587 | |||
fd09a0ce54 | |||
50d3a2600e | |||
7e1b05933f | |||
03c4fdc607 | |||
0485cf51ff | |||
ba9201831b | |||
f660036a25 | |||
f09cbfddbc | |||
a12f1dcb13 | |||
d2bb1ddc29 | |||
528d81106e | |||
f0bed24742 | |||
5b54d8135e | |||
31559051f6 | |||
e6dbc9bfdf | |||
d1ee9d83b5 | |||
ffa6371e3d | |||
ee6e241144 | |||
bdf1023b16 | |||
9a8f248a75 | |||
6845cda146 | |||
4488b2b7a5 | |||
7dd8cb5d8d | |||
ebf631a15f | |||
3770b75a78 | |||
5d81b61325 | |||
a8e5171b40 | |||
a3e0abb6ce | |||
c51f20eb99 | |||
be897c4df2 | |||
11b948fb69 | |||
070660848b | |||
61af0ec9c6 | |||
897f115363 | |||
b8fcf0355c | |||
5bdff87e3f | |||
31991a3567 | |||
25c369d422 | |||
8d396b1518 | |||
ba327b746a | |||
7d11f912c9 | |||
919cdfb5a9 | |||
da9dd6f775 | |||
8b841f026e | |||
5342b39640 | |||
fc08add504 | |||
20379ac61e | |||
af40aa59ab | |||
f9afc5597a | |||
40178e4661 | |||
ad56abd6f5 | |||
9073a09d84 | |||
2a4e6fce3f | |||
0a3a407217 | |||
9ca9cf80df | |||
6c881a5da7 | |||
5322acd58c | |||
ce489e53c6 | |||
0c95e509dc | |||
46a006ed54 | |||
0cc9378d05 | |||
f3edb2ee68 | |||
a539f23194 | |||
6b6dec79c5 | |||
d7f5c042bf | |||
2fe9812b26 | |||
1c15c3c7a3 | |||
1ee5857139 | |||
2f9c2b0d65 | |||
6e5161f43b | |||
d492d74a64 | |||
26506731c5 | |||
b0c03d4f47 | |||
3bc8348c32 | |||
a034fbba83 | |||
73b5261c49 | |||
cee0cbebc2 | |||
9723147429 | |||
dca385ae87 | |||
71f792944c | |||
6041c4acd2 | |||
0c7529705e | |||
63f1ea1cec | |||
4bbaa75f41 | |||
5fe9314b74 | |||
bfd26493ab | |||
5d74d5d03e | |||
3142e097a5 | |||
b25d8d8201 | |||
7e68cd016a | |||
9e4fc9eb73 | |||
fb0d13a171 | |||
f097b36c2e | |||
57ce3cf80b | |||
c1da62391f | |||
d8882ce979 | |||
9c1871494e | |||
ac26c9114a | |||
fb0a57003c | |||
cda22233a6 | |||
add307577d | |||
4af46ac2b9 | |||
8d39752bda | |||
e3ff9c013e | |||
635870ba4b | |||
a827afb05b | |||
0195e13bdc | |||
76d8b688fd | |||
b4857e2c79 | |||
ac2ae90e8a | |||
0b5cb76b5d | |||
a5bc979c24 | |||
6eed9606ae | |||
29679ff94c | |||
65a1f8b746 | |||
48182d35bd | |||
b526ed47be | |||
2225dec2a9 | |||
011458d642 | |||
e32fff3f61 | |||
0b42e3d0f3 | |||
2b746d1353 | |||
6fed6f9f7d | |||
480945073a | |||
ef6df94838 | |||
fb05848426 | |||
e5be6b96fb | |||
2d706a245a | |||
1abc4f491b | |||
b21a45b43e | |||
585f8450e1 | |||
d3401db5fe | |||
45dc6447bf | |||
409c270ba2 | |||
aed0234d47 | |||
07ebbe56e6 | |||
47b485819f | |||
fd32f7f435 | |||
c4b07b1a7b | |||
95bbeb103e | |||
bfb5570b7a | |||
1e19cf7ccc | |||
0d8999d64f | |||
91fde777cf | |||
061ab12b10 | |||
c516e87180 | |||
de6bfdca0a | |||
788f70d5f3 | |||
b0a35789f6 | |||
eb7fbf011f | |||
50bb6e7204 | |||
15610bb296 | |||
ae0ffdc4d5 | |||
033a6929c3 | |||
7c8292a88d | |||
ab5dad7d91 | |||
0744d215c6 | |||
2622eb4663 | |||
74b3dc2831 | |||
149ddfa8f8 | |||
3830870a83 | |||
b94be080f6 | |||
83382d8dcf | |||
f815228677 | |||
d7d8d23de7 | |||
5834c6ed54 | |||
b0512b3ba7 | |||
d3a7a6ef55 | |||
99fad5bc83 | |||
a54171e1cd | |||
84629f6e63 | |||
b18d597bdc | |||
9125dc4cce | |||
b0e3ea8765 | |||
7c457546f1 | |||
83bef1a840 | |||
b4d89d5666 | |||
3ba8a77d9a | |||
82c31dc47a | |||
7fce694577 | |||
e352d9750d | |||
3d9eac8e6d | |||
6c85b33539 | |||
d979ada4fe | |||
faeeae17d1 | |||
82d1a2b4f9 | |||
cac3496145 | |||
53bfa077ae | |||
0b9366fa28 | |||
c95b709f39 | |||
5745da5466 | |||
ef853e34d6 | |||
7177913d9b | |||
86b6ddb625 | |||
53b9a46feb | |||
d46c1f8687 | |||
c92477b457 | |||
059244bb32 | |||
f10c0d2558 | |||
f5ae89500f | |||
2e3a24d32e | |||
f955d81c5e | |||
4f1fa3bc32 | |||
8305d907e3 | |||
ab73d61178 | |||
8f88d1b7c4 | |||
c5cdbc48a9 | |||
fe00f31147 | |||
79ddb43ac3 | |||
89f95f6459 | |||
87c13b6f26 | |||
d16ea653fe | |||
51dc7fceb0 | |||
bc1c6f7b9a | |||
3fdf77d29b | |||
0b97502029 | |||
cba2bf5cb8 | |||
d8b37328a1 | |||
bb9cf83744 | |||
56fc6ae47c | |||
0cf17cf3db | |||
1bd3297055 | |||
6a10662bc4 | |||
2d84ad8963 | |||
1ec69cbc0d | |||
0057744e57 | |||
45892b4347 | |||
3d41e8882a | |||
436b8216ec | |||
03ba2a680e | |||
2821962d12 | |||
43d38a2e63 | |||
ea28d217e0 | |||
89fe6d57c9 | |||
1d0e1143bf | |||
1a99353559 | |||
ad97d04e37 | |||
25c3abe873 | |||
8eeea50ede | |||
0ded11c6a2 | |||
b6c542212d | |||
182bde4884 | |||
eb84f677cf | |||
3ecb637e70 | |||
bfc826b898 | |||
efc6d4c15a | |||
a96da35f11 | |||
2bff3798af | |||
0fb50a3273 | |||
1c17eee125 | |||
14a43a9cd2 | |||
7bbc7366f2 | |||
879bedd781 | |||
8b79bfab4f | |||
f022e09938 | |||
a63b6a0e3d | |||
dd1facec06 | |||
a46b5716be | |||
e96b7bfd62 | |||
a60c1c1365 | |||
4c39fcd614 | |||
e6b341f2a0 | |||
bdf9e76a6b | |||
e0fc395fbe | |||
107c03653d | |||
a5058cf951 | |||
ed2726c9d2 | |||
6b31ff7e79 | |||
86d3925bf4 | |||
8c2cde4c13 | |||
2d6e34ee6d | |||
adb5577b01 | |||
84ef3f223d | |||
fa50008f3d | |||
6a5537f90f | |||
e0d33a9683 | |||
4092c9a473 | |||
fcaac3d515 | |||
e86d1aad02 | |||
2c94b4c332 | |||
2b6933f6e2 | |||
2e2a7f073e | |||
515c7852ba | |||
5577277944 | |||
ed9e4ff168 | |||
d10915c7a8 | |||
40763fc15d | |||
88d3271c40 | |||
21940c922d | |||
93adc8587d | |||
1907f8d1d1 | |||
ca8848827e | |||
3a7473ba91 | |||
a99da27ff6 | |||
c476649f3e | |||
062473d6f4 | |||
d0ed43a8e5 | |||
701098d19d | |||
c33a0ab439 | |||
b8af848d3a | |||
3dd7fe5d4a | |||
81ab199308 | |||
92938d2c35 | |||
c914632663 | |||
c95104fada | |||
2209fe30e2 | |||
979e0ddc88 | |||
9fab714674 | |||
2eb6463ab0 | |||
5e4d6fbd3f | |||
30df5f3558 | |||
252dd7e09f | |||
2915690d22 | |||
1993596232 | |||
8946e8997f | |||
dfeb156da9 | |||
c10c35e38e | |||
67bfdde113 | |||
c62178a7fe | |||
c12a4323e7 | |||
fd1c4abad7 | |||
bd4fe5a1a7 | |||
190f5ebfc4 | |||
79493df32e | |||
71d523437e | |||
268f503875 | |||
5ac47b823f | |||
ec572da822 | |||
37f96b8cf2 | |||
545db60b98 | |||
f65fdcdbc1 | |||
579acabe5e | |||
f2a9ff8551 | |||
2e40e07563 | |||
cb3af837c6 | |||
3cce89ea3f | |||
5f2dfb24ca | |||
4bc02a7389 | |||
eeeca8afd0 | |||
4f607df5fc | |||
e06b3e2052 | |||
b14b18e4be | |||
fb616b4b53 | |||
a1c5bc00bc | |||
0921632f87 | |||
38ad465233 | |||
881de01073 | |||
2d973e0b90 | |||
e9b43b9b2a | |||
b9193989b0 | |||
be6d9791f5 | |||
baac1b1d80 | |||
40e2d410dd | |||
11617eea99 | |||
5748c4d0ec | |||
2e5b903eae | |||
9405b17e14 | |||
7d1f0e2a69 | |||
c245c24752 | |||
5b0410a207 | |||
62e4c42aa6 | |||
fe1b14ff57 | |||
c074088f2f | |||
0391280c13 | |||
4f98b9e41b | |||
a8de9ac472 | |||
ec7f3fa057 | |||
5cfefd8b15 | |||
7e6b53311d | |||
16bc68f2f9 | |||
974d6b48b2 | |||
db2b1e2dc7 | |||
98656b5d2f | |||
3c7570d814 | |||
fc3e30a826 | |||
2f0476b43c | |||
e310c7d744 | |||
8a649b89c8 | |||
95f52987ef | |||
82b8c66d51 | |||
83fb1843ee | |||
58b10069ab | |||
9cda739672 | |||
276bba050b | |||
147e49b362 | |||
bc338c1f4a | |||
e8fbb18a71 | |||
682c349831 | |||
14b311f6ab | |||
8a40f355c8 | |||
ae2f90c5c2 | |||
7aff773e2c | |||
0cdfa6e7f6 | |||
fc637eef6d | |||
b4c3141170 | |||
41257f7af5 | |||
b204f3ec90 | |||
b4926b3535 | |||
77d63e9848 | |||
94dcd58c2e | |||
689ce16f1b | |||
edc64b8336 | |||
03db5bfd8d | |||
9ad340ab02 | |||
962e26040d | |||
b07884c1da | |||
bad0fb62ed | |||
28e522ce97 | |||
c206cdfa4c | |||
c31ec077f5 | |||
afc6a60746 | |||
0a495b67e6 | |||
37ea7073d5 | |||
feaeef5a70 | |||
5586670d38 | |||
65a9139ffe | |||
3d76f078cd | |||
a1de1b11bc | |||
b5a3e3a4f0 | |||
d7b0ad4916 | |||
2a80a6b217 | |||
9df72f54d5 | |||
ef75ca36c9 | |||
84c0b698f5 | |||
3d9a4ef1e6 | |||
cf51fdceef | |||
85a52ab01f | |||
f2792c0b40 | |||
97109087a4 | |||
953f07f21f | |||
03f1035690 | |||
a561c60f7e | |||
7963b328f9 | |||
3b7e216409 | |||
9ae43a6f75 | |||
6b86de1fb9 | |||
4e6d4ac437 | |||
3b197651cc | |||
c675f1c20c | |||
e87955d59a | |||
c718d8d803 | |||
454a68d1b7 | |||
45f6f74cbe | |||
cb7412a457 | |||
a9fc82365c | |||
edc0fed9e2 | |||
1c718963ea | |||
cd40ccdb9d | |||
80e1dc2446 | |||
d03c4cc4b9 | |||
7bd434e755 | |||
640bcb90c6 | |||
08e86a1378 | |||
fefcc3937a | |||
25210dfa52 | |||
56fbb7b9cf | |||
c55d33b956 | |||
0c5bce101e | |||
0a50e2a95c | |||
5ad940924b |
10
.editorconfig
Normal file
10
.editorconfig
Normal file
@ -0,0 +1,10 @@
|
||||
[*]
|
||||
insert_final_newline = true
|
||||
|
||||
[*.{c,cpp,h,hpp}]
|
||||
indent_style = tab
|
||||
indent_size = 4
|
||||
|
||||
[*.{yml,yaml}]
|
||||
indent_style = space
|
||||
indent_size = 2
|
22
.github/CONTRIBUTING.md
vendored
22
.github/CONTRIBUTING.md
vendored
@ -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
3
.github/FUNDING.yml
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
open_collective: obs-websocket
|
||||
github: Palakis
|
||||
custom: https://www.paypal.me/stephanelepin
|
14
.github/ISSUE_TEMPLATE.md
vendored
14
.github/ISSUE_TEMPLATE.md
vendored
@ -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
35
.github/pull_request_template.md
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
<!--- Please fill out the following template, which will help other contributors review your Pull Request. -->
|
||||
|
||||
<!--- Make sure you’ve 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.
|
||||
|
5
.gitignore
vendored
5
.gitignore
vendored
@ -4,6 +4,7 @@
|
||||
/build32/
|
||||
/build64/
|
||||
/release/
|
||||
/package/
|
||||
/installer/Output/
|
||||
|
||||
.vscode
|
||||
.idea
|
||||
.vscode
|
||||
|
9
.gitmodules
vendored
9
.gitmodules
vendored
@ -1,3 +1,6 @@
|
||||
[submodule "deps/mbedtls"]
|
||||
path = deps/mbedtls
|
||||
url = https://github.com/ARMmbed/mbedtls
|
||||
[submodule "deps/websocketpp"]
|
||||
path = deps/websocketpp
|
||||
url = https://github.com/zaphoyd/websocketpp.git
|
||||
[submodule "deps/asio"]
|
||||
path = deps/asio
|
||||
url = https://github.com/chriskohlhoff/asio.git
|
||||
|
69
.travis.yml
69
.travis.yml
@ -1,69 +0,0 @@
|
||||
language: cpp
|
||||
|
||||
env:
|
||||
global:
|
||||
# AWS key ID
|
||||
- secure: pAiNUGVbjP12BfnWPk0FFTkbnk4Tocvv88XiT3rzRqkQaD7/iyEogLBfHM4nOEgFiIMHbC41aE83w5JgRNPwn6mTgoQBOglzqq1tGuXfqPyV2VStk8beji1evubGoVjjPaoPTFyIdQc5GGxdHyogI/ed9Hb3ccyykYvjyolj9XoCiW42QHx60AHGwl+So+dEa8xydj9SLRPlZ/AitmI/cPVN3YotA7s37BLFiab54enxk7T4rwpR1nU0HVfoCpn5F4wZYxRq+LlSVFzC8vVE9cpDSLS5kjrZIZaT18tYG1/untCj+wqMIZbghaJXLtPSRW2YPHcJTz8q1YSXnJ19+0uiAIMAqaVv0kD5BAM97byYDBW+b9H6SYFkb/Pw/qcK9amMzMBjDPFpYFkl9Q2kzhsNs3HsZf/flSZjtrkQJiP3SOi/KvKzVK9X4Wym6hYZWHgmMTTYFrvr6BYnf2GkpfKNjm1d2kc0NNrq4d5H4NOEQB8MP+QH+o+BPeM6d9dthrUc1Pw+BXzOAr85CN4qtpPGoAl/Dbfgd6eu/88E2LpUufW2VFAOPWjykSOqzSN3orh7AaWuE34VFEnQ+2y3uIE8AKoyXzJv6zYkyNnNewKZeGe2kKYNwLn5UxQA9JEj7a+tvVevk4xBSkkjFAvjSG2z8/F1FXNbEfoLX1Hz/bU=
|
||||
# AWS key secret
|
||||
- secure: bGwljoP3E1OVBXLXox0O6p8kwQXLcNQ8YDKVa4H8u9Y+Ic7uqE4iV3rYS3ynNWSBMVRWY3ZbyClnhrCNwRhBAlcd8qWSJdpjVzs6HdQyzhuKa1P3V4FJPb7upGP/5R/DECGwex8Mun9dmXpYDak75LxfKIJUidPis5VDCYqul7k/xVVCou6Ctjpj7vQhWXDj2G/py+mdB8DERhymnQCtyK1Ziu8c4QlFKByZmnD72GFm/h3JPI1Pq1V2mz3x6x6GaYjb9Rdbd0UNwqjGQX4q2M/c3GEJa6B2JBCoTncawNZBNnPUF9qtv+zh0TNaNHMRWX13AJ/qYB+nVDub0C9b/6Mc48mt0Tv4ze15MproVrylZdV6qHYEG8yGPBqpTVbRP6gv6Y2TXIHWoTzqA+F/Gv2IDChyHXsld/MQQS2MSo5iaYktIrZKtX8Z0qAmTzPwIVBromaSI3vrE7UH0fRSQ6fAM8+Tn+MRthOBdqu23kS1dnG+X2CPbUhBfsJp0OSwVQD5jQtA51/sREVeGFiJvzQIkvwQDjb5MYilsRnwmoBXemkLmqaviXVY4rz1o5AIvz2pgZS2YggK1xHZCuI5tSjcNEkb77VwZTfsqrdDo9EJh6VgfdnGlHQhR2/A5hUJ4ANpJ/LgZlgfVp71Xg2GWQW6M4Znc5uj6A6xLBkO6FA=
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- node_modules
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- os: linux
|
||||
env: _generate_docs
|
||||
script: "./CI/generate-docs.sh"
|
||||
|
||||
- os: linux
|
||||
env: _linux_build
|
||||
dist: trusty
|
||||
sudo: required
|
||||
services:
|
||||
- docker
|
||||
before_install:
|
||||
- docker run -d --name xenial -v $(dirname $(pwd)):/root -v /home/travis/package:/package
|
||||
-e TRAVIS_BRANCH="$TRAVIS_BRANCH" -e TRAVIS_TAG="$TRAVIS_TAG" -w /root nimmis/ubuntu:16.04
|
||||
- docker exec -it xenial /root/obs-websocket/CI/install-dependencies-xenial.sh
|
||||
script:
|
||||
- docker exec -it xenial /root/obs-websocket/CI/build-xenial.sh
|
||||
after_success:
|
||||
- docker exec -it xenial /root/obs-websocket/CI/package-xenial.sh
|
||||
|
||||
- os: osx
|
||||
env: _macos_build
|
||||
osx_image: xcode8.3
|
||||
before_install: "./CI/install-dependencies-macos.sh"
|
||||
script: "./CI/build-macos.sh"
|
||||
after_success:
|
||||
- ./CI/package-macos.sh
|
||||
|
||||
deploy:
|
||||
- provider: s3
|
||||
region: eu-central-1
|
||||
bucket: obs-websocket-linux-builds
|
||||
access_key_id: "$AWS_ID"
|
||||
secret_access_key: "$AWS_SECRET"
|
||||
local_dir: /home/travis/package
|
||||
skip_cleanup: true
|
||||
acl: public_read
|
||||
on:
|
||||
repo: Palakis/obs-websocket
|
||||
condition:
|
||||
- "$TRAVIS_OS_NAME = linux"
|
||||
- "-d /home/travis/package"
|
||||
all_branches: true
|
||||
- provider: s3
|
||||
region: eu-central-1
|
||||
bucket: obs-websocket-osx-builds
|
||||
access_key_id: "$AWS_ID"
|
||||
secret_access_key: "$AWS_SECRET"
|
||||
local_dir: release
|
||||
skip_cleanup: true
|
||||
acl: public_read
|
||||
on:
|
||||
repo: Palakis/obs-websocket
|
||||
condition: "$TRAVIS_OS_NAME = osx"
|
||||
all_branches: true
|
54
BUILDING.md
54
BUILDING.md
@ -1,38 +1,66 @@
|
||||
# Compiling obs-websocket
|
||||
|
||||
## Prerequisites
|
||||
You'll need [QT 5.9.0](https://download.qt.io/official_releases/qt/5.7/5.7.0/), CMake, and a working development environment for OBS Studio installed on your computer.
|
||||
|
||||
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.
|
||||
|
||||
## Windows
|
||||
|
||||
In cmake-gui, you'll have to set the following variables :
|
||||
|
||||
- **QTDIR** (path) : location of the Qt environment suited for your compiler and architecture
|
||||
- **LIBOBS_INCLUDE_DIR** (path) : location of the libobs subfolder in the source code of OBS Studio
|
||||
- **LIBOBS_LIB** (filepath) : location of the obs.lib file
|
||||
- **OBS_FRONTEND_LIB** (filepath) : location of the obs-frontend-api.lib file
|
||||
|
||||
## Linux
|
||||
On Debian/Ubuntu :
|
||||
```
|
||||
sudo apt-get install libqt5websockets5-dev
|
||||
|
||||
On Debian/Ubuntu :
|
||||
|
||||
```shell
|
||||
sudo apt-get install libboost-all-dev
|
||||
git clone --recursive https://github.com/Palakis/obs-websocket.git
|
||||
cd obs-websocket
|
||||
mkdir build && cd build
|
||||
cmake -DLIBOBS_INCLUDE_DIR="<path to the libobs sub-folder in obs-studio's source code>" -DCMAKE_INSTALL_PREFIX=/usr ..
|
||||
cmake -DLIBOBS_INCLUDE_DIR="<path to the libobs sub-folder in obs-studio's source code>" -DCMAKE_INSTALL_PREFIX=/usr -DUSE_UBUNTU_FIX=true ..
|
||||
make -j4
|
||||
sudo make install
|
||||
```
|
||||
|
||||
## OS X
|
||||
Use of the Travis 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-dependencies-macos.sh` will install it for you.
|
||||
Of course, you're encouraged to dig through the contents of these scripts to look for issues or specificities.
|
||||
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 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
|
||||
working obs-studio development environment and have built obs-studio, you can
|
||||
skip that script.
|
||||
|
||||
Of course, you're encouraged to dig through the contents of these scripts to
|
||||
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/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 : [](https://ci.appveyor.com/project/Palakis/obs-websocket/history)
|
||||
- Linux & OS X : [](https://travis-ci.org/Palakis/obs-websocket)
|
||||
|
||||
[](https://dev.azure.com/Palakis/obs-websocket/_build/latest?definitionId=2&branchName=4.x-current)
|
||||
|
@ -1,13 +0,0 @@
|
||||
#!/bin/sh
|
||||
set -ex
|
||||
|
||||
#export QT_PREFIX="$(find /usr/local/Cellar/qt5 -d 1 | tail -n 1)"
|
||||
|
||||
mkdir build && cd build
|
||||
cmake .. \
|
||||
-DQTDIR=/usr/local/opt/qt \
|
||||
-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_INSTALL_PREFIX=/usr \
|
||||
&& make -j4
|
@ -1,8 +0,0 @@
|
||||
#!/bin/sh
|
||||
set -ex
|
||||
|
||||
cd /root/obs-websocket
|
||||
|
||||
mkdir build && cd build
|
||||
cmake -DLIBOBS_INCLUDE_DIR="../../obs-studio/libobs" -DCMAKE_INSTALL_PREFIX=/usr ..
|
||||
make -j4
|
@ -4,6 +4,9 @@ echo "-- Generating documentation."
|
||||
echo "-- Node version: $(node -v)"
|
||||
echo "-- NPM version: $(npm -v)"
|
||||
|
||||
git fetch origin
|
||||
git checkout ${CHECKOUT_REF/refs\/heads\//}
|
||||
|
||||
cd docs
|
||||
npm install
|
||||
npm run build
|
||||
@ -11,23 +14,18 @@ npm run build
|
||||
echo "-- Documentation successfully generated."
|
||||
|
||||
if git diff --quiet; then
|
||||
echo "-- No documentation changes to commit."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$TRAVIS_PULL_REQUEST" != "false" -o "$TRAVIS_BRANCH" != "master" ]; then
|
||||
echo "-- Skipping documentation deployment because this is either a pull request or a non-master branch."
|
||||
exit 0
|
||||
echo "-- No documentation changes to commit."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
REMOTE_URL="$(git config remote.origin.url)"
|
||||
TARGET_REPO=${REMOTE_URL/https:\/\/github.com\//github.com/}
|
||||
GITHUB_REPO=https://${GH_TOKEN:-git}@${TARGET_REPO}
|
||||
|
||||
git config user.name "Travis CI"
|
||||
git config user.name "Azure CI"
|
||||
git config user.email "$COMMIT_AUTHOR_EMAIL"
|
||||
|
||||
git add ./generated
|
||||
git pull
|
||||
git commit -m "docs(travis): Update protocol.md - $(git rev-parse --short HEAD) [skip ci]"
|
||||
git push -q $GITHUB_REPO HEAD:$TRAVIS_BRANCH
|
||||
git commit -m "docs(ci): Update protocol.md - $(git rev-parse --short HEAD) [skip ci]"
|
||||
git push -q $GITHUB_REPO
|
||||
|
@ -1,118 +0,0 @@
|
||||
@echo off
|
||||
SETLOCAL EnableDelayedExpansion
|
||||
|
||||
REM Check if obs-studio build exists.
|
||||
REM If the obs-studio directory does exist, check if the last OBS tag built
|
||||
REM matches the latest OBS tag.
|
||||
REM If the tags match, do not build obs-studio.
|
||||
REM If the tags do not match, build obs-studio.
|
||||
REM If the obs-studio directory doesn't exist, build obs-studio.
|
||||
echo Checking for obs-studio build...
|
||||
|
||||
set OBSLatestTagPrePull=0
|
||||
set OBSLatestTagPostPull=0
|
||||
echo Latest tag pre-pull: %OBSLatestTagPrePull%
|
||||
echo Latest tag post-pull: %OBSLatestTagPostPull%
|
||||
|
||||
REM Set up the build flag as undefined.
|
||||
set "BuildOBS="
|
||||
|
||||
REM Check the last tag successfully built by CI.
|
||||
if exist C:\projects\obs-studio-last-tag-built.txt (
|
||||
set /p OBSLastTagBuilt=<C:\projects\obs-studio-last-tag-built.txt
|
||||
) else (
|
||||
set OBSLastTagBuilt=0
|
||||
)
|
||||
|
||||
REM If obs-studio directory exists, run git pull and get the latest tag number.
|
||||
if exist C:\projects\obs-studio\ (
|
||||
echo obs-studio directory exists
|
||||
echo Updating tag info
|
||||
cd C:\projects\obs-studio\
|
||||
git describe --tags --abbrev=0 > C:\projects\latest-obs-studio-tag-pre-pull.txt
|
||||
set /p OBSLatestTagPrePull=<C:\projects\latest-obs-studio-tag-pre-pull.txt
|
||||
git checkout master
|
||||
git pull
|
||||
git describe --tags --abbrev=0 > C:\projects\latest-obs-studio-tag-post-pull.txt
|
||||
set /p OBSLatestTagPostPull=<C:\projects\latest-obs-studio-tag-post-pull.txt
|
||||
set /p OBSLatestTag=<C:\projects\latest-obs-studio-tag-post-pull.txt
|
||||
echo %OBSLatestTagPostPull%> C:\projects\latest-obs-studio-tag.txt
|
||||
)
|
||||
|
||||
REM Check the obs-studio tags for mismatches.
|
||||
REM If a new tag was pulled, set the build flag.
|
||||
if not %OBSLatestTagPrePull%==%OBSLatestTagPostPull% (
|
||||
echo Latest tag pre-pull: %OBSLatestTagPrePull%
|
||||
echo Latest tag post-pull: %OBSLatestTagPostPull%
|
||||
echo Tags do not match. Need to rebuild OBS.
|
||||
set BuildOBS=true
|
||||
)
|
||||
|
||||
REM If the latest git tag doesn't match the last built tag, set the build flag.
|
||||
if not %OBSLatestTagPostPull%==%OBSLastTagBuilt% (
|
||||
echo Last built OBS tag: %OBSLastTagBuilt%
|
||||
echo Latest tag post-pull: %OBSLatestTagPostPull%
|
||||
echo Tags do not match. Need to rebuild OBS.
|
||||
set BuildOBS=true
|
||||
)
|
||||
|
||||
REM If obs-studio directory does not exist, clone the git repo, get the latest
|
||||
REM tag number, and set the build flag.
|
||||
if not exist C:\projects\obs-studio (
|
||||
echo obs-studio directory does not exist
|
||||
git clone --recursive https://github.com/jp9000/obs-studio
|
||||
cd C:\projects\obs-studio\
|
||||
git describe --tags --abbrev=0 > C:\projects\obs-studio-latest-tag.txt
|
||||
set /p OBSLatestTag=<C:\projects\obs-studio-latest-tag.txt
|
||||
set BuildOBS=true
|
||||
)
|
||||
|
||||
REM Some debug info
|
||||
echo:
|
||||
echo Latest tag pre-pull: %OBSLatestTagPrePull%
|
||||
echo Latest tag post-pull: %OBSLatestTagPostPull%
|
||||
echo Latest tag: %OBSLatestTag%
|
||||
echo Last built OBS tag: %OBSLastTagBuilt%
|
||||
|
||||
if defined BuildOBS (
|
||||
echo BuildOBS: true
|
||||
) else (
|
||||
echo BuildOBS: false
|
||||
)
|
||||
echo:
|
||||
|
||||
REM If the build flag is set, build obs-studio.
|
||||
if defined BuildOBS (
|
||||
echo Building obs-studio...
|
||||
echo git checkout %OBSLatestTag%
|
||||
git checkout %OBSLatestTag%
|
||||
echo:
|
||||
echo Removing previous build dirs...
|
||||
if exist build rmdir /s /q C:\projects\obs-studio\build
|
||||
if exist build32 rmdir /s /q C:\projects\obs-studio\build32
|
||||
if exist build64 rmdir /s /q C:\projects\obs-studio\build64
|
||||
echo Making new build dirs...
|
||||
mkdir build
|
||||
mkdir build32
|
||||
mkdir build64
|
||||
echo Running cmake for obs-studio %OBSLatestTag% 32-bit...
|
||||
cd ./build32
|
||||
cmake -G "Visual Studio 14 2015" -DCOPIED_DEPENDENCIES=false -DCOPY_DEPENDENCIES=true ..
|
||||
echo:
|
||||
echo:
|
||||
echo Running cmake for obs-studio %OBSLatestTag% 64-bit...
|
||||
cd ../build64
|
||||
cmake -G "Visual Studio 14 2015 Win64" -DCOPIED_DEPENDENCIES=false -DCOPY_DEPENDENCIES=true ..
|
||||
echo:
|
||||
echo:
|
||||
echo Building obs-studio %OBSLatestTag% 32-bit ^(Build Config: %build_config%^)...
|
||||
call msbuild /m /p:Configuration=%build_config% C:\projects\obs-studio\build32\obs-studio.sln /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
|
||||
echo Building obs-studio %OBSLatestTag% 64-bit ^(Build Config: %build_config%^)...
|
||||
call msbuild /m /p:Configuration=%build_config% C:\projects\obs-studio\build64\obs-studio.sln /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
|
||||
cd ..
|
||||
git describe --tags --abbrev=0 > C:\projects\obs-studio-last-tag-built.txt
|
||||
set /p OBSLastTagBuilt=<C:\projects\obs-studio-last-tag-built.txt
|
||||
) else (
|
||||
echo Last OBS tag built is: %OBSLastTagBuilt%
|
||||
echo No need to rebuild OBS.
|
||||
)
|
@ -1,32 +0,0 @@
|
||||
#!/bin/sh
|
||||
set -ex
|
||||
|
||||
# OBS Studio deps
|
||||
brew update
|
||||
brew install ffmpeg
|
||||
brew install libav
|
||||
|
||||
# qtwebsockets deps
|
||||
# qt latest
|
||||
#brew install qt5
|
||||
|
||||
# qt 5.9.2
|
||||
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/2b121c9a96e58a5da14228630cb71d5bead7137e/Formula/qt.rb
|
||||
|
||||
#echo "Qt path: $(find /usr/local/Cellar/qt5 -d 1 | tail -n 1)"
|
||||
|
||||
# Build obs-studio
|
||||
cd ..
|
||||
git clone --recursive https://github.com/jp9000/obs-studio
|
||||
cd obs-studio
|
||||
git checkout 21.0.0
|
||||
mkdir build && cd build
|
||||
cmake .. \
|
||||
-DCMAKE_PREFIX_PATH=/usr/local/opt/qt/lib/cmake \
|
||||
&& make -j4
|
||||
|
||||
# Packages app
|
||||
cd ..
|
||||
curl -L -O http://s.sudre.free.fr/Software/files/Packages.dmg -f --retry 5 -C -
|
||||
hdiutil attach ./Packages.dmg
|
||||
sudo installer -pkg /Volumes/Packages\ 1.2.2/packages/Packages.pkg -target /
|
@ -1,57 +0,0 @@
|
||||
#!/bin/sh
|
||||
set -ex
|
||||
|
||||
# OBS Studio deps
|
||||
apt-get -qq update
|
||||
apt-get install -y \
|
||||
libc-dev-bin libc6-dev \
|
||||
git \
|
||||
build-essential
|
||||
|
||||
apt-get install -y \
|
||||
build-essential \
|
||||
checkinstall \
|
||||
cmake \
|
||||
libasound2-dev \
|
||||
libavcodec-dev \
|
||||
libavdevice-dev \
|
||||
libavfilter-dev \
|
||||
libavformat-dev \
|
||||
libavutil-dev \
|
||||
libcurl4-openssl-dev \
|
||||
libfontconfig-dev \
|
||||
libfreetype6-dev \
|
||||
libgl1-mesa-dev \
|
||||
libjack-jackd2-dev \
|
||||
libjansson-dev \
|
||||
libpulse-dev \
|
||||
libqt5x11extras5-dev \
|
||||
libspeexdsp-dev \
|
||||
libswresample-dev \
|
||||
libswscale-dev \
|
||||
libudev-dev \
|
||||
libv4l-dev \
|
||||
libvlc-dev \
|
||||
libx11-dev \
|
||||
libx264-dev \
|
||||
libxcb-shm0-dev \
|
||||
libxcb-xinerama0-dev \
|
||||
libxcomposite-dev \
|
||||
libxinerama-dev \
|
||||
pkg-config \
|
||||
qtbase5-dev
|
||||
|
||||
# obs-websocket deps
|
||||
apt-get install -y libqt5websockets5-dev
|
||||
|
||||
# Build obs-studio
|
||||
cd /root
|
||||
git clone https://github.com/jp9000/obs-studio ./obs-studio
|
||||
cd obs-studio
|
||||
git checkout 21.0.0
|
||||
mkdir build && cd build
|
||||
cmake -DUNIX_STRUCTURE=1 -DCMAKE_INSTALL_PREFIX=/usr ..
|
||||
make -j4
|
||||
make install
|
||||
|
||||
ldconfig
|
@ -1,6 +0,0 @@
|
||||
@echo off
|
||||
|
||||
REM Set default values to use AppVeyor's built-in Qt.
|
||||
set QTDIR32=C:\Qt\5.10.1\msvc2015
|
||||
set QTDIR64=C:\Qt\5.10.1\msvc2015_64
|
||||
set QTCompileVersion=5.10.1
|
9
CI/linux/build-plugin-ubuntu.sh
Executable file
9
CI/linux/build-plugin-ubuntu.sh
Executable file
@ -0,0 +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
|
29
CI/linux/install-dependencies-ubuntu.sh
Executable file
29
CI/linux/install-dependencies-ubuntu.sh
Executable 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
|
24
CI/linux/package-plugin-ubuntu.sh
Executable file
24
CI/linux/package-plugin-ubuntu.sh
Executable file
@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
|
||||
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
|
||||
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-compat --pkgversion="$PKG_VERSION" \
|
||||
--pkglicense="GPLv2.0" --maintainer="stephane.lepin@gmail.com" \
|
||||
--pkggroup="video" \
|
||||
--pkgsource="https://github.com/Palakis/obs-websocket" \
|
||||
--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
5
CI/macos/Brewfile
Normal file
@ -0,0 +1,5 @@
|
||||
brew "jack"
|
||||
brew "speexdsp"
|
||||
brew "cmake"
|
||||
brew "freetype"
|
||||
brew "fdk-aac"
|
27
CI/macos/build-plugin-macos.sh
Executable file
27
CI/macos/build-plugin-macos.sh
Executable file
@ -0,0 +1,27 @@
|
||||
#!/bin/sh
|
||||
|
||||
OSTYPE=$(uname)
|
||||
|
||||
if [ "${OSTYPE}" != "Darwin" ]; then
|
||||
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
|
||||
fi
|
||||
|
||||
echo "[obs-websocket] Building 'obs-websocket' for macOS."
|
||||
mkdir -p build && cd build
|
||||
cmake .. \
|
||||
-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
|
39
CI/macos/install-build-obs-macos.sh
Executable file
39
CI/macos/install-build-obs-macos.sh
Executable 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
|
57
CI/macos/install-dependencies-macos.sh
Executable file
57
CI/macos/install-dependencies-macos.sh
Executable 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
|
@ -12,123 +12,6 @@
|
||||
<dict>
|
||||
<key>CHILDREN</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CHILDREN</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CHILDREN</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CHILDREN</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CHILDREN</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CHILDREN</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CHILDREN</key>
|
||||
<array/>
|
||||
<key>GID</key>
|
||||
<integer>80</integer>
|
||||
<key>PATH</key>
|
||||
<string>../../build/QtNetwork</string>
|
||||
<key>PATH_TYPE</key>
|
||||
<integer>1</integer>
|
||||
<key>PERMISSIONS</key>
|
||||
<integer>292</integer>
|
||||
<key>TYPE</key>
|
||||
<integer>3</integer>
|
||||
<key>UID</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CHILDREN</key>
|
||||
<array/>
|
||||
<key>GID</key>
|
||||
<integer>80</integer>
|
||||
<key>PATH</key>
|
||||
<string>../../build/QtWebSockets</string>
|
||||
<key>PATH_TYPE</key>
|
||||
<integer>1</integer>
|
||||
<key>PERMISSIONS</key>
|
||||
<integer>292</integer>
|
||||
<key>TYPE</key>
|
||||
<integer>3</integer>
|
||||
<key>UID</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
</array>
|
||||
<key>GID</key>
|
||||
<integer>80</integer>
|
||||
<key>PATH</key>
|
||||
<string>bin</string>
|
||||
<key>PATH_TYPE</key>
|
||||
<integer>0</integer>
|
||||
<key>PERMISSIONS</key>
|
||||
<integer>509</integer>
|
||||
<key>TYPE</key>
|
||||
<integer>2</integer>
|
||||
<key>UID</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
</array>
|
||||
<key>GID</key>
|
||||
<integer>80</integer>
|
||||
<key>PATH</key>
|
||||
<string>Resources</string>
|
||||
<key>PATH_TYPE</key>
|
||||
<integer>0</integer>
|
||||
<key>PERMISSIONS</key>
|
||||
<integer>509</integer>
|
||||
<key>TYPE</key>
|
||||
<integer>2</integer>
|
||||
<key>UID</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
</array>
|
||||
<key>GID</key>
|
||||
<integer>80</integer>
|
||||
<key>PATH</key>
|
||||
<string>Contents</string>
|
||||
<key>PATH_TYPE</key>
|
||||
<integer>0</integer>
|
||||
<key>PERMISSIONS</key>
|
||||
<integer>509</integer>
|
||||
<key>TYPE</key>
|
||||
<integer>2</integer>
|
||||
<key>UID</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
</array>
|
||||
<key>GID</key>
|
||||
<integer>80</integer>
|
||||
<key>PATH</key>
|
||||
<string>OBS.app</string>
|
||||
<key>PATH_TYPE</key>
|
||||
<integer>0</integer>
|
||||
<key>PERMISSIONS</key>
|
||||
<integer>509</integer>
|
||||
<key>TYPE</key>
|
||||
<integer>2</integer>
|
||||
<key>UID</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
</array>
|
||||
<key>GID</key>
|
||||
<integer>80</integer>
|
||||
<key>PATH</key>
|
||||
<string>Applications</string>
|
||||
<key>PATH_TYPE</key>
|
||||
<integer>0</integer>
|
||||
<key>PERMISSIONS</key>
|
||||
<integer>509</integer>
|
||||
<key>TYPE</key>
|
||||
<integer>1</integer>
|
||||
<key>UID</key>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CHILDREN</key>
|
||||
<array>
|
||||
@ -153,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>
|
||||
@ -197,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>
|
||||
@ -631,11 +514,11 @@
|
||||
<key>CONCLUSION_ACTION</key>
|
||||
<integer>0</integer>
|
||||
<key>IDENTIFIER</key>
|
||||
<string>fr.palakis.obswebsocket</string>
|
||||
<string>fr.palakis.obs-websocket-compat</string>
|
||||
<key>OVERWRITE_PERMISSIONS</key>
|
||||
<false/>
|
||||
<key>VERSION</key>
|
||||
<string>4.3.3</string>
|
||||
<string>4.9.1-compat</string>
|
||||
</dict>
|
||||
<key>PROJECT_COMMENTS</key>
|
||||
<dict>
|
||||
@ -832,7 +715,7 @@
|
||||
</dict>
|
||||
</array>
|
||||
<key>NAME</key>
|
||||
<string>obs-websocket</string>
|
||||
<string>obs-websocket-compat</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>TYPE</key>
|
||||
|
89
CI/macos/package-plugin-macos.sh
Executable file
89
CI/macos/package-plugin-macos.sh
Executable file
@ -0,0 +1,89 @@
|
||||
#!/bin/bash
|
||||
|
||||
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
|
||||
fi
|
||||
|
||||
echo "[obs-websocket] Preparing package build"
|
||||
|
||||
GIT_HASH=$(git rev-parse --short HEAD)
|
||||
GIT_BRANCH_OR_TAG=$(git name-rev --name-only HEAD | awk -F/ '{print $NF}')
|
||||
|
||||
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-compat.so linking"
|
||||
install_name_tool \
|
||||
-change /tmp/obsdeps/lib/QtWidgets.framework/Versions/5/QtWidgets \
|
||||
@executable_path/../Frameworks/QtWidgets.framework/Versions/5/QtWidgets \
|
||||
-change /tmp/obsdeps/lib/QtGui.framework/Versions/5/QtGui \
|
||||
@executable_path/../Frameworks/QtGui.framework/Versions/5/QtGui \
|
||||
-change /tmp/obsdeps/lib/QtCore.framework/Versions/5/QtCore \
|
||||
@executable_path/../Frameworks/QtCore.framework/Versions/5/QtCore \
|
||||
./build/obs-websocket-compat.so
|
||||
|
||||
# Check if replacement worked
|
||||
echo "[obs-websocket] Dependencies for obs-websocket"
|
||||
otool -L ./build/obs-websocket-compat.so
|
||||
|
||||
if [[ "$RELEASE_MODE" == "True" ]]; then
|
||||
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
|
||||
|
||||
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-compat.pkg ./release/$FILENAME_UNSIGNED
|
||||
|
||||
if [[ "$RELEASE_MODE" == "True" ]]; then
|
||||
echo "[obs-websocket] Signing installer: $FILENAME"
|
||||
productsign \
|
||||
--sign "$INSTALLER_SIGNING_IDENTITY" \
|
||||
./release/$FILENAME_UNSIGNED \
|
||||
./release/$FILENAME
|
||||
rm ./release/$FILENAME_UNSIGNED
|
||||
|
||||
echo "[obs-websocket] Submitting installer $FILENAME for notarization"
|
||||
zip -r ./release/$FILENAME.zip ./release/$FILENAME
|
||||
UPLOAD_RESULT=$(xcrun altool \
|
||||
--notarize-app \
|
||||
--primary-bundle-id "fr.palakis.obs-websocket" \
|
||||
--username "$AC_USERNAME" \
|
||||
--password "$AC_PASSWORD" \
|
||||
--asc-provider "$AC_PROVIDER_SHORTNAME" \
|
||||
--file "./release/$FILENAME.zip")
|
||||
rm ./release/$FILENAME.zip
|
||||
|
||||
REQUEST_UUID=$(echo $UPLOAD_RESULT | awk -F ' = ' '/RequestUUID/ {print $2}')
|
||||
echo "Request UUID: $REQUEST_UUID"
|
||||
|
||||
echo "[obs-websocket] Wait for notarization result"
|
||||
# Pieces of code borrowed from rednoah/notarized-app
|
||||
while sleep 30 && date; do
|
||||
CHECK_RESULT=$(xcrun altool \
|
||||
--notarization-info "$REQUEST_UUID" \
|
||||
--username "$AC_USERNAME" \
|
||||
--password "$AC_PASSWORD" \
|
||||
--asc-provider "$AC_PROVIDER_SHORTNAME")
|
||||
echo $CHECK_RESULT
|
||||
|
||||
if ! grep -q "Status: in progress" <<< "$CHECK_RESULT"; then
|
||||
echo "[obs-websocket] Staple ticket to installer: $FILENAME"
|
||||
xcrun stapler staple ./release/$FILENAME
|
||||
break
|
||||
fi
|
||||
done
|
||||
else
|
||||
echo "[obs-websocket] Skipped installer codesigning and notarization"
|
||||
fi
|
@ -1,66 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
echo "-- Preparing package build"
|
||||
export QT_CELLAR_PREFIX="$(find /usr/local/Cellar/qt -d 1 | tail -n 1)"
|
||||
|
||||
export WS_LIB="/usr/local/opt/qt/lib/QtWebSockets.framework/QtWebSockets"
|
||||
export NET_LIB="/usr/local/opt/qt/lib/QtNetwork.framework/QtNetwork"
|
||||
|
||||
export GIT_HASH=$(git rev-parse --short HEAD)
|
||||
|
||||
export VERSION="$GIT_HASH-$TRAVIS_BRANCH"
|
||||
export LATEST_VERSION="$TRAVIS_BRANCH"
|
||||
if [ -n "${TRAVIS_TAG}" ]; then
|
||||
export VERSION="$TRAVIS_TAG"
|
||||
export LATEST_VERSION="$TRAVIS_TAG"
|
||||
fi
|
||||
|
||||
export FILENAME="obs-websocket-$VERSION.pkg"
|
||||
export LATEST_FILENAME="obs-websocket-latest-$LATEST_VERSION.pkg"
|
||||
|
||||
echo "-- Copying Qt dependencies"
|
||||
cp $WS_LIB ./build
|
||||
cp $NET_LIB ./build
|
||||
|
||||
chmod +rw ./build/QtWebSockets ./build/QtNetwork
|
||||
|
||||
echo "-- Modifying QtNetwork"
|
||||
install_name_tool \
|
||||
-change /usr/local/opt/qt/lib/QtNetwork.framework/Versions/5/QtNetwork @rpath/QtNetwork \
|
||||
-change $QT_CELLAR_PREFIX/lib/QtCore.framework/Versions/5/QtCore @rpath/QtCore \
|
||||
./build/QtNetwork
|
||||
|
||||
echo "-- Modifying QtWebSockets"
|
||||
install_name_tool \
|
||||
-change /usr/local/opt/qt/lib/QtWebSockets.framework/Versions/5/QtWebSockets @rpath/QtWebSockets \
|
||||
-change $QT_CELLAR_PREFIX/lib/QtNetwork.framework/Versions/5/QtNetwork @rpath/QtNetwork \
|
||||
-change $QT_CELLAR_PREFIX/lib/QtCore.framework/Versions/5/QtCore @rpath/QtCore \
|
||||
./build/QtWebSockets
|
||||
|
||||
echo "-- Modifying obs-websocket.so"
|
||||
install_name_tool \
|
||||
-change /usr/local/opt/qt/lib/QtWebSockets.framework/Versions/5/QtWebSockets @rpath/QtWebSockets \
|
||||
-change /usr/local/opt/qt/lib/QtWidgets.framework/Versions/5/QtWidgets @rpath/QtWidgets \
|
||||
-change /usr/local/opt/qt/lib/QtNetwork.framework/Versions/5/QtNetwork @rpath/QtNetwork \
|
||||
-change /usr/local/opt/qt/lib/QtGui.framework/Versions/5/QtGui @rpath/QtGui \
|
||||
-change /usr/local/opt/qt/lib/QtCore.framework/Versions/5/QtCore @rpath/QtCore \
|
||||
./build/obs-websocket.so
|
||||
|
||||
# Check if replacement worked
|
||||
echo "-- Dependencies for QtNetwork"
|
||||
otool -L ./build/QtNetwork
|
||||
echo "-- Dependencies for QtWebSockets"
|
||||
otool -L ./build/QtWebSockets
|
||||
echo "-- Dependencies for obs-websocket"
|
||||
otool -L ./build/obs-websocket.so
|
||||
|
||||
chmod -w ./build/QtWebSockets ./build/QtNetwork
|
||||
|
||||
echo "-- Actual package build"
|
||||
packagesbuild ./CI/macos/obs-websocket.pkgproj
|
||||
|
||||
echo "-- Renaming obs-websocket.pkg to $FILENAME"
|
||||
mv ./release/obs-websocket.pkg ./release/$FILENAME
|
||||
cp ./release/$FILENAME ./release/$LATEST_FILENAME
|
@ -1,24 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
cd /root/obs-websocket
|
||||
|
||||
export GIT_HASH=$(git rev-parse --short HEAD)
|
||||
export PKG_VERSION="1-$GIT_HASH-$TRAVIS_BRANCH-git"
|
||||
|
||||
if [ -n "${TRAVIS_TAG}" ]; then
|
||||
export PKG_VERSION="$TRAVIS_TAG"
|
||||
fi
|
||||
|
||||
cd /root/obs-websocket/build
|
||||
|
||||
PAGER=cat checkinstall -y --type=debian --fstrans=no --nodoc \
|
||||
--backup=no --deldoc=yes --install=no \
|
||||
--pkgname=obs-websocket --pkgversion="$PKG_VERSION" \
|
||||
--pkglicense="GPLv2.0" --maintainer="contact@slepin.fr" \
|
||||
--requires="libqt5websockets5" --pkggroup="video" \
|
||||
--pkgsource="https://github.com/Palakis/obs-websocket" \
|
||||
--pakdir="/package"
|
||||
|
||||
chmod ao+r /package/*
|
7
CI/windows/download-obs-deps.cmd
Normal file
7
CI/windows/download-obs-deps.cmd
Normal 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%
|
||||
)
|
8
CI/windows/install-qt-win.cmd
Normal file
8
CI/windows/install-qt-win.cmd
Normal 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%
|
12
CI/windows/package-plugin-windows.cmd
Normal file
12
CI/windows/package-plugin-windows.cmd
Normal file
@ -0,0 +1,12 @@
|
||||
mkdir package
|
||||
cd package
|
||||
|
||||
git rev-parse --short HEAD > package-version.txt
|
||||
set /p PackageVersion=<package-version.txt
|
||||
del package-version.txt
|
||||
|
||||
REM Package ZIP archive
|
||||
7z a "obs-websocket-%PackageVersion%-Windows.zip" "..\release\*"
|
||||
|
||||
REM Build installer
|
||||
iscc ..\installer\installer.iss /O. /F"obs-websocket-%PackageVersion%-Windows-Installer"
|
38
CI/windows/prepare-obs-windows.cmd
Normal file
38
CI/windows/prepare-obs-windows.cmd
Normal 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"
|
7
CI/windows/prepare-plugin-windows.cmd
Normal file
7
CI/windows/prepare-plugin-windows.cmd
Normal 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" ..
|
178
CMakeLists.txt
178
CMakeLists.txt
@ -1,24 +1,31 @@
|
||||
cmake_minimum_required(VERSION 3.2)
|
||||
project(obs-websocket)
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
project(obs-websocket-compat VERSION 4.9.1)
|
||||
|
||||
set(CMAKE_PREFIX_PATH "${QTDIR}")
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
|
||||
include(external/FindLibObs.cmake)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
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()
|
||||
|
||||
find_package(LibObs REQUIRED)
|
||||
find_package(Qt5Core REQUIRED)
|
||||
find_package(Qt5WebSockets REQUIRED)
|
||||
find_package(Qt5Widgets REQUIRED)
|
||||
find_package(Qt5 REQUIRED COMPONENTS Core Widgets)
|
||||
|
||||
add_subdirectory(deps/mbedtls EXCLUDE_FROM_ALL)
|
||||
set(ENABLE_PROGRAMS false)
|
||||
|
||||
set(obs-websocket_SOURCES
|
||||
set(obs-websocket-compat_SOURCES
|
||||
src/obs-websocket.cpp
|
||||
src/WSServer.cpp
|
||||
src/ConnectionProperties.cpp
|
||||
src/WSRequestHandler.cpp
|
||||
src/WSRequestHandler_General.cpp
|
||||
src/WSRequestHandler_Profiles.cpp
|
||||
@ -29,53 +36,67 @@ 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
|
||||
src/rpc/RpcRequest.cpp
|
||||
src/rpc/RpcResponse.cpp
|
||||
src/rpc/RpcEvent.cpp
|
||||
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
|
||||
src/WSRequestHandler.h
|
||||
src/WSEvents.h
|
||||
src/Config.h
|
||||
src/Utils.h
|
||||
src/rpc/RpcRequest.h
|
||||
src/rpc/RpcResponse.h
|
||||
src/rpc/RpcEvent.h
|
||||
src/protocol/OBSRemoteProtocol.h
|
||||
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})
|
||||
|
||||
add_dependencies(obs-websocket mbedcrypto)
|
||||
|
||||
include_directories(
|
||||
include_directories(
|
||||
"${LIBOBS_INCLUDE_DIR}/../UI/obs-frontend-api"
|
||||
${Qt5Core_INCLUDES}
|
||||
${Qt5WebSockets_INCLUDES}
|
||||
${Qt5Widgets_INCLUDES}
|
||||
${mbedcrypto_INCLUDES}
|
||||
"${CMAKE_SOURCE_DIR}/deps/mbedtls/include")
|
||||
"${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::WebSockets
|
||||
Qt5::Widgets
|
||||
mbedcrypto)
|
||||
Qt5::Widgets)
|
||||
|
||||
# --- End of section ---
|
||||
|
||||
# --- 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)
|
||||
# Enable Multicore Builds and disable FH4 (to not depend on VCRUNTIME140_1.DLL)
|
||||
add_definitions(/MP /d2FH4-)
|
||||
endif()
|
||||
|
||||
add_definitions(-D_WEBSOCKETPP_CPP11_STL_)
|
||||
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(ARCH_NAME "64bit")
|
||||
set(OBS_BUILDDIR_ARCH "build64")
|
||||
@ -88,57 +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}")
|
||||
|
||||
add_custom_command(TARGET obs-websocket POST_BUILD
|
||||
COMMAND if $<CONFIG:Release>==1 ("${CMAKE_COMMAND}" -E copy
|
||||
"${QTDIR}/bin/Qt5WebSockets.dll"
|
||||
"${QTDIR}/bin/Qt5Network.dll"
|
||||
"${CMAKE_BINARY_DIR}/$<CONFIG>")
|
||||
|
||||
COMMAND if $<CONFIG:Debug>==1 ("${CMAKE_COMMAND}" -E copy
|
||||
"${QTDIR}/bin/Qt5WebSocketsd.dll"
|
||||
"${QTDIR}/bin/Qt5Networkd.dll"
|
||||
"${CMAKE_BINARY_DIR}/$<CONFIG>")
|
||||
)
|
||||
|
||||
# --- 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
|
||||
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}")
|
||||
|
||||
COMMAND if $<CONFIG:Release>==1 ("${CMAKE_COMMAND}" -E copy_directory
|
||||
"${RELEASE_DIR}/obs-plugins/${ARCH_NAME}"
|
||||
)
|
||||
|
||||
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>"
|
||||
"${QTDIR}/bin/Qt5WebSockets.dll"
|
||||
"${QTDIR}/bin/Qt5Network.dll"
|
||||
"${RELEASE_DIR}/obs-plugins/${ARCH_NAME}")
|
||||
COMMAND if $<OR:$<CONFIG:Release>,$<CONFIG:RelWithDebInfo>>==1 (
|
||||
"${CMAKE_COMMAND}" -E copy
|
||||
"$<TARGET_FILE:obs-websocket-compat>"
|
||||
"${RELEASE_DIR}/obs-plugins/${ARCH_NAME}"
|
||||
)
|
||||
|
||||
# Copy to obs-studio dev environment for immediate testing
|
||||
# If config is RelWithDebInfo, package PDB file for target
|
||||
COMMAND if $<CONFIG:RelWithDebInfo>==1 (
|
||||
"${CMAKE_COMMAND}" -E copy
|
||||
"$<TARGET_PDB_FILE:obs-websocket-compat>"
|
||||
"${RELEASE_DIR}/obs-plugins/${ARCH_NAME}"
|
||||
)
|
||||
|
||||
# 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>"
|
||||
"${QTDIR}/bin/Qt5WebSocketsd.dll"
|
||||
"${QTDIR}/bin/Qt5Networkd.dll"
|
||||
"${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-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 ---
|
||||
|
||||
@ -147,19 +173,30 @@ endif()
|
||||
|
||||
# --- Linux-specific build settings and tasks ---
|
||||
if(UNIX AND NOT APPLE)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||
include(GNUInstallDirs)
|
||||
|
||||
target_compile_options(mbedcrypto PRIVATE -fPIC)
|
||||
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)
|
||||
|
||||
install(TARGETS obs-websocket
|
||||
LIBRARY DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/obs-plugins")
|
||||
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-compat LIBRARY
|
||||
DESTINATION "/usr/lib/obs-plugins"
|
||||
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
|
||||
endif()
|
||||
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_PREFIX}/share/obs/obs-plugins/obs-websocket/locale")
|
||||
DESTINATION "${CMAKE_INSTALL_FULL_DATAROOTDIR}/obs/obs-plugins/obs-websocket-compat/locale")
|
||||
endif()
|
||||
# --- End of section ---
|
||||
|
||||
@ -167,7 +204,8 @@ endif()
|
||||
if(APPLE)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ -fvisibility=default")
|
||||
|
||||
set_target_properties(obs-websocket PROPERTIES PREFIX "")
|
||||
target_link_libraries(obs-websocket "${OBS_FRONTEND_LIB}")
|
||||
set(CMAKE_SKIP_RPATH TRUE)
|
||||
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
82
CONTRIBUTING.md
Normal 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").
|
122
README.md
122
README.md
@ -1,75 +1,131 @@
|
||||
obs-websocket
|
||||
==============
|
||||
Remote control of OBS Studio made easy.
|
||||
# obs-websocket
|
||||
|
||||
Follow the project on Twitter for news & updates : [@obswebsocket](https://twitter.com/obswebsocket)
|
||||
WebSockets API for OBS Studio.
|
||||
|
||||
[](https://gitter.im/obs-websocket/obs-websocket) [](https://ci.appveyor.com/project/Palakis/obs-websocket/history) [](https://travis-ci.org/Palakis/obs-websocket)
|
||||
[](https://dev.azure.com/Palakis/obs-websocket/_build/latest?definitionId=2&branchName=4.x-current)
|
||||
[](https://www.codefactor.io/repository/github/palakis/obs-websocket)
|
||||
[](https://twitter.com/LePalakis)
|
||||
[](https://discord.gg/WBaSQ3A)
|
||||
[](https://opencollective.com/obs-websocket)
|
||||
|
||||
## Downloads
|
||||
Binaries for Windows and Linux are available in the [Releases](https://github.com/Palakis/obs-websocket/releases) section.
|
||||
|
||||
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.
|
||||
|
||||
### Possible use cases
|
||||
|
||||
- Remote control OBS from a phone or tablet on the same local network
|
||||
- Change your stream overlay/graphics based on the current scene (like the AGDQ overlay does)
|
||||
- Change your stream overlay/graphics based on the current scene
|
||||
- Automate scene switching with a third-party program (e.g. : auto-pilot, foot pedal, ...)
|
||||
|
||||
### For developers
|
||||
The server is a typical Websockets server running by default on port 4444 (the port number can be changed in the Settings dialog).
|
||||
The protocol understood by the server is documented in [PROTOCOL.md](docs/generated/protocol.md).
|
||||
|
||||
The server is a typical Websockets server running by default on port 4444 (the port number can be changed in the Settings dialog).
|
||||
The protocol understood by the server is documented in [PROTOCOL.md](docs/generated/protocol.md).
|
||||
|
||||
Here's a list of available language APIs for obs-websocket :
|
||||
- Javascript (browser & nodejs): [obs-websocket-js](https://github.com/haganbmj/obs-websocket-js) by Brendan Hagan
|
||||
- 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
|
||||
- Java 8+: [obs-websocket-java](https://github.com/Twasi/websocket-obs-java) by TwasiNET
|
||||
- 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 `contact at slepin dot fr` !
|
||||
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
|
||||
|
||||
See the [build instructions](BUILDING.md).
|
||||
|
||||
## Contributing
|
||||
|
||||
See [the contributing document](/CONTRIBUTING.md)
|
||||
|
||||
## Translations
|
||||
**We need your help 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 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) : German localization
|
||||
- [Genture](https://github.com/Genteure) : Simplified Chinese and Traditional Chinese localizations
|
||||
- [Larissa Gabilan](https://github.com/laris151) : Portuguese localization
|
||||
- [Andy Asquelt](https://github.com/asquelt) : Polish localization
|
||||
- [Marcel Haazen](https://github.com/inpothet) : 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
|
||||
|
||||
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.
|
||||
|
||||
[](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.
|
||||
|
||||
[](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
45
SSL-TUNNELLING.md
Normal 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.
|
37
appveyor.yml
37
appveyor.yml
@ -1,37 +0,0 @@
|
||||
environment:
|
||||
CURL_VERSION: 7.39.0
|
||||
|
||||
install:
|
||||
- git submodule update --init --recursive
|
||||
- cd C:\projects\
|
||||
- if not exist dependencies2015.zip curl -kLO https://obsproject.com/downloads/dependencies2015.zip -f --retry 5 -C -
|
||||
- 7z x dependencies2015.zip -odependencies2015
|
||||
- set DepsPath32=%CD%\dependencies2015\win32
|
||||
- set DepsPath64=%CD%\dependencies2015\win64
|
||||
- call C:\projects\obs-websocket\CI\install-setup-qt.cmd
|
||||
- set build_config=Release
|
||||
- call C:\projects\obs-websocket\CI\install-build-obs.cmd
|
||||
- cd C:\projects\obs-websocket\
|
||||
- mkdir build32
|
||||
- mkdir build64
|
||||
- cd ./build32
|
||||
- cmake -G "Visual Studio 14 2015" -DQTDIR="%QTDIR32%" -DLibObs_DIR="C:\projects\obs-studio\build32\libobs" -DLIBOBS_INCLUDE_DIR="C:\projects\obs-studio\libobs" -DLIBOBS_LIB="C:\projects\obs-studio\build32\libobs\%build_config%\obs.lib" -DOBS_FRONTEND_LIB="C:\projects\obs-studio\build32\UI\obs-frontend-api\%build_config%\obs-frontend-api.lib" ..
|
||||
- cd ../build64
|
||||
- cmake -G "Visual Studio 14 2015 Win64" -DQTDIR="%QTDIR64%" -DLibObs_DIR="C:\projects\obs-studio\build64\libobs" -DLIBOBS_INCLUDE_DIR="C:\projects\obs-studio\libobs" -DLIBOBS_LIB="C:\projects\obs-studio\build64\libobs\%build_config%\obs.lib" -DOBS_FRONTEND_LIB="C:\projects\obs-studio\build64\UI\obs-frontend-api\%build_config%\obs-frontend-api.lib" ..
|
||||
|
||||
build_script:
|
||||
- call msbuild /m /p:Configuration=%build_config% C:\projects\obs-websocket\build32\obs-websocket.sln /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
|
||||
- call msbuild /m /p:Configuration=%build_config% C:\projects\obs-websocket\build64\obs-websocket.sln /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
|
||||
|
||||
before_deploy:
|
||||
- 7z a "C:\projects\obs-websocket\build.zip" C:\projects\obs-websocket\release\*
|
||||
|
||||
deploy_script:
|
||||
- ps: Push-AppveyorArtifact "C:\projects\obs-websocket\build.zip" -FileName "obs-websocket-$(git log --pretty=format:'%h' -n 1).zip"
|
||||
|
||||
test: off
|
||||
|
||||
cache:
|
||||
- C:\projects\dependencies2015.zip
|
||||
- C:\projects\obs-studio-last-tag-built.txt
|
||||
- C:\projects\obs-studio\
|
200
azure-pipelines.yml
Normal file
200
azure-pipelines.yml
Normal file
@ -0,0 +1,200 @@
|
||||
variables:
|
||||
isReleaseMode: ${{ startsWith(variables['Build.SourceBranch'], 'refs/tags/') }}
|
||||
|
||||
trigger:
|
||||
branches:
|
||||
include:
|
||||
- '4.x-current'
|
||||
- '4.x-compat'
|
||||
tags:
|
||||
include:
|
||||
- '*'
|
||||
|
||||
jobs:
|
||||
- job: 'GenerateDocs'
|
||||
condition: |
|
||||
or(
|
||||
eq(variables['Build.SourceBranch'], 'refs/heads/4.x-current'),
|
||||
eq(variables['Build.SourceBranch'], 'refs/heads/master')
|
||||
)
|
||||
pool:
|
||||
vmImage: 'ubuntu-18.04'
|
||||
steps:
|
||||
- checkout: self
|
||||
submodules: false
|
||||
|
||||
- script: ./CI/generate-docs.sh
|
||||
displayName: 'Generate docs'
|
||||
env:
|
||||
CHECKOUT_REF: $(Build.SourceBranch)
|
||||
GH_TOKEN: $(GithubToken)
|
||||
|
||||
- job: 'Build_Windows'
|
||||
pool:
|
||||
vmImage: 'windows-2019'
|
||||
variables:
|
||||
build_config: RelWithDebInfo
|
||||
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
|
||||
|
||||
- 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:
|
||||
QT_BASE_DIR: $(QT_BASE_DIR)
|
||||
|
||||
- task: Cache@2
|
||||
displayName: Restore cached OBS Studio dependencies
|
||||
inputs:
|
||||
key: 'obsdeps-"$(DEPS_CACHE_VERSION)" | "$(Agent.OS)"'
|
||||
restoreKeys: |
|
||||
obsdeps-"$(DEPS_CACHE_VERSION)" | "$(Agent.OS)"
|
||||
path: $(DEPS_BASE_PATH)
|
||||
|
||||
- script: ./CI/windows/download-obs-deps.cmd
|
||||
displayName: 'Download OBS Studio dependencies'
|
||||
|
||||
- task: Cache@2
|
||||
displayName: Restore cached OBS Studio builds
|
||||
inputs:
|
||||
key: 'obs-"$(OBS_CACHE_VERSION)" | "$(Agent.OS)"'
|
||||
restoreKeys: |
|
||||
obs-"$(OBS_CACHE_VERSION)" | "$(Agent.OS)"
|
||||
path: $(OBS_PATH)
|
||||
|
||||
- script: ./CI/windows/prepare-obs-windows.cmd
|
||||
displayName: 'Checkout & CMake OBS Studio'
|
||||
env:
|
||||
build_config: $(build_config)
|
||||
DEPS_PATH_32: $(DEPS_PATH_32)
|
||||
DEPS_PATH_64: $(DEPS_PATH_64)
|
||||
QTDIR32: $(QTDIR32)
|
||||
QTDIR64: $(QTDIR64)
|
||||
OBS_PATH: $(OBS_PATH)
|
||||
|
||||
- task: MSBuild@1
|
||||
displayName: 'Build OBS Studio 32-bit'
|
||||
inputs:
|
||||
msbuildArguments: '/m /p:Configuration=$(build_config)'
|
||||
solution: '$(OBS_PATH)\build32\obs-studio.sln'
|
||||
|
||||
- task: MSBuild@1
|
||||
displayName: 'Build OBS Studio 64-bit'
|
||||
inputs:
|
||||
msbuildArguments: '/m /p:Configuration=$(build_config)'
|
||||
solution: '$(OBS_PATH)\build64\obs-studio.sln'
|
||||
|
||||
- script: ./CI/windows/prepare-plugin-windows.cmd
|
||||
displayName: 'CMake obs-websocket'
|
||||
env:
|
||||
build_config: $(build_config)
|
||||
QTDIR32: $(QTDIR32)
|
||||
QTDIR64: $(QTDIR64)
|
||||
OBS_PATH: $(OBS_PATH)
|
||||
|
||||
- task: MSBuild@1
|
||||
displayName: 'Build obs-websocket 32-bit'
|
||||
inputs:
|
||||
msbuildArguments: '/m /p:Configuration=$(build_config)'
|
||||
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-compat.sln'
|
||||
|
||||
- script: ./CI/windows/package-plugin-windows.cmd
|
||||
displayName: 'Package obs-websocket'
|
||||
|
||||
- task: PublishBuildArtifacts@1
|
||||
displayName: 'Upload package artifacts'
|
||||
inputs:
|
||||
pathtoPublish: './package'
|
||||
artifactName: 'windows_build'
|
||||
|
||||
- job: 'Build_Linux'
|
||||
pool:
|
||||
vmImage: 'ubuntu-20.04'
|
||||
variables:
|
||||
BRANCH_SHORT_NAME: $(Build.SourceBranchName)
|
||||
BRANCH_FULL_NAME: $(Build.SourceBranch)
|
||||
steps:
|
||||
- checkout: self
|
||||
submodules: true
|
||||
|
||||
- script: ./CI/linux/install-dependencies-ubuntu.sh
|
||||
displayName: 'Install dependencies'
|
||||
|
||||
- script: ./CI/linux/build-plugin-ubuntu.sh
|
||||
displayName: 'Build obs-websocket'
|
||||
|
||||
- script: ./CI/linux/package-plugin-ubuntu.sh
|
||||
displayName: 'Package obs-websocket'
|
||||
|
||||
- task: PublishBuildArtifacts@1
|
||||
inputs:
|
||||
pathtoPublish: './package'
|
||||
artifactName: 'deb_build'
|
||||
|
||||
- job: 'Build_macOS'
|
||||
pool:
|
||||
vmImage: 'macOS-10.15'
|
||||
variables:
|
||||
OBS_DEPS_VERSION: '2020-12-22'
|
||||
QT_VERSION: '5.15.2'
|
||||
steps:
|
||||
- checkout: self
|
||||
submodules: true
|
||||
|
||||
- script: ./CI/macos/install-dependencies-macos.sh
|
||||
displayName: 'Install dependencies'
|
||||
env:
|
||||
OBS_DEPS_VERSION: $(OBS_DEPS_VERSION)
|
||||
QT_VERSION: $(QT_VERSION)
|
||||
|
||||
- script: ./CI/macos/install-build-obs-macos.sh
|
||||
displayName: 'Build OBS'
|
||||
|
||||
- script: ./CI/macos/build-plugin-macos.sh
|
||||
displayName: 'Build obs-websocket'
|
||||
|
||||
- task: InstallAppleCertificate@2
|
||||
displayName: 'Install release signing certificates'
|
||||
condition: eq(variables['isReleaseMode'], true)
|
||||
inputs:
|
||||
certSecureFile: 'Certificates.p12'
|
||||
certPwd: $(secrets.macOS.certificatesImportPassword)
|
||||
|
||||
- script: ./CI/macos/package-plugin-macos.sh
|
||||
displayName: 'Package obs-websocket'
|
||||
env:
|
||||
RELEASE_MODE: $(isReleaseMode)
|
||||
CODE_SIGNING_IDENTITY: $(secrets.macOS.codeSigningIdentity)
|
||||
INSTALLER_SIGNING_IDENTITY: $(secrets.macOS.installerSigningIdentity)
|
||||
AC_USERNAME: $(secrets.macOS.notarization.username)
|
||||
AC_PASSWORD: $(secrets.macOS.notarization.password)
|
||||
AC_PROVIDER_SHORTNAME: $(secrets.macOS.notarization.providerShortName)
|
||||
|
||||
- task: PublishBuildArtifacts@1
|
||||
inputs:
|
||||
pathtoPublish: './release'
|
||||
artifactName: 'macos_build'
|
@ -1,14 +0,0 @@
|
||||
OBSWebsocket.Menu.SettingsItem="Websocket-Server Einstellungen"
|
||||
OBSWebsocket.Settings.DialogTitle="Websocket-Server Einstellungen"
|
||||
OBSWebsocket.Settings.ServerEnable="Websocket-Server aktivieren"
|
||||
OBSWebsocket.Settings.ServerPort="Server Port"
|
||||
OBSWebsocket.Settings.AuthRequired="Authentifizierung erforderlich"
|
||||
OBSWebsocket.Settings.Password="Passwort"
|
||||
OBSWebsocket.Settings.DebugEnable="Debug-Protokollierung aktivieren"
|
||||
OBSWebsocket.Settings.AlertsEnable="Infobereich-Benachrichtigungen 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-Server Fehler"
|
||||
OBSWebsocket.Server.StartFailed.Message="Der WebSocket-Server konnte nicht gestartet werden, mögliche Gründe:\n - TCP Port %1 wird möglicherweise gerade von einem anderen Programm verwendet. Versuchen Sie einen anderen Port in den WebSocket-Server Einstellungen zu setzten oder alle Programme zu beenden, die den Port möglicherweise verwenden.\n - Ein unbekannter Netzwerkfehler ist aufgetreten. Versuchen Sie es erneut mit anderen Einstellungen, einem OBS neustart oder einem System neustart."
|
@ -1,14 +1,21 @@
|
||||
OBSWebsocket.Menu.SettingsItem="Websocket server settings"
|
||||
OBSWebsocket.Settings.DialogTitle="obs-websocket"
|
||||
OBSWebsocket.Settings.ServerEnable="Enable Websocket 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="WebSocket Server failure"
|
||||
OBSWebsocket.Server.StartFailed.Message="The obs-websocket 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 - An unknown network error happened on your system. Try again by changing settings, restarting OBS or restarting your system."
|
||||
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)"
|
||||
|
@ -1,14 +0,0 @@
|
||||
OBSWebsocket.Menu.SettingsItem="Configuración del servidor obs-websocket"
|
||||
OBSWebsocket.Settings.DialogTitle="obs-websocket"
|
||||
OBSWebsocket.Settings.ServerEnable="Habilitar el servidor Websocket"
|
||||
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 de 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="Fallo del servidor WebSocket"
|
||||
OBSWebsocket.Server.StartFailed.Message="El servidor obs-websocket no se pudo iniciar, tal vez porque: \n - el puerto TCP %1 podría estar actualmente en uso en 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 ocurrido en su sistema. Inténtalo de nuevo cambiando la configuración, reiniciando OBS o reiniciando su sistema."
|
@ -1,13 +0,0 @@
|
||||
OBSWebsocket.Menu.SettingsItem="Paramètres du serveur Websocket"
|
||||
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 WebSocket"
|
||||
OBSWebsocket.Server.StartFailed.Message="Le serveur WebSocket 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."
|
@ -1,14 +0,0 @@
|
||||
OBSWebsocket.Menu.SettingsItem="Impostazioni del server di WebSocket"
|
||||
OBSWebsocket.Settings.DialogTitle="obs-websocket"
|
||||
OBSWebsocket.Settings.ServerEnable="Abilitare il server Websocket"
|
||||
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 obs-websocket: \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 WebSocket, 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."
|
@ -1,8 +0,0 @@
|
||||
OBSWebsocket.Menu.SettingsItem="Websocket サーバー設定"
|
||||
OBSWebsocket.Settings.DialogTitle="obs-websocket"
|
||||
OBSWebsocket.Settings.ServerEnable="Websocket サーバーを有効にする"
|
||||
OBSWebsocket.Settings.ServerPort="サーバーポート"
|
||||
OBSWebsocket.Settings.AuthRequired="認証を有効にする"
|
||||
OBSWebsocket.Settings.Password="パスワード"
|
||||
OBSWebsocket.Settings.DebugEnable="デバッグログを有効にする"
|
||||
OBSWebsocket.NotifyConnect.Title="新しいWebSocket接続"
|
@ -1,14 +0,0 @@
|
||||
OBSWebsocket.Menu.SettingsItem="Websocket server instellingen"
|
||||
OBSWebsocket.Settings.DialogTitle="obs-websocket"
|
||||
OBSWebsocket.Settings.ServerEnable="Activeer Websocket server"
|
||||
OBSWebsocket.Settings.ServerPort="Serverpoort"
|
||||
OBSWebsocket.Settings.AuthRequired="Activeer authenticatie"
|
||||
OBSWebsocket.Settings.Password="Wachtwoord"
|
||||
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="WebSocket Server mislukt"
|
||||
OBSWebsocket.Server.StartFailed.Message="De obs-websocket server kan niet worden gestart, misschien omdat: \n - TCP-poort %1 momenteel wordt gebruikt elders op dit systeem, eventueel door een andere toepassing. Probeer een andere TCP-poort instellen in de WebSocket Server-instellingen of stoppen van elke toepassing die deze poort zouden kunnen gebruiken.\n Een onbekende netwerkfout gebeurde op uw systeem. Probeer het opnieuw door de instellingen wijzigen, OBS herstarten of opnieuw opstarten van uw systeem."
|
@ -1,14 +0,0 @@
|
||||
OBSWebsocket.Menu.SettingsItem="Ustawienia serwera zdalnego sterowania"
|
||||
OBSWebsocket.Settings.DialogTitle="Serwer zdalnego sterowania"
|
||||
OBSWebsocket.Settings.ServerEnable="Włącz serwer zdalnego sterowania (Websocket)"
|
||||
OBSWebsocket.Settings.ServerPort="Port serwera"
|
||||
OBSWebsocket.Settings.AuthRequired="Wymagaj hasła"
|
||||
OBSWebsocket.Settings.Password="Hasło"
|
||||
OBSWebsocket.Settings.DebugEnable="Włącz rejestrowanie debugowania"
|
||||
OBSWebsocket.Settings.AlertsEnable="Włącz powiadomienia o 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 połączony"
|
||||
OBSWebsocket.Server.StartFailed.Title="Awaria serwera WebSocket"
|
||||
OBSWebsocket.Server.StartFailed.Message="Nie udało się uruchomić serwera obs-websocket, 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 WebSocket, 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."
|
@ -1,5 +0,0 @@
|
||||
OBSWebsocket.Menu.SettingsItem="Configuraçes do Servidor Websocket"
|
||||
OBSWebsocket.Settings.ServerEnable="Habilitar o Servidor Websocket"
|
||||
OBSWebsocket.Settings.ServerPort="Porta do Servidor"
|
||||
OBSWebsocket.Settings.AuthRequired="Autenticação Requerida"
|
||||
OBSWebsocket.Settings.Password="Senha"
|
@ -1,14 +0,0 @@
|
||||
OBSWebsocket.Menu.SettingsItem="Configurações do servidor Websocket"
|
||||
OBSWebsocket.Settings.DialogTitle="obs-websocket"
|
||||
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 obs-websocket 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 WebSocket, 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."
|
@ -1,14 +0,0 @@
|
||||
OBSWebsocket.Menu.SettingsItem="Параметры сервера Websocket"
|
||||
OBSWebsocket.Settings.DialogTitle="obs-websocket"
|
||||
OBSWebsocket.Settings.ServerEnable="Включить сервер Websocket"
|
||||
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="Сбой сервера WebSocket"
|
||||
OBSWebsocket.Server.StartFailed.Message="Сбой запуска сервера obs-websocket. Вероятные причины:\n - Возможно, TCP-порт %1 занят другим приложением в системе. Попробуйте задать другой TCP-порт в настройках сервера WebSocket или закройте приложение, которое может использовать данный порт.\n - Произошла неизвестная сетевая ошибка в системе. Попробуйте снова после изменения настроек, перезапуска OBS или перезапуска системы."
|
@ -1,6 +0,0 @@
|
||||
OBSWebsocket.Menu.SettingsItem="Websocket 服务器设置"
|
||||
OBSWebsocket.Settings.DialogTitle="obs-websocket 设置"
|
||||
OBSWebsocket.Settings.ServerEnable="启用 Websocket 服务器"
|
||||
OBSWebsocket.Settings.ServerPort="服务器端口"
|
||||
OBSWebsocket.Settings.AuthRequired="启用密码认证"
|
||||
OBSWebsocket.Settings.Password="密码"
|
@ -1,6 +0,0 @@
|
||||
OBSWebsocket.Menu.SettingsItem="Websocket 伺服器設定"
|
||||
OBSWebsocket.Settings.DialogTitle="obs-websocket 設定"
|
||||
OBSWebsocket.Settings.ServerEnable="啟用 Websocket 伺服器"
|
||||
OBSWebsocket.Settings.ServerPort="伺服器端口"
|
||||
OBSWebsocket.Settings.AuthRequired="啟用密碼認證"
|
||||
OBSWebsocket.Settings.Password="密碼"
|
1
deps/asio
vendored
Submodule
1
deps/asio
vendored
Submodule
Submodule deps/asio added at b73dc1d2c0
1
deps/mbedtls
vendored
1
deps/mbedtls
vendored
Submodule deps/mbedtls deleted from 1a6a15c795
1
deps/websocketpp
vendored
Submodule
1
deps/websocketpp
vendored
Submodule
Submodule deps/websocketpp added at 56123c8759
@ -30,6 +30,14 @@ const processComments = comments => {
|
||||
let errors = [];
|
||||
|
||||
comments.forEach(comment => {
|
||||
if (comment.typedef) {
|
||||
comment.comment = undefined;
|
||||
comment.context = undefined;
|
||||
sorted['typedefs'] = sorted['typedefs'] || [];
|
||||
sorted['typedefs'].push(comment);
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof comment.api === 'undefined') return;
|
||||
let validationFailures = validateComment(comment);
|
||||
|
||||
@ -84,9 +92,7 @@ const validateComment = comment => {
|
||||
fullContext: Object.assign({}, comment)
|
||||
};
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
const files = glob.sync(config.srcGlob);
|
||||
const comments = processComments(parseFiles(files));
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,12 +1,13 @@
|
||||
# obs-websocket 4.3.2 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
|
||||
OBSWebSocket uses SHA256 to transmit credentials.
|
||||
**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:
|
||||
- A `challenge`: a random string that will be used to generate the auth response.
|
||||
@ -33,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.
|
||||
|
@ -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.
|
||||
|
2
docs/partials/typedefsHeader.md
Normal file
2
docs/partials/typedefsHeader.md
Normal file
@ -0,0 +1,2 @@
|
||||
# Typedefs
|
||||
These are complex types, such as `Source` and `Scene`, which are used as arguments or return values in multiple requests and/or events.
|
@ -7,6 +7,19 @@
|
||||
|
||||
|
||||
|
||||
{{#read "partials/typedefsHeader.md"}}{{/read}}
|
||||
|
||||
{{#each typedefs}}
|
||||
## {{typedefs.0.name}}
|
||||
| Name | Type | Description |
|
||||
| ---- | :---: | ------------|
|
||||
{{#each properties}}
|
||||
| `{{name}}` | _{{depipe type}}_ | {{{depipe description}}} |
|
||||
{{/each}}
|
||||
{{/each}}
|
||||
|
||||
|
||||
|
||||
{{#read "partials/eventsHeader.md"}}{{/read}}
|
||||
|
||||
{{#each events}}
|
||||
|
@ -2,7 +2,7 @@
|
||||
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
|
||||
|
||||
#define MyAppName "obs-websocket"
|
||||
#define MyAppVersion "4.3.3"
|
||||
#define MyAppVersion "4.9.1-compat"
|
||||
#define MyAppPublisher "Stephane Lepin"
|
||||
#define MyAppURL "http://github.com/Palakis/obs-websocket"
|
||||
|
||||
@ -20,17 +20,17 @@ AppSupportURL={#MyAppURL}
|
||||
AppUpdatesURL={#MyAppURL}
|
||||
DefaultDirName={code:GetDirName}
|
||||
DefaultGroupName={#MyAppName}
|
||||
OutputBaseFilename=obs-websocket-{#MyAppVersion}-Windows-Installer
|
||||
OutputBaseFilename=obs-websocket-Windows-Installer
|
||||
Compression=lzma
|
||||
SolidCompression=yes
|
||||
LicenseFile=..\LICENSE
|
||||
DirExistsWarning=no
|
||||
|
||||
[Languages]
|
||||
Name: "english"; MessagesFile: "compiler:Default.isl"
|
||||
Name: "french"; MessagesFile: "compiler:Languages\French.isl"
|
||||
|
||||
[Files]
|
||||
Source: "..\release\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
|
||||
Source: "..\LICENSE"; Flags: dontcopy
|
||||
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
|
||||
|
||||
[Icons]
|
||||
@ -38,17 +38,32 @@ Name: "{group}\{cm:ProgramOnTheWeb,{#MyAppName}}"; Filename: "{#MyAppURL}"
|
||||
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
|
||||
|
||||
[Code]
|
||||
procedure InitializeWizard();
|
||||
var
|
||||
GPLText: AnsiString;
|
||||
Page: TOutputMsgMemoWizardPage;
|
||||
begin
|
||||
ExtractTemporaryFile('LICENSE');
|
||||
LoadStringFromFile(ExpandConstant('{tmp}\LICENSE'), GPLText);
|
||||
|
||||
Page := CreateOutputMsgMemoPage(wpWelcome,
|
||||
'License Information', 'Please review the license terms before installing obs-websocket',
|
||||
'Press Page Down to see the rest of the agreement. Once you are aware of your rights, click Next to continue.',
|
||||
String(GPLText)
|
||||
);
|
||||
end;
|
||||
|
||||
// credit where it's due :
|
||||
// following function come from https://github.com/Xaymar/obs-studio_amf-encoder-plugin/blob/master/%23Resources/Installer.in.iss#L45
|
||||
function GetDirName(Value: string): string;
|
||||
var
|
||||
InstallPath: string;
|
||||
InstallPath: string;
|
||||
begin
|
||||
// initialize default path, which will be returned when the following registry
|
||||
// key queries fail due to missing keys or for some different reason
|
||||
Result := '{pf}\obs-studio';
|
||||
// query the first registry value; if this succeeds, return the obtained value
|
||||
if RegQueryStringValue(HKLM32, 'SOFTWARE\OBS Studio', '', InstallPath) then
|
||||
Result := InstallPath
|
||||
// initialize default path, which will be returned when the following registry
|
||||
// key queries fail due to missing keys or for some different reason
|
||||
Result := '{pf}\obs-studio';
|
||||
// query the first registry value; if this succeeds, return the obtained value
|
||||
if RegQueryStringValue(HKLM32, 'SOFTWARE\OBS Studio', '', InstallPath) then
|
||||
Result := InstallPath
|
||||
end;
|
||||
|
||||
|
416
src/Config.cpp
416
src/Config.cpp
@ -16,181 +16,337 @@ 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 <mbedtls/base64.h>
|
||||
#include <mbedtls/sha256.h>
|
||||
#include <obs-frontend-api.h>
|
||||
#include <util/config-file.h>
|
||||
#include <string>
|
||||
|
||||
#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"
|
||||
|
||||
#include "Config.h"
|
||||
#define GLOBAL_AUTH_SETUP_PROMPTED "AuthSetupPrompted"
|
||||
|
||||
#include "Utils.h"
|
||||
#include "WSServer.h"
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#define QT_TO_UTF8(str) str.toUtf8().constData()
|
||||
|
||||
Config* Config::_instance = new Config();
|
||||
|
||||
Config::Config() :
|
||||
ServerEnabled(true),
|
||||
ServerPort(4444),
|
||||
DebugEnabled(false),
|
||||
AlertsEnabled(true),
|
||||
AuthRequired(false),
|
||||
Secret(""),
|
||||
Salt(""),
|
||||
SettingsLoaded(false)
|
||||
ServerEnabled(true),
|
||||
ServerPort(4444),
|
||||
LockToIPv4(false),
|
||||
DebugEnabled(false),
|
||||
AlertsEnabled(true),
|
||||
AuthRequired(true),
|
||||
Secret(""),
|
||||
Salt(""),
|
||||
SettingsLoaded(false)
|
||||
{
|
||||
// OBS Config defaults
|
||||
config_t* obsConfig = obs_frontend_get_global_config();
|
||||
if (obsConfig) {
|
||||
config_set_default_bool(obsConfig,
|
||||
SECTION_NAME, PARAM_ENABLE, ServerEnabled);
|
||||
config_set_default_uint(obsConfig,
|
||||
SECTION_NAME, PARAM_PORT, ServerPort);
|
||||
qsrand(QTime::currentTime().msec());
|
||||
|
||||
config_set_default_bool(obsConfig,
|
||||
SECTION_NAME, PARAM_DEBUG, DebugEnabled);
|
||||
config_set_default_bool(obsConfig,
|
||||
SECTION_NAME, PARAM_ALERT, AlertsEnabled);
|
||||
SetDefaults();
|
||||
SessionChallenge = GenerateSalt();
|
||||
|
||||
config_set_default_bool(obsConfig,
|
||||
SECTION_NAME, PARAM_AUTHREQUIRED, AuthRequired);
|
||||
config_set_default_string(obsConfig,
|
||||
SECTION_NAME, PARAM_SECRET, QT_TO_UTF8(Secret));
|
||||
config_set_default_string(obsConfig,
|
||||
SECTION_NAME, PARAM_SALT, QT_TO_UTF8(Salt));
|
||||
}
|
||||
|
||||
mbedtls_entropy_init(&entropy);
|
||||
mbedtls_ctr_drbg_init(&rng);
|
||||
mbedtls_ctr_drbg_seed(&rng, mbedtls_entropy_func, &entropy, nullptr, 0);
|
||||
|
||||
SessionChallenge = GenerateSalt();
|
||||
obs_frontend_add_event_callback(OnFrontendEvent, this);
|
||||
}
|
||||
|
||||
Config::~Config() {
|
||||
mbedtls_ctr_drbg_free(&rng);
|
||||
mbedtls_entropy_free(&entropy);
|
||||
Config::~Config()
|
||||
{
|
||||
obs_frontend_remove_event_callback(OnFrontendEvent, this);
|
||||
}
|
||||
|
||||
void Config::Load() {
|
||||
config_t* obsConfig = obs_frontend_get_global_config();
|
||||
void Config::Load()
|
||||
{
|
||||
config_t* obsConfig = GetConfigStore();
|
||||
|
||||
ServerEnabled = config_get_bool(obsConfig, SECTION_NAME, PARAM_ENABLE);
|
||||
ServerPort = config_get_uint(obsConfig, SECTION_NAME, PARAM_PORT);
|
||||
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);
|
||||
DebugEnabled = config_get_bool(obsConfig, SECTION_NAME, PARAM_DEBUG);
|
||||
AlertsEnabled = config_get_bool(obsConfig, SECTION_NAME, PARAM_ALERT);
|
||||
|
||||
AuthRequired = config_get_bool(obsConfig, SECTION_NAME, PARAM_AUTHREQUIRED);
|
||||
Secret = config_get_string(obsConfig, SECTION_NAME, PARAM_SECRET);
|
||||
Salt = config_get_string(obsConfig, SECTION_NAME, PARAM_SALT);
|
||||
AuthRequired = config_get_bool(obsConfig, SECTION_NAME, PARAM_AUTHREQUIRED);
|
||||
Secret = config_get_string(obsConfig, SECTION_NAME, PARAM_SECRET);
|
||||
Salt = config_get_string(obsConfig, SECTION_NAME, PARAM_SALT);
|
||||
}
|
||||
|
||||
void Config::Save() {
|
||||
config_t* obsConfig = obs_frontend_get_global_config();
|
||||
void Config::Save()
|
||||
{
|
||||
config_t* obsConfig = GetConfigStore();
|
||||
|
||||
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_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);
|
||||
config_set_bool(obsConfig, SECTION_NAME, PARAM_DEBUG, DebugEnabled);
|
||||
config_set_bool(obsConfig, SECTION_NAME, PARAM_ALERT, AlertsEnabled);
|
||||
|
||||
config_set_bool(obsConfig, SECTION_NAME, PARAM_AUTHREQUIRED, AuthRequired);
|
||||
config_set_string(obsConfig, SECTION_NAME, PARAM_SECRET,
|
||||
QT_TO_UTF8(Secret));
|
||||
config_set_string(obsConfig, SECTION_NAME, PARAM_SALT,
|
||||
QT_TO_UTF8(Salt));
|
||||
config_set_bool(obsConfig, SECTION_NAME, PARAM_AUTHREQUIRED, AuthRequired);
|
||||
config_set_string(obsConfig, SECTION_NAME, PARAM_SECRET,
|
||||
QT_TO_UTF8(Secret));
|
||||
config_set_string(obsConfig, SECTION_NAME, PARAM_SALT,
|
||||
QT_TO_UTF8(Salt));
|
||||
|
||||
config_save(obsConfig);
|
||||
config_save(obsConfig);
|
||||
}
|
||||
|
||||
QString Config::GenerateSalt() {
|
||||
// Generate 32 random chars
|
||||
unsigned char* randomChars = (unsigned char*)bzalloc(32);
|
||||
mbedtls_ctr_drbg_random(&rng, randomChars, 32);
|
||||
void Config::SetDefaults()
|
||||
{
|
||||
// OBS Config defaults
|
||||
config_t* obsConfig = GetConfigStore();
|
||||
if (obsConfig) {
|
||||
config_set_default_bool(obsConfig,
|
||||
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);
|
||||
|
||||
// Convert the 32 random chars to a base64 string
|
||||
char* salt = (char*)bzalloc(64);
|
||||
size_t saltBytes;
|
||||
mbedtls_base64_encode(
|
||||
(unsigned char*)salt, 64, &saltBytes,
|
||||
randomChars, 32);
|
||||
config_set_default_bool(obsConfig,
|
||||
SECTION_NAME, PARAM_DEBUG, DebugEnabled);
|
||||
config_set_default_bool(obsConfig,
|
||||
SECTION_NAME, PARAM_ALERT, AlertsEnabled);
|
||||
|
||||
bfree(randomChars);
|
||||
return salt;
|
||||
config_set_default_bool(obsConfig,
|
||||
SECTION_NAME, PARAM_AUTHREQUIRED, AuthRequired);
|
||||
config_set_default_string(obsConfig,
|
||||
SECTION_NAME, PARAM_SECRET, QT_TO_UTF8(Secret));
|
||||
config_set_default_string(obsConfig,
|
||||
SECTION_NAME, PARAM_SALT, QT_TO_UTF8(Salt));
|
||||
}
|
||||
}
|
||||
|
||||
QString Config::GenerateSecret(QString password, QString salt) {
|
||||
// Concatenate the password and the salt
|
||||
QString passAndSalt = "";
|
||||
passAndSalt += password;
|
||||
passAndSalt += salt;
|
||||
|
||||
// Generate a SHA256 hash of the password
|
||||
unsigned char* challengeHash = (unsigned char*)bzalloc(32);
|
||||
mbedtls_sha256(
|
||||
(unsigned char*)passAndSalt.toUtf8().constData(), passAndSalt.length(),
|
||||
challengeHash, 0);
|
||||
|
||||
// Encode SHA256 hash to Base64
|
||||
char* challenge = (char*)bzalloc(64);
|
||||
size_t challengeBytes = 0;
|
||||
mbedtls_base64_encode(
|
||||
(unsigned char*)challenge, 64, &challengeBytes,
|
||||
challengeHash, 32);
|
||||
|
||||
bfree(challengeHash);
|
||||
return challenge;
|
||||
config_t* Config::GetConfigStore()
|
||||
{
|
||||
return obs_frontend_get_profile_config();
|
||||
}
|
||||
|
||||
void Config::SetPassword(QString password) {
|
||||
QString newSalt = GenerateSalt();
|
||||
QString newChallenge = GenerateSecret(password, newSalt);
|
||||
void Config::MigrateFromGlobalSettings()
|
||||
{
|
||||
config_t* source = obs_frontend_get_global_config();
|
||||
config_t* destination = obs_frontend_get_profile_config();
|
||||
|
||||
this->Salt = newSalt;
|
||||
this->Secret = newChallenge;
|
||||
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);
|
||||
}
|
||||
|
||||
bool Config::CheckAuth(QString response) {
|
||||
// Concatenate auth secret with the challenge sent to the user
|
||||
QString challengeAndResponse = "";
|
||||
challengeAndResponse += Secret;
|
||||
challengeAndResponse += SessionChallenge;
|
||||
QString Config::GenerateSalt()
|
||||
{
|
||||
// Generate 32 random chars
|
||||
const size_t randomCount = 32;
|
||||
QByteArray randomChars;
|
||||
for (size_t i = 0; i < randomCount; i++) {
|
||||
randomChars.append((char)qrand());
|
||||
}
|
||||
|
||||
// Generate a SHA256 hash of challengeAndResponse
|
||||
unsigned char* hash = (unsigned char*)bzalloc(32);
|
||||
mbedtls_sha256(
|
||||
(unsigned char*)challengeAndResponse.toUtf8().constData(),
|
||||
challengeAndResponse.length(),
|
||||
hash, 0);
|
||||
// Convert the 32 random chars to a base64 string
|
||||
QString salt = randomChars.toBase64();
|
||||
|
||||
// Encode the SHA256 hash to Base64
|
||||
char* expectedResponse = (char*)bzalloc(64);
|
||||
size_t base64_size = 0;
|
||||
mbedtls_base64_encode(
|
||||
(unsigned char*)expectedResponse, 64, &base64_size,
|
||||
hash, 32);
|
||||
|
||||
bool authSuccess = false;
|
||||
if (response == QString(expectedResponse)) {
|
||||
SessionChallenge = GenerateSalt();
|
||||
authSuccess = true;
|
||||
}
|
||||
|
||||
bfree(hash);
|
||||
bfree(expectedResponse);
|
||||
return authSuccess;
|
||||
return salt;
|
||||
}
|
||||
|
||||
Config* Config::Current() {
|
||||
return _instance;
|
||||
QString Config::GenerateSecret(QString password, QString salt)
|
||||
{
|
||||
// Concatenate the password and the salt
|
||||
QString passAndSalt = "";
|
||||
passAndSalt += password;
|
||||
passAndSalt += salt;
|
||||
|
||||
// Generate a SHA256 hash of the password and salt
|
||||
auto challengeHash = QCryptographicHash::hash(
|
||||
passAndSalt.toUtf8(),
|
||||
QCryptographicHash::Algorithm::Sha256
|
||||
);
|
||||
|
||||
// Encode SHA256 hash to Base64
|
||||
QString challenge = challengeHash.toBase64();
|
||||
|
||||
return challenge;
|
||||
}
|
||||
|
||||
void Config::SetPassword(QString password)
|
||||
{
|
||||
QString newSalt = GenerateSalt();
|
||||
QString newChallenge = GenerateSecret(password, newSalt);
|
||||
|
||||
this->Salt = newSalt;
|
||||
this->Secret = newChallenge;
|
||||
}
|
||||
|
||||
bool Config::CheckAuth(QString response)
|
||||
{
|
||||
// Concatenate auth secret with the challenge sent to the user
|
||||
QString challengeAndResponse = "";
|
||||
challengeAndResponse += Secret;
|
||||
challengeAndResponse += SessionChallenge;
|
||||
|
||||
// Generate a SHA256 hash of challengeAndResponse
|
||||
auto hash = QCryptographicHash::hash(
|
||||
challengeAndResponse.toUtf8(),
|
||||
QCryptographicHash::Algorithm::Sha256
|
||||
);
|
||||
|
||||
// Encode the SHA256 hash to Base64
|
||||
QString expectedResponse = hash.toBase64();
|
||||
|
||||
bool authSuccess = false;
|
||||
if (response == expectedResponse) {
|
||||
SessionChallenge = GenerateSalt();
|
||||
authSuccess = true;
|
||||
}
|
||||
|
||||
return authSuccess;
|
||||
}
|
||||
|
||||
void Config::OnFrontendEvent(enum obs_frontend_event event, void* param)
|
||||
{
|
||||
auto config = reinterpret_cast<Config*>(param);
|
||||
|
||||
if (event == OBS_FRONTEND_EVENT_PROFILE_CHANGED) {
|
||||
obs_frontend_push_ui_translation(obs_module_get_string);
|
||||
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 || config->LockToIPv4 != previousLock) {
|
||||
auto server = GetServer();
|
||||
server->stop();
|
||||
|
||||
if (config->ServerEnabled) {
|
||||
server->start(config->ServerPort, config->LockToIPv4);
|
||||
|
||||
if (previousEnabled != config->ServerEnabled) {
|
||||
Utils::SysTrayNotify(startMessage, QSystemTrayIcon::MessageIcon::Information);
|
||||
} else {
|
||||
Utils::SysTrayNotify(restartMessage, QSystemTrayIcon::MessageIcon::Information);
|
||||
}
|
||||
} else {
|
||||
Utils::SysTrayNotify(stopMessage, QSystemTrayIcon::MessageIcon::Information);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (event == OBS_FRONTEND_EVENT_FINISHED_LOADING) {
|
||||
FirstRunPasswordSetup();
|
||||
}
|
||||
}
|
||||
|
||||
void Config::FirstRunPasswordSetup()
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
|
||||
// lift the flag up and save it
|
||||
config_set_bool(globalConfig, SECTION_NAME, GLOBAL_AUTH_SETUP_PROMPTED, true);
|
||||
config_save(globalConfig);
|
||||
|
||||
// check if the password is already set
|
||||
auto config = GetConfig();
|
||||
if (!config) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(config->Secret.isEmpty()) && !(config->Salt.isEmpty())) {
|
||||
return;
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
auto mainWindow = reinterpret_cast<QMainWindow*>(
|
||||
obs_frontend_get_main_window()
|
||||
);
|
||||
|
||||
QMessageBox::StandardButton response = QMessageBox::question(mainWindow, dialogTitle, dialogText);
|
||||
if (response == QMessageBox::Yes) {
|
||||
ShowPasswordSetting();
|
||||
}
|
||||
else {
|
||||
// tell the user they still can set the password later in our settings dialog
|
||||
QMessageBox::information(mainWindow, dialogTitle, dismissedText);
|
||||
}
|
||||
}
|
||||
|
65
src/Config.h
65
src/Config.h
@ -1,6 +1,6 @@
|
||||
/*
|
||||
obs-websocket
|
||||
Copyright (C) 2016-2017 Stéphane Lepin <stephane.lepin@gmail.com>
|
||||
Copyright (C) 2016-2019 Stéphane Lepin <stephane.lepin@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
|
||||
@ -16,45 +16,44 @@ You should have received a copy of the GNU General Public License along
|
||||
with this program. If not, see <https://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_H
|
||||
#define CONFIG_H
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include <mbedtls/entropy.h>
|
||||
#include <mbedtls/ctr_drbg.h>
|
||||
#include <obs-frontend-api.h>
|
||||
#include <util/config-file.h>
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QSharedPointer>
|
||||
|
||||
class Config {
|
||||
public:
|
||||
Config();
|
||||
~Config();
|
||||
void Load();
|
||||
void Save();
|
||||
public:
|
||||
Config();
|
||||
~Config();
|
||||
void Load();
|
||||
void Save();
|
||||
void SetDefaults();
|
||||
config_t* GetConfigStore();
|
||||
|
||||
void SetPassword(QString password);
|
||||
bool CheckAuth(QString userChallenge);
|
||||
QString GenerateSalt();
|
||||
static QString GenerateSecret(
|
||||
QString password, QString salt);
|
||||
void MigrateFromGlobalSettings();
|
||||
|
||||
bool ServerEnabled;
|
||||
uint64_t ServerPort;
|
||||
void SetPassword(QString password);
|
||||
bool CheckAuth(QString userChallenge);
|
||||
QString GenerateSalt();
|
||||
static QString GenerateSecret(
|
||||
QString password, QString salt);
|
||||
|
||||
bool DebugEnabled;
|
||||
bool AlertsEnabled;
|
||||
bool ServerEnabled;
|
||||
uint64_t ServerPort;
|
||||
bool LockToIPv4;
|
||||
|
||||
bool AuthRequired;
|
||||
QString Secret;
|
||||
QString Salt;
|
||||
QString SessionChallenge;
|
||||
bool SettingsLoaded;
|
||||
bool DebugEnabled;
|
||||
bool AlertsEnabled;
|
||||
|
||||
static Config* Current();
|
||||
bool AuthRequired;
|
||||
QString Secret;
|
||||
QString Salt;
|
||||
QString SessionChallenge;
|
||||
bool SettingsLoaded;
|
||||
|
||||
private:
|
||||
static Config* _instance;
|
||||
mbedtls_entropy_context entropy;
|
||||
mbedtls_ctr_drbg_context rng;
|
||||
private:
|
||||
static void OnFrontendEvent(enum obs_frontend_event event, void* param);
|
||||
static void FirstRunPasswordSetup();
|
||||
};
|
||||
|
||||
#endif // CONFIG_H
|
34
src/ConnectionProperties.cpp
Normal file
34
src/ConnectionProperties.cpp
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
obs-websocket
|
||||
Copyright (C) 2016-2019 Stéphane Lepin <stephane.lepin@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/>
|
||||
*/
|
||||
|
||||
#include "ConnectionProperties.h"
|
||||
|
||||
ConnectionProperties::ConnectionProperties()
|
||||
: _authenticated(false)
|
||||
{
|
||||
}
|
||||
|
||||
bool ConnectionProperties::isAuthenticated()
|
||||
{
|
||||
return _authenticated.load();
|
||||
}
|
||||
|
||||
void ConnectionProperties::setAuthenticated(bool authenticated)
|
||||
{
|
||||
_authenticated.store(authenticated);
|
||||
}
|
31
src/ConnectionProperties.h
Normal file
31
src/ConnectionProperties.h
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
obs-websocket
|
||||
Copyright (C) 2016-2019 Stéphane Lepin <stephane.lepin@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 <atomic>
|
||||
|
||||
class ConnectionProperties
|
||||
{
|
||||
public:
|
||||
explicit ConnectionProperties();
|
||||
bool isAuthenticated();
|
||||
void setAuthenticated(bool authenticated);
|
||||
private:
|
||||
std::atomic<bool> _authenticated;
|
||||
};
|
1156
src/Utils.cpp
1156
src/Utils.cpp
File diff suppressed because it is too large
Load Diff
110
src/Utils.h
110
src/Utils.h
@ -1,6 +1,6 @@
|
||||
/*
|
||||
obs-websocket
|
||||
Copyright (C) 2016-2017 Stéphane Lepin <stephane.lepin@gmail.com>
|
||||
Copyright (C) 2016-2019 Stéphane Lepin <stephane.lepin@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
|
||||
@ -16,70 +16,84 @@ You should have received a copy of the GNU General Public License along
|
||||
with this program. If not, see <https://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
#ifndef UTILS_H
|
||||
#define UTILS_H
|
||||
#pragma once
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <QSpinBox>
|
||||
#include <QPushButton>
|
||||
#include <QLayout>
|
||||
#include <QListWidget>
|
||||
#include <QSystemTrayIcon>
|
||||
#include <QHostAddress>
|
||||
#include <QtCore/QString>
|
||||
#include <QtWidgets/QSpinBox>
|
||||
#include <QtWidgets/QPushButton>
|
||||
#include <QtWidgets/QLayout>
|
||||
#include <QtWidgets/QListWidget>
|
||||
#include <QtWidgets/QSystemTrayIcon>
|
||||
|
||||
#include <obs.hpp>
|
||||
#include <obs-module.h>
|
||||
#include <util/config-file.h>
|
||||
|
||||
class Utils {
|
||||
public:
|
||||
static obs_data_array_t* StringListToArray(char** strings, char* key);
|
||||
static obs_data_array_t* GetSceneItems(obs_source_t* source);
|
||||
static obs_data_t* GetSceneItemData(obs_sceneitem_t* item);
|
||||
static obs_sceneitem_t* GetSceneItemFromName(
|
||||
obs_source_t* source, QString name);
|
||||
static obs_source_t* GetTransitionFromName(QString transitionName);
|
||||
static obs_source_t* GetSceneFromNameOrCurrent(QString sceneName);
|
||||
typedef void(*PauseRecordingFunction)(bool);
|
||||
typedef bool(*RecordingPausedFunction)();
|
||||
|
||||
static bool IsValidAlignment(const uint32_t alignment);
|
||||
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);
|
||||
|
||||
static obs_data_array_t* GetScenes();
|
||||
static obs_data_t* GetSceneData(obs_source_t* source);
|
||||
// These functions support nested lookup into groups
|
||||
obs_sceneitem_t* GetSceneItemFromName(obs_scene_t* scene, QString name);
|
||||
obs_sceneitem_t* GetSceneItemFromId(obs_scene_t* scene, int64_t id);
|
||||
obs_sceneitem_t* GetSceneItemFromItem(obs_scene_t* scene, obs_data_t* item);
|
||||
obs_sceneitem_t* GetSceneItemFromRequestField(obs_scene_t* scene, obs_data_item_t* dataItem);
|
||||
|
||||
static QSpinBox* GetTransitionDurationControl();
|
||||
static int GetTransitionDuration();
|
||||
static void SetTransitionDuration(int ms);
|
||||
obs_scene_t* GetSceneFromNameOrCurrent(QString sceneName);
|
||||
obs_data_t* GetSceneItemPropertiesData(obs_sceneitem_t* item);
|
||||
|
||||
static bool SetTransitionByName(QString transitionName);
|
||||
obs_data_t* GetSourceFilterInfo(obs_source_t* filter, bool includeSettings);
|
||||
obs_data_array_t* GetSourceFiltersList(obs_source_t* source, bool includeSettings);
|
||||
|
||||
static QPushButton* GetPreviewModeButtonControl();
|
||||
static QLayout* GetPreviewLayout();
|
||||
static QListWidget* GetSceneListControl();
|
||||
static obs_scene_t* SceneListItemToScene(QListWidgetItem* item);
|
||||
bool IsValidAlignment(const uint32_t alignment);
|
||||
|
||||
static void TransitionToProgram();
|
||||
obs_data_array_t* GetScenes();
|
||||
obs_data_t* GetSceneData(obs_source_t* source);
|
||||
|
||||
static QString OBSVersionString();
|
||||
// TODO contribute a proper frontend API method for this to OBS and remove this hack
|
||||
QSpinBox* GetTransitionDurationControl();
|
||||
int GetTransitionDuration(obs_source_t* transition);
|
||||
obs_source_t* GetTransitionFromName(QString transitionName);
|
||||
bool SetTransitionByName(QString transitionName);
|
||||
obs_data_t* GetTransitionData(obs_source_t* transition);
|
||||
|
||||
static QSystemTrayIcon* GetTrayIcon();
|
||||
static void SysTrayNotify(
|
||||
QString &text,
|
||||
QSystemTrayIcon::MessageIcon n,
|
||||
QString title = QString("obs-websocket"));
|
||||
QString OBSVersionString();
|
||||
|
||||
static QString FormatIPAddress(QHostAddress &addr);
|
||||
QSystemTrayIcon* GetTrayIcon();
|
||||
void SysTrayNotify(
|
||||
QString text,
|
||||
QSystemTrayIcon::MessageIcon n,
|
||||
QString title = QString("obs-websocket"));
|
||||
|
||||
static const char* GetRecordingFolder();
|
||||
static bool SetRecordingFolder(const char* path);
|
||||
const char* GetRecordingFolder();
|
||||
bool SetRecordingFolder(const char* path);
|
||||
|
||||
static QString ParseDataToQueryString(obs_data_t* data);
|
||||
static obs_hotkey_t* FindHotkeyByName(QString name);
|
||||
static bool ReplayBufferEnabled();
|
||||
static void StartReplayBuffer();
|
||||
static bool IsRPHotkeySet();
|
||||
static const char* GetFilenameFormatting();
|
||||
static bool SetFilenameFormatting(const char* filenameFormatting);
|
||||
QString ParseDataToQueryString(obs_data_t* data);
|
||||
obs_hotkey_t* FindHotkeyByName(QString name);
|
||||
|
||||
bool ReplayBufferEnabled();
|
||||
void StartReplayBuffer();
|
||||
bool IsRPHotkeySet();
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
#endif // UTILS_H
|
||||
|
2049
src/WSEvents.cpp
2049
src/WSEvents.cpp
File diff suppressed because it is too large
Load Diff
186
src/WSEvents.h
186
src/WSEvents.h
@ -1,6 +1,6 @@
|
||||
/*
|
||||
obs-websocket
|
||||
Copyright (C) 2016-2017 Stéphane Lepin <stephane.lepin@gmail.com>
|
||||
Copyright (C) 2016-2019 Stéphane Lepin <stephane.lepin@gmail.com>
|
||||
Copyright (C) 2017 Brendan Hagan <https://github.com/haganbmj>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@ -17,95 +17,145 @@ You should have received a copy of the GNU General Public License along
|
||||
with this program. If not, see <https://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
#ifndef WSEVENTS_H
|
||||
#define WSEVENTS_H
|
||||
#pragma once
|
||||
|
||||
#include <obs.hpp>
|
||||
#include <obs-frontend-api.h>
|
||||
#include <QListWidgetItem>
|
||||
#include <util/platform.h>
|
||||
|
||||
#include <QtWidgets/QListWidgetItem>
|
||||
#include <QtCore/QSharedPointer>
|
||||
#include <QtCore/QTimer>
|
||||
|
||||
#include "WSServer.h"
|
||||
|
||||
class WSEvents : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit WSEvents(WSServer* srv);
|
||||
~WSEvents();
|
||||
static void FrontendEventHandler(
|
||||
enum obs_frontend_event event, void* privateData);
|
||||
static WSEvents* Instance;
|
||||
void connectTransitionSignals(obs_source_t* transition);
|
||||
void connectSceneSignals(obs_source_t* scene);
|
||||
class WSEvents : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
uint64_t GetStreamingTime();
|
||||
const char* GetStreamingTimecode();
|
||||
uint64_t GetRecordingTime();
|
||||
const char* GetRecordingTimecode();
|
||||
public:
|
||||
explicit WSEvents(WSServerPtr srv);
|
||||
~WSEvents();
|
||||
|
||||
bool HeartbeatIsActive;
|
||||
void connectSourceSignals(obs_source_t* source);
|
||||
void disconnectSourceSignals(obs_source_t* source);
|
||||
|
||||
private slots:
|
||||
void deferredInitOperations();
|
||||
void StreamStatus();
|
||||
void Heartbeat();
|
||||
void TransitionDurationChanged(int ms);
|
||||
void SelectedSceneChanged(
|
||||
QListWidgetItem* current, QListWidgetItem* prev);
|
||||
void connectFilterSignals(obs_source_t* filter);
|
||||
void disconnectFilterSignals(obs_source_t* filter);
|
||||
|
||||
private:
|
||||
WSServer* _srv;
|
||||
OBSSource currentScene;
|
||||
OBSSource currentTransition;
|
||||
void hookTransitionPlaybackEvents();
|
||||
void unhookTransitionPlaybackEvents();
|
||||
|
||||
bool pulse;
|
||||
uint64_t getStreamingTime();
|
||||
uint64_t getRecordingTime();
|
||||
uint64_t getVirtualCamTime();
|
||||
|
||||
bool _streamingActive;
|
||||
bool _recordingActive;
|
||||
QString getStreamingTimecode();
|
||||
QString getRecordingTimecode();
|
||||
QString getVirtualCamTimecode();
|
||||
|
||||
obs_data_t* GetStats();
|
||||
|
||||
uint64_t _streamStarttime;
|
||||
uint64_t _recStarttime;
|
||||
void OnBroadcastCustomMessage(QString realm, obs_data_t* data);
|
||||
|
||||
uint64_t _lastBytesSent;
|
||||
uint64_t _lastBytesSentTime;
|
||||
bool HeartbeatIsActive;
|
||||
|
||||
void broadcastUpdate(const char* updateType,
|
||||
obs_data_t* additionalFields);
|
||||
private slots:
|
||||
void StreamStatus();
|
||||
void Heartbeat();
|
||||
void TransitionDurationChanged(int ms);
|
||||
|
||||
void OnSceneChange();
|
||||
void OnSceneListChange();
|
||||
void OnSceneCollectionChange();
|
||||
void OnSceneCollectionListChange();
|
||||
private:
|
||||
WSServerPtr _srv;
|
||||
QTimer streamStatusTimer;
|
||||
QTimer heartbeatTimer;
|
||||
os_cpu_usage_info_t* cpuUsageInfo;
|
||||
|
||||
void OnTransitionChange();
|
||||
void OnTransitionListChange();
|
||||
bool pulse;
|
||||
|
||||
void OnProfileChange();
|
||||
void OnProfileListChange();
|
||||
uint64_t _streamStarttime;
|
||||
|
||||
void OnStreamStarting();
|
||||
void OnStreamStarted();
|
||||
void OnStreamStopping();
|
||||
void OnStreamStopped();
|
||||
uint64_t _lastBytesSent;
|
||||
uint64_t _lastBytesSentTime;
|
||||
|
||||
void OnRecordingStarting();
|
||||
void OnRecordingStarted();
|
||||
void OnRecordingStopping();
|
||||
void OnRecordingStopped();
|
||||
void broadcastUpdate(const char* updateType,
|
||||
obs_data_t* additionalFields);
|
||||
|
||||
void OnReplayStarting();
|
||||
void OnReplayStarted();
|
||||
void OnReplayStopping();
|
||||
void OnReplayStopped();
|
||||
void OnSceneChange();
|
||||
void OnSceneListChange();
|
||||
void OnSceneCollectionChange();
|
||||
void OnSceneCollectionListChange();
|
||||
|
||||
void OnStudioModeSwitched(bool enabled);
|
||||
void OnTransitionChange();
|
||||
void OnTransitionListChange();
|
||||
|
||||
void OnExit();
|
||||
void OnProfileChange();
|
||||
void OnProfileListChange();
|
||||
|
||||
static void OnTransitionBegin(void* param, calldata_t* data);
|
||||
void OnStreamStarting();
|
||||
void OnStreamStarted();
|
||||
void OnStreamStopping();
|
||||
void OnStreamStopped();
|
||||
|
||||
static void OnSceneReordered(void* param, calldata_t* data);
|
||||
static void OnSceneItemAdd(void* param, calldata_t* data);
|
||||
static void OnSceneItemDelete(void* param, calldata_t* data);
|
||||
static void OnSceneItemVisibilityChanged(void* param, calldata_t* data);
|
||||
void OnRecordingStarting();
|
||||
void OnRecordingStarted();
|
||||
void OnRecordingStopping();
|
||||
void OnRecordingStopped();
|
||||
void OnRecordingPaused();
|
||||
void OnRecordingResumed();
|
||||
|
||||
void OnVirtualCamStarted();
|
||||
void OnVirtualCamStopped();
|
||||
|
||||
void OnReplayStarting();
|
||||
void OnReplayStarted();
|
||||
void OnReplayStopping();
|
||||
void OnReplayStopped();
|
||||
|
||||
void OnStudioModeSwitched(bool enabled);
|
||||
void OnPreviewSceneChanged();
|
||||
|
||||
void OnExit();
|
||||
|
||||
static void FrontendEventHandler(
|
||||
enum obs_frontend_event event, void* privateData);
|
||||
|
||||
static void OnTransitionBegin(void* param, calldata_t* data);
|
||||
static void OnTransitionEnd(void* param, calldata_t* data);
|
||||
static void OnTransitionVideoEnd(void* param, calldata_t* data);
|
||||
|
||||
static void OnSourceCreate(void* param, calldata_t* data);
|
||||
static void OnSourceDestroy(void* param, calldata_t* data);
|
||||
|
||||
static void OnSourceVolumeChange(void* param, calldata_t* data);
|
||||
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);
|
||||
|
||||
static void OnSourceFilterAdded(void* param, calldata_t* data);
|
||||
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);
|
||||
static void OnSceneItemDelete(void* param, calldata_t* data);
|
||||
static void OnSceneItemVisibilityChanged(void* param, calldata_t* data);
|
||||
static void OnSceneItemLockChanged(void* param, calldata_t* data);
|
||||
static void OnSceneItemTransform(void* param, calldata_t* data);
|
||||
static void OnSceneItemSelected(void* param, calldata_t* data);
|
||||
static void OnSceneItemDeselected(void* param, calldata_t* data);
|
||||
};
|
||||
|
||||
#endif // WSEVENTS_H
|
@ -17,6 +17,8 @@
|
||||
* with this program. If not, see <https://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include <obs-data.h>
|
||||
|
||||
#include "Config.h"
|
||||
@ -24,194 +26,196 @@
|
||||
|
||||
#include "WSRequestHandler.h"
|
||||
|
||||
QHash<QString, void(*)(WSRequestHandler*)> WSRequestHandler::messageMap {
|
||||
{ "GetVersion", WSRequestHandler::HandleGetVersion },
|
||||
{ "GetAuthRequired", WSRequestHandler::HandleGetAuthRequired },
|
||||
{ "Authenticate", WSRequestHandler::HandleAuthenticate },
|
||||
using namespace std::placeholders;
|
||||
|
||||
{ "SetHeartbeat", WSRequestHandler::HandleSetHeartbeat },
|
||||
const QHash<QString, RpcMethodHandler> WSRequestHandler::messageMap{
|
||||
// Category: General
|
||||
{ "GetVersion", &WSRequestHandler::GetVersion },
|
||||
{ "GetAuthRequired", &WSRequestHandler::GetAuthRequired },
|
||||
{ "Authenticate", &WSRequestHandler::Authenticate },
|
||||
{ "SetHeartbeat", &WSRequestHandler::SetHeartbeat },
|
||||
{ "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 },
|
||||
|
||||
{ "SetFilenameFormatting", WSRequestHandler::HandleSetFilenameFormatting },
|
||||
{ "GetFilenameFormatting", WSRequestHandler::HandleGetFilenameFormatting },
|
||||
// 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 },
|
||||
|
||||
{ "SetCurrentScene", WSRequestHandler::HandleSetCurrentScene },
|
||||
{ "GetCurrentScene", WSRequestHandler::HandleGetCurrentScene },
|
||||
{ "GetSceneList", WSRequestHandler::HandleGetSceneList },
|
||||
// Category: Outputs
|
||||
{ "ListOutputs", &WSRequestHandler::ListOutputs },
|
||||
{ "GetOutputInfo", &WSRequestHandler::GetOutputInfo },
|
||||
{ "StartOutput", &WSRequestHandler::StartOutput },
|
||||
{ "StopOutput", &WSRequestHandler::StopOutput },
|
||||
|
||||
{ "SetSourceRender", WSRequestHandler::HandleSetSceneItemRender }, // Retrocompat
|
||||
{ "SetSceneItemRender", WSRequestHandler::HandleSetSceneItemRender },
|
||||
{ "SetSceneItemPosition", WSRequestHandler::HandleSetSceneItemPosition },
|
||||
{ "SetSceneItemTransform", WSRequestHandler::HandleSetSceneItemTransform },
|
||||
{ "SetSceneItemCrop", WSRequestHandler::HandleSetSceneItemCrop },
|
||||
{ "GetSceneItemProperties", WSRequestHandler::HandleGetSceneItemProperties },
|
||||
{ "SetSceneItemProperties", WSRequestHandler::HandleSetSceneItemProperties },
|
||||
{ "ResetSceneItem", WSRequestHandler::HandleResetSceneItem },
|
||||
// Category: Profiles
|
||||
{ "SetCurrentProfile", &WSRequestHandler::SetCurrentProfile },
|
||||
{ "GetCurrentProfile", &WSRequestHandler::GetCurrentProfile },
|
||||
{ "ListProfiles", &WSRequestHandler::ListProfiles },
|
||||
|
||||
{ "GetStreamingStatus", WSRequestHandler::HandleGetStreamingStatus },
|
||||
{ "StartStopStreaming", WSRequestHandler::HandleStartStopStreaming },
|
||||
{ "StartStopRecording", WSRequestHandler::HandleStartStopRecording },
|
||||
{ "StartStreaming", WSRequestHandler::HandleStartStreaming },
|
||||
{ "StopStreaming", WSRequestHandler::HandleStopStreaming },
|
||||
{ "StartRecording", WSRequestHandler::HandleStartRecording },
|
||||
{ "StopRecording", WSRequestHandler::HandleStopRecording },
|
||||
// Category: Recording
|
||||
{ "GetRecordingStatus", &WSRequestHandler::GetRecordingStatus },
|
||||
{ "StartStopRecording", &WSRequestHandler::StartStopRecording },
|
||||
{ "StartRecording", &WSRequestHandler::StartRecording },
|
||||
{ "StopRecording", &WSRequestHandler::StopRecording },
|
||||
{ "PauseRecording", &WSRequestHandler::PauseRecording },
|
||||
{ "ResumeRecording", &WSRequestHandler::ResumeRecording },
|
||||
{ "SetRecordingFolder", &WSRequestHandler::SetRecordingFolder },
|
||||
{ "GetRecordingFolder", &WSRequestHandler::GetRecordingFolder },
|
||||
|
||||
{ "StartStopReplayBuffer", WSRequestHandler::HandleStartStopReplayBuffer },
|
||||
{ "StartReplayBuffer", WSRequestHandler::HandleStartReplayBuffer },
|
||||
{ "StopReplayBuffer", WSRequestHandler::HandleStopReplayBuffer },
|
||||
{ "SaveReplayBuffer", WSRequestHandler::HandleSaveReplayBuffer },
|
||||
// Category: Replay Buffer
|
||||
{ "GetReplayBufferStatus", &WSRequestHandler::GetReplayBufferStatus },
|
||||
{ "StartStopReplayBuffer", &WSRequestHandler::StartStopReplayBuffer },
|
||||
{ "StartReplayBuffer", &WSRequestHandler::StartReplayBuffer },
|
||||
{ "StopReplayBuffer", &WSRequestHandler::StopReplayBuffer },
|
||||
{ "SaveReplayBuffer", &WSRequestHandler::SaveReplayBuffer },
|
||||
|
||||
{ "SetRecordingFolder", WSRequestHandler::HandleSetRecordingFolder },
|
||||
{ "GetRecordingFolder", WSRequestHandler::HandleGetRecordingFolder },
|
||||
// Category: Scene Collections
|
||||
{ "SetCurrentSceneCollection", &WSRequestHandler::SetCurrentSceneCollection },
|
||||
{ "GetCurrentSceneCollection", &WSRequestHandler::GetCurrentSceneCollection },
|
||||
{ "ListSceneCollections", &WSRequestHandler::ListSceneCollections },
|
||||
|
||||
{ "GetTransitionList", WSRequestHandler::HandleGetTransitionList },
|
||||
{ "GetCurrentTransition", WSRequestHandler::HandleGetCurrentTransition },
|
||||
{ "SetCurrentTransition", WSRequestHandler::HandleSetCurrentTransition },
|
||||
{ "SetTransitionDuration", WSRequestHandler::HandleSetTransitionDuration },
|
||||
{ "GetTransitionDuration", WSRequestHandler::HandleGetTransitionDuration },
|
||||
// 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::HandleSetVolume },
|
||||
{ "GetVolume", WSRequestHandler::HandleGetVolume },
|
||||
{ "ToggleMute", WSRequestHandler::HandleToggleMute },
|
||||
{ "SetMute", WSRequestHandler::HandleSetMute },
|
||||
{ "GetMute", WSRequestHandler::HandleGetMute },
|
||||
{ "SetSyncOffset", WSRequestHandler::HandleSetSyncOffset },
|
||||
{ "GetSyncOffset", WSRequestHandler::HandleGetSyncOffset },
|
||||
{ "GetSpecialSources", WSRequestHandler::HandleGetSpecialSources },
|
||||
{ "GetSourcesList", WSRequestHandler::HandleGetSourcesList },
|
||||
{ "GetSourceTypesList", WSRequestHandler::HandleGetSourceTypesList },
|
||||
{ "GetSourceSettings", WSRequestHandler::HandleGetSourceSettings },
|
||||
{ "SetSourceSettings", WSRequestHandler::HandleSetSourceSettings },
|
||||
// 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 },
|
||||
|
||||
{ "SetCurrentSceneCollection", WSRequestHandler::HandleSetCurrentSceneCollection },
|
||||
{ "GetCurrentSceneCollection", WSRequestHandler::HandleGetCurrentSceneCollection },
|
||||
{ "ListSceneCollections", WSRequestHandler::HandleListSceneCollections },
|
||||
// Category: Sources
|
||||
{ "CreateSource", &WSRequestHandler::CreateSource },
|
||||
{ "GetSourcesList", &WSRequestHandler::GetSourcesList },
|
||||
{ "GetSourceTypesList", &WSRequestHandler::GetSourceTypesList },
|
||||
{ "GetVolume", &WSRequestHandler::GetVolume },
|
||||
{ "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 },
|
||||
{ "GetSourceSettings", &WSRequestHandler::GetSourceSettings },
|
||||
{ "SetSourceSettings", &WSRequestHandler::SetSourceSettings },
|
||||
{ "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 },
|
||||
{ "RemoveFilterFromSource", &WSRequestHandler::RemoveFilterFromSource },
|
||||
{ "ReorderSourceFilter", &WSRequestHandler::ReorderSourceFilter },
|
||||
{ "MoveSourceFilter", &WSRequestHandler::MoveSourceFilter },
|
||||
{ "SetSourceFilterSettings", &WSRequestHandler::SetSourceFilterSettings },
|
||||
{ "SetSourceFilterVisibility", &WSRequestHandler::SetSourceFilterVisibility },
|
||||
{ "GetAudioMonitorType", &WSRequestHandler::GetAudioMonitorType },
|
||||
{ "SetAudioMonitorType", &WSRequestHandler::SetAudioMonitorType },
|
||||
{ "GetSourceDefaultSettings", &WSRequestHandler::GetSourceDefaultSettings },
|
||||
{ "TakeSourceScreenshot", &WSRequestHandler::TakeSourceScreenshot },
|
||||
{ "RefreshBrowserSource", &WSRequestHandler::RefreshBrowserSource },
|
||||
|
||||
{ "SetCurrentProfile", WSRequestHandler::HandleSetCurrentProfile },
|
||||
{ "GetCurrentProfile", WSRequestHandler::HandleGetCurrentProfile },
|
||||
{ "ListProfiles", WSRequestHandler::HandleListProfiles },
|
||||
// Category: Streaming
|
||||
{ "GetStreamingStatus", &WSRequestHandler::GetStreamingStatus },
|
||||
{ "StartStopStreaming", &WSRequestHandler::StartStopStreaming },
|
||||
{ "StartStreaming", &WSRequestHandler::StartStreaming },
|
||||
{ "StopStreaming", &WSRequestHandler::StopStreaming },
|
||||
{ "SetStreamSettings", &WSRequestHandler::SetStreamSettings },
|
||||
{ "GetStreamSettings", &WSRequestHandler::GetStreamSettings },
|
||||
{ "SaveStreamSettings", &WSRequestHandler::SaveStreamSettings },
|
||||
{ "SendCaptions", &WSRequestHandler::SendCaptions },
|
||||
|
||||
// Category: VirtualCam
|
||||
{ "GetVirtualCamStatus", &WSRequestHandler::GetVirtualCamStatus },
|
||||
{ "StartStopVirtualCam", &WSRequestHandler::StartStopVirtualCam },
|
||||
{ "StartVirtualCam", &WSRequestHandler::StartVirtualCam },
|
||||
{ "StopVirtualCam", &WSRequestHandler::StopVirtualCam },
|
||||
|
||||
{ "SetStreamSettings", WSRequestHandler::HandleSetStreamSettings },
|
||||
{ "GetStreamSettings", WSRequestHandler::HandleGetStreamSettings },
|
||||
{ "SaveStreamSettings", WSRequestHandler::HandleSaveStreamSettings },
|
||||
// Category: Studio Mode
|
||||
{ "GetStudioModeStatus", &WSRequestHandler::GetStudioModeStatus },
|
||||
{ "GetPreviewScene", &WSRequestHandler::GetPreviewScene },
|
||||
{ "SetPreviewScene", &WSRequestHandler::SetPreviewScene },
|
||||
{ "TransitionToProgram", &WSRequestHandler::TransitionToProgram },
|
||||
{ "EnableStudioMode", &WSRequestHandler::EnableStudioMode },
|
||||
{ "DisableStudioMode", &WSRequestHandler::DisableStudioMode },
|
||||
{ "ToggleStudioMode", &WSRequestHandler::ToggleStudioMode },
|
||||
|
||||
{ "GetStudioModeStatus", WSRequestHandler::HandleGetStudioModeStatus },
|
||||
{ "GetPreviewScene", WSRequestHandler::HandleGetPreviewScene },
|
||||
{ "SetPreviewScene", WSRequestHandler::HandleSetPreviewScene },
|
||||
{ "TransitionToProgram", WSRequestHandler::HandleTransitionToProgram },
|
||||
{ "EnableStudioMode", WSRequestHandler::HandleEnableStudioMode },
|
||||
{ "DisableStudioMode", WSRequestHandler::HandleDisableStudioMode },
|
||||
{ "ToggleStudioMode", WSRequestHandler::HandleToggleStudioMode },
|
||||
|
||||
{ "SetTextGDIPlusProperties", WSRequestHandler::HandleSetTextGDIPlusProperties },
|
||||
{ "GetTextGDIPlusProperties", WSRequestHandler::HandleGetTextGDIPlusProperties },
|
||||
|
||||
{ "GetBrowserSourceProperties", WSRequestHandler::HandleGetBrowserSourceProperties },
|
||||
{ "SetBrowserSourceProperties", WSRequestHandler::HandleSetBrowserSourceProperties }
|
||||
// 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 }
|
||||
};
|
||||
|
||||
QSet<QString> WSRequestHandler::authNotRequired {
|
||||
"GetVersion",
|
||||
"GetAuthRequired",
|
||||
"Authenticate"
|
||||
const QSet<QString> WSRequestHandler::authNotRequired {
|
||||
"GetVersion",
|
||||
"GetAuthRequired",
|
||||
"Authenticate"
|
||||
};
|
||||
|
||||
WSRequestHandler::WSRequestHandler(QWebSocket* client) :
|
||||
_messageId(0),
|
||||
_requestType(""),
|
||||
data(nullptr),
|
||||
_client(client)
|
||||
WSRequestHandler::WSRequestHandler(ConnectionProperties& connProperties) :
|
||||
_connProperties(connProperties)
|
||||
{
|
||||
}
|
||||
|
||||
void WSRequestHandler::processIncomingMessage(QString textMessage) {
|
||||
QByteArray msgData = textMessage.toUtf8();
|
||||
const char* msg = msgData.constData();
|
||||
RpcResponse WSRequestHandler::processRequest(const RpcRequest& request) {
|
||||
auto config = GetConfig();
|
||||
if ((config && config->AuthRequired)
|
||||
&& (!authNotRequired.contains(request.methodName()))
|
||||
&& (!_connProperties.isAuthenticated()))
|
||||
{
|
||||
return RpcResponse::fail(request, "Not Authenticated");
|
||||
}
|
||||
|
||||
data = obs_data_create_from_json(msg);
|
||||
if (!data) {
|
||||
if (!msg)
|
||||
msg = "<null pointer>";
|
||||
RpcMethodHandler handlerFunc = messageMap[request.methodName()];
|
||||
if (!handlerFunc) {
|
||||
return RpcResponse::fail(request, "invalid request type");
|
||||
}
|
||||
|
||||
blog(LOG_ERROR, "invalid JSON payload received for '%s'", msg);
|
||||
SendErrorResponse("invalid JSON payload");
|
||||
return;
|
||||
}
|
||||
|
||||
if (Config::Current()->DebugEnabled) {
|
||||
blog(LOG_DEBUG, "Request >> '%s'", msg);
|
||||
}
|
||||
|
||||
if (!hasField("request-type")
|
||||
|| !hasField("message-id"))
|
||||
{
|
||||
SendErrorResponse("missing request parameters");
|
||||
return;
|
||||
}
|
||||
|
||||
_requestType = obs_data_get_string(data, "request-type");
|
||||
_messageId = obs_data_get_string(data, "message-id");
|
||||
|
||||
if (Config::Current()->AuthRequired
|
||||
&& (_client->property(PROP_AUTHENTICATED).toBool() == false)
|
||||
&& (authNotRequired.find(_requestType) == authNotRequired.end()))
|
||||
{
|
||||
SendErrorResponse("Not Authenticated");
|
||||
return;
|
||||
}
|
||||
|
||||
void (*handlerFunc)(WSRequestHandler*) = (messageMap[_requestType]);
|
||||
|
||||
if (handlerFunc != nullptr)
|
||||
handlerFunc(this);
|
||||
else
|
||||
SendErrorResponse("invalid request type");
|
||||
}
|
||||
|
||||
WSRequestHandler::~WSRequestHandler() {
|
||||
}
|
||||
|
||||
void WSRequestHandler::SendOKResponse(obs_data_t* additionalFields) {
|
||||
OBSDataAutoRelease response = obs_data_create();
|
||||
obs_data_set_string(response, "status", "ok");
|
||||
obs_data_set_string(response, "message-id", _messageId);
|
||||
|
||||
if (additionalFields)
|
||||
obs_data_apply(response, additionalFields);
|
||||
|
||||
SendResponse(response);
|
||||
}
|
||||
|
||||
void WSRequestHandler::SendErrorResponse(const char* errorMessage) {
|
||||
OBSDataAutoRelease response = obs_data_create();
|
||||
obs_data_set_string(response, "status", "error");
|
||||
obs_data_set_string(response, "error", errorMessage);
|
||||
obs_data_set_string(response, "message-id", _messageId);
|
||||
|
||||
SendResponse(response);
|
||||
}
|
||||
|
||||
void WSRequestHandler::SendErrorResponse(obs_data_t* additionalFields) {
|
||||
OBSDataAutoRelease response = obs_data_create();
|
||||
obs_data_set_string(response, "status", "error");
|
||||
obs_data_set_string(response, "message-id", _messageId);
|
||||
|
||||
if (additionalFields)
|
||||
obs_data_set_obj(response, "error", additionalFields);
|
||||
|
||||
SendResponse(response);
|
||||
}
|
||||
|
||||
void WSRequestHandler::SendResponse(obs_data_t* response) {
|
||||
QString json = obs_data_get_json(response);
|
||||
_client->sendTextMessage(json);
|
||||
|
||||
if (Config::Current()->DebugEnabled)
|
||||
blog(LOG_DEBUG, "Response << '%s'", json.toUtf8().constData());
|
||||
}
|
||||
|
||||
bool WSRequestHandler::hasField(QString name) {
|
||||
if (!data || name.isEmpty() || name.isNull())
|
||||
return false;
|
||||
|
||||
return obs_data_has_user_value(data, name.toUtf8());
|
||||
return std::bind(handlerFunc, this, _1)(request);
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
obs-websocket
|
||||
Copyright (C) 2016-2017 Stéphane Lepin <stephane.lepin@gmail.com>
|
||||
Copyright (C) 2016-2019 Stéphane Lepin <stephane.lepin@gmail.com>
|
||||
Copyright (C) 2017 Mikhail Swift <https://github.com/mikhailswift>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
@ -17,123 +17,194 @@ You should have received a copy of the GNU General Public License along
|
||||
with this program. If not, see <https://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
#ifndef WSREQUESTHANDLER_H
|
||||
#define WSREQUESTHANDLER_H
|
||||
#pragma once
|
||||
|
||||
#include <QHash>
|
||||
#include <QSet>
|
||||
#include <QWebSocket>
|
||||
#include <QWebSocketServer>
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QHash>
|
||||
#include <QtCore/QSet>
|
||||
|
||||
#include <obs.hpp>
|
||||
#include <obs-frontend-api.h>
|
||||
|
||||
#include "ConnectionProperties.h"
|
||||
|
||||
#include "rpc/RpcRequest.h"
|
||||
#include "rpc/RpcResponse.h"
|
||||
|
||||
#include "obs-websocket.h"
|
||||
|
||||
class WSRequestHandler : public QObject {
|
||||
Q_OBJECT
|
||||
class WSRequestHandler;
|
||||
typedef RpcResponse(WSRequestHandler::*RpcMethodHandler)(const RpcRequest&);
|
||||
|
||||
public:
|
||||
explicit WSRequestHandler(QWebSocket* client);
|
||||
~WSRequestHandler();
|
||||
void processIncomingMessage(QString textMessage);
|
||||
bool hasField(QString name);
|
||||
class WSRequestHandler {
|
||||
public:
|
||||
explicit WSRequestHandler(ConnectionProperties& connProperties);
|
||||
RpcResponse processRequest(const RpcRequest& textMessage);
|
||||
|
||||
private:
|
||||
QWebSocket* _client;
|
||||
const char* _messageId;
|
||||
const char* _requestType;
|
||||
OBSDataAutoRelease data;
|
||||
private:
|
||||
ConnectionProperties& _connProperties;
|
||||
|
||||
void SendOKResponse(obs_data_t* additionalFields = NULL);
|
||||
void SendErrorResponse(const char* errorMessage);
|
||||
void SendErrorResponse(obs_data_t* additionalFields = NULL);
|
||||
void SendResponse(obs_data_t* response);
|
||||
static const QHash<QString, RpcMethodHandler> messageMap;
|
||||
static const QSet<QString> authNotRequired;
|
||||
|
||||
static QHash<QString, void(*)(WSRequestHandler*)> messageMap;
|
||||
static QSet<QString> authNotRequired;
|
||||
// Category: General
|
||||
RpcResponse GetVersion(const RpcRequest&);
|
||||
RpcResponse GetAuthRequired(const RpcRequest&);
|
||||
RpcResponse Authenticate(const RpcRequest&);
|
||||
RpcResponse SetHeartbeat(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&);
|
||||
|
||||
static void HandleGetVersion(WSRequestHandler* req);
|
||||
static void HandleGetAuthRequired(WSRequestHandler* req);
|
||||
static void HandleAuthenticate(WSRequestHandler* req);
|
||||
// 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&);
|
||||
|
||||
static void HandleSetHeartbeat(WSRequestHandler* req);
|
||||
// Category: Outputs
|
||||
RpcResponse ListOutputs(const RpcRequest&);
|
||||
RpcResponse GetOutputInfo(const RpcRequest&);
|
||||
RpcResponse StartOutput(const RpcRequest&);
|
||||
RpcResponse StopOutput(const RpcRequest&);
|
||||
|
||||
static void HandleSetFilenameFormatting(WSRequestHandler* req);
|
||||
static void HandleGetFilenameFormatting(WSRequestHandler* req);
|
||||
// Category: Profiles
|
||||
RpcResponse SetCurrentProfile(const RpcRequest&);
|
||||
RpcResponse GetCurrentProfile(const RpcRequest&);
|
||||
RpcResponse ListProfiles(const RpcRequest&);
|
||||
|
||||
static void HandleSetCurrentScene(WSRequestHandler* req);
|
||||
static void HandleGetCurrentScene(WSRequestHandler* req);
|
||||
static void HandleGetSceneList(WSRequestHandler* req);
|
||||
// Category: Recording
|
||||
RpcResponse GetRecordingStatus(const RpcRequest&);
|
||||
RpcResponse StartStopRecording(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&);
|
||||
|
||||
static void HandleSetSceneItemRender(WSRequestHandler* req);
|
||||
static void HandleSetSceneItemPosition(WSRequestHandler* req);
|
||||
static void HandleSetSceneItemTransform(WSRequestHandler* req);
|
||||
static void HandleSetSceneItemCrop(WSRequestHandler* req);
|
||||
static void HandleGetSceneItemProperties(WSRequestHandler* req);
|
||||
static void HandleSetSceneItemProperties(WSRequestHandler* req);
|
||||
static void HandleResetSceneItem(WSRequestHandler* req);
|
||||
// Category: Replay Buffer
|
||||
RpcResponse GetReplayBufferStatus(const RpcRequest&);
|
||||
RpcResponse StartStopReplayBuffer(const RpcRequest&);
|
||||
RpcResponse StartReplayBuffer(const RpcRequest&);
|
||||
RpcResponse StopReplayBuffer(const RpcRequest&);
|
||||
RpcResponse SaveReplayBuffer(const RpcRequest&);
|
||||
|
||||
static void HandleGetStreamingStatus(WSRequestHandler* req);
|
||||
static void HandleStartStopStreaming(WSRequestHandler* req);
|
||||
static void HandleStartStopRecording(WSRequestHandler* req);
|
||||
static void HandleStartStreaming(WSRequestHandler* req);
|
||||
static void HandleStopStreaming(WSRequestHandler* req);
|
||||
static void HandleStartRecording(WSRequestHandler* req);
|
||||
static void HandleStopRecording(WSRequestHandler* req);
|
||||
// Category: Scene Collections
|
||||
RpcResponse SetCurrentSceneCollection(const RpcRequest&);
|
||||
RpcResponse GetCurrentSceneCollection(const RpcRequest&);
|
||||
RpcResponse ListSceneCollections(const RpcRequest&);
|
||||
|
||||
static void HandleStartStopReplayBuffer(WSRequestHandler* req);
|
||||
static void HandleStartReplayBuffer(WSRequestHandler* req);
|
||||
static void HandleStopReplayBuffer(WSRequestHandler* req);
|
||||
static void HandleSaveReplayBuffer(WSRequestHandler* req);
|
||||
// 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&);
|
||||
|
||||
static void HandleSetRecordingFolder(WSRequestHandler* req);
|
||||
static void HandleGetRecordingFolder(WSRequestHandler* req);
|
||||
// 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&);
|
||||
|
||||
static void HandleGetTransitionList(WSRequestHandler* req);
|
||||
static void HandleGetCurrentTransition(WSRequestHandler* req);
|
||||
static void HandleSetCurrentTransition(WSRequestHandler* req);
|
||||
// Category: Sources
|
||||
RpcResponse CreateSource(const RpcRequest&);
|
||||
RpcResponse GetSourcesList(const RpcRequest&);
|
||||
RpcResponse GetSourceTypesList(const RpcRequest&);
|
||||
RpcResponse GetVolume(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 GetSourceSettings(const RpcRequest&);
|
||||
RpcResponse SetSourceSettings(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&);
|
||||
RpcResponse RemoveFilterFromSource(const RpcRequest&);
|
||||
RpcResponse ReorderSourceFilter(const RpcRequest&);
|
||||
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&);
|
||||
|
||||
static void HandleSetVolume(WSRequestHandler* req);
|
||||
static void HandleGetVolume(WSRequestHandler* req);
|
||||
static void HandleToggleMute(WSRequestHandler* req);
|
||||
static void HandleSetMute(WSRequestHandler* req);
|
||||
static void HandleGetMute(WSRequestHandler* req);
|
||||
static void HandleSetSyncOffset(WSRequestHandler* req);
|
||||
static void HandleGetSyncOffset(WSRequestHandler* req);
|
||||
static void HandleGetSpecialSources(WSRequestHandler* req);
|
||||
static void HandleGetSourcesList(WSRequestHandler* req);
|
||||
static void HandleGetSourceTypesList(WSRequestHandler* req);
|
||||
static void HandleGetSourceSettings(WSRequestHandler* req);
|
||||
static void HandleSetSourceSettings(WSRequestHandler* req);
|
||||
// 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&);
|
||||
RpcResponse SendCaptions(const RpcRequest&);
|
||||
|
||||
// Category: Virtual Cam
|
||||
RpcResponse GetVirtualCamStatus(const RpcRequest&);
|
||||
RpcResponse StartStopVirtualCam(const RpcRequest&);
|
||||
RpcResponse StartVirtualCam(const RpcRequest&);
|
||||
RpcResponse StopVirtualCam(const RpcRequest&);
|
||||
|
||||
static void HandleSetCurrentSceneCollection(WSRequestHandler* req);
|
||||
static void HandleGetCurrentSceneCollection(WSRequestHandler* req);
|
||||
static void HandleListSceneCollections(WSRequestHandler* req);
|
||||
// Category: Studio Mode
|
||||
RpcResponse GetStudioModeStatus(const RpcRequest&);
|
||||
RpcResponse GetPreviewScene(const RpcRequest&);
|
||||
RpcResponse SetPreviewScene(const RpcRequest&);
|
||||
RpcResponse TransitionToProgram(const RpcRequest&);
|
||||
RpcResponse EnableStudioMode(const RpcRequest&);
|
||||
RpcResponse DisableStudioMode(const RpcRequest&);
|
||||
RpcResponse ToggleStudioMode(const RpcRequest&);
|
||||
|
||||
static void HandleSetCurrentProfile(WSRequestHandler* req);
|
||||
static void HandleGetCurrentProfile(WSRequestHandler* req);
|
||||
static void HandleListProfiles(WSRequestHandler* req);
|
||||
|
||||
static void HandleSetStreamSettings(WSRequestHandler* req);
|
||||
static void HandleGetStreamSettings(WSRequestHandler* req);
|
||||
static void HandleSaveStreamSettings(WSRequestHandler* req);
|
||||
|
||||
static void HandleSetTransitionDuration(WSRequestHandler* req);
|
||||
static void HandleGetTransitionDuration(WSRequestHandler* req);
|
||||
|
||||
static void HandleGetStudioModeStatus(WSRequestHandler* req);
|
||||
static void HandleGetPreviewScene(WSRequestHandler* req);
|
||||
static void HandleSetPreviewScene(WSRequestHandler* req);
|
||||
static void HandleTransitionToProgram(WSRequestHandler* req);
|
||||
static void HandleEnableStudioMode(WSRequestHandler* req);
|
||||
static void HandleDisableStudioMode(WSRequestHandler* req);
|
||||
static void HandleToggleStudioMode(WSRequestHandler* req);
|
||||
|
||||
static void HandleSetTextGDIPlusProperties(WSRequestHandler* req);
|
||||
static void HandleGetTextGDIPlusProperties(WSRequestHandler* req);
|
||||
static void HandleSetBrowserSourceProperties(WSRequestHandler* req);
|
||||
static void HandleGetBrowserSourceProperties(WSRequestHandler* req);
|
||||
// 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&);
|
||||
};
|
||||
|
||||
#endif // WSPROTOCOL_H
|
||||
|
@ -1,10 +1,61 @@
|
||||
#include <QString>
|
||||
#include "WSRequestHandler.h"
|
||||
|
||||
#include <QtCore/QByteArray>
|
||||
#include <QtGui/QImageWriter>
|
||||
|
||||
#include "obs-websocket.h"
|
||||
#include "Config.h"
|
||||
#include "Utils.h"
|
||||
#include "WSEvents.h"
|
||||
#include "protocol/OBSRemoteProtocol.h"
|
||||
|
||||
#include "WSRequestHandler.h"
|
||||
#define CASE(x) case x: return #x;
|
||||
const char *describe_output_format(int format) {
|
||||
switch (format) {
|
||||
default:
|
||||
CASE(VIDEO_FORMAT_NONE)
|
||||
CASE(VIDEO_FORMAT_I420)
|
||||
CASE(VIDEO_FORMAT_NV12)
|
||||
CASE(VIDEO_FORMAT_YVYU)
|
||||
CASE(VIDEO_FORMAT_YUY2)
|
||||
CASE(VIDEO_FORMAT_UYVY)
|
||||
CASE(VIDEO_FORMAT_RGBA)
|
||||
CASE(VIDEO_FORMAT_BGRA)
|
||||
CASE(VIDEO_FORMAT_BGRX)
|
||||
CASE(VIDEO_FORMAT_Y800)
|
||||
CASE(VIDEO_FORMAT_I444)
|
||||
}
|
||||
}
|
||||
|
||||
const char *describe_color_space(int cs) {
|
||||
switch (cs) {
|
||||
default:
|
||||
CASE(VIDEO_CS_DEFAULT)
|
||||
CASE(VIDEO_CS_601)
|
||||
CASE(VIDEO_CS_709)
|
||||
}
|
||||
}
|
||||
|
||||
const char *describe_color_range(int range) {
|
||||
switch (range) {
|
||||
default:
|
||||
CASE(VIDEO_RANGE_DEFAULT)
|
||||
CASE(VIDEO_RANGE_PARTIAL)
|
||||
CASE(VIDEO_RANGE_FULL)
|
||||
}
|
||||
}
|
||||
|
||||
const char *describe_scale_type(int scale) {
|
||||
switch (scale) {
|
||||
default:
|
||||
CASE(VIDEO_SCALE_DEFAULT)
|
||||
CASE(VIDEO_SCALE_POINT)
|
||||
CASE(VIDEO_SCALE_FAST_BILINEAR)
|
||||
CASE(VIDEO_SCALE_BILINEAR)
|
||||
CASE(VIDEO_SCALE_BICUBIC)
|
||||
}
|
||||
}
|
||||
#undef CASE
|
||||
|
||||
/**
|
||||
* Returns the latest version of the plugin and the API.
|
||||
@ -13,31 +64,41 @@
|
||||
* @return {String} `obs-websocket-version` obs-websocket plugin version.
|
||||
* @return {String} `obs-studio-version` OBS Studio program version.
|
||||
* @return {String} `available-requests` List of available request types, formatted as a comma-separated list string (e.g. : "Method1,Method2,Method3").
|
||||
* @return {String} `supported-image-export-formats` List of supported formats for features that use image export (like the TakeSourceScreenshot request type) formatted as a comma-separated list string
|
||||
*
|
||||
* @api requests
|
||||
* @name GetVersion
|
||||
* @category general
|
||||
* @since 0.3
|
||||
*/
|
||||
void WSRequestHandler::HandleGetVersion(WSRequestHandler* req) {
|
||||
QString obsVersion = Utils::OBSVersionString();
|
||||
RpcResponse WSRequestHandler::GetVersion(const RpcRequest& request) {
|
||||
QString obsVersion = Utils::OBSVersionString();
|
||||
|
||||
QList<QString> names = req->messageMap.keys();
|
||||
names.sort(Qt::CaseInsensitive);
|
||||
QList<QString> names = messageMap.keys();
|
||||
QList<QByteArray> imageWriterFormats = QImageWriter::supportedImageFormats();
|
||||
|
||||
// (Palakis) OBS' data arrays only support object arrays, so I improvised.
|
||||
QString requests;
|
||||
requests += names.takeFirst();
|
||||
for (QString reqName : names) {
|
||||
requests += ("," + reqName);
|
||||
}
|
||||
// (Palakis) OBS' data arrays only support object arrays, so I improvised.
|
||||
QString requests;
|
||||
names.sort(Qt::CaseInsensitive);
|
||||
requests += names.takeFirst();
|
||||
for (const QString& reqName : names) {
|
||||
requests += ("," + reqName);
|
||||
}
|
||||
|
||||
OBSDataAutoRelease data = obs_data_create();
|
||||
obs_data_set_string(data, "obs-websocket-version", OBS_WEBSOCKET_VERSION);
|
||||
obs_data_set_string(data, "obs-studio-version", obsVersion.toUtf8());
|
||||
obs_data_set_string(data, "available-requests", requests.toUtf8());
|
||||
QString supportedImageExportFormats;
|
||||
supportedImageExportFormats += QString::fromUtf8(imageWriterFormats.takeFirst());
|
||||
for (const QByteArray& format : imageWriterFormats) {
|
||||
supportedImageExportFormats += ("," + QString::fromUtf8(format));
|
||||
}
|
||||
|
||||
req->SendOKResponse(data);
|
||||
OBSDataAutoRelease data = obs_data_create();
|
||||
obs_data_set_double(data, "version", 1.1);
|
||||
obs_data_set_string(data, "obs-websocket-version", OBS_WEBSOCKET_VERSION);
|
||||
obs_data_set_string(data, "obs-studio-version", obsVersion.toUtf8());
|
||||
obs_data_set_string(data, "available-requests", requests.toUtf8());
|
||||
obs_data_set_string(data, "supported-image-export-formats", supportedImageExportFormats.toUtf8());
|
||||
|
||||
return request.success(data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -53,20 +114,21 @@
|
||||
* @category general
|
||||
* @since 0.3
|
||||
*/
|
||||
void WSRequestHandler::HandleGetAuthRequired(WSRequestHandler* req) {
|
||||
bool authRequired = Config::Current()->AuthRequired;
|
||||
RpcResponse WSRequestHandler::GetAuthRequired(const RpcRequest& request) {
|
||||
auto config = GetConfig();
|
||||
bool authRequired = (config && config->AuthRequired);
|
||||
|
||||
OBSDataAutoRelease data = obs_data_create();
|
||||
obs_data_set_bool(data, "authRequired", authRequired);
|
||||
OBSDataAutoRelease data = obs_data_create();
|
||||
obs_data_set_bool(data, "authRequired", authRequired);
|
||||
|
||||
if (authRequired) {
|
||||
obs_data_set_string(data, "challenge",
|
||||
Config::Current()->SessionChallenge.toUtf8());
|
||||
obs_data_set_string(data, "salt",
|
||||
Config::Current()->Salt.toUtf8());
|
||||
}
|
||||
if (authRequired) {
|
||||
obs_data_set_string(data, "challenge",
|
||||
config->SessionChallenge.toUtf8());
|
||||
obs_data_set_string(data, "salt",
|
||||
config->Salt.toUtf8());
|
||||
}
|
||||
|
||||
req->SendOKResponse(data);
|
||||
return request.success(data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -79,26 +141,27 @@ void WSRequestHandler::HandleGetAuthRequired(WSRequestHandler* req) {
|
||||
* @category general
|
||||
* @since 0.3
|
||||
*/
|
||||
void WSRequestHandler::HandleAuthenticate(WSRequestHandler* req) {
|
||||
if (!req->hasField("auth")) {
|
||||
req->SendErrorResponse("missing request parameters");
|
||||
return;
|
||||
}
|
||||
RpcResponse WSRequestHandler::Authenticate(const RpcRequest& request) {
|
||||
if (!request.hasField("auth")) {
|
||||
return request.failed("missing request parameters");
|
||||
}
|
||||
|
||||
QString auth = obs_data_get_string(req->data, "auth");
|
||||
if (auth.isEmpty()) {
|
||||
req->SendErrorResponse("auth not specified!");
|
||||
return;
|
||||
}
|
||||
if (_connProperties.isAuthenticated()) {
|
||||
return request.failed("already authenticated");
|
||||
}
|
||||
|
||||
if ((req->_client->property(PROP_AUTHENTICATED).toBool() == false)
|
||||
&& Config::Current()->CheckAuth(auth))
|
||||
{
|
||||
req->_client->setProperty(PROP_AUTHENTICATED, true);
|
||||
req->SendOKResponse();
|
||||
} else {
|
||||
req->SendErrorResponse("Authentication Failed.");
|
||||
}
|
||||
QString auth = obs_data_get_string(request.parameters(), "auth");
|
||||
if (auth.isEmpty()) {
|
||||
return request.failed("auth not specified!");
|
||||
}
|
||||
|
||||
auto config = GetConfig();
|
||||
if (!config || (config->CheckAuth(auth) == false)) {
|
||||
return request.failed("Authentication Failed.");
|
||||
}
|
||||
|
||||
_connProperties.setAuthenticated(true);
|
||||
return request.success();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -110,20 +173,20 @@ void WSRequestHandler::HandleAuthenticate(WSRequestHandler* req) {
|
||||
* @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.
|
||||
*/
|
||||
void WSRequestHandler::HandleSetHeartbeat(WSRequestHandler* req) {
|
||||
if (!req->hasField("enable")) {
|
||||
req->SendErrorResponse("Heartbeat <enable> parameter missing");
|
||||
return;
|
||||
}
|
||||
RpcResponse WSRequestHandler::SetHeartbeat(const RpcRequest& request) {
|
||||
if (!request.hasField("enable")) {
|
||||
return request.failed("Heartbeat <enable> parameter missing");
|
||||
}
|
||||
|
||||
WSEvents::Instance->HeartbeatIsActive =
|
||||
obs_data_get_bool(req->data, "enable");
|
||||
auto events = GetEventsSystem();
|
||||
events->HeartbeatIsActive = obs_data_get_bool(request.parameters(), "enable");
|
||||
|
||||
OBSDataAutoRelease response = obs_data_create();
|
||||
obs_data_set_bool(response, "enable",
|
||||
WSEvents::Instance->HeartbeatIsActive);
|
||||
req->SendOKResponse(response);
|
||||
OBSDataAutoRelease response = obs_data_create();
|
||||
obs_data_set_bool(response, "enable", events->HeartbeatIsActive);
|
||||
|
||||
return request.success(response);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -136,19 +199,19 @@ void WSRequestHandler::HandleAuthenticate(WSRequestHandler* req) {
|
||||
* @category general
|
||||
* @since 4.3.0
|
||||
*/
|
||||
void WSRequestHandler::HandleSetFilenameFormatting(WSRequestHandler* req) {
|
||||
if (!req->hasField("filename-formatting")) {
|
||||
req->SendErrorResponse("<filename-formatting> parameter missing");
|
||||
return;
|
||||
}
|
||||
RpcResponse WSRequestHandler::SetFilenameFormatting(const RpcRequest& request) {
|
||||
if (!request.hasField("filename-formatting")) {
|
||||
return request.failed("<filename-formatting> parameter missing");
|
||||
}
|
||||
|
||||
QString filenameFormatting = obs_data_get_string(req->data, "filename-formatting");
|
||||
if (!filenameFormatting.isEmpty()) {
|
||||
Utils::SetFilenameFormatting(filenameFormatting.toUtf8());
|
||||
req->SendOKResponse();
|
||||
} else {
|
||||
req->SendErrorResponse("invalid request parameters");
|
||||
}
|
||||
QString filenameFormatting = obs_data_get_string(request.parameters(), "filename-formatting");
|
||||
if (filenameFormatting.isEmpty()) {
|
||||
return request.failed("invalid request parameters");
|
||||
}
|
||||
|
||||
Utils::SetFilenameFormatting(filenameFormatting.toUtf8());
|
||||
|
||||
return request.success();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -161,8 +224,274 @@ void WSRequestHandler::HandleSetFilenameFormatting(WSRequestHandler* req) {
|
||||
* @category general
|
||||
* @since 4.3.0
|
||||
*/
|
||||
void WSRequestHandler::HandleGetFilenameFormatting(WSRequestHandler* req) {
|
||||
OBSDataAutoRelease response = obs_data_create();
|
||||
obs_data_set_string(response, "filename-formatting", Utils::GetFilenameFormatting());
|
||||
req->SendOKResponse(response);
|
||||
RpcResponse WSRequestHandler::GetFilenameFormatting(const RpcRequest& request) {
|
||||
OBSDataAutoRelease response = obs_data_create();
|
||||
obs_data_set_string(response, "filename-formatting", Utils::GetFilenameFormatting());
|
||||
|
||||
return request.success(response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get OBS stats (almost the same info as provided in OBS' stats window)
|
||||
*
|
||||
* @return {OBSStats} `stats` [OBS stats](#obsstats)
|
||||
*
|
||||
* @api requests
|
||||
* @name GetStats
|
||||
* @category general
|
||||
* @since 4.6.0
|
||||
*/
|
||||
RpcResponse WSRequestHandler::GetStats(const RpcRequest& request) {
|
||||
OBSDataAutoRelease stats = GetEventsSystem()->GetStats();
|
||||
|
||||
OBSDataAutoRelease response = obs_data_create();
|
||||
obs_data_set_obj(response, "stats", stats);
|
||||
|
||||
return request.success(response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Broadcast custom message to all connected WebSocket clients
|
||||
*
|
||||
* @param {String} `realm` Identifier to be choosen by the client
|
||||
* @param {Object} `data` User-defined data
|
||||
*
|
||||
* @api requests
|
||||
* @name BroadcastCustomMessage
|
||||
* @category general
|
||||
* @since 4.7.0
|
||||
*/
|
||||
RpcResponse WSRequestHandler::BroadcastCustomMessage(const RpcRequest& request) {
|
||||
if (!request.hasField("realm") || !request.hasField("data")) {
|
||||
return request.failed("missing request parameters");
|
||||
}
|
||||
|
||||
QString realm = obs_data_get_string(request.parameters(), "realm");
|
||||
OBSDataAutoRelease data = obs_data_get_obj(request.parameters(), "data");
|
||||
|
||||
if (realm.isEmpty()) {
|
||||
return request.failed("realm not specified!");
|
||||
}
|
||||
|
||||
if (!data) {
|
||||
return request.failed("data not specified!");
|
||||
}
|
||||
|
||||
auto events = GetEventsSystem();
|
||||
events->OnBroadcastCustomMessage(realm, data);
|
||||
|
||||
return request.success();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get basic OBS video information
|
||||
*
|
||||
* @return {int} `baseWidth` Base (canvas) width
|
||||
* @return {int} `baseHeight` Base (canvas) height
|
||||
* @return {int} `outputWidth` Output width
|
||||
* @return {int} `outputHeight` Output height
|
||||
* @return {String} `scaleType` Scaling method used if output size differs from base size
|
||||
* @return {double} `fps` Frames rendered per second
|
||||
* @return {String} `videoFormat` Video color format
|
||||
* @return {String} `colorSpace` Color space for YUV
|
||||
* @return {String} `colorRange` Color range (full or partial)
|
||||
*
|
||||
* @api requests
|
||||
* @name GetVideoInfo
|
||||
* @category general
|
||||
* @since 4.6.0
|
||||
*/
|
||||
RpcResponse WSRequestHandler::GetVideoInfo(const RpcRequest& request) {
|
||||
obs_video_info ovi;
|
||||
obs_get_video_info(&ovi);
|
||||
|
||||
OBSDataAutoRelease response = obs_data_create();
|
||||
obs_data_set_int(response, "baseWidth", ovi.base_width);
|
||||
obs_data_set_int(response, "baseHeight", ovi.base_height);
|
||||
obs_data_set_int(response, "outputWidth", ovi.output_width);
|
||||
obs_data_set_int(response, "outputHeight", ovi.output_height);
|
||||
obs_data_set_double(response, "fps", (double)ovi.fps_num / ovi.fps_den);
|
||||
obs_data_set_string(response, "videoFormat", describe_output_format(ovi.output_format));
|
||||
obs_data_set_string(response, "colorSpace", describe_color_space(ovi.colorspace));
|
||||
obs_data_set_string(response, "colorRange", describe_color_range(ovi.range));
|
||||
obs_data_set_string(response, "scaleType", describe_scale_type(ovi.scale_type));
|
||||
|
||||
return request.success(response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 {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)} `name` Name of the source or scene to be displayed (ignored for other projector types).
|
||||
*
|
||||
* @api requests
|
||||
* @name OpenProjector
|
||||
* @category general
|
||||
* @since 4.8.0
|
||||
*/
|
||||
RpcResponse WSRequestHandler::OpenProjector(const RpcRequest& request) {
|
||||
const char* type = obs_data_get_string(request.parameters(), "type");
|
||||
|
||||
int monitor = -1;
|
||||
if (request.hasField("monitor")) {
|
||||
monitor = obs_data_get_int(request.parameters(), "monitor");
|
||||
}
|
||||
|
||||
const char* geometry = obs_data_get_string(request.parameters(), "geometry");
|
||||
const char* name = obs_data_get_string(request.parameters(), "name");
|
||||
|
||||
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();
|
||||
}
|
||||
|
405
src/WSRequestHandler_MediaControl.cpp
Normal file
405
src/WSRequestHandler_MediaControl.cpp
Normal 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);
|
||||
}
|
188
src/WSRequestHandler_Outputs.cpp
Normal file
188
src/WSRequestHandler_Outputs.cpp
Normal file
@ -0,0 +1,188 @@
|
||||
#include <functional>
|
||||
|
||||
#include "WSRequestHandler.h"
|
||||
|
||||
/**
|
||||
* @typedef {Object} `Output`
|
||||
* @property {String} `name` Output name
|
||||
* @property {String} `type` Output type/kind
|
||||
* @property {int} `width` Video output width
|
||||
* @property {int} `height` Video output height
|
||||
* @property {Object} `flags` Output flags
|
||||
* @property {int} `flags.rawValue` Raw flags value
|
||||
* @property {boolean} `flags.audio` Output uses audio
|
||||
* @property {boolean} `flags.video` Output uses video
|
||||
* @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 settings
|
||||
* @property {boolean} `active` Output status (active or not)
|
||||
* @property {boolean} `reconnecting` Output reconnection status (reconnecting or not)
|
||||
* @property {double} `congestion` Output congestion
|
||||
* @property {int} `totalFrames` Number of frames sent
|
||||
* @property {int} `droppedFrames` Number of frames dropped
|
||||
* @property {int} `totalBytes` Total bytes sent
|
||||
*/
|
||||
obs_data_t* getOutputInfo(obs_output_t* output)
|
||||
{
|
||||
if (!output) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
OBSDataAutoRelease settings = obs_output_get_settings(output);
|
||||
|
||||
uint32_t rawFlags = obs_output_get_flags(output);
|
||||
OBSDataAutoRelease flags = obs_data_create();
|
||||
obs_data_set_int(flags, "rawValue", rawFlags);
|
||||
obs_data_set_bool(flags, "audio", rawFlags & OBS_OUTPUT_AUDIO);
|
||||
obs_data_set_bool(flags, "video", rawFlags & OBS_OUTPUT_VIDEO);
|
||||
obs_data_set_bool(flags, "encoded", rawFlags & OBS_OUTPUT_ENCODED);
|
||||
obs_data_set_bool(flags, "multiTrack", rawFlags & OBS_OUTPUT_MULTI_TRACK);
|
||||
obs_data_set_bool(flags, "service", rawFlags & OBS_OUTPUT_SERVICE);
|
||||
|
||||
obs_data_t* data = obs_data_create();
|
||||
|
||||
obs_data_set_string(data, "name", obs_output_get_name(output));
|
||||
obs_data_set_string(data, "type", obs_output_get_id(output));
|
||||
obs_data_set_int(data, "width", obs_output_get_width(output));
|
||||
obs_data_set_int(data, "height", obs_output_get_height(output));
|
||||
obs_data_set_obj(data, "flags", flags);
|
||||
obs_data_set_obj(data, "settings", settings);
|
||||
|
||||
obs_data_set_bool(data, "active", obs_output_active(output));
|
||||
obs_data_set_bool(data, "reconnecting", obs_output_reconnecting(output));
|
||||
obs_data_set_double(data, "congestion", obs_output_get_congestion(output));
|
||||
obs_data_set_int(data, "totalFrames", obs_output_get_total_frames(output));
|
||||
obs_data_set_int(data, "droppedFrames", obs_output_get_frames_dropped(output));
|
||||
obs_data_set_int(data, "totalBytes", obs_output_get_total_bytes(output));
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
RpcResponse findOutputOrFail(const RpcRequest& request, std::function<RpcResponse (obs_output_t*, const RpcRequest&)> callback)
|
||||
{
|
||||
if (!request.hasField("outputName")) {
|
||||
return request.failed("missing request parameters");
|
||||
}
|
||||
|
||||
const char* outputName = obs_data_get_string(request.parameters(), "outputName");
|
||||
OBSOutputAutoRelease output = obs_get_output_by_name(outputName);
|
||||
if (!output) {
|
||||
return request.failed("specified output doesn't exist");
|
||||
}
|
||||
|
||||
return callback(output, request);
|
||||
}
|
||||
|
||||
/**
|
||||
* List existing outputs
|
||||
*
|
||||
* @return {Array<Output>} `outputs` Outputs list
|
||||
*
|
||||
* @api requests
|
||||
* @name ListOutputs
|
||||
* @category outputs
|
||||
* @since 4.7.0
|
||||
*/
|
||||
RpcResponse WSRequestHandler::ListOutputs(const RpcRequest& request)
|
||||
{
|
||||
OBSDataArrayAutoRelease outputs = obs_data_array_create();
|
||||
|
||||
obs_enum_outputs([](void* param, obs_output_t* output) {
|
||||
obs_data_array_t* outputs = reinterpret_cast<obs_data_array_t*>(param);
|
||||
|
||||
OBSDataAutoRelease outputInfo = getOutputInfo(output);
|
||||
obs_data_array_push_back(outputs, outputInfo);
|
||||
|
||||
return true;
|
||||
}, outputs);
|
||||
|
||||
OBSDataAutoRelease fields = obs_data_create();
|
||||
obs_data_set_array(fields, "outputs", outputs);
|
||||
|
||||
return request.success(fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get information about a single output
|
||||
*
|
||||
* @param {String} `outputName` Output name
|
||||
*
|
||||
* @return {Output} `outputInfo` Output info
|
||||
*
|
||||
* @api requests
|
||||
* @name GetOutputInfo
|
||||
* @category outputs
|
||||
* @since 4.7.0
|
||||
*/
|
||||
RpcResponse WSRequestHandler::GetOutputInfo(const RpcRequest& request)
|
||||
{
|
||||
return findOutputOrFail(request, [](obs_output_t* output, const RpcRequest& request) {
|
||||
OBSDataAutoRelease outputInfo = getOutputInfo(output);
|
||||
|
||||
OBSDataAutoRelease fields = obs_data_create();
|
||||
obs_data_set_obj(fields, "outputInfo", outputInfo);
|
||||
return request.success(fields);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @name StartOutput
|
||||
* @category outputs
|
||||
* @since 4.7.0
|
||||
*/
|
||||
RpcResponse WSRequestHandler::StartOutput(const RpcRequest& request)
|
||||
{
|
||||
return findOutputOrFail(request, [](obs_output_t* output, const RpcRequest& request) {
|
||||
if (obs_output_active(output)) {
|
||||
return request.failed("output already active");
|
||||
}
|
||||
|
||||
bool success = obs_output_start(output);
|
||||
if (!success) {
|
||||
QString lastError = obs_output_get_last_error(output);
|
||||
QString errorMessage = QString("output start failed: %1").arg(lastError);
|
||||
return request.failed(errorMessage);
|
||||
}
|
||||
|
||||
return request.success();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
*
|
||||
* @api requests
|
||||
* @name StopOutput
|
||||
* @category outputs
|
||||
* @since 4.7.0
|
||||
*/
|
||||
RpcResponse WSRequestHandler::StopOutput(const RpcRequest& request)
|
||||
{
|
||||
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);
|
||||
} else {
|
||||
obs_output_stop(output);
|
||||
}
|
||||
|
||||
return request.success();
|
||||
});
|
||||
}
|
@ -1,11 +1,10 @@
|
||||
#include <QString>
|
||||
#include "Utils.h"
|
||||
|
||||
#include "WSRequestHandler.h"
|
||||
|
||||
/**
|
||||
* Set the currently active profile.
|
||||
*
|
||||
*
|
||||
* @param {String} `profile-name` Name of the desired profile.
|
||||
*
|
||||
* @api requests
|
||||
@ -13,25 +12,33 @@
|
||||
* @category profiles
|
||||
* @since 4.0.0
|
||||
*/
|
||||
void WSRequestHandler::HandleSetCurrentProfile(WSRequestHandler* req) {
|
||||
if (!req->hasField("profile-name")) {
|
||||
req->SendErrorResponse("missing request parameters");
|
||||
return;
|
||||
}
|
||||
RpcResponse WSRequestHandler::SetCurrentProfile(const RpcRequest& request) {
|
||||
if (!request.hasField("profile-name")) {
|
||||
return request.failed("missing request parameters");
|
||||
}
|
||||
|
||||
QString profileName = obs_data_get_string(req->data, "profile-name");
|
||||
if (!profileName.isEmpty()) {
|
||||
// TODO : check if profile exists
|
||||
obs_frontend_set_current_profile(profileName.toUtf8());
|
||||
req->SendOKResponse();
|
||||
} else {
|
||||
req->SendErrorResponse("invalid request parameters");
|
||||
}
|
||||
const char* profileName = obs_data_get_string(request.parameters(), "profile-name");
|
||||
if (!profileName) {
|
||||
return request.failed("invalid request parameters");
|
||||
}
|
||||
|
||||
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
|
||||
@ -39,32 +46,32 @@
|
||||
* @category profiles
|
||||
* @since 4.0.0
|
||||
*/
|
||||
void WSRequestHandler::HandleGetCurrentProfile(WSRequestHandler* req) {
|
||||
OBSDataAutoRelease response = obs_data_create();
|
||||
obs_data_set_string(response, "profile-name",
|
||||
obs_frontend_get_current_profile());
|
||||
|
||||
req->SendOKResponse(response);
|
||||
RpcResponse WSRequestHandler::GetCurrentProfile(const RpcRequest& request) {
|
||||
OBSDataAutoRelease response = obs_data_create();
|
||||
char* currentProfile = obs_frontend_get_current_profile();
|
||||
obs_data_set_string(response, "profile-name", currentProfile);
|
||||
bfree(currentProfile);
|
||||
return request.success(response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of available profiles.
|
||||
*
|
||||
* @return {Object|Array} `profiles` List of available profiles.
|
||||
* @return {Array<Object>} `profiles` List of available profiles.
|
||||
* @return {String} `profiles.*.profile-name` Filter name
|
||||
*
|
||||
* @api requests
|
||||
* @name ListProfiles
|
||||
* @category profiles
|
||||
* @since 4.0.0
|
||||
*/
|
||||
void WSRequestHandler::HandleListProfiles(WSRequestHandler* req) {
|
||||
char** profiles = obs_frontend_get_profiles();
|
||||
OBSDataArrayAutoRelease list =
|
||||
Utils::StringListToArray(profiles, "profile-name");
|
||||
bfree(profiles);
|
||||
RpcResponse WSRequestHandler::ListProfiles(const RpcRequest& request) {
|
||||
char** profiles = obs_frontend_get_profiles();
|
||||
OBSDataArrayAutoRelease list = Utils::StringListToArray(profiles, "profile-name");
|
||||
bfree(profiles);
|
||||
|
||||
OBSDataAutoRelease response = obs_data_create();
|
||||
obs_data_set_array(response, "profiles", list);
|
||||
OBSDataAutoRelease response = obs_data_create();
|
||||
obs_data_set_array(response, "profiles", list);
|
||||
|
||||
req->SendOKResponse(response);
|
||||
return request.success(response);
|
||||
}
|
||||
|
@ -1,23 +1,51 @@
|
||||
#include <QString>
|
||||
#include "Utils.h"
|
||||
|
||||
#include "obs-websocket.h"
|
||||
#include "WSRequestHandler.h"
|
||||
|
||||
#include <functional>
|
||||
#include <util/platform.h>
|
||||
#include "Utils.h"
|
||||
#include "WSEvents.h"
|
||||
|
||||
/**
|
||||
* 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();
|
||||
|
||||
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
|
||||
* @category recording
|
||||
* @since 0.3
|
||||
*/
|
||||
void WSRequestHandler::HandleStartStopRecording(WSRequestHandler* req) {
|
||||
if (obs_frontend_recording_active())
|
||||
obs_frontend_recording_stop();
|
||||
else
|
||||
obs_frontend_recording_start();
|
||||
|
||||
req->SendOKResponse();
|
||||
RpcResponse WSRequestHandler::StartStopRecording(const RpcRequest& request) {
|
||||
(obs_frontend_recording_active() ? obs_frontend_recording_stop() : obs_frontend_recording_start());
|
||||
return request.success();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -29,13 +57,13 @@
|
||||
* @category recording
|
||||
* @since 4.1.0
|
||||
*/
|
||||
void WSRequestHandler::HandleStartRecording(WSRequestHandler* req) {
|
||||
if (obs_frontend_recording_active() == false) {
|
||||
obs_frontend_recording_start();
|
||||
req->SendOKResponse();
|
||||
} else {
|
||||
req->SendErrorResponse("recording already active");
|
||||
}
|
||||
RpcResponse WSRequestHandler::StartRecording(const RpcRequest& request) {
|
||||
if (obs_frontend_recording_active()) {
|
||||
return request.failed("recording already active");
|
||||
}
|
||||
|
||||
obs_frontend_recording_start();
|
||||
return request.success();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -47,18 +75,63 @@
|
||||
* @category recording
|
||||
* @since 4.1.0
|
||||
*/
|
||||
void WSRequestHandler::HandleStopRecording(WSRequestHandler* req) {
|
||||
if (obs_frontend_recording_active() == true) {
|
||||
obs_frontend_recording_stop();
|
||||
req->SendOKResponse();
|
||||
} else {
|
||||
req->SendErrorResponse("recording not active");
|
||||
}
|
||||
RpcResponse WSRequestHandler::StopRecording(const RpcRequest& request) {
|
||||
if (!obs_frontend_recording_active()) {
|
||||
return request.failed("recording not active");
|
||||
}
|
||||
|
||||
obs_frontend_recording_stop();
|
||||
return request.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the current recording folder.
|
||||
*
|
||||
* Pause the current recording.
|
||||
* Returns an error if recording is not active or already paused.
|
||||
*
|
||||
* @api requests
|
||||
* @name PauseRecording
|
||||
* @category recording
|
||||
* @since 4.7.0
|
||||
*/
|
||||
RpcResponse WSRequestHandler::PauseRecording(const RpcRequest& request) {
|
||||
if (!obs_frontend_recording_active())
|
||||
return request.failed("recording is not active");
|
||||
|
||||
if (obs_frontend_recording_paused())
|
||||
return request.failed("recording already paused");
|
||||
|
||||
obs_frontend_recording_pause(true);
|
||||
return request.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* Resume/unpause the current recording (if paused).
|
||||
* Returns an error if recording is not active or not paused.
|
||||
*
|
||||
* @api requests
|
||||
* @name ResumeRecording
|
||||
* @category recording
|
||||
* @since 4.7.0
|
||||
*/
|
||||
RpcResponse WSRequestHandler::ResumeRecording(const RpcRequest& request) {
|
||||
if (!obs_frontend_recording_active())
|
||||
return request.failed("recording is not active");
|
||||
|
||||
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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @param {String} `rec-folder` Path of the recording folder.
|
||||
*
|
||||
* @api requests
|
||||
@ -66,18 +139,18 @@ void WSRequestHandler::HandleStopRecording(WSRequestHandler* req) {
|
||||
* @category recording
|
||||
* @since 4.1.0
|
||||
*/
|
||||
void WSRequestHandler::HandleSetRecordingFolder(WSRequestHandler* req) {
|
||||
if (!req->hasField("rec-folder")) {
|
||||
req->SendErrorResponse("missing request parameters");
|
||||
return;
|
||||
}
|
||||
RpcResponse WSRequestHandler::SetRecordingFolder(const RpcRequest& request) {
|
||||
if (!request.hasField("rec-folder")) {
|
||||
return request.failed("missing request parameters");
|
||||
}
|
||||
|
||||
const char* newRecFolder = obs_data_get_string(req->data, "rec-folder");
|
||||
bool success = Utils::SetRecordingFolder(newRecFolder);
|
||||
if (success)
|
||||
req->SendOKResponse();
|
||||
else
|
||||
req->SendErrorResponse("invalid request parameters");
|
||||
const char* newRecFolder = obs_data_get_string(request.parameters(), "rec-folder");
|
||||
bool success = Utils::SetRecordingFolder(newRecFolder);
|
||||
if (!success) {
|
||||
return request.failed("invalid request parameters");
|
||||
}
|
||||
|
||||
return request.success();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -90,11 +163,11 @@ void WSRequestHandler::HandleStopRecording(WSRequestHandler* req) {
|
||||
* @category recording
|
||||
* @since 4.1.0
|
||||
*/
|
||||
void WSRequestHandler::HandleGetRecordingFolder(WSRequestHandler* req) {
|
||||
const char* recFolder = Utils::GetRecordingFolder();
|
||||
RpcResponse WSRequestHandler::GetRecordingFolder(const RpcRequest& request) {
|
||||
const char* recFolder = Utils::GetRecordingFolder();
|
||||
|
||||
OBSDataAutoRelease response = obs_data_create();
|
||||
obs_data_set_string(response, "rec-folder", recFolder);
|
||||
OBSDataAutoRelease response = obs_data_create();
|
||||
obs_data_set_string(response, "rec-folder", recFolder);
|
||||
|
||||
req->SendOKResponse(response);
|
||||
return request.success(response);
|
||||
}
|
||||
|
@ -1,23 +1,42 @@
|
||||
#include <QString>
|
||||
#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
|
||||
* @category replay buffer
|
||||
* @since 4.2.0
|
||||
*/
|
||||
void WSRequestHandler::HandleStartStopReplayBuffer(WSRequestHandler* req) {
|
||||
if (obs_frontend_replay_buffer_active()) {
|
||||
obs_frontend_replay_buffer_stop();
|
||||
} else {
|
||||
Utils::StartReplayBuffer();
|
||||
}
|
||||
req->SendOKResponse();
|
||||
RpcResponse WSRequestHandler::StartStopReplayBuffer(const RpcRequest& request) {
|
||||
if (obs_frontend_replay_buffer_active()) {
|
||||
obs_frontend_replay_buffer_stop();
|
||||
} else {
|
||||
Utils::StartReplayBuffer();
|
||||
}
|
||||
return request.success();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -32,19 +51,17 @@ void WSRequestHandler::HandleStartStopReplayBuffer(WSRequestHandler* req) {
|
||||
* @category replay buffer
|
||||
* @since 4.2.0
|
||||
*/
|
||||
void WSRequestHandler::HandleStartReplayBuffer(WSRequestHandler* req) {
|
||||
if (!Utils::ReplayBufferEnabled()) {
|
||||
req->SendErrorResponse("replay buffer disabled in settings");
|
||||
return;
|
||||
}
|
||||
RpcResponse WSRequestHandler::StartReplayBuffer(const RpcRequest& request) {
|
||||
if (!Utils::ReplayBufferEnabled()) {
|
||||
return request.failed("replay buffer disabled in settings");
|
||||
}
|
||||
|
||||
if (obs_frontend_replay_buffer_active() == true) {
|
||||
req->SendErrorResponse("replay buffer already active");
|
||||
return;
|
||||
}
|
||||
if (obs_frontend_replay_buffer_active() == true) {
|
||||
return request.failed("replay buffer already active");
|
||||
}
|
||||
|
||||
Utils::StartReplayBuffer();
|
||||
req->SendOKResponse();
|
||||
Utils::StartReplayBuffer();
|
||||
return request.success();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -56,13 +73,13 @@ void WSRequestHandler::HandleStartReplayBuffer(WSRequestHandler* req) {
|
||||
* @category replay buffer
|
||||
* @since 4.2.0
|
||||
*/
|
||||
void WSRequestHandler::HandleStopReplayBuffer(WSRequestHandler* req) {
|
||||
if (obs_frontend_replay_buffer_active() == true) {
|
||||
obs_frontend_replay_buffer_stop();
|
||||
req->SendOKResponse();
|
||||
} else {
|
||||
req->SendErrorResponse("replay buffer not active");
|
||||
}
|
||||
RpcResponse WSRequestHandler::StopReplayBuffer(const RpcRequest& request) {
|
||||
if (obs_frontend_replay_buffer_active() == true) {
|
||||
obs_frontend_replay_buffer_stop();
|
||||
return request.success();
|
||||
} else {
|
||||
return request.failed("replay buffer not active");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -75,18 +92,17 @@ void WSRequestHandler::HandleStopReplayBuffer(WSRequestHandler* req) {
|
||||
* @category replay buffer
|
||||
* @since 4.2.0
|
||||
*/
|
||||
void WSRequestHandler::HandleSaveReplayBuffer(WSRequestHandler* req) {
|
||||
if (!obs_frontend_replay_buffer_active()) {
|
||||
req->SendErrorResponse("replay buffer not active");
|
||||
return;
|
||||
}
|
||||
RpcResponse WSRequestHandler::SaveReplayBuffer(const RpcRequest& request) {
|
||||
if (!obs_frontend_replay_buffer_active()) {
|
||||
return request.failed("replay buffer not active");
|
||||
}
|
||||
|
||||
OBSOutputAutoRelease replayOutput = obs_frontend_get_replay_buffer_output();
|
||||
OBSOutputAutoRelease replayOutput = obs_frontend_get_replay_buffer_output();
|
||||
|
||||
calldata_t cd = { 0 };
|
||||
proc_handler_t* ph = obs_output_get_proc_handler(replayOutput);
|
||||
proc_handler_call(ph, "save", &cd);
|
||||
calldata_free(&cd);
|
||||
calldata_t cd = { 0 };
|
||||
proc_handler_t* ph = obs_output_get_proc_handler(replayOutput);
|
||||
proc_handler_call(ph, "save", &cd);
|
||||
calldata_free(&cd);
|
||||
|
||||
req->SendOKResponse();
|
||||
return request.success();
|
||||
}
|
||||
|
@ -1,8 +1,12 @@
|
||||
#include <QString>
|
||||
#include "Utils.h"
|
||||
|
||||
#include "WSRequestHandler.h"
|
||||
|
||||
/**
|
||||
* @typedef {Object} `ScenesCollection`
|
||||
* @property {String} `sc-name` Name of the scene collection
|
||||
*/
|
||||
|
||||
/**
|
||||
* Change the active scene collection.
|
||||
*
|
||||
@ -13,20 +17,28 @@
|
||||
* @category scene collections
|
||||
* @since 4.0.0
|
||||
*/
|
||||
void WSRequestHandler::HandleSetCurrentSceneCollection(WSRequestHandler* req) {
|
||||
if (!req->hasField("sc-name")) {
|
||||
req->SendErrorResponse("missing request parameters");
|
||||
return;
|
||||
}
|
||||
RpcResponse WSRequestHandler::SetCurrentSceneCollection(const RpcRequest& request) {
|
||||
if (!request.hasField("sc-name")) {
|
||||
return request.failed("missing request parameters");
|
||||
}
|
||||
|
||||
QString sceneCollection = obs_data_get_string(req->data, "sc-name");
|
||||
if (!sceneCollection.isEmpty()) {
|
||||
// TODO : Check if specified profile exists and if changing is allowed
|
||||
obs_frontend_set_current_scene_collection(sceneCollection.toUtf8());
|
||||
req->SendOKResponse();
|
||||
} else {
|
||||
req->SendErrorResponse("invalid request parameters");
|
||||
}
|
||||
const char* sceneCollection = obs_data_get_string(request.parameters(), "sc-name");
|
||||
if (!sceneCollection) {
|
||||
return request.failed("invalid request parameters");
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -39,33 +51,34 @@
|
||||
* @category scene collections
|
||||
* @since 4.0.0
|
||||
*/
|
||||
void WSRequestHandler::HandleGetCurrentSceneCollection(WSRequestHandler* req) {
|
||||
OBSDataAutoRelease response = obs_data_create();
|
||||
obs_data_set_string(response, "sc-name",
|
||||
obs_frontend_get_current_scene_collection());
|
||||
RpcResponse WSRequestHandler::GetCurrentSceneCollection(const RpcRequest& request) {
|
||||
OBSDataAutoRelease response = obs_data_create();
|
||||
|
||||
req->SendOKResponse(response);
|
||||
char* sceneCollection = obs_frontend_get_current_scene_collection();
|
||||
obs_data_set_string(response, "sc-name", sceneCollection);
|
||||
bfree(sceneCollection);
|
||||
|
||||
return request.success(response);
|
||||
}
|
||||
|
||||
/**
|
||||
* List available scene collections
|
||||
*
|
||||
* @return {Object|Array} `scene-collections` Scene collections list
|
||||
* @return {String} `scene-collections.*.`
|
||||
* @return {Array<ScenesCollection>} `scene-collections` Scene collections list
|
||||
*
|
||||
* @api requests
|
||||
* @name ListSceneCollections
|
||||
* @category scene collections
|
||||
* @since 4.0.0
|
||||
*/
|
||||
void WSRequestHandler::HandleListSceneCollections(WSRequestHandler* req) {
|
||||
char** sceneCollections = obs_frontend_get_scene_collections();
|
||||
OBSDataArrayAutoRelease list =
|
||||
Utils::StringListToArray(sceneCollections, "sc-name");
|
||||
bfree(sceneCollections);
|
||||
RpcResponse WSRequestHandler::ListSceneCollections(const RpcRequest& request) {
|
||||
char** sceneCollections = obs_frontend_get_scene_collections();
|
||||
OBSDataArrayAutoRelease list =
|
||||
Utils::StringListToArray(sceneCollections, "sc-name");
|
||||
bfree(sceneCollections);
|
||||
|
||||
OBSDataAutoRelease response = obs_data_create();
|
||||
obs_data_set_array(response, "scene-collections", list);
|
||||
OBSDataAutoRelease response = obs_data_create();
|
||||
obs_data_set_array(response, "scene-collections", list);
|
||||
|
||||
req->SendOKResponse(response);
|
||||
return request.success(response);
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,8 +1,13 @@
|
||||
#include <QString>
|
||||
#include "Utils.h"
|
||||
|
||||
#include "WSRequestHandler.h"
|
||||
|
||||
/**
|
||||
* @typedef {Object} `Scene`
|
||||
* @property {String} `name` Name of the currently active scene.
|
||||
* @property {Array<SceneItem>} `sources` Ordered list of the current scene's source items.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Switch to the specified scene.
|
||||
*
|
||||
@ -13,64 +18,285 @@
|
||||
* @category scenes
|
||||
* @since 0.3
|
||||
*/
|
||||
void WSRequestHandler::HandleSetCurrentScene(WSRequestHandler* req) {
|
||||
if (!req->hasField("scene-name")) {
|
||||
req->SendErrorResponse("missing request parameters");
|
||||
return;
|
||||
}
|
||||
RpcResponse WSRequestHandler::SetCurrentScene(const RpcRequest& request) {
|
||||
if (!request.hasField("scene-name")) {
|
||||
return request.failed("missing request parameters");
|
||||
}
|
||||
|
||||
const char* sceneName = obs_data_get_string(req->data, "scene-name");
|
||||
OBSSourceAutoRelease source = obs_get_source_by_name(sceneName);
|
||||
const char* sceneName = obs_data_get_string(request.parameters(), "scene-name");
|
||||
OBSSourceAutoRelease source = obs_get_source_by_name(sceneName);
|
||||
|
||||
if (source) {
|
||||
obs_frontend_set_current_scene(source);
|
||||
req->SendOKResponse();
|
||||
} else {
|
||||
req->SendErrorResponse("requested scene does not exist");
|
||||
}
|
||||
if (source) {
|
||||
obs_frontend_set_current_scene(source);
|
||||
return request.success();
|
||||
} else {
|
||||
return request.failed("requested scene does not exist");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current scene's name and source items.
|
||||
*
|
||||
*
|
||||
* @return {String} `name` Name of the currently active scene.
|
||||
* @return {Source|Array} `sources` Ordered list of the current scene's source items.
|
||||
* @return {Array<SceneItem>} `sources` Ordered list of the current scene's source items.
|
||||
*
|
||||
* @api requests
|
||||
* @name GetCurrentScene
|
||||
* @category scenes
|
||||
* @since 0.3
|
||||
*/
|
||||
void WSRequestHandler::HandleGetCurrentScene(WSRequestHandler* req) {
|
||||
OBSSourceAutoRelease currentScene = obs_frontend_get_current_scene();
|
||||
OBSDataArrayAutoRelease sceneItems = Utils::GetSceneItems(currentScene);
|
||||
RpcResponse WSRequestHandler::GetCurrentScene(const RpcRequest& request) {
|
||||
OBSSourceAutoRelease currentScene = obs_frontend_get_current_scene();
|
||||
OBSDataArrayAutoRelease sceneItems = Utils::GetSceneItems(currentScene);
|
||||
|
||||
OBSDataAutoRelease data = obs_data_create();
|
||||
obs_data_set_string(data, "name", obs_source_get_name(currentScene));
|
||||
obs_data_set_array(data, "sources", sceneItems);
|
||||
OBSDataAutoRelease data = obs_data_create();
|
||||
obs_data_set_string(data, "name", obs_source_get_name(currentScene));
|
||||
obs_data_set_array(data, "sources", sceneItems);
|
||||
|
||||
req->SendOKResponse(data);
|
||||
return request.success(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of scenes in the currently active profile.
|
||||
*
|
||||
*
|
||||
* @return {String} `current-scene` Name of the currently active scene.
|
||||
* @return {Scene|Array} `scenes` Ordered list of the current profile's scenes (See `[GetCurrentScene](#getcurrentscene)` for more information).
|
||||
* @return {Array<Scene>} `scenes` Ordered list of the current profile's scenes (See [GetCurrentScene](#getcurrentscene) for more information).
|
||||
*
|
||||
* @api requests
|
||||
* @name GetSceneList
|
||||
* @category scenes
|
||||
* @since 0.3
|
||||
*/
|
||||
void WSRequestHandler::HandleGetSceneList(WSRequestHandler* req) {
|
||||
OBSSourceAutoRelease currentScene = obs_frontend_get_current_scene();
|
||||
OBSDataArrayAutoRelease scenes = Utils::GetScenes();
|
||||
RpcResponse WSRequestHandler::GetSceneList(const RpcRequest& request) {
|
||||
OBSSourceAutoRelease currentScene = obs_frontend_get_current_scene();
|
||||
OBSDataArrayAutoRelease scenes = Utils::GetScenes();
|
||||
|
||||
OBSDataAutoRelease data = obs_data_create();
|
||||
obs_data_set_string(data, "current-scene",
|
||||
obs_source_get_name(currentScene));
|
||||
obs_data_set_array(data, "scenes", scenes);
|
||||
OBSDataAutoRelease data = obs_data_create();
|
||||
obs_data_set_string(data, "current-scene",
|
||||
obs_source_get_name(currentScene));
|
||||
obs_data_set_array(data, "scenes", scenes);
|
||||
|
||||
req->SendOKResponse(data);
|
||||
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<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
|
||||
* @category scenes
|
||||
* @since 4.5.0
|
||||
*/
|
||||
RpcResponse WSRequestHandler::ReorderSceneItems(const RpcRequest& request) {
|
||||
QString sceneName = obs_data_get_string(request.parameters(), "scene");
|
||||
OBSScene scene = Utils::GetSceneFromNameOrCurrent(sceneName);
|
||||
if (!scene) {
|
||||
return request.failed("requested scene doesn't exist");
|
||||
}
|
||||
|
||||
OBSDataArrayAutoRelease items = obs_data_get_array(request.parameters(), "items");
|
||||
if (!items) {
|
||||
return request.failed("sceneItem order not specified");
|
||||
}
|
||||
|
||||
struct reorder_context {
|
||||
obs_data_array_t* items;
|
||||
bool success;
|
||||
QString errorMessage;
|
||||
};
|
||||
|
||||
struct reorder_context ctx;
|
||||
ctx.success = false;
|
||||
ctx.items = items;
|
||||
|
||||
obs_scene_atomic_update(scene, [](void* param, obs_scene_t* scene) {
|
||||
auto ctx = reinterpret_cast<struct reorder_context*>(param);
|
||||
|
||||
QVector<struct obs_sceneitem_order_info> orderList;
|
||||
struct obs_sceneitem_order_info info;
|
||||
|
||||
size_t itemCount = obs_data_array_count(ctx->items);
|
||||
for (uint i = 0; i < itemCount; i++) {
|
||||
OBSDataAutoRelease item = obs_data_array_item(ctx->items, i);
|
||||
|
||||
OBSSceneItemAutoRelease sceneItem = Utils::GetSceneItemFromItem(scene, item);
|
||||
if (!sceneItem) {
|
||||
ctx->success = false;
|
||||
ctx->errorMessage = "Invalid sceneItem id or name specified";
|
||||
return;
|
||||
}
|
||||
|
||||
info.group = nullptr;
|
||||
info.item = sceneItem;
|
||||
orderList.insert(0, info);
|
||||
}
|
||||
|
||||
ctx->success = obs_scene_reorder_items2(scene, orderList.data(), orderList.size());
|
||||
if (!ctx->success) {
|
||||
ctx->errorMessage = "Invalid sceneItem order";
|
||||
}
|
||||
}, &ctx);
|
||||
|
||||
if (!ctx.success) {
|
||||
return request.failed(ctx.errorMessage);
|
||||
}
|
||||
|
||||
return request.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a scene to use a specific transition override.
|
||||
*
|
||||
* @param {String} `sceneName` Name of the scene to switch to.
|
||||
* @param {String} `transitionName` Name of the transition to use.
|
||||
* @param {int (Optional)} `transitionDuration` Duration in milliseconds of the transition if transition is not fixed. Defaults to the current duration specified in the UI if there is no current override and this value is not given.
|
||||
*
|
||||
* @api requests
|
||||
* @name SetSceneTransitionOverride
|
||||
* @category scenes
|
||||
* @since 4.8.0
|
||||
*/
|
||||
RpcResponse WSRequestHandler::SetSceneTransitionOverride(const RpcRequest& request) {
|
||||
if (!request.hasField("sceneName") || !request.hasField("transitionName")) {
|
||||
return request.failed("missing request parameters");
|
||||
}
|
||||
|
||||
QString sceneName = obs_data_get_string(request.parameters(), "sceneName");
|
||||
OBSSourceAutoRelease source = obs_get_source_by_name(sceneName.toUtf8());
|
||||
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");
|
||||
OBSSourceAutoRelease transition = Utils::GetTransitionFromName(transitionName);
|
||||
if (!transition) {
|
||||
return request.failed("requested transition does not exist");
|
||||
}
|
||||
|
||||
OBSDataAutoRelease sourceData = obs_source_get_private_settings(source);
|
||||
obs_data_set_string(sourceData, "transition", transitionName.toUtf8().constData());
|
||||
|
||||
if (request.hasField("transitionDuration")) {
|
||||
int transitionOverrideDuration = obs_data_get_int(request.parameters(), "transitionDuration");
|
||||
obs_data_set_int(sourceData, "transition_duration", transitionOverrideDuration);
|
||||
} else if(!obs_data_has_user_value(sourceData, "transition_duration")) {
|
||||
obs_data_set_int(sourceData, "transition_duration",
|
||||
obs_frontend_get_transition_duration()
|
||||
);
|
||||
}
|
||||
|
||||
return request.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove any transition override on a scene.
|
||||
*
|
||||
* @param {String} `sceneName` Name of the scene to switch to.
|
||||
*
|
||||
* @api requests
|
||||
* @name RemoveSceneTransitionOverride
|
||||
* @category scenes
|
||||
* @since 4.8.0
|
||||
*/
|
||||
RpcResponse WSRequestHandler::RemoveSceneTransitionOverride(const RpcRequest& request) {
|
||||
if (!request.hasField("sceneName")) {
|
||||
return request.failed("missing request parameters");
|
||||
}
|
||||
|
||||
QString sceneName = obs_data_get_string(request.parameters(), "sceneName");
|
||||
OBSSourceAutoRelease source = obs_get_source_by_name(sceneName.toUtf8());
|
||||
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");
|
||||
}
|
||||
|
||||
OBSDataAutoRelease sourceData = obs_source_get_private_settings(source);
|
||||
obs_data_erase(sourceData, "transition");
|
||||
obs_data_erase(sourceData, "transition_duration");
|
||||
|
||||
return request.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current scene transition override.
|
||||
*
|
||||
* @param {String} `sceneName` Name of the scene to switch to.
|
||||
*
|
||||
* @return {String} `transitionName` Name of the current overriding transition. Empty string if no override is set.
|
||||
* @return {int} `transitionDuration` Transition duration. `-1` if no override is set.
|
||||
*
|
||||
* @api requests
|
||||
* @name GetSceneTransitionOverride
|
||||
* @category scenes
|
||||
* @since 4.8.0
|
||||
*/
|
||||
RpcResponse WSRequestHandler::GetSceneTransitionOverride(const RpcRequest& request) {
|
||||
if (!request.hasField("sceneName")) {
|
||||
return request.failed("missing request parameters");
|
||||
}
|
||||
|
||||
QString sceneName = obs_data_get_string(request.parameters(), "sceneName");
|
||||
OBSSourceAutoRelease source = obs_get_source_by_name(sceneName.toUtf8());
|
||||
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");
|
||||
}
|
||||
|
||||
OBSDataAutoRelease sourceData = obs_source_get_private_settings(source);
|
||||
const char* transitionOverrideName = obs_data_get_string(sourceData, "transition");
|
||||
|
||||
bool hasDurationOverride = obs_data_has_user_value(sourceData, "transition_duration");
|
||||
int transitionOverrideDuration = obs_data_get_int(sourceData, "transition_duration");
|
||||
|
||||
OBSDataAutoRelease fields = obs_data_create();
|
||||
obs_data_set_string(fields, "transitionName", transitionOverrideName);
|
||||
obs_data_set_int(fields, "transitionDuration",
|
||||
(hasDurationOverride ? transitionOverrideDuration : -1)
|
||||
);
|
||||
|
||||
return request.success(fields);
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
||||
#include <QString>
|
||||
#include "obs-websocket.h"
|
||||
#include "Utils.h"
|
||||
#include "WSEvents.h"
|
||||
|
||||
@ -8,159 +8,168 @@
|
||||
|
||||
/**
|
||||
* Get current streaming and recording status.
|
||||
*
|
||||
*
|
||||
* @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
|
||||
* @category streaming
|
||||
* @since 0.3
|
||||
*/
|
||||
void WSRequestHandler::HandleGetStreamingStatus(WSRequestHandler* req) {
|
||||
OBSDataAutoRelease data = obs_data_create();
|
||||
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, "preview-only", false);
|
||||
RpcResponse WSRequestHandler::GetStreamingStatus(const RpcRequest& request) {
|
||||
auto events = GetEventsSystem();
|
||||
|
||||
const char* tc = nullptr;
|
||||
if (obs_frontend_streaming_active()) {
|
||||
tc = WSEvents::Instance->GetStreamingTimecode();
|
||||
obs_data_set_string(data, "stream-timecode", tc);
|
||||
bfree((void*)tc);
|
||||
}
|
||||
OBSDataAutoRelease data = obs_data_create();
|
||||
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_recording_active()) {
|
||||
tc = WSEvents::Instance->GetRecordingTimecode();
|
||||
obs_data_set_string(data, "rec-timecode", tc);
|
||||
bfree((void*)tc);
|
||||
}
|
||||
if (obs_frontend_streaming_active()) {
|
||||
QString streamingTimecode = events->getStreamingTimecode();
|
||||
obs_data_set_string(data, "stream-timecode", streamingTimecode.toUtf8().constData());
|
||||
}
|
||||
|
||||
req->SendOKResponse(data);
|
||||
if (obs_frontend_recording_active()) {
|
||||
QString recordingTimecode = events->getRecordingTimecode();
|
||||
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
|
||||
* @category streaming
|
||||
* @since 0.3
|
||||
*/
|
||||
void WSRequestHandler::HandleStartStopStreaming(WSRequestHandler* req) {
|
||||
if (obs_frontend_streaming_active())
|
||||
HandleStopStreaming(req);
|
||||
else
|
||||
HandleStartStreaming(req);
|
||||
RpcResponse WSRequestHandler::StartStopStreaming(const RpcRequest& request) {
|
||||
if (obs_frontend_streaming_active())
|
||||
return StopStreaming(request);
|
||||
else
|
||||
return StartStreaming(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.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.
|
||||
* @param {String (optional)} `stream.settings.server` The publish URL.
|
||||
* @param {String (optional)} `stream.settings.key` The publish key of the stream.
|
||||
* @param {boolean (optional)} `stream.settings.use-auth` Indicates whether authentication should be used when connecting to the streaming server.
|
||||
* @param {String (optional)} `stream.settings.username` If authentication is enabled, the username for the streaming server. Ignored if `use-auth` is not set to `true`.
|
||||
* @param {String (optional)} `stream.settings.password` If authentication is enabled, the password for the streaming server. Ignored if `use-auth` is not set to `true`.
|
||||
* @param {boolean (optional)} `stream.settings.use_auth` Indicates whether authentication should be used when connecting to the streaming server.
|
||||
* @param {String (optional)} `stream.settings.username` If authentication is enabled, the username for the streaming server. Ignored if `use_auth` is not set to `true`.
|
||||
* @param {String (optional)} `stream.settings.password` If authentication is enabled, the password for the streaming server. Ignored if `use_auth` is not set to `true`.
|
||||
*
|
||||
* @api requests
|
||||
* @name StartStreaming
|
||||
* @category streaming
|
||||
* @since 4.1.0
|
||||
*/
|
||||
void WSRequestHandler::HandleStartStreaming(WSRequestHandler* req) {
|
||||
if (obs_frontend_streaming_active() == false) {
|
||||
OBSService configuredService = obs_frontend_get_streaming_service();
|
||||
OBSService newService = nullptr;
|
||||
RpcResponse WSRequestHandler::StartStreaming(const RpcRequest& request) {
|
||||
if (obs_frontend_streaming_active() == false) {
|
||||
OBSService configuredService = obs_frontend_get_streaming_service();
|
||||
OBSService newService = nullptr;
|
||||
|
||||
// TODO: fix service memory leak
|
||||
// TODO: fix service memory leak
|
||||
|
||||
if (req->hasField("stream")) {
|
||||
OBSDataAutoRelease streamData = obs_data_get_obj(req->data, "stream");
|
||||
OBSDataAutoRelease newSettings = obs_data_get_obj(streamData, "settings");
|
||||
OBSDataAutoRelease newMetadata = obs_data_get_obj(streamData, "metadata");
|
||||
if (request.hasField("stream")) {
|
||||
OBSDataAutoRelease streamData = obs_data_get_obj(request.parameters(), "stream");
|
||||
OBSDataAutoRelease newSettings = obs_data_get_obj(streamData, "settings");
|
||||
OBSDataAutoRelease newMetadata = obs_data_get_obj(streamData, "metadata");
|
||||
|
||||
OBSDataAutoRelease csHotkeys =
|
||||
obs_hotkeys_save_service(configuredService);
|
||||
OBSDataAutoRelease csHotkeys =
|
||||
obs_hotkeys_save_service(configuredService);
|
||||
|
||||
QString currentType = obs_service_get_type(configuredService);
|
||||
QString newType = obs_data_get_string(streamData, "type");
|
||||
if (newType.isEmpty() || newType.isNull()) {
|
||||
newType = currentType;
|
||||
}
|
||||
QString currentType = obs_service_get_type(configuredService);
|
||||
QString newType = obs_data_get_string(streamData, "type");
|
||||
if (newType.isEmpty() || newType.isNull()) {
|
||||
newType = currentType;
|
||||
}
|
||||
|
||||
//Supporting adding metadata parameters to key query string
|
||||
QString query = Utils::ParseDataToQueryString(newMetadata);
|
||||
if (!query.isEmpty()
|
||||
&& obs_data_has_user_value(newSettings, "key"))
|
||||
{
|
||||
const char* key = obs_data_get_string(newSettings, "key");
|
||||
int keylen = strlen(key);
|
||||
//Supporting adding metadata parameters to key query string
|
||||
QString query = Utils::ParseDataToQueryString(newMetadata);
|
||||
if (!query.isEmpty()
|
||||
&& obs_data_has_user_value(newSettings, "key"))
|
||||
{
|
||||
const char* key = obs_data_get_string(newSettings, "key");
|
||||
size_t keylen = strlen(key);
|
||||
|
||||
bool hasQuestionMark = false;
|
||||
for (int i = 0; i < keylen; i++) {
|
||||
if (key[i] == '?') {
|
||||
hasQuestionMark = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
bool hasQuestionMark = false;
|
||||
for (size_t i = 0; i < keylen; i++) {
|
||||
if (key[i] == '?') {
|
||||
hasQuestionMark = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasQuestionMark) {
|
||||
query.prepend('&');
|
||||
} else {
|
||||
query.prepend('?');
|
||||
}
|
||||
if (hasQuestionMark) {
|
||||
query.prepend('&');
|
||||
} else {
|
||||
query.prepend('?');
|
||||
}
|
||||
|
||||
query.prepend(key);
|
||||
obs_data_set_string(newSettings, "key", query.toUtf8());
|
||||
}
|
||||
query.prepend(key);
|
||||
obs_data_set_string(newSettings, "key", query.toUtf8());
|
||||
}
|
||||
|
||||
if (newType == currentType) {
|
||||
// Service type doesn't change: apply settings to current service
|
||||
if (newType == currentType) {
|
||||
// Service type doesn't change: apply settings to current service
|
||||
|
||||
// By doing this, you can send a request to the websocket
|
||||
// that only contains settings you want to change, instead of
|
||||
// having to do a get and then change them
|
||||
// By doing this, you can send a request to the websocket
|
||||
// that only contains settings you want to change, instead of
|
||||
// having to do a get and then change them
|
||||
|
||||
OBSDataAutoRelease currentSettings = obs_service_get_settings(configuredService);
|
||||
OBSDataAutoRelease updatedSettings = obs_data_create();
|
||||
OBSDataAutoRelease currentSettings = obs_service_get_settings(configuredService);
|
||||
OBSDataAutoRelease updatedSettings = obs_data_create();
|
||||
|
||||
obs_data_apply(updatedSettings, currentSettings); //first apply the existing settings
|
||||
obs_data_apply(updatedSettings, newSettings); //then apply the settings from the request should they exist
|
||||
obs_data_apply(updatedSettings, currentSettings); //first apply the existing settings
|
||||
obs_data_apply(updatedSettings, newSettings); //then apply the settings from the request should they exist
|
||||
|
||||
newService = obs_service_create(
|
||||
newType.toUtf8(), STREAM_SERVICE_ID,
|
||||
updatedSettings, csHotkeys);
|
||||
}
|
||||
else {
|
||||
// Service type changed: override service settings
|
||||
newService = obs_service_create(
|
||||
newType.toUtf8(), STREAM_SERVICE_ID,
|
||||
newSettings, csHotkeys);
|
||||
}
|
||||
newService = obs_service_create(
|
||||
newType.toUtf8(), STREAM_SERVICE_ID,
|
||||
updatedSettings, csHotkeys);
|
||||
}
|
||||
else {
|
||||
// Service type changed: override service settings
|
||||
newService = obs_service_create(
|
||||
newType.toUtf8(), STREAM_SERVICE_ID,
|
||||
newSettings, csHotkeys);
|
||||
}
|
||||
|
||||
obs_frontend_set_streaming_service(newService);
|
||||
}
|
||||
obs_frontend_set_streaming_service(newService);
|
||||
}
|
||||
|
||||
obs_frontend_streaming_start();
|
||||
obs_frontend_streaming_start();
|
||||
|
||||
// Stream settings provided in StartStreaming are not persisted to disk
|
||||
if (newService != nullptr) {
|
||||
obs_frontend_set_streaming_service(configuredService);
|
||||
}
|
||||
// Stream settings provided in StartStreaming are not persisted to disk
|
||||
if (newService != nullptr) {
|
||||
obs_frontend_set_streaming_service(configuredService);
|
||||
}
|
||||
|
||||
req->SendOKResponse();
|
||||
} else {
|
||||
req->SendErrorResponse("streaming already active");
|
||||
}
|
||||
return request.success();
|
||||
} else {
|
||||
return request.failed("streaming already active");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -172,23 +181,23 @@
|
||||
* @category streaming
|
||||
* @since 4.1.0
|
||||
*/
|
||||
void WSRequestHandler::HandleStopStreaming(WSRequestHandler* req) {
|
||||
if (obs_frontend_streaming_active() == true) {
|
||||
obs_frontend_streaming_stop();
|
||||
req->SendOKResponse();
|
||||
} else {
|
||||
req->SendErrorResponse("streaming not active");
|
||||
}
|
||||
RpcResponse WSRequestHandler::StopStreaming(const RpcRequest& request) {
|
||||
if (obs_frontend_streaming_active() == true) {
|
||||
obs_frontend_streaming_stop();
|
||||
return request.success();
|
||||
} else {
|
||||
return request.failed("streaming not active");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets one or more attributes of the current streaming server settings. Any options not passed will remain unchanged. Returns the updated settings in response. If 'type' is different than the current streaming service type, all settings are required. Returns the full settings of the stream (the same as GetStreamSettings).
|
||||
*
|
||||
*
|
||||
* @param {String} `type` The type of streaming service configuration, usually `rtmp_custom` or `rtmp_common`.
|
||||
* @param {Object} `settings` The actual settings of the stream.
|
||||
* @param {String (optional)} `settings.server` The publish URL.
|
||||
* @param {String (optional)} `settings.key` The publish key.
|
||||
* @param {boolean (optional)} `settings.use-auth` Indicates whether authentication should be used when connecting to the streaming server.
|
||||
* @param {boolean (optional)} `settings.use_auth` Indicates whether authentication should be used when connecting to the streaming server.
|
||||
* @param {String (optional)} `settings.username` The username for the streaming service.
|
||||
* @param {String (optional)} `settings.password` The password for the streaming service.
|
||||
* @param {boolean} `save` Persist the settings to disk.
|
||||
@ -198,51 +207,53 @@ void WSRequestHandler::HandleStopStreaming(WSRequestHandler* req) {
|
||||
* @category streaming
|
||||
* @since 4.1.0
|
||||
*/
|
||||
void WSRequestHandler::HandleSetStreamSettings(WSRequestHandler* req) {
|
||||
OBSService service = obs_frontend_get_streaming_service();
|
||||
RpcResponse WSRequestHandler::SetStreamSettings(const RpcRequest& request) {
|
||||
OBSService service = obs_frontend_get_streaming_service();
|
||||
|
||||
OBSDataAutoRelease requestSettings = obs_data_get_obj(req->data, "settings");
|
||||
if (!requestSettings) {
|
||||
req->SendErrorResponse("'settings' are required'");
|
||||
return;
|
||||
}
|
||||
OBSDataAutoRelease requestSettings = obs_data_get_obj(request.parameters(), "settings");
|
||||
if (!requestSettings) {
|
||||
return request.failed("'settings' are required'");
|
||||
}
|
||||
|
||||
QString serviceType = obs_service_get_type(service);
|
||||
QString requestedType = obs_data_get_string(req->data, "type");
|
||||
QString serviceType = obs_service_get_type(service);
|
||||
QString requestedType = obs_data_get_string(request.parameters(), "type");
|
||||
|
||||
if (requestedType != nullptr && requestedType != serviceType) {
|
||||
OBSDataAutoRelease hotkeys = obs_hotkeys_save_service(service);
|
||||
service = obs_service_create(
|
||||
requestedType.toUtf8(), STREAM_SERVICE_ID, requestSettings, hotkeys);
|
||||
} else {
|
||||
// If type isn't changing, we should overlay the settings we got
|
||||
// to the existing settings. By doing so, you can send a request that
|
||||
// only contains the settings you want to change, instead of having to
|
||||
// do a get and then change them
|
||||
if (requestedType != nullptr && requestedType != serviceType) {
|
||||
OBSDataAutoRelease hotkeys = obs_hotkeys_save_service(service);
|
||||
service = obs_service_create(
|
||||
requestedType.toUtf8(), STREAM_SERVICE_ID, requestSettings, hotkeys);
|
||||
obs_frontend_set_streaming_service(service);
|
||||
} else {
|
||||
// If type isn't changing, we should overlay the settings we got
|
||||
// to the existing settings. By doing so, you can send a request that
|
||||
// only contains the settings you want to change, instead of having to
|
||||
// do a get and then change them
|
||||
|
||||
OBSDataAutoRelease existingSettings = obs_service_get_settings(service);
|
||||
OBSDataAutoRelease newSettings = obs_data_create();
|
||||
OBSDataAutoRelease existingSettings = obs_service_get_settings(service);
|
||||
OBSDataAutoRelease newSettings = obs_data_create();
|
||||
|
||||
// Apply existing settings
|
||||
obs_data_apply(newSettings, existingSettings);
|
||||
// Then apply the settings from the request
|
||||
obs_data_apply(newSettings, requestSettings);
|
||||
// Apply existing settings
|
||||
obs_data_apply(newSettings, existingSettings);
|
||||
// Then apply the settings from the request
|
||||
obs_data_apply(newSettings, requestSettings);
|
||||
|
||||
obs_service_update(service, newSettings);
|
||||
}
|
||||
obs_service_update(service, newSettings);
|
||||
}
|
||||
|
||||
//if save is specified we should immediately save the streaming service
|
||||
if (obs_data_get_bool(req->data, "save")) {
|
||||
obs_frontend_save_streaming_service();
|
||||
}
|
||||
//if save is specified we should immediately save the streaming service
|
||||
if (obs_data_get_bool(request.parameters(), "save")) {
|
||||
obs_frontend_save_streaming_service();
|
||||
}
|
||||
|
||||
OBSDataAutoRelease serviceSettings = obs_service_get_settings(service);
|
||||
OBSService responseService = obs_frontend_get_streaming_service();
|
||||
OBSDataAutoRelease serviceSettings = obs_service_get_settings(responseService);
|
||||
const char* responseType = obs_service_get_type(responseService);
|
||||
|
||||
OBSDataAutoRelease response = obs_data_create();
|
||||
obs_data_set_string(response, "type", requestedType.toUtf8());
|
||||
obs_data_set_obj(response, "settings", serviceSettings);
|
||||
OBSDataAutoRelease response = obs_data_create();
|
||||
obs_data_set_string(response, "type", responseType);
|
||||
obs_data_set_obj(response, "settings", serviceSettings);
|
||||
|
||||
req->SendOKResponse(response);
|
||||
return request.success(response);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -252,26 +263,26 @@ void WSRequestHandler::HandleStopStreaming(WSRequestHandler* req) {
|
||||
* @return {Object} `settings` Stream settings object.
|
||||
* @return {String} `settings.server` The publish URL.
|
||||
* @return {String} `settings.key` The publish key of the stream.
|
||||
* @return {boolean} `settings.use-auth` Indicates whether audentication should be used when connecting to the streaming server.
|
||||
* @return {String} `settings.username` The username to use when accessing the streaming server. Only present if `use-auth` is `true`.
|
||||
* @return {String} `settings.password` The password to use when accessing the streaming server. Only present if `use-auth` is `true`.
|
||||
* @return {boolean} `settings.use_auth` Indicates whether authentication should be used when connecting to the streaming server.
|
||||
* @return {String} `settings.username` The username to use when accessing the streaming server. Only present if `use_auth` is `true`.
|
||||
* @return {String} `settings.password` The password to use when accessing the streaming server. Only present if `use_auth` is `true`.
|
||||
*
|
||||
* @api requests
|
||||
* @name GetStreamSettings
|
||||
* @category streaming
|
||||
* @since 4.1.0
|
||||
*/
|
||||
void WSRequestHandler::HandleGetStreamSettings(WSRequestHandler* req) {
|
||||
OBSService service = obs_frontend_get_streaming_service();
|
||||
RpcResponse WSRequestHandler::GetStreamSettings(const RpcRequest& request) {
|
||||
OBSService service = obs_frontend_get_streaming_service();
|
||||
|
||||
const char* serviceType = obs_service_get_type(service);
|
||||
OBSDataAutoRelease settings = obs_service_get_settings(service);
|
||||
const char* serviceType = obs_service_get_type(service);
|
||||
OBSDataAutoRelease settings = obs_service_get_settings(service);
|
||||
|
||||
OBSDataAutoRelease response = obs_data_create();
|
||||
obs_data_set_string(response, "type", serviceType);
|
||||
obs_data_set_obj(response, "settings", settings);
|
||||
OBSDataAutoRelease response = obs_data_create();
|
||||
obs_data_set_string(response, "type", serviceType);
|
||||
obs_data_set_obj(response, "settings", settings);
|
||||
|
||||
req->SendOKResponse(response);
|
||||
return request.success(response);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -282,7 +293,34 @@ void WSRequestHandler::HandleGetStreamSettings(WSRequestHandler* req) {
|
||||
* @category streaming
|
||||
* @since 4.1.0
|
||||
*/
|
||||
void WSRequestHandler::HandleSaveStreamSettings(WSRequestHandler* req) {
|
||||
obs_frontend_save_streaming_service();
|
||||
req->SendOKResponse();
|
||||
RpcResponse WSRequestHandler::SaveStreamSettings(const RpcRequest& request) {
|
||||
obs_frontend_save_streaming_service();
|
||||
return request.success();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Send the provided text as embedded CEA-608 caption data.
|
||||
*
|
||||
* @param {String} `text` Captions text
|
||||
*
|
||||
* @api requests
|
||||
* @name SendCaptions
|
||||
* @category streaming
|
||||
* @since 4.6.0
|
||||
*/
|
||||
RpcResponse WSRequestHandler::SendCaptions(const RpcRequest& request) {
|
||||
if (!request.hasField("text")) {
|
||||
return request.failed("missing request parameters");
|
||||
}
|
||||
|
||||
OBSOutputAutoRelease output = obs_frontend_get_streaming_output();
|
||||
if (output) {
|
||||
const char* caption = obs_data_get_string(request.parameters(), "text");
|
||||
// Send caption text with immediately (0 second delay)
|
||||
obs_output_output_caption_text2(output, caption, 0.0);
|
||||
}
|
||||
|
||||
return request.success();
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
#include <QString>
|
||||
#include "Utils.h"
|
||||
|
||||
#include "WSRequestHandler.h"
|
||||
@ -13,13 +12,13 @@
|
||||
* @category studio mode
|
||||
* @since 4.1.0
|
||||
*/
|
||||
void WSRequestHandler::HandleGetStudioModeStatus(WSRequestHandler* req) {
|
||||
bool previewActive = obs_frontend_preview_program_mode_active();
|
||||
RpcResponse WSRequestHandler::GetStudioModeStatus(const RpcRequest& request) {
|
||||
bool previewActive = obs_frontend_preview_program_mode_active();
|
||||
|
||||
OBSDataAutoRelease response = obs_data_create();
|
||||
obs_data_set_bool(response, "studio-mode", previewActive);
|
||||
OBSDataAutoRelease response = obs_data_create();
|
||||
obs_data_set_bool(response, "studio-mode", previewActive);
|
||||
|
||||
req->SendOKResponse(response);
|
||||
return request.success(response);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -27,27 +26,26 @@
|
||||
* Will return an `error` if Studio Mode is not enabled.
|
||||
*
|
||||
* @return {String} `name` The name of the active preview scene.
|
||||
* @return {Source|Array} `sources`
|
||||
* @return {Array<SceneItem>} `sources`
|
||||
*
|
||||
* @api requests
|
||||
* @name GetPreviewScene
|
||||
* @category studio mode
|
||||
* @since 4.1.0
|
||||
*/
|
||||
void WSRequestHandler::HandleGetPreviewScene(WSRequestHandler* req) {
|
||||
if (!obs_frontend_preview_program_mode_active()) {
|
||||
req->SendErrorResponse("studio mode not enabled");
|
||||
return;
|
||||
}
|
||||
RpcResponse WSRequestHandler::GetPreviewScene(const RpcRequest& request) {
|
||||
if (!obs_frontend_preview_program_mode_active()) {
|
||||
return request.failed("studio mode not enabled");
|
||||
}
|
||||
|
||||
OBSSourceAutoRelease scene = obs_frontend_get_current_preview_scene();
|
||||
OBSDataArrayAutoRelease sceneItems = Utils::GetSceneItems(scene);
|
||||
OBSSourceAutoRelease scene = obs_frontend_get_current_preview_scene();
|
||||
OBSDataArrayAutoRelease sceneItems = Utils::GetSceneItems(scene);
|
||||
|
||||
OBSDataAutoRelease data = obs_data_create();
|
||||
obs_data_set_string(data, "name", obs_source_get_name(scene));
|
||||
obs_data_set_array(data, "sources", sceneItems);
|
||||
OBSDataAutoRelease data = obs_data_create();
|
||||
obs_data_set_string(data, "name", obs_source_get_name(scene));
|
||||
obs_data_set_array(data, "sources", sceneItems);
|
||||
|
||||
req->SendOKResponse(data);
|
||||
return request.success(data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -61,26 +59,23 @@ void WSRequestHandler::HandleGetPreviewScene(WSRequestHandler* req) {
|
||||
* @category studio mode
|
||||
* @since 4.1.0
|
||||
*/
|
||||
void WSRequestHandler::HandleSetPreviewScene(WSRequestHandler* req) {
|
||||
if (!obs_frontend_preview_program_mode_active()) {
|
||||
req->SendErrorResponse("studio mode not enabled");
|
||||
return;
|
||||
}
|
||||
RpcResponse WSRequestHandler::SetPreviewScene(const RpcRequest& request) {
|
||||
if (!obs_frontend_preview_program_mode_active()) {
|
||||
return request.failed("studio mode not enabled");
|
||||
}
|
||||
|
||||
if (!req->hasField("scene-name")) {
|
||||
req->SendErrorResponse("missing request parameters");
|
||||
return;
|
||||
}
|
||||
if (!request.hasField("scene-name")) {
|
||||
return request.failed("missing request parameters");
|
||||
}
|
||||
|
||||
const char* scene_name = obs_data_get_string(req->data, "scene-name");
|
||||
OBSSourceAutoRelease scene = Utils::GetSceneFromNameOrCurrent(scene_name);
|
||||
const char* scene_name = obs_data_get_string(request.parameters(), "scene-name");
|
||||
OBSScene scene = Utils::GetSceneFromNameOrCurrent(scene_name);
|
||||
if (!scene) {
|
||||
return request.failed("specified scene doesn't exist");
|
||||
}
|
||||
|
||||
if (scene) {
|
||||
obs_frontend_set_current_preview_scene(scene);
|
||||
req->SendOKResponse();
|
||||
} else {
|
||||
req->SendErrorResponse("specified scene doesn't exist");
|
||||
}
|
||||
obs_frontend_set_current_preview_scene(obs_scene_get_source(scene));
|
||||
return request.success();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -96,40 +91,37 @@ void WSRequestHandler::HandleSetPreviewScene(WSRequestHandler* req) {
|
||||
* @category studio mode
|
||||
* @since 4.1.0
|
||||
*/
|
||||
void WSRequestHandler::HandleTransitionToProgram(WSRequestHandler* req) {
|
||||
if (!obs_frontend_preview_program_mode_active()) {
|
||||
req->SendErrorResponse("studio mode not enabled");
|
||||
return;
|
||||
}
|
||||
RpcResponse WSRequestHandler::TransitionToProgram(const RpcRequest& request) {
|
||||
if (!obs_frontend_preview_program_mode_active()) {
|
||||
return request.failed("studio mode not enabled");
|
||||
}
|
||||
|
||||
if (req->hasField("with-transition")) {
|
||||
OBSDataAutoRelease transitionInfo =
|
||||
obs_data_get_obj(req->data, "with-transition");
|
||||
if (request.hasField("with-transition")) {
|
||||
OBSDataAutoRelease transitionInfo =
|
||||
obs_data_get_obj(request.parameters(), "with-transition");
|
||||
|
||||
if (obs_data_has_user_value(transitionInfo, "name")) {
|
||||
QString transitionName =
|
||||
obs_data_get_string(transitionInfo, "name");
|
||||
if (transitionName.isEmpty()) {
|
||||
req->SendErrorResponse("invalid request parameters");
|
||||
return;
|
||||
}
|
||||
if (obs_data_has_user_value(transitionInfo, "name")) {
|
||||
QString transitionName =
|
||||
obs_data_get_string(transitionInfo, "name");
|
||||
if (transitionName.isEmpty()) {
|
||||
return request.failed("invalid request parameters");
|
||||
}
|
||||
|
||||
bool success = Utils::SetTransitionByName(transitionName);
|
||||
if (!success) {
|
||||
req->SendErrorResponse("specified transition doesn't exist");
|
||||
return;
|
||||
}
|
||||
}
|
||||
bool success = Utils::SetTransitionByName(transitionName);
|
||||
if (!success) {
|
||||
return request.failed("specified transition doesn't exist");
|
||||
}
|
||||
}
|
||||
|
||||
if (obs_data_has_user_value(transitionInfo, "duration")) {
|
||||
int transitionDuration =
|
||||
obs_data_get_int(transitionInfo, "duration");
|
||||
Utils::SetTransitionDuration(transitionDuration);
|
||||
}
|
||||
}
|
||||
if (obs_data_has_user_value(transitionInfo, "duration")) {
|
||||
int transitionDuration =
|
||||
obs_data_get_int(transitionInfo, "duration");
|
||||
obs_frontend_set_transition_duration(transitionDuration);
|
||||
}
|
||||
}
|
||||
|
||||
Utils::TransitionToProgram();
|
||||
req->SendOKResponse();
|
||||
obs_frontend_preview_program_trigger_transition();
|
||||
return request.success();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -140,9 +132,16 @@ void WSRequestHandler::HandleTransitionToProgram(WSRequestHandler* req) {
|
||||
* @category studio mode
|
||||
* @since 4.1.0
|
||||
*/
|
||||
void WSRequestHandler::HandleEnableStudioMode(WSRequestHandler* req) {
|
||||
obs_frontend_set_preview_program_mode(true);
|
||||
req->SendOKResponse();
|
||||
RpcResponse WSRequestHandler::EnableStudioMode(const RpcRequest& request) {
|
||||
if (obs_frontend_preview_program_mode_active()) {
|
||||
return request.failed("studio mode already active");
|
||||
}
|
||||
obs_queue_task(OBS_TASK_UI, [](void* param) {
|
||||
obs_frontend_set_preview_program_mode(true);
|
||||
|
||||
UNUSED_PARAMETER(param);
|
||||
}, nullptr, true);
|
||||
return request.success();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -153,21 +152,34 @@ void WSRequestHandler::HandleEnableStudioMode(WSRequestHandler* req) {
|
||||
* @category studio mode
|
||||
* @since 4.1.0
|
||||
*/
|
||||
void WSRequestHandler::HandleDisableStudioMode(WSRequestHandler* req) {
|
||||
obs_frontend_set_preview_program_mode(false);
|
||||
req->SendOKResponse();
|
||||
RpcResponse WSRequestHandler::DisableStudioMode(const RpcRequest& request) {
|
||||
if (!obs_frontend_preview_program_mode_active()) {
|
||||
return request.failed("studio mode not active");
|
||||
}
|
||||
obs_queue_task(OBS_TASK_UI, [](void* param) {
|
||||
obs_frontend_set_preview_program_mode(false);
|
||||
|
||||
UNUSED_PARAMETER(param);
|
||||
}, nullptr, true);
|
||||
|
||||
return request.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggles Studio Mode.
|
||||
* Toggles Studio Mode (depending on the current state of studio mode).
|
||||
*
|
||||
* @api requests
|
||||
* @name ToggleStudioMode
|
||||
* @category studio mode
|
||||
* @since 4.1.0
|
||||
*/
|
||||
void WSRequestHandler::HandleToggleStudioMode(WSRequestHandler* req) {
|
||||
bool previewProgramMode = obs_frontend_preview_program_mode_active();
|
||||
obs_frontend_set_preview_program_mode(!previewProgramMode);
|
||||
req->SendOKResponse();
|
||||
}
|
||||
RpcResponse WSRequestHandler::ToggleStudioMode(const RpcRequest& request) {
|
||||
obs_queue_task(OBS_TASK_UI, [](void* param) {
|
||||
bool previewProgramMode = obs_frontend_preview_program_mode_active();
|
||||
obs_frontend_set_preview_program_mode(!previewProgramMode);
|
||||
|
||||
UNUSED_PARAMETER(param);
|
||||
}, nullptr, true);
|
||||
|
||||
return request.success();
|
||||
}
|
@ -1,4 +1,3 @@
|
||||
#include <QString>
|
||||
#include "Utils.h"
|
||||
|
||||
#include "WSRequestHandler.h"
|
||||
@ -7,35 +6,35 @@
|
||||
* List of all transitions available in the frontend's dropdown menu.
|
||||
*
|
||||
* @return {String} `current-transition` Name of the currently active transition.
|
||||
* @return {Object|Array} `transitions` List of transitions.
|
||||
* @return {String} `transitions[].name` Name of the transition.
|
||||
* @return {Array<Object>} `transitions` List of transitions.
|
||||
* @return {String} `transitions.*.name` Name of the transition.
|
||||
*
|
||||
* @api requests
|
||||
* @name GetTransitionList
|
||||
* @category transitions
|
||||
* @since 4.1.0
|
||||
*/
|
||||
void WSRequestHandler::HandleGetTransitionList(WSRequestHandler* req) {
|
||||
OBSSourceAutoRelease currentTransition = obs_frontend_get_current_transition();
|
||||
obs_frontend_source_list transitionList = {};
|
||||
obs_frontend_get_transitions(&transitionList);
|
||||
RpcResponse WSRequestHandler::GetTransitionList(const RpcRequest& request) {
|
||||
OBSSourceAutoRelease currentTransition = obs_frontend_get_current_transition();
|
||||
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];
|
||||
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 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 response = obs_data_create();
|
||||
obs_data_set_string(response, "current-transition",
|
||||
obs_source_get_name(currentTransition));
|
||||
obs_data_set_array(response, "transitions", transitions);
|
||||
OBSDataAutoRelease response = obs_data_create();
|
||||
obs_data_set_string(response, "current-transition",
|
||||
obs_source_get_name(currentTransition));
|
||||
obs_data_set_array(response, "transitions", transitions);
|
||||
|
||||
req->SendOKResponse(response);
|
||||
return request.success(response);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -49,17 +48,17 @@
|
||||
* @category transitions
|
||||
* @since 0.3
|
||||
*/
|
||||
void WSRequestHandler::HandleGetCurrentTransition(WSRequestHandler* req) {
|
||||
OBSSourceAutoRelease currentTransition = obs_frontend_get_current_transition();
|
||||
RpcResponse WSRequestHandler::GetCurrentTransition(const RpcRequest& request) {
|
||||
OBSSourceAutoRelease currentTransition = obs_frontend_get_current_transition();
|
||||
|
||||
OBSDataAutoRelease response = obs_data_create();
|
||||
obs_data_set_string(response, "name",
|
||||
obs_source_get_name(currentTransition));
|
||||
OBSDataAutoRelease response = obs_data_create();
|
||||
obs_data_set_string(response, "name",
|
||||
obs_source_get_name(currentTransition));
|
||||
|
||||
if (!obs_transition_fixed(currentTransition))
|
||||
obs_data_set_int(response, "duration", Utils::GetTransitionDuration());
|
||||
if (!obs_transition_fixed(currentTransition))
|
||||
obs_data_set_int(response, "duration", obs_frontend_get_transition_duration());
|
||||
|
||||
req->SendOKResponse(response);
|
||||
return request.success(response);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -72,18 +71,18 @@ void WSRequestHandler::HandleGetCurrentTransition(WSRequestHandler* req) {
|
||||
* @category transitions
|
||||
* @since 0.3
|
||||
*/
|
||||
void WSRequestHandler::HandleSetCurrentTransition(WSRequestHandler* req) {
|
||||
if (!req->hasField("transition-name")) {
|
||||
req->SendErrorResponse("missing request parameters");
|
||||
return;
|
||||
}
|
||||
RpcResponse WSRequestHandler::SetCurrentTransition(const RpcRequest& request) {
|
||||
if (!request.hasField("transition-name")) {
|
||||
return request.failed("missing request parameters");
|
||||
}
|
||||
|
||||
QString name = obs_data_get_string(req->data, "transition-name");
|
||||
bool success = Utils::SetTransitionByName(name);
|
||||
if (success)
|
||||
req->SendOKResponse();
|
||||
else
|
||||
req->SendErrorResponse("requested transition does not exist");
|
||||
QString name = obs_data_get_string(request.parameters(), "transition-name");
|
||||
bool success = Utils::SetTransitionByName(name);
|
||||
if (!success) {
|
||||
return request.failed("requested transition does not exist");
|
||||
}
|
||||
|
||||
return request.success();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -96,15 +95,14 @@ void WSRequestHandler::HandleSetCurrentTransition(WSRequestHandler* req) {
|
||||
* @category transitions
|
||||
* @since 4.0.0
|
||||
*/
|
||||
void WSRequestHandler::HandleSetTransitionDuration(WSRequestHandler* req) {
|
||||
if (!req->hasField("duration")) {
|
||||
req->SendErrorResponse("missing request parameters");
|
||||
return;
|
||||
}
|
||||
RpcResponse WSRequestHandler::SetTransitionDuration(const RpcRequest& request) {
|
||||
if (!request.hasField("duration")) {
|
||||
return request.failed("missing request parameters");
|
||||
}
|
||||
|
||||
int ms = obs_data_get_int(req->data, "duration");
|
||||
Utils::SetTransitionDuration(ms);
|
||||
req->SendOKResponse();
|
||||
int ms = obs_data_get_int(request.parameters(), "duration");
|
||||
obs_frontend_set_transition_duration(ms);
|
||||
return request.success();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -117,10 +115,162 @@ void WSRequestHandler::HandleSetTransitionDuration(WSRequestHandler* req) {
|
||||
* @category transitions
|
||||
* @since 4.1.0
|
||||
*/
|
||||
void WSRequestHandler::HandleGetTransitionDuration(WSRequestHandler* req) {
|
||||
OBSDataAutoRelease response = obs_data_create();
|
||||
obs_data_set_int(response, "transition-duration",
|
||||
Utils::GetTransitionDuration());
|
||||
|
||||
req->SendOKResponse(response);
|
||||
RpcResponse WSRequestHandler::GetTransitionDuration(const RpcRequest& request) {
|
||||
OBSDataAutoRelease response = obs_data_create();
|
||||
obs_data_set_int(response, "transition-duration", obs_frontend_get_transition_duration());
|
||||
return request.success(response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the position of the current transition.
|
||||
*
|
||||
* @return {double} `position` current transition position. This value will be between 0.0 and 1.0. Note: Transition returns 1.0 when not active.
|
||||
*
|
||||
* @api requests
|
||||
* @name GetTransitionPosition
|
||||
* @category transitions
|
||||
* @since 4.9.0
|
||||
*/
|
||||
RpcResponse WSRequestHandler::GetTransitionPosition(const RpcRequest& request) {
|
||||
OBSSourceAutoRelease currentTransition = obs_frontend_get_current_transition();
|
||||
|
||||
OBSDataAutoRelease response = obs_data_create();
|
||||
obs_data_set_double(response, "position", obs_transition_get_time(currentTransition));
|
||||
|
||||
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();
|
||||
}
|
||||
|
79
src/WSRequestHandler_VirtualCam.cpp
Normal file
79
src/WSRequestHandler_VirtualCam.cpp
Normal 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();
|
||||
}
|
359
src/WSServer.cpp
359
src/WSServer.cpp
@ -16,153 +16,282 @@ 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 <QtWebSockets/QWebSocket>
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
|
||||
#include <QtCore/QThread>
|
||||
#include <QtCore/QByteArray>
|
||||
#include <QMainWindow>
|
||||
#include <QMessageBox>
|
||||
#include <QtWidgets/QMainWindow>
|
||||
#include <QtWidgets/QMessageBox>
|
||||
#include <QtConcurrent/QtConcurrent>
|
||||
#include <obs-frontend-api.h>
|
||||
#include <util/platform.h>
|
||||
|
||||
#include "WSServer.h"
|
||||
#include "obs-websocket.h"
|
||||
#include "Config.h"
|
||||
#include "Utils.h"
|
||||
#include "protocol/OBSRemoteProtocol.h"
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
WSServer* WSServer::Instance = nullptr;
|
||||
using websocketpp::lib::placeholders::_1;
|
||||
using websocketpp::lib::placeholders::_2;
|
||||
using websocketpp::lib::bind;
|
||||
|
||||
WSServer::WSServer(QObject* parent)
|
||||
: QObject(parent),
|
||||
_wsServer(Q_NULLPTR),
|
||||
_clients(),
|
||||
_clMutex(QMutex::Recursive)
|
||||
WSServer::WSServer()
|
||||
: QObject(nullptr),
|
||||
_connections(),
|
||||
_clMutex(QMutex::Recursive)
|
||||
{
|
||||
_wsServer = new QWebSocketServer(
|
||||
QStringLiteral("obs-websocket"),
|
||||
QWebSocketServer::NonSecureMode);
|
||||
_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);
|
||||
#endif
|
||||
|
||||
_server.set_open_handler(bind(&WSServer::onOpen, this, ::_1));
|
||||
_server.set_close_handler(bind(&WSServer::onClose, this, ::_1));
|
||||
_server.set_message_handler(bind(&WSServer::onMessage, this, ::_1, ::_2));
|
||||
}
|
||||
|
||||
WSServer::~WSServer() {
|
||||
Stop();
|
||||
WSServer::~WSServer()
|
||||
{
|
||||
stop();
|
||||
}
|
||||
|
||||
void WSServer::Start(quint16 port) {
|
||||
if (port == _wsServer->serverPort())
|
||||
return;
|
||||
|
||||
if(_wsServer->isListening())
|
||||
Stop();
|
||||
|
||||
bool serverStarted = _wsServer->listen(QHostAddress::Any, port);
|
||||
if (serverStarted) {
|
||||
blog(LOG_INFO, "server started successfully on TCP port %d", port);
|
||||
|
||||
connect(_wsServer, SIGNAL(newConnection()),
|
||||
this, SLOT(onNewConnection()));
|
||||
}
|
||||
else {
|
||||
QString errorString = _wsServer->errorString();
|
||||
blog(LOG_ERROR,
|
||||
"error: failed to start server on TCP port %d: %s",
|
||||
port, errorString.toUtf8().constData());
|
||||
|
||||
QMainWindow* mainWindow = (QMainWindow*)obs_frontend_get_main_window();
|
||||
|
||||
obs_frontend_push_ui_translation(obs_module_get_string);
|
||||
QString title = tr("OBSWebsocket.Server.StartFailed.Title");
|
||||
QString msg = tr("OBSWebsocket.Server.StartFailed.Message").arg(port);
|
||||
obs_frontend_pop_ui_translation();
|
||||
|
||||
QMessageBox::warning(mainWindow, title, msg);
|
||||
}
|
||||
void WSServer::serverRunner()
|
||||
{
|
||||
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::Stop() {
|
||||
QMutexLocker locker(&_clMutex);
|
||||
for(QWebSocket* pClient : _clients) {
|
||||
pClient->close();
|
||||
}
|
||||
locker.unlock();
|
||||
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;
|
||||
}
|
||||
|
||||
_wsServer->close();
|
||||
if (_server.is_listening()) {
|
||||
stop();
|
||||
}
|
||||
|
||||
blog(LOG_INFO, "server stopped successfully");
|
||||
_server.reset();
|
||||
|
||||
_serverPort = port;
|
||||
_lockToIPv4 = lockToIPv4;
|
||||
|
||||
websocketpp::lib::error_code 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("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());
|
||||
QMessageBox::warning(mainWindow, errorTitle, errorMessage);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
_server.start_accept();
|
||||
|
||||
_serverThread = std::thread(&WSServer::serverRunner, this);
|
||||
|
||||
blog(LOG_INFO, "server started successfully on port %d", _serverPort);
|
||||
}
|
||||
|
||||
void WSServer::broadcast(QString message) {
|
||||
QMutexLocker locker(&_clMutex);
|
||||
for(QWebSocket* pClient : _clients) {
|
||||
if (Config::Current()->AuthRequired
|
||||
&& (pClient->property(PROP_AUTHENTICATED).toBool() == false)) {
|
||||
// Skip this client if unauthenticated
|
||||
continue;
|
||||
}
|
||||
pClient->sendTextMessage(message);
|
||||
}
|
||||
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) {
|
||||
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();
|
||||
|
||||
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));
|
||||
|
||||
if (config && config->DebugEnabled)
|
||||
blog(LOG_INFO, "[WSServer::stop] Performing join on IO thread...");
|
||||
_serverThread.join();
|
||||
|
||||
blog(LOG_INFO, "Server stopped successfully.");
|
||||
}
|
||||
|
||||
void WSServer::onNewConnection() {
|
||||
QWebSocket* pSocket = _wsServer->nextPendingConnection();
|
||||
if (pSocket) {
|
||||
connect(pSocket, SIGNAL(textMessageReceived(const QString&)),
|
||||
this, SLOT(onTextMessageReceived(QString)));
|
||||
connect(pSocket, SIGNAL(disconnected()),
|
||||
this, SLOT(onSocketDisconnected()));
|
||||
void WSServer::broadcast(const RpcEvent& event)
|
||||
{
|
||||
std::string message = OBSRemoteProtocol::encodeEvent(event);
|
||||
|
||||
pSocket->setProperty(PROP_AUTHENTICATED, false);
|
||||
auto config = GetConfig();
|
||||
if (config && config->DebugEnabled) {
|
||||
blog(LOG_INFO, "Update << '%s'", message.c_str());
|
||||
}
|
||||
|
||||
QMutexLocker locker(&_clMutex);
|
||||
_clients << pSocket;
|
||||
locker.unlock();
|
||||
QMutexLocker locker(&_clMutex);
|
||||
for (connection_hdl hdl : _connections) {
|
||||
if (config && config->AuthRequired) {
|
||||
bool authenticated = _connectionProperties[hdl].isAuthenticated();
|
||||
if (!authenticated) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
QHostAddress clientAddr = pSocket->peerAddress();
|
||||
QString clientIp = Utils::FormatIPAddress(clientAddr);
|
||||
websocketpp::lib::error_code errorCode;
|
||||
_server.send(hdl, message, websocketpp::frame::opcode::text, errorCode);
|
||||
|
||||
blog(LOG_INFO, "new client connection from %s:%d",
|
||||
clientIp.toUtf8().constData(), pSocket->peerPort());
|
||||
|
||||
obs_frontend_push_ui_translation(obs_module_get_string);
|
||||
QString title = tr("OBSWebsocket.NotifyConnect.Title");
|
||||
QString msg = tr("OBSWebsocket.NotifyConnect.Message")
|
||||
.arg(Utils::FormatIPAddress(clientAddr));
|
||||
obs_frontend_pop_ui_translation();
|
||||
|
||||
Utils::SysTrayNotify(msg, QSystemTrayIcon::Information, title);
|
||||
}
|
||||
if (errorCode) {
|
||||
std::string errorCodeMessage = errorCode.message();
|
||||
blog(LOG_INFO, "server(broadcast): send failed: %s",
|
||||
errorCodeMessage.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WSServer::onTextMessageReceived(QString message) {
|
||||
QWebSocket* pSocket = qobject_cast<QWebSocket*>(sender());
|
||||
if (pSocket) {
|
||||
WSRequestHandler handler(pSocket);
|
||||
handler.processIncomingMessage(message);
|
||||
}
|
||||
bool WSServer::isListening()
|
||||
{
|
||||
return _server.is_listening();
|
||||
}
|
||||
|
||||
void WSServer::onSocketDisconnected() {
|
||||
QWebSocket* pSocket = qobject_cast<QWebSocket*>(sender());
|
||||
if (pSocket) {
|
||||
pSocket->setProperty(PROP_AUTHENTICATED, false);
|
||||
void WSServer::onOpen(connection_hdl hdl)
|
||||
{
|
||||
QMutexLocker locker(&_clMutex);
|
||||
_connections.insert(hdl);
|
||||
locker.unlock();
|
||||
|
||||
QMutexLocker locker(&_clMutex);
|
||||
_clients.removeAll(pSocket);
|
||||
locker.unlock();
|
||||
|
||||
pSocket->deleteLater();
|
||||
|
||||
QHostAddress clientAddr = pSocket->peerAddress();
|
||||
QString clientIp = Utils::FormatIPAddress(clientAddr);
|
||||
|
||||
blog(LOG_INFO, "client %s:%d disconnected",
|
||||
clientIp.toUtf8().constData(), pSocket->peerPort());
|
||||
|
||||
obs_frontend_push_ui_translation(obs_module_get_string);
|
||||
QString title = tr("OBSWebsocket.NotifyDisconnect.Title");
|
||||
QString msg = tr("OBSWebsocket.NotifyDisconnect.Message")
|
||||
.arg(Utils::FormatIPAddress(clientAddr));
|
||||
obs_frontend_pop_ui_translation();
|
||||
|
||||
Utils::SysTrayNotify(msg, QSystemTrayIcon::Information, title);
|
||||
}
|
||||
QString clientIp = getRemoteEndpoint(hdl);
|
||||
notifyConnection(clientIp);
|
||||
blog(LOG_INFO, "new client connection from %s", clientIp.toUtf8().constData());
|
||||
}
|
||||
|
||||
void WSServer::onMessage(connection_hdl hdl, server::message_ptr message)
|
||||
{
|
||||
auto opcode = message->get_opcode();
|
||||
if (opcode != websocketpp::frame::opcode::text) {
|
||||
return;
|
||||
}
|
||||
|
||||
QtConcurrent::run(&_threadPool, [=]() {
|
||||
std::string payload = message->get_payload();
|
||||
|
||||
QMutexLocker locker(&_clMutex);
|
||||
ConnectionProperties& connProperties = _connectionProperties[hdl];
|
||||
locker.unlock();
|
||||
|
||||
auto config = GetConfig();
|
||||
if (config && config->DebugEnabled) {
|
||||
blog(LOG_INFO, "Request >> '%s'", payload.c_str());
|
||||
}
|
||||
|
||||
WSRequestHandler requestHandler(connProperties);
|
||||
std::string response = OBSRemoteProtocol::processMessage(requestHandler, payload);
|
||||
|
||||
if (config && config->DebugEnabled) {
|
||||
blog(LOG_INFO, "Response << '%s'", response.c_str());
|
||||
}
|
||||
|
||||
websocketpp::lib::error_code errorCode;
|
||||
_server.send(hdl, response, websocketpp::frame::opcode::text, errorCode);
|
||||
|
||||
if (errorCode) {
|
||||
std::string errorCodeMessage = errorCode.message();
|
||||
blog(LOG_INFO, "server(response): send failed: %s",
|
||||
errorCodeMessage.c_str());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void WSServer::onClose(connection_hdl hdl)
|
||||
{
|
||||
QMutexLocker locker(&_clMutex);
|
||||
_connections.erase(hdl);
|
||||
_connectionProperties.erase(hdl);
|
||||
locker.unlock();
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
QString WSServer::getRemoteEndpoint(connection_hdl hdl)
|
||||
{
|
||||
auto conn = _server.get_con_from_hdl(hdl);
|
||||
return QString::fromStdString(conn->get_remote_endpoint());
|
||||
}
|
||||
|
||||
void WSServer::notifyConnection(QString clientIp)
|
||||
{
|
||||
obs_frontend_push_ui_translation(obs_module_get_string);
|
||||
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);
|
||||
}
|
||||
|
||||
void WSServer::notifyDisconnection(QString clientIp)
|
||||
{
|
||||
obs_frontend_push_ui_translation(obs_module_get_string);
|
||||
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);
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
obs-websocket
|
||||
Copyright (C) 2016-2017 Stéphane Lepin <stephane.lepin@gmail.com>
|
||||
Copyright (C) 2016-2019 Stéphane Lepin <stephane.lepin@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
|
||||
@ -16,37 +16,60 @@ You should have received a copy of the GNU General Public License along
|
||||
with this program. If not, see <https://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
#ifndef WSSERVER_H
|
||||
#define WSSERVER_H
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QList>
|
||||
#include <QMutex>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QMutex>
|
||||
#include <QtCore/QSharedPointer>
|
||||
#include <QtCore/QVariantHash>
|
||||
#include <QtCore/QThreadPool>
|
||||
|
||||
#include <asio.hpp>
|
||||
#include <websocketpp/config/asio_no_tls.hpp>
|
||||
#include <websocketpp/server.hpp>
|
||||
|
||||
#include "ConnectionProperties.h"
|
||||
#include "WSRequestHandler.h"
|
||||
#include "rpc/RpcEvent.h"
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QWebSocketServer)
|
||||
QT_FORWARD_DECLARE_CLASS(QWebSocket)
|
||||
using websocketpp::connection_hdl;
|
||||
|
||||
class WSServer : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit WSServer(QObject* parent = Q_NULLPTR);
|
||||
virtual ~WSServer();
|
||||
void Start(quint16 port);
|
||||
void Stop();
|
||||
void broadcast(QString message);
|
||||
static WSServer* Instance;
|
||||
typedef websocketpp::server<websocketpp::config::asio> server;
|
||||
|
||||
private slots:
|
||||
void onNewConnection();
|
||||
void onTextMessageReceived(QString message);
|
||||
void onSocketDisconnected();
|
||||
class WSServer : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
QWebSocketServer* _wsServer;
|
||||
QList<QWebSocket*> _clients;
|
||||
QMutex _clMutex;
|
||||
public:
|
||||
explicit WSServer();
|
||||
virtual ~WSServer();
|
||||
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);
|
||||
|
||||
QString getRemoteEndpoint(connection_hdl hdl);
|
||||
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;
|
||||
QThreadPool _threadPool;
|
||||
};
|
||||
|
||||
#endif // WSSERVER_H
|
@ -16,89 +16,121 @@ 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"
|
||||
|
||||
SettingsDialog::SettingsDialog(QWidget* parent) :
|
||||
QDialog(parent, Qt::Dialog),
|
||||
ui(new Ui::SettingsDialog)
|
||||
QDialog(parent, Qt::Dialog),
|
||||
ui(new Ui::SettingsDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->setupUi(this);
|
||||
|
||||
connect(ui->authRequired, &QCheckBox::stateChanged,
|
||||
this, &SettingsDialog::AuthCheckboxChanged);
|
||||
connect(ui->buttonBox, &QDialogButtonBox::accepted,
|
||||
this, &SettingsDialog::FormAccepted);
|
||||
|
||||
|
||||
AuthCheckboxChanged();
|
||||
connect(ui->authRequired, &QCheckBox::stateChanged,
|
||||
this, &SettingsDialog::AuthCheckboxChanged);
|
||||
connect(ui->buttonBox, &QDialogButtonBox::accepted,
|
||||
this, &SettingsDialog::FormAccepted);
|
||||
}
|
||||
|
||||
void SettingsDialog::showEvent(QShowEvent* event) {
|
||||
Config* conf = Config::Current();
|
||||
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->setText(CHANGE_ME);
|
||||
ui->password->setEnabled(ui->authRequired->isChecked());
|
||||
}
|
||||
|
||||
void SettingsDialog::ToggleShowHide() {
|
||||
if (!isVisible())
|
||||
setVisible(true);
|
||||
else
|
||||
setVisible(false);
|
||||
if (!isVisible())
|
||||
setVisible(true);
|
||||
else
|
||||
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())
|
||||
ui->password->setEnabled(true);
|
||||
else
|
||||
ui->password->setEnabled(false);
|
||||
if (ui->authRequired->isChecked()) {
|
||||
ui->password->setEnabled(true);
|
||||
}
|
||||
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() {
|
||||
Config* conf = Config::Current();
|
||||
auto conf = GetConfig();
|
||||
if (!conf) {
|
||||
return;
|
||||
}
|
||||
|
||||
conf->ServerEnabled = ui->serverEnabled->isChecked();
|
||||
conf->ServerPort = ui->serverPort->value();
|
||||
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();
|
||||
conf->DebugEnabled = ui->debugEnabled->isChecked();
|
||||
conf->AlertsEnabled = ui->alertsEnabled->isChecked();
|
||||
|
||||
if (ui->authRequired->isChecked()) {
|
||||
if (ui->password->text() != CHANGE_ME) {
|
||||
conf->SetPassword(ui->password->text());
|
||||
}
|
||||
if (ui->authRequired->isChecked()) {
|
||||
if (ui->password->text() != CHANGE_ME) {
|
||||
conf->SetPassword(ui->password->text());
|
||||
}
|
||||
|
||||
if (!Config::Current()->Secret.isEmpty())
|
||||
conf->AuthRequired = true;
|
||||
else
|
||||
conf->AuthRequired = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
conf->AuthRequired = false;
|
||||
}
|
||||
if (!conf->Secret.isEmpty())
|
||||
conf->AuthRequired = true;
|
||||
else
|
||||
conf->AuthRequired = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
conf->AuthRequired = false;
|
||||
}
|
||||
|
||||
conf->Save();
|
||||
conf->Save();
|
||||
|
||||
if (conf->ServerEnabled)
|
||||
WSServer::Instance->Start(conf->ServerPort);
|
||||
else
|
||||
WSServer::Instance->Stop();
|
||||
auto server = GetServer();
|
||||
if (conf->ServerEnabled) {
|
||||
server->start(conf->ServerPort, conf->LockToIPv4);
|
||||
} else {
|
||||
server->stop();
|
||||
}
|
||||
}
|
||||
|
||||
SettingsDialog::~SettingsDialog() {
|
||||
delete ui;
|
||||
delete ui;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
obs-websocket
|
||||
Copyright (C) 2016-2017 Stéphane Lepin <stephane.lepin@gmail.com>
|
||||
Copyright (C) 2016-2019 Stéphane Lepin <stephane.lepin@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
|
||||
@ -16,29 +16,27 @@ You should have received a copy of the GNU General Public License along
|
||||
with this program. If not, see <https://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
#ifndef SETTINGSDIALOG_H
|
||||
#define SETTINGSDIALOG_H
|
||||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
#include <QtWidgets/QDialog>
|
||||
|
||||
#include "ui_settings-dialog.h"
|
||||
|
||||
class SettingsDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SettingsDialog(QWidget* parent = 0);
|
||||
~SettingsDialog();
|
||||
void showEvent(QShowEvent* event);
|
||||
void ToggleShowHide();
|
||||
explicit SettingsDialog(QWidget* parent = 0);
|
||||
~SettingsDialog();
|
||||
void showEvent(QShowEvent* event);
|
||||
void ToggleShowHide();
|
||||
void PreparePasswordEntry();
|
||||
|
||||
private Q_SLOTS:
|
||||
void AuthCheckboxChanged();
|
||||
void FormAccepted();
|
||||
void AuthCheckboxChanged();
|
||||
void FormAccepted();
|
||||
|
||||
private:
|
||||
Ui::SettingsDialog* ui;
|
||||
Ui::SettingsDialog* ui;
|
||||
};
|
||||
|
||||
#endif // SETTINGSDIALOG_H
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>407</width>
|
||||
<height>195</height>
|
||||
<height>216</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@ -17,7 +17,7 @@
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>OBSWebsocket.Settings.DialogTitle</string>
|
||||
<string>OBSWebsocketCompat.Settings.DialogTitle</string>
|
||||
</property>
|
||||
<property name="sizeGripEnabled">
|
||||
<bool>false</bool>
|
||||
@ -31,14 +31,14 @@
|
||||
<item row="3" column="1">
|
||||
<widget class="QCheckBox" name="authRequired">
|
||||
<property name="text">
|
||||
<string>OBSWebsocket.Settings.AuthRequired</string>
|
||||
<string>OBSWebsocketCompat.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>
|
||||
<string>OBSWebsocketCompat.Settings.Password</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -52,7 +52,7 @@
|
||||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="serverEnabled">
|
||||
<property name="text">
|
||||
<string>OBSWebsocket.Settings.ServerEnable</string>
|
||||
<string>OBSWebsocketCompat.Settings.ServerEnable</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
@ -62,7 +62,7 @@
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lbl_serverPort">
|
||||
<property name="text">
|
||||
<string>OBSWebsocket.Settings.ServerPort</string>
|
||||
<string>OBSWebsocketCompat.Settings.ServerPort</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -79,25 +79,32 @@
|
||||
</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>
|
||||
<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>
|
||||
|
@ -18,9 +18,11 @@ with this program. If not, see <https://www.gnu.org/licenses/>
|
||||
|
||||
#include <obs-module.h>
|
||||
#include <obs-frontend-api.h>
|
||||
#include <QAction>
|
||||
#include <QMainWindow>
|
||||
#include <QTimer>
|
||||
#include <obs-data.h>
|
||||
|
||||
#include <QtCore/QTimer>
|
||||
#include <QtWidgets/QAction>
|
||||
#include <QtWidgets/QMainWindow>
|
||||
|
||||
#include "obs-websocket.h"
|
||||
#include "WSServer.h"
|
||||
@ -28,53 +30,91 @@ 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);
|
||||
}
|
||||
|
||||
OBS_DECLARE_MODULE()
|
||||
OBS_MODULE_USE_DEFAULT_LOCALE("obs-websocket", "en-US")
|
||||
|
||||
SettingsDialog* settings_dialog;
|
||||
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, "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* config = Config::Current();
|
||||
config->Load();
|
||||
// Core setup
|
||||
_config = ConfigPtr(new Config());
|
||||
_config->MigrateFromGlobalSettings(); // TODO remove this on the next minor jump
|
||||
_config->Load();
|
||||
|
||||
WSServer::Instance = new WSServer();
|
||||
WSEvents::Instance = new WSEvents(WSServer::Instance);
|
||||
_server = WSServerPtr(new WSServer());
|
||||
_eventsSystem = WSEventsPtr(new WSEvents(_server));
|
||||
|
||||
if (config->ServerEnabled)
|
||||
WSServer::Instance->Start(config->ServerPort);
|
||||
// UI setup
|
||||
obs_frontend_push_ui_translation(obs_module_get_string);
|
||||
QMainWindow* mainWindow = (QMainWindow*)obs_frontend_get_main_window();
|
||||
settingsDialog = new SettingsDialog(mainWindow);
|
||||
obs_frontend_pop_ui_translation();
|
||||
|
||||
// UI setup
|
||||
QAction* menu_action = (QAction*)obs_frontend_add_tools_menu_qaction(
|
||||
obs_module_text("OBSWebsocket.Menu.SettingsItem"));
|
||||
const char* menuActionText =
|
||||
obs_module_text("OBSWebsocketCompat.Settings.DialogTitle");
|
||||
QAction* menuAction =
|
||||
(QAction*)obs_frontend_add_tools_menu_qaction(menuActionText);
|
||||
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();
|
||||
});
|
||||
|
||||
obs_frontend_push_ui_translation(obs_module_get_string);
|
||||
QMainWindow* main_window = (QMainWindow*)obs_frontend_get_main_window();
|
||||
settings_dialog = new SettingsDialog(main_window);
|
||||
obs_frontend_pop_ui_translation();
|
||||
// Setup event handler to start the server once OBS is ready
|
||||
auto eventCallback = [](enum obs_frontend_event event, void *param) {
|
||||
if (event == OBS_FRONTEND_EVENT_FINISHED_LOADING) {
|
||||
if (_config->ServerEnabled) {
|
||||
_server->start(_config->ServerPort, _config->LockToIPv4);
|
||||
}
|
||||
obs_frontend_remove_event_callback((obs_frontend_event_cb)param, nullptr);
|
||||
}
|
||||
};
|
||||
obs_frontend_add_event_callback(eventCallback, (void*)(obs_frontend_event_cb)eventCallback);
|
||||
|
||||
auto menu_cb = [] {
|
||||
settings_dialog->ToggleShowHide();
|
||||
};
|
||||
menu_action->connect(menu_action, &QAction::triggered, menu_cb);
|
||||
// Loading finished
|
||||
blog(LOG_INFO, "module loaded!");
|
||||
|
||||
// Loading finished
|
||||
blog(LOG_INFO, "module loaded!");
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void obs_module_unload() {
|
||||
blog(LOG_INFO, "goodbye!");
|
||||
_server->stop();
|
||||
|
||||
_eventsSystem.reset();
|
||||
_server.reset();
|
||||
_config.reset();
|
||||
|
||||
blog(LOG_INFO, "goodbye!");
|
||||
}
|
||||
|
||||
ConfigPtr GetConfig() {
|
||||
return _config;
|
||||
}
|
||||
|
||||
WSServerPtr GetServer() {
|
||||
return _server;
|
||||
}
|
||||
|
||||
WSEventsPtr GetEventsSystem() {
|
||||
return _eventsSystem;
|
||||
}
|
||||
|
||||
void ShowPasswordSetting() {
|
||||
if (settingsDialog) {
|
||||
settingsDialog->PreparePasswordEntry();
|
||||
settingsDialog->setVisible(true);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
obs-websocket
|
||||
Copyright (C) 2016-2017 Stéphane Lepin <stephane.lepin@gmail.com>
|
||||
Copyright (C) 2016-2019 Stéphane Lepin <stephane.lepin@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
|
||||
@ -16,31 +16,30 @@ You should have received a copy of the GNU General Public License along
|
||||
with this program. If not, see <https://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
#ifndef OBSWEBSOCKET_H
|
||||
#define OBSWEBSOCKET_H
|
||||
#pragma once
|
||||
|
||||
#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*);
|
||||
void ___data_item_dummy_addref(obs_data_item_t*);
|
||||
void ___data_item_release(obs_data_item_t*);
|
||||
using OBSDataItemAutoRelease =
|
||||
OBSRef<obs_data_item_t*, ___data_item_dummy_addref, ___data_item_release>;
|
||||
|
||||
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>;
|
||||
class Config;
|
||||
typedef std::shared_ptr<Config> ConfigPtr;
|
||||
|
||||
#define PROP_AUTHENTICATED "wsclient_authenticated"
|
||||
#define OBS_WEBSOCKET_VERSION "4.3.3"
|
||||
class WSServer;
|
||||
typedef std::shared_ptr<WSServer> WSServerPtr;
|
||||
|
||||
#define blog(level, msg, ...) blog(level, "[obs-websocket] " msg, ##__VA_ARGS__)
|
||||
class WSEvents;
|
||||
typedef std::shared_ptr<WSEvents> WSEventsPtr;
|
||||
|
||||
#endif // OBSWEBSOCKET_H
|
||||
ConfigPtr GetConfig();
|
||||
WSServerPtr GetServer();
|
||||
WSEventsPtr GetEventsSystem();
|
||||
void ShowPasswordSetting();
|
||||
|
||||
#define OBS_WEBSOCKET_VERSION "4.9.1-compat"
|
||||
|
||||
#define blog(level, msg, ...) blog(level, "[obs-websocket 4.9.1-compat] " msg, ##__VA_ARGS__)
|
||||
|
31
src/plugin-macros.generated.h
Normal file
31
src/plugin-macros.generated.h
Normal 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()
|
139
src/protocol/OBSRemoteProtocol.cpp
Normal file
139
src/protocol/OBSRemoteProtocol.cpp
Normal file
@ -0,0 +1,139 @@
|
||||
/*
|
||||
obs-websocket
|
||||
Copyright (C) 2016-2019 Stéphane Lepin <stephane.lepin@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/>
|
||||
*/
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "OBSRemoteProtocol.h"
|
||||
#include "../WSRequestHandler.h"
|
||||
#include "../rpc/RpcEvent.h"
|
||||
#include "../Utils.h"
|
||||
|
||||
std::string OBSRemoteProtocol::processMessage(WSRequestHandler& requestHandler, std::string message)
|
||||
{
|
||||
std::string msgContainer(message);
|
||||
const char* msg = msgContainer.c_str();
|
||||
|
||||
OBSDataAutoRelease data = obs_data_create_from_json(msg);
|
||||
if (!data) {
|
||||
blog(LOG_ERROR, "invalid JSON payload received for '%s'", msg);
|
||||
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 jsonDataToString(
|
||||
errorResponse(nullptr, "missing request parameters")
|
||||
);
|
||||
}
|
||||
|
||||
QString methodName = obs_data_get_string(data, "request-type");
|
||||
QString messageId = obs_data_get_string(data, "message-id");
|
||||
|
||||
OBSDataAutoRelease params = obs_data_create();
|
||||
obs_data_apply(params, data);
|
||||
obs_data_unset_user_value(params, "request-type");
|
||||
obs_data_unset_user_value(params, "message-id");
|
||||
|
||||
RpcRequest request(messageId, methodName, params);
|
||||
RpcResponse response = requestHandler.processRequest(request);
|
||||
|
||||
OBSDataAutoRelease responseData = rpcResponseToJsonData(response);
|
||||
return jsonDataToString(responseData);
|
||||
}
|
||||
|
||||
std::string OBSRemoteProtocol::encodeEvent(const RpcEvent& event)
|
||||
{
|
||||
OBSDataAutoRelease eventData = obs_data_create();
|
||||
|
||||
QString updateType = event.updateType();
|
||||
obs_data_set_string(eventData, "update-type", updateType.toUtf8().constData());
|
||||
|
||||
auto streamTime = event.streamTime();
|
||||
if (streamTime) {
|
||||
QString streamingTimecode = Utils::nsToTimestamp(streamTime);
|
||||
obs_data_set_string(eventData, "stream-timecode", streamingTimecode.toUtf8().constData());
|
||||
}
|
||||
|
||||
auto recordingTime = event.recordingTime();
|
||||
if (recordingTime) {
|
||||
QString recordingTimecode = Utils::nsToTimestamp(recordingTime);
|
||||
obs_data_set_string(eventData, "rec-timecode", recordingTimecode.toUtf8().constData());
|
||||
}
|
||||
|
||||
OBSData additionalFields = event.additionalFields();
|
||||
if (additionalFields) {
|
||||
obs_data_apply(eventData, additionalFields);
|
||||
}
|
||||
|
||||
return std::string(obs_data_get_json(eventData));
|
||||
}
|
||||
|
||||
obs_data_t* OBSRemoteProtocol::rpcResponseToJsonData(const RpcResponse& response)
|
||||
{
|
||||
QByteArray messageIdBytes = response.messageId().toUtf8();
|
||||
const char* messageId = messageIdBytes.constData();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
obs_data_t* OBSRemoteProtocol::successResponse(const char* messageId, obs_data_t* fields)
|
||||
{
|
||||
return buildResponse(messageId, "ok", fields);
|
||||
}
|
||||
|
||||
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);
|
||||
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;
|
||||
}
|
41
src/protocol/OBSRemoteProtocol.h
Normal file
41
src/protocol/OBSRemoteProtocol.h
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
obs-websocket
|
||||
Copyright (C) 2016-2019 Stéphane Lepin <stephane.lepin@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 <string>
|
||||
#include <obs-data.h>
|
||||
|
||||
#include "../rpc/RpcResponse.h"
|
||||
|
||||
class WSRequestHandler;
|
||||
class RpcEvent;
|
||||
|
||||
class OBSRemoteProtocol
|
||||
{
|
||||
public:
|
||||
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:
|
||||
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);
|
||||
};
|
35
src/rpc/RpcEvent.cpp
Normal file
35
src/rpc/RpcEvent.cpp
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
obs-websocket
|
||||
Copyright (C) 2016-2020 Stéphane Lepin <stephane.lepin@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/>
|
||||
*/
|
||||
|
||||
#include "RpcEvent.h"
|
||||
|
||||
RpcEvent::RpcEvent(
|
||||
const QString& updateType,
|
||||
uint64_t streamTime, uint64_t recordingTime,
|
||||
obs_data_t* additionalFields
|
||||
) :
|
||||
_updateType(updateType),
|
||||
_streamTime(streamTime),
|
||||
_recordingTime(recordingTime),
|
||||
_additionalFields(nullptr)
|
||||
{
|
||||
if (additionalFields) {
|
||||
_additionalFields = obs_data_create();
|
||||
obs_data_apply(_additionalFields, additionalFields);
|
||||
}
|
||||
}
|
60
src/rpc/RpcEvent.h
Normal file
60
src/rpc/RpcEvent.h
Normal file
@ -0,0 +1,60 @@
|
||||
/*
|
||||
obs-websocket
|
||||
Copyright (C) 2016-2020 Stéphane Lepin <stephane.lepin@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 <obs-data.h>
|
||||
#include <QtCore/QString>
|
||||
|
||||
#include "../obs-websocket.h"
|
||||
|
||||
class RpcEvent
|
||||
{
|
||||
public:
|
||||
explicit RpcEvent(
|
||||
const QString& updateType,
|
||||
uint64_t streamTime, uint64_t recordingTime,
|
||||
obs_data_t* additionalFields = nullptr
|
||||
);
|
||||
|
||||
const QString& updateType() const
|
||||
{
|
||||
return _updateType;
|
||||
}
|
||||
|
||||
const uint64_t streamTime() const
|
||||
{
|
||||
return _streamTime;
|
||||
}
|
||||
|
||||
const uint64_t recordingTime() const
|
||||
{
|
||||
return _recordingTime;
|
||||
}
|
||||
|
||||
const OBSData additionalFields() const
|
||||
{
|
||||
return OBSData(_additionalFields);
|
||||
}
|
||||
|
||||
private:
|
||||
QString _updateType;
|
||||
uint64_t _streamTime;
|
||||
uint64_t _recordingTime;
|
||||
OBSDataAutoRelease _additionalFields;
|
||||
};
|
104
src/rpc/RpcRequest.cpp
Normal file
104
src/rpc/RpcRequest.cpp
Normal file
@ -0,0 +1,104 @@
|
||||
/*
|
||||
obs-websocket
|
||||
Copyright (C) 2016-2019 Stéphane Lepin <stephane.lepin@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/>
|
||||
*/
|
||||
|
||||
#include "RpcRequest.h"
|
||||
#include "RpcResponse.h"
|
||||
|
||||
RpcRequest::RpcRequest(const QString& messageId, const QString& methodName, obs_data_t* params) :
|
||||
_messageId(messageId),
|
||||
_methodName(methodName),
|
||||
_parameters(nullptr)
|
||||
{
|
||||
if (params) {
|
||||
_parameters = obs_data_create();
|
||||
obs_data_apply(_parameters, params);
|
||||
}
|
||||
}
|
||||
|
||||
const RpcResponse RpcRequest::success(obs_data_t* additionalFields) const
|
||||
{
|
||||
return RpcResponse::ok(*this, additionalFields);
|
||||
}
|
||||
|
||||
const RpcResponse RpcRequest::failed(const QString& errorMessage, obs_data_t* additionalFields) const
|
||||
{
|
||||
return RpcResponse::fail(*this, errorMessage, additionalFields);
|
||||
}
|
||||
|
||||
const bool RpcRequest::hasField(QString name, obs_data_type expectedFieldType, obs_data_number_type expectedNumberType) const
|
||||
{
|
||||
if (!_parameters || name.isEmpty() || name.isNull()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
OBSDataItemAutoRelease dataItem = obs_data_item_byname(_parameters, name.toUtf8());
|
||||
if (!dataItem) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (expectedFieldType != OBS_DATA_NULL) {
|
||||
obs_data_type fieldType = obs_data_item_gettype(dataItem);
|
||||
if (fieldType != expectedFieldType) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (fieldType == OBS_DATA_NUMBER && expectedNumberType != OBS_DATA_NUM_INVALID) {
|
||||
obs_data_number_type numberType = obs_data_item_numtype(dataItem);
|
||||
if (numberType != expectedNumberType) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
const bool RpcRequest::hasBool(QString fieldName) const
|
||||
{
|
||||
return this->hasField(fieldName, OBS_DATA_BOOLEAN);
|
||||
}
|
||||
|
||||
const bool RpcRequest::hasString(QString fieldName) const
|
||||
{
|
||||
return this->hasField(fieldName, OBS_DATA_STRING);
|
||||
}
|
||||
|
||||
const bool RpcRequest::hasNumber(QString fieldName, obs_data_number_type expectedNumberType) const
|
||||
{
|
||||
return this->hasField(fieldName, OBS_DATA_NUMBER, expectedNumberType);
|
||||
}
|
||||
|
||||
const bool RpcRequest::hasInteger(QString fieldName) const
|
||||
{
|
||||
return this->hasNumber(fieldName, OBS_DATA_NUM_INT);
|
||||
}
|
||||
|
||||
const bool RpcRequest::hasDouble(QString fieldName) const
|
||||
{
|
||||
return this->hasNumber(fieldName, OBS_DATA_NUM_DOUBLE);
|
||||
}
|
||||
|
||||
const bool RpcRequest::hasArray(QString fieldName) const
|
||||
{
|
||||
return this->hasField(fieldName, OBS_DATA_ARRAY);
|
||||
}
|
||||
|
||||
const bool RpcRequest::hasObject(QString fieldName) const
|
||||
{
|
||||
return this->hasField(fieldName, OBS_DATA_OBJECT);
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user