Compare commits
1267 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
47b5dea95c | ||
|
|
b0df63f1e8 | ||
|
|
3c4209b676 | ||
|
|
d51b9a8e0e | ||
|
|
3b56125bd2 | ||
|
|
6e69e39007 | ||
|
|
97208cb329 | ||
|
|
414a4a97fb | ||
|
|
2a809f96c4 | ||
|
|
17799b03f3 | ||
|
|
efc55fc648 | ||
|
|
22bd41211a | ||
|
|
4cb0171bd0 | ||
|
|
ce6c5af72c | ||
|
|
171575256c | ||
|
|
d3664dcf78 | ||
|
|
0788981783 | ||
|
|
aeee7c02d5 | ||
|
|
6e49a50461 | ||
|
|
fbc99827ab | ||
|
|
3b134320c4 | ||
|
|
c315e5016d | ||
|
|
7aebd6ed57 | ||
|
|
1a8ca06495 | ||
|
|
a27ae7e4a6 | ||
|
|
dd0ab897aa | ||
|
|
00ad92fb6d | ||
|
|
f84128ecbd | ||
|
|
ba89e0f4e3 | ||
|
|
832d36a4d4 | ||
|
|
0b437b3bfb | ||
|
|
7b50ec4630 | ||
|
|
4ddb13abac | ||
|
|
d2ac081177 | ||
|
|
9692fbf15b | ||
|
|
be966488e8 | ||
|
|
0ce613264f | ||
|
|
34634d776e | ||
|
|
673ded3819 | ||
|
|
b9a94ad3ae | ||
|
|
3f80b330cc | ||
|
|
01632d538c | ||
|
|
b0a9b1cd09 | ||
|
|
1f772081fd | ||
|
|
4ae54dbaad | ||
|
|
e47f4ff731 | ||
|
|
465369d79e | ||
|
|
15ddf6ff20 | ||
|
|
16a753bd95 | ||
|
|
c15103636c | ||
|
|
8a5f82ee7d | ||
|
|
5ec33ec821 | ||
|
|
ab7d383cf1 | ||
|
|
184e9a5c93 | ||
|
|
c4f5363cde | ||
|
|
002882cebf | ||
|
|
1cb3ec0c7b | ||
|
|
6bf325c6f6 | ||
|
|
09c7ff9e8b | ||
|
|
c2a94b61bf | ||
|
|
1db16232de | ||
|
|
3da681a6b1 | ||
|
|
a79b3e7852 | ||
|
|
b1099e6974 | ||
|
|
4f6e06131c | ||
|
|
19f69e9e6c | ||
|
|
01481da773 | ||
|
|
3e8f7e1cf1 | ||
|
|
5da69646f2 | ||
|
|
3cac01583b | ||
|
|
d16a26605e | ||
|
|
a4f692c788 | ||
|
|
9f01206c57 | ||
|
|
d34fc551ed | ||
|
|
7aa5f0d258 | ||
|
|
276a34bb66 | ||
|
|
0d820eda12 | ||
|
|
1991c1b677 | ||
|
|
459404e3f0 | ||
|
|
badc623a3c | ||
|
|
8e39f92cb7 | ||
|
|
3ff4885973 | ||
|
|
f9d45f7657 | ||
|
|
789ff9df5c | ||
|
|
a2064ed16b | ||
|
|
b3d06c0868 | ||
|
|
db1a6b3e38 | ||
|
|
8390237cc4 | ||
|
|
9967eae7bb | ||
|
|
b3be7d1c6f | ||
|
|
33ccb5dbb2 | ||
|
|
5b90c0d695 | ||
|
|
472a660239 | ||
|
|
ab67536d9a | ||
|
|
ee85fb3aec | ||
|
|
214b6f4358 | ||
|
|
af0d092054 | ||
|
|
b07903c3e9 | ||
|
|
ffa4c6bf09 | ||
|
|
b4125fa56c | ||
|
|
2c72302087 | ||
|
|
0fa52bc64f | ||
|
|
f55a80b15a | ||
|
|
0735483321 | ||
|
|
53fc2c7c21 | ||
|
|
f22133c3c5 | ||
|
|
2d5a6d6583 | ||
|
|
dc4adf2836 | ||
|
|
dd6e254e4f | ||
|
|
4c028c1659 | ||
|
|
d332a6777a | ||
|
|
378251f229 | ||
|
|
b6b9b903ed | ||
|
|
143d68cfd5 | ||
|
|
a31eac1426 | ||
|
|
797196f7fc | ||
|
|
c9d0bc81dd | ||
|
|
b5448ff607 | ||
|
|
5ebd363d5d | ||
|
|
1d439e673e | ||
|
|
0b7b7656b2 | ||
|
|
eb270df835 | ||
|
|
ff73dd2183 | ||
|
|
e043a03eb6 | ||
|
|
3cb4e8e373 | ||
|
|
7e6de528b4 | ||
|
|
df901c30ef | ||
|
|
13856b33ec | ||
|
|
a3a1c6f4c8 | ||
|
|
638998a861 | ||
|
|
6e2ec89a05 | ||
|
|
af67de8aa6 | ||
|
|
425dac478e | ||
|
|
b15c4ecd10 | ||
|
|
d7f88cf3a4 | ||
|
|
5b7fbcd9b8 | ||
|
|
7af64b0782 | ||
|
|
b84c70e811 | ||
|
|
f5b245c72d | ||
|
|
4307183817 | ||
|
|
aeb32783d6 | ||
|
|
3927b3bf27 | ||
|
|
da9d2f9417 | ||
|
|
1cec48e8f8 | ||
|
|
f1105393da | ||
|
|
dc7047e3c2 | ||
|
|
08b2945623 | ||
|
|
cbcc223150 | ||
|
|
9830f21e4a | ||
|
|
5f49567bf7 | ||
|
|
6154ae7342 | ||
|
|
978f3a3682 | ||
|
|
1f0961d574 | ||
|
|
a101252701 | ||
|
|
c96c29b1e3 | ||
|
|
3b0fc180ff | ||
|
|
9b8bfdf33c | ||
|
|
4328831fcd | ||
|
|
e5b3df41e9 | ||
|
|
cf5259e218 | ||
|
|
f24b6a520c | ||
|
|
4140163ab2 | ||
|
|
7afde0e93f | ||
|
|
d27a571882 | ||
|
|
1c70e3be25 | ||
|
|
1819f64467 | ||
|
|
9852e588c1 | ||
|
|
71a1ea481b | ||
|
|
9e32f0d778 | ||
|
|
4478174dc2 | ||
|
|
07553476d4 | ||
|
|
1773283456 | ||
|
|
221ab51d90 | ||
|
|
43e0dd922b | ||
|
|
b3262652c3 | ||
|
|
0cfa2b8c20 | ||
|
|
c4600b2187 | ||
|
|
89b15e3b57 | ||
|
|
07d8c3e770 | ||
|
|
c5ae64070e | ||
|
|
2cb7c52147 | ||
|
|
c045b16213 | ||
|
|
b29387d409 | ||
|
|
614a09db1d | ||
|
|
bcc5450aef | ||
|
|
b0420a0566 | ||
|
|
08d627bc9f | ||
|
|
5b5f048faf | ||
|
|
212ebae043 | ||
|
|
a0c99df6b2 | ||
|
|
b0fabd7897 | ||
|
|
938811f24f | ||
|
|
374d6e4d0f | ||
|
|
5f54cdee0f | ||
|
|
c2bd452391 | ||
|
|
d2bfc73b91 | ||
|
|
42c62206c8 | ||
|
|
4208b512f8 | ||
|
|
3a3d5cd487 | ||
|
|
e143a6d126 | ||
|
|
a99a19aa60 | ||
|
|
aba7d2b6a4 | ||
|
|
2fc6f835a8 | ||
|
|
27ce0e6d60 | ||
|
|
05c70f2adb | ||
|
|
904097b7b1 | ||
|
|
4e003c12a6 | ||
|
|
24f2cfb29f | ||
|
|
3f2b683fca | ||
|
|
83cee26d7d | ||
|
|
c7df0c9b28 | ||
|
|
26a8bfaac4 | ||
|
|
fc8a3be7d9 | ||
|
|
b195c4033d | ||
|
|
ab2732c55d | ||
|
|
7fd5c058be | ||
|
|
b22e8b4702 | ||
|
|
e2c2af3447 | ||
|
|
4cd738ecb5 | ||
|
|
e838470c26 | ||
|
|
68e0bc40e1 | ||
|
|
9fc8bcdf62 | ||
|
|
227b14a0b6 | ||
|
|
abcd184d5d | ||
|
|
3fd9f4b0df | ||
|
|
12ff3e963b | ||
|
|
558e392234 | ||
|
|
e747c2e263 | ||
|
|
4d78b30e8c | ||
|
|
9a1520d5e3 | ||
|
|
04f3543424 | ||
|
|
eae287be37 | ||
|
|
a0e698b058 | ||
|
|
cd2932adea | ||
|
|
286b270592 | ||
|
|
d1ebef2cc5 | ||
|
|
deb567fde7 | ||
|
|
26586fb9ef | ||
|
|
5f71a558b9 | ||
|
|
08882639e0 | ||
|
|
837ae2932f | ||
|
|
b51cc21140 | ||
|
|
f1115ba706 | ||
|
|
dc36aee7ff | ||
|
|
740f9581e6 | ||
|
|
de0e3a7bc9 | ||
|
|
95e894fb4d | ||
|
|
faacb0d69f | ||
|
|
28b139e1b8 | ||
|
|
39b1e0676b | ||
|
|
c05fc5bd36 | ||
|
|
bbae9157fb | ||
|
|
fc5c63a869 | ||
|
|
e2e068f8e5 | ||
|
|
43a068e30e | ||
|
|
2beb4b8c6f | ||
|
|
ad4230f7fa | ||
|
|
00369a2cfe | ||
|
|
248e487dd5 | ||
|
|
3a3dc02a66 | ||
|
|
f49c47c20d | ||
|
|
417ef1a7a4 | ||
|
|
8e8889483f | ||
|
|
b5818a9b62 | ||
|
|
e709f676dc | ||
|
|
bb611bf655 | ||
|
|
24e8ca67c5 | ||
|
|
0695941a77 | ||
|
|
7c71efd1b3 | ||
|
|
5099aff5c3 | ||
|
|
d3463250a9 | ||
|
|
3b58c02db0 | ||
|
|
64f0313d3c | ||
|
|
d3958e757b | ||
|
|
651020388d | ||
|
|
72ede666d4 | ||
|
|
a68c249d4e | ||
|
|
56caab4461 | ||
|
|
13b60351a6 | ||
|
|
ad49d38e46 | ||
|
|
082c9097e4 | ||
|
|
2fbdb29ebc | ||
|
|
ef34dce4dc | ||
|
|
577b7d8ec8 | ||
|
|
4ce099294c | ||
|
|
72bff7fa35 | ||
|
|
8c36b8803f | ||
|
|
c69993bd57 | ||
|
|
ea3e4982d2 | ||
|
|
9a5f6c7b9b | ||
|
|
033d56a4b3 | ||
|
|
dfa684cccc | ||
|
|
b4e0f43dfc | ||
|
|
783cf7f1b0 | ||
|
|
92d6fc3fad | ||
|
|
436cdea4fd | ||
|
|
6b144b3b1f | ||
|
|
7820082eb8 | ||
|
|
e732f921a3 | ||
|
|
8b7c5d8585 | ||
|
|
9e959b189c | ||
|
|
5c7a4cdc22 | ||
|
|
756e619e07 | ||
|
|
eea6194b90 | ||
|
|
a09c1fa154 | ||
|
|
38c742328c | ||
|
|
1d5db1446d | ||
|
|
3f5f3d143f | ||
|
|
d297a7198a | ||
|
|
e5bd99dee4 | ||
|
|
2720e13e88 | ||
|
|
0e9c1789ff | ||
|
|
281cb10f84 | ||
|
|
69a92ffe72 | ||
|
|
6447f159e5 | ||
|
|
94430883ad | ||
|
|
046512eb3d | ||
|
|
4479d97e90 | ||
|
|
bf5fea8951 | ||
|
|
07282e3de6 | ||
|
|
c2f90a20df | ||
|
|
481d2d699e | ||
|
|
cf9a7e6ed3 | ||
|
|
c35235371a | ||
|
|
5d5723ad58 | ||
|
|
6c77294a86 | ||
|
|
823f65f1ca | ||
|
|
0c378c1642 | ||
|
|
bbb4162867 | ||
|
|
5dbdde3f2b | ||
|
|
2521954bd9 | ||
|
|
5f1002894e | ||
|
|
0489b312a3 | ||
|
|
732be5a34f | ||
|
|
1f45c78ebb | ||
|
|
8b86c79bf9 | ||
|
|
710ed81067 | ||
|
|
24ac0e7b9b | ||
|
|
15b2bfbb29 | ||
|
|
b7494eb381 | ||
|
|
27ac590250 | ||
|
|
972076edab | ||
|
|
bfa9a1eb8a | ||
|
|
b0966f14e6 | ||
|
|
37cf0c2fb6 | ||
|
|
4eb11c32b0 | ||
|
|
25457bc09a | ||
|
|
d5cfb5f733 | ||
|
|
79ba6e628e | ||
|
|
ef73add05a | ||
|
|
ec3d11fb27 | ||
|
|
3fbc7031b5 | ||
|
|
40beb5e428 | ||
|
|
0f608c8ef0 | ||
|
|
8509cb4743 | ||
|
|
f4429e8c4a | ||
|
|
e9e0829cdc | ||
|
|
93f0230423 | ||
|
|
f26a0df4a4 | ||
|
|
c7d4624282 | ||
|
|
b03eee2a22 | ||
|
|
7d4d72e706 | ||
|
|
e3c367984b | ||
|
|
0ebfa10d32 | ||
|
|
16d9a077f0 | ||
|
|
a9d8bbad42 | ||
|
|
d78bb94af3 | ||
|
|
b139c0a824 | ||
|
|
5b0b924d34 | ||
|
|
f75acf820c | ||
|
|
43a47f33ac | ||
|
|
fcea3a0877 | ||
|
|
a950ec3bd5 | ||
|
|
e35501ff0a | ||
|
|
4bfad9dad8 | ||
|
|
c5c7a07c12 | ||
|
|
7e22e0e552 | ||
|
|
84ec4bdc79 | ||
|
|
2bcad9b637 | ||
|
|
c8d5f03070 | ||
|
|
168e101a5a | ||
|
|
b4bc7333d9 | ||
|
|
e8b58c940e | ||
|
|
ec7202e3f6 | ||
|
|
9a740f7962 | ||
|
|
9210fdee0d | ||
|
|
d7661f0964 | ||
|
|
139e148912 | ||
|
|
1b8dedb4ed | ||
|
|
5d6b0fa329 | ||
|
|
f35bbd89c9 | ||
|
|
538a9e42f4 | ||
|
|
623147dea7 | ||
|
|
dfecd0cd12 | ||
|
|
fe3af3a676 | ||
|
|
25f60331ed | ||
|
|
d4860a3426 | ||
|
|
e7e77ed86b | ||
|
|
dc80459c59 | ||
|
|
2f2de59234 | ||
|
|
7bccc21878 | ||
|
|
40f9dafa44 | ||
|
|
355d436d29 | ||
|
|
079b684388 | ||
|
|
fd11f46d30 | ||
|
|
cb7099199a | ||
|
|
8566d91e89 | ||
|
|
f44ce49ea7 | ||
|
|
6ef69f6b32 | ||
|
|
f5983d5f10 | ||
|
|
54cce5e089 | ||
|
|
4e4e596a1e | ||
|
|
727a1f5ad1 | ||
|
|
85fa86625b | ||
|
|
2c91877f83 | ||
|
|
7d1fac44e9 | ||
|
|
2e34abfc0d | ||
|
|
81ba63e247 | ||
|
|
8b11a65522 | ||
|
|
7190ad1d15 | ||
|
|
1c9bae5df5 | ||
|
|
cc7fd73916 | ||
|
|
6d8725f268 | ||
|
|
373c7cdbc4 | ||
|
|
a4855bb33b | ||
|
|
57c1358ded | ||
|
|
eb4ce1feab | ||
|
|
838c17e144 | ||
|
|
4499cbca3c | ||
|
|
a835a4a2f7 | ||
|
|
9cc6a94353 | ||
|
|
5ed9d9c4a0 | ||
|
|
9c5ac7080d | ||
|
|
6346370e86 | ||
|
|
80697f8f30 | ||
|
|
18b8b56367 | ||
|
|
760aacca26 | ||
|
|
1a4f0dcf5a | ||
|
|
947484a71c | ||
|
|
a74439d038 | ||
|
|
c338618593 | ||
|
|
011897da53 | ||
|
|
3fcaa58947 | ||
|
|
ef8bd4362a | ||
|
|
627a2ef6dd | ||
|
|
2732536d6e | ||
|
|
5a1b4b3ff8 | ||
|
|
d93ec82e4f | ||
|
|
15080972f3 | ||
|
|
171b58f737 | ||
|
|
c008ab6141 | ||
|
|
f14c3654dc | ||
|
|
ae05a61551 | ||
|
|
8e1def225b | ||
|
|
6e061764ee | ||
|
|
ac55b22839 | ||
|
|
49f77d3b75 | ||
|
|
4abc650edf | ||
|
|
5ba00b61be | ||
|
|
bc16a6c4cb | ||
|
|
ea4dc6f040 | ||
|
|
749ae8d5eb | ||
|
|
7a56ffb7c3 | ||
|
|
e62ab23de2 | ||
|
|
c6f6118506 | ||
|
|
8a5d5ad952 | ||
|
|
49e2615d14 | ||
|
|
9289394261 | ||
|
|
8da4c88fd3 | ||
|
|
a303850341 | ||
|
|
fb33610672 | ||
|
|
d024dd6563 | ||
|
|
0be48f9f59 | ||
|
|
df9292bafe | ||
|
|
c1dcef3477 | ||
|
|
48bc1f8361 | ||
|
|
2b2b4dbcf4 | ||
|
|
a1eadecdef | ||
|
|
f0b529952d | ||
|
|
c1ac2debb8 | ||
|
|
ac40094d37 | ||
|
|
cb2bb4cb67 | ||
|
|
f2965940cc | ||
|
|
c9ca147898 | ||
|
|
c379d7f846 | ||
|
|
45ae1ed265 | ||
|
|
9bf00eff40 | ||
|
|
1677b3d5b9 | ||
|
|
2a6806004a | ||
|
|
39347d69df | ||
|
|
a2c0e4d4b1 | ||
|
|
ab2ffd9ac1 | ||
|
|
c69fff52cc | ||
|
|
1cfe61dc72 | ||
|
|
a23f39d81e | ||
|
|
b7724ff583 | ||
|
|
e5dba60fab | ||
|
|
2ccf489a83 | ||
|
|
068939ca0b | ||
|
|
94ba8614ec | ||
|
|
f12a0c2379 | ||
|
|
8ab257645b | ||
|
|
6331a0615f | ||
|
|
a21855fa20 | ||
|
|
12150c2180 | ||
|
|
d90aecb164 | ||
|
|
e738f2bc9f | ||
|
|
2f72c41cda | ||
|
|
aa43d42cdb | ||
|
|
be8228e33c | ||
|
|
5591472dbd | ||
|
|
30e6ced4e9 | ||
|
|
5f4c2bae89 | ||
|
|
0f036d9a43 | ||
|
|
1695ac3a32 | ||
|
|
07a19ba619 | ||
|
|
4dd78d89a0 | ||
|
|
8f4056faa6 | ||
|
|
7b40c33892 | ||
|
|
b06bb5142f | ||
|
|
d576156ee1 | ||
|
|
77079968a5 | ||
|
|
e12aca6214 | ||
|
|
2a72891f28 | ||
|
|
6fe47e78f1 | ||
|
|
0094894b52 | ||
|
|
0951bfb7ac | ||
|
|
60e8519b65 | ||
|
|
78df0ed707 | ||
|
|
e3da0d6c9f | ||
|
|
5df30580a6 | ||
|
|
4816b7dcd8 | ||
|
|
75bced198b | ||
|
|
b500813617 | ||
|
|
a80037f7fc | ||
|
|
1a6345342f | ||
|
|
21b2193cd0 | ||
|
|
3efc496c41 | ||
|
|
16340fbb78 | ||
|
|
a858b28bc4 | ||
|
|
307961cc7e | ||
|
|
3074377b55 | ||
|
|
5a3edc00ac | ||
|
|
5a5f50e1e4 | ||
|
|
7f39a38d6c | ||
|
|
8321a48af7 | ||
|
|
7e613f032e | ||
|
|
1c38c39db2 | ||
|
|
4a0235c2ed | ||
|
|
b92961fda0 | ||
|
|
a2a06be62f | ||
|
|
c0956ed3b0 | ||
|
|
3705e4e4d4 | ||
|
|
3fdbe84573 | ||
|
|
fb8e7d803f | ||
|
|
b01821aa03 | ||
|
|
69f974c9d0 | ||
|
|
5db8b743fe | ||
|
|
c424b0c888 | ||
|
|
d035c7d3b8 | ||
|
|
144ffbc428 | ||
|
|
afa8486d40 | ||
|
|
a4cd42c448 | ||
|
|
853f4b75fa | ||
|
|
b95612287f | ||
|
|
64e779172c | ||
|
|
10a136b4a3 | ||
|
|
ddc3af28ab | ||
|
|
f602948dcf | ||
|
|
973229cf4e | ||
|
|
d1f5cbea4a | ||
|
|
49fe670ddb | ||
|
|
d6d87675c9 | ||
|
|
1ca1927904 | ||
|
|
454c3d1a3c | ||
|
|
11f5004112 | ||
|
|
625343f698 | ||
|
|
89d96a3ec1 | ||
|
|
c4c47fa196 | ||
|
|
ca35894b82 | ||
|
|
0213b6556b | ||
|
|
4edfd9be30 | ||
|
|
e55d9cafb6 | ||
|
|
8deb0ed556 | ||
|
|
82f995f243 | ||
|
|
b41c2ca724 | ||
|
|
06ddbaf2cc | ||
|
|
2adbfe1fbd | ||
|
|
7ae049b559 | ||
|
|
72913ceb1a | ||
|
|
6a2be22fa1 | ||
|
|
eaf20ce8d2 | ||
|
|
97f9e142b4 | ||
|
|
2e0f7b367f | ||
|
|
7312e3f452 | ||
|
|
8faa9f075b | ||
|
|
584dcae075 | ||
|
|
910e869b8d | ||
|
|
469e00b396 | ||
|
|
ec46c758ba | ||
|
|
8970e46bce | ||
|
|
3a4107d903 | ||
|
|
52ee21d550 | ||
|
|
cdda4826cb | ||
|
|
6745df5041 | ||
|
|
3d3efe1117 | ||
|
|
82e5ae05ce | ||
|
|
0dbdd55a6a | ||
|
|
424b0e61cb | ||
|
|
533da8f89c | ||
|
|
31506662db | ||
|
|
7ff1a88ca8 | ||
|
|
1851f26e3f | ||
|
|
84cd65dd6c | ||
|
|
8e0d792bf0 | ||
|
|
e74548b991 | ||
|
|
2356ff5ebb | ||
|
|
691f5d99ca | ||
|
|
ab7b65a30b | ||
|
|
814bb3006c | ||
|
|
4bd4d3ae03 | ||
|
|
af1b0ace19 | ||
|
|
fb54febe03 | ||
|
|
28faae5a4a | ||
|
|
624a920aec | ||
|
|
2bf8187bff | ||
|
|
cf06bf91e3 | ||
|
|
e96f0504c0 | ||
|
|
5fd61725bd | ||
|
|
3fddfa075b | ||
|
|
d712e5c409 | ||
|
|
6287afae6c | ||
|
|
925540055a | ||
|
|
d4373aae93 | ||
|
|
c4be310081 | ||
|
|
d1aa276465 | ||
|
|
2af6fc7452 | ||
|
|
ed15394a96 | ||
|
|
3791d11162 | ||
|
|
032ddabc06 | ||
|
|
bfb93ac6ed | ||
|
|
f6d889d752 | ||
|
|
a7053f4269 | ||
|
|
233a6d06be | ||
|
|
853224148f | ||
|
|
c5c8c27b2e | ||
|
|
d352d5fcff | ||
|
|
0003de9320 | ||
|
|
04f43e77af | ||
|
|
be7cc55488 | ||
|
|
c8f3379a48 | ||
|
|
b5a7945e49 | ||
|
|
0bdac2e97d | ||
|
|
1468a821fb | ||
|
|
3cdc8dc4b6 | ||
|
|
aa255aa7e6 | ||
|
|
66e5ccb9cc | ||
|
|
2215f300bf | ||
|
|
eec767406b | ||
|
|
31aa42c2fa | ||
|
|
e912c59402 | ||
|
|
c9988976f3 | ||
|
|
443be1c2c8 | ||
|
|
7f442cff3b | ||
|
|
3696ae44ad | ||
|
|
fc2d601424 | ||
|
|
8818f24114 | ||
|
|
0e12c8249e | ||
|
|
06d62a70a9 | ||
|
|
76d8018ca2 | ||
|
|
4123b41a5e | ||
|
|
5930257fed | ||
|
|
d3d60327ab | ||
|
|
5080ffb9fc | ||
|
|
9b688a5179 | ||
|
|
a603dc5227 | ||
|
|
c25f682caf | ||
|
|
27a2fd298d | ||
|
|
bb38053cb3 | ||
|
|
5e82ee8695 | ||
|
|
6c691ff9a8 | ||
|
|
ac5a14fe4a | ||
|
|
00402d13ef | ||
|
|
079a559247 | ||
|
|
a19ea8fdba | ||
|
|
c6e172f942 | ||
|
|
bdc9f3e8bf | ||
|
|
8ec5a587fc | ||
|
|
9caf46f2fb | ||
|
|
13fdbfc5e8 | ||
|
|
882c94110e | ||
|
|
97bc980611 | ||
|
|
be9bf5c173 | ||
|
|
6df38c389c | ||
|
|
6c6bceb8cc | ||
|
|
b5a897bb4d | ||
|
|
ab85b716bb | ||
|
|
8e256e6d5c | ||
|
|
288036a63b | ||
|
|
f2005c3343 | ||
|
|
79d516b899 | ||
|
|
28b2f6eae3 | ||
|
|
09ed2b945c | ||
|
|
74aec89ef0 | ||
|
|
4faa23d099 | ||
|
|
5c4997ab20 | ||
|
|
cd490ca946 | ||
|
|
793f6b00e6 | ||
|
|
c1ec568fda | ||
|
|
4e2b52975e | ||
|
|
c141df6b86 | ||
|
|
63b781765a | ||
|
|
c121e141e7 | ||
|
|
7544c9a9f5 | ||
|
|
722a088515 | ||
|
|
0ce75bff58 | ||
|
|
3744b6d3de | ||
|
|
a4ebd91e8d | ||
|
|
3bb0ee916d | ||
|
|
fd6afdf5f3 | ||
|
|
47c13a840e | ||
|
|
5b61992b3c | ||
|
|
36331dc253 | ||
|
|
4265cf31b2 | ||
|
|
337e47269f | ||
|
|
7039234471 | ||
|
|
f7f9333d91 | ||
|
|
bf35665932 | ||
|
|
089a2271c2 | ||
|
|
f8e83e3631 | ||
|
|
46fd329913 | ||
|
|
6b9ba96e77 | ||
|
|
b7d360d850 | ||
|
|
8e226302ab | ||
|
|
7795b9edaf | ||
|
|
9375d9699a | ||
|
|
cf0442d5b8 | ||
|
|
b386ca14df | ||
|
|
ea47fae31e | ||
|
|
e0fed07b10 | ||
|
|
779d5ff7b6 | ||
|
|
eb6fbd03ec | ||
|
|
95409d1b0e | ||
|
|
49599c8731 | ||
|
|
572f94e000 | ||
|
|
c0a2ad5f50 | ||
|
|
71fa5acc74 | ||
|
|
bac5b7679d | ||
|
|
93ade821a5 | ||
|
|
a718e19979 | ||
|
|
8ac83a46f5 | ||
|
|
1b65dcd7df | ||
|
|
bbad45f1e7 | ||
|
|
331b9cca18 | ||
|
|
a9accb7d85 | ||
|
|
1862e70628 | ||
|
|
c4f7054ca6 | ||
|
|
175e568a28 | ||
|
|
c8d580e7de | ||
|
|
bc0c50ee65 | ||
|
|
45e9dd96d1 | ||
|
|
1cc73562a3 | ||
|
|
d870ef0bd5 | ||
|
|
53d308dac5 | ||
|
|
89b06ae7c7 | ||
|
|
d38485a8ad | ||
|
|
834877c503 | ||
|
|
d033b79af4 | ||
|
|
daec2cc203 | ||
|
|
4e593cebab | ||
|
|
73d7701e94 | ||
|
|
24f1d7a72f | ||
|
|
6387a01d7b | ||
|
|
e838840548 | ||
|
|
6a430b441e | ||
|
|
7b977ea839 | ||
|
|
62b8521cbe | ||
|
|
308244d901 | ||
|
|
6f521183f9 | ||
|
|
76c6f7e733 | ||
|
|
80ebfbeb6b | ||
|
|
793901b319 | ||
|
|
3950df8ec9 | ||
|
|
e800b236aa | ||
|
|
4ab7871106 | ||
|
|
3de85549b6 | ||
|
|
73164f7182 | ||
|
|
004b000890 | ||
|
|
d9c703d944 | ||
|
|
364b650033 | ||
|
|
156eb874db | ||
|
|
1a28dd0311 | ||
|
|
e29b4b8609 | ||
|
|
c02997e6d9 | ||
|
|
7c9fc91af9 | ||
|
|
cf5198ac64 | ||
|
|
e76ddd6dd2 | ||
|
|
e3a4cf1cf5 | ||
|
|
5844616ea8 | ||
|
|
abeb580228 | ||
|
|
4d888dfce8 | ||
|
|
08ff6f0ede | ||
|
|
c458c27231 | ||
|
|
9821b70c38 | ||
|
|
8ab8401110 | ||
|
|
4f798c85cf | ||
|
|
1949bdb43f | ||
|
|
8cf2e6b31b | ||
|
|
b1069f9f18 | ||
|
|
fb8dfa9ae9 | ||
|
|
4402a56e94 | ||
|
|
f449808ba3 | ||
|
|
5599739433 | ||
|
|
197cf85f56 | ||
|
|
8c039c9c8b | ||
|
|
c1d9bc046d | ||
|
|
cd99fac7ed | ||
|
|
f4489e6807 | ||
|
|
f2078271b6 | ||
|
|
a3ae9acebb | ||
|
|
b0580265ca | ||
|
|
b4f012392a | ||
|
|
1598809f55 | ||
|
|
6d4f7aa61f | ||
|
|
382080ae4e | ||
|
|
66ac529bca | ||
|
|
ab72207027 | ||
|
|
e3aebf1ca2 | ||
|
|
0e5820c038 | ||
|
|
780e4d34df | ||
|
|
a8700572b7 | ||
|
|
055516312a | ||
|
|
76b4a6585e | ||
|
|
b57535c5ad | ||
|
|
eb10a15eee | ||
|
|
30ed362a8c | ||
|
|
34f071ed1d | ||
|
|
3d3d641e1c | ||
|
|
10c11f2c3d | ||
|
|
cec2745dc0 | ||
|
|
8d15edb063 | ||
|
|
38cf3dc141 | ||
|
|
c146290e07 | ||
|
|
a1745289be | ||
|
|
5a7dbfc87a | ||
|
|
f645950a8f | ||
|
|
b273da0b5e | ||
|
|
689f1eb0c5 | ||
|
|
b0a2edf5fa | ||
|
|
e7b5e02657 | ||
|
|
2d4efd6cf0 | ||
|
|
defc0ada78 | ||
|
|
2f3f4f609c | ||
|
|
4a9c9f8cd4 | ||
|
|
bdc089290d | ||
|
|
cf9f48d8da | ||
|
|
2d67279180 | ||
|
|
83e10aac27 | ||
|
|
9972124aa1 | ||
|
|
d0eb1ba96e | ||
|
|
f5d2910638 | ||
|
|
1cafaf3a79 | ||
|
|
fccc133cb2 | ||
|
|
9fb50b8a73 | ||
|
|
c66c1e17d3 | ||
|
|
4496760340 | ||
|
|
506200d2ee | ||
|
|
04898a3b01 | ||
|
|
f67fb53308 | ||
|
|
c5b78dde04 | ||
|
|
57d9c87de6 | ||
|
|
795f95d855 | ||
|
|
c0ebbc8e2f | ||
|
|
fb377c32ea | ||
|
|
e13faff2d7 | ||
|
|
b0c5348116 | ||
|
|
b462ec022a | ||
|
|
e45a0bf24b | ||
|
|
8962644ba8 | ||
|
|
ad5e04bbcc | ||
|
|
6fc7baec39 | ||
|
|
acd49a9c40 | ||
|
|
bf04358a47 | ||
|
|
b7e13c7b86 | ||
|
|
9b45f0661e | ||
|
|
2a61b1202b | ||
|
|
114f862ea4 | ||
|
|
5a490a8b5a | ||
|
|
8fdc1c1b21 | ||
|
|
32cac90720 | ||
|
|
b2160255d3 | ||
|
|
7fe1f4de93 | ||
|
|
1fbb1b1524 | ||
|
|
0105a53765 | ||
|
|
bd5ab80276 | ||
|
|
387d790228 | ||
|
|
d199a2be0d | ||
|
|
f81ecffda6 | ||
|
|
882f80de1e | ||
|
|
4359f2a0ce | ||
|
|
9c485c4d94 | ||
|
|
1330197036 | ||
|
|
0b0d5fa227 | ||
|
|
45424b8a52 | ||
|
|
0956acbdfb | ||
|
|
654f553d8f | ||
|
|
e4b6e20db6 | ||
|
|
b4f6c6f869 | ||
|
|
16edc52bae | ||
|
|
a33e6c03e4 | ||
|
|
4dccb40bf9 | ||
|
|
9ce1981f93 | ||
|
|
6374c77aa8 | ||
|
|
871bb391d6 | ||
|
|
c3903a7b35 | ||
|
|
6aabf82c11 | ||
|
|
89b624aadf | ||
|
|
67317292ee | ||
|
|
42e7f64856 | ||
|
|
79d963fd65 | ||
|
|
44649fd950 | ||
|
|
0e97f99f93 | ||
|
|
4f52ceb3e0 | ||
|
|
61253b5551 | ||
|
|
12bd6f0d9b | ||
|
|
a32010e03b | ||
|
|
4a934c9dab | ||
|
|
20766c1feb | ||
|
|
6cd4de548f | ||
|
|
8ac4dea8f1 | ||
|
|
e8af3e8d3c | ||
|
|
cd05b10168 | ||
|
|
140935bd8c | ||
|
|
ecb122d93c | ||
|
|
c6e08e0039 | ||
|
|
be1e14df81 | ||
|
|
28bca261fb | ||
|
|
2ab5bc1ad2 | ||
|
|
10c57cf6da | ||
|
|
e65c5eeab1 | ||
|
|
85fad35dc2 | ||
|
|
c992768efe | ||
|
|
7b13c0d059 | ||
|
|
2d3f41da6f | ||
|
|
43b9941dc8 | ||
|
|
dcf27f54aa | ||
|
|
fbf6b69e75 | ||
|
|
0bfebd90da | ||
|
|
e7c3dafa36 | ||
|
|
e90a36da79 | ||
|
|
93f33615ad | ||
|
|
99569081c9 | ||
|
|
588a0b3c41 | ||
|
|
4a1118ceb3 | ||
|
|
a65415bc10 | ||
|
|
8a0e66bf11 | ||
|
|
02cda47c28 | ||
|
|
d34a323a81 | ||
|
|
4166ae8db0 | ||
|
|
955b906b52 | ||
|
|
0d424aa81e | ||
|
|
80acbfa56a | ||
|
|
a7cac24004 | ||
|
|
2927bcf09d | ||
|
|
08dee6bb4f | ||
|
|
08c92f906a | ||
|
|
8e9c9802d1 | ||
|
|
138df66d5e | ||
|
|
0a71347e9a | ||
|
|
2a541a7b9c | ||
|
|
705c12e8da | ||
|
|
cf33df1339 | ||
|
|
87e543b5ef | ||
|
|
81caec99b7 | ||
|
|
41484f8673 | ||
|
|
da0d61f36a | ||
|
|
6f3bc74db0 | ||
|
|
af3bd6ec2f | ||
|
|
b5eb13449b | ||
|
|
bd78e8c275 | ||
|
|
2df21081a1 | ||
|
|
ffebff4ea9 | ||
|
|
2885bc99ca | ||
|
|
2657b80adb | ||
|
|
ebfc106701 | ||
|
|
4d60ca951d | ||
|
|
acf5c57599 | ||
|
|
927df5ff39 | ||
|
|
31fc031267 | ||
|
|
02794e0ebd | ||
|
|
ea6cce7068 | ||
|
|
e4cefeaa8f | ||
|
|
d12d5fd8ae | ||
|
|
0617c3fdc0 | ||
|
|
f00eedf57e | ||
|
|
6d36ae6197 | ||
|
|
45125abb8f | ||
|
|
045b0cd075 | ||
|
|
ff3333e1bf | ||
|
|
7663c5e149 | ||
|
|
4d4748a0a8 | ||
|
|
f8f84ed09e | ||
|
|
e7de7ebbfa | ||
|
|
c9f01f4bc4 | ||
|
|
f2675adc05 | ||
|
|
75beaa3684 | ||
|
|
079495cc32 | ||
|
|
c8bd89e56f | ||
|
|
b089ba2e04 | ||
|
|
adbf8495c6 | ||
|
|
ad062862d8 | ||
|
|
3a86a93154 | ||
|
|
dcf0d6f72d | ||
|
|
83d3725240 | ||
|
|
ce1dd69557 | ||
|
|
4081bdd752 | ||
|
|
c3f1e312b3 | ||
|
|
d820878b89 | ||
|
|
7fa1461d5e | ||
|
|
f4b1ef4d04 | ||
|
|
656130a739 | ||
|
|
aa8679dff5 | ||
|
|
f94a3095fd | ||
|
|
e11958dd58 | ||
|
|
a5a251a964 | ||
|
|
8cb1015a35 | ||
|
|
b5dd90b2d5 | ||
|
|
5f7efee00e | ||
|
|
4150e3efde | ||
|
|
8ebcb71e6e | ||
|
|
f3e852c042 | ||
|
|
5e2a07d144 | ||
|
|
25f6231e9d | ||
|
|
beeba88ea5 | ||
|
|
cc3d454d60 | ||
|
|
afb583cff4 | ||
|
|
561fa66393 | ||
|
|
870dc0d36f | ||
|
|
51462dee1e | ||
|
|
c752d28c6a | ||
|
|
d5ca0ca283 | ||
|
|
f371b3a338 | ||
|
|
93fc4a2c86 | ||
|
|
f10d3f86cc | ||
|
|
af17b0015b | ||
|
|
61af1d1c72 | ||
|
|
65780e1672 | ||
|
|
c92a7967ea | ||
|
|
60aed593b3 | ||
|
|
044f347729 | ||
|
|
aec9df1882 | ||
|
|
4f0a2515f8 | ||
|
|
5cde33711e | ||
|
|
64750025f6 | ||
|
|
cd1cbfdffe | ||
|
|
d413f2c3a7 | ||
|
|
ba314dd734 | ||
|
|
9105b7615c | ||
|
|
a9c162476c | ||
|
|
732b37aca0 | ||
|
|
291b5fad7f | ||
|
|
c2a6def8b9 | ||
|
|
9083c578cc | ||
|
|
bcfd1d39bb | ||
|
|
1185b910c4 | ||
|
|
540b6eba04 | ||
|
|
47f4287e64 | ||
|
|
264c6e259b | ||
|
|
0bbe9838c4 | ||
|
|
2fe337eac3 | ||
|
|
5d7caafdf7 | ||
|
|
f416ef925b | ||
|
|
60bd90848b | ||
|
|
b9f4407815 | ||
|
|
f9cd2639ff | ||
|
|
aeb36e8665 | ||
|
|
057482a3e5 | ||
|
|
15721da46e | ||
|
|
f12b82b5ce | ||
|
|
10dc725942 | ||
|
|
5bd5cdf435 | ||
|
|
84b3603c08 | ||
|
|
8f59b96731 | ||
|
|
e1de110dd7 | ||
|
|
8b6fd3d594 | ||
|
|
d7761e8d79 | ||
|
|
751d652a2f | ||
|
|
647e7e708a | ||
|
|
505c0eeae2 | ||
|
|
bf4001968e | ||
|
|
9d222e2c57 | ||
|
|
033300d659 | ||
|
|
4f2b04bd8f | ||
|
|
f8b9bb4b0f | ||
|
|
8ce8e320c3 | ||
|
|
7c0ab4212b | ||
|
|
26633e0982 | ||
|
|
d27a3f1f33 | ||
|
|
89252d0dba | ||
|
|
dbd2edf442 | ||
|
|
dabd6f8284 | ||
|
|
beb3ab463f | ||
|
|
1d67b623e0 | ||
|
|
2c8cde4d91 | ||
|
|
8cc1d48115 | ||
|
|
ec2468fb8d | ||
|
|
7b54cef23b | ||
|
|
a9da8811fc | ||
|
|
60e86b9881 | ||
|
|
a6766f3c99 | ||
|
|
e59c3c6f70 | ||
|
|
49aa344d8b | ||
|
|
4fed6ab298 | ||
|
|
58eab4d3bc | ||
|
|
5ef5da687d | ||
|
|
4875d319dc | ||
|
|
fb5a53435e | ||
|
|
4f805d65b3 | ||
|
|
56ffb0deb1 | ||
|
|
c0c1457073 | ||
|
|
85a0748ad9 | ||
|
|
c1939a36dd | ||
|
|
b7c394b7a5 | ||
|
|
a070681f89 | ||
|
|
d5e424eec8 | ||
|
|
e0366d38f1 | ||
|
|
cbf1d96b16 | ||
|
|
7cc0d6bb5a | ||
|
|
e19b840ee6 | ||
|
|
5c2ca1e3d9 | ||
|
|
059c4beb30 | ||
|
|
427808226f | ||
|
|
5448245942 | ||
|
|
34ab907007 | ||
|
|
e5fde27859 | ||
|
|
699e8e3ddb | ||
|
|
28ee967371 | ||
|
|
1b0b5f2554 | ||
|
|
1bcc86f989 | ||
|
|
f26f932fd7 | ||
|
|
2b7d48ce77 | ||
|
|
111712fd6d | ||
|
|
7609bc181e | ||
|
|
8b05af7ca3 | ||
|
|
20f9108ebf | ||
|
|
cecae7cdc3 | ||
|
|
e5f3123567 | ||
|
|
27b0e27cfd | ||
|
|
890fba0f61 | ||
|
|
c4b732ff93 | ||
|
|
b8fa2985d5 | ||
|
|
ba741fbce8 | ||
|
|
67d070c334 | ||
|
|
8576afe6f5 | ||
|
|
36807fd376 | ||
|
|
2ad1d27a59 | ||
|
|
7cc9c75d15 | ||
|
|
f33609bbf8 | ||
|
|
69eeb4b0f8 | ||
|
|
aa583ec1aa | ||
|
|
2b9f153257 | ||
|
|
cb9b7fc917 | ||
|
|
74b36c8884 | ||
|
|
89ff7d6dae | ||
|
|
91df420cb4 | ||
|
|
fc25c9f0bc | ||
|
|
12a27e3a8d | ||
|
|
125e32ff00 | ||
|
|
4a110633e8 | ||
|
|
65648f8abd | ||
|
|
50174861dc | ||
|
|
486eb1722e | ||
|
|
740ead4059 | ||
|
|
96424be0da | ||
|
|
cd9d659672 | ||
|
|
ca140388d9 | ||
|
|
8fe0229a2c | ||
|
|
1f43de9458 | ||
|
|
2793f38c2d | ||
|
|
42de7de21d | ||
|
|
1072dc0a41 | ||
|
|
9d8f310e30 | ||
|
|
170adfd00c | ||
|
|
d0135a5ff7 | ||
|
|
1c926cca45 | ||
|
|
ace8ecbb4e | ||
|
|
193fa176dc | ||
|
|
054db62cfa | ||
|
|
fe549cf4c5 | ||
|
|
d347e49b6a | ||
|
|
d6a3f7b329 | ||
|
|
4171bc4c70 | ||
|
|
deca5e5021 | ||
|
|
e0923a0494 | ||
|
|
0a1dfeb860 | ||
|
|
1c911575fa | ||
|
|
d2ef0a996f | ||
|
|
1e886cb12c | ||
|
|
984abc89a8 | ||
|
|
3c6c9741ff | ||
|
|
247a11146c | ||
|
|
d1108c533f | ||
|
|
881339848f | ||
|
|
c44638dcbe | ||
|
|
4887b85b8a | ||
|
|
239f58e290 | ||
|
|
560000f69d | ||
|
|
2d3509ae56 | ||
|
|
4cc926a627 | ||
|
|
a499a70633 | ||
|
|
60a9154326 | ||
|
|
f761b8d4e1 | ||
|
|
7a0f6684e5 | ||
|
|
3ed6817ac9 | ||
|
|
ba76385a2f | ||
|
|
7bcd5ba14c | ||
|
|
40db9f7020 | ||
|
|
dffc46551e | ||
|
|
cf92852bb3 | ||
|
|
844c4a28f4 | ||
|
|
d2fc5a6228 | ||
|
|
006da837aa | ||
|
|
d920e27ab3 | ||
|
|
27bafa8ab2 | ||
|
|
907d18a83a | ||
|
|
37b923bea3 | ||
|
|
91e597bbdd | ||
|
|
a0d697bf6f | ||
|
|
63d5018ad6 | ||
|
|
ca928bdacb | ||
|
|
f7e7791b8b | ||
|
|
80c2e5b141 | ||
|
|
63c171e3b4 | ||
|
|
b0bfb0fdd4 | ||
|
|
31b24d9a09 | ||
|
|
8b04a3b16a | ||
|
|
b88d35d7cb | ||
|
|
e00dcf1af0 | ||
|
|
7f23b9b424 | ||
|
|
e9bf04031b | ||
|
|
c8f2334003 | ||
|
|
380b84195f | ||
|
|
fd26137ad2 | ||
|
|
1ad163aac3 | ||
|
|
36dccc8157 | ||
|
|
6dcdf5bf92 | ||
|
|
0b460017b8 | ||
|
|
061b06cd08 | ||
|
|
86272e1788 | ||
|
|
86f3e011d8 | ||
|
|
0367c5bd1c | ||
|
|
eed008de4b | ||
|
|
74f713ee35 | ||
|
|
6dbb8751b2 | ||
|
|
368bb54870 | ||
|
|
77903a5ecd | ||
|
|
9be161d165 | ||
|
|
0ce5b50950 | ||
|
|
9dded5203e | ||
|
|
d1c2188e5c | ||
|
|
c4285a14b2 | ||
|
|
cf0a47e836 | ||
|
|
c38639afcb | ||
|
|
5863593c65 | ||
|
|
c2fa7f9a57 | ||
|
|
41f5cf6bee | ||
|
|
ea508e9c35 |
603
.circleci/config.yml
Normal file
603
.circleci/config.yml
Normal file
@@ -0,0 +1,603 @@
|
|||||||
|
version: 2.1
|
||||||
|
commands:
|
||||||
|
|
||||||
|
cmake:
|
||||||
|
description: Configure build
|
||||||
|
steps:
|
||||||
|
- run:
|
||||||
|
name: Configure build
|
||||||
|
command: cmake ..
|
||||||
|
working_directory: build
|
||||||
|
|
||||||
|
|
||||||
|
build_source:
|
||||||
|
description: Create source tarball
|
||||||
|
steps:
|
||||||
|
- run:
|
||||||
|
name: Create source tarball
|
||||||
|
command: ../dist/scripts/maketarball.sh
|
||||||
|
working_directory: build
|
||||||
|
|
||||||
|
|
||||||
|
build_rpm:
|
||||||
|
description: Build RPM
|
||||||
|
steps:
|
||||||
|
- run:
|
||||||
|
name: Create RPM build sources directories
|
||||||
|
command: mkdir -p ~/rpmbuild/SOURCES /usr/src/packages/SOURCES
|
||||||
|
- run:
|
||||||
|
name: Copy source tarball 1
|
||||||
|
command: cp strawberry-*.tar.xz ~/rpmbuild/SOURCES/
|
||||||
|
working_directory: build
|
||||||
|
- run:
|
||||||
|
name: Copy source tarball 2
|
||||||
|
command: cp strawberry-*.tar.xz /usr/src/packages/SOURCES/
|
||||||
|
working_directory: build
|
||||||
|
- run:
|
||||||
|
name: Build RPM
|
||||||
|
command: rpmbuild -ba ../dist/unix/strawberry.spec
|
||||||
|
working_directory: build
|
||||||
|
|
||||||
|
|
||||||
|
build_deb:
|
||||||
|
description: Build Deb
|
||||||
|
steps:
|
||||||
|
- run:
|
||||||
|
name: make deb
|
||||||
|
command: dpkg-buildpackage -b -d -uc -us -nc -j2
|
||||||
|
|
||||||
|
|
||||||
|
install_opensuse_dependencies:
|
||||||
|
description: Install openSUSE dependencies
|
||||||
|
steps:
|
||||||
|
- run:
|
||||||
|
name: Update packages
|
||||||
|
command: zypper --non-interactive --gpg-auto-import-keys ref
|
||||||
|
- run:
|
||||||
|
name: Install openSUSE dependencies
|
||||||
|
command: >
|
||||||
|
zypper --non-interactive --gpg-auto-import-keys install
|
||||||
|
lsb-release
|
||||||
|
rpm-build
|
||||||
|
git
|
||||||
|
tar
|
||||||
|
make
|
||||||
|
cmake
|
||||||
|
gcc
|
||||||
|
gcc-c++
|
||||||
|
gettext-tools
|
||||||
|
glibc-devel
|
||||||
|
libboost_headers-devel
|
||||||
|
boost-devel
|
||||||
|
glib2-devel
|
||||||
|
glib2-tools
|
||||||
|
dbus-1-devel
|
||||||
|
alsa-devel
|
||||||
|
libnotify-devel
|
||||||
|
libgnutls-devel
|
||||||
|
protobuf-devel
|
||||||
|
sqlite3-devel
|
||||||
|
libpulse-devel
|
||||||
|
gstreamer-devel
|
||||||
|
gstreamer-plugins-base-devel
|
||||||
|
vlc-devel
|
||||||
|
libQt5Core-devel
|
||||||
|
libQt5Gui-devel
|
||||||
|
libQt5Widgets-devel
|
||||||
|
libQt5Concurrent-devel
|
||||||
|
libQt5Network-devel
|
||||||
|
libQt5Sql-devel
|
||||||
|
libQt5DBus-devel
|
||||||
|
libQt5Test-devel
|
||||||
|
libqt5-qtx11extras-devel
|
||||||
|
libqt5-qtbase-common-devel
|
||||||
|
libQt5Sql5-sqlite
|
||||||
|
libqt5-linguist-devel
|
||||||
|
libcdio-devel
|
||||||
|
libgpod-devel
|
||||||
|
libmtp-devel
|
||||||
|
libchromaprint-devel
|
||||||
|
desktop-file-utils
|
||||||
|
update-desktop-files
|
||||||
|
appstream-glib
|
||||||
|
hicolor-icon-theme
|
||||||
|
|
||||||
|
|
||||||
|
install_fedora_dependencies:
|
||||||
|
description: Install Fedora dependencies
|
||||||
|
steps:
|
||||||
|
- run:
|
||||||
|
name: Update packages
|
||||||
|
command: yum update --assumeyes
|
||||||
|
- run:
|
||||||
|
name: Upgrade packages
|
||||||
|
command: yum upgrade --assumeyes
|
||||||
|
- run:
|
||||||
|
name: Install Fedora dependencies
|
||||||
|
command: >
|
||||||
|
dnf install --assumeyes
|
||||||
|
@development-tools
|
||||||
|
redhat-lsb-core
|
||||||
|
git
|
||||||
|
glibc
|
||||||
|
gcc-c++
|
||||||
|
rpmdevtools
|
||||||
|
make
|
||||||
|
cmake
|
||||||
|
pkgconfig
|
||||||
|
glib
|
||||||
|
man
|
||||||
|
tar
|
||||||
|
gettext
|
||||||
|
openssh
|
||||||
|
boost-devel
|
||||||
|
dbus-devel
|
||||||
|
protobuf-devel
|
||||||
|
protobuf-compiler
|
||||||
|
sqlite-devel
|
||||||
|
alsa-lib-devel
|
||||||
|
pulseaudio-libs-devel
|
||||||
|
libnotify-devel
|
||||||
|
gnutls-devel
|
||||||
|
qt5-qtbase-devel
|
||||||
|
qt5-qtx11extras-devel
|
||||||
|
qt5-qttools-devel
|
||||||
|
gstreamer1-devel
|
||||||
|
gstreamer1-plugins-base-devel
|
||||||
|
taglib-devel
|
||||||
|
libcdio-devel
|
||||||
|
libgpod-devel
|
||||||
|
libmtp-devel
|
||||||
|
libchromaprint-devel
|
||||||
|
fftw-devel
|
||||||
|
desktop-file-utils
|
||||||
|
libappstream-glib
|
||||||
|
hicolor-icon-theme
|
||||||
|
|
||||||
|
|
||||||
|
install_centos_dependencies:
|
||||||
|
description: Install CentOS dependencies
|
||||||
|
steps:
|
||||||
|
- run:
|
||||||
|
name: Install epel-release
|
||||||
|
command: dnf install -y epel-release
|
||||||
|
- run:
|
||||||
|
name: Install epel-release-latest-8.noarch.rpm
|
||||||
|
command: dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
|
||||||
|
- run:
|
||||||
|
name: Install config-manager
|
||||||
|
command: dnf install -y 'dnf-command(config-manager)'
|
||||||
|
- run:
|
||||||
|
name: PowerTools
|
||||||
|
command: dnf config-manager --set-enabled PowerTools
|
||||||
|
- run:
|
||||||
|
name: DNF Clean All
|
||||||
|
command: dnf clean all
|
||||||
|
- run:
|
||||||
|
name: Update packages
|
||||||
|
command: dnf update -y
|
||||||
|
- run:
|
||||||
|
name: Install CentOS dependencies
|
||||||
|
command: >
|
||||||
|
dnf install -y
|
||||||
|
glibc
|
||||||
|
gcc-c++
|
||||||
|
make
|
||||||
|
libtool
|
||||||
|
cmake3
|
||||||
|
rpmdevtools
|
||||||
|
redhat-lsb-core
|
||||||
|
git
|
||||||
|
man
|
||||||
|
tar
|
||||||
|
gettext
|
||||||
|
boost-devel
|
||||||
|
fuse-devel
|
||||||
|
dbus-devel
|
||||||
|
libnotify-devel
|
||||||
|
gnutls-devel
|
||||||
|
sqlite-devel
|
||||||
|
protobuf-devel
|
||||||
|
protobuf-compiler
|
||||||
|
alsa-lib-devel
|
||||||
|
pulseaudio-libs-devel
|
||||||
|
qt5-devel
|
||||||
|
qt5-qtbase-devel
|
||||||
|
qt5-qtx11extras-devel
|
||||||
|
qt5-qttools-devel
|
||||||
|
fftw-devel
|
||||||
|
libchromaprint-devel
|
||||||
|
libcdio-devel
|
||||||
|
libgpod-devel
|
||||||
|
libmtp-devel
|
||||||
|
libjpeg-devel
|
||||||
|
cairo-devel
|
||||||
|
dbus-x11
|
||||||
|
xorg-x11-server-Xvfb
|
||||||
|
xorg-x11-xauth
|
||||||
|
vim-common
|
||||||
|
desktop-file-utils
|
||||||
|
libappstream-glib
|
||||||
|
appstream-data
|
||||||
|
hicolor-icon-theme
|
||||||
|
python3-pip
|
||||||
|
python3-devel
|
||||||
|
gstreamer1-devel
|
||||||
|
gstreamer1-plugins-base-devel
|
||||||
|
|
||||||
|
|
||||||
|
install_mageia_dependencies:
|
||||||
|
description: Install Mageia dependencies
|
||||||
|
steps:
|
||||||
|
- run:
|
||||||
|
name: Update packages
|
||||||
|
command: urpmi.update --auto -a
|
||||||
|
- run:
|
||||||
|
name: Configure auto update
|
||||||
|
command: urpmi --auto --auto-update
|
||||||
|
- run:
|
||||||
|
name: Install dependencies
|
||||||
|
command: >
|
||||||
|
urpmi --auto --force
|
||||||
|
urpmi-debuginfo-install
|
||||||
|
git
|
||||||
|
tar
|
||||||
|
rpmdevtools
|
||||||
|
make
|
||||||
|
cmake
|
||||||
|
glibc
|
||||||
|
binutils
|
||||||
|
gcc-c++
|
||||||
|
man
|
||||||
|
gettext
|
||||||
|
notification-daemon
|
||||||
|
dbus-devel
|
||||||
|
libgnutls-devel
|
||||||
|
lib64boost-devel
|
||||||
|
lib64protobuf-devel
|
||||||
|
protobuf-compiler
|
||||||
|
lib64sqlite3-devel
|
||||||
|
lib64alsa2-devel
|
||||||
|
lib64pulseaudio-devel
|
||||||
|
lib64notify-devel
|
||||||
|
lib64qt5core-devel
|
||||||
|
lib64qt5gui-devel
|
||||||
|
lib64qt5widgets-devel
|
||||||
|
lib64qt5network-devel
|
||||||
|
lib64qt5concurrent-devel
|
||||||
|
lib64qt5sql-devel
|
||||||
|
lib64qt5dbus-devel
|
||||||
|
lib64qt5x11extras-devel
|
||||||
|
lib64qt5help-devel
|
||||||
|
libqt5test-devel
|
||||||
|
lib64gstreamer1.0-devel
|
||||||
|
lib64gstreamer-plugins-base1.0-devel
|
||||||
|
lib64cdio-devel
|
||||||
|
lib64gpod-devel
|
||||||
|
lib64mtp-devel
|
||||||
|
lib64raw1394-devel
|
||||||
|
lib64chromaprint-devel
|
||||||
|
libfftw-devel
|
||||||
|
desktop-file-utils
|
||||||
|
appstream-util
|
||||||
|
libappstream-glib8
|
||||||
|
hicolor-icon-theme
|
||||||
|
qt5ct
|
||||||
|
lib64mesaegl1
|
||||||
|
|
||||||
|
|
||||||
|
install_debian_dependencies:
|
||||||
|
description: Install Debian dependencies
|
||||||
|
steps:
|
||||||
|
- run:
|
||||||
|
name: Install Debian dependencies
|
||||||
|
command: >
|
||||||
|
apt-get update && apt-get install -y
|
||||||
|
build-essential
|
||||||
|
ssh
|
||||||
|
git
|
||||||
|
make
|
||||||
|
cmake
|
||||||
|
gcc
|
||||||
|
pkg-config
|
||||||
|
fakeroot
|
||||||
|
gettext
|
||||||
|
lsb-release
|
||||||
|
libglib2.0-dev
|
||||||
|
dpkg-dev
|
||||||
|
libdbus-1-dev
|
||||||
|
libboost-dev
|
||||||
|
libprotobuf-dev
|
||||||
|
protobuf-compiler
|
||||||
|
libsqlite3-dev
|
||||||
|
libgnutls28-dev
|
||||||
|
libasound2-dev
|
||||||
|
libpulse-dev
|
||||||
|
qtbase5-dev
|
||||||
|
qtbase5-dev-tools
|
||||||
|
qtbase5-private-dev
|
||||||
|
libqt5x11extras5-dev
|
||||||
|
qttools5-dev
|
||||||
|
libgstreamer1.0-dev
|
||||||
|
libgstreamer-plugins-base1.0-dev
|
||||||
|
gstreamer1.0-alsa
|
||||||
|
gstreamer1.0-pulseaudio
|
||||||
|
libchromaprint-dev
|
||||||
|
libfftw3-dev
|
||||||
|
libcdio-dev
|
||||||
|
libmtp-dev
|
||||||
|
libgpod-dev
|
||||||
|
|
||||||
|
|
||||||
|
install_ubuntu_dependencies:
|
||||||
|
description: Install Ubuntu dependencies
|
||||||
|
steps:
|
||||||
|
- run:
|
||||||
|
name: Setup environment
|
||||||
|
command: |
|
||||||
|
echo 'export DEBIAN_FRONTEND=noninteractive' >> $BASH_ENV
|
||||||
|
source $BASH_ENV
|
||||||
|
- run:
|
||||||
|
name: Install Ubuntu dependencies
|
||||||
|
command: >
|
||||||
|
apt-get update && apt-get install -y
|
||||||
|
build-essential
|
||||||
|
ssh
|
||||||
|
git
|
||||||
|
make
|
||||||
|
cmake
|
||||||
|
pkg-config
|
||||||
|
gcc
|
||||||
|
fakeroot
|
||||||
|
wget
|
||||||
|
curl
|
||||||
|
gettext
|
||||||
|
lsb-release
|
||||||
|
dpkg-dev
|
||||||
|
libglib2.0-dev
|
||||||
|
libboost-dev
|
||||||
|
libdbus-1-dev
|
||||||
|
libprotobuf-dev
|
||||||
|
protobuf-compiler
|
||||||
|
libsqlite3-dev
|
||||||
|
libgnutls28-dev
|
||||||
|
libasound2-dev
|
||||||
|
libpulse-dev
|
||||||
|
qtbase5-dev
|
||||||
|
qtbase5-dev-tools
|
||||||
|
qtbase5-private-dev
|
||||||
|
libqt5x11extras5-dev
|
||||||
|
qttools5-dev
|
||||||
|
libgstreamer1.0-dev
|
||||||
|
libgstreamer-plugins-base1.0-dev
|
||||||
|
libgstreamer-plugins-good1.0-dev
|
||||||
|
gstreamer1.0-alsa
|
||||||
|
gstreamer1.0-pulseaudio
|
||||||
|
libchromaprint-dev
|
||||||
|
libfftw3-dev
|
||||||
|
libcdio-dev
|
||||||
|
libmtp-dev
|
||||||
|
libgpod-dev
|
||||||
|
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
|
||||||
|
build_source:
|
||||||
|
docker:
|
||||||
|
- image: opensuse/leap:15.1
|
||||||
|
steps:
|
||||||
|
- install_opensuse_dependencies
|
||||||
|
- checkout
|
||||||
|
- cmake
|
||||||
|
- build_source
|
||||||
|
|
||||||
|
|
||||||
|
build_opensuse_tumbleweed:
|
||||||
|
docker:
|
||||||
|
- image: opensuse/tumbleweed
|
||||||
|
environment:
|
||||||
|
RPM_BUILD_NCPUS: "2"
|
||||||
|
steps:
|
||||||
|
- run:
|
||||||
|
name: Update packages
|
||||||
|
command: zypper --non-interactive --gpg-auto-import-keys ref
|
||||||
|
- run:
|
||||||
|
name: Upgrade packages
|
||||||
|
command: zypper --non-interactive --gpg-auto-import-keys dup
|
||||||
|
- install_opensuse_dependencies
|
||||||
|
- checkout
|
||||||
|
- cmake
|
||||||
|
- build_source
|
||||||
|
- build_rpm
|
||||||
|
|
||||||
|
build_opensuse_lp151:
|
||||||
|
docker:
|
||||||
|
- image: opensuse/leap:15.1
|
||||||
|
environment:
|
||||||
|
RPM_BUILD_NCPUS: "2"
|
||||||
|
steps:
|
||||||
|
- install_opensuse_dependencies
|
||||||
|
- checkout
|
||||||
|
- cmake
|
||||||
|
- build_source
|
||||||
|
- build_rpm
|
||||||
|
|
||||||
|
build_opensuse_lp152:
|
||||||
|
docker:
|
||||||
|
- image: opensuse/leap:15.2
|
||||||
|
environment:
|
||||||
|
RPM_BUILD_NCPUS: "2"
|
||||||
|
steps:
|
||||||
|
- install_opensuse_dependencies
|
||||||
|
- checkout
|
||||||
|
- cmake
|
||||||
|
- build_source
|
||||||
|
- build_rpm
|
||||||
|
|
||||||
|
|
||||||
|
build_fedora_31:
|
||||||
|
docker:
|
||||||
|
- image: fedora:31
|
||||||
|
environment:
|
||||||
|
RPM_BUILD_NCPUS: "2"
|
||||||
|
steps:
|
||||||
|
- install_fedora_dependencies
|
||||||
|
- checkout
|
||||||
|
- cmake
|
||||||
|
- build_source
|
||||||
|
- build_rpm
|
||||||
|
|
||||||
|
build_fedora_32:
|
||||||
|
docker:
|
||||||
|
- image: fedora:32
|
||||||
|
environment:
|
||||||
|
RPM_BUILD_NCPUS: "2"
|
||||||
|
steps:
|
||||||
|
- install_fedora_dependencies
|
||||||
|
- checkout
|
||||||
|
- cmake
|
||||||
|
- build_source
|
||||||
|
- build_rpm
|
||||||
|
|
||||||
|
|
||||||
|
build_centos_8:
|
||||||
|
docker:
|
||||||
|
- image: centos:8
|
||||||
|
environment:
|
||||||
|
RPM_BUILD_NCPUS: "2"
|
||||||
|
steps:
|
||||||
|
- install_centos_dependencies
|
||||||
|
- checkout
|
||||||
|
- cmake
|
||||||
|
- build_source
|
||||||
|
- build_rpm
|
||||||
|
|
||||||
|
|
||||||
|
build_mageia_7:
|
||||||
|
docker:
|
||||||
|
- image: mageia:7
|
||||||
|
environment:
|
||||||
|
RPM_BUILD_NCPUS: "2"
|
||||||
|
steps:
|
||||||
|
- install_mageia_dependencies
|
||||||
|
- checkout
|
||||||
|
- cmake
|
||||||
|
- build_source
|
||||||
|
- build_rpm
|
||||||
|
|
||||||
|
|
||||||
|
build_debian_buster:
|
||||||
|
docker:
|
||||||
|
- image: debian:buster
|
||||||
|
steps:
|
||||||
|
- install_debian_dependencies
|
||||||
|
- checkout
|
||||||
|
- cmake
|
||||||
|
- build_deb
|
||||||
|
|
||||||
|
build_debian_bullseye:
|
||||||
|
docker:
|
||||||
|
- image: debian:bullseye
|
||||||
|
steps:
|
||||||
|
- install_debian_dependencies
|
||||||
|
- checkout
|
||||||
|
- cmake
|
||||||
|
- build_deb
|
||||||
|
|
||||||
|
|
||||||
|
build_ubuntu_bionic:
|
||||||
|
docker:
|
||||||
|
- image: ubuntu:bionic
|
||||||
|
steps:
|
||||||
|
- install_ubuntu_dependencies
|
||||||
|
- checkout
|
||||||
|
- cmake
|
||||||
|
- build_deb
|
||||||
|
|
||||||
|
build_ubuntu_focal:
|
||||||
|
docker:
|
||||||
|
- image: ubuntu:focal
|
||||||
|
steps:
|
||||||
|
- install_ubuntu_dependencies
|
||||||
|
- checkout
|
||||||
|
- cmake
|
||||||
|
- build_deb
|
||||||
|
|
||||||
|
build_ubuntu_groovy:
|
||||||
|
docker:
|
||||||
|
- image: ubuntu:groovy
|
||||||
|
steps:
|
||||||
|
- install_ubuntu_dependencies
|
||||||
|
- checkout
|
||||||
|
- cmake
|
||||||
|
- build_deb
|
||||||
|
|
||||||
|
workflows:
|
||||||
|
version: 2
|
||||||
|
build_all:
|
||||||
|
jobs:
|
||||||
|
|
||||||
|
- build_source:
|
||||||
|
filters:
|
||||||
|
tags:
|
||||||
|
only: /.*/
|
||||||
|
|
||||||
|
|
||||||
|
- build_opensuse_tumbleweed:
|
||||||
|
filters:
|
||||||
|
tags:
|
||||||
|
only: /.*/
|
||||||
|
- build_opensuse_lp151:
|
||||||
|
filters:
|
||||||
|
tags:
|
||||||
|
only: /.*/
|
||||||
|
- build_opensuse_lp152:
|
||||||
|
filters:
|
||||||
|
tags:
|
||||||
|
only: /.*/
|
||||||
|
|
||||||
|
|
||||||
|
- build_fedora_31:
|
||||||
|
filters:
|
||||||
|
tags:
|
||||||
|
only: /.*/
|
||||||
|
- build_fedora_32:
|
||||||
|
filters:
|
||||||
|
tags:
|
||||||
|
only: /.*/
|
||||||
|
|
||||||
|
|
||||||
|
- build_mageia_7:
|
||||||
|
filters:
|
||||||
|
tags:
|
||||||
|
only: /.*/
|
||||||
|
|
||||||
|
|
||||||
|
- build_centos_8:
|
||||||
|
filters:
|
||||||
|
tags:
|
||||||
|
only: /.*/
|
||||||
|
|
||||||
|
|
||||||
|
- build_debian_buster:
|
||||||
|
filters:
|
||||||
|
tags:
|
||||||
|
only: /.*/
|
||||||
|
- build_debian_bullseye:
|
||||||
|
filters:
|
||||||
|
tags:
|
||||||
|
only: /.*/
|
||||||
|
|
||||||
|
|
||||||
|
- build_ubuntu_bionic:
|
||||||
|
filters:
|
||||||
|
tags:
|
||||||
|
only: /.*/
|
||||||
|
- build_ubuntu_focal:
|
||||||
|
filters:
|
||||||
|
tags:
|
||||||
|
only: /.*/
|
||||||
|
- build_ubuntu_groovy:
|
||||||
|
filters:
|
||||||
|
tags:
|
||||||
|
only: /.*/
|
||||||
1
.github/FUNDING.yml
vendored
Normal file
1
.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
github: jonaski
|
||||||
29
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
29
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
---
|
||||||
|
name: Bug report
|
||||||
|
about: Create a report to help us improve
|
||||||
|
title: ''
|
||||||
|
labels: ''
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
For general technical questions and help with technical issues please use the forum on https://forum.strawberrymusicplayer.org/
|
||||||
|
|
||||||
|
**Describe the bug**
|
||||||
|
A clear and concise description of what the bug is.
|
||||||
|
|
||||||
|
**To Reproduce**
|
||||||
|
Steps to reproduce the behavior.
|
||||||
|
|
||||||
|
**Expected behavior**
|
||||||
|
A clear and concise description of what you expected to happen.
|
||||||
|
|
||||||
|
**Screenshots:**
|
||||||
|
If applicable, add screenshots to help explain your problem.
|
||||||
|
|
||||||
|
**System Information:**
|
||||||
|
- Operating system:
|
||||||
|
- Strawberry Version:
|
||||||
|
|
||||||
|
**Additional context**
|
||||||
|
Add any other context about the problem here.
|
||||||
1130
.github/workflows/ccpp.yml
vendored
Normal file
1130
.github/workflows/ccpp.yml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
6
.gitignore
vendored
6
.gitignore
vendored
@@ -73,6 +73,11 @@ CMakeLists.txt.user*
|
|||||||
target_wrapper.*
|
target_wrapper.*
|
||||||
compile_commands.json
|
compile_commands.json
|
||||||
|
|
||||||
|
*.kdev4
|
||||||
|
*.vscode
|
||||||
|
*.code-workspace
|
||||||
|
*.sublime-workspace
|
||||||
|
|
||||||
# Temporary files
|
# Temporary files
|
||||||
*~
|
*~
|
||||||
*.autosave
|
*.autosave
|
||||||
@@ -99,7 +104,6 @@ Thumbs.db
|
|||||||
|
|
||||||
# Stuff in dist
|
# Stuff in dist
|
||||||
maketarball.sh
|
maketarball.sh
|
||||||
create-dmg.sh
|
|
||||||
changelog
|
changelog
|
||||||
PKGBUILD
|
PKGBUILD
|
||||||
|
|
||||||
|
|||||||
61
.travis.yml
61
.travis.yml
@@ -1,53 +1,58 @@
|
|||||||
sudo: required
|
sudo: required
|
||||||
language: C++
|
language: C++
|
||||||
os:
|
os:
|
||||||
- linux
|
- osx
|
||||||
#- osx
|
|
||||||
services:
|
services:
|
||||||
- docker
|
- docker
|
||||||
compiler:
|
compiler:
|
||||||
- gcc
|
- gcc
|
||||||
- clang
|
|
||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
- echo $DEPLOY_KEY_ENC | base64 --decode | openssl aes-256-cbc -K $encrypted_83a41ac424a6_key -iv $encrypted_83a41ac424a6_iv -out ~/.ssh/id_rsa -d
|
- if ! [ "$DEPLOY_KEY_ENC" == "" ]; then
|
||||||
- chmod 600 ~/.ssh/id_rsa
|
echo $DEPLOY_KEY_ENC | base64 --decode | openssl aes-256-cbc -K $encrypted_83a41ac424a6_key -iv $encrypted_83a41ac424a6_iv -out ~/.ssh/id_rsa -d ;
|
||||||
|
chmod 600 ~/.ssh/id_rsa ;
|
||||||
|
fi
|
||||||
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
|
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
|
||||||
docker build -f Dockerfile -t strawberry-build .;
|
docker build -f Dockerfile -t strawberry-build . || travis_terminate 1;
|
||||||
docker run --name build -itd strawberry-build /bin/bash;
|
docker run --name build -itd strawberry-build /bin/bash || travis_terminate 1;
|
||||||
docker exec build git clone https://github.com/jonaski/strawberry;
|
docker exec build git clone https://github.com/strawberrymusicplayer/strawberry;
|
||||||
fi
|
fi
|
||||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
|
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
|
||||||
git fetch --unshallow;
|
git fetch --unshallow || travis_terminate 1;
|
||||||
git pull;
|
git pull || travis_terminate 1;
|
||||||
brew update;
|
brew unlink python@2 || travis_terminate 1;
|
||||||
brew unlink python;
|
brew install glib pkgconfig libffi protobuf protobuf-c qt gettext gnutls fftw sqlite chromaprint zlib taglib;
|
||||||
brew install glib pkgconfig libffi protobuf protobuf-c qt gettext;
|
brew install gstreamer gst-plugins-base gst-plugins-good gst-plugins-bad gst-plugins-ugly gst-libav;
|
||||||
brew install sqlite --with-fts;
|
brew install libcdio libmtp;
|
||||||
brew install gstreamer gst-plugins-base;
|
brew install create-dmg;
|
||||||
brew install gst-plugins-good --with-flac;
|
brew cask install sparkle;
|
||||||
brew install gst-plugins-bad gst-plugins-ugly gst-libav;
|
sudo ln -s /usr/local/Caskroom/sparkle/$(ls /usr/local/Caskroom/sparkle | head -n1)/Sparkle.framework /Library/Frameworks/Sparkle.framework;
|
||||||
brew install chromaprint;
|
sudo ln -s /usr/local/Caskroom/sparkle/$(ls /usr/local/Caskroom/sparkle | head -n1)/Sparkle.framework.dSYM /Library/Frameworks/Sparkle.framework.dSYM;
|
||||||
brew install libcdio libmtp libimobiledevice libplist;
|
|
||||||
export Qt5_DIR=/usr/local/opt/qt5/lib/cmake;
|
export Qt5_DIR=/usr/local/opt/qt5/lib/cmake;
|
||||||
export Qt5LinguistTools_DIR=/usr/local/Cellar/qt/$(ls /usr/local/Cellar/qt | head -n1)/lib/cmake/Qt5LinguistTools;
|
export Qt5LinguistTools_DIR=/usr/local/opt/qt5/lib/cmake/Qt5LinguistTools;
|
||||||
export PATH="/usr/local/opt/gettext/bin:$PATH";
|
export PATH="/usr/local/opt/gettext/bin:$PATH";
|
||||||
|
export PKG_CONFIG_PATH="/usr/local/opt/libffi/lib/pkgconfig/:/usr/local/opt/zlib/lib/pkgconfig:$PKG_CONFIG_PATH";
|
||||||
ls /usr/local/lib/gstreamer-1.0;
|
ls /usr/local/lib/gstreamer-1.0;
|
||||||
fi
|
fi
|
||||||
before_script:
|
before_script:
|
||||||
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then docker exec build cmake -Hstrawberry -Bbuild -DENABLE_TRANSLATIONS=ON ; fi
|
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then docker exec build cmake -Hstrawberry -Bbuild ; fi
|
||||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then mkdir build; cd build; cmake .. -DUSE_BUNDLE=ON -DENABLE_TRANSLATIONS=ON ; fi
|
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then mkdir build; cd build; cmake .. -DUSE_BUNDLE=ON ; fi
|
||||||
script:
|
script:
|
||||||
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then docker exec build make -C build -j8 ; fi
|
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then docker exec build make -C build -j8 ; fi
|
||||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
|
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
|
||||||
make -j8;
|
make -j8 || travis_terminate 1;
|
||||||
sudo make install;
|
make install || travis_terminate 1;
|
||||||
sudo ../dist/macos/macdeploy.py strawberry.app;
|
make dmg;
|
||||||
../dist/macos/create-dmg.sh strawberry.app $CC_FOR_BUILD;
|
|
||||||
fi
|
fi
|
||||||
after_success:
|
after_success:
|
||||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ls -lh strawberry.dmg; fi
|
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ls -lh strawberry*.dmg; fi
|
||||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]] && [[ "$TRAVIS_BRANCH" == "master" ]]; then rsync -e "ssh -o StrictHostKeyChecking=no" -va strawberry*.dmg travis@echoes.jkvinge.net:/home/travis/builds/macos; fi
|
- if [[ "$TRAVIS_OS_NAME" == "osx" ]] && [[ "$CC_FOR_BUILD" == "gcc" ]] && [ -f ~/.ssh/id_rsa ]; then
|
||||||
|
if [[ "$TRAVIS_BRANCH" == "master" ]]; then
|
||||||
|
rsync -e "ssh -o StrictHostKeyChecking=no" -va strawberry*.dmg travis@echoes.jkvinge.net:/home/travis/builds/macos;
|
||||||
|
elif [[ "$TRAVIS_BRANCH" == "macos" ]]; then
|
||||||
|
rsync -e "ssh -o StrictHostKeyChecking=no" -va strawberry*.dmg travis@echoes.jkvinge.net:/home/travis/builds/macos;
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
branches:
|
branches:
|
||||||
except:
|
except:
|
||||||
|
|||||||
19
3rdparty/README.md
vendored
19
3rdparty/README.md
vendored
@@ -19,7 +19,7 @@ TagLib is a library for reading and editing the meta-data of several popular aud
|
|||||||
by Strawberry to identify audio files. It is important that it is kept up-to-date for Strawberry to function
|
by Strawberry to identify audio files. It is important that it is kept up-to-date for Strawberry to function
|
||||||
correctly.
|
correctly.
|
||||||
|
|
||||||
It is kept in 3rdparty because there currently is no offical release of TagLib with the features and bugfixes
|
It is kept in 3rdparty because there currently is no official release of TagLib with the features and bugfixes
|
||||||
that are in the official repository. And also because some distros use older, or unpatched versions.
|
that are in the official repository. And also because some distros use older, or unpatched versions.
|
||||||
|
|
||||||
There is a bug in the latest version (1.11.1) corrupting Ogg files,
|
There is a bug in the latest version (1.11.1) corrupting Ogg files,
|
||||||
@@ -37,21 +37,6 @@ URL: https://github.com/taglib/taglib
|
|||||||
utf8-cpp
|
utf8-cpp
|
||||||
--------
|
--------
|
||||||
|
|
||||||
This is 2 header files used by taglib, but kept in a seperate directory because it is maintained by others.
|
This is 2 header files used by taglib, but kept in a separate directory because it is maintained by others.
|
||||||
|
|
||||||
URL: http://utfcpp.sourceforge.net/
|
URL: http://utfcpp.sourceforge.net/
|
||||||
|
|
||||||
|
|
||||||
qocoa
|
|
||||||
-----
|
|
||||||
This is a small static library currently used for the search fields above the collection, playlist and in
|
|
||||||
the cover manager. It is slightly modified from original version.
|
|
||||||
|
|
||||||
URL: https://github.com/mikemcquaid/Qocoa
|
|
||||||
|
|
||||||
|
|
||||||
SPMediaKeyTap
|
|
||||||
-------------
|
|
||||||
|
|
||||||
This is used for macOS only to enable strawberry to grab global shortcuts and can safely be deleted on other
|
|
||||||
platforms.
|
|
||||||
|
|||||||
13
3rdparty/SPMediaKeyTap/CMakeLists.txt
vendored
13
3rdparty/SPMediaKeyTap/CMakeLists.txt
vendored
@@ -1,13 +0,0 @@
|
|||||||
set(SPMEDIAKEY-SOURCES
|
|
||||||
SPMediaKeyTap.m
|
|
||||||
SPInvocationGrabbing/NSObject+SPInvocationGrabbing.m
|
|
||||||
)
|
|
||||||
|
|
||||||
set(SPMEDIAKEY-HEADERS
|
|
||||||
SPMediaKeyTap.h
|
|
||||||
SPInvocationGrabbing/NSObject+SPInvocationGrabbing.h
|
|
||||||
)
|
|
||||||
|
|
||||||
ADD_LIBRARY(SPMediaKeyTap STATIC
|
|
||||||
${SPMEDIAKEY-SOURCES}
|
|
||||||
)
|
|
||||||
8
3rdparty/SPMediaKeyTap/LICENSE
vendored
8
3rdparty/SPMediaKeyTap/LICENSE
vendored
@@ -1,8 +0,0 @@
|
|||||||
Copyright (c) 2011, Joachim Bengtsson
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Neither the name of the organization nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
12
3rdparty/SPMediaKeyTap/README.md
vendored
12
3rdparty/SPMediaKeyTap/README.md
vendored
@@ -1,12 +0,0 @@
|
|||||||
SPMediaKeyTap
|
|
||||||
=============
|
|
||||||
|
|
||||||
`SPMediaKeyTap` abstracts a `CGEventHook` and other nastiness in order to give you a relatively simple API to receive media key events (prev/next/playpause, on F7 to F9 on modern MacBook Pros) exclusively, without them reaching other applications like iTunes. `SPMediaKeyTap` is clever enough to resign its exclusive lock on media keys by looking for which application was active most recently: if that application is in `SPMediaKeyTap`'s whitelist, it will resign the keys. This is similar to the behavior of Apple's applications collaborating on media key handling exclusivity, but unfortunately, Apple are not exposing any APIs allowing third-parties to join in on this collaboration.
|
|
||||||
|
|
||||||
For now, the whitelist is just a hardcoded array in `+[SPMediaKeyTap defaultMediaKeyUserBundleIdentifiers]`. If your app starts using `SPMediaKeyTap`, please [mail me](mailto:nevyn@spotify.com) your bundle ID, and I'll include it in the canonical repository. This is a bad solution; a better solution would be to use distributed notifications to collaborate in creating this whitelist at runtime. Hopefully someone'll have the time and energy to write this soon.
|
|
||||||
|
|
||||||
In `Example/SPMediaKeyTapExampleAppDelegate.m` is an example of both how you use `SPMediaKeyTap`, and how you handle the semi-private `NSEvent` subtypes involved in media keys, including on how to fall back to non-event tap handling of these events.
|
|
||||||
|
|
||||||
`SPMediaKeyTap` and other `CGEventHook`s on the event type `NSSystemDefined` is known to interfere with each other and applications doing weird stuff with mouse input, because mouse clicks are also part of the `NSSystemDefined` category. The single issue we have had reported here at Spotify is Adobe Fireworks, in which item selection stops working with `SPMediaKeyTap` is active.
|
|
||||||
|
|
||||||
`SPMediaKeyTap` requires 10.5 to work, and disables itself on 10.4.
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
#import <Foundation/Foundation.h>
|
|
||||||
|
|
||||||
@interface SPInvocationGrabber : NSObject {
|
|
||||||
id _object;
|
|
||||||
NSInvocation *_invocation;
|
|
||||||
int frameCount;
|
|
||||||
char **frameStrings;
|
|
||||||
BOOL backgroundAfterForward;
|
|
||||||
BOOL onMainAfterForward;
|
|
||||||
BOOL waitUntilDone;
|
|
||||||
}
|
|
||||||
-(id)initWithObject:(id)obj;
|
|
||||||
-(id)initWithObject:(id)obj stacktraceSaving:(BOOL)saveStack;
|
|
||||||
@property (readonly, retain, nonatomic) id object;
|
|
||||||
@property (readonly, retain, nonatomic) NSInvocation *invocation;
|
|
||||||
@property BOOL backgroundAfterForward;
|
|
||||||
@property BOOL onMainAfterForward;
|
|
||||||
@property BOOL waitUntilDone;
|
|
||||||
-(void)invoke; // will release object and invocation
|
|
||||||
-(void)printBacktrace;
|
|
||||||
-(void)saveBacktrace;
|
|
||||||
@end
|
|
||||||
|
|
||||||
@interface NSObject (SPInvocationGrabbing)
|
|
||||||
-(id)grab;
|
|
||||||
-(id)invokeAfter:(NSTimeInterval)delta;
|
|
||||||
-(id)nextRunloop;
|
|
||||||
-(id)inBackground;
|
|
||||||
-(id)onMainAsync:(BOOL)async;
|
|
||||||
@end
|
|
||||||
@@ -1,128 +0,0 @@
|
|||||||
#import "NSObject+SPInvocationGrabbing.h"
|
|
||||||
#import <execinfo.h>
|
|
||||||
|
|
||||||
#pragma mark Invocation grabbing
|
|
||||||
@interface SPInvocationGrabber ()
|
|
||||||
@property (readwrite, retain, nonatomic) id object;
|
|
||||||
@property (readwrite, retain, nonatomic) NSInvocation *invocation;
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
@implementation SPInvocationGrabber
|
|
||||||
- (id)initWithObject:(id)obj;
|
|
||||||
{
|
|
||||||
return [self initWithObject:obj stacktraceSaving:YES];
|
|
||||||
}
|
|
||||||
|
|
||||||
-(id)initWithObject:(id)obj stacktraceSaving:(BOOL)saveStack;
|
|
||||||
{
|
|
||||||
self.object = obj;
|
|
||||||
|
|
||||||
if(saveStack)
|
|
||||||
[self saveBacktrace];
|
|
||||||
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
-(void)dealloc;
|
|
||||||
{
|
|
||||||
free(frameStrings);
|
|
||||||
self.object = nil;
|
|
||||||
self.invocation = nil;
|
|
||||||
[super dealloc];
|
|
||||||
}
|
|
||||||
@synthesize invocation = _invocation, object = _object;
|
|
||||||
|
|
||||||
@synthesize backgroundAfterForward, onMainAfterForward, waitUntilDone;
|
|
||||||
- (void)runInBackground;
|
|
||||||
{
|
|
||||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
|
||||||
@try {
|
|
||||||
[self invoke];
|
|
||||||
}
|
|
||||||
@finally {
|
|
||||||
[pool drain];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
- (void)forwardInvocation:(NSInvocation *)anInvocation {
|
|
||||||
[anInvocation retainArguments];
|
|
||||||
anInvocation.target = _object;
|
|
||||||
self.invocation = anInvocation;
|
|
||||||
|
|
||||||
if(backgroundAfterForward)
|
|
||||||
[NSThread detachNewThreadSelector:@selector(runInBackground) toTarget:self withObject:nil];
|
|
||||||
else if(onMainAfterForward)
|
|
||||||
[self performSelectorOnMainThread:@selector(invoke) withObject:nil waitUntilDone:waitUntilDone];
|
|
||||||
}
|
|
||||||
- (NSMethodSignature *)methodSignatureForSelector:(SEL)inSelector {
|
|
||||||
NSMethodSignature *signature = [super methodSignatureForSelector:inSelector];
|
|
||||||
if (signature == NULL)
|
|
||||||
signature = [_object methodSignatureForSelector:inSelector];
|
|
||||||
|
|
||||||
return signature;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)invoke;
|
|
||||||
{
|
|
||||||
|
|
||||||
@try {
|
|
||||||
[_invocation invoke];
|
|
||||||
}
|
|
||||||
@catch (NSException * e) {
|
|
||||||
NSLog(@"SPInvocationGrabber's target raised %@:\n\t%@\nInvocation was originally scheduled at:", e.name, e);
|
|
||||||
[self printBacktrace];
|
|
||||||
printf("\n");
|
|
||||||
[e raise];
|
|
||||||
}
|
|
||||||
|
|
||||||
self.invocation = nil;
|
|
||||||
self.object = nil;
|
|
||||||
}
|
|
||||||
|
|
||||||
-(void)saveBacktrace;
|
|
||||||
{
|
|
||||||
void *backtraceFrames[128];
|
|
||||||
frameCount = backtrace(&backtraceFrames[0], 128);
|
|
||||||
frameStrings = backtrace_symbols(&backtraceFrames[0], frameCount);
|
|
||||||
}
|
|
||||||
-(void)printBacktrace;
|
|
||||||
{
|
|
||||||
int x;
|
|
||||||
for(x = 3; x < frameCount; x++) {
|
|
||||||
if(frameStrings[x] == NULL) { break; }
|
|
||||||
printf("%s\n", frameStrings[x]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@end
|
|
||||||
|
|
||||||
@implementation NSObject (SPInvocationGrabbing)
|
|
||||||
-(id)grab;
|
|
||||||
{
|
|
||||||
return [[[SPInvocationGrabber alloc] initWithObject:self] autorelease];
|
|
||||||
}
|
|
||||||
-(id)invokeAfter:(NSTimeInterval)delta;
|
|
||||||
{
|
|
||||||
id grabber = [self grab];
|
|
||||||
[NSTimer scheduledTimerWithTimeInterval:delta target:grabber selector:@selector(invoke) userInfo:nil repeats:NO];
|
|
||||||
return grabber;
|
|
||||||
}
|
|
||||||
- (id)nextRunloop;
|
|
||||||
{
|
|
||||||
return [self invokeAfter:0];
|
|
||||||
}
|
|
||||||
-(id)inBackground;
|
|
||||||
{
|
|
||||||
SPInvocationGrabber *grabber = [self grab];
|
|
||||||
grabber.backgroundAfterForward = YES;
|
|
||||||
return grabber;
|
|
||||||
}
|
|
||||||
-(id)onMainAsync:(BOOL)async;
|
|
||||||
{
|
|
||||||
SPInvocationGrabber *grabber = [self grab];
|
|
||||||
grabber.onMainAfterForward = YES;
|
|
||||||
grabber.waitUntilDone = !async;
|
|
||||||
return grabber;
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
// A
|
|
||||||
+(UIView*)flashAt:(CGRect)r in:(UIView*)parent color:(UIColor*)color;
|
|
||||||
{
|
|
||||||
float duration = 0.5;
|
|
||||||
UIView *flash = [[[UIView alloc] initWithFrame:r] autorelease];
|
|
||||||
flash.backgroundColor = color;
|
|
||||||
[parent addSubview:flash];
|
|
||||||
[[flash invokeAfter:duration+0.1] removeFromSuperview];
|
|
||||||
|
|
||||||
[UIView beginAnimations:@"SPFlash" context:NULL];
|
|
||||||
[UIView setAnimationDuration:duration];
|
|
||||||
flash.alpha = 0.0;
|
|
||||||
[UIView commitAnimations];
|
|
||||||
return flash;
|
|
||||||
}
|
|
||||||
|
|
||||||
// B
|
|
||||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
||||||
|
|
||||||
// Force the animation to happen by calling this method again after a small
|
|
||||||
// delay - see http://blog.instapaper.com/post/53568356
|
|
||||||
[[self nextRunloop] delayedTableViewDidSelectRowAtIndexPath: indexPath];
|
|
||||||
}
|
|
||||||
|
|
||||||
// C
|
|
||||||
[[tableView invokeAfter:0.15] selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionNone];
|
|
||||||
[[tableView invokeAfter:0.30] deselectRowAtIndexPath:indexPath animated:YES];
|
|
||||||
[[tableView invokeAfter:0.45] selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionNone];
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
@interface MyClass : NSObject
|
|
||||||
-(BOOL)areTheNewViewersGoneYet:(Duck*)duck;
|
|
||||||
@end
|
|
||||||
...
|
|
||||||
MyClass *myInstance = [[MyClass alloc] init];
|
|
||||||
id invocationGrabber = [[[SPInvocationGrabber alloc] initWithTarget:myInstance] autorelease];
|
|
||||||
|
|
||||||
|
|
||||||
[invocationGrabber areTheNewViewersGoneYet:[Duck yellowDuck]]; // line 9
|
|
||||||
|
|
||||||
|
|
||||||
NSInvocation *invocationForAreTheNewViewersGoneYet = [invocationGrabber invocation];
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
#import <Cocoa/Cocoa.h>
|
|
||||||
#import "NSObject+SPInvocationGrabbing.h"
|
|
||||||
|
|
||||||
@interface Foo : NSObject {
|
|
||||||
int a;
|
|
||||||
}
|
|
||||||
-(void)startIt;
|
|
||||||
-(void)theBackgroundStuff;
|
|
||||||
-(void)theForegroundStuff;
|
|
||||||
@end
|
|
||||||
|
|
||||||
@implementation Foo
|
|
||||||
-(void)startIt;
|
|
||||||
{
|
|
||||||
NSLog(@"Starting out on the main thread...");
|
|
||||||
a = 3;
|
|
||||||
[[self inBackground] theBackgroundStuff];
|
|
||||||
}
|
|
||||||
-(void)theBackgroundStuff;
|
|
||||||
{
|
|
||||||
NSLog(@"Woah, this is a background thread!");
|
|
||||||
a += 6;
|
|
||||||
[[self onMainAsync:YES] theForegroundStuff];
|
|
||||||
}
|
|
||||||
-(void)theForegroundStuff;
|
|
||||||
{
|
|
||||||
NSLog(@"Hey presto: %d", a);
|
|
||||||
}
|
|
||||||
@end
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
|
||||||
Foo *foo = [Foo new];
|
|
||||||
[foo startIt];
|
|
||||||
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:1]];
|
|
||||||
[pool release];
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
34
3rdparty/SPMediaKeyTap/SPMediaKeyTap.h
vendored
34
3rdparty/SPMediaKeyTap/SPMediaKeyTap.h
vendored
@@ -1,34 +0,0 @@
|
|||||||
#include <Cocoa/Cocoa.h>
|
|
||||||
#import <IOKit/hidsystem/ev_keymap.h>
|
|
||||||
#import <Carbon/Carbon.h>
|
|
||||||
|
|
||||||
// http://overooped.com/post/2593597587/mediakeys
|
|
||||||
|
|
||||||
#define SPSystemDefinedEventMediaKeys 8
|
|
||||||
|
|
||||||
@interface SPMediaKeyTap : NSObject {
|
|
||||||
EventHandlerRef _app_switching_ref;
|
|
||||||
EventHandlerRef _app_terminating_ref;
|
|
||||||
CFMachPortRef _eventPort;
|
|
||||||
CFRunLoopSourceRef _eventPortSource;
|
|
||||||
CFRunLoopRef _tapThreadRL;
|
|
||||||
BOOL _shouldInterceptMediaKeyEvents;
|
|
||||||
id _delegate;
|
|
||||||
// The app that is frontmost in this list owns media keys
|
|
||||||
NSMutableArray *_mediaKeyAppList;
|
|
||||||
}
|
|
||||||
+ (NSArray*)defaultMediaKeyUserBundleIdentifiers;
|
|
||||||
|
|
||||||
-(id)initWithDelegate:(id)delegate;
|
|
||||||
|
|
||||||
+(BOOL)usesGlobalMediaKeyTap;
|
|
||||||
-(void)startWatchingMediaKeys;
|
|
||||||
-(void)stopWatchingMediaKeys;
|
|
||||||
-(void)handleAndReleaseMediaKeyEvent:(NSEvent *)event;
|
|
||||||
@end
|
|
||||||
|
|
||||||
@interface NSObject (SPMediaKeyTapDelegate)
|
|
||||||
-(void)mediaKeyTap:(SPMediaKeyTap*)keyTap receivedMediaKeyEvent:(NSEvent*)event;
|
|
||||||
@end
|
|
||||||
|
|
||||||
extern NSString *kMediaKeyUsingBundleIdentifiersDefaultsKey;
|
|
||||||
300
3rdparty/SPMediaKeyTap/SPMediaKeyTap.m
vendored
300
3rdparty/SPMediaKeyTap/SPMediaKeyTap.m
vendored
@@ -1,300 +0,0 @@
|
|||||||
// Copyright (c) 2010 Spotify AB
|
|
||||||
#import "SPMediaKeyTap.h"
|
|
||||||
#import "SPInvocationGrabbing/NSObject+SPInvocationGrabbing.h" // https://gist.github.com/511181, in submodule
|
|
||||||
|
|
||||||
@interface SPMediaKeyTap ()
|
|
||||||
-(BOOL)shouldInterceptMediaKeyEvents;
|
|
||||||
-(void)setShouldInterceptMediaKeyEvents:(BOOL)newSetting;
|
|
||||||
-(void)startWatchingAppSwitching;
|
|
||||||
-(void)stopWatchingAppSwitching;
|
|
||||||
-(void)eventTapThread;
|
|
||||||
@end
|
|
||||||
static SPMediaKeyTap *singleton = nil;
|
|
||||||
|
|
||||||
static pascal OSStatus appSwitched (EventHandlerCallRef nextHandler, EventRef evt, void* userData);
|
|
||||||
static pascal OSStatus appTerminated (EventHandlerCallRef nextHandler, EventRef evt, void* userData);
|
|
||||||
static CGEventRef tapEventCallback(CGEventTapProxy proxy, CGEventType type, CGEventRef event, void *refcon);
|
|
||||||
|
|
||||||
|
|
||||||
// Inspired by http://gist.github.com/546311
|
|
||||||
|
|
||||||
@implementation SPMediaKeyTap
|
|
||||||
|
|
||||||
#pragma mark -
|
|
||||||
#pragma mark Setup and teardown
|
|
||||||
-(id)initWithDelegate:(id)delegate;
|
|
||||||
{
|
|
||||||
_delegate = delegate;
|
|
||||||
[self startWatchingAppSwitching];
|
|
||||||
singleton = self;
|
|
||||||
_mediaKeyAppList = [NSMutableArray new];
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
-(void)dealloc;
|
|
||||||
{
|
|
||||||
[self stopWatchingMediaKeys];
|
|
||||||
[self stopWatchingAppSwitching];
|
|
||||||
[_mediaKeyAppList release];
|
|
||||||
[super dealloc];
|
|
||||||
}
|
|
||||||
|
|
||||||
-(void)startWatchingAppSwitching;
|
|
||||||
{
|
|
||||||
// Listen to "app switched" event, so that we don't intercept media keys if we
|
|
||||||
// weren't the last "media key listening" app to be active
|
|
||||||
EventTypeSpec eventType = { kEventClassApplication, kEventAppFrontSwitched };
|
|
||||||
OSStatus err = InstallApplicationEventHandler(NewEventHandlerUPP(appSwitched), 1, &eventType, self, &_app_switching_ref);
|
|
||||||
assert(err == noErr);
|
|
||||||
|
|
||||||
eventType.eventKind = kEventAppTerminated;
|
|
||||||
err = InstallApplicationEventHandler(NewEventHandlerUPP(appTerminated), 1, &eventType, self, &_app_terminating_ref);
|
|
||||||
assert(err == noErr);
|
|
||||||
}
|
|
||||||
-(void)stopWatchingAppSwitching;
|
|
||||||
{
|
|
||||||
if(!_app_switching_ref) return;
|
|
||||||
RemoveEventHandler(_app_switching_ref);
|
|
||||||
_app_switching_ref = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
-(void)startWatchingMediaKeys;{
|
|
||||||
[self setShouldInterceptMediaKeyEvents:YES];
|
|
||||||
|
|
||||||
// Add an event tap to intercept the system defined media key events
|
|
||||||
_eventPort = CGEventTapCreate(kCGSessionEventTap,
|
|
||||||
kCGHeadInsertEventTap,
|
|
||||||
kCGEventTapOptionDefault,
|
|
||||||
CGEventMaskBit(NX_SYSDEFINED),
|
|
||||||
tapEventCallback,
|
|
||||||
self);
|
|
||||||
assert(_eventPort != NULL);
|
|
||||||
|
|
||||||
_eventPortSource = CFMachPortCreateRunLoopSource(kCFAllocatorSystemDefault, _eventPort, 0);
|
|
||||||
assert(_eventPortSource != NULL);
|
|
||||||
|
|
||||||
// Let's do this in a separate thread so that a slow app doesn't lag the event tap
|
|
||||||
[NSThread detachNewThreadSelector:@selector(eventTapThread) toTarget:self withObject:nil];
|
|
||||||
}
|
|
||||||
-(void)stopWatchingMediaKeys;
|
|
||||||
{
|
|
||||||
// TODO<nevyn>: Shut down thread, remove event tap port and source
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma mark -
|
|
||||||
#pragma mark Accessors
|
|
||||||
|
|
||||||
+(BOOL)usesGlobalMediaKeyTap
|
|
||||||
{
|
|
||||||
#ifdef _DEBUG
|
|
||||||
// breaking in gdb with a key tap inserted sometimes locks up all mouse and keyboard input forever, forcing reboot
|
|
||||||
return NO;
|
|
||||||
#else
|
|
||||||
// XXX(nevyn): MediaKey event tap doesn't work on 10.4, feel free to figure out why if you have the energy.
|
|
||||||
return floor(NSAppKitVersionNumber) >= 949/*NSAppKitVersionNumber10_5*/;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
+ (NSArray*)defaultMediaKeyUserBundleIdentifiers;
|
|
||||||
{
|
|
||||||
return [NSArray arrayWithObjects:
|
|
||||||
[[NSBundle mainBundle] bundleIdentifier], // your app
|
|
||||||
@"com.spotify.client",
|
|
||||||
@"com.apple.iTunes",
|
|
||||||
@"com.apple.QuickTimePlayerX",
|
|
||||||
@"com.apple.quicktimeplayer",
|
|
||||||
@"com.apple.iWork.Keynote",
|
|
||||||
@"com.apple.iPhoto",
|
|
||||||
@"org.videolan.vlc",
|
|
||||||
@"com.apple.Aperture",
|
|
||||||
@"com.plexsquared.Plex",
|
|
||||||
@"com.soundcloud.desktop",
|
|
||||||
@"com.macromedia.fireworks", // the tap messes up their mouse input
|
|
||||||
nil
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
-(BOOL)shouldInterceptMediaKeyEvents;
|
|
||||||
{
|
|
||||||
BOOL shouldIntercept = NO;
|
|
||||||
@synchronized(self) {
|
|
||||||
shouldIntercept = _shouldInterceptMediaKeyEvents;
|
|
||||||
}
|
|
||||||
return shouldIntercept;
|
|
||||||
}
|
|
||||||
|
|
||||||
-(void)pauseTapOnTapThread:(BOOL)yeahno;
|
|
||||||
{
|
|
||||||
CGEventTapEnable(self->_eventPort, yeahno);
|
|
||||||
}
|
|
||||||
-(void)setShouldInterceptMediaKeyEvents:(BOOL)newSetting;
|
|
||||||
{
|
|
||||||
BOOL oldSetting;
|
|
||||||
@synchronized(self) {
|
|
||||||
oldSetting = _shouldInterceptMediaKeyEvents;
|
|
||||||
_shouldInterceptMediaKeyEvents = newSetting;
|
|
||||||
}
|
|
||||||
if(_tapThreadRL && oldSetting != newSetting) {
|
|
||||||
id grab = [self grab];
|
|
||||||
[grab pauseTapOnTapThread:newSetting];
|
|
||||||
NSTimer *timer = [NSTimer timerWithTimeInterval:0 invocation:[grab invocation] repeats:NO];
|
|
||||||
CFRunLoopAddTimer(_tapThreadRL, (CFRunLoopTimerRef)timer, kCFRunLoopCommonModes);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma mark
|
|
||||||
#pragma mark -
|
|
||||||
#pragma mark Event tap callbacks
|
|
||||||
|
|
||||||
// Note: method called on background thread
|
|
||||||
|
|
||||||
static CGEventRef tapEventCallback2(CGEventTapProxy proxy, CGEventType type, CGEventRef event, void *refcon)
|
|
||||||
{
|
|
||||||
SPMediaKeyTap *self = refcon;
|
|
||||||
|
|
||||||
if(type == kCGEventTapDisabledByTimeout) {
|
|
||||||
NSLog(@"Media key event tap was disabled by timeout");
|
|
||||||
CGEventTapEnable(self->_eventPort, TRUE);
|
|
||||||
return event;
|
|
||||||
} else if(type == kCGEventTapDisabledByUserInput) {
|
|
||||||
// Was disabled manually by -[pauseTapOnTapThread]
|
|
||||||
return event;
|
|
||||||
}
|
|
||||||
NSEvent *nsEvent = nil;
|
|
||||||
@try {
|
|
||||||
nsEvent = [NSEvent eventWithCGEvent:event];
|
|
||||||
}
|
|
||||||
@catch (NSException * e) {
|
|
||||||
NSLog(@"Strange CGEventType: %d: %@", type, e);
|
|
||||||
assert(0);
|
|
||||||
return event;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type != NX_SYSDEFINED || [nsEvent subtype] != SPSystemDefinedEventMediaKeys)
|
|
||||||
return event;
|
|
||||||
|
|
||||||
int keyCode = (([nsEvent data1] & 0xFFFF0000) >> 16);
|
|
||||||
if (keyCode != NX_KEYTYPE_PLAY && keyCode != NX_KEYTYPE_FAST && keyCode != NX_KEYTYPE_REWIND)
|
|
||||||
return event;
|
|
||||||
|
|
||||||
if (![self shouldInterceptMediaKeyEvents])
|
|
||||||
return event;
|
|
||||||
|
|
||||||
[nsEvent retain]; // matched in handleAndReleaseMediaKeyEvent:
|
|
||||||
[self performSelectorOnMainThread:@selector(handleAndReleaseMediaKeyEvent:) withObject:nsEvent waitUntilDone:NO];
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static CGEventRef tapEventCallback(CGEventTapProxy proxy, CGEventType type, CGEventRef event, void *refcon)
|
|
||||||
{
|
|
||||||
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
|
||||||
CGEventRef ret = tapEventCallback2(proxy, type, event, refcon);
|
|
||||||
[pool drain];
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// event will have been retained in the other thread
|
|
||||||
-(void)handleAndReleaseMediaKeyEvent:(NSEvent *)event {
|
|
||||||
[event autorelease];
|
|
||||||
|
|
||||||
[_delegate mediaKeyTap:self receivedMediaKeyEvent:event];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
-(void)eventTapThread;
|
|
||||||
{
|
|
||||||
_tapThreadRL = CFRunLoopGetCurrent();
|
|
||||||
CFRunLoopAddSource(_tapThreadRL, _eventPortSource, kCFRunLoopCommonModes);
|
|
||||||
CFRunLoopRun();
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma mark Task switching callbacks
|
|
||||||
|
|
||||||
NSString *kMediaKeyUsingBundleIdentifiersDefaultsKey = @"SPApplicationsNeedingMediaKeys";
|
|
||||||
|
|
||||||
|
|
||||||
-(void)mediaKeyAppListChanged;
|
|
||||||
{
|
|
||||||
if([_mediaKeyAppList count] == 0) return;
|
|
||||||
|
|
||||||
/*NSLog(@"--");
|
|
||||||
int i = 0;
|
|
||||||
for (NSValue *psnv in _mediaKeyAppList) {
|
|
||||||
ProcessSerialNumber psn; [psnv getValue:&psn];
|
|
||||||
NSDictionary *processInfo = [(id)ProcessInformationCopyDictionary(
|
|
||||||
&psn,
|
|
||||||
kProcessDictionaryIncludeAllInformationMask
|
|
||||||
) autorelease];
|
|
||||||
NSString *bundleIdentifier = [processInfo objectForKey:(id)kCFBundleIdentifierKey];
|
|
||||||
NSLog(@"%d: %@", i++, bundleIdentifier);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
ProcessSerialNumber mySerial, topSerial;
|
|
||||||
GetCurrentProcess(&mySerial);
|
|
||||||
[[_mediaKeyAppList objectAtIndex:0] getValue:&topSerial];
|
|
||||||
|
|
||||||
Boolean same;
|
|
||||||
OSErr err = SameProcess(&mySerial, &topSerial, &same);
|
|
||||||
[self setShouldInterceptMediaKeyEvents:(err == noErr && same)];
|
|
||||||
|
|
||||||
}
|
|
||||||
-(void)appIsNowFrontmost:(ProcessSerialNumber)psn;
|
|
||||||
{
|
|
||||||
NSValue *psnv = [NSValue valueWithBytes:&psn objCType:@encode(ProcessSerialNumber)];
|
|
||||||
|
|
||||||
NSDictionary *processInfo = [(id)ProcessInformationCopyDictionary(
|
|
||||||
&psn,
|
|
||||||
kProcessDictionaryIncludeAllInformationMask
|
|
||||||
) autorelease];
|
|
||||||
NSString *bundleIdentifier = [processInfo objectForKey:(id)kCFBundleIdentifierKey];
|
|
||||||
|
|
||||||
NSArray *whitelistIdentifiers = [[NSUserDefaults standardUserDefaults] arrayForKey:kMediaKeyUsingBundleIdentifiersDefaultsKey];
|
|
||||||
if(![whitelistIdentifiers containsObject:bundleIdentifier]) return;
|
|
||||||
|
|
||||||
[_mediaKeyAppList removeObject:psnv];
|
|
||||||
[_mediaKeyAppList insertObject:psnv atIndex:0];
|
|
||||||
[self mediaKeyAppListChanged];
|
|
||||||
}
|
|
||||||
-(void)appTerminated:(ProcessSerialNumber)psn;
|
|
||||||
{
|
|
||||||
NSValue *psnv = [NSValue valueWithBytes:&psn objCType:@encode(ProcessSerialNumber)];
|
|
||||||
[_mediaKeyAppList removeObject:psnv];
|
|
||||||
[self mediaKeyAppListChanged];
|
|
||||||
}
|
|
||||||
|
|
||||||
static pascal OSStatus appSwitched (EventHandlerCallRef nextHandler, EventRef evt, void* userData)
|
|
||||||
{
|
|
||||||
SPMediaKeyTap *self = (id)userData;
|
|
||||||
|
|
||||||
ProcessSerialNumber newSerial;
|
|
||||||
GetFrontProcess(&newSerial);
|
|
||||||
|
|
||||||
[self appIsNowFrontmost:newSerial];
|
|
||||||
|
|
||||||
return CallNextEventHandler(nextHandler, evt);
|
|
||||||
}
|
|
||||||
|
|
||||||
static pascal OSStatus appTerminated (EventHandlerCallRef nextHandler, EventRef evt, void* userData)
|
|
||||||
{
|
|
||||||
SPMediaKeyTap *self = (id)userData;
|
|
||||||
|
|
||||||
ProcessSerialNumber deadPSN;
|
|
||||||
|
|
||||||
GetEventParameter(
|
|
||||||
evt,
|
|
||||||
kEventParamProcessID,
|
|
||||||
typeProcessSerialNumber,
|
|
||||||
NULL,
|
|
||||||
sizeof(deadPSN),
|
|
||||||
NULL,
|
|
||||||
&deadPSN
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
[self appTerminated:deadPSN];
|
|
||||||
return CallNextEventHandler(nextHandler, evt);
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
|
||||||
25
3rdparty/SPMediaKeyTap/SPMediaKeyTapDelegate.m
vendored
25
3rdparty/SPMediaKeyTap/SPMediaKeyTapDelegate.m
vendored
@@ -1,25 +0,0 @@
|
|||||||
-(void)mediaKeyTap:(SPMediaKeyTap*)keyTap receivedMediaKeyEvent:(NSEvent*)event;
|
|
||||||
{
|
|
||||||
assert([event type] == NSSystemDefined && [event subtype] == SPSystemDefinedEventMediaKeys);
|
|
||||||
|
|
||||||
int keyCode = (([event data1] & 0xFFFF0000) >> 16);
|
|
||||||
int keyFlags = ([event data1] & 0x0000FFFF);
|
|
||||||
int keyState = (((keyFlags & 0xFF00) >> 8)) == 0xA;
|
|
||||||
int keyRepeat = (keyFlags & 0x1);
|
|
||||||
|
|
||||||
if (keyState == 1 && windowController != NULL) {
|
|
||||||
|
|
||||||
|
|
||||||
switch (keyCode) {
|
|
||||||
|
|
||||||
case NX_KEYTYPE_PLAY:
|
|
||||||
... return;
|
|
||||||
|
|
||||||
case NX_KEYTYPE_FAST:
|
|
||||||
... return;
|
|
||||||
|
|
||||||
case NX_KEYTYPE_REWIND:
|
|
||||||
... return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
35
3rdparty/qocoa/CMakeLists.txt
vendored
35
3rdparty/qocoa/CMakeLists.txt
vendored
@@ -1,35 +0,0 @@
|
|||||||
cmake_minimum_required(VERSION 2.8.11)
|
|
||||||
set(CMAKE_CXX_STANDARD 11)
|
|
||||||
|
|
||||||
set(SOURCES)
|
|
||||||
|
|
||||||
set(HEADERS
|
|
||||||
qsearchfield.h
|
|
||||||
qbutton.h
|
|
||||||
qprogressindicatorspinning.h
|
|
||||||
)
|
|
||||||
|
|
||||||
qt5_wrap_cpp(MOC_SOURCES ${HEADERS})
|
|
||||||
|
|
||||||
if(APPLE)
|
|
||||||
list(APPEND SOURCES
|
|
||||||
qsearchfield_mac.mm
|
|
||||||
qbutton_mac.mm
|
|
||||||
qprogressindicatorspinning_mac.mm
|
|
||||||
)
|
|
||||||
else()
|
|
||||||
list(APPEND SOURCES
|
|
||||||
qsearchfield_nonmac.cpp
|
|
||||||
qbutton_nonmac.cpp
|
|
||||||
qprogressindicatorspinning_nonmac.cpp
|
|
||||||
)
|
|
||||||
set(RESOURCES
|
|
||||||
qsearchfield_nonmac.qrc
|
|
||||||
qprogressindicatorspinning_nonmac.qrc
|
|
||||||
)
|
|
||||||
qt5_add_resources(RESOURCES_SOURCES ${RESOURCES})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_library(Qocoa STATIC ${SOURCES} ${MOC_SOURCES} ${RESOURCES_SOURCES})
|
|
||||||
target_link_libraries(Qocoa ${QT_LIBRARIES})
|
|
||||||
|
|
||||||
19
3rdparty/qocoa/LICENSE.txt
vendored
19
3rdparty/qocoa/LICENSE.txt
vendored
@@ -1,19 +0,0 @@
|
|||||||
Copyright (C) 2011 by Mike McQuaid
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
|
||||||
all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
THE SOFTWARE.
|
|
||||||
38
3rdparty/qocoa/README.md
vendored
38
3rdparty/qocoa/README.md
vendored
@@ -1,38 +0,0 @@
|
|||||||
# Qocoa
|
|
||||||
Qocoa is a collection of Qt wrappers for OSX's Cocoa widgets.
|
|
||||||
|
|
||||||
## Features
|
|
||||||
- basic fallback to sensible Qt types on non-OSX platforms
|
|
||||||
- shared class headers which expose no implementation details
|
|
||||||
- typical Qt signal/slot-based API
|
|
||||||
- trivial to import into projects (class header/implementation, [single shared global header](https://github.com/mikemcquaid/Qocoa/blob/master/qocoa_mac.h))
|
|
||||||
|
|
||||||
## Building
|
|
||||||
```
|
|
||||||
git clone git://github.com/mikemcquaid/Qocoa.git
|
|
||||||
cd Qocoa
|
|
||||||
qmake # or cmake .
|
|
||||||
make
|
|
||||||
```
|
|
||||||
|
|
||||||
## Status
|
|
||||||
I'm not personally working on this any more but will accept pull-requests.
|
|
||||||
|
|
||||||
[](https://travis-ci.org/MikeMcQuaid/Qocoa)
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
For each class you want to use copy the [`qocoa_mac.h`](https://github.com/mikemcquaid/Qocoa/blob/master/qocoa_mac.h), `$CLASS.h`, `$CLASS_mac.*` and `$CLASS_nonmac.*` files into your source tree and add them to your buildsystem. Examples are provided for [CMake](https://github.com/mikemcquaid/Qocoa/blob/master/CMakeLists.txt) and [QMake](https://github.com/mikemcquaid/Qocoa/blob/master/Qocoa.pro).
|
|
||||||
|
|
||||||
## Contact
|
|
||||||
[Mike McQuaid](mailto:mike@mikemcquaid.com)
|
|
||||||
|
|
||||||
## License
|
|
||||||
Qocoa is licensed under the [MIT License](http://en.wikipedia.org/wiki/MIT_License).
|
|
||||||
The full license text is available in [LICENSE.txt](https://github.com/mikemcquaid/Qocoa/blob/master/LICENSE.txt).
|
|
||||||
|
|
||||||
Magnifier and EditClear icons taken from [QtCreator](http://qt-project.org/) and are licensed under the [LGPL](http://www.gnu.org/copyleft/lesser.html).
|
|
||||||
|
|
||||||
Other icons are taken from the [Oxygen Project](http://www.oxygen-icons.org/) and are licensed under the [Creative Commons Attribution-ShareAlike 3.0 License](http://creativecommons.org/licenses/by-sa/3.0/).
|
|
||||||
|
|
||||||
## Gallery
|
|
||||||

|
|
||||||
13
3rdparty/qocoa/TODO.md
vendored
13
3rdparty/qocoa/TODO.md
vendored
@@ -1,13 +0,0 @@
|
|||||||
Widgets I hope to implement (or at least investigate):
|
|
||||||
|
|
||||||
- NSTokenField
|
|
||||||
- NSSegmentedControl
|
|
||||||
- NSLevelIndicator
|
|
||||||
- NSPathControl
|
|
||||||
- NSSlider (Circular)
|
|
||||||
- NSSplitView
|
|
||||||
- NSTextFinder
|
|
||||||
- NSOutlineView in an NSScrollView (Source List)
|
|
||||||
- NSDrawer
|
|
||||||
- PDFView
|
|
||||||
- WebView
|
|
||||||
49
3rdparty/qocoa/qbutton.h
vendored
49
3rdparty/qocoa/qbutton.h
vendored
@@ -1,49 +0,0 @@
|
|||||||
#ifndef QBUTTON_H
|
|
||||||
#define QBUTTON_H
|
|
||||||
|
|
||||||
#include <QWidget>
|
|
||||||
#include <QPointer>
|
|
||||||
|
|
||||||
class QButtonPrivate;
|
|
||||||
class QButton : public QWidget
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
// Matches NSBezelStyle
|
|
||||||
enum BezelStyle {
|
|
||||||
Rounded = 1,
|
|
||||||
RegularSquare = 2,
|
|
||||||
Disclosure = 5,
|
|
||||||
ShadowlessSquare = 6,
|
|
||||||
Circular = 7,
|
|
||||||
TexturedSquare = 8,
|
|
||||||
HelpButton = 9,
|
|
||||||
SmallSquare = 10,
|
|
||||||
TexturedRounded = 11,
|
|
||||||
RoundRect = 12,
|
|
||||||
Recessed = 13,
|
|
||||||
RoundedDisclosure = 14,
|
|
||||||
#ifdef __MAC_10_7
|
|
||||||
Inline = 15
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
explicit QButton(QWidget *parent, BezelStyle bezelStyle = Rounded);
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void setText(const QString &text);
|
|
||||||
void setImage(const QPixmap &image);
|
|
||||||
void setChecked(bool checked);
|
|
||||||
|
|
||||||
public:
|
|
||||||
void setCheckable(bool checkable);
|
|
||||||
bool isChecked();
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void clicked(bool checked = false);
|
|
||||||
|
|
||||||
private:
|
|
||||||
friend class QButtonPrivate;
|
|
||||||
QPointer<QButtonPrivate> pimpl;
|
|
||||||
};
|
|
||||||
#endif // QBUTTON_H
|
|
||||||
229
3rdparty/qocoa/qbutton_mac.mm
vendored
229
3rdparty/qocoa/qbutton_mac.mm
vendored
@@ -1,229 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright (C) 2011 by Mike McQuaid
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
|
||||||
all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "qbutton.h"
|
|
||||||
|
|
||||||
#include "qocoa_mac.h"
|
|
||||||
|
|
||||||
#import "Foundation/NSAutoreleasePool.h"
|
|
||||||
#import "AppKit/NSButton.h"
|
|
||||||
#import "AppKit/NSFont.h"
|
|
||||||
|
|
||||||
class QButtonPrivate : public QObject
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
QButtonPrivate(QButton *qButton, NSButton *nsButton, QButton::BezelStyle bezelStyle)
|
|
||||||
: QObject(qButton), qButton(qButton), nsButton(nsButton)
|
|
||||||
{
|
|
||||||
switch(bezelStyle) {
|
|
||||||
case QButton::Disclosure:
|
|
||||||
case QButton::Circular:
|
|
||||||
#ifdef __MAC_10_7
|
|
||||||
case QButton::Inline:
|
|
||||||
#endif
|
|
||||||
case QButton::RoundedDisclosure:
|
|
||||||
case QButton::HelpButton:
|
|
||||||
[nsButton setTitle:@""];
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
NSFont* font = 0;
|
|
||||||
switch(bezelStyle) {
|
|
||||||
case QButton::RoundRect:
|
|
||||||
font = [NSFont fontWithName:@"Lucida Grande" size:12];
|
|
||||||
break;
|
|
||||||
|
|
||||||
case QButton::Recessed:
|
|
||||||
font = [NSFont fontWithName:@"Lucida Grande Bold" size:12];
|
|
||||||
break;
|
|
||||||
|
|
||||||
#ifdef __MAC_10_7
|
|
||||||
case QButton::Inline:
|
|
||||||
font = [NSFont boldSystemFontOfSize:[NSFont systemFontSizeForControlSize:NSSmallControlSize]];
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
default:
|
|
||||||
font = [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSRegularControlSize]];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
[nsButton setFont:font];
|
|
||||||
|
|
||||||
switch(bezelStyle) {
|
|
||||||
case QButton::Rounded:
|
|
||||||
qButton->setMinimumWidth(40);
|
|
||||||
qButton->setFixedHeight(24);
|
|
||||||
qButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
|
|
||||||
break;
|
|
||||||
case QButton::RegularSquare:
|
|
||||||
case QButton::TexturedSquare:
|
|
||||||
qButton->setMinimumSize(14, 23);
|
|
||||||
qButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
|
||||||
break;
|
|
||||||
case QButton::ShadowlessSquare:
|
|
||||||
qButton->setMinimumSize(5, 25);
|
|
||||||
qButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
|
||||||
break;
|
|
||||||
case QButton::SmallSquare:
|
|
||||||
qButton->setMinimumSize(4, 21);
|
|
||||||
qButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
|
||||||
break;
|
|
||||||
case QButton::TexturedRounded:
|
|
||||||
qButton->setMinimumSize(10, 22);
|
|
||||||
qButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
|
||||||
break;
|
|
||||||
case QButton::RoundRect:
|
|
||||||
case QButton::Recessed:
|
|
||||||
qButton->setMinimumWidth(16);
|
|
||||||
qButton->setFixedHeight(18);
|
|
||||||
qButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
|
|
||||||
break;
|
|
||||||
case QButton::Disclosure:
|
|
||||||
qButton->setMinimumWidth(13);
|
|
||||||
qButton->setFixedHeight(13);
|
|
||||||
qButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
|
|
||||||
break;
|
|
||||||
case QButton::Circular:
|
|
||||||
qButton->setMinimumSize(16, 16);
|
|
||||||
qButton->setMaximumHeight(40);
|
|
||||||
qButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
|
||||||
break;
|
|
||||||
case QButton::HelpButton:
|
|
||||||
case QButton::RoundedDisclosure:
|
|
||||||
qButton->setMinimumWidth(22);
|
|
||||||
qButton->setFixedHeight(22);
|
|
||||||
qButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
|
|
||||||
break;
|
|
||||||
#ifdef __MAC_10_7
|
|
||||||
case QButton::Inline:
|
|
||||||
qButton->setMinimumWidth(10);
|
|
||||||
qButton->setFixedHeight(16);
|
|
||||||
qButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
switch(bezelStyle) {
|
|
||||||
case QButton::Recessed:
|
|
||||||
[nsButton setButtonType:NSPushOnPushOffButton];
|
|
||||||
case QButton::Disclosure:
|
|
||||||
[nsButton setButtonType:NSOnOffButton];
|
|
||||||
default:
|
|
||||||
[nsButton setButtonType:NSMomentaryPushInButton];
|
|
||||||
}
|
|
||||||
|
|
||||||
[nsButton setBezelStyle:(__bridge NSBezelStyle)bezelStyle];
|
|
||||||
}
|
|
||||||
|
|
||||||
void clicked()
|
|
||||||
{
|
|
||||||
emit qButton->clicked(qButton->isChecked());
|
|
||||||
}
|
|
||||||
|
|
||||||
~QButtonPrivate() {
|
|
||||||
[[nsButton target] release];
|
|
||||||
[nsButton setTarget:nil];
|
|
||||||
}
|
|
||||||
|
|
||||||
QButton *qButton;
|
|
||||||
NSButton *nsButton;
|
|
||||||
};
|
|
||||||
|
|
||||||
@interface QButtonTarget : NSObject
|
|
||||||
{
|
|
||||||
@public
|
|
||||||
QPointer<QButtonPrivate> pimpl;
|
|
||||||
}
|
|
||||||
-(void)clicked;
|
|
||||||
@end
|
|
||||||
|
|
||||||
@implementation QButtonTarget
|
|
||||||
-(void)clicked {
|
|
||||||
Q_ASSERT(pimpl);
|
|
||||||
if (pimpl)
|
|
||||||
pimpl->clicked();
|
|
||||||
}
|
|
||||||
@end
|
|
||||||
|
|
||||||
QButton::QButton(QWidget *parent, BezelStyle bezelStyle) : QWidget(parent)
|
|
||||||
{
|
|
||||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
|
||||||
|
|
||||||
NSButton *button = [[NSButton alloc] init];
|
|
||||||
pimpl = new QButtonPrivate(this, button, bezelStyle);
|
|
||||||
|
|
||||||
QButtonTarget *target = [[QButtonTarget alloc] init];
|
|
||||||
target->pimpl = pimpl;
|
|
||||||
[button setTarget:target];
|
|
||||||
|
|
||||||
[button setAction:@selector(clicked)];
|
|
||||||
|
|
||||||
setupLayout(button, this);
|
|
||||||
|
|
||||||
[button release];
|
|
||||||
|
|
||||||
[pool drain];
|
|
||||||
}
|
|
||||||
|
|
||||||
void QButton::setText(const QString &text)
|
|
||||||
{
|
|
||||||
Q_ASSERT(pimpl);
|
|
||||||
if (!pimpl)
|
|
||||||
return;
|
|
||||||
|
|
||||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
|
||||||
[pimpl->nsButton setTitle:fromQString(text)];
|
|
||||||
[pool drain];
|
|
||||||
}
|
|
||||||
|
|
||||||
void QButton::setImage(const QPixmap &image)
|
|
||||||
{
|
|
||||||
Q_ASSERT(pimpl);
|
|
||||||
if (pimpl)
|
|
||||||
[pimpl->nsButton setImage:fromQPixmap(image)];
|
|
||||||
}
|
|
||||||
|
|
||||||
void QButton::setChecked(bool checked)
|
|
||||||
{
|
|
||||||
Q_ASSERT(pimpl);
|
|
||||||
if (pimpl)
|
|
||||||
[pimpl->nsButton setState:checked];
|
|
||||||
}
|
|
||||||
|
|
||||||
void QButton::setCheckable(bool checkable)
|
|
||||||
{
|
|
||||||
const NSInteger cellMask = checkable ? NSChangeBackgroundCellMask : NSNoCellMask;
|
|
||||||
|
|
||||||
Q_ASSERT(pimpl);
|
|
||||||
if (pimpl)
|
|
||||||
[[pimpl->nsButton cell] setShowsStateBy:cellMask];
|
|
||||||
}
|
|
||||||
|
|
||||||
bool QButton::isChecked()
|
|
||||||
{
|
|
||||||
Q_ASSERT(pimpl);
|
|
||||||
if (!pimpl)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return [pimpl->nsButton state];
|
|
||||||
}
|
|
||||||
89
3rdparty/qocoa/qbutton_nonmac.cpp
vendored
89
3rdparty/qocoa/qbutton_nonmac.cpp
vendored
@@ -1,89 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright (C) 2011 by Mike McQuaid
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
|
||||||
all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "qbutton.h"
|
|
||||||
|
|
||||||
#include <QToolBar>
|
|
||||||
#include <QToolButton>
|
|
||||||
#include <QPushButton>
|
|
||||||
#include <QVBoxLayout>
|
|
||||||
|
|
||||||
class QButtonPrivate : public QObject
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
QButtonPrivate(QButton *button, QAbstractButton *abstractButton)
|
|
||||||
: QObject(button), abstractButton(abstractButton) {}
|
|
||||||
QPointer<QAbstractButton> abstractButton;
|
|
||||||
};
|
|
||||||
|
|
||||||
QButton::QButton(QWidget *parent, BezelStyle) : QWidget(parent)
|
|
||||||
{
|
|
||||||
QAbstractButton *button = 0;
|
|
||||||
if (qobject_cast<QToolBar*>(parent))
|
|
||||||
button = new QToolButton(this);
|
|
||||||
else
|
|
||||||
button = new QPushButton(this);
|
|
||||||
connect(button, SIGNAL(clicked()),
|
|
||||||
this, SIGNAL(clicked()));
|
|
||||||
pimpl = new QButtonPrivate(this, button);
|
|
||||||
|
|
||||||
QVBoxLayout *layout = new QVBoxLayout(this);
|
|
||||||
layout->setMargin(0);
|
|
||||||
layout->addWidget(button);
|
|
||||||
}
|
|
||||||
|
|
||||||
void QButton::setText(const QString &text)
|
|
||||||
{
|
|
||||||
Q_ASSERT(pimpl);
|
|
||||||
if (pimpl)
|
|
||||||
pimpl->abstractButton->setText(text);
|
|
||||||
}
|
|
||||||
|
|
||||||
void QButton::setImage(const QPixmap &image)
|
|
||||||
{
|
|
||||||
Q_ASSERT(pimpl);
|
|
||||||
if (pimpl)
|
|
||||||
pimpl->abstractButton->setIcon(image);
|
|
||||||
}
|
|
||||||
|
|
||||||
void QButton::setChecked(bool checked)
|
|
||||||
{
|
|
||||||
Q_ASSERT(pimpl);
|
|
||||||
if (pimpl)
|
|
||||||
pimpl->abstractButton->setChecked(checked);
|
|
||||||
}
|
|
||||||
|
|
||||||
void QButton::setCheckable(bool checkable)
|
|
||||||
{
|
|
||||||
Q_ASSERT(pimpl);
|
|
||||||
if (pimpl)
|
|
||||||
pimpl->abstractButton->setCheckable(checkable);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool QButton::isChecked()
|
|
||||||
{
|
|
||||||
Q_ASSERT(pimpl);
|
|
||||||
if (!pimpl)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return pimpl->abstractButton->isChecked();
|
|
||||||
}
|
|
||||||
29
3rdparty/qocoa/qprogressindicatorspinning.h
vendored
29
3rdparty/qocoa/qprogressindicatorspinning.h
vendored
@@ -1,29 +0,0 @@
|
|||||||
#ifndef QPROGRESSINDICATORSPINNING_H
|
|
||||||
#define QPROGRESSINDICATORSPINNING_H
|
|
||||||
|
|
||||||
#include <QWidget>
|
|
||||||
#include <QPointer>
|
|
||||||
|
|
||||||
class QProgressIndicatorSpinningPrivate;
|
|
||||||
class QProgressIndicatorSpinning : public QWidget
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
// Matches NSProgressIndicatorThickness
|
|
||||||
enum Thickness {
|
|
||||||
Default = 14,
|
|
||||||
Small = 10,
|
|
||||||
Large = 18,
|
|
||||||
Aqua = 12
|
|
||||||
};
|
|
||||||
|
|
||||||
explicit QProgressIndicatorSpinning(QWidget *parent,
|
|
||||||
Thickness thickness = Default);
|
|
||||||
public slots:
|
|
||||||
void animate(bool animate = true);
|
|
||||||
private:
|
|
||||||
friend class QProgressIndicatorSpinningPrivate;
|
|
||||||
QPointer<QProgressIndicatorSpinningPrivate> pimpl;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // QPROGRESSINDICATORSPINNING_H
|
|
||||||
70
3rdparty/qocoa/qprogressindicatorspinning_mac.mm
vendored
70
3rdparty/qocoa/qprogressindicatorspinning_mac.mm
vendored
@@ -1,70 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright (C) 2011 by Mike McQuaid
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
|
||||||
all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "qprogressindicatorspinning.h"
|
|
||||||
|
|
||||||
#include "qocoa_mac.h"
|
|
||||||
|
|
||||||
#import "Foundation/NSAutoreleasePool.h"
|
|
||||||
#import "AppKit/NSProgressIndicator.h"
|
|
||||||
|
|
||||||
class QProgressIndicatorSpinningPrivate : public QObject
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
QProgressIndicatorSpinningPrivate(QProgressIndicatorSpinning *qProgressIndicatorSpinning,
|
|
||||||
NSProgressIndicator *nsProgressIndicator)
|
|
||||||
: QObject(qProgressIndicatorSpinning), nsProgressIndicator(nsProgressIndicator) {}
|
|
||||||
|
|
||||||
NSProgressIndicator *nsProgressIndicator;
|
|
||||||
};
|
|
||||||
|
|
||||||
QProgressIndicatorSpinning::QProgressIndicatorSpinning(QWidget *parent,
|
|
||||||
Thickness thickness)
|
|
||||||
: QWidget(parent)
|
|
||||||
{
|
|
||||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
|
||||||
|
|
||||||
NSProgressIndicator *progress = [[NSProgressIndicator alloc] init];
|
|
||||||
[progress setStyle:NSProgressIndicatorSpinningStyle];
|
|
||||||
|
|
||||||
pimpl = new QProgressIndicatorSpinningPrivate(this, progress);
|
|
||||||
|
|
||||||
setupLayout(progress, this);
|
|
||||||
|
|
||||||
setFixedSize(thickness, thickness);
|
|
||||||
|
|
||||||
[progress release];
|
|
||||||
|
|
||||||
[pool drain];
|
|
||||||
}
|
|
||||||
|
|
||||||
void QProgressIndicatorSpinning::animate(bool animate)
|
|
||||||
{
|
|
||||||
Q_ASSERT(pimpl);
|
|
||||||
if (!pimpl)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (animate)
|
|
||||||
[pimpl->nsProgressIndicator startAnimation:nil];
|
|
||||||
else
|
|
||||||
[pimpl->nsProgressIndicator stopAnimation:nil];
|
|
||||||
}
|
|
||||||
@@ -1,72 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright (C) 2011 by Mike McQuaid
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
|
||||||
all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "qprogressindicatorspinning.h"
|
|
||||||
|
|
||||||
#include <QVBoxLayout>
|
|
||||||
#include <QMovie>
|
|
||||||
#include <QLabel>
|
|
||||||
|
|
||||||
class QProgressIndicatorSpinningPrivate : public QObject
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
QProgressIndicatorSpinningPrivate(QProgressIndicatorSpinning *qProgressIndicatorSpinning,
|
|
||||||
QMovie *movie)
|
|
||||||
: QObject(qProgressIndicatorSpinning), movie(movie) {}
|
|
||||||
|
|
||||||
QPointer<QMovie> movie;
|
|
||||||
};
|
|
||||||
|
|
||||||
QProgressIndicatorSpinning::QProgressIndicatorSpinning(QWidget *parent,
|
|
||||||
Thickness thickness)
|
|
||||||
: QWidget(parent)
|
|
||||||
{
|
|
||||||
QVBoxLayout *layout = new QVBoxLayout(this);
|
|
||||||
layout->setMargin(0);
|
|
||||||
|
|
||||||
QSize size(thickness, thickness);
|
|
||||||
QMovie *movie = new QMovie(this);
|
|
||||||
movie->setFileName(":/Qocoa/qprogressindicatorspinning_nonmac.gif");
|
|
||||||
movie->setScaledSize(size);
|
|
||||||
// Roughly match OSX speed.
|
|
||||||
movie->setSpeed(200);
|
|
||||||
pimpl = new QProgressIndicatorSpinningPrivate(this, movie);
|
|
||||||
|
|
||||||
QLabel *label = new QLabel(this);
|
|
||||||
label->setMovie(movie);
|
|
||||||
|
|
||||||
layout->addWidget(label);
|
|
||||||
setFixedSize(size);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void QProgressIndicatorSpinning::animate(bool animate)
|
|
||||||
{
|
|
||||||
Q_ASSERT(pimpl && pimpl->movie);
|
|
||||||
if (!(pimpl && pimpl->movie))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (animate)
|
|
||||||
pimpl->movie->start();
|
|
||||||
else
|
|
||||||
pimpl->movie->stop();
|
|
||||||
}
|
|
||||||
BIN
3rdparty/qocoa/qprogressindicatorspinning_nonmac.gif
vendored
BIN
3rdparty/qocoa/qprogressindicatorspinning_nonmac.gif
vendored
Binary file not shown.
|
Before Width: | Height: | Size: 3.1 KiB |
@@ -1,5 +0,0 @@
|
|||||||
<RCC>
|
|
||||||
<qresource prefix="/Qocoa">
|
|
||||||
<file>qprogressindicatorspinning_nonmac.gif</file>
|
|
||||||
</qresource>
|
|
||||||
</RCC>
|
|
||||||
7
3rdparty/qocoa/qsearchfield_nonmac.qrc
vendored
7
3rdparty/qocoa/qsearchfield_nonmac.qrc
vendored
@@ -1,7 +0,0 @@
|
|||||||
<RCC>
|
|
||||||
<qresource prefix="/Qocoa">
|
|
||||||
<file>qsearchfield_nonmac_clear.png</file>
|
|
||||||
<file>qsearchfield_nonmac_magnifier_menu.png</file>
|
|
||||||
<file>qsearchfield_nonmac_magnifier.png</file>
|
|
||||||
</qresource>
|
|
||||||
</RCC>
|
|
||||||
BIN
3rdparty/qocoa/qsearchfield_nonmac_clear.png
vendored
BIN
3rdparty/qocoa/qsearchfield_nonmac_clear.png
vendored
Binary file not shown.
|
Before Width: | Height: | Size: 736 B |
BIN
3rdparty/qocoa/qsearchfield_nonmac_magnifier.png
vendored
BIN
3rdparty/qocoa/qsearchfield_nonmac_magnifier.png
vendored
Binary file not shown.
|
Before Width: | Height: | Size: 300 B |
Binary file not shown.
|
Before Width: | Height: | Size: 439 B |
57
3rdparty/singleapplication/CMakeLists.txt
vendored
57
3rdparty/singleapplication/CMakeLists.txt
vendored
@@ -1,14 +1,55 @@
|
|||||||
cmake_minimum_required(VERSION 2.8.11)
|
cmake_minimum_required(VERSION 3.0)
|
||||||
set(CMAKE_CXX_STANDARD 11)
|
|
||||||
|
include(CheckIncludeFiles)
|
||||||
|
include(CheckFunctionExists)
|
||||||
|
|
||||||
|
if(CMAKE_VERSION VERSION_GREATER 3.0)
|
||||||
|
check_function_exists(geteuid HAVE_GETEUID)
|
||||||
|
check_function_exists(getpwuid HAVE_GETPWUID)
|
||||||
|
endif()
|
||||||
|
|
||||||
set(SINGLEAPP-SOURCES singleapplication.cpp singleapplication_p.cpp)
|
set(SINGLEAPP-SOURCES singleapplication.cpp singleapplication_p.cpp)
|
||||||
set(SINGLEAPP-MOC-HEADERS singleapplication.h singleapplication_p.h)
|
set(SINGLEAPP-MOC-HEADERS singleapplication.h singleapplication_p.h)
|
||||||
QT5_WRAP_CPP(SINGLEAPP-SOURCES-MOC ${SINGLEAPP-MOC-HEADERS})
|
if(WITH_QT6)
|
||||||
ADD_LIBRARY(singleapplication STATIC ${SINGLEAPP-SOURCES} ${SINGLEAPP-SOURCES-MOC})
|
qt6_wrap_cpp(SINGLEAPP-SOURCES-MOC ${SINGLEAPP-MOC-HEADERS})
|
||||||
target_link_libraries(singleapplication Qt5::Core Qt5::Widgets Qt5::Network)
|
else()
|
||||||
|
qt5_wrap_cpp(SINGLEAPP-SOURCES-MOC ${SINGLEAPP-MOC-HEADERS})
|
||||||
|
endif()
|
||||||
|
add_library(singleapplication STATIC ${SINGLEAPP-SOURCES} ${SINGLEAPP-SOURCES-MOC})
|
||||||
|
target_include_directories(singleapplication SYSTEM PRIVATE
|
||||||
|
${QtCore_INCLUDE_DIRS}
|
||||||
|
${QtWidgets_INCLUDE_DIRS}
|
||||||
|
${QtNetwork_INCLUDE_DIRS}
|
||||||
|
)
|
||||||
|
target_include_directories(singleapplication PRIVATE
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}
|
||||||
|
)
|
||||||
|
target_link_libraries(singleapplication PRIVATE
|
||||||
|
${QtCore_LIBRARIES}
|
||||||
|
${QtWidgets_LIBRARIES}
|
||||||
|
${QtNetwork_LIBRARIES}
|
||||||
|
)
|
||||||
|
|
||||||
set(SINGLECOREAPP-SOURCES singlecoreapplication.cpp singlecoreapplication_p.cpp)
|
set(SINGLECOREAPP-SOURCES singlecoreapplication.cpp singlecoreapplication_p.cpp)
|
||||||
set(SINGLECOREAPP-MOC-HEADERS singlecoreapplication.h singlecoreapplication_p.h)
|
set(SINGLECOREAPP-MOC-HEADERS singlecoreapplication.h singlecoreapplication_p.h)
|
||||||
QT5_WRAP_CPP(SINGLECOREAPP-SOURCES-MOC ${SINGLECOREAPP-MOC-HEADERS})
|
if(WITH_QT6)
|
||||||
ADD_LIBRARY(singlecoreapplication STATIC ${SINGLECOREAPP-SOURCES} ${SINGLECOREAPP-SOURCES-MOC})
|
qt6_wrap_cpp(SINGLECOREAPP-SOURCES-MOC ${SINGLECOREAPP-MOC-HEADERS})
|
||||||
target_link_libraries(singlecoreapplication Qt5::Core Qt5::Widgets Qt5::Network)
|
else()
|
||||||
|
qt5_wrap_cpp(SINGLECOREAPP-SOURCES-MOC ${SINGLECOREAPP-MOC-HEADERS})
|
||||||
|
endif()
|
||||||
|
add_library(singlecoreapplication STATIC ${SINGLECOREAPP-SOURCES} ${SINGLECOREAPP-SOURCES-MOC})
|
||||||
|
target_include_directories(singlecoreapplication SYSTEM PRIVATE
|
||||||
|
${QtCore_INCLUDE_DIRS}
|
||||||
|
${QtNetwork_INCLUDE_DIRS}
|
||||||
|
)
|
||||||
|
target_include_directories(singlecoreapplication PRIVATE
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}
|
||||||
|
)
|
||||||
|
target_link_libraries(singlecoreapplication PRIVATE
|
||||||
|
${QtCore_LIBRARIES}
|
||||||
|
${QtNetwork_LIBRARIES}
|
||||||
|
)
|
||||||
|
|
||||||
|
configure_file(config.h.in "${CMAKE_CURRENT_BINARY_DIR}/config.h")
|
||||||
|
|||||||
2
3rdparty/singleapplication/config.h.in
vendored
Normal file
2
3rdparty/singleapplication/config.h.in
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
#cmakedefine HAVE_GETEUID
|
||||||
|
#cmakedefine HAVE_GETPWUID
|
||||||
120
3rdparty/singleapplication/singleapplication.cpp
vendored
120
3rdparty/singleapplication/singleapplication.cpp
vendored
@@ -20,72 +20,93 @@
|
|||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
#include <QApplication>
|
//
|
||||||
#include <QtCore/QTime>
|
// W A R N I N G !!!
|
||||||
#include <QtCore/QThread>
|
// -----------------
|
||||||
#include <QtCore/QDateTime>
|
//
|
||||||
#include <QtCore/QByteArray>
|
// This is a modified version of SingleApplication,
|
||||||
#include <QtCore/QSharedMemory>
|
// The original version is at:
|
||||||
|
//
|
||||||
|
// https://github.com/itay-grudev/SingleApplication
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
|
#include <QtGlobal>
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QThread>
|
||||||
|
#include <QSharedMemory>
|
||||||
|
#include <QLocalSocket>
|
||||||
|
#include <QByteArray>
|
||||||
|
#include <QElapsedTimer>
|
||||||
|
#include <QtDebug>
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
|
||||||
|
# include <QRandomGenerator>
|
||||||
|
#else
|
||||||
|
# include <QDateTime>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "singleapplication.h"
|
#include "singleapplication.h"
|
||||||
#include "singleapplication_p.h"
|
#include "singleapplication_p.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Constructor. Checks and fires up LocalServer or closes the program
|
* @brief Constructor.
|
||||||
* if another instance already exists
|
* Checks and fires up LocalServer or closes the program if another instance already exists
|
||||||
* @param argc
|
* @param argc
|
||||||
* @param argv
|
* @param argv
|
||||||
* @param {bool} allowSecondaryInstances
|
* @param {bool} allowSecondaryInstances
|
||||||
*/
|
*/
|
||||||
SingleApplication::SingleApplication( int &argc, char *argv[], bool allowSecondary, Options options, int timeout )
|
SingleApplication::SingleApplication(int &argc, char *argv[], bool allowSecondary, Options options, int timeout)
|
||||||
: app_t( argc, argv ), d_ptr( new SingleApplicationPrivate( this ) )
|
: app_t(argc, argv), d_ptr(new SingleApplicationPrivate(this)) {
|
||||||
{
|
|
||||||
Q_D(SingleApplication);
|
Q_D(SingleApplication);
|
||||||
|
|
||||||
// Store the current mode of the program
|
// Store the current mode of the program
|
||||||
d->options = options;
|
d->options = options;
|
||||||
|
|
||||||
// Generating an application ID used for identifying the shared memory
|
// Generating an application ID used for identifying the shared memory block and QLocalServer
|
||||||
// block and QLocalServer
|
|
||||||
d->genBlockServerName();
|
d->genBlockServerName();
|
||||||
|
|
||||||
#ifdef Q_OS_UNIX
|
#ifdef Q_OS_UNIX
|
||||||
// By explicitly attaching it and then deleting it we make sure that the
|
// By explicitly attaching it and then deleting it we make sure that the
|
||||||
// memory is deleted even after the process has crashed on Unix.
|
// memory is deleted even after the process has crashed on Unix.
|
||||||
d->memory = new QSharedMemory( d->blockServerName );
|
d->memory = new QSharedMemory(d->blockServerName);
|
||||||
d->memory->attach();
|
d->memory->attach();
|
||||||
delete d->memory;
|
delete d->memory;
|
||||||
#endif
|
#endif
|
||||||
// Guarantee thread safe behaviour with a shared memory block.
|
// Guarantee thread safe behaviour with a shared memory block.
|
||||||
d->memory = new QSharedMemory( d->blockServerName );
|
d->memory = new QSharedMemory(d->blockServerName);
|
||||||
|
|
||||||
// Create a shared memory block
|
// Create a shared memory block
|
||||||
if( d->memory->create( sizeof( InstancesInfo ) ) ) {
|
if (d->memory->create(sizeof(InstancesInfo))) {
|
||||||
// Initialize the shared memory block
|
// Initialize the shared memory block
|
||||||
d->memory->lock();
|
d->memory->lock();
|
||||||
d->initializeMemoryBlock();
|
d->initializeMemoryBlock();
|
||||||
d->memory->unlock();
|
d->memory->unlock();
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
// Attempt to attach to the memory segment
|
// Attempt to attach to the memory segment
|
||||||
if( ! d->memory->attach() ) {
|
if (! d->memory->attach()) {
|
||||||
qCritical() << "SingleApplication: Unable to attach to shared memory block.";
|
qCritical() << "SingleApplication: Unable to attach to shared memory block.";
|
||||||
qCritical() << d->memory->errorString();
|
qCritical() << d->memory->errorString();
|
||||||
delete d;
|
delete d;
|
||||||
::exit( EXIT_FAILURE );
|
::exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
InstancesInfo* inst = static_cast<InstancesInfo*>( d->memory->data() );
|
InstancesInfo* inst = static_cast<InstancesInfo*>(d->memory->data());
|
||||||
QTime time;
|
QElapsedTimer time;
|
||||||
time.start();
|
time.start();
|
||||||
|
|
||||||
// Make sure the shared memory block is initialised and in consistent state
|
// Make sure the shared memory block is initialised and in consistent state
|
||||||
while( true ) {
|
while (true) {
|
||||||
d->memory->lock();
|
d->memory->lock();
|
||||||
|
|
||||||
if( d->blockChecksum() == inst->checksum ) break;
|
if (d->blockChecksum() == inst->checksum) break;
|
||||||
|
|
||||||
if( time.elapsed() > 5000 ) {
|
if (time.elapsed() > 5000) {
|
||||||
qWarning() << "SingleApplication: Shared memory block has been in an inconsistent state from more than 5s. Assuming primary instance failure.";
|
qWarning() << "SingleApplication: Shared memory block has been in an inconsistent state from more than 5s. Assuming primary instance failure.";
|
||||||
d->initializeMemoryBlock();
|
d->initializeMemoryBlock();
|
||||||
}
|
}
|
||||||
@@ -93,24 +114,28 @@ SingleApplication::SingleApplication( int &argc, char *argv[], bool allowSeconda
|
|||||||
d->memory->unlock();
|
d->memory->unlock();
|
||||||
|
|
||||||
// Random sleep here limits the probability of a collision between two racing apps
|
// Random sleep here limits the probability of a collision between two racing apps
|
||||||
qsrand( QDateTime::currentMSecsSinceEpoch() % std::numeric_limits<uint>::max() );
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
|
||||||
QThread::sleep( 8 + static_cast <unsigned long>( static_cast <float>( qrand() ) / RAND_MAX * 10 ) );
|
QThread::sleep(QRandomGenerator::global()->bounded(8u, 18u));
|
||||||
|
#else
|
||||||
|
qsrand(QDateTime::currentMSecsSinceEpoch() % std::numeric_limits<uint>::max());
|
||||||
|
QThread::sleep(8 + static_cast<unsigned long>(static_cast <float>(qrand()) / RAND_MAX * 10));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if( inst->primary == false) {
|
if (inst->primary == false) {
|
||||||
d->startPrimary();
|
d->startPrimary();
|
||||||
d->memory->unlock();
|
d->memory->unlock();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if another instance can be started
|
// Check if another instance can be started
|
||||||
if( allowSecondary ) {
|
if (allowSecondary) {
|
||||||
inst->secondary += 1;
|
inst->secondary += 1;
|
||||||
inst->checksum = d->blockChecksum();
|
inst->checksum = d->blockChecksum();
|
||||||
d->instanceNumber = inst->secondary;
|
d->instanceNumber = inst->secondary;
|
||||||
d->startSecondary();
|
d->startSecondary();
|
||||||
if( d->options & Mode::SecondaryNotification ) {
|
if (d->options & Mode::SecondaryNotification) {
|
||||||
d->connectToPrimary( timeout, SingleApplicationPrivate::SecondaryInstance );
|
d->connectToPrimary(timeout, SingleApplicationPrivate::SecondaryInstance);
|
||||||
}
|
}
|
||||||
d->memory->unlock();
|
d->memory->unlock();
|
||||||
return;
|
return;
|
||||||
@@ -118,58 +143,55 @@ SingleApplication::SingleApplication( int &argc, char *argv[], bool allowSeconda
|
|||||||
|
|
||||||
d->memory->unlock();
|
d->memory->unlock();
|
||||||
|
|
||||||
d->connectToPrimary( timeout, SingleApplicationPrivate::NewInstance );
|
d->connectToPrimary(timeout, SingleApplicationPrivate::NewInstance);
|
||||||
|
|
||||||
delete d;
|
delete d;
|
||||||
|
|
||||||
::exit( EXIT_SUCCESS );
|
::exit(EXIT_SUCCESS);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Destructor
|
* @brief Destructor
|
||||||
*/
|
*/
|
||||||
SingleApplication::~SingleApplication()
|
SingleApplication::~SingleApplication() {
|
||||||
{
|
|
||||||
Q_D(SingleApplication);
|
Q_D(SingleApplication);
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SingleApplication::isPrimary()
|
bool SingleApplication::isPrimary() {
|
||||||
{
|
|
||||||
Q_D(SingleApplication);
|
Q_D(SingleApplication);
|
||||||
return d->server != nullptr;
|
return d->server != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SingleApplication::isSecondary()
|
bool SingleApplication::isSecondary() {
|
||||||
{
|
|
||||||
Q_D(SingleApplication);
|
Q_D(SingleApplication);
|
||||||
return d->server == nullptr;
|
return d->server == nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
quint32 SingleApplication::instanceId()
|
quint32 SingleApplication::instanceId() {
|
||||||
{
|
|
||||||
Q_D(SingleApplication);
|
Q_D(SingleApplication);
|
||||||
return d->instanceNumber;
|
return d->instanceNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 SingleApplication::primaryPid()
|
qint64 SingleApplication::primaryPid() {
|
||||||
{
|
|
||||||
Q_D(SingleApplication);
|
Q_D(SingleApplication);
|
||||||
return d->primaryPid();
|
return d->primaryPid();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SingleApplication::sendMessage( QByteArray message, int timeout )
|
bool SingleApplication::sendMessage(QByteArray message, int timeout) {
|
||||||
{
|
|
||||||
Q_D(SingleApplication);
|
Q_D(SingleApplication);
|
||||||
|
|
||||||
// Nobody to connect to
|
// Nobody to connect to
|
||||||
if( isPrimary() ) return false;
|
if (isPrimary()) return false;
|
||||||
|
|
||||||
// Make sure the socket is connected
|
// Make sure the socket is connected
|
||||||
d->connectToPrimary( timeout, SingleApplicationPrivate::Reconnect );
|
d->connectToPrimary(timeout, SingleApplicationPrivate::Reconnect);
|
||||||
|
|
||||||
d->socket->write( message );
|
d->socket->write(message);
|
||||||
bool dataWritten = d->socket->flush();
|
bool dataWritten = d->socket->waitForBytesWritten(timeout);
|
||||||
d->socket->waitForBytesWritten( timeout );
|
d->socket->flush();
|
||||||
return dataWritten;
|
return dataWritten;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
30
3rdparty/singleapplication/singleapplication.h
vendored
30
3rdparty/singleapplication/singleapplication.h
vendored
@@ -20,12 +20,24 @@
|
|||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
//
|
||||||
|
// W A R N I N G !!!
|
||||||
|
// -----------------
|
||||||
|
//
|
||||||
|
// This is a modified version of SingleApplication,
|
||||||
|
// The original version is at:
|
||||||
|
//
|
||||||
|
// https://github.com/itay-grudev/SingleApplication
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef SINGLEAPPLICATION_H
|
#ifndef SINGLEAPPLICATION_H
|
||||||
#define SINGLEAPPLICATION_H
|
#define SINGLEAPPLICATION_H
|
||||||
|
|
||||||
#include <QtCore/QtGlobal>
|
#include <QtGlobal>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QtNetwork/QLocalSocket>
|
#include <QFlags>
|
||||||
|
#include <QByteArray>
|
||||||
|
|
||||||
class SingleApplicationPrivate;
|
class SingleApplicationPrivate;
|
||||||
|
|
||||||
@@ -34,8 +46,7 @@ class SingleApplicationPrivate;
|
|||||||
* Application
|
* Application
|
||||||
* @see QCoreApplication
|
* @see QCoreApplication
|
||||||
*/
|
*/
|
||||||
class SingleApplication : public QApplication
|
class SingleApplication : public QApplication {
|
||||||
{
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
typedef QApplication app_t;
|
typedef QApplication app_t;
|
||||||
@@ -69,7 +80,7 @@ public:
|
|||||||
* if there is already a primary instance.
|
* if there is already a primary instance.
|
||||||
* @arg {Mode} mode - Whether for the SingleApplication block to be applied
|
* @arg {Mode} mode - Whether for the SingleApplication block to be applied
|
||||||
* User wide or System wide.
|
* User wide or System wide.
|
||||||
* @arg {int} timeout - Timeout to wait in miliseconds.
|
* @arg {int} timeout - Timeout to wait in milliseconds.
|
||||||
* @note argc and argv may be changed as Qt removes arguments that it
|
* @note argc and argv may be changed as Qt removes arguments that it
|
||||||
* recognizes
|
* recognizes
|
||||||
* @note Mode::SecondaryNotification only works if set on both the primary
|
* @note Mode::SecondaryNotification only works if set on both the primary
|
||||||
@@ -81,7 +92,7 @@ public:
|
|||||||
* @see See the corresponding QAPPLICATION_CLASS constructor for reference
|
* @see See the corresponding QAPPLICATION_CLASS constructor for reference
|
||||||
*/
|
*/
|
||||||
explicit SingleApplication( int &argc, char *argv[], bool allowSecondary = false, Options options = Mode::User, int timeout = 1000 );
|
explicit SingleApplication( int &argc, char *argv[], bool allowSecondary = false, Options options = Mode::User, int timeout = 1000 );
|
||||||
~SingleApplication();
|
~SingleApplication() override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Returns if the instance is the primary instance
|
* @brief Returns if the instance is the primary instance
|
||||||
@@ -114,15 +125,16 @@ public:
|
|||||||
* @note sendMessage() will return false if invoked from the primary
|
* @note sendMessage() will return false if invoked from the primary
|
||||||
* instance.
|
* instance.
|
||||||
*/
|
*/
|
||||||
bool sendMessage( QByteArray message, int timeout = 100 );
|
bool sendMessage( QByteArray message, int timeout = 1000 );
|
||||||
|
|
||||||
Q_SIGNALS:
|
signals:
|
||||||
void instanceStarted();
|
void instanceStarted();
|
||||||
void receivedMessage( quint32 instanceId, QByteArray message );
|
void receivedMessage( quint32 instanceId, QByteArray message );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SingleApplicationPrivate *d_ptr;
|
SingleApplicationPrivate *d_ptr;
|
||||||
Q_DECLARE_PRIVATE(SingleApplication)
|
Q_DECLARE_PRIVATE(SingleApplication)
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_OPERATORS_FOR_FLAGS(SingleApplication::Options)
|
Q_DECLARE_OPERATORS_FOR_FLAGS(SingleApplication::Options)
|
||||||
|
|||||||
291
3rdparty/singleapplication/singleapplication_p.cpp
vendored
291
3rdparty/singleapplication/singleapplication_p.cpp
vendored
@@ -24,51 +24,61 @@
|
|||||||
// W A R N I N G !!!
|
// W A R N I N G !!!
|
||||||
// -----------------
|
// -----------------
|
||||||
//
|
//
|
||||||
// This file is not part of the SingleApplication API. It is used purely as an
|
// This is a modified version of SingleApplication,
|
||||||
// implementation detail. This header file may change from version to
|
// The original version is at:
|
||||||
// version without notice, or may even be removed.
|
|
||||||
//
|
//
|
||||||
|
// https://github.com/itay-grudev/SingleApplication
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
#include <QtCore/QDir>
|
#ifdef Q_OS_UNIX
|
||||||
#include <QtCore/QProcess>
|
# include <unistd.h>
|
||||||
#include <QtCore/QByteArray>
|
# include <sys/types.h>
|
||||||
#include <QtCore/QSemaphore>
|
# include <pwd.h>
|
||||||
#include <QtCore/QDataStream>
|
#endif
|
||||||
#include <QtCore/QStandardPaths>
|
|
||||||
#include <QtCore/QCryptographicHash>
|
#include <QIODevice>
|
||||||
#include <QtNetwork/QLocalServer>
|
#include <QSharedMemory>
|
||||||
#include <QtNetwork/QLocalSocket>
|
#include <QByteArray>
|
||||||
|
#include <QDataStream>
|
||||||
|
#include <QCryptographicHash>
|
||||||
|
#include <QLocalServer>
|
||||||
|
#include <QLocalSocket>
|
||||||
|
#include <QDir>
|
||||||
|
|
||||||
#include "singleapplication.h"
|
#include "singleapplication.h"
|
||||||
#include "singleapplication_p.h"
|
#include "singleapplication_p.h"
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
#include <windows.h>
|
# include <windows.h>
|
||||||
#include <lmcons.h>
|
# include <lmcons.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SingleApplicationPrivate::SingleApplicationPrivate( SingleApplication *q_ptr )
|
SingleApplicationPrivate::SingleApplicationPrivate(SingleApplication *_q_ptr)
|
||||||
: q_ptr( q_ptr )
|
: q_ptr(_q_ptr),
|
||||||
{
|
memory(nullptr),
|
||||||
server = nullptr;
|
socket(nullptr),
|
||||||
socket = nullptr;
|
server(nullptr),
|
||||||
memory = nullptr;
|
instanceNumber(-1)
|
||||||
instanceNumber = -1;
|
{}
|
||||||
}
|
|
||||||
|
|
||||||
SingleApplicationPrivate::~SingleApplicationPrivate()
|
SingleApplicationPrivate::~SingleApplicationPrivate() {
|
||||||
{
|
|
||||||
if( socket != nullptr ) {
|
if (socket != nullptr) {
|
||||||
socket->close();
|
socket->close();
|
||||||
delete socket;
|
delete socket;
|
||||||
}
|
}
|
||||||
|
|
||||||
memory->lock();
|
memory->lock();
|
||||||
InstancesInfo* inst = static_cast<InstancesInfo*>(memory->data());
|
InstancesInfo* inst = static_cast<InstancesInfo*>(memory->data());
|
||||||
if( server != nullptr ) {
|
if (server != nullptr) {
|
||||||
server->close();
|
server->close();
|
||||||
delete server;
|
delete server;
|
||||||
inst->primary = false;
|
inst->primary = false;
|
||||||
@@ -78,141 +88,133 @@ SingleApplicationPrivate::~SingleApplicationPrivate()
|
|||||||
memory->unlock();
|
memory->unlock();
|
||||||
|
|
||||||
delete memory;
|
delete memory;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SingleApplicationPrivate::genBlockServerName()
|
void SingleApplicationPrivate::genBlockServerName() {
|
||||||
{
|
|
||||||
QCryptographicHash appData( QCryptographicHash::Sha256 );
|
|
||||||
appData.addData( "SingleApplication", 17 );
|
|
||||||
appData.addData( SingleApplication::app_t::applicationName().toUtf8() );
|
|
||||||
appData.addData( SingleApplication::app_t::organizationName().toUtf8() );
|
|
||||||
appData.addData( SingleApplication::app_t::organizationDomain().toUtf8() );
|
|
||||||
|
|
||||||
if( ! (options & SingleApplication::Mode::ExcludeAppVersion) ) {
|
QCryptographicHash appData(QCryptographicHash::Sha256);
|
||||||
appData.addData( SingleApplication::app_t::applicationVersion().toUtf8() );
|
appData.addData("SingleApplication", 17);
|
||||||
|
appData.addData(SingleApplication::app_t::applicationName().toUtf8());
|
||||||
|
appData.addData(SingleApplication::app_t::organizationName().toUtf8());
|
||||||
|
appData.addData(SingleApplication::app_t::organizationDomain().toUtf8());
|
||||||
|
|
||||||
|
if (!(options & SingleApplication::Mode::ExcludeAppVersion)) {
|
||||||
|
appData.addData(SingleApplication::app_t::applicationVersion().toUtf8());
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ! (options & SingleApplication::Mode::ExcludeAppPath) ) {
|
if (! (options & SingleApplication::Mode::ExcludeAppPath)) {
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
appData.addData( SingleApplication::app_t::applicationFilePath().toLower().toUtf8() );
|
appData.addData(SingleApplication::app_t::applicationFilePath().toLower().toUtf8());
|
||||||
#else
|
#else
|
||||||
appData.addData( SingleApplication::app_t::applicationFilePath().toUtf8() );
|
appData.addData(SingleApplication::app_t::applicationFilePath().toUtf8());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// User level block requires a user specific data in the hash
|
// User level block requires a user specific data in the hash
|
||||||
if( options & SingleApplication::Mode::User ) {
|
if (options & SingleApplication::Mode::User) {
|
||||||
|
#ifdef Q_OS_UNIX
|
||||||
|
QByteArray username;
|
||||||
|
#if defined(HAVE_GETEUID) && defined(HAVE_GETPWUID)
|
||||||
|
struct passwd *pw = getpwuid(geteuid());
|
||||||
|
if (pw) {
|
||||||
|
username = pw->pw_name;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (username.isEmpty()) username = qgetenv("USER");
|
||||||
|
appData.addData(username);
|
||||||
|
#endif
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
wchar_t username [ UNLEN + 1 ];
|
wchar_t username [ UNLEN + 1 ];
|
||||||
// Specifies size of the buffer on input
|
// Specifies size of the buffer on input
|
||||||
DWORD usernameLength = UNLEN + 1;
|
DWORD usernameLength = UNLEN + 1;
|
||||||
if( GetUserNameW( username, &usernameLength ) ) {
|
if (GetUserNameW(username, &usernameLength)) {
|
||||||
appData.addData( QString::fromWCharArray(username).toUtf8() );
|
appData.addData(QString::fromWCharArray(username).toUtf8());
|
||||||
} else {
|
|
||||||
appData.addData( QStandardPaths::standardLocations( QStandardPaths::HomeLocation ).join("").toUtf8() );
|
|
||||||
}
|
}
|
||||||
#endif
|
else {
|
||||||
#ifdef Q_OS_UNIX
|
appData.addData(qgetenv("USERNAME"));
|
||||||
QProcess process;
|
|
||||||
process.start( "whoami" );
|
|
||||||
if( process.waitForFinished( 100 ) &&
|
|
||||||
process.exitCode() == QProcess::NormalExit) {
|
|
||||||
appData.addData( process.readLine() );
|
|
||||||
} else {
|
|
||||||
appData.addData(
|
|
||||||
QDir(
|
|
||||||
QStandardPaths::standardLocations( QStandardPaths::HomeLocation ).first()
|
|
||||||
).absolutePath().toUtf8()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replace the backslash in RFC 2045 Base64 [a-zA-Z0-9+/=] to comply with
|
// Replace the backslash in RFC 2045 Base64 [a-zA-Z0-9+/=] to comply with server naming requirements.
|
||||||
// server naming requirements.
|
|
||||||
blockServerName = appData.result().toBase64().replace("/", "_");
|
blockServerName = appData.result().toBase64().replace("/", "_");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SingleApplicationPrivate::initializeMemoryBlock()
|
void SingleApplicationPrivate::initializeMemoryBlock() {
|
||||||
{
|
|
||||||
InstancesInfo* inst = static_cast<InstancesInfo*>( memory->data() );
|
InstancesInfo* inst = static_cast<InstancesInfo*>(memory->data());
|
||||||
inst->primary = false;
|
inst->primary = false;
|
||||||
inst->secondary = 0;
|
inst->secondary = 0;
|
||||||
inst->primaryPid = -1;
|
inst->primaryPid = -1;
|
||||||
inst->checksum = blockChecksum();
|
inst->checksum = blockChecksum();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SingleApplicationPrivate::startPrimary()
|
void SingleApplicationPrivate::startPrimary() {
|
||||||
{
|
|
||||||
Q_Q(SingleApplication);
|
Q_Q(SingleApplication);
|
||||||
|
|
||||||
// Successful creation means that no main process exists
|
// Successful creation means that no main process exists
|
||||||
// So we start a QLocalServer to listen for connections
|
// So we start a QLocalServer to listen for connections
|
||||||
QLocalServer::removeServer( blockServerName );
|
QLocalServer::removeServer(blockServerName);
|
||||||
server = new QLocalServer();
|
server = new QLocalServer();
|
||||||
|
|
||||||
// Restrict access to the socket according to the
|
// Restrict access to the socket according to the
|
||||||
// SingleApplication::Mode::User flag on User level or no restrictions
|
// SingleApplication::Mode::User flag on User level or no restrictions
|
||||||
if( options & SingleApplication::Mode::User ) {
|
if (options & SingleApplication::Mode::User) {
|
||||||
server->setSocketOptions( QLocalServer::UserAccessOption );
|
server->setSocketOptions(QLocalServer::UserAccessOption);
|
||||||
} else {
|
}
|
||||||
server->setSocketOptions( QLocalServer::WorldAccessOption );
|
else {
|
||||||
|
server->setSocketOptions(QLocalServer::WorldAccessOption);
|
||||||
}
|
}
|
||||||
|
|
||||||
server->listen( blockServerName );
|
server->listen(blockServerName);
|
||||||
QObject::connect(
|
QObject::connect(server, &QLocalServer::newConnection, this, &SingleApplicationPrivate::slotConnectionEstablished);
|
||||||
server,
|
|
||||||
&QLocalServer::newConnection,
|
|
||||||
this,
|
|
||||||
&SingleApplicationPrivate::slotConnectionEstablished
|
|
||||||
);
|
|
||||||
|
|
||||||
// Reset the number of connections
|
// Reset the number of connections
|
||||||
InstancesInfo* inst = static_cast <InstancesInfo*>( memory->data() );
|
InstancesInfo* inst = static_cast <InstancesInfo*>(memory->data());
|
||||||
|
|
||||||
inst->primary = true;
|
inst->primary = true;
|
||||||
inst->primaryPid = q->applicationPid();
|
inst->primaryPid = q->applicationPid();
|
||||||
inst->checksum = blockChecksum();
|
inst->checksum = blockChecksum();
|
||||||
|
|
||||||
instanceNumber = 0;
|
instanceNumber = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SingleApplicationPrivate::startSecondary()
|
void SingleApplicationPrivate::startSecondary() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void SingleApplicationPrivate::connectToPrimary( int msecs, ConnectionType connectionType )
|
void SingleApplicationPrivate::connectToPrimary(const int msecs, const ConnectionType connectionType) {
|
||||||
{
|
|
||||||
// Connect to the Local Server of the Primary Instance if not already
|
// Connect to the Local Server of the Primary Instance if not already connected.
|
||||||
// connected.
|
if (socket == nullptr) {
|
||||||
if( socket == nullptr ) {
|
|
||||||
socket = new QLocalSocket();
|
socket = new QLocalSocket();
|
||||||
}
|
}
|
||||||
|
|
||||||
// If already connected - we are done;
|
// If already connected - we are done;
|
||||||
if( socket->state() == QLocalSocket::ConnectedState )
|
if (socket->state() == QLocalSocket::ConnectedState)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// If not connect
|
// If not connect
|
||||||
if( socket->state() == QLocalSocket::UnconnectedState ||
|
if (socket->state() == QLocalSocket::UnconnectedState ||
|
||||||
socket->state() == QLocalSocket::ClosingState ) {
|
socket->state() == QLocalSocket::ClosingState) {
|
||||||
socket->connectToServer( blockServerName );
|
socket->connectToServer(blockServerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait for being connected
|
// Wait for being connected
|
||||||
if( socket->state() == QLocalSocket::ConnectingState ) {
|
if (socket->state() == QLocalSocket::ConnectingState) {
|
||||||
socket->waitForConnected( msecs );
|
socket->waitForConnected(msecs);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialisation message according to the SingleApplication protocol
|
// Initialisation message according to the SingleApplication protocol
|
||||||
if( socket->state() == QLocalSocket::ConnectedState ) {
|
if (socket->state() == QLocalSocket::ConnectedState) {
|
||||||
// Notify the parent that a new instance had been started;
|
// Notify the parent that a new instance had been started;
|
||||||
QByteArray initMsg;
|
QByteArray initMsg;
|
||||||
QDataStream writeStream(&initMsg, QIODevice::WriteOnly);
|
QDataStream writeStream(&initMsg, QIODevice::WriteOnly);
|
||||||
|
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
|
|
||||||
writeStream.setVersion(QDataStream::Qt_5_6);
|
writeStream.setVersion(QDataStream::Qt_5_6);
|
||||||
#endif
|
|
||||||
|
|
||||||
writeStream << blockServerName.toLatin1();
|
writeStream << blockServerName.toLatin1();
|
||||||
writeStream << static_cast<quint8>(connectionType);
|
writeStream << static_cast<quint8>(connectionType);
|
||||||
@@ -224,50 +226,49 @@ void SingleApplicationPrivate::connectToPrimary( int msecs, ConnectionType conne
|
|||||||
QByteArray header;
|
QByteArray header;
|
||||||
QDataStream headerStream(&header, QIODevice::WriteOnly);
|
QDataStream headerStream(&header, QIODevice::WriteOnly);
|
||||||
|
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
|
|
||||||
headerStream.setVersion(QDataStream::Qt_5_6);
|
headerStream.setVersion(QDataStream::Qt_5_6);
|
||||||
#endif
|
|
||||||
headerStream << static_cast <quint64>( initMsg.length() );
|
|
||||||
|
|
||||||
socket->write( header );
|
headerStream << static_cast <quint64>(initMsg.length());
|
||||||
socket->write( initMsg );
|
|
||||||
|
socket->write(header);
|
||||||
|
socket->write(initMsg);
|
||||||
socket->flush();
|
socket->flush();
|
||||||
socket->waitForBytesWritten( msecs );
|
socket->waitForBytesWritten(msecs);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
quint16 SingleApplicationPrivate::blockChecksum()
|
quint16 SingleApplicationPrivate::blockChecksum() {
|
||||||
{
|
|
||||||
return qChecksum(
|
return qChecksum(static_cast <const char *>(memory->data()), offsetof(InstancesInfo, checksum));
|
||||||
static_cast <const char *>( memory->data() ),
|
|
||||||
offsetof( InstancesInfo, checksum )
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 SingleApplicationPrivate::primaryPid()
|
qint64 SingleApplicationPrivate::primaryPid() {
|
||||||
{
|
|
||||||
qint64 pid;
|
qint64 pid;
|
||||||
|
|
||||||
memory->lock();
|
memory->lock();
|
||||||
InstancesInfo* inst = static_cast<InstancesInfo*>( memory->data() );
|
InstancesInfo* inst = static_cast<InstancesInfo*>(memory->data());
|
||||||
pid = inst->primaryPid;
|
pid = inst->primaryPid;
|
||||||
memory->unlock();
|
memory->unlock();
|
||||||
|
|
||||||
return pid;
|
return pid;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Executed when a connection has been made to the LocalServer
|
* @brief Executed when a connection has been made to the LocalServer
|
||||||
*/
|
*/
|
||||||
void SingleApplicationPrivate::slotConnectionEstablished()
|
void SingleApplicationPrivate::slotConnectionEstablished() {
|
||||||
{
|
|
||||||
QLocalSocket *nextConnSocket = server->nextPendingConnection();
|
QLocalSocket *nextConnSocket = server->nextPendingConnection();
|
||||||
connectionMap.insert(nextConnSocket, ConnectionInfo());
|
connectionMap.insert(nextConnSocket, ConnectionInfo());
|
||||||
|
|
||||||
QObject::connect(nextConnSocket, &QLocalSocket::aboutToClose,
|
QObject::connect(nextConnSocket, &QLocalSocket::aboutToClose,
|
||||||
[nextConnSocket, this]() {
|
[nextConnSocket, this]() {
|
||||||
auto &info = connectionMap[nextConnSocket];
|
auto &info = connectionMap[nextConnSocket];
|
||||||
Q_EMIT this->slotClientConnectionClosed( nextConnSocket, info.instanceId );
|
Q_EMIT this->slotClientConnectionClosed(nextConnSocket, info.instanceId);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -289,30 +290,29 @@ void SingleApplicationPrivate::slotConnectionEstablished()
|
|||||||
readInitMessageBody(nextConnSocket);
|
readInitMessageBody(nextConnSocket);
|
||||||
break;
|
break;
|
||||||
case StageConnected:
|
case StageConnected:
|
||||||
Q_EMIT this->slotDataAvailable( nextConnSocket, info.instanceId );
|
Q_EMIT this->slotDataAvailable(nextConnSocket, info.instanceId);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SingleApplicationPrivate::readInitMessageHeader( QLocalSocket *sock )
|
void SingleApplicationPrivate::readInitMessageHeader(QLocalSocket *sock) {
|
||||||
{
|
|
||||||
if (!connectionMap.contains( sock )) {
|
if (!connectionMap.contains(sock)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( sock->bytesAvailable() < ( qint64 )sizeof( quint64 ) ) {
|
if (sock->bytesAvailable() < static_cast<qint64>(sizeof(quint64))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDataStream headerStream( sock );
|
QDataStream headerStream(sock);
|
||||||
|
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
|
headerStream.setVersion(QDataStream::Qt_5_6);
|
||||||
headerStream.setVersion( QDataStream::Qt_5_6 );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Read the header to know the message length
|
// Read the header to know the message length
|
||||||
quint64 msgLen = 0;
|
quint64 msgLen = 0;
|
||||||
@@ -321,21 +321,22 @@ void SingleApplicationPrivate::readInitMessageHeader( QLocalSocket *sock )
|
|||||||
info.stage = StageBody;
|
info.stage = StageBody;
|
||||||
info.msgLen = msgLen;
|
info.msgLen = msgLen;
|
||||||
|
|
||||||
if ( sock->bytesAvailable() >= (qint64) msgLen ) {
|
if (sock->bytesAvailable() >= static_cast<qint64>(msgLen)) {
|
||||||
readInitMessageBody( sock );
|
readInitMessageBody(sock);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SingleApplicationPrivate::readInitMessageBody( QLocalSocket *sock )
|
void SingleApplicationPrivate::readInitMessageBody(QLocalSocket *sock) {
|
||||||
{
|
|
||||||
Q_Q(SingleApplication);
|
Q_Q(SingleApplication);
|
||||||
|
|
||||||
if (!connectionMap.contains( sock )) {
|
if (!connectionMap.contains(sock)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConnectionInfo &info = connectionMap[sock];
|
ConnectionInfo &info = connectionMap[sock];
|
||||||
if( sock->bytesAvailable() < ( qint64 )info.msgLen ) {
|
if (sock->bytesAvailable() < static_cast<qint64>(info.msgLen)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -343,9 +344,7 @@ void SingleApplicationPrivate::readInitMessageBody( QLocalSocket *sock )
|
|||||||
QByteArray msgBytes = sock->read(info.msgLen);
|
QByteArray msgBytes = sock->read(info.msgLen);
|
||||||
QDataStream readStream(msgBytes);
|
QDataStream readStream(msgBytes);
|
||||||
|
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
|
readStream.setVersion(QDataStream::Qt_5_6);
|
||||||
readStream.setVersion( QDataStream::Qt_5_6 );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// server name
|
// server name
|
||||||
QByteArray latin1Name;
|
QByteArray latin1Name;
|
||||||
@@ -355,7 +354,7 @@ void SingleApplicationPrivate::readInitMessageBody( QLocalSocket *sock )
|
|||||||
ConnectionType connectionType = InvalidConnection;
|
ConnectionType connectionType = InvalidConnection;
|
||||||
quint8 connTypeVal = InvalidConnection;
|
quint8 connTypeVal = InvalidConnection;
|
||||||
readStream >> connTypeVal;
|
readStream >> connTypeVal;
|
||||||
connectionType = static_cast <ConnectionType>( connTypeVal );
|
connectionType = static_cast <ConnectionType>(connTypeVal);
|
||||||
|
|
||||||
// instance id
|
// instance id
|
||||||
quint32 instanceId = 0;
|
quint32 instanceId = 0;
|
||||||
@@ -365,13 +364,11 @@ void SingleApplicationPrivate::readInitMessageBody( QLocalSocket *sock )
|
|||||||
quint16 msgChecksum = 0;
|
quint16 msgChecksum = 0;
|
||||||
readStream >> msgChecksum;
|
readStream >> msgChecksum;
|
||||||
|
|
||||||
const quint16 actualChecksum = qChecksum( msgBytes.constData(), static_cast<quint32>( msgBytes.length() - sizeof( quint16 ) ) );
|
const quint16 actualChecksum = qChecksum(msgBytes.constData(), static_cast<quint32>(msgBytes.length() - sizeof(quint16)));
|
||||||
|
|
||||||
bool isValid = readStream.status() == QDataStream::Ok &&
|
bool isValid = readStream.status() == QDataStream::Ok && QLatin1String(latin1Name) == blockServerName && msgChecksum == actualChecksum;
|
||||||
QLatin1String(latin1Name) == blockServerName &&
|
|
||||||
msgChecksum == actualChecksum;
|
|
||||||
|
|
||||||
if( !isValid ) {
|
if (!isValid) {
|
||||||
sock->close();
|
sock->close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -379,26 +376,26 @@ void SingleApplicationPrivate::readInitMessageBody( QLocalSocket *sock )
|
|||||||
info.instanceId = instanceId;
|
info.instanceId = instanceId;
|
||||||
info.stage = StageConnected;
|
info.stage = StageConnected;
|
||||||
|
|
||||||
if( connectionType == NewInstance ||
|
if (connectionType == NewInstance || (connectionType == SecondaryInstance && options & SingleApplication::Mode::SecondaryNotification)) {
|
||||||
( connectionType == SecondaryInstance &&
|
|
||||||
options & SingleApplication::Mode::SecondaryNotification ) )
|
|
||||||
{
|
|
||||||
Q_EMIT q->instanceStarted();
|
Q_EMIT q->instanceStarted();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sock->bytesAvailable() > 0) {
|
if (sock->bytesAvailable() > 0) {
|
||||||
Q_EMIT this->slotDataAvailable( sock, instanceId );
|
Q_EMIT this->slotDataAvailable(sock, instanceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SingleApplicationPrivate::slotDataAvailable( QLocalSocket *dataSocket, quint32 instanceId )
|
void SingleApplicationPrivate::slotDataAvailable(QLocalSocket *dataSocket, const quint32 instanceId) {
|
||||||
{
|
|
||||||
Q_Q(SingleApplication);
|
Q_Q(SingleApplication);
|
||||||
Q_EMIT q->receivedMessage( instanceId, dataSocket->readAll() );
|
Q_EMIT q->receivedMessage(instanceId, dataSocket->readAll());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SingleApplicationPrivate::slotClientConnectionClosed( QLocalSocket *closedSocket, quint32 instanceId )
|
void SingleApplicationPrivate::slotClientConnectionClosed(QLocalSocket *closedSocket, const quint32 instanceId) {
|
||||||
{
|
|
||||||
if( closedSocket->bytesAvailable() > 0 )
|
if (closedSocket->bytesAvailable() > 0)
|
||||||
Q_EMIT slotDataAvailable( closedSocket, instanceId );
|
Q_EMIT slotDataAvailable(closedSocket, instanceId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
38
3rdparty/singleapplication/singleapplication_p.h
vendored
38
3rdparty/singleapplication/singleapplication_p.h
vendored
@@ -24,19 +24,26 @@
|
|||||||
// W A R N I N G !!!
|
// W A R N I N G !!!
|
||||||
// -----------------
|
// -----------------
|
||||||
//
|
//
|
||||||
// This file is not part of the SingleApplication API. It is used purely as an
|
// This is a modified version of SingleApplication,
|
||||||
// implementation detail. This header file may change from version to
|
// The original version is at:
|
||||||
// version without notice, or may even be removed.
|
//
|
||||||
|
// https://github.com/itay-grudev/SingleApplication
|
||||||
|
//
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef SINGLEAPPLICATION_P_H
|
#ifndef SINGLEAPPLICATION_P_H
|
||||||
#define SINGLEAPPLICATION_P_H
|
#define SINGLEAPPLICATION_P_H
|
||||||
|
|
||||||
#include <QtCore/QSharedMemory>
|
#include <QtGlobal>
|
||||||
#include <QtNetwork/QLocalServer>
|
#include <QObject>
|
||||||
#include <QtNetwork/QLocalSocket>
|
#include <QMap>
|
||||||
|
|
||||||
#include "singleapplication.h"
|
#include "singleapplication.h"
|
||||||
|
|
||||||
|
class QLocalServer;
|
||||||
|
class QLocalSocket;
|
||||||
|
class QSharedMemory;
|
||||||
|
|
||||||
struct InstancesInfo {
|
struct InstancesInfo {
|
||||||
bool primary;
|
bool primary;
|
||||||
quint32 secondary;
|
quint32 secondary;
|
||||||
@@ -45,16 +52,15 @@ struct InstancesInfo {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct ConnectionInfo {
|
struct ConnectionInfo {
|
||||||
explicit ConnectionInfo() :
|
explicit ConnectionInfo() : msgLen(0), instanceId(0), stage(0) {}
|
||||||
msgLen(0), instanceId(0), stage(0) {}
|
|
||||||
qint64 msgLen;
|
qint64 msgLen;
|
||||||
quint32 instanceId;
|
quint32 instanceId;
|
||||||
quint8 stage;
|
quint8 stage;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SingleApplicationPrivate : public QObject {
|
class SingleApplicationPrivate : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
enum ConnectionType : quint8 {
|
enum ConnectionType : quint8 {
|
||||||
InvalidConnection = 0,
|
InvalidConnection = 0,
|
||||||
NewInstance = 1,
|
NewInstance = 1,
|
||||||
@@ -68,14 +74,14 @@ public:
|
|||||||
};
|
};
|
||||||
Q_DECLARE_PUBLIC(SingleApplication)
|
Q_DECLARE_PUBLIC(SingleApplication)
|
||||||
|
|
||||||
SingleApplicationPrivate( SingleApplication *q_ptr );
|
explicit SingleApplicationPrivate(SingleApplication *_q_ptr);
|
||||||
~SingleApplicationPrivate();
|
~SingleApplicationPrivate() override;
|
||||||
|
|
||||||
void genBlockServerName();
|
void genBlockServerName();
|
||||||
void initializeMemoryBlock();
|
void initializeMemoryBlock();
|
||||||
void startPrimary();
|
void startPrimary();
|
||||||
void startSecondary();
|
void startSecondary();
|
||||||
void connectToPrimary(int msecs, ConnectionType connectionType );
|
void connectToPrimary(const int msecs, const ConnectionType connectionType);
|
||||||
quint16 blockChecksum();
|
quint16 blockChecksum();
|
||||||
qint64 primaryPid();
|
qint64 primaryPid();
|
||||||
void readInitMessageHeader(QLocalSocket *socket);
|
void readInitMessageHeader(QLocalSocket *socket);
|
||||||
@@ -90,10 +96,10 @@ public:
|
|||||||
SingleApplication::Options options;
|
SingleApplication::Options options;
|
||||||
QMap<QLocalSocket*, ConnectionInfo> connectionMap;
|
QMap<QLocalSocket*, ConnectionInfo> connectionMap;
|
||||||
|
|
||||||
public Q_SLOTS:
|
public slots:
|
||||||
void slotConnectionEstablished();
|
void slotConnectionEstablished();
|
||||||
void slotDataAvailable( QLocalSocket*, quint32 );
|
void slotDataAvailable(QLocalSocket*, const quint32);
|
||||||
void slotClientConnectionClosed( QLocalSocket*, quint32 );
|
void slotClientConnectionClosed(QLocalSocket*, const quint32);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SINGLEAPPLICATION_P_H
|
#endif // SINGLEAPPLICATION_P_H
|
||||||
|
|||||||
114
3rdparty/singleapplication/singlecoreapplication.cpp
vendored
114
3rdparty/singleapplication/singlecoreapplication.cpp
vendored
@@ -20,12 +20,33 @@
|
|||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
//
|
||||||
|
// W A R N I N G !!!
|
||||||
|
// -----------------
|
||||||
|
//
|
||||||
|
// This is a modified version of SingleApplication,
|
||||||
|
// The original version is at:
|
||||||
|
//
|
||||||
|
// https://github.com/itay-grudev/SingleApplication
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
|
#include <QtGlobal>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QtCore/QTime>
|
#include <QThread>
|
||||||
#include <QtCore/QThread>
|
#include <QSharedMemory>
|
||||||
#include <QtCore/QDateTime>
|
#include <QLocalSocket>
|
||||||
#include <QtCore/QByteArray>
|
#include <QByteArray>
|
||||||
#include <QtCore/QSharedMemory>
|
#include <QElapsedTimer>
|
||||||
|
#include <QtDebug>
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
|
||||||
|
# include <QRandomGenerator>
|
||||||
|
#else
|
||||||
|
# include <QDateTime>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "singlecoreapplication.h"
|
#include "singlecoreapplication.h"
|
||||||
#include "singlecoreapplication_p.h"
|
#include "singlecoreapplication_p.h"
|
||||||
@@ -37,55 +58,55 @@
|
|||||||
* @param argv
|
* @param argv
|
||||||
* @param {bool} allowSecondaryInstances
|
* @param {bool} allowSecondaryInstances
|
||||||
*/
|
*/
|
||||||
SingleCoreApplication::SingleCoreApplication( int &argc, char *argv[], bool allowSecondary, Options options, int timeout )
|
SingleCoreApplication::SingleCoreApplication(int &argc, char *argv[], bool allowSecondary, Options options, int timeout)
|
||||||
: app_t( argc, argv ), d_ptr( new SingleCoreApplicationPrivate( this ) )
|
: app_t(argc, argv), d_ptr(new SingleCoreApplicationPrivate(this)) {
|
||||||
{
|
|
||||||
Q_D(SingleCoreApplication);
|
Q_D(SingleCoreApplication);
|
||||||
|
|
||||||
// Store the current mode of the program
|
// Store the current mode of the program
|
||||||
d->options = options;
|
d->options = options;
|
||||||
|
|
||||||
// Generating an application ID used for identifying the shared memory
|
// Generating an application ID used for identifying the shared memory block and QLocalServer
|
||||||
// block and QLocalServer
|
|
||||||
d->genBlockServerName();
|
d->genBlockServerName();
|
||||||
|
|
||||||
#ifdef Q_OS_UNIX
|
#ifdef Q_OS_UNIX
|
||||||
// By explicitly attaching it and then deleting it we make sure that the
|
// By explicitly attaching it and then deleting it we make sure that the
|
||||||
// memory is deleted even after the process has crashed on Unix.
|
// memory is deleted even after the process has crashed on Unix.
|
||||||
d->memory = new QSharedMemory( d->blockServerName );
|
d->memory = new QSharedMemory(d->blockServerName);
|
||||||
d->memory->attach();
|
d->memory->attach();
|
||||||
delete d->memory;
|
delete d->memory;
|
||||||
#endif
|
#endif
|
||||||
// Guarantee thread safe behaviour with a shared memory block.
|
// Guarantee thread safe behaviour with a shared memory block.
|
||||||
d->memory = new QSharedMemory( d->blockServerName );
|
d->memory = new QSharedMemory(d->blockServerName);
|
||||||
|
|
||||||
// Create a shared memory block
|
// Create a shared memory block
|
||||||
if( d->memory->create( sizeof( InstancesInfo ) ) ) {
|
if (d->memory->create(sizeof(InstancesInfo))) {
|
||||||
// Initialize the shared memory block
|
// Initialize the shared memory block
|
||||||
d->memory->lock();
|
d->memory->lock();
|
||||||
d->initializeMemoryBlock();
|
d->initializeMemoryBlock();
|
||||||
d->memory->unlock();
|
d->memory->unlock();
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
// Attempt to attach to the memory segment
|
// Attempt to attach to the memory segment
|
||||||
if( ! d->memory->attach() ) {
|
if (!d->memory->attach()) {
|
||||||
qCritical() << "SingleCoreApplication: Unable to attach to shared memory block.";
|
qCritical() << "SingleCoreApplication: Unable to attach to shared memory block.";
|
||||||
qCritical() << d->memory->errorString();
|
qCritical() << d->memory->errorString();
|
||||||
delete d;
|
delete d;
|
||||||
::exit( EXIT_FAILURE );
|
::exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
InstancesInfo* inst = static_cast<InstancesInfo*>( d->memory->data() );
|
InstancesInfo* inst = static_cast<InstancesInfo*>(d->memory->data());
|
||||||
QTime time;
|
QElapsedTimer time;
|
||||||
time.start();
|
time.start();
|
||||||
|
|
||||||
// Make sure the shared memory block is initialised and in consistent state
|
// Make sure the shared memory block is initialised and in consistent state
|
||||||
while( true ) {
|
while (true) {
|
||||||
d->memory->lock();
|
d->memory->lock();
|
||||||
|
|
||||||
if( d->blockChecksum() == inst->checksum ) break;
|
if(d->blockChecksum() == inst->checksum) break;
|
||||||
|
|
||||||
if( time.elapsed() > 5000 ) {
|
if (time.elapsed() > 5000) {
|
||||||
qWarning() << "SingleCoreApplication: Shared memory block has been in an inconsistent state from more than 5s. Assuming primary instance failure.";
|
qWarning() << "SingleCoreApplication: Shared memory block has been in an inconsistent state from more than 5s. Assuming primary instance failure.";
|
||||||
d->initializeMemoryBlock();
|
d->initializeMemoryBlock();
|
||||||
}
|
}
|
||||||
@@ -93,24 +114,28 @@ SingleCoreApplication::SingleCoreApplication( int &argc, char *argv[], bool allo
|
|||||||
d->memory->unlock();
|
d->memory->unlock();
|
||||||
|
|
||||||
// Random sleep here limits the probability of a collision between two racing apps
|
// Random sleep here limits the probability of a collision between two racing apps
|
||||||
qsrand( QDateTime::currentMSecsSinceEpoch() % std::numeric_limits<uint>::max() );
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
|
||||||
QThread::sleep( 8 + static_cast <unsigned long>( static_cast <float>( qrand() ) / RAND_MAX * 10 ) );
|
QThread::sleep(QRandomGenerator::global()->bounded(8u, 18u));
|
||||||
|
#else
|
||||||
|
qsrand(QDateTime::currentMSecsSinceEpoch() % std::numeric_limits<uint>::max());
|
||||||
|
QThread::sleep(8 + static_cast<unsigned long>(static_cast <float>(qrand()) / RAND_MAX * 10));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if( inst->primary == false) {
|
if (inst->primary == false) {
|
||||||
d->startPrimary();
|
d->startPrimary();
|
||||||
d->memory->unlock();
|
d->memory->unlock();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if another instance can be started
|
// Check if another instance can be started
|
||||||
if( allowSecondary ) {
|
if (allowSecondary) {
|
||||||
inst->secondary += 1;
|
inst->secondary += 1;
|
||||||
inst->checksum = d->blockChecksum();
|
inst->checksum = d->blockChecksum();
|
||||||
d->instanceNumber = inst->secondary;
|
d->instanceNumber = inst->secondary;
|
||||||
d->startSecondary();
|
d->startSecondary();
|
||||||
if( d->options & Mode::SecondaryNotification ) {
|
if(d->options & Mode::SecondaryNotification) {
|
||||||
d->connectToPrimary( timeout, SingleCoreApplicationPrivate::SecondaryInstance );
|
d->connectToPrimary(timeout, SingleCoreApplicationPrivate::SecondaryInstance);
|
||||||
}
|
}
|
||||||
d->memory->unlock();
|
d->memory->unlock();
|
||||||
return;
|
return;
|
||||||
@@ -118,58 +143,55 @@ SingleCoreApplication::SingleCoreApplication( int &argc, char *argv[], bool allo
|
|||||||
|
|
||||||
d->memory->unlock();
|
d->memory->unlock();
|
||||||
|
|
||||||
d->connectToPrimary( timeout, SingleCoreApplicationPrivate::NewInstance );
|
d->connectToPrimary(timeout, SingleCoreApplicationPrivate::NewInstance);
|
||||||
|
|
||||||
delete d;
|
delete d;
|
||||||
|
|
||||||
::exit( EXIT_SUCCESS );
|
::exit(EXIT_SUCCESS);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Destructor
|
* @brief Destructor
|
||||||
*/
|
*/
|
||||||
SingleCoreApplication::~SingleCoreApplication()
|
SingleCoreApplication::~SingleCoreApplication() {
|
||||||
{
|
|
||||||
Q_D(SingleCoreApplication);
|
Q_D(SingleCoreApplication);
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SingleCoreApplication::isPrimary()
|
bool SingleCoreApplication::isPrimary() {
|
||||||
{
|
|
||||||
Q_D(SingleCoreApplication);
|
Q_D(SingleCoreApplication);
|
||||||
return d->server != nullptr;
|
return d->server != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SingleCoreApplication::isSecondary()
|
bool SingleCoreApplication::isSecondary() {
|
||||||
{
|
|
||||||
Q_D(SingleCoreApplication);
|
Q_D(SingleCoreApplication);
|
||||||
return d->server == nullptr;
|
return d->server == nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
quint32 SingleCoreApplication::instanceId()
|
quint32 SingleCoreApplication::instanceId() {
|
||||||
{
|
|
||||||
Q_D(SingleCoreApplication);
|
Q_D(SingleCoreApplication);
|
||||||
return d->instanceNumber;
|
return d->instanceNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 SingleCoreApplication::primaryPid()
|
qint64 SingleCoreApplication::primaryPid() {
|
||||||
{
|
|
||||||
Q_D(SingleCoreApplication);
|
Q_D(SingleCoreApplication);
|
||||||
return d->primaryPid();
|
return d->primaryPid();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SingleCoreApplication::sendMessage( QByteArray message, int timeout )
|
bool SingleCoreApplication::sendMessage(QByteArray message, int timeout) {
|
||||||
{
|
|
||||||
Q_D(SingleCoreApplication);
|
Q_D(SingleCoreApplication);
|
||||||
|
|
||||||
// Nobody to connect to
|
// Nobody to connect to
|
||||||
if( isPrimary() ) return false;
|
if(isPrimary()) return false;
|
||||||
|
|
||||||
// Make sure the socket is connected
|
// Make sure the socket is connected
|
||||||
d->connectToPrimary( timeout, SingleCoreApplicationPrivate::Reconnect );
|
d->connectToPrimary(timeout, SingleCoreApplicationPrivate::Reconnect);
|
||||||
|
|
||||||
d->socket->write( message );
|
d->socket->write(message);
|
||||||
bool dataWritten = d->socket->flush();
|
bool dataWritten = d->socket->waitForBytesWritten(timeout);
|
||||||
d->socket->waitForBytesWritten( timeout );
|
d->socket->flush();
|
||||||
return dataWritten;
|
return dataWritten;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,22 +20,33 @@
|
|||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
//
|
||||||
|
// W A R N I N G !!!
|
||||||
|
// -----------------
|
||||||
|
//
|
||||||
|
// This is a modified version of SingleApplication,
|
||||||
|
// The original version is at:
|
||||||
|
//
|
||||||
|
// https://github.com/itay-grudev/SingleApplication
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef SINGLECOREAPPLICATION_H
|
#ifndef SINGLECOREAPPLICATION_H
|
||||||
#define SINGLECOREAPPLICATION_H
|
#define SINGLECOREAPPLICATION_H
|
||||||
|
|
||||||
#include <QtCore/QtGlobal>
|
#include <QtGlobal>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QtNetwork/QLocalSocket>
|
#include <QFlags>
|
||||||
|
#include <QByteArray>
|
||||||
|
|
||||||
class SingleCoreApplicationPrivate;
|
class SingleCoreApplicationPrivate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The SingleCoreApplication class handles multipe instances of the same
|
* @brief The SingleCoreApplication class handles multiple instances of the same
|
||||||
* Application
|
* Application
|
||||||
* @see QCoreApplication
|
* @see QCoreApplication
|
||||||
*/
|
*/
|
||||||
class SingleCoreApplication : public QCoreApplication
|
class SingleCoreApplication : public QCoreApplication {
|
||||||
{
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
typedef QCoreApplication app_t;
|
typedef QCoreApplication app_t;
|
||||||
@@ -69,7 +80,7 @@ public:
|
|||||||
* if there is already a primary instance.
|
* if there is already a primary instance.
|
||||||
* @arg {Mode} mode - Whether for the SingleCoreApplication block to be applied
|
* @arg {Mode} mode - Whether for the SingleCoreApplication block to be applied
|
||||||
* User wide or System wide.
|
* User wide or System wide.
|
||||||
* @arg {int} timeout - Timeout to wait in miliseconds.
|
* @arg {int} timeout - Timeout to wait in milliseconds.
|
||||||
* @note argc and argv may be changed as Qt removes arguments that it
|
* @note argc and argv may be changed as Qt removes arguments that it
|
||||||
* recognizes
|
* recognizes
|
||||||
* @note Mode::SecondaryNotification only works if set on both the primary
|
* @note Mode::SecondaryNotification only works if set on both the primary
|
||||||
@@ -81,7 +92,7 @@ public:
|
|||||||
* @see See the corresponding QAPPLICATION_CLASS constructor for reference
|
* @see See the corresponding QAPPLICATION_CLASS constructor for reference
|
||||||
*/
|
*/
|
||||||
explicit SingleCoreApplication( int &argc, char *argv[], bool allowSecondary = false, Options options = Mode::User, int timeout = 1000 );
|
explicit SingleCoreApplication( int &argc, char *argv[], bool allowSecondary = false, Options options = Mode::User, int timeout = 1000 );
|
||||||
~SingleCoreApplication();
|
~SingleCoreApplication() override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Returns if the instance is the primary instance
|
* @brief Returns if the instance is the primary instance
|
||||||
@@ -114,9 +125,9 @@ public:
|
|||||||
* @note sendMessage() will return false if invoked from the primary
|
* @note sendMessage() will return false if invoked from the primary
|
||||||
* instance.
|
* instance.
|
||||||
*/
|
*/
|
||||||
bool sendMessage( QByteArray message, int timeout = 100 );
|
bool sendMessage( QByteArray message, int timeout = 1000 );
|
||||||
|
|
||||||
Q_SIGNALS:
|
signals:
|
||||||
void instanceStarted();
|
void instanceStarted();
|
||||||
void receivedMessage( quint32 instanceId, QByteArray message );
|
void receivedMessage( quint32 instanceId, QByteArray message );
|
||||||
|
|
||||||
|
|||||||
@@ -24,51 +24,61 @@
|
|||||||
// W A R N I N G !!!
|
// W A R N I N G !!!
|
||||||
// -----------------
|
// -----------------
|
||||||
//
|
//
|
||||||
// This file is not part of the SingleCoreApplication API. It is used purely as an
|
// This is a modified version of SingleApplication,
|
||||||
// implementation detail. This header file may change from version to
|
// The original version is at:
|
||||||
// version without notice, or may even be removed.
|
|
||||||
//
|
//
|
||||||
|
// https://github.com/itay-grudev/SingleApplication
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
#include <QtCore/QDir>
|
#ifdef Q_OS_UNIX
|
||||||
#include <QtCore/QProcess>
|
# include <unistd.h>
|
||||||
#include <QtCore/QByteArray>
|
# include <sys/types.h>
|
||||||
#include <QtCore/QSemaphore>
|
# include <pwd.h>
|
||||||
#include <QtCore/QDataStream>
|
#endif
|
||||||
#include <QtCore/QStandardPaths>
|
|
||||||
#include <QtCore/QCryptographicHash>
|
#include <QIODevice>
|
||||||
#include <QtNetwork/QLocalServer>
|
#include <QSharedMemory>
|
||||||
#include <QtNetwork/QLocalSocket>
|
#include <QByteArray>
|
||||||
|
#include <QDataStream>
|
||||||
|
#include <QCryptographicHash>
|
||||||
|
#include <QLocalServer>
|
||||||
|
#include <QLocalSocket>
|
||||||
|
#include <QDir>
|
||||||
|
|
||||||
#include "singlecoreapplication.h"
|
#include "singlecoreapplication.h"
|
||||||
#include "singlecoreapplication_p.h"
|
#include "singlecoreapplication_p.h"
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
#include <windows.h>
|
# include <windows.h>
|
||||||
#include <lmcons.h>
|
# include <lmcons.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SingleCoreApplicationPrivate::SingleCoreApplicationPrivate( SingleCoreApplication *q_ptr )
|
SingleCoreApplicationPrivate::SingleCoreApplicationPrivate(SingleCoreApplication *_q_ptr)
|
||||||
: q_ptr( q_ptr )
|
: q_ptr(_q_ptr),
|
||||||
{
|
memory(nullptr),
|
||||||
server = nullptr;
|
socket(nullptr),
|
||||||
socket = nullptr;
|
server(nullptr),
|
||||||
memory = nullptr;
|
instanceNumber(-1)
|
||||||
instanceNumber = -1;
|
{}
|
||||||
}
|
|
||||||
|
|
||||||
SingleCoreApplicationPrivate::~SingleCoreApplicationPrivate()
|
SingleCoreApplicationPrivate::~SingleCoreApplicationPrivate() {
|
||||||
{
|
|
||||||
if( socket != nullptr ) {
|
if (socket != nullptr) {
|
||||||
socket->close();
|
socket->close();
|
||||||
delete socket;
|
delete socket;
|
||||||
}
|
}
|
||||||
|
|
||||||
memory->lock();
|
memory->lock();
|
||||||
InstancesInfo* inst = static_cast<InstancesInfo*>(memory->data());
|
InstancesInfo* inst = static_cast<InstancesInfo*>(memory->data());
|
||||||
if( server != nullptr ) {
|
if (server != nullptr) {
|
||||||
server->close();
|
server->close();
|
||||||
delete server;
|
delete server;
|
||||||
inst->primary = false;
|
inst->primary = false;
|
||||||
@@ -78,141 +88,133 @@ SingleCoreApplicationPrivate::~SingleCoreApplicationPrivate()
|
|||||||
memory->unlock();
|
memory->unlock();
|
||||||
|
|
||||||
delete memory;
|
delete memory;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SingleCoreApplicationPrivate::genBlockServerName()
|
void SingleCoreApplicationPrivate::genBlockServerName() {
|
||||||
{
|
|
||||||
QCryptographicHash appData( QCryptographicHash::Sha256 );
|
|
||||||
appData.addData( "SingleApplication", 17 );
|
|
||||||
appData.addData( SingleCoreApplication::app_t::applicationName().toUtf8() );
|
|
||||||
appData.addData( SingleCoreApplication::app_t::organizationName().toUtf8() );
|
|
||||||
appData.addData( SingleCoreApplication::app_t::organizationDomain().toUtf8() );
|
|
||||||
|
|
||||||
if( ! (options & SingleCoreApplication::Mode::ExcludeAppVersion) ) {
|
QCryptographicHash appData(QCryptographicHash::Sha256);
|
||||||
appData.addData( SingleCoreApplication::app_t::applicationVersion().toUtf8() );
|
appData.addData("SingleApplication", 17);
|
||||||
|
appData.addData(SingleCoreApplication::app_t::applicationName().toUtf8());
|
||||||
|
appData.addData(SingleCoreApplication::app_t::organizationName().toUtf8());
|
||||||
|
appData.addData(SingleCoreApplication::app_t::organizationDomain().toUtf8());
|
||||||
|
|
||||||
|
if (!(options & SingleCoreApplication::Mode::ExcludeAppVersion)) {
|
||||||
|
appData.addData(SingleCoreApplication::app_t::applicationVersion().toUtf8());
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ! (options & SingleCoreApplication::Mode::ExcludeAppPath) ) {
|
if (!(options & SingleCoreApplication::Mode::ExcludeAppPath)) {
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
appData.addData( SingleCoreApplication::app_t::applicationFilePath().toLower().toUtf8() );
|
appData.addData(SingleCoreApplication::app_t::applicationFilePath().toLower().toUtf8());
|
||||||
#else
|
#else
|
||||||
appData.addData( SingleCoreApplication::app_t::applicationFilePath().toUtf8() );
|
appData.addData(SingleCoreApplication::app_t::applicationFilePath().toUtf8());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// User level block requires a user specific data in the hash
|
// User level block requires a user specific data in the hash
|
||||||
if( options & SingleCoreApplication::Mode::User ) {
|
if (options & SingleCoreApplication::Mode::User) {
|
||||||
|
#ifdef Q_OS_UNIX
|
||||||
|
QByteArray username;
|
||||||
|
#if defined(HAVE_GETEUID) && defined(HAVE_GETPWUID)
|
||||||
|
struct passwd *pw = getpwuid(geteuid());
|
||||||
|
if (pw) {
|
||||||
|
username = pw->pw_name;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (username.isEmpty()) username = qgetenv("USER");
|
||||||
|
appData.addData(username);
|
||||||
|
#endif
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
wchar_t username [ UNLEN + 1 ];
|
wchar_t username [ UNLEN + 1 ];
|
||||||
// Specifies size of the buffer on input
|
// Specifies size of the buffer on input
|
||||||
DWORD usernameLength = UNLEN + 1;
|
DWORD usernameLength = UNLEN + 1;
|
||||||
if( GetUserNameW( username, &usernameLength ) ) {
|
if (GetUserNameW(username, &usernameLength)) {
|
||||||
appData.addData( QString::fromWCharArray(username).toUtf8() );
|
appData.addData(QString::fromWCharArray(username).toUtf8());
|
||||||
} else {
|
|
||||||
appData.addData( QStandardPaths::standardLocations( QStandardPaths::HomeLocation ).join("").toUtf8() );
|
|
||||||
}
|
}
|
||||||
#endif
|
else {
|
||||||
#ifdef Q_OS_UNIX
|
appData.addData(qgetenv("USERNAME"));
|
||||||
QProcess process;
|
|
||||||
process.start( "whoami" );
|
|
||||||
if( process.waitForFinished( 100 ) &&
|
|
||||||
process.exitCode() == QProcess::NormalExit) {
|
|
||||||
appData.addData( process.readLine() );
|
|
||||||
} else {
|
|
||||||
appData.addData(
|
|
||||||
QDir(
|
|
||||||
QStandardPaths::standardLocations( QStandardPaths::HomeLocation ).first()
|
|
||||||
).absolutePath().toUtf8()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replace the backslash in RFC 2045 Base64 [a-zA-Z0-9+/=] to comply with
|
// Replace the backslash in RFC 2045 Base64 [a-zA-Z0-9+/=] to comply with server naming requirements.
|
||||||
// server naming requirements.
|
|
||||||
blockServerName = appData.result().toBase64().replace("/", "_");
|
blockServerName = appData.result().toBase64().replace("/", "_");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SingleCoreApplicationPrivate::initializeMemoryBlock()
|
void SingleCoreApplicationPrivate::initializeMemoryBlock() {
|
||||||
{
|
|
||||||
InstancesInfo* inst = static_cast<InstancesInfo*>( memory->data() );
|
InstancesInfo* inst = static_cast<InstancesInfo*>(memory->data());
|
||||||
inst->primary = false;
|
inst->primary = false;
|
||||||
inst->secondary = 0;
|
inst->secondary = 0;
|
||||||
inst->primaryPid = -1;
|
inst->primaryPid = -1;
|
||||||
inst->checksum = blockChecksum();
|
inst->checksum = blockChecksum();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SingleCoreApplicationPrivate::startPrimary()
|
void SingleCoreApplicationPrivate::startPrimary() {
|
||||||
{
|
|
||||||
Q_Q(SingleCoreApplication);
|
Q_Q(SingleCoreApplication);
|
||||||
|
|
||||||
// Successful creation means that no main process exists
|
// Successful creation means that no main process exists
|
||||||
// So we start a QLocalServer to listen for connections
|
// So we start a QLocalServer to listen for connections
|
||||||
QLocalServer::removeServer( blockServerName );
|
QLocalServer::removeServer(blockServerName);
|
||||||
server = new QLocalServer();
|
server = new QLocalServer();
|
||||||
|
|
||||||
// Restrict access to the socket according to the
|
// Restrict access to the socket according to the
|
||||||
// SingleCoreApplication::Mode::User flag on User level or no restrictions
|
// SingleCoreApplication::Mode::User flag on User level or no restrictions
|
||||||
if( options & SingleCoreApplication::Mode::User ) {
|
if (options & SingleCoreApplication::Mode::User) {
|
||||||
server->setSocketOptions( QLocalServer::UserAccessOption );
|
server->setSocketOptions(QLocalServer::UserAccessOption);
|
||||||
} else {
|
}
|
||||||
server->setSocketOptions( QLocalServer::WorldAccessOption );
|
else {
|
||||||
|
server->setSocketOptions(QLocalServer::WorldAccessOption);
|
||||||
}
|
}
|
||||||
|
|
||||||
server->listen( blockServerName );
|
server->listen(blockServerName);
|
||||||
QObject::connect(
|
QObject::connect(server, &QLocalServer::newConnection, this, &SingleCoreApplicationPrivate::slotConnectionEstablished);
|
||||||
server,
|
|
||||||
&QLocalServer::newConnection,
|
|
||||||
this,
|
|
||||||
&SingleCoreApplicationPrivate::slotConnectionEstablished
|
|
||||||
);
|
|
||||||
|
|
||||||
// Reset the number of connections
|
// Reset the number of connections
|
||||||
InstancesInfo* inst = static_cast <InstancesInfo*>( memory->data() );
|
InstancesInfo* inst = static_cast <InstancesInfo*>(memory->data());
|
||||||
|
|
||||||
inst->primary = true;
|
inst->primary = true;
|
||||||
inst->primaryPid = q->applicationPid();
|
inst->primaryPid = q->applicationPid();
|
||||||
inst->checksum = blockChecksum();
|
inst->checksum = blockChecksum();
|
||||||
|
|
||||||
instanceNumber = 0;
|
instanceNumber = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SingleCoreApplicationPrivate::startSecondary()
|
void SingleCoreApplicationPrivate::startSecondary() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void SingleCoreApplicationPrivate::connectToPrimary( int msecs, ConnectionType connectionType )
|
void SingleCoreApplicationPrivate::connectToPrimary(const int msecs, const ConnectionType connectionType) {
|
||||||
{
|
|
||||||
// Connect to the Local Server of the Primary Instance if not already
|
// Connect to the Local Server of the Primary Instance if not already connected.
|
||||||
// connected.
|
if (socket == nullptr) {
|
||||||
if( socket == nullptr ) {
|
|
||||||
socket = new QLocalSocket();
|
socket = new QLocalSocket();
|
||||||
}
|
}
|
||||||
|
|
||||||
// If already connected - we are done;
|
// If already connected - we are done;
|
||||||
if( socket->state() == QLocalSocket::ConnectedState )
|
if (socket->state() == QLocalSocket::ConnectedState)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// If not connect
|
// If not connect
|
||||||
if( socket->state() == QLocalSocket::UnconnectedState ||
|
if (socket->state() == QLocalSocket::UnconnectedState ||
|
||||||
socket->state() == QLocalSocket::ClosingState ) {
|
socket->state() == QLocalSocket::ClosingState) {
|
||||||
socket->connectToServer( blockServerName );
|
socket->connectToServer(blockServerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait for being connected
|
// Wait for being connected
|
||||||
if( socket->state() == QLocalSocket::ConnectingState ) {
|
if (socket->state() == QLocalSocket::ConnectingState) {
|
||||||
socket->waitForConnected( msecs );
|
socket->waitForConnected(msecs);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialisation message according to the SingleCoreApplication protocol
|
// Initialisation message according to the SingleCoreApplication protocol
|
||||||
if( socket->state() == QLocalSocket::ConnectedState ) {
|
if (socket->state() == QLocalSocket::ConnectedState) {
|
||||||
// Notify the parent that a new instance had been started;
|
// Notify the parent that a new instance had been started;
|
||||||
QByteArray initMsg;
|
QByteArray initMsg;
|
||||||
QDataStream writeStream(&initMsg, QIODevice::WriteOnly);
|
QDataStream writeStream(&initMsg, QIODevice::WriteOnly);
|
||||||
|
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
|
|
||||||
writeStream.setVersion(QDataStream::Qt_5_6);
|
writeStream.setVersion(QDataStream::Qt_5_6);
|
||||||
#endif
|
|
||||||
|
|
||||||
writeStream << blockServerName.toLatin1();
|
writeStream << blockServerName.toLatin1();
|
||||||
writeStream << static_cast<quint8>(connectionType);
|
writeStream << static_cast<quint8>(connectionType);
|
||||||
@@ -224,50 +226,49 @@ void SingleCoreApplicationPrivate::connectToPrimary( int msecs, ConnectionType c
|
|||||||
QByteArray header;
|
QByteArray header;
|
||||||
QDataStream headerStream(&header, QIODevice::WriteOnly);
|
QDataStream headerStream(&header, QIODevice::WriteOnly);
|
||||||
|
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
|
|
||||||
headerStream.setVersion(QDataStream::Qt_5_6);
|
headerStream.setVersion(QDataStream::Qt_5_6);
|
||||||
#endif
|
|
||||||
headerStream << static_cast <quint64>( initMsg.length() );
|
|
||||||
|
|
||||||
socket->write( header );
|
headerStream << static_cast <quint64>(initMsg.length());
|
||||||
socket->write( initMsg );
|
|
||||||
|
socket->write(header);
|
||||||
|
socket->write(initMsg);
|
||||||
socket->flush();
|
socket->flush();
|
||||||
socket->waitForBytesWritten( msecs );
|
socket->waitForBytesWritten(msecs);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
quint16 SingleCoreApplicationPrivate::blockChecksum()
|
quint16 SingleCoreApplicationPrivate::blockChecksum() {
|
||||||
{
|
|
||||||
return qChecksum(
|
return qChecksum(static_cast <const char*> (memory->data()), offsetof(InstancesInfo, checksum));
|
||||||
static_cast <const char *>( memory->data() ),
|
|
||||||
offsetof( InstancesInfo, checksum )
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 SingleCoreApplicationPrivate::primaryPid()
|
qint64 SingleCoreApplicationPrivate::primaryPid() {
|
||||||
{
|
|
||||||
qint64 pid;
|
qint64 pid;
|
||||||
|
|
||||||
memory->lock();
|
memory->lock();
|
||||||
InstancesInfo* inst = static_cast<InstancesInfo*>( memory->data() );
|
InstancesInfo* inst = static_cast<InstancesInfo*>(memory->data());
|
||||||
pid = inst->primaryPid;
|
pid = inst->primaryPid;
|
||||||
memory->unlock();
|
memory->unlock();
|
||||||
|
|
||||||
return pid;
|
return pid;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Executed when a connection has been made to the LocalServer
|
* @brief Executed when a connection has been made to the LocalServer
|
||||||
*/
|
*/
|
||||||
void SingleCoreApplicationPrivate::slotConnectionEstablished()
|
void SingleCoreApplicationPrivate::slotConnectionEstablished() {
|
||||||
{
|
|
||||||
QLocalSocket *nextConnSocket = server->nextPendingConnection();
|
QLocalSocket *nextConnSocket = server->nextPendingConnection();
|
||||||
connectionMap.insert(nextConnSocket, ConnectionInfo());
|
connectionMap.insert(nextConnSocket, ConnectionInfo());
|
||||||
|
|
||||||
QObject::connect(nextConnSocket, &QLocalSocket::aboutToClose,
|
QObject::connect(nextConnSocket, &QLocalSocket::aboutToClose,
|
||||||
[nextConnSocket, this]() {
|
[nextConnSocket, this]() {
|
||||||
auto &info = connectionMap[nextConnSocket];
|
auto &info = connectionMap[nextConnSocket];
|
||||||
Q_EMIT this->slotClientConnectionClosed( nextConnSocket, info.instanceId );
|
Q_EMIT this->slotClientConnectionClosed(nextConnSocket, info.instanceId);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -289,30 +290,29 @@ void SingleCoreApplicationPrivate::slotConnectionEstablished()
|
|||||||
readInitMessageBody(nextConnSocket);
|
readInitMessageBody(nextConnSocket);
|
||||||
break;
|
break;
|
||||||
case StageConnected:
|
case StageConnected:
|
||||||
Q_EMIT this->slotDataAvailable( nextConnSocket, info.instanceId );
|
Q_EMIT this->slotDataAvailable(nextConnSocket, info.instanceId);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SingleCoreApplicationPrivate::readInitMessageHeader( QLocalSocket *sock )
|
void SingleCoreApplicationPrivate::readInitMessageHeader(QLocalSocket *sock) {
|
||||||
{
|
|
||||||
if (!connectionMap.contains( sock )) {
|
if (!connectionMap.contains(sock)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( sock->bytesAvailable() < ( qint64 )sizeof( quint64 ) ) {
|
if (sock->bytesAvailable() < static_cast<qint64>(sizeof(quint64))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDataStream headerStream( sock );
|
QDataStream headerStream(sock);
|
||||||
|
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
|
headerStream.setVersion(QDataStream::Qt_5_6);
|
||||||
headerStream.setVersion( QDataStream::Qt_5_6 );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Read the header to know the message length
|
// Read the header to know the message length
|
||||||
quint64 msgLen = 0;
|
quint64 msgLen = 0;
|
||||||
@@ -321,21 +321,22 @@ void SingleCoreApplicationPrivate::readInitMessageHeader( QLocalSocket *sock )
|
|||||||
info.stage = StageBody;
|
info.stage = StageBody;
|
||||||
info.msgLen = msgLen;
|
info.msgLen = msgLen;
|
||||||
|
|
||||||
if ( sock->bytesAvailable() >= (qint64) msgLen ) {
|
if (sock->bytesAvailable() >= static_cast<qint64>(msgLen)) {
|
||||||
readInitMessageBody( sock );
|
readInitMessageBody(sock);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SingleCoreApplicationPrivate::readInitMessageBody( QLocalSocket *sock )
|
void SingleCoreApplicationPrivate::readInitMessageBody(QLocalSocket *sock) {
|
||||||
{
|
|
||||||
Q_Q(SingleCoreApplication);
|
Q_Q(SingleCoreApplication);
|
||||||
|
|
||||||
if (!connectionMap.contains( sock )) {
|
if (!connectionMap.contains(sock)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConnectionInfo &info = connectionMap[sock];
|
ConnectionInfo &info = connectionMap[sock];
|
||||||
if( sock->bytesAvailable() < ( qint64 )info.msgLen ) {
|
if (sock->bytesAvailable() < static_cast<qint64>(info.msgLen)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -343,9 +344,7 @@ void SingleCoreApplicationPrivate::readInitMessageBody( QLocalSocket *sock )
|
|||||||
QByteArray msgBytes = sock->read(info.msgLen);
|
QByteArray msgBytes = sock->read(info.msgLen);
|
||||||
QDataStream readStream(msgBytes);
|
QDataStream readStream(msgBytes);
|
||||||
|
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
|
readStream.setVersion(QDataStream::Qt_5_6);
|
||||||
readStream.setVersion( QDataStream::Qt_5_6 );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// server name
|
// server name
|
||||||
QByteArray latin1Name;
|
QByteArray latin1Name;
|
||||||
@@ -355,7 +354,7 @@ void SingleCoreApplicationPrivate::readInitMessageBody( QLocalSocket *sock )
|
|||||||
ConnectionType connectionType = InvalidConnection;
|
ConnectionType connectionType = InvalidConnection;
|
||||||
quint8 connTypeVal = InvalidConnection;
|
quint8 connTypeVal = InvalidConnection;
|
||||||
readStream >> connTypeVal;
|
readStream >> connTypeVal;
|
||||||
connectionType = static_cast <ConnectionType>( connTypeVal );
|
connectionType = static_cast <ConnectionType>(connTypeVal);
|
||||||
|
|
||||||
// instance id
|
// instance id
|
||||||
quint32 instanceId = 0;
|
quint32 instanceId = 0;
|
||||||
@@ -365,13 +364,11 @@ void SingleCoreApplicationPrivate::readInitMessageBody( QLocalSocket *sock )
|
|||||||
quint16 msgChecksum = 0;
|
quint16 msgChecksum = 0;
|
||||||
readStream >> msgChecksum;
|
readStream >> msgChecksum;
|
||||||
|
|
||||||
const quint16 actualChecksum = qChecksum( msgBytes.constData(), static_cast<quint32>( msgBytes.length() - sizeof( quint16 ) ) );
|
const quint16 actualChecksum = qChecksum(msgBytes.constData(), static_cast<quint32>(msgBytes.length() - sizeof(quint16)));
|
||||||
|
|
||||||
bool isValid = readStream.status() == QDataStream::Ok &&
|
bool isValid = readStream.status() == QDataStream::Ok && QLatin1String(latin1Name) == blockServerName && msgChecksum == actualChecksum;
|
||||||
QLatin1String(latin1Name) == blockServerName &&
|
|
||||||
msgChecksum == actualChecksum;
|
|
||||||
|
|
||||||
if( !isValid ) {
|
if (!isValid) {
|
||||||
sock->close();
|
sock->close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -379,26 +376,26 @@ void SingleCoreApplicationPrivate::readInitMessageBody( QLocalSocket *sock )
|
|||||||
info.instanceId = instanceId;
|
info.instanceId = instanceId;
|
||||||
info.stage = StageConnected;
|
info.stage = StageConnected;
|
||||||
|
|
||||||
if( connectionType == NewInstance ||
|
if (connectionType == NewInstance || (connectionType == SecondaryInstance && options & SingleCoreApplication::Mode::SecondaryNotification)) {
|
||||||
( connectionType == SecondaryInstance &&
|
|
||||||
options & SingleCoreApplication::Mode::SecondaryNotification ) )
|
|
||||||
{
|
|
||||||
Q_EMIT q->instanceStarted();
|
Q_EMIT q->instanceStarted();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sock->bytesAvailable() > 0) {
|
if (sock->bytesAvailable() > 0) {
|
||||||
Q_EMIT this->slotDataAvailable( sock, instanceId );
|
Q_EMIT this->slotDataAvailable(sock, instanceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SingleCoreApplicationPrivate::slotDataAvailable( QLocalSocket *dataSocket, quint32 instanceId )
|
void SingleCoreApplicationPrivate::slotDataAvailable(QLocalSocket *dataSocket, const quint32 instanceId) {
|
||||||
{
|
|
||||||
Q_Q(SingleCoreApplication);
|
Q_Q(SingleCoreApplication);
|
||||||
Q_EMIT q->receivedMessage( instanceId, dataSocket->readAll() );
|
Q_EMIT q->receivedMessage(instanceId, dataSocket->readAll());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SingleCoreApplicationPrivate::slotClientConnectionClosed( QLocalSocket *closedSocket, quint32 instanceId )
|
void SingleCoreApplicationPrivate::slotClientConnectionClosed(QLocalSocket *closedSocket, const quint32 instanceId) {
|
||||||
{
|
|
||||||
if( closedSocket->bytesAvailable() > 0 )
|
if (closedSocket->bytesAvailable() > 0)
|
||||||
Q_EMIT slotDataAvailable( closedSocket, instanceId );
|
Q_EMIT slotDataAvailable(closedSocket, instanceId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,19 +24,26 @@
|
|||||||
// W A R N I N G !!!
|
// W A R N I N G !!!
|
||||||
// -----------------
|
// -----------------
|
||||||
//
|
//
|
||||||
// This file is not part of the SingleCoreApplication API. It is used purely as an
|
// This is a modified version of SingleApplication,
|
||||||
// implementation detail. This header file may change from version to
|
// The original version is at:
|
||||||
// version without notice, or may even be removed.
|
//
|
||||||
|
// https://github.com/itay-grudev/SingleApplication
|
||||||
|
//
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef SINGLECOREAPPLICATION_P_H
|
#ifndef SINGLECOREAPPLICATION_P_H
|
||||||
#define SINGLECOREAPPLICATION_P_H
|
#define SINGLECOREAPPLICATION_P_H
|
||||||
|
|
||||||
#include <QtCore/QSharedMemory>
|
#include <QtGlobal>
|
||||||
#include <QtNetwork/QLocalServer>
|
#include <QObject>
|
||||||
#include <QtNetwork/QLocalSocket>
|
#include <QMap>
|
||||||
|
|
||||||
#include "singlecoreapplication.h"
|
#include "singlecoreapplication.h"
|
||||||
|
|
||||||
|
class QLocalServer;
|
||||||
|
class QLocalSocket;
|
||||||
|
class QSharedMemory;
|
||||||
|
|
||||||
struct InstancesInfo {
|
struct InstancesInfo {
|
||||||
bool primary;
|
bool primary;
|
||||||
quint32 secondary;
|
quint32 secondary;
|
||||||
@@ -45,16 +52,15 @@ struct InstancesInfo {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct ConnectionInfo {
|
struct ConnectionInfo {
|
||||||
explicit ConnectionInfo() :
|
explicit ConnectionInfo() : msgLen(0), instanceId(0), stage(0) {}
|
||||||
msgLen(0), instanceId(0), stage(0) {}
|
|
||||||
qint64 msgLen;
|
qint64 msgLen;
|
||||||
quint32 instanceId;
|
quint32 instanceId;
|
||||||
quint8 stage;
|
quint8 stage;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SingleCoreApplicationPrivate : public QObject {
|
class SingleCoreApplicationPrivate : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
enum ConnectionType : quint8 {
|
enum ConnectionType : quint8 {
|
||||||
InvalidConnection = 0,
|
InvalidConnection = 0,
|
||||||
NewInstance = 1,
|
NewInstance = 1,
|
||||||
@@ -68,14 +74,14 @@ public:
|
|||||||
};
|
};
|
||||||
Q_DECLARE_PUBLIC(SingleCoreApplication)
|
Q_DECLARE_PUBLIC(SingleCoreApplication)
|
||||||
|
|
||||||
SingleCoreApplicationPrivate( SingleCoreApplication *q_ptr );
|
explicit SingleCoreApplicationPrivate(SingleCoreApplication *_q_ptr);
|
||||||
~SingleCoreApplicationPrivate();
|
~SingleCoreApplicationPrivate() override;
|
||||||
|
|
||||||
void genBlockServerName();
|
void genBlockServerName();
|
||||||
void initializeMemoryBlock();
|
void initializeMemoryBlock();
|
||||||
void startPrimary();
|
void startPrimary();
|
||||||
void startSecondary();
|
void startSecondary();
|
||||||
void connectToPrimary(int msecs, ConnectionType connectionType );
|
void connectToPrimary(const int msecs, const ConnectionType connectionType);
|
||||||
quint16 blockChecksum();
|
quint16 blockChecksum();
|
||||||
qint64 primaryPid();
|
qint64 primaryPid();
|
||||||
void readInitMessageHeader(QLocalSocket *socket);
|
void readInitMessageHeader(QLocalSocket *socket);
|
||||||
@@ -90,10 +96,10 @@ public:
|
|||||||
SingleCoreApplication::Options options;
|
SingleCoreApplication::Options options;
|
||||||
QMap<QLocalSocket*, ConnectionInfo> connectionMap;
|
QMap<QLocalSocket*, ConnectionInfo> connectionMap;
|
||||||
|
|
||||||
public Q_SLOTS:
|
public slots:
|
||||||
void slotConnectionEstablished();
|
void slotConnectionEstablished();
|
||||||
void slotDataAvailable( QLocalSocket*, quint32 );
|
void slotDataAvailable(QLocalSocket*, const quint32);
|
||||||
void slotClientConnectionClosed( QLocalSocket*, quint32 );
|
void slotClientConnectionClosed(QLocalSocket*, const quint32);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SINGLECOREAPPLICATION_P_H
|
#endif // SINGLECOREAPPLICATION_P_H
|
||||||
|
|||||||
142
3rdparty/taglib/CMakeLists.txt
vendored
142
3rdparty/taglib/CMakeLists.txt
vendored
@@ -1,6 +1,4 @@
|
|||||||
cmake_minimum_required(VERSION 2.8.11)
|
cmake_minimum_required(VERSION 3.0)
|
||||||
set(CMAKE_CXX_STANDARD 11)
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-delete-non-virtual-dtor")
|
|
||||||
|
|
||||||
set(TAGLIB_SOVERSION_CURRENT 17)
|
set(TAGLIB_SOVERSION_CURRENT 17)
|
||||||
set(TAGLIB_SOVERSION_REVISION 0)
|
set(TAGLIB_SOVERSION_REVISION 0)
|
||||||
@@ -10,65 +8,24 @@ math(EXPR TAGLIB_SOVERSION_MAJOR "${TAGLIB_SOVERSION_CURRENT} - ${TAGLIB_SOVERSI
|
|||||||
math(EXPR TAGLIB_SOVERSION_MINOR "${TAGLIB_SOVERSION_AGE}")
|
math(EXPR TAGLIB_SOVERSION_MINOR "${TAGLIB_SOVERSION_AGE}")
|
||||||
math(EXPR TAGLIB_SOVERSION_PATCH "${TAGLIB_SOVERSION_REVISION}")
|
math(EXPR TAGLIB_SOVERSION_PATCH "${TAGLIB_SOVERSION_REVISION}")
|
||||||
|
|
||||||
include(TestBigEndian)
|
include(ConfigureChecks.cmake)
|
||||||
test_big_endian(IS_BIG_ENDIAN)
|
set(TESTS_DIR "${CMAKE_SOURCE_DIR}/tests/taglib/")
|
||||||
|
configure_file(taglib-config.h.cmake "${CMAKE_CURRENT_BINARY_DIR}/taglib-config.h")
|
||||||
|
|
||||||
if(NOT IS_BIG_ENDIAN)
|
add_definitions(-DHAVE_CONFIG_H)
|
||||||
add_definitions(-DSYSTEM_BYTEORDER=1)
|
add_definitions(-DTAGLIB_STATIC)
|
||||||
else()
|
|
||||||
add_definitions(-DSYSTEM_BYTEORDER=2)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
configure_file(taglib_config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/taglib_config.h)
|
|
||||||
|
|
||||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
|
||||||
include_directories(
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/toolkit
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/asf
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/mpeg
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/ogg
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/ogg/flac
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/flac
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/mpc
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/mp4
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/ogg/vorbis
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/ogg/speex
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/ogg/opus
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/mpeg/id3v2
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/mpeg/id3v2/frames
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/mpeg/id3v1
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/ape
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/wavpack
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/trueaudio
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/riff
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/riff/aiff
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/riff/wav
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/mod
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/s3m
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/it
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/xm
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/dsf
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/dsdiff
|
|
||||||
${CMAKE_SOURCE_DIR}/3rdparty
|
|
||||||
)
|
|
||||||
|
|
||||||
if(ZLIB_FOUND)
|
|
||||||
include_directories(${ZLIB_INCLUDE_DIR})
|
|
||||||
elseif(HAVE_ZLIB_SOURCE)
|
|
||||||
include_directories(${ZLIB_SOURCE})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(tag_HDRS
|
set(tag_HDRS
|
||||||
tag.h
|
tag.h
|
||||||
fileref.h
|
fileref.h
|
||||||
audioproperties.h
|
audioproperties.h
|
||||||
taglib_export.h
|
taglib_export.h
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/taglib_config.h
|
|
||||||
toolkit/taglib.h
|
toolkit/taglib.h
|
||||||
toolkit/tstring.h
|
toolkit/tstring.h
|
||||||
toolkit/tlist.h
|
toolkit/tlist.h
|
||||||
toolkit/tlist.tcc
|
toolkit/tlist.tcc
|
||||||
toolkit/tstringlist.h
|
toolkit/tstringlist.h
|
||||||
|
toolkit/tstringhandler.h
|
||||||
toolkit/tbytevector.h
|
toolkit/tbytevector.h
|
||||||
toolkit/tbytevectorlist.h
|
toolkit/tbytevectorlist.h
|
||||||
toolkit/tbytevectorstream.h
|
toolkit/tbytevectorstream.h
|
||||||
@@ -77,6 +34,8 @@ set(tag_HDRS
|
|||||||
toolkit/tfilestream.h
|
toolkit/tfilestream.h
|
||||||
toolkit/tmap.h
|
toolkit/tmap.h
|
||||||
toolkit/tmap.tcc
|
toolkit/tmap.tcc
|
||||||
|
toolkit/tpicture.h
|
||||||
|
toolkit/tpicturemap.h
|
||||||
toolkit/tpropertymap.h
|
toolkit/tpropertymap.h
|
||||||
toolkit/trefcounter.h
|
toolkit/trefcounter.h
|
||||||
toolkit/tdebuglistener.h
|
toolkit/tdebuglistener.h
|
||||||
@@ -86,6 +45,7 @@ set(tag_HDRS
|
|||||||
mpeg/xingheader.h
|
mpeg/xingheader.h
|
||||||
mpeg/id3v1/id3v1tag.h
|
mpeg/id3v1/id3v1tag.h
|
||||||
mpeg/id3v1/id3v1genres.h
|
mpeg/id3v1/id3v1genres.h
|
||||||
|
mpeg/id3v2/id3v2.h
|
||||||
mpeg/id3v2/id3v2extendedheader.h
|
mpeg/id3v2/id3v2extendedheader.h
|
||||||
mpeg/id3v2/id3v2frame.h
|
mpeg/id3v2/id3v2frame.h
|
||||||
mpeg/id3v2/id3v2header.h
|
mpeg/id3v2/id3v2header.h
|
||||||
@@ -335,8 +295,10 @@ set(dsdiff_SRCS
|
|||||||
)
|
)
|
||||||
|
|
||||||
set(toolkit_SRCS
|
set(toolkit_SRCS
|
||||||
|
toolkit/taglib.cpp
|
||||||
toolkit/tstring.cpp
|
toolkit/tstring.cpp
|
||||||
toolkit/tstringlist.cpp
|
toolkit/tstringlist.cpp
|
||||||
|
toolkit/tstringhandler.cpp
|
||||||
toolkit/tbytevector.cpp
|
toolkit/tbytevector.cpp
|
||||||
toolkit/tbytevectorlist.cpp
|
toolkit/tbytevectorlist.cpp
|
||||||
toolkit/tbytevectorstream.cpp
|
toolkit/tbytevectorstream.cpp
|
||||||
@@ -344,28 +306,40 @@ set(toolkit_SRCS
|
|||||||
toolkit/tfile.cpp
|
toolkit/tfile.cpp
|
||||||
toolkit/tfilestream.cpp
|
toolkit/tfilestream.cpp
|
||||||
toolkit/tdebug.cpp
|
toolkit/tdebug.cpp
|
||||||
|
toolkit/tpicture.cpp
|
||||||
|
toolkit/tpicturemap.cpp
|
||||||
toolkit/tpropertymap.cpp
|
toolkit/tpropertymap.cpp
|
||||||
toolkit/trefcounter.cpp
|
toolkit/trefcounter.cpp
|
||||||
toolkit/tdebuglistener.cpp
|
toolkit/tdebuglistener.cpp
|
||||||
toolkit/tzlib.cpp
|
toolkit/tzlib.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
if(HAVE_ZLIB_SOURCE)
|
|
||||||
set(zlib_SRCS
|
|
||||||
${ZLIB_SOURCE}/adler32.c
|
|
||||||
${ZLIB_SOURCE}/crc32.c
|
|
||||||
${ZLIB_SOURCE}/inffast.c
|
|
||||||
${ZLIB_SOURCE}/inflate.c
|
|
||||||
${ZLIB_SOURCE}/inftrees.c
|
|
||||||
${ZLIB_SOURCE}/zutil.c
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(tag_LIB_SRCS
|
set(tag_LIB_SRCS
|
||||||
${mpeg_SRCS} ${id3v1_SRCS} ${id3v2_SRCS} ${frames_SRCS} ${ogg_SRCS}
|
${mpeg_SRCS}
|
||||||
${vorbis_SRCS} ${oggflacs_SRCS} ${mpc_SRCS} ${ape_SRCS} ${toolkit_SRCS} ${flacs_SRCS}
|
${id3v1_SRCS}
|
||||||
${wavpack_SRCS} ${speex_SRCS} ${trueaudio_SRCS} ${riff_SRCS} ${aiff_SRCS} ${wav_SRCS}
|
${id3v2_SRCS}
|
||||||
${asf_SRCS} ${mp4_SRCS} ${mod_SRCS} ${s3m_SRCS} ${it_SRCS} ${xm_SRCS} ${opus_SRCS} ${dsf_SRCS} ${dsdiff_SRCS}
|
${frames_SRCS}
|
||||||
|
${ogg_SRCS}
|
||||||
|
${vorbis_SRCS}
|
||||||
|
${oggflacs_SRCS}
|
||||||
|
${mpc_SRCS}
|
||||||
|
${ape_SRCS}
|
||||||
|
${toolkit_SRCS}
|
||||||
|
${flacs_SRCS}
|
||||||
|
${wavpack_SRCS}
|
||||||
|
${speex_SRCS}
|
||||||
|
${trueaudio_SRCS}
|
||||||
|
${riff_SRCS}
|
||||||
|
${aiff_SRCS} ${wav_SRCS}
|
||||||
|
${asf_SRCS}
|
||||||
|
${mp4_SRCS}
|
||||||
|
${mod_SRCS}
|
||||||
|
${s3m_SRCS}
|
||||||
|
${it_SRCS}
|
||||||
|
${xm_SRCS}
|
||||||
|
${opus_SRCS}
|
||||||
|
${dsf_SRCS}
|
||||||
|
${dsdiff_SRCS}
|
||||||
${zlib_SRCS}
|
${zlib_SRCS}
|
||||||
tag.cpp
|
tag.cpp
|
||||||
tagunion.cpp
|
tagunion.cpp
|
||||||
@@ -376,9 +350,40 @@ set(tag_LIB_SRCS
|
|||||||
|
|
||||||
add_library(tag STATIC ${tag_LIB_SRCS} ${tag_HDRS})
|
add_library(tag STATIC ${tag_LIB_SRCS} ${tag_HDRS})
|
||||||
|
|
||||||
if(HAVE_ZLIB AND NOT HAVE_ZLIB_SOURCE)
|
target_include_directories(tag PRIVATE
|
||||||
target_link_libraries(tag ${ZLIB_LIBRARIES})
|
${ZLIB_INCLUDE_DIR}
|
||||||
endif()
|
${CMAKE_CURRENT_BINARY_DIR}
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/toolkit
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/asf
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/mpeg
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/ogg
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/ogg/flac
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/flac
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/mpc
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/mp4
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/ogg/vorbis
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/ogg/speex
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/ogg/opus
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/mpeg/id3v2
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/mpeg/id3v2/frames
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/mpeg/id3v1
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/ape
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/wavpack
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/trueaudio
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/riff
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/riff/aiff
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/riff/wav
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/mod
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/s3m
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/it
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/xm
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/dsf
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/dsdiff
|
||||||
|
${CMAKE_SOURCE_DIR}/3rdparty
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(tag PRIVATE ${ZLIB_LIBRARIES})
|
||||||
|
|
||||||
set_target_properties(tag PROPERTIES
|
set_target_properties(tag PROPERTIES
|
||||||
VERSION ${TAGLIB_SOVERSION_MAJOR}.${TAGLIB_SOVERSION_MINOR}.${TAGLIB_SOVERSION_PATCH}
|
VERSION ${TAGLIB_SOVERSION_MAJOR}.${TAGLIB_SOVERSION_MINOR}.${TAGLIB_SOVERSION_PATCH}
|
||||||
@@ -395,4 +400,3 @@ foreach(header ${tag_HDRS})
|
|||||||
COPYONLY
|
COPYONLY
|
||||||
)
|
)
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
|
|||||||
216
3rdparty/taglib/ConfigureChecks.cmake
vendored
Normal file
216
3rdparty/taglib/ConfigureChecks.cmake
vendored
Normal file
@@ -0,0 +1,216 @@
|
|||||||
|
include(CheckLibraryExists)
|
||||||
|
include(CheckTypeSize)
|
||||||
|
include(CheckCXXCompilerFlag)
|
||||||
|
include(CheckCXXSourceCompiles)
|
||||||
|
|
||||||
|
# Check if the size of numeric types are suitable.
|
||||||
|
|
||||||
|
check_type_size("short" SIZEOF_SHORT)
|
||||||
|
if(NOT SIZEOF_SHORT EQUAL 2)
|
||||||
|
message(FATAL_ERROR "TagLib requires that short is 16-bit wide.")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
check_type_size("int" SIZEOF_INT)
|
||||||
|
if(NOT SIZEOF_INT EQUAL 4)
|
||||||
|
message(FATAL_ERROR "TagLib requires that int is 32-bit wide.")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
check_type_size("long long" SIZEOF_LONGLONG)
|
||||||
|
if(NOT SIZEOF_LONGLONG EQUAL 8)
|
||||||
|
message(FATAL_ERROR "TagLib requires that long long is 64-bit wide.")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
check_type_size("wchar_t" SIZEOF_WCHAR_T)
|
||||||
|
if(SIZEOF_WCHAR_T LESS 2)
|
||||||
|
message(FATAL_ERROR "TagLib requires that wchar_t is sufficient to store a UTF-16 char.")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
check_type_size("float" SIZEOF_FLOAT)
|
||||||
|
if(NOT SIZEOF_FLOAT EQUAL 4)
|
||||||
|
message(FATAL_ERROR "TagLib requires that float is 32-bit wide.")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
check_type_size("double" SIZEOF_DOUBLE)
|
||||||
|
if(NOT SIZEOF_DOUBLE EQUAL 8)
|
||||||
|
message(FATAL_ERROR "TagLib requires that double is 64-bit wide.")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Determine which kind of atomic operations your compiler supports.
|
||||||
|
|
||||||
|
check_cxx_source_compiles("
|
||||||
|
#include <atomic>
|
||||||
|
int main() {
|
||||||
|
std::atomic_int x(1);
|
||||||
|
++x;
|
||||||
|
--x;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
" HAVE_STD_ATOMIC)
|
||||||
|
|
||||||
|
if(NOT HAVE_STD_ATOMIC)
|
||||||
|
check_cxx_source_compiles("
|
||||||
|
int main() {
|
||||||
|
volatile int x;
|
||||||
|
__sync_add_and_fetch(&x, 1);
|
||||||
|
int y = __sync_sub_and_fetch(&x, 1);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
" HAVE_GCC_ATOMIC)
|
||||||
|
|
||||||
|
if(NOT HAVE_GCC_ATOMIC)
|
||||||
|
check_cxx_source_compiles("
|
||||||
|
#include <libkern/OSAtomic.h>
|
||||||
|
int main() {
|
||||||
|
volatile int32_t x;
|
||||||
|
OSAtomicIncrement32Barrier(&x);
|
||||||
|
int32_t y = OSAtomicDecrement32Barrier(&x);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
" HAVE_MAC_ATOMIC)
|
||||||
|
|
||||||
|
if(NOT HAVE_MAC_ATOMIC)
|
||||||
|
check_cxx_source_compiles("
|
||||||
|
#include <windows.h>
|
||||||
|
int main() {
|
||||||
|
volatile LONG x;
|
||||||
|
InterlockedIncrement(&x);
|
||||||
|
LONG y = InterlockedDecrement(&x);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
" HAVE_WIN_ATOMIC)
|
||||||
|
|
||||||
|
if(NOT HAVE_WIN_ATOMIC)
|
||||||
|
check_cxx_source_compiles("
|
||||||
|
#include <ia64intrin.h>
|
||||||
|
int main() {
|
||||||
|
volatile int x;
|
||||||
|
__sync_add_and_fetch(&x, 1);
|
||||||
|
int y = __sync_sub_and_fetch(&x, 1);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
" HAVE_IA64_ATOMIC)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Determine which kind of byte swap functions your compiler supports.
|
||||||
|
|
||||||
|
check_cxx_source_compiles("
|
||||||
|
int main() {
|
||||||
|
__builtin_bswap16(0);
|
||||||
|
__builtin_bswap32(0);
|
||||||
|
__builtin_bswap64(0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
" HAVE_GCC_BYTESWAP)
|
||||||
|
|
||||||
|
if(NOT HAVE_GCC_BYTESWAP)
|
||||||
|
check_cxx_source_compiles("
|
||||||
|
#include <byteswap.h>
|
||||||
|
int main() {
|
||||||
|
__bswap_16(0);
|
||||||
|
__bswap_32(0);
|
||||||
|
__bswap_64(0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
" HAVE_GLIBC_BYTESWAP)
|
||||||
|
|
||||||
|
if(NOT HAVE_GLIBC_BYTESWAP)
|
||||||
|
check_cxx_source_compiles("
|
||||||
|
#include <stdlib.h>
|
||||||
|
int main() {
|
||||||
|
_byteswap_ushort(0);
|
||||||
|
_byteswap_ulong(0);
|
||||||
|
_byteswap_uint64(0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
" HAVE_MSC_BYTESWAP)
|
||||||
|
|
||||||
|
if(NOT HAVE_MSC_BYTESWAP)
|
||||||
|
check_cxx_source_compiles("
|
||||||
|
#include <libkern/OSByteOrder.h>
|
||||||
|
int main() {
|
||||||
|
OSSwapInt16(0);
|
||||||
|
OSSwapInt32(0);
|
||||||
|
OSSwapInt64(0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
" HAVE_MAC_BYTESWAP)
|
||||||
|
|
||||||
|
if(NOT HAVE_MAC_BYTESWAP)
|
||||||
|
check_cxx_source_compiles("
|
||||||
|
#include <sys/endian.h>
|
||||||
|
int main() {
|
||||||
|
swap16(0);
|
||||||
|
swap32(0);
|
||||||
|
swap64(0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
" HAVE_OPENBSD_BYTESWAP)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Determine whether your compiler supports some safer version of vsprintf.
|
||||||
|
|
||||||
|
check_cxx_source_compiles("
|
||||||
|
#include <cstdio>
|
||||||
|
#include <cstdarg>
|
||||||
|
int main() {
|
||||||
|
char buf[20];
|
||||||
|
va_list args;
|
||||||
|
vsnprintf(buf, 20, \"%d\", args);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
" HAVE_VSNPRINTF)
|
||||||
|
|
||||||
|
if(NOT HAVE_VSNPRINTF)
|
||||||
|
check_cxx_source_compiles("
|
||||||
|
#include <cstdio>
|
||||||
|
#include <cstdarg>
|
||||||
|
int main() {
|
||||||
|
char buf[20];
|
||||||
|
va_list args;
|
||||||
|
vsprintf_s(buf, \"%d\", args);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
" HAVE_VSPRINTF_S)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Determine whether your compiler supports ISO _strdup.
|
||||||
|
|
||||||
|
check_cxx_source_compiles("
|
||||||
|
#include <cstring>
|
||||||
|
int main() {
|
||||||
|
_strdup(0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
" HAVE_ISO_STRDUP)
|
||||||
|
|
||||||
|
# Determine whether zlib is installed.
|
||||||
|
|
||||||
|
if(NOT ZLIB_SOURCE)
|
||||||
|
find_package(ZLIB)
|
||||||
|
if(ZLIB_FOUND)
|
||||||
|
set(HAVE_ZLIB 1)
|
||||||
|
else()
|
||||||
|
set(HAVE_ZLIB 0)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Determine whether CppUnit is installed.
|
||||||
|
|
||||||
|
if(BUILD_TESTS AND NOT BUILD_SHARED_LIBS)
|
||||||
|
find_package(CppUnit)
|
||||||
|
if(NOT CppUnit_FOUND)
|
||||||
|
message(STATUS "CppUnit not found, disabling tests.")
|
||||||
|
set(BUILD_TESTS OFF)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Detect WinRT mode
|
||||||
|
if(CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
|
||||||
|
set(PLATFORM WINRT 1)
|
||||||
|
endif()
|
||||||
189
3rdparty/taglib/ape/apefile.cpp
vendored
189
3rdparty/taglib/ape/apefile.cpp
vendored
@@ -31,137 +31,115 @@
|
|||||||
* http://www.mozilla.org/MPL/ *
|
* http://www.mozilla.org/MPL/ *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include <tbytevector.h>
|
#include <memory>
|
||||||
#include <tstring.h>
|
|
||||||
#include <tdebug.h>
|
#include "tbytevector.h"
|
||||||
#include <tagunion.h>
|
#include "tstring.h"
|
||||||
#include <id3v1tag.h>
|
#include "tdebug.h"
|
||||||
#include <id3v2header.h>
|
#include "tagunion.h"
|
||||||
#include <tpropertymap.h>
|
#include "id3v1tag.h"
|
||||||
#include <tagutils.h>
|
#include "id3v2header.h"
|
||||||
|
#include "tpropertymap.h"
|
||||||
|
#include "tagutils.h"
|
||||||
|
|
||||||
#include "apefile.h"
|
#include "apefile.h"
|
||||||
#include "apetag.h"
|
#include "apetag.h"
|
||||||
#include "apefooter.h"
|
#include "apefooter.h"
|
||||||
|
|
||||||
using namespace TagLib;
|
using namespace Strawberry_TagLib::TagLib;
|
||||||
|
|
||||||
namespace
|
namespace {
|
||||||
{
|
enum { ApeAPEIndex = 0,
|
||||||
enum { ApeAPEIndex = 0, ApeID3v1Index = 1 };
|
ApeID3v1Index = 1 };
|
||||||
}
|
}
|
||||||
|
|
||||||
class APE::File::FilePrivate
|
class APE::File::FilePrivate {
|
||||||
{
|
public:
|
||||||
public:
|
FilePrivate() : APELocation(-1),
|
||||||
FilePrivate() :
|
|
||||||
APELocation(-1),
|
|
||||||
APESize(0),
|
APESize(0),
|
||||||
ID3v1Location(-1),
|
ID3v1Location(-1),
|
||||||
ID3v2Header(0),
|
|
||||||
ID3v2Location(-1),
|
ID3v2Location(-1),
|
||||||
ID3v2Size(0),
|
ID3v2Size(0) {}
|
||||||
properties(0) {}
|
|
||||||
|
|
||||||
~FilePrivate()
|
long long APELocation;
|
||||||
{
|
long long APESize;
|
||||||
delete ID3v2Header;
|
|
||||||
delete properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
long APELocation;
|
long long ID3v1Location;
|
||||||
long APESize;
|
|
||||||
|
|
||||||
long ID3v1Location;
|
std::unique_ptr<ID3v2::Header> ID3v2Header;
|
||||||
|
long long ID3v2Location;
|
||||||
|
long long ID3v2Size;
|
||||||
|
|
||||||
ID3v2::Header *ID3v2Header;
|
DoubleTagUnion tag;
|
||||||
long ID3v2Location;
|
|
||||||
long ID3v2Size;
|
|
||||||
|
|
||||||
TagUnion tag;
|
std::unique_ptr<AudioProperties> properties;
|
||||||
|
|
||||||
Properties *properties;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// static members
|
// static members
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
bool APE::File::isSupported(IOStream *stream)
|
bool APE::File::isSupported(IOStream *stream) {
|
||||||
{
|
|
||||||
// An APE file has an ID "MAC " somewhere. An ID3v2 tag may precede.
|
// An APE file has an ID "MAC " somewhere. An ID3v2 tag may precede.
|
||||||
|
|
||||||
const ByteVector buffer = Utils::readHeader(stream, bufferSize(), true);
|
const ByteVector buffer = Utils::readHeader(stream, bufferSize(), true);
|
||||||
return (buffer.find("MAC ") >= 0);
|
return (buffer.find("MAC ") == 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// public members
|
// public members
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
APE::File::File(FileName file, bool readProperties, Properties::ReadStyle) :
|
APE::File::File(FileName file, bool readProperties, AudioProperties::ReadStyle) : Strawberry_TagLib::TagLib::File(file), d(new FilePrivate()) {
|
||||||
TagLib::File(file),
|
|
||||||
d(new FilePrivate())
|
if (isOpen())
|
||||||
{
|
|
||||||
if(isOpen())
|
|
||||||
read(readProperties);
|
read(readProperties);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
APE::File::File(IOStream *stream, bool readProperties, Properties::ReadStyle) :
|
APE::File::File(IOStream *stream, bool readProperties, AudioProperties::ReadStyle) : Strawberry_TagLib::TagLib::File(stream), d(new FilePrivate()) {
|
||||||
TagLib::File(stream),
|
|
||||||
d(new FilePrivate())
|
if (isOpen())
|
||||||
{
|
|
||||||
if(isOpen())
|
|
||||||
read(readProperties);
|
read(readProperties);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
APE::File::~File()
|
APE::File::~File() {
|
||||||
{
|
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
TagLib::Tag *APE::File::tag() const
|
Strawberry_TagLib::TagLib::Tag *APE::File::tag() const {
|
||||||
{
|
|
||||||
return &d->tag;
|
return &d->tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertyMap APE::File::properties() const
|
PropertyMap APE::File::setProperties(const PropertyMap &properties) {
|
||||||
{
|
|
||||||
return d->tag.properties();
|
|
||||||
}
|
|
||||||
|
|
||||||
void APE::File::removeUnsupportedProperties(const StringList &properties)
|
if (ID3v1Tag())
|
||||||
{
|
|
||||||
d->tag.removeUnsupportedProperties(properties);
|
|
||||||
}
|
|
||||||
|
|
||||||
PropertyMap APE::File::setProperties(const PropertyMap &properties)
|
|
||||||
{
|
|
||||||
if(ID3v1Tag())
|
|
||||||
ID3v1Tag()->setProperties(properties);
|
ID3v1Tag()->setProperties(properties);
|
||||||
|
|
||||||
return APETag(true)->setProperties(properties);
|
return APETag(true)->setProperties(properties);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
APE::Properties *APE::File::audioProperties() const
|
APE::AudioProperties *APE::File::audioProperties() const {
|
||||||
{
|
return d->properties.get();
|
||||||
return d->properties;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool APE::File::save()
|
bool APE::File::save() {
|
||||||
{
|
|
||||||
if(readOnly()) {
|
if (readOnly()) {
|
||||||
debug("APE::File::save() -- File is read only.");
|
debug("APE::File::save() -- File is read only.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update ID3v1 tag
|
// Update ID3v1 tag
|
||||||
|
|
||||||
if(ID3v1Tag() && !ID3v1Tag()->isEmpty()) {
|
if (ID3v1Tag() && !ID3v1Tag()->isEmpty()) {
|
||||||
|
|
||||||
// ID3v1 tag is not empty. Update the old one or create a new one.
|
// ID3v1 tag is not empty. Update the old one or create a new one.
|
||||||
|
|
||||||
if(d->ID3v1Location >= 0) {
|
if (d->ID3v1Location >= 0) {
|
||||||
seek(d->ID3v1Location);
|
seek(d->ID3v1Location);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -175,7 +153,7 @@ bool APE::File::save()
|
|||||||
|
|
||||||
// ID3v1 tag is empty. Remove the old one.
|
// ID3v1 tag is empty. Remove the old one.
|
||||||
|
|
||||||
if(d->ID3v1Location >= 0) {
|
if (d->ID3v1Location >= 0) {
|
||||||
truncate(d->ID3v1Location);
|
truncate(d->ID3v1Location);
|
||||||
d->ID3v1Location = -1;
|
d->ID3v1Location = -1;
|
||||||
}
|
}
|
||||||
@@ -183,12 +161,12 @@ bool APE::File::save()
|
|||||||
|
|
||||||
// Update APE tag
|
// Update APE tag
|
||||||
|
|
||||||
if(APETag() && !APETag()->isEmpty()) {
|
if (APETag() && !APETag()->isEmpty()) {
|
||||||
|
|
||||||
// APE tag is not empty. Update the old one or create a new one.
|
// APE tag is not empty. Update the old one or create a new one.
|
||||||
|
|
||||||
if(d->APELocation < 0) {
|
if (d->APELocation < 0) {
|
||||||
if(d->ID3v1Location >= 0)
|
if (d->ID3v1Location >= 0)
|
||||||
d->APELocation = d->ID3v1Location;
|
d->APELocation = d->ID3v1Location;
|
||||||
else
|
else
|
||||||
d->APELocation = length();
|
d->APELocation = length();
|
||||||
@@ -197,7 +175,7 @@ bool APE::File::save()
|
|||||||
const ByteVector data = APETag()->render();
|
const ByteVector data = APETag()->render();
|
||||||
insert(data, d->APELocation, d->APESize);
|
insert(data, d->APELocation, d->APESize);
|
||||||
|
|
||||||
if(d->ID3v1Location >= 0)
|
if (d->ID3v1Location >= 0)
|
||||||
d->ID3v1Location += (static_cast<long>(data.size()) - d->APESize);
|
d->ID3v1Location += (static_cast<long>(data.size()) - d->APESize);
|
||||||
|
|
||||||
d->APESize = data.size();
|
d->APESize = data.size();
|
||||||
@@ -206,10 +184,10 @@ bool APE::File::save()
|
|||||||
|
|
||||||
// APE tag is empty. Remove the old one.
|
// APE tag is empty. Remove the old one.
|
||||||
|
|
||||||
if(d->APELocation >= 0) {
|
if (d->APELocation >= 0) {
|
||||||
removeBlock(d->APELocation, d->APESize);
|
removeBlock(d->APELocation, d->APESize);
|
||||||
|
|
||||||
if(d->ID3v1Location >= 0)
|
if (d->ID3v1Location >= 0)
|
||||||
d->ID3v1Location -= d->APESize;
|
d->ID3v1Location -= d->APESize;
|
||||||
|
|
||||||
d->APELocation = -1;
|
d->APELocation = -1;
|
||||||
@@ -218,37 +196,35 @@ bool APE::File::save()
|
|||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ID3v1::Tag *APE::File::ID3v1Tag(bool create)
|
ID3v1::Tag *APE::File::ID3v1Tag(bool create) {
|
||||||
{
|
|
||||||
return d->tag.access<ID3v1::Tag>(ApeID3v1Index, create);
|
return d->tag.access<ID3v1::Tag>(ApeID3v1Index, create);
|
||||||
}
|
}
|
||||||
|
|
||||||
APE::Tag *APE::File::APETag(bool create)
|
APE::Tag *APE::File::APETag(bool create) {
|
||||||
{
|
|
||||||
return d->tag.access<APE::Tag>(ApeAPEIndex, create);
|
return d->tag.access<APE::Tag>(ApeAPEIndex, create);
|
||||||
}
|
}
|
||||||
|
|
||||||
void APE::File::strip(int tags)
|
void APE::File::strip(int tags) {
|
||||||
{
|
|
||||||
if(tags & ID3v1)
|
|
||||||
d->tag.set(ApeID3v1Index, 0);
|
|
||||||
|
|
||||||
if(tags & APE)
|
if (tags & ID3v1)
|
||||||
d->tag.set(ApeAPEIndex, 0);
|
d->tag.set(ApeID3v1Index, nullptr);
|
||||||
|
|
||||||
if(!ID3v1Tag())
|
if (tags & APE)
|
||||||
|
d->tag.set(ApeAPEIndex, nullptr);
|
||||||
|
|
||||||
|
if (!ID3v1Tag())
|
||||||
APETag(true);
|
APETag(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool APE::File::hasAPETag() const
|
bool APE::File::hasAPETag() const {
|
||||||
{
|
|
||||||
return (d->APELocation >= 0);
|
return (d->APELocation >= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool APE::File::hasID3v1Tag() const
|
bool APE::File::hasID3v1Tag() const {
|
||||||
{
|
|
||||||
return (d->ID3v1Location >= 0);
|
return (d->ID3v1Location >= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -256,15 +232,15 @@ bool APE::File::hasID3v1Tag() const
|
|||||||
// private members
|
// private members
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void APE::File::read(bool readProperties)
|
void APE::File::read(bool readProperties) {
|
||||||
{
|
|
||||||
// Look for an ID3v2 tag
|
// Look for an ID3v2 tag
|
||||||
|
|
||||||
d->ID3v2Location = Utils::findID3v2(this);
|
d->ID3v2Location = Utils::findID3v2(this);
|
||||||
|
|
||||||
if(d->ID3v2Location >= 0) {
|
if (d->ID3v2Location >= 0) {
|
||||||
seek(d->ID3v2Location);
|
seek(d->ID3v2Location);
|
||||||
d->ID3v2Header = new ID3v2::Header(readBlock(ID3v2::Header::size()));
|
d->ID3v2Header.reset(new ID3v2::Header(readBlock(ID3v2::Header::size())));
|
||||||
d->ID3v2Size = d->ID3v2Header->completeTagSize();
|
d->ID3v2Size = d->ID3v2Header->completeTagSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -272,36 +248,36 @@ void APE::File::read(bool readProperties)
|
|||||||
|
|
||||||
d->ID3v1Location = Utils::findID3v1(this);
|
d->ID3v1Location = Utils::findID3v1(this);
|
||||||
|
|
||||||
if(d->ID3v1Location >= 0)
|
if (d->ID3v1Location >= 0)
|
||||||
d->tag.set(ApeID3v1Index, new ID3v1::Tag(this, d->ID3v1Location));
|
d->tag.set(ApeID3v1Index, new ID3v1::Tag(this, d->ID3v1Location));
|
||||||
|
|
||||||
// Look for an APE tag
|
// Look for an APE tag
|
||||||
|
|
||||||
d->APELocation = Utils::findAPE(this, d->ID3v1Location);
|
d->APELocation = Utils::findAPE(this, d->ID3v1Location);
|
||||||
|
|
||||||
if(d->APELocation >= 0) {
|
if (d->APELocation >= 0) {
|
||||||
d->tag.set(ApeAPEIndex, new APE::Tag(this, d->APELocation));
|
d->tag.set(ApeAPEIndex, new APE::Tag(this, d->APELocation));
|
||||||
d->APESize = APETag()->footer()->completeTagSize();
|
d->APESize = APETag()->footer()->completeTagSize();
|
||||||
d->APELocation = d->APELocation + APE::Footer::size() - d->APESize;
|
d->APELocation = d->APELocation + APE::Footer::size() - d->APESize;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(d->ID3v1Location < 0)
|
if (d->ID3v1Location < 0)
|
||||||
APETag(true);
|
APETag(true);
|
||||||
|
|
||||||
// Look for APE audio properties
|
// Look for APE audio properties
|
||||||
|
|
||||||
if(readProperties) {
|
if (readProperties) {
|
||||||
|
|
||||||
long streamLength;
|
long long streamLength;
|
||||||
|
|
||||||
if(d->APELocation >= 0)
|
if (d->APELocation >= 0)
|
||||||
streamLength = d->APELocation;
|
streamLength = d->APELocation;
|
||||||
else if(d->ID3v1Location >= 0)
|
else if (d->ID3v1Location >= 0)
|
||||||
streamLength = d->ID3v1Location;
|
streamLength = d->ID3v1Location;
|
||||||
else
|
else
|
||||||
streamLength = length();
|
streamLength = length();
|
||||||
|
|
||||||
if(d->ID3v2Location >= 0) {
|
if (d->ID3v2Location >= 0) {
|
||||||
seek(d->ID3v2Location + d->ID3v2Size);
|
seek(d->ID3v2Location + d->ID3v2Size);
|
||||||
streamLength -= (d->ID3v2Location + d->ID3v2Size);
|
streamLength -= (d->ID3v2Location + d->ID3v2Size);
|
||||||
}
|
}
|
||||||
@@ -309,6 +285,7 @@ void APE::File::read(bool readProperties)
|
|||||||
seek(0);
|
seek(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
d->properties = new Properties(this, streamLength);
|
d->properties.reset(new AudioProperties(this, streamLength));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
137
3rdparty/taglib/ape/apefile.h
vendored
137
3rdparty/taglib/ape/apefile.h
vendored
@@ -38,39 +38,42 @@
|
|||||||
#include "taglib_export.h"
|
#include "taglib_export.h"
|
||||||
#include "apeproperties.h"
|
#include "apeproperties.h"
|
||||||
|
|
||||||
|
namespace Strawberry_TagLib {
|
||||||
namespace TagLib {
|
namespace TagLib {
|
||||||
|
|
||||||
class Tag;
|
class Tag;
|
||||||
|
|
||||||
namespace ID3v1 { class Tag; }
|
namespace ID3v1 {
|
||||||
namespace APE { class Tag; }
|
class Tag;
|
||||||
|
}
|
||||||
|
namespace APE {
|
||||||
|
class Tag;
|
||||||
|
}
|
||||||
|
|
||||||
//! An implementation of APE metadata
|
//! An implementation of APE metadata
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* This is implementation of APE metadata.
|
* This is implementation of APE metadata.
|
||||||
*
|
*
|
||||||
* This supports ID3v1 and APE (v1 and v2) style comments as well as reading stream
|
* This supports ID3v1 and APE (v1 and v2) style comments as well as reading stream properties from the file.
|
||||||
* properties from the file.
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace APE {
|
namespace APE {
|
||||||
|
|
||||||
//! An implementation of TagLib::File with APE specific methods
|
//! An implementation of TagLib::File with APE specific methods
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* This implements and provides an interface for APE files to the
|
* This implements and provides an interface for APE files to the
|
||||||
* TagLib::Tag and TagLib::AudioProperties interfaces by way of implementing
|
* TagLib::Tag and TagLib::AudioProperties interfaces by way of implementing
|
||||||
* the abstract TagLib::File API as well as providing some additional
|
* the abstract TagLib::File API as well as providing some additional information specific to APE files.
|
||||||
* information specific to APE files.
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class TAGLIB_EXPORT File : public TagLib::File
|
class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
/*!
|
/*!
|
||||||
* This set of flags is used for various operations and is suitable for
|
* This set of flags is used for various operations and is suitable for being OR-ed together.
|
||||||
* being OR-ed together.
|
|
||||||
*/
|
*/
|
||||||
enum TagTypes {
|
enum TagTypes {
|
||||||
//! Empty set. Matches no tag types.
|
//! Empty set. Matches no tag types.
|
||||||
@@ -84,62 +87,45 @@ namespace TagLib {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Constructs an APE file from \a file. If \a readProperties is true the
|
* Constructs an APE file from \a file.
|
||||||
* file's audio properties will also be read.
|
* If \a readProperties is true the file's audio properties will also be read.
|
||||||
*
|
*
|
||||||
* \note In the current implementation, \a propertiesStyle is ignored.
|
* \note In the current implementation, \a propertiesStyle is ignored.
|
||||||
*/
|
*/
|
||||||
File(FileName file, bool readProperties = true,
|
explicit File(FileName file, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average);
|
||||||
Properties::ReadStyle propertiesStyle = Properties::Average);
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Constructs an APE file from \a stream. If \a readProperties is true the
|
* Constructs an APE file from \a stream.
|
||||||
* file's audio properties will also be read.
|
* If \a readProperties is true the file's audio properties will also be read.
|
||||||
*
|
*
|
||||||
* \note TagLib will *not* take ownership of the stream, the caller is
|
* \note TagLib will *not* take ownership of the stream, the caller is responsible for deleting it after the File object.
|
||||||
* responsible for deleting it after the File object.
|
|
||||||
*
|
*
|
||||||
* \note In the current implementation, \a propertiesStyle is ignored.
|
* \note In the current implementation, \a propertiesStyle is ignored.
|
||||||
*/
|
*/
|
||||||
File(IOStream *stream, bool readProperties = true,
|
explicit File(IOStream *stream, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average);
|
||||||
Properties::ReadStyle propertiesStyle = Properties::Average);
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Destroys this instance of the File.
|
* Destroys this instance of the File.
|
||||||
*/
|
*/
|
||||||
virtual ~File();
|
~File() override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the Tag for this file. This will be an APE tag, an ID3v1 tag
|
* Returns the Tag for this file. This will be an APE tag, an ID3v1 tag or a combination of the two.
|
||||||
* or a combination of the two.
|
|
||||||
*/
|
*/
|
||||||
virtual TagLib::Tag *tag() const;
|
Strawberry_TagLib::TagLib::Tag *tag() const override;
|
||||||
|
|
||||||
/*!
|
|
||||||
* Implements the unified property interface -- export function.
|
|
||||||
* If the file contains both an APE and an ID3v1 tag, only APE
|
|
||||||
* will be converted to the PropertyMap.
|
|
||||||
*/
|
|
||||||
PropertyMap properties() const;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* Removes unsupported properties. Forwards to the actual Tag's
|
|
||||||
* removeUnsupportedProperties() function.
|
|
||||||
*/
|
|
||||||
void removeUnsupportedProperties(const StringList &properties);
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Implements the unified property interface -- import function.
|
* Implements the unified property interface -- import function.
|
||||||
* Creates an APEv2 tag if necessary. A potentially existing ID3v1
|
* Creates an APEv2 tag if necessary.
|
||||||
* tag will be updated as well.
|
* A potentially existing ID3v1 tag will be updated as well.
|
||||||
*/
|
*/
|
||||||
PropertyMap setProperties(const PropertyMap &);
|
PropertyMap setProperties(const PropertyMap&) override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the APE::Properties for this file. If no audio properties
|
* Returns the APE::AudioProperties for this file.
|
||||||
* were read then this will return a null pointer.
|
* If no audio properties were read then this will return a null pointer.
|
||||||
*/
|
*/
|
||||||
virtual Properties *audioProperties() const;
|
AudioProperties *audioProperties() const override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Saves the file.
|
* Saves the file.
|
||||||
@@ -147,22 +133,19 @@ namespace TagLib {
|
|||||||
* \note According to the official Monkey's Audio SDK, an APE file
|
* \note According to the official Monkey's Audio SDK, an APE file
|
||||||
* can only have either ID3V1 or APE tags, so a parameter is used here.
|
* can only have either ID3V1 or APE tags, so a parameter is used here.
|
||||||
*/
|
*/
|
||||||
virtual bool save();
|
bool save() override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns a pointer to the ID3v1 tag of the file.
|
* Returns a pointer to the ID3v1 tag of the file.
|
||||||
*
|
*
|
||||||
* If \a create is false (the default) this may return a null pointer
|
* If \a create is false (the default) this may return a null pointer if there is no valid ID3v1 tag.
|
||||||
* if there is no valid ID3v1 tag. If \a create is true it will create
|
* If \a create is true it will create an ID3v1 tag if one does not exist and returns a valid pointer.
|
||||||
* an ID3v1 tag if one does not exist and returns a valid pointer.
|
|
||||||
*
|
*
|
||||||
* \note This may return a valid pointer regardless of whether or not the
|
* \note This may return a valid pointer regardless of whether or not the file on disk has an ID3v1 tag.
|
||||||
* file on disk has an ID3v1 tag. Use hasID3v1Tag() to check if the file
|
* Use hasID3v1Tag() to check if the file on disk actually has an ID3v1 tag.
|
||||||
* on disk actually has an ID3v1 tag.
|
|
||||||
*
|
*
|
||||||
* \note The Tag <b>is still</b> owned by the MPEG::File and should not be
|
* \note The Tag <b>is still</b> owned by the MPEG::File and should not be deleted by the user.
|
||||||
* deleted by the user. It will be deleted when the file (object) is
|
* It will be deleted when the file (object) is destroyed.
|
||||||
* destroyed.
|
|
||||||
*
|
*
|
||||||
* \see hasID3v1Tag()
|
* \see hasID3v1Tag()
|
||||||
*/
|
*/
|
||||||
@@ -171,28 +154,24 @@ namespace TagLib {
|
|||||||
/*!
|
/*!
|
||||||
* Returns a pointer to the APE tag of the file.
|
* Returns a pointer to the APE tag of the file.
|
||||||
*
|
*
|
||||||
* If \a create is false (the default) this may return a null pointer
|
* If \a create is false (the default) this may return a null pointer if there is no valid APE tag.
|
||||||
* if there is no valid APE tag. If \a create is true it will create
|
* If \a create is true it will create an APE tag if one does not exist and returns a valid pointer.
|
||||||
* an APE tag if one does not exist and returns a valid pointer.
|
|
||||||
*
|
*
|
||||||
* \note This may return a valid pointer regardless of whether or not the
|
* \note This may return a valid pointer regardless of whether or not the file on disk has an APE tag.
|
||||||
* file on disk has an APE tag. Use hasAPETag() to check if the file
|
* Use hasAPETag() to check if the file on disk actually has an APE tag.
|
||||||
* on disk actually has an APE tag.
|
|
||||||
*
|
*
|
||||||
* \note The Tag <b>is still</b> owned by the MPEG::File and should not be
|
* \note The Tag <b>is still</b> owned by the MPEG::File and should not be deleted by the user.
|
||||||
* deleted by the user. It will be deleted when the file (object) is
|
* It will be deleted when the file (object) is destroyed.
|
||||||
* destroyed.
|
|
||||||
*
|
*
|
||||||
* \see hasAPETag()
|
* \see hasAPETag()
|
||||||
*/
|
*/
|
||||||
APE::Tag *APETag(bool create = false);
|
APE::Tag *APETag(bool create = false);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* This will remove the tags that match the OR-ed together TagTypes from the
|
* This will remove the tags that match the OR-ed together TagTypes from the file.
|
||||||
* file. By default it removes all tags.
|
* By default it removes all tags.
|
||||||
*
|
*
|
||||||
* \note This will also invalidate pointers to the tags
|
* \note This will also invalidate pointers to the tags as their memory will be freed.
|
||||||
* as their memory will be freed.
|
|
||||||
* \note In order to make the removal permanent save() still needs to be called
|
* \note In order to make the removal permanent save() still needs to be called
|
||||||
*/
|
*/
|
||||||
void strip(int tags = AllTags);
|
void strip(int tags = AllTags);
|
||||||
@@ -212,11 +191,10 @@ namespace TagLib {
|
|||||||
bool hasID3v1Tag() const;
|
bool hasID3v1Tag() const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns whether or not the given \a stream can be opened as an APE
|
* Returns whether or not the given \a stream can be opened as an APE file.
|
||||||
* file.
|
|
||||||
*
|
*
|
||||||
* \note This method is designed to do a quick check. The result may
|
* \note This method is designed to do a quick check.
|
||||||
* not necessarily be correct.
|
* The result may not necessarily be correct.
|
||||||
*/
|
*/
|
||||||
static bool isSupported(IOStream *stream);
|
static bool isSupported(IOStream *stream);
|
||||||
|
|
||||||
@@ -228,8 +206,9 @@ namespace TagLib {
|
|||||||
|
|
||||||
class FilePrivate;
|
class FilePrivate;
|
||||||
FilePrivate *d;
|
FilePrivate *d;
|
||||||
};
|
};
|
||||||
}
|
} // namespace APE
|
||||||
}
|
} // namespace TagLib
|
||||||
|
} // namespace Strawberry_TagLib
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
105
3rdparty/taglib/ape/apefooter.cpp
vendored
105
3rdparty/taglib/ape/apefooter.cpp
vendored
@@ -27,19 +27,17 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <bitset>
|
#include <bitset>
|
||||||
|
|
||||||
#include <tstring.h>
|
#include "tstring.h"
|
||||||
#include <tdebug.h>
|
#include "tdebug.h"
|
||||||
|
|
||||||
#include "apefooter.h"
|
#include "apefooter.h"
|
||||||
|
|
||||||
using namespace TagLib;
|
using namespace Strawberry_TagLib::TagLib;
|
||||||
using namespace APE;
|
using namespace APE;
|
||||||
|
|
||||||
class APE::Footer::FooterPrivate
|
class APE::Footer::FooterPrivate {
|
||||||
{
|
public:
|
||||||
public:
|
FooterPrivate() : version(0),
|
||||||
FooterPrivate() :
|
|
||||||
version(0),
|
|
||||||
footerPresent(true),
|
footerPresent(true),
|
||||||
headerPresent(false),
|
headerPresent(false),
|
||||||
isHeader(false),
|
isHeader(false),
|
||||||
@@ -61,13 +59,11 @@ public:
|
|||||||
// static members
|
// static members
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
unsigned int APE::Footer::size()
|
unsigned int APE::Footer::size() {
|
||||||
{
|
|
||||||
return 32;
|
return 32;
|
||||||
}
|
}
|
||||||
|
|
||||||
ByteVector APE::Footer::fileIdentifier()
|
ByteVector APE::Footer::fileIdentifier() {
|
||||||
{
|
|
||||||
return ByteVector("APETAGEX");
|
return ByteVector("APETAGEX");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,119 +71,103 @@ ByteVector APE::Footer::fileIdentifier()
|
|||||||
// public members
|
// public members
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
APE::Footer::Footer() :
|
APE::Footer::Footer() : d(new FooterPrivate()) {
|
||||||
d(new FooterPrivate())
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
APE::Footer::Footer(const ByteVector &data) :
|
APE::Footer::Footer(const ByteVector &data) : d(new FooterPrivate()) {
|
||||||
d(new FooterPrivate())
|
|
||||||
{
|
|
||||||
parse(data);
|
parse(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
APE::Footer::~Footer()
|
APE::Footer::~Footer() {
|
||||||
{
|
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int APE::Footer::version() const
|
unsigned int APE::Footer::version() const {
|
||||||
{
|
|
||||||
return d->version;
|
return d->version;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool APE::Footer::headerPresent() const
|
bool APE::Footer::headerPresent() const {
|
||||||
{
|
|
||||||
return d->headerPresent;
|
return d->headerPresent;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool APE::Footer::footerPresent() const
|
bool APE::Footer::footerPresent() const {
|
||||||
{
|
|
||||||
return d->footerPresent;
|
return d->footerPresent;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool APE::Footer::isHeader() const
|
bool APE::Footer::isHeader() const {
|
||||||
{
|
|
||||||
return d->isHeader;
|
return d->isHeader;
|
||||||
}
|
}
|
||||||
|
|
||||||
void APE::Footer::setHeaderPresent(bool b) const
|
void APE::Footer::setHeaderPresent(bool b) const {
|
||||||
{
|
|
||||||
d->headerPresent = b;
|
d->headerPresent = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int APE::Footer::itemCount() const
|
unsigned int APE::Footer::itemCount() const {
|
||||||
{
|
|
||||||
return d->itemCount;
|
return d->itemCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
void APE::Footer::setItemCount(unsigned int s)
|
void APE::Footer::setItemCount(unsigned int s) {
|
||||||
{
|
|
||||||
d->itemCount = s;
|
d->itemCount = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int APE::Footer::tagSize() const
|
unsigned int APE::Footer::tagSize() const {
|
||||||
{
|
|
||||||
return d->tagSize;
|
return d->tagSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int APE::Footer::completeTagSize() const
|
unsigned int APE::Footer::completeTagSize() const {
|
||||||
{
|
if (d->headerPresent)
|
||||||
if(d->headerPresent)
|
|
||||||
return d->tagSize + size();
|
return d->tagSize + size();
|
||||||
else
|
else
|
||||||
return d->tagSize;
|
return d->tagSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
void APE::Footer::setTagSize(unsigned int s)
|
void APE::Footer::setTagSize(unsigned int s) {
|
||||||
{
|
|
||||||
d->tagSize = s;
|
d->tagSize = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
void APE::Footer::setData(const ByteVector &data)
|
void APE::Footer::setData(const ByteVector &data) {
|
||||||
{
|
|
||||||
parse(data);
|
parse(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
ByteVector APE::Footer::renderFooter() const
|
ByteVector APE::Footer::renderFooter() const {
|
||||||
{
|
|
||||||
return render(false);
|
return render(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
ByteVector APE::Footer::renderHeader() const
|
ByteVector APE::Footer::renderHeader() const {
|
||||||
{
|
|
||||||
if(!d->headerPresent)
|
if (!d->headerPresent)
|
||||||
return ByteVector();
|
return ByteVector();
|
||||||
else
|
else
|
||||||
return render(true);
|
return render(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// protected members
|
// protected members
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void APE::Footer::parse(const ByteVector &data)
|
void APE::Footer::parse(const ByteVector &data) {
|
||||||
{
|
|
||||||
if(data.size() < size())
|
if (data.size() < size())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// The first eight bytes, data[0..7], are the File Identifier, "APETAGEX".
|
// The first eight bytes, data[0..7], are the File Identifier, "APETAGEX".
|
||||||
|
|
||||||
// Read the version number
|
// Read the version number
|
||||||
|
|
||||||
d->version = data.toUInt(8, false);
|
d->version = data.toUInt32LE(8);
|
||||||
|
|
||||||
// Read the tag size
|
// Read the tag size
|
||||||
|
|
||||||
d->tagSize = data.toUInt(12, false);
|
d->tagSize = data.toUInt32LE(12);
|
||||||
|
|
||||||
// Read the item count
|
// Read the item count
|
||||||
|
|
||||||
d->itemCount = data.toUInt(16, false);
|
d->itemCount = data.toUInt32LE(16);
|
||||||
|
|
||||||
// Read the flags
|
// Read the flags
|
||||||
|
|
||||||
std::bitset<32> flags(TAGLIB_CONSTRUCT_BITSET(data.toUInt(20, false)));
|
std::bitset<32> flags(TAGLIB_CONSTRUCT_BITSET(data.toUInt32LE(20)));
|
||||||
|
|
||||||
d->headerPresent = flags[31];
|
d->headerPresent = flags[31];
|
||||||
d->footerPresent = !flags[30];
|
d->footerPresent = !flags[30];
|
||||||
@@ -195,8 +175,8 @@ void APE::Footer::parse(const ByteVector &data)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ByteVector APE::Footer::render(bool isHeader) const
|
ByteVector APE::Footer::render(bool isHeader) const {
|
||||||
{
|
|
||||||
ByteVector v;
|
ByteVector v;
|
||||||
|
|
||||||
// add the file identifier -- "APETAGEX"
|
// add the file identifier -- "APETAGEX"
|
||||||
@@ -206,15 +186,15 @@ ByteVector APE::Footer::render(bool isHeader) const
|
|||||||
// add the version number -- we always render a 2.000 tag regardless of what
|
// add the version number -- we always render a 2.000 tag regardless of what
|
||||||
// the tag originally was.
|
// the tag originally was.
|
||||||
|
|
||||||
v.append(ByteVector::fromUInt(2000, false));
|
v.append(ByteVector::fromUInt32LE(2000));
|
||||||
|
|
||||||
// add the tag size
|
// add the tag size
|
||||||
|
|
||||||
v.append(ByteVector::fromUInt(d->tagSize, false));
|
v.append(ByteVector::fromUInt32LE(d->tagSize));
|
||||||
|
|
||||||
// add the item count
|
// add the item count
|
||||||
|
|
||||||
v.append(ByteVector::fromUInt(d->itemCount, false));
|
v.append(ByteVector::fromUInt32LE(d->itemCount));
|
||||||
|
|
||||||
// render and add the flags
|
// render and add the flags
|
||||||
|
|
||||||
@@ -224,11 +204,12 @@ ByteVector APE::Footer::render(bool isHeader) const
|
|||||||
flags[30] = false; // footer is always present
|
flags[30] = false; // footer is always present
|
||||||
flags[29] = isHeader;
|
flags[29] = isHeader;
|
||||||
|
|
||||||
v.append(ByteVector::fromUInt(flags.to_ulong(), false));
|
v.append(ByteVector::fromUInt32LE(flags.to_ulong()));
|
||||||
|
|
||||||
// add the reserved 64bit
|
// add the reserved 64bit
|
||||||
|
|
||||||
v.append(ByteVector::fromLongLong(0));
|
v.append(ByteVector::fromUInt64BE(0));
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
44
3rdparty/taglib/ape/apefooter.h
vendored
44
3rdparty/taglib/ape/apefooter.h
vendored
@@ -29,32 +29,32 @@
|
|||||||
#include "tbytevector.h"
|
#include "tbytevector.h"
|
||||||
#include "taglib_export.h"
|
#include "taglib_export.h"
|
||||||
|
|
||||||
|
namespace Strawberry_TagLib {
|
||||||
namespace TagLib {
|
namespace TagLib {
|
||||||
|
|
||||||
namespace APE {
|
namespace APE {
|
||||||
|
|
||||||
//! An implementation of APE footers
|
//! An implementation of APE footers
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* This class implements APE footers (and headers). It attempts to follow, both
|
* This class implements APE footers (and headers).
|
||||||
* semantically and programmatically, the structure specified in
|
* It attempts to follow, both semantically and programmatically,
|
||||||
* the APE v2.0 standard. The API is based on the properties of APE footer and
|
* the structure specified in the APE v2.0 standard.
|
||||||
* headers specified there.
|
* The API is based on the properties of APE footer and headers specified there.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class TAGLIB_EXPORT Footer
|
class TAGLIB_EXPORT Footer {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
/*!
|
/*!
|
||||||
* Constructs an empty APE footer.
|
* Constructs an empty APE footer.
|
||||||
*/
|
*/
|
||||||
Footer();
|
explicit Footer();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Constructs an APE footer based on \a data. parse() is called
|
* Constructs an APE footer based on \a data. parse() is called immediately.
|
||||||
* immediately.
|
|
||||||
*/
|
*/
|
||||||
Footer(const ByteVector &data);
|
explicit Footer(const ByteVector &data);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Destroys the footer.
|
* Destroys the footer.
|
||||||
@@ -98,7 +98,8 @@ namespace TagLib {
|
|||||||
void setItemCount(unsigned int s);
|
void setItemCount(unsigned int s);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the tag size in bytes. This is the size of the frame content and footer.
|
* Returns the tag size in bytes.
|
||||||
|
* This is the size of the frame content and footer.
|
||||||
* The size of the \e entire tag will be this plus the header size, if present.
|
* The size of the \e entire tag will be this plus the header size, if present.
|
||||||
*
|
*
|
||||||
* \see completeTagSize()
|
* \see completeTagSize()
|
||||||
@@ -142,15 +143,15 @@ namespace TagLib {
|
|||||||
ByteVector renderFooter() const;
|
ByteVector renderFooter() const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Renders the header corresponding to the footer. If headerPresent is
|
* Renders the header corresponding to the footer.
|
||||||
* set to false, it returns an empty ByteVector.
|
* If headerPresent is set to false, it returns an empty ByteVector.
|
||||||
*/
|
*/
|
||||||
ByteVector renderHeader() const;
|
ByteVector renderHeader() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/*!
|
/*!
|
||||||
* Called by setData() to parse the footer data. It makes this information
|
* Called by setData() to parse the footer data.
|
||||||
* available through the public API.
|
* It makes this information available through the public API.
|
||||||
*/
|
*/
|
||||||
void parse(const ByteVector &data);
|
void parse(const ByteVector &data);
|
||||||
|
|
||||||
@@ -165,9 +166,10 @@ namespace TagLib {
|
|||||||
|
|
||||||
class FooterPrivate;
|
class FooterPrivate;
|
||||||
FooterPrivate *d;
|
FooterPrivate *d;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace APE
|
||||||
}
|
} // namespace TagLib
|
||||||
|
} // namespace Strawberry_TagLib
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
258
3rdparty/taglib/ape/apeitem.cpp
vendored
258
3rdparty/taglib/ape/apeitem.cpp
vendored
@@ -23,20 +23,18 @@
|
|||||||
* http://www.mozilla.org/MPL/ *
|
* http://www.mozilla.org/MPL/ *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include <tbytevectorlist.h>
|
#include <memory>
|
||||||
#include <tdebug.h>
|
|
||||||
|
#include "tbytevectorlist.h"
|
||||||
|
#include "tdebug.h"
|
||||||
|
|
||||||
#include "apeitem.h"
|
#include "apeitem.h"
|
||||||
|
|
||||||
using namespace TagLib;
|
using namespace Strawberry_TagLib::TagLib;
|
||||||
using namespace APE;
|
using namespace APE;
|
||||||
|
|
||||||
class APE::Item::ItemPrivate
|
struct ItemData {
|
||||||
{
|
ItemData() : type(Item::Text), readOnly(false) {}
|
||||||
public:
|
|
||||||
ItemPrivate() :
|
|
||||||
type(Text),
|
|
||||||
readOnly(false) {}
|
|
||||||
|
|
||||||
Item::ItemTypes type;
|
Item::ItemTypes type;
|
||||||
String key;
|
String key;
|
||||||
@@ -45,257 +43,229 @@ public:
|
|||||||
bool readOnly;
|
bool readOnly;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class APE::Item::ItemPrivate {
|
||||||
|
public:
|
||||||
|
ItemPrivate() : data(new ItemData()) {}
|
||||||
|
|
||||||
|
std::shared_ptr<ItemData> data;
|
||||||
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// public members
|
// public members
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
APE::Item::Item() :
|
APE::Item::Item() : d(new ItemPrivate()) {}
|
||||||
d(new ItemPrivate())
|
|
||||||
{
|
APE::Item::Item(const String &key, const String &value) : d(new ItemPrivate()) {
|
||||||
|
d->data->key = key;
|
||||||
|
d->data->text.append(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
APE::Item::Item(const String &key, const String &value) :
|
APE::Item::Item(const String &key, const StringList &values) : d(new ItemPrivate()) {
|
||||||
d(new ItemPrivate())
|
d->data->key = key;
|
||||||
{
|
d->data->text = values;
|
||||||
d->key = key;
|
|
||||||
d->text.append(value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
APE::Item::Item(const String &key, const StringList &values) :
|
APE::Item::Item(const String &key, const ByteVector &value, bool binary) : d(new ItemPrivate()) {
|
||||||
d(new ItemPrivate())
|
d->data->key = key;
|
||||||
{
|
if (binary) {
|
||||||
d->key = key;
|
d->data->type = Binary;
|
||||||
d->text = values;
|
d->data->value = value;
|
||||||
}
|
|
||||||
|
|
||||||
APE::Item::Item(const String &key, const ByteVector &value, bool binary) :
|
|
||||||
d(new ItemPrivate())
|
|
||||||
{
|
|
||||||
d->key = key;
|
|
||||||
if(binary) {
|
|
||||||
d->type = Binary;
|
|
||||||
d->value = value;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
d->text.append(value);
|
d->data->text.append(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
APE::Item::Item(const Item &item) :
|
APE::Item::Item(const Item &item) : d(new ItemPrivate(*item.d)) {}
|
||||||
d(new ItemPrivate(*item.d))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
APE::Item::~Item()
|
APE::Item::~Item() {
|
||||||
{
|
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
Item &APE::Item::operator=(const Item &item)
|
Item &APE::Item::operator=(const Item &item) {
|
||||||
{
|
|
||||||
Item(item).swap(*this);
|
Item(item).swap(*this);
|
||||||
return *this;
|
return *this;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void APE::Item::swap(Item &item)
|
void APE::Item::swap(Item &item) {
|
||||||
{
|
|
||||||
using std::swap;
|
using std::swap;
|
||||||
|
|
||||||
swap(d, item.d);
|
swap(d, item.d);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void APE::Item::setReadOnly(bool readOnly)
|
void APE::Item::setReadOnly(bool readOnly) {
|
||||||
{
|
d->data->readOnly = readOnly;
|
||||||
d->readOnly = readOnly;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool APE::Item::isReadOnly() const
|
bool APE::Item::isReadOnly() const {
|
||||||
{
|
return d->data->readOnly;
|
||||||
return d->readOnly;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void APE::Item::setType(APE::Item::ItemTypes val)
|
void APE::Item::setType(APE::Item::ItemTypes val) {
|
||||||
{
|
d->data->type = val;
|
||||||
d->type = val;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
APE::Item::ItemTypes APE::Item::type() const
|
APE::Item::ItemTypes APE::Item::type() const {
|
||||||
{
|
return d->data->type;
|
||||||
return d->type;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String APE::Item::key() const
|
String APE::Item::key() const {
|
||||||
{
|
return d->data->key;
|
||||||
return d->key;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ByteVector APE::Item::binaryData() const
|
ByteVector APE::Item::binaryData() const {
|
||||||
{
|
return d->data->value;
|
||||||
return d->value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void APE::Item::setBinaryData(const ByteVector &value)
|
void APE::Item::setBinaryData(const ByteVector &value) {
|
||||||
{
|
d->data->type = Binary;
|
||||||
d->type = Binary;
|
d->data->value = value;
|
||||||
d->value = value;
|
d->data->text.clear();
|
||||||
d->text.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ByteVector APE::Item::value() const
|
void APE::Item::setKey(const String &key) {
|
||||||
{
|
d->data->key = key;
|
||||||
// This seems incorrect as it won't be actually rendering the value to keep it
|
|
||||||
// up to date.
|
|
||||||
|
|
||||||
return d->value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void APE::Item::setKey(const String &key)
|
void APE::Item::setValue(const String &value) {
|
||||||
{
|
d->data->type = Text;
|
||||||
d->key = key;
|
d->data->text = value;
|
||||||
|
d->data->value.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void APE::Item::setValue(const String &value)
|
void APE::Item::setValues(const StringList &value) {
|
||||||
{
|
d->data->type = Text;
|
||||||
d->type = Text;
|
d->data->text = value;
|
||||||
d->text = value;
|
d->data->value.clear();
|
||||||
d->value.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void APE::Item::setValues(const StringList &value)
|
void APE::Item::appendValue(const String &value) {
|
||||||
{
|
d->data->type = Text;
|
||||||
d->type = Text;
|
d->data->text.append(value);
|
||||||
d->text = value;
|
d->data->value.clear();
|
||||||
d->value.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void APE::Item::appendValue(const String &value)
|
void APE::Item::appendValues(const StringList &values) {
|
||||||
{
|
d->data->type = Text;
|
||||||
d->type = Text;
|
d->data->text.append(values);
|
||||||
d->text.append(value);
|
d->data->value.clear();
|
||||||
d->value.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void APE::Item::appendValues(const StringList &values)
|
int APE::Item::size() const {
|
||||||
{
|
size_t result = 8 + d->data->key.size() + 1;
|
||||||
d->type = Text;
|
switch (d->data->type) {
|
||||||
d->text.append(values);
|
|
||||||
d->value.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
int APE::Item::size() const
|
|
||||||
{
|
|
||||||
int result = 8 + d->key.size() + 1;
|
|
||||||
switch(d->type) {
|
|
||||||
case Text:
|
case Text:
|
||||||
if(!d->text.isEmpty()) {
|
if (!d->data->text.isEmpty()) {
|
||||||
StringList::ConstIterator it = d->text.begin();
|
StringList::ConstIterator it = d->data->text.begin();
|
||||||
|
|
||||||
result += it->data(String::UTF8).size();
|
result += it->data(String::UTF8).size();
|
||||||
it++;
|
it++;
|
||||||
for(; it != d->text.end(); ++it)
|
for (; it != d->data->text.end(); ++it)
|
||||||
result += 1 + it->data(String::UTF8).size();
|
result += 1 + it->data(String::UTF8).size();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Binary:
|
case Binary:
|
||||||
case Locator:
|
case Locator:
|
||||||
result += d->value.size();
|
result += d->data->value.size();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
StringList APE::Item::toStringList() const
|
StringList APE::Item::values() const {
|
||||||
{
|
return d->data->text;
|
||||||
return d->text;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
StringList APE::Item::values() const
|
String APE::Item::toString() const {
|
||||||
{
|
if (d->data->type == Text && !isEmpty())
|
||||||
return d->text;
|
return d->data->text.front();
|
||||||
}
|
|
||||||
|
|
||||||
String APE::Item::toString() const
|
|
||||||
{
|
|
||||||
if(d->type == Text && !isEmpty())
|
|
||||||
return d->text.front();
|
|
||||||
else
|
else
|
||||||
return String();
|
return String();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool APE::Item::isEmpty() const
|
bool APE::Item::isEmpty() const {
|
||||||
{
|
switch (d->data->type) {
|
||||||
switch(d->type) {
|
|
||||||
case Text:
|
case Text:
|
||||||
if(d->text.isEmpty())
|
if (d->data->text.isEmpty())
|
||||||
return true;
|
return true;
|
||||||
if(d->text.size() == 1 && d->text.front().isEmpty())
|
if (d->data->text.size() == 1 && d->data->text.front().isEmpty())
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
case Binary:
|
case Binary:
|
||||||
case Locator:
|
case Locator:
|
||||||
return d->value.isEmpty();
|
return d->data->value.isEmpty();
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void APE::Item::parse(const ByteVector &data)
|
void APE::Item::parse(const ByteVector &data) {
|
||||||
{
|
|
||||||
// 11 bytes is the minimum size for an APE item
|
// 11 bytes is the minimum size for an APE item
|
||||||
|
|
||||||
if(data.size() < 11) {
|
if (data.size() < 11) {
|
||||||
debug("APE::Item::parse() -- no data in item");
|
debug("APE::Item::parse() -- no data in item");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const unsigned int valueLength = data.toUInt(0, false);
|
const unsigned int valueLength = data.toUInt32LE(0);
|
||||||
const unsigned int flags = data.toUInt(4, false);
|
const unsigned int flags = data.toUInt32LE(4);
|
||||||
|
|
||||||
// An item key can contain ASCII characters from 0x20 up to 0x7E, not UTF-8.
|
// An item key can contain ASCII characters from 0x20 up to 0x7E, not UTF-8.
|
||||||
// We assume that the validity of the given key has been checked.
|
// We assume that the validity of the given key has been checked.
|
||||||
|
|
||||||
d->key = String(&data[8], String::Latin1);
|
d->data->key = String(&data[8], String::Latin1);
|
||||||
|
|
||||||
const ByteVector value = data.mid(8 + d->key.size() + 1, valueLength);
|
const ByteVector value = data.mid(8 + d->data->key.size() + 1, valueLength);
|
||||||
|
|
||||||
setReadOnly(flags & 1);
|
setReadOnly(flags & 1);
|
||||||
setType(ItemTypes((flags >> 1) & 3));
|
setType(ItemTypes((flags >> 1) & 3));
|
||||||
|
|
||||||
if(Text == d->type)
|
if (Text == d->data->type)
|
||||||
d->text = StringList(ByteVectorList::split(value, '\0'), String::UTF8);
|
d->data->text = StringList(ByteVectorList::split(value, '\0'), String::UTF8);
|
||||||
else
|
else
|
||||||
d->value = value;
|
d->data->value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
ByteVector APE::Item::render() const
|
ByteVector APE::Item::render() const {
|
||||||
{
|
|
||||||
ByteVector data;
|
ByteVector data;
|
||||||
unsigned int flags = ((d->readOnly) ? 1 : 0) | (d->type << 1);
|
unsigned int flags = ((d->data->readOnly) ? 1 : 0) | (d->data->type << 1);
|
||||||
ByteVector value;
|
ByteVector value;
|
||||||
|
|
||||||
if(isEmpty())
|
if (isEmpty())
|
||||||
return data;
|
return data;
|
||||||
|
|
||||||
if(d->type == Text) {
|
if (d->data->type == Text) {
|
||||||
StringList::ConstIterator it = d->text.begin();
|
StringList::ConstIterator it = d->data->text.begin();
|
||||||
|
|
||||||
value.append(it->data(String::UTF8));
|
value.append(it->data(String::UTF8));
|
||||||
it++;
|
it++;
|
||||||
for(; it != d->text.end(); ++it) {
|
for (; it != d->data->text.end(); ++it) {
|
||||||
value.append('\0');
|
value.append('\0');
|
||||||
value.append(it->data(String::UTF8));
|
value.append(it->data(String::UTF8));
|
||||||
}
|
}
|
||||||
d->value = value;
|
d->data->value = value;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
value.append(d->value);
|
value.append(d->data->value);
|
||||||
|
|
||||||
data.append(ByteVector::fromUInt(value.size(), false));
|
data.append(ByteVector::fromUInt32LE(value.size()));
|
||||||
data.append(ByteVector::fromUInt(flags, false));
|
data.append(ByteVector::fromUInt32LE(flags));
|
||||||
data.append(d->key.data(String::Latin1));
|
data.append(d->data->key.data(String::Latin1));
|
||||||
data.append(ByteVector('\0'));
|
data.append(ByteVector('\0'));
|
||||||
data.append(value);
|
data.append(value);
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
61
3rdparty/taglib/ape/apeitem.h
vendored
61
3rdparty/taglib/ape/apeitem.h
vendored
@@ -30,17 +30,16 @@
|
|||||||
#include "tstring.h"
|
#include "tstring.h"
|
||||||
#include "tstringlist.h"
|
#include "tstringlist.h"
|
||||||
|
|
||||||
|
namespace Strawberry_TagLib {
|
||||||
namespace TagLib {
|
namespace TagLib {
|
||||||
|
namespace APE {
|
||||||
|
|
||||||
namespace APE {
|
//! An implementation of APE-items
|
||||||
|
|
||||||
//! An implementation of APE-items
|
/*!
|
||||||
|
|
||||||
/*!
|
|
||||||
* This class provides the features of items in the APEv2 standard.
|
* This class provides the features of items in the APEv2 standard.
|
||||||
*/
|
*/
|
||||||
class TAGLIB_EXPORT Item
|
class TAGLIB_EXPORT Item {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
/*!
|
/*!
|
||||||
* Enum of types an Item can have. The value of 3 is reserved.
|
* Enum of types an Item can have. The value of 3 is reserved.
|
||||||
@@ -56,24 +55,23 @@ namespace TagLib {
|
|||||||
/*!
|
/*!
|
||||||
* Constructs an empty item.
|
* Constructs an empty item.
|
||||||
*/
|
*/
|
||||||
Item();
|
explicit Item();
|
||||||
|
|
||||||
/*!
|
|
||||||
* Constructs a text item with \a key and \a value.
|
|
||||||
*/
|
|
||||||
// BIC: Remove this, StringList has a constructor from a single string
|
|
||||||
Item(const String &key, const String &value);
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Constructs a text item with \a key and \a values.
|
* Constructs a text item with \a key and \a values.
|
||||||
*/
|
*/
|
||||||
Item(const String &key, const StringList &values);
|
explicit Item(const String &key, const String &values);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Constructs a text item with \a key and \a values.
|
||||||
|
*/
|
||||||
|
explicit Item(const String &key, const StringList &values);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Constructs an item with \a key and \a value.
|
* Constructs an item with \a key and \a value.
|
||||||
* If \a binary is true a Binary item will be created, otherwise \a value will be interpreted as text
|
* If \a binary is true a Binary item will be created, otherwise \a value will be interpreted as text
|
||||||
*/
|
*/
|
||||||
Item(const String &key, const ByteVector &value, bool binary);
|
explicit Item(const String &key, const ByteVector &value, bool binary);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Construct an item as a copy of \a item.
|
* Construct an item as a copy of \a item.
|
||||||
@@ -112,11 +110,6 @@ namespace TagLib {
|
|||||||
*/
|
*/
|
||||||
void setBinaryData(const ByteVector &value);
|
void setBinaryData(const ByteVector &value);
|
||||||
|
|
||||||
#ifndef DO_NOT_DOCUMENT
|
|
||||||
/* Remove in next binary incompatible release */
|
|
||||||
ByteVector value() const;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Sets the key for the item to \a key.
|
* Sets the key for the item to \a key.
|
||||||
*/
|
*/
|
||||||
@@ -130,8 +123,7 @@ namespace TagLib {
|
|||||||
void setValue(const String &value);
|
void setValue(const String &value);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Sets the text value of the item to the list of values in \a value and clears
|
* Sets the text value of the item to the list of values in \a value and clears any previous contents.
|
||||||
* any previous contents.
|
|
||||||
*
|
*
|
||||||
* \see toStringList()
|
* \see toStringList()
|
||||||
*/
|
*/
|
||||||
@@ -157,20 +149,13 @@ namespace TagLib {
|
|||||||
int size() const;
|
int size() const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the value as a single string. In case of multiple strings,
|
* Returns the value as a single string. In case of multiple strings, the first is returned.
|
||||||
* the first is returned. If the data type is not \a Text, always returns
|
* If the data type is not \a Text, always returns an empty String.
|
||||||
* an empty String.
|
|
||||||
*/
|
*/
|
||||||
String toString() const;
|
String toString() const;
|
||||||
|
|
||||||
#ifndef DO_NOT_DOCUMENT
|
|
||||||
/* Remove in next binary incompatible release */
|
|
||||||
StringList toStringList() const;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the list of text values. If the data type is not \a Text, always
|
* Returns the list of text values. If the data type is not \a Text, always returns an empty StringList.
|
||||||
* returns an empty StringList.
|
|
||||||
*/
|
*/
|
||||||
StringList values() const;
|
StringList values() const;
|
||||||
|
|
||||||
@@ -182,7 +167,7 @@ namespace TagLib {
|
|||||||
/*!
|
/*!
|
||||||
* Parse the item from the ByteVector \a data.
|
* Parse the item from the ByteVector \a data.
|
||||||
*/
|
*/
|
||||||
void parse(const ByteVector& data);
|
void parse(const ByteVector &data);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Set the item to read-only.
|
* Set the item to read-only.
|
||||||
@@ -214,11 +199,9 @@ namespace TagLib {
|
|||||||
private:
|
private:
|
||||||
class ItemPrivate;
|
class ItemPrivate;
|
||||||
ItemPrivate *d;
|
ItemPrivate *d;
|
||||||
};
|
};
|
||||||
}
|
} // namespace APE
|
||||||
|
} // namespace TagLib
|
||||||
}
|
} // namespace Strawberry_TagLib
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
151
3rdparty/taglib/ape/apeproperties.cpp
vendored
151
3rdparty/taglib/ape/apeproperties.cpp
vendored
@@ -27,22 +27,20 @@
|
|||||||
* http://www.mozilla.org/MPL/ *
|
* http://www.mozilla.org/MPL/ *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include <tstring.h>
|
#include "tstring.h"
|
||||||
#include <tdebug.h>
|
#include "tdebug.h"
|
||||||
#include <bitset>
|
|
||||||
#include "id3v2tag.h"
|
#include "id3v2tag.h"
|
||||||
#include "apeproperties.h"
|
#include "apeproperties.h"
|
||||||
#include "apefile.h"
|
#include "apefile.h"
|
||||||
#include "apetag.h"
|
#include "apetag.h"
|
||||||
#include "apefooter.h"
|
#include "apefooter.h"
|
||||||
|
|
||||||
using namespace TagLib;
|
using namespace Strawberry_TagLib::TagLib;
|
||||||
|
|
||||||
class APE::Properties::PropertiesPrivate
|
class APE::AudioProperties::AudioPropertiesPrivate {
|
||||||
{
|
public:
|
||||||
public:
|
explicit AudioPropertiesPrivate() : length(0),
|
||||||
PropertiesPrivate() :
|
|
||||||
length(0),
|
|
||||||
bitrate(0),
|
bitrate(0),
|
||||||
sampleRate(0),
|
sampleRate(0),
|
||||||
channels(0),
|
channels(0),
|
||||||
@@ -63,67 +61,43 @@ public:
|
|||||||
// public members
|
// public members
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
APE::Properties::Properties(File *, ReadStyle style) :
|
APE::AudioProperties::AudioProperties(File *file, long long streamLength, ReadStyle) : Strawberry_TagLib::TagLib::AudioProperties(), d(new AudioPropertiesPrivate()) {
|
||||||
AudioProperties(style),
|
|
||||||
d(new PropertiesPrivate())
|
|
||||||
{
|
|
||||||
debug("APE::Properties::Properties() -- This constructor is no longer used.");
|
|
||||||
}
|
|
||||||
|
|
||||||
APE::Properties::Properties(File *file, long streamLength, ReadStyle style) :
|
|
||||||
AudioProperties(style),
|
|
||||||
d(new PropertiesPrivate())
|
|
||||||
{
|
|
||||||
read(file, streamLength);
|
read(file, streamLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
APE::Properties::~Properties()
|
APE::AudioProperties::~AudioProperties() {
|
||||||
{
|
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
int APE::Properties::length() const
|
int APE::AudioProperties::lengthInSeconds() const {
|
||||||
{
|
|
||||||
return lengthInSeconds();
|
|
||||||
}
|
|
||||||
|
|
||||||
int APE::Properties::lengthInSeconds() const
|
|
||||||
{
|
|
||||||
return d->length / 1000;
|
return d->length / 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
int APE::Properties::lengthInMilliseconds() const
|
int APE::AudioProperties::lengthInMilliseconds() const {
|
||||||
{
|
|
||||||
return d->length;
|
return d->length;
|
||||||
}
|
}
|
||||||
|
|
||||||
int APE::Properties::bitrate() const
|
int APE::AudioProperties::bitrate() const {
|
||||||
{
|
|
||||||
return d->bitrate;
|
return d->bitrate;
|
||||||
}
|
}
|
||||||
|
|
||||||
int APE::Properties::sampleRate() const
|
int APE::AudioProperties::sampleRate() const {
|
||||||
{
|
|
||||||
return d->sampleRate;
|
return d->sampleRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
int APE::Properties::channels() const
|
int APE::AudioProperties::channels() const {
|
||||||
{
|
|
||||||
return d->channels;
|
return d->channels;
|
||||||
}
|
}
|
||||||
|
|
||||||
int APE::Properties::version() const
|
int APE::AudioProperties::version() const {
|
||||||
{
|
|
||||||
return d->version;
|
return d->version;
|
||||||
}
|
}
|
||||||
|
|
||||||
int APE::Properties::bitsPerSample() const
|
int APE::AudioProperties::bitsPerSample() const {
|
||||||
{
|
|
||||||
return d->bitsPerSample;
|
return d->bitsPerSample;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int APE::Properties::sampleFrames() const
|
unsigned int APE::AudioProperties::sampleFrames() const {
|
||||||
{
|
|
||||||
return d->sampleFrames;
|
return d->sampleFrames;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,122 +105,123 @@ unsigned int APE::Properties::sampleFrames() const
|
|||||||
// private members
|
// private members
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
namespace
|
namespace {
|
||||||
{
|
int headerVersion(const ByteVector &header) {
|
||||||
int headerVersion(const ByteVector &header)
|
if (header.size() < 6 || !header.startsWith("MAC "))
|
||||||
{
|
|
||||||
if(header.size() < 6 || !header.startsWith("MAC "))
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return header.toUShort(4, false);
|
return header.toUInt16LE(4);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
void APE::AudioProperties::read(File *file, long long streamLength) {
|
||||||
|
|
||||||
void APE::Properties::read(File *file, long streamLength)
|
|
||||||
{
|
|
||||||
// First, we assume that the file pointer is set at the first descriptor.
|
// First, we assume that the file pointer is set at the first descriptor.
|
||||||
long offset = file->tell();
|
long long offset = file->tell();
|
||||||
int version = headerVersion(file->readBlock(6));
|
int version = headerVersion(file->readBlock(6));
|
||||||
|
|
||||||
// Next, we look for the descriptor.
|
// Next, we look for the descriptor.
|
||||||
if(version < 0) {
|
if (version < 0) {
|
||||||
offset = file->find("MAC ", offset);
|
offset = file->find("MAC ", offset);
|
||||||
file->seek(offset);
|
file->seek(offset);
|
||||||
version = headerVersion(file->readBlock(6));
|
version = headerVersion(file->readBlock(6));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(version < 0) {
|
if (version < 0) {
|
||||||
debug("APE::Properties::read() -- APE descriptor not found");
|
debug("APE::AudioProperties::read() -- APE descriptor not found");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
d->version = version;
|
d->version = version;
|
||||||
|
|
||||||
if(d->version >= 3980)
|
if (d->version >= 3980)
|
||||||
analyzeCurrent(file);
|
analyzeCurrent(file);
|
||||||
else
|
else
|
||||||
analyzeOld(file);
|
analyzeOld(file);
|
||||||
|
|
||||||
if(d->sampleFrames > 0 && d->sampleRate > 0) {
|
if (d->sampleFrames > 0 && d->sampleRate > 0) {
|
||||||
const double length = d->sampleFrames * 1000.0 / d->sampleRate;
|
const double length = d->sampleFrames * 1000.0 / d->sampleRate;
|
||||||
d->length = static_cast<int>(length + 0.5);
|
d->length = static_cast<int>(length + 0.5);
|
||||||
d->bitrate = static_cast<int>(streamLength * 8.0 / length + 0.5);
|
d->bitrate = static_cast<int>(streamLength * 8.0 / length + 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void APE::Properties::analyzeCurrent(File *file)
|
void APE::AudioProperties::analyzeCurrent(File *file) {
|
||||||
{
|
|
||||||
// Read the descriptor
|
// Read the descriptor
|
||||||
file->seek(2, File::Current);
|
file->seek(2, File::Current);
|
||||||
const ByteVector descriptor = file->readBlock(44);
|
const ByteVector descriptor = file->readBlock(44);
|
||||||
if(descriptor.size() < 44) {
|
if (descriptor.size() < 44) {
|
||||||
debug("APE::Properties::analyzeCurrent() -- descriptor is too short.");
|
debug("APE::AudioProperties::analyzeCurrent() -- descriptor is too short.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const unsigned int descriptorBytes = descriptor.toUInt(0, false);
|
const unsigned int descriptorBytes = descriptor.toUInt32LE(0);
|
||||||
|
|
||||||
if((descriptorBytes - 52) > 0)
|
if ((descriptorBytes - 52) > 0)
|
||||||
file->seek(descriptorBytes - 52, File::Current);
|
file->seek(descriptorBytes - 52, File::Current);
|
||||||
|
|
||||||
// Read the header
|
// Read the header
|
||||||
const ByteVector header = file->readBlock(24);
|
const ByteVector header = file->readBlock(24);
|
||||||
if(header.size() < 24) {
|
if (header.size() < 24) {
|
||||||
debug("APE::Properties::analyzeCurrent() -- MAC header is too short.");
|
debug("APE::AudioProperties::analyzeCurrent() -- MAC header is too short.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the APE info
|
// Get the APE info
|
||||||
d->channels = header.toShort(18, false);
|
d->channels = header.toUInt16LE(18);
|
||||||
d->sampleRate = header.toUInt(20, false);
|
d->sampleRate = header.toUInt32LE(20);
|
||||||
d->bitsPerSample = header.toShort(16, false);
|
d->bitsPerSample = header.toUInt16LE(16);
|
||||||
|
|
||||||
const unsigned int totalFrames = header.toUInt(12, false);
|
const unsigned int totalFrames = header.toUInt32LE(12);
|
||||||
if(totalFrames == 0)
|
if (totalFrames == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const unsigned int blocksPerFrame = header.toUInt(4, false);
|
const unsigned int blocksPerFrame = header.toUInt32LE(4);
|
||||||
const unsigned int finalFrameBlocks = header.toUInt(8, false);
|
const unsigned int finalFrameBlocks = header.toUInt32LE(8);
|
||||||
d->sampleFrames = (totalFrames - 1) * blocksPerFrame + finalFrameBlocks;
|
d->sampleFrames = (totalFrames - 1) * blocksPerFrame + finalFrameBlocks;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void APE::Properties::analyzeOld(File *file)
|
void APE::AudioProperties::analyzeOld(File *file) {
|
||||||
{
|
|
||||||
const ByteVector header = file->readBlock(26);
|
const ByteVector header = file->readBlock(26);
|
||||||
if(header.size() < 26) {
|
if (header.size() < 26) {
|
||||||
debug("APE::Properties::analyzeOld() -- MAC header is too short.");
|
debug("APE::AudioProperties::analyzeOld() -- MAC header is too short.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const unsigned int totalFrames = header.toUInt(18, false);
|
const unsigned int totalFrames = header.toUInt32LE(18);
|
||||||
|
|
||||||
// Fail on 0 length APE files (catches non-finalized APE files)
|
// Fail on 0 length APE files (catches non-finalized APE files)
|
||||||
if(totalFrames == 0)
|
if (totalFrames == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const short compressionLevel = header.toShort(0, false);
|
const short compressionLevel = header.toUInt32LE(0);
|
||||||
unsigned int blocksPerFrame;
|
unsigned int blocksPerFrame;
|
||||||
if(d->version >= 3950)
|
if (d->version >= 3950)
|
||||||
blocksPerFrame = 73728 * 4;
|
blocksPerFrame = 73728 * 4;
|
||||||
else if(d->version >= 3900 || (d->version >= 3800 && compressionLevel == 4000))
|
else if (d->version >= 3900 || (d->version >= 3800 && compressionLevel == 4000))
|
||||||
blocksPerFrame = 73728;
|
blocksPerFrame = 73728;
|
||||||
else
|
else
|
||||||
blocksPerFrame = 9216;
|
blocksPerFrame = 9216;
|
||||||
|
|
||||||
// Get the APE info
|
// Get the APE info
|
||||||
d->channels = header.toShort(4, false);
|
d->channels = header.toUInt16LE(4);
|
||||||
d->sampleRate = header.toUInt(6, false);
|
d->sampleRate = header.toUInt32LE(6);
|
||||||
|
|
||||||
const unsigned int finalFrameBlocks = header.toUInt(22, false);
|
const unsigned int finalFrameBlocks = header.toUInt32LE(22);
|
||||||
d->sampleFrames = (totalFrames - 1) * blocksPerFrame + finalFrameBlocks;
|
d->sampleFrames = (totalFrames - 1) * blocksPerFrame + finalFrameBlocks;
|
||||||
|
|
||||||
// Get the bit depth from the RIFF-fmt chunk.
|
// Get the bit depth from the RIFF-fmt chunk.
|
||||||
file->seek(16, File::Current);
|
file->seek(16, File::Current);
|
||||||
const ByteVector fmt = file->readBlock(28);
|
const ByteVector fmt = file->readBlock(28);
|
||||||
if(fmt.size() < 28 || !fmt.startsWith("WAVEfmt ")) {
|
if (fmt.size() < 28 || !fmt.startsWith("WAVEfmt ")) {
|
||||||
debug("APE::Properties::analyzeOld() -- fmt header is too short.");
|
debug("APE::AudioProperties::analyzeOld() -- fmt header is too short.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
d->bitsPerSample = fmt.toShort(26, false);
|
d->bitsPerSample = fmt.toUInt16LE(26);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
73
3rdparty/taglib/ape/apeproperties.h
vendored
73
3rdparty/taglib/ape/apeproperties.h
vendored
@@ -33,82 +33,59 @@
|
|||||||
#include "taglib_export.h"
|
#include "taglib_export.h"
|
||||||
#include "audioproperties.h"
|
#include "audioproperties.h"
|
||||||
|
|
||||||
|
namespace Strawberry_TagLib {
|
||||||
namespace TagLib {
|
namespace TagLib {
|
||||||
|
namespace APE {
|
||||||
|
|
||||||
namespace APE {
|
class File;
|
||||||
|
|
||||||
class File;
|
//! An implementation of audio property reading for APE
|
||||||
|
|
||||||
//! An implementation of audio property reading for APE
|
/*!
|
||||||
|
* This reads the data from an APE stream found in the AudioProperties API.
|
||||||
/*!
|
|
||||||
* This reads the data from an APE stream found in the AudioProperties
|
|
||||||
* API.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class TAGLIB_EXPORT Properties : public AudioProperties
|
class TAGLIB_EXPORT AudioProperties : public Strawberry_TagLib::TagLib::AudioProperties {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
/*!
|
|
||||||
* Create an instance of APE::Properties with the data read from the
|
|
||||||
* APE::File \a file.
|
|
||||||
*
|
|
||||||
* \deprecated
|
|
||||||
*/
|
|
||||||
Properties(File *file, ReadStyle style = Average);
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Create an instance of APE::Properties with the data read from the
|
* Create an instance of APE::AudioProperties with the data read from the APE::File \a file.
|
||||||
* APE::File \a file.
|
|
||||||
*/
|
*/
|
||||||
Properties(File *file, long streamLength, ReadStyle style = Average);
|
explicit AudioProperties(File *file, long long streamLength, ReadStyle style = Average);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Destroys this APE::Properties instance.
|
* Destroys this APE::AudioProperties instance.
|
||||||
*/
|
*/
|
||||||
virtual ~Properties();
|
~AudioProperties() override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the length of the file in seconds. The length is rounded down to
|
* Returns the length of the file in seconds. The length is rounded down to the nearest whole second.
|
||||||
* the nearest whole second.
|
|
||||||
*
|
|
||||||
* \note This method is just an alias of lengthInSeconds().
|
|
||||||
*
|
|
||||||
* \deprecated
|
|
||||||
*/
|
|
||||||
virtual int length() const;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* Returns the length of the file in seconds. The length is rounded down to
|
|
||||||
* the nearest whole second.
|
|
||||||
*
|
*
|
||||||
* \see lengthInMilliseconds()
|
* \see lengthInMilliseconds()
|
||||||
*/
|
*/
|
||||||
// BIC: make virtual
|
int lengthInSeconds() const override;
|
||||||
int lengthInSeconds() const;
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the length of the file in milliseconds.
|
* Returns the length of the file in milliseconds.
|
||||||
*
|
*
|
||||||
* \see lengthInSeconds()
|
* \see lengthInSeconds()
|
||||||
*/
|
*/
|
||||||
// BIC: make virtual
|
int lengthInMilliseconds() const override;
|
||||||
int lengthInMilliseconds() const;
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the average bit rate of the file in kb/s.
|
* Returns the average bit rate of the file in kb/s.
|
||||||
*/
|
*/
|
||||||
virtual int bitrate() const;
|
int bitrate() const override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the sample rate in Hz.
|
* Returns the sample rate in Hz.
|
||||||
*/
|
*/
|
||||||
virtual int sampleRate() const;
|
int sampleRate() const override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the number of audio channels.
|
* Returns the number of audio channels.
|
||||||
*/
|
*/
|
||||||
virtual int channels() const;
|
int channels() const override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the number of bits per audio sample.
|
* Returns the number of bits per audio sample.
|
||||||
@@ -126,18 +103,16 @@ namespace TagLib {
|
|||||||
int version() const;
|
int version() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Properties(const Properties &);
|
void read(File *file, long long streamLength);
|
||||||
Properties &operator=(const Properties &);
|
|
||||||
|
|
||||||
void read(File *file, long streamLength);
|
|
||||||
|
|
||||||
void analyzeCurrent(File *file);
|
void analyzeCurrent(File *file);
|
||||||
void analyzeOld(File *file);
|
void analyzeOld(File *file);
|
||||||
|
|
||||||
class PropertiesPrivate;
|
class AudioPropertiesPrivate;
|
||||||
PropertiesPrivate *d;
|
AudioPropertiesPrivate *d;
|
||||||
};
|
};
|
||||||
}
|
} // namespace APE
|
||||||
}
|
} // namespace TagLib
|
||||||
|
} // namespace Strawberry_TagLib
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
386
3rdparty/taglib/ape/apetag.cpp
vendored
386
3rdparty/taglib/ape/apetag.cpp
vendored
@@ -28,59 +28,56 @@
|
|||||||
// it considers specializations with and without class types
|
// it considers specializations with and without class types
|
||||||
// to be different; this define forces Map to use only the
|
// to be different; this define forces Map to use only the
|
||||||
// specialization with the class keyword.
|
// specialization with the class keyword.
|
||||||
#define WANT_CLASS_INSTANTIATION_OF_MAP (1)
|
# define WANT_CLASS_INSTANTIATION_OF_MAP (1)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <tfile.h>
|
#include "tfile.h"
|
||||||
#include <tstring.h>
|
#include "tstring.h"
|
||||||
#include <tmap.h>
|
#include "tmap.h"
|
||||||
#include <tpropertymap.h>
|
#include "tpicturemap.h"
|
||||||
#include <tdebug.h>
|
#include "tpropertymap.h"
|
||||||
#include <tutils.h>
|
#include "tdebug.h"
|
||||||
|
#include "tutils.h"
|
||||||
|
|
||||||
#include "apetag.h"
|
#include "apetag.h"
|
||||||
#include "apefooter.h"
|
#include "apefooter.h"
|
||||||
#include "apeitem.h"
|
#include "apeitem.h"
|
||||||
|
|
||||||
using namespace TagLib;
|
using namespace Strawberry_TagLib::TagLib;
|
||||||
using namespace APE;
|
using namespace APE;
|
||||||
|
|
||||||
namespace
|
namespace {
|
||||||
{
|
const unsigned int MinKeyLength = 2;
|
||||||
const unsigned int MinKeyLength = 2;
|
const unsigned int MaxKeyLength = 255;
|
||||||
const unsigned int MaxKeyLength = 255;
|
|
||||||
|
|
||||||
bool isKeyValid(const ByteVector &key)
|
bool isKeyValid(const ByteVector &key) {
|
||||||
{
|
|
||||||
const char *invalidKeys[] = { "ID3", "TAG", "OGGS", "MP+", 0 };
|
const char *invalidKeys[] = { "ID3", "TAG", "OGGS", "MP+", nullptr };
|
||||||
|
|
||||||
// only allow printable ASCII including space (32..126)
|
// only allow printable ASCII including space (32..126)
|
||||||
|
|
||||||
for(ByteVector::ConstIterator it = key.begin(); it != key.end(); ++it) {
|
for (ByteVector::ConstIterator it = key.begin(); it != key.end(); ++it) {
|
||||||
const int c = static_cast<unsigned char>(*it);
|
const int c = static_cast<unsigned char>(*it);
|
||||||
if(c < 32 || c > 126)
|
if (c < 32 || c > 126)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const String upperKey = String(key).upper();
|
const String upperKey = String(key).upper();
|
||||||
for(size_t i = 0; invalidKeys[i] != 0; ++i) {
|
for (size_t i = 0; invalidKeys[i] != nullptr; ++i) {
|
||||||
if(upperKey == invalidKeys[i])
|
if (upperKey == invalidKeys[i])
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} // namespace
|
||||||
|
|
||||||
class APE::Tag::TagPrivate
|
class APE::Tag::TagPrivate {
|
||||||
{
|
public:
|
||||||
public:
|
TagPrivate() : file(nullptr), footerLocation(0) {}
|
||||||
TagPrivate() :
|
|
||||||
file(0),
|
|
||||||
footerLocation(0) {}
|
|
||||||
|
|
||||||
File *file;
|
File *file;
|
||||||
long footerLocation;
|
long long footerLocation;
|
||||||
|
|
||||||
Footer footer;
|
Footer footer;
|
||||||
ItemListMap itemListMap;
|
ItemListMap itemListMap;
|
||||||
@@ -90,172 +87,257 @@ public:
|
|||||||
// public methods
|
// public methods
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
APE::Tag::Tag() :
|
APE::Tag::Tag() : d(new TagPrivate()) {}
|
||||||
TagLib::Tag(),
|
|
||||||
d(new TagPrivate())
|
APE::Tag::Tag(Strawberry_TagLib::TagLib::File *file, long long footerLocation) : d(new TagPrivate()) {
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
APE::Tag::Tag(TagLib::File *file, long footerLocation) :
|
|
||||||
TagLib::Tag(),
|
|
||||||
d(new TagPrivate())
|
|
||||||
{
|
|
||||||
d->file = file;
|
d->file = file;
|
||||||
d->footerLocation = footerLocation;
|
d->footerLocation = footerLocation;
|
||||||
|
|
||||||
read();
|
read();
|
||||||
}
|
}
|
||||||
|
|
||||||
APE::Tag::~Tag()
|
APE::Tag::~Tag() {
|
||||||
{
|
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
ByteVector APE::Tag::fileIdentifier()
|
ByteVector APE::Tag::fileIdentifier() {
|
||||||
{
|
|
||||||
return ByteVector::fromCString("APETAGEX");
|
return ByteVector::fromCString("APETAGEX");
|
||||||
}
|
}
|
||||||
|
|
||||||
String APE::Tag::title() const
|
String APE::Tag::title() const {
|
||||||
{
|
|
||||||
if(d->itemListMap["TITLE"].isEmpty())
|
if (d->itemListMap["TITLE"].isEmpty())
|
||||||
return String();
|
return String();
|
||||||
return d->itemListMap["TITLE"].values().toString();
|
return d->itemListMap["TITLE"].values().toString();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String APE::Tag::artist() const
|
String APE::Tag::artist() const {
|
||||||
{
|
|
||||||
if(d->itemListMap["ARTIST"].isEmpty())
|
if (d->itemListMap["ARTIST"].isEmpty())
|
||||||
return String();
|
return String();
|
||||||
return d->itemListMap["ARTIST"].values().toString();
|
return d->itemListMap["ARTIST"].values().toString();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String APE::Tag::album() const
|
String APE::Tag::album() const {
|
||||||
{
|
|
||||||
if(d->itemListMap["ALBUM"].isEmpty())
|
if (d->itemListMap["ALBUM"].isEmpty())
|
||||||
return String();
|
return String();
|
||||||
return d->itemListMap["ALBUM"].values().toString();
|
return d->itemListMap["ALBUM"].values().toString();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String APE::Tag::comment() const
|
String APE::Tag::comment() const {
|
||||||
{
|
|
||||||
if(d->itemListMap["COMMENT"].isEmpty())
|
if (d->itemListMap["COMMENT"].isEmpty())
|
||||||
return String();
|
return String();
|
||||||
return d->itemListMap["COMMENT"].values().toString();
|
return d->itemListMap["COMMENT"].values().toString();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String APE::Tag::genre() const
|
String APE::Tag::genre() const {
|
||||||
{
|
|
||||||
if(d->itemListMap["GENRE"].isEmpty())
|
if (d->itemListMap["GENRE"].isEmpty())
|
||||||
return String();
|
return String();
|
||||||
return d->itemListMap["GENRE"].values().toString();
|
return d->itemListMap["GENRE"].values().toString();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int APE::Tag::year() const
|
unsigned int APE::Tag::year() const {
|
||||||
{
|
|
||||||
if(d->itemListMap["YEAR"].isEmpty())
|
if (d->itemListMap["YEAR"].isEmpty())
|
||||||
return 0;
|
return 0;
|
||||||
return d->itemListMap["YEAR"].toString().toInt();
|
return d->itemListMap["YEAR"].toString().toInt();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int APE::Tag::track() const
|
unsigned int APE::Tag::track() const {
|
||||||
{
|
|
||||||
if(d->itemListMap["TRACK"].isEmpty())
|
if (d->itemListMap["TRACK"].isEmpty())
|
||||||
return 0;
|
return 0;
|
||||||
return d->itemListMap["TRACK"].toString().toInt();
|
return d->itemListMap["TRACK"].toString().toInt();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void APE::Tag::setTitle(const String &s)
|
Strawberry_TagLib::TagLib::PictureMap APE::Tag::pictures() const {
|
||||||
{
|
|
||||||
|
PictureMap map;
|
||||||
|
if (d->itemListMap.contains(FRONT_COVER)) {
|
||||||
|
Item front = d->itemListMap[FRONT_COVER];
|
||||||
|
if (Item::Binary == front.type()) {
|
||||||
|
ByteVector picture = front.binaryData();
|
||||||
|
const size_t index = picture.find('\0');
|
||||||
|
if (index < picture.size()) {
|
||||||
|
ByteVector desc = picture.mid(0, index + 1);
|
||||||
|
String mime = "image/jpeg";
|
||||||
|
ByteVector data = picture.mid(index + 1);
|
||||||
|
Picture p(data, Picture::FrontCover, mime, desc);
|
||||||
|
map.insert(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (d->itemListMap.contains(BACK_COVER)) {
|
||||||
|
Item back = d->itemListMap[BACK_COVER];
|
||||||
|
if (Item::Binary == back.type()) {
|
||||||
|
ByteVector picture = back.binaryData();
|
||||||
|
const size_t index = picture.find('\0');
|
||||||
|
if (index < picture.size()) {
|
||||||
|
ByteVector desc = picture.mid(0, index + 1);
|
||||||
|
String mime = "image/jpeg";
|
||||||
|
ByteVector data = picture.mid(index + 1);
|
||||||
|
Picture p(data, Picture::BackCover, mime, desc);
|
||||||
|
map.insert(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return PictureMap(map);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void APE::Tag::setTitle(const String &s) {
|
||||||
addValue("TITLE", s, true);
|
addValue("TITLE", s, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void APE::Tag::setArtist(const String &s)
|
void APE::Tag::setArtist(const String &s) {
|
||||||
{
|
|
||||||
addValue("ARTIST", s, true);
|
addValue("ARTIST", s, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void APE::Tag::setAlbum(const String &s)
|
void APE::Tag::setAlbum(const String &s) {
|
||||||
{
|
|
||||||
addValue("ALBUM", s, true);
|
addValue("ALBUM", s, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void APE::Tag::setComment(const String &s)
|
void APE::Tag::setComment(const String &s) {
|
||||||
{
|
|
||||||
addValue("COMMENT", s, true);
|
addValue("COMMENT", s, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void APE::Tag::setGenre(const String &s)
|
void APE::Tag::setGenre(const String &s) {
|
||||||
{
|
|
||||||
addValue("GENRE", s, true);
|
addValue("GENRE", s, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void APE::Tag::setYear(unsigned int i)
|
void APE::Tag::setYear(unsigned int i) {
|
||||||
{
|
|
||||||
if(i == 0)
|
if (i == 0)
|
||||||
removeItem("YEAR");
|
removeItem("YEAR");
|
||||||
else
|
else
|
||||||
addValue("YEAR", String::number(i), true);
|
addValue("YEAR", String::number(i), true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void APE::Tag::setTrack(unsigned int i)
|
void APE::Tag::setTrack(unsigned int i) {
|
||||||
{
|
|
||||||
if(i == 0)
|
if (i == 0)
|
||||||
removeItem("TRACK");
|
removeItem("TRACK");
|
||||||
else
|
else
|
||||||
addValue("TRACK", String::number(i), true);
|
addValue("TRACK", String::number(i), true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace
|
void APE::Tag::setPictures(const PictureMap &l) {
|
||||||
{
|
|
||||||
// conversions of tag keys between what we use in PropertyMap and what's usual
|
removeItem(FRONT_COVER);
|
||||||
// for APE tags
|
removeItem(BACK_COVER);
|
||||||
// usual, APE
|
|
||||||
const char *keyConversions[][2] = {{"TRACKNUMBER", "TRACK" },
|
for (PictureMap::ConstIterator pictureMapIt = l.begin(); pictureMapIt != l.end(); ++pictureMapIt) {
|
||||||
{"DATE", "YEAR" },
|
Picture::Type type = pictureMapIt->first;
|
||||||
{"ALBUMARTIST", "ALBUM ARTIST"},
|
if (Picture::FrontCover != type && Picture::BackCover != type) {
|
||||||
{"DISCNUMBER", "DISC" },
|
std::cout << "APE: Trying to add a picture with wrong type" << std::endl;
|
||||||
{"REMIXER", "MIXARTIST" }};
|
continue;
|
||||||
const size_t keyConversionsSize = sizeof(keyConversions) / sizeof(keyConversions[0]);
|
}
|
||||||
|
|
||||||
|
const char *id;
|
||||||
|
switch (type) {
|
||||||
|
case Picture::FrontCover:
|
||||||
|
id = FRONT_COVER;
|
||||||
|
break;
|
||||||
|
case Picture::BackCover:
|
||||||
|
id = BACK_COVER;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
id = FRONT_COVER;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
PictureList list = pictureMapIt->second;
|
||||||
|
for (PictureList::ConstIterator pictureListIt = list.begin(); pictureListIt != list.end(); ++pictureListIt) {
|
||||||
|
Picture picture = *pictureListIt;
|
||||||
|
if (d->itemListMap.contains(id)) {
|
||||||
|
std::cout << "APE: Already added a picture of type "
|
||||||
|
<< id
|
||||||
|
<< " '"
|
||||||
|
<< picture.description()
|
||||||
|
<< "' "
|
||||||
|
<< "and next are being ignored"
|
||||||
|
<< std::endl;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
ByteVector data = picture.description().data(String::Latin1).append('\0').append(picture.data());
|
||||||
|
|
||||||
|
Item item;
|
||||||
|
item.setKey(id);
|
||||||
|
item.setType(Item::Binary);
|
||||||
|
item.setBinaryData(data);
|
||||||
|
setItem(item.key(), item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertyMap APE::Tag::properties() const
|
namespace {
|
||||||
{
|
// conversions of tag keys between what we use in PropertyMap and what's usual
|
||||||
|
// for APE tags
|
||||||
|
// usual, APE
|
||||||
|
const char *keyConversions[][2] = { { "TRACKNUMBER", "TRACK" },
|
||||||
|
{ "DATE", "YEAR" },
|
||||||
|
{ "ALBUMARTIST", "ALBUM ARTIST" },
|
||||||
|
{ "DISCNUMBER", "DISC" },
|
||||||
|
{ "REMIXER", "MIXARTIST" } };
|
||||||
|
const size_t keyConversionsSize = sizeof(keyConversions) / sizeof(keyConversions[0]);
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
PropertyMap APE::Tag::properties() const {
|
||||||
|
|
||||||
PropertyMap properties;
|
PropertyMap properties;
|
||||||
ItemListMap::ConstIterator it = itemListMap().begin();
|
ItemListMap::ConstIterator it = itemListMap().begin();
|
||||||
for(; it != itemListMap().end(); ++it) {
|
for (; it != itemListMap().end(); ++it) {
|
||||||
String tagName = it->first.upper();
|
String tagName = it->first.upper();
|
||||||
// if the item is Binary or Locator, or if the key is an invalid string,
|
// if the item is Binary or Locator, or if the key is an invalid string,
|
||||||
// add to unsupportedData
|
// add to unsupportedData
|
||||||
if(it->second.type() != Item::Text || tagName.isEmpty()) {
|
if (it->second.type() != Item::Text || tagName.isEmpty()) {
|
||||||
properties.unsupportedData().append(it->first);
|
properties.unsupportedData().append(it->first);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Some tags need to be handled specially
|
// Some tags need to be handled specially
|
||||||
for(size_t i = 0; i < keyConversionsSize; ++i) {
|
for (size_t i = 0; i < keyConversionsSize; ++i) {
|
||||||
if(tagName == keyConversions[i][1])
|
if (tagName == keyConversions[i][1])
|
||||||
tagName = keyConversions[i][0];
|
tagName = keyConversions[i][0];
|
||||||
}
|
}
|
||||||
properties[tagName].append(it->second.toStringList());
|
properties[tagName].append(it->second.values());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return properties;
|
return properties;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void APE::Tag::removeUnsupportedProperties(const StringList &properties)
|
void APE::Tag::removeUnsupportedProperties(const StringList &properties) {
|
||||||
{
|
|
||||||
StringList::ConstIterator it = properties.begin();
|
StringList::ConstIterator it = properties.begin();
|
||||||
for(; it != properties.end(); ++it)
|
for (; it != properties.end(); ++it)
|
||||||
removeItem(*it);
|
removeItem(*it);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertyMap APE::Tag::setProperties(const PropertyMap &origProps)
|
PropertyMap APE::Tag::setProperties(const PropertyMap &origProps) {
|
||||||
{
|
|
||||||
PropertyMap properties(origProps); // make a local copy that can be modified
|
PropertyMap properties(origProps); // make a local copy that can be modified
|
||||||
|
|
||||||
// see comment in properties()
|
// see comment in properties()
|
||||||
for(size_t i = 0; i < keyConversionsSize; ++i)
|
for (size_t i = 0; i < keyConversionsSize; ++i)
|
||||||
if(properties.contains(keyConversions[i][0])) {
|
if (properties.contains(keyConversions[i][0])) {
|
||||||
properties.insert(keyConversions[i][1], properties[keyConversions[i][0]]);
|
properties.insert(keyConversions[i][1], properties[keyConversions[i][0]]);
|
||||||
properties.erase(keyConversions[i][0]);
|
properties.erase(keyConversions[i][0]);
|
||||||
}
|
}
|
||||||
@@ -263,31 +345,31 @@ PropertyMap APE::Tag::setProperties(const PropertyMap &origProps)
|
|||||||
// first check if tags need to be removed completely
|
// first check if tags need to be removed completely
|
||||||
StringList toRemove;
|
StringList toRemove;
|
||||||
ItemListMap::ConstIterator remIt = itemListMap().begin();
|
ItemListMap::ConstIterator remIt = itemListMap().begin();
|
||||||
for(; remIt != itemListMap().end(); ++remIt) {
|
for (; remIt != itemListMap().end(); ++remIt) {
|
||||||
String key = remIt->first.upper();
|
String key = remIt->first.upper();
|
||||||
// only remove if a) key is valid, b) type is text, c) key not contained in new properties
|
// only remove if a) key is valid, b) type is text, c) key not contained in new properties
|
||||||
if(!key.isEmpty() && remIt->second.type() == APE::Item::Text && !properties.contains(key))
|
if (!key.isEmpty() && remIt->second.type() == APE::Item::Text && !properties.contains(key))
|
||||||
toRemove.append(remIt->first);
|
toRemove.append(remIt->first);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(StringList::ConstIterator removeIt = toRemove.begin(); removeIt != toRemove.end(); removeIt++)
|
for (StringList::ConstIterator removeIt = toRemove.begin(); removeIt != toRemove.end(); removeIt++)
|
||||||
removeItem(*removeIt);
|
removeItem(*removeIt);
|
||||||
|
|
||||||
// now sync in the "forward direction"
|
// now sync in the "forward direction"
|
||||||
PropertyMap::ConstIterator it = properties.begin();
|
PropertyMap::ConstIterator it = properties.begin();
|
||||||
PropertyMap invalid;
|
PropertyMap invalid;
|
||||||
for(; it != properties.end(); ++it) {
|
for (; it != properties.end(); ++it) {
|
||||||
const String &tagName = it->first;
|
const String &tagName = it->first;
|
||||||
if(!checkKey(tagName))
|
if (!checkKey(tagName))
|
||||||
invalid.insert(it->first, it->second);
|
invalid.insert(it->first, it->second);
|
||||||
else if(!(itemListMap().contains(tagName)) || !(itemListMap()[tagName].values() == it->second)) {
|
else if (!(itemListMap().contains(tagName)) || !(itemListMap()[tagName].values() == it->second)) {
|
||||||
if(it->second.isEmpty())
|
if (it->second.isEmpty())
|
||||||
removeItem(tagName);
|
removeItem(tagName);
|
||||||
else {
|
else {
|
||||||
StringList::ConstIterator valueIt = it->second.begin();
|
StringList::ConstIterator valueIt = it->second.begin();
|
||||||
addValue(tagName, *valueIt, true);
|
addValue(tagName, *valueIt, true);
|
||||||
++valueIt;
|
++valueIt;
|
||||||
for(; valueIt != it->second.end(); ++valueIt)
|
for (; valueIt != it->second.end(); ++valueIt)
|
||||||
addValue(tagName, *valueIt, false);
|
addValue(tagName, *valueIt, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -295,35 +377,33 @@ PropertyMap APE::Tag::setProperties(const PropertyMap &origProps)
|
|||||||
return invalid;
|
return invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool APE::Tag::checkKey(const String &key)
|
bool APE::Tag::checkKey(const String &key) {
|
||||||
{
|
|
||||||
if(key.size() < MinKeyLength || key.size() > MaxKeyLength)
|
if (key.size() < MinKeyLength || key.size() > MaxKeyLength)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return isKeyValid(key.data(String::UTF8));
|
return isKeyValid(key.data(String::UTF8));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
APE::Footer *APE::Tag::footer() const
|
APE::Footer *APE::Tag::footer() const {
|
||||||
{
|
|
||||||
return &d->footer;
|
return &d->footer;
|
||||||
}
|
}
|
||||||
|
|
||||||
const APE::ItemListMap& APE::Tag::itemListMap() const
|
const APE::ItemListMap &APE::Tag::itemListMap() const {
|
||||||
{
|
|
||||||
return d->itemListMap;
|
return d->itemListMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
void APE::Tag::removeItem(const String &key)
|
void APE::Tag::removeItem(const String &key) {
|
||||||
{
|
|
||||||
d->itemListMap.erase(key.upper());
|
d->itemListMap.erase(key.upper());
|
||||||
}
|
}
|
||||||
|
|
||||||
void APE::Tag::addValue(const String &key, const String &value, bool replace)
|
void APE::Tag::addValue(const String &key, const String &value, bool replace) {
|
||||||
{
|
|
||||||
if(replace)
|
if (replace)
|
||||||
removeItem(key);
|
removeItem(key);
|
||||||
|
|
||||||
if(value.isEmpty())
|
if (value.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Text items may contain more than one value.
|
// Text items may contain more than one value.
|
||||||
@@ -331,34 +411,36 @@ void APE::Tag::addValue(const String &key, const String &value, bool replace)
|
|||||||
|
|
||||||
ItemListMap::Iterator it = d->itemListMap.find(key.upper());
|
ItemListMap::Iterator it = d->itemListMap.find(key.upper());
|
||||||
|
|
||||||
if(it != d->itemListMap.end() && it->second.type() == Item::Text)
|
if (it != d->itemListMap.end() && it->second.type() == Item::Text)
|
||||||
it->second.appendValue(value);
|
it->second.appendValue(value);
|
||||||
else
|
else
|
||||||
setItem(key, Item(key, value));
|
setItem(key, Item(key, value));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void APE::Tag::setData(const String &key, const ByteVector &value)
|
void APE::Tag::setData(const String &key, const ByteVector &value) {
|
||||||
{
|
|
||||||
removeItem(key);
|
removeItem(key);
|
||||||
|
|
||||||
if(value.isEmpty())
|
if (value.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
setItem(key, Item(key, value, true));
|
setItem(key, Item(key, value, true));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void APE::Tag::setItem(const String &key, const Item &item)
|
void APE::Tag::setItem(const String &key, const Item &item) {
|
||||||
{
|
|
||||||
if(!checkKey(key)) {
|
if (!checkKey(key)) {
|
||||||
debug("APE::Tag::setItem() - Couldn't set an item due to an invalid key.");
|
debug("APE::Tag::setItem() - Couldn't set an item due to an invalid key.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
d->itemListMap[key.upper()] = item;
|
d->itemListMap[key.upper()] = item;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool APE::Tag::isEmpty() const
|
bool APE::Tag::isEmpty() const {
|
||||||
{
|
|
||||||
return d->itemListMap.isEmpty();
|
return d->itemListMap.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -366,28 +448,29 @@ bool APE::Tag::isEmpty() const
|
|||||||
// protected methods
|
// protected methods
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void APE::Tag::read()
|
void APE::Tag::read() {
|
||||||
{
|
|
||||||
if(d->file && d->file->isValid()) {
|
if (d->file && d->file->isValid()) {
|
||||||
|
|
||||||
d->file->seek(d->footerLocation);
|
d->file->seek(d->footerLocation);
|
||||||
d->footer.setData(d->file->readBlock(Footer::size()));
|
d->footer.setData(d->file->readBlock(Footer::size()));
|
||||||
|
|
||||||
if(d->footer.tagSize() <= Footer::size() ||
|
if (d->footer.tagSize() <= Footer::size() ||
|
||||||
d->footer.tagSize() > static_cast<unsigned long>(d->file->length()))
|
d->footer.tagSize() > static_cast<unsigned long>(d->file->length()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
d->file->seek(d->footerLocation + Footer::size() - d->footer.tagSize());
|
d->file->seek(d->footerLocation + Footer::size() - d->footer.tagSize());
|
||||||
parse(d->file->readBlock(d->footer.tagSize() - Footer::size()));
|
parse(d->file->readBlock(d->footer.tagSize() - Footer::size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ByteVector APE::Tag::render() const
|
ByteVector APE::Tag::render() const {
|
||||||
{
|
|
||||||
ByteVector data;
|
ByteVector data;
|
||||||
unsigned int itemCount = 0;
|
unsigned int itemCount = 0;
|
||||||
|
|
||||||
for(ItemListMap::ConstIterator it = d->itemListMap.begin(); it != d->itemListMap.end(); ++it) {
|
for (ItemListMap::ConstIterator it = d->itemListMap.begin(); it != d->itemListMap.end(); ++it) {
|
||||||
data.append(it->second.render());
|
data.append(it->second.render());
|
||||||
itemCount++;
|
itemCount++;
|
||||||
}
|
}
|
||||||
@@ -397,32 +480,30 @@ ByteVector APE::Tag::render() const
|
|||||||
d->footer.setHeaderPresent(true);
|
d->footer.setHeaderPresent(true);
|
||||||
|
|
||||||
return d->footer.renderHeader() + data + d->footer.renderFooter();
|
return d->footer.renderHeader() + data + d->footer.renderFooter();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void APE::Tag::parse(const ByteVector &data)
|
void APE::Tag::parse(const ByteVector &data) {
|
||||||
{
|
|
||||||
// 11 bytes is the minimum size for an APE item
|
// 11 bytes is the minimum size for an APE item
|
||||||
|
|
||||||
if(data.size() < 11)
|
if (data.size() < 11)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
unsigned int pos = 0;
|
size_t pos = 0;
|
||||||
|
|
||||||
for(unsigned int i = 0; i < d->footer.itemCount() && pos <= data.size() - 11; i++) {
|
for (unsigned int i = 0; i < d->footer.itemCount() && pos <= data.size() - 11; i++) {
|
||||||
|
|
||||||
const int nullPos = data.find('\0', pos + 8);
|
const size_t nullPos = data.find('\0', pos + 8);
|
||||||
if(nullPos < 0) {
|
if (nullPos == ByteVector::npos()) {
|
||||||
debug("APE::Tag::parse() - Couldn't find a key/value separator. Stopped parsing.");
|
debug("APE::Tag::parse() - Couldn't find a key/value separator. Stopped parsing.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const unsigned int keyLength = nullPos - pos - 8;
|
const size_t keyLength = nullPos - pos - 8;
|
||||||
const unsigned int valLegnth = data.toUInt(pos, false);
|
const size_t valLegnth = data.toUInt32LE(pos);
|
||||||
|
|
||||||
if(keyLength >= MinKeyLength
|
if (keyLength >= MinKeyLength && keyLength <= MaxKeyLength && isKeyValid(data.mid(pos + 8, keyLength))) {
|
||||||
&& keyLength <= MaxKeyLength
|
|
||||||
&& isKeyValid(data.mid(pos + 8, keyLength)))
|
|
||||||
{
|
|
||||||
APE::Item item;
|
APE::Item item;
|
||||||
item.parse(data.mid(pos));
|
item.parse(data.mid(pos));
|
||||||
|
|
||||||
@@ -434,4 +515,5 @@ void APE::Tag::parse(const ByteVector &data)
|
|||||||
|
|
||||||
pos += keyLength + valLegnth + 9;
|
pos += keyLength + valLegnth + 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
122
3rdparty/taglib/ape/apetag.h
vendored
122
3rdparty/taglib/ape/apetag.h
vendored
@@ -34,105 +34,115 @@
|
|||||||
|
|
||||||
#include "apeitem.h"
|
#include "apeitem.h"
|
||||||
|
|
||||||
|
#define FRONT_COVER "COVER ART (FRONT)"
|
||||||
|
#define BACK_COVER "COVER ART (BACK)"
|
||||||
|
|
||||||
|
namespace Strawberry_TagLib {
|
||||||
namespace TagLib {
|
namespace TagLib {
|
||||||
|
|
||||||
class File;
|
class File;
|
||||||
|
|
||||||
//! An implementation of the APE tagging format
|
//! An implementation of the APE tagging format
|
||||||
|
|
||||||
namespace APE {
|
namespace APE {
|
||||||
|
|
||||||
class Footer;
|
class Footer;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* A mapping between a list of item names, or keys, and the associated item.
|
* A mapping between a list of item names, or keys, and the associated item.
|
||||||
*
|
*
|
||||||
* \see APE::Tag::itemListMap()
|
* \see APE::Tag::itemListMap()
|
||||||
*/
|
*/
|
||||||
typedef Map<const String, Item> ItemListMap;
|
typedef Map<String, Item> ItemListMap;
|
||||||
|
|
||||||
|
|
||||||
//! An APE tag implementation
|
//! An APE tag implementation
|
||||||
|
|
||||||
class TAGLIB_EXPORT Tag : public TagLib::Tag
|
class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
/*!
|
/*!
|
||||||
* Create an APE tag with default values.
|
* Create an APE tag with default values.
|
||||||
*/
|
*/
|
||||||
Tag();
|
explicit Tag();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Create an APE tag and parse the data in \a file with APE footer at
|
* Create an APE tag and parse the data in \a file with APE footer at
|
||||||
* \a tagOffset.
|
* \a tagOffset.
|
||||||
*/
|
*/
|
||||||
Tag(TagLib::File *file, long footerLocation);
|
explicit Tag(Strawberry_TagLib::TagLib::File *file, long long footerLocation);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Destroys this Tag instance.
|
* Destroys this Tag instance.
|
||||||
*/
|
*/
|
||||||
virtual ~Tag();
|
~Tag() override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Renders the in memory values to a ByteVector suitable for writing to
|
* Renders the in memory values to a ByteVector suitable for writing to the file.
|
||||||
* the file.
|
|
||||||
*/
|
*/
|
||||||
ByteVector render() const;
|
ByteVector render() const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the string "APETAGEX" suitable for usage in locating the tag in a
|
* Returns the string "APETAGEX" suitable for usage in locating the tag in a file.
|
||||||
* file.
|
|
||||||
*/
|
*/
|
||||||
static ByteVector fileIdentifier();
|
static ByteVector fileIdentifier();
|
||||||
|
|
||||||
// Reimplementations.
|
// Reimplementations.
|
||||||
|
|
||||||
virtual String title() const;
|
String title() const override;
|
||||||
virtual String artist() const;
|
String artist() const override;
|
||||||
virtual String album() const;
|
String album() const override;
|
||||||
virtual String comment() const;
|
String comment() const override;
|
||||||
virtual String genre() const;
|
String genre() const override;
|
||||||
virtual unsigned int year() const;
|
unsigned int year() const override;
|
||||||
virtual unsigned int track() const;
|
unsigned int track() const override;
|
||||||
|
|
||||||
virtual void setTitle(const String &s);
|
/**
|
||||||
virtual void setArtist(const String &s);
|
* @brief pictures
|
||||||
virtual void setAlbum(const String &s);
|
* According to :
|
||||||
virtual void setComment(const String &s);
|
* http://www.hydrogenaud.io/forums/index.php?showtopic=40603&st=50&p=504669&#entry504669
|
||||||
virtual void setGenre(const String &s);
|
* http://git.videolan.org/?p=vlc.git;a=blob;f=modules/meta_engine/taglib.cpp
|
||||||
virtual void setYear(unsigned int i);
|
* @return
|
||||||
virtual void setTrack(unsigned int i);
|
*/
|
||||||
|
PictureMap pictures() const override;
|
||||||
|
|
||||||
|
void setTitle(const String &s) override;
|
||||||
|
void setArtist(const String &s) override;
|
||||||
|
void setAlbum(const String &s) override;
|
||||||
|
void setComment(const String &s) override;
|
||||||
|
void setGenre(const String &s) override;
|
||||||
|
void setYear(unsigned int i) override;
|
||||||
|
void setTrack(unsigned int i) override;
|
||||||
|
void setPictures(const PictureMap &l) override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Implements the unified tag dictionary interface -- export function.
|
* Implements the unified tag dictionary interface -- export function.
|
||||||
* APE tags are perfectly compatible with the dictionary interface because they
|
* APE tags are perfectly compatible with the dictionary interface because they
|
||||||
* support both arbitrary tag names and multiple values. Currently only
|
* support both arbitrary tag names and multiple values.
|
||||||
* APE items of type *Text* are handled by the dictionary interface; all *Binary*
|
* Currently only APE items of type *Text* are handled by the dictionary interface; all *Binary*
|
||||||
* and *Locator* items will be put into the unsupportedData list and can be
|
* and *Locator* items will be put into the unsupportedData list and can be
|
||||||
* deleted on request using removeUnsupportedProperties(). The same happens
|
* deleted on request using removeUnsupportedProperties().
|
||||||
* to Text items if their key is invalid for PropertyMap (which should actually
|
* The same happens to Text items if their key is invalid for PropertyMap (which should actually never happen).
|
||||||
* never happen).
|
|
||||||
*
|
*
|
||||||
* The only conversion done by this export function is to rename the APE tags
|
* The only conversion done by this export function is to rename the APE tags
|
||||||
* TRACK to TRACKNUMBER, YEAR to DATE, and ALBUM ARTIST to ALBUMARTIST, respectively,
|
* TRACK to TRACKNUMBER, YEAR to DATE, and ALBUM ARTIST to ALBUMARTIST,
|
||||||
* in order to be compliant with the names used in other formats.
|
* respectively, in order to be compliant with the names used in other formats.
|
||||||
*/
|
*/
|
||||||
PropertyMap properties() const;
|
PropertyMap properties() const override;
|
||||||
|
|
||||||
void removeUnsupportedProperties(const StringList &properties);
|
void removeUnsupportedProperties(const StringList &properties) override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Implements the unified tag dictionary interface -- import function. The same
|
* Implements the unified tag dictionary interface -- import function.
|
||||||
* comments as for the export function apply; additionally note that the APE tag
|
* The same comments as for the export function apply; additionally note that the APE tag
|
||||||
* specification requires keys to have between 2 and 16 printable ASCII characters
|
* specification requires keys to have between 2 and 16 printable ASCII characters
|
||||||
* with the exception of the fixed strings "ID3", "TAG", "OGGS", and "MP+".
|
* with the exception of the fixed strings "ID3", "TAG", "OGGS", and "MP+".
|
||||||
*/
|
*/
|
||||||
PropertyMap setProperties(const PropertyMap &);
|
PropertyMap setProperties(const PropertyMap &) override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Check if the given String is a valid APE tag key.
|
* Check if the given String is a valid APE tag key.
|
||||||
*/
|
*/
|
||||||
static bool checkKey(const String&);
|
static bool checkKey(const String &);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns a pointer to the tag's footer.
|
* Returns a pointer to the tag's footer.
|
||||||
@@ -140,8 +150,8 @@ namespace TagLib {
|
|||||||
Footer *footer() const;
|
Footer *footer() const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns a reference to the item list map. This is an ItemListMap of
|
* Returns a reference to the item list map.
|
||||||
* all of the items in the tag.
|
* This is an ItemListMap of all of the items in the tag.
|
||||||
*
|
*
|
||||||
* This is the most powerful structure for accessing the items of the tag.
|
* This is the most powerful structure for accessing the items of the tag.
|
||||||
*
|
*
|
||||||
@@ -159,32 +169,29 @@ namespace TagLib {
|
|||||||
void removeItem(const String &key);
|
void removeItem(const String &key);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Adds to the text item specified by \a key the data \a value. If \a replace
|
* Adds to the text item specified by \a key the data \a value.
|
||||||
* is true, then all of the other values on the same key will be removed
|
* If \a replace is true, then all of the other values on the same key will be removed first.
|
||||||
* first. If a binary item exists for \a key it will be removed first.
|
* If a binary item exists for \a key it will be removed first.
|
||||||
*/
|
*/
|
||||||
void addValue(const String &key, const String &value, bool replace = true);
|
void addValue(const String &key, const String &value, bool replace = true);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Set the binary data for the key specified by \a item to \a value
|
* Set the binary data for the key specified by \a item to \a value
|
||||||
* This will convert the item to type \a Binary if it isn't already and
|
* This will convert the item to type \a Binary if it isn't already and all of the other values on the same key will be removed.
|
||||||
* all of the other values on the same key will be removed.
|
|
||||||
*/
|
*/
|
||||||
void setData(const String &key, const ByteVector &value);
|
void setData(const String &key, const ByteVector &value);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Sets the \a key item to the value of \a item. If an item with the \a key is already
|
* Sets the \a key item to the value of \a item. If an item with the \a key is already present, it will be replaced.
|
||||||
* present, it will be replaced.
|
|
||||||
*/
|
*/
|
||||||
void setItem(const String &key, const Item &item);
|
void setItem(const String &key, const Item &item);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns true if the tag does not contain any data.
|
* Returns true if the tag does not contain any data.
|
||||||
*/
|
*/
|
||||||
bool isEmpty() const;
|
bool isEmpty() const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Reads from the file specified in the constructor.
|
* Reads from the file specified in the constructor.
|
||||||
*/
|
*/
|
||||||
@@ -201,8 +208,9 @@ namespace TagLib {
|
|||||||
|
|
||||||
class TagPrivate;
|
class TagPrivate;
|
||||||
TagPrivate *d;
|
TagPrivate *d;
|
||||||
};
|
};
|
||||||
}
|
} // namespace APE
|
||||||
}
|
} // namespace TagLib
|
||||||
|
} // namespace Strawberry_TagLib
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
285
3rdparty/taglib/asf/asfattribute.cpp
vendored
285
3rdparty/taglib/asf/asfattribute.cpp
vendored
@@ -23,25 +23,22 @@
|
|||||||
* http://www.mozilla.org/MPL/ *
|
* http://www.mozilla.org/MPL/ *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include <taglib.h>
|
#include <memory>
|
||||||
#include <tdebug.h>
|
|
||||||
#include <trefcounter.h>
|
#include "taglib.h"
|
||||||
|
#include "tdebug.h"
|
||||||
|
|
||||||
#include "asfattribute.h"
|
#include "asfattribute.h"
|
||||||
#include "asffile.h"
|
#include "asffile.h"
|
||||||
#include "asfutils.h"
|
#include "asfutils.h"
|
||||||
|
|
||||||
using namespace TagLib;
|
using namespace Strawberry_TagLib::TagLib;
|
||||||
|
|
||||||
class ASF::Attribute::AttributePrivate : public RefCounter
|
namespace {
|
||||||
{
|
struct AttributeData {
|
||||||
public:
|
explicit AttributeData() : numericValue(0), stream(0), language(0) {}
|
||||||
AttributePrivate() :
|
|
||||||
pictureValue(ASF::Picture::fromInvalid()),
|
ASF::Attribute::AttributeTypes type;
|
||||||
numericValue(0),
|
|
||||||
stream(0),
|
|
||||||
language(0) {}
|
|
||||||
AttributeTypes type;
|
|
||||||
String stringValue;
|
String stringValue;
|
||||||
ByteVector byteVectorValue;
|
ByteVector byteVectorValue;
|
||||||
ASF::Picture pictureValue;
|
ASF::Picture pictureValue;
|
||||||
@@ -49,208 +46,188 @@ public:
|
|||||||
int stream;
|
int stream;
|
||||||
int language;
|
int language;
|
||||||
};
|
};
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
class ASF::Attribute::AttributePrivate {
|
||||||
|
public:
|
||||||
|
AttributePrivate() : data(new AttributeData()) {
|
||||||
|
data->pictureValue = ASF::Picture::fromInvalid();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<AttributeData> data;
|
||||||
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// public members
|
// public members
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
ASF::Attribute::Attribute() :
|
ASF::Attribute::Attribute() : d(new AttributePrivate()) {
|
||||||
d(new AttributePrivate())
|
d->data->type = UnicodeType;
|
||||||
{
|
|
||||||
d->type = UnicodeType;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ASF::Attribute::Attribute(const ASF::Attribute &other) :
|
ASF::Attribute::Attribute(const ASF::Attribute &other) : d(new AttributePrivate(*other.d)) {}
|
||||||
d(other.d)
|
|
||||||
{
|
ASF::Attribute::Attribute(const String &value) : d(new AttributePrivate()) {
|
||||||
d->ref();
|
d->data->type = UnicodeType;
|
||||||
|
d->data->stringValue = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASF::Attribute::Attribute(const String &value) :
|
ASF::Attribute::Attribute(const ByteVector &value) : d(new AttributePrivate()) {
|
||||||
d(new AttributePrivate())
|
d->data->type = BytesType;
|
||||||
{
|
d->data->byteVectorValue = value;
|
||||||
d->type = UnicodeType;
|
|
||||||
d->stringValue = value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ASF::Attribute::Attribute(const ByteVector &value) :
|
ASF::Attribute::Attribute(const ASF::Picture &value) : d(new AttributePrivate()) {
|
||||||
d(new AttributePrivate())
|
d->data->type = BytesType;
|
||||||
{
|
d->data->pictureValue = value;
|
||||||
d->type = BytesType;
|
|
||||||
d->byteVectorValue = value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ASF::Attribute::Attribute(const ASF::Picture &value) :
|
ASF::Attribute::Attribute(unsigned int value) : d(new AttributePrivate()) {
|
||||||
d(new AttributePrivate())
|
d->data->type = DWordType;
|
||||||
{
|
d->data->numericValue = value;
|
||||||
d->type = BytesType;
|
|
||||||
d->pictureValue = value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ASF::Attribute::Attribute(unsigned int value) :
|
ASF::Attribute::Attribute(unsigned long long value) : d(new AttributePrivate()) {
|
||||||
d(new AttributePrivate())
|
d->data->type = QWordType;
|
||||||
{
|
d->data->numericValue = value;
|
||||||
d->type = DWordType;
|
|
||||||
d->numericValue = value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ASF::Attribute::Attribute(unsigned long long value) :
|
ASF::Attribute::Attribute(unsigned short value) : d(new AttributePrivate()) {
|
||||||
d(new AttributePrivate())
|
d->data->type = WordType;
|
||||||
{
|
d->data->numericValue = value;
|
||||||
d->type = QWordType;
|
|
||||||
d->numericValue = value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ASF::Attribute::Attribute(unsigned short value) :
|
ASF::Attribute::Attribute(bool value) : d(new AttributePrivate()) {
|
||||||
d(new AttributePrivate())
|
d->data->type = BoolType;
|
||||||
{
|
d->data->numericValue = value;
|
||||||
d->type = WordType;
|
|
||||||
d->numericValue = value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ASF::Attribute::Attribute(bool value) :
|
ASF::Attribute &ASF::Attribute::operator=(const ASF::Attribute &other) {
|
||||||
d(new AttributePrivate())
|
|
||||||
{
|
|
||||||
d->type = BoolType;
|
|
||||||
d->numericValue = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
ASF::Attribute &ASF::Attribute::operator=(const ASF::Attribute &other)
|
|
||||||
{
|
|
||||||
Attribute(other).swap(*this);
|
Attribute(other).swap(*this);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASF::Attribute::swap(Attribute &other)
|
void ASF::Attribute::swap(Attribute &other) {
|
||||||
{
|
|
||||||
using std::swap;
|
using std::swap;
|
||||||
|
|
||||||
swap(d, other.d);
|
swap(d, other.d);
|
||||||
}
|
}
|
||||||
|
|
||||||
ASF::Attribute::~Attribute()
|
ASF::Attribute::~Attribute() {
|
||||||
{
|
|
||||||
if(d->deref())
|
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASF::Attribute::AttributeTypes ASF::Attribute::type() const
|
ASF::Attribute::AttributeTypes ASF::Attribute::type() const {
|
||||||
{
|
return d->data->type;
|
||||||
return d->type;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String ASF::Attribute::toString() const
|
String ASF::Attribute::toString() const {
|
||||||
{
|
return d->data->stringValue;
|
||||||
return d->stringValue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ByteVector ASF::Attribute::toByteVector() const
|
ByteVector ASF::Attribute::toByteVector() const {
|
||||||
{
|
if (d->data->pictureValue.isValid())
|
||||||
if(d->pictureValue.isValid())
|
return d->data->pictureValue.render();
|
||||||
return d->pictureValue.render();
|
|
||||||
return d->byteVectorValue;
|
return d->data->byteVectorValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned short ASF::Attribute::toBool() const
|
unsigned short ASF::Attribute::toBool() const {
|
||||||
{
|
return d->data->numericValue ? 1 : 0;
|
||||||
return d->numericValue ? 1 : 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned short ASF::Attribute::toUShort() const
|
unsigned short ASF::Attribute::toUShort() const {
|
||||||
{
|
return static_cast<unsigned short>(d->data->numericValue);
|
||||||
return static_cast<unsigned short>(d->numericValue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int ASF::Attribute::toUInt() const
|
unsigned int ASF::Attribute::toUInt() const {
|
||||||
{
|
return static_cast<unsigned int>(d->data->numericValue);
|
||||||
return static_cast<unsigned int>(d->numericValue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long long ASF::Attribute::toULongLong() const
|
unsigned long long ASF::Attribute::toULongLong() const {
|
||||||
{
|
return static_cast<unsigned long long>(d->data->numericValue);
|
||||||
return static_cast<unsigned long long>(d->numericValue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ASF::Picture ASF::Attribute::toPicture() const
|
ASF::Picture ASF::Attribute::toPicture() const {
|
||||||
{
|
return d->data->pictureValue;
|
||||||
return d->pictureValue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String ASF::Attribute::parse(ASF::File &f, int kind)
|
String ASF::Attribute::parse(ASF::File &f, int kind) {
|
||||||
{
|
|
||||||
unsigned int size, nameLength;
|
unsigned int size, nameLength;
|
||||||
String name;
|
String name;
|
||||||
d->pictureValue = Picture::fromInvalid();
|
d->data->pictureValue = Picture::fromInvalid();
|
||||||
// extended content descriptor
|
// extended content descriptor
|
||||||
if(kind == 0) {
|
if (kind == 0) {
|
||||||
nameLength = readWORD(&f);
|
nameLength = readWORD(&f);
|
||||||
name = readString(&f, nameLength);
|
name = readString(&f, nameLength);
|
||||||
d->type = ASF::Attribute::AttributeTypes(readWORD(&f));
|
d->data->type = ASF::Attribute::AttributeTypes(readWORD(&f));
|
||||||
size = readWORD(&f);
|
size = readWORD(&f);
|
||||||
}
|
}
|
||||||
// metadata & metadata library
|
// metadata & metadata library
|
||||||
else {
|
else {
|
||||||
int temp = readWORD(&f);
|
int temp = readWORD(&f);
|
||||||
// metadata library
|
// metadata library
|
||||||
if(kind == 2) {
|
if (kind == 2) {
|
||||||
d->language = temp;
|
d->data->language = temp;
|
||||||
}
|
}
|
||||||
d->stream = readWORD(&f);
|
d->data->stream = readWORD(&f);
|
||||||
nameLength = readWORD(&f);
|
nameLength = readWORD(&f);
|
||||||
d->type = ASF::Attribute::AttributeTypes(readWORD(&f));
|
d->data->type = ASF::Attribute::AttributeTypes(readWORD(&f));
|
||||||
size = readDWORD(&f);
|
size = readDWORD(&f);
|
||||||
name = readString(&f, nameLength);
|
name = readString(&f, nameLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(kind != 2 && size > 65535) {
|
if (kind != 2 && size > 65535) {
|
||||||
debug("ASF::Attribute::parse() -- Value larger than 64kB");
|
debug("ASF::Attribute::parse() -- Value larger than 64kB");
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(d->type) {
|
switch (d->data->type) {
|
||||||
case WordType:
|
case WordType:
|
||||||
d->numericValue = readWORD(&f);
|
d->data->numericValue = readWORD(&f);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BoolType:
|
case BoolType:
|
||||||
if(kind == 0) {
|
if (kind == 0) {
|
||||||
d->numericValue = (readDWORD(&f) != 0);
|
d->data->numericValue = (readDWORD(&f) != 0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
d->numericValue = (readWORD(&f) != 0);
|
d->data->numericValue = (readWORD(&f) != 0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DWordType:
|
case DWordType:
|
||||||
d->numericValue = readDWORD(&f);
|
d->data->numericValue = readDWORD(&f);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case QWordType:
|
case QWordType:
|
||||||
d->numericValue = readQWORD(&f);
|
d->data->numericValue = readQWORD(&f);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UnicodeType:
|
case UnicodeType:
|
||||||
d->stringValue = readString(&f, size);
|
d->data->stringValue = readString(&f, size);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BytesType:
|
case BytesType:
|
||||||
case GuidType:
|
case GuidType:
|
||||||
d->byteVectorValue = f.readBlock(size);
|
d->data->byteVectorValue = f.readBlock(size);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(d->type == BytesType && name == "WM/Picture") {
|
if (d->data->type == BytesType && name == "WM/Picture") {
|
||||||
d->pictureValue.parse(d->byteVectorValue);
|
d->data->pictureValue.parse(d->data->byteVectorValue);
|
||||||
if(d->pictureValue.isValid()) {
|
if (d->data->pictureValue.isValid()) {
|
||||||
d->byteVectorValue.clear();
|
d->data->byteVectorValue.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ASF::Attribute::dataSize() const
|
int ASF::Attribute::dataSize() const {
|
||||||
{
|
|
||||||
switch (d->type) {
|
switch (d->data->type) {
|
||||||
case WordType:
|
case WordType:
|
||||||
return 2;
|
return 2;
|
||||||
case BoolType:
|
case BoolType:
|
||||||
@@ -260,92 +237,92 @@ int ASF::Attribute::dataSize() const
|
|||||||
case QWordType:
|
case QWordType:
|
||||||
return 5;
|
return 5;
|
||||||
case UnicodeType:
|
case UnicodeType:
|
||||||
return d->stringValue.size() * 2 + 2;
|
return static_cast<int>(d->data->stringValue.size() * 2 + 2);
|
||||||
case BytesType:
|
case BytesType:
|
||||||
if(d->pictureValue.isValid())
|
if (d->data->pictureValue.isValid())
|
||||||
return d->pictureValue.dataSize();
|
return d->data->pictureValue.dataSize();
|
||||||
|
break;
|
||||||
case GuidType:
|
case GuidType:
|
||||||
return d->byteVectorValue.size();
|
return static_cast<int>(d->data->byteVectorValue.size());
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ByteVector ASF::Attribute::render(const String &name, int kind) const
|
ByteVector ASF::Attribute::render(const String &name, int kind) const {
|
||||||
{
|
|
||||||
ByteVector data;
|
ByteVector data;
|
||||||
|
|
||||||
switch (d->type) {
|
switch (d->data->type) {
|
||||||
case WordType:
|
case WordType:
|
||||||
data.append(ByteVector::fromShort(toUShort(), false));
|
data.append(ByteVector::fromUInt16LE(toUShort()));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BoolType:
|
case BoolType:
|
||||||
if(kind == 0) {
|
if (kind == 0) {
|
||||||
data.append(ByteVector::fromUInt(toBool(), false));
|
data.append(ByteVector::fromUInt32LE(toBool()));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
data.append(ByteVector::fromShort(toBool(), false));
|
data.append(ByteVector::fromUInt16LE(toBool()));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DWordType:
|
case DWordType:
|
||||||
data.append(ByteVector::fromUInt(toUInt(), false));
|
data.append(ByteVector::fromUInt32LE(toUInt()));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case QWordType:
|
case QWordType:
|
||||||
data.append(ByteVector::fromLongLong(toULongLong(), false));
|
data.append(ByteVector::fromUInt64LE(toULongLong()));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UnicodeType:
|
case UnicodeType:
|
||||||
data.append(renderString(d->stringValue));
|
data.append(renderString(d->data->stringValue));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BytesType:
|
case BytesType:
|
||||||
if(d->pictureValue.isValid()) {
|
if (d->data->pictureValue.isValid()) {
|
||||||
data.append(d->pictureValue.render());
|
data.append(d->data->pictureValue.render());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
case GuidType:
|
case GuidType:
|
||||||
data.append(d->byteVectorValue);
|
data.append(d->data->byteVectorValue);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(kind == 0) {
|
if (kind == 0) {
|
||||||
data = renderString(name, true) +
|
data = renderString(name, true) +
|
||||||
ByteVector::fromShort((int)d->type, false) +
|
ByteVector::fromUInt16LE((int)d->data->type) +
|
||||||
ByteVector::fromShort(data.size(), false) +
|
ByteVector::fromUInt16LE(data.size()) +
|
||||||
data;
|
data;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ByteVector nameData = renderString(name);
|
ByteVector nameData = renderString(name);
|
||||||
data = ByteVector::fromShort(kind == 2 ? d->language : 0, false) +
|
data = ByteVector::fromUInt16LE(kind == 2 ? d->data->language : 0) +
|
||||||
ByteVector::fromShort(d->stream, false) +
|
ByteVector::fromUInt16LE(d->data->stream) +
|
||||||
ByteVector::fromShort(nameData.size(), false) +
|
ByteVector::fromUInt16LE(nameData.size()) +
|
||||||
ByteVector::fromShort((int)d->type, false) +
|
ByteVector::fromUInt16LE(static_cast<int>(d->data->type)) +
|
||||||
ByteVector::fromUInt(data.size(), false) +
|
ByteVector::fromUInt32LE(data.size()) +
|
||||||
nameData +
|
nameData +
|
||||||
data;
|
data;
|
||||||
}
|
}
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ASF::Attribute::language() const
|
int ASF::Attribute::language() const {
|
||||||
{
|
return d->data->language;
|
||||||
return d->language;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASF::Attribute::setLanguage(int value)
|
void ASF::Attribute::setLanguage(int value) {
|
||||||
{
|
d->data->language = value;
|
||||||
d->language = value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ASF::Attribute::stream() const
|
int ASF::Attribute::stream() const {
|
||||||
{
|
return d->data->stream;
|
||||||
return d->stream;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASF::Attribute::setStream(int value)
|
void ASF::Attribute::setStream(int value) {
|
||||||
{
|
d->data->stream = value;
|
||||||
d->stream = value;
|
|
||||||
}
|
}
|
||||||
|
|||||||
32
3rdparty/taglib/asf/asfattribute.h
vendored
32
3rdparty/taglib/asf/asfattribute.h
vendored
@@ -31,19 +31,15 @@
|
|||||||
#include "taglib_export.h"
|
#include "taglib_export.h"
|
||||||
#include "asfpicture.h"
|
#include "asfpicture.h"
|
||||||
|
|
||||||
namespace TagLib
|
namespace Strawberry_TagLib {
|
||||||
{
|
namespace TagLib {
|
||||||
|
namespace ASF {
|
||||||
|
|
||||||
namespace ASF
|
class File;
|
||||||
{
|
class Picture;
|
||||||
|
|
||||||
class File;
|
class TAGLIB_EXPORT Attribute {
|
||||||
class Picture;
|
|
||||||
|
|
||||||
class TAGLIB_EXPORT Attribute
|
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Enum of types an Attribute can have.
|
* Enum of types an Attribute can have.
|
||||||
*/
|
*/
|
||||||
@@ -108,7 +104,7 @@ namespace TagLib
|
|||||||
/*!
|
/*!
|
||||||
* Construct an attribute as a copy of \a other.
|
* Construct an attribute as a copy of \a other.
|
||||||
*/
|
*/
|
||||||
Attribute(const Attribute &item);
|
Attribute(const Attribute &other);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Copies the contents of \a other into this item.
|
* Copies the contents of \a other into this item.
|
||||||
@@ -185,24 +181,20 @@ namespace TagLib
|
|||||||
*/
|
*/
|
||||||
void setStream(int value);
|
void setStream(int value);
|
||||||
|
|
||||||
#ifndef DO_NOT_DOCUMENT
|
|
||||||
/* THIS IS PRIVATE, DON'T TOUCH IT! */
|
|
||||||
String parse(ASF::File &file, int kind = 0);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//! Returns the size of the stored data
|
//! Returns the size of the stored data
|
||||||
int dataSize() const;
|
int dataSize() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class File;
|
friend class File;
|
||||||
|
|
||||||
|
String parse(ASF::File &file, int kind = 0);
|
||||||
ByteVector render(const String &name, int kind = 0) const;
|
ByteVector render(const String &name, int kind = 0) const;
|
||||||
|
|
||||||
class AttributePrivate;
|
class AttributePrivate;
|
||||||
AttributePrivate *d;
|
AttributePrivate *d;
|
||||||
};
|
};
|
||||||
}
|
} // namespace ASF
|
||||||
|
} // namespace TagLib
|
||||||
}
|
} // namespace Strawberry_TagLib
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
542
3rdparty/taglib/asf/asffile.cpp
vendored
542
3rdparty/taglib/asf/asffile.cpp
vendored
@@ -23,22 +23,23 @@
|
|||||||
* http://www.mozilla.org/MPL/ *
|
* http://www.mozilla.org/MPL/ *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include <tdebug.h>
|
#include <memory>
|
||||||
#include <tbytevectorlist.h>
|
|
||||||
#include <tpropertymap.h>
|
#include "tdebug.h"
|
||||||
#include <tstring.h>
|
#include "tbytevectorlist.h"
|
||||||
#include <tagutils.h>
|
#include "tpropertymap.h"
|
||||||
|
#include "tstring.h"
|
||||||
|
#include "tagutils.h"
|
||||||
|
|
||||||
#include "asffile.h"
|
#include "asffile.h"
|
||||||
#include "asftag.h"
|
#include "asftag.h"
|
||||||
#include "asfproperties.h"
|
#include "asfproperties.h"
|
||||||
#include "asfutils.h"
|
#include "asfutils.h"
|
||||||
|
|
||||||
using namespace TagLib;
|
using namespace Strawberry_TagLib::TagLib;
|
||||||
|
|
||||||
class ASF::File::FilePrivate
|
class ASF::File::FilePrivate {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
class BaseObject;
|
class BaseObject;
|
||||||
class UnknownObject;
|
class UnknownObject;
|
||||||
class FilePropertiesObject;
|
class FilePropertiesObject;
|
||||||
@@ -50,58 +51,42 @@ public:
|
|||||||
class MetadataObject;
|
class MetadataObject;
|
||||||
class MetadataLibraryObject;
|
class MetadataLibraryObject;
|
||||||
|
|
||||||
FilePrivate():
|
typedef List<std::shared_ptr<BaseObject>> ObjectList;
|
||||||
headerSize(0),
|
typedef ObjectList::ConstIterator ObjectConstIterator;
|
||||||
tag(0),
|
|
||||||
properties(0),
|
|
||||||
contentDescriptionObject(0),
|
|
||||||
extendedContentDescriptionObject(0),
|
|
||||||
headerExtensionObject(0),
|
|
||||||
metadataObject(0),
|
|
||||||
metadataLibraryObject(0)
|
|
||||||
{
|
|
||||||
objects.setAutoDelete(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
~FilePrivate()
|
FilePrivate() : headerSize(0) {}
|
||||||
{
|
|
||||||
delete tag;
|
|
||||||
delete properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned long long headerSize;
|
unsigned long long headerSize;
|
||||||
|
|
||||||
ASF::Tag *tag;
|
std::unique_ptr<ASF::Tag> tag;
|
||||||
ASF::Properties *properties;
|
std::unique_ptr<ASF::AudioProperties> properties;
|
||||||
|
|
||||||
List<BaseObject *> objects;
|
ObjectList objects;
|
||||||
|
|
||||||
ContentDescriptionObject *contentDescriptionObject;
|
std::shared_ptr<ContentDescriptionObject> contentDescriptionObject;
|
||||||
ExtendedContentDescriptionObject *extendedContentDescriptionObject;
|
std::shared_ptr<ExtendedContentDescriptionObject> extendedContentDescriptionObject;
|
||||||
HeaderExtensionObject *headerExtensionObject;
|
std::shared_ptr<HeaderExtensionObject> headerExtensionObject;
|
||||||
MetadataObject *metadataObject;
|
std::shared_ptr<MetadataObject> metadataObject;
|
||||||
MetadataLibraryObject *metadataLibraryObject;
|
std::shared_ptr<MetadataLibraryObject> metadataLibraryObject;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace
|
namespace {
|
||||||
{
|
const ByteVector headerGuid("\x30\x26\xB2\x75\x8E\x66\xCF\x11\xA6\xD9\x00\xAA\x00\x62\xCE\x6C", 16);
|
||||||
const ByteVector headerGuid("\x30\x26\xB2\x75\x8E\x66\xCF\x11\xA6\xD9\x00\xAA\x00\x62\xCE\x6C", 16);
|
const ByteVector filePropertiesGuid("\xA1\xDC\xAB\x8C\x47\xA9\xCF\x11\x8E\xE4\x00\xC0\x0C\x20\x53\x65", 16);
|
||||||
const ByteVector filePropertiesGuid("\xA1\xDC\xAB\x8C\x47\xA9\xCF\x11\x8E\xE4\x00\xC0\x0C\x20\x53\x65", 16);
|
const ByteVector streamPropertiesGuid("\x91\x07\xDC\xB7\xB7\xA9\xCF\x11\x8E\xE6\x00\xC0\x0C\x20\x53\x65", 16);
|
||||||
const ByteVector streamPropertiesGuid("\x91\x07\xDC\xB7\xB7\xA9\xCF\x11\x8E\xE6\x00\xC0\x0C\x20\x53\x65", 16);
|
const ByteVector contentDescriptionGuid("\x33\x26\xB2\x75\x8E\x66\xCF\x11\xA6\xD9\x00\xAA\x00\x62\xCE\x6C", 16);
|
||||||
const ByteVector contentDescriptionGuid("\x33\x26\xB2\x75\x8E\x66\xCF\x11\xA6\xD9\x00\xAA\x00\x62\xCE\x6C", 16);
|
const ByteVector extendedContentDescriptionGuid("\x40\xA4\xD0\xD2\x07\xE3\xD2\x11\x97\xF0\x00\xA0\xC9\x5E\xA8\x50", 16);
|
||||||
const ByteVector extendedContentDescriptionGuid("\x40\xA4\xD0\xD2\x07\xE3\xD2\x11\x97\xF0\x00\xA0\xC9\x5E\xA8\x50", 16);
|
const ByteVector headerExtensionGuid("\xb5\x03\xbf_.\xa9\xcf\x11\x8e\xe3\x00\xc0\x0c Se", 16);
|
||||||
const ByteVector headerExtensionGuid("\xb5\x03\xbf_.\xa9\xcf\x11\x8e\xe3\x00\xc0\x0c Se", 16);
|
const ByteVector metadataGuid("\xEA\xCB\xF8\xC5\xAF[wH\204g\xAA\214D\xFAL\xCA", 16);
|
||||||
const ByteVector metadataGuid("\xEA\xCB\xF8\xC5\xAF[wH\204g\xAA\214D\xFAL\xCA", 16);
|
const ByteVector metadataLibraryGuid("\224\034#D\230\224\321I\241A\x1d\x13NEpT", 16);
|
||||||
const ByteVector metadataLibraryGuid("\224\034#D\230\224\321I\241A\x1d\x13NEpT", 16);
|
const ByteVector codecListGuid("\x40\x52\xd1\x86\x1d\x31\xd0\x11\xa3\xa4\x00\xa0\xc9\x03\x48\xf6", 16);
|
||||||
const ByteVector codecListGuid("\x40\x52\xd1\x86\x1d\x31\xd0\x11\xa3\xa4\x00\xa0\xc9\x03\x48\xf6", 16);
|
const ByteVector contentEncryptionGuid("\xFB\xB3\x11\x22\x23\xBD\xD2\x11\xB4\xB7\x00\xA0\xC9\x55\xFC\x6E", 16);
|
||||||
const ByteVector contentEncryptionGuid("\xFB\xB3\x11\x22\x23\xBD\xD2\x11\xB4\xB7\x00\xA0\xC9\x55\xFC\x6E", 16);
|
const ByteVector extendedContentEncryptionGuid("\x14\xE6\x8A\x29\x22\x26 \x17\x4C\xB9\x35\xDA\xE0\x7E\xE9\x28\x9C", 16);
|
||||||
const ByteVector extendedContentEncryptionGuid("\x14\xE6\x8A\x29\x22\x26 \x17\x4C\xB9\x35\xDA\xE0\x7E\xE9\x28\x9C", 16);
|
const ByteVector advancedContentEncryptionGuid("\xB6\x9B\x07\x7A\xA4\xDA\x12\x4E\xA5\xCA\x91\xD3\x8D\xC1\x1A\x8D", 16);
|
||||||
const ByteVector advancedContentEncryptionGuid("\xB6\x9B\x07\x7A\xA4\xDA\x12\x4E\xA5\xCA\x91\xD3\x8D\xC1\x1A\x8D", 16);
|
} // namespace
|
||||||
}
|
|
||||||
|
|
||||||
class ASF::File::FilePrivate::BaseObject
|
class ASF::File::FilePrivate::BaseObject {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
ByteVector data;
|
ByteVector data;
|
||||||
virtual ~BaseObject() {}
|
virtual ~BaseObject() {}
|
||||||
virtual ByteVector guid() const = 0;
|
virtual ByteVector guid() const = 0;
|
||||||
@@ -109,355 +94,346 @@ public:
|
|||||||
virtual ByteVector render(ASF::File *file);
|
virtual ByteVector render(ASF::File *file);
|
||||||
};
|
};
|
||||||
|
|
||||||
class ASF::File::FilePrivate::UnknownObject : public ASF::File::FilePrivate::BaseObject
|
class ASF::File::FilePrivate::UnknownObject : public ASF::File::FilePrivate::BaseObject {
|
||||||
{
|
|
||||||
ByteVector myGuid;
|
ByteVector myGuid;
|
||||||
public:
|
|
||||||
UnknownObject(const ByteVector &guid);
|
public:
|
||||||
ByteVector guid() const;
|
explicit UnknownObject(const ByteVector &guid);
|
||||||
|
ByteVector guid() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ASF::File::FilePrivate::FilePropertiesObject : public ASF::File::FilePrivate::BaseObject
|
class ASF::File::FilePrivate::FilePropertiesObject : public ASF::File::FilePrivate::BaseObject {
|
||||||
{
|
public:
|
||||||
public:
|
ByteVector guid() const override;
|
||||||
ByteVector guid() const;
|
void parse(ASF::File *file, unsigned int size) override;
|
||||||
void parse(ASF::File *file, unsigned int size);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class ASF::File::FilePrivate::StreamPropertiesObject : public ASF::File::FilePrivate::BaseObject
|
class ASF::File::FilePrivate::StreamPropertiesObject : public ASF::File::FilePrivate::BaseObject {
|
||||||
{
|
public:
|
||||||
public:
|
ByteVector guid() const override;
|
||||||
ByteVector guid() const;
|
void parse(ASF::File *file, unsigned int size) override;
|
||||||
void parse(ASF::File *file, unsigned int size);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class ASF::File::FilePrivate::ContentDescriptionObject : public ASF::File::FilePrivate::BaseObject
|
class ASF::File::FilePrivate::ContentDescriptionObject : public ASF::File::FilePrivate::BaseObject {
|
||||||
{
|
public:
|
||||||
public:
|
ByteVector guid() const override;
|
||||||
ByteVector guid() const;
|
void parse(ASF::File *file, unsigned int size) override;
|
||||||
void parse(ASF::File *file, unsigned int size);
|
ByteVector render(ASF::File *file) override;
|
||||||
ByteVector render(ASF::File *file);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class ASF::File::FilePrivate::ExtendedContentDescriptionObject : public ASF::File::FilePrivate::BaseObject
|
class ASF::File::FilePrivate::ExtendedContentDescriptionObject : public ASF::File::FilePrivate::BaseObject {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
ByteVectorList attributeData;
|
ByteVectorList attributeData;
|
||||||
ByteVector guid() const;
|
ByteVector guid() const override;
|
||||||
void parse(ASF::File *file, unsigned int size);
|
void parse(ASF::File *file, unsigned int size) override;
|
||||||
ByteVector render(ASF::File *file);
|
ByteVector render(ASF::File *file) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ASF::File::FilePrivate::MetadataObject : public ASF::File::FilePrivate::BaseObject
|
class ASF::File::FilePrivate::MetadataObject : public ASF::File::FilePrivate::BaseObject {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
ByteVectorList attributeData;
|
ByteVectorList attributeData;
|
||||||
ByteVector guid() const;
|
ByteVector guid() const override;
|
||||||
void parse(ASF::File *file, unsigned int size);
|
void parse(ASF::File *file, unsigned int size) override;
|
||||||
ByteVector render(ASF::File *file);
|
ByteVector render(ASF::File *file) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ASF::File::FilePrivate::MetadataLibraryObject : public ASF::File::FilePrivate::BaseObject
|
class ASF::File::FilePrivate::MetadataLibraryObject : public ASF::File::FilePrivate::BaseObject {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
ByteVectorList attributeData;
|
ByteVectorList attributeData;
|
||||||
ByteVector guid() const;
|
ByteVector guid() const override;
|
||||||
void parse(ASF::File *file, unsigned int size);
|
void parse(ASF::File *file, unsigned int size) override;
|
||||||
ByteVector render(ASF::File *file);
|
ByteVector render(ASF::File *file) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ASF::File::FilePrivate::HeaderExtensionObject : public ASF::File::FilePrivate::BaseObject
|
class ASF::File::FilePrivate::HeaderExtensionObject : public ASF::File::FilePrivate::BaseObject {
|
||||||
{
|
public:
|
||||||
public:
|
ObjectList objects;
|
||||||
List<ASF::File::FilePrivate::BaseObject *> objects;
|
|
||||||
HeaderExtensionObject();
|
HeaderExtensionObject();
|
||||||
ByteVector guid() const;
|
ByteVector guid() const override;
|
||||||
void parse(ASF::File *file, unsigned int size);
|
void parse(ASF::File *file, unsigned int size) override;
|
||||||
ByteVector render(ASF::File *file);
|
ByteVector render(ASF::File *file) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ASF::File::FilePrivate::CodecListObject : public ASF::File::FilePrivate::BaseObject
|
class ASF::File::FilePrivate::CodecListObject : public ASF::File::FilePrivate::BaseObject {
|
||||||
{
|
public:
|
||||||
public:
|
ByteVector guid() const override;
|
||||||
ByteVector guid() const;
|
void parse(ASF::File *file, unsigned int size) override;
|
||||||
void parse(ASF::File *file, unsigned int size);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum CodecType
|
enum CodecType {
|
||||||
{
|
|
||||||
Video = 0x0001,
|
Video = 0x0001,
|
||||||
Audio = 0x0002,
|
Audio = 0x0002,
|
||||||
Unknown = 0xFFFF
|
Unknown = 0xFFFF
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
void ASF::File::FilePrivate::BaseObject::parse(ASF::File *file, unsigned int size)
|
void ASF::File::FilePrivate::BaseObject::parse(ASF::File *file, unsigned int size) {
|
||||||
{
|
|
||||||
data.clear();
|
data.clear();
|
||||||
if(size > 24 && size <= (unsigned int)(file->length()))
|
if (size > 24 && static_cast<long long>(size) <= file->length())
|
||||||
data = file->readBlock(size - 24);
|
data = file->readBlock(size - 24);
|
||||||
else
|
else
|
||||||
data = ByteVector();
|
data = ByteVector();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ByteVector ASF::File::FilePrivate::BaseObject::render(ASF::File * /*file*/)
|
ByteVector ASF::File::FilePrivate::BaseObject::render(ASF::File * /*file*/) {
|
||||||
{
|
return guid() + ByteVector::fromUInt64LE(data.size() + 24) + data;
|
||||||
return guid() + ByteVector::fromLongLong(data.size() + 24, false) + data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ASF::File::FilePrivate::UnknownObject::UnknownObject(const ByteVector &guid) : myGuid(guid)
|
ASF::File::FilePrivate::UnknownObject::UnknownObject(const ByteVector &guid) : myGuid(guid) {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
ByteVector ASF::File::FilePrivate::UnknownObject::guid() const
|
ByteVector ASF::File::FilePrivate::UnknownObject::guid() const {
|
||||||
{
|
|
||||||
return myGuid;
|
return myGuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
ByteVector ASF::File::FilePrivate::FilePropertiesObject::guid() const
|
ByteVector ASF::File::FilePrivate::FilePropertiesObject::guid() const {
|
||||||
{
|
|
||||||
return filePropertiesGuid;
|
return filePropertiesGuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASF::File::FilePrivate::FilePropertiesObject::parse(ASF::File *file, unsigned int size)
|
void ASF::File::FilePrivate::FilePropertiesObject::parse(ASF::File *file, unsigned int size) {
|
||||||
{
|
|
||||||
BaseObject::parse(file, size);
|
BaseObject::parse(file, size);
|
||||||
if(data.size() < 64) {
|
if (data.size() < 64) {
|
||||||
debug("ASF::File::FilePrivate::FilePropertiesObject::parse() -- data is too short.");
|
debug("ASF::File::FilePrivate::FilePropertiesObject::parse() -- data is too short.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const long long duration = data.toLongLong(40, false);
|
const long long duration = data.toInt64LE(40);
|
||||||
const long long preroll = data.toLongLong(56, false);
|
const long long preroll = data.toInt64LE(56);
|
||||||
file->d->properties->setLengthInMilliseconds(static_cast<int>(duration / 10000.0 - preroll + 0.5));
|
file->d->properties->setLengthInMilliseconds(static_cast<int>(duration / 10000.0 - preroll + 0.5));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ByteVector ASF::File::FilePrivate::StreamPropertiesObject::guid() const
|
ByteVector ASF::File::FilePrivate::StreamPropertiesObject::guid() const {
|
||||||
{
|
|
||||||
return streamPropertiesGuid;
|
return streamPropertiesGuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASF::File::FilePrivate::StreamPropertiesObject::parse(ASF::File *file, unsigned int size)
|
void ASF::File::FilePrivate::StreamPropertiesObject::parse(ASF::File *file, unsigned int size) {
|
||||||
{
|
|
||||||
BaseObject::parse(file, size);
|
BaseObject::parse(file, size);
|
||||||
if(data.size() < 70) {
|
if (data.size() < 70) {
|
||||||
debug("ASF::File::FilePrivate::StreamPropertiesObject::parse() -- data is too short.");
|
debug("ASF::File::FilePrivate::StreamPropertiesObject::parse() -- data is too short.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
file->d->properties->setCodec(data.toUShort(54, false));
|
file->d->properties->setCodec(data.toUInt16LE(54));
|
||||||
file->d->properties->setChannels(data.toUShort(56, false));
|
file->d->properties->setChannels(data.toUInt16LE(56));
|
||||||
file->d->properties->setSampleRate(data.toUInt(58, false));
|
file->d->properties->setSampleRate(data.toUInt32LE(58));
|
||||||
file->d->properties->setBitrate(static_cast<int>(data.toUInt(62, false) * 8.0 / 1000.0 + 0.5));
|
file->d->properties->setBitrate(static_cast<int>(data.toUInt32LE(62) * 8.0 / 1000.0 + 0.5));
|
||||||
file->d->properties->setBitsPerSample(data.toUShort(68, false));
|
file->d->properties->setBitsPerSample(data.toUInt16LE(68));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ByteVector ASF::File::FilePrivate::ContentDescriptionObject::guid() const
|
ByteVector ASF::File::FilePrivate::ContentDescriptionObject::guid() const {
|
||||||
{
|
|
||||||
return contentDescriptionGuid;
|
return contentDescriptionGuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASF::File::FilePrivate::ContentDescriptionObject::parse(ASF::File *file, unsigned int /*size*/)
|
void ASF::File::FilePrivate::ContentDescriptionObject::parse(ASF::File *file, unsigned int /*size*/) {
|
||||||
{
|
|
||||||
const int titleLength = readWORD(file);
|
const int titleLength = readWORD(file);
|
||||||
const int artistLength = readWORD(file);
|
const int artistLength = readWORD(file);
|
||||||
const int copyrightLength = readWORD(file);
|
const int copyrightLength = readWORD(file);
|
||||||
const int commentLength = readWORD(file);
|
const int commentLength = readWORD(file);
|
||||||
const int ratingLength = readWORD(file);
|
const int ratingLength = readWORD(file);
|
||||||
file->d->tag->setTitle(readString(file,titleLength));
|
file->d->tag->setTitle(readString(file, titleLength));
|
||||||
file->d->tag->setArtist(readString(file,artistLength));
|
file->d->tag->setArtist(readString(file, artistLength));
|
||||||
file->d->tag->setCopyright(readString(file,copyrightLength));
|
file->d->tag->setCopyright(readString(file, copyrightLength));
|
||||||
file->d->tag->setComment(readString(file,commentLength));
|
file->d->tag->setComment(readString(file, commentLength));
|
||||||
file->d->tag->setRating(readString(file,ratingLength));
|
file->d->tag->setRating(readString(file, ratingLength));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ByteVector ASF::File::FilePrivate::ContentDescriptionObject::render(ASF::File *file)
|
ByteVector ASF::File::FilePrivate::ContentDescriptionObject::render(ASF::File *file) {
|
||||||
{
|
|
||||||
const ByteVector v1 = renderString(file->d->tag->title());
|
const ByteVector v1 = renderString(file->d->tag->title());
|
||||||
const ByteVector v2 = renderString(file->d->tag->artist());
|
const ByteVector v2 = renderString(file->d->tag->artist());
|
||||||
const ByteVector v3 = renderString(file->d->tag->copyright());
|
const ByteVector v3 = renderString(file->d->tag->copyright());
|
||||||
const ByteVector v4 = renderString(file->d->tag->comment());
|
const ByteVector v4 = renderString(file->d->tag->comment());
|
||||||
const ByteVector v5 = renderString(file->d->tag->rating());
|
const ByteVector v5 = renderString(file->d->tag->rating());
|
||||||
data.clear();
|
data.clear();
|
||||||
data.append(ByteVector::fromShort(v1.size(), false));
|
data.append(ByteVector::fromUInt16LE(v1.size()));
|
||||||
data.append(ByteVector::fromShort(v2.size(), false));
|
data.append(ByteVector::fromUInt16LE(v2.size()));
|
||||||
data.append(ByteVector::fromShort(v3.size(), false));
|
data.append(ByteVector::fromUInt16LE(v3.size()));
|
||||||
data.append(ByteVector::fromShort(v4.size(), false));
|
data.append(ByteVector::fromUInt16LE(v4.size()));
|
||||||
data.append(ByteVector::fromShort(v5.size(), false));
|
data.append(ByteVector::fromUInt16LE(v5.size()));
|
||||||
data.append(v1);
|
data.append(v1);
|
||||||
data.append(v2);
|
data.append(v2);
|
||||||
data.append(v3);
|
data.append(v3);
|
||||||
data.append(v4);
|
data.append(v4);
|
||||||
data.append(v5);
|
data.append(v5);
|
||||||
return BaseObject::render(file);
|
return BaseObject::render(file);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ByteVector ASF::File::FilePrivate::ExtendedContentDescriptionObject::guid() const
|
ByteVector ASF::File::FilePrivate::ExtendedContentDescriptionObject::guid() const {
|
||||||
{
|
|
||||||
return extendedContentDescriptionGuid;
|
return extendedContentDescriptionGuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASF::File::FilePrivate::ExtendedContentDescriptionObject::parse(ASF::File *file, unsigned int /*size*/)
|
void ASF::File::FilePrivate::ExtendedContentDescriptionObject::parse(ASF::File *file, unsigned int /*size*/) {
|
||||||
{
|
|
||||||
int count = readWORD(file);
|
int count = readWORD(file);
|
||||||
while(count--) {
|
while (count--) {
|
||||||
ASF::Attribute attribute;
|
ASF::Attribute attribute;
|
||||||
String name = attribute.parse(*file);
|
String name = attribute.parse(*file);
|
||||||
file->d->tag->addAttribute(name, attribute);
|
file->d->tag->addAttribute(name, attribute);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ByteVector ASF::File::FilePrivate::ExtendedContentDescriptionObject::render(ASF::File *file)
|
ByteVector ASF::File::FilePrivate::ExtendedContentDescriptionObject::render(ASF::File *file) {
|
||||||
{
|
|
||||||
data.clear();
|
data.clear();
|
||||||
data.append(ByteVector::fromShort(attributeData.size(), false));
|
data.append(ByteVector::fromUInt16LE(attributeData.size()));
|
||||||
data.append(attributeData.toByteVector(""));
|
data.append(attributeData.toByteVector(""));
|
||||||
return BaseObject::render(file);
|
return BaseObject::render(file);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ByteVector ASF::File::FilePrivate::MetadataObject::guid() const
|
ByteVector ASF::File::FilePrivate::MetadataObject::guid() const {
|
||||||
{
|
|
||||||
return metadataGuid;
|
return metadataGuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASF::File::FilePrivate::MetadataObject::parse(ASF::File *file, unsigned int /*size*/)
|
void ASF::File::FilePrivate::MetadataObject::parse(ASF::File *file, unsigned int /*size*/) {
|
||||||
{
|
|
||||||
int count = readWORD(file);
|
int count = readWORD(file);
|
||||||
while(count--) {
|
while (count--) {
|
||||||
ASF::Attribute attribute;
|
ASF::Attribute attribute;
|
||||||
String name = attribute.parse(*file, 1);
|
String name = attribute.parse(*file, 1);
|
||||||
file->d->tag->addAttribute(name, attribute);
|
file->d->tag->addAttribute(name, attribute);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ByteVector ASF::File::FilePrivate::MetadataObject::render(ASF::File *file)
|
ByteVector ASF::File::FilePrivate::MetadataObject::render(ASF::File *file) {
|
||||||
{
|
|
||||||
data.clear();
|
data.clear();
|
||||||
data.append(ByteVector::fromShort(attributeData.size(), false));
|
data.append(ByteVector::fromUInt16LE(attributeData.size()));
|
||||||
data.append(attributeData.toByteVector(""));
|
data.append(attributeData.toByteVector(""));
|
||||||
return BaseObject::render(file);
|
return BaseObject::render(file);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ByteVector ASF::File::FilePrivate::MetadataLibraryObject::guid() const
|
ByteVector ASF::File::FilePrivate::MetadataLibraryObject::guid() const {
|
||||||
{
|
|
||||||
return metadataLibraryGuid;
|
return metadataLibraryGuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASF::File::FilePrivate::MetadataLibraryObject::parse(ASF::File *file, unsigned int /*size*/)
|
void ASF::File::FilePrivate::MetadataLibraryObject::parse(ASF::File *file, unsigned int /*size*/) {
|
||||||
{
|
|
||||||
int count = readWORD(file);
|
int count = readWORD(file);
|
||||||
while(count--) {
|
while (count--) {
|
||||||
ASF::Attribute attribute;
|
ASF::Attribute attribute;
|
||||||
String name = attribute.parse(*file, 2);
|
String name = attribute.parse(*file, 2);
|
||||||
file->d->tag->addAttribute(name, attribute);
|
file->d->tag->addAttribute(name, attribute);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ByteVector ASF::File::FilePrivate::MetadataLibraryObject::render(ASF::File *file)
|
ByteVector ASF::File::FilePrivate::MetadataLibraryObject::render(ASF::File *file) {
|
||||||
{
|
|
||||||
data.clear();
|
data.clear();
|
||||||
data.append(ByteVector::fromShort(attributeData.size(), false));
|
data.append(ByteVector::fromUInt16LE(attributeData.size()));
|
||||||
data.append(attributeData.toByteVector(""));
|
data.append(attributeData.toByteVector(""));
|
||||||
return BaseObject::render(file);
|
return BaseObject::render(file);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ASF::File::FilePrivate::HeaderExtensionObject::HeaderExtensionObject()
|
ASF::File::FilePrivate::HeaderExtensionObject::HeaderExtensionObject() {
|
||||||
{
|
|
||||||
objects.setAutoDelete(true);
|
objects.setAutoDelete(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
ByteVector ASF::File::FilePrivate::HeaderExtensionObject::guid() const
|
ByteVector ASF::File::FilePrivate::HeaderExtensionObject::guid() const {
|
||||||
{
|
|
||||||
return headerExtensionGuid;
|
return headerExtensionGuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASF::File::FilePrivate::HeaderExtensionObject::parse(ASF::File *file, unsigned int /*size*/)
|
void ASF::File::FilePrivate::HeaderExtensionObject::parse(ASF::File *file, unsigned int /*size*/) {
|
||||||
{
|
|
||||||
file->seek(18, File::Current);
|
file->seek(18, File::Current);
|
||||||
long long dataSize = readDWORD(file);
|
long long dataSize = readDWORD(file);
|
||||||
long long dataPos = 0;
|
long long dataPos = 0;
|
||||||
while(dataPos < dataSize) {
|
while (dataPos < dataSize) {
|
||||||
ByteVector guid = file->readBlock(16);
|
ByteVector guid = file->readBlock(16);
|
||||||
if(guid.size() != 16) {
|
if (guid.size() != 16) {
|
||||||
file->setValid(false);
|
file->setValid(false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
bool ok;
|
bool ok;
|
||||||
long long size = readQWORD(file, &ok);
|
long long size = readQWORD(file, &ok);
|
||||||
if(!ok) {
|
if (!ok) {
|
||||||
file->setValid(false);
|
file->setValid(false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
BaseObject *obj;
|
std::shared_ptr<BaseObject> obj;
|
||||||
if(guid == metadataGuid) {
|
if (guid == metadataGuid) {
|
||||||
file->d->metadataObject = new MetadataObject();
|
file->d->metadataObject.reset(new MetadataObject());
|
||||||
obj = file->d->metadataObject;
|
obj = file->d->metadataObject;
|
||||||
}
|
}
|
||||||
else if(guid == metadataLibraryGuid) {
|
else if (guid == metadataLibraryGuid) {
|
||||||
file->d->metadataLibraryObject = new MetadataLibraryObject();
|
file->d->metadataLibraryObject.reset(new MetadataLibraryObject());
|
||||||
obj = file->d->metadataLibraryObject;
|
obj = file->d->metadataLibraryObject;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
obj = new UnknownObject(guid);
|
obj.reset(new UnknownObject(guid));
|
||||||
}
|
}
|
||||||
obj->parse(file, (unsigned int)size);
|
obj->parse(file, static_cast<unsigned int>(size));
|
||||||
objects.append(obj);
|
objects.append(obj);
|
||||||
dataPos += size;
|
dataPos += size;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ByteVector ASF::File::FilePrivate::HeaderExtensionObject::render(ASF::File *file)
|
ByteVector ASF::File::FilePrivate::HeaderExtensionObject::render(ASF::File *file) {
|
||||||
{
|
|
||||||
data.clear();
|
data.clear();
|
||||||
for(List<BaseObject *>::ConstIterator it = objects.begin(); it != objects.end(); ++it) {
|
for (ObjectConstIterator it = objects.begin(); it != objects.end(); ++it) {
|
||||||
data.append((*it)->render(file));
|
data.append((*it)->render(file));
|
||||||
}
|
}
|
||||||
data = ByteVector("\x11\xD2\xD3\xAB\xBA\xA9\xcf\x11\x8E\xE6\x00\xC0\x0C\x20\x53\x65\x06\x00", 18) + ByteVector::fromUInt(data.size(), false) + data;
|
data = ByteVector("\x11\xD2\xD3\xAB\xBA\xA9\xcf\x11\x8E\xE6\x00\xC0\x0C\x20\x53\x65\x06\x00", 18) + ByteVector::fromUInt32LE(data.size()) + data;
|
||||||
return BaseObject::render(file);
|
return BaseObject::render(file);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ByteVector ASF::File::FilePrivate::CodecListObject::guid() const
|
ByteVector ASF::File::FilePrivate::CodecListObject::guid() const {
|
||||||
{
|
|
||||||
return codecListGuid;
|
return codecListGuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASF::File::FilePrivate::CodecListObject::parse(ASF::File *file, unsigned int size)
|
void ASF::File::FilePrivate::CodecListObject::parse(ASF::File *file, unsigned int size) {
|
||||||
{
|
|
||||||
BaseObject::parse(file, size);
|
BaseObject::parse(file, size);
|
||||||
if(data.size() <= 20) {
|
if (data.size() <= 20) {
|
||||||
debug("ASF::File::FilePrivate::CodecListObject::parse() -- data is too short.");
|
debug("ASF::File::FilePrivate::CodecListObject::parse() -- data is too short.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int pos = 16;
|
unsigned int pos = 16;
|
||||||
|
|
||||||
const int count = data.toUInt(pos, false);
|
const int count = data.toUInt32LE(pos);
|
||||||
pos += 4;
|
pos += 4;
|
||||||
|
|
||||||
for(int i = 0; i < count; ++i) {
|
for (int i = 0; i < count; ++i) {
|
||||||
|
|
||||||
if(pos >= data.size())
|
if (pos >= data.size())
|
||||||
break;
|
break;
|
||||||
|
|
||||||
const CodecType type = static_cast<CodecType>(data.toUShort(pos, false));
|
const CodecType type = static_cast<CodecType>(data.toUInt16LE(pos));
|
||||||
pos += 2;
|
pos += 2;
|
||||||
|
|
||||||
int nameLength = data.toUShort(pos, false);
|
int nameLength = data.toUInt16LE(pos);
|
||||||
pos += 2;
|
pos += 2;
|
||||||
|
|
||||||
const unsigned int namePos = pos;
|
const unsigned int namePos = pos;
|
||||||
pos += nameLength * 2;
|
pos += nameLength * 2;
|
||||||
|
|
||||||
const int descLength = data.toUShort(pos, false);
|
const int descLength = data.toUInt16LE(pos);
|
||||||
pos += 2;
|
pos += 2;
|
||||||
|
|
||||||
const unsigned int descPos = pos;
|
const unsigned int descPos = pos;
|
||||||
pos += descLength * 2;
|
pos += descLength * 2;
|
||||||
|
|
||||||
const int infoLength = data.toUShort(pos, false);
|
const int infoLength = data.toUInt16LE(pos);
|
||||||
pos += 2 + infoLength * 2;
|
pos += 2 + infoLength * 2;
|
||||||
|
|
||||||
if(type == CodecListObject::Audio) {
|
if (type == CodecListObject::Audio) {
|
||||||
// First audio codec found.
|
// First audio codec found.
|
||||||
|
|
||||||
const String name(data.mid(namePos, nameLength * 2), String::UTF16LE);
|
const String name(data.mid(namePos, nameLength * 2), String::UTF16LE);
|
||||||
@@ -469,100 +445,78 @@ void ASF::File::FilePrivate::CodecListObject::parse(ASF::File *file, unsigned in
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// static members
|
// static members
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
bool ASF::File::isSupported(IOStream *stream)
|
bool ASF::File::isSupported(IOStream *stream) {
|
||||||
{
|
|
||||||
// An ASF file has to start with the designated GUID.
|
// An ASF file has to start with the designated GUID.
|
||||||
|
|
||||||
const ByteVector id = Utils::readHeader(stream, 16, false);
|
const ByteVector id = Utils::readHeader(stream, 16, false);
|
||||||
return (id == headerGuid);
|
return (id == headerGuid);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// public members
|
// public members
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
ASF::File::File(FileName file, bool, Properties::ReadStyle) :
|
ASF::File::File(FileName file, bool, AudioProperties::ReadStyle) : Strawberry_TagLib::TagLib::File(file), d(new FilePrivate()) {
|
||||||
TagLib::File(file),
|
if (isOpen())
|
||||||
d(new FilePrivate())
|
|
||||||
{
|
|
||||||
if(isOpen())
|
|
||||||
read();
|
read();
|
||||||
}
|
}
|
||||||
|
|
||||||
ASF::File::File(IOStream *stream, bool, Properties::ReadStyle) :
|
ASF::File::File(IOStream *stream, bool, AudioProperties::ReadStyle) : Strawberry_TagLib::TagLib::File(stream), d(new FilePrivate()) {
|
||||||
TagLib::File(stream),
|
if (isOpen())
|
||||||
d(new FilePrivate())
|
|
||||||
{
|
|
||||||
if(isOpen())
|
|
||||||
read();
|
read();
|
||||||
}
|
}
|
||||||
|
|
||||||
ASF::File::~File()
|
ASF::File::~File() {
|
||||||
{
|
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASF::Tag *ASF::File::tag() const
|
ASF::Tag *ASF::File::tag() const {
|
||||||
{
|
return d->tag.get();
|
||||||
return d->tag;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertyMap ASF::File::properties() const
|
ASF::AudioProperties *ASF::File::audioProperties() const {
|
||||||
{
|
return d->properties.get();
|
||||||
return d->tag->properties();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASF::File::removeUnsupportedProperties(const StringList &properties)
|
bool ASF::File::save() {
|
||||||
{
|
|
||||||
d->tag->removeUnsupportedProperties(properties);
|
|
||||||
}
|
|
||||||
|
|
||||||
PropertyMap ASF::File::setProperties(const PropertyMap &properties)
|
if (readOnly()) {
|
||||||
{
|
|
||||||
return d->tag->setProperties(properties);
|
|
||||||
}
|
|
||||||
|
|
||||||
ASF::Properties *ASF::File::audioProperties() const
|
|
||||||
{
|
|
||||||
return d->properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ASF::File::save()
|
|
||||||
{
|
|
||||||
if(readOnly()) {
|
|
||||||
debug("ASF::File::save() -- File is read only.");
|
debug("ASF::File::save() -- File is read only.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!isValid()) {
|
if (!isValid()) {
|
||||||
debug("ASF::File::save() -- Trying to save invalid file.");
|
debug("ASF::File::save() -- Trying to save invalid file.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!d->contentDescriptionObject) {
|
if (!d->contentDescriptionObject) {
|
||||||
d->contentDescriptionObject = new FilePrivate::ContentDescriptionObject();
|
d->contentDescriptionObject.reset(new FilePrivate::ContentDescriptionObject());
|
||||||
d->objects.append(d->contentDescriptionObject);
|
d->objects.append(d->contentDescriptionObject);
|
||||||
}
|
}
|
||||||
if(!d->extendedContentDescriptionObject) {
|
if (!d->extendedContentDescriptionObject) {
|
||||||
d->extendedContentDescriptionObject = new FilePrivate::ExtendedContentDescriptionObject();
|
d->extendedContentDescriptionObject.reset(new FilePrivate::ExtendedContentDescriptionObject());
|
||||||
d->objects.append(d->extendedContentDescriptionObject);
|
d->objects.append(d->extendedContentDescriptionObject);
|
||||||
}
|
}
|
||||||
if(!d->headerExtensionObject) {
|
if (!d->headerExtensionObject) {
|
||||||
d->headerExtensionObject = new FilePrivate::HeaderExtensionObject();
|
d->headerExtensionObject.reset(new FilePrivate::HeaderExtensionObject());
|
||||||
d->objects.append(d->headerExtensionObject);
|
d->objects.append(d->headerExtensionObject);
|
||||||
}
|
}
|
||||||
if(!d->metadataObject) {
|
if (!d->metadataObject) {
|
||||||
d->metadataObject = new FilePrivate::MetadataObject();
|
d->metadataObject.reset(new FilePrivate::MetadataObject());
|
||||||
d->headerExtensionObject->objects.append(d->metadataObject);
|
d->headerExtensionObject->objects.append(d->metadataObject);
|
||||||
}
|
}
|
||||||
if(!d->metadataLibraryObject) {
|
if (!d->metadataLibraryObject) {
|
||||||
d->metadataLibraryObject = new FilePrivate::MetadataLibraryObject();
|
d->metadataLibraryObject.reset(new FilePrivate::MetadataLibraryObject());
|
||||||
d->headerExtensionObject->objects.append(d->metadataLibraryObject);
|
d->headerExtensionObject->objects.append(d->metadataLibraryObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -572,7 +526,7 @@ bool ASF::File::save()
|
|||||||
|
|
||||||
const AttributeListMap allAttributes = d->tag->attributeListMap();
|
const AttributeListMap allAttributes = d->tag->attributeListMap();
|
||||||
|
|
||||||
for(AttributeListMap::ConstIterator it = allAttributes.begin(); it != allAttributes.end(); ++it) {
|
for (AttributeListMap::ConstIterator it = allAttributes.begin(); it != allAttributes.end(); ++it) {
|
||||||
|
|
||||||
const String &name = it->first;
|
const String &name = it->first;
|
||||||
const AttributeList &attributes = it->second;
|
const AttributeList &attributes = it->second;
|
||||||
@@ -580,17 +534,17 @@ bool ASF::File::save()
|
|||||||
bool inExtendedContentDescriptionObject = false;
|
bool inExtendedContentDescriptionObject = false;
|
||||||
bool inMetadataObject = false;
|
bool inMetadataObject = false;
|
||||||
|
|
||||||
for(AttributeList::ConstIterator jt = attributes.begin(); jt != attributes.end(); ++jt) {
|
for (AttributeList::ConstIterator jt = attributes.begin(); jt != attributes.end(); ++jt) {
|
||||||
|
|
||||||
const Attribute &attribute = *jt;
|
const Attribute &attribute = *jt;
|
||||||
const bool largeValue = (attribute.dataSize() > 65535);
|
const bool largeValue = (attribute.dataSize() > 65535);
|
||||||
const bool guid = (attribute.type() == Attribute::GuidType);
|
const bool guid = (attribute.type() == Attribute::GuidType);
|
||||||
|
|
||||||
if(!inExtendedContentDescriptionObject && !guid && !largeValue && attribute.language() == 0 && attribute.stream() == 0) {
|
if (!inExtendedContentDescriptionObject && !guid && !largeValue && attribute.language() == 0 && attribute.stream() == 0) {
|
||||||
d->extendedContentDescriptionObject->attributeData.append(attribute.render(name));
|
d->extendedContentDescriptionObject->attributeData.append(attribute.render(name));
|
||||||
inExtendedContentDescriptionObject = true;
|
inExtendedContentDescriptionObject = true;
|
||||||
}
|
}
|
||||||
else if(!inMetadataObject && !guid && !largeValue && attribute.language() == 0 && attribute.stream() != 0) {
|
else if (!inMetadataObject && !guid && !largeValue && attribute.language() == 0 && attribute.stream() != 0) {
|
||||||
d->metadataObject->attributeData.append(attribute.render(name, 1));
|
d->metadataObject->attributeData.append(attribute.render(name, 1));
|
||||||
inMetadataObject = true;
|
inMetadataObject = true;
|
||||||
}
|
}
|
||||||
@@ -601,105 +555,107 @@ bool ASF::File::save()
|
|||||||
}
|
}
|
||||||
|
|
||||||
ByteVector data;
|
ByteVector data;
|
||||||
for(List<FilePrivate::BaseObject *>::ConstIterator it = d->objects.begin(); it != d->objects.end(); ++it) {
|
for (FilePrivate::ObjectConstIterator it = d->objects.begin(); it != d->objects.end(); ++it) {
|
||||||
data.append((*it)->render(this));
|
data.append((*it)->render(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
seek(16);
|
seek(16);
|
||||||
writeBlock(ByteVector::fromLongLong(data.size() + 30, false));
|
writeBlock(ByteVector::fromUInt64LE(data.size() + 30));
|
||||||
writeBlock(ByteVector::fromUInt(d->objects.size(), false));
|
writeBlock(ByteVector::fromUInt32LE(d->objects.size()));
|
||||||
writeBlock(ByteVector("\x01\x02", 2));
|
writeBlock(ByteVector("\x01\x02", 2));
|
||||||
|
|
||||||
insert(data, 30, static_cast<unsigned long>(d->headerSize - 30));
|
insert(data, 30, static_cast<size_t>(d->headerSize - 30));
|
||||||
|
|
||||||
d->headerSize = data.size() + 30;
|
d->headerSize = data.size() + 30;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// private members
|
// private members
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void ASF::File::read()
|
void ASF::File::read() {
|
||||||
{
|
|
||||||
if(!isValid())
|
if (!isValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(readBlock(16) != headerGuid) {
|
if (readBlock(16) != headerGuid) {
|
||||||
debug("ASF::File::read(): Not an ASF file.");
|
debug("ASF::File::read(): Not an ASF file.");
|
||||||
setValid(false);
|
setValid(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
d->tag = new ASF::Tag();
|
d->tag.reset(new ASF::Tag());
|
||||||
d->properties = new ASF::Properties();
|
d->properties.reset(new ASF::AudioProperties());
|
||||||
|
|
||||||
bool ok;
|
bool ok;
|
||||||
d->headerSize = readQWORD(this, &ok);
|
d->headerSize = readQWORD(this, &ok);
|
||||||
if(!ok) {
|
if (!ok) {
|
||||||
setValid(false);
|
setValid(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int numObjects = readDWORD(this, &ok);
|
int numObjects = readDWORD(this, &ok);
|
||||||
if(!ok) {
|
if (!ok) {
|
||||||
setValid(false);
|
setValid(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
seek(2, Current);
|
seek(2, Current);
|
||||||
|
|
||||||
FilePrivate::FilePropertiesObject *filePropertiesObject = 0;
|
std::shared_ptr<FilePrivate::FilePropertiesObject> filePropertiesObject;
|
||||||
FilePrivate::StreamPropertiesObject *streamPropertiesObject = 0;
|
std::shared_ptr<FilePrivate::StreamPropertiesObject> streamPropertiesObject;
|
||||||
for(int i = 0; i < numObjects; i++) {
|
for (int i = 0; i < numObjects; i++) {
|
||||||
const ByteVector guid = readBlock(16);
|
const ByteVector guid = readBlock(16);
|
||||||
if(guid.size() != 16) {
|
if (guid.size() != 16) {
|
||||||
setValid(false);
|
setValid(false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
long size = (long)readQWORD(this, &ok);
|
long size = static_cast<long>(readQWORD(this, &ok));
|
||||||
if(!ok) {
|
if (!ok) {
|
||||||
setValid(false);
|
setValid(false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
FilePrivate::BaseObject *obj;
|
std::shared_ptr<FilePrivate::BaseObject> obj;
|
||||||
if(guid == filePropertiesGuid) {
|
if (guid == filePropertiesGuid) {
|
||||||
filePropertiesObject = new FilePrivate::FilePropertiesObject();
|
filePropertiesObject.reset(new FilePrivate::FilePropertiesObject());
|
||||||
obj = filePropertiesObject;
|
obj = filePropertiesObject;
|
||||||
}
|
}
|
||||||
else if(guid == streamPropertiesGuid) {
|
else if (guid == streamPropertiesGuid) {
|
||||||
streamPropertiesObject = new FilePrivate::StreamPropertiesObject();
|
streamPropertiesObject.reset(new FilePrivate::StreamPropertiesObject());
|
||||||
obj = streamPropertiesObject;
|
obj = streamPropertiesObject;
|
||||||
}
|
}
|
||||||
else if(guid == contentDescriptionGuid) {
|
else if (guid == contentDescriptionGuid) {
|
||||||
d->contentDescriptionObject = new FilePrivate::ContentDescriptionObject();
|
d->contentDescriptionObject.reset(new FilePrivate::ContentDescriptionObject());
|
||||||
obj = d->contentDescriptionObject;
|
obj = d->contentDescriptionObject;
|
||||||
}
|
}
|
||||||
else if(guid == extendedContentDescriptionGuid) {
|
else if (guid == extendedContentDescriptionGuid) {
|
||||||
d->extendedContentDescriptionObject = new FilePrivate::ExtendedContentDescriptionObject();
|
d->extendedContentDescriptionObject.reset(new FilePrivate::ExtendedContentDescriptionObject());
|
||||||
obj = d->extendedContentDescriptionObject;
|
obj = d->extendedContentDescriptionObject;
|
||||||
}
|
}
|
||||||
else if(guid == headerExtensionGuid) {
|
else if (guid == headerExtensionGuid) {
|
||||||
d->headerExtensionObject = new FilePrivate::HeaderExtensionObject();
|
d->headerExtensionObject.reset(new FilePrivate::HeaderExtensionObject());
|
||||||
obj = d->headerExtensionObject;
|
obj = d->headerExtensionObject;
|
||||||
}
|
}
|
||||||
else if(guid == codecListGuid) {
|
else if (guid == codecListGuid) {
|
||||||
obj = new FilePrivate::CodecListObject();
|
obj.reset(new FilePrivate::CodecListObject());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(guid == contentEncryptionGuid ||
|
if (guid == contentEncryptionGuid ||
|
||||||
guid == extendedContentEncryptionGuid ||
|
guid == extendedContentEncryptionGuid ||
|
||||||
guid == advancedContentEncryptionGuid) {
|
guid == advancedContentEncryptionGuid) {
|
||||||
d->properties->setEncrypted(true);
|
d->properties->setEncrypted(true);
|
||||||
}
|
}
|
||||||
obj = new FilePrivate::UnknownObject(guid);
|
obj.reset(new FilePrivate::UnknownObject(guid));
|
||||||
}
|
}
|
||||||
obj->parse(this, size);
|
obj->parse(this, size);
|
||||||
d->objects.append(obj);
|
d->objects.append(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!filePropertiesObject || !streamPropertiesObject) {
|
if (!filePropertiesObject || !streamPropertiesObject) {
|
||||||
debug("ASF::File::read(): Missing mandatory header objects.");
|
debug("ASF::File::read(): Missing mandatory header objects.");
|
||||||
setValid(false);
|
setValid(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
54
3rdparty/taglib/asf/asffile.h
vendored
54
3rdparty/taglib/asf/asffile.h
vendored
@@ -32,21 +32,20 @@
|
|||||||
#include "asfproperties.h"
|
#include "asfproperties.h"
|
||||||
#include "asftag.h"
|
#include "asftag.h"
|
||||||
|
|
||||||
|
namespace Strawberry_TagLib {
|
||||||
namespace TagLib {
|
namespace TagLib {
|
||||||
|
|
||||||
//! An implementation of ASF (WMA) metadata
|
//! An implementation of ASF (WMA) metadata
|
||||||
namespace ASF {
|
namespace ASF {
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* This implements and provides an interface for ASF files to the
|
* This implements and provides an interface for ASF files to the
|
||||||
* TagLib::Tag and TagLib::AudioProperties interfaces by way of implementing
|
* TagLib::Tag and TagLib::AudioProperties interfaces by way of implementing
|
||||||
* the abstract TagLib::File API as well as providing some additional
|
* the abstract TagLib::File API as well as providing some additional
|
||||||
* information specific to ASF files.
|
* information specific to ASF files.
|
||||||
*/
|
*/
|
||||||
class TAGLIB_EXPORT File : public TagLib::File
|
class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Constructs an ASF file from \a file.
|
* Constructs an ASF file from \a file.
|
||||||
*
|
*
|
||||||
@@ -54,8 +53,7 @@ namespace TagLib {
|
|||||||
* \a propertiesStyle are ignored. The audio properties are always
|
* \a propertiesStyle are ignored. The audio properties are always
|
||||||
* read.
|
* read.
|
||||||
*/
|
*/
|
||||||
File(FileName file, bool readProperties = true,
|
explicit File(FileName file, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average);
|
||||||
Properties::ReadStyle propertiesStyle = Properties::Average);
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Constructs an ASF file from \a stream.
|
* Constructs an ASF file from \a stream.
|
||||||
@@ -67,13 +65,12 @@ namespace TagLib {
|
|||||||
* \note TagLib will *not* take ownership of the stream, the caller is
|
* \note TagLib will *not* take ownership of the stream, the caller is
|
||||||
* responsible for deleting it after the File object.
|
* responsible for deleting it after the File object.
|
||||||
*/
|
*/
|
||||||
File(IOStream *stream, bool readProperties = true,
|
explicit File(IOStream *stream, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average);
|
||||||
Properties::ReadStyle propertiesStyle = Properties::Average);
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Destroys this instance of the File.
|
* Destroys this instance of the File.
|
||||||
*/
|
*/
|
||||||
virtual ~File();
|
~File() override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns a pointer to the ASF tag of the file.
|
* Returns a pointer to the ASF tag of the file.
|
||||||
@@ -85,42 +82,24 @@ namespace TagLib {
|
|||||||
* deleted by the user. It will be deleted when the file (object) is
|
* deleted by the user. It will be deleted when the file (object) is
|
||||||
* destroyed.
|
* destroyed.
|
||||||
*/
|
*/
|
||||||
virtual Tag *tag() const;
|
Tag *tag() const override;
|
||||||
|
|
||||||
/*!
|
|
||||||
* Implements the unified property interface -- export function.
|
|
||||||
*/
|
|
||||||
PropertyMap properties() const;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* Removes unsupported properties. Forwards to the actual Tag's
|
|
||||||
* removeUnsupportedProperties() function.
|
|
||||||
*/
|
|
||||||
void removeUnsupportedProperties(const StringList &properties);
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* Implements the unified property interface -- import function.
|
|
||||||
*/
|
|
||||||
PropertyMap setProperties(const PropertyMap &);
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the ASF audio properties for this file.
|
* Returns the ASF audio properties for this file.
|
||||||
*/
|
*/
|
||||||
virtual Properties *audioProperties() const;
|
AudioProperties *audioProperties() const override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Save the file.
|
* Save the file.
|
||||||
*
|
*
|
||||||
* This returns true if the save was successful.
|
* This returns true if the save was successful.
|
||||||
*/
|
*/
|
||||||
virtual bool save();
|
bool save() override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns whether or not the given \a stream can be opened as an ASF
|
* Returns whether or not the given \a stream can be opened as an ASF file.
|
||||||
* file.
|
|
||||||
*
|
*
|
||||||
* \note This method is designed to do a quick check. The result may
|
* \note This method is designed to do a quick check. The result may not necessarily be correct.
|
||||||
* not necessarily be correct.
|
|
||||||
*/
|
*/
|
||||||
static bool isSupported(IOStream *stream);
|
static bool isSupported(IOStream *stream);
|
||||||
|
|
||||||
@@ -129,10 +108,11 @@ namespace TagLib {
|
|||||||
|
|
||||||
class FilePrivate;
|
class FilePrivate;
|
||||||
FilePrivate *d;
|
FilePrivate *d;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace ASF
|
||||||
|
|
||||||
}
|
} // namespace TagLib
|
||||||
|
} // namespace Strawberry_TagLib
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
157
3rdparty/taglib/asf/asfpicture.cpp
vendored
157
3rdparty/taglib/asf/asfpicture.cpp
vendored
@@ -23,161 +23,146 @@
|
|||||||
* http://www.mozilla.org/MPL/ *
|
* http://www.mozilla.org/MPL/ *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include <taglib.h>
|
#include <memory>
|
||||||
#include <tdebug.h>
|
|
||||||
#include <trefcounter.h>
|
#include "taglib.h"
|
||||||
|
#include "tdebug.h"
|
||||||
|
|
||||||
#include "asfattribute.h"
|
#include "asfattribute.h"
|
||||||
#include "asffile.h"
|
#include "asffile.h"
|
||||||
#include "asfpicture.h"
|
#include "asfpicture.h"
|
||||||
#include "asfutils.h"
|
#include "asfutils.h"
|
||||||
|
|
||||||
using namespace TagLib;
|
using namespace Strawberry_TagLib::TagLib;
|
||||||
|
|
||||||
class ASF::Picture::PicturePrivate : public RefCounter
|
namespace {
|
||||||
{
|
struct PictureData {
|
||||||
public:
|
|
||||||
bool valid;
|
bool valid;
|
||||||
Type type;
|
ASF::Picture::Type type;
|
||||||
String mimeType;
|
String mimeType;
|
||||||
String description;
|
String description;
|
||||||
ByteVector picture;
|
ByteVector picture;
|
||||||
};
|
};
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
class ASF::Picture::PicturePrivate {
|
||||||
|
public:
|
||||||
|
explicit PicturePrivate() : data(new PictureData()) {}
|
||||||
|
|
||||||
|
std::shared_ptr<PictureData> data;
|
||||||
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Picture class members
|
// Picture class members
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
ASF::Picture::Picture() :
|
ASF::Picture::Picture() : d(new PicturePrivate()) {
|
||||||
d(new PicturePrivate())
|
d->data->valid = true;
|
||||||
{
|
|
||||||
d->valid = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ASF::Picture::Picture(const Picture& other) :
|
ASF::Picture::Picture(const Picture& other) : d(new PicturePrivate(*other.d)) {}
|
||||||
d(other.d)
|
|
||||||
{
|
|
||||||
d->ref();
|
|
||||||
}
|
|
||||||
|
|
||||||
ASF::Picture::~Picture()
|
ASF::Picture::~Picture() {
|
||||||
{
|
|
||||||
if(d->deref())
|
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ASF::Picture::isValid() const
|
bool ASF::Picture::isValid() const {
|
||||||
{
|
return d->data->valid;
|
||||||
return d->valid;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String ASF::Picture::mimeType() const
|
String ASF::Picture::mimeType() const {
|
||||||
{
|
return d->data->mimeType;
|
||||||
return d->mimeType;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASF::Picture::setMimeType(const String &value)
|
void ASF::Picture::setMimeType(const String& value) {
|
||||||
{
|
d->data->mimeType = value;
|
||||||
d->mimeType = value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ASF::Picture::Type ASF::Picture::type() const
|
ASF::Picture::Type ASF::Picture::type() const {
|
||||||
{
|
return d->data->type;
|
||||||
return d->type;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASF::Picture::setType(const ASF::Picture::Type& t)
|
void ASF::Picture::setType(const ASF::Picture::Type &t) {
|
||||||
{
|
d->data->type = t;
|
||||||
d->type = t;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String ASF::Picture::description() const
|
String ASF::Picture::description() const {
|
||||||
{
|
return d->data->description;
|
||||||
return d->description;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASF::Picture::setDescription(const String &desc)
|
void ASF::Picture::setDescription(const String& desc) {
|
||||||
{
|
d->data->description = desc;
|
||||||
d->description = desc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ByteVector ASF::Picture::picture() const
|
ByteVector ASF::Picture::picture() const {
|
||||||
{
|
return d->data->picture;
|
||||||
return d->picture;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASF::Picture::setPicture(const ByteVector &p)
|
void ASF::Picture::setPicture(const ByteVector &p) {
|
||||||
{
|
d->data->picture = p;
|
||||||
d->picture = p;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ASF::Picture::dataSize() const
|
int ASF::Picture::dataSize() const {
|
||||||
{
|
return 9 + (d->data->mimeType.length() + d->data->description.length()) * 2 + d->data->picture.size();
|
||||||
return
|
|
||||||
9 + (d->mimeType.length() + d->description.length()) * 2 +
|
|
||||||
d->picture.size();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ASF::Picture& ASF::Picture::operator=(const ASF::Picture& other)
|
ASF::Picture& ASF::Picture::operator=(const ASF::Picture& other) {
|
||||||
{
|
|
||||||
Picture(other).swap(*this);
|
Picture(other).swap(*this);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASF::Picture::swap(Picture &other)
|
void ASF::Picture::swap(Picture& other) {
|
||||||
{
|
|
||||||
using std::swap;
|
using std::swap;
|
||||||
|
|
||||||
swap(d, other.d);
|
swap(d, other.d);
|
||||||
}
|
}
|
||||||
|
|
||||||
ByteVector ASF::Picture::render() const
|
ByteVector ASF::Picture::render() const {
|
||||||
{
|
|
||||||
if(!isValid())
|
if (!isValid())
|
||||||
return ByteVector();
|
return ByteVector();
|
||||||
|
|
||||||
return
|
return ByteVector(static_cast<char>(d->data->type)) + ByteVector::fromUInt32LE(d->data->picture.size()) + renderString(d->data->mimeType) + renderString(d->data->description) + d->data->picture;
|
||||||
ByteVector((char)d->type) +
|
|
||||||
ByteVector::fromUInt(d->picture.size(), false) +
|
|
||||||
renderString(d->mimeType) +
|
|
||||||
renderString(d->description) +
|
|
||||||
d->picture;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASF::Picture::parse(const ByteVector& bytes)
|
void ASF::Picture::parse(const ByteVector &bytes) {
|
||||||
{
|
|
||||||
d->valid = false;
|
d->data->valid = false;
|
||||||
if(bytes.size() < 9)
|
if (bytes.size() < 9)
|
||||||
return;
|
return;
|
||||||
int pos = 0;
|
size_t pos = 0;
|
||||||
d->type = (Type)bytes[0]; ++pos;
|
d->data->type = static_cast<Type>(bytes[0]);
|
||||||
const unsigned int dataLen = bytes.toUInt(pos, false); pos+=4;
|
++pos;
|
||||||
|
const unsigned int dataLen = bytes.toUInt32LE(pos);
|
||||||
|
pos += 4;
|
||||||
|
|
||||||
const ByteVector nullStringTerminator(2, 0);
|
const ByteVector nullStringTerminator(2, 0);
|
||||||
|
|
||||||
int endPos = bytes.find(nullStringTerminator, pos, 2);
|
size_t endPos = bytes.find(nullStringTerminator, pos, 2);
|
||||||
if(endPos < 0)
|
if (endPos == ByteVector::npos())
|
||||||
return;
|
return;
|
||||||
d->mimeType = String(bytes.mid(pos, endPos - pos), String::UTF16LE);
|
d->data->mimeType = String(bytes.mid(pos, endPos - pos), String::UTF16LE);
|
||||||
pos = endPos+2;
|
pos = endPos + 2;
|
||||||
|
|
||||||
endPos = bytes.find(nullStringTerminator, pos, 2);
|
endPos = bytes.find(nullStringTerminator, pos, 2);
|
||||||
if(endPos < 0)
|
if (endPos == ByteVector::npos())
|
||||||
return;
|
return;
|
||||||
d->description = String(bytes.mid(pos, endPos - pos), String::UTF16LE);
|
d->data->description = String(bytes.mid(pos, endPos - pos), String::UTF16LE);
|
||||||
pos = endPos+2;
|
pos = endPos + 2;
|
||||||
|
|
||||||
if(dataLen + pos != bytes.size())
|
if (dataLen + pos != bytes.size())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
d->picture = bytes.mid(pos, dataLen);
|
d->data->picture = bytes.mid(pos, dataLen);
|
||||||
d->valid = true;
|
d->data->valid = true;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ASF::Picture ASF::Picture::fromInvalid()
|
ASF::Picture ASF::Picture::fromInvalid() {
|
||||||
{
|
|
||||||
Picture ret;
|
Picture ret;
|
||||||
ret.d->valid = false;
|
ret.d->data->valid = false;
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
62
3rdparty/taglib/asf/asfpicture.h
vendored
62
3rdparty/taglib/asf/asfpicture.h
vendored
@@ -31,24 +31,22 @@
|
|||||||
#include "taglib_export.h"
|
#include "taglib_export.h"
|
||||||
#include "attachedpictureframe.h"
|
#include "attachedpictureframe.h"
|
||||||
|
|
||||||
namespace TagLib
|
namespace Strawberry_TagLib {
|
||||||
{
|
namespace TagLib {
|
||||||
namespace ASF
|
namespace ASF {
|
||||||
{
|
class Attribute;
|
||||||
|
|
||||||
//! An ASF attached picture interface implementation
|
//! An ASF attached picture interface implementation
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* This is an implementation of ASF attached pictures interface. Pictures may be
|
* This is an implementation of ASF attached pictures interface.
|
||||||
* included in attributes, one per WM/Picture attribute (but there may be multiple WM/Picture
|
* Pictures may be included in attributes, one per WM/Picture attribute (but there may be multiple WM/Picture attribute in a single tag).
|
||||||
* attribute in a single tag). These pictures are usually in either JPEG or
|
* These pictures are usually in either JPEG or PNG format.
|
||||||
* PNG format.
|
|
||||||
* \see Attribute::toPicture()
|
* \see Attribute::toPicture()
|
||||||
* \see Attribute::Attribute(const Picture& picture)
|
* \see Attribute::Attribute(const Picture& picture)
|
||||||
*/
|
*/
|
||||||
class TAGLIB_EXPORT Picture {
|
class TAGLIB_EXPORT Picture {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* This describes the function or content of the picture.
|
* This describes the function or content of the picture.
|
||||||
*/
|
*/
|
||||||
@@ -100,7 +98,7 @@ namespace TagLib
|
|||||||
/*!
|
/*!
|
||||||
* Constructs an empty picture.
|
* Constructs an empty picture.
|
||||||
*/
|
*/
|
||||||
Picture();
|
explicit Picture();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Construct an picture as a copy of \a other.
|
* Construct an picture as a copy of \a other.
|
||||||
@@ -120,7 +118,7 @@ namespace TagLib
|
|||||||
/*!
|
/*!
|
||||||
* Exchanges the content of the Picture by the content of \a other.
|
* Exchanges the content of the Picture by the content of \a other.
|
||||||
*/
|
*/
|
||||||
void swap(Picture &other);
|
void swap(Picture& other);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns true if Picture stores valid picture
|
* Returns true if Picture stores valid picture
|
||||||
@@ -128,8 +126,7 @@ namespace TagLib
|
|||||||
bool isValid() const;
|
bool isValid() const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the mime type of the image. This should in most cases be
|
* Returns the mime type of the image. This should in most cases be "image/png" or "image/jpeg".
|
||||||
* "image/png" or "image/jpeg".
|
|
||||||
* \see setMimeType(const String &)
|
* \see setMimeType(const String &)
|
||||||
* \see picture()
|
* \see picture()
|
||||||
* \see setPicture(const ByteArray&)
|
* \see setPicture(const ByteArray&)
|
||||||
@@ -137,13 +134,12 @@ namespace TagLib
|
|||||||
String mimeType() const;
|
String mimeType() const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Sets the mime type of the image. This should in most cases be
|
* Sets the mime type of the image. This should in most cases be "image/png" or "image/jpeg".
|
||||||
* "image/png" or "image/jpeg".
|
|
||||||
* \see setMimeType(const String &)
|
* \see setMimeType(const String &)
|
||||||
* \see picture()
|
* \see picture()
|
||||||
* \see setPicture(const ByteArray&)
|
* \see setPicture(const ByteArray&)
|
||||||
*/
|
*/
|
||||||
void setMimeType(const String &value);
|
void setMimeType(const String& value);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the type of the image.
|
* Returns the type of the image.
|
||||||
@@ -173,13 +169,12 @@ namespace TagLib
|
|||||||
*
|
*
|
||||||
* \see description()
|
* \see description()
|
||||||
*/
|
*/
|
||||||
void setDescription(const String &desc);
|
void setDescription(const String& desc);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the image data as a ByteVector.
|
* Returns the image data as a ByteVector.
|
||||||
*
|
*
|
||||||
* \note ByteVector has a data() method that returns a const char * which
|
* \note ByteVector has a data() method that returns a const char * which should make it easy to export this data to external programs.
|
||||||
* should make it easy to export this data to external programs.
|
|
||||||
*
|
*
|
||||||
* \see setPicture()
|
* \see setPicture()
|
||||||
* \see mimeType()
|
* \see mimeType()
|
||||||
@@ -187,14 +182,14 @@ namespace TagLib
|
|||||||
ByteVector picture() const;
|
ByteVector picture() const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Sets the image data to \a p. \a p should be of the type specified in
|
* Sets the image data to \a p.
|
||||||
* this frame's mime-type specification.
|
* \a p should be of the type specified in this frame's mime-type specification.
|
||||||
*
|
*
|
||||||
* \see picture()
|
* \see picture()
|
||||||
* \see mimeType()
|
* \see mimeType()
|
||||||
* \see setMimeType()
|
* \see setMimeType()
|
||||||
*/
|
*/
|
||||||
void setPicture(const ByteVector &p);
|
void setPicture(const ByteVector& p);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns picture as binary raw data \a value
|
* Returns picture as binary raw data \a value
|
||||||
@@ -206,17 +201,18 @@ namespace TagLib
|
|||||||
*/
|
*/
|
||||||
int dataSize() const;
|
int dataSize() const;
|
||||||
|
|
||||||
#ifndef DO_NOT_DOCUMENT
|
private:
|
||||||
/* THIS IS PRIVATE, DON'T TOUCH IT! */
|
friend class Attribute;
|
||||||
void parse(const ByteVector& );
|
|
||||||
|
void parse(const ByteVector&);
|
||||||
static Picture fromInvalid();
|
static Picture fromInvalid();
|
||||||
#endif
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class PicturePrivate;
|
class PicturePrivate;
|
||||||
PicturePrivate *d;
|
PicturePrivate* d;
|
||||||
};
|
};
|
||||||
}
|
} // namespace ASF
|
||||||
}
|
} // namespace TagLib
|
||||||
|
} // namespace Strawberry_TagLib
|
||||||
|
|
||||||
#endif // ASFPICTURE_H
|
#endif // ASFPICTURE_H
|
||||||
|
|||||||
98
3rdparty/taglib/asf/asfproperties.cpp
vendored
98
3rdparty/taglib/asf/asfproperties.cpp
vendored
@@ -23,22 +23,20 @@
|
|||||||
* http://www.mozilla.org/MPL/ *
|
* http://www.mozilla.org/MPL/ *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include <tdebug.h>
|
#include "tdebug.h"
|
||||||
#include <tstring.h>
|
#include "tstring.h"
|
||||||
#include "asfproperties.h"
|
#include "asfproperties.h"
|
||||||
|
|
||||||
using namespace TagLib;
|
using namespace Strawberry_TagLib::TagLib;
|
||||||
|
|
||||||
class ASF::Properties::PropertiesPrivate
|
class ASF::AudioProperties::AudioPropertiesPrivate {
|
||||||
{
|
public:
|
||||||
public:
|
explicit AudioPropertiesPrivate() : length(0),
|
||||||
PropertiesPrivate() :
|
|
||||||
length(0),
|
|
||||||
bitrate(0),
|
bitrate(0),
|
||||||
sampleRate(0),
|
sampleRate(0),
|
||||||
channels(0),
|
channels(0),
|
||||||
bitsPerSample(0),
|
bitsPerSample(0),
|
||||||
codec(ASF::Properties::Unknown),
|
codec(ASF::AudioProperties::Unknown),
|
||||||
encrypted(false) {}
|
encrypted(false) {}
|
||||||
|
|
||||||
int length;
|
int length;
|
||||||
@@ -46,7 +44,7 @@ public:
|
|||||||
int sampleRate;
|
int sampleRate;
|
||||||
int channels;
|
int channels;
|
||||||
int bitsPerSample;
|
int bitsPerSample;
|
||||||
ASF::Properties::Codec codec;
|
ASF::AudioProperties::Codec codec;
|
||||||
String codecName;
|
String codecName;
|
||||||
String codecDescription;
|
String codecDescription;
|
||||||
bool encrypted;
|
bool encrypted;
|
||||||
@@ -56,69 +54,50 @@ public:
|
|||||||
// public members
|
// public members
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
ASF::Properties::Properties() :
|
ASF::AudioProperties::AudioProperties() : Strawberry_TagLib::TagLib::AudioProperties(), d(new AudioPropertiesPrivate()) {
|
||||||
AudioProperties(AudioProperties::Average),
|
|
||||||
d(new PropertiesPrivate())
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ASF::Properties::~Properties()
|
ASF::AudioProperties::~AudioProperties() {
|
||||||
{
|
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ASF::Properties::length() const
|
int ASF::AudioProperties::lengthInSeconds() const {
|
||||||
{
|
|
||||||
return lengthInSeconds();
|
|
||||||
}
|
|
||||||
|
|
||||||
int ASF::Properties::lengthInSeconds() const
|
|
||||||
{
|
|
||||||
return d->length / 1000;
|
return d->length / 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ASF::Properties::lengthInMilliseconds() const
|
int ASF::AudioProperties::lengthInMilliseconds() const {
|
||||||
{
|
|
||||||
return d->length;
|
return d->length;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ASF::Properties::bitrate() const
|
int ASF::AudioProperties::bitrate() const {
|
||||||
{
|
|
||||||
return d->bitrate;
|
return d->bitrate;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ASF::Properties::sampleRate() const
|
int ASF::AudioProperties::sampleRate() const {
|
||||||
{
|
|
||||||
return d->sampleRate;
|
return d->sampleRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ASF::Properties::channels() const
|
int ASF::AudioProperties::channels() const {
|
||||||
{
|
|
||||||
return d->channels;
|
return d->channels;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ASF::Properties::bitsPerSample() const
|
int ASF::AudioProperties::bitsPerSample() const {
|
||||||
{
|
|
||||||
return d->bitsPerSample;
|
return d->bitsPerSample;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASF::Properties::Codec ASF::Properties::codec() const
|
ASF::AudioProperties::Codec ASF::AudioProperties::codec() const {
|
||||||
{
|
|
||||||
return d->codec;
|
return d->codec;
|
||||||
}
|
}
|
||||||
|
|
||||||
String ASF::Properties::codecName() const
|
String ASF::AudioProperties::codecName() const {
|
||||||
{
|
|
||||||
return d->codecName;
|
return d->codecName;
|
||||||
}
|
}
|
||||||
|
|
||||||
String ASF::Properties::codecDescription() const
|
String ASF::AudioProperties::codecDescription() const {
|
||||||
{
|
|
||||||
return d->codecDescription;
|
return d->codecDescription;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ASF::Properties::isEncrypted() const
|
bool ASF::AudioProperties::isEncrypted() const {
|
||||||
{
|
|
||||||
return d->encrypted;
|
return d->encrypted;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,40 +105,29 @@ bool ASF::Properties::isEncrypted() const
|
|||||||
// private members
|
// private members
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void ASF::Properties::setLength(int /*length*/)
|
void ASF::AudioProperties::setLengthInMilliseconds(int value) {
|
||||||
{
|
|
||||||
debug("ASF::Properties::setLength() -- This method is deprecated. Do not use.");
|
|
||||||
}
|
|
||||||
|
|
||||||
void ASF::Properties::setLengthInMilliseconds(int value)
|
|
||||||
{
|
|
||||||
d->length = value;
|
d->length = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASF::Properties::setBitrate(int value)
|
void ASF::AudioProperties::setBitrate(int value) {
|
||||||
{
|
|
||||||
d->bitrate = value;
|
d->bitrate = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASF::Properties::setSampleRate(int value)
|
void ASF::AudioProperties::setSampleRate(int value) {
|
||||||
{
|
|
||||||
d->sampleRate = value;
|
d->sampleRate = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASF::Properties::setChannels(int value)
|
void ASF::AudioProperties::setChannels(int value) {
|
||||||
{
|
|
||||||
d->channels = value;
|
d->channels = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASF::Properties::setBitsPerSample(int value)
|
void ASF::AudioProperties::setBitsPerSample(int value) {
|
||||||
{
|
|
||||||
d->bitsPerSample = value;
|
d->bitsPerSample = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASF::Properties::setCodec(int value)
|
void ASF::AudioProperties::setCodec(int value) {
|
||||||
{
|
|
||||||
switch(value)
|
switch (value) {
|
||||||
{
|
|
||||||
case 0x0160:
|
case 0x0160:
|
||||||
d->codec = WMA1;
|
d->codec = WMA1;
|
||||||
break;
|
break;
|
||||||
@@ -176,19 +144,17 @@ void ASF::Properties::setCodec(int value)
|
|||||||
d->codec = Unknown;
|
d->codec = Unknown;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASF::Properties::setCodecName(const String &value)
|
void ASF::AudioProperties::setCodecName(const String &value) {
|
||||||
{
|
|
||||||
d->codecName = value;
|
d->codecName = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASF::Properties::setCodecDescription(const String &value)
|
void ASF::AudioProperties::setCodecDescription(const String &value) {
|
||||||
{
|
|
||||||
d->codecDescription = value;
|
d->codecDescription = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASF::Properties::setEncrypted(bool value)
|
void ASF::AudioProperties::setEncrypted(bool value) {
|
||||||
{
|
|
||||||
d->encrypted = value;
|
d->encrypted = value;
|
||||||
}
|
}
|
||||||
|
|||||||
64
3rdparty/taglib/asf/asfproperties.h
vendored
64
3rdparty/taglib/asf/asfproperties.h
vendored
@@ -30,20 +30,19 @@
|
|||||||
#include "tstring.h"
|
#include "tstring.h"
|
||||||
#include "taglib_export.h"
|
#include "taglib_export.h"
|
||||||
|
|
||||||
|
namespace Strawberry_TagLib {
|
||||||
namespace TagLib {
|
namespace TagLib {
|
||||||
|
namespace ASF {
|
||||||
|
|
||||||
namespace ASF {
|
//! An implementation of ASF audio properties
|
||||||
|
class TAGLIB_EXPORT AudioProperties : public Strawberry_TagLib::TagLib::AudioProperties {
|
||||||
|
friend class File;
|
||||||
|
|
||||||
//! An implementation of ASF audio properties
|
|
||||||
class TAGLIB_EXPORT Properties : public AudioProperties
|
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Audio codec types can be used in ASF file.
|
* Audio codec types can be used in ASF file.
|
||||||
*/
|
*/
|
||||||
enum Codec
|
enum Codec {
|
||||||
{
|
|
||||||
/*!
|
/*!
|
||||||
* Couldn't detect the codec.
|
* Couldn't detect the codec.
|
||||||
*/
|
*/
|
||||||
@@ -73,22 +72,12 @@ namespace TagLib {
|
|||||||
/*!
|
/*!
|
||||||
* Creates an instance of ASF::Properties.
|
* Creates an instance of ASF::Properties.
|
||||||
*/
|
*/
|
||||||
Properties();
|
explicit AudioProperties();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Destroys this ASF::Properties instance.
|
* Destroys this ASF::AudioProperties instance.
|
||||||
*/
|
*/
|
||||||
virtual ~Properties();
|
~AudioProperties() override;
|
||||||
|
|
||||||
/*!
|
|
||||||
* Returns the length of the file in seconds. The length is rounded down to
|
|
||||||
* the nearest whole second.
|
|
||||||
*
|
|
||||||
* \note This method is just an alias of lengthInSeconds().
|
|
||||||
*
|
|
||||||
* \deprecated
|
|
||||||
*/
|
|
||||||
virtual int length() const;
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the length of the file in seconds. The length is rounded down to
|
* Returns the length of the file in seconds. The length is rounded down to
|
||||||
@@ -96,31 +85,29 @@ namespace TagLib {
|
|||||||
*
|
*
|
||||||
* \see lengthInMilliseconds()
|
* \see lengthInMilliseconds()
|
||||||
*/
|
*/
|
||||||
// BIC: make virtual
|
int lengthInSeconds() const override;
|
||||||
int lengthInSeconds() const;
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the length of the file in milliseconds.
|
* Returns the length of the file in milliseconds.
|
||||||
*
|
*
|
||||||
* \see lengthInSeconds()
|
* \see lengthInSeconds()
|
||||||
*/
|
*/
|
||||||
// BIC: make virtual
|
int lengthInMilliseconds() const override;
|
||||||
int lengthInMilliseconds() const;
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the average bit rate of the file in kb/s.
|
* Returns the average bit rate of the file in kb/s.
|
||||||
*/
|
*/
|
||||||
virtual int bitrate() const;
|
int bitrate() const override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the sample rate in Hz.
|
* Returns the sample rate in Hz.
|
||||||
*/
|
*/
|
||||||
virtual int sampleRate() const;
|
int sampleRate() const override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the number of audio channels.
|
* Returns the number of audio channels.
|
||||||
*/
|
*/
|
||||||
virtual int channels() const;
|
int channels() const override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the number of bits per audio sample.
|
* Returns the number of bits per audio sample.
|
||||||
@@ -136,8 +123,7 @@ namespace TagLib {
|
|||||||
Codec codec() const;
|
Codec codec() const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the concrete codec name, for example "Windows Media Audio 9.1"
|
* Returns the concrete codec name, for example "Windows Media Audio 9.1" used in the file if available, otherwise an empty string.
|
||||||
* used in the file if available, otherwise an empty string.
|
|
||||||
*
|
*
|
||||||
* \see codec()
|
* \see codec()
|
||||||
* \see codecDescription()
|
* \see codecDescription()
|
||||||
@@ -146,8 +132,7 @@ namespace TagLib {
|
|||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the codec description, typically contains the encoder settings,
|
* Returns the codec description, typically contains the encoder settings,
|
||||||
* for example "VBR Quality 50, 44kHz, stereo 1-pass VBR" if available,
|
* for example "VBR Quality 50, 44kHz, stereo 1-pass VBR" if available, otherwise an empty string.
|
||||||
* otherwise an empty string.
|
|
||||||
*
|
*
|
||||||
* \see codec()
|
* \see codec()
|
||||||
* \see codecName()
|
* \see codecName()
|
||||||
@@ -159,10 +144,7 @@ namespace TagLib {
|
|||||||
*/
|
*/
|
||||||
bool isEncrypted() const;
|
bool isEncrypted() const;
|
||||||
|
|
||||||
#ifndef DO_NOT_DOCUMENT
|
private:
|
||||||
// deprecated
|
|
||||||
void setLength(int value);
|
|
||||||
|
|
||||||
void setLengthInMilliseconds(int value);
|
void setLengthInMilliseconds(int value);
|
||||||
void setBitrate(int value);
|
void setBitrate(int value);
|
||||||
void setSampleRate(int value);
|
void setSampleRate(int value);
|
||||||
@@ -172,15 +154,15 @@ namespace TagLib {
|
|||||||
void setCodecName(const String &value);
|
void setCodecName(const String &value);
|
||||||
void setCodecDescription(const String &value);
|
void setCodecDescription(const String &value);
|
||||||
void setEncrypted(bool value);
|
void setEncrypted(bool value);
|
||||||
#endif
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class PropertiesPrivate;
|
class AudioPropertiesPrivate;
|
||||||
PropertiesPrivate *d;
|
AudioPropertiesPrivate *d;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace ASF
|
||||||
|
|
||||||
}
|
} // namespace TagLib
|
||||||
|
} // namespace Strawberry_TagLib
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
382
3rdparty/taglib/asf/asftag.cpp
vendored
382
3rdparty/taglib/asf/asftag.cpp
vendored
@@ -23,14 +23,14 @@
|
|||||||
* http://www.mozilla.org/MPL/ *
|
* http://www.mozilla.org/MPL/ *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include <tpropertymap.h>
|
#include "tpicturemap.h"
|
||||||
|
#include "tpropertymap.h"
|
||||||
#include "asftag.h"
|
#include "asftag.h"
|
||||||
|
|
||||||
using namespace TagLib;
|
using namespace Strawberry_TagLib::TagLib;
|
||||||
|
|
||||||
class ASF::Tag::TagPrivate
|
class ASF::Tag::TagPrivate {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
String title;
|
String title;
|
||||||
String artist;
|
String artist;
|
||||||
String copyright;
|
String copyright;
|
||||||
@@ -39,180 +39,320 @@ public:
|
|||||||
AttributeListMap attributeListMap;
|
AttributeListMap attributeListMap;
|
||||||
};
|
};
|
||||||
|
|
||||||
ASF::Tag::Tag() :
|
ASF::Tag::Tag() : d(new TagPrivate()) {}
|
||||||
TagLib::Tag(),
|
|
||||||
d(new TagPrivate())
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
ASF::Tag::~Tag()
|
ASF::Tag::~Tag() {
|
||||||
{
|
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
String ASF::Tag::title() const
|
String ASF::Tag::title() const {
|
||||||
{
|
|
||||||
return d->title;
|
return d->title;
|
||||||
}
|
}
|
||||||
|
|
||||||
String ASF::Tag::artist() const
|
String ASF::Tag::artist() const {
|
||||||
{
|
|
||||||
return d->artist;
|
return d->artist;
|
||||||
}
|
}
|
||||||
|
|
||||||
String ASF::Tag::album() const
|
String ASF::Tag::album() const {
|
||||||
{
|
|
||||||
if(d->attributeListMap.contains("WM/AlbumTitle"))
|
if (d->attributeListMap.contains("WM/AlbumTitle"))
|
||||||
return d->attributeListMap["WM/AlbumTitle"][0].toString();
|
return d->attributeListMap["WM/AlbumTitle"][0].toString();
|
||||||
return String();
|
return String();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String ASF::Tag::copyright() const
|
String ASF::Tag::copyright() const {
|
||||||
{
|
|
||||||
return d->copyright;
|
return d->copyright;
|
||||||
}
|
}
|
||||||
|
|
||||||
String ASF::Tag::comment() const
|
String ASF::Tag::comment() const {
|
||||||
{
|
|
||||||
return d->comment;
|
return d->comment;
|
||||||
}
|
}
|
||||||
|
|
||||||
String ASF::Tag::rating() const
|
String ASF::Tag::rating() const {
|
||||||
{
|
|
||||||
return d->rating;
|
return d->rating;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int ASF::Tag::year() const
|
unsigned int ASF::Tag::year() const {
|
||||||
{
|
|
||||||
if(d->attributeListMap.contains("WM/Year"))
|
if (d->attributeListMap.contains("WM/Year"))
|
||||||
return d->attributeListMap["WM/Year"][0].toString().toInt();
|
return d->attributeListMap["WM/Year"][0].toString().toInt();
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int ASF::Tag::track() const
|
unsigned int ASF::Tag::track() const {
|
||||||
{
|
|
||||||
if(d->attributeListMap.contains("WM/TrackNumber")) {
|
if (d->attributeListMap.contains("WM/TrackNumber")) {
|
||||||
const ASF::Attribute attr = d->attributeListMap["WM/TrackNumber"][0];
|
const ASF::Attribute attr = d->attributeListMap["WM/TrackNumber"][0];
|
||||||
if(attr.type() == ASF::Attribute::DWordType)
|
if (attr.type() == ASF::Attribute::DWordType)
|
||||||
return attr.toUInt();
|
return attr.toUInt();
|
||||||
else
|
else
|
||||||
return attr.toString().toInt();
|
return attr.toString().toInt();
|
||||||
}
|
}
|
||||||
if(d->attributeListMap.contains("WM/Track"))
|
if (d->attributeListMap.contains("WM/Track"))
|
||||||
return d->attributeListMap["WM/Track"][0].toUInt();
|
return d->attributeListMap["WM/Track"][0].toUInt();
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String ASF::Tag::genre() const
|
String ASF::Tag::genre() const {
|
||||||
{
|
|
||||||
if(d->attributeListMap.contains("WM/Genre"))
|
if (d->attributeListMap.contains("WM/Genre"))
|
||||||
return d->attributeListMap["WM/Genre"][0].toString();
|
return d->attributeListMap["WM/Genre"][0].toString();
|
||||||
return String();
|
return String();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASF::Tag::setTitle(const String &value)
|
PictureMap ASF::Tag::pictures() const {
|
||||||
{
|
|
||||||
|
PictureMap map;
|
||||||
|
if (d->attributeListMap.contains("WM/Picture")) {
|
||||||
|
AttributeList list = d->attributeListMap["WM/Picture"];
|
||||||
|
for (AttributeList::ConstIterator it = list.begin(); it != list.end(); ++it) {
|
||||||
|
ASF::Picture asfPicture = (*it).toPicture();
|
||||||
|
TagLib::Picture::Type type;
|
||||||
|
switch (asfPicture.type()) {
|
||||||
|
case ASF::Picture::FileIcon:
|
||||||
|
type = TagLib::Picture::FileIcon;
|
||||||
|
break;
|
||||||
|
case ASF::Picture::OtherFileIcon:
|
||||||
|
type = TagLib::Picture::OtherFileIcon;
|
||||||
|
break;
|
||||||
|
case ASF::Picture::FrontCover:
|
||||||
|
type = TagLib::Picture::FrontCover;
|
||||||
|
break;
|
||||||
|
case ASF::Picture::BackCover:
|
||||||
|
type = TagLib::Picture::BackCover;
|
||||||
|
break;
|
||||||
|
case ASF::Picture::LeafletPage:
|
||||||
|
type = TagLib::Picture::LeafletPage;
|
||||||
|
break;
|
||||||
|
case ASF::Picture::Media:
|
||||||
|
type = TagLib::Picture::Media;
|
||||||
|
break;
|
||||||
|
case ASF::Picture::LeadArtist:
|
||||||
|
type = TagLib::Picture::LeadArtist;
|
||||||
|
break;
|
||||||
|
case ASF::Picture::Artist:
|
||||||
|
type = TagLib::Picture::Artist;
|
||||||
|
break;
|
||||||
|
case ASF::Picture::Conductor:
|
||||||
|
type = TagLib::Picture::Conductor;
|
||||||
|
break;
|
||||||
|
case ASF::Picture::Band:
|
||||||
|
type = TagLib::Picture::Band;
|
||||||
|
break;
|
||||||
|
case ASF::Picture::Composer:
|
||||||
|
type = TagLib::Picture::Composer;
|
||||||
|
break;
|
||||||
|
case ASF::Picture::Lyricist:
|
||||||
|
type = TagLib::Picture::Lyricist;
|
||||||
|
break;
|
||||||
|
case ASF::Picture::RecordingLocation:
|
||||||
|
type = TagLib::Picture::RecordingLocation;
|
||||||
|
break;
|
||||||
|
case ASF::Picture::DuringRecording:
|
||||||
|
type = TagLib::Picture::DuringRecording;
|
||||||
|
break;
|
||||||
|
case ASF::Picture::DuringPerformance:
|
||||||
|
type = TagLib::Picture::DuringPerformance;
|
||||||
|
break;
|
||||||
|
case ASF::Picture::MovieScreenCapture:
|
||||||
|
type = TagLib::Picture::MovieScreenCapture;
|
||||||
|
break;
|
||||||
|
case ASF::Picture::ColouredFish:
|
||||||
|
type = TagLib::Picture::ColouredFish;
|
||||||
|
break;
|
||||||
|
case ASF::Picture::Illustration:
|
||||||
|
type = TagLib::Picture::Illustration;
|
||||||
|
break;
|
||||||
|
case ASF::Picture::BandLogo:
|
||||||
|
type = TagLib::Picture::BandLogo;
|
||||||
|
break;
|
||||||
|
case ASF::Picture::PublisherLogo:
|
||||||
|
type = TagLib::Picture::PublisherLogo;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
type = TagLib::Picture::Other;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
TagLib::Picture picture(asfPicture.picture(), type, asfPicture.mimeType(), asfPicture.description());
|
||||||
|
map.insert(picture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return PictureMap(map);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ASF::Tag::setTitle(const String &value) {
|
||||||
d->title = value;
|
d->title = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASF::Tag::setArtist(const String &value)
|
void ASF::Tag::setArtist(const String &value) {
|
||||||
{
|
|
||||||
d->artist = value;
|
d->artist = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASF::Tag::setCopyright(const String &value)
|
void ASF::Tag::setCopyright(const String &value) {
|
||||||
{
|
|
||||||
d->copyright = value;
|
d->copyright = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASF::Tag::setComment(const String &value)
|
void ASF::Tag::setComment(const String &value) {
|
||||||
{
|
|
||||||
d->comment = value;
|
d->comment = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASF::Tag::setRating(const String &value)
|
void ASF::Tag::setRating(const String &value) {
|
||||||
{
|
|
||||||
d->rating = value;
|
d->rating = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASF::Tag::setAlbum(const String &value)
|
void ASF::Tag::setAlbum(const String &value) {
|
||||||
{
|
|
||||||
setAttribute("WM/AlbumTitle", value);
|
setAttribute("WM/AlbumTitle", value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASF::Tag::setGenre(const String &value)
|
void ASF::Tag::setGenre(const String &value) {
|
||||||
{
|
|
||||||
setAttribute("WM/Genre", value);
|
setAttribute("WM/Genre", value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASF::Tag::setYear(unsigned int value)
|
void ASF::Tag::setYear(unsigned int value) {
|
||||||
{
|
|
||||||
setAttribute("WM/Year", String::number(value));
|
setAttribute("WM/Year", String::number(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASF::Tag::setTrack(unsigned int value)
|
void ASF::Tag::setTrack(unsigned int value) {
|
||||||
{
|
|
||||||
setAttribute("WM/TrackNumber", String::number(value));
|
setAttribute("WM/TrackNumber", String::number(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
ASF::AttributeListMap& ASF::Tag::attributeListMap()
|
void ASF::Tag::setPictures(const PictureMap &l) {
|
||||||
{
|
|
||||||
|
removeItem("WM/Picture");
|
||||||
|
for (PictureMap::ConstIterator pictureMapIt = l.begin(); pictureMapIt != l.end(); ++pictureMapIt) {
|
||||||
|
PictureList list = pictureMapIt->second;
|
||||||
|
for (PictureList::ConstIterator pictureListIt = list.begin(); pictureListIt != list.end(); ++pictureListIt) {
|
||||||
|
const TagLib::Picture picture = (*pictureListIt);
|
||||||
|
ASF::Picture asfPicture;
|
||||||
|
asfPicture.setPicture(picture.data());
|
||||||
|
asfPicture.setMimeType(picture.mime());
|
||||||
|
asfPicture.setDescription(picture.description());
|
||||||
|
switch (picture.type()) {
|
||||||
|
case TagLib::Picture::Other:
|
||||||
|
asfPicture.setType(ASF::Picture::Other);
|
||||||
|
break;
|
||||||
|
case TagLib::Picture::FileIcon:
|
||||||
|
asfPicture.setType(ASF::Picture::FileIcon);
|
||||||
|
break;
|
||||||
|
case TagLib::Picture::OtherFileIcon:
|
||||||
|
asfPicture.setType(ASF::Picture::OtherFileIcon);
|
||||||
|
break;
|
||||||
|
case TagLib::Picture::FrontCover:
|
||||||
|
asfPicture.setType(ASF::Picture::FrontCover);
|
||||||
|
break;
|
||||||
|
case TagLib::Picture::BackCover:
|
||||||
|
asfPicture.setType(ASF::Picture::BackCover);
|
||||||
|
break;
|
||||||
|
case TagLib::Picture::LeafletPage:
|
||||||
|
asfPicture.setType(ASF::Picture::LeafletPage);
|
||||||
|
break;
|
||||||
|
case TagLib::Picture::Media:
|
||||||
|
asfPicture.setType(ASF::Picture::Media);
|
||||||
|
break;
|
||||||
|
case TagLib::Picture::LeadArtist:
|
||||||
|
asfPicture.setType(ASF::Picture::LeadArtist);
|
||||||
|
break;
|
||||||
|
case TagLib::Picture::Artist:
|
||||||
|
asfPicture.setType(ASF::Picture::Artist);
|
||||||
|
break;
|
||||||
|
case TagLib::Picture::Conductor:
|
||||||
|
asfPicture.setType(ASF::Picture::Conductor);
|
||||||
|
break;
|
||||||
|
case TagLib::Picture::Band:
|
||||||
|
asfPicture.setType(ASF::Picture::Band);
|
||||||
|
break;
|
||||||
|
case TagLib::Picture::Composer:
|
||||||
|
asfPicture.setType(ASF::Picture::Composer);
|
||||||
|
break;
|
||||||
|
case TagLib::Picture::Lyricist:
|
||||||
|
asfPicture.setType(ASF::Picture::Lyricist);
|
||||||
|
break;
|
||||||
|
case TagLib::Picture::RecordingLocation:
|
||||||
|
asfPicture.setType(ASF::Picture::RecordingLocation);
|
||||||
|
break;
|
||||||
|
case TagLib::Picture::DuringRecording:
|
||||||
|
asfPicture.setType(ASF::Picture::DuringRecording);
|
||||||
|
break;
|
||||||
|
case TagLib::Picture::DuringPerformance:
|
||||||
|
asfPicture.setType(ASF::Picture::DuringPerformance);
|
||||||
|
break;
|
||||||
|
case TagLib::Picture::MovieScreenCapture:
|
||||||
|
asfPicture.setType(ASF::Picture::MovieScreenCapture);
|
||||||
|
break;
|
||||||
|
case TagLib::Picture::ColouredFish:
|
||||||
|
asfPicture.setType(ASF::Picture::ColouredFish);
|
||||||
|
break;
|
||||||
|
case TagLib::Picture::Illustration:
|
||||||
|
asfPicture.setType(ASF::Picture::Illustration);
|
||||||
|
break;
|
||||||
|
case TagLib::Picture::BandLogo:
|
||||||
|
asfPicture.setType(ASF::Picture::BandLogo);
|
||||||
|
break;
|
||||||
|
case TagLib::Picture::PublisherLogo:
|
||||||
|
asfPicture.setType(ASF::Picture::PublisherLogo);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
addAttribute("WM/Picture", Attribute(asfPicture));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
const ASF::AttributeListMap &ASF::Tag::attributeListMap() const {
|
||||||
return d->attributeListMap;
|
return d->attributeListMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ASF::AttributeListMap &ASF::Tag::attributeListMap() const
|
bool ASF::Tag::contains(const String &key) const {
|
||||||
{
|
|
||||||
return d->attributeListMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ASF::Tag::contains(const String &key) const
|
|
||||||
{
|
|
||||||
return d->attributeListMap.contains(key);
|
return d->attributeListMap.contains(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASF::Tag::removeItem(const String &key)
|
void ASF::Tag::removeItem(const String &key) {
|
||||||
{
|
|
||||||
d->attributeListMap.erase(key);
|
d->attributeListMap.erase(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
ASF::AttributeList ASF::Tag::attribute(const String &name) const
|
ASF::AttributeList ASF::Tag::attribute(const String &name) const {
|
||||||
{
|
|
||||||
return d->attributeListMap[name];
|
return d->attributeListMap[name];
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASF::Tag::setAttribute(const String &name, const Attribute &attribute)
|
void ASF::Tag::setAttribute(const String &name, const Attribute &attribute) {
|
||||||
{
|
|
||||||
AttributeList value;
|
AttributeList value;
|
||||||
value.append(attribute);
|
value.append(attribute);
|
||||||
d->attributeListMap.insert(name, value);
|
d->attributeListMap.insert(name, value);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASF::Tag::setAttribute(const String &name, const AttributeList &values)
|
void ASF::Tag::setAttribute(const String &name, const AttributeList &values) {
|
||||||
{
|
|
||||||
d->attributeListMap.insert(name, values);
|
d->attributeListMap.insert(name, values);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASF::Tag::addAttribute(const String &name, const Attribute &attribute)
|
void ASF::Tag::addAttribute(const String &name, const Attribute &attribute) {
|
||||||
{
|
|
||||||
if(d->attributeListMap.contains(name)) {
|
if (d->attributeListMap.contains(name)) {
|
||||||
d->attributeListMap[name].append(attribute);
|
d->attributeListMap[name].append(attribute);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
setAttribute(name, attribute);
|
setAttribute(name, attribute);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ASF::Tag::isEmpty() const
|
bool ASF::Tag::isEmpty() const {
|
||||||
{
|
|
||||||
return TagLib::Tag::isEmpty() &&
|
return Strawberry_TagLib::TagLib::Tag::isEmpty() &&
|
||||||
copyright().isEmpty() &&
|
copyright().isEmpty() &&
|
||||||
rating().isEmpty() &&
|
rating().isEmpty() &&
|
||||||
d->attributeListMap.isEmpty();
|
d->attributeListMap.isEmpty();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace
|
namespace {
|
||||||
{
|
const char *keyTranslation[][2] = {
|
||||||
const char *keyTranslation[][2] = {
|
|
||||||
{ "WM/AlbumTitle", "ALBUM" },
|
{ "WM/AlbumTitle", "ALBUM" },
|
||||||
{ "WM/AlbumArtist", "ALBUMARTIST" },
|
{ "WM/AlbumArtist", "ALBUMARTIST" },
|
||||||
{ "WM/Composer", "COMPOSER" },
|
{ "WM/Composer", "COMPOSER" },
|
||||||
@@ -252,45 +392,46 @@ namespace
|
|||||||
{ "MusicIP/PUID", "MUSICIP_PUID" },
|
{ "MusicIP/PUID", "MUSICIP_PUID" },
|
||||||
{ "Acoustid/Id", "ACOUSTID_ID" },
|
{ "Acoustid/Id", "ACOUSTID_ID" },
|
||||||
{ "Acoustid/Fingerprint", "ACOUSTID_FINGERPRINT" },
|
{ "Acoustid/Fingerprint", "ACOUSTID_FINGERPRINT" },
|
||||||
};
|
};
|
||||||
const size_t keyTranslationSize = sizeof(keyTranslation) / sizeof(keyTranslation[0]);
|
const size_t keyTranslationSize = sizeof(keyTranslation) / sizeof(keyTranslation[0]);
|
||||||
|
|
||||||
String translateKey(const String &key)
|
String translateKey(const String &key) {
|
||||||
{
|
|
||||||
for(size_t i = 0; i < keyTranslationSize; ++i) {
|
for (size_t i = 0; i < keyTranslationSize; ++i) {
|
||||||
if(key == keyTranslation[i][0])
|
if (key == keyTranslation[i][0])
|
||||||
return keyTranslation[i][1];
|
return keyTranslation[i][1];
|
||||||
}
|
}
|
||||||
|
|
||||||
return String();
|
return String();
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PropertyMap ASF::Tag::properties() const
|
}
|
||||||
{
|
} // namespace
|
||||||
|
|
||||||
|
PropertyMap ASF::Tag::properties() const {
|
||||||
|
|
||||||
PropertyMap props;
|
PropertyMap props;
|
||||||
|
|
||||||
if(!d->title.isEmpty()) {
|
if (!d->title.isEmpty()) {
|
||||||
props["TITLE"] = d->title;
|
props["TITLE"] = d->title;
|
||||||
}
|
}
|
||||||
if(!d->artist.isEmpty()) {
|
if (!d->artist.isEmpty()) {
|
||||||
props["ARTIST"] = d->artist;
|
props["ARTIST"] = d->artist;
|
||||||
}
|
}
|
||||||
if(!d->copyright.isEmpty()) {
|
if (!d->copyright.isEmpty()) {
|
||||||
props["COPYRIGHT"] = d->copyright;
|
props["COPYRIGHT"] = d->copyright;
|
||||||
}
|
}
|
||||||
if(!d->comment.isEmpty()) {
|
if (!d->comment.isEmpty()) {
|
||||||
props["COMMENT"] = d->comment;
|
props["COMMENT"] = d->comment;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASF::AttributeListMap::ConstIterator it = d->attributeListMap.begin();
|
ASF::AttributeListMap::ConstIterator it = d->attributeListMap.begin();
|
||||||
for(; it != d->attributeListMap.end(); ++it) {
|
for (; it != d->attributeListMap.end(); ++it) {
|
||||||
const String key = translateKey(it->first);
|
const String key = translateKey(it->first);
|
||||||
if(!key.isEmpty()) {
|
if (!key.isEmpty()) {
|
||||||
AttributeList::ConstIterator it2 = it->second.begin();
|
AttributeList::ConstIterator it2 = it->second.begin();
|
||||||
for(; it2 != it->second.end(); ++it2) {
|
for (; it2 != it->second.end(); ++it2) {
|
||||||
if(key == "TRACKNUMBER") {
|
if (key == "TRACKNUMBER") {
|
||||||
if(it2->type() == ASF::Attribute::DWordType)
|
if (it2->type() == ASF::Attribute::DWordType)
|
||||||
props.insert(key, String::number(it2->toUInt()));
|
props.insert(key, String::number(it2->toUInt()));
|
||||||
else
|
else
|
||||||
props.insert(key, it2->toString());
|
props.insert(key, it2->toString());
|
||||||
@@ -305,39 +446,41 @@ PropertyMap ASF::Tag::properties() const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return props;
|
return props;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASF::Tag::removeUnsupportedProperties(const StringList &props)
|
void ASF::Tag::removeUnsupportedProperties(const StringList &props) {
|
||||||
{
|
|
||||||
StringList::ConstIterator it = props.begin();
|
StringList::ConstIterator it = props.begin();
|
||||||
for(; it != props.end(); ++it)
|
for (; it != props.end(); ++it)
|
||||||
d->attributeListMap.erase(*it);
|
d->attributeListMap.erase(*it);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertyMap ASF::Tag::setProperties(const PropertyMap &props)
|
PropertyMap ASF::Tag::setProperties(const PropertyMap &props) {
|
||||||
{
|
|
||||||
static Map<String, String> reverseKeyMap;
|
static Map<String, String> reverseKeyMap;
|
||||||
if(reverseKeyMap.isEmpty()) {
|
if (reverseKeyMap.isEmpty()) {
|
||||||
int numKeys = sizeof(keyTranslation) / sizeof(keyTranslation[0]);
|
int numKeys = sizeof(keyTranslation) / sizeof(keyTranslation[0]);
|
||||||
for(int i = 0; i < numKeys; i++) {
|
for (int i = 0; i < numKeys; i++) {
|
||||||
reverseKeyMap[keyTranslation[i][1]] = keyTranslation[i][0];
|
reverseKeyMap[keyTranslation[i][1]] = keyTranslation[i][0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertyMap origProps = properties();
|
PropertyMap origProps = properties();
|
||||||
PropertyMap::ConstIterator it = origProps.begin();
|
PropertyMap::ConstIterator it = origProps.begin();
|
||||||
for(; it != origProps.end(); ++it) {
|
for (; it != origProps.end(); ++it) {
|
||||||
if(!props.contains(it->first) || props[it->first].isEmpty()) {
|
if (!props.contains(it->first) || props[it->first].isEmpty()) {
|
||||||
if(it->first == "TITLE") {
|
if (it->first == "TITLE") {
|
||||||
d->title.clear();
|
d->title.clear();
|
||||||
}
|
}
|
||||||
else if(it->first == "ARTIST") {
|
else if (it->first == "ARTIST") {
|
||||||
d->artist.clear();
|
d->artist.clear();
|
||||||
}
|
}
|
||||||
else if(it->first == "COMMENT") {
|
else if (it->first == "COMMENT") {
|
||||||
d->comment.clear();
|
d->comment.clear();
|
||||||
}
|
}
|
||||||
else if(it->first == "COPYRIGHT") {
|
else if (it->first == "COPYRIGHT") {
|
||||||
d->copyright.clear();
|
d->copyright.clear();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -348,25 +491,25 @@ PropertyMap ASF::Tag::setProperties(const PropertyMap &props)
|
|||||||
|
|
||||||
PropertyMap ignoredProps;
|
PropertyMap ignoredProps;
|
||||||
it = props.begin();
|
it = props.begin();
|
||||||
for(; it != props.end(); ++it) {
|
for (; it != props.end(); ++it) {
|
||||||
if(reverseKeyMap.contains(it->first)) {
|
if (reverseKeyMap.contains(it->first)) {
|
||||||
String name = reverseKeyMap[it->first];
|
String name = reverseKeyMap[it->first];
|
||||||
removeItem(name);
|
removeItem(name);
|
||||||
StringList::ConstIterator it2 = it->second.begin();
|
StringList::ConstIterator it2 = it->second.begin();
|
||||||
for(; it2 != it->second.end(); ++it2) {
|
for (; it2 != it->second.end(); ++it2) {
|
||||||
addAttribute(name, *it2);
|
addAttribute(name, *it2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(it->first == "TITLE") {
|
else if (it->first == "TITLE") {
|
||||||
d->title = it->second.toString();
|
d->title = it->second.toString();
|
||||||
}
|
}
|
||||||
else if(it->first == "ARTIST") {
|
else if (it->first == "ARTIST") {
|
||||||
d->artist = it->second.toString();
|
d->artist = it->second.toString();
|
||||||
}
|
}
|
||||||
else if(it->first == "COMMENT") {
|
else if (it->first == "COMMENT") {
|
||||||
d->comment = it->second.toString();
|
d->comment = it->second.toString();
|
||||||
}
|
}
|
||||||
else if(it->first == "COPYRIGHT") {
|
else if (it->first == "COPYRIGHT") {
|
||||||
d->copyright = it->second.toString();
|
d->copyright = it->second.toString();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -375,4 +518,5 @@ PropertyMap ASF::Tag::setProperties(const PropertyMap &props)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return ignoredProps;
|
return ignoredProps;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
106
3rdparty/taglib/asf/asftag.h
vendored
106
3rdparty/taglib/asf/asftag.h
vendored
@@ -32,49 +32,47 @@
|
|||||||
#include "taglib_export.h"
|
#include "taglib_export.h"
|
||||||
#include "asfattribute.h"
|
#include "asfattribute.h"
|
||||||
|
|
||||||
|
namespace Strawberry_TagLib {
|
||||||
namespace TagLib {
|
namespace TagLib {
|
||||||
|
|
||||||
namespace ASF {
|
namespace ASF {
|
||||||
|
|
||||||
typedef List<Attribute> AttributeList;
|
typedef List<Attribute> AttributeList;
|
||||||
typedef Map<String, AttributeList> AttributeListMap;
|
typedef Map<String, AttributeList> AttributeListMap;
|
||||||
|
|
||||||
class TAGLIB_EXPORT Tag : public TagLib::Tag {
|
class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag {
|
||||||
|
|
||||||
friend class File;
|
friend class File;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
explicit Tag();
|
||||||
|
|
||||||
Tag();
|
~Tag() override;
|
||||||
|
|
||||||
virtual ~Tag();
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the track name.
|
* Returns the track name.
|
||||||
*/
|
*/
|
||||||
virtual String title() const;
|
String title() const override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the artist name.
|
* Returns the artist name.
|
||||||
*/
|
*/
|
||||||
virtual String artist() const;
|
String artist() const override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the album name; if no album name is present in the tag
|
* Returns the album name; if no album name is present in the tag String::null will be returned.
|
||||||
* String::null will be returned.
|
|
||||||
*/
|
*/
|
||||||
virtual String album() const;
|
String album() const override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the track comment.
|
* Returns the track comment.
|
||||||
*/
|
*/
|
||||||
virtual String comment() const;
|
String comment() const override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the genre name; if no genre is present in the tag String::null
|
* Returns the genre name; if no genre is present in the tag String::null will be returned.
|
||||||
* will be returned.
|
|
||||||
*/
|
*/
|
||||||
virtual String genre() const;
|
String genre() const override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the rating.
|
* Returns the rating.
|
||||||
@@ -82,105 +80,97 @@ namespace TagLib {
|
|||||||
virtual String rating() const;
|
virtual String rating() const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the genre name; if no genre is present in the tag String::null
|
* Returns the genre name; if no genre is present in the tag String::null will be returned.
|
||||||
* will be returned.
|
|
||||||
*/
|
*/
|
||||||
virtual String copyright() const;
|
virtual String copyright() const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the year; if there is no year set, this will return 0.
|
* Returns the year; if there is no year set, this will return 0.
|
||||||
*/
|
*/
|
||||||
virtual unsigned int year() const;
|
unsigned int year() const override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the track number; if there is no track number set, this will
|
* Returns the track number; if there is no track number set, this will return 0.
|
||||||
* return 0.
|
|
||||||
*/
|
*/
|
||||||
virtual unsigned int track() const;
|
unsigned int track() const override;
|
||||||
|
|
||||||
|
PictureMap pictures() const override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Sets the title to \a s.
|
* Sets the title to \a s.
|
||||||
*/
|
*/
|
||||||
virtual void setTitle(const String &s);
|
void setTitle(const String &value) override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Sets the artist to \a s.
|
* Sets the artist to \a s.
|
||||||
*/
|
*/
|
||||||
virtual void setArtist(const String &s);
|
void setArtist(const String &value) override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Sets the album to \a s. If \a s is String::null then this value will be
|
* Sets the album to \a s. If \a s is String::null then this value will be cleared.
|
||||||
* cleared.
|
|
||||||
*/
|
*/
|
||||||
virtual void setAlbum(const String &s);
|
void setAlbum(const String &value) override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Sets the comment to \a s.
|
* Sets the comment to \a s.
|
||||||
*/
|
*/
|
||||||
virtual void setComment(const String &s);
|
void setComment(const String &value) override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Sets the rating to \a s.
|
* Sets the rating to \a s.
|
||||||
*/
|
*/
|
||||||
virtual void setRating(const String &s);
|
virtual void setRating(const String &value);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Sets the copyright to \a s.
|
* Sets the copyright to \a s.
|
||||||
*/
|
*/
|
||||||
virtual void setCopyright(const String &s);
|
virtual void setCopyright(const String &value);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Sets the genre to \a s.
|
* Sets the genre to \a s.
|
||||||
*/
|
*/
|
||||||
virtual void setGenre(const String &s);
|
void setGenre(const String &value) override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Sets the year to \a i. If \a s is 0 then this value will be cleared.
|
* Sets the year to \a i. If \a s is 0 then this value will be cleared.
|
||||||
*/
|
*/
|
||||||
virtual void setYear(unsigned int i);
|
void setYear(unsigned int value) override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Sets the track to \a i. If \a s is 0 then this value will be cleared.
|
* Sets the track to \a i. If \a s is 0 then this value will be cleared.
|
||||||
*/
|
*/
|
||||||
virtual void setTrack(unsigned int i);
|
void setTrack(unsigned int value) override;
|
||||||
|
|
||||||
|
void setPictures(const PictureMap&) override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns true if the tag does not contain any data. This should be
|
* Returns true if the tag does not contain any data.
|
||||||
* reimplemented in subclasses that provide more than the basic tagging
|
* This should be reimplemented in subclasses that provide more than the basic tagging abilities in this class.
|
||||||
* abilities in this class.
|
|
||||||
*/
|
*/
|
||||||
virtual bool isEmpty() const;
|
bool isEmpty() const override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \deprecated
|
* Returns a reference to the item list map. This is an AttributeListMap of all of the items in the tag.
|
||||||
*/
|
|
||||||
AttributeListMap &attributeListMap();
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* Returns a reference to the item list map. This is an AttributeListMap of
|
|
||||||
* all of the items in the tag.
|
|
||||||
*/
|
*/
|
||||||
const AttributeListMap &attributeListMap() const;
|
const AttributeListMap &attributeListMap() const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \return True if a value for \a attribute is currently set.
|
* \return True if a value for \a attribute is currently set.
|
||||||
*/
|
*/
|
||||||
bool contains(const String &name) const;
|
bool contains(const String &key) const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Removes the \a key attribute from the tag
|
* Removes the \a key attribute from the tag
|
||||||
*/
|
*/
|
||||||
void removeItem(const String &name);
|
void removeItem(const String &key);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \return The list of values for the key \a name, or an empty list if no
|
* \return The list of values for the key \a name, or an empty list if no values have been set.
|
||||||
* values have been set.
|
|
||||||
*/
|
*/
|
||||||
AttributeList attribute(const String &name) const;
|
AttributeList attribute(const String &name) const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Sets the \a key attribute to the value of \a attribute. If an attribute
|
* Sets the \a key attribute to the value of \a attribute. If an attribute with the \a key is already present, it will be replaced.
|
||||||
* with the \a key is already present, it will be replaced.
|
|
||||||
*/
|
*/
|
||||||
void setAttribute(const String &name, const Attribute &attribute);
|
void setAttribute(const String &name, const Attribute &attribute);
|
||||||
|
|
||||||
@@ -195,15 +185,17 @@ namespace TagLib {
|
|||||||
*/
|
*/
|
||||||
void addAttribute(const String &name, const Attribute &attribute);
|
void addAttribute(const String &name, const Attribute &attribute);
|
||||||
|
|
||||||
PropertyMap properties() const;
|
PropertyMap properties() const override;
|
||||||
void removeUnsupportedProperties(const StringList& properties);
|
void removeUnsupportedProperties(const StringList &props) override;
|
||||||
PropertyMap setProperties(const PropertyMap &properties);
|
PropertyMap setProperties(const PropertyMap &props) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
class TagPrivate;
|
class TagPrivate;
|
||||||
TagPrivate *d;
|
TagPrivate *d;
|
||||||
};
|
};
|
||||||
}
|
|
||||||
}
|
} // namespace ASF
|
||||||
|
} // namespace TagLib
|
||||||
|
} // namespace Strawberry_TagLib
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
84
3rdparty/taglib/asf/asfutils.h
vendored
84
3rdparty/taglib/asf/asfutils.h
vendored
@@ -30,75 +30,71 @@
|
|||||||
|
|
||||||
#ifndef DO_NOT_DOCUMENT // tell Doxygen not to document this header
|
#ifndef DO_NOT_DOCUMENT // tell Doxygen not to document this header
|
||||||
|
|
||||||
namespace TagLib
|
namespace Strawberry_TagLib {
|
||||||
{
|
namespace TagLib {
|
||||||
namespace ASF
|
namespace ASF {
|
||||||
{
|
namespace {
|
||||||
namespace
|
|
||||||
{
|
|
||||||
|
|
||||||
inline unsigned short readWORD(File *file, bool *ok = 0)
|
inline unsigned short readWORD(File *file, bool *ok = nullptr) {
|
||||||
{
|
|
||||||
const ByteVector v = file->readBlock(2);
|
const ByteVector v = file->readBlock(2);
|
||||||
if(v.size() != 2) {
|
if (v.size() != 2) {
|
||||||
if(ok) *ok = false;
|
if (ok) *ok = false;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if(ok) *ok = true;
|
if (ok) *ok = true;
|
||||||
return v.toUShort(false);
|
return v.toUInt16LE(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline unsigned int readDWORD(File *file, bool *ok = 0)
|
inline unsigned int readDWORD(File *file, bool *ok = nullptr) {
|
||||||
{
|
|
||||||
const ByteVector v = file->readBlock(4);
|
const ByteVector v = file->readBlock(4);
|
||||||
if(v.size() != 4) {
|
if (v.size() != 4) {
|
||||||
if(ok) *ok = false;
|
if (ok) *ok = false;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if(ok) *ok = true;
|
if (ok) *ok = true;
|
||||||
return v.toUInt(false);
|
return v.toUInt32LE(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline long long readQWORD(File *file, bool *ok = 0)
|
inline long long readQWORD(File *file, bool *ok = nullptr) {
|
||||||
{
|
|
||||||
const ByteVector v = file->readBlock(8);
|
const ByteVector v = file->readBlock(8);
|
||||||
if(v.size() != 8) {
|
if (v.size() != 8) {
|
||||||
if(ok) *ok = false;
|
if (ok) *ok = false;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if(ok) *ok = true;
|
if (ok) *ok = true;
|
||||||
return v.toLongLong(false);
|
return v.toInt64LE(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline String readString(File *file, int length) {
|
||||||
|
|
||||||
inline String readString(File *file, int length)
|
|
||||||
{
|
|
||||||
ByteVector data = file->readBlock(length);
|
ByteVector data = file->readBlock(length);
|
||||||
unsigned int size = data.size();
|
size_t size = data.size();
|
||||||
while (size >= 2) {
|
while (size >= 2) {
|
||||||
if(data[size - 1] != '\0' || data[size - 2] != '\0') {
|
if (data[size - 1] != '\0' || data[size - 2] != '\0') {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
size -= 2;
|
size -= 2;
|
||||||
}
|
}
|
||||||
if(size != data.size()) {
|
if (size != data.size()) {
|
||||||
data.resize(size);
|
data.resize(size);
|
||||||
}
|
}
|
||||||
return String(data, String::UTF16LE);
|
return String(data, String::UTF16LE);
|
||||||
}
|
|
||||||
|
|
||||||
inline ByteVector renderString(const String &str, bool includeLength = false)
|
|
||||||
{
|
|
||||||
ByteVector data = str.data(String::UTF16LE) + ByteVector::fromShort(0, false);
|
|
||||||
if(includeLength) {
|
|
||||||
data = ByteVector::fromShort(data.size(), false) + data;
|
|
||||||
}
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline ByteVector renderString(const String &str, bool includeLength = false) {
|
||||||
|
ByteVector data = str.data(String::UTF16LE) + ByteVector::fromUInt16LE(0);
|
||||||
|
if (includeLength) {
|
||||||
|
data = ByteVector::fromUInt16LE(data.size()) + data;
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
} // namespace ASF
|
||||||
|
} // namespace TagLib
|
||||||
|
} // namespace Strawberry_TagLib
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
86
3rdparty/taglib/audioproperties.cpp
vendored
86
3rdparty/taglib/audioproperties.cpp
vendored
@@ -23,95 +23,31 @@
|
|||||||
* http://www.mozilla.org/MPL/ *
|
* http://www.mozilla.org/MPL/ *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include <tbytevector.h>
|
#include "tstringlist.h"
|
||||||
|
|
||||||
#include "aiffproperties.h"
|
|
||||||
#include "apeproperties.h"
|
|
||||||
#include "asfproperties.h"
|
|
||||||
#include "flacproperties.h"
|
|
||||||
#include "mp4properties.h"
|
|
||||||
#include "mpcproperties.h"
|
|
||||||
#include "mpegproperties.h"
|
|
||||||
#include "opusproperties.h"
|
|
||||||
#include "speexproperties.h"
|
|
||||||
#include "trueaudioproperties.h"
|
|
||||||
#include "vorbisproperties.h"
|
|
||||||
#include "wavproperties.h"
|
|
||||||
#include "wavpackproperties.h"
|
|
||||||
#include "dsfproperties.h"
|
|
||||||
#include "dsdiffproperties.h"
|
|
||||||
|
|
||||||
#include "audioproperties.h"
|
#include "audioproperties.h"
|
||||||
|
|
||||||
using namespace TagLib;
|
using namespace Strawberry_TagLib::TagLib;
|
||||||
|
|
||||||
// This macro is a workaround for the fact that we can't add virtual functions.
|
|
||||||
// Should be true virtual functions in taglib2.
|
|
||||||
|
|
||||||
#define VIRTUAL_FUNCTION_WORKAROUND(function_name, default_value) \
|
|
||||||
if(dynamic_cast<const APE::Properties*>(this)) \
|
|
||||||
return dynamic_cast<const APE::Properties*>(this)->function_name(); \
|
|
||||||
else if(dynamic_cast<const ASF::Properties*>(this)) \
|
|
||||||
return dynamic_cast<const ASF::Properties*>(this)->function_name(); \
|
|
||||||
else if(dynamic_cast<const FLAC::Properties*>(this)) \
|
|
||||||
return dynamic_cast<const FLAC::Properties*>(this)->function_name(); \
|
|
||||||
else if(dynamic_cast<const MP4::Properties*>(this)) \
|
|
||||||
return dynamic_cast<const MP4::Properties*>(this)->function_name(); \
|
|
||||||
else if(dynamic_cast<const MPC::Properties*>(this)) \
|
|
||||||
return dynamic_cast<const MPC::Properties*>(this)->function_name(); \
|
|
||||||
else if(dynamic_cast<const MPEG::Properties*>(this)) \
|
|
||||||
return dynamic_cast<const MPEG::Properties*>(this)->function_name(); \
|
|
||||||
else if(dynamic_cast<const Ogg::Opus::Properties*>(this)) \
|
|
||||||
return dynamic_cast<const Ogg::Opus::Properties*>(this)->function_name(); \
|
|
||||||
else if(dynamic_cast<const Ogg::Speex::Properties*>(this)) \
|
|
||||||
return dynamic_cast<const Ogg::Speex::Properties*>(this)->function_name(); \
|
|
||||||
else if(dynamic_cast<const TrueAudio::Properties*>(this)) \
|
|
||||||
return dynamic_cast<const TrueAudio::Properties*>(this)->function_name(); \
|
|
||||||
else if(dynamic_cast<const RIFF::AIFF::Properties*>(this)) \
|
|
||||||
return dynamic_cast<const RIFF::AIFF::Properties*>(this)->function_name(); \
|
|
||||||
else if(dynamic_cast<const RIFF::WAV::Properties*>(this)) \
|
|
||||||
return dynamic_cast<const RIFF::WAV::Properties*>(this)->function_name(); \
|
|
||||||
else if(dynamic_cast<const Vorbis::Properties*>(this)) \
|
|
||||||
return dynamic_cast<const Vorbis::Properties*>(this)->function_name(); \
|
|
||||||
else if(dynamic_cast<const WavPack::Properties*>(this)) \
|
|
||||||
return dynamic_cast<const WavPack::Properties*>(this)->function_name(); \
|
|
||||||
else if(dynamic_cast<const DSF::Properties*>(this)) \
|
|
||||||
return dynamic_cast<const DSF::Properties*>(this)->function_name(); \
|
|
||||||
else if(dynamic_cast<const DSDIFF::Properties*>(this)) \
|
|
||||||
return dynamic_cast<const DSDIFF::Properties*>(this)->function_name(); \
|
|
||||||
else \
|
|
||||||
return (default_value);
|
|
||||||
|
|
||||||
class AudioProperties::AudioPropertiesPrivate
|
|
||||||
{
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// public methods
|
// public methods
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
AudioProperties::~AudioProperties()
|
AudioProperties::~AudioProperties() {}
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
int AudioProperties::lengthInSeconds() const
|
String AudioProperties::toString() const {
|
||||||
{
|
|
||||||
VIRTUAL_FUNCTION_WORKAROUND(lengthInSeconds, 0)
|
StringList desc;
|
||||||
}
|
desc.append("Audio");
|
||||||
|
desc.append(String::number(lengthInSeconds()) + " seconds");
|
||||||
|
desc.append(String::number(bitrate()) + " kbps");
|
||||||
|
return desc.toString(", ");
|
||||||
|
|
||||||
int AudioProperties::lengthInMilliseconds() const
|
|
||||||
{
|
|
||||||
VIRTUAL_FUNCTION_WORKAROUND(lengthInMilliseconds, 0)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// protected methods
|
// protected methods
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
AudioProperties::AudioProperties(ReadStyle) :
|
AudioProperties::AudioProperties() : d(nullptr) {}
|
||||||
d(0)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
69
3rdparty/taglib/audioproperties.h
vendored
69
3rdparty/taglib/audioproperties.h
vendored
@@ -27,28 +27,27 @@
|
|||||||
#define TAGLIB_AUDIOPROPERTIES_H
|
#define TAGLIB_AUDIOPROPERTIES_H
|
||||||
|
|
||||||
#include "taglib_export.h"
|
#include "taglib_export.h"
|
||||||
|
#include "tstring.h"
|
||||||
|
|
||||||
|
namespace Strawberry_TagLib {
|
||||||
namespace TagLib {
|
namespace TagLib {
|
||||||
|
|
||||||
//! A simple, abstract interface to common audio properties
|
//! A simple, abstract interface to common audio properties
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* The values here are common to most audio formats. For more specific, codec
|
* The values here are common to most audio formats.
|
||||||
* dependent values, please see see the subclasses APIs. This is meant to
|
* For more specific, codec dependent values, please see see the subclasses APIs.
|
||||||
* compliment the TagLib::File and TagLib::Tag APIs in providing a simple
|
* This is meant to compliment the TagLib::File and TagLib::Tag APIs in providing a simple
|
||||||
* interface that is sufficient for most applications.
|
* interface that is sufficient for most applications.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class TAGLIB_EXPORT AudioProperties
|
class TAGLIB_EXPORT AudioProperties {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Reading audio properties from a file can sometimes be very time consuming
|
* Reading audio properties from a file can sometimes be very time consuming
|
||||||
* and for the most accurate results can often involve reading the entire
|
* and for the most accurate results can often involve reading the entire file.
|
||||||
* file. Because in many situations speed is critical or the accuracy of the
|
* Because in many situations speed is critical or the accuracy of the values
|
||||||
* values is not particularly important this allows the level of desired
|
* is not particularly important this allows the level of desired accuracy to be set.
|
||||||
* accuracy to be set.
|
|
||||||
*/
|
*/
|
||||||
enum ReadStyle {
|
enum ReadStyle {
|
||||||
//! Read as little of the file as possible
|
//! Read as little of the file as possible
|
||||||
@@ -65,31 +64,22 @@ namespace TagLib {
|
|||||||
virtual ~AudioProperties();
|
virtual ~AudioProperties();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the length of the file in seconds.
|
* Returns the length of the file in seconds. The length is rounded down to the nearest whole second.
|
||||||
*/
|
|
||||||
virtual int length() const = 0;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* Returns the length of the file in seconds. The length is rounded down to
|
|
||||||
* the nearest whole second.
|
|
||||||
*
|
*
|
||||||
* \see lengthInMilliseconds()
|
* \see lengthInMilliseconds()
|
||||||
*/
|
*/
|
||||||
// BIC: make virtual
|
virtual int lengthInSeconds() const = 0;
|
||||||
int lengthInSeconds() const;
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the length of the file in milliseconds.
|
* Returns the length of the file in milliseconds.
|
||||||
*
|
*
|
||||||
* \see lengthInSeconds()
|
* \see lengthInSeconds()
|
||||||
*/
|
*/
|
||||||
// BIC: make virtual
|
virtual int lengthInMilliseconds() const = 0;
|
||||||
int lengthInMilliseconds() const;
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the most appropriate bit rate for the file in kb/s. For constant
|
* Returns the most appropriate bit rate for the file in kb/s. For constant bitrate formats this is simply the bitrate of the file.
|
||||||
* bitrate formats this is simply the bitrate of the file. For variable
|
* For variable bitrate formats this is either the average or nominal bitrate.
|
||||||
* bitrate formats this is either the average or nominal bitrate.
|
|
||||||
*/
|
*/
|
||||||
virtual int bitrate() const = 0;
|
virtual int bitrate() const = 0;
|
||||||
|
|
||||||
@@ -103,25 +93,28 @@ namespace TagLib {
|
|||||||
*/
|
*/
|
||||||
virtual int channels() const = 0;
|
virtual int channels() const = 0;
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Construct an audio properties instance. This is protected as this class
|
* Returns description of the audio file.
|
||||||
* should not be instantiated directly, but should be instantiated via its
|
|
||||||
* subclasses and can be fetched from the FileRef or File APIs.
|
|
||||||
*
|
|
||||||
* \see ReadStyle
|
|
||||||
*/
|
*/
|
||||||
AudioProperties(ReadStyle style);
|
virtual String toString() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/*!
|
||||||
|
* Construct an audio properties instance.
|
||||||
|
* This is protected as this class should not be instantiated directly,
|
||||||
|
* but should be instantiated via its subclasses and can be fetched from the FileRef or File APIs.
|
||||||
|
*/
|
||||||
|
explicit AudioProperties();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AudioProperties(const AudioProperties &);
|
AudioProperties(const AudioProperties&);
|
||||||
AudioProperties &operator=(const AudioProperties &);
|
AudioProperties &operator=(const AudioProperties&);
|
||||||
|
|
||||||
class AudioPropertiesPrivate;
|
class AudioPropertiesPrivate;
|
||||||
AudioPropertiesPrivate *d;
|
AudioPropertiesPrivate *d;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace TagLib
|
||||||
|
} // namespace Strawberry_TagLib
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
105
3rdparty/taglib/dsdiff/dsdiffdiintag.cpp
vendored
105
3rdparty/taglib/dsdiff/dsdiffdiintag.cpp
vendored
@@ -26,137 +26,122 @@
|
|||||||
#include "dsdiffdiintag.h"
|
#include "dsdiffdiintag.h"
|
||||||
#include "tstringlist.h"
|
#include "tstringlist.h"
|
||||||
#include "tpropertymap.h"
|
#include "tpropertymap.h"
|
||||||
|
#include "tpicturemap.h"
|
||||||
|
|
||||||
using namespace TagLib;
|
using namespace Strawberry_TagLib::TagLib;
|
||||||
using namespace DSDIFF::DIIN;
|
using namespace DSDIFF::DIIN;
|
||||||
|
|
||||||
class DSDIFF::DIIN::Tag::TagPrivate
|
class DSDIFF::DIIN::Tag::TagPrivate {
|
||||||
{
|
public:
|
||||||
public:
|
TagPrivate() {
|
||||||
TagPrivate()
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String title;
|
String title;
|
||||||
String artist;
|
String artist;
|
||||||
};
|
};
|
||||||
|
|
||||||
DSDIFF::DIIN::Tag::Tag() : TagLib::Tag()
|
DSDIFF::DIIN::Tag::Tag() {
|
||||||
{
|
|
||||||
d = new TagPrivate;
|
d = new TagPrivate;
|
||||||
}
|
}
|
||||||
|
|
||||||
DSDIFF::DIIN::Tag::~Tag()
|
DSDIFF::DIIN::Tag::~Tag() {
|
||||||
{
|
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
String DSDIFF::DIIN::Tag::title() const
|
String DSDIFF::DIIN::Tag::title() const {
|
||||||
{
|
|
||||||
return d->title;
|
return d->title;
|
||||||
}
|
}
|
||||||
|
|
||||||
String DSDIFF::DIIN::Tag::artist() const
|
String DSDIFF::DIIN::Tag::artist() const {
|
||||||
{
|
|
||||||
return d->artist;
|
return d->artist;
|
||||||
}
|
}
|
||||||
|
|
||||||
String DSDIFF::DIIN::Tag::album() const
|
String DSDIFF::DIIN::Tag::album() const {
|
||||||
{
|
|
||||||
return String();
|
return String();
|
||||||
}
|
}
|
||||||
|
|
||||||
String DSDIFF::DIIN::Tag::comment() const
|
String DSDIFF::DIIN::Tag::comment() const {
|
||||||
{
|
|
||||||
return String();
|
return String();
|
||||||
}
|
}
|
||||||
|
|
||||||
String DSDIFF::DIIN::Tag::genre() const
|
String DSDIFF::DIIN::Tag::genre() const {
|
||||||
{
|
|
||||||
return String();
|
return String();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int DSDIFF::DIIN::Tag::year() const
|
unsigned int DSDIFF::DIIN::Tag::year() const {
|
||||||
{
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int DSDIFF::DIIN::Tag::track() const
|
unsigned int DSDIFF::DIIN::Tag::track() const {
|
||||||
{
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DSDIFF::DIIN::Tag::setTitle(const String &title)
|
PictureMap DSDIFF::DIIN::Tag::pictures() const {
|
||||||
{
|
return PictureMap();
|
||||||
if(title.isNull() || title.isEmpty())
|
}
|
||||||
d->title = String();
|
|
||||||
else
|
void DSDIFF::DIIN::Tag::setTitle(const String &title) {
|
||||||
|
|
||||||
d->title = title;
|
d->title = title;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DSDIFF::DIIN::Tag::setArtist(const String &artist)
|
void DSDIFF::DIIN::Tag::setArtist(const String &artist) {
|
||||||
{
|
|
||||||
if(artist.isNull() || artist.isEmpty())
|
|
||||||
d->artist = String();
|
|
||||||
else
|
|
||||||
d->artist = artist;
|
d->artist = artist;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DSDIFF::DIIN::Tag::setAlbum(const String &)
|
void DSDIFF::DIIN::Tag::setAlbum(const String &) {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void DSDIFF::DIIN::Tag::setComment(const String &)
|
void DSDIFF::DIIN::Tag::setComment(const String &) {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void DSDIFF::DIIN::Tag::setGenre(const String &)
|
void DSDIFF::DIIN::Tag::setGenre(const String &) {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void DSDIFF::DIIN::Tag::setYear(unsigned int)
|
void DSDIFF::DIIN::Tag::setYear(unsigned int) {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void DSDIFF::DIIN::Tag::setTrack(unsigned int)
|
void DSDIFF::DIIN::Tag::setTrack(unsigned int) {}
|
||||||
{
|
|
||||||
}
|
void DSDIFF::DIIN::Tag::setPictures(const PictureMap&) {}
|
||||||
|
|
||||||
|
PropertyMap DSDIFF::DIIN::Tag::properties() const {
|
||||||
|
|
||||||
PropertyMap DSDIFF::DIIN::Tag::properties() const
|
|
||||||
{
|
|
||||||
PropertyMap properties;
|
PropertyMap properties;
|
||||||
properties["TITLE"] = d->title;
|
properties["TITLE"] = d->title;
|
||||||
properties["ARTIST"] = d->artist;
|
properties["ARTIST"] = d->artist;
|
||||||
return properties;
|
return properties;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertyMap DSDIFF::DIIN::Tag::setProperties(const PropertyMap &origProps)
|
PropertyMap DSDIFF::DIIN::Tag::setProperties(const PropertyMap &origProps) {
|
||||||
{
|
|
||||||
PropertyMap properties(origProps);
|
PropertyMap properties(origProps);
|
||||||
properties.removeEmpty();
|
properties.removeEmpty();
|
||||||
StringList oneValueSet;
|
StringList oneValueSet;
|
||||||
|
|
||||||
if(properties.contains("TITLE")) {
|
if (properties.contains("TITLE")) {
|
||||||
d->title = properties["TITLE"].front();
|
d->title = properties["TITLE"].front();
|
||||||
oneValueSet.append("TITLE");
|
oneValueSet.append("TITLE");
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
d->title = String();
|
d->title = String();
|
||||||
|
|
||||||
if(properties.contains("ARTIST")) {
|
if (properties.contains("ARTIST")) {
|
||||||
d->artist = properties["ARTIST"].front();
|
d->artist = properties["ARTIST"].front();
|
||||||
oneValueSet.append("ARTIST");
|
oneValueSet.append("ARTIST");
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
d->artist = String();
|
d->artist = String();
|
||||||
|
|
||||||
// for each tag that has been set above, remove the first entry in the corresponding
|
// for each tag that has been set above, remove the first entry in the corresponding
|
||||||
// value list. The others will be returned as unsupported by this format.
|
// value list. The others will be returned as unsupported by this format.
|
||||||
for(StringList::Iterator it = oneValueSet.begin(); it != oneValueSet.end(); ++it) {
|
for (StringList::Iterator it = oneValueSet.begin(); it != oneValueSet.end(); ++it) {
|
||||||
if(properties[*it].size() == 1)
|
if (properties[*it].size() == 1)
|
||||||
properties.erase(*it);
|
properties.erase(*it);
|
||||||
else
|
else
|
||||||
properties[*it].erase(properties[*it].begin());
|
properties[*it].erase(properties[*it].begin());
|
||||||
}
|
}
|
||||||
|
|
||||||
return properties;
|
return properties;
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
88
3rdparty/taglib/dsdiff/dsdiffdiintag.h
vendored
88
3rdparty/taglib/dsdiff/dsdiffdiintag.h
vendored
@@ -28,112 +28,116 @@
|
|||||||
|
|
||||||
#include "tag.h"
|
#include "tag.h"
|
||||||
|
|
||||||
|
namespace Strawberry_TagLib {
|
||||||
namespace TagLib {
|
namespace TagLib {
|
||||||
|
namespace DSDIFF {
|
||||||
|
namespace DIIN {
|
||||||
|
|
||||||
namespace DSDIFF {
|
/*!
|
||||||
|
|
||||||
namespace DIIN {
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* Tags from the Edited Master Chunk Info
|
* Tags from the Edited Master Chunk Info
|
||||||
*
|
*
|
||||||
* Only Title and Artist tags are supported
|
* Only Title and Artist tags are supported
|
||||||
*/
|
*/
|
||||||
class TAGLIB_EXPORT Tag : public TagLib::Tag
|
|
||||||
{
|
class TAGLIB_EXPORT Tag : public Strawberry_TagLib::TagLib::Tag {
|
||||||
public:
|
public:
|
||||||
Tag();
|
explicit Tag();
|
||||||
virtual ~Tag();
|
~Tag() override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the track name; if no track name is present in the tag
|
* Returns the track name; if no track name is present in the tag String() will be returned.
|
||||||
* String() will be returned.
|
|
||||||
*/
|
*/
|
||||||
String title() const;
|
String title() const override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the artist name; if no artist name is present in the tag
|
* Returns the artist name; if no artist name is present in the tag String() will be returned.
|
||||||
* String() will be returned.
|
|
||||||
*/
|
*/
|
||||||
String artist() const;
|
String artist() const override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Not supported. Therefore always returns String().
|
* Not supported. Therefore always returns String().
|
||||||
*/
|
*/
|
||||||
String album() const;
|
String album() const override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Not supported. Therefore always returns String().
|
* Not supported. Therefore always returns String().
|
||||||
*/
|
*/
|
||||||
String comment() const;
|
String comment() const override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Not supported. Therefore always returns String().
|
* Not supported. Therefore always returns String().
|
||||||
*/
|
*/
|
||||||
String genre() const;
|
String genre() const override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Not supported. Therefore always returns 0.
|
* Not supported. Therefore always returns 0.
|
||||||
*/
|
*/
|
||||||
unsigned int year() const;
|
unsigned int year() const override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Not supported. Therefore always returns 0.
|
* Not supported. Therefore always returns 0.
|
||||||
*/
|
*/
|
||||||
unsigned int track() const;
|
unsigned int track() const override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Sets the title to \a title. If \a title is String() then this
|
* Not supported. Therefore always returns an empty list.
|
||||||
* value will be cleared.
|
|
||||||
*/
|
*/
|
||||||
void setTitle(const String &title);
|
PictureMap pictures() const override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Sets the artist to \a artist. If \a artist is String() then this
|
* Sets the title to \a title. If \a title is String() then this value will be cleared.
|
||||||
* value will be cleared.
|
|
||||||
*/
|
*/
|
||||||
void setArtist(const String &artist);
|
void setTitle(const String &title) override;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the artist to \a artist. If \a artist is String() then this value will be cleared.
|
||||||
|
*/
|
||||||
|
void setArtist(const String &artist) override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Not supported and therefore ignored.
|
* Not supported and therefore ignored.
|
||||||
*/
|
*/
|
||||||
void setAlbum(const String &album);
|
void setAlbum(const String &album) override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Not supported and therefore ignored.
|
* Not supported and therefore ignored.
|
||||||
*/
|
*/
|
||||||
void setComment(const String &comment);
|
void setComment(const String &comment) override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Not supported and therefore ignored.
|
* Not supported and therefore ignored.
|
||||||
*/
|
*/
|
||||||
void setGenre(const String &genre);
|
void setGenre(const String &genre) override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Not supported and therefore ignored.
|
* Not supported and therefore ignored.
|
||||||
*/
|
*/
|
||||||
void setYear(unsigned int year);
|
void setYear(unsigned int year) override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Not supported and therefore ignored.
|
* Not supported and therefore ignored.
|
||||||
*/
|
*/
|
||||||
void setTrack(unsigned int track);
|
void setTrack(unsigned int track) override;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Not supported and therefore ignored.
|
||||||
|
*/
|
||||||
|
void setPictures(const PictureMap&) override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Implements the unified property interface -- export function.
|
* Implements the unified property interface -- export function.
|
||||||
* Since the DIIN tag is very limited, the exported map is as well.
|
* Since the DIIN tag is very limited, the exported map is as well.
|
||||||
*/
|
*/
|
||||||
PropertyMap properties() const;
|
PropertyMap properties() const override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Implements the unified property interface -- import function.
|
* Implements the unified property interface -- import function.
|
||||||
* Because of the limitations of the DIIN file tag, any tags besides
|
* Because of the limitations of the DIIN file tag, any tags besides
|
||||||
* TITLE and ARTIST, will be
|
* TITLE and ARTIST, will be returned.
|
||||||
* returned. Additionally, if the map contains tags with multiple values,
|
* Additionally, if the map contains tags with multiple values,
|
||||||
* all but the first will be contained in the returned map of unsupported
|
* all but the first will be contained in the returned map of unsupported properties.
|
||||||
* properties.
|
|
||||||
*/
|
*/
|
||||||
PropertyMap setProperties(const PropertyMap &);
|
PropertyMap setProperties(const PropertyMap &) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Tag(const Tag &);
|
Tag(const Tag &);
|
||||||
@@ -141,10 +145,10 @@ namespace TagLib {
|
|||||||
|
|
||||||
class TagPrivate;
|
class TagPrivate;
|
||||||
TagPrivate *d;
|
TagPrivate *d;
|
||||||
};
|
};
|
||||||
}
|
} // namespace DIIN
|
||||||
}
|
} // namespace DSDIFF
|
||||||
}
|
} // namespace TagLib
|
||||||
|
} // namespace Strawberry_TagLib
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
691
3rdparty/taglib/dsdiff/dsdifffile.cpp
vendored
691
3rdparty/taglib/dsdiff/dsdifffile.cpp
vendored
File diff suppressed because it is too large
Load Diff
177
3rdparty/taglib/dsdiff/dsdifffile.h
vendored
177
3rdparty/taglib/dsdiff/dsdifffile.h
vendored
@@ -31,124 +31,128 @@
|
|||||||
#include "dsdiffproperties.h"
|
#include "dsdiffproperties.h"
|
||||||
#include "dsdiffdiintag.h"
|
#include "dsdiffdiintag.h"
|
||||||
|
|
||||||
|
namespace Strawberry_TagLib {
|
||||||
namespace TagLib {
|
namespace TagLib {
|
||||||
|
|
||||||
//! An implementation of DSDIFF metadata
|
//! An implementation of DSDIFF metadata
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* This is implementation of DSDIFF metadata.
|
* This is implementation of DSDIFF metadata.
|
||||||
*
|
*
|
||||||
* This supports an ID3v2 tag as well as reading stream from the ID3 RIFF
|
* This supports an ID3v2 tag as well as reading stream from the ID3 RIFF
|
||||||
* chunk as well as properties from the file.
|
* chunk as well as properties from the file.
|
||||||
* Description of the DSDIFF format is available
|
* Description of the DSDIFF format is available at http://dsd-guide.com/sites/default/files/white-papers/DSDIFF_1.5_Spec.pdf
|
||||||
* at http://dsd-guide.com/sites/default/files/white-papers/DSDIFF_1.5_Spec.pdf
|
* DSDIFF standard does not explicitly specify the ID3V2 chunk
|
||||||
* DSDIFF standard does not explictly specify the ID3V2 chunk
|
* It can be found at the root level, but also sometimes inside the PROP chunk.
|
||||||
* It can be found at the root level, but also sometimes inside the PROP chunk
|
|
||||||
* In addition, title and artist info are stored as part of the standard
|
* In addition, title and artist info are stored as part of the standard
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace DSDIFF {
|
namespace DSDIFF {
|
||||||
|
|
||||||
//! An implementation of TagLib::File with DSDIFF specific methods
|
//! An implementation of TagLib::File with DSDIFF specific methods
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* This implements and provides an interface for DSDIFF files to the
|
* This implements and provides an interface for DSDIFF files to the
|
||||||
* TagLib::Tag and TagLib::AudioProperties interfaces by way of implementing
|
* TagLib::Tag and TagLib::AudioProperties interfaces by way of implementing the
|
||||||
* the abstract TagLib::File API as well as providing some additional
|
* abstract TagLib::File API as well as providing some additional information specific to DSDIFF files.
|
||||||
* information specific to DSDIFF files.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class TAGLIB_EXPORT File : public TagLib::File
|
class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
/*!
|
/*!
|
||||||
* Constructs an DSDIFF file from \a file. If \a readProperties is true
|
* This set of flags is used for various operations and is suitable for
|
||||||
* the file's audio properties will also be read.
|
* being OR-ed together.
|
||||||
*
|
|
||||||
* \note In the current implementation, \a propertiesStyle is ignored.
|
|
||||||
*/
|
*/
|
||||||
File(FileName file, bool readProperties = true,
|
enum TagTypes {
|
||||||
Properties::ReadStyle propertiesStyle = Properties::Average);
|
//! Empty set. Matches no tag types.
|
||||||
|
NoTags = 0x0000,
|
||||||
|
//! Matches DIIN tags.
|
||||||
|
DIIN = 0x0002,
|
||||||
|
//! Matches ID3v1 tags.
|
||||||
|
ID3v2 = 0x0002,
|
||||||
|
//! Matches all tag types.
|
||||||
|
AllTags = 0xffff
|
||||||
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Constructs an DSDIFF file from \a stream. If \a readProperties is true
|
* Constructs an DSDIFF file from \a file.
|
||||||
* the file's audio properties will also be read.
|
* If \a readProperties is true the file's audio properties will also be read.
|
||||||
*
|
|
||||||
* \note TagLib will *not* take ownership of the stream, the caller is
|
|
||||||
* responsible for deleting it after the File object.
|
|
||||||
*
|
*
|
||||||
* \note In the current implementation, \a propertiesStyle is ignored.
|
* \note In the current implementation, \a propertiesStyle is ignored.
|
||||||
*/
|
*/
|
||||||
File(IOStream *stream, bool readProperties = true,
|
explicit File(FileName file, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average);
|
||||||
Properties::ReadStyle propertiesStyle = Properties::Average);
|
|
||||||
|
/*!
|
||||||
|
* Constructs an DSDIFF file from \a stream.
|
||||||
|
* If \a readProperties is true the file's audio properties will also be read.
|
||||||
|
*
|
||||||
|
* \note TagLib will *not* take ownership of the stream, the caller is responsible for deleting it after the File object.
|
||||||
|
*
|
||||||
|
* \note In the current implementation, \a propertiesStyle is ignored.
|
||||||
|
*/
|
||||||
|
explicit File(IOStream *stream, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Destroys this instance of the File.
|
* Destroys this instance of the File.
|
||||||
*/
|
*/
|
||||||
virtual ~File();
|
~File() override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns a pointer to a tag that is the union of the ID3v2 and DIIN
|
* Returns a pointer to a tag that is the union of the ID3v2 and DIIN tags.
|
||||||
* tags. The ID3v2 tag is given priority in reading the information -- if
|
* The ID3v2 tag is given priority in reading the information -- if requested information exists in both the ID3v2 tag and the ID3v1 tag,
|
||||||
* requested information exists in both the ID3v2 tag and the ID3v1 tag,
|
|
||||||
* the information from the ID3v2 tag will be returned.
|
* the information from the ID3v2 tag will be returned.
|
||||||
*
|
*
|
||||||
* If you would like more granular control over the content of the tags,
|
* If you would like more granular control over the content of the tags, with the concession of generality, use the tag-type specific calls.
|
||||||
* with the concession of generality, use the tag-type specific calls.
|
|
||||||
*
|
*
|
||||||
* \note As this tag is not implemented as an ID3v2 tag or a DIIN tag,
|
* \note As this tag is not implemented as an ID3v2 tag or a DIIN tag,
|
||||||
* but a union of the two this pointer may not be cast to the specific
|
* but a union of the two this pointer may not be cast to the specific tag types.
|
||||||
* tag types.
|
|
||||||
*
|
*
|
||||||
* \see ID3v2Tag()
|
* \see ID3v2Tag()
|
||||||
* \see DIINTag()
|
* \see DIINTag()
|
||||||
*/
|
*/
|
||||||
virtual Tag *tag() const;
|
Tag *tag() const override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the ID3V2 Tag for this file.
|
* Returns the ID3V2 Tag for this file.
|
||||||
*
|
*
|
||||||
* \note This always returns a valid pointer regardless of whether or not
|
* \note This always returns a valid pointer regardless of whether or not the file on disk has an ID3v2 tag.
|
||||||
* the file on disk has an ID3v2 tag. Use hasID3v2Tag() to check if the
|
* Use hasID3v2Tag() to check if the file on disk actually has an ID3v2 tag.
|
||||||
* file on disk actually has an ID3v2 tag.
|
|
||||||
*
|
*
|
||||||
* \see hasID3v2Tag()
|
* \see hasID3v2Tag()
|
||||||
*/
|
*/
|
||||||
virtual ID3v2::Tag *ID3v2Tag() const;
|
ID3v2::Tag *ID3v2Tag(bool create = false) const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the DSDIFF DIIN Tag for this file
|
* Returns the DSDIFF DIIN Tag for this file
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
DSDIFF::DIIN::Tag *DIINTag() const;
|
DSDIFF::DIIN::Tag *DIINTag(bool create = false) const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Implements the unified property interface -- export function.
|
* Implements the unified property interface -- export function.
|
||||||
* This method forwards to ID3v2::Tag::properties().
|
* This method forwards to ID3v2::Tag::properties().
|
||||||
*/
|
*/
|
||||||
PropertyMap properties() const;
|
PropertyMap properties() const override;
|
||||||
|
|
||||||
void removeUnsupportedProperties(const StringList &properties);
|
void removeUnsupportedProperties(const StringList &properties) override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Implements the unified property interface -- import function.
|
* Implements the unified property interface -- import function.
|
||||||
* This method forwards to ID3v2::Tag::setProperties().
|
* This method forwards to ID3v2::Tag::setProperties().
|
||||||
*/
|
*/
|
||||||
PropertyMap setProperties(const PropertyMap &);
|
PropertyMap setProperties(const PropertyMap &properties) override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the AIFF::Properties for this file. If no audio properties
|
* Returns the AIFF::AudioProperties for this file.
|
||||||
* were read then this will return a null pointer.
|
* If no audio properties were read then this will return a null pointer.
|
||||||
*/
|
*/
|
||||||
virtual Properties *audioProperties() const;
|
AudioProperties *audioProperties() const override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Save the file. If at least one tag -- ID3v1 or DIIN -- exists this
|
* Save the file. If at least one tag -- ID3v1 or DIIN -- exists this will duplicate its content into the other tag.
|
||||||
* will duplicate its content into the other tag. This returns true
|
* This returns true if saving was successful.
|
||||||
* if saving was successful.
|
|
||||||
*
|
*
|
||||||
* If neither exists or if both tags are empty, this will strip the tags
|
* If neither exists or if both tags are empty, this will strip the tags from the file.
|
||||||
* from the file.
|
|
||||||
*
|
*
|
||||||
* This is the same as calling save(AllTags);
|
* This is the same as calling save(AllTags);
|
||||||
*
|
*
|
||||||
@@ -157,18 +161,22 @@ namespace TagLib {
|
|||||||
*
|
*
|
||||||
* \see save(int tags)
|
* \see save(int tags)
|
||||||
*/
|
*/
|
||||||
virtual bool save();
|
bool save() override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Save the file. This will attempt to save all of the tag types that are
|
* Save the file. If \a strip is specified,
|
||||||
* specified by OR-ing together TagTypes values. The save() method above
|
* it is possible to choose if tags not specified in \a tags should be stripped from the file or retained.
|
||||||
* uses AllTags. This returns true if saving was successful.
|
* With \a version, it is possible to specify whether ID3v2.4 or ID3v2.3 should be used.
|
||||||
*
|
|
||||||
* This strips all tags not included in the mask, but does not modify them
|
|
||||||
* in memory, so later calls to save() which make use of these tags will
|
|
||||||
* remain valid. This also strips empty tags.
|
|
||||||
*/
|
*/
|
||||||
bool save(int tags);
|
bool save(TagTypes tags, StripTags strip = StripOthers, ID3v2::Version version = ID3v2::v4);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This will strip the tags that match the OR-ed together TagTypes from the file.
|
||||||
|
* By default it strips all tags. It returns true if the tags are successfully stripped.
|
||||||
|
*
|
||||||
|
* \note This will update the file immediately.
|
||||||
|
*/
|
||||||
|
void strip(TagTypes tags = AllTags);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns whether or not the file on disk actually has an ID3v2 tag.
|
* Returns whether or not the file on disk actually has an ID3v2 tag.
|
||||||
@@ -178,24 +186,24 @@ namespace TagLib {
|
|||||||
bool hasID3v2Tag() const;
|
bool hasID3v2Tag() const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns whether or not the file on disk actually has the DSDIFF
|
* Returns whether or not the file on disk actually has the DSDIFF title and artist tags.
|
||||||
* Title & Artist tag.
|
|
||||||
*
|
*
|
||||||
* \see DIINTag()
|
* \see DIINTag()
|
||||||
*/
|
*/
|
||||||
bool hasDIINTag() const;
|
bool hasDIINTag() const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns whether or not the given \a stream can be opened as a DSDIFF
|
* Returns whether or not the given \a stream can be opened as a DSDIFF file.
|
||||||
* file.
|
|
||||||
*
|
*
|
||||||
* \note This method is designed to do a quick check. The result may
|
* \note This method is designed to do a quick check. The result may not necessarily be correct.
|
||||||
* not necessarily be correct.
|
|
||||||
*/
|
*/
|
||||||
static bool isSupported(IOStream *stream);
|
static bool isSupported(IOStream *stream);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
enum Endianness { BigEndian, LittleEndian };
|
enum Endianness {
|
||||||
|
BigEndian,
|
||||||
|
LittleEndian
|
||||||
|
};
|
||||||
|
|
||||||
File(FileName file, Endianness endianness);
|
File(FileName file, Endianness endianness);
|
||||||
File(IOStream *stream, Endianness endianness);
|
File(IOStream *stream, Endianness endianness);
|
||||||
@@ -204,6 +212,10 @@ namespace TagLib {
|
|||||||
File(const File &);
|
File(const File &);
|
||||||
File &operator=(const File &);
|
File &operator=(const File &);
|
||||||
|
|
||||||
|
void removeRootChunk(const ByteVector &id);
|
||||||
|
void removeRootChunk(unsigned int i);
|
||||||
|
void removeChildChunk(unsigned int i, unsigned int childChunkNum);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Sets the data for the the specified chunk at root level to \a data.
|
* Sets the data for the the specified chunk at root level to \a data.
|
||||||
*
|
*
|
||||||
@@ -213,9 +225,7 @@ namespace TagLib {
|
|||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Sets the data for the root-level chunk \a name to \a data.
|
* Sets the data for the root-level chunk \a name to \a data.
|
||||||
* If a root-level chunk with the given name already exists
|
* If a root-level chunk with the given name already exists it will be overwritten, otherwise it will be created after the existing chunks.
|
||||||
* it will be overwritten, otherwise it will be
|
|
||||||
* created after the existing chunks.
|
|
||||||
*
|
*
|
||||||
* \warning This will update the file immediately.
|
* \warning This will update the file immediately.
|
||||||
*/
|
*/
|
||||||
@@ -228,33 +238,28 @@ namespace TagLib {
|
|||||||
*
|
*
|
||||||
* \warning This will update the file immediately.
|
* \warning This will update the file immediately.
|
||||||
*/
|
*/
|
||||||
void setChildChunkData(unsigned int i, const ByteVector &data,
|
void setChildChunkData(unsigned int i, const ByteVector &data, unsigned int childChunkNum);
|
||||||
unsigned int childChunkNum);
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Sets the data for the child chunk \a name to \a data. If a chunk with
|
* Sets the data for the child chunk \a name to \a data.
|
||||||
* the given name already exists it will be overwritten, otherwise it will
|
* If a chunk with the given name already exists it will be overwritten, otherwise it will be created after the existing chunks inside child chunk.
|
||||||
* be created after the existing chunks inside child chunk.
|
|
||||||
*
|
*
|
||||||
* If data is null, then remove the chunks with \a name name
|
* If data is null, then remove the chunks with \a name name
|
||||||
*
|
*
|
||||||
* \warning This will update the file immediately.
|
* \warning This will update the file immediately.
|
||||||
*/
|
*/
|
||||||
void setChildChunkData(const ByteVector &name, const ByteVector &data,
|
void setChildChunkData(const ByteVector &name, const ByteVector &data, unsigned int childChunkNum);
|
||||||
unsigned int childChunkNum);
|
|
||||||
|
|
||||||
void updateRootChunksStructure(unsigned int startingChunk);
|
void updateRootChunksStructure(unsigned int startingChunk);
|
||||||
|
|
||||||
void read(bool readProperties, Properties::ReadStyle propertiesStyle);
|
void read(bool readProperties, AudioProperties::ReadStyle propertiesStyle);
|
||||||
void writeChunk(const ByteVector &name, const ByteVector &data,
|
void writeChunk(const ByteVector &name, const ByteVector &data, unsigned long long offset, unsigned long replace = 0, unsigned int leadingPadding = 0);
|
||||||
unsigned long long offset, unsigned long replace = 0,
|
|
||||||
unsigned int leadingPadding = 0);
|
|
||||||
|
|
||||||
class FilePrivate;
|
class FilePrivate;
|
||||||
FilePrivate *d;
|
FilePrivate *d;
|
||||||
};
|
};
|
||||||
}
|
} // namespace DSDIFF
|
||||||
}
|
} // namespace TagLib
|
||||||
|
} // namespace Strawberry_TagLib
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
60
3rdparty/taglib/dsdiff/dsdiffproperties.cpp
vendored
60
3rdparty/taglib/dsdiff/dsdiffproperties.cpp
vendored
@@ -23,24 +23,21 @@
|
|||||||
* http://www.mozilla.org/MPL/ *
|
* http://www.mozilla.org/MPL/ *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include <tstring.h>
|
#include "tstring.h"
|
||||||
#include <tdebug.h>
|
#include "tdebug.h"
|
||||||
|
|
||||||
#include "dsdiffproperties.h"
|
#include "dsdiffproperties.h"
|
||||||
|
|
||||||
using namespace TagLib;
|
using namespace Strawberry_TagLib::TagLib;
|
||||||
|
|
||||||
class DSDIFF::Properties::PropertiesPrivate
|
class DSDIFF::AudioProperties::AudioPropertiesPrivate {
|
||||||
{
|
public:
|
||||||
public:
|
explicit AudioPropertiesPrivate() : length(0),
|
||||||
PropertiesPrivate() :
|
|
||||||
length(0),
|
|
||||||
bitrate(0),
|
bitrate(0),
|
||||||
sampleRate(0),
|
sampleRate(0),
|
||||||
channels(0),
|
channels(0),
|
||||||
sampleWidth(0),
|
sampleWidth(0),
|
||||||
sampleCount(0)
|
sampleCount(0) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int length;
|
int length;
|
||||||
@@ -55,66 +52,45 @@ public:
|
|||||||
// public members
|
// public members
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
DSDIFF::Properties::Properties(const unsigned int sampleRate,
|
DSDIFF::AudioProperties::AudioProperties(const unsigned int sampleRate, const unsigned short channels, const unsigned long long samplesCount, const int bitrate, ReadStyle) : Strawberry_TagLib::TagLib::AudioProperties(), d(new AudioPropertiesPrivate) {
|
||||||
const unsigned short channels,
|
|
||||||
const unsigned long long samplesCount,
|
|
||||||
const int bitrate,
|
|
||||||
ReadStyle style) : AudioProperties(style)
|
|
||||||
{
|
|
||||||
d = new PropertiesPrivate;
|
|
||||||
|
|
||||||
d->channels = channels;
|
d->channels = channels;
|
||||||
d->sampleCount = samplesCount;
|
d->sampleCount = samplesCount;
|
||||||
d->sampleWidth = 1;
|
d->sampleWidth = 1;
|
||||||
d->sampleRate = sampleRate;
|
d->sampleRate = sampleRate;
|
||||||
d->bitrate = bitrate;
|
d->bitrate = bitrate;
|
||||||
d->length = d->sampleRate > 0
|
d->length = d->sampleRate > 0 ? static_cast<int>((d->sampleCount * 1000.0) / d->sampleRate + 0.5) : 0;
|
||||||
? static_cast<int>((d->sampleCount * 1000.0) / d->sampleRate + 0.5)
|
|
||||||
: 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DSDIFF::Properties::~Properties()
|
DSDIFF::AudioProperties::~AudioProperties() {
|
||||||
{
|
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DSDIFF::Properties::length() const
|
int DSDIFF::AudioProperties::lengthInSeconds() const {
|
||||||
{
|
|
||||||
return lengthInSeconds();
|
|
||||||
}
|
|
||||||
|
|
||||||
int DSDIFF::Properties::lengthInSeconds() const
|
|
||||||
{
|
|
||||||
return d->length / 1000;
|
return d->length / 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DSDIFF::Properties::lengthInMilliseconds() const
|
int DSDIFF::AudioProperties::lengthInMilliseconds() const {
|
||||||
{
|
|
||||||
return d->length;
|
return d->length;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DSDIFF::Properties::bitrate() const
|
int DSDIFF::AudioProperties::bitrate() const {
|
||||||
{
|
|
||||||
return d->bitrate;
|
return d->bitrate;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DSDIFF::Properties::sampleRate() const
|
int DSDIFF::AudioProperties::sampleRate() const {
|
||||||
{
|
|
||||||
return d->sampleRate;
|
return d->sampleRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DSDIFF::Properties::channels() const
|
int DSDIFF::AudioProperties::channels() const {
|
||||||
{
|
|
||||||
return d->channels;
|
return d->channels;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DSDIFF::Properties::bitsPerSample() const
|
int DSDIFF::AudioProperties::bitsPerSample() const {
|
||||||
{
|
|
||||||
return d->sampleWidth;
|
return d->sampleWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
long long DSDIFF::Properties::sampleCount() const
|
long long DSDIFF::AudioProperties::sampleCount() const {
|
||||||
{
|
|
||||||
return d->sampleCount;
|
return d->sampleCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
55
3rdparty/taglib/dsdiff/dsdiffproperties.h
vendored
55
3rdparty/taglib/dsdiff/dsdiffproperties.h
vendored
@@ -28,56 +28,51 @@
|
|||||||
|
|
||||||
#include "audioproperties.h"
|
#include "audioproperties.h"
|
||||||
|
|
||||||
|
namespace Strawberry_TagLib {
|
||||||
namespace TagLib {
|
namespace TagLib {
|
||||||
|
namespace DSDIFF {
|
||||||
|
|
||||||
namespace DSDIFF {
|
class File;
|
||||||
|
|
||||||
class File;
|
//! An implementation of audio property reading for DSDIFF
|
||||||
|
|
||||||
//! An implementation of audio property reading for DSDIFF
|
/*!
|
||||||
|
* This reads the data from an DSDIFF stream found in the AudioProperties API.
|
||||||
/*!
|
|
||||||
* This reads the data from an DSDIFF stream found in the AudioProperties
|
|
||||||
* API.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class TAGLIB_EXPORT Properties : public AudioProperties
|
class TAGLIB_EXPORT AudioProperties : public Strawberry_TagLib::TagLib::AudioProperties {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
/*!
|
/*!
|
||||||
* Create an instance of DSDIFF::Properties with the data read from the
|
* Create an instance of DSDIFF::AudioProperties with the data read from the ByteVector \a data.
|
||||||
* ByteVector \a data.
|
|
||||||
*/
|
*/
|
||||||
Properties(const unsigned int sampleRate, const unsigned short channels,
|
explicit AudioProperties(const unsigned int sampleRate, const unsigned short channels, const unsigned long long samplesCount, const int bitrate, ReadStyle);
|
||||||
const unsigned long long samplesCount, const int bitrate,
|
|
||||||
ReadStyle style);
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Destroys this DSDIFF::Properties instance.
|
* Destroys this DSDIFF::AudioProperties instance.
|
||||||
*/
|
*/
|
||||||
virtual ~Properties();
|
~AudioProperties() override;
|
||||||
|
|
||||||
// Reimplementations.
|
// Reimplementations.
|
||||||
|
|
||||||
virtual int length() const;
|
int lengthInSeconds() const override;
|
||||||
virtual int lengthInSeconds() const;
|
int lengthInMilliseconds() const override;
|
||||||
virtual int lengthInMilliseconds() const;
|
int bitrate() const override;
|
||||||
virtual int bitrate() const;
|
int sampleRate() const override;
|
||||||
virtual int sampleRate() const;
|
int channels() const override;
|
||||||
virtual int channels() const;
|
|
||||||
|
|
||||||
int bitsPerSample() const;
|
int bitsPerSample() const;
|
||||||
long long sampleCount() const;
|
long long sampleCount() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Properties(const Properties &);
|
AudioProperties(const AudioProperties &);
|
||||||
Properties &operator=(const Properties &);
|
AudioProperties &operator=(const AudioProperties &);
|
||||||
|
|
||||||
class PropertiesPrivate;
|
class AudioPropertiesPrivate;
|
||||||
PropertiesPrivate *d;
|
AudioPropertiesPrivate *d;
|
||||||
};
|
};
|
||||||
}
|
|
||||||
}
|
} // namespace DSDIFF
|
||||||
|
} // namespace TagLib
|
||||||
|
} // namespace Strawberry_TagLib
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
143
3rdparty/taglib/dsf/dsffile.cpp
vendored
143
3rdparty/taglib/dsf/dsffile.cpp
vendored
@@ -23,49 +23,43 @@
|
|||||||
* http://www.mozilla.org/MPL/ *
|
* http://www.mozilla.org/MPL/ *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include <tbytevector.h>
|
#include <memory>
|
||||||
#include <tdebug.h>
|
|
||||||
#include <id3v2tag.h>
|
#include "tbytevector.h"
|
||||||
#include <tstringlist.h>
|
#include "tdebug.h"
|
||||||
#include <tpropertymap.h>
|
#include "id3v2tag.h"
|
||||||
#include <tagutils.h>
|
#include "tstringlist.h"
|
||||||
|
#include "tpropertymap.h"
|
||||||
|
#include "tagutils.h"
|
||||||
|
|
||||||
#include "dsffile.h"
|
#include "dsffile.h"
|
||||||
|
|
||||||
using namespace TagLib;
|
using namespace Strawberry_TagLib::TagLib;
|
||||||
|
|
||||||
// The DSF specification is located at http://dsd-guide.com/sites/default/files/white-papers/DSFFileFormatSpec_E.pdf
|
// The DSF specification is located at http://dsd-guide.com/sites/default/files/white-papers/DSFFileFormatSpec_E.pdf
|
||||||
|
|
||||||
class DSF::File::FilePrivate
|
class DSF::File::FilePrivate {
|
||||||
{
|
public:
|
||||||
public:
|
FilePrivate() : fileSize(0),
|
||||||
FilePrivate() :
|
metadataOffset(0) {}
|
||||||
properties(0),
|
|
||||||
tag(0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
~FilePrivate()
|
|
||||||
{
|
|
||||||
delete properties;
|
|
||||||
delete tag;
|
|
||||||
}
|
|
||||||
|
|
||||||
long long fileSize;
|
long long fileSize;
|
||||||
long long metadataOffset;
|
long long metadataOffset;
|
||||||
Properties *properties;
|
|
||||||
ID3v2::Tag *tag;
|
std::unique_ptr<AudioProperties> properties;
|
||||||
|
std::unique_ptr<ID3v2::Tag> tag;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// static members
|
// static members
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
bool DSF::File::isSupported(IOStream *stream)
|
bool DSF::File::isSupported(IOStream *stream) {
|
||||||
{
|
|
||||||
// A DSF file has to start with "DSD "
|
// A DSF file has to start with "DSD "
|
||||||
const ByteVector id = Utils::readHeader(stream, 4, false);
|
const ByteVector id = Utils::readHeader(stream, 4, false);
|
||||||
return id.startsWith("DSD ");
|
return id.startsWith("DSD ");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -73,74 +67,66 @@ bool DSF::File::isSupported(IOStream *stream)
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
DSF::File::File(FileName file, bool readProperties,
|
DSF::File::File(FileName file, bool readProperties,
|
||||||
Properties::ReadStyle propertiesStyle) :
|
AudioProperties::ReadStyle propertiesStyle) : Strawberry_TagLib::TagLib::File(file), d(new FilePrivate()) {
|
||||||
TagLib::File(file),
|
|
||||||
d(new FilePrivate())
|
if (isOpen())
|
||||||
{
|
|
||||||
if(isOpen())
|
|
||||||
read(readProperties, propertiesStyle);
|
read(readProperties, propertiesStyle);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DSF::File::File(IOStream *stream, bool readProperties,
|
DSF::File::File(IOStream *stream, bool readProperties, AudioProperties::ReadStyle propertiesStyle) : Strawberry_TagLib::TagLib::File(stream), d(new FilePrivate()) {
|
||||||
Properties::ReadStyle propertiesStyle) :
|
|
||||||
TagLib::File(stream),
|
if (isOpen())
|
||||||
d(new FilePrivate())
|
|
||||||
{
|
|
||||||
if(isOpen())
|
|
||||||
read(readProperties, propertiesStyle);
|
read(readProperties, propertiesStyle);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DSF::File::~File()
|
DSF::File::~File() {
|
||||||
{
|
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
ID3v2::Tag *DSF::File::tag() const
|
ID3v2::Tag *DSF::File::tag() const {
|
||||||
{
|
return d->tag.get();
|
||||||
return d->tag;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertyMap DSF::File::properties() const
|
DSF::AudioProperties *DSF::File::audioProperties() const {
|
||||||
{
|
return d->properties.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
PropertyMap DSF::File::properties() const {
|
||||||
return d->tag->properties();
|
return d->tag->properties();
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertyMap DSF::File::setProperties(const PropertyMap &properties)
|
PropertyMap DSF::File::setProperties(const PropertyMap &properties) {
|
||||||
{
|
|
||||||
return d->tag->setProperties(properties);
|
return d->tag->setProperties(properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
DSF::Properties *DSF::File::audioProperties() const
|
bool DSF::File::save() {
|
||||||
{
|
|
||||||
return d->properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DSF::File::save()
|
if (readOnly()) {
|
||||||
{
|
|
||||||
if(readOnly()) {
|
|
||||||
debug("DSF::File::save() -- File is read only.");
|
debug("DSF::File::save() -- File is read only.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!isValid()) {
|
if (!isValid()) {
|
||||||
debug("DSF::File::save() -- Trying to save invalid file.");
|
debug("DSF::File::save() -- Trying to save invalid file.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Three things must be updated: the file size, the tag data, and the metadata offset
|
// Three things must be updated: the file size, the tag data, and the metadata offset
|
||||||
|
|
||||||
if(d->tag->isEmpty()) {
|
if (d->tag->isEmpty()) {
|
||||||
long long newFileSize = d->metadataOffset ? d->metadataOffset : d->fileSize;
|
long long newFileSize = d->metadataOffset ? d->metadataOffset : d->fileSize;
|
||||||
|
|
||||||
// Update the file size
|
// Update the file size
|
||||||
if(d->fileSize != newFileSize) {
|
if (d->fileSize != newFileSize) {
|
||||||
insert(ByteVector::fromLongLong(newFileSize, false), 12, 8);
|
insert(ByteVector::fromUInt64LE(newFileSize), 12, 8);
|
||||||
d->fileSize = newFileSize;
|
d->fileSize = newFileSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the metadata offset to 0 since there is no longer a tag
|
// Update the metadata offset to 0 since there is no longer a tag
|
||||||
if(d->metadataOffset) {
|
if (d->metadataOffset) {
|
||||||
insert(ByteVector::fromLongLong(0ULL, false), 20, 8);
|
insert(ByteVector::fromUInt64LE(0ULL), 20, 8);
|
||||||
d->metadataOffset = 0;
|
d->metadataOffset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,14 +141,14 @@ bool DSF::File::save()
|
|||||||
long long oldTagSize = d->fileSize - newMetadataOffset;
|
long long oldTagSize = d->fileSize - newMetadataOffset;
|
||||||
|
|
||||||
// Update the file size
|
// Update the file size
|
||||||
if(d->fileSize != newFileSize) {
|
if (d->fileSize != newFileSize) {
|
||||||
insert(ByteVector::fromLongLong(newFileSize, false), 12, 8);
|
insert(ByteVector::fromUInt64LE(newFileSize), 12, 8);
|
||||||
d->fileSize = newFileSize;
|
d->fileSize = newFileSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the metadata offset
|
// Update the metadata offset
|
||||||
if(d->metadataOffset != newMetadataOffset) {
|
if (d->metadataOffset != newMetadataOffset) {
|
||||||
insert(ByteVector::fromLongLong(newMetadataOffset, false), 20, 8);
|
insert(ByteVector::fromUInt64LE(newMetadataOffset), 20, 8);
|
||||||
d->metadataOffset = newMetadataOffset;
|
d->metadataOffset = newMetadataOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,6 +157,7 @@ bool DSF::File::save()
|
|||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -178,41 +165,41 @@ bool DSF::File::save()
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
void DSF::File::read(bool readProperties, Properties::ReadStyle propertiesStyle)
|
void DSF::File::read(bool, AudioProperties::ReadStyle propertiesStyle) {
|
||||||
{
|
|
||||||
// A DSF file consists of four chunks: DSD chunk, format chunk, data chunk, and metadata chunk
|
// A DSF file consists of four chunks: DSD chunk, format chunk, data chunk, and metadata chunk
|
||||||
// The file format is not chunked in the sense of a RIFF File, though
|
// The file format is not chunked in the sense of a RIFF File, though
|
||||||
|
|
||||||
// DSD chunk
|
// DSD chunk
|
||||||
ByteVector chunkName = readBlock(4);
|
ByteVector chunkName = readBlock(4);
|
||||||
if(chunkName != "DSD ") {
|
if (chunkName != "DSD ") {
|
||||||
debug("DSF::File::read() -- Not a DSF file.");
|
debug("DSF::File::read() -- Not a DSF file.");
|
||||||
setValid(false);
|
setValid(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
long long chunkSize = readBlock(8).toLongLong(false);
|
long long chunkSize = readBlock(8).toInt64LE(0);
|
||||||
|
|
||||||
// Integrity check
|
// Integrity check
|
||||||
if(28 != chunkSize) {
|
if (28 != chunkSize) {
|
||||||
debug("DSF::File::read() -- File is corrupted, wrong chunk size");
|
debug("DSF::File::read() -- File is corrupted, wrong chunk size");
|
||||||
setValid(false);
|
setValid(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
d->fileSize = readBlock(8).toLongLong(false);
|
d->fileSize = readBlock(8).toInt64LE(0);
|
||||||
|
|
||||||
// File is malformed or corrupted
|
// File is malformed or corrupted
|
||||||
if(d->fileSize != length()) {
|
if (d->fileSize != length()) {
|
||||||
debug("DSF::File::read() -- File is corrupted wrong length");
|
debug("DSF::File::read() -- File is corrupted wrong length");
|
||||||
setValid(false);
|
setValid(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
d->metadataOffset = readBlock(8).toLongLong(false);
|
d->metadataOffset = readBlock(8).toInt64LE(0);
|
||||||
|
|
||||||
// File is malformed or corrupted
|
// File is malformed or corrupted
|
||||||
if(d->metadataOffset > d->fileSize) {
|
if (d->metadataOffset > d->fileSize) {
|
||||||
debug("DSF::File::read() -- Invalid metadata offset.");
|
debug("DSF::File::read() -- Invalid metadata offset.");
|
||||||
setValid(false);
|
setValid(false);
|
||||||
return;
|
return;
|
||||||
@@ -220,22 +207,22 @@ void DSF::File::read(bool readProperties, Properties::ReadStyle propertiesStyle)
|
|||||||
|
|
||||||
// Format chunk
|
// Format chunk
|
||||||
chunkName = readBlock(4);
|
chunkName = readBlock(4);
|
||||||
if(chunkName != "fmt ") {
|
if (chunkName != "fmt ") {
|
||||||
debug("DSF::File::read() -- Missing 'fmt ' chunk.");
|
debug("DSF::File::read() -- Missing 'fmt ' chunk.");
|
||||||
setValid(false);
|
setValid(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
chunkSize = readBlock(8).toLongLong(false);
|
chunkSize = readBlock(8).toInt64LE(0);
|
||||||
|
|
||||||
d->properties = new Properties(readBlock(chunkSize), propertiesStyle);
|
d->properties.reset(new AudioProperties(readBlock(chunkSize), propertiesStyle));
|
||||||
|
|
||||||
// Skip the data chunk
|
// Skip the data chunk
|
||||||
|
|
||||||
// A metadata offset of 0 indicates the absence of an ID3v2 tag
|
// A metadata offset of 0 indicates the absence of an ID3v2 tag
|
||||||
if(0 == d->metadataOffset)
|
if (0 == d->metadataOffset)
|
||||||
d->tag = new ID3v2::Tag();
|
d->tag.reset(new ID3v2::Tag());
|
||||||
else
|
else
|
||||||
d->tag = new ID3v2::Tag(this, d->metadataOffset);
|
d->tag.reset(new ID3v2::Tag(this, d->metadataOffset));
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
71
3rdparty/taglib/dsf/dsffile.h
vendored
71
3rdparty/taglib/dsf/dsffile.h
vendored
@@ -30,85 +30,82 @@
|
|||||||
#include "id3v2tag.h"
|
#include "id3v2tag.h"
|
||||||
#include "dsfproperties.h"
|
#include "dsfproperties.h"
|
||||||
|
|
||||||
|
namespace Strawberry_TagLib {
|
||||||
namespace TagLib {
|
namespace TagLib {
|
||||||
|
|
||||||
//! An implementation of DSF metadata
|
//! An implementation of DSF metadata
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* This is implementation of DSF metadata.
|
* This is implementation of DSF metadata.
|
||||||
*
|
*
|
||||||
* This supports an ID3v2 tag as well as properties from the file.
|
* This supports an ID3v2 tag as well as properties from the file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace DSF {
|
namespace DSF {
|
||||||
|
|
||||||
//! An implementation of TagLib::File with DSF specific methods
|
//! An implementation of Strawberry_TagLib::TagLib::File with DSF specific methods
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* This implements and provides an interface for DSF files to the
|
* This implements and provides an interface for DSF files to the
|
||||||
* TagLib::Tag and TagLib::AudioProperties interfaces by way of implementing
|
* Strawberry_TagLib::TagLib::Tag and Strawberry_TagLib::TagLib::AudioProperties interfaces by way of implementing
|
||||||
* the abstract TagLib::File API as well as providing some additional
|
* the abstract Strawberry_TagLib::TagLib::File API as well as providing some additional information specific to DSF files.
|
||||||
* information specific to DSF files.
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class TAGLIB_EXPORT File : public TagLib::File
|
class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
/*!
|
/*!
|
||||||
* Contructs an DSF file from \a file. If \a readProperties is true the
|
* Constructs an DSF file from \a file.
|
||||||
* file's audio properties will also be read using \a propertiesStyle. If
|
* If \a readProperties is true the file's audio properties will also be read using \a propertiesStyle.
|
||||||
* false, \a propertiesStyle is ignored.
|
* If false, \a propertiesStyle is ignored.
|
||||||
*/
|
*/
|
||||||
File(FileName file, bool readProperties = true,
|
explicit File(FileName file, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average);
|
||||||
Properties::ReadStyle propertiesStyle = Properties::Average);
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Contructs an DSF file from \a file. If \a readProperties is true the
|
* Constructs an DSF file from \a file.
|
||||||
* file's audio properties will also be read using \a propertiesStyle. If
|
* If \a readProperties is true the file's audio properties will also be read using \a propertiesStyle.
|
||||||
* false, \a propertiesStyle is ignored.
|
* If false, \a propertiesStyle is ignored.
|
||||||
*/
|
*/
|
||||||
File(IOStream *stream, bool readProperties = true,
|
explicit File(IOStream *stream, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average);
|
||||||
Properties::ReadStyle propertiesStyle = Properties::Average);
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Destroys this instance of the File.
|
* Destroys this instance of the File.
|
||||||
*/
|
*/
|
||||||
virtual ~File();
|
~File() override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the Tag for this file.
|
* Returns the Tag for this file.
|
||||||
*/
|
*/
|
||||||
ID3v2::Tag *tag() const;
|
ID3v2::Tag *tag() const override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Implements the unified property interface -- export function.
|
* Implements the unified property interface -- export function.
|
||||||
* This method forwards to ID3v2::Tag::properties().
|
* This method forwards to ID3v2::Tag::properties().
|
||||||
*/
|
*/
|
||||||
PropertyMap properties() const;
|
PropertyMap properties() const override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Implements the unified property interface -- import function.
|
* Implements the unified property interface -- import function.
|
||||||
* This method forwards to ID3v2::Tag::setProperties().
|
* This method forwards to ID3v2::Tag::setProperties().
|
||||||
*/
|
*/
|
||||||
PropertyMap setProperties(const PropertyMap &);
|
PropertyMap setProperties(const PropertyMap &) override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the DSF::AudioProperties for this file. If no audio properties
|
* Returns the DSF::AudioProperties for this file.
|
||||||
* were read then this will return a null pointer.
|
* If no audio properties were read then this will return a null pointer.
|
||||||
*/
|
*/
|
||||||
virtual Properties *audioProperties() const;
|
AudioProperties *audioProperties() const override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Saves the file.
|
* Saves the file.
|
||||||
*/
|
*/
|
||||||
virtual bool save();
|
bool save() override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns whether or not the given \a stream can be opened as a DSF
|
* Returns whether or not the given \a stream can be opened as a DSF file.
|
||||||
* file.
|
|
||||||
*
|
*
|
||||||
* \note This method is designed to do a quick check. The result may
|
* \note This method is designed to do a quick check.
|
||||||
* not necessarily be correct.
|
* The result may not necessarily be correct.
|
||||||
*/
|
*/
|
||||||
static bool isSupported(IOStream *stream);
|
static bool isSupported(IOStream *stream);
|
||||||
|
|
||||||
@@ -116,13 +113,13 @@ namespace TagLib {
|
|||||||
File(const File &);
|
File(const File &);
|
||||||
File &operator=(const File &);
|
File &operator=(const File &);
|
||||||
|
|
||||||
void read(bool readProperties, Properties::ReadStyle propertiesStyle);
|
void read(bool readProperties, AudioProperties::ReadStyle propertiesStyle);
|
||||||
|
|
||||||
class FilePrivate;
|
class FilePrivate;
|
||||||
FilePrivate *d;
|
FilePrivate *d;
|
||||||
};
|
};
|
||||||
}
|
} // namespace DSF
|
||||||
}
|
} // namespace TagLib
|
||||||
|
} // namespace Strawberry_TagLib
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
92
3rdparty/taglib/dsf/dsfproperties.cpp
vendored
92
3rdparty/taglib/dsf/dsfproperties.cpp
vendored
@@ -23,18 +23,16 @@
|
|||||||
* http://www.mozilla.org/MPL/ *
|
* http://www.mozilla.org/MPL/ *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include <tstring.h>
|
#include "tstring.h"
|
||||||
#include <tdebug.h>
|
#include "tdebug.h"
|
||||||
|
|
||||||
#include "dsfproperties.h"
|
#include "dsfproperties.h"
|
||||||
|
|
||||||
using namespace TagLib;
|
using namespace Strawberry_TagLib::TagLib;
|
||||||
|
|
||||||
class DSF::Properties::PropertiesPrivate
|
class DSF::AudioProperties::AudioPropertiesPrivate {
|
||||||
{
|
public:
|
||||||
public:
|
explicit AudioPropertiesPrivate() : formatVersion(0),
|
||||||
PropertiesPrivate() :
|
|
||||||
formatVersion(0),
|
|
||||||
formatID(0),
|
formatID(0),
|
||||||
channelType(0),
|
channelType(0),
|
||||||
channelNum(0),
|
channelNum(0),
|
||||||
@@ -43,8 +41,7 @@ public:
|
|||||||
sampleCount(0),
|
sampleCount(0),
|
||||||
blockSizePerChannel(0),
|
blockSizePerChannel(0),
|
||||||
bitrate(0),
|
bitrate(0),
|
||||||
length(0)
|
length(0) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Nomenclature is from DSF file format specification
|
// Nomenclature is from DSF file format specification
|
||||||
@@ -58,83 +55,64 @@ public:
|
|||||||
unsigned int blockSizePerChannel;
|
unsigned int blockSizePerChannel;
|
||||||
|
|
||||||
// Computed
|
// Computed
|
||||||
unsigned int bitrate;
|
int bitrate;
|
||||||
unsigned int length;
|
int length;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// public members
|
// public members
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
DSF::Properties::Properties(const ByteVector &data, ReadStyle style) : TagLib::AudioProperties(style)
|
DSF::AudioProperties::AudioProperties(const ByteVector &data, ReadStyle) : Strawberry_TagLib::TagLib::AudioProperties(), d(new AudioPropertiesPrivate()) {
|
||||||
{
|
|
||||||
d = new PropertiesPrivate;
|
|
||||||
read(data);
|
read(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
DSF::Properties::~Properties()
|
DSF::AudioProperties::~AudioProperties() {
|
||||||
{
|
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DSF::Properties::length() const
|
int DSF::AudioProperties::lengthInSeconds() const {
|
||||||
{
|
|
||||||
return lengthInSeconds();
|
|
||||||
}
|
|
||||||
|
|
||||||
int DSF::Properties::lengthInSeconds() const
|
|
||||||
{
|
|
||||||
return d->length / 1000;
|
return d->length / 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DSF::Properties::lengthInMilliseconds() const
|
int DSF::AudioProperties::lengthInMilliseconds() const {
|
||||||
{
|
|
||||||
return d->length;
|
return d->length;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DSF::Properties::bitrate() const
|
int DSF::AudioProperties::bitrate() const {
|
||||||
{
|
|
||||||
return d->bitrate;
|
return d->bitrate;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DSF::Properties::sampleRate() const
|
int DSF::AudioProperties::sampleRate() const {
|
||||||
{
|
|
||||||
return d->samplingFrequency;
|
return d->samplingFrequency;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DSF::Properties::channels() const
|
int DSF::AudioProperties::channels() const {
|
||||||
{
|
|
||||||
return d->channelNum;
|
return d->channelNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
// DSF specific
|
// DSF specific
|
||||||
int DSF::Properties::formatVersion() const
|
int DSF::AudioProperties::formatVersion() const {
|
||||||
{
|
|
||||||
return d->formatVersion;
|
return d->formatVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DSF::Properties::formatID() const
|
int DSF::AudioProperties::formatID() const {
|
||||||
{
|
|
||||||
return d->formatID;
|
return d->formatID;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DSF::Properties::channelType() const
|
int DSF::AudioProperties::channelType() const {
|
||||||
{
|
|
||||||
return d->channelType;
|
return d->channelType;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DSF::Properties::bitsPerSample() const
|
int DSF::AudioProperties::bitsPerSample() const {
|
||||||
{
|
|
||||||
return d->bitsPerSample;
|
return d->bitsPerSample;
|
||||||
}
|
}
|
||||||
|
|
||||||
long long DSF::Properties::sampleCount() const
|
long long DSF::AudioProperties::sampleCount() const {
|
||||||
{
|
|
||||||
return d->sampleCount;
|
return d->sampleCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DSF::Properties::blockSizePerChannel() const
|
int DSF::AudioProperties::blockSizePerChannel() const {
|
||||||
{
|
|
||||||
return d->blockSizePerChannel;
|
return d->blockSizePerChannel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,20 +120,16 @@ int DSF::Properties::blockSizePerChannel() const
|
|||||||
// private members
|
// private members
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void DSF::Properties::read(const ByteVector &data)
|
void DSF::AudioProperties::read(const ByteVector &data) {
|
||||||
{
|
d->formatVersion = data.toUInt32LE(0);
|
||||||
d->formatVersion = data.toUInt(0U,false);
|
d->formatID = data.toUInt32LE(4);
|
||||||
d->formatID = data.toUInt(4U,false);
|
d->channelType = data.toUInt32LE(8);
|
||||||
d->channelType = data.toUInt(8U,false);
|
d->channelNum = data.toUInt32LE(12);
|
||||||
d->channelNum = data.toUInt(12U,false);
|
d->samplingFrequency = data.toUInt32LE(16);
|
||||||
d->samplingFrequency = data.toUInt(16U,false);
|
d->bitsPerSample = data.toUInt32LE(20);
|
||||||
d->bitsPerSample = data.toUInt(20U,false);
|
d->sampleCount = data.toInt64LE(24);
|
||||||
d->sampleCount = data.toLongLong(24U,false);
|
d->blockSizePerChannel = data.toUInt32LE(32);
|
||||||
d->blockSizePerChannel = data.toUInt(32U,false);
|
|
||||||
|
|
||||||
d->bitrate
|
d->bitrate = static_cast<int>((d->samplingFrequency * d->bitsPerSample * d->channelNum) / 1000.0 + 0.5);
|
||||||
= static_cast<unsigned int>((d->samplingFrequency * d->bitsPerSample * d->channelNum) / 1000.0 + 0.5);
|
d->length = d->samplingFrequency > 0 ? static_cast<int>(d->sampleCount * 1000.0 / d->samplingFrequency + 0.5) : 0;
|
||||||
d->length
|
|
||||||
= d->samplingFrequency > 0 ? static_cast<unsigned int>(d->sampleCount * 1000.0 / d->samplingFrequency + 0.5) : 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
60
3rdparty/taglib/dsf/dsfproperties.h
vendored
60
3rdparty/taglib/dsf/dsfproperties.h
vendored
@@ -28,48 +28,50 @@
|
|||||||
|
|
||||||
#include "audioproperties.h"
|
#include "audioproperties.h"
|
||||||
|
|
||||||
|
namespace Strawberry_TagLib {
|
||||||
namespace TagLib {
|
namespace TagLib {
|
||||||
|
namespace DSF {
|
||||||
|
|
||||||
namespace DSF {
|
class File;
|
||||||
|
|
||||||
class File;
|
//! An implementation of audio property reading for DSF
|
||||||
|
|
||||||
//! An implementation of audio property reading for DSF
|
/*!
|
||||||
|
* This reads the data from a DSF stream found in the AudioProperties API.
|
||||||
/*!
|
|
||||||
* This reads the data from a DSF stream found in the AudioProperties
|
|
||||||
* API.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class TAGLIB_EXPORT Properties : public TagLib::AudioProperties
|
class TAGLIB_EXPORT AudioProperties : public Strawberry_TagLib::TagLib::AudioProperties {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
/*!
|
/*!
|
||||||
* Create an instance of DSF::AudioProperties with the data read from the
|
* Create an instance of DSF::AudioProperties with the data read from the ByteVector \a data.
|
||||||
* ByteVector \a data.
|
|
||||||
*/
|
*/
|
||||||
Properties(const ByteVector &data, ReadStyle style);
|
explicit AudioProperties(const ByteVector &data, ReadStyle);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Destroys this DSF::AudioProperties instance.
|
* Destroys this DSF::AudioProperties instance.
|
||||||
*/
|
*/
|
||||||
virtual ~Properties();
|
~AudioProperties() override;
|
||||||
|
|
||||||
// Reimplementations.
|
// Reimplementations.
|
||||||
|
|
||||||
virtual int length() const;
|
int lengthInSeconds() const override;
|
||||||
virtual int lengthInSeconds() const;
|
int lengthInMilliseconds() const override;
|
||||||
virtual int lengthInMilliseconds() const;
|
int bitrate() const override;
|
||||||
virtual int bitrate() const;
|
int sampleRate() const override;
|
||||||
virtual int sampleRate() const;
|
int channels() const override;
|
||||||
virtual int channels() const;
|
|
||||||
|
|
||||||
int formatVersion() const;
|
int formatVersion() const;
|
||||||
int formatID() const;
|
int formatID() const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Channel type values: 1 = mono, 2 = stereo, 3 = 3 channels,
|
* Channel type values:
|
||||||
* 4 = quad, 5 = 4 channels, 6 = 5 channels, 7 = 5.1 channels
|
* 1 = mono,
|
||||||
|
* 2 = stereo,
|
||||||
|
* 3 = 3 channels,
|
||||||
|
* 4 = quad,
|
||||||
|
* 5 = 4 channels,
|
||||||
|
* 6 = 5 channels,
|
||||||
|
* 7 = 5.1 channels
|
||||||
*/
|
*/
|
||||||
int channelType() const;
|
int channelType() const;
|
||||||
int bitsPerSample() const;
|
int bitsPerSample() const;
|
||||||
@@ -77,16 +79,16 @@ namespace TagLib {
|
|||||||
int blockSizePerChannel() const;
|
int blockSizePerChannel() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Properties(const Properties &);
|
AudioProperties(const AudioProperties&);
|
||||||
Properties &operator=(const Properties &);
|
AudioProperties &operator=(const AudioProperties&);
|
||||||
|
|
||||||
void read(const ByteVector &data);
|
void read(const ByteVector &data);
|
||||||
|
|
||||||
class PropertiesPrivate;
|
class AudioPropertiesPrivate;
|
||||||
PropertiesPrivate *d;
|
AudioPropertiesPrivate *d;
|
||||||
};
|
};
|
||||||
}
|
} // namespace DSF
|
||||||
}
|
} // namespace TagLib
|
||||||
|
} // namespace Strawberry_TagLib
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
411
3rdparty/taglib/fileref.cpp
vendored
411
3rdparty/taglib/fileref.cpp
vendored
@@ -27,11 +27,12 @@
|
|||||||
* http://www.mozilla.org/MPL/ *
|
* http://www.mozilla.org/MPL/ *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include <tfile.h>
|
#include <memory>
|
||||||
#include <tfilestream.h>
|
|
||||||
#include <tstring.h>
|
#include "tfile.h"
|
||||||
#include <tdebug.h>
|
#include "tfilestream.h"
|
||||||
#include <trefcounter.h>
|
#include "tstring.h"
|
||||||
|
#include "tdebug.h"
|
||||||
|
|
||||||
#include "fileref.h"
|
#include "fileref.h"
|
||||||
#include "asffile.h"
|
#include "asffile.h"
|
||||||
@@ -55,234 +56,151 @@
|
|||||||
#include "dsffile.h"
|
#include "dsffile.h"
|
||||||
#include "dsdifffile.h"
|
#include "dsdifffile.h"
|
||||||
|
|
||||||
using namespace TagLib;
|
using namespace Strawberry_TagLib::TagLib;
|
||||||
|
|
||||||
namespace
|
namespace {
|
||||||
{
|
typedef List<const FileRef::FileTypeResolver*> ResolverList;
|
||||||
typedef List<const FileRef::FileTypeResolver *> ResolverList;
|
ResolverList fileTypeResolvers;
|
||||||
ResolverList fileTypeResolvers;
|
|
||||||
|
|
||||||
// Detect the file type by user-defined resolvers.
|
// Detect the file type by user-defined resolvers.
|
||||||
|
|
||||||
|
File *detectByResolvers(FileName fileName, bool readAudioProperties, AudioProperties::ReadStyle audioPropertiesStyle) {
|
||||||
|
|
||||||
File *detectByResolvers(FileName fileName, bool readAudioProperties,
|
|
||||||
AudioProperties::ReadStyle audioPropertiesStyle)
|
|
||||||
{
|
|
||||||
ResolverList::ConstIterator it = fileTypeResolvers.begin();
|
ResolverList::ConstIterator it = fileTypeResolvers.begin();
|
||||||
for(; it != fileTypeResolvers.end(); ++it) {
|
for (; it != fileTypeResolvers.end(); ++it) {
|
||||||
File *file = (*it)->createFile(fileName, readAudioProperties, audioPropertiesStyle);
|
File *file = (*it)->createFile(fileName, readAudioProperties, audioPropertiesStyle);
|
||||||
if(file)
|
if (file)
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
|
||||||
|
|
||||||
// Detect the file type based on the file extension.
|
}
|
||||||
|
|
||||||
|
// Detect the file type based on the file extension.
|
||||||
|
|
||||||
|
File *detectByExtension(IOStream *stream, bool readAudioProperties, AudioProperties::ReadStyle audioPropertiesStyle) {
|
||||||
|
|
||||||
File* detectByExtension(IOStream *stream, bool readAudioProperties,
|
|
||||||
AudioProperties::ReadStyle audioPropertiesStyle)
|
|
||||||
{
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
const String s = stream->name().toString();
|
const String s(stream->name().wstr());
|
||||||
#else
|
#else
|
||||||
const String s(stream->name());
|
const String s(stream->name());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
String ext;
|
String ext;
|
||||||
const int pos = s.rfind(".");
|
const size_t pos = s.rfind(".");
|
||||||
if(pos != -1)
|
if (pos != String::npos())
|
||||||
ext = s.substr(pos + 1).upper();
|
ext = s.substr(pos + 1).upper();
|
||||||
|
|
||||||
// If this list is updated, the method defaultFileExtensions() should also be
|
// If this list is updated, the method defaultFileExtensions() should also be
|
||||||
// updated. However at some point that list should be created at the same time
|
// updated. However at some point that list should be created at the same time
|
||||||
// that a default file type resolver is created.
|
// that a default file type resolver is created.
|
||||||
|
|
||||||
if(ext.isEmpty())
|
if (ext.isEmpty())
|
||||||
return 0;
|
return nullptr;
|
||||||
|
|
||||||
// .oga can be any audio in the Ogg container. So leave it to content-based detection.
|
// .oga can be any audio in the Ogg container. So leave it to content-based detection.
|
||||||
|
|
||||||
if(ext == "MP3")
|
if (ext == "MP3")
|
||||||
return new MPEG::File(stream, ID3v2::FrameFactory::instance(), readAudioProperties, audioPropertiesStyle);
|
return new MPEG::File(stream, ID3v2::FrameFactory::instance(), readAudioProperties, audioPropertiesStyle);
|
||||||
if(ext == "OGG")
|
if (ext == "OGG")
|
||||||
return new Ogg::Vorbis::File(stream, readAudioProperties, audioPropertiesStyle);
|
return new Ogg::Vorbis::File(stream, readAudioProperties, audioPropertiesStyle);
|
||||||
if(ext == "FLAC")
|
if (ext == "FLAC")
|
||||||
return new FLAC::File(stream, ID3v2::FrameFactory::instance(), readAudioProperties, audioPropertiesStyle);
|
return new FLAC::File(stream, readAudioProperties, audioPropertiesStyle);
|
||||||
if(ext == "MPC")
|
if (ext == "MPC")
|
||||||
return new MPC::File(stream, readAudioProperties, audioPropertiesStyle);
|
return new MPC::File(stream, readAudioProperties, audioPropertiesStyle);
|
||||||
if(ext == "WV")
|
if (ext == "WV")
|
||||||
return new WavPack::File(stream, readAudioProperties, audioPropertiesStyle);
|
return new WavPack::File(stream, readAudioProperties, audioPropertiesStyle);
|
||||||
if(ext == "SPX")
|
if (ext == "SPX")
|
||||||
return new Ogg::Speex::File(stream, readAudioProperties, audioPropertiesStyle);
|
return new Ogg::Speex::File(stream, readAudioProperties, audioPropertiesStyle);
|
||||||
if(ext == "OPUS")
|
if (ext == "OPUS")
|
||||||
return new Ogg::Opus::File(stream, readAudioProperties, audioPropertiesStyle);
|
return new Ogg::Opus::File(stream, readAudioProperties, audioPropertiesStyle);
|
||||||
if(ext == "TTA")
|
if (ext == "TTA")
|
||||||
return new TrueAudio::File(stream, readAudioProperties, audioPropertiesStyle);
|
return new TrueAudio::File(stream, readAudioProperties, audioPropertiesStyle);
|
||||||
if(ext == "M4A" || ext == "M4R" || ext == "M4B" || ext == "M4P" || ext == "MP4" || ext == "3G2" || ext == "M4V")
|
if (ext == "M4A" || ext == "M4R" || ext == "M4B" || ext == "M4P" || ext == "MP4" || ext == "3G2" || ext == "M4V")
|
||||||
return new MP4::File(stream, readAudioProperties, audioPropertiesStyle);
|
return new MP4::File(stream, readAudioProperties, audioPropertiesStyle);
|
||||||
if(ext == "WMA" || ext == "ASF")
|
if (ext == "WMA" || ext == "ASF")
|
||||||
return new ASF::File(stream, readAudioProperties, audioPropertiesStyle);
|
return new ASF::File(stream, readAudioProperties, audioPropertiesStyle);
|
||||||
if(ext == "AIF" || ext == "AIFF" || ext == "AFC" || ext == "AIFC")
|
if (ext == "AIF" || ext == "AIFF" || ext == "AFC" || ext == "AIFC")
|
||||||
return new RIFF::AIFF::File(stream, readAudioProperties, audioPropertiesStyle);
|
return new RIFF::AIFF::File(stream, readAudioProperties, audioPropertiesStyle);
|
||||||
if(ext == "WAV")
|
if (ext == "WAV")
|
||||||
return new RIFF::WAV::File(stream, readAudioProperties, audioPropertiesStyle);
|
return new RIFF::WAV::File(stream, readAudioProperties, audioPropertiesStyle);
|
||||||
if(ext == "APE")
|
if (ext == "APE")
|
||||||
return new APE::File(stream, readAudioProperties, audioPropertiesStyle);
|
return new APE::File(stream, readAudioProperties, audioPropertiesStyle);
|
||||||
// module, nst and wow are possible but uncommon extensions
|
// module, nst and wow are possible but uncommon extensions
|
||||||
if(ext == "MOD" || ext == "MODULE" || ext == "NST" || ext == "WOW")
|
if (ext == "MOD" || ext == "MODULE" || ext == "NST" || ext == "WOW")
|
||||||
return new Mod::File(stream, readAudioProperties, audioPropertiesStyle);
|
return new Mod::File(stream, readAudioProperties, audioPropertiesStyle);
|
||||||
if(ext == "S3M")
|
if (ext == "S3M")
|
||||||
return new S3M::File(stream, readAudioProperties, audioPropertiesStyle);
|
return new S3M::File(stream, readAudioProperties, audioPropertiesStyle);
|
||||||
if(ext == "IT")
|
if (ext == "IT")
|
||||||
return new IT::File(stream, readAudioProperties, audioPropertiesStyle);
|
return new IT::File(stream, readAudioProperties, audioPropertiesStyle);
|
||||||
if(ext == "XM")
|
if (ext == "XM")
|
||||||
return new XM::File(stream, readAudioProperties, audioPropertiesStyle);
|
return new XM::File(stream, readAudioProperties, audioPropertiesStyle);
|
||||||
if(ext == "DFF" || ext == "DSDIFF")
|
if (ext == "DFF" || ext == "DSDIFF")
|
||||||
return new DSDIFF::File(stream, readAudioProperties, audioPropertiesStyle);
|
return new DSDIFF::File(stream, readAudioProperties, audioPropertiesStyle);
|
||||||
if(ext == "DSF")
|
if (ext == "DSF")
|
||||||
return new DSF::File(stream, readAudioProperties, audioPropertiesStyle);
|
return new DSF::File(stream, readAudioProperties, audioPropertiesStyle);
|
||||||
|
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
|
||||||
|
|
||||||
// Detect the file type based on the actual content of the stream.
|
}
|
||||||
|
|
||||||
File *detectByContent(IOStream *stream, bool readAudioProperties,
|
// Detect the file type based on the actual content of the stream.
|
||||||
AudioProperties::ReadStyle audioPropertiesStyle)
|
|
||||||
{
|
|
||||||
File *file = 0;
|
|
||||||
|
|
||||||
if(MPEG::File::isSupported(stream))
|
File *detectByContent(IOStream *stream, bool readAudioProperties, AudioProperties::ReadStyle audioPropertiesStyle) {
|
||||||
|
|
||||||
|
File *file = nullptr;
|
||||||
|
|
||||||
|
if (MPEG::File::isSupported(stream))
|
||||||
file = new MPEG::File(stream, ID3v2::FrameFactory::instance(), readAudioProperties, audioPropertiesStyle);
|
file = new MPEG::File(stream, ID3v2::FrameFactory::instance(), readAudioProperties, audioPropertiesStyle);
|
||||||
else if(Ogg::Vorbis::File::isSupported(stream))
|
else if (Ogg::Vorbis::File::isSupported(stream))
|
||||||
file = new Ogg::Vorbis::File(stream, readAudioProperties, audioPropertiesStyle);
|
file = new Ogg::Vorbis::File(stream, readAudioProperties, audioPropertiesStyle);
|
||||||
else if(Ogg::FLAC::File::isSupported(stream))
|
else if (Ogg::FLAC::File::isSupported(stream))
|
||||||
file = new Ogg::FLAC::File(stream, readAudioProperties, audioPropertiesStyle);
|
file = new Ogg::FLAC::File(stream, readAudioProperties, audioPropertiesStyle);
|
||||||
else if(FLAC::File::isSupported(stream))
|
else if (FLAC::File::isSupported(stream))
|
||||||
file = new FLAC::File(stream, ID3v2::FrameFactory::instance(), readAudioProperties, audioPropertiesStyle);
|
file = new FLAC::File(stream, readAudioProperties, audioPropertiesStyle);
|
||||||
else if(MPC::File::isSupported(stream))
|
else if (MPC::File::isSupported(stream))
|
||||||
file = new MPC::File(stream, readAudioProperties, audioPropertiesStyle);
|
file = new MPC::File(stream, readAudioProperties, audioPropertiesStyle);
|
||||||
else if(WavPack::File::isSupported(stream))
|
else if (WavPack::File::isSupported(stream))
|
||||||
file = new WavPack::File(stream, readAudioProperties, audioPropertiesStyle);
|
file = new WavPack::File(stream, readAudioProperties, audioPropertiesStyle);
|
||||||
else if(Ogg::Speex::File::isSupported(stream))
|
else if (Ogg::Speex::File::isSupported(stream))
|
||||||
file = new Ogg::Speex::File(stream, readAudioProperties, audioPropertiesStyle);
|
file = new Ogg::Speex::File(stream, readAudioProperties, audioPropertiesStyle);
|
||||||
else if(Ogg::Opus::File::isSupported(stream))
|
else if (Ogg::Opus::File::isSupported(stream))
|
||||||
file = new Ogg::Opus::File(stream, readAudioProperties, audioPropertiesStyle);
|
file = new Ogg::Opus::File(stream, readAudioProperties, audioPropertiesStyle);
|
||||||
else if(TrueAudio::File::isSupported(stream))
|
else if (TrueAudio::File::isSupported(stream))
|
||||||
file = new TrueAudio::File(stream, readAudioProperties, audioPropertiesStyle);
|
file = new TrueAudio::File(stream, readAudioProperties, audioPropertiesStyle);
|
||||||
else if(MP4::File::isSupported(stream))
|
else if (MP4::File::isSupported(stream))
|
||||||
file = new MP4::File(stream, readAudioProperties, audioPropertiesStyle);
|
file = new MP4::File(stream, readAudioProperties, audioPropertiesStyle);
|
||||||
else if(ASF::File::isSupported(stream))
|
else if (ASF::File::isSupported(stream))
|
||||||
file = new ASF::File(stream, readAudioProperties, audioPropertiesStyle);
|
file = new ASF::File(stream, readAudioProperties, audioPropertiesStyle);
|
||||||
else if(RIFF::AIFF::File::isSupported(stream))
|
else if (RIFF::AIFF::File::isSupported(stream))
|
||||||
file = new RIFF::AIFF::File(stream, readAudioProperties, audioPropertiesStyle);
|
file = new RIFF::AIFF::File(stream, readAudioProperties, audioPropertiesStyle);
|
||||||
else if(RIFF::WAV::File::isSupported(stream))
|
else if (RIFF::WAV::File::isSupported(stream))
|
||||||
file = new RIFF::WAV::File(stream, readAudioProperties, audioPropertiesStyle);
|
file = new RIFF::WAV::File(stream, readAudioProperties, audioPropertiesStyle);
|
||||||
else if(APE::File::isSupported(stream))
|
else if (APE::File::isSupported(stream))
|
||||||
file = new APE::File(stream, readAudioProperties, audioPropertiesStyle);
|
file = new APE::File(stream, readAudioProperties, audioPropertiesStyle);
|
||||||
else if(DSDIFF::File::isSupported(stream))
|
else if (DSDIFF::File::isSupported(stream))
|
||||||
file = new DSDIFF::File(stream, readAudioProperties, audioPropertiesStyle);
|
file = new DSDIFF::File(stream, readAudioProperties, audioPropertiesStyle);
|
||||||
else if(DSF::File::isSupported(stream))
|
else if (DSF::File::isSupported(stream))
|
||||||
file = new DSF::File(stream, readAudioProperties, audioPropertiesStyle);
|
file = new DSF::File(stream, readAudioProperties, audioPropertiesStyle);
|
||||||
|
|
||||||
// isSupported() only does a quick check, so double check the file here.
|
// isSupported() only does a quick check, so double check the file here.
|
||||||
|
|
||||||
if(file) {
|
if (file) {
|
||||||
if(file->isValid())
|
if (file->isValid())
|
||||||
return file;
|
return file;
|
||||||
else
|
else
|
||||||
delete file;
|
delete file;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
|
||||||
|
|
||||||
// Internal function that supports FileRef::create().
|
|
||||||
// This looks redundant, but necessary in order not to change the previous
|
|
||||||
// behavior of FileRef::create().
|
|
||||||
|
|
||||||
File* createInternal(FileName fileName, bool readAudioProperties,
|
|
||||||
AudioProperties::ReadStyle audioPropertiesStyle)
|
|
||||||
{
|
|
||||||
File *file = detectByResolvers(fileName, readAudioProperties, audioPropertiesStyle);
|
|
||||||
if(file)
|
|
||||||
return file;
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
const String s = fileName.toString();
|
|
||||||
#else
|
|
||||||
const String s(fileName);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
String ext;
|
|
||||||
const int pos = s.rfind(".");
|
|
||||||
if(pos != -1)
|
|
||||||
ext = s.substr(pos + 1).upper();
|
|
||||||
|
|
||||||
if(ext.isEmpty())
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if(ext == "MP3")
|
|
||||||
return new MPEG::File(fileName, ID3v2::FrameFactory::instance(), readAudioProperties, audioPropertiesStyle);
|
|
||||||
if(ext == "OGG")
|
|
||||||
return new Ogg::Vorbis::File(fileName, readAudioProperties, audioPropertiesStyle);
|
|
||||||
if(ext == "OGA") {
|
|
||||||
/* .oga can be any audio in the Ogg container. First try FLAC, then Vorbis. */
|
|
||||||
File *file = new Ogg::FLAC::File(fileName, readAudioProperties, audioPropertiesStyle);
|
|
||||||
if(file->isValid())
|
|
||||||
return file;
|
|
||||||
delete file;
|
|
||||||
return new Ogg::Vorbis::File(fileName, readAudioProperties, audioPropertiesStyle);
|
|
||||||
}
|
|
||||||
if(ext == "FLAC")
|
|
||||||
return new FLAC::File(fileName, ID3v2::FrameFactory::instance(), readAudioProperties, audioPropertiesStyle);
|
|
||||||
if(ext == "MPC")
|
|
||||||
return new MPC::File(fileName, readAudioProperties, audioPropertiesStyle);
|
|
||||||
if(ext == "WV")
|
|
||||||
return new WavPack::File(fileName, readAudioProperties, audioPropertiesStyle);
|
|
||||||
if(ext == "SPX")
|
|
||||||
return new Ogg::Speex::File(fileName, readAudioProperties, audioPropertiesStyle);
|
|
||||||
if(ext == "OPUS")
|
|
||||||
return new Ogg::Opus::File(fileName, readAudioProperties, audioPropertiesStyle);
|
|
||||||
if(ext == "TTA")
|
|
||||||
return new TrueAudio::File(fileName, readAudioProperties, audioPropertiesStyle);
|
|
||||||
if(ext == "M4A" || ext == "M4R" || ext == "M4B" || ext == "M4P" || ext == "MP4" || ext == "3G2" || ext == "M4V")
|
|
||||||
return new MP4::File(fileName, readAudioProperties, audioPropertiesStyle);
|
|
||||||
if(ext == "WMA" || ext == "ASF")
|
|
||||||
return new ASF::File(fileName, readAudioProperties, audioPropertiesStyle);
|
|
||||||
if(ext == "AIF" || ext == "AIFF" || ext == "AFC" || ext == "AIFC")
|
|
||||||
return new RIFF::AIFF::File(fileName, readAudioProperties, audioPropertiesStyle);
|
|
||||||
if(ext == "WAV")
|
|
||||||
return new RIFF::WAV::File(fileName, readAudioProperties, audioPropertiesStyle);
|
|
||||||
if(ext == "APE")
|
|
||||||
return new APE::File(fileName, readAudioProperties, audioPropertiesStyle);
|
|
||||||
// module, nst and wow are possible but uncommon extensions
|
|
||||||
if(ext == "MOD" || ext == "MODULE" || ext == "NST" || ext == "WOW")
|
|
||||||
return new Mod::File(fileName, readAudioProperties, audioPropertiesStyle);
|
|
||||||
if(ext == "S3M")
|
|
||||||
return new S3M::File(fileName, readAudioProperties, audioPropertiesStyle);
|
|
||||||
if(ext == "IT")
|
|
||||||
return new IT::File(fileName, readAudioProperties, audioPropertiesStyle);
|
|
||||||
if(ext == "XM")
|
|
||||||
return new XM::File(fileName, readAudioProperties, audioPropertiesStyle);
|
|
||||||
if(ext == "DFF" || ext == "DSDIFF")
|
|
||||||
return new DSDIFF::File(fileName, readAudioProperties, audioPropertiesStyle);
|
|
||||||
if(ext == "DSF")
|
|
||||||
return new DSF::File(fileName, readAudioProperties, audioPropertiesStyle);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class FileRef::FileRefPrivate : public RefCounter
|
struct FileRefData {
|
||||||
{
|
FileRefData() : file(nullptr), stream(nullptr) {}
|
||||||
public:
|
|
||||||
FileRefPrivate() :
|
|
||||||
RefCounter(),
|
|
||||||
file(0),
|
|
||||||
stream(0) {}
|
|
||||||
|
|
||||||
~FileRefPrivate() {
|
~FileRefData() {
|
||||||
delete file;
|
delete file;
|
||||||
delete stream;
|
delete stream;
|
||||||
}
|
}
|
||||||
@@ -291,86 +209,108 @@ public:
|
|||||||
IOStream *stream;
|
IOStream *stream;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
class FileRef::FileRefPrivate {
|
||||||
|
public:
|
||||||
|
FileRefPrivate() : data(new FileRefData()) {}
|
||||||
|
|
||||||
|
std::shared_ptr<FileRefData> data;
|
||||||
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// public members
|
// public members
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
FileRef::FileRef() :
|
FileRef::FileRef() : d(new FileRefPrivate()) {}
|
||||||
d(new FileRefPrivate())
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
FileRef::FileRef(FileName fileName, bool readAudioProperties,
|
FileRef::FileRef(FileName fileName, bool readAudioProperties, AudioProperties::ReadStyle audioPropertiesStyle) : d(new FileRefPrivate()) {
|
||||||
AudioProperties::ReadStyle audioPropertiesStyle) :
|
|
||||||
d(new FileRefPrivate())
|
|
||||||
{
|
|
||||||
parse(fileName, readAudioProperties, audioPropertiesStyle);
|
parse(fileName, readAudioProperties, audioPropertiesStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
FileRef::FileRef(IOStream* stream, bool readAudioProperties, AudioProperties::ReadStyle audioPropertiesStyle) :
|
FileRef::FileRef(IOStream *stream, bool readAudioProperties, AudioProperties::ReadStyle audioPropertiesStyle) : d(new FileRefPrivate()) {
|
||||||
d(new FileRefPrivate())
|
|
||||||
{
|
|
||||||
parse(stream, readAudioProperties, audioPropertiesStyle);
|
parse(stream, readAudioProperties, audioPropertiesStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
FileRef::FileRef(File *file) :
|
FileRef::FileRef(File *file) : d(new FileRefPrivate()) {
|
||||||
d(new FileRefPrivate())
|
d->data->file = file;
|
||||||
{
|
|
||||||
d->file = file;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FileRef::FileRef(const FileRef &ref) :
|
FileRef::FileRef(const FileRef &ref) : d(new FileRefPrivate(*ref.d)) {}
|
||||||
d(ref.d)
|
|
||||||
{
|
|
||||||
d->ref();
|
|
||||||
}
|
|
||||||
|
|
||||||
FileRef::~FileRef()
|
FileRef::~FileRef() {
|
||||||
{
|
|
||||||
if(d->deref())
|
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
Tag *FileRef::tag() const
|
Tag *FileRef::tag() const {
|
||||||
{
|
|
||||||
if(isNull()) {
|
if (isNull()) {
|
||||||
debug("FileRef::tag() - Called without a valid file.");
|
debug("FileRef::tag() - Called without a valid file.");
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return d->file->tag();
|
return d->data->file->tag();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioProperties *FileRef::audioProperties() const
|
PropertyMap FileRef::properties() const {
|
||||||
{
|
if (isNull()) {
|
||||||
if(isNull()) {
|
debug("FileRef::properties() - Called without a valid file.");
|
||||||
|
return PropertyMap();
|
||||||
|
}
|
||||||
|
|
||||||
|
return d->data->file->properties();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FileRef::removeUnsupportedProperties(const StringList &properties) {
|
||||||
|
if (isNull()) {
|
||||||
|
debug("FileRef::removeUnsupportedProperties() - Called without a valid file.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
d->data->file->removeUnsupportedProperties(properties);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PropertyMap FileRef::setProperties(const PropertyMap &properties) {
|
||||||
|
if (isNull()) {
|
||||||
|
debug("FileRef::setProperties() - Called without a valid file.");
|
||||||
|
return PropertyMap();
|
||||||
|
}
|
||||||
|
|
||||||
|
return d->data->file->setProperties(properties);
|
||||||
|
}
|
||||||
|
|
||||||
|
AudioProperties *FileRef::audioProperties() const {
|
||||||
|
|
||||||
|
if (isNull()) {
|
||||||
debug("FileRef::audioProperties() - Called without a valid file.");
|
debug("FileRef::audioProperties() - Called without a valid file.");
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return d->file->audioProperties();
|
return d->data->file->audioProperties();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
File *FileRef::file() const
|
File *FileRef::file() const {
|
||||||
{
|
return d->data->file;
|
||||||
return d->file;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FileRef::save()
|
bool FileRef::save() {
|
||||||
{
|
|
||||||
if(isNull()) {
|
if (isNull()) {
|
||||||
debug("FileRef::save() - Called without a valid file.");
|
debug("FileRef::save() - Called without a valid file.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return d->file->save();
|
return d->data->file->save();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const FileRef::FileTypeResolver *FileRef::addFileTypeResolver(const FileRef::FileTypeResolver *resolver) // static
|
const FileRef::FileTypeResolver *FileRef::addFileTypeResolver(const FileRef::FileTypeResolver *resolver) { // static
|
||||||
{
|
|
||||||
fileTypeResolvers.prepend(resolver);
|
fileTypeResolvers.prepend(resolver);
|
||||||
return resolver;
|
return resolver;
|
||||||
}
|
}
|
||||||
|
|
||||||
StringList FileRef::defaultFileExtensions()
|
StringList FileRef::defaultFileExtensions() {
|
||||||
{
|
|
||||||
StringList l;
|
StringList l;
|
||||||
|
|
||||||
l.append("ogg");
|
l.append("ogg");
|
||||||
@@ -406,86 +346,79 @@ StringList FileRef::defaultFileExtensions()
|
|||||||
l.append("dsdiff"); // alias for "dff"
|
l.append("dsdiff"); // alias for "dff"
|
||||||
|
|
||||||
return l;
|
return l;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FileRef::isNull() const
|
bool FileRef::isValid() const {
|
||||||
{
|
return (d->data->file && d->data->file->isValid());
|
||||||
return (!d->file || !d->file->isValid());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FileRef &FileRef::operator=(const FileRef &ref)
|
bool FileRef::isNull() const {
|
||||||
{
|
return (!d->data->file || !d->data->file->isValid());
|
||||||
|
}
|
||||||
|
|
||||||
|
FileRef &FileRef::operator=(const FileRef &ref) {
|
||||||
FileRef(ref).swap(*this);
|
FileRef(ref).swap(*this);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileRef::swap(FileRef &ref)
|
void FileRef::swap(FileRef &ref) {
|
||||||
{
|
|
||||||
using std::swap;
|
using std::swap;
|
||||||
|
|
||||||
swap(d, ref.d);
|
swap(d, ref.d);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FileRef::operator==(const FileRef &ref) const
|
bool FileRef::operator==(const FileRef &ref) const {
|
||||||
{
|
return (ref.d->data == d->data);
|
||||||
return (ref.d->file == d->file);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FileRef::operator!=(const FileRef &ref) const
|
bool FileRef::operator!=(const FileRef &ref) const {
|
||||||
{
|
return (ref.d->data != d->data);
|
||||||
return (ref.d->file != d->file);
|
|
||||||
}
|
|
||||||
|
|
||||||
File *FileRef::create(FileName fileName, bool readAudioProperties,
|
|
||||||
AudioProperties::ReadStyle audioPropertiesStyle) // static
|
|
||||||
{
|
|
||||||
return createInternal(fileName, readAudioProperties, audioPropertiesStyle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// private members
|
// private members
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void FileRef::parse(FileName fileName, bool readAudioProperties,
|
void FileRef::parse(FileName fileName, bool readAudioProperties, AudioProperties::ReadStyle audioPropertiesStyle) {
|
||||||
AudioProperties::ReadStyle audioPropertiesStyle)
|
|
||||||
{
|
|
||||||
// Try user-defined resolvers.
|
// Try user-defined resolvers.
|
||||||
|
|
||||||
d->file = detectByResolvers(fileName, readAudioProperties, audioPropertiesStyle);
|
d->data->file = detectByResolvers(fileName, readAudioProperties, audioPropertiesStyle);
|
||||||
if(d->file)
|
if (d->data->file)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Try to resolve file types based on the file extension.
|
// Try to resolve file types based on the file extension.
|
||||||
|
|
||||||
d->stream = new FileStream(fileName);
|
d->data->stream = new FileStream(fileName);
|
||||||
d->file = detectByExtension(d->stream, readAudioProperties, audioPropertiesStyle);
|
d->data->file = detectByExtension(d->data->stream, readAudioProperties, audioPropertiesStyle);
|
||||||
if(d->file)
|
if (d->data->file)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// At last, try to resolve file types based on the actual content.
|
// At last, try to resolve file types based on the actual content.
|
||||||
|
|
||||||
d->file = detectByContent(d->stream, readAudioProperties, audioPropertiesStyle);
|
d->data->file = detectByContent(d->data->stream, readAudioProperties, audioPropertiesStyle);
|
||||||
if(d->file)
|
if (d->data->file)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Stream have to be closed here if failed to resolve file types.
|
// Stream have to be closed here if failed to resolve file types.
|
||||||
|
|
||||||
delete d->stream;
|
delete d->data->stream;
|
||||||
d->stream = 0;
|
d->data->stream = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileRef::parse(IOStream *stream, bool readAudioProperties,
|
void FileRef::parse(IOStream *stream, bool readAudioProperties, AudioProperties::ReadStyle audioPropertiesStyle) {
|
||||||
AudioProperties::ReadStyle audioPropertiesStyle)
|
|
||||||
{
|
|
||||||
// User-defined resolvers won't work with a stream.
|
// User-defined resolvers won't work with a stream.
|
||||||
|
|
||||||
// Try to resolve file types based on the file extension.
|
// Try to resolve file types based on the file extension.
|
||||||
|
|
||||||
d->file = detectByExtension(stream, readAudioProperties, audioPropertiesStyle);
|
d->data->file = detectByExtension(stream, readAudioProperties, audioPropertiesStyle);
|
||||||
if(d->file)
|
if (d->data->file)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// At last, try to resolve file types based on the actual content of the file.
|
// At last, try to resolve file types based on the actual content of the file.
|
||||||
|
|
||||||
d->file = detectByContent(stream, readAudioProperties, audioPropertiesStyle);
|
d->data->file = detectByContent(stream, readAudioProperties, audioPropertiesStyle);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
168
3rdparty/taglib/fileref.h
vendored
168
3rdparty/taglib/fileref.h
vendored
@@ -30,41 +30,37 @@
|
|||||||
#include "tstringlist.h"
|
#include "tstringlist.h"
|
||||||
|
|
||||||
#include "taglib_export.h"
|
#include "taglib_export.h"
|
||||||
|
#include "tpropertymap.h"
|
||||||
#include "audioproperties.h"
|
#include "audioproperties.h"
|
||||||
|
|
||||||
|
namespace Strawberry_TagLib {
|
||||||
namespace TagLib {
|
namespace TagLib {
|
||||||
|
|
||||||
class Tag;
|
class Tag;
|
||||||
|
|
||||||
//! This class provides a simple abstraction for creating and handling files
|
//! This class provides a simple abstraction for creating and handling files
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* FileRef exists to provide a minimal, generic and value-based wrapper around
|
* FileRef exists to provide a minimal, generic and value-based wrapper around a File.
|
||||||
* a File. It is lightweight and implicitly shared, and as such suitable for
|
* It is lightweight and implicitly shared, and as such suitable for pass-by-value use.
|
||||||
* pass-by-value use. This hides some of the uglier details of TagLib::File
|
* This hides some of the uglier details of TagLib::File and the non-generic portions of the concrete file implementations.
|
||||||
* and the non-generic portions of the concrete file implementations.
|
|
||||||
*
|
*
|
||||||
* This class is useful in a "simple usage" situation where it is desirable
|
* This class is useful in a "simple usage" situation where it is desirable
|
||||||
* to be able to get and set some of the tag information that is similar
|
* to be able to get and set some of the tag information that is similar across file types.
|
||||||
* across file types.
|
|
||||||
*
|
*
|
||||||
* Also note that it is probably a good idea to plug this into your mime
|
* Also note that it is probably a good idea to plug this into your mime
|
||||||
* type system rather than using the constructor that accepts a file name using
|
* type system rather than using the constructor that accepts a file name using the FileTypeResolver.
|
||||||
* the FileTypeResolver.
|
|
||||||
*
|
*
|
||||||
* \see FileTypeResolver
|
* \see FileTypeResolver
|
||||||
* \see addFileTypeResolver()
|
* \see addFileTypeResolver()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class TAGLIB_EXPORT FileRef
|
class TAGLIB_EXPORT FileRef {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//! A class for pluggable file type resolution.
|
//! A class for pluggable file type resolution.
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* This class is used to add extend TagLib's very basic file name based file
|
* This class is used to add extend TagLib's very basic file name based file type resolution.
|
||||||
* type resolution.
|
|
||||||
*
|
*
|
||||||
* This can be accomplished with:
|
* This can be accomplished with:
|
||||||
*
|
*
|
||||||
@@ -72,10 +68,10 @@ namespace TagLib {
|
|||||||
*
|
*
|
||||||
* class MyFileTypeResolver : FileTypeResolver
|
* class MyFileTypeResolver : FileTypeResolver
|
||||||
* {
|
* {
|
||||||
* TagLib::File *createFile(TagLib::FileName *fileName, bool, AudioProperties::ReadStyle) const
|
* Strawberry_TagLib::TagLib::File *createFile(Strawberry_TagLib::TagLib::FileName *fileName, bool, AudioProperties::ReadStyle) const
|
||||||
* {
|
* {
|
||||||
* if(someCheckForAnMP3File(fileName))
|
* if(someCheckForAnMP3File(fileName))
|
||||||
* return new TagLib::MPEG::File(fileName);
|
* return new Strawberry_TagLib::TagLib::MPEG::File(fileName);
|
||||||
* return 0;
|
* return 0;
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
@@ -84,69 +80,52 @@ namespace TagLib {
|
|||||||
*
|
*
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* Naturally a less contrived example would be slightly more complex. This
|
* Naturally a less contrived example would be slightly more complex.
|
||||||
* can be used to plug in mime-type detection systems or to add new file types
|
* This can be used to plug in mime-type detection systems or to add new file types to TagLib.
|
||||||
* to TagLib.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class TAGLIB_EXPORT FileTypeResolver
|
class TAGLIB_EXPORT FileTypeResolver {
|
||||||
{
|
|
||||||
TAGLIB_IGNORE_MISSING_DESTRUCTOR
|
|
||||||
public:
|
public:
|
||||||
|
virtual ~FileTypeResolver() {}
|
||||||
/*!
|
/*!
|
||||||
* This method must be overridden to provide an additional file type
|
* This method must be overridden to provide an additional file type resolver.
|
||||||
* resolver. If the resolver is able to determine the file type it should
|
* If the resolver is able to determine the file type it should return a valid File object; if not it should return 0.
|
||||||
* return a valid File object; if not it should return 0.
|
|
||||||
*
|
*
|
||||||
* \note The created file is then owned by the FileRef and should not be
|
* \note The created file is then owned by the FileRef and should not be deleted.
|
||||||
* deleted. Deletion will happen automatically when the FileRef passes
|
* Deletion will happen automatically when the FileRef passes out of scope.
|
||||||
* out of scope.
|
|
||||||
*/
|
*/
|
||||||
virtual File *createFile(FileName fileName,
|
virtual File *createFile(FileName fileName, bool readAudioProperties = true, AudioProperties::ReadStyle audioPropertiesStyle = AudioProperties::Average) const = 0;
|
||||||
bool readAudioProperties = true,
|
|
||||||
AudioProperties::ReadStyle
|
|
||||||
audioPropertiesStyle = AudioProperties::Average) const = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Creates a null FileRef.
|
* Creates a null FileRef.
|
||||||
*/
|
*/
|
||||||
FileRef();
|
explicit FileRef();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Create a FileRef from \a fileName. If \a readAudioProperties is true then
|
* Create a FileRef from \a fileName.
|
||||||
* the audio properties will be read using \a audioPropertiesStyle. If
|
* If \a readAudioProperties is true then the audio properties will be read using \a audioPropertiesStyle.
|
||||||
* \a readAudioProperties is false then \a audioPropertiesStyle will be
|
* If \a readAudioProperties is false then \a audioPropertiesStyle will be ignored.
|
||||||
* ignored.
|
|
||||||
*
|
*
|
||||||
* Also see the note in the class documentation about why you may not want to
|
* Also see the note in the class documentation about why you may not want to
|
||||||
* use this method in your application.
|
* use this method in your application.
|
||||||
*/
|
*/
|
||||||
explicit FileRef(FileName fileName,
|
explicit FileRef(FileName fileName, bool readAudioProperties = true, AudioProperties::ReadStyle audioPropertiesStyle = AudioProperties::Average);
|
||||||
bool readAudioProperties = true,
|
|
||||||
AudioProperties::ReadStyle
|
|
||||||
audioPropertiesStyle = AudioProperties::Average);
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Construct a FileRef from an opened \a IOStream. If \a readAudioProperties
|
* Construct a FileRef from an opened \a IOStream.
|
||||||
* is true then the audio properties will be read using \a audioPropertiesStyle.
|
* If \a readAudioProperties is true then the audio properties will be read using \a audioPropertiesStyle.
|
||||||
* If \a readAudioProperties is false then \a audioPropertiesStyle will be
|
* If \a readAudioProperties is false then \a audioPropertiesStyle will be ignored.
|
||||||
* ignored.
|
|
||||||
*
|
*
|
||||||
* Also see the note in the class documentation about why you may not want to
|
* Also see the note in the class documentation about why you may not want to use this method in your application.
|
||||||
* use this method in your application.
|
|
||||||
*
|
*
|
||||||
* \note TagLib will *not* take ownership of the stream, the caller is
|
* \note TagLib will *not* take ownership of the stream, the caller is responsible for deleting it after the File object.
|
||||||
* responsible for deleting it after the File object.
|
|
||||||
*/
|
*/
|
||||||
explicit FileRef(IOStream* stream,
|
explicit FileRef(IOStream *stream, bool readAudioProperties = true, AudioProperties::ReadStyle audioPropertiesStyle = AudioProperties::Average);
|
||||||
bool readAudioProperties = true,
|
|
||||||
AudioProperties::ReadStyle
|
|
||||||
audioPropertiesStyle = AudioProperties::Average);
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Construct a FileRef using \a file. The FileRef now takes ownership of the
|
* Construct a FileRef using \a file.
|
||||||
* pointer and will delete the File when it passes out of scope.
|
* The FileRef now takes ownership of the pointer and will delete the File when it passes out of scope.
|
||||||
*/
|
*/
|
||||||
explicit FileRef(File *file);
|
explicit FileRef(File *file);
|
||||||
|
|
||||||
@@ -174,8 +153,36 @@ namespace TagLib {
|
|||||||
Tag *tag() const;
|
Tag *tag() const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the audio properties for this FileRef. If no audio properties
|
* Exports the tags of the file as dictionary mapping (human readable) tag names (uppercase Strings) to StringLists of tag values.
|
||||||
* were read then this will returns a null pointer.
|
* Calls the according specialization in the File subclasses.
|
||||||
|
* For each metadata object of the file that could not be parsed into the PropertyMap format,
|
||||||
|
* the returend map's unsupportedData() list will contain one entry identifying that object (e.g. the frame type for ID3v2 tags).
|
||||||
|
* Use removeUnsupportedProperties() to remove (a subset of) them.
|
||||||
|
* For files that contain more than one tag (e.g. an MP3 with both an ID3v1 and an ID3v2 tag) only the most "modern" one will be exported (ID3v2 in this case).
|
||||||
|
*/
|
||||||
|
PropertyMap properties() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Removes unsupported properties, or a subset of them, from the file's metadata.
|
||||||
|
* The parameter \a properties must contain only entries from properties().unsupportedData().
|
||||||
|
*/
|
||||||
|
void removeUnsupportedProperties(const StringList &properties);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Sets the tags of this File to those specified in \a properties.
|
||||||
|
* Calls the according specialization method in the subclasses of File to do the translation into the format-specific details.
|
||||||
|
* If some value(s) could not be written imported to the specific metadata format,
|
||||||
|
* the returned PropertyMap will contain those value(s). Otherwise it will be empty, indicating that no problems occured.
|
||||||
|
* With file types that support several tag formats (for instance, MP3 files can have ID3v1, ID3v2, and APEv2 tags),
|
||||||
|
* this function will create the most appropriate one (ID3v2 for MP3 files). Older formats will be updated as well,
|
||||||
|
* if they exist, but won't be taken into account for the return value of this function.
|
||||||
|
* See the documentation of the subclass implementations for detailed descriptions.
|
||||||
|
*/
|
||||||
|
PropertyMap setProperties(const PropertyMap &properties);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the audio properties for this FileRef.
|
||||||
|
* If no audio properties were read then this will returns a null pointer.
|
||||||
*/
|
*/
|
||||||
AudioProperties *audioProperties() const;
|
AudioProperties *audioProperties() const;
|
||||||
|
|
||||||
@@ -202,14 +209,12 @@ namespace TagLib {
|
|||||||
bool save();
|
bool save();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Adds a FileTypeResolver to the list of those used by TagLib. Each
|
* Adds a FileTypeResolver to the list of those used by TagLib.
|
||||||
* additional FileTypeResolver is added to the front of a list of resolvers
|
* Each additional FileTypeResolver is added to the front of a list of resolvers that are tried.
|
||||||
* that are tried. If the FileTypeResolver returns zero the next resolver
|
* If the FileTypeResolver returns zero the next resolver is tried.
|
||||||
* is tried.
|
|
||||||
*
|
*
|
||||||
* Returns a pointer to the added resolver (the same one that's passed in --
|
* Returns a pointer to the added resolver (the same one that's passed in --
|
||||||
* this is mostly so that static initializers have something to use for
|
* this is mostly so that static initializers have something to use for assignment).
|
||||||
* assignment).
|
|
||||||
*
|
*
|
||||||
* \see FileTypeResolver
|
* \see FileTypeResolver
|
||||||
*/
|
*/
|
||||||
@@ -217,8 +222,7 @@ namespace TagLib {
|
|||||||
|
|
||||||
/*!
|
/*!
|
||||||
* As is mentioned elsewhere in this class's documentation, the default file
|
* As is mentioned elsewhere in this class's documentation, the default file
|
||||||
* type resolution code provided by TagLib only works by comparing file
|
* type resolution code provided by TagLib only works by comparing file extensions.
|
||||||
* extensions.
|
|
||||||
*
|
*
|
||||||
* This method returns the list of file extensions that are used by default.
|
* This method returns the list of file extensions that are used by default.
|
||||||
*
|
*
|
||||||
@@ -233,6 +237,13 @@ namespace TagLib {
|
|||||||
*/
|
*/
|
||||||
static StringList defaultFileExtensions();
|
static StringList defaultFileExtensions();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns true if the file is open and readable.
|
||||||
|
*
|
||||||
|
* \note Just a negative of isNull().
|
||||||
|
*/
|
||||||
|
bool isValid() const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns true if the file (and as such other pointers) are null.
|
* Returns true if the file (and as such other pointers) are null.
|
||||||
*/
|
*/
|
||||||
@@ -254,34 +265,19 @@ namespace TagLib {
|
|||||||
bool operator==(const FileRef &ref) const;
|
bool operator==(const FileRef &ref) const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns true if this FileRef and \a ref do not point to the same File
|
* Returns true if this FileRef and \a ref do not point to the same File object.
|
||||||
* object.
|
|
||||||
*/
|
*/
|
||||||
bool operator!=(const FileRef &ref) const;
|
bool operator!=(const FileRef &ref) const;
|
||||||
|
|
||||||
/*!
|
|
||||||
* A simple implementation of file type guessing. If \a readAudioProperties
|
|
||||||
* is true then the audio properties will be read using
|
|
||||||
* \a audioPropertiesStyle. If \a readAudioProperties is false then
|
|
||||||
* \a audioPropertiesStyle will be ignored.
|
|
||||||
*
|
|
||||||
* \note You generally shouldn't use this method, but instead the constructor
|
|
||||||
* directly.
|
|
||||||
*
|
|
||||||
* \deprecated
|
|
||||||
*/
|
|
||||||
static File *create(FileName fileName,
|
|
||||||
bool readAudioProperties = true,
|
|
||||||
AudioProperties::ReadStyle audioPropertiesStyle = AudioProperties::Average);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void parse(FileName fileName, bool readAudioProperties, AudioProperties::ReadStyle audioPropertiesStyle);
|
void parse(FileName fileName, bool readAudioProperties, AudioProperties::ReadStyle audioPropertiesStyle);
|
||||||
void parse(IOStream *stream, bool readAudioProperties, AudioProperties::ReadStyle audioPropertiesStyle);
|
void parse(IOStream *stream, bool readAudioProperties, AudioProperties::ReadStyle audioPropertiesStyle);
|
||||||
|
|
||||||
class FileRefPrivate;
|
class FileRefPrivate;
|
||||||
FileRefPrivate *d;
|
FileRefPrivate *d;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace TagLib
|
} // namespace TagLib
|
||||||
|
} // namespace Strawberry_TagLib
|
||||||
|
|
||||||
#endif
|
#endif // TAGLIB_FILEREF_H
|
||||||
|
|||||||
358
3rdparty/taglib/flac/flacfile.cpp
vendored
358
3rdparty/taglib/flac/flacfile.cpp
vendored
@@ -23,75 +23,85 @@
|
|||||||
* http://www.mozilla.org/MPL/ *
|
* http://www.mozilla.org/MPL/ *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include <tbytevector.h>
|
#include <memory>
|
||||||
#include <tstring.h>
|
|
||||||
#include <tlist.h>
|
|
||||||
#include <tdebug.h>
|
|
||||||
#include <tagunion.h>
|
|
||||||
#include <tpropertymap.h>
|
|
||||||
#include <tagutils.h>
|
|
||||||
|
|
||||||
#include <id3v2header.h>
|
#include "tbytevector.h"
|
||||||
#include <id3v2tag.h>
|
#include "tstring.h"
|
||||||
#include <id3v1tag.h>
|
#include "tlist.h"
|
||||||
#include <xiphcomment.h>
|
#include "tdebug.h"
|
||||||
|
#include "tagunion.h"
|
||||||
|
#include "tpropertymap.h"
|
||||||
|
#include "tagutils.h"
|
||||||
|
|
||||||
|
#include "id3v2header.h"
|
||||||
|
#include "id3v2tag.h"
|
||||||
|
#include "id3v1tag.h"
|
||||||
|
#include "xiphcomment.h"
|
||||||
|
|
||||||
#include "flacpicture.h"
|
#include "flacpicture.h"
|
||||||
#include "flacfile.h"
|
#include "flacfile.h"
|
||||||
#include "flacmetadatablock.h"
|
#include "flacmetadatablock.h"
|
||||||
#include "flacunknownmetadatablock.h"
|
#include "flacunknownmetadatablock.h"
|
||||||
|
|
||||||
using namespace TagLib;
|
using namespace Strawberry_TagLib::TagLib;
|
||||||
|
|
||||||
namespace
|
namespace {
|
||||||
{
|
typedef List<std::shared_ptr<FLAC::MetadataBlock>> BlockList;
|
||||||
typedef List<FLAC::MetadataBlock *> BlockList;
|
typedef BlockList::Iterator BlockIterator;
|
||||||
typedef BlockList::Iterator BlockIterator;
|
typedef BlockList::Iterator BlockConstIterator;
|
||||||
typedef BlockList::Iterator BlockConstIterator;
|
|
||||||
|
|
||||||
enum { FlacXiphIndex = 0, FlacID3v2Index = 1, FlacID3v1Index = 2 };
|
enum { FlacXiphIndex = 0,
|
||||||
|
FlacID3v2Index = 1,
|
||||||
|
FlacID3v1Index = 2 };
|
||||||
|
|
||||||
const long MinPaddingLength = 4096;
|
const long long MinPaddingLength = 4096;
|
||||||
const long MaxPaddingLegnth = 1024 * 1024;
|
const long long MaxPaddingLegnth = 1024 * 1024;
|
||||||
|
|
||||||
const char LastBlockFlag = '\x80';
|
const char LastBlockFlag = '\x80';
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
namespace Strawberry_TagLib {
|
||||||
|
namespace TagLib {
|
||||||
|
namespace FLAC {
|
||||||
|
// Enables BlockList::find() to take raw pointers.
|
||||||
|
|
||||||
|
bool operator==(std::shared_ptr<MetadataBlock> lhs, MetadataBlock *rhs);
|
||||||
|
bool operator==(std::shared_ptr<MetadataBlock> lhs, MetadataBlock *rhs) {
|
||||||
|
return lhs.get() == rhs;
|
||||||
}
|
}
|
||||||
|
} // namespace FLAC
|
||||||
|
} // namespace TagLib
|
||||||
|
} // namespace Strawberry_TagLib
|
||||||
|
|
||||||
class FLAC::File::FilePrivate
|
class FLAC::File::FilePrivate {
|
||||||
{
|
public:
|
||||||
public:
|
explicit FilePrivate(const ID3v2::FrameFactory *frameFactory) : ID3v2FrameFactory(ID3v2::FrameFactory::instance()),
|
||||||
FilePrivate(const ID3v2::FrameFactory *frameFactory = ID3v2::FrameFactory::instance()) :
|
|
||||||
ID3v2FrameFactory(frameFactory),
|
|
||||||
ID3v2Location(-1),
|
ID3v2Location(-1),
|
||||||
ID3v2OriginalSize(0),
|
ID3v2OriginalSize(0),
|
||||||
ID3v1Location(-1),
|
ID3v1Location(-1),
|
||||||
properties(0),
|
|
||||||
flacStart(0),
|
flacStart(0),
|
||||||
streamStart(0),
|
streamStart(0),
|
||||||
scanned(false)
|
scanned(false) {
|
||||||
{
|
|
||||||
blocks.setAutoDelete(true);
|
if (frameFactory)
|
||||||
}
|
ID3v2FrameFactory = frameFactory;
|
||||||
|
|
||||||
~FilePrivate()
|
|
||||||
{
|
|
||||||
delete properties;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const ID3v2::FrameFactory *ID3v2FrameFactory;
|
const ID3v2::FrameFactory *ID3v2FrameFactory;
|
||||||
long ID3v2Location;
|
long long ID3v2Location;
|
||||||
long ID3v2OriginalSize;
|
long long ID3v2OriginalSize;
|
||||||
|
|
||||||
long ID3v1Location;
|
long long ID3v1Location;
|
||||||
|
|
||||||
TagUnion tag;
|
TripleTagUnion tag;
|
||||||
|
|
||||||
Properties *properties;
|
std::unique_ptr<AudioProperties> properties;
|
||||||
ByteVector xiphCommentData;
|
ByteVector xiphCommentData;
|
||||||
BlockList blocks;
|
BlockList blocks;
|
||||||
|
|
||||||
long flacStart;
|
long long flacStart;
|
||||||
long streamStart;
|
long long streamStart;
|
||||||
bool scanned;
|
bool scanned;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -99,111 +109,85 @@ public:
|
|||||||
// static members
|
// static members
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
bool FLAC::File::isSupported(IOStream *stream)
|
bool FLAC::File::isSupported(IOStream *stream) {
|
||||||
{
|
|
||||||
// A FLAC file has an ID "fLaC" somewhere. An ID3v2 tag may precede.
|
// A FLAC file has an ID "fLaC" somewhere. An ID3v2 tag may precede.
|
||||||
|
|
||||||
const ByteVector buffer = Utils::readHeader(stream, bufferSize(), true);
|
const ByteVector buffer = Utils::readHeader(stream, bufferSize(), true);
|
||||||
return (buffer.find("fLaC") >= 0);
|
return (buffer.find("fLaC") != ByteVector::npos());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// public members
|
// public members
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
FLAC::File::File(FileName file, bool readProperties, Properties::ReadStyle) :
|
FLAC::File::File(FileName file, bool readProperties, AudioProperties::ReadStyle, ID3v2::FrameFactory *frameFactory) : Strawberry_TagLib::TagLib::File(file), d(new FilePrivate(frameFactory)) {
|
||||||
TagLib::File(file),
|
|
||||||
d(new FilePrivate())
|
if (isOpen())
|
||||||
{
|
|
||||||
if(isOpen())
|
|
||||||
read(readProperties);
|
read(readProperties);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FLAC::File::File(FileName file, ID3v2::FrameFactory *frameFactory,
|
FLAC::File::File(IOStream *stream, bool readProperties, AudioProperties::ReadStyle, ID3v2::FrameFactory *frameFactory) : Strawberry_TagLib::TagLib::File(stream), d(new FilePrivate(frameFactory)) {
|
||||||
bool readProperties, Properties::ReadStyle) :
|
|
||||||
TagLib::File(file),
|
if (isOpen())
|
||||||
d(new FilePrivate(frameFactory))
|
|
||||||
{
|
|
||||||
if(isOpen())
|
|
||||||
read(readProperties);
|
read(readProperties);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FLAC::File::File(IOStream *stream, ID3v2::FrameFactory *frameFactory,
|
FLAC::File::~File() {
|
||||||
bool readProperties, Properties::ReadStyle) :
|
|
||||||
TagLib::File(stream),
|
|
||||||
d(new FilePrivate(frameFactory))
|
|
||||||
{
|
|
||||||
if(isOpen())
|
|
||||||
read(readProperties);
|
|
||||||
}
|
|
||||||
|
|
||||||
FLAC::File::~File()
|
|
||||||
{
|
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
TagLib::Tag *FLAC::File::tag() const
|
Strawberry_TagLib::TagLib::Tag *FLAC::File::tag() const {
|
||||||
{
|
|
||||||
return &d->tag;
|
return &d->tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertyMap FLAC::File::properties() const
|
PropertyMap FLAC::File::setProperties(const PropertyMap &properties) {
|
||||||
{
|
|
||||||
return d->tag.properties();
|
|
||||||
}
|
|
||||||
|
|
||||||
void FLAC::File::removeUnsupportedProperties(const StringList &unsupported)
|
|
||||||
{
|
|
||||||
d->tag.removeUnsupportedProperties(unsupported);
|
|
||||||
}
|
|
||||||
|
|
||||||
PropertyMap FLAC::File::setProperties(const PropertyMap &properties)
|
|
||||||
{
|
|
||||||
return xiphComment(true)->setProperties(properties);
|
return xiphComment(true)->setProperties(properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
FLAC::Properties *FLAC::File::audioProperties() const
|
FLAC::AudioProperties *FLAC::File::audioProperties() const {
|
||||||
{
|
return d->properties.get();
|
||||||
return d->properties;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FLAC::File::save()
|
bool FLAC::File::save() {
|
||||||
{
|
|
||||||
if(readOnly()) {
|
if (readOnly()) {
|
||||||
debug("FLAC::File::save() - Cannot save to a read only file.");
|
debug("FLAC::File::save() - Cannot save to a read only file.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!isValid()) {
|
if (!isValid()) {
|
||||||
debug("FLAC::File::save() -- Trying to save invalid file.");
|
debug("FLAC::File::save() -- Trying to save invalid file.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create new vorbis comments
|
// Create new vorbis comments
|
||||||
if(!hasXiphComment())
|
if (!hasXiphComment())
|
||||||
Tag::duplicate(&d->tag, xiphComment(true), false);
|
Tag::duplicate(&d->tag, xiphComment(true), false);
|
||||||
|
|
||||||
d->xiphCommentData = xiphComment()->render(false);
|
d->xiphCommentData = xiphComment()->render(false);
|
||||||
|
|
||||||
// Replace metadata blocks
|
// Replace metadata blocks
|
||||||
|
|
||||||
for(BlockIterator it = d->blocks.begin(); it != d->blocks.end(); ++it) {
|
for (BlockIterator it = d->blocks.begin(); it != d->blocks.end(); ++it) {
|
||||||
if((*it)->code() == MetadataBlock::VorbisComment) {
|
if ((*it)->code() == MetadataBlock::VorbisComment) {
|
||||||
// Set the new Vorbis Comment block
|
// Set the new Vorbis Comment block
|
||||||
delete *it;
|
|
||||||
d->blocks.erase(it);
|
d->blocks.erase(it);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
d->blocks.append(new UnknownMetadataBlock(MetadataBlock::VorbisComment, d->xiphCommentData));
|
d->blocks.append(std::shared_ptr<MetadataBlock>(new UnknownMetadataBlock(MetadataBlock::VorbisComment, d->xiphCommentData)));
|
||||||
|
|
||||||
// Render data for the metadata blocks
|
// Render data for the metadata blocks
|
||||||
|
|
||||||
ByteVector data;
|
ByteVector data;
|
||||||
for(BlockConstIterator it = d->blocks.begin(); it != d->blocks.end(); ++it) {
|
for (BlockConstIterator it = d->blocks.begin(); it != d->blocks.end(); ++it) {
|
||||||
ByteVector blockData = (*it)->render();
|
ByteVector blockData = (*it)->render();
|
||||||
ByteVector blockHeader = ByteVector::fromUInt(blockData.size());
|
ByteVector blockHeader = ByteVector::fromUInt32BE(blockData.size());
|
||||||
blockHeader[0] = (*it)->code();
|
blockHeader[0] = (*it)->code();
|
||||||
data.append(blockHeader);
|
data.append(blockHeader);
|
||||||
data.append(blockData);
|
data.append(blockData);
|
||||||
@@ -211,27 +195,27 @@ bool FLAC::File::save()
|
|||||||
|
|
||||||
// Compute the amount of padding, and append that to data.
|
// Compute the amount of padding, and append that to data.
|
||||||
|
|
||||||
long originalLength = d->streamStart - d->flacStart;
|
long long originalLength = d->streamStart - d->flacStart;
|
||||||
long paddingLength = originalLength - data.size() - 4;
|
long long paddingLength = originalLength - data.size() - 4;
|
||||||
|
|
||||||
if(paddingLength <= 0) {
|
if (paddingLength <= 0) {
|
||||||
paddingLength = MinPaddingLength;
|
paddingLength = MinPaddingLength;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Padding won't increase beyond 1% of the file size or 1MB.
|
// Padding won't increase beyond 1% of the file size or 1MB.
|
||||||
|
|
||||||
long threshold = length() / 100;
|
long long threshold = length() / 100;
|
||||||
threshold = std::max(threshold, MinPaddingLength);
|
threshold = std::max(threshold, MinPaddingLength);
|
||||||
threshold = std::min(threshold, MaxPaddingLegnth);
|
threshold = std::min(threshold, MaxPaddingLegnth);
|
||||||
|
|
||||||
if(paddingLength > threshold)
|
if (paddingLength > threshold)
|
||||||
paddingLength = MinPaddingLength;
|
paddingLength = MinPaddingLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
ByteVector paddingHeader = ByteVector::fromUInt(paddingLength);
|
ByteVector paddingHeader = ByteVector::fromUInt32BE(paddingLength);
|
||||||
paddingHeader[0] = static_cast<char>(MetadataBlock::Padding | LastBlockFlag);
|
paddingHeader[0] = static_cast<char>(MetadataBlock::Padding | LastBlockFlag);
|
||||||
data.append(paddingHeader);
|
data.append(paddingHeader);
|
||||||
data.resize(static_cast<unsigned int>(data.size() + paddingLength));
|
data.resize(static_cast<size_t>(data.size() + paddingLength));
|
||||||
|
|
||||||
// Write the data to the file
|
// Write the data to the file
|
||||||
|
|
||||||
@@ -239,16 +223,16 @@ bool FLAC::File::save()
|
|||||||
|
|
||||||
d->streamStart += (static_cast<long>(data.size()) - originalLength);
|
d->streamStart += (static_cast<long>(data.size()) - originalLength);
|
||||||
|
|
||||||
if(d->ID3v1Location >= 0)
|
if (d->ID3v1Location >= 0)
|
||||||
d->ID3v1Location += (static_cast<long>(data.size()) - originalLength);
|
d->ID3v1Location += (static_cast<long>(data.size()) - originalLength);
|
||||||
|
|
||||||
// Update ID3 tags
|
// Update ID3 tags
|
||||||
|
|
||||||
if(ID3v2Tag() && !ID3v2Tag()->isEmpty()) {
|
if (ID3v2Tag() && !ID3v2Tag()->isEmpty()) {
|
||||||
|
|
||||||
// ID3v2 tag is not empty. Update the old one or create a new one.
|
// ID3v2 tag is not empty. Update the old one or create a new one.
|
||||||
|
|
||||||
if(d->ID3v2Location < 0)
|
if (d->ID3v2Location < 0)
|
||||||
d->ID3v2Location = 0;
|
d->ID3v2Location = 0;
|
||||||
|
|
||||||
data = ID3v2Tag()->render();
|
data = ID3v2Tag()->render();
|
||||||
@@ -257,7 +241,7 @@ bool FLAC::File::save()
|
|||||||
d->flacStart += (static_cast<long>(data.size()) - d->ID3v2OriginalSize);
|
d->flacStart += (static_cast<long>(data.size()) - d->ID3v2OriginalSize);
|
||||||
d->streamStart += (static_cast<long>(data.size()) - d->ID3v2OriginalSize);
|
d->streamStart += (static_cast<long>(data.size()) - d->ID3v2OriginalSize);
|
||||||
|
|
||||||
if(d->ID3v1Location >= 0)
|
if (d->ID3v1Location >= 0)
|
||||||
d->ID3v1Location += (static_cast<long>(data.size()) - d->ID3v2OriginalSize);
|
d->ID3v1Location += (static_cast<long>(data.size()) - d->ID3v2OriginalSize);
|
||||||
|
|
||||||
d->ID3v2OriginalSize = data.size();
|
d->ID3v2OriginalSize = data.size();
|
||||||
@@ -266,13 +250,13 @@ bool FLAC::File::save()
|
|||||||
|
|
||||||
// ID3v2 tag is empty. Remove the old one.
|
// ID3v2 tag is empty. Remove the old one.
|
||||||
|
|
||||||
if(d->ID3v2Location >= 0) {
|
if (d->ID3v2Location >= 0) {
|
||||||
removeBlock(d->ID3v2Location, d->ID3v2OriginalSize);
|
removeBlock(d->ID3v2Location, d->ID3v2OriginalSize);
|
||||||
|
|
||||||
d->flacStart -= d->ID3v2OriginalSize;
|
d->flacStart -= d->ID3v2OriginalSize;
|
||||||
d->streamStart -= d->ID3v2OriginalSize;
|
d->streamStart -= d->ID3v2OriginalSize;
|
||||||
|
|
||||||
if(d->ID3v1Location >= 0)
|
if (d->ID3v1Location >= 0)
|
||||||
d->ID3v1Location -= d->ID3v2OriginalSize;
|
d->ID3v1Location -= d->ID3v2OriginalSize;
|
||||||
|
|
||||||
d->ID3v2Location = -1;
|
d->ID3v2Location = -1;
|
||||||
@@ -280,11 +264,11 @@ bool FLAC::File::save()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ID3v1Tag() && !ID3v1Tag()->isEmpty()) {
|
if (ID3v1Tag() && !ID3v1Tag()->isEmpty()) {
|
||||||
|
|
||||||
// ID3v1 tag is not empty. Update the old one or create a new one.
|
// ID3v1 tag is not empty. Update the old one or create a new one.
|
||||||
|
|
||||||
if(d->ID3v1Location >= 0) {
|
if (d->ID3v1Location >= 0) {
|
||||||
seek(d->ID3v1Location);
|
seek(d->ID3v1Location);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -298,113 +282,90 @@ bool FLAC::File::save()
|
|||||||
|
|
||||||
// ID3v1 tag is empty. Remove the old one.
|
// ID3v1 tag is empty. Remove the old one.
|
||||||
|
|
||||||
if(d->ID3v1Location >= 0) {
|
if (d->ID3v1Location >= 0) {
|
||||||
truncate(d->ID3v1Location);
|
truncate(d->ID3v1Location);
|
||||||
d->ID3v1Location = -1;
|
d->ID3v1Location = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ID3v2::Tag *FLAC::File::ID3v2Tag(bool create)
|
ID3v2::Tag *FLAC::File::ID3v2Tag(bool create) {
|
||||||
{
|
|
||||||
return d->tag.access<ID3v2::Tag>(FlacID3v2Index, create);
|
return d->tag.access<ID3v2::Tag>(FlacID3v2Index, create);
|
||||||
}
|
}
|
||||||
|
|
||||||
ID3v1::Tag *FLAC::File::ID3v1Tag(bool create)
|
ID3v1::Tag *FLAC::File::ID3v1Tag(bool create) {
|
||||||
{
|
|
||||||
return d->tag.access<ID3v1::Tag>(FlacID3v1Index, create);
|
return d->tag.access<ID3v1::Tag>(FlacID3v1Index, create);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ogg::XiphComment *FLAC::File::xiphComment(bool create)
|
Ogg::XiphComment *FLAC::File::xiphComment(bool create) {
|
||||||
{
|
|
||||||
return d->tag.access<Ogg::XiphComment>(FlacXiphIndex, create);
|
return d->tag.access<Ogg::XiphComment>(FlacXiphIndex, create);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FLAC::File::setID3v2FrameFactory(const ID3v2::FrameFactory *factory)
|
List<FLAC::Picture *> FLAC::File::pictureList() {
|
||||||
{
|
|
||||||
d->ID3v2FrameFactory = factory;
|
|
||||||
}
|
|
||||||
|
|
||||||
ByteVector FLAC::File::streamInfoData()
|
|
||||||
{
|
|
||||||
debug("FLAC::File::streamInfoData() -- This function is obsolete. Returning an empty ByteVector.");
|
|
||||||
return ByteVector();
|
|
||||||
}
|
|
||||||
|
|
||||||
long FLAC::File::streamLength()
|
|
||||||
{
|
|
||||||
debug("FLAC::File::streamLength() -- This function is obsolete. Returning zero.");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<FLAC::Picture *> FLAC::File::pictureList()
|
|
||||||
{
|
|
||||||
List<Picture *> pictures;
|
List<Picture *> pictures;
|
||||||
for(BlockConstIterator it = d->blocks.begin(); it != d->blocks.end(); ++it) {
|
for (BlockConstIterator it = d->blocks.begin(); it != d->blocks.end(); ++it) {
|
||||||
Picture *picture = dynamic_cast<Picture *>(*it);
|
Picture *picture = dynamic_cast<Picture *>(it->get());
|
||||||
if(picture) {
|
if (picture) {
|
||||||
pictures.append(picture);
|
pictures.append(picture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return pictures;
|
return pictures;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FLAC::File::addPicture(Picture *picture)
|
void FLAC::File::addPicture(Picture *picture) {
|
||||||
{
|
d->blocks.append(std::shared_ptr<Picture>(picture));
|
||||||
d->blocks.append(picture);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FLAC::File::removePicture(Picture *picture, bool del)
|
void FLAC::File::removePicture(Picture *picture) {
|
||||||
{
|
|
||||||
BlockIterator it = d->blocks.find(picture);
|
BlockIterator it = d->blocks.find(picture);
|
||||||
if(it != d->blocks.end())
|
if (it != d->blocks.end())
|
||||||
d->blocks.erase(it);
|
d->blocks.erase(it);
|
||||||
|
|
||||||
if(del)
|
|
||||||
delete picture;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FLAC::File::removePictures()
|
void FLAC::File::removePictures() {
|
||||||
{
|
|
||||||
for(BlockIterator it = d->blocks.begin(); it != d->blocks.end(); ) {
|
for (BlockIterator it = d->blocks.begin(); it != d->blocks.end();) {
|
||||||
if(dynamic_cast<Picture *>(*it)) {
|
if (dynamic_cast<Picture *>(it->get())) {
|
||||||
delete *it;
|
|
||||||
it = d->blocks.erase(it);
|
it = d->blocks.erase(it);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FLAC::File::strip(int tags)
|
void FLAC::File::strip(int tags) {
|
||||||
{
|
|
||||||
if(tags & ID3v1)
|
|
||||||
d->tag.set(FlacID3v1Index, 0);
|
|
||||||
|
|
||||||
if(tags & ID3v2)
|
if (tags & ID3v1)
|
||||||
d->tag.set(FlacID3v2Index, 0);
|
d->tag.set(FlacID3v1Index, nullptr);
|
||||||
|
|
||||||
if(tags & XiphComment) {
|
if (tags & ID3v2)
|
||||||
|
d->tag.set(FlacID3v2Index, nullptr);
|
||||||
|
|
||||||
|
if (tags & XiphComment) {
|
||||||
xiphComment()->removeAllFields();
|
xiphComment()->removeAllFields();
|
||||||
xiphComment()->removeAllPictures();
|
xiphComment()->removeAllPictures();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FLAC::File::hasXiphComment() const
|
bool FLAC::File::hasXiphComment() const {
|
||||||
{
|
|
||||||
return !d->xiphCommentData.isEmpty();
|
return !d->xiphCommentData.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FLAC::File::hasID3v1Tag() const
|
bool FLAC::File::hasID3v1Tag() const {
|
||||||
{
|
|
||||||
return (d->ID3v1Location >= 0);
|
return (d->ID3v1Location >= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FLAC::File::hasID3v2Tag() const
|
bool FLAC::File::hasID3v2Tag() const {
|
||||||
{
|
|
||||||
return (d->ID3v2Location >= 0);
|
return (d->ID3v2Location >= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -412,13 +373,13 @@ bool FLAC::File::hasID3v2Tag() const
|
|||||||
// private members
|
// private members
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void FLAC::File::read(bool readProperties)
|
void FLAC::File::read(bool readProperties) {
|
||||||
{
|
|
||||||
// Look for an ID3v2 tag
|
// Look for an ID3v2 tag
|
||||||
|
|
||||||
d->ID3v2Location = Utils::findID3v2(this);
|
d->ID3v2Location = Utils::findID3v2(this);
|
||||||
|
|
||||||
if(d->ID3v2Location >= 0) {
|
if (d->ID3v2Location >= 0) {
|
||||||
d->tag.set(FlacID3v2Index, new ID3v2::Tag(this, d->ID3v2Location, d->ID3v2FrameFactory));
|
d->tag.set(FlacID3v2Index, new ID3v2::Tag(this, d->ID3v2Location, d->ID3v2FrameFactory));
|
||||||
d->ID3v2OriginalSize = ID3v2Tag()->header()->completeTagSize();
|
d->ID3v2OriginalSize = ID3v2Tag()->header()->completeTagSize();
|
||||||
}
|
}
|
||||||
@@ -427,56 +388,57 @@ void FLAC::File::read(bool readProperties)
|
|||||||
|
|
||||||
d->ID3v1Location = Utils::findID3v1(this);
|
d->ID3v1Location = Utils::findID3v1(this);
|
||||||
|
|
||||||
if(d->ID3v1Location >= 0)
|
if (d->ID3v1Location >= 0)
|
||||||
d->tag.set(FlacID3v1Index, new ID3v1::Tag(this, d->ID3v1Location));
|
d->tag.set(FlacID3v1Index, new ID3v1::Tag(this, d->ID3v1Location));
|
||||||
|
|
||||||
// Look for FLAC metadata, including vorbis comments
|
// Look for FLAC metadata, including vorbis comments
|
||||||
|
|
||||||
scan();
|
scan();
|
||||||
|
|
||||||
if(!isValid())
|
if (!isValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(!d->xiphCommentData.isEmpty())
|
if (!d->xiphCommentData.isEmpty())
|
||||||
d->tag.set(FlacXiphIndex, new Ogg::XiphComment(d->xiphCommentData));
|
d->tag.set(FlacXiphIndex, new Ogg::XiphComment(d->xiphCommentData));
|
||||||
else
|
else
|
||||||
d->tag.set(FlacXiphIndex, new Ogg::XiphComment());
|
d->tag.set(FlacXiphIndex, new Ogg::XiphComment());
|
||||||
|
|
||||||
if(readProperties) {
|
if (readProperties) {
|
||||||
|
|
||||||
// First block should be the stream_info metadata
|
// First block should be the stream_info metadata
|
||||||
|
|
||||||
const ByteVector infoData = d->blocks.front()->render();
|
const ByteVector infoData = d->blocks.front()->render();
|
||||||
|
|
||||||
long streamLength;
|
long long streamLength;
|
||||||
|
|
||||||
if(d->ID3v1Location >= 0)
|
if (d->ID3v1Location >= 0)
|
||||||
streamLength = d->ID3v1Location - d->streamStart;
|
streamLength = d->ID3v1Location - d->streamStart;
|
||||||
else
|
else
|
||||||
streamLength = length() - d->streamStart;
|
streamLength = length() - d->streamStart;
|
||||||
|
|
||||||
d->properties = new Properties(infoData, streamLength);
|
d->properties.reset(new AudioProperties(infoData, streamLength));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FLAC::File::scan()
|
void FLAC::File::scan() {
|
||||||
{
|
|
||||||
// Scan the metadata pages
|
// Scan the metadata pages
|
||||||
|
|
||||||
if(d->scanned)
|
if (d->scanned)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(!isValid())
|
if (!isValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
long nextBlockOffset;
|
long long nextBlockOffset;
|
||||||
|
|
||||||
if(d->ID3v2Location >= 0)
|
if (d->ID3v2Location >= 0)
|
||||||
nextBlockOffset = find("fLaC", d->ID3v2Location + d->ID3v2OriginalSize);
|
nextBlockOffset = find("fLaC", d->ID3v2Location + d->ID3v2OriginalSize);
|
||||||
else
|
else
|
||||||
nextBlockOffset = find("fLaC");
|
nextBlockOffset = find("fLaC");
|
||||||
|
|
||||||
if(nextBlockOffset < 0) {
|
if (nextBlockOffset < 0) {
|
||||||
debug("FLAC::File::scan() -- FLAC stream not found");
|
debug("FLAC::File::scan() -- FLAC stream not found");
|
||||||
setValid(false);
|
setValid(false);
|
||||||
return;
|
return;
|
||||||
@@ -485,7 +447,7 @@ void FLAC::File::scan()
|
|||||||
nextBlockOffset += 4;
|
nextBlockOffset += 4;
|
||||||
d->flacStart = nextBlockOffset;
|
d->flacStart = nextBlockOffset;
|
||||||
|
|
||||||
while(true) {
|
while (true) {
|
||||||
|
|
||||||
seek(nextBlockOffset);
|
seek(nextBlockOffset);
|
||||||
const ByteVector header = readBlock(4);
|
const ByteVector header = readBlock(4);
|
||||||
@@ -504,66 +466,63 @@ void FLAC::File::scan()
|
|||||||
|
|
||||||
const char blockType = header[0] & ~LastBlockFlag;
|
const char blockType = header[0] & ~LastBlockFlag;
|
||||||
const bool isLastBlock = (header[0] & LastBlockFlag) != 0;
|
const bool isLastBlock = (header[0] & LastBlockFlag) != 0;
|
||||||
const unsigned int blockLength = header.toUInt(1U, 3U);
|
const size_t blockLength = header.toUInt24BE(1);
|
||||||
|
|
||||||
// First block should be the stream_info metadata
|
// First block should be the stream_info metadata
|
||||||
|
|
||||||
if(d->blocks.isEmpty() && blockType != MetadataBlock::StreamInfo) {
|
if (d->blocks.isEmpty() && blockType != MetadataBlock::StreamInfo) {
|
||||||
debug("FLAC::File::scan() -- First block should be the stream_info metadata");
|
debug("FLAC::File::scan() -- First block should be the stream_info metadata");
|
||||||
setValid(false);
|
setValid(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(blockLength == 0
|
if (blockLength == 0 && blockType != MetadataBlock::Padding && blockType != MetadataBlock::SeekTable) {
|
||||||
&& blockType != MetadataBlock::Padding && blockType != MetadataBlock::SeekTable)
|
|
||||||
{
|
|
||||||
debug("FLAC::File::scan() -- Zero-sized metadata block found");
|
debug("FLAC::File::scan() -- Zero-sized metadata block found");
|
||||||
setValid(false);
|
setValid(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ByteVector data = readBlock(blockLength);
|
const ByteVector data = readBlock(blockLength);
|
||||||
if(data.size() != blockLength) {
|
if (data.size() != blockLength) {
|
||||||
debug("FLAC::File::scan() -- Failed to read a metadata block");
|
debug("FLAC::File::scan() -- Failed to read a metadata block");
|
||||||
setValid(false);
|
setValid(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MetadataBlock *block = 0;
|
std::shared_ptr<MetadataBlock> block;
|
||||||
|
|
||||||
// Found the vorbis-comment
|
// Found the vorbis-comment
|
||||||
if(blockType == MetadataBlock::VorbisComment) {
|
if (blockType == MetadataBlock::VorbisComment) {
|
||||||
if(d->xiphCommentData.isEmpty()) {
|
if (d->xiphCommentData.isEmpty()) {
|
||||||
d->xiphCommentData = data;
|
d->xiphCommentData = data;
|
||||||
block = new UnknownMetadataBlock(MetadataBlock::VorbisComment, data);
|
block.reset(new UnknownMetadataBlock(MetadataBlock::VorbisComment, data));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
debug("FLAC::File::scan() -- multiple Vorbis Comment blocks found, discarding");
|
debug("FLAC::File::scan() -- multiple Vorbis Comment blocks found, discarding");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(blockType == MetadataBlock::Picture) {
|
else if (blockType == MetadataBlock::Picture) {
|
||||||
FLAC::Picture *picture = new FLAC::Picture();
|
std::shared_ptr<FLAC::Picture> picture(new FLAC::Picture());
|
||||||
if(picture->parse(data)) {
|
if (picture->parse(data)) {
|
||||||
block = picture;
|
block = picture;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
debug("FLAC::File::scan() -- invalid picture found, discarding");
|
debug("FLAC::File::scan() -- invalid picture found, discarding");
|
||||||
delete picture;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(blockType == MetadataBlock::Padding) {
|
else if (blockType == MetadataBlock::Padding) {
|
||||||
// Skip all padding blocks.
|
// Skip all padding blocks.
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
block = new UnknownMetadataBlock(blockType, data);
|
block.reset(new UnknownMetadataBlock(blockType, data));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(block)
|
if (block)
|
||||||
d->blocks.append(block);
|
d->blocks.append(block);
|
||||||
|
|
||||||
nextBlockOffset += blockLength + 4;
|
nextBlockOffset += blockLength + 4;
|
||||||
|
|
||||||
if(isLastBlock)
|
if (isLastBlock)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -572,4 +531,5 @@ void FLAC::File::scan()
|
|||||||
d->streamStart = nextBlockOffset;
|
d->streamStart = nextBlockOffset;
|
||||||
|
|
||||||
d->scanned = true;
|
d->scanned = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
225
3rdparty/taglib/flac/flacfile.h
vendored
225
3rdparty/taglib/flac/flacfile.h
vendored
@@ -26,6 +26,8 @@
|
|||||||
#ifndef TAGLIB_FLACFILE_H
|
#ifndef TAGLIB_FLACFILE_H
|
||||||
#define TAGLIB_FLACFILE_H
|
#define TAGLIB_FLACFILE_H
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include "taglib_export.h"
|
#include "taglib_export.h"
|
||||||
#include "tfile.h"
|
#include "tfile.h"
|
||||||
#include "tlist.h"
|
#include "tlist.h"
|
||||||
@@ -34,16 +36,24 @@
|
|||||||
#include "flacpicture.h"
|
#include "flacpicture.h"
|
||||||
#include "flacproperties.h"
|
#include "flacproperties.h"
|
||||||
|
|
||||||
|
namespace Strawberry_TagLib {
|
||||||
namespace TagLib {
|
namespace TagLib {
|
||||||
|
|
||||||
class Tag;
|
class Tag;
|
||||||
namespace ID3v2 { class FrameFactory; class Tag; }
|
namespace ID3v2 {
|
||||||
namespace ID3v1 { class Tag; }
|
class FrameFactory;
|
||||||
namespace Ogg { class XiphComment; }
|
class Tag;
|
||||||
|
} // namespace ID3v2
|
||||||
|
namespace ID3v1 {
|
||||||
|
class Tag;
|
||||||
|
}
|
||||||
|
namespace Ogg {
|
||||||
|
class XiphComment;
|
||||||
|
}
|
||||||
|
|
||||||
//! An implementation of FLAC metadata
|
//! An implementation of FLAC metadata
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* This is implementation of FLAC metadata for non-Ogg FLAC files. At some
|
* This is implementation of FLAC metadata for non-Ogg FLAC files. At some
|
||||||
* point when Ogg / FLAC is more common there will be a similar implementation
|
* point when Ogg / FLAC is more common there will be a similar implementation
|
||||||
* under the Ogg hierarchy.
|
* under the Ogg hierarchy.
|
||||||
@@ -52,19 +62,17 @@ namespace TagLib {
|
|||||||
* properties from the file.
|
* properties from the file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace FLAC {
|
namespace FLAC {
|
||||||
|
|
||||||
//! An implementation of TagLib::File with FLAC specific methods
|
//! An implementation of TagLib::File with FLAC specific methods
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* This implements and provides an interface for FLAC files to the
|
* This implements and provides an interface for FLAC files to the TagLib::Tag and TagLib::AudioProperties interfaces
|
||||||
* TagLib::Tag and TagLib::AudioProperties interfaces by way of implementing
|
* by way of implementing the abstract TagLib::File API as well as providing some additional information specific to FLAC files.
|
||||||
* the abstract TagLib::File API as well as providing some additional
|
*
|
||||||
* information specific to FLAC files.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class TAGLIB_EXPORT File : public TagLib::File
|
class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::File {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
/*!
|
/*!
|
||||||
* This set of flags is used for various operations and is suitable for
|
* This set of flags is used for various operations and is suitable for
|
||||||
@@ -84,111 +92,73 @@ namespace TagLib {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Constructs a FLAC file from \a file. If \a readProperties is true the
|
* Constructs an FLAC file from \a file.
|
||||||
* file's audio properties will also be read.
|
* If \a readProperties is true the file's audio properties will also be read.
|
||||||
|
*
|
||||||
|
* If this file contains and ID3v2 tag the frames will be created using \a frameFactory.
|
||||||
*
|
*
|
||||||
* \note In the current implementation, \a propertiesStyle is ignored.
|
* \note In the current implementation, \a propertiesStyle is ignored.
|
||||||
*
|
|
||||||
* \deprecated This constructor will be dropped in favor of the one below
|
|
||||||
* in a future version.
|
|
||||||
*/
|
*/
|
||||||
File(FileName file, bool readProperties = true,
|
explicit File(FileName file, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average, ID3v2::FrameFactory *frameFactory = nullptr);
|
||||||
Properties::ReadStyle propertiesStyle = Properties::Average);
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Constructs an FLAC file from \a file. If \a readProperties is true the
|
* Constructs a FLAC file from \a stream. If \a readProperties is true the file's audio properties will also be read.
|
||||||
* file's audio properties will also be read.
|
|
||||||
*
|
*
|
||||||
* If this file contains and ID3v2 tag the frames will be created using
|
* \note TagLib will *not* take ownership of the stream, the caller is responsible for deleting it after the File object.
|
||||||
* \a frameFactory.
|
*
|
||||||
|
* If this file contains and ID3v2 tag the frames will be created using \a frameFactory.
|
||||||
*
|
*
|
||||||
* \note In the current implementation, \a propertiesStyle is ignored.
|
* \note In the current implementation, \a propertiesStyle is ignored.
|
||||||
*/
|
*/
|
||||||
// BIC: merge with the above constructor
|
// BIC: merge with the above constructor
|
||||||
File(FileName file, ID3v2::FrameFactory *frameFactory,
|
explicit File(IOStream *stream, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average, ID3v2::FrameFactory *frameFactory = nullptr);
|
||||||
bool readProperties = true,
|
|
||||||
Properties::ReadStyle propertiesStyle = Properties::Average);
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* Constructs a FLAC file from \a stream. If \a readProperties is true the
|
|
||||||
* file's audio properties will also be read.
|
|
||||||
*
|
|
||||||
* \note TagLib will *not* take ownership of the stream, the caller is
|
|
||||||
* responsible for deleting it after the File object.
|
|
||||||
*
|
|
||||||
* If this file contains and ID3v2 tag the frames will be created using
|
|
||||||
* \a frameFactory.
|
|
||||||
*
|
|
||||||
* \note In the current implementation, \a propertiesStyle is ignored.
|
|
||||||
*/
|
|
||||||
// BIC: merge with the above constructor
|
|
||||||
File(IOStream *stream, ID3v2::FrameFactory *frameFactory,
|
|
||||||
bool readProperties = true,
|
|
||||||
Properties::ReadStyle propertiesStyle = Properties::Average);
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Destroys this instance of the File.
|
* Destroys this instance of the File.
|
||||||
*/
|
*/
|
||||||
virtual ~File();
|
~File() override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the Tag for this file. This will be a union of XiphComment,
|
* Returns the Tag for this file. This will be a union of XiphComment, ID3v1 and ID3v2 tags.
|
||||||
* ID3v1 and ID3v2 tags.
|
|
||||||
*
|
*
|
||||||
* \see ID3v2Tag()
|
* \see ID3v2Tag()
|
||||||
* \see ID3v1Tag()
|
* \see ID3v1Tag()
|
||||||
* \see XiphComment()
|
* \see XiphComment()
|
||||||
*/
|
*/
|
||||||
virtual TagLib::Tag *tag() const;
|
Strawberry_TagLib::TagLib::Tag *tag() const override;
|
||||||
|
|
||||||
/*!
|
|
||||||
* Implements the unified property interface -- export function.
|
|
||||||
* If the file contains more than one tag (e.g. XiphComment and ID3v1),
|
|
||||||
* only the first one (in the order XiphComment, ID3v2, ID3v1) will be
|
|
||||||
* converted to the PropertyMap.
|
|
||||||
*/
|
|
||||||
PropertyMap properties() const;
|
|
||||||
|
|
||||||
void removeUnsupportedProperties(const StringList &);
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Implements the unified property interface -- import function.
|
* Implements the unified property interface -- import function.
|
||||||
* This always creates a Xiph comment, if none exists. The return value
|
* This always creates a Xiph comment, if none exists. The return value relates to the Xiph comment only.
|
||||||
* relates to the Xiph comment only.
|
* Ignores any changes to ID3v1 or ID3v2 comments since they are not allowed in the FLAC specification.
|
||||||
* Ignores any changes to ID3v1 or ID3v2 comments since they are not allowed
|
|
||||||
* in the FLAC specification.
|
|
||||||
*/
|
*/
|
||||||
PropertyMap setProperties(const PropertyMap &);
|
PropertyMap setProperties(const PropertyMap &) override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the FLAC::Properties for this file. If no audio properties
|
* Returns the FLAC::AudioProperties for this file. If no audio properties were read then this will return a null pointer.
|
||||||
* were read then this will return a null pointer.
|
|
||||||
*/
|
*/
|
||||||
virtual Properties *audioProperties() const;
|
AudioProperties *audioProperties() const override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Save the file. This will primarily save the XiphComment, but
|
* Save the file. This will primarily save the XiphComment, but will also keep any old ID3-tags up to date.
|
||||||
* will also keep any old ID3-tags up to date. If the file
|
* If the file has no XiphComment, one will be constructed from the ID3-tags.
|
||||||
* has no XiphComment, one will be constructed from the ID3-tags.
|
|
||||||
*
|
*
|
||||||
* This returns true if the save was successful.
|
* This returns true if the save was successful.
|
||||||
*/
|
*/
|
||||||
virtual bool save();
|
bool save() override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns a pointer to the ID3v2 tag of the file.
|
* Returns a pointer to the ID3v2 tag of the file.
|
||||||
*
|
*
|
||||||
* If \a create is false (the default) this returns a null pointer
|
* If \a create is false (the default) this returns a null pointer
|
||||||
* if there is no valid ID3v2 tag. If \a create is true it will create
|
* if there is no valid ID3v2 tag.
|
||||||
* an ID3v2 tag if one does not exist and returns a valid pointer.
|
* If \a create is true it will create an ID3v2 tag if one does not exist and returns a valid pointer.
|
||||||
*
|
*
|
||||||
* \note This may return a valid pointer regardless of whether or not the
|
* \note This may return a valid pointer regardless of whether or not the file on disk has an ID3v2 tag.
|
||||||
* file on disk has an ID3v2 tag. Use hasID3v2Tag() to check if the file
|
* Use hasID3v2Tag() to check if the file on disk actually has an ID3v2 tag.
|
||||||
* on disk actually has an ID3v2 tag.
|
|
||||||
*
|
*
|
||||||
* \note The Tag <b>is still</b> owned by the MPEG::File and should not be
|
* \note The Tag <b>is still</b> owned by the MPEG::File and should not be
|
||||||
* deleted by the user. It will be deleted when the file (object) is
|
* deleted by the user. It will be deleted when the file (object) is destroyed.
|
||||||
* destroyed.
|
|
||||||
*
|
*
|
||||||
* \see hasID3v2Tag()
|
* \see hasID3v2Tag()
|
||||||
*/
|
*/
|
||||||
@@ -197,17 +167,14 @@ namespace TagLib {
|
|||||||
/*!
|
/*!
|
||||||
* Returns a pointer to the ID3v1 tag of the file.
|
* Returns a pointer to the ID3v1 tag of the file.
|
||||||
*
|
*
|
||||||
* If \a create is false (the default) this returns a null pointer
|
* If \a create is false (the default) this returns a null pointer if there is no valid APE tag.
|
||||||
* if there is no valid APE tag. If \a create is true it will create
|
* If \a create is true it will create an APE tag if one does not exist and returns a valid pointer.
|
||||||
* an APE tag if one does not exist and returns a valid pointer.
|
|
||||||
*
|
*
|
||||||
* \note This may return a valid pointer regardless of whether or not the
|
* \note This may return a valid pointer regardless of whether or not the file on disk has an ID3v1 tag.
|
||||||
* file on disk has an ID3v1 tag. Use hasID3v1Tag() to check if the file
|
* Use hasID3v1Tag() to check if the file on disk actually has an ID3v1 tag.
|
||||||
* on disk actually has an ID3v1 tag.
|
|
||||||
*
|
*
|
||||||
* \note The Tag <b>is still</b> owned by the MPEG::File and should not be
|
* \note The Tag <b>is still</b> owned by the MPEG::File and should not be deleted by the user.
|
||||||
* deleted by the user. It will be deleted when the file (object) is
|
* It will be deleted when the file (object) is destroyed.
|
||||||
* destroyed.
|
|
||||||
*
|
*
|
||||||
* \see hasID3v1Tag()
|
* \see hasID3v1Tag()
|
||||||
*/
|
*/
|
||||||
@@ -216,58 +183,28 @@ namespace TagLib {
|
|||||||
/*!
|
/*!
|
||||||
* Returns a pointer to the XiphComment for the file.
|
* Returns a pointer to the XiphComment for the file.
|
||||||
*
|
*
|
||||||
* If \a create is false (the default) this returns a null pointer
|
* If \a create is false (the default) this returns a null pointer if there is no valid XiphComment.
|
||||||
* if there is no valid XiphComment. If \a create is true it will create
|
* If \a create is true it will create a XiphComment if one does not exist and returns a valid pointer.
|
||||||
* a XiphComment if one does not exist and returns a valid pointer.
|
|
||||||
*
|
*
|
||||||
* \note This may return a valid pointer regardless of whether or not the
|
* \note This may return a valid pointer regardless of whether or not the file on disk has a XiphComment.
|
||||||
* file on disk has a XiphComment. Use hasXiphComment() to check if the
|
* Use hasXiphComment() to check if the file on disk actually has a XiphComment.
|
||||||
* file on disk actually has a XiphComment.
|
|
||||||
*
|
*
|
||||||
* \note The Tag <b>is still</b> owned by the FLAC::File and should not be
|
* \note The Tag <b>is still</b> owned by the FLAC::File and should not be deleted by the user.
|
||||||
* deleted by the user. It will be deleted when the file (object) is
|
* It will be deleted when the file (object) is destroyed.
|
||||||
* destroyed.
|
|
||||||
*
|
*
|
||||||
* \see hasXiphComment()
|
* \see hasXiphComment()
|
||||||
*/
|
*/
|
||||||
Ogg::XiphComment *xiphComment(bool create = false);
|
Ogg::XiphComment *xiphComment(bool create = false);
|
||||||
|
|
||||||
/*!
|
|
||||||
* Set the ID3v2::FrameFactory to something other than the default. This
|
|
||||||
* can be used to specify the way that ID3v2 frames will be interpreted
|
|
||||||
* when
|
|
||||||
*
|
|
||||||
* \see ID3v2FrameFactory
|
|
||||||
* \deprecated This value should be passed in via the constructor
|
|
||||||
*/
|
|
||||||
void setID3v2FrameFactory(const ID3v2::FrameFactory *factory);
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* Returns the block of data used by FLAC::Properties for parsing the
|
|
||||||
* stream properties.
|
|
||||||
*
|
|
||||||
* \deprecated Always returns an empty vector.
|
|
||||||
*/
|
|
||||||
ByteVector streamInfoData(); // BIC: remove
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* Returns the length of the audio-stream, used by FLAC::Properties for
|
|
||||||
* calculating the bitrate.
|
|
||||||
*
|
|
||||||
* \deprecated Always returns zero.
|
|
||||||
*/
|
|
||||||
long streamLength(); // BIC: remove
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns a list of pictures attached to the FLAC file.
|
* Returns a list of pictures attached to the FLAC file.
|
||||||
*/
|
*/
|
||||||
List<Picture *> pictureList();
|
List<Picture *> pictureList();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Removes an attached picture. If \a del is true the picture's memory
|
* Removes an attached picture. The picture's memory will be freed.
|
||||||
* will be freed; if it is false, it must be deleted by the user.
|
|
||||||
*/
|
*/
|
||||||
void removePicture(Picture *picture, bool del = true);
|
void removePicture(Picture *picture);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Remove all attached images.
|
* Remove all attached images.
|
||||||
@@ -275,25 +212,23 @@ namespace TagLib {
|
|||||||
void removePictures();
|
void removePictures();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Add a new picture to the file. The file takes ownership of the
|
* Add a new picture to the file.
|
||||||
* picture and will handle freeing its memory.
|
* The file takes ownership of the picture and will handle freeing its memory.
|
||||||
*
|
*
|
||||||
* \note The file will be saved only after calling save().
|
* \note The file will be saved only after calling save().
|
||||||
*/
|
*/
|
||||||
void addPicture(Picture *picture);
|
void addPicture(Picture *picture);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* This will remove the tags that match the OR-ed together TagTypes from
|
* This will remove the tags that match the OR-ed together TagTypes from the file.
|
||||||
* the file. By default it removes all tags.
|
* By default it removes all tags.
|
||||||
*
|
*
|
||||||
* \warning This will also invalidate pointers to the tags as their memory
|
* \warning This will also invalidate pointers to the tags as their memory will be freed.
|
||||||
* will be freed.
|
|
||||||
*
|
*
|
||||||
* \note In order to make the removal permanent save() still needs to be
|
* \note In order to make the removal permanent save() still needs to be called.
|
||||||
* called.
|
|
||||||
*
|
*
|
||||||
* \note This won't remove the Vorbis comment block completely. The
|
* \note This won't remove the Vorbis comment block completely.
|
||||||
* vendor ID will be preserved.
|
* The vendor ID will be preserved.
|
||||||
*/
|
*/
|
||||||
void strip(int tags = AllTags);
|
void strip(int tags = AllTags);
|
||||||
|
|
||||||
@@ -319,25 +254,25 @@ namespace TagLib {
|
|||||||
bool hasID3v2Tag() const;
|
bool hasID3v2Tag() const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns whether or not the given \a stream can be opened as a FLAC
|
* Returns whether or not the given \a stream can be opened as a FLAC file.
|
||||||
* file.
|
|
||||||
*
|
*
|
||||||
* \note This method is designed to do a quick check. The result may
|
* \note This method is designed to do a quick check.
|
||||||
* not necessarily be correct.
|
* The result may not necessarily be correct.
|
||||||
*/
|
*/
|
||||||
static bool isSupported(IOStream *stream);
|
static bool isSupported(IOStream *stream);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
File(const File &);
|
File(const File&);
|
||||||
File &operator=(const File &);
|
File &operator=(const File&);
|
||||||
|
|
||||||
void read(bool readProperties);
|
void read(bool readProperties);
|
||||||
void scan();
|
void scan();
|
||||||
|
|
||||||
class FilePrivate;
|
class FilePrivate;
|
||||||
FilePrivate *d;
|
FilePrivate *d;
|
||||||
};
|
};
|
||||||
}
|
} // namespace FLAC
|
||||||
}
|
} // namespace TagLib
|
||||||
|
} // namespace Strawberry_TagLib
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
22
3rdparty/taglib/flac/flacmetadatablock.cpp
vendored
22
3rdparty/taglib/flac/flacmetadatablock.cpp
vendored
@@ -23,25 +23,17 @@
|
|||||||
* http://www.mozilla.org/MPL/ *
|
* http://www.mozilla.org/MPL/ *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include <taglib.h>
|
#include "taglib.h"
|
||||||
#include <tdebug.h>
|
#include "tdebug.h"
|
||||||
#include "flacmetadatablock.h"
|
#include "flacmetadatablock.h"
|
||||||
|
|
||||||
using namespace TagLib;
|
using namespace Strawberry_TagLib::TagLib;
|
||||||
|
|
||||||
class FLAC::MetadataBlock::MetadataBlockPrivate
|
class FLAC::MetadataBlock::MetadataBlockPrivate {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
MetadataBlockPrivate() {}
|
MetadataBlockPrivate() {}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
FLAC::MetadataBlock::MetadataBlock()
|
FLAC::MetadataBlock::MetadataBlock() : d(nullptr) {}
|
||||||
{
|
|
||||||
d = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
FLAC::MetadataBlock::~MetadataBlock()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
FLAC::MetadataBlock::~MetadataBlock() {}
|
||||||
|
|||||||
17
3rdparty/taglib/flac/flacmetadatablock.h
vendored
17
3rdparty/taglib/flac/flacmetadatablock.h
vendored
@@ -30,14 +30,13 @@
|
|||||||
#include "tbytevector.h"
|
#include "tbytevector.h"
|
||||||
#include "taglib_export.h"
|
#include "taglib_export.h"
|
||||||
|
|
||||||
|
namespace Strawberry_TagLib {
|
||||||
namespace TagLib {
|
namespace TagLib {
|
||||||
|
namespace FLAC {
|
||||||
|
|
||||||
namespace FLAC {
|
class TAGLIB_EXPORT MetadataBlock {
|
||||||
|
|
||||||
class TAGLIB_EXPORT MetadataBlock
|
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
MetadataBlock();
|
explicit MetadataBlock();
|
||||||
virtual ~MetadataBlock();
|
virtual ~MetadataBlock();
|
||||||
|
|
||||||
enum BlockType {
|
enum BlockType {
|
||||||
@@ -66,10 +65,10 @@ namespace TagLib {
|
|||||||
|
|
||||||
class MetadataBlockPrivate;
|
class MetadataBlockPrivate;
|
||||||
MetadataBlockPrivate *d;
|
MetadataBlockPrivate *d;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace FLAC
|
||||||
|
} // namespace TagLib
|
||||||
}
|
} // namespace Strawberry_TagLib
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
133
3rdparty/taglib/flac/flacpicture.cpp
vendored
133
3rdparty/taglib/flac/flacpicture.cpp
vendored
@@ -23,22 +23,20 @@
|
|||||||
* http://www.mozilla.org/MPL/ *
|
* http://www.mozilla.org/MPL/ *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include <taglib.h>
|
#include "taglib.h"
|
||||||
#include <tdebug.h>
|
#include "tdebug.h"
|
||||||
#include "flacpicture.h"
|
#include "flacpicture.h"
|
||||||
|
|
||||||
using namespace TagLib;
|
using namespace Strawberry_TagLib::TagLib;
|
||||||
|
|
||||||
class FLAC::Picture::PicturePrivate
|
class FLAC::Picture::PicturePrivate {
|
||||||
{
|
public:
|
||||||
public:
|
explicit PicturePrivate() : type(FLAC::Picture::Other),
|
||||||
PicturePrivate() :
|
|
||||||
type(FLAC::Picture::Other),
|
|
||||||
width(0),
|
width(0),
|
||||||
height(0),
|
height(0),
|
||||||
colorDepth(0),
|
colorDepth(0),
|
||||||
numColors(0)
|
numColors(0) {
|
||||||
{}
|
}
|
||||||
|
|
||||||
Type type;
|
Type type;
|
||||||
String mimeType;
|
String mimeType;
|
||||||
@@ -50,168 +48,147 @@ public:
|
|||||||
ByteVector data;
|
ByteVector data;
|
||||||
};
|
};
|
||||||
|
|
||||||
FLAC::Picture::Picture() :
|
FLAC::Picture::Picture() : d(new PicturePrivate()) {
|
||||||
d(new PicturePrivate())
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FLAC::Picture::Picture(const ByteVector &data) :
|
FLAC::Picture::Picture(const ByteVector &data) : d(new PicturePrivate()) {
|
||||||
d(new PicturePrivate())
|
|
||||||
{
|
|
||||||
parse(data);
|
parse(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
FLAC::Picture::~Picture()
|
FLAC::Picture::~Picture() {
|
||||||
{
|
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FLAC::Picture::code() const
|
int FLAC::Picture::code() const {
|
||||||
{
|
|
||||||
return FLAC::MetadataBlock::Picture;
|
return FLAC::MetadataBlock::Picture;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FLAC::Picture::parse(const ByteVector &data)
|
bool FLAC::Picture::parse(const ByteVector &data) {
|
||||||
{
|
|
||||||
if(data.size() < 32) {
|
if (data.size() < 32) {
|
||||||
debug("A picture block must contain at least 5 bytes.");
|
debug("A picture block must contain at least 5 bytes.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int pos = 0;
|
size_t pos = 0;
|
||||||
d->type = FLAC::Picture::Type(data.toUInt(pos));
|
d->type = FLAC::Picture::Type(data.toUInt32BE(pos));
|
||||||
pos += 4;
|
pos += 4;
|
||||||
unsigned int mimeTypeLength = data.toUInt(pos);
|
const unsigned int mimeTypeLength = data.toUInt32BE(pos);
|
||||||
pos += 4;
|
pos += 4;
|
||||||
if(pos + mimeTypeLength + 24 > data.size()) {
|
if (pos + mimeTypeLength + 24 > data.size()) {
|
||||||
debug("Invalid picture block.");
|
debug("Invalid picture block.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
d->mimeType = String(data.mid(pos, mimeTypeLength), String::UTF8);
|
d->mimeType = String(data.mid(pos, mimeTypeLength), String::UTF8);
|
||||||
pos += mimeTypeLength;
|
pos += mimeTypeLength;
|
||||||
unsigned int descriptionLength = data.toUInt(pos);
|
const unsigned int descriptionLength = data.toUInt32BE(pos);
|
||||||
pos += 4;
|
pos += 4;
|
||||||
if(pos + descriptionLength + 20 > data.size()) {
|
if (pos + descriptionLength + 20 > data.size()) {
|
||||||
debug("Invalid picture block.");
|
debug("Invalid picture block.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
d->description = String(data.mid(pos, descriptionLength), String::UTF8);
|
d->description = String(data.mid(pos, descriptionLength), String::UTF8);
|
||||||
pos += descriptionLength;
|
pos += descriptionLength;
|
||||||
d->width = data.toUInt(pos);
|
d->width = data.toUInt32BE(pos);
|
||||||
pos += 4;
|
pos += 4;
|
||||||
d->height = data.toUInt(pos);
|
d->height = data.toUInt32BE(pos);
|
||||||
pos += 4;
|
pos += 4;
|
||||||
d->colorDepth = data.toUInt(pos);
|
d->colorDepth = data.toUInt32BE(pos);
|
||||||
pos += 4;
|
pos += 4;
|
||||||
d->numColors = data.toUInt(pos);
|
d->numColors = data.toUInt32BE(pos);
|
||||||
pos += 4;
|
pos += 4;
|
||||||
unsigned int dataLength = data.toUInt(pos);
|
const unsigned int dataLength = data.toUInt32BE(pos);
|
||||||
pos += 4;
|
pos += 4;
|
||||||
if(pos + dataLength > data.size()) {
|
if (pos + dataLength > data.size()) {
|
||||||
debug("Invalid picture block.");
|
debug("Invalid picture block.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
d->data = data.mid(pos, dataLength);
|
d->data = data.mid(pos, dataLength);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ByteVector FLAC::Picture::render() const
|
ByteVector FLAC::Picture::render() const {
|
||||||
{
|
|
||||||
ByteVector result;
|
ByteVector result;
|
||||||
result.append(ByteVector::fromUInt(d->type));
|
result.append(ByteVector::fromUInt32BE(d->type));
|
||||||
ByteVector mimeTypeData = d->mimeType.data(String::UTF8);
|
ByteVector mimeTypeData = d->mimeType.data(String::UTF8);
|
||||||
result.append(ByteVector::fromUInt(mimeTypeData.size()));
|
result.append(ByteVector::fromUInt32BE(mimeTypeData.size()));
|
||||||
result.append(mimeTypeData);
|
result.append(mimeTypeData);
|
||||||
ByteVector descriptionData = d->description.data(String::UTF8);
|
ByteVector descriptionData = d->description.data(String::UTF8);
|
||||||
result.append(ByteVector::fromUInt(descriptionData.size()));
|
result.append(ByteVector::fromUInt32BE(descriptionData.size()));
|
||||||
result.append(descriptionData);
|
result.append(descriptionData);
|
||||||
result.append(ByteVector::fromUInt(d->width));
|
result.append(ByteVector::fromUInt32BE(d->width));
|
||||||
result.append(ByteVector::fromUInt(d->height));
|
result.append(ByteVector::fromUInt32BE(d->height));
|
||||||
result.append(ByteVector::fromUInt(d->colorDepth));
|
result.append(ByteVector::fromUInt32BE(d->colorDepth));
|
||||||
result.append(ByteVector::fromUInt(d->numColors));
|
result.append(ByteVector::fromUInt32BE(d->numColors));
|
||||||
result.append(ByteVector::fromUInt(d->data.size()));
|
result.append(ByteVector::fromUInt32BE(d->data.size()));
|
||||||
result.append(d->data);
|
result.append(d->data);
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FLAC::Picture::Type FLAC::Picture::type() const
|
FLAC::Picture::Type FLAC::Picture::type() const {
|
||||||
{
|
|
||||||
return d->type;
|
return d->type;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FLAC::Picture::setType(FLAC::Picture::Type type)
|
void FLAC::Picture::setType(FLAC::Picture::Type type) {
|
||||||
{
|
|
||||||
d->type = type;
|
d->type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
String FLAC::Picture::mimeType() const
|
String FLAC::Picture::mimeType() const {
|
||||||
{
|
|
||||||
return d->mimeType;
|
return d->mimeType;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FLAC::Picture::setMimeType(const String &mimeType)
|
void FLAC::Picture::setMimeType(const String &mimeType) {
|
||||||
{
|
|
||||||
d->mimeType = mimeType;
|
d->mimeType = mimeType;
|
||||||
}
|
}
|
||||||
|
|
||||||
String FLAC::Picture::description() const
|
String FLAC::Picture::description() const {
|
||||||
{
|
|
||||||
return d->description;
|
return d->description;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FLAC::Picture::setDescription(const String &description)
|
void FLAC::Picture::setDescription(const String &description) {
|
||||||
{
|
|
||||||
d->description = description;
|
d->description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FLAC::Picture::width() const
|
int FLAC::Picture::width() const {
|
||||||
{
|
|
||||||
return d->width;
|
return d->width;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FLAC::Picture::setWidth(int width)
|
void FLAC::Picture::setWidth(int width) {
|
||||||
{
|
|
||||||
d->width = width;
|
d->width = width;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FLAC::Picture::height() const
|
int FLAC::Picture::height() const {
|
||||||
{
|
|
||||||
return d->height;
|
return d->height;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FLAC::Picture::setHeight(int height)
|
void FLAC::Picture::setHeight(int height) {
|
||||||
{
|
|
||||||
d->height = height;
|
d->height = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FLAC::Picture::colorDepth() const
|
int FLAC::Picture::colorDepth() const {
|
||||||
{
|
|
||||||
return d->colorDepth;
|
return d->colorDepth;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FLAC::Picture::setColorDepth(int colorDepth)
|
void FLAC::Picture::setColorDepth(int colorDepth) {
|
||||||
{
|
|
||||||
d->colorDepth = colorDepth;
|
d->colorDepth = colorDepth;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FLAC::Picture::numColors() const
|
int FLAC::Picture::numColors() const {
|
||||||
{
|
|
||||||
return d->numColors;
|
return d->numColors;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FLAC::Picture::setNumColors(int numColors)
|
void FLAC::Picture::setNumColors(int numColors) {
|
||||||
{
|
|
||||||
d->numColors = numColors;
|
d->numColors = numColors;
|
||||||
}
|
}
|
||||||
|
|
||||||
ByteVector FLAC::Picture::data() const
|
ByteVector FLAC::Picture::data() const {
|
||||||
{
|
|
||||||
return d->data;
|
return d->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FLAC::Picture::setData(const ByteVector &data)
|
void FLAC::Picture::setData(const ByteVector &data) {
|
||||||
{
|
|
||||||
d->data = data;
|
d->data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
33
3rdparty/taglib/flac/flacpicture.h
vendored
33
3rdparty/taglib/flac/flacpicture.h
vendored
@@ -32,14 +32,13 @@
|
|||||||
#include "taglib_export.h"
|
#include "taglib_export.h"
|
||||||
#include "flacmetadatablock.h"
|
#include "flacmetadatablock.h"
|
||||||
|
|
||||||
|
namespace Strawberry_TagLib {
|
||||||
namespace TagLib {
|
namespace TagLib {
|
||||||
|
|
||||||
namespace FLAC {
|
namespace FLAC {
|
||||||
|
|
||||||
class TAGLIB_EXPORT Picture : public MetadataBlock
|
class TAGLIB_EXPORT Picture : public MetadataBlock {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* This describes the function or content of the picture.
|
* This describes the function or content of the picture.
|
||||||
*/
|
*/
|
||||||
@@ -88,9 +87,9 @@ namespace TagLib {
|
|||||||
PublisherLogo = 0x14
|
PublisherLogo = 0x14
|
||||||
};
|
};
|
||||||
|
|
||||||
Picture();
|
explicit Picture();
|
||||||
Picture(const ByteVector &data);
|
explicit Picture(const ByteVector &data);
|
||||||
~Picture();
|
~Picture() override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the type of the image.
|
* Returns the type of the image.
|
||||||
@@ -103,14 +102,12 @@ namespace TagLib {
|
|||||||
void setType(Type type);
|
void setType(Type type);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the mime type of the image. This should in most cases be
|
* Returns the mime type of the image. This should in most cases be "image/png" or "image/jpeg".
|
||||||
* "image/png" or "image/jpeg".
|
|
||||||
*/
|
*/
|
||||||
String mimeType() const;
|
String mimeType() const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Sets the mime type of the image. This should in most cases be
|
* Sets the mime type of the image. This should in most cases be "image/png" or "image/jpeg".
|
||||||
* "image/png" or "image/jpeg".
|
|
||||||
*/
|
*/
|
||||||
void setMimeType(const String &m);
|
void setMimeType(const String &m);
|
||||||
|
|
||||||
@@ -179,12 +176,12 @@ namespace TagLib {
|
|||||||
/*!
|
/*!
|
||||||
* Returns the FLAC metadata block type.
|
* Returns the FLAC metadata block type.
|
||||||
*/
|
*/
|
||||||
int code() const;
|
int code() const override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Render the content to the FLAC picture block format.
|
* Render the content to the FLAC picture block format.
|
||||||
*/
|
*/
|
||||||
ByteVector render() const;
|
ByteVector render() const override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Parse the picture data in the FLAC picture block format.
|
* Parse the picture data in the FLAC picture block format.
|
||||||
@@ -197,12 +194,10 @@ namespace TagLib {
|
|||||||
|
|
||||||
class PicturePrivate;
|
class PicturePrivate;
|
||||||
PicturePrivate *d;
|
PicturePrivate *d;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef List<Picture> PictureList;
|
} // namespace FLAC
|
||||||
|
} // namespace TagLib
|
||||||
}
|
} // namespace Strawberry_TagLib
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
82
3rdparty/taglib/flac/flacproperties.cpp
vendored
82
3rdparty/taglib/flac/flacproperties.cpp
vendored
@@ -23,19 +23,17 @@
|
|||||||
* http://www.mozilla.org/MPL/ *
|
* http://www.mozilla.org/MPL/ *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include <tstring.h>
|
#include "tstring.h"
|
||||||
#include <tdebug.h>
|
#include "tdebug.h"
|
||||||
|
|
||||||
#include "flacproperties.h"
|
#include "flacproperties.h"
|
||||||
#include "flacfile.h"
|
#include "flacfile.h"
|
||||||
|
|
||||||
using namespace TagLib;
|
using namespace Strawberry_TagLib::TagLib;
|
||||||
|
|
||||||
class FLAC::Properties::PropertiesPrivate
|
class FLAC::AudioProperties::AudioPropertiesPrivate {
|
||||||
{
|
public:
|
||||||
public:
|
explicit AudioPropertiesPrivate() : length(0),
|
||||||
PropertiesPrivate() :
|
|
||||||
length(0),
|
|
||||||
bitrate(0),
|
bitrate(0),
|
||||||
sampleRate(0),
|
sampleRate(0),
|
||||||
bitsPerSample(0),
|
bitsPerSample(0),
|
||||||
@@ -55,72 +53,43 @@ public:
|
|||||||
// public members
|
// public members
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
FLAC::Properties::Properties(ByteVector data, long streamLength, ReadStyle style) :
|
FLAC::AudioProperties::AudioProperties(const ByteVector &data, long long streamLength, ReadStyle) : Strawberry_TagLib::TagLib::AudioProperties(), d(new AudioPropertiesPrivate()) {
|
||||||
AudioProperties(style),
|
|
||||||
d(new PropertiesPrivate())
|
|
||||||
{
|
|
||||||
read(data, streamLength);
|
read(data, streamLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
FLAC::Properties::Properties(File *, ReadStyle style) :
|
FLAC::AudioProperties::~AudioProperties() {
|
||||||
AudioProperties(style),
|
|
||||||
d(new PropertiesPrivate())
|
|
||||||
{
|
|
||||||
debug("FLAC::Properties::Properties() - This constructor is no longer used.");
|
|
||||||
}
|
|
||||||
|
|
||||||
FLAC::Properties::~Properties()
|
|
||||||
{
|
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FLAC::Properties::length() const
|
int FLAC::AudioProperties::lengthInSeconds() const {
|
||||||
{
|
|
||||||
return lengthInSeconds();
|
|
||||||
}
|
|
||||||
|
|
||||||
int FLAC::Properties::lengthInSeconds() const
|
|
||||||
{
|
|
||||||
return d->length / 1000;
|
return d->length / 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FLAC::Properties::lengthInMilliseconds() const
|
int FLAC::AudioProperties::lengthInMilliseconds() const {
|
||||||
{
|
|
||||||
return d->length;
|
return d->length;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FLAC::Properties::bitrate() const
|
int FLAC::AudioProperties::bitrate() const {
|
||||||
{
|
|
||||||
return d->bitrate;
|
return d->bitrate;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FLAC::Properties::sampleRate() const
|
int FLAC::AudioProperties::sampleRate() const {
|
||||||
{
|
|
||||||
return d->sampleRate;
|
return d->sampleRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FLAC::Properties::bitsPerSample() const
|
int FLAC::AudioProperties::bitsPerSample() const {
|
||||||
{
|
|
||||||
return d->bitsPerSample;
|
return d->bitsPerSample;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FLAC::Properties::sampleWidth() const
|
int FLAC::AudioProperties::channels() const {
|
||||||
{
|
|
||||||
return bitsPerSample();
|
|
||||||
}
|
|
||||||
|
|
||||||
int FLAC::Properties::channels() const
|
|
||||||
{
|
|
||||||
return d->channels;
|
return d->channels;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long long FLAC::Properties::sampleFrames() const
|
unsigned long long FLAC::AudioProperties::sampleFrames() const {
|
||||||
{
|
|
||||||
return d->sampleFrames;
|
return d->sampleFrames;
|
||||||
}
|
}
|
||||||
|
|
||||||
ByteVector FLAC::Properties::signature() const
|
ByteVector FLAC::AudioProperties::signature() const {
|
||||||
{
|
|
||||||
return d->signature;
|
return d->signature;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,14 +97,14 @@ ByteVector FLAC::Properties::signature() const
|
|||||||
// private members
|
// private members
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void FLAC::Properties::read(const ByteVector &data, long streamLength)
|
void FLAC::AudioProperties::read(const ByteVector &data, long long streamLength) {
|
||||||
{
|
|
||||||
if(data.size() < 18) {
|
if (data.size() < 18) {
|
||||||
debug("FLAC::Properties::read() - FLAC properties must contain at least 18 bytes.");
|
debug("FLAC::AudioProperties::read() - FLAC properties must contain at least 18 bytes.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int pos = 0;
|
size_t pos = 0;
|
||||||
|
|
||||||
// Minimum block size (in samples)
|
// Minimum block size (in samples)
|
||||||
pos += 2;
|
pos += 2;
|
||||||
@@ -149,7 +118,7 @@ void FLAC::Properties::read(const ByteVector &data, long streamLength)
|
|||||||
// Maximum frame size (in bytes)
|
// Maximum frame size (in bytes)
|
||||||
pos += 3;
|
pos += 3;
|
||||||
|
|
||||||
const unsigned int flags = data.toUInt(pos, true);
|
const unsigned int flags = data.toUInt32BE(pos);
|
||||||
pos += 4;
|
pos += 4;
|
||||||
|
|
||||||
d->sampleRate = flags >> 12;
|
d->sampleRate = flags >> 12;
|
||||||
@@ -160,17 +129,18 @@ void FLAC::Properties::read(const ByteVector &data, long streamLength)
|
|||||||
// stream length in samples. (Audio files measured in days)
|
// stream length in samples. (Audio files measured in days)
|
||||||
|
|
||||||
const unsigned long long hi = flags & 0xf;
|
const unsigned long long hi = flags & 0xf;
|
||||||
const unsigned long long lo = data.toUInt(pos, true);
|
const unsigned long long lo = data.toUInt32BE(pos);
|
||||||
pos += 4;
|
pos += 4;
|
||||||
|
|
||||||
d->sampleFrames = (hi << 32) | lo;
|
d->sampleFrames = (hi << 32) | lo;
|
||||||
|
|
||||||
if(d->sampleFrames > 0 && d->sampleRate > 0) {
|
if (d->sampleFrames > 0 && d->sampleRate > 0) {
|
||||||
const double length = d->sampleFrames * 1000.0 / d->sampleRate;
|
const double length = d->sampleFrames * 1000.0 / d->sampleRate;
|
||||||
d->length = static_cast<int>(length + 0.5);
|
d->length = static_cast<int>(length + 0.5);
|
||||||
d->bitrate = static_cast<int>(streamLength * 8.0 / length + 0.5);
|
d->bitrate = static_cast<int>(streamLength * 8.0 / length + 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(data.size() >= pos + 16)
|
if (data.size() >= pos + 16)
|
||||||
d->signature = data.mid(pos, 16);
|
d->signature = data.mid(pos, 16);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
89
3rdparty/taglib/flac/flacproperties.h
vendored
89
3rdparty/taglib/flac/flacproperties.h
vendored
@@ -29,120 +29,83 @@
|
|||||||
#include "taglib_export.h"
|
#include "taglib_export.h"
|
||||||
#include "audioproperties.h"
|
#include "audioproperties.h"
|
||||||
|
|
||||||
|
namespace Strawberry_TagLib {
|
||||||
namespace TagLib {
|
namespace TagLib {
|
||||||
|
|
||||||
namespace FLAC {
|
namespace FLAC {
|
||||||
|
|
||||||
class File;
|
class File;
|
||||||
|
|
||||||
//! An implementation of audio property reading for FLAC
|
//! An implementation of audio property reading for FLAC
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* This reads the data from an FLAC stream found in the AudioProperties
|
* This reads the data from an FLAC stream found in the AudioProperties API.
|
||||||
* API.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class TAGLIB_EXPORT Properties : public AudioProperties
|
class TAGLIB_EXPORT AudioProperties : public Strawberry_TagLib::TagLib::AudioProperties {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
/*!
|
/*!
|
||||||
* Create an instance of FLAC::Properties with the data read from the
|
* Create an instance of FLAC::AudioProperties with the data read from the ByteVector \a data.
|
||||||
* ByteVector \a data.
|
|
||||||
*/
|
*/
|
||||||
// BIC: switch to const reference
|
explicit AudioProperties(const ByteVector &data, long long streamLength, ReadStyle style = Average);
|
||||||
Properties(ByteVector data, long streamLength, ReadStyle style = Average);
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Create an instance of FLAC::Properties with the data read from the
|
* Destroys this FLAC::AudioProperties instance.
|
||||||
* FLAC::File \a file.
|
|
||||||
*/
|
*/
|
||||||
// BIC: remove
|
~AudioProperties() override;
|
||||||
Properties(File *file, ReadStyle style = Average);
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Destroys this FLAC::Properties instance.
|
* Returns the length of the file in seconds. The length is rounded down to the nearest whole second.
|
||||||
*/
|
|
||||||
virtual ~Properties();
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* Returns the length of the file in seconds. The length is rounded down to
|
|
||||||
* the nearest whole second.
|
|
||||||
*
|
|
||||||
* \note This method is just an alias of lengthInSeconds().
|
|
||||||
*
|
|
||||||
* \deprecated
|
|
||||||
*/
|
|
||||||
virtual int length() const;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* Returns the length of the file in seconds. The length is rounded down to
|
|
||||||
* the nearest whole second.
|
|
||||||
*
|
*
|
||||||
* \see lengthInMilliseconds()
|
* \see lengthInMilliseconds()
|
||||||
*/
|
*/
|
||||||
// BIC: make virtual
|
int lengthInSeconds() const override;
|
||||||
int lengthInSeconds() const;
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the length of the file in milliseconds.
|
* Returns the length of the file in milliseconds.
|
||||||
*
|
*
|
||||||
* \see lengthInSeconds()
|
* \see lengthInSeconds()
|
||||||
*/
|
*/
|
||||||
// BIC: make virtual
|
int lengthInMilliseconds() const override;
|
||||||
int lengthInMilliseconds() const;
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the average bit rate of the file in kb/s.
|
* Returns the average bit rate of the file in kb/s.
|
||||||
*/
|
*/
|
||||||
virtual int bitrate() const;
|
int bitrate() const override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the sample rate in Hz.
|
* Returns the sample rate in Hz.
|
||||||
*/
|
*/
|
||||||
virtual int sampleRate() const;
|
int sampleRate() const override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the number of audio channels.
|
* Returns the number of audio channels.
|
||||||
*/
|
*/
|
||||||
virtual int channels() const;
|
int channels() const override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the number of bits per audio sample as read from the FLAC
|
* Returns the number of bits per audio sample as read from the FLAC identification header.
|
||||||
* identification header.
|
|
||||||
*/
|
*/
|
||||||
int bitsPerSample() const;
|
int bitsPerSample() const;
|
||||||
|
|
||||||
/*!
|
|
||||||
* Returns the sample width as read from the FLAC identification
|
|
||||||
* header.
|
|
||||||
*
|
|
||||||
* \note This method is just an alias of bitsPerSample().
|
|
||||||
*
|
|
||||||
* \deprecated
|
|
||||||
*/
|
|
||||||
int sampleWidth() const;
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Return the number of sample frames.
|
* Return the number of sample frames.
|
||||||
*/
|
*/
|
||||||
unsigned long long sampleFrames() const;
|
unsigned long long sampleFrames() const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the MD5 signature of the uncompressed audio stream as read
|
* Returns the MD5 signature of the uncompressed audio stream as read from the stream info header.
|
||||||
* from the stream info header.
|
|
||||||
*/
|
*/
|
||||||
ByteVector signature() const;
|
ByteVector signature() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Properties(const Properties &);
|
void read(const ByteVector &data, long long streamLength);
|
||||||
Properties &operator=(const Properties &);
|
|
||||||
|
|
||||||
void read(const ByteVector &data, long streamLength);
|
class AudioPropertiesPrivate;
|
||||||
|
AudioPropertiesPrivate *d;
|
||||||
class PropertiesPrivate;
|
};
|
||||||
PropertiesPrivate *d;
|
} // namespace FLAC
|
||||||
};
|
} // namespace TagLib
|
||||||
}
|
} // namespace Strawberry_TagLib
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -23,56 +23,46 @@
|
|||||||
* http://www.mozilla.org/MPL/ *
|
* http://www.mozilla.org/MPL/ *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include <taglib.h>
|
#include "taglib.h"
|
||||||
#include <tdebug.h>
|
#include "tdebug.h"
|
||||||
#include <tstring.h>
|
#include "tstring.h"
|
||||||
#include "flacunknownmetadatablock.h"
|
#include "flacunknownmetadatablock.h"
|
||||||
|
|
||||||
using namespace TagLib;
|
using namespace Strawberry_TagLib::TagLib;
|
||||||
|
|
||||||
class FLAC::UnknownMetadataBlock::UnknownMetadataBlockPrivate
|
class FLAC::UnknownMetadataBlock::UnknownMetadataBlockPrivate {
|
||||||
{
|
public:
|
||||||
public:
|
explicit UnknownMetadataBlockPrivate() : code(0) {}
|
||||||
UnknownMetadataBlockPrivate() : code(0) {}
|
|
||||||
|
|
||||||
int code;
|
int code;
|
||||||
ByteVector data;
|
ByteVector data;
|
||||||
};
|
};
|
||||||
|
|
||||||
FLAC::UnknownMetadataBlock::UnknownMetadataBlock(int code, const ByteVector &data) :
|
FLAC::UnknownMetadataBlock::UnknownMetadataBlock(int code, const ByteVector &data) : d(new UnknownMetadataBlockPrivate()) {
|
||||||
d(new UnknownMetadataBlockPrivate())
|
|
||||||
{
|
|
||||||
d->code = code;
|
d->code = code;
|
||||||
d->data = data;
|
d->data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
FLAC::UnknownMetadataBlock::~UnknownMetadataBlock()
|
FLAC::UnknownMetadataBlock::~UnknownMetadataBlock() {
|
||||||
{
|
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FLAC::UnknownMetadataBlock::code() const
|
int FLAC::UnknownMetadataBlock::code() const {
|
||||||
{
|
|
||||||
return d->code;
|
return d->code;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FLAC::UnknownMetadataBlock::setCode(int code)
|
void FLAC::UnknownMetadataBlock::setCode(int code) {
|
||||||
{
|
|
||||||
d->code = code;
|
d->code = code;
|
||||||
}
|
}
|
||||||
|
|
||||||
ByteVector FLAC::UnknownMetadataBlock::data() const
|
ByteVector FLAC::UnknownMetadataBlock::data() const {
|
||||||
{
|
|
||||||
return d->data;
|
return d->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FLAC::UnknownMetadataBlock::setData(const ByteVector &data)
|
void FLAC::UnknownMetadataBlock::setData(const ByteVector &data) {
|
||||||
{
|
|
||||||
d->data = data;
|
d->data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
ByteVector FLAC::UnknownMetadataBlock::render() const
|
ByteVector FLAC::UnknownMetadataBlock::render() const {
|
||||||
{
|
|
||||||
return d->data;
|
return d->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
25
3rdparty/taglib/flac/flacunknownmetadatablock.h
vendored
25
3rdparty/taglib/flac/flacunknownmetadatablock.h
vendored
@@ -31,20 +31,19 @@
|
|||||||
#include "taglib_export.h"
|
#include "taglib_export.h"
|
||||||
#include "flacmetadatablock.h"
|
#include "flacmetadatablock.h"
|
||||||
|
|
||||||
|
namespace Strawberry_TagLib {
|
||||||
namespace TagLib {
|
namespace TagLib {
|
||||||
|
namespace FLAC {
|
||||||
|
|
||||||
namespace FLAC {
|
class TAGLIB_EXPORT UnknownMetadataBlock : public MetadataBlock {
|
||||||
|
|
||||||
class TAGLIB_EXPORT UnknownMetadataBlock : public MetadataBlock
|
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
UnknownMetadataBlock(int blockType, const ByteVector &data);
|
explicit UnknownMetadataBlock(int code, const ByteVector &data);
|
||||||
~UnknownMetadataBlock();
|
~UnknownMetadataBlock() override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the FLAC metadata block type.
|
* Returns the FLAC metadata block type.
|
||||||
*/
|
*/
|
||||||
int code() const;
|
int code() const override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Sets the FLAC metadata block type.
|
* Sets the FLAC metadata block type.
|
||||||
@@ -64,18 +63,18 @@ namespace TagLib {
|
|||||||
/*!
|
/*!
|
||||||
* Render the content of the block.
|
* Render the content of the block.
|
||||||
*/
|
*/
|
||||||
ByteVector render() const;
|
ByteVector render() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UnknownMetadataBlock(const MetadataBlock &item);
|
explicit UnknownMetadataBlock(const MetadataBlock &item);
|
||||||
UnknownMetadataBlock &operator=(const MetadataBlock &item);
|
UnknownMetadataBlock &operator=(const MetadataBlock &item);
|
||||||
|
|
||||||
class UnknownMetadataBlockPrivate;
|
class UnknownMetadataBlockPrivate;
|
||||||
UnknownMetadataBlockPrivate *d;
|
UnknownMetadataBlockPrivate *d;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace FLAC
|
||||||
|
} // namespace TagLib
|
||||||
}
|
} // namespace Strawberry_TagLib
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
139
3rdparty/taglib/it/itfile.cpp
vendored
139
3rdparty/taglib/it/itfile.cpp
vendored
@@ -30,68 +30,46 @@
|
|||||||
#include "modfileprivate.h"
|
#include "modfileprivate.h"
|
||||||
#include "tpropertymap.h"
|
#include "tpropertymap.h"
|
||||||
|
|
||||||
using namespace TagLib;
|
using namespace Strawberry_TagLib::TagLib;
|
||||||
using namespace IT;
|
using namespace IT;
|
||||||
|
|
||||||
class IT::File::FilePrivate
|
class IT::File::FilePrivate {
|
||||||
{
|
public:
|
||||||
public:
|
explicit FilePrivate(AudioProperties::ReadStyle propertiesStyle) : properties(propertiesStyle) {}
|
||||||
FilePrivate(AudioProperties::ReadStyle propertiesStyle)
|
|
||||||
: tag(), properties(propertiesStyle)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Mod::Tag tag;
|
Mod::Tag tag;
|
||||||
IT::Properties properties;
|
IT::AudioProperties properties;
|
||||||
};
|
};
|
||||||
|
|
||||||
IT::File::File(FileName file, bool readProperties,
|
IT::File::File(FileName file, bool readProperties, AudioProperties::ReadStyle propertiesStyle) : Mod::FileBase(file), d(new FilePrivate(propertiesStyle)) {
|
||||||
AudioProperties::ReadStyle propertiesStyle) :
|
|
||||||
Mod::FileBase(file),
|
if (isOpen())
|
||||||
d(new FilePrivate(propertiesStyle))
|
|
||||||
{
|
|
||||||
if(isOpen())
|
|
||||||
read(readProperties);
|
read(readProperties);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IT::File::File(IOStream *stream, bool readProperties,
|
IT::File::File(IOStream *stream, bool readProperties, AudioProperties::ReadStyle propertiesStyle) : Mod::FileBase(stream), d(new FilePrivate(propertiesStyle)) {
|
||||||
AudioProperties::ReadStyle propertiesStyle) :
|
|
||||||
Mod::FileBase(stream),
|
if (isOpen())
|
||||||
d(new FilePrivate(propertiesStyle))
|
|
||||||
{
|
|
||||||
if(isOpen())
|
|
||||||
read(readProperties);
|
read(readProperties);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IT::File::~File()
|
IT::File::~File() {
|
||||||
{
|
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
Mod::Tag *IT::File::tag() const
|
Mod::Tag *IT::File::tag() const {
|
||||||
{
|
|
||||||
return &d->tag;
|
return &d->tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertyMap IT::File::properties() const
|
IT::AudioProperties *IT::File::audioProperties() const {
|
||||||
{
|
|
||||||
return d->tag.properties();
|
|
||||||
}
|
|
||||||
|
|
||||||
PropertyMap IT::File::setProperties(const PropertyMap &properties)
|
|
||||||
{
|
|
||||||
return d->tag.setProperties(properties);
|
|
||||||
}
|
|
||||||
|
|
||||||
IT::Properties *IT::File::audioProperties() const
|
|
||||||
{
|
|
||||||
return &d->properties;
|
return &d->properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IT::File::save()
|
bool IT::File::save() {
|
||||||
{
|
|
||||||
if(readOnly())
|
if (readOnly()) {
|
||||||
{
|
|
||||||
debug("IT::File::save() - Cannot save to a read only file.");
|
debug("IT::File::save() - Cannot save to a read only file.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -105,37 +83,37 @@ bool IT::File::save()
|
|||||||
unsigned short instrumentCount = 0;
|
unsigned short instrumentCount = 0;
|
||||||
unsigned short sampleCount = 0;
|
unsigned short sampleCount = 0;
|
||||||
|
|
||||||
if(!readU16L(length) || !readU16L(instrumentCount) || !readU16L(sampleCount))
|
if (!readU16L(length) || !readU16L(instrumentCount) || !readU16L(sampleCount))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
seek(15, Current);
|
seek(15, Current);
|
||||||
|
|
||||||
// write comment as instrument and sample names:
|
// write comment as instrument and sample names:
|
||||||
StringList lines = d->tag.comment().split("\n");
|
StringList lines = d->tag.comment().split("\n");
|
||||||
for(unsigned short i = 0; i < instrumentCount; ++ i) {
|
for (unsigned short i = 0; i < instrumentCount; ++i) {
|
||||||
seek(192L + length + ((long)i << 2));
|
seek(192L + length + (static_cast<long>(i) << 2));
|
||||||
unsigned long instrumentOffset = 0;
|
unsigned int instrumentOffset = 0;
|
||||||
if(!readU32L(instrumentOffset))
|
if (!readU32L(instrumentOffset))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
seek(instrumentOffset + 32);
|
seek(instrumentOffset + 32);
|
||||||
|
|
||||||
if(i < lines.size())
|
if (i < lines.size())
|
||||||
writeString(lines[i], 25);
|
writeString(lines[i], 25);
|
||||||
else
|
else
|
||||||
writeString(String(), 25);
|
writeString(String(), 25);
|
||||||
writeByte(0);
|
writeByte(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(unsigned short i = 0; i < sampleCount; ++ i) {
|
for (unsigned short i = 0; i < sampleCount; ++i) {
|
||||||
seek(192L + length + ((long)instrumentCount << 2) + ((long)i << 2));
|
seek(192L + length + (static_cast<long>(instrumentCount) << 2) + (static_cast<long>(i) << 2));
|
||||||
unsigned long sampleOffset = 0;
|
unsigned int sampleOffset = 0;
|
||||||
if(!readU32L(sampleOffset))
|
if (!readU32L(sampleOffset))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
seek(sampleOffset + 20);
|
seek(sampleOffset + 20);
|
||||||
|
|
||||||
if((unsigned int)(i + instrumentCount) < lines.size())
|
if (static_cast<unsigned int>(i + instrumentCount) < lines.size())
|
||||||
writeString(lines[i + instrumentCount], 25);
|
writeString(lines[i + instrumentCount], 25);
|
||||||
else
|
else
|
||||||
writeString(String(), 25);
|
writeString(String(), 25);
|
||||||
@@ -144,41 +122,40 @@ bool IT::File::save()
|
|||||||
|
|
||||||
// write rest as message:
|
// write rest as message:
|
||||||
StringList messageLines;
|
StringList messageLines;
|
||||||
for(unsigned int i = instrumentCount + sampleCount; i < lines.size(); ++ i)
|
for (unsigned int i = instrumentCount + sampleCount; i < lines.size(); ++i)
|
||||||
messageLines.append(lines[i]);
|
messageLines.append(lines[i]);
|
||||||
ByteVector message = messageLines.toString("\r").data(String::Latin1);
|
ByteVector message = messageLines.toString("\r").data(String::Latin1);
|
||||||
|
|
||||||
// it's actually not really stated if the message needs a
|
// it's actually not really stated if the message needs a
|
||||||
// terminating NUL but it does not hurt to add one:
|
// terminating NUL but it does not hurt to add one:
|
||||||
if(message.size() > 7999)
|
if (message.size() > 7999)
|
||||||
message.resize(7999);
|
message.resize(7999);
|
||||||
message.append((char)0);
|
message.append(static_cast<char>(0));
|
||||||
|
|
||||||
unsigned short special = 0;
|
unsigned short special = 0;
|
||||||
unsigned short messageLength = 0;
|
unsigned short messageLength = 0;
|
||||||
unsigned long messageOffset = 0;
|
unsigned int messageOffset = 0;
|
||||||
|
|
||||||
seek(46);
|
seek(46);
|
||||||
if(!readU16L(special))
|
if (!readU16L(special))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
unsigned long fileSize = File::length();
|
unsigned int fileSize = File::length();
|
||||||
if(special & Properties::MessageAttached) {
|
if (special & AudioProperties::MessageAttached) {
|
||||||
seek(54);
|
seek(54);
|
||||||
if(!readU16L(messageLength) || !readU32L(messageOffset))
|
if (!readU16L(messageLength) || !readU32L(messageOffset))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(messageLength == 0)
|
if (messageLength == 0)
|
||||||
messageOffset = fileSize;
|
messageOffset = fileSize;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
messageOffset = fileSize;
|
messageOffset = fileSize;
|
||||||
seek(46);
|
seek(46);
|
||||||
writeU16L(special | 0x1);
|
writeU16L(special | 0x1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(messageOffset + messageLength >= fileSize) {
|
if (messageOffset + messageLength >= fileSize) {
|
||||||
// append new message
|
// append new message
|
||||||
seek(54);
|
seek(54);
|
||||||
writeU16L(message.size());
|
writeU16L(message.size());
|
||||||
@@ -199,9 +176,8 @@ bool IT::File::save()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IT::File::read(bool)
|
void IT::File::read(bool) {
|
||||||
{
|
if (!isOpen())
|
||||||
if(!isOpen())
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
seek(0);
|
seek(0);
|
||||||
@@ -233,14 +209,14 @@ void IT::File::read(bool)
|
|||||||
// sample/instrument names are abused as comments so
|
// sample/instrument names are abused as comments so
|
||||||
// I just add all together.
|
// I just add all together.
|
||||||
String message;
|
String message;
|
||||||
if(special & Properties::MessageAttached) {
|
if (special & AudioProperties::MessageAttached) {
|
||||||
READ_U16L_AS(messageLength);
|
READ_U16L_AS(messageLength);
|
||||||
READ_U32L_AS(messageOffset);
|
READ_U32L_AS(messageOffset);
|
||||||
seek(messageOffset);
|
seek(messageOffset);
|
||||||
ByteVector messageBytes = readBlock(messageLength);
|
ByteVector messageBytes = readBlock(messageLength);
|
||||||
READ_ASSERT(messageBytes.size() == messageLength);
|
READ_ASSERT(messageBytes.size() == messageLength);
|
||||||
int index = messageBytes.find((char) 0);
|
const size_t index = messageBytes.find(static_cast<char>(0));
|
||||||
if(index > -1)
|
if (index != ByteVector::npos())
|
||||||
messageBytes.resize(index, 0);
|
messageBytes.resize(index, 0);
|
||||||
messageBytes.replace('\r', '\n');
|
messageBytes.replace('\r', '\n');
|
||||||
message = messageBytes;
|
message = messageBytes;
|
||||||
@@ -252,23 +228,23 @@ void IT::File::read(bool)
|
|||||||
ByteVector volumes = readBlock(64);
|
ByteVector volumes = readBlock(64);
|
||||||
READ_ASSERT(pannings.size() == 64 && volumes.size() == 64);
|
READ_ASSERT(pannings.size() == 64 && volumes.size() == 64);
|
||||||
int channels = 0;
|
int channels = 0;
|
||||||
for(int i = 0; i < 64; ++ i) {
|
for (int i = 0; i < 64; ++i) {
|
||||||
// Strictly speaking an IT file has always 64 channels, but
|
// Strictly speaking an IT file has always 64 channels, but
|
||||||
// I don't count disabled and muted channels.
|
// I don't count disabled and muted channels.
|
||||||
// But this always gives 64 channels for all my files anyway.
|
// But this always gives 64 channels for all my files anyway.
|
||||||
// Strangely VLC does report other values. I wonder how VLC
|
// Strangely VLC does report other values. I wonder how VLC
|
||||||
// gets it's values.
|
// gets it's values.
|
||||||
if((unsigned char) pannings[i] < 128 && volumes[i] > 0)
|
if (static_cast<unsigned char>(pannings[i]) < 128 && volumes[i] > 0)
|
||||||
++channels;
|
++channels;
|
||||||
}
|
}
|
||||||
d->properties.setChannels(channels);
|
d->properties.setChannels(channels);
|
||||||
|
|
||||||
// real length might be shorter because of skips and terminator
|
// real length might be shorter because of skips and terminator
|
||||||
unsigned short realLength = 0;
|
unsigned short realLength = 0;
|
||||||
for(unsigned short i = 0; i < length; ++ i) {
|
for (unsigned short i = 0; i < length; ++i) {
|
||||||
READ_BYTE_AS(order);
|
READ_BYTE_AS(order);
|
||||||
if(order == 255) break;
|
if (order == 255) break;
|
||||||
if(order != 254) ++ realLength;
|
if (order != 254) ++realLength;
|
||||||
}
|
}
|
||||||
d->properties.setLengthInPatterns(realLength);
|
d->properties.setLengthInPatterns(realLength);
|
||||||
|
|
||||||
@@ -277,10 +253,10 @@ void IT::File::read(bool)
|
|||||||
// in the instrument/sample names and more characters
|
// in the instrument/sample names and more characters
|
||||||
// afterwards. The spec does not mention such a case.
|
// afterwards. The spec does not mention such a case.
|
||||||
// Currently I just discard anything after a nil, but
|
// Currently I just discard anything after a nil, but
|
||||||
// e.g. VLC seems to interprete a nil as a space. I
|
// e.g. VLC seems to interpret a nil as a space. I
|
||||||
// don't know what is the proper behaviour.
|
// don't know what is the proper behaviour.
|
||||||
for(unsigned short i = 0; i < instrumentCount; ++ i) {
|
for (unsigned short i = 0; i < instrumentCount; ++i) {
|
||||||
seek(192L + length + ((long)i << 2));
|
seek(192L + length + (static_cast<long>(i) << 2));
|
||||||
READ_U32L_AS(instrumentOffset);
|
READ_U32L_AS(instrumentOffset);
|
||||||
seek(instrumentOffset);
|
seek(instrumentOffset);
|
||||||
|
|
||||||
@@ -295,8 +271,8 @@ void IT::File::read(bool)
|
|||||||
comment.append(instrumentName);
|
comment.append(instrumentName);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(unsigned short i = 0; i < sampleCount; ++ i) {
|
for (unsigned short i = 0; i < sampleCount; ++i) {
|
||||||
seek(192L + length + ((long)instrumentCount << 2) + ((long)i << 2));
|
seek(192L + length + (static_cast<long>(instrumentCount) << 2) + (static_cast<long>(i) << 2));
|
||||||
READ_U32L_AS(sampleOffset);
|
READ_U32L_AS(sampleOffset);
|
||||||
|
|
||||||
seek(sampleOffset);
|
seek(sampleOffset);
|
||||||
@@ -328,8 +304,9 @@ void IT::File::read(bool)
|
|||||||
comment.append(sampleName);
|
comment.append(sampleName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(message.size() > 0)
|
if (message.size() > 0)
|
||||||
comment.append(message);
|
comment.append(message);
|
||||||
d->tag.setComment(comment.toString("\n"));
|
d->tag.setComment(comment.toString("\n"));
|
||||||
d->tag.setTrackerName("Impulse Tracker");
|
d->tag.setTrackerName("Impulse Tracker");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
62
3rdparty/taglib/it/itfile.h
vendored
62
3rdparty/taglib/it/itfile.h
vendored
@@ -29,61 +29,42 @@
|
|||||||
#include "modtag.h"
|
#include "modtag.h"
|
||||||
#include "itproperties.h"
|
#include "itproperties.h"
|
||||||
|
|
||||||
|
namespace Strawberry_TagLib {
|
||||||
namespace TagLib {
|
namespace TagLib {
|
||||||
|
namespace IT {
|
||||||
|
|
||||||
namespace IT {
|
class TAGLIB_EXPORT File : public Mod::FileBase {
|
||||||
|
|
||||||
class TAGLIB_EXPORT File : public Mod::FileBase {
|
|
||||||
public:
|
public:
|
||||||
/*!
|
/*!
|
||||||
* Constructs a Impulse Tracker file from \a file.
|
* Constructs a Impulse Tracker file from \a file.
|
||||||
*
|
*
|
||||||
* \note In the current implementation, both \a readProperties and
|
* \note In the current implementation, both \a readProperties and \a propertiesStyle are ignored.
|
||||||
* \a propertiesStyle are ignored. The audio properties are always
|
* The audio properties are always read.
|
||||||
* read.
|
|
||||||
*/
|
*/
|
||||||
File(FileName file, bool readProperties = true,
|
explicit File(FileName file, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average);
|
||||||
AudioProperties::ReadStyle propertiesStyle =
|
|
||||||
AudioProperties::Average);
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Constructs a Impulse Tracker file from \a stream.
|
* Constructs a Impulse Tracker file from \a stream.
|
||||||
*
|
*
|
||||||
* \note In the current implementation, both \a readProperties and
|
* \note In the current implementation, both \a readProperties and \a propertiesStyle are ignored.
|
||||||
* \a propertiesStyle are ignored. The audio properties are always
|
* The audio properties are always read.
|
||||||
* read.
|
|
||||||
*
|
*
|
||||||
* \note TagLib will *not* take ownership of the stream, the caller is
|
* \note TagLib will *not* take ownership of the stream, the caller is responsible for deleting it after the File object.
|
||||||
* responsible for deleting it after the File object.
|
|
||||||
*/
|
*/
|
||||||
File(IOStream *stream, bool readProperties = true,
|
explicit File(IOStream *stream, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average);
|
||||||
AudioProperties::ReadStyle propertiesStyle =
|
|
||||||
AudioProperties::Average);
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Destroys this instance of the File.
|
* Destroys this instance of the File.
|
||||||
*/
|
*/
|
||||||
virtual ~File();
|
~File() override;
|
||||||
|
|
||||||
Mod::Tag *tag() const;
|
Mod::Tag *tag() const override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Forwards to Mod::Tag::properties().
|
* Returns the IT::AudioProperties for this file. If no audio properties
|
||||||
* BIC: will be removed once File::toDict() is made virtual
|
|
||||||
*/
|
|
||||||
PropertyMap properties() const;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* Forwards to Mod::Tag::setProperties().
|
|
||||||
* BIC: will be removed once File::setProperties() is made virtual
|
|
||||||
*/
|
|
||||||
PropertyMap setProperties(const PropertyMap &);
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* Returns the IT::Properties for this file. If no audio properties
|
|
||||||
* were read then this will return a null pointer.
|
* were read then this will return a null pointer.
|
||||||
*/
|
*/
|
||||||
IT::Properties *audioProperties() const;
|
IT::AudioProperties *audioProperties() const override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Save the file.
|
* Save the file.
|
||||||
@@ -91,19 +72,20 @@ namespace TagLib {
|
|||||||
*
|
*
|
||||||
* \note Saving Impulse Tracker tags is not supported.
|
* \note Saving Impulse Tracker tags is not supported.
|
||||||
*/
|
*/
|
||||||
bool save();
|
bool save() override;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
File(const File &);
|
File(const File&);
|
||||||
File &operator=(const File &);
|
File &operator=(const File&);
|
||||||
|
|
||||||
void read(bool readProperties);
|
void read(bool readProperties);
|
||||||
|
|
||||||
class FilePrivate;
|
class FilePrivate;
|
||||||
FilePrivate *d;
|
FilePrivate *d;
|
||||||
};
|
};
|
||||||
}
|
|
||||||
}
|
} // namespace IT
|
||||||
|
} // namespace TagLib
|
||||||
|
} // namespace Strawberry_TagLib
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
136
3rdparty/taglib/it/itproperties.cpp
vendored
136
3rdparty/taglib/it/itproperties.cpp
vendored
@@ -26,14 +26,12 @@
|
|||||||
|
|
||||||
#include "itproperties.h"
|
#include "itproperties.h"
|
||||||
|
|
||||||
using namespace TagLib;
|
using namespace Strawberry_TagLib::TagLib;
|
||||||
using namespace IT;
|
using namespace IT;
|
||||||
|
|
||||||
class IT::Properties::PropertiesPrivate
|
class IT::AudioProperties::AudioPropertiesPrivate {
|
||||||
{
|
public:
|
||||||
public:
|
explicit AudioPropertiesPrivate() : channels(0),
|
||||||
PropertiesPrivate() :
|
|
||||||
channels(0),
|
|
||||||
lengthInPatterns(0),
|
lengthInPatterns(0),
|
||||||
instrumentCount(0),
|
instrumentCount(0),
|
||||||
sampleCount(0),
|
sampleCount(0),
|
||||||
@@ -47,8 +45,7 @@ public:
|
|||||||
tempo(0),
|
tempo(0),
|
||||||
bpmSpeed(0),
|
bpmSpeed(0),
|
||||||
panningSeparation(0),
|
panningSeparation(0),
|
||||||
pitchWheelDepth(0)
|
pitchWheelDepth(0) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int channels;
|
int channels;
|
||||||
@@ -68,193 +65,152 @@ public:
|
|||||||
unsigned char pitchWheelDepth;
|
unsigned char pitchWheelDepth;
|
||||||
};
|
};
|
||||||
|
|
||||||
IT::Properties::Properties(AudioProperties::ReadStyle propertiesStyle) :
|
IT::AudioProperties::AudioProperties(AudioProperties::ReadStyle) : Strawberry_TagLib::TagLib::AudioProperties(), d(new AudioPropertiesPrivate()) {}
|
||||||
AudioProperties(propertiesStyle),
|
|
||||||
d(new PropertiesPrivate())
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
IT::Properties::~Properties()
|
IT::AudioProperties::~AudioProperties() {
|
||||||
{
|
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
int IT::Properties::length() const
|
int IT::AudioProperties::lengthInSeconds() const {
|
||||||
{
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int IT::Properties::lengthInSeconds() const
|
int IT::AudioProperties::lengthInMilliseconds() const {
|
||||||
{
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int IT::Properties::lengthInMilliseconds() const
|
int IT::AudioProperties::bitrate() const {
|
||||||
{
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int IT::Properties::bitrate() const
|
int IT::AudioProperties::sampleRate() const {
|
||||||
{
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int IT::Properties::sampleRate() const
|
int IT::AudioProperties::channels() const {
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int IT::Properties::channels() const
|
|
||||||
{
|
|
||||||
return d->channels;
|
return d->channels;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned short IT::Properties::lengthInPatterns() const
|
unsigned short IT::AudioProperties::lengthInPatterns() const {
|
||||||
{
|
|
||||||
return d->lengthInPatterns;
|
return d->lengthInPatterns;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IT::Properties::stereo() const
|
bool IT::AudioProperties::stereo() const {
|
||||||
{
|
|
||||||
return d->flags & Stereo;
|
return d->flags & Stereo;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned short IT::Properties::instrumentCount() const
|
unsigned short IT::AudioProperties::instrumentCount() const {
|
||||||
{
|
|
||||||
return d->instrumentCount;
|
return d->instrumentCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned short IT::Properties::sampleCount() const
|
unsigned short IT::AudioProperties::sampleCount() const {
|
||||||
{
|
|
||||||
return d->sampleCount;
|
return d->sampleCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned short IT::Properties::patternCount() const
|
unsigned short IT::AudioProperties::patternCount() const {
|
||||||
{
|
|
||||||
return d->patternCount;
|
return d->patternCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned short IT::Properties::version() const
|
unsigned short IT::AudioProperties::version() const {
|
||||||
{
|
|
||||||
return d->version;
|
return d->version;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned short IT::Properties::compatibleVersion() const
|
unsigned short IT::AudioProperties::compatibleVersion() const {
|
||||||
{
|
|
||||||
return d->compatibleVersion;
|
return d->compatibleVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned short IT::Properties::flags() const
|
unsigned short IT::AudioProperties::flags() const {
|
||||||
{
|
|
||||||
return d->flags;
|
return d->flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned short IT::Properties::special() const
|
unsigned short IT::AudioProperties::special() const {
|
||||||
{
|
|
||||||
return d->special;
|
return d->special;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char IT::Properties::globalVolume() const
|
unsigned char IT::AudioProperties::globalVolume() const {
|
||||||
{
|
|
||||||
return d->globalVolume;
|
return d->globalVolume;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char IT::Properties::mixVolume() const
|
unsigned char IT::AudioProperties::mixVolume() const {
|
||||||
{
|
|
||||||
return d->mixVolume;
|
return d->mixVolume;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char IT::Properties::tempo() const
|
unsigned char IT::AudioProperties::tempo() const {
|
||||||
{
|
|
||||||
return d->tempo;
|
return d->tempo;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char IT::Properties::bpmSpeed() const
|
unsigned char IT::AudioProperties::bpmSpeed() const {
|
||||||
{
|
|
||||||
return d->bpmSpeed;
|
return d->bpmSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char IT::Properties::panningSeparation() const
|
unsigned char IT::AudioProperties::panningSeparation() const {
|
||||||
{
|
|
||||||
return d->panningSeparation;
|
return d->panningSeparation;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char IT::Properties::pitchWheelDepth() const
|
unsigned char IT::AudioProperties::pitchWheelDepth() const {
|
||||||
{
|
|
||||||
return d->pitchWheelDepth;
|
return d->pitchWheelDepth;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IT::Properties::setChannels(int channels)
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
{
|
// private members
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void IT::AudioProperties::setChannels(int channels) {
|
||||||
d->channels = channels;
|
d->channels = channels;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IT::Properties::setLengthInPatterns(unsigned short lengthInPatterns)
|
void IT::AudioProperties::setLengthInPatterns(unsigned short lengthInPatterns) {
|
||||||
{
|
|
||||||
d->lengthInPatterns = lengthInPatterns;
|
d->lengthInPatterns = lengthInPatterns;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IT::Properties::setInstrumentCount(unsigned short instrumentCount)
|
void IT::AudioProperties::setInstrumentCount(unsigned short instrumentCount) {
|
||||||
{
|
|
||||||
d->instrumentCount = instrumentCount;
|
d->instrumentCount = instrumentCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IT::Properties::setSampleCount(unsigned short sampleCount)
|
void IT::AudioProperties::setSampleCount(unsigned short sampleCount) {
|
||||||
{
|
|
||||||
d->sampleCount = sampleCount;
|
d->sampleCount = sampleCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IT::Properties::setPatternCount(unsigned short patternCount)
|
void IT::AudioProperties::setPatternCount(unsigned short patternCount) {
|
||||||
{
|
|
||||||
d->patternCount = patternCount;
|
d->patternCount = patternCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IT::Properties::setFlags(unsigned short flags)
|
void IT::AudioProperties::setFlags(unsigned short flags) {
|
||||||
{
|
|
||||||
d->flags = flags;
|
d->flags = flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IT::Properties::setSpecial(unsigned short special)
|
void IT::AudioProperties::setSpecial(unsigned short special) {
|
||||||
{
|
|
||||||
d->special = special;
|
d->special = special;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IT::Properties::setCompatibleVersion(unsigned short compatibleVersion)
|
void IT::AudioProperties::setCompatibleVersion(unsigned short compatibleVersion) {
|
||||||
{
|
|
||||||
d->compatibleVersion = compatibleVersion;
|
d->compatibleVersion = compatibleVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IT::Properties::setVersion(unsigned short version)
|
void IT::AudioProperties::setVersion(unsigned short version) {
|
||||||
{
|
|
||||||
d->version = version;
|
d->version = version;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IT::Properties::setGlobalVolume(unsigned char globalVolume)
|
void IT::AudioProperties::setGlobalVolume(unsigned char globalVolume) {
|
||||||
{
|
|
||||||
d->globalVolume = globalVolume;
|
d->globalVolume = globalVolume;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IT::Properties::setMixVolume(unsigned char mixVolume)
|
void IT::AudioProperties::setMixVolume(unsigned char mixVolume) {
|
||||||
{
|
|
||||||
d->mixVolume = mixVolume;
|
d->mixVolume = mixVolume;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IT::Properties::setTempo(unsigned char tempo)
|
void IT::AudioProperties::setTempo(unsigned char tempo) {
|
||||||
{
|
|
||||||
d->tempo = tempo;
|
d->tempo = tempo;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IT::Properties::setBpmSpeed(unsigned char bpmSpeed)
|
void IT::AudioProperties::setBpmSpeed(unsigned char bpmSpeed) {
|
||||||
{
|
|
||||||
d->bpmSpeed = bpmSpeed;
|
d->bpmSpeed = bpmSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IT::Properties::setPanningSeparation(unsigned char panningSeparation)
|
void IT::AudioProperties::setPanningSeparation(unsigned char panningSeparation) {
|
||||||
{
|
|
||||||
d->panningSeparation = panningSeparation;
|
d->panningSeparation = panningSeparation;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IT::Properties::setPitchWheelDepth(unsigned char pitchWheelDepth)
|
void IT::AudioProperties::setPitchWheelDepth(unsigned char pitchWheelDepth) {
|
||||||
{
|
|
||||||
d->pitchWheelDepth = pitchWheelDepth;
|
d->pitchWheelDepth = pitchWheelDepth;
|
||||||
}
|
}
|
||||||
|
|||||||
52
3rdparty/taglib/it/itproperties.h
vendored
52
3rdparty/taglib/it/itproperties.h
vendored
@@ -29,10 +29,12 @@
|
|||||||
#include "taglib.h"
|
#include "taglib.h"
|
||||||
#include "audioproperties.h"
|
#include "audioproperties.h"
|
||||||
|
|
||||||
|
namespace Strawberry_TagLib {
|
||||||
namespace TagLib {
|
namespace TagLib {
|
||||||
namespace IT {
|
namespace IT {
|
||||||
class TAGLIB_EXPORT Properties : public AudioProperties {
|
class TAGLIB_EXPORT AudioProperties : public Strawberry_TagLib::TagLib::AudioProperties {
|
||||||
friend class File;
|
friend class File;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/*! Flag bits. */
|
/*! Flag bits. */
|
||||||
enum {
|
enum {
|
||||||
@@ -52,15 +54,14 @@ namespace TagLib {
|
|||||||
MidiConfEmbedded = 8
|
MidiConfEmbedded = 8
|
||||||
};
|
};
|
||||||
|
|
||||||
Properties(AudioProperties::ReadStyle propertiesStyle);
|
explicit AudioProperties(AudioProperties::ReadStyle);
|
||||||
virtual ~Properties();
|
~AudioProperties() override;
|
||||||
|
|
||||||
int length() const;
|
int lengthInSeconds() const override;
|
||||||
int lengthInSeconds() const;
|
int lengthInMilliseconds() const override;
|
||||||
int lengthInMilliseconds() const;
|
int bitrate() const override;
|
||||||
int bitrate() const;
|
int sampleRate() const override;
|
||||||
int sampleRate() const;
|
int channels() const override;
|
||||||
int channels() const;
|
|
||||||
|
|
||||||
unsigned short lengthInPatterns() const;
|
unsigned short lengthInPatterns() const;
|
||||||
bool stereo() const;
|
bool stereo() const;
|
||||||
@@ -78,30 +79,29 @@ namespace TagLib {
|
|||||||
unsigned char panningSeparation() const;
|
unsigned char panningSeparation() const;
|
||||||
unsigned char pitchWheelDepth() const;
|
unsigned char pitchWheelDepth() const;
|
||||||
|
|
||||||
|
private:
|
||||||
void setChannels(int channels);
|
void setChannels(int channels);
|
||||||
void setLengthInPatterns(unsigned short lengthInPatterns);
|
void setLengthInPatterns(unsigned short lengthInPatterns);
|
||||||
void setInstrumentCount(unsigned short instrumentCount);
|
void setInstrumentCount(unsigned short instrumentCount);
|
||||||
void setSampleCount (unsigned short sampleCount);
|
void setSampleCount(unsigned short sampleCount);
|
||||||
void setPatternCount(unsigned short patternCount);
|
void setPatternCount(unsigned short patternCount);
|
||||||
void setVersion (unsigned short version);
|
void setVersion(unsigned short version);
|
||||||
void setCompatibleVersion(unsigned short compatibleVersion);
|
void setCompatibleVersion(unsigned short compatibleVersion);
|
||||||
void setFlags (unsigned short flags);
|
void setFlags(unsigned short flags);
|
||||||
void setSpecial (unsigned short special);
|
void setSpecial(unsigned short special);
|
||||||
void setGlobalVolume(unsigned char globalVolume);
|
void setGlobalVolume(unsigned char globalVolume);
|
||||||
void setMixVolume (unsigned char mixVolume);
|
void setMixVolume(unsigned char mixVolume);
|
||||||
void setTempo (unsigned char tempo);
|
void setTempo(unsigned char tempo);
|
||||||
void setBpmSpeed (unsigned char bpmSpeed);
|
void setBpmSpeed(unsigned char bpmSpeed);
|
||||||
void setPanningSeparation(unsigned char panningSeparation);
|
void setPanningSeparation(unsigned char panningSeparation);
|
||||||
void setPitchWheelDepth (unsigned char pitchWheelDepth);
|
void setPitchWheelDepth(unsigned char pitchWheelDepth);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Properties(const Properties&);
|
class AudioPropertiesPrivate;
|
||||||
Properties &operator=(const Properties&);
|
AudioPropertiesPrivate *d;
|
||||||
|
};
|
||||||
class PropertiesPrivate;
|
} // namespace IT
|
||||||
PropertiesPrivate *d;
|
} // namespace TagLib
|
||||||
};
|
} // namespace Strawberry_TagLib
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
87
3rdparty/taglib/mod/modfile.cpp
vendored
87
3rdparty/taglib/mod/modfile.cpp
vendored
@@ -30,89 +30,69 @@
|
|||||||
#include "modfileprivate.h"
|
#include "modfileprivate.h"
|
||||||
#include "tpropertymap.h"
|
#include "tpropertymap.h"
|
||||||
|
|
||||||
using namespace TagLib;
|
using namespace Strawberry_TagLib::TagLib;
|
||||||
using namespace Mod;
|
using namespace Mod;
|
||||||
|
|
||||||
class Mod::File::FilePrivate
|
class Mod::File::FilePrivate {
|
||||||
{
|
public:
|
||||||
public:
|
explicit FilePrivate(AudioProperties::ReadStyle propertiesStyle) : properties(propertiesStyle) {}
|
||||||
FilePrivate(AudioProperties::ReadStyle propertiesStyle)
|
|
||||||
: properties(propertiesStyle)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Mod::Tag tag;
|
Mod::Tag tag;
|
||||||
Mod::Properties properties;
|
Mod::AudioProperties properties;
|
||||||
};
|
};
|
||||||
|
|
||||||
Mod::File::File(FileName file, bool readProperties,
|
Mod::File::File(FileName file, bool readProperties, AudioProperties::ReadStyle propertiesStyle) : Mod::FileBase(file), d(new FilePrivate(propertiesStyle)) {
|
||||||
AudioProperties::ReadStyle propertiesStyle) :
|
|
||||||
Mod::FileBase(file),
|
if (isOpen())
|
||||||
d(new FilePrivate(propertiesStyle))
|
|
||||||
{
|
|
||||||
if(isOpen())
|
|
||||||
read(readProperties);
|
read(readProperties);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Mod::File::File(IOStream *stream, bool readProperties,
|
Mod::File::File(IOStream *stream, bool readProperties, AudioProperties::ReadStyle propertiesStyle) : Mod::FileBase(stream), d(new FilePrivate(propertiesStyle)) {
|
||||||
AudioProperties::ReadStyle propertiesStyle) :
|
|
||||||
Mod::FileBase(stream),
|
if (isOpen())
|
||||||
d(new FilePrivate(propertiesStyle))
|
|
||||||
{
|
|
||||||
if(isOpen())
|
|
||||||
read(readProperties);
|
read(readProperties);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Mod::File::~File()
|
Mod::File::~File() {
|
||||||
{
|
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
Mod::Tag *Mod::File::tag() const
|
Mod::Tag *Mod::File::tag() const {
|
||||||
{
|
|
||||||
return &d->tag;
|
return &d->tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
Mod::Properties *Mod::File::audioProperties() const
|
Mod::AudioProperties *Mod::File::audioProperties() const {
|
||||||
{
|
|
||||||
return &d->properties;
|
return &d->properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertyMap Mod::File::properties() const
|
bool Mod::File::save() {
|
||||||
{
|
|
||||||
return d->tag.properties();
|
|
||||||
}
|
|
||||||
|
|
||||||
PropertyMap Mod::File::setProperties(const PropertyMap &properties)
|
if (readOnly()) {
|
||||||
{
|
|
||||||
return d->tag.setProperties(properties);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Mod::File::save()
|
|
||||||
{
|
|
||||||
if(readOnly()) {
|
|
||||||
debug("Mod::File::save() - Cannot save to a read only file.");
|
debug("Mod::File::save() - Cannot save to a read only file.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
seek(0);
|
seek(0);
|
||||||
writeString(d->tag.title(), 20);
|
writeString(d->tag.title(), 20);
|
||||||
StringList lines = d->tag.comment().split("\n");
|
StringList lines = d->tag.comment().split("\n");
|
||||||
unsigned int n = std::min(lines.size(), d->properties.instrumentCount());
|
size_t n = std::min<size_t>(lines.size(), d->properties.instrumentCount());
|
||||||
for(unsigned int i = 0; i < n; ++ i) {
|
for (size_t i = 0; i < n; ++i) {
|
||||||
writeString(lines[i], 22);
|
writeString(lines[i], 22);
|
||||||
seek(8, Current);
|
seek(8, Current);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(unsigned int i = n; i < d->properties.instrumentCount(); ++ i) {
|
for (size_t i = n; i < d->properties.instrumentCount(); ++i) {
|
||||||
writeString(String(), 22);
|
writeString(String(), 22);
|
||||||
seek(8, Current);
|
seek(8, Current);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Mod::File::read(bool)
|
void Mod::File::read(bool) {
|
||||||
{
|
|
||||||
if(!isOpen())
|
if (!isOpen())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
seek(1080);
|
seek(1080);
|
||||||
@@ -121,27 +101,27 @@ void Mod::File::read(bool)
|
|||||||
|
|
||||||
int channels = 4;
|
int channels = 4;
|
||||||
unsigned int instruments = 31;
|
unsigned int instruments = 31;
|
||||||
if(modId == "M.K." || modId == "M!K!" || modId == "M&K!" || modId == "N.T.") {
|
if (modId == "M.K." || modId == "M!K!" || modId == "M&K!" || modId == "N.T.") {
|
||||||
d->tag.setTrackerName("ProTracker");
|
d->tag.setTrackerName("ProTracker");
|
||||||
channels = 4;
|
channels = 4;
|
||||||
}
|
}
|
||||||
else if(modId.startsWith("FLT") || modId.startsWith("TDZ")) {
|
else if (modId.startsWith("FLT") || modId.startsWith("TDZ")) {
|
||||||
d->tag.setTrackerName("StarTrekker");
|
d->tag.setTrackerName("StarTrekker");
|
||||||
char digit = modId[3];
|
char digit = modId[3];
|
||||||
READ_ASSERT(digit >= '0' && digit <= '9');
|
READ_ASSERT(digit >= '0' && digit <= '9');
|
||||||
channels = digit - '0';
|
channels = digit - '0';
|
||||||
}
|
}
|
||||||
else if(modId.endsWith("CHN")) {
|
else if (modId.endsWith("CHN")) {
|
||||||
d->tag.setTrackerName("StarTrekker");
|
d->tag.setTrackerName("StarTrekker");
|
||||||
char digit = modId[0];
|
char digit = modId[0];
|
||||||
READ_ASSERT(digit >= '0' && digit <= '9');
|
READ_ASSERT(digit >= '0' && digit <= '9');
|
||||||
channels = digit - '0';
|
channels = digit - '0';
|
||||||
}
|
}
|
||||||
else if(modId == "CD81" || modId == "OKTA") {
|
else if (modId == "CD81" || modId == "OKTA") {
|
||||||
d->tag.setTrackerName("Atari Oktalyzer");
|
d->tag.setTrackerName("Atari Oktalyzer");
|
||||||
channels = 8;
|
channels = 8;
|
||||||
}
|
}
|
||||||
else if(modId.endsWith("CH") || modId.endsWith("CN")) {
|
else if (modId.endsWith("CH") || modId.endsWith("CN")) {
|
||||||
d->tag.setTrackerName("TakeTracker");
|
d->tag.setTrackerName("TakeTracker");
|
||||||
char digit = modId[0];
|
char digit = modId[0];
|
||||||
READ_ASSERT(digit >= '0' && digit <= '9');
|
READ_ASSERT(digit >= '0' && digit <= '9');
|
||||||
@@ -164,7 +144,7 @@ void Mod::File::read(bool)
|
|||||||
READ_STRING(d->tag.setTitle, 20);
|
READ_STRING(d->tag.setTitle, 20);
|
||||||
|
|
||||||
StringList comment;
|
StringList comment;
|
||||||
for(unsigned int i = 0; i < instruments; ++ i) {
|
for (unsigned int i = 0; i < instruments; ++i) {
|
||||||
READ_STRING_AS(instrumentName, 22);
|
READ_STRING_AS(instrumentName, 22);
|
||||||
// value in words, * 2 (<< 1) for bytes:
|
// value in words, * 2 (<< 1) for bytes:
|
||||||
READ_U16B_AS(sampleLength);
|
READ_U16B_AS(sampleLength);
|
||||||
@@ -172,10 +152,10 @@ void Mod::File::read(bool)
|
|||||||
READ_BYTE_AS(fineTuneByte);
|
READ_BYTE_AS(fineTuneByte);
|
||||||
int fineTune = fineTuneByte & 0xF;
|
int fineTune = fineTuneByte & 0xF;
|
||||||
// > 7 means negative value
|
// > 7 means negative value
|
||||||
if(fineTune > 7) fineTune -= 16;
|
if (fineTune > 7) fineTune -= 16;
|
||||||
|
|
||||||
READ_BYTE_AS(volume);
|
READ_BYTE_AS(volume);
|
||||||
if(volume > 64) volume = 64;
|
if (volume > 64) volume = 64;
|
||||||
// volume in decibels: 20 * log10(volume / 64)
|
// volume in decibels: 20 * log10(volume / 64)
|
||||||
|
|
||||||
// value in words, * 2 (<< 1) for bytes:
|
// value in words, * 2 (<< 1) for bytes:
|
||||||
@@ -189,4 +169,5 @@ void Mod::File::read(bool)
|
|||||||
READ_BYTE(d->properties.setLengthInPatterns);
|
READ_BYTE(d->properties.setLengthInPatterns);
|
||||||
|
|
||||||
d->tag.setComment(comment.toString("\n"));
|
d->tag.setComment(comment.toString("\n"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
55
3rdparty/taglib/mod/modfile.h
vendored
55
3rdparty/taglib/mod/modfile.h
vendored
@@ -33,61 +33,42 @@
|
|||||||
#include "modtag.h"
|
#include "modtag.h"
|
||||||
#include "modproperties.h"
|
#include "modproperties.h"
|
||||||
|
|
||||||
|
namespace Strawberry_TagLib {
|
||||||
namespace TagLib {
|
namespace TagLib {
|
||||||
|
namespace Mod {
|
||||||
|
|
||||||
namespace Mod {
|
class TAGLIB_EXPORT File : public Strawberry_TagLib::TagLib::Mod::FileBase {
|
||||||
|
|
||||||
class TAGLIB_EXPORT File : public TagLib::Mod::FileBase
|
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
/*!
|
/*!
|
||||||
* Constructs a Protracker file from \a file.
|
* Constructs a Protracker file from \a file.
|
||||||
*
|
*
|
||||||
* \note In the current implementation, both \a readProperties and
|
* \note In the current implementation, both \a readProperties and \a propertiesStyle are ignored.
|
||||||
* \a propertiesStyle are ignored. The audio properties are always
|
* The audio properties are always read.
|
||||||
* read.
|
|
||||||
*/
|
*/
|
||||||
File(FileName file, bool readProperties = true,
|
explicit File(FileName file, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average);
|
||||||
AudioProperties::ReadStyle propertiesStyle =
|
|
||||||
AudioProperties::Average);
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Constructs a Protracker file from \a stream.
|
* Constructs a Protracker file from \a stream.
|
||||||
*
|
*
|
||||||
* \note In the current implementation, both \a readProperties and
|
* \note In the current implementation, both \a readProperties and \a propertiesStyle are ignored.
|
||||||
* \a propertiesStyle are ignored. The audio properties are always
|
* The audio properties are always read.
|
||||||
* read.
|
|
||||||
*
|
*
|
||||||
* \note TagLib will *not* take ownership of the stream, the caller is
|
* \note TagLib will *not* take ownership of the stream, the caller is
|
||||||
* responsible for deleting it after the File object.
|
* responsible for deleting it after the File object.
|
||||||
*/
|
*/
|
||||||
File(IOStream *stream, bool readProperties = true,
|
explicit File(IOStream *stream, bool readProperties = true, AudioProperties::ReadStyle propertiesStyle = AudioProperties::Average);
|
||||||
AudioProperties::ReadStyle propertiesStyle =
|
|
||||||
AudioProperties::Average);
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Destroys this instance of the File.
|
* Destroys this instance of the File.
|
||||||
*/
|
*/
|
||||||
virtual ~File();
|
~File() override;
|
||||||
|
|
||||||
Mod::Tag *tag() const;
|
Mod::Tag *tag() const override;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Implements the unified property interface -- export function.
|
* Returns the Mod::AudioProperties for this file. If no audio properties were read then this will return a null pointer.
|
||||||
* Forwards to Mod::Tag::properties().
|
|
||||||
*/
|
*/
|
||||||
PropertyMap properties() const;
|
Mod::AudioProperties *audioProperties() const override;
|
||||||
|
|
||||||
/*!
|
|
||||||
* Implements the unified property interface -- import function.
|
|
||||||
* Forwards to Mod::Tag::setProperties().
|
|
||||||
*/
|
|
||||||
PropertyMap setProperties(const PropertyMap &);
|
|
||||||
/*!
|
|
||||||
* Returns the Mod::Properties for this file. If no audio properties
|
|
||||||
* were read then this will return a null pointer.
|
|
||||||
*/
|
|
||||||
Mod::Properties *audioProperties() const;
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Save the file.
|
* Save the file.
|
||||||
@@ -95,7 +76,7 @@ namespace TagLib {
|
|||||||
*
|
*
|
||||||
* \note Saving Protracker tags is not supported.
|
* \note Saving Protracker tags is not supported.
|
||||||
*/
|
*/
|
||||||
bool save();
|
bool save() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
File(const File &);
|
File(const File &);
|
||||||
@@ -105,10 +86,10 @@ namespace TagLib {
|
|||||||
|
|
||||||
class FilePrivate;
|
class FilePrivate;
|
||||||
FilePrivate *d;
|
FilePrivate *d;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace Mod
|
||||||
|
} // namespace TagLib
|
||||||
}
|
} // namespace Strawberry_TagLib
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
93
3rdparty/taglib/mod/modfilebase.cpp
vendored
93
3rdparty/taglib/mod/modfilebase.cpp
vendored
@@ -27,99 +27,96 @@
|
|||||||
#include "tdebug.h"
|
#include "tdebug.h"
|
||||||
#include "modfilebase.h"
|
#include "modfilebase.h"
|
||||||
|
|
||||||
using namespace TagLib;
|
using namespace Strawberry_TagLib::TagLib;
|
||||||
using namespace Mod;
|
using namespace Mod;
|
||||||
|
|
||||||
Mod::FileBase::FileBase(FileName file) : TagLib::File(file)
|
Mod::FileBase::FileBase(FileName file) : Strawberry_TagLib::TagLib::File(file) {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Mod::FileBase::FileBase(IOStream *stream) : TagLib::File(stream)
|
Mod::FileBase::FileBase(IOStream *stream) : Strawberry_TagLib::TagLib::File(stream) {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void Mod::FileBase::writeString(const String &s, unsigned long size, char padding)
|
void Mod::FileBase::writeString(const String &s, unsigned int size, char padding) {
|
||||||
{
|
|
||||||
ByteVector data(s.data(String::Latin1));
|
ByteVector data(s.data(String::Latin1));
|
||||||
data.resize(size, padding);
|
data.resize(size, padding);
|
||||||
writeBlock(data);
|
writeBlock(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Mod::FileBase::readString(String &s, unsigned long size)
|
bool Mod::FileBase::readString(String &s, unsigned int size) {
|
||||||
{
|
|
||||||
ByteVector data(readBlock(size));
|
ByteVector data(readBlock(size));
|
||||||
if(data.size() < size) return false;
|
if (data.size() < size) return false;
|
||||||
int index = data.find((char) 0);
|
const size_t index = data.find(static_cast<char>(0));
|
||||||
if(index > -1)
|
if (index != ByteVector::npos()) {
|
||||||
{
|
|
||||||
data.resize(index);
|
data.resize(index);
|
||||||
}
|
}
|
||||||
data.replace('\xff', ' ');
|
data.replace('\xff', ' ');
|
||||||
|
|
||||||
s = data;
|
s = data;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Mod::FileBase::writeByte(unsigned char byte)
|
void Mod::FileBase::writeByte(unsigned char _byte) {
|
||||||
{
|
ByteVector data(1, _byte);
|
||||||
ByteVector data(1, byte);
|
|
||||||
writeBlock(data);
|
writeBlock(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Mod::FileBase::writeU16L(unsigned short number)
|
void Mod::FileBase::writeU16L(unsigned short number) {
|
||||||
{
|
writeBlock(ByteVector::fromUInt16LE(number));
|
||||||
writeBlock(ByteVector::fromShort(number, false));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Mod::FileBase::writeU32L(unsigned long number)
|
void Mod::FileBase::writeU32L(unsigned int number) {
|
||||||
{
|
writeBlock(ByteVector::fromUInt32LE(number));
|
||||||
writeBlock(ByteVector::fromUInt(number, false));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Mod::FileBase::writeU16B(unsigned short number)
|
void Mod::FileBase::writeU16B(unsigned short number) {
|
||||||
{
|
writeBlock(ByteVector::fromUInt16BE(number));
|
||||||
writeBlock(ByteVector::fromShort(number, true));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Mod::FileBase::writeU32B(unsigned long number)
|
void Mod::FileBase::writeU32B(unsigned int number) {
|
||||||
{
|
writeBlock(ByteVector::fromUInt32BE(number));
|
||||||
writeBlock(ByteVector::fromUInt(number, true));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Mod::FileBase::readByte(unsigned char &byte)
|
bool Mod::FileBase::readByte(unsigned char &_byte) {
|
||||||
{
|
|
||||||
ByteVector data(readBlock(1));
|
ByteVector data(readBlock(1));
|
||||||
if(data.size() < 1) return false;
|
if (data.size() < 1) return false;
|
||||||
byte = data[0];
|
_byte = data[0];
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Mod::FileBase::readU16L(unsigned short &number)
|
bool Mod::FileBase::readU16L(unsigned short &number) {
|
||||||
{
|
|
||||||
ByteVector data(readBlock(2));
|
ByteVector data(readBlock(2));
|
||||||
if(data.size() < 2) return false;
|
if (data.size() < 2) return false;
|
||||||
number = data.toUShort(false);
|
number = data.toUInt16LE(0);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Mod::FileBase::readU32L(unsigned long &number) {
|
bool Mod::FileBase::readU32L(unsigned int &number) {
|
||||||
|
|
||||||
ByteVector data(readBlock(4));
|
ByteVector data(readBlock(4));
|
||||||
if(data.size() < 4) return false;
|
if (data.size() < 4) return false;
|
||||||
number = data.toUInt(false);
|
number = data.toUInt32LE(0);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Mod::FileBase::readU16B(unsigned short &number)
|
bool Mod::FileBase::readU16B(unsigned short &number) {
|
||||||
{
|
|
||||||
ByteVector data(readBlock(2));
|
ByteVector data(readBlock(2));
|
||||||
if(data.size() < 2) return false;
|
if (data.size() < 2) return false;
|
||||||
number = data.toUShort(true);
|
number = data.toUInt16BE(0);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Mod::FileBase::readU32B(unsigned long &number) {
|
bool Mod::FileBase::readU32B(unsigned int &number) {
|
||||||
|
|
||||||
ByteVector data(readBlock(4));
|
ByteVector data(readBlock(4));
|
||||||
if(data.size() < 4) return false;
|
if (data.size() < 4) return false;
|
||||||
number = data.toUInt(true);
|
number = data.toUInt32BE(0);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
33
3rdparty/taglib/mod/modfilebase.h
vendored
33
3rdparty/taglib/mod/modfilebase.h
vendored
@@ -34,33 +34,32 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
namespace Strawberry_TagLib {
|
||||||
namespace TagLib {
|
namespace TagLib {
|
||||||
|
namespace Mod {
|
||||||
|
|
||||||
namespace Mod {
|
class TAGLIB_EXPORT FileBase : public Strawberry_TagLib::TagLib::File {
|
||||||
|
|
||||||
class TAGLIB_EXPORT FileBase : public TagLib::File
|
|
||||||
{
|
|
||||||
protected:
|
protected:
|
||||||
FileBase(FileName file);
|
explicit FileBase(FileName file);
|
||||||
FileBase(IOStream *stream);
|
explicit FileBase(IOStream *stream);
|
||||||
|
|
||||||
void writeString(const String &s, unsigned long size, char padding = 0);
|
void writeString(const String &s, unsigned int size, char padding = 0);
|
||||||
void writeByte(unsigned char byte);
|
void writeByte(unsigned char byte);
|
||||||
void writeU16L(unsigned short number);
|
void writeU16L(unsigned short number);
|
||||||
void writeU32L(unsigned long number);
|
void writeU32L(unsigned int number);
|
||||||
void writeU16B(unsigned short number);
|
void writeU16B(unsigned short number);
|
||||||
void writeU32B(unsigned long number);
|
void writeU32B(unsigned int number);
|
||||||
|
|
||||||
bool readString(String &s, unsigned long size);
|
bool readString(String &s, unsigned int size);
|
||||||
bool readByte(unsigned char &byte);
|
bool readByte(unsigned char &_byte);
|
||||||
bool readU16L(unsigned short &number);
|
bool readU16L(unsigned short &number);
|
||||||
bool readU32L(unsigned long &number);
|
bool readU32L(unsigned int &number);
|
||||||
bool readU16B(unsigned short &number);
|
bool readU16B(unsigned short &number);
|
||||||
bool readU32B(unsigned long &number);
|
bool readU32B(unsigned int &number);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace Mod
|
||||||
|
} // namespace TagLib
|
||||||
}
|
} // namespace Strawberry_TagLib
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
31
3rdparty/taglib/mod/modfileprivate.h
vendored
31
3rdparty/taglib/mod/modfileprivate.h
vendored
@@ -24,43 +24,42 @@
|
|||||||
|
|
||||||
// some helper-macros only used internally by (s3m|it|xm)file.cpp
|
// some helper-macros only used internally by (s3m|it|xm)file.cpp
|
||||||
#define READ_ASSERT(cond) \
|
#define READ_ASSERT(cond) \
|
||||||
if(!(cond)) \
|
if (!(cond)) { \
|
||||||
{ \
|
|
||||||
setValid(false); \
|
setValid(false); \
|
||||||
return; \
|
return; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define READ(setter,type,read) \
|
#define READ(setter, type, read) \
|
||||||
{ \
|
{ \
|
||||||
type number; \
|
type number; \
|
||||||
READ_ASSERT(read(number)); \
|
READ_ASSERT(read(number)); \
|
||||||
setter(number); \
|
setter(number); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define READ_BYTE(setter) READ(setter,unsigned char,readByte)
|
#define READ_BYTE(setter) READ(setter, unsigned char, readByte)
|
||||||
#define READ_U16L(setter) READ(setter,unsigned short,readU16L)
|
#define READ_U16L(setter) READ(setter, unsigned short, readU16L)
|
||||||
#define READ_U32L(setter) READ(setter,unsigned long,readU32L)
|
#define READ_U32L(setter) READ(setter, unsigned int, readU32L)
|
||||||
#define READ_U16B(setter) READ(setter,unsigned short,readU16B)
|
#define READ_U16B(setter) READ(setter, unsigned short, readU16B)
|
||||||
#define READ_U32B(setter) READ(setter,unsigned long,readU32B)
|
#define READ_U32B(setter) READ(setter, unsigned int, readU32B)
|
||||||
|
|
||||||
#define READ_STRING(setter,size) \
|
#define READ_STRING(setter, size) \
|
||||||
{ \
|
{ \
|
||||||
String s; \
|
String s; \
|
||||||
READ_ASSERT(readString(s, size)); \
|
READ_ASSERT(readString(s, size)); \
|
||||||
setter(s); \
|
setter(s); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define READ_AS(type,name,read) \
|
#define READ_AS(type, name, read) \
|
||||||
type name = 0; \
|
type name = 0; \
|
||||||
READ_ASSERT(read(name));
|
READ_ASSERT(read(name));
|
||||||
|
|
||||||
#define READ_BYTE_AS(name) READ_AS(unsigned char,name,readByte)
|
#define READ_BYTE_AS(name) READ_AS(unsigned char, name, readByte)
|
||||||
#define READ_U16L_AS(name) READ_AS(unsigned short,name,readU16L)
|
#define READ_U16L_AS(name) READ_AS(unsigned short, name, readU16L)
|
||||||
#define READ_U32L_AS(name) READ_AS(unsigned long,name,readU32L)
|
#define READ_U32L_AS(name) READ_AS(unsigned int, name, readU32L)
|
||||||
#define READ_U16B_AS(name) READ_AS(unsigned short,name,readU16B)
|
#define READ_U16B_AS(name) READ_AS(unsigned short, name, readU16B)
|
||||||
#define READ_U32B_AS(name) READ_AS(unsigned long,name,readU32B)
|
#define READ_U32B_AS(name) READ_AS(unsigned int, name, readU32B)
|
||||||
|
|
||||||
#define READ_STRING_AS(name,size) \
|
#define READ_STRING_AS(name, size) \
|
||||||
String name; \
|
String name; \
|
||||||
READ_ASSERT(readString(name, size));
|
READ_ASSERT(readString(name, size));
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user