Compare commits
877 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ba75777c0d | ||
|
|
92c0b4493a | ||
|
|
803231c558 | ||
|
|
120909f8d6 | ||
|
|
f0f23cbd0b | ||
|
|
939a35ee97 | ||
|
|
18e1785e57 | ||
|
|
bef2709834 | ||
|
|
c063e2fc30 | ||
|
|
6e62ce15b5 | ||
|
|
19221e1fcc | ||
|
|
c25d6cb551 | ||
|
|
86920a3083 | ||
|
|
68c39290ec | ||
|
|
563f56d2a2 | ||
|
|
4174333b40 | ||
|
|
a74445f9e4 | ||
|
|
859d8cc86c | ||
|
|
d8d2f1c801 | ||
|
|
85308462eb | ||
|
|
d84f8b14c4 | ||
|
|
0f4889923d | ||
|
|
2093816f2d | ||
|
|
7de751f882 | ||
|
|
6da476aebb | ||
|
|
7140d25a87 | ||
|
|
cb413a99f0 | ||
|
|
e6d21518d2 | ||
|
|
19e647ae84 | ||
|
|
494f5c71bb | ||
|
|
c4ad80f3b9 | ||
|
|
460fa6c8e6 | ||
|
|
5a62ffe178 | ||
|
|
c867d7bdf2 | ||
|
|
167cf7c659 | ||
|
|
73a3ec3f63 | ||
|
|
f8981248dc | ||
|
|
b90b2469b5 | ||
|
|
2de9ca144d | ||
|
|
f1a89a1c55 | ||
|
|
3909aa4ab7 | ||
|
|
10e95f5388 | ||
|
|
21bb2af7ea | ||
|
|
9b7b4071bf | ||
|
|
2ec267fc4f | ||
|
|
e6b954e9e8 | ||
|
|
b2ce0f3934 | ||
|
|
01d3a91e40 | ||
|
|
cf0b87298d | ||
|
|
02c69c1686 | ||
|
|
9a53ffa6d0 | ||
|
|
d22e23937f | ||
|
|
7b820e10e0 | ||
|
|
d795fee579 | ||
|
|
80418162d4 | ||
|
|
32c83a6eee | ||
|
|
d0b8cf0275 | ||
|
|
74fa6da8c2 | ||
|
|
f199f96f7b | ||
|
|
bfc13549e9 | ||
|
|
7660b07fa8 | ||
|
|
b72054c2f7 | ||
|
|
9dcbc38231 | ||
|
|
dbb50cf580 | ||
|
|
da0782d036 | ||
|
|
778801992d | ||
|
|
f410ff0ed2 | ||
|
|
23685253a8 | ||
|
|
21ad2cab07 | ||
|
|
c5a14422ee | ||
|
|
c12deb4b56 | ||
|
|
792d98dfd5 | ||
|
|
12aa3b19d5 | ||
|
|
4b3f782ece | ||
|
|
0016a41474 | ||
|
|
e115981b9f | ||
|
|
94fbe58fb7 | ||
|
|
90962d0391 | ||
|
|
7092de8809 | ||
|
|
81a0a724ab | ||
|
|
34297feed4 | ||
|
|
4407f8ac68 | ||
|
|
3de691fa0d | ||
|
|
e7f388999d | ||
|
|
8d66913a8e | ||
|
|
b30b5b6474 | ||
|
|
19b8412d67 | ||
|
|
24d2555c5e | ||
|
|
322564bc42 | ||
|
|
12bff7aa9e | ||
|
|
d87a84db85 | ||
|
|
b38017eb1c | ||
|
|
2d99870ec2 | ||
|
|
6f7a4aa234 | ||
|
|
49add7e0f8 | ||
|
|
c2708078db | ||
|
|
a46e68f145 | ||
|
|
a4f8d46d69 | ||
|
|
94d6bc4bca | ||
|
|
ec78631691 | ||
|
|
cd8f9792ab | ||
|
|
fd9c868c40 | ||
|
|
6282500305 | ||
|
|
7b5bc6d236 | ||
|
|
3e45ec7353 | ||
|
|
5051f4e38c | ||
|
|
5532e3349a | ||
|
|
4ea7a09583 | ||
|
|
affba5a29f | ||
|
|
d486055fc8 | ||
|
|
52b7cd68c1 | ||
|
|
afdf4bf108 | ||
|
|
a33dbac984 | ||
|
|
ff48107b1a | ||
|
|
3afaaed1fb | ||
|
|
7ca6299fba | ||
|
|
cba7f5b801 | ||
|
|
d75ed8aeee | ||
|
|
b9b2984235 | ||
|
|
c2b7892e6c | ||
|
|
6ce07c0a4b | ||
|
|
008e217a79 | ||
|
|
5847e52fbc | ||
|
|
e9baa25b46 | ||
|
|
b6213e1ed8 | ||
|
|
59ac3a0bb8 | ||
|
|
9b63972878 | ||
|
|
4955e24f12 | ||
|
|
16fb654b98 | ||
|
|
eda88b3078 | ||
|
|
2435277e49 | ||
|
|
7caded7c95 | ||
|
|
df6cdf9a80 | ||
|
|
25be63ef2c | ||
|
|
b0a042369f | ||
|
|
d8d68dcf71 | ||
|
|
133fb661b3 | ||
|
|
d5f2b375a6 | ||
|
|
f280d3b64c | ||
|
|
e20261fa66 | ||
|
|
b6a41d417d | ||
|
|
80f3052c2b | ||
|
|
62060e0c04 | ||
|
|
f3f7c57f10 | ||
|
|
82d61909f6 | ||
|
|
03c68d1dc3 | ||
|
|
05f593e40c | ||
|
|
5719c6cfc2 | ||
|
|
1ba8ff06e1 | ||
|
|
fae5d09001 | ||
|
|
3eecb412c6 | ||
|
|
b022be49a1 | ||
|
|
7238eccfd2 | ||
|
|
e3b8ccff9e | ||
|
|
c1aa3c9d4d | ||
|
|
00345c94a3 | ||
|
|
20001e6a26 | ||
|
|
c06fdc7760 | ||
|
|
8e28eba959 | ||
|
|
47ff1a2dd8 | ||
|
|
00ff0f532f | ||
|
|
2e0732c75b | ||
|
|
842247de54 | ||
|
|
52840ce8ae | ||
|
|
f640d2574b | ||
|
|
8598aad9e2 | ||
|
|
5dc82aadc7 | ||
|
|
2f8411a658 | ||
|
|
fcce9b62d5 | ||
|
|
5a077d2f52 | ||
|
|
36f8ea8df0 | ||
|
|
fe623d93a1 | ||
|
|
d41b8a7c24 | ||
|
|
f016a82a32 | ||
|
|
d872aa4a6c | ||
|
|
2c7262ced4 | ||
|
|
01e21ea212 | ||
|
|
0eae04ab83 | ||
|
|
e42afcb434 | ||
|
|
fad4be419a | ||
|
|
9768d17b9b | ||
|
|
e36bae2ab6 | ||
|
|
f8b5b1db9c | ||
|
|
9ccf1a31bc | ||
|
|
36d23b5dc2 | ||
|
|
9d27335d7d | ||
|
|
a913cee7a4 | ||
|
|
eeeba3d2b7 | ||
|
|
b8a56776da | ||
|
|
0e9fe58c06 | ||
|
|
6cf7635005 | ||
|
|
6c7ea3a16d | ||
|
|
4ded0d03d0 | ||
|
|
ac45ad740d | ||
|
|
f010c840e6 | ||
|
|
90b59908c6 | ||
|
|
13c6693cdd | ||
|
|
cd56c960a6 | ||
|
|
a51423a4d6 | ||
|
|
80a25ec71c | ||
|
|
51209179d1 | ||
|
|
b3937caa10 | ||
|
|
8927ba7c73 | ||
|
|
5f4c867618 | ||
|
|
fced4178be | ||
|
|
da0944c814 | ||
|
|
7aa14219b8 | ||
|
|
09a3494183 | ||
|
|
8924d81e0a | ||
|
|
b599fbf88d | ||
|
|
578a72f560 | ||
|
|
6b1e298d43 | ||
|
|
698665c4cc | ||
|
|
caa3e4d07a | ||
|
|
7606baa20b | ||
|
|
fde6be3f97 | ||
|
|
abdc70121d | ||
|
|
879a0524fc | ||
|
|
a529b34f99 | ||
|
|
e8daeb5f30 | ||
|
|
f610e8ba1e | ||
|
|
b3245c967b | ||
|
|
0af9da2214 | ||
|
|
db68f80048 | ||
|
|
b0efd80e42 | ||
|
|
3e12e0b84d | ||
|
|
5465a45dc6 | ||
|
|
53bd7d6ae2 | ||
|
|
d66751b6ac | ||
|
|
95de6d0afc | ||
|
|
147daa7681 | ||
|
|
ece925858a | ||
|
|
657b05d077 | ||
|
|
cf3bceeb46 | ||
|
|
6735e5eaaa | ||
|
|
7b9e71df40 | ||
|
|
fae61f3d87 | ||
|
|
a57419150e | ||
|
|
378257b7bf | ||
|
|
885b92a0a1 | ||
|
|
58371c36d3 | ||
|
|
d39064b209 | ||
|
|
f497da7967 | ||
|
|
03931cb232 | ||
|
|
4eeb02d9d4 | ||
|
|
8ff5ae3555 | ||
|
|
053a5e9dbe | ||
|
|
5a1a88bf33 | ||
|
|
f19b18d806 | ||
|
|
f6e4701d6b | ||
|
|
c3d686e472 | ||
|
|
6c7ff870e8 | ||
|
|
38bac83ddd | ||
|
|
4d8c77cf3e | ||
|
|
0a147697d2 | ||
|
|
21837e7464 | ||
|
|
d747962e24 | ||
|
|
49f09d1b3a | ||
|
|
783d6e69b1 | ||
|
|
6452ff78c0 | ||
|
|
a430d39849 | ||
|
|
33c222555f | ||
|
|
00f7e0fe62 | ||
|
|
44a31ede74 | ||
|
|
fb3ee2aa8c | ||
|
|
58e5dd9186 | ||
|
|
27ec46c64e | ||
|
|
12a5d777e5 | ||
|
|
276a94f9e8 | ||
|
|
ccc3c86900 | ||
|
|
124415363f | ||
|
|
de850b39f2 | ||
|
|
379f73b6ca | ||
|
|
159b778fa9 | ||
|
|
007f7a0ce1 | ||
|
|
54fa642693 | ||
|
|
2fbc6f9193 | ||
|
|
262c6fd8ab | ||
|
|
7fcb53c7d0 | ||
|
|
d0e1101bfb | ||
|
|
a8bb4ae6d1 | ||
|
|
d743307e59 | ||
|
|
e92e9eb45c | ||
|
|
aaefa356ae | ||
|
|
3a7da2bc98 | ||
|
|
94b211e3b7 | ||
|
|
9ff5b90605 | ||
|
|
a033b74f7f | ||
|
|
bb4e81b00a | ||
|
|
5f2e0b79cd | ||
|
|
64a7fef7c1 | ||
|
|
09dbc5c84e | ||
|
|
e71e0791bc | ||
|
|
2a4be39c9a | ||
|
|
3cde191afb | ||
|
|
02a8d9a243 | ||
|
|
7f4e313a78 | ||
|
|
44e3d90dcb | ||
|
|
945eb3ccc6 | ||
|
|
793008852a | ||
|
|
7e791ee5e4 | ||
|
|
1413490579 | ||
|
|
57154e5d0b | ||
|
|
57a1556e23 | ||
|
|
e248e92ca1 | ||
|
|
fa5adcf08b | ||
|
|
87a51afd99 | ||
|
|
4efaa1f350 | ||
|
|
1d329600af | ||
|
|
c2a0e51984 | ||
|
|
ebd59e38ce | ||
|
|
f75b384c17 | ||
|
|
5419622c74 | ||
|
|
ab40011954 | ||
|
|
1b658e9b40 | ||
|
|
49605f9c23 | ||
|
|
d9b6b808f7 | ||
|
|
1607dd329d | ||
|
|
74337b2699 | ||
|
|
d6a684bbe7 | ||
|
|
feeb997f62 | ||
|
|
26da3bf9a8 | ||
|
|
82046afd9f | ||
|
|
97704deea0 | ||
|
|
64b2a18ff3 | ||
|
|
cf16edceec | ||
|
|
f6008737d1 | ||
|
|
61de8c4717 | ||
|
|
83ad83e656 | ||
|
|
2afb13c580 | ||
|
|
e48a963503 | ||
|
|
c846a0626f | ||
|
|
a6b1d09ff1 | ||
|
|
3603e146cc | ||
|
|
9ab597c0e9 | ||
|
|
3251e9f845 | ||
|
|
3e7b24a3de | ||
|
|
6989cd4d40 | ||
|
|
c7205a512e | ||
|
|
c0befa0f49 | ||
|
|
2223024383 | ||
|
|
216d9a1686 | ||
|
|
1f9bff6182 | ||
|
|
0f7d42ab83 | ||
|
|
60334f24f1 | ||
|
|
d7d099d2d7 | ||
|
|
514d4170be | ||
|
|
6b1c1853b8 | ||
|
|
ced318637f | ||
|
|
c2c7c37ef6 | ||
|
|
7e5041eac5 | ||
|
|
4b7db87444 | ||
|
|
22aba74ed9 | ||
|
|
5283dd2f9e | ||
|
|
8bc69ba0a4 | ||
|
|
90207c6184 | ||
|
|
678590fc4f | ||
|
|
9170aba906 | ||
|
|
59a92bb172 | ||
|
|
f12cf8a6ce | ||
|
|
26cb75f93f | ||
|
|
e8b05cd7c2 | ||
|
|
4930c07e9c | ||
|
|
39d4002491 | ||
|
|
e095b139ae | ||
|
|
088cf97ebf | ||
|
|
be90b30b8f | ||
|
|
0ff3041e89 | ||
|
|
9d2c2c0e47 | ||
|
|
b35f2b7cb4 | ||
|
|
1988c5fe9a | ||
|
|
aad99ce3a4 | ||
|
|
1d7209693a | ||
|
|
4017732d71 | ||
|
|
c09f2a1121 | ||
|
|
9467a0700a | ||
|
|
ef74faeef4 | ||
|
|
2891ad7efe | ||
|
|
364ffc4659 | ||
|
|
8aa82274ff | ||
|
|
71ca037ca8 | ||
|
|
341aac8ff7 | ||
|
|
99ccfb8e94 | ||
|
|
4ed884de55 | ||
|
|
f9caa75aa7 | ||
|
|
37a7bc43fd | ||
|
|
cdd6ac1d8b | ||
|
|
235e0efc09 | ||
|
|
2f4f93d3ba | ||
|
|
f25a1b70f3 | ||
|
|
6ec8edd5e2 | ||
|
|
8beeced7c2 | ||
|
|
f4add84a13 | ||
|
|
c507d0ed7e | ||
|
|
3ff193f42d | ||
|
|
8104050658 | ||
|
|
b53f0b4c1b | ||
|
|
7698c05dd5 | ||
|
|
18734345a1 | ||
|
|
ad54ee4bda | ||
|
|
f8a4b7b1db | ||
|
|
e6966df9ac | ||
|
|
8e17fc0edb | ||
|
|
2cdb8c022d | ||
|
|
04822346a6 | ||
|
|
6fcfc2da34 | ||
|
|
62c7b8cdc1 | ||
|
|
d2d899a8d0 | ||
|
|
921e09227f | ||
|
|
39c274a515 | ||
|
|
5db65b6e6e | ||
|
|
c71fc5575f | ||
|
|
2ebf264feb | ||
|
|
aa20cf5138 | ||
|
|
5f96a8991a | ||
|
|
47e0d6ae19 | ||
|
|
e3e2d8d2f6 | ||
|
|
f57e057f2a | ||
|
|
dc0df8cc61 | ||
|
|
c30d7a2089 | ||
|
|
03bffb3319 | ||
|
|
65dc93ed37 | ||
|
|
8ed04b9c6e | ||
|
|
e6a9327bae | ||
|
|
658c506653 | ||
|
|
ad4a4281b4 | ||
|
|
6b0070ec56 | ||
|
|
c9cf6baf4b | ||
|
|
85a25a0a39 | ||
|
|
e192d254f9 | ||
|
|
9e2b9d7cf4 | ||
|
|
cd545213e4 | ||
|
|
935d2ff02c | ||
|
|
b7d6218b89 | ||
|
|
d86754b0e6 | ||
|
|
b97674a404 | ||
|
|
f91522fc14 | ||
|
|
9b4ef00278 | ||
|
|
43270c7763 | ||
|
|
9a98fb399c | ||
|
|
c255b0249f | ||
|
|
b0e71f6f18 | ||
|
|
7e59377daf | ||
|
|
73aa369e6d | ||
|
|
731d7e5d6b | ||
|
|
bc5e1c7df9 | ||
|
|
1a15f9b581 | ||
|
|
136d6052d8 | ||
|
|
811b270bae | ||
|
|
7870e3cfce | ||
|
|
4874af1d5a | ||
|
|
1b7ead0479 | ||
|
|
ac97984314 | ||
|
|
8c778e8afb | ||
|
|
2b6bbce1d9 | ||
|
|
b8e0a9c1dd | ||
|
|
4c3c3de065 | ||
|
|
a74801a0af | ||
|
|
cbe8217790 | ||
|
|
e1cdf34955 | ||
|
|
fefc20c52a | ||
|
|
ad1e574cfe | ||
|
|
c25d4b7dad | ||
|
|
207aa88daf | ||
|
|
3be08a3e63 | ||
|
|
7d91ffbafa | ||
|
|
128ba084ad | ||
|
|
0defff8f7c | ||
|
|
6e3497e4c4 | ||
|
|
1c309b2c89 | ||
|
|
35507e7fbb | ||
|
|
bc439829cf | ||
|
|
93f433f388 | ||
|
|
f9e99e2a33 | ||
|
|
94dcf7c3f3 | ||
|
|
c3bb29182e | ||
|
|
b11f6d5b3b | ||
|
|
d2b900f7c3 | ||
|
|
bf2b5d8882 | ||
|
|
e7878bdb8f | ||
|
|
0670550521 | ||
|
|
f5df923c51 | ||
|
|
f1f62816b5 | ||
|
|
db462690b3 | ||
|
|
c28685c700 | ||
|
|
1f1780597c | ||
|
|
1590251dad | ||
|
|
d25c17342b | ||
|
|
e105022185 | ||
|
|
16931917b7 | ||
|
|
e2e316a079 | ||
|
|
1dd2151a20 | ||
|
|
c7367ad46a | ||
|
|
21045411e7 | ||
|
|
128e8834e8 | ||
|
|
7433772606 | ||
|
|
8967f5f090 | ||
|
|
3b51a6e2a9 | ||
|
|
c5cb635b4e | ||
|
|
1e9f8d707e | ||
|
|
69a0aa4bd8 | ||
|
|
581fa88055 | ||
|
|
f991ae5aed | ||
|
|
44825ece04 | ||
|
|
eac2c5c020 | ||
|
|
a593e97227 | ||
|
|
ecad786f50 | ||
|
|
9012d33c05 | ||
|
|
268751815f | ||
|
|
6529b170e6 | ||
|
|
5ce465cb30 | ||
|
|
48f1df2fd6 | ||
|
|
3e6ddf560a | ||
|
|
0051533ac8 | ||
|
|
e69ac7ca28 | ||
|
|
9c8abb8edf | ||
|
|
9ee434f275 | ||
|
|
4826d9fbf0 | ||
|
|
3fd7b8ed3c | ||
|
|
ebc8d483d9 | ||
|
|
9821d3595a | ||
|
|
f21be9d10c | ||
|
|
d221036cde | ||
|
|
1dbff48ebb | ||
|
|
43e56fc433 | ||
|
|
b3b562f4bb | ||
|
|
784ac996d3 | ||
|
|
fb6a95078d | ||
|
|
189e7b8bc9 | ||
|
|
55967ad27c | ||
|
|
e2c82af4d6 | ||
|
|
8712923bec | ||
|
|
416635179b | ||
|
|
c1b635e036 | ||
|
|
2860d8f1de | ||
|
|
c1fb07b4c7 | ||
|
|
5036c2231c | ||
|
|
c848666e17 | ||
|
|
55aef98a30 | ||
|
|
7cbbf799dc | ||
|
|
30a4e0297c | ||
|
|
5f68f51693 | ||
|
|
8e6aaf29e0 | ||
|
|
cde0e74a2e | ||
|
|
2a573cbab3 | ||
|
|
941275a1b9 | ||
|
|
c5884ec498 | ||
|
|
da06cf52ec | ||
|
|
07e8f489c1 | ||
|
|
baed2ac031 | ||
|
|
cdab138b2f | ||
|
|
06524edfb3 | ||
|
|
0e40550427 | ||
|
|
e08b6ade9e | ||
|
|
36bc4944f9 | ||
|
|
a0be95d634 | ||
|
|
faf8d4c4ad | ||
|
|
8af740caa8 | ||
|
|
69fa3521f9 | ||
|
|
991a96d3dc | ||
|
|
b10bf06305 | ||
|
|
7f54b30fbe | ||
|
|
ee79043536 | ||
|
|
c9e6611b92 | ||
|
|
73d128d89a | ||
|
|
5a240acd86 | ||
|
|
7dc4a5cf87 | ||
|
|
6d835297b2 | ||
|
|
b44c29e235 | ||
|
|
8da9a9cf27 | ||
|
|
a3617626f7 | ||
|
|
e44832ea9e | ||
|
|
f841e78dcf | ||
|
|
e7a8d48cca | ||
|
|
69e8d0e32f | ||
|
|
830d1a6bf9 | ||
|
|
e9b72b442a | ||
|
|
77ac7eca18 | ||
|
|
86d4198ffd | ||
|
|
37dfe31ac2 | ||
|
|
584e1c48e6 | ||
|
|
15766ceb97 | ||
|
|
6e79f28b69 | ||
|
|
e9632d206b | ||
|
|
a0f55bfcb5 | ||
|
|
3c32f1da6e | ||
|
|
7e13c1b22a | ||
|
|
2fc52e673f | ||
|
|
48001a660b | ||
|
|
5a6daf79b6 | ||
|
|
ae4fd9f7df | ||
|
|
7dfa8776fd | ||
|
|
a836796fcc | ||
|
|
fb131972d4 | ||
|
|
140ce358fa | ||
|
|
dd92f2dccb | ||
|
|
d62004eadf | ||
|
|
abc21e9692 | ||
|
|
a13b0d5d91 | ||
|
|
12f8c75c2d | ||
|
|
bdc1920166 | ||
|
|
8cb0d57ffe | ||
|
|
7344689263 | ||
|
|
f521ca1118 | ||
|
|
6712f1383e | ||
|
|
d756fd4a29 | ||
|
|
e070ef1b7f | ||
|
|
ea7786a002 | ||
|
|
3eec07fac1 | ||
|
|
46afa76af8 | ||
|
|
6cc1ba64d8 | ||
|
|
225596481f | ||
|
|
4ef3b3b332 | ||
|
|
e7ac768b5b | ||
|
|
b1e8833daa | ||
|
|
155d71dc80 | ||
|
|
94ebf17134 | ||
|
|
d6fe2edf0d | ||
|
|
867cd7e583 | ||
|
|
1a2471a32d | ||
|
|
057dd9c01d | ||
|
|
5a2c0e15e9 | ||
|
|
ae5ae24f6f | ||
|
|
7a2f3fe840 | ||
|
|
b46788c81a | ||
|
|
3c1f37e5f9 | ||
|
|
d8d4322b2e | ||
|
|
1613e9ce46 | ||
|
|
aee3c8db1b | ||
|
|
becaeedff1 | ||
|
|
c9c6651368 | ||
|
|
d77371912b | ||
|
|
93cb12be89 | ||
|
|
4ac2bd8e92 | ||
|
|
34d52c975e | ||
|
|
85194c7f4f | ||
|
|
af009e03a0 | ||
|
|
cef7379c07 | ||
|
|
f1e75d8593 | ||
|
|
c5a194e98c | ||
|
|
7858033628 | ||
|
|
f2405e02f6 | ||
|
|
452221daa5 | ||
|
|
91f551c2d8 | ||
|
|
2ca1763280 | ||
|
|
da4a8333f7 | ||
|
|
c0b08f3219 | ||
|
|
c273e9125c | ||
|
|
7244b95844 | ||
|
|
a298b6587d | ||
|
|
d87f6b74f3 | ||
|
|
1f0b145740 | ||
|
|
f6d528d36d | ||
|
|
ea6502a282 | ||
|
|
8a36a94e73 | ||
|
|
1604eaa239 | ||
|
|
fec2fb7ce6 | ||
|
|
d2e3b854aa | ||
|
|
f8e8d33c61 | ||
|
|
dd76135efd | ||
|
|
d7be7a69ab | ||
|
|
fd942b28c6 | ||
|
|
7c850b0405 | ||
|
|
e3bb95b3dd | ||
|
|
662d8bcfda | ||
|
|
3c0b2c64e1 | ||
|
|
ed7d42cf6d | ||
|
|
8852914ceb | ||
|
|
944778175a | ||
|
|
81704c08c9 | ||
|
|
810059e6da | ||
|
|
8d95bd16fd | ||
|
|
4600253d1e | ||
|
|
d695aa9f57 | ||
|
|
7867aac55f | ||
|
|
e26563c3d6 | ||
|
|
07ad262857 | ||
|
|
cb0abd51db | ||
|
|
cc69baf0dd | ||
|
|
852a8d04c9 | ||
|
|
ffdacb3850 | ||
|
|
062e8357fa | ||
|
|
07dece9cd7 | ||
|
|
d628a513d9 | ||
|
|
6012ad9b1e | ||
|
|
c3e618de36 | ||
|
|
6b9795fe96 | ||
|
|
f7da3a347d | ||
|
|
cf020d06c6 | ||
|
|
137b5ca4f9 | ||
|
|
82be9326a8 | ||
|
|
222282dced | ||
|
|
c7a2086850 | ||
|
|
168ac5065d | ||
|
|
158ea1984f | ||
|
|
f66d73e385 | ||
|
|
252ed1c6f2 | ||
|
|
69e35167bc | ||
|
|
2140075133 | ||
|
|
80469ead18 | ||
|
|
77dc563219 | ||
|
|
9d7f0b22f7 | ||
|
|
56b17116e3 | ||
|
|
c71791b649 | ||
|
|
c8f8fcf9d3 | ||
|
|
d41a85f4a1 | ||
|
|
3c465f9a7a | ||
|
|
c25427cf4a | ||
|
|
1c8575e40c | ||
|
|
e512eab1e8 | ||
|
|
4dd8ceb245 | ||
|
|
07e2bd4bcf | ||
|
|
05eb62bb35 | ||
|
|
0df3342757 | ||
|
|
0615f38a26 | ||
|
|
1fe63b68ee | ||
|
|
1e7dbb5331 | ||
|
|
0ddc03b7c0 | ||
|
|
becc3d0953 | ||
|
|
48b1bfaebd | ||
|
|
c043026764 | ||
|
|
0aed9fc306 | ||
|
|
739559783b | ||
|
|
0f4076acab | ||
|
|
9692ac3f4d | ||
|
|
365a333b1d | ||
|
|
f039755bde | ||
|
|
d314f1bae2 | ||
|
|
aae1915519 | ||
|
|
220df8918c | ||
|
|
3e41655902 | ||
|
|
54a23f5ae7 | ||
|
|
edffcf8902 | ||
|
|
dd55f41264 | ||
|
|
8fef0052a3 | ||
|
|
f2db10d29a | ||
|
|
33756c775c | ||
|
|
ef65dd8cc6 | ||
|
|
74d0d851ca | ||
|
|
49ebc17334 | ||
|
|
548aba5b7c | ||
|
|
dc1f1e02a1 | ||
|
|
d10b809687 | ||
|
|
ad438ef339 | ||
|
|
8a7a6ed4f5 | ||
|
|
c6097e0397 | ||
|
|
0f3e856438 | ||
|
|
5b6ec81cee | ||
|
|
e888bfbc8d | ||
|
|
b04ab65258 | ||
|
|
46b707f246 | ||
|
|
f2a6073829 | ||
|
|
e5926a5371 | ||
|
|
86c4581a50 | ||
|
|
a80074dc21 | ||
|
|
3effdd1408 | ||
|
|
b927c55216 | ||
|
|
49c590a9b5 | ||
|
|
8df6a2dd83 | ||
|
|
fe66c95a29 | ||
|
|
c080959f64 | ||
|
|
f27a88787d | ||
|
|
5853495125 | ||
|
|
f49d94948d | ||
|
|
82dad0fad3 | ||
|
|
fea99498af | ||
|
|
5582ee8ed8 | ||
|
|
f4b6db9404 | ||
|
|
5c92362aae | ||
|
|
667ea9fa64 | ||
|
|
b710750035 | ||
|
|
491ff01c79 | ||
|
|
4981145dd8 | ||
|
|
e9497b03f4 | ||
|
|
d76e518db1 | ||
|
|
a2906c6aa5 | ||
|
|
e0676c66a0 | ||
|
|
0b12c5a169 | ||
|
|
39b61fe331 | ||
|
|
83e77681d9 | ||
|
|
95a69937bd | ||
|
|
c355bd7569 | ||
|
|
559a186cd9 | ||
|
|
7e81ef37d7 | ||
|
|
2e167d260d | ||
|
|
aa50d818ec | ||
|
|
b9dd0a3877 | ||
|
|
e03ef7e214 | ||
|
|
caa05d739f | ||
|
|
f580673dea | ||
|
|
297d271e63 | ||
|
|
a28e4be5a3 | ||
|
|
6b672acdc7 | ||
|
|
26f5368264 | ||
|
|
fc5b967973 | ||
|
|
3cf497fa91 | ||
|
|
f50411e9db | ||
|
|
74eca2e527 | ||
|
|
6200e78e93 | ||
|
|
904c122ee0 | ||
|
|
741afaea18 | ||
|
|
6cf86d80e2 | ||
|
|
886305ec13 | ||
|
|
ab040f5268 | ||
|
|
8404e0f670 | ||
|
|
3605ae14b5 | ||
|
|
bce372bd79 | ||
|
|
715c48b7eb | ||
|
|
eb9a3c2ad1 | ||
|
|
b261829aea | ||
|
|
595be6b7b8 | ||
|
|
9ed76ae4da | ||
|
|
2ae0ef40d4 | ||
|
|
f5f7d3c154 | ||
|
|
a9ab4dbe38 | ||
|
|
5c3c26851c | ||
|
|
2b3696aab1 | ||
|
|
35ec0c9bcf | ||
|
|
4f915d6708 | ||
|
|
f4eb8b246b | ||
|
|
1a80e52241 | ||
|
|
afa27a04fe | ||
|
|
b82c83de5e | ||
|
|
625e2305ba | ||
|
|
6b4781b7d5 | ||
|
|
7acffabdd8 | ||
|
|
e6f2aa2399 | ||
|
|
ece7e04c7c | ||
|
|
0b4d273e08 | ||
|
|
81e8d6d99c | ||
|
|
e96444671e | ||
|
|
e52785a8b4 | ||
|
|
ddccc5ff6b | ||
|
|
8bbcef585f | ||
|
|
e58041227b | ||
|
|
3678e8fb27 | ||
|
|
1146a9125b | ||
|
|
aab0c055ed | ||
|
|
685082e212 | ||
|
|
1bb8b636b9 | ||
|
|
43c51c3b82 | ||
|
|
b9ed64fba2 | ||
|
|
ceaac03adf | ||
|
|
3085a837c8 | ||
|
|
2e5e2c8430 | ||
|
|
48df5c0eb1 | ||
|
|
fcad6766c3 | ||
|
|
c91a4670de | ||
|
|
5e7c325874 | ||
|
|
6b8a1428d7 | ||
|
|
5bd81db37e | ||
|
|
9834baedfa | ||
|
|
0b4c42859d | ||
|
|
a92b45ae26 | ||
|
|
1e2096e691 | ||
|
|
3df6ffe280 | ||
|
|
d4f370c071 | ||
|
|
b894ea866a | ||
|
|
3a300a4ca3 | ||
|
|
0ad844d10e | ||
|
|
d310a45f72 | ||
|
|
57c31804b4 | ||
|
|
5fb70a9b9a | ||
|
|
d402143989 | ||
|
|
ad8d799cf6 | ||
|
|
cec705264d | ||
|
|
28a2e61361 | ||
|
|
6017215ada | ||
|
|
8f3128e4b3 | ||
|
|
ac86d75e10 | ||
|
|
6403e51ba7 | ||
|
|
6e3dd8165e | ||
|
|
a2d61cc30a | ||
|
|
4455aa6709 | ||
|
|
addd199407 | ||
|
|
26cc67cd41 | ||
|
|
7b7875e23f |
50
.github/workflows/jekyll-gh-pages.yml
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
# Sample workflow for building and deploying a Jekyll site to GitHub Pages
|
||||
name: Deploy Jekyll with GitHub Pages dependencies preinstalled
|
||||
|
||||
on:
|
||||
# Runs on pushes targeting the default branch
|
||||
push:
|
||||
branches: ["master"]
|
||||
|
||||
# Allows you to run this workflow manually from the Actions tab
|
||||
workflow_dispatch:
|
||||
|
||||
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
|
||||
permissions:
|
||||
contents: read
|
||||
pages: write
|
||||
id-token: write
|
||||
|
||||
# Allow one concurrent deployment
|
||||
concurrency:
|
||||
group: "pages"
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
# Build job
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- name: Setup Pages
|
||||
uses: actions/configure-pages@v2
|
||||
- name: Build with Jekyll
|
||||
uses: actions/jekyll-build-pages@v1
|
||||
with:
|
||||
source: ./docs
|
||||
destination: ./_site
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-pages-artifact@v1
|
||||
|
||||
# Deployment job
|
||||
deploy:
|
||||
environment:
|
||||
name: github-pages
|
||||
url: ${{ steps.deployment.outputs.page_url }}
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
steps:
|
||||
- name: Deploy to GitHub Pages
|
||||
id: deployment
|
||||
uses: actions/deploy-pages@v1
|
||||
6
.gitignore
vendored
@@ -26,3 +26,9 @@ osx/.DS_Store
|
||||
osx/runvimix
|
||||
|
||||
*.autosave
|
||||
|
||||
flatpak/.flatpak-builder
|
||||
|
||||
flatpak/repo/
|
||||
|
||||
flatpak/build/
|
||||
|
||||
6
.gitmodules
vendored
@@ -13,12 +13,12 @@
|
||||
[submodule "ext/Dirent"]
|
||||
path = ext/Dirent
|
||||
url = https://github.com/tronkko/dirent.git
|
||||
[submodule "ext/tfd"]
|
||||
path = ext/tfd
|
||||
url = https://github.com/native-toolkit/tinyfiledialogs.git
|
||||
[submodule "ext/glm"]
|
||||
path = ext/glm
|
||||
url = https://github.com/g-truc/glm.git
|
||||
[submodule "ext/link"]
|
||||
path = ext/link
|
||||
url = https://github.com/Ableton/link.git
|
||||
[submodule "ext/tfd"]
|
||||
path = ext/tfd
|
||||
url = https://git.code.sf.net/p/tinyfiledialogs/code
|
||||
792
CMakeLists.txt
@@ -1,9 +1,15 @@
|
||||
#####
|
||||
##### This file is part of vimix - video live mixer
|
||||
##### **Copyright** (C) 2019-2023 Bruno Herbelin <bruno.herbelin@gmail.com>
|
||||
#####
|
||||
|
||||
cmake_minimum_required(VERSION 3.8.2)
|
||||
project(vimix VERSION 0.0.1 LANGUAGES CXX C)
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
# use git
|
||||
#####
|
||||
##### Use git to read version from tags
|
||||
#####
|
||||
find_package (Git)
|
||||
if(GIT_EXECUTABLE)
|
||||
execute_process(
|
||||
@@ -16,23 +22,37 @@ if(GIT_EXECUTABLE)
|
||||
if(NOT GIT_DESCRIBE_ERROR_CODE)
|
||||
string(SUBSTRING ${GIT_DESCRIBE_VERSION} 0 1 VIMIX_VERSION_MAJOR)
|
||||
string(SUBSTRING ${GIT_DESCRIBE_VERSION} 2 1 VIMIX_VERSION_MINOR)
|
||||
string(SUBSTRING ${GIT_DESCRIBE_VERSION} 4 1 VIMIX_VERSION_PATCH)
|
||||
string(LENGTH ${GIT_DESCRIBE_VERSION} VIMIX_VERSION_LENGTH)
|
||||
if (VIMIX_VERSION_LENGTH GREATER 4)
|
||||
string(SUBSTRING ${GIT_DESCRIBE_VERSION} 4 1 VIMIX_VERSION_PATCH)
|
||||
else()
|
||||
set(VIMIX_VERSION_PATCH "0")
|
||||
endif()
|
||||
add_definitions(-DVIMIX_GIT="${GIT_DESCRIBE_VERSION}")
|
||||
add_definitions(-DVIMIX_VERSION_MAJOR=${VIMIX_VERSION_MAJOR})
|
||||
add_definitions(-DVIMIX_VERSION_MINOR=${VIMIX_VERSION_MINOR})
|
||||
add_definitions(-DVIMIX_VERSION_PATCH=${VIMIX_VERSION_PATCH})
|
||||
message(STATUS "Compiling vimix version ${VIMIX_VERSION_MAJOR}.${VIMIX_VERSION_MINOR}.${VIMIX_VERSION_PATCH}")
|
||||
else()
|
||||
message(STATUS "Compiling vimix (unknown version)")
|
||||
message(STATUS "Compiling vimix version ${VIMIX_VERSION_MAJOR}.${VIMIX_VERSION_MINOR}.${VIMIX_VERSION_PATCH} (${GIT_DESCRIBE_VERSION})")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(CMAKE_INCLUDE_CURRENTDIR ON)
|
||||
|
||||
# Find the cmake modules
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules )
|
||||
#####
|
||||
##### Find the cmake modules
|
||||
#####
|
||||
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} /usr/share/cmake ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules )
|
||||
include(MacroLogFeature)
|
||||
include(MacroFindGStreamerLibrary)
|
||||
|
||||
|
||||
#####
|
||||
##### Configure cmake
|
||||
#####
|
||||
|
||||
set(BUILD_STATIC_LIBS ON)
|
||||
set(CMAKE_INCLUDE_CURRENTDIR ON)
|
||||
|
||||
if(UNIX)
|
||||
if (APPLE)
|
||||
add_definitions(-DAPPLE)
|
||||
@@ -40,15 +60,37 @@ if(UNIX)
|
||||
# the RPATH to be used when installing
|
||||
set(CMAKE_SKIP_RPATH TRUE)
|
||||
set(OpenGL_DIR /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/)
|
||||
set(CMAKE_OSX_ARCHITECTURES "x86_64")
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.14")
|
||||
|
||||
# MacOS target
|
||||
set(CMAKE_OSX_ARCHITECTURES "arm64" CACHE STRING "")
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET "13" CACHE STRING "")
|
||||
|
||||
# CPACK
|
||||
set(CPACK_SYSTEM_NAME "OSX_${CMAKE_OSX_DEPLOYMENT_TARGET}_${CMAKE_OSX_ARCHITECTURES}")
|
||||
set(CPACK_GENERATOR DragNDrop)
|
||||
set(CPACK_BINARY_DRAGNDROP ON)
|
||||
|
||||
# Apple ID code signing
|
||||
set(APPLE_CODESIGN_ENTITLEMENTS "${CMAKE_CURRENT_SOURCE_DIR}/osx/entitlements.plist")
|
||||
## team ID, for example if your certificate is: Developer ID Application: JOHN, DOE (X4MF6H9XZ6) the team ID is: X4MF6H9XZ6
|
||||
set(APPLE_CODESIGN_TEAM "" CACHE STRING "")
|
||||
## Apple identity, in the form Developer ID Application
|
||||
set(APPLE_CODESIGN_IDENTITY "Developer ID Application:" CACHE STRING "")
|
||||
## Apple keychain profile for app-specific password
|
||||
## 1. Create a password for "vimix" at https://support.apple.com/en-us/102654
|
||||
## 2. Run e.g.
|
||||
## xcrun notarytool store-credentials "vimix" --apple-id <email_login_apple_id> --team-id <team> --password <string_given_https://appleid.apple.com/account/manage>
|
||||
set(APPLE_CODESIGN_STORED_CREDENTIAL "vimix" CACHE STRING "")
|
||||
|
||||
# find icu4c in OSX (pretty well hidden...)
|
||||
set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:/usr/local/opt/icu4c/lib/pkgconfig")
|
||||
set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:/usr/local/opt/icu4c/lib/pkgconfig:/opt/homebrew/opt/icu4c/lib/pkgconfig")
|
||||
|
||||
else()
|
||||
add_definitions(-DLINUX)
|
||||
|
||||
# CPACK
|
||||
set(CPACK_SYSTEM_NAME "${CMAKE_HOST_SYSTEM_NAME}")
|
||||
|
||||
# linux opengl
|
||||
set(OpenGL_GL_PREFERENCE "GLVND")
|
||||
|
||||
@@ -56,6 +98,11 @@ if(UNIX)
|
||||
find_package(GTK 3.0 REQUIRED)
|
||||
macro_log_feature(GTK_FOUND "GTK" "GTK cross-platform widget toolkit" "http://www.gtk.org" TRUE)
|
||||
|
||||
find_package(X11 REQUIRED COMPONENTS xcb)
|
||||
include_directories(
|
||||
${X11_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
endif()
|
||||
add_definitions(-DUNIX)
|
||||
elseif(WIN32)
|
||||
@@ -63,23 +110,34 @@ elseif(WIN32)
|
||||
add_definitions(-DMINGW32)
|
||||
endif()
|
||||
|
||||
#####
|
||||
##### Preprocessor options
|
||||
#####
|
||||
|
||||
# add_definitions(-DUSE_GST_OPENGL_SYNC_HANDLER)
|
||||
# add_definitions(-DUSE_GL_BUFFER_SUBDATA)
|
||||
# add_definitions(-DIGNORE_GST_BUS_MESSAGE)
|
||||
|
||||
#####
|
||||
##### Dependencies
|
||||
#####
|
||||
|
||||
#
|
||||
# Basics
|
||||
#
|
||||
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
find_package(GLIB2)
|
||||
macro_log_feature(GLIB2_FOUND "GLib" "GTK general-purpose utility library" "http://www.gtk.org" TRUE)
|
||||
|
||||
find_package(GObject)
|
||||
macro_log_feature(GOBJECT_FOUND "GObject" "GTK object-oriented framework" "http://www.gtk.org" TRUE)
|
||||
|
||||
find_package(PNG REQUIRED)
|
||||
macro_log_feature(PNG_FOUND "PNG" "Portable Network Graphics" "http://www.libpng.org" TRUE)
|
||||
find_package(ZLIB REQUIRED)
|
||||
|
||||
#
|
||||
# GSTREAMER
|
||||
#
|
||||
find_package(GLIB2 REQUIRED)
|
||||
macro_log_feature(GLIB2_FOUND "GLib" "GTK general-purpose utility library" "http://www.gtk.org" TRUE)
|
||||
|
||||
find_package(GObject REQUIRED)
|
||||
macro_log_feature(GOBJECT_FOUND "GObject" "GTK object-oriented framework" "http://www.gtk.org" TRUE)
|
||||
|
||||
find_package(GStreamer 1.0.0 COMPONENTS base)
|
||||
macro_log_feature(GSTREAMER_FOUND "GStreamer"
|
||||
@@ -105,6 +163,17 @@ macro_log_feature(GSTREAMER_GL_LIBRARY_FOUND "GStreamerPluginsBase" "GStreamer o
|
||||
# Various preprocessor definitions for GST
|
||||
add_definitions(-DGST_DISABLE_XML -DGST_DISABLE_LOADSAVE)
|
||||
|
||||
include_directories(
|
||||
${GLIB2_INCLUDE_DIR}
|
||||
${GSTREAMER_INCLUDE_DIR}
|
||||
${GSTREAMER_AUDIO_INCLUDE_DIR}
|
||||
${GSTREAMER_VIDEO_INCLUDE_DIR}
|
||||
${GSTREAMER_BASE_INCLUDE_DIR}
|
||||
${GSTREAMER_APP_INCLUDE_DIR}
|
||||
${GSTREAMER_PBUTILS_INCLUDE_DIR}
|
||||
${GSTREAMER_GL_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
#
|
||||
# ICU4C
|
||||
#
|
||||
@@ -113,8 +182,17 @@ if (PKG_CONFIG_FOUND)
|
||||
else ()
|
||||
find_package(ICU REQUIRED COMPONENTS i18n io uc)
|
||||
endif ()
|
||||
|
||||
macro_log_feature(ICU_FOUND "ICU" "International Components for Unicode" "http://site.icu-project.org" TRUE)
|
||||
|
||||
include_directories(
|
||||
${ICU_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
link_directories(
|
||||
${ICU_LIBRARY_DIRS}
|
||||
)
|
||||
|
||||
#
|
||||
# GLFW3
|
||||
#
|
||||
@@ -123,37 +201,176 @@ if (PKG_CONFIG_FOUND)
|
||||
else ()
|
||||
find_package(glfw3 3.2 REQUIRED)
|
||||
endif()
|
||||
|
||||
macro_log_feature(GLFW3_FOUND "glfw3" "Open Source multi-platform library for OpenGL" "http://www.glfw.org" TRUE)
|
||||
|
||||
include_directories(
|
||||
${GLFW3_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
macro_display_feature_log()
|
||||
|
||||
# static sub packages in ext
|
||||
set(BUILD_STATIC_LIBS ON)
|
||||
link_directories(
|
||||
${GLFW3_LIBRARY_DIRS}
|
||||
)
|
||||
|
||||
#
|
||||
# GLM
|
||||
#
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/ext/glm)
|
||||
message(STATUS "Compiling 'GLM' OpenGL mathematics https://glm.g-truc.net -- ${CMAKE_CURRENT_SOURCE_DIR}/ext/glm")
|
||||
if (PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(GLM QUIET glm>=0.9.9)
|
||||
else ()
|
||||
find_package(glm 0.9.9 QUIET)
|
||||
endif()
|
||||
|
||||
if (GLM_FOUND)
|
||||
macro_log_feature(GLM_FOUND "GLM" "OpenGL mathematics" "https://glm.g-truc.net" TRUE)
|
||||
else ()
|
||||
set(GLM_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/ext/glm)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/ext/glm)
|
||||
message(STATUS "Compiling 'GLM' OpenGL mathematics https://glm.g-truc.net -- ${CMAKE_CURRENT_SOURCE_DIR}/ext/glm")
|
||||
endif()
|
||||
|
||||
include_directories(
|
||||
${GLM_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
#
|
||||
# TINY XML 2
|
||||
#
|
||||
if (PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(TINYXML2 QUIET tinyxml2>=8.0)
|
||||
else ()
|
||||
find_package(tinyxml2 8.0 QUIET)
|
||||
endif()
|
||||
|
||||
if (TINYXML2_FOUND)
|
||||
macro_log_feature(TINYXML2_FOUND "TinyXML2" "TinyXML2 library" "https://github.com/leethomason/tinyxml2.git" TRUE)
|
||||
else ()
|
||||
set(TINYXML2_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/ext/tinyxml2)
|
||||
set(TINYXML2_LIBRARIES TINYXML2)
|
||||
add_library(TINYXML2 "${CMAKE_CURRENT_SOURCE_DIR}/ext/tinyxml2/tinyxml2.cpp")
|
||||
set_property(TARGET TINYXML2 PROPERTY CXX_STANDARD 17)
|
||||
set_property(TARGET TINYXML2 PROPERTY C_STANDARD 11)
|
||||
message(STATUS "Compiling 'TinyXML2' from https://github.com/leethomason/tinyxml2.git -- ${TINYXML2_INCLUDE_DIRS}")
|
||||
endif()
|
||||
|
||||
include_directories(
|
||||
${TINYXML2_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
#
|
||||
# STB
|
||||
#
|
||||
if (PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(STB QUIET stb)
|
||||
else ()
|
||||
find_package(stb QUIET)
|
||||
endif()
|
||||
|
||||
if (STB_FOUND)
|
||||
macro_log_feature(STB_FOUND "STB" "single-file image and audio processing" "https://github.com/nothings/stb" TRUE)
|
||||
else ()
|
||||
set(STB_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/ext/stb)
|
||||
message(STATUS "Including 'STB' single-file image and audio processing from https://github.com/nothings/stb -- ${STB_INCLUDE_DIRS}")
|
||||
endif()
|
||||
|
||||
include_directories(
|
||||
${STB_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
#
|
||||
# Ableton LINK
|
||||
#
|
||||
#add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/ext/link)
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/ext/link/AbletonLinkConfig.cmake)
|
||||
message(STATUS "Compiling Ableton 'Link' https://github.com/Ableton/link -- ${CMAKE_CURRENT_SOURCE_DIR}/ext/link")
|
||||
find_package(AbletonLink QUIET)
|
||||
|
||||
if (AbletonLink_FOUND)
|
||||
macro_log_feature(AbletonLink_FOUND "AbletonLink" "Ableton Link synchronizer" "https://github.com/Ableton/link" TRUE)
|
||||
else ()
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/ext/link/AbletonLinkConfig.cmake)
|
||||
message(STATUS "Compiling 'Ableton Link' from https://github.com/Ableton/link -- ${CMAKE_CURRENT_SOURCE_DIR}/ext/link")
|
||||
endif()
|
||||
|
||||
include_directories(
|
||||
${link_HEADERS}
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
# FILE DIALOG: use tinyfiledialog for all except Linux
|
||||
#
|
||||
if(APPLE OR WIN32)
|
||||
set(TINYFD_LIBRARIES TINYFD)
|
||||
set(TINYFD_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/ext/tfd)
|
||||
include_directories(
|
||||
${TINYFD_INCLUDE_DIR}
|
||||
)
|
||||
add_library(TINYFD "${CMAKE_CURRENT_SOURCE_DIR}/ext/tfd/tinyfiledialogs.c")
|
||||
message(STATUS "Compiling 'TinyFileDialog' from https://git.code.sf.net/p/tinyfiledialogs/code -- ${TINYFD_INCLUDE_DIR}.")
|
||||
endif()
|
||||
|
||||
#
|
||||
# DIRENT (windows only)
|
||||
if(WIN32)
|
||||
set(DIRENT_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/ext/Dirent/include)
|
||||
include_directories(
|
||||
${DIRENT_INCLUDE_DIR}
|
||||
)
|
||||
message(STATUS "Including 'Dirent' from https://github.com/tronkko/dirent -- ${DIRENT_INCLUDE_DIR}.")
|
||||
endif()
|
||||
|
||||
|
||||
#
|
||||
# SHMDATA (Unix only)
|
||||
#
|
||||
if(UNIX)
|
||||
|
||||
if (PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(SHMDATA QUIET shmdata-1.3)
|
||||
endif()
|
||||
|
||||
if(SHMDATA_FOUND)
|
||||
find_library(GSTREAMER_SHMDATA_LIBRARY
|
||||
NAMES gstshmdata
|
||||
HINTS ${SHMDATA_LIBRARY_DIRS}/gstreamer-1.0
|
||||
)
|
||||
if(GSTREAMER_SHMDATA_LIBRARY)
|
||||
add_definitions(-DGSTREAMER_SHMDATA_PLUGIN=\"${GSTREAMER_SHMDATA_LIBRARY}\")
|
||||
endif()
|
||||
|
||||
macro_log_feature(GSTREAMER_SHMDATA_LIBRARY "GStreamerPluginShmdata" "Plugin to share any flow" "https://gitlab.com/sat-mtl/tools/shmdata" FALSE)
|
||||
endif(SHMDATA_FOUND)
|
||||
|
||||
endif(UNIX)
|
||||
|
||||
|
||||
# show message about found libs
|
||||
macro_display_feature_log()
|
||||
|
||||
#####
|
||||
##### Locally built libraries
|
||||
#####
|
||||
|
||||
#
|
||||
# GLAD
|
||||
#
|
||||
set(GLAD_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/ext/glad/include)
|
||||
set(GLAD_LIBRARIES GLAD)
|
||||
set(GLAD_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/ext/glad/include)
|
||||
include_directories(
|
||||
${GLAD_INCLUDE_DIRS}
|
||||
)
|
||||
add_library(GLAD "${CMAKE_CURRENT_SOURCE_DIR}/ext/glad/src/glad.c")
|
||||
message(STATUS "Compiling 'GLAD' Open source multi-language OpenGL loader https://glad.dav1d.de -- ${GLAD_INCLUDE_DIR}")
|
||||
set_property(TARGET GLAD PROPERTY C_STANDARD 11)
|
||||
message(STATUS "Compiling 'GLAD 2' Open source multi-language OpenGL loader https://gen.glad.sh -- ${GLAD_INCLUDE_DIRS}")
|
||||
|
||||
#
|
||||
# DEAR IMGUI
|
||||
#
|
||||
set(IMGUI_LIBRARIES IMGUI IMGUITEXTEDIT)
|
||||
set(IMGUI_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/ext/imgui)
|
||||
set(IMGUI_BACKEND_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/ext/imgui/examples)
|
||||
include_directories(
|
||||
${IMGUI_INCLUDE_DIRS}
|
||||
${IMGUI_BACKEND_INCLUDE_DIRS}
|
||||
)
|
||||
set(IMGUI_SRCS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ext/imgui/imgui.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ext/imgui//imgui_demo.cpp
|
||||
@@ -161,18 +378,23 @@ set(IMGUI_SRCS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ext/imgui//imgui_widgets.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ext/imgui/examples/imgui_impl_glfw.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ext/imgui/examples/imgui_impl_opengl3.cpp
|
||||
)
|
||||
set(IMGUI_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/ext/imgui)
|
||||
)
|
||||
add_library(IMGUI "${IMGUI_SRCS}")
|
||||
target_compile_definitions(IMGUI PRIVATE "IMGUI_IMPL_OPENGL_LOADER_GLAD")
|
||||
message(STATUS "Compiling 'Dear ImGui' from https://github.com/ocornut/imgui.git -- ${IMGUI_INCLUDE_DIR}")
|
||||
target_compile_definitions(IMGUI PRIVATE "IMGUI_USE_STB_SPRINTF")
|
||||
message(STATUS "Compiling 'Dear ImGui' from https://github.com/ocornut/imgui.git -- ${IMGUI_INCLUDE_DIRS}")
|
||||
|
||||
#
|
||||
# TINY XML 2
|
||||
# ImGui Color Text Editor
|
||||
#
|
||||
set(TINYXML2_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/ext/tinyxml2)
|
||||
add_library(TINYXML2 "${CMAKE_CURRENT_SOURCE_DIR}/ext/tinyxml2/tinyxml2.cpp")
|
||||
message(STATUS "Compiling 'TinyXML2' from https://github.com/leethomason/tinyxml2.git -- ${TINYXML2_INCLUDE_DIR}")
|
||||
set(IMGUITEXTEDIT_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/ext/ImGuiColorTextEdit)
|
||||
include_directories(
|
||||
${IMGUITEXTEDIT_INCLUDE_DIR}
|
||||
)
|
||||
add_library(IMGUITEXTEDIT "${CMAKE_CURRENT_SOURCE_DIR}/ext/ImGuiColorTextEdit/TextEditor.cpp")
|
||||
set_property(TARGET IMGUITEXTEDIT PROPERTY CXX_STANDARD 17)
|
||||
message(STATUS "Compiling 'ImGuiColorTextEdit' from https://github.com/BalazsJako/ImGuiColorTextEdit -- ${IMGUITEXTEDIT_INCLUDE_DIR}")
|
||||
|
||||
|
||||
#
|
||||
# OSCPack
|
||||
@@ -191,160 +413,106 @@ set(OSCPACK_SRCS
|
||||
${OSCPACK_PLATFORM_DIR}/NetworkingUtils.cpp
|
||||
${OSCPACK_PLATFORM_DIR}/UdpSocket.cpp
|
||||
)
|
||||
set(OSCPACK_LIBRARIES OSCPACK)
|
||||
set(OSCPACK_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/ext/OSCPack)
|
||||
include_directories(
|
||||
${OSCPACK_INCLUDE_DIR}
|
||||
)
|
||||
add_library(OSCPACK "${OSCPACK_SRCS}")
|
||||
set_property(TARGET OSCPACK PROPERTY CXX_STANDARD 17)
|
||||
set_property(TARGET OSCPACK PROPERTY C_STANDARD 11)
|
||||
# if(APPLE)
|
||||
target_compile_definitions(OSCPACK
|
||||
PRIVATE
|
||||
_M_X64
|
||||
)
|
||||
# endif(APPLE)
|
||||
message(STATUS "Compiling 'OSCPack' from http://www.rossbencina.com/code/oscpack -- ${OSCPACK_INCLUDE_DIR}")
|
||||
|
||||
|
||||
#####
|
||||
##### Ressources
|
||||
#####
|
||||
|
||||
set(RSC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/rsc)
|
||||
|
||||
#
|
||||
# FILE DIALOG: use tinyfiledialog for all except Linux
|
||||
# Fonts
|
||||
#
|
||||
if(UNIX)
|
||||
if (APPLE)
|
||||
set(TINYFD_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/ext/tfd)
|
||||
add_library(TINYFD "${CMAKE_CURRENT_SOURCE_DIR}/ext/tfd/tinyfiledialogs.c")
|
||||
message(STATUS "Compiling 'TinyFileDialog' from https://github.com/native-toolkit/tinyfiledialogs.git -- ${TINYFD_INCLUDE_DIR}.")
|
||||
set(TINYFD_LIBRARY TINYFD)
|
||||
endif()
|
||||
else()
|
||||
set(TINYFD_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/ext/tfd)
|
||||
add_library(TINYFD "${CMAKE_CURRENT_SOURCE_DIR}/ext/tfd/tinyfiledialogs.c")
|
||||
message(STATUS "Compiling 'TinyFileDialog' from https://github.com/native-toolkit/tinyfiledialogs.git -- ${TINYFD_INCLUDE_DIR}.")
|
||||
set(TINYFD_LIBRARY TINYFD)
|
||||
|
||||
file(GLOB_RECURSE ROBOTO_REGULAR "${RSC_DIR}/*/Roboto-Regular.ttf")
|
||||
if(NOT ROBOTO_REGULAR)
|
||||
file(GLOB_RECURSE ROBOTO_REGULAR "/usr/share/fonts/*/Roboto-Regular.ttf")
|
||||
message(STATUS "Copy ${ROBOTO_REGULAR} to ${RSC_DIR}/fonts")
|
||||
file(COPY ${ROBOTO_REGULAR} DESTINATION ${RSC_DIR}/fonts)
|
||||
set(ROBOTO_REGULAR "${RSC_DIR}/fonts/Roboto-Regular.ttf")
|
||||
endif()
|
||||
|
||||
#
|
||||
# ImGui Color Text Editor
|
||||
#
|
||||
set(IMGUITEXTEDIT_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/ext/ImGuiColorTextEdit)
|
||||
set(IMGUITEXTEDIT_SRC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ext/ImGuiColorTextEdit/TextEditor.cpp
|
||||
)
|
||||
message(STATUS "Including 'ImGuiColorTextEdit' from https://github.com/BalazsJako/ImGuiColorTextEdit -- ${IMGUITEXTEDIT_INCLUDE_DIR}")
|
||||
|
||||
#
|
||||
# STB
|
||||
#
|
||||
set(STB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/ext/stb)
|
||||
add_definitions(-DIMGUI_USE_STB_SPRINTF)
|
||||
message(STATUS "Including 'STB Nothings' from https://github.com/nothings/stb -- ${STB_INCLUDE_DIR}")
|
||||
|
||||
#
|
||||
# DIRENT (windows only)
|
||||
if(WIN32)
|
||||
set(DIRENT_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/ext/Dirent/include)
|
||||
message(STATUS "Including 'Dirent' from https://github.com/tronkko/dirent -- ${DIRENT_INCLUDE_DIR}.")
|
||||
file(GLOB_RECURSE ROBOTO_BOLD "${RSC_DIR}/*/Roboto-Bold.ttf")
|
||||
if(NOT ROBOTO_BOLD)
|
||||
file(GLOB_RECURSE ROBOTO_BOLD "/usr/share/fonts/*/Roboto-Bold.ttf")
|
||||
message(STATUS "Copy ${ROBOTO_BOLD} to ${RSC_DIR}/fonts")
|
||||
file(COPY ${ROBOTO_BOLD} DESTINATION ${RSC_DIR}/fonts)
|
||||
set(ROBOTO_BOLD "${RSC_DIR}/fonts/Roboto-Bold.ttf")
|
||||
endif()
|
||||
|
||||
#
|
||||
# Application
|
||||
#
|
||||
file(GLOB_RECURSE ROBOTO_ITALIC "${RSC_DIR}/*/Roboto-Italic.ttf")
|
||||
if(NOT ROBOTO_ITALIC)
|
||||
file(GLOB_RECURSE ROBOTO_ITALIC "/usr/share/fonts/*/Roboto-Italic.ttf")
|
||||
message(STATUS "Copy ${ROBOTO_ITALIC} to ${RSC_DIR}/fonts")
|
||||
file(COPY ${ROBOTO_ITALIC} DESTINATION ${RSC_DIR}/fonts)
|
||||
set(ROBOTO_ITALIC "${RSC_DIR}/fonts/Roboto-Italic.ttf")
|
||||
endif()
|
||||
|
||||
file(GLOB_RECURSE HACK_REGULAR "${RSC_DIR}/*/Hack-Regular.ttf")
|
||||
if(NOT HACK_REGULAR)
|
||||
file(GLOB_RECURSE HACK_REGULAR "/usr/share/fonts/*/Hack-Regular.ttf")
|
||||
message(STATUS "Copy ${HACK_REGULAR} to ${RSC_DIR}/fonts")
|
||||
file(COPY ${HACK_REGULAR} DESTINATION ${RSC_DIR}/fonts)
|
||||
set(HACK_REGULAR "${RSC_DIR}/fonts/Hack-Regular.ttf")
|
||||
endif()
|
||||
|
||||
file(GLOB_RECURSE AWESOME_SOLID "${RSC_DIR}/*/fa-solid-900.ttf")
|
||||
if(NOT AWESOME_SOLID)
|
||||
file(GLOB_RECURSE AWESOME_SOLID "/usr/share/fonts/*/fa-solid-900.ttf")
|
||||
message(STATUS "Copy ${AWESOME_SOLID} to ${RSC_DIR}/fonts")
|
||||
file(COPY ${AWESOME_SOLID} DESTINATION ${RSC_DIR}/fonts)
|
||||
set(AWESOME_SOLID "${RSC_DIR}/fonts/fa-solid-900.ttf")
|
||||
endif()
|
||||
|
||||
file(GLOB_RECURSE AWESOME_REGULAR "${RSC_DIR}/*/fa-regular-400.ttf")
|
||||
if(NOT AWESOME_REGULAR)
|
||||
file(GLOB_RECURSE AWESOME_REGULAR "/usr/share/fonts/*/fa-regular-400.ttf")
|
||||
message(STATUS "Copy ${AWESOME_REGULAR} to ${RSC_DIR}/fonts")
|
||||
file(COPY ${AWESOME_REGULAR} DESTINATION ${RSC_DIR}/fonts)
|
||||
set(AWESOME_REGULAR "${RSC_DIR}/fonts/fa-regular-400.ttf")
|
||||
endif()
|
||||
|
||||
# Setup the environment
|
||||
include_directories(
|
||||
${GSTREAMER_INCLUDE_DIR}
|
||||
${GSTREAMER_AUDIO_INCLUDE_DIR}
|
||||
${GSTREAMER_VIDEO_INCLUDE_DIR}
|
||||
${GSTREAMER_BASE_INCLUDE_DIR}
|
||||
${GSTREAMER_APP_INCLUDE_DIR}
|
||||
${GSTREAMER_PBUTILS_INCLUDE_DIR}
|
||||
${GSTREAMER_GL_INCLUDE_DIR}
|
||||
${GLFW3_INCLUDE_DIRS}
|
||||
${ICU_INCLUDE_DIRS}
|
||||
${GLM_INCLUDE_DIRS}
|
||||
${GLIB2_INCLUDE_DIR}
|
||||
${GLAD_INCLUDE_DIR}
|
||||
${IMGUI_INCLUDE_DIR}
|
||||
${IMGUI_INCLUDE_DIR}/examples
|
||||
${IMGUITEXTEDIT_INCLUDE_DIR}
|
||||
${TINYXML2_INCLUDE_DIR}
|
||||
${TINYFD_INCLUDE_DIR}
|
||||
${STB_INCLUDE_DIR}
|
||||
${DIRENT_INCLUDE_DIR}
|
||||
${OSCPACK_INCLUDE_DIR}
|
||||
${link_HEADERS}
|
||||
)
|
||||
|
||||
link_directories(
|
||||
${GLFW3_LIBRARY_DIRS}
|
||||
${ICU_LIBRARY_DIRS}
|
||||
"${RSC_DIR}/fonts"
|
||||
)
|
||||
|
||||
|
||||
set(VMIX_BINARY "vimix")
|
||||
set(VMIX_SRCS
|
||||
main.cpp
|
||||
Log.cpp
|
||||
BaseToolkit.cpp
|
||||
Shader.cpp
|
||||
ImageShader.cpp
|
||||
ImageProcessingShader.cpp
|
||||
UpdateCallback.cpp
|
||||
Scene.cpp
|
||||
Primitives.cpp
|
||||
Mesh.cpp
|
||||
Decorations.cpp
|
||||
View.cpp
|
||||
RenderView.cpp
|
||||
GeometryView.cpp
|
||||
MixingView.cpp
|
||||
MixingGroup.cpp
|
||||
LayerView.cpp
|
||||
TextureView.cpp
|
||||
TransitionView.cpp
|
||||
Source.cpp
|
||||
SourceCallback.cpp
|
||||
SourceList.cpp
|
||||
Session.cpp
|
||||
Selection.cpp
|
||||
SessionSource.cpp
|
||||
SessionVisitor.cpp
|
||||
Interpolator.cpp
|
||||
SessionCreator.cpp
|
||||
SessionParser.cpp
|
||||
Mixer.cpp
|
||||
FrameGrabber.cpp
|
||||
Recorder.cpp
|
||||
Streamer.cpp
|
||||
Loopback.cpp
|
||||
Settings.cpp
|
||||
Screenshot.cpp
|
||||
Resource.cpp
|
||||
Timeline.cpp
|
||||
Stream.cpp
|
||||
MediaPlayer.cpp
|
||||
MediaSource.cpp
|
||||
StreamSource.cpp
|
||||
PatternSource.cpp
|
||||
DeviceSource.cpp
|
||||
NetworkSource.cpp
|
||||
MultiFileSource.cpp
|
||||
FrameBuffer.cpp
|
||||
RenderingManager.cpp
|
||||
UserInterfaceManager.cpp
|
||||
PickingVisitor.cpp
|
||||
BoundingBoxVisitor.cpp
|
||||
DrawVisitor.cpp
|
||||
SearchVisitor.cpp
|
||||
ImGuiToolkit.cpp
|
||||
ImGuiVisitor.cpp
|
||||
InfoVisitor.cpp
|
||||
GstToolkit.cpp
|
||||
GlmToolkit.cpp
|
||||
SystemToolkit.cpp
|
||||
DialogToolkit.cpp
|
||||
tinyxml2Toolkit.cpp
|
||||
NetworkToolkit.cpp
|
||||
Connection.cpp
|
||||
ActionManager.cpp
|
||||
Overlay.cpp
|
||||
Metronome.cpp
|
||||
ControlManager.cpp
|
||||
)
|
||||
#
|
||||
# CMake RC module
|
||||
#
|
||||
|
||||
# Include the CMake RC module
|
||||
include(CMakeRC)
|
||||
message(STATUS "Using 'CMakeRC ' from https://github.com/vector-of-bool/cmrc.git -- ${CMAKE_MODULE_PATH}.")
|
||||
|
||||
# set the files to package
|
||||
set(VMIX_RSC_FILES
|
||||
${ROBOTO_REGULAR}
|
||||
${ROBOTO_BOLD}
|
||||
${ROBOTO_ITALIC}
|
||||
${HACK_REGULAR}
|
||||
${AWESOME_REGULAR}
|
||||
${AWESOME_SOLID}
|
||||
./rsc/shaders/simple.fs
|
||||
./rsc/shaders/simple.vs
|
||||
./rsc/shaders/texture.fs
|
||||
./rsc/shaders/texture.vs
|
||||
./rsc/shaders/image.fs
|
||||
./rsc/shaders/mask_elipse.fs
|
||||
./rsc/shaders/mask_box.fs
|
||||
@@ -355,12 +523,6 @@ set(VMIX_RSC_FILES
|
||||
./rsc/shaders/image.vs
|
||||
./rsc/shaders/imageprocessing.fs
|
||||
./rsc/shaders/imageblending.fs
|
||||
./rsc/fonts/Hack-Regular.ttf
|
||||
./rsc/fonts/Roboto-Regular.ttf
|
||||
./rsc/fonts/Roboto-Bold.ttf
|
||||
./rsc/fonts/Roboto-Italic.ttf
|
||||
./rsc/fonts/fa-regular-400.ttf
|
||||
./rsc/fonts/fa-solid-900.ttf
|
||||
./rsc/images/mask_vignette.png
|
||||
./rsc/images/mask_halo.png
|
||||
./rsc/images/mask_glow.png
|
||||
@@ -371,6 +533,7 @@ set(VMIX_RSC_FILES
|
||||
./rsc/images/mask_linear_left.png
|
||||
./rsc/images/mask_linear_right.png
|
||||
./rsc/images/vimix_256x256.png
|
||||
./rsc/images/vimix_crow_white.png
|
||||
./rsc/images/icons.dds
|
||||
./rsc/images/gradient_0_cross_linear.png
|
||||
./rsc/images/gradient_1_black_linear.png
|
||||
@@ -404,9 +567,12 @@ set(VMIX_RSC_FILES
|
||||
./rsc/mesh/border_handles_sharp.ply
|
||||
./rsc/mesh/border_handles_menu.ply
|
||||
./rsc/mesh/border_handles_crop.ply
|
||||
./rsc/mesh/border_handles_shape.ply
|
||||
./rsc/mesh/border_handles_lock.ply
|
||||
./rsc/mesh/border_handles_lock_open.ply
|
||||
./rsc/mesh/border_handles_shadow.ply
|
||||
./rsc/mesh/border_handles_arrows.ply
|
||||
./rsc/mesh/border_handles_roundcorner.ply
|
||||
./rsc/mesh/border_large_sharp.ply
|
||||
./rsc/mesh/border_vertical_overlay.ply
|
||||
./rsc/mesh/perspective_layer.ply
|
||||
@@ -419,6 +585,7 @@ set(VMIX_RSC_FILES
|
||||
./rsc/mesh/icon_video.ply
|
||||
./rsc/mesh/icon_image.ply
|
||||
./rsc/mesh/icon_render.ply
|
||||
./rsc/mesh/icon_pattern.ply
|
||||
./rsc/mesh/icon_gear.ply
|
||||
./rsc/mesh/icon_camera.ply
|
||||
./rsc/mesh/icon_share.ply
|
||||
@@ -426,7 +593,6 @@ set(VMIX_RSC_FILES
|
||||
./rsc/mesh/icon_vimix.ply
|
||||
./rsc/mesh/icon_group_vimix.ply
|
||||
./rsc/mesh/icon_circles.ply
|
||||
./rsc/mesh/icon_dots.ply
|
||||
./rsc/mesh/icon_empty.ply
|
||||
./rsc/mesh/icon_lock.ply
|
||||
./rsc/mesh/icon_unlock.ply
|
||||
@@ -436,97 +602,81 @@ set(VMIX_RSC_FILES
|
||||
./rsc/mesh/icon_clock.ply
|
||||
./rsc/mesh/icon_clock_hand.ply
|
||||
./rsc/mesh/icon_grid.ply
|
||||
./rsc/mesh/icon_rightarrow.ply
|
||||
./rsc/mesh/icon_crop.ply
|
||||
./rsc/mesh/icon_eye.ply
|
||||
./rsc/mesh/icon_eye_slash.ply
|
||||
./rsc/mesh/icon_vector_square_slash.ply
|
||||
./rsc/mesh/icon_tv.ply
|
||||
./rsc/mesh/icon_cube.ply
|
||||
./rsc/mesh/icon_sequence.ply
|
||||
./rsc/mesh/icon_receive.ply
|
||||
./rsc/mesh/icon_text.ply
|
||||
./rsc/mesh/icon_play.ply
|
||||
./rsc/mesh/icon_fastforward.ply
|
||||
./rsc/mesh/icon_blend_normal.ply
|
||||
./rsc/mesh/icon_blend_add.ply
|
||||
./rsc/mesh/icon_blend_subtract.ply
|
||||
./rsc/mesh/icon_blend_mult.ply
|
||||
./rsc/mesh/icon_blend_soft_light.ply
|
||||
./rsc/mesh/icon_blend_hard_light.ply
|
||||
./rsc/mesh/icon_blend_soft_sub.ply
|
||||
./rsc/mesh/icon_blend_lighten.ply
|
||||
./rsc/mesh/h_line.ply
|
||||
./rsc/mesh/h_mark.ply
|
||||
./rsc/shaders/filters/default.glsl
|
||||
./rsc/shaders/filters/blend.glsl
|
||||
./rsc/shaders/filters/bloom.glsl
|
||||
./rsc/shaders/filters/bokeh.glsl
|
||||
./rsc/shaders/filters/talk.glsl
|
||||
./rsc/shaders/filters/fisheye.glsl
|
||||
./rsc/shaders/filters/blur.glsl
|
||||
./rsc/shaders/filters/blur_1.glsl
|
||||
./rsc/shaders/filters/blur_2.glsl
|
||||
./rsc/shaders/filters/lens_1.glsl
|
||||
./rsc/shaders/filters/lens_2.glsl
|
||||
./rsc/shaders/filters/hashedblur.glsl
|
||||
./rsc/shaders/filters/circularblur.glsl
|
||||
./rsc/shaders/filters/hashederosion.glsl
|
||||
./rsc/shaders/filters/hasheddilation.glsl
|
||||
./rsc/shaders/filters/sharp.glsl
|
||||
./rsc/shaders/filters/sharpen.glsl
|
||||
./rsc/shaders/filters/sharpen_1.glsl
|
||||
./rsc/shaders/filters/sharpen_2.glsl
|
||||
./rsc/shaders/filters/contour_2.glsl
|
||||
./rsc/shaders/filters/sharpenedge.glsl
|
||||
./rsc/shaders/filters/chromakey.glsl
|
||||
./rsc/shaders/filters/lumakey.glsl
|
||||
./rsc/shaders/filters/coloralpha.glsl
|
||||
./rsc/shaders/filters/bilinear.glsl
|
||||
./rsc/shaders/filters/edge.glsl
|
||||
./rsc/shaders/filters/sobel.glsl
|
||||
./rsc/shaders/filters/freichen.glsl
|
||||
./rsc/shaders/filters/kuwahara.glsl
|
||||
./rsc/shaders/filters/pixelate.glsl
|
||||
./rsc/shaders/filters/focus.glsl
|
||||
./rsc/shaders/filters/denoise.glsl
|
||||
./rsc/shaders/filters/noise.glsl
|
||||
./rsc/shaders/filters/grain.glsl
|
||||
./rsc/shaders/filters/stippling.glsl
|
||||
./rsc/shaders/filters/dithering.glsl
|
||||
./rsc/shaders/filters/erosion.glsl
|
||||
./rsc/shaders/filters/dilation.glsl
|
||||
./rsc/shaders/filters/tophat.glsl
|
||||
./rsc/shaders/filters/blackhat.glsl
|
||||
./rsc/shaders/filters/resample_double.glsl
|
||||
./rsc/shaders/filters/resample_half.glsl
|
||||
./rsc/shaders/filters/resample_quarter.glsl
|
||||
./rsc/shaders/filters/earlybird.glsl
|
||||
./rsc/shaders/filters/logo.glsl
|
||||
./rsc/shaders/filters/whitebalance.glsl
|
||||
./rsc/images/logo.vmx
|
||||
)
|
||||
|
||||
# Include the CMake RC module
|
||||
include(CMakeRC)
|
||||
cmrc_add_resource_library(vmix-resources ALIAS vmix::rc NAMESPACE vmix WHENCE rsc ${VMIX_RSC_FILES})
|
||||
message(STATUS "Using 'CMakeRC ' from https://github.com/vector-of-bool/cmrc.git -- ${CMAKE_MODULE_PATH}.")
|
||||
|
||||
### DEFINE THE TARGET (OS specific)
|
||||
|
||||
IF(APPLE)
|
||||
|
||||
# set icon
|
||||
set(MACOSX_BUNDLE_ICON vimix.icns)
|
||||
set(MACOSX_BUNDLE_ICON_FILE ${CMAKE_SOURCE_DIR}/osx/${MACOSX_BUNDLE_ICON})
|
||||
# set where in the bundle to put the icns file
|
||||
set_source_files_properties(${MACOSX_BUNDLE_ICON_FILE} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
|
||||
|
||||
# create the application
|
||||
add_executable(${VMIX_BINARY} MACOSX_BUNDLE
|
||||
${VMIX_SRCS}
|
||||
${IMGUITEXTEDIT_SRC}
|
||||
${MACOSX_BUNDLE_ICON_FILE}
|
||||
)
|
||||
|
||||
# set the Info.plist file
|
||||
set(MACOSX_BUNDLE_PLIST_FILE ${CMAKE_SOURCE_DIR}/osx/Info.plist)
|
||||
set_target_properties(${VMIX_BINARY} PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${MACOSX_BUNDLE_PLIST_FILE})
|
||||
|
||||
set(PLATFORM_LIBS
|
||||
"-framework CoreFoundation"
|
||||
"-framework Appkit"
|
||||
)
|
||||
|
||||
ELSE(APPLE)
|
||||
|
||||
link_directories (${GTK3_LIBRARY_DIRS})
|
||||
|
||||
add_executable(${VMIX_BINARY}
|
||||
${VMIX_SRCS}
|
||||
${IMGUITEXTEDIT_SRC}
|
||||
)
|
||||
|
||||
set(PLATFORM_LIBS
|
||||
GTK::GTK
|
||||
)
|
||||
|
||||
ENDIF(APPLE)
|
||||
|
||||
### COMPILE THE TARGET (all OS)
|
||||
|
||||
set_property(TARGET ${VMIX_BINARY} PROPERTY CXX_STANDARD 17)
|
||||
set_property(TARGET ${VMIX_BINARY} PROPERTY C_STANDARD 11)
|
||||
|
||||
target_compile_definitions(${VMIX_BINARY} PUBLIC "IMGUI_IMPL_OPENGL_LOADER_GLAD")
|
||||
|
||||
target_link_libraries(${VMIX_BINARY} LINK_PRIVATE
|
||||
vmix::rc
|
||||
glm::glm
|
||||
GLAD
|
||||
TINYXML2
|
||||
IMGUI
|
||||
OSCPACK
|
||||
${TINYFD_LIBRARY}
|
||||
${GLFW3_LIBRARIES}
|
||||
${ICU_LIBRARIES}
|
||||
${CMAKE_DL_LIBS}
|
||||
${GOBJECT_LIBRARIES}
|
||||
${GSTREAMER_LIBRARY}
|
||||
${GSTREAMER_BASE_LIBRARY}
|
||||
${GSTREAMER_APP_LIBRARY}
|
||||
${GSTREAMER_AUDIO_LIBRARY}
|
||||
${GSTREAMER_VIDEO_LIBRARY}
|
||||
${GSTREAMER_PBUTILS_LIBRARY}
|
||||
${GSTREAMER_GL_LIBRARY}
|
||||
Threads::Threads
|
||||
PNG::PNG
|
||||
Ableton::Link
|
||||
${PLATFORM_LIBS}
|
||||
)
|
||||
|
||||
|
||||
### DEFINE THE PACKAGING (all OS)
|
||||
#####
|
||||
##### DEFINE THE PACKAGING (all OS)
|
||||
#####
|
||||
|
||||
SET(CPACK_PACKAGE_NAME "vimix")
|
||||
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "vimix\nReal-time video mixing for live performance.")
|
||||
@@ -543,127 +693,15 @@ SET(CPACK_SOURCE_IGNORE_FILES
|
||||
"/\\\\.gitignore$"
|
||||
"/\\\\.gitmodules$"
|
||||
)
|
||||
|
||||
|
||||
# optimize size ?
|
||||
SET(CPACK_STRIP_FILES TRUE)
|
||||
|
||||
### DEFINE THE PACKAGING (OS specific)
|
||||
|
||||
IF(APPLE)
|
||||
|
||||
# Bundle target
|
||||
set(CPACK_GENERATOR DragNDrop)
|
||||
set(CPACK_BINARY_DRAGNDROP ON)
|
||||
|
||||
# OSX cpack info
|
||||
set(CPACK_SYSTEM_NAME "OSX_${CMAKE_OSX_DEPLOYMENT_TARGET}_${CMAKE_OSX_ARCHITECTURES}")
|
||||
|
||||
install(TARGETS ${VMIX_BINARY}
|
||||
CONFIGURATIONS Release RelWithDebInfo
|
||||
BUNDLE DESTINATION . COMPONENT Runtime
|
||||
RUNTIME DESTINATION bin COMPONENT Runtime
|
||||
)
|
||||
|
||||
# create GST plugins directory in Bundle Resources subfolder
|
||||
set(plugin_dest_dir vimix.app/Contents/Resources/)
|
||||
|
||||
### TODO configure auto to find installation dir of gst
|
||||
|
||||
message(STATUS "install gst-plugins ${PKG_GSTREAMER_PLUGIN_DIR}")
|
||||
message(STATUS "install gst-plugins-base ${PKG_GSTREAMER_BASE_PLUGIN_DIR}")
|
||||
|
||||
if (PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(PKG_GSTREAMER_PLUGINS_BAD gstreamer-plugins-bad-${GSTREAMER_ABI_VERSION})
|
||||
set(PKG_GSTREAMER_BAD_PLUGIN_DIR ${PKG_GSTREAMER_PLUGINS_BAD_LIBDIR}/gstreamer-${GSTREAMER_ABI_VERSION})
|
||||
message(STATUS "install gst-plugins-bad ${PKG_GSTREAMER_BAD_PLUGIN_DIR}")
|
||||
endif()
|
||||
|
||||
|
||||
# intall the gst-plugin-scanner program (used by plugins at load time)
|
||||
set(PKG_GSTREAMER_SCANNER "${PKG_GSTREAMER_PREFIX}/libexec/gstreamer-1.0/gst-plugin-scanner")
|
||||
message(STATUS "install gst-plugin-scanner ${PKG_GSTREAMER_SCANNER}")
|
||||
install(FILES "${PKG_GSTREAMER_SCANNER}"
|
||||
DESTINATION "${plugin_dest_dir}"
|
||||
PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
|
||||
COMPONENT Runtime
|
||||
)
|
||||
|
||||
# Install the gst-plugins (all those installed with brew )
|
||||
install(DIRECTORY "${PKG_GSTREAMER_PLUGIN_DIR}" DESTINATION "${plugin_dest_dir}" COMPONENT Runtime)
|
||||
install(DIRECTORY "${PKG_GSTREAMER_BASE_PLUGIN_DIR}" DESTINATION "${plugin_dest_dir}" COMPONENT Runtime)
|
||||
install(DIRECTORY "${PKG_GSTREAMER_BAD_PLUGIN_DIR}" DESTINATION "${plugin_dest_dir}" COMPONENT Runtime)
|
||||
|
||||
install(DIRECTORY "/usr/local/Cellar/gst-plugins-good/1.18.4/lib/gstreamer-1.0" DESTINATION "${plugin_dest_dir}" COMPONENT Runtime)
|
||||
install(DIRECTORY "/usr/local/Cellar/gst-plugins-ugly/1.18.4_1/lib/gstreamer-1.0" DESTINATION "${plugin_dest_dir}" COMPONENT Runtime)
|
||||
install(DIRECTORY "/usr/local/Cellar/gst-libav/1.18.4/lib/gstreamer-1.0" DESTINATION "${plugin_dest_dir}" COMPONENT Runtime)
|
||||
|
||||
# install locally recompiled & installed gst-plugins (because not included in brew package)
|
||||
install(FILES "/usr/local/lib/gstreamer-1.0/libgstapplemedia.dylib"
|
||||
"/usr/local/lib/gstreamer-1.0/libgstde265.dylib"
|
||||
"/usr/local/lib/gstreamer-1.0/libgstx265.dylib"
|
||||
DESTINATION "${plugin_dest_dir}/gstreamer-1.0" COMPONENT Runtime)
|
||||
|
||||
# install frei0r plugins (dependencies of gstreamer-1.0/libgstfrei0r.dylib plugin)
|
||||
install(FILES "/usr/local/Cellar/frei0r/1.7.0/lib/frei0r-1/lissajous0r.so"
|
||||
"/usr/local/Cellar/frei0r/1.7.0/lib/frei0r-1/rgbnoise.so"
|
||||
DESTINATION "${plugin_dest_dir}/frei0r-1" COMPONENT Runtime)
|
||||
|
||||
|
||||
# ICU DATA LIB GST dependency : undocumented and hacked here : seems to work
|
||||
# install(FILES "${ICU_LINK_LIBRARIES}" DESTINATION "${plugin_dest_dir}/gstreamer-1.0" COMPONENT Runtime)
|
||||
install(FILES "/usr/local/Cellar/icu4c/69.1/lib/libicudata.69.1.dylib" DESTINATION "${plugin_dest_dir}/gstreamer-1.0" RENAME "libicudata.69.dylib" COMPONENT Runtime)
|
||||
message(STATUS "install ${ICU_LINK_LIBRARIES} from ${ICU_LIBRARY_DIRS}")
|
||||
|
||||
# package runtime fixup bundle
|
||||
set(APPS "\${CMAKE_INSTALL_PREFIX}/vimix.app")
|
||||
install(CODE "
|
||||
file(GLOB_RECURSE GSTPLUGINS \"\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/gstreamer-1.0/*.dylib\")
|
||||
list(APPEND LIBS_PATH \"\${ICU_LIBRARY_DIRS}\")
|
||||
include(BundleUtilities)
|
||||
set(BU_CHMOD_BUNDLE_ITEMS TRUE)
|
||||
fixup_bundle(\"${APPS}\" \"\${GSTPLUGINS}\" \"${LIBS_PATH}\")
|
||||
"
|
||||
COMPONENT Runtime
|
||||
)
|
||||
|
||||
set(APPLE_CODESIGN_ENTITLEMENTS "${CMAKE_CURRENT_SOURCE_DIR}/osx/entitlements.plist")
|
||||
set(APPLE_CODESIGN_IDENTITY "" CACHE STRING "")
|
||||
string(LENGTH "${APPLE_CODESIGN_IDENTITY}" APPLE_CODESIGN_IDENTITY_LENGHT)
|
||||
if( ${APPLE_CODESIGN_IDENTITY_LENGHT} LESS 40 )
|
||||
message(STATUS "Not signing bundle. Specify APPLE_CODESIGN_IDENTITY to cmake before running cpack to sign")
|
||||
else()
|
||||
install(CODE "
|
||||
execute_process(COMMAND
|
||||
codesign --verbose=4 --deep --force
|
||||
--entitlements \"${APPLE_CODESIGN_ENTITLEMENTS}\"
|
||||
--sign \"${APPLE_CODESIGN_IDENTITY}\"
|
||||
\"${APPS}\" )
|
||||
"
|
||||
COMPONENT Runtime
|
||||
)
|
||||
endif()
|
||||
|
||||
# # package runtime fixup bundle and codesign
|
||||
# set(BUNDLE_NAME "vimix.app")
|
||||
# set(BUNDLE_LIBS_DIR "${plugin_dest_dir}/gstreamer-1.0")
|
||||
# set(BUNDLE_DIRS "${ICU_LIBRARY_DIRS}")
|
||||
# set(APPLE_CODESIGN_ENTITLEMENTS "${CMAKE_CURRENT_SOURCE_DIR}/osx/entitlements.plist")
|
||||
|
||||
# configure_file(cmake/modules/BundleInstall.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/BundleInstall.cmake" @ONLY)
|
||||
# install(SCRIPT "${CMAKE_CURRENT_BINARY_DIR}/BundleInstall.cmake" COMPONENT Runtime)
|
||||
|
||||
ELSE(APPLE)
|
||||
|
||||
install(TARGETS ${VMIX_BINARY}
|
||||
CONFIGURATIONS Release RelWithDebInfo
|
||||
RUNTIME DESTINATION bin COMPONENT Runtime
|
||||
)
|
||||
|
||||
ENDIF(APPLE)
|
||||
|
||||
# Package full name
|
||||
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}_${CPACK_SYSTEM_NAME}")
|
||||
set(CPACK_STRIP_FILES TRUE)
|
||||
|
||||
|
||||
#####
|
||||
##### Build Application
|
||||
#####
|
||||
add_subdirectory(src)
|
||||
|
||||
|
||||
# To Create a package, run "cpack"
|
||||
include(CPack)
|
||||
|
||||
@@ -1,756 +0,0 @@
|
||||
/*
|
||||
* This file is part of vimix - video live mixer
|
||||
*
|
||||
* **Copyright** (C) 2019-2022 Bruno Herbelin <bruno.herbelin@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 3 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 <thread>
|
||||
#include <mutex>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
#include "osc/OscOutboundPacketStream.h"
|
||||
|
||||
#include "defines.h"
|
||||
#include "Log.h"
|
||||
#include "Settings.h"
|
||||
#include "BaseToolkit.h"
|
||||
#include "Mixer.h"
|
||||
#include "Source.h"
|
||||
#include "ActionManager.h"
|
||||
#include "SystemToolkit.h"
|
||||
#include "tinyxml2Toolkit.h"
|
||||
|
||||
#include "ControlManager.h"
|
||||
|
||||
#ifndef NDEBUG
|
||||
#define CONTROL_DEBUG
|
||||
#endif
|
||||
|
||||
#define CONTROL_OSC_MSG "OSC: "
|
||||
|
||||
|
||||
void Control::RequestListener::ProcessMessage( const osc::ReceivedMessage& m,
|
||||
const IpEndpointName& remoteEndpoint )
|
||||
{
|
||||
char sender[IpEndpointName::ADDRESS_AND_PORT_STRING_LENGTH];
|
||||
remoteEndpoint.AddressAndPortAsString(sender);
|
||||
|
||||
try{
|
||||
#ifdef CONTROL_DEBUG
|
||||
Log::Info(CONTROL_OSC_MSG "received '%s' from %s", FullMessage(m).c_str(), sender);
|
||||
#endif
|
||||
// Preprocessing with Translator
|
||||
std::string address_pattern = Control::manager().translate(m.AddressPattern());
|
||||
|
||||
// structured OSC address
|
||||
std::list<std::string> address = BaseToolkit::splitted(address_pattern, OSC_SEPARATOR);
|
||||
//
|
||||
// A wellformed OSC address is in the form '/vimix/target/attribute {arguments}'
|
||||
// First test: should have 3 elements and start with APP_NAME ('vimix')
|
||||
//
|
||||
if (address.size() > 2 && address.front().compare(OSC_PREFIX) == 0 ){
|
||||
// done with the first part of the OSC address
|
||||
address.pop_front();
|
||||
// next part of the OSC message is the target
|
||||
std::string target = address.front();
|
||||
// next part of the OSC message is the attribute
|
||||
address.pop_front();
|
||||
std::string attribute = address.front();
|
||||
// Log target: just print text in log window
|
||||
if ( target.compare(OSC_INFO) == 0 )
|
||||
{
|
||||
if ( attribute.compare(OSC_INFO_NOTIFY) == 0) {
|
||||
Log::Notify(CONTROL_OSC_MSG "Received '%s' from %s", FullMessage(m).c_str(), sender);
|
||||
}
|
||||
else if ( attribute.compare(OSC_INFO_LOG) == 0) {
|
||||
Log::Info(CONTROL_OSC_MSG "Received '%s' from %s", FullMessage(m).c_str(), sender);
|
||||
}
|
||||
}
|
||||
// Output target: concerns attributes of the rendering output
|
||||
else if ( target.compare(OSC_OUTPUT) == 0 )
|
||||
{
|
||||
if ( Control::manager().receiveOutputAttribute(attribute, m.ArgumentStream())) {
|
||||
// send the global status
|
||||
Control::manager().sendOutputStatus(remoteEndpoint);
|
||||
}
|
||||
}
|
||||
// Session target: concerns attributes of the session
|
||||
else if ( target.compare(OSC_SESSION) == 0 )
|
||||
{
|
||||
if ( Control::manager().receiveSessionAttribute(attribute, m.ArgumentStream()) ) {
|
||||
// send the global status
|
||||
Control::manager().sendOutputStatus(remoteEndpoint);
|
||||
// send the status of all sources
|
||||
Control::manager().sendSourcesStatus(remoteEndpoint, m.ArgumentStream());
|
||||
}
|
||||
}
|
||||
// ALL sources target: apply attribute to all sources of the session
|
||||
else if ( target.compare(OSC_ALL) == 0 )
|
||||
{
|
||||
// Loop over selected sources
|
||||
for (SourceList::iterator it = Mixer::manager().session()->begin(); it != Mixer::manager().session()->end(); ++it) {
|
||||
// apply attributes
|
||||
if ( Control::manager().receiveSourceAttribute( *it, attribute, m.ArgumentStream()) && Mixer::manager().currentSource() == *it)
|
||||
// and send back feedback if needed
|
||||
Control::manager().sendSourceAttibutes(remoteEndpoint, OSC_CURRENT);
|
||||
}
|
||||
}
|
||||
// Selected sources target: apply attribute to all sources of the selection
|
||||
else if ( target.compare(OSC_SELECTED) == 0 )
|
||||
{
|
||||
// Loop over selected sources
|
||||
for (SourceList::iterator it = Mixer::selection().begin(); it != Mixer::selection().end(); ++it) {
|
||||
// apply attributes
|
||||
if ( Control::manager().receiveSourceAttribute( *it, attribute, m.ArgumentStream()) && Mixer::manager().currentSource() == *it)
|
||||
// and send back feedback if needed
|
||||
Control::manager().sendSourceAttibutes(remoteEndpoint, OSC_CURRENT);
|
||||
}
|
||||
}
|
||||
// Current source target: apply attribute to the current sources
|
||||
else if ( target.compare(OSC_CURRENT) == 0 )
|
||||
{
|
||||
int sourceid = -1;
|
||||
if ( attribute.compare(OSC_SYNC) == 0) {
|
||||
// send the status of all sources
|
||||
Control::manager().sendSourcesStatus(remoteEndpoint, m.ArgumentStream());
|
||||
}
|
||||
else if ( attribute.compare(OSC_NEXT) == 0) {
|
||||
// set current to NEXT
|
||||
Mixer::manager().setCurrentNext();
|
||||
// send the status of all sources
|
||||
Control::manager().sendSourcesStatus(remoteEndpoint, m.ArgumentStream());
|
||||
}
|
||||
else if ( attribute.compare(OSC_PREVIOUS) == 0) {
|
||||
// set current to PREVIOUS
|
||||
Mixer::manager().setCurrentPrevious();
|
||||
// send the status of all sources
|
||||
Control::manager().sendSourcesStatus(remoteEndpoint, m.ArgumentStream());
|
||||
}
|
||||
else if ( BaseToolkit::is_a_number( attribute.substr(1), &sourceid) ){
|
||||
// set current to given INDEX
|
||||
Mixer::manager().setCurrentIndex(sourceid);
|
||||
// send the status of all sources
|
||||
Control::manager().sendSourcesStatus(remoteEndpoint, m.ArgumentStream());
|
||||
}
|
||||
// all other attributes operate on current source
|
||||
else {
|
||||
// apply attributes to current source
|
||||
if ( Control::manager().receiveSourceAttribute( Mixer::manager().currentSource(), attribute, m.ArgumentStream()) )
|
||||
// and send back feedback if needed
|
||||
Control::manager().sendSourceAttibutes(remoteEndpoint, OSC_CURRENT);
|
||||
}
|
||||
}
|
||||
// General case: try to identify the target
|
||||
else {
|
||||
// try to find source by index
|
||||
Source *s = nullptr;
|
||||
int sourceid = -1;
|
||||
if ( BaseToolkit::is_a_number(target.substr(1), &sourceid) )
|
||||
s = Mixer::manager().sourceAtIndex(sourceid);
|
||||
|
||||
// if failed, try to find source by name
|
||||
if (s == nullptr)
|
||||
s = Mixer::manager().findSource(target.substr(1));
|
||||
|
||||
// if a source with the given target name or index was found
|
||||
if (s) {
|
||||
// apply attributes to source
|
||||
if ( Control::manager().receiveSourceAttribute(s, attribute, m.ArgumentStream()) )
|
||||
// and send back feedback if needed
|
||||
Control::manager().sendSourceAttibutes(remoteEndpoint, target, s);
|
||||
}
|
||||
else
|
||||
Log::Info(CONTROL_OSC_MSG "Unknown target '%s' requested by %s.", target.c_str(), sender);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Log::Info(CONTROL_OSC_MSG "Unknown osc message '%s' sent by %s.", m.AddressPattern(), sender);
|
||||
}
|
||||
}
|
||||
catch( osc::Exception& e ){
|
||||
// any parsing errors such as unexpected argument types, or
|
||||
// missing arguments get thrown as exceptions.
|
||||
Log::Info(CONTROL_OSC_MSG "Ignoring error in message '%s' from %s : %s", m.AddressPattern(), sender, e.what());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::string Control::RequestListener::FullMessage( const osc::ReceivedMessage& m )
|
||||
{
|
||||
// build a string with the address pattern of the message
|
||||
std::ostringstream message;
|
||||
message << m.AddressPattern() << " ";
|
||||
|
||||
// try to fill the string with the arguments
|
||||
std::ostringstream arguments;
|
||||
try{
|
||||
// loop over all arguments
|
||||
osc::ReceivedMessage::const_iterator arg = m.ArgumentsBegin();
|
||||
while (arg != m.ArgumentsEnd()) {
|
||||
if( arg->IsBool() ){
|
||||
bool a = (arg++)->AsBoolUnchecked();
|
||||
message << (a ? "T" : "F");
|
||||
}
|
||||
else if( arg->IsInt32() ){
|
||||
int a = (arg++)->AsInt32Unchecked();
|
||||
message << "i";
|
||||
arguments << " " << a;
|
||||
}
|
||||
else if( arg->IsFloat() ){
|
||||
float a = (arg++)->AsFloatUnchecked();
|
||||
message << "f";
|
||||
arguments << " " << std::fixed << std::setprecision(2) << a;
|
||||
}
|
||||
else if( arg->IsString() ){
|
||||
const char *a = (arg++)->AsStringUnchecked();
|
||||
message << "s";
|
||||
arguments << " " << a;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( osc::Exception& e ){
|
||||
// any parsing errors such as unexpected argument types, or
|
||||
// missing arguments get thrown as exceptions.
|
||||
Log::Info(CONTROL_OSC_MSG "Ignoring error in message '%s': %s", m.AddressPattern(), e.what());
|
||||
}
|
||||
|
||||
// append list of arguments to the message string
|
||||
message << arguments.str();
|
||||
|
||||
// returns the full message
|
||||
return message.str();
|
||||
}
|
||||
|
||||
|
||||
Control::Control() : receiver_(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
Control::~Control()
|
||||
{
|
||||
terminate();
|
||||
}
|
||||
|
||||
|
||||
std::string Control::translate (std::string addresspattern)
|
||||
{
|
||||
auto it_translation = translation_.find(addresspattern);
|
||||
if ( it_translation != translation_.end() )
|
||||
return it_translation->second;
|
||||
else
|
||||
return addresspattern;
|
||||
}
|
||||
|
||||
void Control::loadOscConfig()
|
||||
{
|
||||
// reset translations
|
||||
translation_.clear();
|
||||
|
||||
// load osc config file
|
||||
tinyxml2::XMLDocument xmlDoc;
|
||||
tinyxml2::XMLError eResult = xmlDoc.LoadFile(Settings::application.control.osc_filename.c_str());
|
||||
|
||||
// the only reason to return false is if the file does not exist or is empty
|
||||
if (eResult == tinyxml2::XML_ERROR_FILE_NOT_FOUND
|
||||
| eResult == tinyxml2::XML_ERROR_FILE_COULD_NOT_BE_OPENED
|
||||
| eResult == tinyxml2::XML_ERROR_FILE_READ_ERROR
|
||||
| eResult == tinyxml2::XML_ERROR_EMPTY_DOCUMENT )
|
||||
resetOscConfig();
|
||||
|
||||
// found the file, could open and read it
|
||||
else if (eResult != tinyxml2::XML_SUCCESS)
|
||||
Log::Warning(CONTROL_OSC_MSG "Error while parsing Translator: %s", xmlDoc.ErrorIDToName(eResult));
|
||||
|
||||
// no XML parsing error
|
||||
else {
|
||||
// parse all entries 'osc'
|
||||
tinyxml2::XMLElement* osc = xmlDoc.FirstChildElement("osc");
|
||||
for( ; osc ; osc=osc->NextSiblingElement()) {
|
||||
// get the 'from' entry
|
||||
tinyxml2::XMLElement* from = osc->FirstChildElement("from");
|
||||
if (from) {
|
||||
const char *str_from = from->GetText();
|
||||
if (str_from) {
|
||||
// get the 'to' entry
|
||||
tinyxml2::XMLElement* to = osc->FirstChildElement("to");
|
||||
if (to) {
|
||||
const char *str_to = to->GetText();
|
||||
// if could get both; add to translator
|
||||
if (str_to)
|
||||
translation_[str_from] = str_to;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Log::Info(CONTROL_OSC_MSG "Loaded %d translation%s.", translation_.size(), translation_.size()>1?"s":"");
|
||||
}
|
||||
|
||||
void Control::resetOscConfig()
|
||||
{
|
||||
// generate a template xml translation dictionnary
|
||||
tinyxml2::XMLDocument xmlDoc;
|
||||
tinyxml2::XMLDeclaration *pDec = xmlDoc.NewDeclaration();
|
||||
xmlDoc.InsertFirstChild(pDec);
|
||||
tinyxml2::XMLComment *pComment = xmlDoc.NewComment("The OSC translator converts OSC address patterns into other ones.\n"
|
||||
"Complete the dictionnary by adding as many <osc> translations as you want.\n"
|
||||
"Each <osc> should contain a <from> pattern to translate into a <to> pattern.\n"
|
||||
"More at https://github.com/brunoherbelin/vimix/wiki/Open-Sound-Control-API.");
|
||||
xmlDoc.InsertEndChild(pComment);
|
||||
tinyxml2::XMLElement *from = xmlDoc.NewElement( "from" );
|
||||
from->InsertFirstChild( xmlDoc.NewText("/example/osc/message") );
|
||||
tinyxml2::XMLElement *to = xmlDoc.NewElement( "to" );
|
||||
to->InsertFirstChild( xmlDoc.NewText("/vimix/info/log") );
|
||||
tinyxml2::XMLElement *osc = xmlDoc.NewElement("osc");
|
||||
osc->InsertEndChild(from);
|
||||
osc->InsertEndChild(to);
|
||||
xmlDoc.InsertEndChild(osc);
|
||||
|
||||
// save xml in osc config file
|
||||
xmlDoc.SaveFile(Settings::application.control.osc_filename.c_str());
|
||||
|
||||
// reset and fill translation with default example
|
||||
translation_.clear();
|
||||
translation_["/example/osc/message"] = "/vimix/info/log";
|
||||
}
|
||||
|
||||
bool Control::init()
|
||||
{
|
||||
//
|
||||
// terminate before init (allows calling init() multiple times)
|
||||
//
|
||||
terminate();
|
||||
|
||||
//
|
||||
// load OSC Translator
|
||||
//
|
||||
loadOscConfig();
|
||||
|
||||
//
|
||||
// launch OSC listener
|
||||
//
|
||||
try {
|
||||
// try to create listenning socket
|
||||
// through exception runtime if fails
|
||||
receiver_ = new UdpListeningReceiveSocket( IpEndpointName( IpEndpointName::ANY_ADDRESS,
|
||||
Settings::application.control.osc_port_receive ), &listener_ );
|
||||
// listen for answers in a separate thread
|
||||
std::thread(listen).detach();
|
||||
|
||||
// inform user
|
||||
IpEndpointName ip = receiver_->LocalEndpointFor( IpEndpointName( NetworkToolkit::hostname().c_str(),
|
||||
Settings::application.control.osc_port_receive ));
|
||||
static char *addresseip = (char *)malloc(IpEndpointName::ADDRESS_AND_PORT_STRING_LENGTH);
|
||||
ip.AddressAndPortAsString(addresseip);
|
||||
Log::Info(CONTROL_OSC_MSG "Listening to UDP messages sent to %s", addresseip);
|
||||
}
|
||||
catch (const std::runtime_error &e) {
|
||||
// arg, the receiver could not be initialized
|
||||
// (often because the port was not available)
|
||||
receiver_ = nullptr;
|
||||
Log::Warning(CONTROL_OSC_MSG "Failed to init listener on port %d; %s", Settings::application.control.osc_port_receive, e.what());
|
||||
}
|
||||
|
||||
return receiver_ != nullptr;
|
||||
}
|
||||
|
||||
void Control::listen()
|
||||
{
|
||||
if (Control::manager().receiver_)
|
||||
Control::manager().receiver_->Run();
|
||||
|
||||
Control::manager().receiver_end_.notify_all();
|
||||
}
|
||||
|
||||
void Control::terminate()
|
||||
{
|
||||
if ( receiver_ != nullptr ) {
|
||||
|
||||
// request termination of receiver
|
||||
receiver_->AsynchronousBreak();
|
||||
|
||||
// wait for the receiver_end_ notification
|
||||
std::mutex mtx;
|
||||
std::unique_lock<std::mutex> lck(mtx);
|
||||
// if waited more than 2 seconds, its dead :(
|
||||
if ( receiver_end_.wait_for(lck,std::chrono::seconds(2)) == std::cv_status::timeout)
|
||||
Log::Warning(CONTROL_OSC_MSG "Failed to terminate; try again.");
|
||||
|
||||
// delete receiver and ready to initialize
|
||||
delete receiver_;
|
||||
receiver_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Control::receiveOutputAttribute(const std::string &attribute,
|
||||
osc::ReceivedMessageArgumentStream arguments)
|
||||
{
|
||||
bool need_feedback = false;
|
||||
|
||||
try {
|
||||
if ( attribute.compare(OSC_SYNC) == 0) {
|
||||
need_feedback = true;
|
||||
}
|
||||
/// e.g. '/vimix/output/enable' or '/vimix/output/enable 1.0' or '/vimix/output/enable 0.0'
|
||||
else if ( attribute.compare(OSC_OUTPUT_ENABLE) == 0) {
|
||||
float on = 1.f;
|
||||
if ( !arguments.Eos()) {
|
||||
arguments >> on >> osc::EndMessage;
|
||||
}
|
||||
Settings::application.render.disabled = on < 0.5f;
|
||||
}
|
||||
/// e.g. '/vimix/output/disable' or '/vimix/output/disable 1.0' or '/vimix/output/disable 0.0'
|
||||
else if ( attribute.compare(OSC_OUTPUT_DISABLE) == 0) {
|
||||
float on = 1.f;
|
||||
if ( !arguments.Eos()) {
|
||||
arguments >> on >> osc::EndMessage;
|
||||
}
|
||||
Settings::application.render.disabled = on > 0.5f;
|
||||
}
|
||||
/// e.g. '/vimix/output/fading f 0.2' or '/vimix/output/fading ff 1.0 300.f'
|
||||
else if ( attribute.compare(OSC_OUTPUT_FADING) == 0) {
|
||||
float f = 0.f, d = 0.f;
|
||||
// first argument is fading value
|
||||
arguments >> f;
|
||||
if (arguments.Eos())
|
||||
arguments >> osc::EndMessage;
|
||||
// if a second argument is given, it is a duration
|
||||
else
|
||||
arguments >> d >> osc::EndMessage;
|
||||
Mixer::manager().session()->setFadingTarget(f, d);
|
||||
}
|
||||
/// e.g. '/vimix/output/fadein' or '/vimix/output/fadein f 300.f'
|
||||
else if ( attribute.compare(OSC_OUTPUT_FADE_IN) == 0) {
|
||||
float f = 0.f;
|
||||
// if argument is given, it is a duration
|
||||
if (!arguments.Eos())
|
||||
arguments >> f >> osc::EndMessage;
|
||||
Mixer::manager().session()->setFadingTarget( Mixer::manager().session()->fading() - f * 0.01);
|
||||
need_feedback = true;
|
||||
}
|
||||
else if ( attribute.compare(OSC_OUTPUT_FADE_OUT) == 0) {
|
||||
float f = 0.f;
|
||||
// if argument is given, it is a duration
|
||||
if (!arguments.Eos())
|
||||
arguments >> f >> osc::EndMessage;
|
||||
Mixer::manager().session()->setFadingTarget( Mixer::manager().session()->fading() + f * 0.01);
|
||||
need_feedback = true;
|
||||
}
|
||||
#ifdef CONTROL_DEBUG
|
||||
else {
|
||||
Log::Info(CONTROL_OSC_MSG "Ignoring attribute '%s' for target 'output'", attribute.c_str());
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
catch (osc::MissingArgumentException &e) {
|
||||
Log::Info(CONTROL_OSC_MSG "Missing argument for attribute '%s' for target 'output'", attribute.c_str());
|
||||
}
|
||||
catch (osc::ExcessArgumentException &e) {
|
||||
Log::Info(CONTROL_OSC_MSG "Too many arguments for attribute '%s' for target 'output'", attribute.c_str());
|
||||
}
|
||||
catch (osc::WrongArgumentTypeException &e) {
|
||||
Log::Info(CONTROL_OSC_MSG "Invalid argument for attribute '%s' for target 'output'", attribute.c_str());
|
||||
}
|
||||
|
||||
return need_feedback;
|
||||
}
|
||||
|
||||
bool Control::receiveSourceAttribute(Source *target, const std::string &attribute,
|
||||
osc::ReceivedMessageArgumentStream arguments)
|
||||
{
|
||||
bool send_feedback = false;
|
||||
|
||||
if (target == nullptr)
|
||||
return send_feedback;
|
||||
|
||||
try {
|
||||
/// e.g. '/vimix/current/play' or '/vimix/current/play T' or '/vimix/current/play F'
|
||||
if ( attribute.compare(OSC_SOURCE_PLAY) == 0) {
|
||||
float on = 1.f;
|
||||
if ( !arguments.Eos()) {
|
||||
arguments >> on >> osc::EndMessage;
|
||||
}
|
||||
target->call( new SetPlay(on > 0.5f) );
|
||||
}
|
||||
/// e.g. '/vimix/current/pause' or '/vimix/current/pause T' or '/vimix/current/pause F'
|
||||
else if ( attribute.compare(OSC_SOURCE_PAUSE) == 0) {
|
||||
float on = 1.f;
|
||||
if ( !arguments.Eos()) {
|
||||
arguments >> on >> osc::EndMessage;
|
||||
}
|
||||
target->call( new SetPlay(on < 0.5f) );
|
||||
}
|
||||
/// e.g. '/vimix/current/replay'
|
||||
else if ( attribute.compare(OSC_SOURCE_REPLAY) == 0) {
|
||||
target->call( new RePlay() );
|
||||
}
|
||||
/// e.g. '/vimix/current/alpha f 0.3'
|
||||
else if ( attribute.compare(OSC_SOURCE_LOCK) == 0) {
|
||||
float x = 1.f;
|
||||
arguments >> x >> osc::EndMessage;
|
||||
target->call( new SetLock(x > 0.5f ? true : false) );
|
||||
}
|
||||
/// e.g. '/vimix/current/alpha f 0.3'
|
||||
else if ( attribute.compare(OSC_SOURCE_ALPHA) == 0) {
|
||||
float x = 1.f;
|
||||
arguments >> x >> osc::EndMessage;
|
||||
target->call( new SetAlpha(x), true );
|
||||
}
|
||||
/// e.g. '/vimix/current/alpha f 0.3'
|
||||
else if ( attribute.compare(OSC_SOURCE_LOOM) == 0) {
|
||||
float x = 1.f;
|
||||
arguments >> x >> osc::EndMessage;
|
||||
target->call( new Loom(x), true );
|
||||
// this will require to send feedback status about source
|
||||
send_feedback = true;
|
||||
}
|
||||
/// e.g. '/vimix/current/transparency f 0.7'
|
||||
else if ( attribute.compare(OSC_SOURCE_TRANSPARENCY) == 0) {
|
||||
float x = 0.f;
|
||||
arguments >> x >> osc::EndMessage;
|
||||
target->call( new SetAlpha(1.f - x), true );
|
||||
}
|
||||
/// e.g. '/vimix/current/depth f 5.0'
|
||||
else if ( attribute.compare(OSC_SOURCE_DEPTH) == 0) {
|
||||
float x = 0.f;
|
||||
arguments >> x >> osc::EndMessage;
|
||||
target->call( new SetDepth(x), true );
|
||||
}
|
||||
/// e.g. '/vimix/current/translation ff 10.0 2.2'
|
||||
else if ( attribute.compare(OSC_SOURCE_GRAB) == 0) {
|
||||
float x = 0.f, y = 0.f;
|
||||
arguments >> x >> y >> osc::EndMessage;
|
||||
target->call( new Grab( x, y), true );
|
||||
}
|
||||
/// e.g. '/vimix/current/scale ff 10.0 2.2'
|
||||
else if ( attribute.compare(OSC_SOURCE_RESIZE) == 0) {
|
||||
float x = 0.f, y = 0.f;
|
||||
arguments >> x >> y >> osc::EndMessage;
|
||||
target->call( new Resize( x, y), true );
|
||||
}
|
||||
/// e.g. '/vimix/current/turn f 1.0'
|
||||
else if ( attribute.compare(OSC_SOURCE_TURN) == 0) {
|
||||
float x = 0.f, y = 0.f;
|
||||
arguments >> x;
|
||||
if (arguments.Eos())
|
||||
arguments >> osc::EndMessage;
|
||||
else // ignore second argument
|
||||
arguments >> y >> osc::EndMessage;
|
||||
target->call( new Turn( x ), true );
|
||||
}
|
||||
/// e.g. '/vimix/current/reset'
|
||||
else if ( attribute.compare(OSC_SOURCE_RESET) == 0) {
|
||||
target->call( new ResetGeometry(), true );
|
||||
}
|
||||
#ifdef CONTROL_DEBUG
|
||||
else {
|
||||
Log::Info(CONTROL_OSC_MSG "Ignoring attribute '%s' for target %s.", attribute.c_str(), target->name().c_str());
|
||||
}
|
||||
#endif
|
||||
|
||||
// overwrite value if source locked
|
||||
if (target->locked())
|
||||
send_feedback = true;
|
||||
|
||||
}
|
||||
catch (osc::MissingArgumentException &e) {
|
||||
Log::Info(CONTROL_OSC_MSG "Missing argument for attribute '%s' for target %s.", attribute.c_str(), target->name().c_str());
|
||||
}
|
||||
catch (osc::ExcessArgumentException &e) {
|
||||
Log::Info(CONTROL_OSC_MSG "Too many arguments for attribute '%s' for target %s.", attribute.c_str(), target->name().c_str());
|
||||
}
|
||||
catch (osc::WrongArgumentTypeException &e) {
|
||||
Log::Info(CONTROL_OSC_MSG "Invalid argument for attribute '%s' for target %s.", attribute.c_str(), target->name().c_str());
|
||||
}
|
||||
|
||||
return send_feedback;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Control::receiveSessionAttribute(const std::string &attribute,
|
||||
osc::ReceivedMessageArgumentStream arguments)
|
||||
{
|
||||
bool send_feedback = false;
|
||||
|
||||
try {
|
||||
if ( attribute.compare(OSC_SYNC) == 0) {
|
||||
send_feedback = true;
|
||||
}
|
||||
else if ( attribute.compare(OSC_SESSION_VERSION) == 0) {
|
||||
float v = 0.f;
|
||||
arguments >> v >> osc::EndMessage;
|
||||
size_t id = (int) ceil(v);
|
||||
std::list<uint64_t> snapshots = Action::manager().snapshots();
|
||||
if ( id < snapshots.size() ) {
|
||||
for (size_t i = 0; i < id; ++i)
|
||||
snapshots.pop_back();
|
||||
uint64_t snap = snapshots.back();
|
||||
Action::manager().restore(snap);
|
||||
}
|
||||
send_feedback = true;
|
||||
}
|
||||
#ifdef CONTROL_DEBUG
|
||||
else {
|
||||
Log::Info(CONTROL_OSC_MSG "Ignoring attribute '%s' for target 'session'", attribute.c_str());
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
catch (osc::MissingArgumentException &e) {
|
||||
Log::Info(CONTROL_OSC_MSG "Missing argument for attribute '%s' for target 'session'", attribute.c_str());
|
||||
}
|
||||
catch (osc::ExcessArgumentException &e) {
|
||||
Log::Info(CONTROL_OSC_MSG "Too many arguments for attribute '%s' for target 'session'", attribute.c_str());
|
||||
}
|
||||
catch (osc::WrongArgumentTypeException &e) {
|
||||
Log::Info(CONTROL_OSC_MSG "Invalid argument for attribute '%s' for target 'session'", attribute.c_str());
|
||||
}
|
||||
|
||||
return send_feedback;
|
||||
}
|
||||
|
||||
void Control::sendSourceAttibutes(const IpEndpointName &remoteEndpoint, std::string target, Source *s)
|
||||
{
|
||||
// default values
|
||||
char name[21] = {"\0"};
|
||||
float lock = 0.f;
|
||||
float play = 0.f;
|
||||
float depth = 0.f;
|
||||
float alpha = 0.f;
|
||||
|
||||
// get source or current source
|
||||
Source *_s = s;
|
||||
if ( target.compare(OSC_CURRENT) == 0 )
|
||||
_s = Mixer::manager().currentSource();
|
||||
|
||||
// fill values if the source is valid
|
||||
if (_s!=nullptr) {
|
||||
strncpy(name, _s->name().c_str(), 20);
|
||||
lock = _s->locked() ? 1.f : 0.f;
|
||||
play = _s->playing() ? 1.f : 0.f;
|
||||
depth = _s->depth();
|
||||
alpha = _s->alpha();
|
||||
}
|
||||
|
||||
// build socket to send message to indicated endpoint
|
||||
UdpTransmitSocket socket( IpEndpointName( remoteEndpoint.address, Settings::application.control.osc_port_send ) );
|
||||
|
||||
// build messages packet
|
||||
char buffer[IP_MTU_SIZE];
|
||||
osc::OutboundPacketStream p( buffer, IP_MTU_SIZE );
|
||||
|
||||
// create bundle
|
||||
p.Clear();
|
||||
p << osc::BeginBundle();
|
||||
|
||||
/// name
|
||||
std::string address = std::string(OSC_PREFIX) + target + OSC_SOURCE_NAME;
|
||||
p << osc::BeginMessage( address.c_str() ) << name << osc::EndMessage;
|
||||
/// Play status
|
||||
address = std::string(OSC_PREFIX) + target + OSC_SOURCE_LOCK;
|
||||
p << osc::BeginMessage( address.c_str() ) << lock << osc::EndMessage;
|
||||
/// Play status
|
||||
address = std::string(OSC_PREFIX) + target + OSC_SOURCE_PLAY;
|
||||
p << osc::BeginMessage( address.c_str() ) << play << osc::EndMessage;
|
||||
/// Depth
|
||||
address = std::string(OSC_PREFIX) + target + OSC_SOURCE_DEPTH;
|
||||
p << osc::BeginMessage( address.c_str() ) << depth << osc::EndMessage;
|
||||
/// Alpha
|
||||
address = std::string(OSC_PREFIX) + target + OSC_SOURCE_ALPHA;
|
||||
p << osc::BeginMessage( address.c_str() ) << alpha << osc::EndMessage;
|
||||
|
||||
// send bundle
|
||||
p << osc::EndBundle;
|
||||
socket.Send( p.Data(), p.Size() );
|
||||
}
|
||||
|
||||
|
||||
void Control::sendSourcesStatus(const IpEndpointName &remoteEndpoint, osc::ReceivedMessageArgumentStream arguments)
|
||||
{
|
||||
// (if an argument is given, it indicates the number of sources to update)
|
||||
float N = 0.f;
|
||||
if ( !arguments.Eos())
|
||||
arguments >> N >> osc::EndMessage;
|
||||
|
||||
// build socket to send message to indicated endpoint
|
||||
UdpTransmitSocket socket( IpEndpointName( remoteEndpoint.address, Settings::application.control.osc_port_send ) );
|
||||
|
||||
// build messages packet
|
||||
char buffer[IP_MTU_SIZE];
|
||||
osc::OutboundPacketStream p( buffer, IP_MTU_SIZE );
|
||||
|
||||
p.Clear();
|
||||
p << osc::BeginBundle();
|
||||
|
||||
int i = 0;
|
||||
char oscaddr[128];
|
||||
int index_current = Mixer::manager().indexCurrentSource();
|
||||
for (; i < Mixer::manager().count(); ++i) {
|
||||
// send status of currently selected
|
||||
sprintf(oscaddr, OSC_PREFIX OSC_CURRENT "/%d", i);
|
||||
p << osc::BeginMessage( oscaddr ) << (index_current == i ? 1.f : 0.f) << osc::EndMessage;
|
||||
|
||||
// send status of alpha
|
||||
sprintf(oscaddr, OSC_PREFIX "/%d" OSC_SOURCE_ALPHA, i);
|
||||
p << osc::BeginMessage( oscaddr ) << Mixer::manager().sourceAtIndex(i)->alpha() << osc::EndMessage;
|
||||
}
|
||||
|
||||
for (; i < (int) N ; ++i) {
|
||||
// reset status of currently selected
|
||||
sprintf(oscaddr, OSC_PREFIX OSC_CURRENT "/%d", i);
|
||||
p << osc::BeginMessage( oscaddr ) << 0.f << osc::EndMessage;
|
||||
|
||||
// reset status of alpha
|
||||
sprintf(oscaddr, OSC_PREFIX "/%d" OSC_SOURCE_ALPHA, i);
|
||||
p << osc::BeginMessage( oscaddr ) << 0.f << osc::EndMessage;
|
||||
}
|
||||
|
||||
p << osc::EndBundle;
|
||||
socket.Send( p.Data(), p.Size() );
|
||||
|
||||
// send status of current source
|
||||
sendSourceAttibutes(remoteEndpoint, OSC_CURRENT);
|
||||
}
|
||||
|
||||
|
||||
void Control::sendOutputStatus(const IpEndpointName &remoteEndpoint)
|
||||
{
|
||||
// build socket to send message to indicated endpoint
|
||||
UdpTransmitSocket socket( IpEndpointName( remoteEndpoint.address, Settings::application.control.osc_port_send ) );
|
||||
|
||||
// build messages packet
|
||||
char buffer[IP_MTU_SIZE];
|
||||
osc::OutboundPacketStream p( buffer, IP_MTU_SIZE );
|
||||
|
||||
p.Clear();
|
||||
p << osc::BeginBundle();
|
||||
|
||||
/// output attributes
|
||||
p << osc::BeginMessage( OSC_PREFIX OSC_OUTPUT OSC_OUTPUT_ENABLE );
|
||||
p << (Settings::application.render.disabled ? 0.f : 1.f);
|
||||
p << osc::EndMessage;
|
||||
p << osc::BeginMessage( OSC_PREFIX OSC_OUTPUT OSC_OUTPUT_FADING );
|
||||
p << Mixer::manager().session()->fading();
|
||||
p << osc::EndMessage;
|
||||
|
||||
p << osc::EndBundle;
|
||||
socket.Send( p.Data(), p.Size() );
|
||||
}
|
||||
105
ControlManager.h
@@ -1,105 +0,0 @@
|
||||
#ifndef CONTROL_H
|
||||
#define CONTROL_H
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <condition_variable>
|
||||
#include "NetworkToolkit.h"
|
||||
|
||||
#define OSC_SYNC "/sync"
|
||||
|
||||
#define OSC_INFO "/info"
|
||||
#define OSC_INFO_LOG "/log"
|
||||
#define OSC_INFO_NOTIFY "/notify"
|
||||
|
||||
#define OSC_OUTPUT "/output"
|
||||
#define OSC_OUTPUT_ENABLE "/enable"
|
||||
#define OSC_OUTPUT_DISABLE "/disable"
|
||||
#define OSC_OUTPUT_FADING "/fading"
|
||||
#define OSC_OUTPUT_FADE_IN "/fade-in"
|
||||
#define OSC_OUTPUT_FADE_OUT "/fade-out"
|
||||
|
||||
#define OSC_ALL "/all"
|
||||
#define OSC_SELECTED "/selected"
|
||||
#define OSC_CURRENT "/current"
|
||||
#define OSC_NEXT "/next"
|
||||
#define OSC_PREVIOUS "/previous"
|
||||
|
||||
#define OSC_SOURCE_NAME "/name"
|
||||
#define OSC_SOURCE_LOCK "/lock"
|
||||
#define OSC_SOURCE_PLAY "/play"
|
||||
#define OSC_SOURCE_PAUSE "/pause"
|
||||
#define OSC_SOURCE_REPLAY "/replay"
|
||||
#define OSC_SOURCE_ALPHA "/alpha"
|
||||
#define OSC_SOURCE_LOOM "/loom"
|
||||
#define OSC_SOURCE_TRANSPARENCY "/transparency"
|
||||
#define OSC_SOURCE_DEPTH "/depth"
|
||||
#define OSC_SOURCE_GRAB "/grab"
|
||||
#define OSC_SOURCE_RESIZE "/resize"
|
||||
#define OSC_SOURCE_TURN "/turn"
|
||||
#define OSC_SOURCE_RESET "/reset"
|
||||
|
||||
#define OSC_SESSION "/session"
|
||||
#define OSC_SESSION_VERSION "/version"
|
||||
|
||||
class Session;
|
||||
class Source;
|
||||
|
||||
class Control
|
||||
{
|
||||
// Private Constructor
|
||||
Control();
|
||||
Control(Control const& copy) = delete;
|
||||
Control& operator=(Control const& copy) = delete;
|
||||
|
||||
public:
|
||||
|
||||
static Control& manager ()
|
||||
{
|
||||
// The only instance
|
||||
static Control _instance;
|
||||
return _instance;
|
||||
}
|
||||
~Control();
|
||||
|
||||
bool init();
|
||||
void terminate();
|
||||
|
||||
std::string translate (std::string addresspattern);
|
||||
|
||||
protected:
|
||||
|
||||
class RequestListener : public osc::OscPacketListener {
|
||||
protected:
|
||||
virtual void ProcessMessage( const osc::ReceivedMessage& m,
|
||||
const IpEndpointName& remoteEndpoint );
|
||||
std::string FullMessage( const osc::ReceivedMessage& m );
|
||||
};
|
||||
|
||||
bool receiveOutputAttribute(const std::string &attribute,
|
||||
osc::ReceivedMessageArgumentStream arguments);
|
||||
|
||||
bool receiveSourceAttribute(Source *target, const std::string &attribute,
|
||||
osc::ReceivedMessageArgumentStream arguments);
|
||||
|
||||
bool receiveSessionAttribute(const std::string &attribute,
|
||||
osc::ReceivedMessageArgumentStream arguments);
|
||||
|
||||
void sendSourceAttibutes(const IpEndpointName& remoteEndpoint, std::string target, Source *s = nullptr);
|
||||
void sendSourcesStatus(const IpEndpointName& remoteEndpoint, osc::ReceivedMessageArgumentStream arguments);
|
||||
void sendOutputStatus(const IpEndpointName& remoteEndpoint);
|
||||
|
||||
private:
|
||||
|
||||
static void listen();
|
||||
RequestListener listener_;
|
||||
std::condition_variable receiver_end_;
|
||||
UdpListeningReceiveSocket *receiver_;
|
||||
|
||||
std::map<std::string, std::string> translation_;
|
||||
void loadOscConfig();
|
||||
void resetOscConfig();
|
||||
|
||||
};
|
||||
|
||||
#endif // CONTROL_H
|
||||
610
DeviceSource.cpp
@@ -1,610 +0,0 @@
|
||||
/*
|
||||
* This file is part of vimix - video live mixer
|
||||
*
|
||||
* **Copyright** (C) 2019-2022 Bruno Herbelin <bruno.herbelin@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 3 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 <algorithm>
|
||||
#include <sstream>
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
|
||||
#include <gst/pbutils/gstdiscoverer.h>
|
||||
#include <gst/pbutils/pbutils.h>
|
||||
#include <gst/gst.h>
|
||||
|
||||
#include "DeviceSource.h"
|
||||
|
||||
#include "defines.h"
|
||||
#include "ImageShader.h"
|
||||
#include "ImageProcessingShader.h"
|
||||
#include "Resource.h"
|
||||
#include "Decorations.h"
|
||||
#include "Stream.h"
|
||||
#include "Visitor.h"
|
||||
#include "Log.h"
|
||||
|
||||
#ifndef NDEBUG
|
||||
#define DEVICE_DEBUG
|
||||
#define GST_DEVICE_DEBUG
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#if defined(APPLE)
|
||||
std::string gst_plugin_device = "avfvideosrc";
|
||||
std::string gst_plugin_vidcap = "avfvideosrc capture-screen=true";
|
||||
#else
|
||||
std::string gst_plugin_device = "v4l2src";
|
||||
std::string gst_plugin_vidcap = "ximagesrc";
|
||||
#endif
|
||||
|
||||
////EXAMPLE :
|
||||
///
|
||||
//v4l2deviceprovider, udev-probed=(boolean)true,
|
||||
//device.bus_path=(string)pci-0000:00:14.0-usb-0:2:1.0,
|
||||
//sysfs.path=(string)/sys/devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2:1.0/video4linux/video0,
|
||||
//device.bus=(string)usb,
|
||||
//device.subsystem=(string)video4linux,
|
||||
//device.vendor.id=(string)1bcf,
|
||||
//device.vendor.name=(string)"Sunplus\\x20IT\\x20Co\\x20",
|
||||
//device.product.id=(string)2286,
|
||||
//device.product.name=(string)"AUSDOM\ FHD\ Camera:\ AUSDOM\ FHD\ C",
|
||||
//device.serial=(string)Sunplus_IT_Co_AUSDOM_FHD_Camera,
|
||||
//device.capabilities=(string):capture:,
|
||||
//device.api=(string)v4l2,
|
||||
//device.path=(string)/dev/video0,
|
||||
//v4l2.device.driver=(string)uvcvideo,
|
||||
//v4l2.device.card=(string)"AUSDOM\ FHD\ Camera:\ AUSDOM\ FHD\ C",
|
||||
//v4l2.device.bus_info=(string)usb-0000:00:14.0-2,
|
||||
//v4l2.device.version=(uint)328748,
|
||||
//v4l2.device.capabilities=(uint)2225078273,
|
||||
//v4l2.device.device_caps=(uint)69206017;
|
||||
//Device added: AUSDOM FHD Camera: AUSDOM FHD C - v4l2src device=/dev/video0
|
||||
|
||||
//v4l2deviceprovider, udev-probed=(boolean)true,
|
||||
//device.bus_path=(string)pci-0000:00:14.0-usb-0:4:1.0,
|
||||
//sysfs.path=(string)/sys/devices/pci0000:00/0000:00:14.0/usb1/1-4/1-4:1.0/video4linux/video2,
|
||||
//device.bus=(string)usb,
|
||||
//device.subsystem=(string)video4linux,
|
||||
//device.vendor.id=(string)046d,
|
||||
//device.vendor.name=(string)046d,
|
||||
//device.product.id=(string)080f,
|
||||
//device.product.name=(string)"UVC\ Camera\ \(046d:080f\)",
|
||||
//device.serial=(string)046d_080f_3EA77580,
|
||||
//device.capabilities=(string):capture:,
|
||||
//device.api=(string)v4l2,
|
||||
//device.path=(string)/dev/video2,
|
||||
//v4l2.device.driver=(string)uvcvideo,
|
||||
//v4l2.device.card=(string)"UVC\ Camera\ \(046d:080f\)",
|
||||
//v4l2.device.bus_info=(string)usb-0000:00:14.0-4,
|
||||
//v4l2.device.version=(uint)328748,
|
||||
//v4l2.device.capabilities=(uint)2225078273,
|
||||
//v4l2.device.device_caps=(uint)69206017; // decimal of hexadecimal v4l code Device Caps : 0x04200001
|
||||
//Device added: UVC Camera (046d:080f) - v4l2src device=/dev/video2
|
||||
|
||||
std::string pipelineForDevice(GstDevice *device, uint index)
|
||||
{
|
||||
std::ostringstream pipe;
|
||||
const gchar *str = gst_structure_get_string(gst_device_get_properties(device), "device.api");
|
||||
|
||||
if (str && gst_plugin_device.find(str) != std::string::npos)
|
||||
{
|
||||
pipe << gst_plugin_device;
|
||||
|
||||
#if defined(APPLE)
|
||||
pipe << " device-index=" << index;
|
||||
#else
|
||||
str = gst_structure_get_string(gst_device_get_properties(device), "device.path");
|
||||
if (str)
|
||||
pipe << " device=" << str;
|
||||
#endif
|
||||
}
|
||||
|
||||
return pipe.str();
|
||||
}
|
||||
|
||||
gboolean
|
||||
Device::callback_device_monitor (GstBus *, GstMessage * message, gpointer )
|
||||
{
|
||||
GstDevice *device;
|
||||
|
||||
switch (GST_MESSAGE_TYPE (message)) {
|
||||
case GST_MESSAGE_DEVICE_ADDED:
|
||||
{
|
||||
gst_message_parse_device_added (message, &device);
|
||||
manager().add(device);
|
||||
gst_object_unref (device);
|
||||
|
||||
}
|
||||
break;
|
||||
case GST_MESSAGE_DEVICE_REMOVED:
|
||||
{
|
||||
gst_message_parse_device_removed (message, &device);
|
||||
manager().remove(device);
|
||||
gst_object_unref (device);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return G_SOURCE_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
void Device::add(GstDevice *device)
|
||||
{
|
||||
if (device==nullptr)
|
||||
return;
|
||||
|
||||
gchar *device_name = gst_device_get_display_name (device);
|
||||
|
||||
if ( std::find(manager().src_name_.begin(), manager().src_name_.end(), device_name) == manager().src_name_.end()) {
|
||||
|
||||
std::string p = pipelineForDevice(device, manager().src_description_.size());
|
||||
DeviceConfigSet confs = getDeviceConfigs(p);
|
||||
|
||||
// add if not in the list and valid
|
||||
if (!p.empty() && !confs.empty()) {
|
||||
src_name_.push_back(device_name);
|
||||
src_description_.push_back(p);
|
||||
src_config_.push_back(confs);
|
||||
#ifdef GST_DEVICE_DEBUG
|
||||
gchar *stru = gst_structure_to_string( gst_device_get_properties(device) );
|
||||
g_print("\nDevice %s plugged : %s\n", device_name, stru);
|
||||
g_free (stru);
|
||||
#endif
|
||||
}
|
||||
list_uptodate_ = false;
|
||||
}
|
||||
g_free (device_name);
|
||||
}
|
||||
|
||||
void Device::remove(GstDevice *device)
|
||||
{
|
||||
if (device==nullptr)
|
||||
return;
|
||||
|
||||
gchar *device_name = gst_device_get_display_name (device);
|
||||
|
||||
std::vector< std::string >::iterator nameit = src_name_.begin();
|
||||
std::vector< std::string >::iterator descit = src_description_.begin();
|
||||
std::vector< DeviceConfigSet >::iterator coit = src_config_.begin();
|
||||
while (nameit != src_name_.end()){
|
||||
|
||||
if ( (*nameit).compare(device_name) == 0 )
|
||||
{
|
||||
src_name_.erase(nameit);
|
||||
src_description_.erase(descit);
|
||||
src_config_.erase(coit);
|
||||
|
||||
list_uptodate_ = false;
|
||||
|
||||
#ifdef GST_DEVICE_DEBUG
|
||||
g_print("\nDevice %s unplugged\n", device_name);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
++nameit;
|
||||
++descit;
|
||||
++coit;
|
||||
}
|
||||
g_free (device_name);
|
||||
}
|
||||
|
||||
|
||||
Device::Device(): list_uptodate_(false)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Device::init()
|
||||
{
|
||||
GstBus *bus;
|
||||
GstCaps *caps;
|
||||
|
||||
// create GStreamer device monitor to capture
|
||||
// when a device is plugged in or out
|
||||
monitor_ = gst_device_monitor_new ();
|
||||
|
||||
bus = gst_device_monitor_get_bus (monitor_);
|
||||
gst_bus_add_watch (bus, callback_device_monitor, NULL);
|
||||
gst_object_unref (bus);
|
||||
|
||||
caps = gst_caps_new_empty_simple ("video/x-raw");
|
||||
gst_device_monitor_add_filter (monitor_, "Video/Source", caps);
|
||||
gst_caps_unref (caps);
|
||||
|
||||
gst_device_monitor_set_show_all_devices(monitor_, true);
|
||||
gst_device_monitor_start (monitor_);
|
||||
|
||||
// initial fill of the list
|
||||
GList *devices = gst_device_monitor_get_devices(monitor_);
|
||||
GList *tmp;
|
||||
for (tmp = devices; tmp ; tmp = tmp->next ) {
|
||||
GstDevice *device = (GstDevice *) tmp->data;
|
||||
add(device);
|
||||
gst_object_unref (device);
|
||||
}
|
||||
g_list_free(devices);
|
||||
|
||||
// Add config for plugged screen
|
||||
src_name_.push_back("Screen capture");
|
||||
src_description_.push_back(gst_plugin_vidcap);
|
||||
|
||||
// Try to auto find resolution
|
||||
DeviceConfigSet confs = getDeviceConfigs(gst_plugin_vidcap);
|
||||
if (!confs.empty()) {
|
||||
// fix the framerate (otherwise at 1 FPS
|
||||
DeviceConfig best = *confs.rbegin();
|
||||
DeviceConfigSet confscreen;
|
||||
best.fps_numerator = 15;
|
||||
confscreen.insert(best);
|
||||
src_config_.push_back(confscreen);
|
||||
}
|
||||
|
||||
// TODO Use lib glfw to get monitors
|
||||
// TODO Detect auto removal of monitors
|
||||
|
||||
list_uptodate_ = true;
|
||||
}
|
||||
|
||||
|
||||
int Device::numDevices() const
|
||||
{
|
||||
return src_name_.size();
|
||||
}
|
||||
|
||||
bool Device::exists(const std::string &device) const
|
||||
{
|
||||
std::vector< std::string >::const_iterator d = std::find(src_name_.begin(), src_name_.end(), device);
|
||||
return d != src_name_.end();
|
||||
}
|
||||
|
||||
struct hasDevice: public std::unary_function<DeviceSource*, bool>
|
||||
{
|
||||
inline bool operator()(const DeviceSource* elem) const {
|
||||
return (elem && elem->device() == _d);
|
||||
}
|
||||
explicit hasDevice(const std::string &d) : _d(d) { }
|
||||
private:
|
||||
std::string _d;
|
||||
};
|
||||
|
||||
Source *Device::createSource(const std::string &device) const
|
||||
{
|
||||
Source *s = nullptr;
|
||||
|
||||
// find if a DeviceSource with this device is already registered
|
||||
std::list< DeviceSource *>::const_iterator d = std::find_if(device_sources_.begin(), device_sources_.end(), hasDevice(device));
|
||||
|
||||
// if already registered, clone the device source
|
||||
if ( d != device_sources_.end()) {
|
||||
CloneSource *cs = (*d)->clone();
|
||||
s = cs;
|
||||
}
|
||||
// otherwise, we are free to create a new device source
|
||||
else {
|
||||
DeviceSource *ds = new DeviceSource();
|
||||
ds->setDevice(device);
|
||||
s = ds;
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
bool Device::unplugged(const std::string &device) const
|
||||
{
|
||||
if (list_uptodate_)
|
||||
return false;
|
||||
return !exists(device);
|
||||
}
|
||||
|
||||
std::string Device::name(int index) const
|
||||
{
|
||||
if (index > -1 && index < (int) src_name_.size())
|
||||
return src_name_[index];
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string Device::description(int index) const
|
||||
{
|
||||
if (index > -1 && index < (int) src_description_.size())
|
||||
return src_description_[index];
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
DeviceConfigSet Device::config(int index) const
|
||||
{
|
||||
if (index > -1 && index < (int) src_config_.size())
|
||||
return src_config_[index];
|
||||
else
|
||||
return DeviceConfigSet();
|
||||
}
|
||||
|
||||
int Device::index(const std::string &device) const
|
||||
{
|
||||
int i = -1;
|
||||
std::vector< std::string >::const_iterator p = std::find(src_name_.begin(), src_name_.end(), device);
|
||||
if (p != src_name_.end())
|
||||
i = std::distance(src_name_.begin(), p);
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
DeviceSource::DeviceSource(uint64_t id) : StreamSource(id)
|
||||
{
|
||||
// create stream
|
||||
stream_ = new Stream;
|
||||
|
||||
// set symbol
|
||||
symbol_ = new Symbol(Symbol::CAMERA, glm::vec3(0.75f, 0.75f, 0.01f));
|
||||
symbol_->scale_.y = 1.5f;
|
||||
}
|
||||
|
||||
DeviceSource::~DeviceSource()
|
||||
{
|
||||
// unregister this device source
|
||||
Device::manager().device_sources_.remove(this);
|
||||
}
|
||||
|
||||
void DeviceSource::setDevice(const std::string &devicename)
|
||||
{
|
||||
device_ = devicename;
|
||||
|
||||
int index = Device::manager().index(device_);
|
||||
if (index > -1) {
|
||||
|
||||
// register this device source
|
||||
Device::manager().device_sources_.push_back(this);
|
||||
|
||||
// start filling in the gstreamer pipeline
|
||||
std::ostringstream pipeline;
|
||||
pipeline << Device::manager().description(index);
|
||||
|
||||
// test the device and get config
|
||||
DeviceConfigSet confs = Device::manager().config(index);
|
||||
#ifdef DEVICE_DEBUG
|
||||
Log::Info("Device %s supported configs:", devicename.c_str());
|
||||
for( DeviceConfigSet::iterator it = confs.begin(); it != confs.end(); ++it ){
|
||||
float fps = static_cast<float>((*it).fps_numerator) / static_cast<float>((*it).fps_denominator);
|
||||
Log::Info(" - %s %s %d x %d %.1f fps", (*it).stream.c_str(), (*it).format.c_str(), (*it).width, (*it).height, fps);
|
||||
}
|
||||
#endif
|
||||
if (!confs.empty()) {
|
||||
DeviceConfig best = *confs.rbegin();
|
||||
float fps = static_cast<float>(best.fps_numerator) / static_cast<float>(best.fps_denominator);
|
||||
Log::Info("Device %s selected its optimal config: %s %s %dx%d@%.1ffps", device_.c_str(), best.stream.c_str(), best.format.c_str(), best.width, best.height, fps);
|
||||
|
||||
pipeline << " ! " << best.stream;
|
||||
if (!best.format.empty())
|
||||
pipeline << ",format=" << best.format;
|
||||
pipeline << ",framerate=" << best.fps_numerator << "/" << best.fps_denominator;
|
||||
pipeline << ",width=" << best.width;
|
||||
pipeline << ",height=" << best.height;
|
||||
|
||||
if ( best.stream.find("jpeg") != std::string::npos )
|
||||
pipeline << " ! jpegdec";
|
||||
|
||||
if ( device_.find("Screen") != std::string::npos )
|
||||
pipeline << " ! videoconvert ! video/x-raw,format=RGB ! queue max-size-buffers=3";
|
||||
|
||||
pipeline << " ! videoconvert";
|
||||
|
||||
// resize render buffer
|
||||
if (renderbuffer_)
|
||||
renderbuffer_->resize(best.width, best.height);
|
||||
|
||||
// open gstreamer
|
||||
stream_->open( pipeline.str(), best.width, best.height);
|
||||
stream_->play(true);
|
||||
}
|
||||
|
||||
// will be ready after init and one frame rendered
|
||||
ready_ = false;
|
||||
}
|
||||
else
|
||||
Log::Warning("No such device '%s'", device_.c_str());
|
||||
}
|
||||
|
||||
void DeviceSource::accept(Visitor& v)
|
||||
{
|
||||
Source::accept(v);
|
||||
if (!failed())
|
||||
v.visit(*this);
|
||||
}
|
||||
|
||||
bool DeviceSource::failed() const
|
||||
{
|
||||
return stream_->failed() || Device::manager().unplugged(device_);
|
||||
}
|
||||
|
||||
DeviceConfigSet Device::getDeviceConfigs(const std::string &src_description)
|
||||
{
|
||||
DeviceConfigSet configs;
|
||||
|
||||
// create dummy pipeline to be tested
|
||||
std::string description = src_description;
|
||||
description += " name=devsrc ! fakesink name=sink";
|
||||
|
||||
// parse pipeline descriptor
|
||||
GError *error = NULL;
|
||||
GstElement *pipeline_ = gst_parse_launch (description.c_str(), &error);
|
||||
if (error != NULL) {
|
||||
Log::Warning("DeviceSource Could not construct test pipeline %s:\n%s", description.c_str(), error->message);
|
||||
g_clear_error (&error);
|
||||
return configs;
|
||||
}
|
||||
|
||||
// get the pipeline element named "devsrc" from the Device class
|
||||
GstElement *elem = gst_bin_get_by_name (GST_BIN (pipeline_), "devsrc");
|
||||
if (elem) {
|
||||
|
||||
// initialize the pipeline
|
||||
GstStateChangeReturn ret = gst_element_set_state (pipeline_, GST_STATE_PAUSED);
|
||||
if (ret != GST_STATE_CHANGE_FAILURE) {
|
||||
|
||||
// get the first pad and its content
|
||||
GstIterator *iter = gst_element_iterate_src_pads(elem);
|
||||
GValue vPad = G_VALUE_INIT;
|
||||
GstPad* pad_ret = NULL;
|
||||
if (gst_iterator_next(iter, &vPad) == GST_ITERATOR_OK)
|
||||
{
|
||||
pad_ret = GST_PAD(g_value_get_object(&vPad));
|
||||
GstCaps *device_caps = gst_pad_query_caps (pad_ret, NULL);
|
||||
|
||||
// loop over all caps offered by the pad
|
||||
int C = gst_caps_get_size(device_caps);
|
||||
for (int c = 0; c < C; ++c) {
|
||||
// get GST cap
|
||||
GstStructure *decice_cap_struct = gst_caps_get_structure (device_caps, c);
|
||||
#ifdef GST_DEVICE_DEBUG
|
||||
gchar *capstext = gst_structure_to_string (decice_cap_struct);
|
||||
g_print("\nDevice caps: %s", capstext);
|
||||
g_free(capstext);
|
||||
#endif
|
||||
|
||||
// fill our config
|
||||
DeviceConfig config;
|
||||
|
||||
// not managing opengl texture-target types
|
||||
// TODO: support input devices texture-target video/x-raw(memory:GLMemory) for improved pipeline
|
||||
if ( gst_structure_has_field (decice_cap_struct, "texture-target"))
|
||||
continue;
|
||||
|
||||
// NAME : typically video/x-raw or image/jpeg
|
||||
config.stream = gst_structure_get_name (decice_cap_struct);
|
||||
|
||||
// FORMAT : typically BGRA or YUVY
|
||||
if ( gst_structure_has_field (decice_cap_struct, "format")) {
|
||||
// get generic value
|
||||
const GValue *val = gst_structure_get_value(decice_cap_struct, "format");
|
||||
|
||||
// if its a list of format string
|
||||
if ( GST_VALUE_HOLDS_LIST(val)) {
|
||||
int N = gst_value_list_get_size(val);
|
||||
for (int n = 0; n < N; n++ ){
|
||||
std::string f = gst_value_serialize( gst_value_list_get_value(val, n) );
|
||||
|
||||
// preference order : 1) RGBx, 2) JPEG, 3) ALL OTHER
|
||||
// select f if it contains R (e.g. for RGBx) and not already RGB in config
|
||||
if ( (f.find("R") != std::string::npos) && (config.format.find("R") == std::string::npos ) ) {
|
||||
config.format = f;
|
||||
break;
|
||||
}
|
||||
// default, take at least one if nothing yet in config
|
||||
else if ( config.format.empty() )
|
||||
config.format = f;
|
||||
}
|
||||
|
||||
}
|
||||
// single format
|
||||
else {
|
||||
config.format = gst_value_serialize(val);
|
||||
}
|
||||
}
|
||||
|
||||
// FRAMERATE : can be a fraction of a list of fractions
|
||||
if ( gst_structure_has_field (decice_cap_struct, "framerate")) {
|
||||
|
||||
// get generic value
|
||||
const GValue *val = gst_structure_get_value(decice_cap_struct, "framerate");
|
||||
// if its a single fraction
|
||||
if ( GST_VALUE_HOLDS_FRACTION(val)) {
|
||||
config.fps_numerator = gst_value_get_fraction_numerator(val);
|
||||
config.fps_denominator= gst_value_get_fraction_denominator(val);
|
||||
}
|
||||
// if its a range of fraction; take the max
|
||||
else if ( GST_VALUE_HOLDS_FRACTION_RANGE(val)) {
|
||||
config.fps_numerator = gst_value_get_fraction_numerator(gst_value_get_fraction_range_max(val));
|
||||
config.fps_denominator= gst_value_get_fraction_denominator(gst_value_get_fraction_range_max(val));
|
||||
}
|
||||
// deal otherwise with a list of fractions; find the max
|
||||
else if ( GST_VALUE_HOLDS_LIST(val)) {
|
||||
gdouble fps_max = 1.0;
|
||||
// loop over all fractions
|
||||
int N = gst_value_list_get_size(val);
|
||||
for (int i = 0; i < N; ++i ){
|
||||
const GValue *frac = gst_value_list_get_value(val, i);
|
||||
// read one fraction in the list
|
||||
if ( GST_VALUE_HOLDS_FRACTION(frac)) {
|
||||
int n = gst_value_get_fraction_numerator(frac);
|
||||
int d = gst_value_get_fraction_denominator(frac);
|
||||
// keep only the higher FPS
|
||||
gdouble f = 1.0;
|
||||
gst_util_fraction_to_double( n, d, &f );
|
||||
if ( f > fps_max ) {
|
||||
config.fps_numerator = n;
|
||||
config.fps_denominator = d;
|
||||
fps_max = f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// WIDTH and HEIGHT
|
||||
if ( gst_structure_has_field (decice_cap_struct, "width"))
|
||||
gst_structure_get_int (decice_cap_struct, "width", &config.width);
|
||||
if ( gst_structure_has_field (decice_cap_struct, "height"))
|
||||
gst_structure_get_int (decice_cap_struct, "height", &config.height);
|
||||
|
||||
|
||||
// add this config
|
||||
configs.insert(config);
|
||||
}
|
||||
|
||||
}
|
||||
gst_iterator_free(iter);
|
||||
|
||||
// terminate pipeline
|
||||
gst_element_set_state (pipeline_, GST_STATE_NULL);
|
||||
}
|
||||
|
||||
g_object_unref (elem);
|
||||
}
|
||||
|
||||
gst_object_unref (pipeline_);
|
||||
|
||||
return configs;
|
||||
}
|
||||
|
||||
|
||||
glm::ivec2 DeviceSource::icon() const
|
||||
{
|
||||
if ( device_.find("Screen") != std::string::npos )
|
||||
return glm::ivec2(ICON_SOURCE_DEVICE_SCREEN);
|
||||
else
|
||||
return glm::ivec2(ICON_SOURCE_DEVICE);
|
||||
}
|
||||
|
||||
std::string DeviceSource::info() const
|
||||
{
|
||||
return std::string("device '") + device_ + "'";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
133
DeviceSource.h
@@ -1,133 +0,0 @@
|
||||
#ifndef DEVICESOURCE_H
|
||||
#define DEVICESOURCE_H
|
||||
|
||||
#include <vector>
|
||||
#include <set>
|
||||
|
||||
#include "GstToolkit.h"
|
||||
#include "StreamSource.h"
|
||||
|
||||
class DeviceSource : public StreamSource
|
||||
{
|
||||
public:
|
||||
DeviceSource(uint64_t id = 0);
|
||||
~DeviceSource();
|
||||
|
||||
// Source interface
|
||||
bool failed() const override;
|
||||
void accept (Visitor& v) override;
|
||||
|
||||
// StreamSource interface
|
||||
Stream *stream() const override { return stream_; }
|
||||
|
||||
// specific interface
|
||||
void setDevice(const std::string &devicename);
|
||||
inline std::string device() const { return device_; }
|
||||
|
||||
glm::ivec2 icon() const override;
|
||||
std::string info() const override;
|
||||
|
||||
private:
|
||||
std::string device_;
|
||||
|
||||
};
|
||||
|
||||
struct DeviceConfig {
|
||||
gint width;
|
||||
gint height;
|
||||
gint fps_numerator;
|
||||
gint fps_denominator;
|
||||
std::string stream;
|
||||
std::string format;
|
||||
|
||||
DeviceConfig() {
|
||||
width = 0;
|
||||
height = 0;
|
||||
fps_numerator = 1;
|
||||
fps_denominator = 1;
|
||||
stream = "";
|
||||
format = "";
|
||||
}
|
||||
|
||||
inline DeviceConfig& operator = (const DeviceConfig& b)
|
||||
{
|
||||
if (this != &b) {
|
||||
this->width = b.width;
|
||||
this->height = b.height;
|
||||
this->fps_numerator = b.fps_numerator;
|
||||
this->fps_denominator = b.fps_denominator;
|
||||
this->stream = b.stream;
|
||||
this->format = b.format;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline bool operator < (const DeviceConfig b) const
|
||||
{
|
||||
int formatscore = this->format.find("R") != std::string::npos ? 2 : 1; // best score for RGBx
|
||||
int b_formatscore = b.format.find("R") != std::string::npos ? 2 : 1;
|
||||
float fps = static_cast<float>(this->fps_numerator) / static_cast<float>(this->fps_denominator);
|
||||
float b_fps = static_cast<float>(b.fps_numerator) / static_cast<float>(b.fps_denominator);
|
||||
return ( fps * static_cast<float>(this->height * formatscore) < b_fps * static_cast<float>(b.height * b_formatscore));
|
||||
}
|
||||
};
|
||||
|
||||
struct better_device_comparator
|
||||
{
|
||||
inline bool operator () (const DeviceConfig a, const DeviceConfig b) const
|
||||
{
|
||||
return (a < b);
|
||||
}
|
||||
};
|
||||
|
||||
typedef std::set<DeviceConfig, better_device_comparator> DeviceConfigSet;
|
||||
|
||||
|
||||
class Device
|
||||
{
|
||||
friend class DeviceSource;
|
||||
|
||||
Device();
|
||||
Device(Device const& copy) = delete;
|
||||
Device& operator=(Device const& copy) = delete;
|
||||
|
||||
public:
|
||||
|
||||
static Device& manager()
|
||||
{
|
||||
// The only instance
|
||||
static Device _instance;
|
||||
return _instance;
|
||||
}
|
||||
|
||||
void init();
|
||||
int numDevices () const;
|
||||
std::string name (int index) const;
|
||||
std::string description (int index) const;
|
||||
DeviceConfigSet config (int index) const;
|
||||
|
||||
int index (const std::string &device) const;
|
||||
bool exists (const std::string &device) const;
|
||||
bool unplugged (const std::string &device) const;
|
||||
|
||||
Source *createSource(const std::string &device) const;
|
||||
|
||||
static gboolean callback_device_monitor (GstBus *, GstMessage *, gpointer);
|
||||
static DeviceConfigSet getDeviceConfigs(const std::string &src_description);
|
||||
|
||||
private:
|
||||
|
||||
void remove(GstDevice *device);
|
||||
void add(GstDevice *device);
|
||||
|
||||
std::vector< std::string > src_name_;
|
||||
std::vector< std::string > src_description_;
|
||||
std::vector< DeviceConfigSet > src_config_;
|
||||
bool list_uptodate_;
|
||||
GstDeviceMonitor *monitor_;
|
||||
|
||||
std::list< DeviceSource * > device_sources_;
|
||||
};
|
||||
|
||||
|
||||
#endif // DEVICESOURCE_H
|
||||
@@ -1,615 +0,0 @@
|
||||
/*
|
||||
* This file is part of vimix - video live mixer
|
||||
*
|
||||
* **Copyright** (C) 2019-2022 Bruno Herbelin <bruno.herbelin@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 3 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/>.
|
||||
**/
|
||||
|
||||
|
||||
// multiplatform implementation of system dialogs
|
||||
//
|
||||
// 'TinyFileDialog' from https://github.com/native-toolkit/tinyfiledialogs.git
|
||||
// is the prefered solution, but it is not compatible with linux snap packaging
|
||||
// because of 'zenity' access rights nightmare :(
|
||||
// Thus this re-implementation of native GTK+ dialogs for linux
|
||||
|
||||
#include "defines.h"
|
||||
#include "Settings.h"
|
||||
#include "SystemToolkit.h"
|
||||
#include "DialogToolkit.h"
|
||||
|
||||
#if defined(LINUX)
|
||||
#define USE_TINYFILEDIALOG 0
|
||||
#else
|
||||
#define USE_TINYFILEDIALOG 1
|
||||
#endif
|
||||
|
||||
#if USE_TINYFILEDIALOG
|
||||
#include "tinyfiledialogs.h"
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
static bool gtk_init_ok = false;
|
||||
static int window_x = -1, window_y = -1;
|
||||
|
||||
void add_filter_any_file_dialog( GtkWidget *dialog)
|
||||
{
|
||||
/* append a wildcard option */
|
||||
GtkFileFilter *filter;
|
||||
filter = gtk_file_filter_new();
|
||||
gtk_file_filter_set_name( filter, "Any file" );
|
||||
gtk_file_filter_add_pattern( filter, "*" );
|
||||
gtk_file_chooser_add_filter( GTK_FILE_CHOOSER(dialog), filter );
|
||||
}
|
||||
|
||||
void add_filter_file_dialog( GtkWidget *dialog, int const countfilterPatterns, char const * const * const filterPatterns, char const * const filterDescription)
|
||||
{
|
||||
GtkFileFilter *filter;
|
||||
filter = gtk_file_filter_new();
|
||||
gtk_file_filter_set_name( filter, filterDescription );
|
||||
for (int i = 0; i < countfilterPatterns; i++ ) {
|
||||
gtk_file_filter_add_pattern( filter, g_ascii_strdown(filterPatterns[i], -1) );
|
||||
gtk_file_filter_add_pattern( filter, g_ascii_strup(filterPatterns[i], -1) );
|
||||
}
|
||||
gtk_file_chooser_add_filter( GTK_FILE_CHOOSER(dialog), filter );
|
||||
}
|
||||
|
||||
void wait_for_event(void)
|
||||
{
|
||||
while ( gtk_events_pending() )
|
||||
gtk_main_iteration();
|
||||
}
|
||||
|
||||
bool gtk_init()
|
||||
{
|
||||
if (!gtk_init_ok) {
|
||||
if ( gtk_init_check( NULL, NULL ) )
|
||||
gtk_init_ok = true;
|
||||
}
|
||||
return gtk_init_ok;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// globals
|
||||
const std::chrono::milliseconds timeout = std::chrono::milliseconds(4);
|
||||
bool DialogToolkit::FileDialog::busy_ = false;
|
||||
|
||||
//
|
||||
// FileDialog common functions
|
||||
//
|
||||
DialogToolkit::FileDialog::FileDialog(const std::string &name) : id_(name)
|
||||
{
|
||||
if ( Settings::application.dialogRecentFolder.count(id_) == 0 )
|
||||
Settings::application.dialogRecentFolder[id_] = SystemToolkit::home_path();
|
||||
}
|
||||
|
||||
bool DialogToolkit::FileDialog::closed()
|
||||
{
|
||||
if ( !promises_.empty() ) {
|
||||
// check that file dialog thread finished
|
||||
if (promises_.back().wait_for(timeout) == std::future_status::ready ) {
|
||||
// get the filename from this file dialog
|
||||
path_ = promises_.back().get();
|
||||
if (!path_.empty()) {
|
||||
// save path location
|
||||
Settings::application.dialogRecentFolder[id_] = SystemToolkit::path_filename(path_);
|
||||
}
|
||||
// done with this file dialog
|
||||
promises_.pop_back();
|
||||
busy_ = false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// type specific implementations
|
||||
//
|
||||
std::string openImageFileDialog(const std::string &label, const std::string &path);
|
||||
void DialogToolkit::OpenImageDialog::open()
|
||||
{
|
||||
if ( !busy_ && promises_.empty() ) {
|
||||
promises_.emplace_back( std::async(std::launch::async, openImageFileDialog, id_,
|
||||
Settings::application.dialogRecentFolder[id_]) );
|
||||
busy_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
std::string openSessionFileDialog(const std::string &label, const std::string &path);
|
||||
void DialogToolkit::OpenSessionDialog::open()
|
||||
{
|
||||
if ( !busy_ && promises_.empty() ) {
|
||||
promises_.emplace_back( std::async(std::launch::async, openSessionFileDialog, id_,
|
||||
Settings::application.dialogRecentFolder[id_]) );
|
||||
busy_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
std::string openMediaFileDialog(const std::string &label, const std::string &path);
|
||||
void DialogToolkit::OpenMediaDialog::open()
|
||||
{
|
||||
if ( !busy_ && promises_.empty() ) {
|
||||
promises_.emplace_back( std::async(std::launch::async, openMediaFileDialog, id_,
|
||||
Settings::application.dialogRecentFolder[id_]) );
|
||||
busy_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
std::string saveSessionFileDialog(const std::string &label, const std::string &path);
|
||||
void DialogToolkit::SaveSessionDialog::open()
|
||||
{
|
||||
if ( !busy_ && promises_.empty() ) {
|
||||
promises_.emplace_back( std::async(std::launch::async, saveSessionFileDialog, id_,
|
||||
Settings::application.dialogRecentFolder[id_]) );
|
||||
busy_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
std::string openFolderDialog(const std::string &label, const std::string &path);
|
||||
void DialogToolkit::OpenFolderDialog::open()
|
||||
{
|
||||
if ( !busy_ && promises_.empty() ) {
|
||||
promises_.emplace_back( std::async(std::launch::async, openFolderDialog, id_,
|
||||
Settings::application.dialogRecentFolder[id_]) );
|
||||
busy_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
std::list<std::string> selectImagesFileDialog(const std::string &label,const std::string &path);
|
||||
void DialogToolkit::MultipleImagesDialog::open()
|
||||
{
|
||||
if ( !busy_ && promisedlist_.empty() ) {
|
||||
promisedlist_.emplace_back( std::async(std::launch::async, selectImagesFileDialog, id_,
|
||||
Settings::application.dialogRecentFolder[id_]) );
|
||||
busy_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
bool DialogToolkit::MultipleImagesDialog::closed()
|
||||
{
|
||||
if ( !promisedlist_.empty() ) {
|
||||
// check that file dialog thread finished
|
||||
if (promisedlist_.back().wait_for(timeout) == std::future_status::ready ) {
|
||||
// get the filename from this file dialog
|
||||
std::list<std::string> list = promisedlist_.back().get();
|
||||
if (!list.empty()) {
|
||||
// selected a filenames
|
||||
pathlist_ = list;
|
||||
path_ = list.front();
|
||||
// save path location
|
||||
Settings::application.dialogRecentFolder[id_] = SystemToolkit::path_filename(path_);
|
||||
}
|
||||
else {
|
||||
pathlist_.clear();
|
||||
path_.clear();
|
||||
}
|
||||
// done with this file dialog
|
||||
promisedlist_.pop_back();
|
||||
busy_ = false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
//
|
||||
// CALLBACKS
|
||||
//
|
||||
//
|
||||
|
||||
std::string saveSessionFileDialog(const std::string &label, const std::string &path)
|
||||
{
|
||||
std::string filename = "";
|
||||
char const * save_pattern[1] = { VIMIX_FILES_PATTERN };
|
||||
|
||||
#if USE_TINYFILEDIALOG
|
||||
char const * save_file_name;
|
||||
|
||||
save_file_name = tinyfd_saveFileDialog( label.c_str(), path.c_str(), 1, save_pattern, "vimix session");
|
||||
|
||||
if (save_file_name)
|
||||
filename = std::string(save_file_name);
|
||||
#else
|
||||
if (!gtk_init()) {
|
||||
DialogToolkit::ErrorDialog("Could not initialize GTK+ for dialog");
|
||||
return filename;
|
||||
}
|
||||
|
||||
GtkWidget *dialog = gtk_file_chooser_dialog_new( label.c_str(), NULL,
|
||||
GTK_FILE_CHOOSER_ACTION_SAVE,
|
||||
"_Cancel", GTK_RESPONSE_CANCEL,
|
||||
"_Save", GTK_RESPONSE_ACCEPT, NULL );
|
||||
gtk_file_chooser_set_do_overwrite_confirmation( GTK_FILE_CHOOSER(dialog), TRUE );
|
||||
|
||||
// set file filters
|
||||
add_filter_file_dialog(dialog, 1, save_pattern, "vimix session");
|
||||
add_filter_any_file_dialog(dialog);
|
||||
|
||||
// Set the default path
|
||||
gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER(dialog), path.c_str() );
|
||||
|
||||
// ensure front and centered
|
||||
gtk_window_set_keep_above( GTK_WINDOW(dialog), TRUE );
|
||||
if (window_x > 0 && window_y > 0)
|
||||
gtk_window_move( GTK_WINDOW(dialog), window_x, window_y);
|
||||
|
||||
// display and get filename
|
||||
if ( gtk_dialog_run( GTK_DIALOG(dialog) ) == GTK_RESPONSE_ACCEPT ) {
|
||||
|
||||
char *save_file_name = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER(dialog) );
|
||||
if (save_file_name)
|
||||
filename = std::string(save_file_name);
|
||||
g_free( save_file_name );
|
||||
}
|
||||
|
||||
// remember position
|
||||
gtk_window_get_position( GTK_WINDOW(dialog), &window_x, &window_y);
|
||||
|
||||
// done
|
||||
gtk_widget_destroy(dialog);
|
||||
wait_for_event();
|
||||
#endif
|
||||
|
||||
std::string extension = filename.substr(filename.find_last_of(".") + 1);
|
||||
if (!filename.empty() && extension != "mix")
|
||||
filename += ".mix";
|
||||
|
||||
return filename;
|
||||
}
|
||||
|
||||
|
||||
std::string openSessionFileDialog(const std::string &label, const std::string &path)
|
||||
{
|
||||
std::string filename = "";
|
||||
std::string startpath = SystemToolkit::file_exists(path) ? path : SystemToolkit::home_path();
|
||||
char const * open_pattern[1] = { VIMIX_FILES_PATTERN };
|
||||
|
||||
#if USE_TINYFILEDIALOG
|
||||
char const * open_file_name;
|
||||
open_file_name = tinyfd_openFileDialog( label.c_str(), startpath.c_str(), 1, open_pattern, "vimix session", 0);
|
||||
|
||||
if (open_file_name)
|
||||
filename = std::string(open_file_name);
|
||||
#else
|
||||
if (!gtk_init()) {
|
||||
DialogToolkit::ErrorDialog("Could not initialize GTK+ for dialog");
|
||||
return filename;
|
||||
}
|
||||
|
||||
GtkWidget *dialog = gtk_file_chooser_dialog_new( label.c_str(), NULL,
|
||||
GTK_FILE_CHOOSER_ACTION_OPEN,
|
||||
"_Cancel", GTK_RESPONSE_CANCEL,
|
||||
"_Open", GTK_RESPONSE_ACCEPT, NULL );
|
||||
|
||||
// set file filters
|
||||
add_filter_file_dialog(dialog, 1, open_pattern, "vimix session");
|
||||
add_filter_any_file_dialog(dialog);
|
||||
|
||||
// Set the default path
|
||||
gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER(dialog), startpath.c_str() );
|
||||
|
||||
// ensure front and centered
|
||||
gtk_window_set_keep_above( GTK_WINDOW(dialog), TRUE );
|
||||
if (window_x > 0 && window_y > 0)
|
||||
gtk_window_move( GTK_WINDOW(dialog), window_x, window_y);
|
||||
|
||||
// display and get filename
|
||||
if ( gtk_dialog_run( GTK_DIALOG(dialog) ) == GTK_RESPONSE_ACCEPT ) {
|
||||
|
||||
char *open_file_name = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER(dialog) );
|
||||
if (open_file_name)
|
||||
filename = std::string(open_file_name);
|
||||
g_free( open_file_name );
|
||||
}
|
||||
|
||||
// remember position
|
||||
gtk_window_get_position( GTK_WINDOW(dialog), &window_x, &window_y);
|
||||
|
||||
// done
|
||||
gtk_widget_destroy(dialog);
|
||||
wait_for_event();
|
||||
#endif
|
||||
|
||||
return filename;
|
||||
}
|
||||
|
||||
|
||||
std::string openMediaFileDialog(const std::string &label, const std::string &path)
|
||||
{
|
||||
std::string filename = "";
|
||||
std::string startpath = SystemToolkit::file_exists(path) ? path : SystemToolkit::home_path();
|
||||
char const * open_pattern[26] = { MEDIA_FILES_PATTERN };
|
||||
|
||||
#if USE_TINYFILEDIALOG
|
||||
char const * open_file_name;
|
||||
open_file_name = tinyfd_openFileDialog( label.c_str(), startpath.c_str(), 26, open_pattern, "All supported formats", 0);
|
||||
|
||||
if (open_file_name)
|
||||
filename = std::string(open_file_name);
|
||||
#else
|
||||
|
||||
if (!gtk_init()) {
|
||||
DialogToolkit::ErrorDialog("Could not initialize GTK+ for dialog");
|
||||
return filename;
|
||||
}
|
||||
|
||||
GtkWidget *dialog = gtk_file_chooser_dialog_new( label.c_str(), NULL,
|
||||
GTK_FILE_CHOOSER_ACTION_OPEN,
|
||||
"_Cancel", GTK_RESPONSE_CANCEL,
|
||||
"_Open", GTK_RESPONSE_ACCEPT, NULL );
|
||||
|
||||
// set file filters
|
||||
add_filter_file_dialog(dialog, 26, open_pattern, "Supported formats (videos, images, sessions)");
|
||||
add_filter_any_file_dialog(dialog);
|
||||
|
||||
// Set the default path
|
||||
gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER(dialog), startpath.c_str() );
|
||||
|
||||
// ensure front and centered
|
||||
gtk_window_set_keep_above( GTK_WINDOW(dialog), TRUE );
|
||||
if (window_x > 0 && window_y > 0)
|
||||
gtk_window_move( GTK_WINDOW(dialog), window_x, window_y);
|
||||
|
||||
// display and get filename
|
||||
if ( gtk_dialog_run( GTK_DIALOG(dialog) ) == GTK_RESPONSE_ACCEPT ) {
|
||||
|
||||
char *open_file_name = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER(dialog) );
|
||||
if (open_file_name)
|
||||
filename = std::string(open_file_name);
|
||||
g_free( open_file_name );
|
||||
}
|
||||
|
||||
// remember position
|
||||
gtk_window_get_position( GTK_WINDOW(dialog), &window_x, &window_y);
|
||||
|
||||
// done
|
||||
gtk_widget_destroy(dialog);
|
||||
wait_for_event();
|
||||
#endif
|
||||
|
||||
return filename;
|
||||
}
|
||||
|
||||
|
||||
std::string openImageFileDialog(const std::string &label, const std::string &path)
|
||||
{
|
||||
std::string filename = "";
|
||||
std::string startpath = SystemToolkit::file_exists(path) ? path : SystemToolkit::home_path();
|
||||
char const * open_pattern[5] = { IMAGES_FILES_PATTERN };
|
||||
|
||||
#if USE_TINYFILEDIALOG
|
||||
char const * open_file_name;
|
||||
open_file_name = tinyfd_openFileDialog( label.c_str(), startpath.c_str(), 5, open_pattern, "Image (JPG, PNG, BMP, PPM, GIF)", 0);
|
||||
|
||||
if (open_file_name)
|
||||
filename = std::string(open_file_name);
|
||||
#else
|
||||
|
||||
if (!gtk_init()) {
|
||||
DialogToolkit::ErrorDialog("Could not initialize GTK+ for dialog");
|
||||
return filename;
|
||||
}
|
||||
|
||||
GtkWidget *dialog = gtk_file_chooser_dialog_new( label.c_str(), NULL,
|
||||
GTK_FILE_CHOOSER_ACTION_OPEN,
|
||||
"_Cancel", GTK_RESPONSE_CANCEL,
|
||||
"_Open", GTK_RESPONSE_ACCEPT, NULL );
|
||||
|
||||
// set file filters
|
||||
add_filter_file_dialog(dialog, 5, open_pattern, "Image (JPG, PNG, BMP, PPM, GIF)");
|
||||
add_filter_any_file_dialog(dialog);
|
||||
|
||||
// Set the default path
|
||||
gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER(dialog), startpath.c_str() );
|
||||
|
||||
// ensure front and centered
|
||||
gtk_window_set_keep_above( GTK_WINDOW(dialog), TRUE );
|
||||
if (window_x > 0 && window_y > 0)
|
||||
gtk_window_move( GTK_WINDOW(dialog), window_x, window_y);
|
||||
|
||||
// display and get filename
|
||||
if ( gtk_dialog_run( GTK_DIALOG(dialog) ) == GTK_RESPONSE_ACCEPT ) {
|
||||
|
||||
char *open_file_name = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER(dialog) );
|
||||
if (open_file_name)
|
||||
filename = std::string(open_file_name);
|
||||
g_free( open_file_name );
|
||||
}
|
||||
|
||||
// remember position
|
||||
gtk_window_get_position( GTK_WINDOW(dialog), &window_x, &window_y);
|
||||
|
||||
// done
|
||||
gtk_widget_destroy(dialog);
|
||||
wait_for_event();
|
||||
#endif
|
||||
|
||||
return filename;
|
||||
}
|
||||
|
||||
|
||||
std::string openFolderDialog(const std::string &label, const std::string &path)
|
||||
{
|
||||
std::string foldername = "";
|
||||
std::string startpath = SystemToolkit::file_exists(path) ? path : SystemToolkit::home_path();
|
||||
|
||||
#if USE_TINYFILEDIALOG
|
||||
char const * open_folder_name;
|
||||
open_folder_name = tinyfd_selectFolderDialog(label.c_str(), startpath.c_str());
|
||||
|
||||
if (open_folder_name)
|
||||
foldername = std::string(open_folder_name);
|
||||
#else
|
||||
if (!gtk_init()) {
|
||||
DialogToolkit::ErrorDialog("Could not initialize GTK+ for dialog");
|
||||
return foldername;
|
||||
}
|
||||
|
||||
GtkWidget *dialog = gtk_file_chooser_dialog_new( label.c_str(), NULL,
|
||||
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
|
||||
"_Cancel", GTK_RESPONSE_CANCEL,
|
||||
"_Select", GTK_RESPONSE_ACCEPT, NULL );
|
||||
gtk_file_chooser_set_do_overwrite_confirmation( GTK_FILE_CHOOSER(dialog), TRUE );
|
||||
|
||||
// Set the default path
|
||||
gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER(dialog), startpath.c_str() );
|
||||
|
||||
// ensure front and centered
|
||||
gtk_window_set_keep_above( GTK_WINDOW(dialog), TRUE );
|
||||
if (window_x > 0 && window_y > 0)
|
||||
gtk_window_move( GTK_WINDOW(dialog), window_x, window_y);
|
||||
|
||||
// display and get filename
|
||||
if ( gtk_dialog_run( GTK_DIALOG(dialog) ) == GTK_RESPONSE_ACCEPT ) {
|
||||
|
||||
char *open_folder_name = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER(dialog) );
|
||||
if (open_folder_name)
|
||||
foldername = std::string(open_folder_name);
|
||||
g_free( open_folder_name );
|
||||
}
|
||||
|
||||
// remember position
|
||||
gtk_window_get_position( GTK_WINDOW(dialog), &window_x, &window_y);
|
||||
|
||||
// done
|
||||
gtk_widget_destroy(dialog);
|
||||
wait_for_event();
|
||||
#endif
|
||||
|
||||
return foldername;
|
||||
}
|
||||
|
||||
|
||||
std::list<std::string> selectImagesFileDialog(const std::string &label,const std::string &path)
|
||||
{
|
||||
std::list<std::string> files;
|
||||
|
||||
std::string startpath = SystemToolkit::file_exists(path) ? path : SystemToolkit::home_path();
|
||||
char const * open_pattern[6] = { "*.jpg", "*.png", "*.tif" };
|
||||
|
||||
#if USE_TINYFILEDIALOG
|
||||
char const * open_file_names;
|
||||
open_file_names = tinyfd_openFileDialog(label.c_str(), startpath.c_str(), 3, open_pattern, "Images (JPG, PNG, TIF)", 1);
|
||||
|
||||
if (open_file_names) {
|
||||
|
||||
const std::string& str (open_file_names);
|
||||
const std::string& delimiters = "|";
|
||||
// Skip delimiters at beginning.
|
||||
std::string::size_type lastPos = str.find_first_not_of(delimiters, 0);
|
||||
|
||||
// Find first non-delimiter.
|
||||
std::string::size_type pos = str.find_first_of(delimiters, lastPos);
|
||||
|
||||
while (std::string::npos != pos || std::string::npos != lastPos) {
|
||||
// Found a token, add it to the vector.
|
||||
files.push_back(str.substr(lastPos, pos - lastPos));
|
||||
|
||||
// Skip delimiters.
|
||||
lastPos = str.find_first_not_of(delimiters, pos);
|
||||
|
||||
// Find next non-delimiter.
|
||||
pos = str.find_first_of(delimiters, lastPos);
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
||||
if (!gtk_init()) {
|
||||
DialogToolkit::ErrorDialog("Could not initialize GTK+ for dialog");
|
||||
return files;
|
||||
}
|
||||
|
||||
GtkWidget *dialog = gtk_file_chooser_dialog_new( label.c_str(), NULL,
|
||||
GTK_FILE_CHOOSER_ACTION_OPEN,
|
||||
"_Cancel", GTK_RESPONSE_CANCEL,
|
||||
"_Open", GTK_RESPONSE_ACCEPT, NULL );
|
||||
|
||||
// set file filters
|
||||
add_filter_file_dialog(dialog, 3, open_pattern, "Images (JPG, PNG, TIF)");
|
||||
add_filter_any_file_dialog(dialog);
|
||||
|
||||
// multiple files
|
||||
gtk_file_chooser_set_select_multiple( GTK_FILE_CHOOSER(dialog), true );
|
||||
|
||||
// Set the default path
|
||||
gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER(dialog), startpath.c_str() );
|
||||
|
||||
// ensure front and centered
|
||||
gtk_window_set_keep_above( GTK_WINDOW(dialog), TRUE );
|
||||
if (window_x > 0 && window_y > 0)
|
||||
gtk_window_move( GTK_WINDOW(dialog), window_x, window_y);
|
||||
|
||||
// display and get filename
|
||||
if ( gtk_dialog_run( GTK_DIALOG(dialog) ) == GTK_RESPONSE_ACCEPT ) {
|
||||
|
||||
GSList *open_file_names = gtk_file_chooser_get_filenames( GTK_FILE_CHOOSER(dialog) );
|
||||
|
||||
while (open_file_names) {
|
||||
files.push_back( (char *) open_file_names->data );
|
||||
open_file_names = open_file_names->next;
|
||||
// g_free( open_file_names->data );
|
||||
}
|
||||
|
||||
g_slist_free( open_file_names );
|
||||
}
|
||||
|
||||
// remember position
|
||||
gtk_window_get_position( GTK_WINDOW(dialog), &window_x, &window_y);
|
||||
|
||||
// done
|
||||
gtk_widget_destroy(dialog);
|
||||
wait_for_event();
|
||||
#endif
|
||||
|
||||
|
||||
return files;
|
||||
}
|
||||
|
||||
void DialogToolkit::ErrorDialog(const char* message)
|
||||
{
|
||||
#if USE_TINYFILEDIALOG
|
||||
tinyfd_messageBox( APP_TITLE, message, "ok", "error", 0);
|
||||
#else
|
||||
if (!gtk_init()) {
|
||||
return;
|
||||
}
|
||||
|
||||
GtkWidget *dialog = gtk_message_dialog_new( NULL, GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
|
||||
"Error: %s", message);
|
||||
|
||||
gtk_window_set_keep_above( GTK_WINDOW(dialog), TRUE );
|
||||
static int x = 0, y = 0;
|
||||
if (x != 0)
|
||||
gtk_window_move( GTK_WINDOW(dialog), x, y);
|
||||
|
||||
// show
|
||||
gtk_dialog_run( GTK_DIALOG(dialog) );
|
||||
|
||||
// remember position
|
||||
gtk_window_get_position( GTK_WINDOW(dialog), &x, &y);
|
||||
|
||||
// done
|
||||
gtk_widget_destroy( dialog );
|
||||
wait_for_event();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
#ifndef DIALOGTOOLKIT_H
|
||||
#define DIALOGTOOLKIT_H
|
||||
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <vector>
|
||||
#include <future>
|
||||
|
||||
#define VIMIX_FILES_PATTERN "*.mix"
|
||||
#define MEDIA_FILES_PATTERN "*.mix", "*.mp4", "*.mpg", "*.mpeg", "*.m2v", "*.m4v", "*.avi", "*.mov",\
|
||||
"*.mkv", "*.webm", "*.mod", "*.wmv", "*.mxf", "*.ogg",\
|
||||
"*.flv", "*.hevc", "*.asf", "*.jpg", "*.png", "*.gif",\
|
||||
"*.tif", "*.tiff", "*.webp", "*.bmp", "*.ppm", "*.svg,"
|
||||
#define IMAGES_FILES_PATTERN "*.jpg", "*.png", "*.bmp", "*.ppm", "*.gif"
|
||||
|
||||
namespace DialogToolkit
|
||||
{
|
||||
|
||||
void ErrorDialog(const char* message);
|
||||
|
||||
class FileDialog
|
||||
{
|
||||
protected:
|
||||
std::string id_;
|
||||
std::string directory_;
|
||||
std::string path_;
|
||||
std::vector< std::future<std::string> >promises_;
|
||||
static bool busy_;
|
||||
|
||||
public:
|
||||
FileDialog(const std::string &name);
|
||||
|
||||
virtual void open() = 0;
|
||||
virtual bool closed();
|
||||
inline std::string path() const { return path_; }
|
||||
|
||||
static bool busy() { return busy_; }
|
||||
};
|
||||
|
||||
class OpenImageDialog : public FileDialog
|
||||
{
|
||||
public:
|
||||
OpenImageDialog(const std::string &name) : FileDialog(name) {}
|
||||
void open();
|
||||
};
|
||||
|
||||
class OpenSessionDialog : public FileDialog
|
||||
{
|
||||
public:
|
||||
OpenSessionDialog(const std::string &name) : FileDialog(name) {}
|
||||
void open();
|
||||
};
|
||||
|
||||
class OpenMediaDialog : public FileDialog
|
||||
{
|
||||
public:
|
||||
OpenMediaDialog(const std::string &name) : FileDialog(name) {}
|
||||
void open();
|
||||
};
|
||||
|
||||
class SaveSessionDialog : public FileDialog
|
||||
{
|
||||
public:
|
||||
SaveSessionDialog(const std::string &name) : FileDialog(name) {}
|
||||
void open();
|
||||
};
|
||||
|
||||
class OpenFolderDialog : public FileDialog
|
||||
{
|
||||
public:
|
||||
OpenFolderDialog(const std::string &name) : FileDialog(name) {}
|
||||
void open();
|
||||
};
|
||||
|
||||
class MultipleImagesDialog : public FileDialog
|
||||
{
|
||||
std::list<std::string> pathlist_;
|
||||
std::vector< std::future< std::list<std::string> > > promisedlist_;
|
||||
public:
|
||||
MultipleImagesDialog(const std::string &name) : FileDialog(name) {}
|
||||
void open() override;
|
||||
bool closed() override;
|
||||
inline std::list<std::string> images() const { return pathlist_; }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif // DIALOGTOOLKIT_H
|
||||
@@ -1,29 +0,0 @@
|
||||
#ifndef DRAWVISITOR_H
|
||||
#define DRAWVISITOR_H
|
||||
|
||||
#include "GlmToolkit.h"
|
||||
#include "Visitor.h"
|
||||
|
||||
class DrawVisitor : public Visitor
|
||||
{
|
||||
glm::mat4 modelview_;
|
||||
glm::mat4 projection_;
|
||||
std::vector<Node *> targets_;
|
||||
bool force_;
|
||||
int num_duplicat_;
|
||||
glm::mat4 transform_duplicat_;
|
||||
|
||||
public:
|
||||
DrawVisitor(Node *nodetodraw, glm::mat4 projection, bool force = false);
|
||||
DrawVisitor(const std::vector<Node *> &nodestodraw, glm::mat4 projection, bool force = false);
|
||||
|
||||
void loop(int num, glm::mat4 transform);
|
||||
|
||||
void visit(Scene& n) override;
|
||||
void visit(Node& n) override;
|
||||
void visit(Primitive& ) override;
|
||||
void visit(Group& n) override;
|
||||
void visit(Switch& n) override;
|
||||
};
|
||||
|
||||
#endif // DRAWVISITOR_H
|
||||
1232
FileDialog.cpp
112
FileDialog.h
@@ -1,112 +0,0 @@
|
||||
#ifndef __IMGUI_FILE_DIALOG_H_
|
||||
#define __IMGUI_FILE_DIALOG_H_
|
||||
|
||||
#include "imgui.h"
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <future>
|
||||
#include <functional>
|
||||
|
||||
#define MAX_FILE_DIALOG_NAME_BUFFER 1024
|
||||
|
||||
struct FileInfoStruct
|
||||
{
|
||||
char type = ' ';
|
||||
std::string filePath;
|
||||
std::string fileName;
|
||||
std::string ext;
|
||||
};
|
||||
|
||||
class FileDialog
|
||||
{
|
||||
private:
|
||||
std::vector<FileInfoStruct> m_FileList;
|
||||
std::map<std::string, ImVec4> m_FilterColor;
|
||||
std::string m_SelectedFileName;
|
||||
std::string m_SelectedExt;
|
||||
std::string m_CurrentPath;
|
||||
std::vector<std::string> m_CurrentPath_Decomposition;
|
||||
std::string m_Name;
|
||||
bool m_ShowDialog;
|
||||
bool m_ShowDrives;
|
||||
|
||||
public:
|
||||
static char FileNameBuffer[MAX_FILE_DIALOG_NAME_BUFFER];
|
||||
static char DirectoryNameBuffer[MAX_FILE_DIALOG_NAME_BUFFER];
|
||||
static char SearchBuffer[MAX_FILE_DIALOG_NAME_BUFFER];
|
||||
static int FilterIndex;
|
||||
bool IsOk;
|
||||
bool m_AnyWindowsHovered;
|
||||
bool m_CreateDirectoryMode;
|
||||
|
||||
private:
|
||||
std::string dlg_key;
|
||||
std::string dlg_name;
|
||||
const char *dlg_filters;
|
||||
std::string dlg_path;
|
||||
std::string dlg_defaultFileName;
|
||||
std::string dlg_defaultExt;
|
||||
std::function<void(std::string, bool*)> dlg_optionsPane;
|
||||
size_t dlg_optionsPaneWidth;
|
||||
std::string searchTag;
|
||||
std::string dlg_userString;
|
||||
|
||||
public:
|
||||
static FileDialog* Instance()
|
||||
{
|
||||
static FileDialog *_instance = new FileDialog();
|
||||
return _instance;
|
||||
}
|
||||
|
||||
static void RenderCurrent();
|
||||
// Open an Open File dialog for TEXT file
|
||||
static void SetCurrentOpenText();
|
||||
// Open an Open File dialog for IMAGE file
|
||||
static void SetCurrentOpenImage();
|
||||
// Open an Open File dialog for MEDIA file
|
||||
static void SetCurrentOpenMedia();
|
||||
|
||||
protected:
|
||||
|
||||
FileDialog(); // Prevent construction
|
||||
FileDialog(const FileDialog&) = delete; // Prevent construction by copying
|
||||
FileDialog& operator =(const FileDialog&) = delete; // Prevent assignment
|
||||
~FileDialog(); // Prevent unwanted destruction
|
||||
|
||||
public:
|
||||
void OpenDialog(const std::string& vKey, const char* vName, const char* vFilters,
|
||||
const std::string& vPath, const std::string& vDefaultFileName,
|
||||
std::function<void(std::string, bool*)> vOptionsPane, size_t vOptionsPaneWidth = 250, const std::string& vUserString = "");
|
||||
void OpenDialog(const std::string& vKey, const char* vName, const char* vFilters,
|
||||
const std::string& vDefaultFileName,
|
||||
std::function<void(std::string, bool*)> vOptionsPane, size_t vOptionsPaneWidth = 250, const std::string& vUserString = "");
|
||||
void OpenDialog(const std::string& vKey, const char* vName, const char* vFilters,
|
||||
const std::string& vPath, const std::string& vDefaultFileName, const std::string& vUserString = "");
|
||||
void OpenDialog(const std::string& vKey, const char* vName, const char* vFilters,
|
||||
const std::string& vFilePathName, const std::string& vUserString = "");
|
||||
|
||||
void CloseDialog(const std::string& vKey);
|
||||
bool Render(const std::string& vKey, ImVec2 geometry);
|
||||
std::string GetFilepathName();
|
||||
std::string GetCurrentPath();
|
||||
std::string GetCurrentFileName();
|
||||
std::string GetCurrentFilter();
|
||||
std::string GetUserString();
|
||||
|
||||
void SetFilterColor(const std::string &vFilter, ImVec4 vColor);
|
||||
bool GetFilterColor(const std::string &vFilter, ImVec4 *vColor);
|
||||
void ClearFilterColor();
|
||||
|
||||
private:
|
||||
void SetPath(const std::string& vPath);
|
||||
void ScanDir(const std::string& vPath);
|
||||
void SetCurrentDir(const std::string& vPath);
|
||||
bool CreateDir(const std::string& vPath);
|
||||
void ComposeNewPath(std::vector<std::string>::iterator vIter);
|
||||
void GetDrives();
|
||||
};
|
||||
|
||||
|
||||
#endif // __IMGUI_FILE_DIALOG_H_
|
||||
475
FrameBuffer.cpp
@@ -1,475 +0,0 @@
|
||||
/*
|
||||
* This file is part of vimix - video live mixer
|
||||
*
|
||||
* **Copyright** (C) 2019-2022 Bruno Herbelin <bruno.herbelin@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 3 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 <sstream>
|
||||
|
||||
#include "FrameBuffer.h"
|
||||
#include "ImageShader.h"
|
||||
#include "Resource.h"
|
||||
#include "Settings.h"
|
||||
#include "Log.h"
|
||||
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
|
||||
#include <glad/glad.h>
|
||||
#include <stb_image.h>
|
||||
#include <stb_image_write.h>
|
||||
|
||||
const char* FrameBuffer::aspect_ratio_name[5] = { "4:3", "3:2", "16:10", "16:9", "21:9" };
|
||||
glm::vec2 FrameBuffer::aspect_ratio_size[5] = { glm::vec2(4.f,3.f), glm::vec2(3.f,2.f), glm::vec2(16.f,10.f), glm::vec2(16.f,9.f) , glm::vec2(21.f,9.f) };
|
||||
const char* FrameBuffer::resolution_name[5] = { "720", "1080", "1200", "1440", "2160" };
|
||||
float FrameBuffer::resolution_height[5] = { 720.f, 1080.f, 1200.f, 1440.f, 2160.f };
|
||||
|
||||
|
||||
glm::vec3 FrameBuffer::getResolutionFromParameters(int ar, int h)
|
||||
{
|
||||
float width = aspect_ratio_size[ar].x * resolution_height[h] / aspect_ratio_size[ar].y;
|
||||
width -= (int)width % 2;
|
||||
glm::vec3 res = glm::vec3( width, resolution_height[h] , 0.f);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
glm::ivec2 FrameBuffer::getParametersFromResolution(glm::vec3 res)
|
||||
{
|
||||
glm::ivec2 p = glm::ivec2(-1);
|
||||
|
||||
// get aspect ratio parameter
|
||||
static int num_ar = ((int)(sizeof(FrameBuffer::aspect_ratio_size) / sizeof(*FrameBuffer::aspect_ratio_size)));
|
||||
float myratio = res.x / res.y;
|
||||
for(int ar = 0; ar < num_ar; ar++) {
|
||||
if ( myratio - (FrameBuffer::aspect_ratio_size[ar].x / FrameBuffer::aspect_ratio_size[ar].y ) < EPSILON){
|
||||
p.x = ar;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// get height parameter
|
||||
static int num_height = ((int)(sizeof(FrameBuffer::resolution_height) / sizeof(*FrameBuffer::resolution_height)));
|
||||
for(int h = 0; h < num_height; h++) {
|
||||
if ( res.y - FrameBuffer::resolution_height[h] < 1){
|
||||
p.y = h;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
FrameBuffer::FrameBuffer(glm::vec3 resolution, bool useAlpha, bool multiSampling):
|
||||
textureid_(0), intermediate_textureid_(0), framebufferid_(0), intermediate_framebufferid_(0),
|
||||
use_alpha_(useAlpha), use_multi_sampling_(multiSampling)
|
||||
{
|
||||
attrib_.viewport = glm::ivec2(resolution);
|
||||
setProjectionArea(glm::vec2(1.f, 1.f));
|
||||
attrib_.clear_color = glm::vec4(0.f, 0.f, 0.f, 0.f);
|
||||
}
|
||||
|
||||
FrameBuffer::FrameBuffer(uint width, uint height, bool useAlpha, bool multiSampling):
|
||||
textureid_(0), intermediate_textureid_(0), framebufferid_(0), intermediate_framebufferid_(0),
|
||||
use_alpha_(useAlpha), use_multi_sampling_(multiSampling)
|
||||
{
|
||||
attrib_.viewport = glm::ivec2(width, height);
|
||||
setProjectionArea(glm::vec2(1.f, 1.f));
|
||||
attrib_.clear_color = glm::vec4(0.f, 0.f, 0.f, 0.f);
|
||||
}
|
||||
|
||||
void FrameBuffer::init()
|
||||
{
|
||||
// generate texture
|
||||
glGenTextures(1, &textureid_);
|
||||
glBindTexture(GL_TEXTURE_2D, textureid_);
|
||||
glTexStorage2D(GL_TEXTURE_2D, 1, use_alpha_ ? GL_RGBA8 : GL_RGB8, attrib_.viewport.x, attrib_.viewport.y);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
// create a framebuffer object
|
||||
glGenFramebuffers(1, &framebufferid_);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, framebufferid_);
|
||||
|
||||
// take settings into account: no multisampling for level 0
|
||||
use_multi_sampling_ &= Settings::application.render.multisampling > 0;
|
||||
|
||||
if (use_multi_sampling_){
|
||||
|
||||
// create a multisample texture
|
||||
glGenTextures(1, &intermediate_textureid_);
|
||||
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, intermediate_textureid_);
|
||||
glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, Settings::application.render.multisampling,
|
||||
use_alpha_ ? GL_RGBA8 : GL_RGB8, attrib_.viewport.x, attrib_.viewport.y, GL_TRUE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, 0);
|
||||
|
||||
// attach the multisampled texture to FBO (framebufferid_ currently binded)
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE, intermediate_textureid_, 0);
|
||||
|
||||
// create an intermediate FBO : this is the FBO to use for reading
|
||||
glGenFramebuffers(1, &intermediate_framebufferid_);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, intermediate_framebufferid_);
|
||||
|
||||
// attach the 2D texture to intermediate FBO (intermediate_framebufferid_)
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textureid_, 0);
|
||||
|
||||
// Log::Info("New FBO %d Multi Sampling ", framebufferid_);
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
// direct attach the 2D texture to FBO
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textureid_, 0);
|
||||
|
||||
// Log::Info("New FBO %d Single Sampling ", framebufferid_);
|
||||
}
|
||||
|
||||
checkFramebufferStatus();
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
|
||||
}
|
||||
|
||||
FrameBuffer::~FrameBuffer()
|
||||
{
|
||||
if (framebufferid_)
|
||||
glDeleteFramebuffers(1, &framebufferid_);
|
||||
if (intermediate_framebufferid_)
|
||||
glDeleteFramebuffers(1, &intermediate_framebufferid_);
|
||||
if (textureid_)
|
||||
glDeleteTextures(1, &textureid_);
|
||||
if (intermediate_textureid_)
|
||||
glDeleteTextures(1, &intermediate_textureid_);
|
||||
}
|
||||
|
||||
|
||||
uint FrameBuffer::texture() const
|
||||
{
|
||||
if (framebufferid_ == 0)
|
||||
return Resource::getTextureBlack();
|
||||
|
||||
return textureid_;
|
||||
}
|
||||
|
||||
float FrameBuffer::aspectRatio() const
|
||||
{
|
||||
return static_cast<float>(attrib_.viewport.x) / static_cast<float>(attrib_.viewport.y);
|
||||
}
|
||||
|
||||
|
||||
std::string FrameBuffer::info() const
|
||||
{
|
||||
glm::ivec2 p = FrameBuffer::getParametersFromResolution(resolution());
|
||||
std::ostringstream info;
|
||||
|
||||
info << attrib_.viewport.x << "x" << attrib_.viewport.y;
|
||||
if (p.x > -1)
|
||||
info << "px, " << FrameBuffer::aspect_ratio_name[p.x];
|
||||
|
||||
return info.str();
|
||||
}
|
||||
|
||||
glm::vec3 FrameBuffer::resolution() const
|
||||
{
|
||||
return glm::vec3(attrib_.viewport.x, attrib_.viewport.y, 0.f);
|
||||
}
|
||||
|
||||
void FrameBuffer::resize(int width, int height)
|
||||
{
|
||||
if (framebufferid_) {
|
||||
if (attrib_.viewport.x != width || attrib_.viewport.y != height)
|
||||
{
|
||||
// de-init
|
||||
glDeleteFramebuffers(1, &framebufferid_);
|
||||
framebufferid_ = 0;
|
||||
|
||||
if (intermediate_framebufferid_)
|
||||
glDeleteFramebuffers(1, &intermediate_framebufferid_);
|
||||
intermediate_framebufferid_ = 0;
|
||||
if (textureid_)
|
||||
glDeleteTextures(1, &textureid_);
|
||||
textureid_ = 0;
|
||||
if (intermediate_textureid_)
|
||||
glDeleteTextures(1, &intermediate_textureid_);
|
||||
intermediate_textureid_ = 0;
|
||||
|
||||
// change resolution
|
||||
attrib_.viewport = glm::ivec2(width, height);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FrameBuffer::begin(bool clear)
|
||||
{
|
||||
if (!framebufferid_)
|
||||
init();
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, framebufferid_);
|
||||
|
||||
Rendering::manager().pushAttrib(attrib_);
|
||||
|
||||
if (clear)
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
|
||||
void FrameBuffer::end()
|
||||
{
|
||||
// if multisampling frame buffer
|
||||
if (use_multi_sampling_) {
|
||||
// blit the multisample FBO into unisample FBO to generate 2D texture
|
||||
// Doing this blit will automatically resolve the multisampled FBO.
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, framebufferid_);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, intermediate_framebufferid_);
|
||||
glBlitFramebuffer(0, 0, attrib_.viewport.x, attrib_.viewport.y,
|
||||
0, 0, attrib_.viewport.x, attrib_.viewport.y, GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||
}
|
||||
|
||||
FrameBuffer::release();
|
||||
|
||||
Rendering::manager().popAttrib();
|
||||
}
|
||||
|
||||
void FrameBuffer::release()
|
||||
{
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
}
|
||||
|
||||
void FrameBuffer::readPixels(uint8_t *target_data)
|
||||
{
|
||||
if (!framebufferid_)
|
||||
return;
|
||||
|
||||
if (use_multi_sampling_)
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, intermediate_framebufferid_);
|
||||
else
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, framebufferid_);
|
||||
|
||||
if (use_alpha())
|
||||
glPixelStorei(GL_PACK_ALIGNMENT, 4);
|
||||
else
|
||||
glPixelStorei(GL_PACK_ALIGNMENT, 1);
|
||||
|
||||
glReadPixels(0, 0, attrib_.viewport.x, attrib_.viewport.y, (use_alpha_? GL_RGBA : GL_RGB), GL_UNSIGNED_BYTE, target_data);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
}
|
||||
|
||||
bool FrameBuffer::blit(FrameBuffer *destination)
|
||||
{
|
||||
if (!framebufferid_ || !destination || (use_alpha_ != destination->use_alpha_) )
|
||||
return false;
|
||||
|
||||
if (!destination->framebufferid_)
|
||||
destination->init();
|
||||
|
||||
if (use_multi_sampling_)
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, intermediate_framebufferid_);
|
||||
else
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, framebufferid_);
|
||||
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, destination->framebufferid_);
|
||||
// blit to the frame buffer object
|
||||
glBlitFramebuffer(0, 0, attrib_.viewport.x, attrib_.viewport.y,
|
||||
0, 0, destination->width(), destination->height(), GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void FrameBuffer::checkFramebufferStatus()
|
||||
{
|
||||
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||
switch (status){
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
|
||||
Log::Warning("GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT is returned if any of the framebuffer attachment points are framebuffer incomplete.");
|
||||
break;
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
|
||||
Log::Warning("GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT is returned if the framebuffer does not have at least one image attached to it.");
|
||||
break;
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER:
|
||||
Log::Warning("GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER is returned if the value of GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE is GL_NONE for any color attachment point(s) named by GL_DRAWBUFFERi.");
|
||||
break;
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER:
|
||||
Log::Warning("GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER is returned if GL_READ_BUFFER is not GL_NONE and the value of GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE is GL_NONE for the color attachment point named by GL_READ_BUFFER.");
|
||||
break;
|
||||
case GL_FRAMEBUFFER_UNSUPPORTED:
|
||||
Log::Warning("GL_FRAMEBUFFER_UNSUPPORTED is returned if the combination of internal formats of the attached images violates an implementation-dependent set of restrictions.");
|
||||
break;
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:
|
||||
Log::Warning("GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE is returned if the value of GL_RENDERBUFFER_SAMPLES is not the same for all attached renderbuffers; if the value of GL_TEXTURE_SAMPLES is the not same for all attached textures; or, if the attached images are a mix of renderbuffers and textures, the value of GL_RENDERBUFFER_SAMPLES does not match the value of GL_TEXTURE_SAMPLES.\nGL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE is also returned if the value of GL_TEXTURE_FIXED_SAMPLE_LOCATIONS is not the same for all attached textures; or, if the attached images are a mix of renderbuffers and textures, the value of GL_TEXTURE_FIXED_SAMPLE_LOCATIONS is not GL_TRUE for all attached textures.");
|
||||
break;
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS:
|
||||
Log::Warning("GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS is returned if any framebuffer attachment is layered, and any populated attachment is not layered, or if all populated color attachments are not from textures of the same target.");
|
||||
break;
|
||||
case GL_FRAMEBUFFER_UNDEFINED:
|
||||
Log::Warning(" GL_FRAMEBUFFER_UNDEFINED is returned if target is the default framebuffer, but the default framebuffer does not exist.");
|
||||
break;
|
||||
case GL_FRAMEBUFFER_COMPLETE:
|
||||
#ifndef NDEBUG
|
||||
g_print("Framebuffer created %d x %d\n", width(), height());
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
glm::mat4 FrameBuffer::projection() const
|
||||
{
|
||||
return projection_;
|
||||
}
|
||||
|
||||
glm::vec2 FrameBuffer::projectionArea() const
|
||||
{
|
||||
return projection_area_;
|
||||
}
|
||||
|
||||
void FrameBuffer::setProjectionArea(glm::vec2 c)
|
||||
{
|
||||
projection_area_.x = CLAMP(c.x, 0.1f, 1.f);
|
||||
projection_area_.y = CLAMP(c.y, 0.1f, 1.f);
|
||||
projection_ = glm::ortho(-projection_area_.x, projection_area_.x, projection_area_.y, -projection_area_.y, -1.f, 1.f);
|
||||
}
|
||||
|
||||
|
||||
FrameBufferImage::FrameBufferImage(int w, int h) :
|
||||
rgb(nullptr), width(w), height(h)
|
||||
{
|
||||
if (width>0 && height>0)
|
||||
rgb = new uint8_t[width*height*3];
|
||||
}
|
||||
|
||||
FrameBufferImage::FrameBufferImage(jpegBuffer jpgimg) :
|
||||
rgb(nullptr), width(0), height(0)
|
||||
{
|
||||
int c = 0;
|
||||
if (jpgimg.buffer != nullptr && jpgimg.len >0)
|
||||
rgb = stbi_load_from_memory(jpgimg.buffer, jpgimg.len, &width, &height, &c, 3);
|
||||
}
|
||||
|
||||
FrameBufferImage::FrameBufferImage(const std::string &filename) :
|
||||
rgb(nullptr), width(0), height(0)
|
||||
{
|
||||
int c = 0;
|
||||
if (!filename.empty())
|
||||
rgb = stbi_load(filename.c_str(), &width, &height, &c, 3);
|
||||
}
|
||||
|
||||
FrameBufferImage::~FrameBufferImage()
|
||||
{
|
||||
if (rgb!=nullptr)
|
||||
delete rgb;
|
||||
}
|
||||
|
||||
FrameBufferImage::jpegBuffer FrameBufferImage::getJpeg() const
|
||||
{
|
||||
jpegBuffer jpgimg;
|
||||
|
||||
// if we hold a valid image
|
||||
if (rgb!=nullptr && width>0 && height>0) {
|
||||
|
||||
// allocate JPEG buffer
|
||||
// (NB: JPEG will need less than this but we can't know before...)
|
||||
jpgimg.buffer = (unsigned char *) malloc( width * height * 3 * sizeof(unsigned char));
|
||||
|
||||
stbi_write_jpg_to_func( [](void *context, void *data, int size)
|
||||
{
|
||||
memcpy(((FrameBufferImage::jpegBuffer*)context)->buffer + ((FrameBufferImage::jpegBuffer*)context)->len, data, size);
|
||||
((FrameBufferImage::jpegBuffer*)context)->len += size;
|
||||
}
|
||||
,&jpgimg, width, height, 3, rgb, FBI_JPEG_QUALITY);
|
||||
}
|
||||
|
||||
return jpgimg;
|
||||
}
|
||||
|
||||
FrameBufferImage *FrameBuffer::image(){
|
||||
|
||||
FrameBufferImage *img = nullptr;
|
||||
|
||||
// not ready
|
||||
if (!framebufferid_)
|
||||
return img;
|
||||
|
||||
// only compatible for RGB FrameBuffers
|
||||
if (use_alpha_ || use_multi_sampling_)
|
||||
return img;
|
||||
|
||||
// allocate image
|
||||
img = new FrameBufferImage(attrib_.viewport.x, attrib_.viewport.y);
|
||||
|
||||
// get pixels into image
|
||||
glBindBuffer(GL_PIXEL_PACK_BUFFER, 0); // set buffer target readpixel
|
||||
readPixels(img->rgb);
|
||||
|
||||
return img;
|
||||
}
|
||||
|
||||
bool FrameBuffer::fill(FrameBufferImage *image)
|
||||
{
|
||||
if (!framebufferid_)
|
||||
init();
|
||||
|
||||
// only compatible for RGB FrameBuffers
|
||||
if (use_alpha_ || use_multi_sampling_)
|
||||
return false;
|
||||
|
||||
// invalid image
|
||||
if ( image == nullptr ||
|
||||
image->rgb==nullptr ||
|
||||
image->width < 1 ||
|
||||
image->height < 1 )
|
||||
return false;
|
||||
|
||||
// is it same size ?
|
||||
if (image->width == attrib_.viewport.x && image->height == attrib_.viewport.y ) {
|
||||
// directly fill texture with image
|
||||
glBindTexture(GL_TEXTURE_2D, textureid_);
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, image->width, image->height,
|
||||
GL_RGB, GL_UNSIGNED_BYTE, image->rgb);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
}
|
||||
else {
|
||||
uint textureimage, framebufferimage;
|
||||
// generate texture
|
||||
glGenTextures(1, &textureimage);
|
||||
glBindTexture(GL_TEXTURE_2D, textureimage);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, image->width, image->height, 0, GL_RGB, GL_UNSIGNED_BYTE, image->rgb);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
// create a framebuffer object
|
||||
glGenFramebuffers(1, &framebufferimage);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, framebufferimage);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textureimage, 0);
|
||||
|
||||
// blit to the frame buffer object with interpolation
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, framebufferimage);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, framebufferid_);
|
||||
glBlitFramebuffer(0, 0, image->width, image->height,
|
||||
0, 0, attrib_.viewport.x, attrib_.viewport.y, GL_COLOR_BUFFER_BIT, GL_LINEAR);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
|
||||
// cleanup
|
||||
glDeleteFramebuffers(1, &framebufferimage);
|
||||
glDeleteTextures(1, &textureimage);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,103 +0,0 @@
|
||||
/*
|
||||
* This file is part of vimix - Live video mixer
|
||||
*
|
||||
* **Copyright** (C) 2020-2021 Bruno Herbelin <bruno.herbelin@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 3 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 <algorithm>
|
||||
|
||||
#include "Log.h"
|
||||
#include "Scene.h"
|
||||
#include "GarbageVisitor.h"
|
||||
|
||||
|
||||
GarbageVisitor::GarbageVisitor(Node *nodetocollect) : Visitor()
|
||||
{
|
||||
targets_.push_front(nodetocollect);
|
||||
current_ = nullptr;
|
||||
found_ = false;
|
||||
}
|
||||
|
||||
GarbageVisitor::GarbageVisitor(Source *sourcetocollect) : Visitor()
|
||||
{
|
||||
targets_.push_front(sourcetocollect->group(View::MIXING));
|
||||
targets_.push_front(sourcetocollect->group(View::GEOMETRY));
|
||||
targets_.push_front(sourcetocollect->group(View::RENDERING));
|
||||
current_ = nullptr;
|
||||
found_ = false;
|
||||
}
|
||||
|
||||
|
||||
void GarbageVisitor::visit(Node &n)
|
||||
{
|
||||
// found the target
|
||||
// if (n.id() == target_->id())
|
||||
// if ( &n == target_ )
|
||||
if ( std::count(targets_.begin(), targets_.end(), &n) )
|
||||
{
|
||||
// end recursive
|
||||
found_ = true;
|
||||
|
||||
// take the node out of the Tree
|
||||
if (current_)
|
||||
current_->detach(&n);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
GarbageVisitor::~GarbageVisitor()
|
||||
{
|
||||
// actually delete the Node
|
||||
|
||||
}
|
||||
|
||||
|
||||
void GarbageVisitor::visit(Group &n)
|
||||
{
|
||||
// no need to go further if the node was found (or is this group)
|
||||
if (found_)
|
||||
return;
|
||||
|
||||
// current group
|
||||
current_ = &n;
|
||||
|
||||
// loop over members of a group
|
||||
// and stop when found
|
||||
for (NodeSet::iterator node = n.begin(); !found_ && node != n.end(); ++node) {
|
||||
// visit the child node
|
||||
(*node)->accept(*this);
|
||||
// un-stack recursive browsing
|
||||
current_ = &n;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void GarbageVisitor::visit(Scene &n)
|
||||
{
|
||||
n.root()->accept(*this);
|
||||
}
|
||||
|
||||
void GarbageVisitor::visit(Switch &n)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void GarbageVisitor::visit(Primitive &n)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
#ifndef GARBAGEVISITOR_H
|
||||
#define GARBAGEVISITOR_H
|
||||
|
||||
#include <list>
|
||||
|
||||
#include "Source.h"
|
||||
#include "Visitor.h"
|
||||
|
||||
|
||||
class GarbageVisitor : public Visitor
|
||||
{
|
||||
Group *current_;
|
||||
std::list<Node *> targets_;
|
||||
bool found_;
|
||||
|
||||
public:
|
||||
GarbageVisitor(Source *sourcetocollect);
|
||||
GarbageVisitor(Node *nodetocollect);
|
||||
~GarbageVisitor();
|
||||
|
||||
void visit(Scene& n) override;
|
||||
void visit(Node& n) override;
|
||||
void visit(Group& n) override;
|
||||
void visit(Switch& n) override;
|
||||
void visit(Primitive& n) override;
|
||||
|
||||
};
|
||||
|
||||
#endif // GARBAGEVISITOR_H
|
||||
1148
GeometryView.cpp
308
GstToolkit.cpp
@@ -1,308 +0,0 @@
|
||||
/*
|
||||
* This file is part of vimix - video live mixer
|
||||
*
|
||||
* **Copyright** (C) 2019-2022 Bruno Herbelin <bruno.herbelin@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 3 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 <sstream>
|
||||
#include <iomanip>
|
||||
using namespace std;
|
||||
|
||||
#include <gst/gl/gl.h>
|
||||
|
||||
#include "GstToolkit.h"
|
||||
|
||||
string GstToolkit::time_to_string(guint64 t, time_string_mode m)
|
||||
{
|
||||
if (t == GST_CLOCK_TIME_NONE) {
|
||||
switch (m) {
|
||||
case TIME_STRING_FIXED:
|
||||
return "00:00:00.00";
|
||||
case TIME_STRING_MINIMAL:
|
||||
return "0.0";
|
||||
case TIME_STRING_READABLE:
|
||||
return "0 second";
|
||||
default:
|
||||
return "00.00";
|
||||
}
|
||||
}
|
||||
|
||||
guint ms = GST_TIME_AS_MSECONDS(t);
|
||||
guint s = ms / 1000;
|
||||
ostringstream oss;
|
||||
|
||||
// READABLE : long format
|
||||
if (m == TIME_STRING_READABLE) {
|
||||
int count = 0;
|
||||
if (s / 3600) {
|
||||
oss << s / 3600 << " h ";
|
||||
count++;
|
||||
}
|
||||
if ((s % 3600) / 60) {
|
||||
oss << (s % 3600) / 60 << " min ";
|
||||
count++;
|
||||
}
|
||||
if (count < 2) {
|
||||
oss << setw(count > 0 ? 2 : 1) << setfill('0') << (s % 3600) % 60;
|
||||
count++;
|
||||
|
||||
if (count < 2 )
|
||||
oss << '.'<< setw(1) << setfill('0') << (ms % 1000) / 100 << " sec";
|
||||
else
|
||||
oss << " s";
|
||||
}
|
||||
}
|
||||
// MINIMAL: keep only the 2 higher values (most significant)
|
||||
else if (m == TIME_STRING_MINIMAL) {
|
||||
int count = 0;
|
||||
// hours
|
||||
if (s / 3600) {
|
||||
oss << s / 3600 << ':';
|
||||
count++;
|
||||
}
|
||||
// minutes
|
||||
if (count > 0) {
|
||||
oss << setw(2) << setfill('0') << (s % 3600) / 60 << ':';
|
||||
count++;
|
||||
}
|
||||
else if ((s % 3600) / 60)
|
||||
{
|
||||
oss << (s % 3600) / 60 << ':';
|
||||
count++;
|
||||
}
|
||||
// seconds
|
||||
{
|
||||
oss << setw(count > 0 ? 2 : 1) << setfill('0') << (s % 3600) % 60;
|
||||
count++;
|
||||
}
|
||||
if (count < 2)
|
||||
oss << '.'<< setw((ms % 1000) / 100 ? 2 : 1) << setfill('0') << (ms % 1000) / 10;
|
||||
}
|
||||
else {
|
||||
// TIME_STRING_FIXED : fixed length string (11 chars) HH:mm:ss.ii"
|
||||
// TIME_STRING_RIGHT : always show the right part (seconds), not the min or hours if none
|
||||
if (m == TIME_STRING_FIXED || (s / 3600) )
|
||||
oss << setw(2) << setfill('0') << s / 3600 << ':';
|
||||
if (m == TIME_STRING_FIXED || ((s % 3600) / 60) )
|
||||
oss << setw(2) << setfill('0') << (s % 3600) / 60 << ':';
|
||||
oss << setw(2) << setfill('0') << (s % 3600) % 60 << '.';
|
||||
oss << setw(2) << setfill('0') << (ms % 1000) / 10;
|
||||
}
|
||||
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
|
||||
std::string GstToolkit::filename_to_uri(std::string path)
|
||||
{
|
||||
if (path.empty())
|
||||
return path;
|
||||
|
||||
// set uri to open
|
||||
gchar *uritmp = gst_filename_to_uri(path.c_str(), NULL);
|
||||
std::string uri( uritmp );
|
||||
g_free(uritmp);
|
||||
return uri;
|
||||
}
|
||||
|
||||
list<string> GstToolkit::all_plugins()
|
||||
{
|
||||
list<string> pluginlist;
|
||||
GList *l, *g;
|
||||
|
||||
l = gst_registry_get_plugin_list (gst_registry_get ());
|
||||
|
||||
for (g = l; g; g = g->next) {
|
||||
GstPlugin *plugin = GST_PLUGIN (g->data);
|
||||
pluginlist.push_front( string( gst_plugin_get_name (plugin) ) );
|
||||
}
|
||||
|
||||
gst_plugin_list_free (l);
|
||||
|
||||
return pluginlist;
|
||||
}
|
||||
|
||||
|
||||
list<string> GstToolkit::all_plugin_features(string pluginname)
|
||||
{
|
||||
list<string> featurelist;
|
||||
GList *l, *g;
|
||||
|
||||
l = gst_registry_get_feature_list_by_plugin (gst_registry_get (), pluginname.c_str());
|
||||
|
||||
for (g = l; g; g = g->next) {
|
||||
GstPluginFeature *feature = GST_PLUGIN_FEATURE (g->data);
|
||||
featurelist.push_front( string( gst_plugin_feature_get_name (feature) ) );
|
||||
}
|
||||
|
||||
gst_plugin_feature_list_free (l);
|
||||
|
||||
return featurelist;
|
||||
}
|
||||
|
||||
bool GstToolkit::enable_feature (string name, bool enable) {
|
||||
GstRegistry *registry = NULL;
|
||||
GstElementFactory *factory = NULL;
|
||||
|
||||
registry = gst_registry_get();
|
||||
if (!registry) return false;
|
||||
|
||||
factory = gst_element_factory_find (name.c_str());
|
||||
if (!factory) return false;
|
||||
|
||||
if (enable) {
|
||||
gst_plugin_feature_set_rank (GST_PLUGIN_FEATURE (factory), GST_RANK_PRIMARY + 1);
|
||||
}
|
||||
else {
|
||||
gst_plugin_feature_set_rank (GST_PLUGIN_FEATURE (factory), GST_RANK_NONE);
|
||||
}
|
||||
|
||||
gst_registry_add_feature (registry, GST_PLUGIN_FEATURE (factory));
|
||||
gst_object_unref (factory);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GstToolkit::has_feature (string name)
|
||||
{
|
||||
if (name.empty())
|
||||
return false;
|
||||
|
||||
GstRegistry *registry = NULL;
|
||||
GstElementFactory *factory = NULL;
|
||||
|
||||
registry = gst_registry_get();
|
||||
if (!registry) return false;
|
||||
|
||||
factory = gst_element_factory_find (name.c_str());
|
||||
if (!factory) return false;
|
||||
|
||||
GstElement *elem = gst_element_factory_create (factory, NULL);
|
||||
gst_object_unref (factory);
|
||||
|
||||
if (!elem) return false;
|
||||
|
||||
gst_object_unref (elem);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
string GstToolkit::gst_version()
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << GST_VERSION_MAJOR << '.' << GST_VERSION_MINOR << '.';
|
||||
oss << std::setw(2) << setfill('0') << GST_VERSION_MICRO ;
|
||||
if (GST_VERSION_NANO > 0)
|
||||
oss << ( (GST_VERSION_NANO < 2 ) ? " - (CVS)" : " - (Prerelease)");
|
||||
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
#if GST_GL_HAVE_PLATFORM_GLX
|
||||
// https://gstreamer.freedesktop.org/documentation/nvcodec/index.html?gi-language=c#plugin-nvcodec
|
||||
// list ordered with higher priority first (e.g. nvidia proprietary before vaapi)
|
||||
const char *plugins[11] = { "nvh264dec", "nvh265dec", "nvmpeg2videodec", "nvmpeg4videodec", "nvvp8dec", "nvvp9dec",
|
||||
"vaapidecodebin", "omxmpeg4videodec", "omxmpeg2dec", "omxh264dec", "vdpaumpegdec",
|
||||
};
|
||||
const int N = 11;
|
||||
#elif GST_GL_HAVE_PLATFORM_CGL
|
||||
const char *plugins[2] = { "vtdec_hw", "vtdechw" };
|
||||
const int N = 2;
|
||||
#else
|
||||
const char *plugins[0] = { };
|
||||
const int N = 0;
|
||||
#endif
|
||||
|
||||
|
||||
// see https://developer.ridgerun.com/wiki/index.php?title=GStreamer_modify_the_elements_rank
|
||||
std::list<std::string> GstToolkit::enable_gpu_decoding_plugins(bool enable)
|
||||
{
|
||||
list<string> plugins_list_;
|
||||
|
||||
static GstRegistry* plugins_register = nullptr;
|
||||
if ( plugins_register == nullptr )
|
||||
plugins_register = gst_registry_get();
|
||||
|
||||
static bool enabled_ = false;
|
||||
if (enabled_ != enable) {
|
||||
enabled_ = enable;
|
||||
for (int i = 0; i < N; i++) {
|
||||
GstPluginFeature* feature = gst_registry_lookup_feature(plugins_register, plugins[i]);
|
||||
if(feature != NULL) {
|
||||
plugins_list_.push_front( string( plugins[i] ) );
|
||||
gst_plugin_feature_set_rank(feature, enable ? GST_RANK_PRIMARY + (N-i) : GST_RANK_MARGINAL);
|
||||
gst_object_unref(feature);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return plugins_list_;
|
||||
}
|
||||
|
||||
|
||||
std::string GstToolkit::used_gpu_decoding_plugins(GstElement *gstbin)
|
||||
{
|
||||
std::string found = "";
|
||||
|
||||
GstIterator* it = gst_bin_iterate_recurse(GST_BIN(gstbin));
|
||||
GValue value = G_VALUE_INIT;
|
||||
for(GstIteratorResult r = gst_iterator_next(it, &value); r != GST_ITERATOR_DONE; r = gst_iterator_next(it, &value))
|
||||
{
|
||||
if ( r == GST_ITERATOR_OK )
|
||||
{
|
||||
GstElement *e = static_cast<GstElement*>(g_value_peek_pointer(&value));
|
||||
if (e) {
|
||||
const gchar *name = gst_element_get_name(e);
|
||||
for (int i = 0; i < N; i++) {
|
||||
if (std::string(name).find(plugins[i]) != std::string::npos) {
|
||||
found = plugins[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
g_value_unset(&value);
|
||||
}
|
||||
gst_iterator_free(it);
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::string GstToolkit::used_decoding_plugins(GstElement *gstbin)
|
||||
{
|
||||
std::string found = "";
|
||||
|
||||
GstIterator* it = gst_bin_iterate_recurse(GST_BIN(gstbin));
|
||||
GValue value = G_VALUE_INIT;
|
||||
for(GstIteratorResult r = gst_iterator_next(it, &value); r != GST_ITERATOR_DONE; r = gst_iterator_next(it, &value))
|
||||
{
|
||||
if ( r == GST_ITERATOR_OK )
|
||||
{
|
||||
GstElement *e = static_cast<GstElement*>(g_value_peek_pointer(&value));
|
||||
if (e) {
|
||||
const gchar *name = gst_element_get_name(e);
|
||||
found += std::string(name) + ", ";
|
||||
}
|
||||
}
|
||||
g_value_unset(&value);
|
||||
}
|
||||
gst_iterator_free(it);
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
35
GstToolkit.h
@@ -1,35 +0,0 @@
|
||||
#ifndef __GSTGUI_TOOLKIT_H_
|
||||
#define __GSTGUI_TOOLKIT_H_
|
||||
|
||||
#include <gst/gst.h>
|
||||
|
||||
#include <string>
|
||||
#include <list>
|
||||
|
||||
namespace GstToolkit
|
||||
{
|
||||
|
||||
typedef enum {
|
||||
TIME_STRING_FIXED = 0,
|
||||
TIME_STRING_ADJUSTED,
|
||||
TIME_STRING_MINIMAL,
|
||||
TIME_STRING_READABLE
|
||||
} time_string_mode;
|
||||
|
||||
std::string time_to_string(guint64 t, time_string_mode m = TIME_STRING_ADJUSTED);
|
||||
std::string filename_to_uri(std::string filename);
|
||||
|
||||
std::string gst_version();
|
||||
|
||||
std::list<std::string> all_plugins();
|
||||
std::list<std::string> enable_gpu_decoding_plugins(bool enable = true);
|
||||
std::string used_gpu_decoding_plugins(GstElement *gstbin);
|
||||
std::string used_decoding_plugins(GstElement *gstbin);
|
||||
|
||||
std::list<std::string> all_plugin_features(std::string pluginname);
|
||||
bool has_feature (std::string name);
|
||||
bool enable_feature (std::string name, bool enable);
|
||||
|
||||
}
|
||||
|
||||
#endif // __GSTGUI_TOOLKIT_H_
|
||||
913
ImGuiVisitor.cpp
@@ -1,913 +0,0 @@
|
||||
/*
|
||||
* This file is part of vimix - video live mixer
|
||||
*
|
||||
* **Copyright** (C) 2019-2022 Bruno Herbelin <bruno.herbelin@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 3 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 <vector>
|
||||
#include <algorithm>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
#include <glm/gtc/constants.hpp>
|
||||
#include <glm/gtc/matrix_access.hpp>
|
||||
|
||||
#include <tinyxml2.h>
|
||||
#include "tinyxml2Toolkit.h"
|
||||
|
||||
#include "defines.h"
|
||||
#include "Log.h"
|
||||
#include "Scene.h"
|
||||
#include "Primitives.h"
|
||||
#include "ImageShader.h"
|
||||
#include "ImageProcessingShader.h"
|
||||
#include "MediaPlayer.h"
|
||||
#include "MediaSource.h"
|
||||
#include "SessionSource.h"
|
||||
#include "PatternSource.h"
|
||||
#include "DeviceSource.h"
|
||||
#include "NetworkSource.h"
|
||||
#include "MultiFileSource.h"
|
||||
#include "SessionCreator.h"
|
||||
#include "SessionVisitor.h"
|
||||
#include "Settings.h"
|
||||
#include "Mixer.h"
|
||||
#include "ActionManager.h"
|
||||
|
||||
#include "imgui.h"
|
||||
#include "ImGuiToolkit.h"
|
||||
#include "BaseToolkit.h"
|
||||
#include "UserInterfaceManager.h"
|
||||
#include "SystemToolkit.h"
|
||||
|
||||
#include "ImGuiVisitor.h"
|
||||
|
||||
ImGuiVisitor::ImGuiVisitor()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ImGuiVisitor::visit(Node &)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ImGuiVisitor::visit(Group &n)
|
||||
{
|
||||
// MODEL VIEW
|
||||
ImGui::PushID(std::to_string(n.id()).c_str());
|
||||
|
||||
if (ImGuiToolkit::ButtonIcon(1, 16)) {
|
||||
n.translation_.x = 0.f;
|
||||
n.translation_.y = 0.f;
|
||||
n.rotation_.z = 0.f;
|
||||
n.scale_.x = 1.f;
|
||||
n.scale_.y = 1.f;
|
||||
Action::manager().store("Geometry Reset");
|
||||
}
|
||||
ImGui::SameLine(0, IMGUI_SAME_LINE);
|
||||
ImGui::Text("Geometry");
|
||||
|
||||
if (ImGuiToolkit::ButtonIcon(6, 15)) {
|
||||
n.translation_.x = 0.f;
|
||||
n.translation_.y = 0.f;
|
||||
Action::manager().store("Position 0.0, 0.0");
|
||||
}
|
||||
ImGui::SameLine(0, IMGUI_SAME_LINE);
|
||||
float translation[2] = { n.translation_.x, n.translation_.y};
|
||||
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
|
||||
if ( ImGui::SliderFloat2("Position", translation, -5.0, 5.0) )
|
||||
{
|
||||
n.translation_.x = translation[0];
|
||||
n.translation_.y = translation[1];
|
||||
}
|
||||
if (ImGui::IsItemDeactivatedAfterEdit()){
|
||||
std::ostringstream oss;
|
||||
oss << "Position " << std::setprecision(3) << n.translation_.x << ", " << n.translation_.y;
|
||||
Action::manager().store(oss.str());
|
||||
}
|
||||
if (ImGuiToolkit::ButtonIcon(3, 15)) {
|
||||
n.scale_.x = 1.f;
|
||||
n.scale_.y = 1.f;
|
||||
Action::manager().store("Scale 1.0 x 1.0");
|
||||
}
|
||||
ImGui::SameLine(0, IMGUI_SAME_LINE);
|
||||
float scale[2] = { n.scale_.x, n.scale_.y} ;
|
||||
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
|
||||
if ( ImGui::SliderFloat2("Scale", scale, -MAX_SCALE, MAX_SCALE, "%.2f") )
|
||||
{
|
||||
n.scale_.x = CLAMP_SCALE(scale[0]);
|
||||
n.scale_.y = CLAMP_SCALE(scale[1]);
|
||||
}
|
||||
if (ImGui::IsItemDeactivatedAfterEdit()){
|
||||
std::ostringstream oss;
|
||||
oss << "Scale " << std::setprecision(3) << n.scale_.x << " x " << n.scale_.y;
|
||||
Action::manager().store(oss.str());
|
||||
}
|
||||
|
||||
if (ImGuiToolkit::ButtonIcon(18, 9)){
|
||||
n.rotation_.z = 0.f;
|
||||
Action::manager().store("Angle 0.0");
|
||||
}
|
||||
ImGui::SameLine(0, IMGUI_SAME_LINE);
|
||||
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
|
||||
ImGui::SliderAngle("Angle", &(n.rotation_.z), -180.f, 180.f) ;
|
||||
if (ImGui::IsItemDeactivatedAfterEdit()) {
|
||||
std::ostringstream oss;
|
||||
oss << "Angle " << std::setprecision(3) << n.rotation_.z * 180.f / M_PI;
|
||||
Action::manager().store(oss.str());
|
||||
}
|
||||
|
||||
|
||||
ImGui::PopID();
|
||||
|
||||
// spacing
|
||||
ImGui::Spacing();
|
||||
}
|
||||
|
||||
void ImGuiVisitor::visit(Switch &n)
|
||||
{
|
||||
if (n.numChildren()>0)
|
||||
n.activeChild()->accept(*this);
|
||||
}
|
||||
|
||||
void ImGuiVisitor::visit(Scene &n)
|
||||
{
|
||||
ImGui::SetNextItemOpen(true, ImGuiCond_Once);
|
||||
if (ImGui::CollapsingHeader("Scene Property Tree"))
|
||||
{
|
||||
n.root()->accept(*this);
|
||||
}
|
||||
}
|
||||
|
||||
void ImGuiVisitor::visit(Primitive &n)
|
||||
{
|
||||
ImGui::PushID(std::to_string(n.id()).c_str());
|
||||
ImGui::Text("Primitive %d");
|
||||
|
||||
n.shader()->accept(*this);
|
||||
|
||||
ImGui::PopID();
|
||||
}
|
||||
|
||||
void ImGuiVisitor::visit(FrameBufferSurface &)
|
||||
{
|
||||
ImGui::Text("Framebuffer");
|
||||
}
|
||||
|
||||
void ImGuiVisitor::visit(MediaPlayer &)
|
||||
{
|
||||
ImGui::Text("Media Player");
|
||||
}
|
||||
|
||||
void ImGuiVisitor::visit(Shader &n)
|
||||
{
|
||||
ImGui::PushID(std::to_string(n.id()).c_str());
|
||||
|
||||
// Base color
|
||||
// if (ImGuiToolkit::ButtonIcon(10, 2)) {
|
||||
// n.blending = Shader::BLEND_OPACITY;
|
||||
// n.color = glm::vec4(1.f, 1.f, 1.f, 1.f);
|
||||
// }
|
||||
// ImGui::SameLine(0, IMGUI_SAME_LINE);
|
||||
// ImGui::ColorEdit3("Color", glm::value_ptr(n.color), ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel ) ;
|
||||
// ImGui::SameLine(0, 5);
|
||||
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
|
||||
int mode = n.blending;
|
||||
if (ImGui::Combo("Blending", &mode, "Normal\0Screen\0Subtract\0Multiply\0Soft light"
|
||||
"\0Hard light\0Soft subtract\0Lighten only\0") ) {
|
||||
n.blending = Shader::BlendMode(mode);
|
||||
|
||||
std::ostringstream oss;
|
||||
oss << "Blending ";
|
||||
switch(n.blending) {
|
||||
case Shader::BLEND_OPACITY:
|
||||
oss<<"Normal";
|
||||
break;
|
||||
case Shader::BLEND_SCREEN:
|
||||
oss<<"Screen";
|
||||
break;
|
||||
case Shader::BLEND_SUBTRACT:
|
||||
oss<<"Subtract";
|
||||
break;
|
||||
case Shader::BLEND_MULTIPLY:
|
||||
oss<<"Multiply";
|
||||
break;
|
||||
case Shader::BLEND_HARD_LIGHT:
|
||||
oss<<"Hard light";
|
||||
break;
|
||||
case Shader::BLEND_SOFT_LIGHT:
|
||||
oss<<"Soft light";
|
||||
break;
|
||||
case Shader::BLEND_SOFT_SUBTRACT:
|
||||
oss<<"Soft subtract";
|
||||
break;
|
||||
case Shader::BLEND_LIGHTEN_ONLY:
|
||||
oss<<"Lighten only";
|
||||
break;
|
||||
case Shader::BLEND_NONE:
|
||||
oss<<"None";
|
||||
break;
|
||||
}
|
||||
Action::manager().store(oss.str());
|
||||
}
|
||||
|
||||
ImGui::PopID();
|
||||
}
|
||||
|
||||
//void ImGuiVisitor::visit(ImageShader &n)
|
||||
//{
|
||||
// ImGui::PushID(std::to_string(n.id()).c_str());
|
||||
// // get index of the mask used in this ImageShader
|
||||
// int item_current = n.mask;
|
||||
//// if (ImGuiToolkit::ButtonIcon(10, 3)) n.mask = 0;
|
||||
//// ImGui::SameLine(0, IMGUI_SAME_LINE);
|
||||
// ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
|
||||
// // combo list of masks
|
||||
// if ( ImGui::Combo("Mask", &item_current, ImageShader::mask_names, IM_ARRAYSIZE(ImageShader::mask_names) ) )
|
||||
// {
|
||||
// if (item_current < (int) ImageShader::mask_presets.size())
|
||||
// n.mask = item_current;
|
||||
// else {
|
||||
// // TODO ask for custom mask
|
||||
// }
|
||||
// Action::manager().store("Mask "+ std::string(ImageShader::mask_names[n.mask]));
|
||||
// }
|
||||
// ImGui::PopID();
|
||||
//}
|
||||
|
||||
void ImGuiVisitor::visit(ImageProcessingShader &n)
|
||||
{
|
||||
ImGui::PushID(std::to_string(n.id()).c_str());
|
||||
|
||||
ImGuiToolkit::Icon(6, 2);
|
||||
ImGui::SameLine(0, IMGUI_SAME_LINE);
|
||||
ImGui::Text("Filters");
|
||||
|
||||
if (ImGuiToolkit::IconButton(6, 4)) {
|
||||
n.gamma = glm::vec4(1.f, 1.f, 1.f, 1.f);
|
||||
Action::manager().store("Gamma & Color");
|
||||
}
|
||||
ImGui::SameLine(0, IMGUI_SAME_LINE);
|
||||
ImGui::ColorEdit3("Gamma Color", glm::value_ptr(n.gamma), ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel) ;
|
||||
if (ImGui::IsItemDeactivatedAfterEdit())
|
||||
Action::manager().store("Gamma Color changed");
|
||||
|
||||
ImGui::SameLine(0, 5);
|
||||
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
|
||||
ImGui::SliderFloat("Gamma", &n.gamma.w, 0.5f, 10.f, "%.2f", 2.f);
|
||||
if (ImGui::IsItemDeactivatedAfterEdit()){
|
||||
std::ostringstream oss;
|
||||
oss << "Gamma " << std::setprecision(2) << n.gamma.w;
|
||||
Action::manager().store(oss.str());
|
||||
}
|
||||
|
||||
// ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
|
||||
// ImGui::SliderFloat4("Levels", glm::value_ptr(n.levels), 0.0, 1.0);
|
||||
|
||||
if (ImGuiToolkit::IconButton(5, 16)) {
|
||||
n.brightness = 0.f;
|
||||
n.contrast = 0.f;
|
||||
Action::manager().store("B & C 0.0 0.0");
|
||||
}
|
||||
ImGui::SameLine(0, IMGUI_SAME_LINE);
|
||||
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
|
||||
float bc[2] = { n.brightness, n.contrast};
|
||||
if ( ImGui::SliderFloat2("B & C", bc, -1.0, 1.0) )
|
||||
{
|
||||
n.brightness = bc[0];
|
||||
n.contrast = bc[1];
|
||||
}
|
||||
if (ImGui::IsItemDeactivatedAfterEdit()){
|
||||
std::ostringstream oss;
|
||||
oss << "B & C " << std::setprecision(2) << n.brightness << " " << n.contrast;
|
||||
Action::manager().store(oss.str());
|
||||
}
|
||||
|
||||
if (ImGuiToolkit::IconButton(9, 16)) {
|
||||
n.saturation = 0.f;
|
||||
Action::manager().store("Saturation 0.0");
|
||||
}
|
||||
ImGui::SameLine(0, IMGUI_SAME_LINE);
|
||||
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
|
||||
ImGui::SliderFloat("Saturation", &n.saturation, -1.0, 1.0);
|
||||
if (ImGui::IsItemDeactivatedAfterEdit()){
|
||||
std::ostringstream oss;
|
||||
oss << "Saturation " << std::setprecision(2) << n.saturation;
|
||||
Action::manager().store(oss.str());
|
||||
}
|
||||
|
||||
if (ImGuiToolkit::IconButton(12, 4)) {
|
||||
n.hueshift = 0.f;
|
||||
Action::manager().store("Hue shift 0.0");
|
||||
}
|
||||
ImGui::SameLine(0, IMGUI_SAME_LINE);
|
||||
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
|
||||
ImGui::SliderFloat("Hue shift", &n.hueshift, 0.0, 1.0);
|
||||
if (ImGui::IsItemDeactivatedAfterEdit()){
|
||||
std::ostringstream oss;
|
||||
oss << "Hue shift " << std::setprecision(2) << n.hueshift;
|
||||
Action::manager().store(oss.str());
|
||||
}
|
||||
|
||||
if (ImGuiToolkit::IconButton(18, 1)) {
|
||||
n.nbColors = 0;
|
||||
Action::manager().store("Posterize None");
|
||||
}
|
||||
ImGui::SameLine(0, IMGUI_SAME_LINE);
|
||||
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
|
||||
ImGui::SliderInt("Posterize", &n.nbColors, 0, 16, n.nbColors == 0 ? "None" : "%d colors");
|
||||
if (ImGui::IsItemDeactivatedAfterEdit()){
|
||||
std::ostringstream oss;
|
||||
oss << "Posterize ";
|
||||
if (n.nbColors == 0) oss << "None"; else oss << n.nbColors;
|
||||
Action::manager().store(oss.str());
|
||||
}
|
||||
|
||||
if (ImGuiToolkit::IconButton(8, 1)) {
|
||||
n.threshold = 0.f;
|
||||
Action::manager().store("Threshold None");
|
||||
}
|
||||
ImGui::SameLine(0, IMGUI_SAME_LINE);
|
||||
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
|
||||
ImGui::SliderFloat("Threshold", &n.threshold, 0.0, 1.0, n.threshold < 0.001 ? "None" : "%.2f");
|
||||
if (ImGui::IsItemDeactivatedAfterEdit()){
|
||||
std::ostringstream oss;
|
||||
oss << "Threshold ";
|
||||
if (n.threshold < 0.001) oss << "None"; else oss << std::setprecision(2) << n.threshold;
|
||||
Action::manager().store(oss.str());
|
||||
}
|
||||
|
||||
if (ImGuiToolkit::IconButton(3, 1)) {
|
||||
n.lumakey = 0.f;
|
||||
Action::manager().store("Lumakey 0.0");
|
||||
}
|
||||
ImGui::SameLine(0, IMGUI_SAME_LINE);
|
||||
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
|
||||
ImGui::SliderFloat("Lumakey", &n.lumakey, 0.0, 1.0);
|
||||
if (ImGui::IsItemDeactivatedAfterEdit()){
|
||||
std::ostringstream oss;
|
||||
oss << "Lumakey " << std::setprecision(2) << n.lumakey;
|
||||
Action::manager().store(oss.str());
|
||||
}
|
||||
|
||||
if (ImGuiToolkit::IconButton(13, 4)) {
|
||||
n.chromakey = glm::vec4(0.f, 0.8f, 0.f, 1.f);
|
||||
n.chromadelta = 0.f;
|
||||
Action::manager().store("Chromakey & Color Reset");
|
||||
}
|
||||
ImGui::SameLine(0, IMGUI_SAME_LINE);
|
||||
ImGui::ColorEdit3("Chroma color", glm::value_ptr(n.chromakey), ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel ) ;
|
||||
if (ImGui::IsItemDeactivatedAfterEdit())
|
||||
Action::manager().store("Chroma color changed");
|
||||
ImGui::SameLine(0, 5);
|
||||
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
|
||||
ImGui::SliderFloat("Chromakey", &n.chromadelta, 0.0, 1.0, n.chromadelta < 0.001 ? "None" : "Tolerance %.2f");
|
||||
if (ImGui::IsItemDeactivatedAfterEdit()){
|
||||
std::ostringstream oss;
|
||||
oss << "Chromakey ";
|
||||
if (n.chromadelta < 0.001) oss << "None"; else oss << std::setprecision(2) << n.chromadelta;
|
||||
Action::manager().store(oss.str());
|
||||
}
|
||||
|
||||
if (ImGuiToolkit::IconButton(6, 16)) {
|
||||
n.invert = 0;
|
||||
Action::manager().store("Invert None");
|
||||
}
|
||||
ImGui::SameLine(0, IMGUI_SAME_LINE);
|
||||
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
|
||||
if (ImGui::Combo("Invert", &n.invert, "None\0Invert Color\0Invert Luminance\0"))
|
||||
Action::manager().store("Invert " + std::string(n.invert<1 ? "None": (n.invert>1 ? "Luminance" : "Color")));
|
||||
|
||||
if (ImGuiToolkit::IconButton(1, 7)) {
|
||||
n.filterid = 0;
|
||||
Action::manager().store("Filter None");
|
||||
}
|
||||
ImGui::SameLine(0, IMGUI_SAME_LINE);
|
||||
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
|
||||
if (ImGui::Combo("Filter", &n.filterid, ImageProcessingShader::filter_names, IM_ARRAYSIZE(ImageProcessingShader::filter_names) ) )
|
||||
Action::manager().store("Filter " + std::string(ImageProcessingShader::filter_names[n.filterid]));
|
||||
|
||||
ImGui::PopID();
|
||||
|
||||
ImGui::Spacing();
|
||||
}
|
||||
|
||||
void ImGuiVisitor::visit (Source& s)
|
||||
{
|
||||
ImGui::PushID(std::to_string(s.id()).c_str());
|
||||
// blending
|
||||
s.blendingShader()->accept(*this);
|
||||
|
||||
// preview
|
||||
float preview_width = ImGui::GetContentRegionAvail().x IMGUI_RIGHT_ALIGN;
|
||||
float preview_height = 4.5f * ImGui::GetFrameHeightWithSpacing();
|
||||
ImVec2 pos = ImGui::GetCursorPos(); // remember where we were...
|
||||
|
||||
float space = ImGui::GetStyle().ItemSpacing.y;
|
||||
float width = preview_width;
|
||||
float height = s.frame()->projectionArea().y * width / ( s.frame()->projectionArea().x * s.frame()->aspectRatio());
|
||||
if (height > preview_height - space) {
|
||||
height = preview_height - space;
|
||||
width = height * s.frame()->aspectRatio() * ( s.frame()->projectionArea().x / s.frame()->projectionArea().y);
|
||||
}
|
||||
// centered image
|
||||
ImGui::SetCursorPos( ImVec2(pos.x + 0.5f * (preview_width-width), pos.y + 0.5f * (preview_height-height-space)) );
|
||||
ImGui::Image((void*)(uintptr_t) s.frame()->texture(), ImVec2(width, height));
|
||||
|
||||
// inform on visibility status
|
||||
ImGui::SetCursorPos( ImVec2(preview_width + 20, pos.y ) );
|
||||
if (s.active()) {
|
||||
if (s.blendingShader()->color.a > 0.f)
|
||||
ImGuiToolkit::Indication("Visible", ICON_FA_EYE);
|
||||
else
|
||||
ImGuiToolkit::Indication("Not visible", ICON_FA_EYE_SLASH);
|
||||
}
|
||||
else
|
||||
ImGuiToolkit::Indication("Inactive", ICON_FA_SNOWFLAKE);
|
||||
|
||||
// Inform on workspace
|
||||
ImGui::SetCursorPos( ImVec2(preview_width + 20, pos.y + ImGui::GetFrameHeightWithSpacing()) );
|
||||
if (s.workspace() == Source::BACKGROUND)
|
||||
ImGuiToolkit::Indication("in Background",10, 16);
|
||||
else if (s.workspace() == Source::FOREGROUND)
|
||||
ImGuiToolkit::Indication("in Foreground",12, 16);
|
||||
else
|
||||
ImGuiToolkit::Indication("in Workspace",11, 16);
|
||||
|
||||
// locking
|
||||
ImGui::SetCursorPos( ImVec2(preview_width + 20, pos.y + 2.f * ImGui::GetFrameHeightWithSpacing()) );
|
||||
const char *tooltip[2] = {"Unlocked", "Locked"};
|
||||
bool l = s.locked();
|
||||
if (ImGuiToolkit::IconToggle(15,6,17,6, &l, tooltip ) ) {
|
||||
s.setLocked(l);
|
||||
if (l) {
|
||||
Mixer::selection().clear();
|
||||
Action::manager().store(s.name() + std::string(": lock."));
|
||||
}
|
||||
else {
|
||||
Mixer::selection().set(&s);
|
||||
Action::manager().store(s.name() + std::string(": unlock."));
|
||||
}
|
||||
}
|
||||
|
||||
// toggle enable/disable image processing
|
||||
bool on = s.imageProcessingEnabled();
|
||||
ImGui::SetCursorPos( ImVec2(preview_width + 15, pos.y + 3.5f * ImGui::GetFrameHeightWithSpacing()) );
|
||||
if ( ImGuiToolkit::ButtonIconToggle(6, 2, 6, 2, &on, "Filters") ){
|
||||
std::ostringstream oss;
|
||||
oss << s.name() << ": " << ( on ? "Enable Filter" : "Disable Filter");
|
||||
Action::manager().store(oss.str());
|
||||
}
|
||||
s.setImageProcessingEnabled(on);
|
||||
|
||||
// image processing pannel
|
||||
if (s.imageProcessingEnabled()) {
|
||||
|
||||
// menu icon for image processing
|
||||
ImGui::SetCursorPos( ImVec2( preview_width - ImGui::GetTextLineHeight(), pos.y + 4.5f * ImGui::GetFrameHeightWithSpacing())); // ...come back
|
||||
if (ImGuiToolkit::IconButton(5, 8))
|
||||
ImGui::OpenPopup( "MenuImageProcessing" );
|
||||
if (ImGui::BeginPopup( "MenuImageProcessing" ))
|
||||
{
|
||||
if (s.processingshader_link_.connected()) {
|
||||
if (ImGui::MenuItem( "Unfollow" )){
|
||||
s.processingshader_link_.disconnect();
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (ImGui::MenuItem("Reset" )){
|
||||
ImageProcessingShader defaultvalues;
|
||||
s.processingShader()->copy(defaultvalues);
|
||||
s.processingshader_link_.disconnect();
|
||||
std::ostringstream oss;
|
||||
oss << s.name() << ": " << "Reset Filter";
|
||||
Action::manager().store(oss.str());
|
||||
}
|
||||
if (ImGui::MenuItem("Copy" )){
|
||||
std::string clipboard = SessionVisitor::getClipboard(s.processingShader());
|
||||
if (!clipboard.empty())
|
||||
ImGui::SetClipboardText(clipboard.c_str());
|
||||
}
|
||||
const char *clipboard = ImGui::GetClipboardText();
|
||||
const bool can_paste = (clipboard != nullptr && SessionLoader::isClipboard(clipboard));
|
||||
if (ImGui::MenuItem("Paste", NULL, false, can_paste)) {
|
||||
SessionLoader::applyImageProcessing(s, clipboard);
|
||||
std::ostringstream oss;
|
||||
oss << s.name() << ": " << "Change Filter";
|
||||
Action::manager().store(oss.str());
|
||||
}
|
||||
// ImGui::Separator();
|
||||
// if (ImGui::BeginMenu("Follow"))
|
||||
// {
|
||||
// for (auto mpit = Mixer::manager().session()->begin();
|
||||
// mpit != Mixer::manager().session()->end(); mpit++ )
|
||||
// {
|
||||
// std::string label = (*mpit)->name();
|
||||
// if ( (*mpit)->id() != s.id() &&
|
||||
// (*mpit)->imageProcessingEnabled() &&
|
||||
// !(*mpit)->processingshader_link_.connected()) {
|
||||
// if (ImGui::MenuItem( label.c_str() )){
|
||||
// s.processingshader_link_.connect(*mpit);
|
||||
// s.touch();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// ImGui::EndMenu();
|
||||
// }
|
||||
}
|
||||
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
// full panel for image processing
|
||||
ImGui::SetCursorPos( ImVec2( pos.x, pos.y + preview_height)); // ...come back
|
||||
|
||||
if (s.processingshader_link_.connected()) {
|
||||
ImGuiToolkit::Icon(6, 2);
|
||||
ImGui::SameLine(0, IMGUI_SAME_LINE);
|
||||
ImGui::Text("Filters");
|
||||
Source *target = s.processingshader_link_.source();
|
||||
ImGui::Text("Following");
|
||||
if ( target != nullptr && ImGui::Button(target->name().c_str(), ImVec2(IMGUI_RIGHT_ALIGN, 0)) )
|
||||
Mixer::manager().setCurrentSource(target);
|
||||
}
|
||||
else
|
||||
s.processingShader()->accept(*this);
|
||||
}
|
||||
|
||||
ImGui::PopID();
|
||||
}
|
||||
|
||||
void ImGuiVisitor::visit (MediaSource& s)
|
||||
{
|
||||
ImGuiToolkit::Icon(s.icon().x, s.icon().y);
|
||||
ImGui::SameLine(0, IMGUI_SAME_LINE);
|
||||
if ( s.mediaplayer()->isImage() )
|
||||
ImGui::Text("Image File");
|
||||
else
|
||||
ImGui::Text("Video File");
|
||||
|
||||
// Media info
|
||||
ImGui::PushTextWrapPos(ImGui::GetCursorPos().x + ImGui::GetContentRegionAvail().x IMGUI_RIGHT_ALIGN);
|
||||
s.accept(info);
|
||||
ImGui::Text("%s", info.str().c_str());
|
||||
ImGui::PopTextWrapPos();
|
||||
|
||||
// icon (>) to open player
|
||||
if ( s.playable() ) {
|
||||
ImVec2 pos = ImGui::GetCursorPos();
|
||||
ImGui::SameLine(0, 0);
|
||||
ImGui::SameLine(0, 10.f + ImGui::GetContentRegionAvail().x IMGUI_RIGHT_ALIGN);
|
||||
if (ImGuiToolkit::IconButton(ICON_FA_PLAY_CIRCLE, "Open in Player"))
|
||||
UserInterface::manager().showSourceEditor(&s);
|
||||
ImGui::SetCursorPos(pos);
|
||||
}
|
||||
|
||||
// folder
|
||||
std::string path = SystemToolkit::path_filename(s.path());
|
||||
std::string label = BaseToolkit::truncated(path, 25);
|
||||
label = BaseToolkit::transliterate(label);
|
||||
ImGuiToolkit::ButtonOpenUrl( label.c_str(), path.c_str(), ImVec2(IMGUI_RIGHT_ALIGN, 0) );
|
||||
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("Folder");
|
||||
}
|
||||
|
||||
void ImGuiVisitor::visit (SessionFileSource& s)
|
||||
{
|
||||
if (s.session() == nullptr)
|
||||
return;
|
||||
|
||||
ImGuiToolkit::Icon(s.icon().x, s.icon().y);
|
||||
ImGui::SameLine(0, IMGUI_SAME_LINE);
|
||||
ImGui::Text("Session File");
|
||||
|
||||
// info
|
||||
ImGui::PushTextWrapPos(ImGui::GetCursorPos().x + ImGui::GetContentRegionAvail().x IMGUI_RIGHT_ALIGN);
|
||||
s.accept(info);
|
||||
ImGui::Text("%s", info.str().c_str());
|
||||
ImGui::PopTextWrapPos();
|
||||
|
||||
// icon (>) to open player
|
||||
if ( s.playable() ) {
|
||||
ImVec2 pos = ImGui::GetCursorPos();
|
||||
ImGui::SameLine(0, 0);
|
||||
ImGui::SameLine(0, 10.f + ImGui::GetContentRegionAvail().x IMGUI_RIGHT_ALIGN);
|
||||
if (ImGuiToolkit::IconButton(ICON_FA_PLAY_CIRCLE, "Open in Player"))
|
||||
UserInterface::manager().showSourceEditor(&s);
|
||||
ImGui::SetCursorPos(pos);
|
||||
}
|
||||
|
||||
if ( ImGui::Button( ICON_FA_FILE_EXPORT " Import", ImVec2(IMGUI_RIGHT_ALIGN, 0)) )
|
||||
Mixer::manager().import( &s );
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("Sources");
|
||||
|
||||
if (ImGuiToolkit::ButtonIcon(3, 2)) s.session()->setFadingTarget(0.f);
|
||||
float f = s.session()->fading();
|
||||
ImGui::SameLine(0, IMGUI_SAME_LINE);
|
||||
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
|
||||
if (ImGui::SliderFloat("Fading", &f, 0.0, 1.0, f < 0.001 ? "None" : "%.2f") )
|
||||
s.session()->setFadingTarget(f);
|
||||
if (ImGui::IsItemDeactivatedAfterEdit()){
|
||||
std::ostringstream oss;
|
||||
oss << s.name() << ": Fading " << std::setprecision(2) << f;
|
||||
Action::manager().store(oss.str());
|
||||
}
|
||||
if ( ImGui::Button( ICON_FA_FILE_UPLOAD " Open", ImVec2(IMGUI_RIGHT_ALIGN, 0)) )
|
||||
Mixer::manager().set( s.detach() );
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("File");
|
||||
|
||||
std::string path = SystemToolkit::path_filename(s.path());
|
||||
std::string label = BaseToolkit::truncated(path, 25);
|
||||
label = BaseToolkit::transliterate(label);
|
||||
ImGuiToolkit::ButtonOpenUrl( label.c_str(), path.c_str(), ImVec2(IMGUI_RIGHT_ALIGN, 0) );
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("Folder");
|
||||
|
||||
}
|
||||
|
||||
void ImGuiVisitor::visit (SessionGroupSource& s)
|
||||
{
|
||||
if (s.session() == nullptr)
|
||||
return;
|
||||
|
||||
ImGuiToolkit::Icon(s.icon().x, s.icon().y);
|
||||
ImGui::SameLine(0, IMGUI_SAME_LINE);
|
||||
ImGui::Text("Flat Sesion group");
|
||||
|
||||
// info
|
||||
ImGui::PushTextWrapPos(ImGui::GetCursorPos().x + ImGui::GetContentRegionAvail().x IMGUI_RIGHT_ALIGN);
|
||||
s.accept(info);
|
||||
ImGui::Text("%s", info.str().c_str());
|
||||
ImGui::PopTextWrapPos();
|
||||
|
||||
// icon (>) to open player
|
||||
if ( s.playable() ) {
|
||||
ImVec2 pos = ImGui::GetCursorPos();
|
||||
ImGui::SameLine(0, 0);
|
||||
ImGui::SameLine(0, 10.f + ImGui::GetContentRegionAvail().x IMGUI_RIGHT_ALIGN);
|
||||
if (ImGuiToolkit::IconButton(ICON_FA_PLAY_CIRCLE, "Open in Player"))
|
||||
UserInterface::manager().showSourceEditor(&s);
|
||||
ImGui::SetCursorPos(pos);
|
||||
}
|
||||
|
||||
if ( ImGui::Button( ICON_FA_UPLOAD " Expand", ImVec2(IMGUI_RIGHT_ALIGN, 0)) ){
|
||||
Mixer::manager().import( &s );
|
||||
}
|
||||
}
|
||||
|
||||
void ImGuiVisitor::visit (RenderSource& s)
|
||||
{
|
||||
ImGuiToolkit::Icon(s.icon().x, s.icon().y);
|
||||
ImGui::SameLine(0, IMGUI_SAME_LINE);
|
||||
ImGui::Text("Rendering Output");
|
||||
if ( ImGui::Button(IMGUI_TITLE_PREVIEW, ImVec2(IMGUI_RIGHT_ALIGN, 0)) )
|
||||
Settings::application.widget.preview = true;
|
||||
}
|
||||
|
||||
void ImGuiVisitor::visit (CloneSource& s)
|
||||
{
|
||||
ImGuiToolkit::Icon(s.icon().x, s.icon().y);
|
||||
ImGui::SameLine(0, IMGUI_SAME_LINE);
|
||||
ImGui::Text("Clone");
|
||||
if ( ImGui::Button(s.origin()->name().c_str(), ImVec2(IMGUI_RIGHT_ALIGN, 0)) )
|
||||
Mixer::manager().setCurrentSource(s.origin());
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("Source");
|
||||
}
|
||||
|
||||
void ImGuiVisitor::visit (PatternSource& s)
|
||||
{
|
||||
ImGuiToolkit::Icon(s.icon().x, s.icon().y);
|
||||
ImGui::SameLine(0, IMGUI_SAME_LINE);
|
||||
ImGui::Text("Pattern");
|
||||
|
||||
// stream info
|
||||
ImGui::PushTextWrapPos(ImGui::GetCursorPos().x + ImGui::GetContentRegionAvail().x IMGUI_RIGHT_ALIGN);
|
||||
s.accept(info);
|
||||
ImGui::Text("%s", info.str().c_str());
|
||||
ImGui::PopTextWrapPos();
|
||||
|
||||
// icon (>) to open player
|
||||
if ( s.playable() ) {
|
||||
ImVec2 pos = ImGui::GetCursorPos();
|
||||
ImGui::SameLine(0, 0);
|
||||
ImGui::SameLine(0, IMGUI_SAME_LINE + ImGui::GetContentRegionAvail().x IMGUI_RIGHT_ALIGN);
|
||||
if (ImGuiToolkit::IconButton(ICON_FA_PLAY_CIRCLE, "Open in Player"))
|
||||
UserInterface::manager().showSourceEditor(&s);
|
||||
ImGui::SetCursorPos(pos);
|
||||
}
|
||||
|
||||
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
|
||||
if (ImGui::BeginCombo("##Patterns", Pattern::get(s.pattern()->type()).label.c_str()) )
|
||||
{
|
||||
for (uint p = 0; p < Pattern::count(); ++p){
|
||||
if (ImGui::Selectable( Pattern::get(p).label.c_str() )) {
|
||||
s.setPattern(p, s.pattern()->resolution());
|
||||
info.reset();
|
||||
std::ostringstream oss;
|
||||
oss << s.name() << ": Pattern " << Pattern::get(p).label;
|
||||
Action::manager().store(oss.str());
|
||||
}
|
||||
}
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("Generator");
|
||||
}
|
||||
|
||||
void ImGuiVisitor::visit (DeviceSource& s)
|
||||
{
|
||||
ImGuiToolkit::Icon(s.icon().x, s.icon().y);
|
||||
ImGui::SameLine(0, IMGUI_SAME_LINE);
|
||||
ImGui::Text("Device");
|
||||
|
||||
ImGui::PushTextWrapPos(ImGui::GetCursorPos().x + ImGui::GetContentRegionAvail().x IMGUI_RIGHT_ALIGN);
|
||||
s.accept(info);
|
||||
ImGui::Text("%s", info.str().c_str());
|
||||
ImGui::PopTextWrapPos();
|
||||
|
||||
// icon (>) to open player
|
||||
if ( s.playable() ) {
|
||||
ImVec2 pos = ImGui::GetCursorPos();
|
||||
ImGui::SameLine(0, 0);
|
||||
ImGui::SameLine(0, IMGUI_SAME_LINE + ImGui::GetContentRegionAvail().x IMGUI_RIGHT_ALIGN);
|
||||
if (ImGuiToolkit::IconButton(ICON_FA_PLAY_CIRCLE, "Open in Player"))
|
||||
UserInterface::manager().showSourceEditor(&s);
|
||||
ImGui::SetCursorPos(pos);
|
||||
}
|
||||
|
||||
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
|
||||
if (ImGui::BeginCombo("##Hardware", s.device().c_str()))
|
||||
{
|
||||
for (int d = 0; d < Device::manager().numDevices(); ++d){
|
||||
std::string namedev = Device::manager().name(d);
|
||||
if (ImGui::Selectable( namedev.c_str() )) {
|
||||
s.setDevice(namedev);
|
||||
info.reset();
|
||||
std::ostringstream oss;
|
||||
oss << s.name() << " Device " << namedev;
|
||||
Action::manager().store(oss.str());
|
||||
}
|
||||
}
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ImGuiVisitor::visit (NetworkSource& s)
|
||||
{
|
||||
ImGuiToolkit::Icon(s.icon().x, s.icon().y);
|
||||
ImGui::SameLine(0, IMGUI_SAME_LINE);
|
||||
ImGui::Text("Network stream");
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(IMGUI_COLOR_STREAM, 0.9f));
|
||||
ImGui::Text("%s", s.connection().c_str());
|
||||
ImGui::PopStyleColor(1);
|
||||
|
||||
// network info
|
||||
ImGui::PushTextWrapPos(ImGui::GetCursorPos().x + ImGui::GetContentRegionAvail().x IMGUI_RIGHT_ALIGN);
|
||||
s.accept(info);
|
||||
ImGui::Text("%s", info.str().c_str());
|
||||
ImGui::PopTextWrapPos();
|
||||
|
||||
// icon (>) to open player
|
||||
if ( s.playable() ) {
|
||||
ImVec2 pos = ImGui::GetCursorPos();
|
||||
ImGui::SameLine(0, 0);
|
||||
ImGui::SameLine(0, IMGUI_SAME_LINE + ImGui::GetContentRegionAvail().x IMGUI_RIGHT_ALIGN);
|
||||
if (ImGuiToolkit::IconButton(ICON_FA_PLAY_CIRCLE, "Open in Player"))
|
||||
UserInterface::manager().showSourceEditor(&s);
|
||||
ImGui::SetCursorPos(pos);
|
||||
}
|
||||
|
||||
if ( ImGui::Button( ICON_FA_REPLY " Reconnect", ImVec2(IMGUI_RIGHT_ALIGN, 0)) )
|
||||
{
|
||||
s.setConnection(s.connection());
|
||||
info.reset();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ImGuiVisitor::visit (MultiFileSource& s)
|
||||
{
|
||||
ImGuiToolkit::Icon(s.icon().x, s.icon().y);
|
||||
ImGui::SameLine(0, IMGUI_SAME_LINE);
|
||||
ImGui::Text("Images sequence");
|
||||
static uint64_t id = 0;
|
||||
|
||||
// information text
|
||||
ImGui::PushTextWrapPos(ImGui::GetCursorPos().x + ImGui::GetContentRegionAvail().x IMGUI_RIGHT_ALIGN);
|
||||
s.accept(info);
|
||||
ImGui::Text("%s", info.str().c_str());
|
||||
ImGui::PopTextWrapPos();
|
||||
|
||||
// icon (>) to open player
|
||||
if ( s.playable() ) {
|
||||
ImVec2 pos = ImGui::GetCursorPos();
|
||||
ImGui::SameLine(0, 0);
|
||||
ImGui::SameLine(0, IMGUI_SAME_LINE + ImGui::GetContentRegionAvail().x IMGUI_RIGHT_ALIGN);
|
||||
if (ImGuiToolkit::IconButton(ICON_FA_PLAY_CIRCLE, "Open in Player"))
|
||||
UserInterface::manager().showSourceEditor(&s);
|
||||
ImGui::SetCursorPos(pos);
|
||||
}
|
||||
|
||||
// change range
|
||||
static int _begin = -1;
|
||||
if (_begin < 0 || id != s.id())
|
||||
_begin = s.begin();
|
||||
static int _end = -1;
|
||||
if (_end < 0 || id != s.id())
|
||||
_end = s.end();
|
||||
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
|
||||
ImGui::DragIntRange2("Range", &_begin, &_end, 1, s.sequence().min, s.sequence().max);
|
||||
if (ImGui::IsItemDeactivatedAfterEdit()){
|
||||
s.setRange( _begin, _end );
|
||||
std::ostringstream oss;
|
||||
oss << s.name() << ": Range " << _begin << "-" << _end;
|
||||
Action::manager().store(oss.str());
|
||||
_begin = _end = -1;
|
||||
}
|
||||
|
||||
// change framerate
|
||||
static int _fps = -1;
|
||||
if (_fps < 0 || id != s.id())
|
||||
_fps = s.framerate();
|
||||
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
|
||||
ImGui::SliderInt("Framerate", &_fps, 1, 30, "%d fps");
|
||||
if (ImGui::IsItemDeactivatedAfterEdit()){
|
||||
s.setFramerate(_fps);
|
||||
std::ostringstream oss;
|
||||
oss << s.name() << ": Framerate " << _fps << " fps";
|
||||
Action::manager().store(oss.str());
|
||||
_fps = -1;
|
||||
}
|
||||
|
||||
// offer to open file browser at location
|
||||
std::string path = SystemToolkit::path_filename(s.sequence().location);
|
||||
std::string label = BaseToolkit::truncated(path, 25);
|
||||
label = BaseToolkit::transliterate(label);
|
||||
ImGuiToolkit::ButtonOpenUrl( label.c_str(), path.c_str(), ImVec2(IMGUI_RIGHT_ALIGN, 0) );
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("Folder");
|
||||
|
||||
if (id != s.id())
|
||||
id = s.id();
|
||||
}
|
||||
|
||||
void ImGuiVisitor::visit (GenericStreamSource& s)
|
||||
{
|
||||
float w = ImGui::GetContentRegionAvail().x IMGUI_RIGHT_ALIGN;
|
||||
|
||||
ImGuiToolkit::Icon(s.icon().x, s.icon().y);
|
||||
ImGui::SameLine(0, IMGUI_SAME_LINE);
|
||||
ImGui::Text("Custom");
|
||||
|
||||
// stream info
|
||||
ImGui::PushTextWrapPos(ImGui::GetCursorPos().x + w);
|
||||
s.accept(info);
|
||||
ImGui::Text("%s", info.str().c_str());
|
||||
ImGui::PopTextWrapPos();
|
||||
|
||||
// icon (>) to open player
|
||||
if ( s.playable() ) {
|
||||
ImVec2 pos = ImGui::GetCursorPos();
|
||||
ImGui::SameLine(0, 0);
|
||||
ImGui::SameLine(0, IMGUI_SAME_LINE + ImGui::GetContentRegionAvail().x IMGUI_RIGHT_ALIGN);
|
||||
if (ImGuiToolkit::IconButton(ICON_FA_PLAY_CIRCLE, "Open in Player"))
|
||||
UserInterface::manager().showSourceEditor(&s);
|
||||
ImGui::SetCursorPos(pos);
|
||||
}
|
||||
|
||||
// Prepare display pipeline text
|
||||
static int numlines = 0;
|
||||
const ImGuiContext& g = *GImGui;
|
||||
ImVec2 fieldsize(w, MAX(3, numlines) * g.FontSize + g.Style.ItemSpacing.y + g.Style.FramePadding.y);
|
||||
|
||||
// Editor
|
||||
std::string _description = s.description();
|
||||
if ( ImGuiToolkit::InputCodeMultiline("Pipeline", &_description, fieldsize, &numlines) ) {
|
||||
s.setDescription(_description);
|
||||
Action::manager().store( s.name() + ": Change pipeline");
|
||||
}
|
||||
|
||||
}
|
||||
298
InfoVisitor.cpp
@@ -1,298 +0,0 @@
|
||||
/*
|
||||
* This file is part of vimix - video live mixer
|
||||
*
|
||||
* **Copyright** (C) 2019-2022 Bruno Herbelin <bruno.herbelin@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 3 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 <vector>
|
||||
#include <algorithm>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
#include <glm/gtc/constants.hpp>
|
||||
#include <glm/gtc/matrix_access.hpp>
|
||||
|
||||
#include <tinyxml2.h>
|
||||
#include "tinyxml2Toolkit.h"
|
||||
|
||||
#include "defines.h"
|
||||
#include "Log.h"
|
||||
#include "Scene.h"
|
||||
#include "Primitives.h"
|
||||
#include "ImageShader.h"
|
||||
#include "ImageProcessingShader.h"
|
||||
#include "MediaPlayer.h"
|
||||
#include "MediaSource.h"
|
||||
#include "SessionSource.h"
|
||||
#include "PatternSource.h"
|
||||
#include "DeviceSource.h"
|
||||
#include "NetworkSource.h"
|
||||
#include "MultiFileSource.h"
|
||||
#include "SessionCreator.h"
|
||||
#include "SessionVisitor.h"
|
||||
#include "Settings.h"
|
||||
#include "Mixer.h"
|
||||
#include "ActionManager.h"
|
||||
#include "BaseToolkit.h"
|
||||
#include "UserInterfaceManager.h"
|
||||
#include "SystemToolkit.h"
|
||||
|
||||
#include "InfoVisitor.h"
|
||||
|
||||
|
||||
|
||||
InfoVisitor::InfoVisitor() : brief_(true), current_id_(0)
|
||||
{
|
||||
}
|
||||
|
||||
void InfoVisitor::visit(Node &)
|
||||
{
|
||||
}
|
||||
|
||||
void InfoVisitor::visit(Group &)
|
||||
{
|
||||
}
|
||||
|
||||
void InfoVisitor::visit(Switch &)
|
||||
{
|
||||
}
|
||||
|
||||
void InfoVisitor::visit(Scene &)
|
||||
{
|
||||
}
|
||||
|
||||
void InfoVisitor::visit(Primitive &)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void InfoVisitor::visit(MediaPlayer &mp)
|
||||
{
|
||||
// do not ask twice
|
||||
if (current_id_ == mp.id())
|
||||
return;
|
||||
|
||||
std::ostringstream oss;
|
||||
if (brief_) {
|
||||
oss << SystemToolkit::filename(mp.filename()) << std::endl;
|
||||
oss << mp.width() << " x " << mp.height() << ", ";
|
||||
oss << mp.media().codec_name.substr(0, mp.media().codec_name.find_first_of(" (,"));
|
||||
if (!mp.isImage())
|
||||
oss << ", " << std::fixed << std::setprecision(1) << mp.frameRate() << " fps";
|
||||
}
|
||||
else {
|
||||
oss << mp.filename() << std::endl;
|
||||
oss << mp.media().codec_name << std::endl;
|
||||
oss << mp.width() << " x " << mp.height() ;
|
||||
if (!mp.isImage())
|
||||
oss << ", " << std::fixed << std::setprecision(1) << mp.frameRate() << " fps";
|
||||
}
|
||||
|
||||
information_ = oss.str();
|
||||
|
||||
// remember (except if codec was not identified yet)
|
||||
if ( !mp.media().codec_name.empty() )
|
||||
current_id_ = mp.id();
|
||||
}
|
||||
|
||||
void InfoVisitor::visit(Stream &n)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
if (brief_) {
|
||||
oss << BaseToolkit::splitted(n.description(), '!').front();
|
||||
}
|
||||
else {
|
||||
oss << n.description();
|
||||
}
|
||||
information_ = oss.str();
|
||||
}
|
||||
|
||||
|
||||
void InfoVisitor::visit (MediaSource& s)
|
||||
{
|
||||
s.mediaplayer()->accept(*this);
|
||||
}
|
||||
|
||||
void InfoVisitor::visit (SessionFileSource& s)
|
||||
{
|
||||
if (current_id_ == s.id() || s.session() == nullptr)
|
||||
return;
|
||||
|
||||
std::ostringstream oss;
|
||||
if (brief_) {
|
||||
oss << SystemToolkit::filename(s.path()) << " (";
|
||||
oss << s.session()->numSource() << " sources)" << std::endl;
|
||||
}
|
||||
else
|
||||
oss << s.path() << std::endl;
|
||||
|
||||
if (s.session()->frame()){
|
||||
oss << s.session()->frame()->width() << " x " << s.session()->frame()->height() << ", ";
|
||||
oss << "RGB";
|
||||
}
|
||||
|
||||
information_ = oss.str();
|
||||
current_id_ = s.id();
|
||||
}
|
||||
|
||||
void InfoVisitor::visit (SessionGroupSource& s)
|
||||
{
|
||||
if (current_id_ == s.id() || s.session() == nullptr)
|
||||
return;
|
||||
|
||||
std::ostringstream oss;
|
||||
oss << s.session()->numSource() << " sources in group" << std::endl;
|
||||
if (s.session()->frame()){
|
||||
oss << s.session()->frame()->width() << " x " << s.session()->frame()->height() << ", ";
|
||||
oss << "RGB";
|
||||
}
|
||||
|
||||
information_ = oss.str();
|
||||
current_id_ = s.id();
|
||||
}
|
||||
|
||||
void InfoVisitor::visit (RenderSource& s)
|
||||
{
|
||||
if (current_id_ == s.id())
|
||||
return;
|
||||
|
||||
information_ = "Rendering Output";
|
||||
current_id_ = s.id();
|
||||
}
|
||||
|
||||
void InfoVisitor::visit (CloneSource& s)
|
||||
{
|
||||
if (current_id_ == s.id())
|
||||
return;
|
||||
|
||||
information_ = "Clone of " + s.origin()->name();
|
||||
current_id_ = s.id();
|
||||
}
|
||||
|
||||
void InfoVisitor::visit (PatternSource& s)
|
||||
{
|
||||
if (current_id_ == s.id())
|
||||
return;
|
||||
|
||||
std::ostringstream oss;
|
||||
oss << Pattern::get(s.pattern()->type()).label << std::endl;
|
||||
if (s.pattern()) {
|
||||
oss << s.pattern()->width() << " x " << s.pattern()->height();
|
||||
oss << ", RGB";
|
||||
}
|
||||
|
||||
information_ = oss.str();
|
||||
current_id_ = s.id();
|
||||
}
|
||||
|
||||
void InfoVisitor::visit (DeviceSource& s)
|
||||
{
|
||||
if (current_id_ == s.id())
|
||||
return;
|
||||
|
||||
std::ostringstream oss;
|
||||
|
||||
DeviceConfigSet confs = Device::manager().config( Device::manager().index(s.device().c_str()));
|
||||
if ( !confs.empty()) {
|
||||
DeviceConfig best = *confs.rbegin();
|
||||
float fps = static_cast<float>(best.fps_numerator) / static_cast<float>(best.fps_denominator);
|
||||
|
||||
if (brief_) {
|
||||
oss << best.width << " x " << best.height << ", ";
|
||||
oss << best.stream << " " << best.format << ", ";
|
||||
oss << std::fixed << std::setprecision(1) << fps << " fps";
|
||||
}
|
||||
else {
|
||||
oss << s.device() << std::endl;
|
||||
oss << best.width << " x " << best.height << ", ";
|
||||
oss << best.stream << " " << best.format << ", ";
|
||||
oss << std::fixed << std::setprecision(1) << fps << " fps";
|
||||
}
|
||||
}
|
||||
|
||||
information_ = oss.str();
|
||||
current_id_ = s.id();
|
||||
}
|
||||
|
||||
void InfoVisitor::visit (NetworkSource& s)
|
||||
{
|
||||
if (current_id_ == s.id())
|
||||
return;
|
||||
|
||||
NetworkStream *ns = s.networkStream();
|
||||
|
||||
std::ostringstream oss;
|
||||
if (brief_) {
|
||||
oss << ns->resolution().x << " x " << ns->resolution().y << ", ";
|
||||
oss << NetworkToolkit::protocol_name[ns->protocol()] << std::endl;
|
||||
oss << "IP " << ns->serverAddress();
|
||||
}
|
||||
else {
|
||||
oss << s.connection() << " (IP " << ns->serverAddress() << ")" << std::endl;
|
||||
oss << ns->resolution().x << " x " << ns->resolution().y << ", ";
|
||||
oss << NetworkToolkit::protocol_name[ns->protocol()];
|
||||
}
|
||||
|
||||
information_ = oss.str();
|
||||
current_id_ = s.id();
|
||||
}
|
||||
|
||||
|
||||
void InfoVisitor::visit (MultiFileSource& s)
|
||||
{
|
||||
if (current_id_ == s.id())
|
||||
return;
|
||||
|
||||
std::ostringstream oss;
|
||||
if (brief_) {
|
||||
oss << s.sequence().width << " x " << s.sequence().height << ", ";
|
||||
oss << s.sequence().codec << std::endl;
|
||||
oss << s.sequence().max - s.sequence().min + 1 << " images [";
|
||||
oss << s.sequence().min << " - " << s.sequence().max << "]";
|
||||
}
|
||||
else {
|
||||
oss << s.sequence().location << " [";
|
||||
oss << s.sequence().min << " - " << s.sequence().max << "]" << std::endl;
|
||||
oss << s.sequence().width << " x " << s.sequence().height << ", ";
|
||||
oss << s.sequence().codec << " (";
|
||||
oss << s.sequence().max - s.sequence().min + 1 << " images)";
|
||||
}
|
||||
|
||||
information_ = oss.str();
|
||||
current_id_ = s.id();
|
||||
}
|
||||
|
||||
void InfoVisitor::visit (GenericStreamSource& s)
|
||||
{
|
||||
if (current_id_ == s.id())
|
||||
return;
|
||||
|
||||
std::ostringstream oss;
|
||||
if (s.stream()) {
|
||||
std::string src_element = s.gstElements().front();
|
||||
src_element = src_element.substr(0, src_element.find(" "));
|
||||
oss << "gstreamer '" << src_element << "'" << std::endl;
|
||||
oss << s.stream()->width() << " x " << s.stream()->height();
|
||||
oss << ", RGB";
|
||||
}
|
||||
else
|
||||
oss << "Undefined";
|
||||
|
||||
information_ = oss.str();
|
||||
current_id_ = s.id();
|
||||
}
|
||||
31
Loopback.h
@@ -1,31 +0,0 @@
|
||||
#ifndef LOOPBACK_H
|
||||
#define LOOPBACK_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <gst/pbutils/pbutils.h>
|
||||
#include <gst/app/gstappsrc.h>
|
||||
|
||||
#include "FrameGrabber.h"
|
||||
|
||||
|
||||
class Loopback : public FrameGrabber
|
||||
{
|
||||
static std::string system_loopback_pipeline;
|
||||
static std::string system_loopback_name;
|
||||
static bool system_loopback_initialized;
|
||||
|
||||
std::string init(GstCaps *caps) override;
|
||||
void terminate() override;
|
||||
|
||||
public:
|
||||
|
||||
Loopback();
|
||||
|
||||
static bool systemLoopbackInitialized();
|
||||
static bool initializeSystemLoopback();
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // LOOPBACK_H
|
||||
119
README.md
@@ -1,5 +1,8 @@
|
||||
# vimix
|
||||
Live Video Mixing
|
||||
__Live Video Mixing__
|
||||
|
||||
<img src=docs/vimix_screenshot.png width="800">
|
||||
|
||||
|
||||
vimix performs graphical mixing and blending of several movie clips and
|
||||
computer generated graphics, with image processing effects in real-time.
|
||||
@@ -7,8 +10,8 @@ computer generated graphics, with image processing effects in real-time.
|
||||
Its intuitive and hands-on user interface gives direct control on image opacity and
|
||||
shape for producing live graphics during concerts and VJ-ing sessions.
|
||||
|
||||
The ouput image is typically projected full-screen on an external
|
||||
monitor or a projector, but can be recorded live (no audio).
|
||||
The output image is typically projected full-screen on an external
|
||||
monitor or a projector, and can be streamed live (SRT, Shmdata) or recorded (without audio).
|
||||
|
||||
vimix is the successor for GLMixer - https://sourceforge.net/projects/glmixer/
|
||||
|
||||
@@ -17,47 +20,80 @@ vimix is the successor for GLMixer - https://sourceforge.net/projects/glmixer/
|
||||
GPL-3.0-or-later
|
||||
See [LICENSE](https://github.com/brunoherbelin/vimix/blob/master/LICENSE)
|
||||
|
||||
# Install
|
||||
# Install vimix
|
||||
|
||||
Check the [Quick Installation Guide](https://github.com/brunoherbelin/vimix/wiki/Quick-Installation-Guide)
|
||||
|
||||
### Linux
|
||||
|
||||
Download and install a release package from https://snapcraft.io/vimix
|
||||
Download and install a released [flatpak package](https://flathub.org/apps/details/io.github.brunoherbelin.Vimix)
|
||||
|
||||
$ snap install vimix
|
||||
flatpak install --user vimix
|
||||
|
||||
NB: You'll need to setup the snap permissions.
|
||||
NB: Building your flatpak package is an option for testing the latest beta version from git ; instructions are [here](https://github.com/brunoherbelin/vimix/tree/master/flatpak).
|
||||
|
||||
|
||||
Download and install a released [snap package](https://snapcraft.io/vimix) (slower release frequency)
|
||||
|
||||
snap install vimix
|
||||
|
||||
Install the stable debian package (slower release frequency)
|
||||
|
||||
sudo apt install vimix
|
||||
|
||||
### Mac OSX
|
||||
|
||||
Download and open a release package from https://github.com/brunoherbelin/vimix/releases
|
||||
|
||||
NB: You'll need to accept the exception in OSX security preference.
|
||||
|
||||
# Build vimix
|
||||
|
||||
## Clone
|
||||
|
||||
$ git clone --recursive https://github.com/brunoherbelin/vimix.git
|
||||
git clone --recursive https://github.com/brunoherbelin/vimix.git
|
||||
|
||||
This will create the directory 'vimix', download the latest version of vimix code,
|
||||
and (recursively) clone all the internal git dependencies.
|
||||
|
||||
To only update a cloned git copy:
|
||||
|
||||
$ git pull
|
||||
|
||||
## Compile
|
||||
|
||||
First time after git clone:
|
||||
|
||||
$ mkdir vimix-build
|
||||
$ cd vimix-build
|
||||
$ cmake -DCMAKE_BUILD_TYPE=Release ../vimix
|
||||
mkdir vimix-build
|
||||
cd vimix-build
|
||||
cmake -DCMAKE_BUILD_TYPE=Release ../vimix
|
||||
cmake --build .
|
||||
|
||||
Compile (or re-compile after pull):
|
||||
This will create the directory 'vimix-build', configure the program for build, and compile vimix.
|
||||
If successful, the compilation will have produced the executable `vimix` in the `src` directory.
|
||||
You can run vimix with `./src/vimix` :
|
||||
|
||||
...
|
||||
[100%] Built target vimix
|
||||
./src/vimix
|
||||
|
||||
$ cmake --build .
|
||||
## Update clone and re-compile
|
||||
|
||||
### Dependencies
|
||||
Run these commands from the `vimix-build` directory if you did 'Clone' and 'Compile' previously and only want to get the latest update and rebuild.
|
||||
|
||||
git -C ../vimix/ pull
|
||||
cmake --build .
|
||||
|
||||
This will pull the latest commit from git and recompile.
|
||||
|
||||
## Try the Beta branch
|
||||
|
||||
Run this commands from the `vimix-build` directory before runing 'Update clone and re-compile above'
|
||||
|
||||
git -C ../vimix/ checkout beta
|
||||
|
||||
It should say;
|
||||
|
||||
branch 'beta' set up to track 'origin/beta'.
|
||||
Switched to a new branch 'beta'
|
||||
|
||||
## Dependencies
|
||||
|
||||
**Compiling tools:**
|
||||
|
||||
@@ -69,37 +105,38 @@ Compile (or re-compile after pull):
|
||||
**Libraries:**
|
||||
|
||||
- gstreamer
|
||||
- gst-plugins : libav, base, good, bad & ugly
|
||||
- gst-plugins (libav, base, good, bad & ugly)
|
||||
- libglfw3
|
||||
- libicu
|
||||
- libicu (icu-i18n icu-uc icu-io)
|
||||
|
||||
#### Install Dependencies
|
||||
Optionnal:
|
||||
|
||||
**Ubuntu**
|
||||
- glm
|
||||
- stb
|
||||
- TinyXML2
|
||||
- AbletonLink
|
||||
- Shmdata
|
||||
|
||||
$ apt-get install build-essential cmake libpng-dev libglfw3-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev gstreamer1.0-libav libicu-dev libgtk-3-dev
|
||||
### Install Dependencies
|
||||
|
||||
**OSX with Brew**
|
||||
#### Ubuntu
|
||||
|
||||
$ brew install cmake libpng glfw gstreamer gst-libav gst-plugins-bad gst-plugins-base gst-plugins-good gst-plugins-ugly icu4c
|
||||
apt-get install build-essential cmake libpng-dev libglfw3-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev gstreamer1.0-libav libicu-dev libgtk-3-dev
|
||||
|
||||
Optionnal:
|
||||
|
||||
#### Generate snap
|
||||
|
||||
To generate the snap (from vimix directory):
|
||||
|
||||
$ snapcraft
|
||||
apt-get install libglm-dev libstb-dev libtinyxml2-dev ableton-link-dev
|
||||
|
||||
To install the locally created snap:
|
||||
|
||||
$ snap install --dangerous vimix_0.5_amd64.snap
|
||||
|
||||
### Memcheck
|
||||
> Follow these instructions to [install Shmdata](https://github.com/nicobou/shmdata/blob/develop/doc/install-from-sources.md).
|
||||
|
||||
git clone https://gitlab.com/sat-metalab/shmdata.git
|
||||
mkdir shmdata-build
|
||||
cd shmdata-build
|
||||
cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr -DCMAKE_BUILD_TYPE=Release -DWITH_PYTHON=0 -DWITH_SDCRASH=0 -DWITH_SDFLOW=0 ../shmdata-build
|
||||
cmake --build . --target package
|
||||
sudo dpkg -i ./libshmdata_1.3*_amd64.deb
|
||||
|
||||
To generate memory usage plots in [massif format](https://valgrind.org/docs/manual/ms-manual.html):
|
||||
#### OSX with Brew
|
||||
|
||||
brew install cmake libpng glfw gstreamer icu4c
|
||||
|
||||
$ G_SLICE=always-malloc valgrind --tool=massif ./vimix
|
||||
|
||||
To check for memory leaks:
|
||||
|
||||
$ G_SLICE=always-malloc valgrind --leak-check=full --log-file=vimix_mem.txt ./vimix
|
||||
|
||||
166
RenderView.cpp
@@ -1,166 +0,0 @@
|
||||
/*
|
||||
* This file is part of vimix - video live mixer
|
||||
*
|
||||
* **Copyright** (C) 2019-2022 Bruno Herbelin <bruno.herbelin@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 3 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 <thread>
|
||||
|
||||
// Opengl
|
||||
#include <glad/glad.h>
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
#include <glm/gtc/matrix_access.hpp>
|
||||
#include <glm/gtx/vector_angle.hpp>
|
||||
|
||||
#include "defines.h"
|
||||
#include "Settings.h"
|
||||
#include "Decorations.h"
|
||||
|
||||
#include "RenderView.h"
|
||||
|
||||
|
||||
RenderView::RenderView() : View(RENDERING), frame_buffer_(nullptr), fading_overlay_(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
RenderView::~RenderView()
|
||||
{
|
||||
if (frame_buffer_)
|
||||
delete frame_buffer_;
|
||||
if (fading_overlay_)
|
||||
delete fading_overlay_;
|
||||
}
|
||||
|
||||
void RenderView::setFading(float f)
|
||||
{
|
||||
if (fading_overlay_ == nullptr)
|
||||
fading_overlay_ = new Surface;
|
||||
|
||||
fading_overlay_->shader()->color.a = CLAMP( f < EPSILON ? 0.f : f, 0.f, 1.f);
|
||||
}
|
||||
|
||||
float RenderView::fading() const
|
||||
{
|
||||
if (fading_overlay_)
|
||||
return fading_overlay_->shader()->color.a;
|
||||
else
|
||||
return 0.f;
|
||||
}
|
||||
|
||||
void RenderView::setResolution(glm::vec3 resolution, bool useAlpha)
|
||||
{
|
||||
// use default resolution if invalid resolution is given (default behavior)
|
||||
if (resolution.x < 2.f || resolution.y < 2.f)
|
||||
resolution = FrameBuffer::getResolutionFromParameters(Settings::application.render.ratio, Settings::application.render.res);
|
||||
|
||||
// do we need to change resolution ?
|
||||
if (frame_buffer_ && frame_buffer_->resolution() != resolution) {
|
||||
|
||||
// new frame buffer
|
||||
delete frame_buffer_;
|
||||
frame_buffer_ = nullptr;
|
||||
}
|
||||
|
||||
if (!frame_buffer_)
|
||||
// output frame is an RBG Multisamples FrameBuffer
|
||||
frame_buffer_ = new FrameBuffer(resolution, useAlpha, true);
|
||||
|
||||
// reset fading
|
||||
setFading();
|
||||
}
|
||||
|
||||
void RenderView::draw()
|
||||
{
|
||||
static glm::mat4 projection = glm::ortho(-1.f, 1.f, 1.f, -1.f, -SCENE_DEPTH, 1.f);
|
||||
|
||||
if (frame_buffer_) {
|
||||
// draw in frame buffer
|
||||
glm::mat4 P = glm::scale( projection, glm::vec3(1.f / frame_buffer_->aspectRatio(), 1.f, 1.f));
|
||||
|
||||
// render the scene normally (pre-multiplied alpha in RGB)
|
||||
frame_buffer_->begin();
|
||||
scene.root()->draw(glm::identity<glm::mat4>(), P);
|
||||
fading_overlay_->draw(glm::identity<glm::mat4>(), projection);
|
||||
frame_buffer_->end();
|
||||
}
|
||||
}
|
||||
|
||||
void RenderView::drawThumbnail()
|
||||
{
|
||||
if (frame_buffer_) {
|
||||
// if a thumbnailer is pending
|
||||
if (thumbnailer_.size() > 0) {
|
||||
|
||||
try {
|
||||
// new thumbnailing framebuffer
|
||||
FrameBuffer *frame_thumbnail = new FrameBuffer( glm::vec3(SESSION_THUMBNAIL_HEIGHT * frame_buffer_->aspectRatio(), SESSION_THUMBNAIL_HEIGHT, 1.f) );
|
||||
|
||||
// render
|
||||
if (Settings::application.render.blit) {
|
||||
if ( !frame_buffer_->blit(frame_thumbnail) )
|
||||
throw std::runtime_error("no blit");
|
||||
}
|
||||
else {
|
||||
FrameBufferSurface *thumb = new FrameBufferSurface(frame_buffer_);
|
||||
frame_thumbnail->begin();
|
||||
thumb->draw(glm::identity<glm::mat4>(), frame_thumbnail->projection());
|
||||
frame_thumbnail->end();
|
||||
delete thumb;
|
||||
}
|
||||
|
||||
// return valid thumbnail promise
|
||||
thumbnailer_.back().set_value( frame_thumbnail->image() );
|
||||
|
||||
// done with thumbnailing framebuffer
|
||||
delete frame_thumbnail;
|
||||
}
|
||||
catch(...) {
|
||||
// return failed thumbnail promise
|
||||
thumbnailer_.back().set_exception(std::current_exception());
|
||||
}
|
||||
|
||||
// done with this promise
|
||||
thumbnailer_.pop_back();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FrameBufferImage *RenderView::thumbnail ()
|
||||
{
|
||||
// by default null image
|
||||
FrameBufferImage *img = nullptr;
|
||||
|
||||
// this function is always called from a parallel thread
|
||||
// So we wait for a few frames of rendering before trying to capture a thumbnail
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
|
||||
// create and store a promise for a FrameBufferImage
|
||||
thumbnailer_.emplace_back( std::promise<FrameBufferImage *>() );
|
||||
|
||||
// future will return the promised FrameBufferImage
|
||||
std::future<FrameBufferImage *> ft = thumbnailer_.back().get_future();
|
||||
|
||||
try {
|
||||
// wait for a valid return value from promise
|
||||
img = ft.get();
|
||||
}
|
||||
// catch any failed promise
|
||||
catch (const std::exception&){
|
||||
}
|
||||
|
||||
return img;
|
||||
}
|
||||
@@ -1,930 +0,0 @@
|
||||
/*
|
||||
* This file is part of vimix - video live mixer
|
||||
*
|
||||
* **Copyright** (C) 2019-2022 Bruno Herbelin <bruno.herbelin@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 3 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 <cstring>
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
#include <chrono>
|
||||
#include <stdlib.h>
|
||||
|
||||
// Desktop OpenGL function loader
|
||||
#include <glad/glad.h> // Initialized with gladLoadGLLoader()
|
||||
|
||||
// Include glfw3.h after our OpenGL definitions
|
||||
#define GLFW_INCLUDE_GLEXT
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#ifdef APPLE
|
||||
#include "osx/CocoaToolkit.h"
|
||||
#define GLFW_EXPOSE_NATIVE_COCOA
|
||||
#define GLFW_EXPOSE_NATIVE_NSGL
|
||||
#else
|
||||
#define GLFW_EXPOSE_NATIVE_X11
|
||||
#define GLFW_EXPOSE_NATIVE_GLX
|
||||
#endif
|
||||
#include <GLFW/glfw3native.h>
|
||||
|
||||
#include <glm/gtc/matrix_transform.hpp> // glm::translate, glm::rotate, glm::scale
|
||||
#include <glm/ext/matrix_clip_space.hpp> // glm::perspective
|
||||
|
||||
// Include GStreamer
|
||||
#include <gst/gl/gl.h>
|
||||
#include <gst/gl/gstglcontext.h>
|
||||
|
||||
#ifdef GLFW_EXPOSE_NATIVE_COCOA
|
||||
//#include <gst/gl/cocoa/gstgldisplay_cocoa.h>
|
||||
#endif
|
||||
#ifdef GLFW_EXPOSE_NATIVE_GLX
|
||||
#include <gst/gl/x11/gstgldisplay_x11.h>
|
||||
#endif
|
||||
|
||||
// standalone image loader
|
||||
#include <stb_image.h>
|
||||
|
||||
// vimix
|
||||
#include "defines.h"
|
||||
#include "Log.h"
|
||||
#include "Resource.h"
|
||||
#include "Settings.h"
|
||||
#include "Primitives.h"
|
||||
#include "Mixer.h"
|
||||
#include "SystemToolkit.h"
|
||||
#include "GstToolkit.h"
|
||||
#include "UserInterfaceManager.h"
|
||||
|
||||
#include "RenderingManager.h"
|
||||
|
||||
#ifdef USE_GST_OPENGL_SYNC_HANDLER
|
||||
//
|
||||
// Discarded because not working under OSX - kept in case it would become useful
|
||||
//
|
||||
// Linking pipeline to the rendering instance ensures the opengl contexts
|
||||
// created by gstreamer inside plugins (e.g. glsinkbin) is the same
|
||||
//
|
||||
static GstGLContext *global_gl_context = NULL;
|
||||
static GstGLDisplay *global_display = NULL;
|
||||
|
||||
static GstBusSyncReply bus_sync_handler( GstBus *, GstMessage * msg, gpointer )
|
||||
{
|
||||
if (GST_MESSAGE_TYPE(msg) == GST_MESSAGE_NEED_CONTEXT) {
|
||||
const gchar* contextType;
|
||||
gst_message_parse_context_type(msg, &contextType);
|
||||
|
||||
if (!g_strcmp0(contextType, GST_GL_DISPLAY_CONTEXT_TYPE)) {
|
||||
GstContext *displayContext = gst_context_new(GST_GL_DISPLAY_CONTEXT_TYPE, TRUE);
|
||||
gst_context_set_gl_display(displayContext, global_display);
|
||||
gst_element_set_context(GST_ELEMENT(msg->src), displayContext);
|
||||
gst_context_unref (displayContext);
|
||||
|
||||
g_info ("Managed %s\n", contextType);
|
||||
}
|
||||
if (!g_strcmp0(contextType, "gst.gl.app_context")) {
|
||||
GstContext *appContext = gst_context_new("gst.gl.app_context", TRUE);
|
||||
GstStructure* structure = gst_context_writable_structure(appContext);
|
||||
gst_structure_set(structure, "context", GST_TYPE_GL_CONTEXT, global_gl_context, nullptr);
|
||||
gst_element_set_context(GST_ELEMENT(msg->src), appContext);
|
||||
gst_context_unref (appContext);
|
||||
|
||||
g_info ("Managed %s\n", contextType);
|
||||
}
|
||||
}
|
||||
|
||||
gst_message_unref (msg);
|
||||
|
||||
return GST_BUS_DROP;
|
||||
}
|
||||
|
||||
void Rendering::LinkPipeline( GstPipeline *pipeline )
|
||||
{
|
||||
// capture bus signals to force a unique opengl context for all GST elements
|
||||
GstBus* m_bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
|
||||
gst_bus_set_sync_handler (m_bus, (GstBusSyncHandler) bus_sync_handler, pipeline, NULL);
|
||||
gst_object_unref (m_bus);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
std::map<GLFWwindow *, RenderingWindow*> GLFW_window_;
|
||||
|
||||
static void glfw_error_callback(int error, const char* description)
|
||||
{
|
||||
Log::Error("Glfw Error %d: %s", error, description);
|
||||
}
|
||||
|
||||
static void WindowRefreshCallback( GLFWwindow * )
|
||||
{
|
||||
Rendering::manager().draw();
|
||||
}
|
||||
|
||||
static void WindowResizeCallback( GLFWwindow *w, int width, int height)
|
||||
{
|
||||
int id = GLFW_window_[w]->index();
|
||||
if (!Settings::application.windows[id].fullscreen) {
|
||||
Settings::application.windows[id].w = width;
|
||||
Settings::application.windows[id].h = height;
|
||||
}
|
||||
}
|
||||
|
||||
static void WindowMoveCallback( GLFWwindow *w, int x, int y)
|
||||
{
|
||||
int id = GLFW_window_[w]->index();
|
||||
if (!Settings::application.windows[id].fullscreen) {
|
||||
Settings::application.windows[id].x = x;
|
||||
Settings::application.windows[id].y = y;
|
||||
}
|
||||
}
|
||||
|
||||
static void WindowEscapeFullscreen( GLFWwindow *w, int key, int, int action, int)
|
||||
{
|
||||
if (action == GLFW_PRESS && key == GLFW_KEY_ESCAPE)
|
||||
{
|
||||
// escape fullscreen
|
||||
GLFW_window_[w]->exitFullscreen();
|
||||
}
|
||||
}
|
||||
|
||||
static void WindowToggleFullscreen( GLFWwindow *w, int button, int action, int)
|
||||
{
|
||||
if (button == GLFW_MOUSE_BUTTON_LEFT && action == GLFW_PRESS)
|
||||
{
|
||||
static double seconds = 0.f;
|
||||
// detect double clic
|
||||
if ( glfwGetTime() - seconds < 0.2f ) {
|
||||
// toggle fullscreen
|
||||
GLFW_window_[w]->toggleFullscreen();
|
||||
}
|
||||
// for next clic detection
|
||||
seconds = glfwGetTime();
|
||||
}
|
||||
}
|
||||
|
||||
Rendering::Rendering()
|
||||
{
|
||||
// main_window_ = nullptr;
|
||||
request_screenshot_ = false;
|
||||
}
|
||||
|
||||
bool Rendering::init()
|
||||
{
|
||||
// Setup window
|
||||
glfwSetErrorCallback(glfw_error_callback);
|
||||
if (!glfwInit()){
|
||||
Log::Error("Failed to Initialize GLFW.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Decide GL+GLSL versions GL 3.3 + GLSL 150
|
||||
glsl_version = "#version 150";
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); // 3.2+ only
|
||||
#if __APPLE__
|
||||
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // Required on Mac
|
||||
#endif
|
||||
|
||||
//
|
||||
// OpenGL Multisampling main window
|
||||
//
|
||||
glfwWindowHint(GLFW_SAMPLES, Settings::application.render.multisampling);
|
||||
main_.init(0);
|
||||
// set application icon
|
||||
main_.setIcon("images/vimix_256x256.png");
|
||||
// additional window callbacks for main window
|
||||
glfwSetWindowRefreshCallback( main_.window(), WindowRefreshCallback );
|
||||
glfwSetDropCallback( main_.window(), Rendering::FileDropped);
|
||||
|
||||
//
|
||||
// Gstreamer setup
|
||||
//
|
||||
std::string plugins_path = SystemToolkit::cwd_path() + "gstreamer-1.0";
|
||||
std::string plugins_scanner = SystemToolkit::cwd_path() + "gst-plugin-scanner" ;
|
||||
if ( SystemToolkit::file_exists(plugins_path)) {
|
||||
Log::Info("Found Gstreamer plugins in %s", plugins_path.c_str());
|
||||
g_setenv ("GST_PLUGIN_SYSTEM_PATH", plugins_path.c_str(), TRUE);
|
||||
g_setenv ("GST_PLUGIN_SCANNER", plugins_scanner.c_str(), TRUE);
|
||||
}
|
||||
std::string frei0r_path = SystemToolkit::cwd_path() + "frei0r-1" ;
|
||||
if ( SystemToolkit::file_exists(frei0r_path)) {
|
||||
Log::Info("Found Frei0r plugins in %s", frei0r_path.c_str());
|
||||
g_setenv ("FREI0R_PATH", frei0r_path.c_str(), TRUE);
|
||||
}
|
||||
g_setenv ("GST_GL_API", "opengl3", TRUE);
|
||||
gst_init (NULL, NULL);
|
||||
|
||||
// increase selection rank for GPU decoding plugins
|
||||
std::list<std::string> gpuplugins = GstToolkit::enable_gpu_decoding_plugins(Settings::application.render.gpu_decoding);
|
||||
if (Settings::application.render.gpu_decoding) {
|
||||
if (gpuplugins.size() > 0) {
|
||||
Log::Info("Found the following GPU decoding plugin(s):");
|
||||
int i = 1;
|
||||
for(auto it = gpuplugins.rbegin(); it != gpuplugins.rend(); it++, ++i)
|
||||
Log::Info("%d. %s", i, (*it).c_str());
|
||||
}
|
||||
else {
|
||||
Log::Info("No GPU decoding plugin found.");
|
||||
}
|
||||
}
|
||||
#ifdef SYNC_GSTREAMER_OPENGL_CONTEXT
|
||||
#if GST_GL_HAVE_PLATFORM_WGL
|
||||
global_gl_context = gst_gl_context_new_wrapped (display, (guintptr) wglGetCurrentContext (),
|
||||
GST_GL_PLATFORM_WGL, GST_GL_API_OPENGL);
|
||||
#elif GST_GL_HAVE_PLATFORM_CGL
|
||||
// global_display = GST_GL_DISPLAY ( glfwGetCocoaMonitor(main_.window()) );
|
||||
global_display = GST_GL_DISPLAY (gst_gl_display_cocoa_new ());
|
||||
|
||||
global_gl_context = gst_gl_context_new_wrapped (global_display,
|
||||
(guintptr) 0,
|
||||
GST_GL_PLATFORM_CGL, GST_GL_API_OPENGL);
|
||||
#elif GST_GL_HAVE_PLATFORM_GLX
|
||||
global_display = (GstGLDisplay*) gst_gl_display_x11_new_with_display( glfwGetX11Display() );
|
||||
global_gl_context = gst_gl_context_new_wrapped (global_display,
|
||||
(guintptr) glfwGetGLXContext(main_.window()),
|
||||
GST_GL_PLATFORM_GLX, GST_GL_API_OPENGL);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//
|
||||
// output window
|
||||
//
|
||||
glfwWindowHint(GLFW_SAMPLES, 0); // no need for multisampling in displaying output
|
||||
output_.init(1, main_.window());
|
||||
output_.setIcon("images/vimix_256x256.png");
|
||||
// special callbacks for user input in output window
|
||||
glfwSetKeyCallback( output_.window(), WindowEscapeFullscreen);
|
||||
glfwSetMouseButtonCallback( output_.window(), WindowToggleFullscreen);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Rendering::show()
|
||||
{
|
||||
// show output window
|
||||
output_.show();
|
||||
|
||||
// show main window
|
||||
main_.show();
|
||||
|
||||
// show menu on first show
|
||||
UserInterface::manager().showPannel(NAV_MENU);
|
||||
}
|
||||
|
||||
bool Rendering::isActive()
|
||||
{
|
||||
return !glfwWindowShouldClose(main_.window());
|
||||
}
|
||||
|
||||
|
||||
void Rendering::pushFrontDrawCallback(RenderingCallback function)
|
||||
{
|
||||
draw_callbacks_.push_front(function);
|
||||
}
|
||||
|
||||
void Rendering::pushBackDrawCallback(RenderingCallback function)
|
||||
{
|
||||
draw_callbacks_.push_back(function);
|
||||
}
|
||||
|
||||
void Rendering::draw()
|
||||
{
|
||||
// change windows fullscreen mode if requested
|
||||
main_.toggleFullscreen_();
|
||||
output_.toggleFullscreen_();
|
||||
|
||||
// change main window title if requested
|
||||
if (!main_new_title_.empty()) {
|
||||
main_.setTitle(main_new_title_);
|
||||
main_new_title_.clear();
|
||||
}
|
||||
|
||||
// operate on main window context
|
||||
main_.makeCurrent();
|
||||
|
||||
// draw
|
||||
std::list<Rendering::RenderingCallback>::iterator iter;
|
||||
for (iter=draw_callbacks_.begin(); iter != draw_callbacks_.end(); ++iter)
|
||||
{
|
||||
(*iter)();
|
||||
}
|
||||
|
||||
// perform screenshot if requested
|
||||
if (request_screenshot_) {
|
||||
// glfwMakeContextCurrent(main_window_);
|
||||
screenshot_.captureGL(0, 0, main_.width(), main_.height());
|
||||
request_screenshot_ = false;
|
||||
}
|
||||
|
||||
// swap GL buffers
|
||||
glfwSwapBuffers(main_.window());
|
||||
|
||||
// draw output window (and swap buffer output)
|
||||
output_.draw( Mixer::manager().session()->frame() );
|
||||
|
||||
// software framerate limiter 60FPS if not v-sync
|
||||
if ( Settings::application.render.vsync < 1 ) {
|
||||
static GTimer *timer = g_timer_new ();
|
||||
double elapsed = g_timer_elapsed (timer, NULL) * 1000000.0;
|
||||
if ( (elapsed < 16000.0) && (elapsed > 0.0) )
|
||||
g_usleep( 16000 - (gulong)elapsed );
|
||||
g_timer_start(timer);
|
||||
}
|
||||
|
||||
// Poll and handle events (inputs, window resize, etc.)
|
||||
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
|
||||
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
|
||||
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
|
||||
// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
|
||||
glfwPollEvents();
|
||||
|
||||
// no g_main_loop_run(loop) : update global GMainContext
|
||||
g_main_context_iteration(NULL, FALSE);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void Rendering::terminate()
|
||||
{
|
||||
// close window
|
||||
glfwDestroyWindow(output_.window());
|
||||
glfwDestroyWindow(main_.window());
|
||||
// glfwTerminate();
|
||||
}
|
||||
|
||||
|
||||
void Rendering::close()
|
||||
{
|
||||
glfwSetWindowShouldClose(main_.window(), true);
|
||||
}
|
||||
|
||||
|
||||
void Rendering::pushAttrib(RenderingAttrib ra)
|
||||
{
|
||||
// push it to top of pile
|
||||
draw_attributes_.push_front(ra);
|
||||
|
||||
// apply Changes to OpenGL
|
||||
glViewport(0, 0, ra.viewport.x, ra.viewport.y);
|
||||
glClearColor(ra.clear_color.r, ra.clear_color.g, ra.clear_color.b, ra.clear_color.a);
|
||||
}
|
||||
|
||||
void Rendering::popAttrib()
|
||||
{
|
||||
// pops the top of the pile
|
||||
if (draw_attributes_.size() > 0)
|
||||
draw_attributes_.pop_front();
|
||||
|
||||
// set attribute element to default
|
||||
RenderingAttrib ra = currentAttrib();
|
||||
|
||||
// apply Changes to OpenGL
|
||||
glViewport(0, 0, ra.viewport.x, ra.viewport.y);
|
||||
glClearColor(ra.clear_color.r, ra.clear_color.g, ra.clear_color.b, ra.clear_color.a);
|
||||
}
|
||||
|
||||
RenderingAttrib Rendering::currentAttrib()
|
||||
{
|
||||
// default rendering attrib is the main window's
|
||||
RenderingAttrib ra = main_.attribs();
|
||||
|
||||
// but if there is an element at top, return it
|
||||
if (draw_attributes_.size() > 0)
|
||||
ra = draw_attributes_.front();
|
||||
return ra;
|
||||
}
|
||||
|
||||
glm::mat4 Rendering::Projection()
|
||||
{
|
||||
static glm::mat4 projection = glm::ortho(-SCENE_UNIT, SCENE_UNIT, -SCENE_UNIT, SCENE_UNIT, -SCENE_DEPTH, 1.f);
|
||||
glm::mat4 scale = glm::scale(glm::identity<glm::mat4>(), glm::vec3(1.f, main_.aspectRatio(), 1.f));
|
||||
|
||||
return projection * scale;
|
||||
}
|
||||
|
||||
|
||||
glm::vec3 Rendering::unProject(glm::vec2 screen_coordinate, glm::mat4 modelview)
|
||||
{
|
||||
glm::vec3 coordinates = glm::vec3( screen_coordinate.x, main_.height() - screen_coordinate.y, 0.f);
|
||||
glm::vec4 viewport = glm::vec4( 0.f, 0.f, main_.width(), main_.height());
|
||||
|
||||
// Log::Info("unproject %d x %d", main_window_attributes_.viewport.x, main_window_attributes_.viewport.y);
|
||||
|
||||
glm::vec3 point = glm::unProject(coordinates, modelview, Projection(), viewport);
|
||||
|
||||
return point;
|
||||
}
|
||||
|
||||
|
||||
glm::vec2 Rendering::project(glm::vec3 scene_coordinate, glm::mat4 modelview, bool to_framebuffer)
|
||||
{
|
||||
glm::vec4 viewport;
|
||||
if (to_framebuffer)
|
||||
viewport= glm::vec4( 0.f, 0.f, main_.width(), main_.height());
|
||||
else
|
||||
viewport= glm::vec4( 0.f, 0.f, main_.width() / main_.dpiScale(), main_.height() / main_.dpiScale());
|
||||
glm::vec3 P = glm::project( scene_coordinate, modelview, Projection(), viewport );
|
||||
|
||||
return glm::vec2(P.x, viewport.w - P.y);
|
||||
}
|
||||
|
||||
void Rendering::FileDropped(GLFWwindow *, int path_count, const char* paths[])
|
||||
{
|
||||
int i = 0;
|
||||
for (; i < path_count; ++i) {
|
||||
std::string filename(paths[i]);
|
||||
if (filename.empty())
|
||||
break;
|
||||
// try to create a source
|
||||
Mixer::manager().addSource ( Mixer::manager().createSourceFile( filename ) );
|
||||
}
|
||||
if (i>0) {
|
||||
UserInterface::manager().showPannel();
|
||||
Rendering::manager().mainWindow().show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Screenshot *Rendering::currentScreenshot()
|
||||
{
|
||||
return &screenshot_;
|
||||
}
|
||||
|
||||
void Rendering::requestScreenshot()
|
||||
{
|
||||
request_screenshot_ = true;
|
||||
}
|
||||
|
||||
|
||||
// custom surface with a new VAO
|
||||
class WindowSurface : public Primitive {
|
||||
|
||||
public:
|
||||
WindowSurface(Shader *s = new ImageShader);
|
||||
};
|
||||
|
||||
WindowSurface::WindowSurface(Shader *s) : Primitive(s)
|
||||
{
|
||||
points_ = std::vector<glm::vec3> { glm::vec3( -1.f, -1.f, 0.f ), glm::vec3( -1.f, 1.f, 0.f ),
|
||||
glm::vec3( 1.f, -1.f, 0.f ), glm::vec3( 1.f, 1.f, 0.f ) };
|
||||
colors_ = std::vector<glm::vec4> { glm::vec4( 1.f, 1.f, 1.f , 1.f ), glm::vec4( 1.f, 1.f, 1.f, 1.f ),
|
||||
glm::vec4( 1.f, 1.f, 1.f, 1.f ), glm::vec4( 1.f, 1.f, 1.f, 1.f ) };
|
||||
texCoords_ = std::vector<glm::vec2> { glm::vec2( 0.f, 1.f ), glm::vec2( 0.f, 0.f ),
|
||||
glm::vec2( 1.f, 1.f ), glm::vec2( 1.f, 0.f ) };
|
||||
indices_ = std::vector<uint> { 0, 1, 2, 3 };
|
||||
drawMode_ = GL_TRIANGLE_STRIP;
|
||||
}
|
||||
|
||||
|
||||
RenderingWindow::RenderingWindow() : window_(nullptr), master_(nullptr),
|
||||
index_(-1), dpi_scale_(1.f), textureid_(0), fbo_(0), surface_(nullptr), request_toggle_fullscreen_(false)
|
||||
{
|
||||
}
|
||||
|
||||
RenderingWindow::~RenderingWindow()
|
||||
{
|
||||
if (surface_ != nullptr)
|
||||
delete surface_;
|
||||
if (fbo_ != 0)
|
||||
glDeleteFramebuffers(1, &fbo_);
|
||||
}
|
||||
|
||||
void RenderingWindow::setTitle(const std::string &title)
|
||||
{
|
||||
std::string fulltitle;
|
||||
if ( title.empty() )
|
||||
fulltitle = Settings::application.windows[index_].name;
|
||||
else
|
||||
fulltitle = title + std::string(" - " APP_NAME);
|
||||
|
||||
glfwSetWindowTitle(window_, fulltitle.c_str());
|
||||
}
|
||||
|
||||
void RenderingWindow::setIcon(const std::string &resource)
|
||||
{
|
||||
size_t fpsize = 0;
|
||||
const char *fp = Resource::getData(resource, &fpsize);
|
||||
if (fp != nullptr) {
|
||||
GLFWimage icon;
|
||||
icon.pixels = stbi_load_from_memory( (const stbi_uc*)fp, fpsize, &icon.width, &icon.height, nullptr, 4 );
|
||||
glfwSetWindowIcon( window_, 1, &icon );
|
||||
free( icon.pixels );
|
||||
}
|
||||
}
|
||||
|
||||
bool RenderingWindow::isFullscreen ()
|
||||
{
|
||||
// return (glfwGetWindowMonitor(window_) != nullptr);
|
||||
return Settings::application.windows[index_].fullscreen;
|
||||
}
|
||||
|
||||
GLFWmonitor *RenderingWindow::monitorAt(int x, int y)
|
||||
{
|
||||
// default to primary monitor
|
||||
GLFWmonitor *mo = glfwGetPrimaryMonitor();
|
||||
|
||||
// list all monitors
|
||||
int count_monitors = 0;
|
||||
GLFWmonitor** monitors = glfwGetMonitors(&count_monitors);
|
||||
// if there is more than one monitor
|
||||
if (count_monitors > 1) {
|
||||
// pick at the coordinates given or at pos of window
|
||||
// try every monitor
|
||||
int i = 0;
|
||||
for (; i < count_monitors; i++) {
|
||||
int workarea_x, workarea_y, workarea_width, workarea_height;
|
||||
#if GLFW_VERSION_MINOR > 2
|
||||
glfwGetMonitorWorkarea(monitors[i], &workarea_x, &workarea_y, &workarea_width, &workarea_height);
|
||||
#else
|
||||
glfwGetMonitorPos(monitors[i], &workarea_x, &workarea_y);
|
||||
const GLFWvidmode *vm = glfwGetVideoMode(monitors[i]);
|
||||
workarea_width = vm->width;
|
||||
workarea_height = vm->height;
|
||||
#endif
|
||||
if ( x >= workarea_x && x <= workarea_x + workarea_width &&
|
||||
y >= workarea_y && y <= workarea_y + workarea_height)
|
||||
break;
|
||||
}
|
||||
// found the monitor containing this point !
|
||||
if ( i < count_monitors)
|
||||
mo = monitors[i];
|
||||
}
|
||||
|
||||
return mo;
|
||||
}
|
||||
|
||||
GLFWmonitor *RenderingWindow::monitorNamed(const std::string &name)
|
||||
{
|
||||
// default to primary monitor
|
||||
GLFWmonitor *mo = glfwGetPrimaryMonitor();
|
||||
|
||||
// list all monitors
|
||||
int count_monitors = 0;
|
||||
GLFWmonitor** monitors = glfwGetMonitors(&count_monitors);
|
||||
// if there is more than one monitor
|
||||
if (count_monitors > 1) {
|
||||
// pick at the coordinates given or at pos of window
|
||||
// try every monitor
|
||||
int i = 0;
|
||||
for (; i < count_monitors; i++) {
|
||||
if ( std::string( glfwGetMonitorName(monitors[i])) == name )
|
||||
break;
|
||||
}
|
||||
// found the monitor with this name
|
||||
if ( i < count_monitors)
|
||||
mo = monitors[i];
|
||||
}
|
||||
|
||||
return mo;
|
||||
}
|
||||
|
||||
GLFWmonitor *RenderingWindow::monitor()
|
||||
{
|
||||
// pick at the coordinates given or at pos of window
|
||||
int x, y;
|
||||
glfwGetWindowPos(window_, &x, &y);
|
||||
return monitorAt(x, y);
|
||||
}
|
||||
|
||||
void RenderingWindow::setFullscreen_(GLFWmonitor *mo)
|
||||
{
|
||||
// done request
|
||||
request_toggle_fullscreen_ = false;
|
||||
|
||||
// disable fullscreen mode
|
||||
if (mo == nullptr) {
|
||||
// store fullscreen mode
|
||||
Settings::application.windows[index_].fullscreen = false;
|
||||
|
||||
// set to window mode
|
||||
glfwSetInputMode( window_, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
|
||||
glfwSetWindowMonitor( window_, nullptr, Settings::application.windows[index_].x,
|
||||
Settings::application.windows[index_].y,
|
||||
Settings::application.windows[index_].w,
|
||||
Settings::application.windows[index_].h, 0 );
|
||||
}
|
||||
// set fullscreen mode
|
||||
else {
|
||||
// store fullscreen mode
|
||||
Settings::application.windows[index_].fullscreen = true;
|
||||
Settings::application.windows[index_].monitor = glfwGetMonitorName(mo);
|
||||
|
||||
// set to fullscreen mode
|
||||
const GLFWvidmode * mode = glfwGetVideoMode(mo);
|
||||
glfwSetInputMode( window_, GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
|
||||
glfwSetWindowMonitor( window_, mo, 0, 0, mode->width, mode->height, mode->refreshRate);
|
||||
}
|
||||
|
||||
// Enable vsync on output window only (i.e. not 0 if has a master)
|
||||
// Workaround for disabled vsync in fullscreen (https://github.com/glfw/glfw/issues/1072)
|
||||
glfwSwapInterval( nullptr == master_ ? 0 : Settings::application.render.vsync);
|
||||
|
||||
}
|
||||
|
||||
void RenderingWindow::exitFullscreen()
|
||||
{
|
||||
if (isFullscreen()) {
|
||||
// exit fullscreen
|
||||
request_toggle_fullscreen_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
void RenderingWindow::toggleFullscreen()
|
||||
{
|
||||
request_toggle_fullscreen_ = true;
|
||||
}
|
||||
|
||||
void RenderingWindow::toggleFullscreen_()
|
||||
{
|
||||
if (request_toggle_fullscreen_) {
|
||||
|
||||
// if in fullscreen mode
|
||||
if (glfwGetWindowMonitor(window_) != nullptr) {
|
||||
// exit fullscreen
|
||||
setFullscreen_(nullptr);
|
||||
}
|
||||
// not in fullscreen mode
|
||||
else {
|
||||
// enter fullscreen in monitor where the window is
|
||||
setFullscreen_(monitor());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int RenderingWindow::width()
|
||||
{
|
||||
return window_attributes_.viewport.x;
|
||||
}
|
||||
|
||||
int RenderingWindow::height()
|
||||
{
|
||||
return window_attributes_.viewport.y;
|
||||
}
|
||||
|
||||
int RenderingWindow::pixelsforRealHeight(float milimeters)
|
||||
{
|
||||
GLFWmonitor *mo = monitor();
|
||||
|
||||
int mm_w = 0;
|
||||
int mm_h = 0;
|
||||
glfwGetMonitorPhysicalSize(mo, &mm_w, &mm_h);
|
||||
|
||||
float pixels = milimeters;
|
||||
if (mm_h > 0)
|
||||
pixels *= static_cast<float>(glfwGetVideoMode(mo)->height) / static_cast<float>(mm_h);
|
||||
else
|
||||
pixels *= 5; // something reasonnable if monitor's physical size is unknown
|
||||
|
||||
return static_cast<int>( round(pixels) );
|
||||
}
|
||||
|
||||
float RenderingWindow::aspectRatio()
|
||||
{
|
||||
return static_cast<float>(window_attributes_.viewport.x) / static_cast<float>(window_attributes_.viewport.y);
|
||||
}
|
||||
|
||||
bool RenderingWindow::init(int index, GLFWwindow *share)
|
||||
{
|
||||
index_ = index;
|
||||
master_ = share;
|
||||
|
||||
// access Settings
|
||||
Settings::WindowConfig winset = Settings::application.windows[index_];
|
||||
|
||||
// do not show at creation
|
||||
glfwWindowHint(GLFW_FOCUSED, GLFW_FALSE);
|
||||
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
|
||||
glfwWindowHint(GLFW_AUTO_ICONIFY, GLFW_FALSE);
|
||||
|
||||
// create the window
|
||||
window_ = glfwCreateWindow(winset.w, winset.h, winset.name.c_str(), NULL, master_);
|
||||
if (window_ == NULL){
|
||||
Log::Error("Failed to create GLFW Window %d", index_);
|
||||
return false;
|
||||
}
|
||||
|
||||
// ensure minimal window size
|
||||
glfwSetWindowSizeLimits(window_, 800, 500, GLFW_DONT_CARE, GLFW_DONT_CARE);
|
||||
|
||||
// set initial position
|
||||
glfwSetWindowPos(window_, winset.x, winset.y);
|
||||
|
||||
/// CALLBACKS
|
||||
// store global ref to pointers (used by callbacks)
|
||||
GLFW_window_[window_] = this;
|
||||
// window position and resize callbacks
|
||||
glfwSetWindowPosCallback( window_, WindowMoveCallback );
|
||||
glfwSetWindowSizeCallback( window_, WindowResizeCallback );
|
||||
|
||||
// take opengl context ownership
|
||||
glfwMakeContextCurrent(window_);
|
||||
|
||||
//
|
||||
// Initialize OpenGL loader on first call
|
||||
//
|
||||
static bool glad_initialized = false;
|
||||
if ( !glad_initialized ) {
|
||||
bool err = gladLoadGLLoader((GLADloadproc) glfwGetProcAddress) == 0;
|
||||
if (err) {
|
||||
Log::Error("Failed to initialize GLAD OpenGL loader.");
|
||||
return false;
|
||||
}
|
||||
glad_initialized = true;
|
||||
}
|
||||
|
||||
// get rendering area
|
||||
glfwGetFramebufferSize(window_, &(window_attributes_.viewport.x), &(window_attributes_.viewport.y));
|
||||
// DPI scaling (retina)
|
||||
dpi_scale_ = float(window_attributes_.viewport.y) / float(winset.h);
|
||||
|
||||
// We decide for byte aligned textures all over
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT,1);
|
||||
// This hint can improve the speed of texturing when perspective-correct texture coordinate interpolation isn't needed
|
||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
|
||||
// fast mipmaps (we are not really using mipmaps anyway)
|
||||
glHint(GL_GENERATE_MIPMAP_HINT, GL_FASTEST);
|
||||
// acurate derivative for shader
|
||||
glHint(GL_FRAGMENT_SHADER_DERIVATIVE_HINT, GL_NICEST);
|
||||
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
|
||||
|
||||
// if not main window
|
||||
if ( master_ != NULL ) {
|
||||
// Enable vsync on output window
|
||||
glfwSwapInterval(Settings::application.render.vsync);
|
||||
// no need for multisampling
|
||||
glDisable(GL_MULTISAMPLE);
|
||||
// clear to black
|
||||
window_attributes_.clear_color = glm::vec4(0.f, 0.f, 0.f, 1.f);
|
||||
// give back context ownership
|
||||
glfwMakeContextCurrent(master_);
|
||||
}
|
||||
else {
|
||||
// Disable vsync on main window
|
||||
glfwSwapInterval(0);
|
||||
// Enable Antialiasing multisampling
|
||||
if (Settings::application.render.multisampling > 0) {
|
||||
glEnable(GL_MULTISAMPLE);
|
||||
glHint(GL_MULTISAMPLE_FILTER_HINT_NV, GL_NICEST);
|
||||
}
|
||||
// clear to grey
|
||||
window_attributes_.clear_color = glm::vec4(COLOR_BGROUND, 1.f);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void RenderingWindow::show()
|
||||
{
|
||||
glfwShowWindow(window_);
|
||||
|
||||
if ( Settings::application.windows[index_].fullscreen ) {
|
||||
GLFWmonitor *mo = monitorNamed(Settings::application.windows[index_].monitor);
|
||||
setFullscreen_(mo);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void RenderingWindow::makeCurrent()
|
||||
{
|
||||
// handle window resize
|
||||
glfwGetFramebufferSize(window_, &(window_attributes_.viewport.x), &(window_attributes_.viewport.y));
|
||||
|
||||
// ensure main context is current
|
||||
glfwMakeContextCurrent(window_);
|
||||
|
||||
// set and clear
|
||||
glViewport(0, 0, window_attributes_.viewport.x, window_attributes_.viewport.y);
|
||||
glClearColor(window_attributes_.clear_color.r, window_attributes_.clear_color.g,
|
||||
window_attributes_.clear_color.b, window_attributes_.clear_color.a);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
}
|
||||
|
||||
// TODO update parameters for draw on resize event (not every frame)
|
||||
|
||||
void RenderingWindow::draw(FrameBuffer *fb)
|
||||
{
|
||||
if (!window_ || !fb)
|
||||
return;
|
||||
|
||||
// only draw if window is not iconified
|
||||
if( !glfwGetWindowAttrib(window_, GLFW_ICONIFIED ) ) {
|
||||
|
||||
// update viewport (could be done with callback)
|
||||
glfwGetFramebufferSize(window_, &(window_attributes_.viewport.x), &(window_attributes_.viewport.y));
|
||||
|
||||
// take context ownership
|
||||
glfwMakeContextCurrent(window_);
|
||||
|
||||
// setup attribs
|
||||
Rendering::manager().pushAttrib(window_attributes_);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
// blit framebuffer
|
||||
if (Settings::application.render.blit) {
|
||||
|
||||
if ( textureid_ != fb->texture()) {
|
||||
|
||||
textureid_ = fb->texture();
|
||||
|
||||
// create a new fbo in this opengl context
|
||||
if (fbo_ != 0)
|
||||
glDeleteFramebuffers(1, &fbo_);
|
||||
glGenFramebuffers(1, &fbo_);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, fbo_);
|
||||
|
||||
// attach the 2D texture to local FBO
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textureid_, 0);
|
||||
#ifndef NDEBUG
|
||||
Log::Info("Blit to output window enabled.");
|
||||
#endif
|
||||
}
|
||||
|
||||
// if not disabled
|
||||
if (!Settings::application.render.disabled) {
|
||||
|
||||
// calculate scaling factor of frame buffer inside window
|
||||
int rx, ry, rw, rh;
|
||||
float renderingAspectRatio = fb->aspectRatio();
|
||||
if (aspectRatio() < renderingAspectRatio) {
|
||||
int nh = (int)( float(window_attributes_.viewport.x) / renderingAspectRatio);
|
||||
rx = 0;
|
||||
ry = (window_attributes_.viewport.y - nh) / 2;
|
||||
rw = window_attributes_.viewport.x;
|
||||
rh = (window_attributes_.viewport.y + nh) / 2;
|
||||
} else {
|
||||
int nw = (int)( float(window_attributes_.viewport.y) * renderingAspectRatio );
|
||||
rx = (window_attributes_.viewport.x - nw) / 2;
|
||||
ry = 0;
|
||||
rw = (window_attributes_.viewport.x + nw) / 2;
|
||||
rh = window_attributes_.viewport.y;
|
||||
}
|
||||
|
||||
// select fbo texture read target
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo_);
|
||||
|
||||
// select screen target
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||
|
||||
// blit operation from fbo (containing texture) to screen
|
||||
glBlitFramebuffer(0, fb->height(), fb->width(), 0, rx, ry, rw, rh, GL_COLOR_BUFFER_BIT, GL_LINEAR);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// draw geometry
|
||||
else if (!Settings::application.render.disabled)
|
||||
{
|
||||
// VAO is not shared between multiple contexts of different windows
|
||||
// so we have to create a new VAO for rendering the surface in this window
|
||||
if (surface_ == 0)
|
||||
surface_ = new WindowSurface;
|
||||
|
||||
// calculate scaling factor of frame buffer inside window
|
||||
float windowAspectRatio = aspectRatio();
|
||||
float renderingAspectRatio = fb->aspectRatio();
|
||||
glm::vec3 scale;
|
||||
if (windowAspectRatio < renderingAspectRatio)
|
||||
scale = glm::vec3(1.f, windowAspectRatio / renderingAspectRatio, 1.f);
|
||||
else
|
||||
scale = glm::vec3(renderingAspectRatio / windowAspectRatio, 1.f, 1.f);
|
||||
|
||||
// make sure previous shader in another glcontext is disabled
|
||||
ShadingProgram::enduse();
|
||||
|
||||
// draw
|
||||
glBindTexture(GL_TEXTURE_2D, fb->texture());
|
||||
// surface->shader()->color.a = 0.4f; // TODO alpha blending ?
|
||||
static glm::mat4 projection = glm::ortho(-1.f, 1.f, -1.f, 1.f, -1.f, 1.f);
|
||||
surface_->draw(glm::scale(glm::identity<glm::mat4>(), scale), projection);
|
||||
|
||||
// done drawing (unload shader from this glcontext)
|
||||
ShadingProgram::enduse();
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
}
|
||||
|
||||
// swap buffer
|
||||
glfwSwapBuffers(window_);
|
||||
}
|
||||
|
||||
// restore attribs
|
||||
Rendering::manager().popAttrib();
|
||||
|
||||
// give back context ownership
|
||||
glfwMakeContextCurrent(master_);
|
||||
}
|
||||
|
||||
626
Session.cpp
@@ -1,626 +0,0 @@
|
||||
/*
|
||||
* This file is part of vimix - video live mixer
|
||||
*
|
||||
* **Copyright** (C) 2019-2022 Bruno Herbelin <bruno.herbelin@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 3 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 <algorithm>
|
||||
|
||||
#include "defines.h"
|
||||
#include "BaseToolkit.h"
|
||||
#include "Source.h"
|
||||
#include "Settings.h"
|
||||
#include "FrameBuffer.h"
|
||||
#include "FrameGrabber.h"
|
||||
#include "SessionCreator.h"
|
||||
#include "SessionSource.h"
|
||||
#include "MixingGroup.h"
|
||||
#include "Log.h"
|
||||
|
||||
#include "Session.h"
|
||||
|
||||
SessionNote::SessionNote(const std::string &t, bool l, int s): label(std::to_string(BaseToolkit::uniqueId())),
|
||||
text(t), large(l), stick(s), pos(glm::vec2(520.f, 30.f)), size(glm::vec2(220.f, 220.f))
|
||||
{
|
||||
}
|
||||
|
||||
Session::Session() : active_(true), activation_threshold_(MIXING_MIN_THRESHOLD),
|
||||
filename_(""), failedSource_(nullptr), thumbnail_(nullptr)
|
||||
{
|
||||
config_[View::RENDERING] = new Group;
|
||||
config_[View::RENDERING]->scale_ = glm::vec3(0.f);
|
||||
|
||||
config_[View::GEOMETRY] = new Group;
|
||||
config_[View::GEOMETRY]->scale_ = Settings::application.views[View::GEOMETRY].default_scale;
|
||||
config_[View::GEOMETRY]->translation_ = Settings::application.views[View::GEOMETRY].default_translation;
|
||||
|
||||
config_[View::LAYER] = new Group;
|
||||
config_[View::LAYER]->scale_ = Settings::application.views[View::LAYER].default_scale;
|
||||
config_[View::LAYER]->translation_ = Settings::application.views[View::LAYER].default_translation;
|
||||
|
||||
config_[View::MIXING] = new Group;
|
||||
config_[View::MIXING]->scale_ = Settings::application.views[View::MIXING].default_scale;
|
||||
config_[View::MIXING]->translation_ = Settings::application.views[View::MIXING].default_translation;
|
||||
|
||||
config_[View::TEXTURE] = new Group;
|
||||
config_[View::TEXTURE]->scale_ = Settings::application.views[View::TEXTURE].default_scale;
|
||||
config_[View::TEXTURE]->translation_ = Settings::application.views[View::TEXTURE].default_translation;
|
||||
|
||||
snapshots_.xmlDoc_ = new tinyxml2::XMLDocument;
|
||||
start_time_ = gst_util_get_timestamp ();
|
||||
}
|
||||
|
||||
|
||||
Session::~Session()
|
||||
{
|
||||
// TODO delete all mixing groups?
|
||||
auto group_iter = mixing_groups_.begin();
|
||||
while ( group_iter != mixing_groups_.end() ){
|
||||
delete (*group_iter);
|
||||
group_iter = mixing_groups_.erase(group_iter);
|
||||
}
|
||||
|
||||
// delete all sources
|
||||
for(auto it = sources_.begin(); it != sources_.end(); ) {
|
||||
// erase this source from the list
|
||||
it = deleteSource(*it);
|
||||
}
|
||||
|
||||
delete config_[View::RENDERING];
|
||||
delete config_[View::GEOMETRY];
|
||||
delete config_[View::LAYER];
|
||||
delete config_[View::MIXING];
|
||||
delete config_[View::TEXTURE];
|
||||
|
||||
snapshots_.keys_.clear();
|
||||
delete snapshots_.xmlDoc_;
|
||||
}
|
||||
|
||||
uint64_t Session::runtime() const
|
||||
{
|
||||
return gst_util_get_timestamp () - start_time_;
|
||||
}
|
||||
|
||||
void Session::setActive (bool on)
|
||||
{
|
||||
if (active_ != on) {
|
||||
active_ = on;
|
||||
for(auto it = sources_.begin(); it != sources_.end(); ++it) {
|
||||
(*it)->setActive(active_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// update all sources
|
||||
void Session::update(float dt)
|
||||
{
|
||||
// no update until render view is initialized
|
||||
if ( render_.frame() == nullptr )
|
||||
return;
|
||||
|
||||
// pre-render all sources
|
||||
failedSource_ = nullptr;
|
||||
bool ready = true;
|
||||
for( SourceList::iterator it = sources_.begin(); it != sources_.end(); ++it){
|
||||
|
||||
// ensure the RenderSource is rendering *this* session
|
||||
RenderSource *rs = dynamic_cast<RenderSource *>( *it );
|
||||
if ( rs!= nullptr && rs->session() != this )
|
||||
rs->setSession(this);
|
||||
|
||||
// discard failed source
|
||||
if ( (*it)->failed() ) {
|
||||
failedSource_ = (*it);
|
||||
}
|
||||
// render normally
|
||||
else {
|
||||
if ( !(*it)->ready() )
|
||||
ready = false;
|
||||
// render the source
|
||||
(*it)->render();
|
||||
// update the source
|
||||
(*it)->setActive(activation_threshold_);
|
||||
(*it)->update(dt);
|
||||
}
|
||||
}
|
||||
|
||||
// update session's mixing groups
|
||||
auto group_iter = mixing_groups_.begin();
|
||||
while ( group_iter != mixing_groups_.end() ){
|
||||
// update all valid groups
|
||||
if ((*group_iter)->size() > 1) {
|
||||
(*group_iter)->update(dt);
|
||||
group_iter++;
|
||||
}
|
||||
else
|
||||
// delete invalid groups (singletons)
|
||||
group_iter = deleteMixingGroup(group_iter);
|
||||
}
|
||||
|
||||
// update fading requested
|
||||
if (fading_.active) {
|
||||
|
||||
// animate
|
||||
fading_.progress += dt;
|
||||
|
||||
// update animation
|
||||
if ( fading_.duration > 0.f && fading_.progress < fading_.duration ) {
|
||||
// interpolation
|
||||
float f = fading_.progress / fading_.duration;
|
||||
f = ( 1.f - f ) * fading_.start + f * fading_.target;
|
||||
render_.setFading( f );
|
||||
}
|
||||
// arrived at target
|
||||
else {
|
||||
// set precise value
|
||||
render_.setFading( fading_.target );
|
||||
// fading finished
|
||||
fading_.active = false;
|
||||
fading_.start = fading_.target;
|
||||
fading_.duration = fading_.progress = 0.f;
|
||||
}
|
||||
}
|
||||
|
||||
// update the scene tree
|
||||
render_.update(dt);
|
||||
|
||||
// draw render view in Frame Buffer
|
||||
render_.draw();
|
||||
|
||||
// draw the thumbnail only after all sources are ready
|
||||
if (ready)
|
||||
render_.drawThumbnail();
|
||||
}
|
||||
|
||||
SourceList::iterator Session::addSource(Source *s)
|
||||
{
|
||||
// lock before change
|
||||
access_.lock();
|
||||
|
||||
// find the source
|
||||
SourceList::iterator its = find(s);
|
||||
|
||||
// ok, its NOT in the list !
|
||||
if (its == sources_.end()) {
|
||||
// insert the source in the rendering
|
||||
render_.scene.ws()->attach(s->group(View::RENDERING));
|
||||
// insert the source to the beginning of the list
|
||||
sources_.push_back(s);
|
||||
// return the iterator to the source created at the beginning
|
||||
its = sources_.end()--;
|
||||
}
|
||||
|
||||
// unlock access
|
||||
access_.unlock();
|
||||
|
||||
return its;
|
||||
}
|
||||
|
||||
SourceList::iterator Session::deleteSource(Source *s)
|
||||
{
|
||||
// lock before change
|
||||
access_.lock();
|
||||
|
||||
// find the source
|
||||
SourceList::iterator its = find(s);
|
||||
// ok, its in the list !
|
||||
if (its != sources_.end()) {
|
||||
// remove Node from the rendering scene
|
||||
render_.scene.ws()->detach( s->group(View::RENDERING) );
|
||||
// inform group
|
||||
if (s->mixingGroup() != nullptr)
|
||||
s->mixingGroup()->detach(s);
|
||||
// erase the source from the update list & get next element
|
||||
its = sources_.erase(its);
|
||||
// delete the source : safe now
|
||||
delete s;
|
||||
}
|
||||
|
||||
// unlock access
|
||||
access_.unlock();
|
||||
|
||||
// return end of next element
|
||||
return its;
|
||||
}
|
||||
|
||||
void Session::removeSource(Source *s)
|
||||
{
|
||||
// lock before change
|
||||
access_.lock();
|
||||
|
||||
// find the source
|
||||
SourceList::iterator its = find(s);
|
||||
// ok, its in the list !
|
||||
if (its != sources_.end()) {
|
||||
// remove Node from the rendering scene
|
||||
render_.scene.ws()->detach( s->group(View::RENDERING) );
|
||||
// inform group
|
||||
if (s->mixingGroup() != nullptr)
|
||||
s->mixingGroup()->detach(s);
|
||||
// erase the source from the update list & get next element
|
||||
sources_.erase(its);
|
||||
}
|
||||
|
||||
// unlock access
|
||||
access_.unlock();
|
||||
}
|
||||
|
||||
Source *Session::popSource()
|
||||
{
|
||||
Source *s = nullptr;
|
||||
|
||||
SourceList::iterator its = sources_.begin();
|
||||
if (its != sources_.end())
|
||||
{
|
||||
s = *its;
|
||||
// remove Node from the rendering scene
|
||||
render_.scene.ws()->detach( s->group(View::RENDERING) );
|
||||
// erase the source from the update list & get next element
|
||||
sources_.erase(its);
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
static void replaceThumbnail(Session *s)
|
||||
{
|
||||
if (s != nullptr) {
|
||||
FrameBufferImage *t = s->renderThumbnail();
|
||||
if (t != nullptr) // avoid recursive infinite loop
|
||||
s->setThumbnail(t);
|
||||
}
|
||||
}
|
||||
|
||||
void Session::setThumbnail(FrameBufferImage *t)
|
||||
{
|
||||
resetThumbnail();
|
||||
// replace with given image
|
||||
if (t != nullptr)
|
||||
thumbnail_ = t;
|
||||
// no thumbnail image given: capture from rendering in a parallel thread
|
||||
else
|
||||
std::thread( replaceThumbnail, this ).detach();
|
||||
}
|
||||
|
||||
void Session::resetThumbnail()
|
||||
{
|
||||
if (thumbnail_ != nullptr)
|
||||
delete thumbnail_;
|
||||
thumbnail_ = nullptr;
|
||||
}
|
||||
|
||||
void Session::setResolution(glm::vec3 resolution, bool useAlpha)
|
||||
{
|
||||
// setup the render view: if not specified the default config resulution will be used
|
||||
render_.setResolution( resolution, useAlpha );
|
||||
// store the actual resolution set in the render view
|
||||
config_[View::RENDERING]->scale_ = render_.resolution();
|
||||
}
|
||||
|
||||
void Session::setFadingTarget(float f, float duration)
|
||||
{
|
||||
// targetted fading value
|
||||
fading_.target = CLAMP(f, 0.f, 1.f);
|
||||
// starting point for interpolation
|
||||
fading_.start = fading();
|
||||
// initiate animation
|
||||
fading_.progress = 0.f;
|
||||
fading_.duration = duration;
|
||||
// activate update
|
||||
fading_.active = true;
|
||||
}
|
||||
|
||||
SourceList::iterator Session::begin()
|
||||
{
|
||||
return sources_.begin();
|
||||
}
|
||||
|
||||
SourceList::iterator Session::end()
|
||||
{
|
||||
return sources_.end();
|
||||
}
|
||||
|
||||
SourceList::iterator Session::find(Source *s)
|
||||
{
|
||||
return std::find(sources_.begin(), sources_.end(), s);
|
||||
}
|
||||
|
||||
SourceList::iterator Session::find(uint64_t id)
|
||||
{
|
||||
return std::find_if(sources_.begin(), sources_.end(), Source::hasId(id));
|
||||
}
|
||||
|
||||
SourceList::iterator Session::find(std::string namesource)
|
||||
{
|
||||
return std::find_if(sources_.begin(), sources_.end(), Source::hasName(namesource));
|
||||
}
|
||||
|
||||
SourceList::iterator Session::find(Node *node)
|
||||
{
|
||||
return std::find_if(sources_.begin(), sources_.end(), Source::hasNode(node));
|
||||
}
|
||||
|
||||
SourceList::iterator Session::find(float depth_from, float depth_to)
|
||||
{
|
||||
return std::find_if(sources_.begin(), sources_.end(), Source::hasDepth(depth_from, depth_to));
|
||||
}
|
||||
|
||||
SourceList Session::getDepthSortedList() const
|
||||
{
|
||||
return depth_sorted(sources_);
|
||||
}
|
||||
|
||||
uint Session::numSource() const
|
||||
{
|
||||
return sources_.size();
|
||||
}
|
||||
|
||||
SourceIdList Session::getIdList() const
|
||||
{
|
||||
return ids(sources_);
|
||||
}
|
||||
|
||||
std::list<std::string> Session::getNameList(uint64_t exceptid) const
|
||||
{
|
||||
std::list<std::string> namelist;
|
||||
|
||||
for( SourceList::const_iterator it = sources_.cbegin(); it != sources_.cend(); ++it) {
|
||||
if ( (*it)->id() != exceptid )
|
||||
namelist.push_back( (*it)->name() );
|
||||
}
|
||||
|
||||
return namelist;
|
||||
}
|
||||
|
||||
|
||||
bool Session::empty() const
|
||||
{
|
||||
return sources_.empty();
|
||||
}
|
||||
|
||||
SourceList::iterator Session::at(int index)
|
||||
{
|
||||
if ( index < 0 || index > (int) sources_.size())
|
||||
return sources_.end();
|
||||
|
||||
int i = 0;
|
||||
SourceList::iterator it = sources_.begin();
|
||||
while ( i < index && it != sources_.end() ){
|
||||
i++;
|
||||
++it;
|
||||
}
|
||||
return it;
|
||||
}
|
||||
|
||||
int Session::index(SourceList::iterator it) const
|
||||
{
|
||||
int index = -1;
|
||||
int count = 0;
|
||||
for(auto i = sources_.begin(); i != sources_.end(); ++i, ++count) {
|
||||
if ( i == it ) {
|
||||
index = count;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
void Session::move(int current_index, int target_index)
|
||||
{
|
||||
if ( current_index < 0 || current_index > (int) sources_.size()
|
||||
|| target_index < 0 || target_index > (int) sources_.size()
|
||||
|| target_index == current_index )
|
||||
return;
|
||||
|
||||
SourceList::iterator from = at(current_index);
|
||||
SourceList::iterator to = at(target_index);
|
||||
if ( target_index > current_index )
|
||||
++to;
|
||||
|
||||
Source *s = (*from);
|
||||
sources_.erase(from);
|
||||
sources_.insert(to, s);
|
||||
}
|
||||
|
||||
bool Session::canlink (SourceList sources)
|
||||
{
|
||||
bool canlink = true;
|
||||
|
||||
// verify that all sources given are valid in the sesion
|
||||
validate(sources);
|
||||
|
||||
for (auto it = sources.begin(); it != sources.end(); ++it) {
|
||||
// this source is linked
|
||||
if ( (*it)->mixingGroup() != nullptr ) {
|
||||
// askt its group to detach it
|
||||
canlink = false;
|
||||
}
|
||||
}
|
||||
|
||||
return canlink;
|
||||
}
|
||||
|
||||
void Session::link(SourceList sources, Group *parent)
|
||||
{
|
||||
// we need at least 2 sources to make a group
|
||||
if (sources.size() > 1) {
|
||||
|
||||
unlink(sources);
|
||||
|
||||
// create and add a new mixing group
|
||||
MixingGroup *g = new MixingGroup(sources);
|
||||
mixing_groups_.push_back(g);
|
||||
|
||||
// if provided, attach the group to the parent
|
||||
if (g && parent != nullptr)
|
||||
g->attachTo( parent );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void Session::unlink (SourceList sources)
|
||||
{
|
||||
// verify that all sources given are valid in the sesion
|
||||
validate(sources);
|
||||
|
||||
// brute force : detach all given sources
|
||||
for (auto it = sources.begin(); it != sources.end(); ++it) {
|
||||
// this source is linked
|
||||
if ( (*it)->mixingGroup() != nullptr ) {
|
||||
// askt its group to detach it
|
||||
(*it)->mixingGroup()->detach(*it);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Session::addNote(SessionNote note)
|
||||
{
|
||||
notes_.push_back( note );
|
||||
}
|
||||
|
||||
std::list<SessionNote>::iterator Session::beginNotes ()
|
||||
{
|
||||
return notes_.begin();
|
||||
}
|
||||
|
||||
std::list<SessionNote>::iterator Session::endNotes ()
|
||||
{
|
||||
return notes_.end();
|
||||
}
|
||||
|
||||
std::list<SessionNote>::iterator Session::deleteNote (std::list<SessionNote>::iterator n)
|
||||
{
|
||||
if (n != notes_.end())
|
||||
return notes_.erase(n);
|
||||
|
||||
return notes_.end();
|
||||
}
|
||||
|
||||
std::list<SourceList> Session::getMixingGroups () const
|
||||
{
|
||||
std::list<SourceList> lmg;
|
||||
|
||||
for (auto group_it = mixing_groups_.begin(); group_it!= mixing_groups_.end(); ++group_it)
|
||||
lmg.push_back( (*group_it)->getCopy() );
|
||||
|
||||
return lmg;
|
||||
}
|
||||
|
||||
std::list<MixingGroup *>::iterator Session::deleteMixingGroup (std::list<MixingGroup *>::iterator g)
|
||||
{
|
||||
if (g != mixing_groups_.end()) {
|
||||
delete (*g);
|
||||
return mixing_groups_.erase(g);
|
||||
}
|
||||
return mixing_groups_.end();
|
||||
}
|
||||
|
||||
std::list<MixingGroup *>::iterator Session::beginMixingGroup()
|
||||
{
|
||||
return mixing_groups_.begin();
|
||||
}
|
||||
|
||||
std::list<MixingGroup *>::iterator Session::endMixingGroup()
|
||||
{
|
||||
return mixing_groups_.end();
|
||||
}
|
||||
|
||||
|
||||
size_t Session::numPlayGroups() const
|
||||
{
|
||||
return play_groups_.size();
|
||||
}
|
||||
|
||||
void Session::addPlayGroup(const SourceIdList &ids)
|
||||
{
|
||||
play_groups_.push_back( ids );
|
||||
}
|
||||
|
||||
void Session::addToPlayGroup(size_t i, Source *s)
|
||||
{
|
||||
if (i < play_groups_.size() )
|
||||
{
|
||||
if ( std::find(play_groups_[i].begin(), play_groups_[i].end(), s->id()) == play_groups_[i].end() )
|
||||
play_groups_[i].push_back(s->id());
|
||||
}
|
||||
}
|
||||
|
||||
void Session::removeFromPlayGroup(size_t i, Source *s)
|
||||
{
|
||||
if (i < play_groups_.size() )
|
||||
{
|
||||
if ( std::find(play_groups_[i].begin(), play_groups_[i].end(), s->id()) != play_groups_[i].end() )
|
||||
play_groups_[i].remove( s->id() );
|
||||
}
|
||||
}
|
||||
|
||||
void Session::deletePlayGroup(size_t i)
|
||||
{
|
||||
if (i < play_groups_.size() )
|
||||
play_groups_.erase( play_groups_.begin() + i);
|
||||
}
|
||||
|
||||
SourceList Session::playGroup(size_t i) const
|
||||
{
|
||||
SourceList list;
|
||||
|
||||
if (i < play_groups_.size() )
|
||||
{
|
||||
for (auto sid = play_groups_[i].begin(); sid != play_groups_[i].end(); ++sid){
|
||||
|
||||
SourceList::const_iterator it = std::find_if(sources_.begin(), sources_.end(), Source::hasId( *sid));;
|
||||
if ( it != sources_.end())
|
||||
list.push_back( *it);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
void Session::lock()
|
||||
{
|
||||
access_.lock();
|
||||
}
|
||||
|
||||
void Session::unlock()
|
||||
{
|
||||
access_.unlock();
|
||||
}
|
||||
|
||||
void Session::validate (SourceList &sources)
|
||||
{
|
||||
// verify that all sources given are valid in the sesion
|
||||
// and remove the invalid sources
|
||||
for (auto _it = sources.begin(); _it != sources.end(); ) {
|
||||
SourceList::iterator found = std::find(sources_.begin(), sources_.end(), *_it);
|
||||
if ( found == sources_.end() )
|
||||
_it = sources.erase(_it);
|
||||
else
|
||||
_it++;
|
||||
}
|
||||
}
|
||||
|
||||
Session *Session::load(const std::string& filename, uint recursion)
|
||||
{
|
||||
// create session
|
||||
SessionCreator creator(recursion);
|
||||
creator.load(filename);
|
||||
|
||||
// return created session
|
||||
return creator.session();
|
||||
}
|
||||
|
||||
640
Settings.cpp
@@ -1,640 +0,0 @@
|
||||
/*
|
||||
* This file is part of vimix - video live mixer
|
||||
*
|
||||
* **Copyright** (C) 2019-2022 Bruno Herbelin <bruno.herbelin@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 3 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 <algorithm>
|
||||
#include <iostream>
|
||||
#include <locale>
|
||||
using namespace std;
|
||||
|
||||
#include <tinyxml2.h>
|
||||
#include "tinyxml2Toolkit.h"
|
||||
using namespace tinyxml2;
|
||||
|
||||
#include "defines.h"
|
||||
#include "SystemToolkit.h"
|
||||
#include "Settings.h"
|
||||
|
||||
|
||||
Settings::Application Settings::application;
|
||||
string settingsFilename = "";
|
||||
|
||||
|
||||
XMLElement *save_history(Settings::History &h, const char *nodename, XMLDocument &xmlDoc)
|
||||
{
|
||||
XMLElement *pElement = xmlDoc.NewElement( nodename );
|
||||
pElement->SetAttribute("path", h.path.c_str());
|
||||
pElement->SetAttribute("autoload", h.load_at_start);
|
||||
pElement->SetAttribute("autosave", h.save_on_exit);
|
||||
pElement->SetAttribute("valid", h.front_is_valid);
|
||||
for(auto it = h.filenames.cbegin();
|
||||
it != h.filenames.cend(); ++it) {
|
||||
XMLElement *fileNode = xmlDoc.NewElement("path");
|
||||
XMLText *text = xmlDoc.NewText( (*it).c_str() );
|
||||
fileNode->InsertEndChild( text );
|
||||
pElement->InsertFirstChild(fileNode);
|
||||
}
|
||||
return pElement;
|
||||
}
|
||||
|
||||
|
||||
void Settings::Save(uint64_t runtime)
|
||||
{
|
||||
// impose C locale for all app
|
||||
setlocale(LC_ALL, "C");
|
||||
|
||||
XMLDocument xmlDoc;
|
||||
XMLDeclaration *pDec = xmlDoc.NewDeclaration();
|
||||
xmlDoc.InsertFirstChild(pDec);
|
||||
|
||||
XMLElement *pRoot = xmlDoc.NewElement(application.name.c_str());
|
||||
#ifdef VIMIX_VERSION_MAJOR
|
||||
pRoot->SetAttribute("major", VIMIX_VERSION_MAJOR);
|
||||
pRoot->SetAttribute("minor", VIMIX_VERSION_MINOR);
|
||||
xmlDoc.InsertEndChild(pRoot);
|
||||
#endif
|
||||
// runtime
|
||||
if (runtime>0)
|
||||
pRoot->SetAttribute("runtime", runtime + application.total_runtime);
|
||||
|
||||
string comment = "Settings for " + application.name;
|
||||
XMLComment *pComment = xmlDoc.NewComment(comment.c_str());
|
||||
pRoot->InsertEndChild(pComment);
|
||||
|
||||
// block: windows
|
||||
{
|
||||
XMLElement *windowsNode = xmlDoc.NewElement( "Windows" );
|
||||
|
||||
for (int i = 0; i < (int) application.windows.size(); ++i)
|
||||
{
|
||||
const Settings::WindowConfig& w = application.windows[i];
|
||||
|
||||
XMLElement *window = xmlDoc.NewElement( "Window" );
|
||||
window->SetAttribute("name", w.name.c_str());
|
||||
window->SetAttribute("id", i);
|
||||
window->SetAttribute("x", w.x);
|
||||
window->SetAttribute("y", w.y);
|
||||
window->SetAttribute("w", w.w);
|
||||
window->SetAttribute("h", w.h);
|
||||
window->SetAttribute("f", w.fullscreen);
|
||||
window->SetAttribute("m", w.monitor.c_str());
|
||||
windowsNode->InsertEndChild(window);
|
||||
}
|
||||
|
||||
pRoot->InsertEndChild(windowsNode);
|
||||
}
|
||||
|
||||
// General application preferences
|
||||
XMLElement *applicationNode = xmlDoc.NewElement( "Application" );
|
||||
applicationNode->SetAttribute("scale", application.scale);
|
||||
applicationNode->SetAttribute("accent_color", application.accent_color);
|
||||
applicationNode->SetAttribute("smooth_transition", application.smooth_transition);
|
||||
applicationNode->SetAttribute("save_snapshot", application.save_version_snapshot);
|
||||
applicationNode->SetAttribute("smooth_cursor", application.smooth_cursor);
|
||||
applicationNode->SetAttribute("action_history_follow_view", application.action_history_follow_view);
|
||||
applicationNode->SetAttribute("show_tooptips", application.show_tooptips);
|
||||
applicationNode->SetAttribute("accept_connections", application.accept_connections);
|
||||
applicationNode->SetAttribute("pannel_history_mode", application.pannel_current_session_mode);
|
||||
applicationNode->SetAttribute("stream_low_bandwidth", application.stream_low_bandwidth);
|
||||
pRoot->InsertEndChild(applicationNode);
|
||||
|
||||
// Widgets
|
||||
XMLElement *widgetsNode = xmlDoc.NewElement( "Widgets" );
|
||||
widgetsNode->SetAttribute("preview", application.widget.preview);
|
||||
widgetsNode->SetAttribute("preview_view", application.widget.preview_view);
|
||||
widgetsNode->SetAttribute("timer", application.widget.timer);
|
||||
widgetsNode->SetAttribute("timer_view", application.widget.timer_view);
|
||||
widgetsNode->SetAttribute("media_player", application.widget.media_player);
|
||||
widgetsNode->SetAttribute("media_player_view", application.widget.media_player_view);
|
||||
widgetsNode->SetAttribute("timeline_editmode", application.widget.timeline_editmode);
|
||||
widgetsNode->SetAttribute("shader_editor", application.widget.shader_editor);
|
||||
widgetsNode->SetAttribute("stats", application.widget.stats);
|
||||
widgetsNode->SetAttribute("stats_mode", application.widget.stats_mode);
|
||||
widgetsNode->SetAttribute("stats_corner", application.widget.stats_corner);
|
||||
widgetsNode->SetAttribute("logs", application.widget.logs);
|
||||
widgetsNode->SetAttribute("toolbox", application.widget.toolbox);
|
||||
pRoot->InsertEndChild(widgetsNode);
|
||||
|
||||
// Render
|
||||
XMLElement *RenderNode = xmlDoc.NewElement( "Render" );
|
||||
RenderNode->SetAttribute("vsync", application.render.vsync);
|
||||
RenderNode->SetAttribute("multisampling", application.render.multisampling);
|
||||
RenderNode->SetAttribute("blit", application.render.blit);
|
||||
RenderNode->SetAttribute("gpu_decoding", application.render.gpu_decoding);
|
||||
RenderNode->SetAttribute("ratio", application.render.ratio);
|
||||
RenderNode->SetAttribute("res", application.render.res);
|
||||
pRoot->InsertEndChild(RenderNode);
|
||||
|
||||
// Record
|
||||
XMLElement *RecordNode = xmlDoc.NewElement( "Record" );
|
||||
RecordNode->SetAttribute("path", application.record.path.c_str());
|
||||
RecordNode->SetAttribute("profile", application.record.profile);
|
||||
RecordNode->SetAttribute("timeout", application.record.timeout);
|
||||
RecordNode->SetAttribute("delay", application.record.delay);
|
||||
RecordNode->SetAttribute("resolution_mode", application.record.resolution_mode);
|
||||
RecordNode->SetAttribute("framerate_mode", application.record.framerate_mode);
|
||||
RecordNode->SetAttribute("buffering_mode", application.record.buffering_mode);
|
||||
RecordNode->SetAttribute("priority_mode", application.record.priority_mode);
|
||||
pRoot->InsertEndChild(RecordNode);
|
||||
|
||||
// Transition
|
||||
XMLElement *TransitionNode = xmlDoc.NewElement( "Transition" );
|
||||
TransitionNode->SetAttribute("hide_windows", application.transition.hide_windows);
|
||||
TransitionNode->SetAttribute("cross_fade", application.transition.cross_fade);
|
||||
TransitionNode->SetAttribute("duration", application.transition.duration);
|
||||
TransitionNode->SetAttribute("profile", application.transition.profile);
|
||||
pRoot->InsertEndChild(TransitionNode);
|
||||
|
||||
// Source
|
||||
XMLElement *SourceConfNode = xmlDoc.NewElement( "Source" );
|
||||
SourceConfNode->SetAttribute("new_type", application.source.new_type);
|
||||
SourceConfNode->SetAttribute("ratio", application.source.ratio);
|
||||
SourceConfNode->SetAttribute("res", application.source.res);
|
||||
pRoot->InsertEndChild(SourceConfNode);
|
||||
|
||||
// Brush
|
||||
XMLElement *BrushNode = xmlDoc.NewElement( "Brush" );
|
||||
BrushNode->InsertEndChild( XMLElementFromGLM(&xmlDoc, application.brush) );
|
||||
pRoot->InsertEndChild(BrushNode);
|
||||
|
||||
// bloc connections
|
||||
{
|
||||
XMLElement *connectionsNode = xmlDoc.NewElement( "Connections" );
|
||||
|
||||
// map<int, std::string>::iterator iter;
|
||||
// for (iter=application.instance_names.begin(); iter != application.instance_names.end(); iter++)
|
||||
// {
|
||||
// XMLElement *connection = xmlDoc.NewElement( "Instance" );
|
||||
// connection->SetAttribute("name", iter->second.c_str());
|
||||
// connection->SetAttribute("id", iter->first);
|
||||
// connectionsNode->InsertEndChild(connection);
|
||||
// }
|
||||
pRoot->InsertEndChild(connectionsNode);
|
||||
}
|
||||
|
||||
// bloc views
|
||||
{
|
||||
XMLElement *viewsNode = xmlDoc.NewElement( "Views" );
|
||||
// save current view only if [mixing, geometry, layers, appearance]
|
||||
int v = application.current_view > 4 ? 1 : application.current_view;
|
||||
viewsNode->SetAttribute("current", v);
|
||||
viewsNode->SetAttribute("workspace", application.current_workspace);
|
||||
|
||||
map<int, Settings::ViewConfig>::iterator iter;
|
||||
for (iter=application.views.begin(); iter != application.views.end(); ++iter)
|
||||
{
|
||||
const Settings::ViewConfig& view_config = iter->second;
|
||||
|
||||
XMLElement *view = xmlDoc.NewElement( "View" );
|
||||
view->SetAttribute("name", view_config.name.c_str());
|
||||
view->SetAttribute("id", iter->first);
|
||||
|
||||
XMLElement *scale = xmlDoc.NewElement("default_scale");
|
||||
scale->InsertEndChild( XMLElementFromGLM(&xmlDoc, view_config.default_scale) );
|
||||
view->InsertEndChild(scale);
|
||||
XMLElement *translation = xmlDoc.NewElement("default_translation");
|
||||
translation->InsertEndChild( XMLElementFromGLM(&xmlDoc, view_config.default_translation) );
|
||||
view->InsertEndChild(translation);
|
||||
|
||||
viewsNode->InsertEndChild(view);
|
||||
}
|
||||
|
||||
pRoot->InsertEndChild(viewsNode);
|
||||
}
|
||||
|
||||
// bloc history
|
||||
{
|
||||
XMLElement *recent = xmlDoc.NewElement( "Recent" );
|
||||
|
||||
// recent session filenames
|
||||
recent->InsertEndChild( save_history(application.recentSessions, "Session", xmlDoc));
|
||||
|
||||
// recent session folders
|
||||
recent->InsertEndChild( save_history(application.recentFolders, "Folder", xmlDoc));
|
||||
|
||||
// recent import media uri
|
||||
recent->InsertEndChild( save_history(application.recentImport, "Import", xmlDoc));
|
||||
|
||||
// recent import folders
|
||||
recent->InsertEndChild( save_history(application.recentImportFolders, "ImportFolder", xmlDoc));
|
||||
|
||||
// recent recordings
|
||||
recent->InsertEndChild( save_history(application.recentRecordings, "Record", xmlDoc));
|
||||
|
||||
// recent dialog path
|
||||
XMLElement *recentdialogpath = xmlDoc.NewElement( "Dialog" );
|
||||
for(auto it = application.dialogRecentFolder.cbegin();
|
||||
it != application.dialogRecentFolder.cend(); ++it) {
|
||||
XMLElement *pathNode = xmlDoc.NewElement("path");
|
||||
pathNode->SetAttribute("label", (*it).first.c_str() );
|
||||
XMLText *text = xmlDoc.NewText( (*it).second.c_str() );
|
||||
pathNode->InsertEndChild( text );
|
||||
recentdialogpath->InsertFirstChild(pathNode);
|
||||
}
|
||||
recent->InsertEndChild(recentdialogpath);
|
||||
|
||||
pRoot->InsertEndChild(recent);
|
||||
}
|
||||
|
||||
// Metronome
|
||||
XMLElement *timerConfNode = xmlDoc.NewElement( "Timer" );
|
||||
timerConfNode->SetAttribute("mode", application.timer.mode);
|
||||
timerConfNode->SetAttribute("link_enabled", application.timer.link_enabled);
|
||||
timerConfNode->SetAttribute("link_tempo", application.timer.link_tempo);
|
||||
timerConfNode->SetAttribute("link_quantum", application.timer.link_quantum);
|
||||
timerConfNode->SetAttribute("link_start_stop_sync", application.timer.link_start_stop_sync);
|
||||
timerConfNode->SetAttribute("stopwatch_duration", application.timer.stopwatch_duration);
|
||||
pRoot->InsertEndChild(timerConfNode);
|
||||
|
||||
// Controller
|
||||
XMLElement *controlConfNode = xmlDoc.NewElement( "Control" );
|
||||
controlConfNode->SetAttribute("osc_port_receive", application.control.osc_port_receive);
|
||||
controlConfNode->SetAttribute("osc_port_send", application.control.osc_port_send);
|
||||
|
||||
|
||||
// First save : create filename
|
||||
if (settingsFilename.empty())
|
||||
settingsFilename = SystemToolkit::full_filename(SystemToolkit::settings_path(), APP_SETTINGS);
|
||||
|
||||
XMLError eResult = xmlDoc.SaveFile(settingsFilename.c_str());
|
||||
XMLResultError(eResult);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void load_history(Settings::History &h, const char *nodename, XMLElement *root)
|
||||
{
|
||||
XMLElement * pElement = root->FirstChildElement(nodename);
|
||||
if (pElement)
|
||||
{
|
||||
// list of path
|
||||
h.filenames.clear();
|
||||
XMLElement* path = pElement->FirstChildElement("path");
|
||||
for( ; path ; path = path->NextSiblingElement())
|
||||
{
|
||||
const char *p = path->GetText();
|
||||
if (p)
|
||||
h.push( std::string (p) );
|
||||
}
|
||||
// path attribute
|
||||
const char *path_ = pElement->Attribute("path");
|
||||
if (path_)
|
||||
h.path = std::string(path_);
|
||||
else
|
||||
h.path = SystemToolkit::home_path();
|
||||
// other attritutes
|
||||
pElement->QueryBoolAttribute("autoload", &h.load_at_start);
|
||||
pElement->QueryBoolAttribute("autosave", &h.save_on_exit);
|
||||
pElement->QueryBoolAttribute("valid", &h.front_is_valid);
|
||||
}
|
||||
}
|
||||
|
||||
void Settings::Load()
|
||||
{
|
||||
// impose C locale for all app
|
||||
setlocale(LC_ALL, "C");
|
||||
|
||||
// set filenames from settings path
|
||||
application.control.osc_filename = SystemToolkit::full_filename(SystemToolkit::settings_path(), OSC_CONFIG_FILE);
|
||||
settingsFilename = SystemToolkit::full_filename(SystemToolkit::settings_path(), APP_SETTINGS);
|
||||
|
||||
// try to load settings file
|
||||
XMLDocument xmlDoc;
|
||||
XMLError eResult = xmlDoc.LoadFile(settingsFilename.c_str());
|
||||
|
||||
// do not warn if non existing file
|
||||
if (eResult == XML_ERROR_FILE_NOT_FOUND)
|
||||
return;
|
||||
// warn and return on other error
|
||||
else if (XMLResultError(eResult))
|
||||
return;
|
||||
|
||||
// first element should be called by the application name
|
||||
XMLElement *pRoot = xmlDoc.FirstChildElement(application.name.c_str());
|
||||
if (pRoot == nullptr)
|
||||
return;
|
||||
|
||||
// cancel on different root name
|
||||
if (application.name.compare( string( pRoot->Value() ) ) != 0 )
|
||||
return;
|
||||
|
||||
#ifdef VIMIX_VERSION_MAJOR
|
||||
// cancel on different version
|
||||
int version_major = -1, version_minor = -1;
|
||||
pRoot->QueryIntAttribute("major", &version_major);
|
||||
pRoot->QueryIntAttribute("minor", &version_minor);
|
||||
if (version_major != VIMIX_VERSION_MAJOR || version_minor != VIMIX_VERSION_MINOR)
|
||||
return;
|
||||
#endif
|
||||
// runtime
|
||||
pRoot->QueryUnsigned64Attribute("runtime", &application.total_runtime);
|
||||
|
||||
XMLElement * applicationNode = pRoot->FirstChildElement("Application");
|
||||
if (applicationNode != nullptr) {
|
||||
applicationNode->QueryFloatAttribute("scale", &application.scale);
|
||||
applicationNode->QueryIntAttribute("accent_color", &application.accent_color);
|
||||
applicationNode->QueryBoolAttribute("smooth_transition", &application.smooth_transition);
|
||||
applicationNode->QueryBoolAttribute("save_snapshot", &application.save_version_snapshot);
|
||||
applicationNode->QueryBoolAttribute("smooth_cursor", &application.smooth_cursor);
|
||||
applicationNode->QueryBoolAttribute("action_history_follow_view", &application.action_history_follow_view);
|
||||
applicationNode->QueryBoolAttribute("show_tooptips", &application.show_tooptips);
|
||||
applicationNode->QueryBoolAttribute("accept_connections", &application.accept_connections);
|
||||
applicationNode->QueryIntAttribute("pannel_history_mode", &application.pannel_current_session_mode);
|
||||
applicationNode->QueryBoolAttribute("stream_low_bandwidth", &application.stream_low_bandwidth);
|
||||
}
|
||||
|
||||
// Widgets
|
||||
XMLElement * widgetsNode = pRoot->FirstChildElement("Widgets");
|
||||
if (widgetsNode != nullptr) {
|
||||
widgetsNode->QueryBoolAttribute("preview", &application.widget.preview);
|
||||
widgetsNode->QueryIntAttribute("preview_view", &application.widget.preview_view);
|
||||
widgetsNode->QueryBoolAttribute("timer", &application.widget.timer);
|
||||
widgetsNode->QueryIntAttribute("timer_view", &application.widget.timer_view);
|
||||
widgetsNode->QueryBoolAttribute("media_player", &application.widget.media_player);
|
||||
widgetsNode->QueryIntAttribute("media_player_view", &application.widget.media_player_view);
|
||||
widgetsNode->QueryBoolAttribute("timeline_editmode", &application.widget.timeline_editmode);
|
||||
widgetsNode->QueryBoolAttribute("shader_editor", &application.widget.shader_editor);
|
||||
widgetsNode->QueryBoolAttribute("stats", &application.widget.stats);
|
||||
widgetsNode->QueryIntAttribute("stats_mode", &application.widget.stats_mode);
|
||||
widgetsNode->QueryIntAttribute("stats_corner", &application.widget.stats_corner);
|
||||
widgetsNode->QueryBoolAttribute("logs", &application.widget.logs);
|
||||
widgetsNode->QueryBoolAttribute("toolbox", &application.widget.toolbox);
|
||||
}
|
||||
|
||||
// Render
|
||||
XMLElement * rendernode = pRoot->FirstChildElement("Render");
|
||||
if (rendernode != nullptr) {
|
||||
rendernode->QueryIntAttribute("vsync", &application.render.vsync);
|
||||
rendernode->QueryIntAttribute("multisampling", &application.render.multisampling);
|
||||
rendernode->QueryBoolAttribute("blit", &application.render.blit);
|
||||
rendernode->QueryBoolAttribute("gpu_decoding", &application.render.gpu_decoding);
|
||||
rendernode->QueryIntAttribute("ratio", &application.render.ratio);
|
||||
rendernode->QueryIntAttribute("res", &application.render.res);
|
||||
}
|
||||
|
||||
// Record
|
||||
XMLElement * recordnode = pRoot->FirstChildElement("Record");
|
||||
if (recordnode != nullptr) {
|
||||
recordnode->QueryIntAttribute("profile", &application.record.profile);
|
||||
recordnode->QueryUnsignedAttribute("timeout", &application.record.timeout);
|
||||
recordnode->QueryIntAttribute("delay", &application.record.delay);
|
||||
recordnode->QueryIntAttribute("resolution_mode", &application.record.resolution_mode);
|
||||
recordnode->QueryIntAttribute("framerate_mode", &application.record.framerate_mode);
|
||||
recordnode->QueryIntAttribute("buffering_mode", &application.record.buffering_mode);
|
||||
recordnode->QueryIntAttribute("priority_mode", &application.record.priority_mode);
|
||||
|
||||
const char *path_ = recordnode->Attribute("path");
|
||||
if (path_)
|
||||
application.record.path = std::string(path_);
|
||||
else
|
||||
application.record.path = SystemToolkit::home_path();
|
||||
}
|
||||
|
||||
// Source
|
||||
XMLElement * sourceconfnode = pRoot->FirstChildElement("Source");
|
||||
if (sourceconfnode != nullptr) {
|
||||
sourceconfnode->QueryIntAttribute("new_type", &application.source.new_type);
|
||||
sourceconfnode->QueryIntAttribute("ratio", &application.source.ratio);
|
||||
sourceconfnode->QueryIntAttribute("res", &application.source.res);
|
||||
}
|
||||
|
||||
// Transition
|
||||
XMLElement * transitionnode = pRoot->FirstChildElement("Transition");
|
||||
if (transitionnode != nullptr) {
|
||||
transitionnode->QueryBoolAttribute("hide_windows", &application.transition.hide_windows);
|
||||
transitionnode->QueryBoolAttribute("cross_fade", &application.transition.cross_fade);
|
||||
transitionnode->QueryFloatAttribute("duration", &application.transition.duration);
|
||||
transitionnode->QueryIntAttribute("profile", &application.transition.profile);
|
||||
}
|
||||
|
||||
// bloc windows
|
||||
{
|
||||
XMLElement * pElement = pRoot->FirstChildElement("Windows");
|
||||
if (pElement)
|
||||
{
|
||||
XMLElement* windowNode = pElement->FirstChildElement("Window");
|
||||
for( ; windowNode ; windowNode=windowNode->NextSiblingElement())
|
||||
{
|
||||
Settings::WindowConfig w;
|
||||
windowNode->QueryIntAttribute("x", &w.x); // If this fails, original value is left as-is
|
||||
windowNode->QueryIntAttribute("y", &w.y);
|
||||
windowNode->QueryIntAttribute("w", &w.w);
|
||||
windowNode->QueryIntAttribute("h", &w.h);
|
||||
windowNode->QueryBoolAttribute("f", &w.fullscreen);
|
||||
const char *text = windowNode->Attribute("m");
|
||||
if (text)
|
||||
w.monitor = std::string(text);
|
||||
|
||||
int i = 0;
|
||||
windowNode->QueryIntAttribute("id", &i);
|
||||
w.name = application.windows[i].name; // keep only original name
|
||||
application.windows[i] = w;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Brush
|
||||
XMLElement * brushnode = pRoot->FirstChildElement("Brush");
|
||||
if (brushnode != nullptr) {
|
||||
tinyxml2::XMLElementToGLM( brushnode->FirstChildElement("vec3"), application.brush);
|
||||
}
|
||||
|
||||
// bloc views
|
||||
{
|
||||
XMLElement * pElement = pRoot->FirstChildElement("Views");
|
||||
if (pElement)
|
||||
{
|
||||
application.views.clear(); // trash existing list
|
||||
pElement->QueryIntAttribute("current", &application.current_view);
|
||||
pElement->QueryIntAttribute("workspace", &application.current_workspace);
|
||||
|
||||
XMLElement* viewNode = pElement->FirstChildElement("View");
|
||||
for( ; viewNode ; viewNode=viewNode->NextSiblingElement())
|
||||
{
|
||||
int id = 0;
|
||||
viewNode->QueryIntAttribute("id", &id);
|
||||
application.views[id].name = viewNode->Attribute("name");
|
||||
|
||||
XMLElement* scaleNode = viewNode->FirstChildElement("default_scale");
|
||||
tinyxml2::XMLElementToGLM( scaleNode->FirstChildElement("vec3"),
|
||||
application.views[id].default_scale);
|
||||
|
||||
XMLElement* translationNode = viewNode->FirstChildElement("default_translation");
|
||||
tinyxml2::XMLElementToGLM( translationNode->FirstChildElement("vec3"),
|
||||
application.views[id].default_translation);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// bloc Connections
|
||||
{
|
||||
XMLElement * pElement = pRoot->FirstChildElement("Connections");
|
||||
if (pElement)
|
||||
{
|
||||
// XMLElement* connectionNode = pElement->FirstChildElement("Instance");
|
||||
// for( ; connectionNode ; connectionNode=connectionNode->NextSiblingElement())
|
||||
// {
|
||||
// int id = 0;
|
||||
// connectionNode->QueryIntAttribute("id", &id);
|
||||
// application.instance_names[id] = connectionNode->Attribute("name");
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// bloc history of recent
|
||||
{
|
||||
XMLElement * pElement = pRoot->FirstChildElement("Recent");
|
||||
if (pElement)
|
||||
{
|
||||
// recent session filenames
|
||||
load_history(application.recentSessions, "Session", pElement);
|
||||
|
||||
// recent session folders
|
||||
load_history(application.recentFolders, "Folder", pElement);
|
||||
|
||||
// recent media uri
|
||||
load_history(application.recentImport, "Import", pElement);
|
||||
|
||||
// recent import folders
|
||||
load_history(application.recentImportFolders, "ImportFolder", pElement);
|
||||
|
||||
// recent recordings
|
||||
load_history(application.recentRecordings, "Record", pElement);
|
||||
|
||||
// recent dialog path
|
||||
XMLElement * pDialog = pElement->FirstChildElement("Dialog");
|
||||
if (pDialog)
|
||||
{
|
||||
application.dialogRecentFolder.clear();
|
||||
XMLElement* path = pDialog->FirstChildElement("path");
|
||||
for( ; path ; path = path->NextSiblingElement())
|
||||
{
|
||||
const char *l = path->Attribute("label");
|
||||
const char *p = path->GetText();
|
||||
if (l && p)
|
||||
application.dialogRecentFolder[ std::string(l)] = std::string (p);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// bloc metronome
|
||||
XMLElement * timerconfnode = pRoot->FirstChildElement("Timer");
|
||||
if (timerconfnode != nullptr) {
|
||||
timerconfnode->QueryUnsigned64Attribute("mode", &application.timer.mode);
|
||||
timerconfnode->QueryBoolAttribute("link_enabled", &application.timer.link_enabled);
|
||||
timerconfnode->QueryDoubleAttribute("link_tempo", &application.timer.link_tempo);
|
||||
timerconfnode->QueryDoubleAttribute("link_quantum", &application.timer.link_quantum);
|
||||
timerconfnode->QueryBoolAttribute("link_start_stop_sync", &application.timer.link_start_stop_sync);
|
||||
timerconfnode->QueryUnsigned64Attribute("stopwatch_duration", &application.timer.stopwatch_duration);
|
||||
}
|
||||
|
||||
// bloc Controller
|
||||
XMLElement *controlconfnode = pRoot->FirstChildElement("Control");
|
||||
if (controlconfnode != nullptr) {
|
||||
controlconfnode->QueryIntAttribute("osc_port_receive", &application.control.osc_port_receive);
|
||||
controlconfnode->QueryIntAttribute("osc_port_send", &application.control.osc_port_send);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Settings::History::push(const string &filename)
|
||||
{
|
||||
if (filename.empty()) {
|
||||
front_is_valid = false;
|
||||
return;
|
||||
}
|
||||
filenames.remove(filename);
|
||||
filenames.push_front(filename);
|
||||
if (filenames.size() > MAX_RECENT_HISTORY)
|
||||
filenames.pop_back();
|
||||
front_is_valid = true;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
void Settings::History::remove(const std::string &filename)
|
||||
{
|
||||
if (filename.empty())
|
||||
return;
|
||||
if (filenames.front() == filename)
|
||||
front_is_valid = false;
|
||||
filenames.remove(filename);
|
||||
changed = true;
|
||||
}
|
||||
|
||||
void Settings::History::validate()
|
||||
{
|
||||
for (auto fit = filenames.begin(); fit != filenames.end();) {
|
||||
if ( SystemToolkit::file_exists( *fit ))
|
||||
++fit;
|
||||
else
|
||||
fit = filenames.erase(fit);
|
||||
}
|
||||
}
|
||||
|
||||
void Settings::Lock()
|
||||
{
|
||||
|
||||
std::string lockfile = SystemToolkit::full_filename(SystemToolkit::settings_path(), "lock");
|
||||
application.fresh_start = false;
|
||||
|
||||
FILE *file = fopen(lockfile.c_str(), "r");
|
||||
int l = 0;
|
||||
if (file) {
|
||||
if ( fscanf(file, "%d", &l) < 1)
|
||||
l = 0;
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
// not locked or file not existing
|
||||
if ( l < 1 ) {
|
||||
file = fopen(lockfile.c_str(), "w");
|
||||
if (file) {
|
||||
fprintf(file, "1");
|
||||
fclose(file);
|
||||
}
|
||||
application.fresh_start = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Settings::Unlock()
|
||||
{
|
||||
std::string lockfile = SystemToolkit::full_filename(SystemToolkit::settings_path(), "lock");
|
||||
FILE *file = fopen(lockfile.c_str(), "w");
|
||||
if (file) {
|
||||
fprintf(file, "0");
|
||||
fclose(file);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Settings::Check()
|
||||
{
|
||||
XMLDocument xmlDoc;
|
||||
XMLError eResult = xmlDoc.LoadFile(settingsFilename.c_str());
|
||||
if (XMLResultError(eResult)) {
|
||||
return;
|
||||
}
|
||||
xmlDoc.Print();
|
||||
}
|
||||
|
||||
287
Shader.cpp
@@ -1,287 +0,0 @@
|
||||
/*
|
||||
* This file is part of vimix - video live mixer
|
||||
*
|
||||
* **Copyright** (C) 2019-2022 Bruno Herbelin <bruno.herbelin@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 3 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 <fstream>
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
#include <chrono>
|
||||
#include <ctime>
|
||||
|
||||
#include <glad/glad.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
#define GLM_ENABLE_EXPERIMENTAL
|
||||
#include <glm/gtx/string_cast.hpp>
|
||||
|
||||
#include "Resource.h"
|
||||
#include "FrameBuffer.h"
|
||||
#include "Log.h"
|
||||
#include "Visitor.h"
|
||||
#include "BaseToolkit.h"
|
||||
#include "RenderingManager.h"
|
||||
|
||||
#include "Shader.h"
|
||||
|
||||
// Globals
|
||||
ShadingProgram *ShadingProgram::currentProgram_ = nullptr;
|
||||
ShadingProgram simpleShadingProgram("shaders/simple.vs", "shaders/simple.fs");
|
||||
|
||||
// Blending presets for matching with Shader::BlendModes:
|
||||
GLenum blending_equation[9] = { GL_FUNC_ADD, // normal
|
||||
GL_FUNC_ADD, // screen
|
||||
GL_FUNC_REVERSE_SUBTRACT, // subtract
|
||||
GL_FUNC_ADD, // multiply
|
||||
GL_FUNC_ADD, // soft light
|
||||
GL_FUNC_ADD, // hard light
|
||||
GL_FUNC_REVERSE_SUBTRACT, // soft subtract
|
||||
GL_MAX, // lighten only
|
||||
GL_FUNC_ADD};
|
||||
GLenum blending_source_function[9] = { GL_ONE, // normal
|
||||
GL_ONE, // screen
|
||||
GL_SRC_COLOR, // subtract (can be GL_ONE)
|
||||
GL_DST_COLOR, // multiply : src x dst color
|
||||
GL_DST_COLOR, // soft light : src x dst color
|
||||
GL_SRC_COLOR, // hard light : src x src color
|
||||
GL_DST_COLOR, // soft subtract
|
||||
GL_ONE, // lighten only
|
||||
GL_ONE};
|
||||
GLenum blending_destination_function[9] = {GL_ONE_MINUS_SRC_ALPHA,// normal
|
||||
GL_ONE, // screen
|
||||
GL_ONE, // subtract
|
||||
GL_ONE_MINUS_SRC_ALPHA, // multiply
|
||||
GL_ONE, // soft light
|
||||
GL_ONE, // hard light
|
||||
GL_ONE, // soft subtract
|
||||
GL_ONE, // lighten only
|
||||
GL_ZERO};
|
||||
|
||||
ShadingProgram::ShadingProgram(const std::string& vertex_file, const std::string& fragment_file) :
|
||||
vertex_id_(0), fragment_id_(0), id_(0), vertex_file_(vertex_file), fragment_file_(fragment_file)
|
||||
{
|
||||
}
|
||||
|
||||
void ShadingProgram::init()
|
||||
{
|
||||
vertex_code_ = Resource::getText(vertex_file_);
|
||||
fragment_code_ = Resource::getText(fragment_file_);
|
||||
compile();
|
||||
link();
|
||||
}
|
||||
|
||||
bool ShadingProgram::initialized()
|
||||
{
|
||||
return (id_ != 0);
|
||||
}
|
||||
|
||||
void ShadingProgram::compile()
|
||||
{
|
||||
const char* vcode = vertex_code_.c_str();
|
||||
vertex_id_ = glCreateShader(GL_VERTEX_SHADER);
|
||||
glShaderSource(vertex_id_, 1, &vcode, NULL);
|
||||
glCompileShader(vertex_id_);
|
||||
|
||||
const char* fcode = fragment_code_.c_str();
|
||||
fragment_id_ = glCreateShader(GL_FRAGMENT_SHADER);
|
||||
glShaderSource(fragment_id_, 1, &fcode, NULL);
|
||||
glCompileShader(fragment_id_);
|
||||
|
||||
checkCompileErr();
|
||||
}
|
||||
|
||||
void ShadingProgram::link()
|
||||
{
|
||||
id_ = glCreateProgram();
|
||||
glAttachShader(id_, vertex_id_);
|
||||
glAttachShader(id_, fragment_id_);
|
||||
glLinkProgram(id_);
|
||||
checkLinkingErr();
|
||||
glUseProgram(id_);
|
||||
glUniform1i(glGetUniformLocation(id_, "iChannel0"), 0);
|
||||
glUniform1i(glGetUniformLocation(id_, "iChannel1"), 1);
|
||||
glUseProgram(0);
|
||||
glDeleteShader(vertex_id_);
|
||||
glDeleteShader(fragment_id_);
|
||||
}
|
||||
|
||||
void ShadingProgram::use()
|
||||
{
|
||||
if (currentProgram_ == nullptr || currentProgram_ != this)
|
||||
{
|
||||
currentProgram_ = this;
|
||||
glUseProgram(id_);
|
||||
}
|
||||
}
|
||||
|
||||
void ShadingProgram::enduse()
|
||||
{
|
||||
glUseProgram(0);
|
||||
currentProgram_ = nullptr ;
|
||||
}
|
||||
|
||||
template<>
|
||||
void ShadingProgram::setUniform<int>(const std::string& name, int val) {
|
||||
glUniform1i(glGetUniformLocation(id_, name.c_str()), val);
|
||||
}
|
||||
|
||||
template<>
|
||||
void ShadingProgram::setUniform<bool>(const std::string& name, bool val) {
|
||||
glUniform1i(glGetUniformLocation(id_, name.c_str()), val);
|
||||
}
|
||||
|
||||
template<>
|
||||
void ShadingProgram::setUniform<float>(const std::string& name, float val) {
|
||||
glUniform1f(glGetUniformLocation(id_, name.c_str()), val);
|
||||
}
|
||||
|
||||
template<>
|
||||
void ShadingProgram::setUniform<float>(const std::string& name, float val1, float val2) {
|
||||
glUniform2f(glGetUniformLocation(id_, name.c_str()), val1, val2);
|
||||
}
|
||||
|
||||
template<>
|
||||
void ShadingProgram::setUniform<float>(const std::string& name, float val1, float val2, float val3) {
|
||||
glUniform3f(glGetUniformLocation(id_, name.c_str()), val1, val2, val3);
|
||||
}
|
||||
|
||||
template<>
|
||||
void ShadingProgram::setUniform<glm::vec2>(const std::string& name, glm::vec2 val) {
|
||||
glm::vec2 v(val);
|
||||
glUniform2fv(glGetUniformLocation(id_, name.c_str()), 1, glm::value_ptr(v));
|
||||
}
|
||||
|
||||
template<>
|
||||
void ShadingProgram::setUniform<glm::vec3>(const std::string& name, glm::vec3 val) {
|
||||
glm::vec3 v(val);
|
||||
glUniform3fv(glGetUniformLocation(id_, name.c_str()), 1, glm::value_ptr(v));
|
||||
}
|
||||
|
||||
template<>
|
||||
void ShadingProgram::setUniform<glm::vec4>(const std::string& name, glm::vec4 val) {
|
||||
glm::vec4 v(val);
|
||||
glUniform4fv(glGetUniformLocation(id_, name.c_str()), 1, glm::value_ptr(v));
|
||||
}
|
||||
|
||||
template<>
|
||||
void ShadingProgram::setUniform<glm::mat4>(const std::string& name, glm::mat4 val) {
|
||||
glm::mat4 m(val);
|
||||
glUniformMatrix4fv(glGetUniformLocation(id_, name.c_str()), 1, GL_FALSE, glm::value_ptr(m));
|
||||
}
|
||||
|
||||
|
||||
// template<>
|
||||
// void ShadingProgram::setUniform<float*>(const std::string& name, float* val) {
|
||||
// glUniformMatrix4fv(glGetUniformLocation(id_, name.c_str()), 1, GL_FALSE, val);
|
||||
// }
|
||||
|
||||
void ShadingProgram::checkCompileErr()
|
||||
{
|
||||
int success;
|
||||
char infoLog[1024];
|
||||
glGetShaderiv(vertex_id_, GL_COMPILE_STATUS, &success);
|
||||
if (!success) {
|
||||
glGetShaderInfoLog(vertex_id_, 1024, NULL, infoLog);
|
||||
Log::Warning("Error compiling Vertex ShadingProgram:\n%s", infoLog);
|
||||
}
|
||||
glGetShaderiv(fragment_id_, GL_COMPILE_STATUS, &success);
|
||||
if (!success) {
|
||||
glGetShaderInfoLog(fragment_id_, 1024, NULL, infoLog);
|
||||
Log::Warning("Error compiling Fragment ShadingProgram:\n%s", infoLog);
|
||||
}
|
||||
}
|
||||
|
||||
void ShadingProgram::checkLinkingErr()
|
||||
{
|
||||
int success;
|
||||
glGetProgramiv(id_, GL_LINK_STATUS, &success);
|
||||
if (!success) {
|
||||
char infoLog[1024];
|
||||
glGetProgramInfoLog(id_, 1024, NULL, infoLog);
|
||||
Log::Warning("Error linking ShadingProgram:\n%s", infoLog);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Shader::force_blending_opacity = false;
|
||||
|
||||
Shader::Shader() : blending(BLEND_OPACITY)
|
||||
{
|
||||
// create unique id
|
||||
id_ = BaseToolkit::uniqueId();
|
||||
|
||||
program_ = &simpleShadingProgram;
|
||||
Shader::reset();
|
||||
}
|
||||
|
||||
|
||||
void Shader::copy(Shader const& S)
|
||||
{
|
||||
color = S.color;
|
||||
blending = S.blending;
|
||||
iTransform = S.iTransform;
|
||||
}
|
||||
|
||||
void Shader::accept(Visitor& v) {
|
||||
v.visit(*this);
|
||||
}
|
||||
|
||||
void Shader::use()
|
||||
{
|
||||
// initialization on first use
|
||||
if (!program_->initialized())
|
||||
program_->init();
|
||||
|
||||
// Use program
|
||||
program_->use();
|
||||
|
||||
// set uniforms
|
||||
program_->setUniform("projection", projection);
|
||||
program_->setUniform("modelview", modelview);
|
||||
program_->setUniform("iTransform", iTransform);
|
||||
program_->setUniform("color", color);
|
||||
|
||||
glm::vec3 iResolution = glm::vec3( Rendering::manager().currentAttrib().viewport, 0.f);
|
||||
program_->setUniform("iResolution", iResolution);
|
||||
|
||||
// Blending Function
|
||||
if (force_blending_opacity) {
|
||||
glEnable(GL_BLEND);
|
||||
glBlendEquationSeparate(GL_FUNC_ADD, GL_FUNC_ADD);
|
||||
glBlendFuncSeparate(GL_ONE, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
else if ( blending < BLEND_NONE ) {
|
||||
glEnable(GL_BLEND);
|
||||
glBlendEquationSeparate(blending_equation[blending], GL_FUNC_ADD);
|
||||
glBlendFuncSeparate(blending_source_function[blending], blending_destination_function[blending], GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
else
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
|
||||
void Shader::reset()
|
||||
{
|
||||
projection = glm::identity<glm::mat4>();
|
||||
modelview = glm::identity<glm::mat4>();
|
||||
iTransform = glm::identity<glm::mat4>();
|
||||
color = glm::vec4(1.f, 1.f, 1.f, 1.f);
|
||||
blending = BLEND_OPACITY;
|
||||
}
|
||||
|
||||
|
||||
80
Shader.h
@@ -1,80 +0,0 @@
|
||||
#ifndef __SHADER_H_
|
||||
#define __SHADER_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
// Forward declare classes referenced
|
||||
class Visitor;
|
||||
class FrameBuffer;
|
||||
|
||||
class ShadingProgram
|
||||
{
|
||||
public:
|
||||
ShadingProgram(const std::string& vertex_file, const std::string& fragment_file);
|
||||
void init();
|
||||
bool initialized();
|
||||
void use();
|
||||
template<typename T> void setUniform(const std::string& name, T val);
|
||||
template<typename T> void setUniform(const std::string& name, T val1, T val2);
|
||||
template<typename T> void setUniform(const std::string& name, T val1, T val2, T val3);
|
||||
|
||||
static void enduse();
|
||||
|
||||
private:
|
||||
void checkCompileErr();
|
||||
void checkLinkingErr();
|
||||
void compile();
|
||||
void link();
|
||||
unsigned int vertex_id_, fragment_id_, id_;
|
||||
std::string vertex_code_;
|
||||
std::string fragment_code_;
|
||||
std::string vertex_file_;
|
||||
std::string fragment_file_;
|
||||
|
||||
static ShadingProgram *currentProgram_;
|
||||
};
|
||||
|
||||
class Shader
|
||||
{
|
||||
uint64_t id_;
|
||||
|
||||
public:
|
||||
Shader();
|
||||
virtual ~Shader() {}
|
||||
|
||||
// unique identifyer generated at instanciation
|
||||
inline uint64_t id () const { return id_; }
|
||||
|
||||
virtual void use();
|
||||
virtual void reset();
|
||||
virtual void accept(Visitor& v);
|
||||
void copy(Shader const& S);
|
||||
|
||||
glm::mat4 projection;
|
||||
glm::mat4 modelview;
|
||||
glm::mat4 iTransform;
|
||||
glm::vec4 color;
|
||||
|
||||
typedef enum {
|
||||
BLEND_OPACITY = 0,
|
||||
BLEND_SCREEN,
|
||||
BLEND_SUBTRACT,
|
||||
BLEND_MULTIPLY,
|
||||
BLEND_SOFT_LIGHT,
|
||||
BLEND_HARD_LIGHT,
|
||||
BLEND_SOFT_SUBTRACT,
|
||||
BLEND_LIGHTEN_ONLY,
|
||||
BLEND_NONE
|
||||
} BlendMode;
|
||||
BlendMode blending;
|
||||
|
||||
static bool force_blending_opacity;
|
||||
|
||||
protected:
|
||||
ShadingProgram *program_;
|
||||
};
|
||||
|
||||
|
||||
#endif /* __SHADER_H_ */
|
||||
@@ -1,299 +0,0 @@
|
||||
/*
|
||||
* This file is part of vimix - video live mixer
|
||||
*
|
||||
* **Copyright** (C) 2019-2022 Bruno Herbelin <bruno.herbelin@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 3 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 "defines.h"
|
||||
#include "Source.h"
|
||||
#include "Log.h"
|
||||
|
||||
#include "SourceCallback.h"
|
||||
|
||||
SourceCallback::SourceCallback(): active_(true), finished_(false), initialized_(false)
|
||||
{
|
||||
}
|
||||
|
||||
void ResetGeometry::update(Source *s, float)
|
||||
{
|
||||
s->group(View::GEOMETRY)->scale_ = glm::vec3(1.f);
|
||||
s->group(View::GEOMETRY)->rotation_.z = 0;
|
||||
s->group(View::GEOMETRY)->crop_ = glm::vec3(1.f);
|
||||
s->group(View::GEOMETRY)->translation_ = glm::vec3(0.f);
|
||||
s->touch();
|
||||
finished_ = true;
|
||||
}
|
||||
|
||||
SetAlpha::SetAlpha(float alpha) : SourceCallback(), alpha_(CLAMP(alpha, 0.f, 1.f))
|
||||
{
|
||||
pos_ = glm::vec2();
|
||||
step_ = glm::normalize(glm::vec2(1.f, 1.f)); // step in diagonal by default
|
||||
}
|
||||
|
||||
void SetAlpha::update(Source *s, float)
|
||||
{
|
||||
if (s && !s->locked()) {
|
||||
// set start position on first run or upon call of reset()
|
||||
if (!initialized_){
|
||||
// initial position
|
||||
pos_ = glm::vec2(s->group(View::MIXING)->translation_);
|
||||
// step in direction of source translation if possible
|
||||
if ( glm::length(pos_) > DELTA_ALPHA)
|
||||
step_ = glm::normalize(pos_);
|
||||
|
||||
initialized_ = true;
|
||||
}
|
||||
|
||||
// perform operation
|
||||
float delta = SourceCore::alphaFromCordinates(pos_.x, pos_.y) - alpha_;
|
||||
|
||||
// converge to reduce the difference of alpha using dichotomic algorithm
|
||||
if ( glm::abs(delta) > DELTA_ALPHA ){
|
||||
pos_ += step_ * (delta / 2.f);
|
||||
s->group(View::MIXING)->translation_ = glm::vec3(pos_, s->group(View::MIXING)->translation_.z);
|
||||
}
|
||||
// done
|
||||
else
|
||||
finished_ = true;
|
||||
}
|
||||
else
|
||||
finished_ = true;
|
||||
}
|
||||
|
||||
SetLock::SetLock(bool on) : SourceCallback(), lock_(on)
|
||||
{
|
||||
}
|
||||
|
||||
void SetLock::update(Source *s, float)
|
||||
{
|
||||
if (s)
|
||||
s->setLocked(lock_);
|
||||
|
||||
finished_ = true;
|
||||
}
|
||||
|
||||
Loom::Loom(float da, float duration) : SourceCallback(), speed_(da),
|
||||
duration_(duration), progress_(0.f)
|
||||
{
|
||||
pos_ = glm::vec2();
|
||||
step_ = glm::normalize(glm::vec2(1.f, 1.f)); // step in diagonal by default
|
||||
}
|
||||
|
||||
void Loom::update(Source *s, float dt)
|
||||
{
|
||||
if (s && !s->locked()) {
|
||||
// reset on first run or upon call of reset()
|
||||
if (!initialized_){
|
||||
// start animation
|
||||
progress_ = 0.f;
|
||||
// initial position
|
||||
pos_ = glm::vec2(s->group(View::MIXING)->translation_);
|
||||
// step in direction of source translation if possible
|
||||
if ( glm::length(pos_) > DELTA_ALPHA)
|
||||
step_ = glm::normalize(pos_);
|
||||
|
||||
initialized_ = true;
|
||||
}
|
||||
|
||||
// time passed
|
||||
progress_ += dt;
|
||||
|
||||
// move target by speed vector (in the direction of step_, amplitude of speed * time (in second))
|
||||
pos_ += step_ * ( speed_ * dt * 0.001f);
|
||||
|
||||
// apply alpha if valid in range [0 1]
|
||||
float alpha = SourceCore::alphaFromCordinates(pos_.x, pos_.y);
|
||||
if ( alpha > DELTA_ALPHA && alpha < 1.0 - DELTA_ALPHA )
|
||||
s->group(View::MIXING)->translation_ = glm::vec3(pos_, s->group(View::MIXING)->translation_.z);
|
||||
|
||||
// time-out
|
||||
if ( progress_ > duration_ ) {
|
||||
// done
|
||||
finished_ = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
finished_ = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
SetDepth::SetDepth(float target, float duration) : SourceCallback(),
|
||||
duration_(duration), progress_(0.f), start_(0.f), target_(CLAMP(target, MIN_DEPTH, MAX_DEPTH))
|
||||
{
|
||||
}
|
||||
|
||||
void SetDepth::update(Source *s, float dt)
|
||||
{
|
||||
if (s && !s->locked()) {
|
||||
// set start position on first run or upon call of reset()
|
||||
if (!initialized_){
|
||||
start_ = s->group(View::LAYER)->translation_.z;
|
||||
progress_ = 0.f;
|
||||
initialized_ = true;
|
||||
}
|
||||
|
||||
// time passed
|
||||
progress_ += dt;
|
||||
|
||||
// perform movement
|
||||
if ( ABS(duration_) > 0.f)
|
||||
s->group(View::LAYER)->translation_.z = start_ + (progress_/duration_) * (target_ - start_);
|
||||
|
||||
// time-out
|
||||
if ( progress_ > duration_ ) {
|
||||
// apply depth to target
|
||||
s->group(View::LAYER)->translation_.z = target_;
|
||||
// ensure reordering of view
|
||||
++View::need_deep_update_;
|
||||
// done
|
||||
finished_ = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
finished_ = true;
|
||||
}
|
||||
|
||||
|
||||
SetPlay::SetPlay(bool on) : SourceCallback(), play_(on)
|
||||
{
|
||||
}
|
||||
|
||||
void SetPlay::update(Source *s, float)
|
||||
{
|
||||
if (s && s->playing() != play_) {
|
||||
// call play function
|
||||
s->play(play_);
|
||||
}
|
||||
|
||||
finished_ = true;
|
||||
}
|
||||
|
||||
RePlay::RePlay() : SourceCallback()
|
||||
{
|
||||
}
|
||||
|
||||
void RePlay::update(Source *s, float)
|
||||
{
|
||||
if (s) {
|
||||
// call replay function
|
||||
s->replay();
|
||||
}
|
||||
|
||||
finished_ = true;
|
||||
}
|
||||
|
||||
|
||||
Grab::Grab(float dx, float dy, float duration) : SourceCallback(), speed_(glm::vec2(dx,dy)),
|
||||
duration_(duration), progress_(0.f)
|
||||
{
|
||||
}
|
||||
|
||||
void Grab::update(Source *s, float dt)
|
||||
{
|
||||
if (s && !s->locked()) {
|
||||
// reset on first run or upon call of reset()
|
||||
if (!initialized_){
|
||||
// start animation
|
||||
progress_ = 0.f;
|
||||
// initial position
|
||||
start_ = glm::vec2(s->group(View::GEOMETRY)->translation_);
|
||||
initialized_ = true;
|
||||
}
|
||||
|
||||
// time passed
|
||||
progress_ += dt;
|
||||
|
||||
// move target by speed vector * time (in second)
|
||||
glm::vec2 pos = start_ + speed_ * ( dt * 0.001f);
|
||||
s->group(View::GEOMETRY)->translation_ = glm::vec3(pos, s->group(View::GEOMETRY)->translation_.z);
|
||||
|
||||
// time-out
|
||||
if ( progress_ > duration_ ) {
|
||||
// done
|
||||
finished_ = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
finished_ = true;
|
||||
}
|
||||
|
||||
Resize::Resize(float dx, float dy, float duration) : SourceCallback(), speed_(glm::vec2(dx,dy)),
|
||||
duration_(duration), progress_(0.f)
|
||||
{
|
||||
}
|
||||
|
||||
void Resize::update(Source *s, float dt)
|
||||
{
|
||||
if (s && !s->locked()) {
|
||||
// reset on first run or upon call of reset()
|
||||
if (!initialized_){
|
||||
// start animation
|
||||
progress_ = 0.f;
|
||||
// initial position
|
||||
start_ = glm::vec2(s->group(View::GEOMETRY)->scale_);
|
||||
initialized_ = true;
|
||||
}
|
||||
|
||||
// time passed
|
||||
progress_ += dt;
|
||||
|
||||
// move target by speed vector * time (in second)
|
||||
glm::vec2 scale = start_ + speed_ * ( dt * 0.001f);
|
||||
s->group(View::GEOMETRY)->scale_ = glm::vec3(scale, s->group(View::GEOMETRY)->scale_.z);
|
||||
|
||||
// time-out
|
||||
if ( progress_ > duration_ ) {
|
||||
// done
|
||||
finished_ = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
finished_ = true;
|
||||
}
|
||||
|
||||
Turn::Turn(float da, float duration) : SourceCallback(), speed_(da),
|
||||
duration_(duration), progress_(0.f)
|
||||
{
|
||||
}
|
||||
|
||||
void Turn::update(Source *s, float dt)
|
||||
{
|
||||
if (s && !s->locked()) {
|
||||
// reset on first run or upon call of reset()
|
||||
if (!initialized_){
|
||||
// start animation
|
||||
progress_ = 0.f;
|
||||
// initial position
|
||||
start_ = s->group(View::GEOMETRY)->rotation_.z;
|
||||
initialized_ = true;
|
||||
}
|
||||
|
||||
// calculate amplitude of movement
|
||||
progress_ += dt;
|
||||
|
||||
// perform movement
|
||||
s->group(View::GEOMETRY)->rotation_.z = start_ + speed_ * ( dt * -0.001f / M_PI);
|
||||
|
||||
// timeout
|
||||
if ( progress_ > duration_ ) {
|
||||
// done
|
||||
finished_ = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
finished_ = true;
|
||||
}
|
||||
157
SourceCallback.h
@@ -1,157 +0,0 @@
|
||||
#ifndef SOURCECALLBACK_H
|
||||
#define SOURCECALLBACK_H
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
class Source;
|
||||
|
||||
class SourceCallback
|
||||
{
|
||||
public:
|
||||
|
||||
typedef enum {
|
||||
CALLBACK_GENERIC = 0,
|
||||
CALLBACK_ALPHA,
|
||||
CALLBACK_LOCK,
|
||||
CALLBACK_LOOM,
|
||||
CALLBACK_DEPTH,
|
||||
CALLBACK_PLAY,
|
||||
CALLBACK_REPLAY,
|
||||
CALLBACK_GRAB,
|
||||
CALLBACK_RESIZE,
|
||||
CALLBACK_TURN
|
||||
} CallbackType;
|
||||
|
||||
SourceCallback();
|
||||
virtual ~SourceCallback() {}
|
||||
|
||||
virtual void update(Source *, float) = 0;
|
||||
virtual CallbackType type () { return CALLBACK_GENERIC; }
|
||||
|
||||
inline bool finished() const { return finished_; }
|
||||
inline bool active() const { return active_; }
|
||||
inline void reset() { initialized_ = false; }
|
||||
|
||||
protected:
|
||||
bool active_;
|
||||
bool finished_;
|
||||
bool initialized_;
|
||||
};
|
||||
|
||||
class ResetGeometry : public SourceCallback
|
||||
{
|
||||
|
||||
public:
|
||||
ResetGeometry() : SourceCallback() {}
|
||||
void update(Source *s, float) override;
|
||||
};
|
||||
|
||||
class SetAlpha : public SourceCallback
|
||||
{
|
||||
float alpha_;
|
||||
glm::vec2 pos_;
|
||||
glm::vec2 step_;
|
||||
|
||||
public:
|
||||
SetAlpha(float alpha);
|
||||
void update(Source *s, float) override;
|
||||
CallbackType type () override { return CALLBACK_ALPHA; }
|
||||
};
|
||||
|
||||
class Loom : public SourceCallback
|
||||
{
|
||||
float speed_;
|
||||
glm::vec2 pos_;
|
||||
glm::vec2 step_;
|
||||
float duration_;
|
||||
float progress_;
|
||||
|
||||
public:
|
||||
Loom(float da, float duration = 0.f);
|
||||
void update(Source *s, float) override;
|
||||
CallbackType type () override { return CALLBACK_LOOM; }
|
||||
};
|
||||
|
||||
class SetLock : public SourceCallback
|
||||
{
|
||||
bool lock_;
|
||||
|
||||
public:
|
||||
SetLock(bool on);
|
||||
void update(Source *s, float) override;
|
||||
CallbackType type () override { return CALLBACK_LOCK; }
|
||||
};
|
||||
|
||||
class SetDepth : public SourceCallback
|
||||
{
|
||||
float duration_;
|
||||
float progress_;
|
||||
float start_;
|
||||
float target_;
|
||||
|
||||
public:
|
||||
SetDepth(float depth, float duration = 0.f);
|
||||
void update(Source *s, float dt) override;
|
||||
CallbackType type () override { return CALLBACK_DEPTH; }
|
||||
};
|
||||
|
||||
class SetPlay : public SourceCallback
|
||||
{
|
||||
bool play_;
|
||||
|
||||
public:
|
||||
SetPlay(bool on);
|
||||
void update(Source *s, float) override;
|
||||
CallbackType type () override { return CALLBACK_PLAY; }
|
||||
};
|
||||
|
||||
class RePlay : public SourceCallback
|
||||
{
|
||||
|
||||
public:
|
||||
RePlay();
|
||||
void update(Source *s, float) override;
|
||||
CallbackType type () override { return CALLBACK_REPLAY; }
|
||||
};
|
||||
|
||||
class Grab : public SourceCallback
|
||||
{
|
||||
glm::vec2 speed_;
|
||||
glm::vec2 start_;
|
||||
float duration_;
|
||||
float progress_;
|
||||
|
||||
public:
|
||||
Grab(float dx, float dy, float duration = 0.f);
|
||||
void update(Source *s, float) override;
|
||||
CallbackType type () override { return CALLBACK_GRAB; }
|
||||
};
|
||||
|
||||
class Resize : public SourceCallback
|
||||
{
|
||||
glm::vec2 speed_;
|
||||
glm::vec2 start_;
|
||||
float duration_;
|
||||
float progress_;
|
||||
|
||||
public:
|
||||
Resize(float dx, float dy, float duration = 0.f);
|
||||
void update(Source *s, float) override;
|
||||
CallbackType type () override { return CALLBACK_RESIZE; }
|
||||
};
|
||||
|
||||
class Turn : public SourceCallback
|
||||
{
|
||||
float speed_;
|
||||
float start_;
|
||||
float duration_;
|
||||
float progress_;
|
||||
|
||||
public:
|
||||
Turn(float da, float duration = 0.f);
|
||||
void update(Source *s, float) override;
|
||||
CallbackType type () override { return CALLBACK_TURN; }
|
||||
};
|
||||
|
||||
|
||||
#endif // SOURCECALLBACK_H
|
||||
@@ -1,359 +0,0 @@
|
||||
#ifndef __UI_MANAGER_H_
|
||||
#define __UI_MANAGER_H_
|
||||
|
||||
#include <string>
|
||||
#include <list>
|
||||
|
||||
#define NAV_COUNT 68
|
||||
#define NAV_MAX 64
|
||||
#define NAV_NEW 65
|
||||
#define NAV_MENU 66
|
||||
#define NAV_TRANS 67
|
||||
|
||||
#ifdef APPLE
|
||||
#define CTRL_MOD "Cmd+"
|
||||
#else
|
||||
#define CTRL_MOD "Ctrl+"
|
||||
#endif
|
||||
|
||||
#define MENU_NEW_FILE ICON_FA_FILE " New"
|
||||
#define SHORTCUT_NEW_FILE CTRL_MOD "W"
|
||||
#define MENU_OPEN_FILE ICON_FA_FILE_UPLOAD " Open"
|
||||
#define SHORTCUT_OPEN_FILE CTRL_MOD "O"
|
||||
#define MENU_REOPEN_FILE ICON_FA_FILE_UPLOAD " Re-open"
|
||||
#define SHORTCUT_REOPEN_FILE CTRL_MOD "Shift+O"
|
||||
#define MENU_SAVE_FILE ICON_FA_FILE_DOWNLOAD " Save"
|
||||
#define SHORTCUT_SAVE_FILE CTRL_MOD "S"
|
||||
#define MENU_SAVEAS_FILE ICON_FA_FILE_DOWNLOAD " Save as"
|
||||
#define SHORTCUT_SAVEAS_FILE CTRL_MOD "Shift+S"
|
||||
#define SHORTCUT_HELP CTRL_MOD "H"
|
||||
#define SHORTCUT_LOGS CTRL_MOD "L"
|
||||
#define MENU_QUIT ICON_FA_POWER_OFF " Quit"
|
||||
#define SHORTCUT_QUIT CTRL_MOD "Q"
|
||||
#define MENU_CUT ICON_FA_CUT " Cut"
|
||||
#define SHORTCUT_CUT CTRL_MOD "X"
|
||||
#define MENU_COPY ICON_FA_COPY " Copy"
|
||||
#define SHORTCUT_COPY CTRL_MOD "C"
|
||||
#define MENU_DELETE ICON_FA_ERASER " Delete"
|
||||
#define SHORTCUT_DELETE "Del"
|
||||
#define MENU_PASTE ICON_FA_PASTE " Paste"
|
||||
#define SHORTCUT_PASTE CTRL_MOD "V"
|
||||
#define MENU_SELECTALL ICON_FA_TH_LIST " Select all"
|
||||
#define SHORTCUT_SELECTALL CTRL_MOD "A"
|
||||
#define MENU_UNDO ICON_FA_UNDO " Undo"
|
||||
#define SHORTCUT_UNDO CTRL_MOD "Z"
|
||||
#define MENU_REDO ICON_FA_REDO " Redo"
|
||||
#define SHORTCUT_REDO CTRL_MOD "Shift+Z"
|
||||
#define MENU_RECORD ICON_FA_CIRCLE " Record"
|
||||
#define SHORTCUT_RECORD CTRL_MOD "R"
|
||||
#define MENU_RECORDCONT ICON_FA_STOP_CIRCLE " Save & continue"
|
||||
#define SHORTCUT_RECORDCONT CTRL_MOD "Alt+R"
|
||||
#define MENU_CAPTUREFRAME ICON_FA_CAMERA_RETRO " Capture frame"
|
||||
#define SHORTCUT_CAPTUREFRAME CTRL_MOD "Shitf+R"
|
||||
#define MENU_OUTPUTDISABLE ICON_FA_EYE_SLASH " Disable"
|
||||
#define SHORTCUT_OUTPUTDISABLE "END"
|
||||
#define MENU_OUTPUTFULLSCREEN ICON_FA_EXPAND_ALT " Fullscreen window"
|
||||
#define SHORTCUT_OUTPUTFULLSCREEN CTRL_MOD "F"
|
||||
#define MENU_PINWINDOW ICON_FA_MAP_PIN " Pin window to view"
|
||||
#define MENU_CLOSE ICON_FA_TIMES " Close"
|
||||
|
||||
#define TOOLTIP_NOTE " New note "
|
||||
#define SHORTCUT_NOTE CTRL_MOD "Shift+N"
|
||||
#define TOOLTIP_PLAYER " Player "
|
||||
#define SHORTCUT_PLAYER CTRL_MOD "P"
|
||||
#define TOOLTIP_OUTPUT " Output "
|
||||
#define SHORTCUT_OUTPUT CTRL_MOD "D"
|
||||
#define TOOLTIP_TIMER " Timer "
|
||||
#define SHORTCUT_TIMER CTRL_MOD "T"
|
||||
#define TOOLTIP_FULLSCREEN " Fullscreen "
|
||||
#define SHORTCUT_FULLSCREEN CTRL_MOD "Shift+F"
|
||||
|
||||
#include "SourceList.h"
|
||||
#include "InfoVisitor.h"
|
||||
#include "DialogToolkit.h"
|
||||
#include "SessionParser.h"
|
||||
|
||||
|
||||
struct ImVec2;
|
||||
class MediaPlayer;
|
||||
class FrameBufferImage;
|
||||
class FrameGrabber;
|
||||
class VideoRecorder;
|
||||
|
||||
class SourcePreview {
|
||||
|
||||
Source *source_;
|
||||
std::string label_;
|
||||
bool reset_;
|
||||
|
||||
public:
|
||||
SourcePreview();
|
||||
|
||||
void setSource(Source *s = nullptr, const std::string &label = "");
|
||||
Source *getSource();
|
||||
|
||||
void Render(float width);
|
||||
bool ready() const;
|
||||
inline bool filled() const { return source_ != nullptr; }
|
||||
};
|
||||
|
||||
class Thumbnail
|
||||
{
|
||||
float aspect_ratio_;
|
||||
uint texture_;
|
||||
|
||||
public:
|
||||
Thumbnail();
|
||||
~Thumbnail();
|
||||
|
||||
void reset();
|
||||
void fill (const FrameBufferImage *image);
|
||||
bool filled();
|
||||
void Render(float width);
|
||||
};
|
||||
|
||||
class Navigator
|
||||
{
|
||||
// geometry left bar & pannel
|
||||
float width_;
|
||||
float height_;
|
||||
float pannel_width_;
|
||||
float padding_width_;
|
||||
|
||||
// behavior pannel
|
||||
bool show_config_;
|
||||
bool pannel_visible_;
|
||||
bool view_pannel_visible;
|
||||
bool selected_button[NAV_COUNT];
|
||||
int pattern_type;
|
||||
bool custom_pipeline;
|
||||
void clearButtonSelection();
|
||||
void applyButtonSelection(int index);
|
||||
|
||||
// side pannels
|
||||
void RenderSourcePannel(Source *s);
|
||||
void RenderMainPannel();
|
||||
void RenderMainPannelVimix();
|
||||
void RenderMainPannelSettings();
|
||||
void RenderTransitionPannel();
|
||||
void RenderNewPannel();
|
||||
void RenderViewPannel(ImVec2 draw_pos, ImVec2 draw_size);
|
||||
|
||||
public:
|
||||
|
||||
typedef enum {
|
||||
SOURCE_FILE = 0,
|
||||
SOURCE_SEQUENCE,
|
||||
SOURCE_CONNECTED,
|
||||
SOURCE_GENERATED,
|
||||
SOURCE_INTERNAL,
|
||||
SOURCE_TYPES
|
||||
} NewSourceType;
|
||||
|
||||
Navigator();
|
||||
void Render();
|
||||
|
||||
bool pannelVisible() { return pannel_visible_; }
|
||||
void hidePannel();
|
||||
void showPannelSource(int index);
|
||||
void togglePannelMenu();
|
||||
void togglePannelNew();
|
||||
void showConfig();
|
||||
|
||||
typedef enum {
|
||||
MEDIA_RECENT = 0,
|
||||
MEDIA_RECORDING,
|
||||
MEDIA_FOLDER
|
||||
} MediaCreateMode;
|
||||
void setNewMedia(MediaCreateMode mode, std::string path = std::string());
|
||||
|
||||
|
||||
private:
|
||||
// for new source panel
|
||||
SourcePreview new_source_preview_;
|
||||
std::list<std::string> sourceSequenceFiles;
|
||||
std::list<std::string> sourceMediaFiles;
|
||||
std::string sourceMediaFileCurrent;
|
||||
MediaCreateMode new_media_mode;
|
||||
bool new_media_mode_changed;
|
||||
};
|
||||
|
||||
class ToolBox
|
||||
{
|
||||
bool show_demo_window;
|
||||
bool show_icons_window;
|
||||
bool show_sandbox;
|
||||
|
||||
public:
|
||||
ToolBox();
|
||||
|
||||
void Render();
|
||||
};
|
||||
|
||||
class HelperToolbox
|
||||
{
|
||||
SessionParser parser_;
|
||||
|
||||
public:
|
||||
HelperToolbox();
|
||||
|
||||
void Render();
|
||||
|
||||
};
|
||||
|
||||
class SourceController
|
||||
{
|
||||
bool focused_;
|
||||
float min_width_;
|
||||
float h_space_;
|
||||
float v_space_;
|
||||
float scrollbar_;
|
||||
float timeline_height_;
|
||||
float mediaplayer_height_;
|
||||
float buttons_width_;
|
||||
float buttons_height_;
|
||||
|
||||
bool play_toggle_request_, replay_request_;
|
||||
bool pending_;
|
||||
std::string active_label_;
|
||||
int active_selection_;
|
||||
InfoVisitor info_;
|
||||
SourceList selection_;
|
||||
|
||||
// re-usable ui parts
|
||||
void DrawButtonBar(ImVec2 bottom, float width);
|
||||
const char *SourcePlayIcon(Source *s);
|
||||
bool SourceButton(Source *s, ImVec2 framesize);
|
||||
|
||||
// Render the sources dynamically selected
|
||||
void RenderSelectedSources();
|
||||
|
||||
// Render a stored selection
|
||||
bool selection_context_menu_;
|
||||
MediaPlayer *selection_mediaplayer_;
|
||||
double selection_target_slower_;
|
||||
double selection_target_faster_;
|
||||
void RenderSelectionContextMenu();
|
||||
void RenderSelection(size_t i);
|
||||
|
||||
// Render a single source
|
||||
void RenderSingleSource(Source *s);
|
||||
|
||||
// Render a single media player
|
||||
MediaPlayer *mediaplayer_active_;
|
||||
bool mediaplayer_edit_fading_;
|
||||
bool mediaplayer_mode_;
|
||||
bool mediaplayer_slider_pressed_;
|
||||
float mediaplayer_timeline_zoom_;
|
||||
void RenderMediaPlayer(MediaPlayer *mp);
|
||||
|
||||
public:
|
||||
SourceController();
|
||||
|
||||
inline void Play() { play_toggle_request_ = true; }
|
||||
inline void Replay() { replay_request_= true; }
|
||||
void Update();
|
||||
|
||||
void resetActiveSelection();
|
||||
void Render();
|
||||
void setVisible(bool on);
|
||||
bool Visible() const;
|
||||
inline bool Foccused() const { return focused_; }
|
||||
};
|
||||
|
||||
|
||||
class UserInterface
|
||||
{
|
||||
friend class Navigator;
|
||||
Navigator navigator;
|
||||
ToolBox toolbox;
|
||||
SourceController sourcecontrol;
|
||||
HelperToolbox sessiontoolbox;
|
||||
|
||||
uint64_t start_time;
|
||||
bool ctrl_modifier_active;
|
||||
bool alt_modifier_active;
|
||||
bool shift_modifier_active;
|
||||
bool show_vimix_about;
|
||||
bool show_imgui_about;
|
||||
bool show_gst_about;
|
||||
bool show_opengl_about;
|
||||
int show_view_navigator;
|
||||
int target_view_navigator;
|
||||
unsigned int screenshot_step;
|
||||
|
||||
// frame grabbers
|
||||
VideoRecorder *video_recorder_;
|
||||
|
||||
#if defined(LINUX)
|
||||
FrameGrabber *webcam_emulator_;
|
||||
#endif
|
||||
|
||||
// Dialogs
|
||||
DialogToolkit::OpenSessionDialog *sessionopendialog;
|
||||
DialogToolkit::OpenSessionDialog *sessionimportdialog;
|
||||
DialogToolkit::SaveSessionDialog *sessionsavedialog;
|
||||
|
||||
// Private Constructor
|
||||
UserInterface();
|
||||
UserInterface(UserInterface const& copy) = delete;
|
||||
UserInterface& operator=(UserInterface const& copy) = delete;
|
||||
|
||||
public:
|
||||
|
||||
static UserInterface& manager()
|
||||
{
|
||||
// The only instance
|
||||
static UserInterface _instance;
|
||||
return _instance;
|
||||
}
|
||||
|
||||
// pre-loop initialization
|
||||
bool Init();
|
||||
// loop update start new frame
|
||||
void NewFrame();
|
||||
// loop update rendering
|
||||
void Render();
|
||||
// Post-loop termination
|
||||
void Terminate();
|
||||
// Runtime
|
||||
uint64_t Runtime() const;
|
||||
|
||||
// status querries
|
||||
inline bool ctrlModifier() const { return ctrl_modifier_active; }
|
||||
inline bool altModifier() const { return alt_modifier_active; }
|
||||
inline bool shiftModifier() const { return shift_modifier_active; }
|
||||
|
||||
void showPannel(int id = 0);
|
||||
void showSourceEditor(Source *s);
|
||||
|
||||
// TODO implement the shader editor
|
||||
std::string currentTextEdit;
|
||||
void fillShaderEditor(const std::string &text);
|
||||
|
||||
void StartScreenshot();
|
||||
inline bool isRecording() const { return video_recorder_ != nullptr; }
|
||||
|
||||
protected:
|
||||
|
||||
void showMenuFile();
|
||||
void showMenuEdit();
|
||||
bool saveOrSaveAs(bool force_versioning = false);
|
||||
void selectSaveFilename();
|
||||
void selectOpenFilename();
|
||||
|
||||
void RenderMetrics (bool* p_open, int* p_corner, int *p_mode);
|
||||
void RenderPreview();
|
||||
void RenderTimer();
|
||||
void RenderShaderEditor();
|
||||
int RenderViewNavigator(int* shift);
|
||||
void RenderAbout(bool* p_open);
|
||||
void RenderNotes();
|
||||
|
||||
void handleKeyboard();
|
||||
void handleMouse();
|
||||
void handleScreenshot();
|
||||
};
|
||||
|
||||
#endif /* #define __UI_MANAGER_H_ */
|
||||
|
||||
88
Visitor.h
@@ -1,88 +0,0 @@
|
||||
#ifndef VISITOR_H
|
||||
#define VISITOR_H
|
||||
|
||||
#include <string>
|
||||
|
||||
// Forward declare different kind of Node
|
||||
class Node;
|
||||
class Group;
|
||||
class Switch;
|
||||
class Primitive;
|
||||
class Scene;
|
||||
class Surface;
|
||||
class ImageSurface;
|
||||
class FrameBufferSurface;
|
||||
class LineStrip;
|
||||
class LineSquare;
|
||||
class LineCircle;
|
||||
class Mesh;
|
||||
class Frame;
|
||||
class Handles;
|
||||
class Symbol;
|
||||
class Disk;
|
||||
class Stream;
|
||||
class MediaPlayer;
|
||||
class Shader;
|
||||
class ImageShader;
|
||||
class MaskShader;
|
||||
class ImageProcessingShader;
|
||||
class Source;
|
||||
class MediaSource;
|
||||
class PatternSource;
|
||||
class DeviceSource;
|
||||
class GenericStreamSource;
|
||||
class SessionFileSource;
|
||||
class SessionGroupSource;
|
||||
class RenderSource;
|
||||
class CloneSource;
|
||||
class NetworkSource;
|
||||
class MixingGroup;
|
||||
class MultiFileSource;
|
||||
|
||||
// Declares the interface for the visitors
|
||||
class Visitor {
|
||||
|
||||
public:
|
||||
// Need to declare overloads for basic kind of Nodes to visit
|
||||
virtual void visit (Scene&) = 0;
|
||||
virtual void visit (Node&) = 0;
|
||||
virtual void visit (Primitive&) = 0;
|
||||
virtual void visit (Group&) = 0;
|
||||
virtual void visit (Switch&) = 0;
|
||||
|
||||
// not mandatory for all others
|
||||
virtual void visit (Surface&) {}
|
||||
virtual void visit (ImageSurface&) {}
|
||||
virtual void visit (FrameBufferSurface&) {}
|
||||
virtual void visit (LineStrip&) {}
|
||||
virtual void visit (LineSquare&) {}
|
||||
virtual void visit (Mesh&) {}
|
||||
virtual void visit (Frame&) {}
|
||||
virtual void visit (Handles&) {}
|
||||
virtual void visit (Symbol&) {}
|
||||
virtual void visit (Disk&) {}
|
||||
virtual void visit (Shader&) {}
|
||||
virtual void visit (ImageShader&) {}
|
||||
virtual void visit (MaskShader&) {}
|
||||
virtual void visit (ImageProcessingShader&) {}
|
||||
|
||||
// utility
|
||||
virtual void visit (Stream&) {}
|
||||
virtual void visit (MediaPlayer&) {}
|
||||
virtual void visit (MixingGroup&) {}
|
||||
virtual void visit (Source&) {}
|
||||
virtual void visit (MediaSource&) {}
|
||||
virtual void visit (NetworkSource&) {}
|
||||
virtual void visit (GenericStreamSource&) {}
|
||||
virtual void visit (DeviceSource&) {}
|
||||
virtual void visit (PatternSource&) {}
|
||||
virtual void visit (SessionFileSource&) {}
|
||||
virtual void visit (SessionGroupSource&) {}
|
||||
virtual void visit (RenderSource&) {}
|
||||
virtual void visit (CloneSource&) {}
|
||||
virtual void visit (MultiFileSource&) {}
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // VISITOR_H
|
||||
@@ -34,7 +34,7 @@ endif()
|
||||
|
||||
set(_version 2.0.0)
|
||||
|
||||
cmake_minimum_required(VERSION 3.3)
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
include(CMakeParseArguments)
|
||||
|
||||
if(COMMAND cmrc_add_resource_library)
|
||||
@@ -77,6 +77,10 @@ set(hpp_content [==[
|
||||
#include <system_error>
|
||||
#include <type_traits>
|
||||
|
||||
#if !(defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) || defined(CMRC_NO_EXCEPTIONS))
|
||||
#define CMRC_NO_EXCEPTIONS 1
|
||||
#endif
|
||||
|
||||
namespace cmrc { namespace detail { struct dummy; } }
|
||||
|
||||
#define CMRC_DECLARE(libid) \
|
||||
@@ -101,7 +105,7 @@ public:
|
||||
iterator cbegin() const noexcept { return _begin; }
|
||||
iterator end() const noexcept { return _end; }
|
||||
iterator cend() const noexcept { return _end; }
|
||||
std::size_t size() const { return std::distance(begin(), end()); }
|
||||
std::size_t size() const { return static_cast<std::size_t>(std::distance(begin(), end())); }
|
||||
|
||||
file() = default;
|
||||
file(iterator beg, iterator end) noexcept : _begin(beg), _end(end) {}
|
||||
@@ -243,16 +247,16 @@ public:
|
||||
return !(*this == rhs);
|
||||
}
|
||||
|
||||
iterator operator++() noexcept {
|
||||
iterator& operator++() noexcept {
|
||||
++_base_iter;
|
||||
return *this;
|
||||
}
|
||||
|
||||
iterator operator++(int) noexcept {
|
||||
auto cp = *this;
|
||||
++_base_iter;
|
||||
return cp;
|
||||
}
|
||||
|
||||
iterator& operator++(int) noexcept {
|
||||
++_base_iter;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
using const_iterator = iterator;
|
||||
@@ -275,7 +279,7 @@ inline std::string normalize_path(std::string path) {
|
||||
}
|
||||
auto off = path.npos;
|
||||
while ((off = path.find("//")) != path.npos) {
|
||||
path.erase(path.begin() + off);
|
||||
path.erase(path.begin() + static_cast<std::string::difference_type>(off));
|
||||
}
|
||||
return path;
|
||||
}
|
||||
@@ -339,7 +343,12 @@ public:
|
||||
file open(const std::string& path) const {
|
||||
auto entry_ptr = _get(path);
|
||||
if (!entry_ptr || !entry_ptr->is_file()) {
|
||||
#ifdef CMRC_NO_EXCEPTIONS
|
||||
fprintf(stderr, "Error no such file or directory: %s\n", path.c_str());
|
||||
abort();
|
||||
#else
|
||||
throw std::system_error(make_error_code(std::errc::no_such_file_or_directory), path);
|
||||
#endif
|
||||
}
|
||||
auto& dat = entry_ptr->as_file();
|
||||
return file{dat.begin_ptr, dat.end_ptr};
|
||||
@@ -362,10 +371,20 @@ public:
|
||||
directory_iterator iterate_directory(const std::string& path) const {
|
||||
auto entry_ptr = _get(path);
|
||||
if (!entry_ptr) {
|
||||
#ifdef CMRC_NO_EXCEPTIONS
|
||||
fprintf(stderr, "Error no such file or directory: %s\n", path.c_str());
|
||||
abort();
|
||||
#else
|
||||
throw std::system_error(make_error_code(std::errc::no_such_file_or_directory), path);
|
||||
#endif
|
||||
}
|
||||
if (!entry_ptr->is_directory()) {
|
||||
#ifdef CMRC_NO_EXCEPTIONS
|
||||
fprintf(stderr, "Error not a directory: %s\n", path.c_str());
|
||||
abort();
|
||||
#else
|
||||
throw std::system_error(make_error_code(std::errc::not_a_directory), path);
|
||||
#endif
|
||||
}
|
||||
return entry_ptr->as_directory().begin();
|
||||
}
|
||||
@@ -387,14 +406,14 @@ endif()
|
||||
file(GENERATE OUTPUT "${cmrc_hpp}" CONTENT "${hpp_content}" CONDITION ${_generate})
|
||||
|
||||
add_library(cmrc-base INTERFACE)
|
||||
target_include_directories(cmrc-base INTERFACE "${CMRC_INCLUDE_DIR}")
|
||||
target_include_directories(cmrc-base INTERFACE $<BUILD_INTERFACE:${CMRC_INCLUDE_DIR}>)
|
||||
# Signal a basic C++11 feature to require C++11.
|
||||
target_compile_features(cmrc-base INTERFACE cxx_nullptr)
|
||||
set_property(TARGET cmrc-base PROPERTY INTERFACE_CXX_EXTENSIONS OFF)
|
||||
add_library(cmrc::base ALIAS cmrc-base)
|
||||
|
||||
function(cmrc_add_resource_library name)
|
||||
set(args ALIAS NAMESPACE)
|
||||
set(args ALIAS NAMESPACE TYPE)
|
||||
cmake_parse_arguments(ARG "" "${args}" "" "${ARGN}")
|
||||
# Generate the identifier for the resource library's namespace
|
||||
set(ns_re "[a-zA-Z_][a-zA-Z0-9_]*")
|
||||
@@ -410,6 +429,14 @@ function(cmrc_add_resource_library name)
|
||||
endif()
|
||||
endif()
|
||||
set(libname "${name}")
|
||||
# Check that type is either "STATIC" or "OBJECT", or default to "STATIC" if
|
||||
# not set
|
||||
if(NOT DEFINED ARG_TYPE)
|
||||
set(ARG_TYPE STATIC)
|
||||
elseif(NOT "${ARG_TYPE}" MATCHES "^(STATIC|OBJECT)$")
|
||||
message(SEND_ERROR "${ARG_TYPE} is not a valid TYPE (STATIC and OBJECT are acceptable)")
|
||||
set(ARG_TYPE STATIC)
|
||||
endif()
|
||||
# Generate a library with the compiled in character arrays.
|
||||
string(CONFIGURE [=[
|
||||
#include <cmrc/cmrc.hpp>
|
||||
@@ -468,7 +495,7 @@ function(cmrc_add_resource_library name)
|
||||
# Generate the actual static library. Each source file is just a single file
|
||||
# with a character array compiled in containing the contents of the
|
||||
# corresponding resource file.
|
||||
add_library(${name} STATIC ${libcpp})
|
||||
add_library(${name} ${ARG_TYPE} ${libcpp})
|
||||
set_property(TARGET ${name} PROPERTY CMRC_LIBDIR "${libdir}")
|
||||
set_property(TARGET ${name} PROPERTY CMRC_NAMESPACE "${ARG_NAMESPACE}")
|
||||
target_link_libraries(${name} PUBLIC cmrc::base)
|
||||
@@ -558,7 +585,7 @@ function(cmrc_add_resources name)
|
||||
endif()
|
||||
get_filename_component(dirpath "${ARG_PREFIX}${relpath}" DIRECTORY)
|
||||
_cmrc_register_dirs("${name}" "${dirpath}")
|
||||
get_filename_component(abs_out "${libdir}/intermediate/${relpath}.cpp" ABSOLUTE)
|
||||
get_filename_component(abs_out "${libdir}/intermediate/${ARG_PREFIX}${relpath}.cpp" ABSOLUTE)
|
||||
# Generate a symbol name relpath the file's character array
|
||||
_cm_encode_fpath(sym "${relpath}")
|
||||
# Get the symbol name for the parent directory
|
||||
|
||||
@@ -33,9 +33,10 @@ find_package(PkgConfig)
|
||||
|
||||
if (PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(PKG_GSTREAMER gstreamer-${GSTREAMER_ABI_VERSION})
|
||||
exec_program(${PKG_CONFIG_EXECUTABLE}
|
||||
ARGS --variable pluginsdir gstreamer-${GSTREAMER_ABI_VERSION}
|
||||
OUTPUT_VARIABLE PKG_GSTREAMER_PLUGIN_DIR)
|
||||
execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE}
|
||||
--variable pluginsdir gstreamer-${GSTREAMER_ABI_VERSION}
|
||||
OUTPUT_VARIABLE PKG_GSTREAMER_PLUGIN_DIR_TMP)
|
||||
string(STRIP ${PKG_GSTREAMER_PLUGIN_DIR_TMP} PKG_GSTREAMER_PLUGIN_DIR)
|
||||
endif()
|
||||
|
||||
find_library(GSTREAMER_LIBRARY
|
||||
|
||||
@@ -41,8 +41,8 @@ foreach(_component ${GStreamerPluginsBad_FIND_COMPONENTS})
|
||||
_find_gst_plugins_bad_component(PLAYER gstplayer.h)
|
||||
elseif (${_component} STREQUAL "webrtc")
|
||||
_find_gst_plugins_bad_component(WEBRTC webrtc.h)
|
||||
elseif (${_component} STREQUAL "mpegts")
|
||||
_find_gst_plugins_bad_component(MPEGTS mpegts.h)
|
||||
elseif (${_component} STREQUAL "srtsrc")
|
||||
_find_gst_plugins_bad_component(SRTSRC mpegts.h)
|
||||
else()
|
||||
message (AUTHOR_WARNING "FindGStreamerPluginBad.cmake: Invalid component \"${_component}\" was specified")
|
||||
endif()
|
||||
|
||||
113
defines.h
@@ -1,113 +0,0 @@
|
||||
#ifndef VMIX_DEFINES_H
|
||||
#define VMIX_DEFINES_H
|
||||
|
||||
#define APP_NAME "vimix"
|
||||
#define APP_TITLE "Video Live Mixer"
|
||||
#define APP_SETTINGS "vimix.xml"
|
||||
#define XML_VERSION_MAJOR 0
|
||||
#define XML_VERSION_MINOR 2
|
||||
#define MAX_RECENT_HISTORY 20
|
||||
#define MAX_SESSION_LEVEL 3
|
||||
|
||||
#define MINI(a, b) (((a) < (b)) ? (a) : (b))
|
||||
#define MAXI(a, b) (((a) > (b)) ? (a) : (b))
|
||||
#define ABS(a) (((a) < 0) ? -(a) : (a))
|
||||
#define ABS_DIFF(a, b) ( (a) < (b) ? (b - a) : (a - b) )
|
||||
#define SIGN(a) (((a) < 0) ? -1.0 : 1.0)
|
||||
#define SQUARE(a) ((a) * (a))
|
||||
#define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
|
||||
#define EPSILON 0.00001
|
||||
#define LOG100(val) (50.0/log(10.0)*log((float)val + 1.0))
|
||||
#define EXP100(val) (exp(log(10.0)/50.0*(float)(val))-1.0)
|
||||
#define EUCLIDEAN(P1, P2) sqrt((P1.x() - P2.x()) * (P1.x() - P2.x()) + (P1.y() - P2.y()) * (P1.y() - P2.y()))
|
||||
#define ROUND(val, factor) float( int( val * factor ) ) / factor;
|
||||
|
||||
#define SCENE_UNIT 5.f
|
||||
#define MIN_SCALE 0.01f
|
||||
#define MAX_SCALE 10.f
|
||||
#define CLAMP_SCALE(x) SIGN(x) * CLAMP( ABS(x), MIN_SCALE, MAX_SCALE)
|
||||
#define SCENE_DEPTH 14.f
|
||||
#define MIN_DEPTH 0.f
|
||||
#define MAX_DEPTH 12.f
|
||||
#define DELTA_DEPTH 0.05f
|
||||
#define DELTA_ALPHA 0.0005f
|
||||
#define MIXING_DEFAULT_SCALE 2.4f
|
||||
#define MIXING_MIN_SCALE 0.8f
|
||||
#define MIXING_MAX_SCALE 7.0f
|
||||
#define MIXING_MIN_THRESHOLD 1.3f
|
||||
#define MIXING_MAX_THRESHOLD 1.9f
|
||||
#define MIXING_ICON_SCALE 0.15f, 0.15f, 1.f
|
||||
#define GEOMETRY_DEFAULT_SCALE 1.4f
|
||||
#define GEOMETRY_MIN_SCALE 0.4f
|
||||
#define GEOMETRY_MAX_SCALE 7.0f
|
||||
#define LAYER_DEFAULT_SCALE 0.6f
|
||||
#define LAYER_MIN_SCALE 0.25f
|
||||
#define LAYER_MAX_SCALE 1.7f
|
||||
#define LAYER_PERSPECTIVE 2.0f
|
||||
#define LAYER_BACKGROUND 2.f
|
||||
#define LAYER_FOREGROUND 10.f
|
||||
#define LAYER_STEP 0.25f
|
||||
#define APPEARANCE_DEFAULT_SCALE 2.f
|
||||
#define APPEARANCE_MIN_SCALE 0.4f
|
||||
#define APPEARANCE_MAX_SCALE 7.0f
|
||||
#define BRUSH_MIN_SIZE 0.05f
|
||||
#define BRUSH_MAX_SIZE 2.f
|
||||
#define BRUSH_MIN_PRESS 0.005f
|
||||
#define BRUSH_MAX_PRESS 1.f
|
||||
#define SHAPE_MIN_BLUR 0.f
|
||||
#define SHAPE_MAX_BLUR 1.f
|
||||
#define TRANSITION_DEFAULT_SCALE 5.0f
|
||||
#define TRANSITION_MIN_DURATION 0.2f
|
||||
#define TRANSITION_MAX_DURATION 10.f
|
||||
#define ARROWS_MOVEMENT_FACTOR 0.1f
|
||||
#define SESSION_THUMBNAIL_HEIGHT 120.f
|
||||
#define RECORD_MAX_TIMEOUT 1200000
|
||||
|
||||
#define IMGUI_TITLE_MAINWINDOW ICON_FA_CIRCLE_NOTCH " vimix"
|
||||
#define IMGUI_TITLE_MEDIAPLAYER ICON_FA_PLAY_CIRCLE " Player"
|
||||
#define IMGUI_TITLE_TIMER ICON_FA_CLOCK " Timer"
|
||||
#define IMGUI_TITLE_LOGS ICON_FA_LIST_UL " Logs"
|
||||
#define IMGUI_TITLE_HELP ICON_FA_LIFE_RING " Help"
|
||||
#define IMGUI_TITLE_TOOLBOX ICON_FA_HAMSA " Guru Toolbox"
|
||||
#define IMGUI_TITLE_SHADEREDITOR ICON_FA_CODE " Code Editor"
|
||||
#define IMGUI_TITLE_PREVIEW ICON_FA_DESKTOP " Ouput"
|
||||
#define IMGUI_TITLE_DELETE ICON_FA_BROOM " Delete?"
|
||||
#define IMGUI_LABEL_RECENT_FILES " Recent files"
|
||||
#define IMGUI_LABEL_RECENT_RECORDS " Recent recordings"
|
||||
#define IMGUI_RIGHT_ALIGN -3.5f * ImGui::GetTextLineHeightWithSpacing()
|
||||
#define IMGUI_SAME_LINE 10
|
||||
#define IMGUI_TOP_ALIGN 10
|
||||
#define IMGUI_COLOR_OVERLAY IM_COL32(5, 5, 5, 150)
|
||||
#define IMGUI_COLOR_LIGHT_OVERLAY IM_COL32(5, 5, 5, 50)
|
||||
#define IMGUI_COLOR_CAPTURE 1.0, 0.55, 0.05
|
||||
#define IMGUI_COLOR_RECORD 1.0, 0.05, 0.05
|
||||
#define IMGUI_COLOR_STREAM 0.05, 0.8, 1.0
|
||||
#define IMGUI_NOTIFICATION_DURATION 2.5f
|
||||
#define IMGUI_TOOLTIP_TIMEOUT 80
|
||||
|
||||
#define COLOR_BGROUND 0.2f, 0.2f, 0.2f
|
||||
#define COLOR_NAVIGATOR 0.1f, 0.1f, 0.1f
|
||||
#define COLOR_DEFAULT_SOURCE 0.7f, 0.7f, 0.7f
|
||||
#define COLOR_HIGHLIGHT_SOURCE 1.f, 1.f, 1.f
|
||||
#define COLOR_TRANSITION_SOURCE 1.f, 0.5f, 1.f
|
||||
#define COLOR_TRANSITION_LINES 0.9f, 0.9f, 0.9f
|
||||
#define COLOR_APPEARANCE_SOURCE 0.9f, 0.9f, 0.1f
|
||||
#define COLOR_APPEARANCE_LIGHT 1.0f, 1.0f, 0.9f
|
||||
#define COLOR_APPEARANCE_MASK 0.9f, 0.9f, 0.9f
|
||||
#define COLOR_APPEARANCE_MASK_DISABLE 0.6f, 0.6f, 0.6f
|
||||
#define COLOR_FRAME 0.75f, 0.2f, 0.75f
|
||||
#define COLOR_FRAME_LIGHT 0.9f, 0.6f, 0.9f
|
||||
#define COLOR_CIRCLE 0.75f, 0.2f, 0.75f
|
||||
#define COLOR_CIRCLE_OVER 0.8f, 0.8f, 0.8f
|
||||
#define COLOR_MIXING_GROUP 0.f, 0.95f, 0.2f
|
||||
#define COLOR_LIMBO_CIRCLE 0.173f, 0.173f, 0.173f
|
||||
#define COLOR_SLIDER_CIRCLE 0.11f, 0.11f, 0.11f
|
||||
#define COLOR_STASH_CIRCLE 0.06f, 0.06f, 0.06f
|
||||
|
||||
#define USE_GST_APPSINK_CALLBACKS
|
||||
|
||||
#define OSC_PORT_RECV_DEFAULT 7000
|
||||
#define OSC_PORT_SEND_DEFAULT 7001
|
||||
#define OSC_CONFIG_FILE "osc.xml"
|
||||
|
||||
#endif // VMIX_DEFINES_H
|
||||
BIN
docs/images/SRT broadcast 1.png
Normal file
|
After Width: | Height: | Size: 377 KiB |
BIN
docs/images/SRT broadcast 2.png
Normal file
|
After Width: | Height: | Size: 971 KiB |
BIN
docs/images/SRT vimix receive 1.png
Normal file
|
After Width: | Height: | Size: 130 KiB |
BIN
docs/images/SRT vimix receive 2.png
Normal file
|
After Width: | Height: | Size: 208 KiB |
BIN
docs/images/SRT vimix receive 3.png
Normal file
|
After Width: | Height: | Size: 381 KiB |
|
Before Width: | Height: | Size: 350 KiB After Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 60 KiB After Width: | Height: | Size: 337 KiB |
|
Before Width: | Height: | Size: 356 KiB After Width: | Height: | Size: 429 KiB |
BIN
docs/images/manual_clonefilter_0.png
Normal file
|
After Width: | Height: | Size: 338 KiB |
BIN
docs/images/manual_clonefilter_1.png
Normal file
|
After Width: | Height: | Size: 498 KiB |
BIN
docs/images/manual_clonefilter_2.png
Normal file
|
After Width: | Height: | Size: 913 KiB |
BIN
docs/images/manual_filter_alpha_chromakey.png
Normal file
|
After Width: | Height: | Size: 113 KiB |
BIN
docs/images/manual_filter_alpha_fill.png
Normal file
|
After Width: | Height: | Size: 72 KiB |
BIN
docs/images/manual_filter_alpha_lumakey.png
Normal file
|
After Width: | Height: | Size: 133 KiB |
BIN
docs/images/manual_filter_blur_closing.png
Normal file
|
After Width: | Height: | Size: 1.2 MiB |
BIN
docs/images/manual_filter_blur_fast.png
Normal file
|
After Width: | Height: | Size: 676 KiB |
BIN
docs/images/manual_filter_blur_gaussian.png
Normal file
|
After Width: | Height: | Size: 592 KiB |
BIN
docs/images/manual_filter_blur_opening.png
Normal file
|
After Width: | Height: | Size: 1.3 MiB |
BIN
docs/images/manual_filter_blur_scattered.png
Normal file
|
After Width: | Height: | Size: 1.6 MiB |
BIN
docs/images/manual_filter_chain_0.png
Normal file
|
After Width: | Height: | Size: 426 KiB |
BIN
docs/images/manual_filter_chain_1.png
Normal file
|
After Width: | Height: | Size: 410 KiB |
BIN
docs/images/manual_filter_chain_2.png
Normal file
|
After Width: | Height: | Size: 526 KiB |
BIN
docs/images/manual_filter_chain_3.png
Normal file
|
After Width: | Height: | Size: 443 KiB |
BIN
docs/images/manual_filter_chain_4.png
Normal file
|
After Width: | Height: | Size: 441 KiB |
BIN
docs/images/manual_filter_chain_5.png
Normal file
|
After Width: | Height: | Size: 383 KiB |
BIN
docs/images/manual_filter_delay.png
Normal file
|
After Width: | Height: | Size: 863 KiB |
BIN
docs/images/manual_filter_downsample.png
Normal file
|
After Width: | Height: | Size: 742 KiB |
BIN
docs/images/manual_filter_edge_contour.png
Normal file
|
After Width: | Height: | Size: 330 KiB |
BIN
docs/images/manual_filter_edge_freichen.png
Normal file
|
After Width: | Height: | Size: 586 KiB |
BIN
docs/images/manual_filter_edge_sobel.png
Normal file
|
After Width: | Height: | Size: 565 KiB |
BIN
docs/images/manual_filter_edge_thresholding.png
Normal file
|
After Width: | Height: | Size: 330 KiB |
BIN
docs/images/manual_filter_sharpen_blackhat.png
Normal file
|
After Width: | Height: | Size: 990 KiB |
BIN
docs/images/manual_filter_sharpen_convolution.png
Normal file
|
After Width: | Height: | Size: 1.3 MiB |
BIN
docs/images/manual_filter_sharpen_edge.png
Normal file
|
After Width: | Height: | Size: 1.4 MiB |
BIN
docs/images/manual_filter_sharpen_unsharpmask.png
Normal file
|
After Width: | Height: | Size: 988 KiB |
BIN
docs/images/manual_filter_sharpen_whitehat.png
Normal file
|
After Width: | Height: | Size: 1006 KiB |
BIN
docs/images/manual_filter_smooth_add_grain.png
Normal file
|
After Width: | Height: | Size: 1.9 MiB |
BIN
docs/images/manual_filter_smooth_add_noise.png
Normal file
|
After Width: | Height: | Size: 1.6 MiB |
BIN
docs/images/manual_filter_smooth_bilateral.png
Normal file
|
After Width: | Height: | Size: 710 KiB |
BIN
docs/images/manual_filter_smooth_closing.png
Normal file
|
After Width: | Height: | Size: 792 KiB |
BIN
docs/images/manual_filter_smooth_dilation.png
Normal file
|
After Width: | Height: | Size: 810 KiB |
BIN
docs/images/manual_filter_smooth_erosion.png
Normal file
|
After Width: | Height: | Size: 779 KiB |
BIN
docs/images/manual_filter_smooth_kuwahara.png
Normal file
|
After Width: | Height: | Size: 838 KiB |
BIN
docs/images/manual_filter_smooth_opening.png
Normal file
|
After Width: | Height: | Size: 735 KiB |
BIN
docs/images/manual_filter_smooth_removenoise.png
Normal file
|
After Width: | Height: | Size: 761 KiB |
|
Before Width: | Height: | Size: 291 KiB After Width: | Height: | Size: 986 KiB |
|
Before Width: | Height: | Size: 379 KiB After Width: | Height: | Size: 1.1 MiB |
BIN
docs/images/manual_group_sources_0.png
Normal file
|
After Width: | Height: | Size: 515 KiB |
BIN
docs/images/manual_group_sources_1.png
Normal file
|
After Width: | Height: | Size: 612 KiB |
BIN
docs/images/manual_group_sources_2.png
Normal file
|
After Width: | Height: | Size: 560 KiB |
BIN
docs/images/manual_group_sources_3.png
Normal file
|
After Width: | Height: | Size: 517 KiB |
BIN
docs/images/manual_group_sources_4.png
Normal file
|
After Width: | Height: | Size: 528 KiB |
BIN
docs/images/manual_group_sources_5.png
Normal file
|
After Width: | Height: | Size: 465 KiB |
BIN
docs/images/manual_laryxscreencast_receive.png
Normal file
|
After Width: | Height: | Size: 327 KiB |
|
Before Width: | Height: | Size: 389 KiB After Width: | Height: | Size: 392 KiB |
BIN
docs/images/manual_order_sources.png
Normal file
|
After Width: | Height: | Size: 41 KiB |
BIN
docs/images/manual_recording_0.png
Normal file
|
After Width: | Height: | Size: 570 KiB |
BIN
docs/images/manual_recording_1.png
Normal file
|
After Width: | Height: | Size: 541 KiB |
BIN
docs/images/manual_recording_2.png
Normal file
|
After Width: | Height: | Size: 670 KiB |
BIN
docs/images/manual_sequence_0.png
Normal file
|
After Width: | Height: | Size: 270 KiB |
BIN
docs/images/manual_sequence_1.png
Normal file
|
After Width: | Height: | Size: 253 KiB |
BIN
docs/images/manual_shadertoy_0.png
Normal file
|
After Width: | Height: | Size: 866 KiB |