diff --git a/Cargo.lock b/Cargo.lock index e58bd980e..e3abca7d6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -48,26 +48,6 @@ dependencies = [ "pkg-config", ] -[[package]] -name = "andrew" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b7f09f89872c2b6b29e319377b1fbe91c6f5947df19a25596e121cf19a7b35e" -dependencies = [ - "bitflags", - "line_drawing", - "rusttype 0.7.9", - "walkdir", - "xdg", - "xml-rs", -] - -[[package]] -name = "android_glue" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "000444226fcff248f2bc4c7625be32c63caccfecc2723a2b9f78a7487a49c407" - [[package]] name = "android_log-sys" version = "0.2.0" @@ -101,23 +81,14 @@ version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28b2cd92db5cbd74e8e5028f7e27dd7aa3090e89e4f2a197cc7c8dfb69c7063b" -[[package]] -name = "approx" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0e60b75072ecd4168020818c0107f2857bb6c4e64252d8d3983f6263b40a5c3" -dependencies = [ - "num-traits 0.2.14", -] - [[package]] name = "async-trait" version = "0.1.50" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b98e84bbb4cbcdd97da190ba0c58a1bb0de2c1fdf67d159e192ed766aeca722" dependencies = [ - "proc-macro2 1.0.26", - "quote 1.0.9", + "proc-macro2", + "quote", "syn", ] @@ -207,8 +178,8 @@ dependencies = [ "lazycell", "log", "peeking_take_while", - "proc-macro2 1.0.26", - "quote 1.0.9", + "proc-macro2", + "quote", "regex", "rustc-hash", "shlex", @@ -231,8 +202,8 @@ dependencies = [ "lazycell", "log", "peeking_take_while", - "proc-macro2 1.0.26", - "quote 1.0.9", + "proc-macro2", + "quote", "regex", "rustc-hash", "shlex", @@ -404,21 +375,6 @@ dependencies = [ "bitflags", ] -[[package]] -name = "cocoa" -version = "0.18.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1706996401131526e36b3b49f0c4d912639ce110996f3ca144d78946727bce54" -dependencies = [ - "bitflags", - "block", - "core-foundation 0.6.4", - "core-graphics 0.17.3", - "foreign-types", - "libc", - "objc", -] - [[package]] name = "cocoa" version = "0.24.0" @@ -429,7 +385,7 @@ dependencies = [ "block", "cocoa-foundation", "core-foundation 0.9.1", - "core-graphics 0.22.2", + "core-graphics", "foreign-types", "libc", "objc", @@ -463,11 +419,10 @@ dependencies = [ [[package]] name = "confy" version = "0.4.1" +source = "git+https://github.com/open-trade/confy#27fa12941291b44ccd856aef4a5452c1eb646047" dependencies = [ "directories", "serde 1.0.125", - "serde_derive", - "serde_yaml", "toml", ] @@ -485,16 +440,6 @@ dependencies = [ "x11-clipboard", ] -[[package]] -name = "core-foundation" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25b9e03f145fd4f2bf705e07b900cd41fc636598fe5dc452fd0db1441c3f496d" -dependencies = [ - "core-foundation-sys 0.6.2", - "libc", -] - [[package]] name = "core-foundation" version = "0.7.0" @@ -533,18 +478,6 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea221b5284a47e40033bf9b66f35f984ec0ea2931eb03505246cd27a963f981b" -[[package]] -name = "core-graphics" -version = "0.17.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56790968ab1c8a1202a102e6de05fc6e1ec87da99e4e93e9a7d13efbfc1e95a9" -dependencies = [ - "bitflags", - "core-foundation 0.6.4", - "foreign-types", - "libc", -] - [[package]] name = "core-graphics" version = "0.22.2" @@ -606,7 +539,7 @@ dependencies = [ "ndk-glue", "nix 0.20.0", "oboe", - "parking_lot 0.11.1", + "parking_lot", "stdweb", "thiserror", "web-sys", @@ -665,8 +598,8 @@ checksum = "f0c960ae2da4de88a91b2d920c2a7233b400bc33cb28453a2987822d8392519b" dependencies = [ "fnv", "ident_case", - "proc-macro2 1.0.26", - "quote 1.0.9", + "proc-macro2", + "quote", "strsim 0.9.3", "syn", ] @@ -678,7 +611,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9b5a2f4ac4969822c62224815d069952656cadc7084fdca9751e6d959189b72" dependencies = [ "darling_core", - "quote 1.0.9", + "quote", "syn", ] @@ -821,14 +754,25 @@ dependencies = [ "dasp_sample", ] +[[package]] +name = "dbus" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8862bb50aa3b2a2db5bfd2c875c73b3038aa931c411087e335ca8ca0ed430b9" +dependencies = [ + "libc", + "libdbus-sys", + "winapi 0.3.9", +] + [[package]] name = "derivative" version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" dependencies = [ - "proc-macro2 1.0.26", - "quote 1.0.9", + "proc-macro2", + "quote", "syn", ] @@ -838,8 +782,8 @@ version = "0.99.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f82b1b72f1263f214c0f823371768776c4f5841b942c9883aa8e5ec584fd0ba6" dependencies = [ - "proc-macro2 1.0.26", - "quote 1.0.9", + "proc-macro2", + "quote", "syn", ] @@ -962,7 +906,7 @@ checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" name = "enigo" version = "0.0.14" dependencies = [ - "core-graphics 0.22.2", + "core-graphics", "libc", "log", "objc", @@ -1006,8 +950,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22deed3a8124cff5fa835713fa105621e43bbdc46690c3a6b68328a012d350d4" dependencies = [ "proc-macro-error", - "proc-macro2 1.0.26", - "quote 1.0.9", + "proc-macro2", + "quote", "rustversion", "syn", "synstructure", @@ -1020,8 +964,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dcc7f65832b62ed38939f98966824eb6294911c3629b0e9a262bfb80836d9686" dependencies = [ "proc-macro-error", - "proc-macro2 1.0.26", - "quote 1.0.9", + "proc-macro2", + "quote", "rustversion", "syn", "synstructure", @@ -1044,7 +988,7 @@ checksum = "1d34cfa13a63ae058bfa601fe9e313bbdb3746427c1459185464ce0fcf62e1e8" dependencies = [ "cfg-if 1.0.0", "libc", - "redox_syscall 0.2.7", + "redox_syscall", "winapi 0.3.9", ] @@ -1174,8 +1118,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "668c6733a182cd7deb4f1de7ba3bf2120823835b3bcfbeacf7d2c4a773c1bb8b" dependencies = [ "proc-macro-hack", - "proc-macro2 1.0.26", - "quote 1.0.9", + "proc-macro2", + "quote", "syn", ] @@ -1378,8 +1322,8 @@ dependencies = [ "itertools", "proc-macro-crate", "proc-macro-error", - "proc-macro2 1.0.26", - "quote 1.0.9", + "proc-macro2", + "quote", "syn", ] @@ -1410,6 +1354,139 @@ dependencies = [ "system-deps", ] +[[package]] +name = "gstreamer" +version = "0.16.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ff5d0f7ff308ae37e6eb47b6ded17785bdea06e438a708cd09e0288c1862f33" +dependencies = [ + "bitflags", + "cfg-if 1.0.0", + "futures-channel", + "futures-core", + "futures-util", + "glib", + "glib-sys", + "gobject-sys", + "gstreamer-sys", + "libc", + "muldiv", + "num-rational", + "once_cell", + "paste", + "pretty-hex", + "thiserror", +] + +[[package]] +name = "gstreamer-app" +version = "0.16.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc80888271338c3ede875d8cafc452eb207476ff5539dcbe0018a8f5b827af0e" +dependencies = [ + "bitflags", + "futures-core", + "futures-sink", + "glib", + "glib-sys", + "gobject-sys", + "gstreamer", + "gstreamer-app-sys", + "gstreamer-base", + "gstreamer-sys", + "libc", + "once_cell", +] + +[[package]] +name = "gstreamer-app-sys" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "813f64275c9e7b33b828b9efcf9dfa64b95996766d4de996e84363ac65b87e3d" +dependencies = [ + "glib-sys", + "gstreamer-base-sys", + "gstreamer-sys", + "libc", + "system-deps", +] + +[[package]] +name = "gstreamer-base" +version = "0.16.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bafd01c56f59cb10f4b5a10f97bb4bdf8c2b2784ae5b04da7e2d400cf6e6afcf" +dependencies = [ + "bitflags", + "glib", + "glib-sys", + "gobject-sys", + "gstreamer", + "gstreamer-base-sys", + "gstreamer-sys", + "libc", +] + +[[package]] +name = "gstreamer-base-sys" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4b7b6dc2d6e160a1ae28612f602bd500b3fa474ce90bf6bb2f08072682beef5" +dependencies = [ + "glib-sys", + "gobject-sys", + "gstreamer-sys", + "libc", + "system-deps", +] + +[[package]] +name = "gstreamer-sys" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc1f154082d01af5718c5f8a8eb4f565a4ea5586ad8833a8fc2c2aa6844b601d" +dependencies = [ + "glib-sys", + "gobject-sys", + "libc", + "system-deps", +] + +[[package]] +name = "gstreamer-video" +version = "0.16.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7bbb1485d87469849ec45c08e03c2f280d3ea20ff3c439d03185be54e3ce98e" +dependencies = [ + "bitflags", + "futures-channel", + "futures-util", + "glib", + "glib-sys", + "gobject-sys", + "gstreamer", + "gstreamer-base", + "gstreamer-base-sys", + "gstreamer-sys", + "gstreamer-video-sys", + "libc", + "once_cell", +] + +[[package]] +name = "gstreamer-video-sys" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92347e46438007d6a2386302125f62cb9df6769cdacb931af5c0f12c1ee21de4" +dependencies = [ + "glib-sys", + "gobject-sys", + "gstreamer-base-sys", + "gstreamer-sys", + "libc", + "system-deps", +] + [[package]] name = "gtk" version = "0.9.2" @@ -1668,6 +1745,15 @@ version = "0.2.94" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "18794a8ad5b29321f790b55d93dfba91e125cb1a9edbd4f8e3150acc771c1a5e" +[[package]] +name = "libdbus-sys" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc12a3bc971424edbbf7edaf6e5740483444db63aa8e23d3751ff12a30f306f0" +dependencies = [ + "pkg-config", +] + [[package]] name = "libloading" version = "0.5.2" @@ -1757,30 +1843,6 @@ dependencies = [ "pkg-config", ] -[[package]] -name = "line_drawing" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cc7ad3d82c845bdb5dde34ffdcc7a5fb4d2996e1e1ee0f19c33bc80e15196b9" -dependencies = [ - "num-traits 0.2.14", -] - -[[package]] -name = "linked-hash-map" -version = "0.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3" - -[[package]] -name = "lock_api" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4da24a77a3d8a6d4862d95f72e6fdb9c09a643ecdb402d754004a557f2bec75" -dependencies = [ - "scopeguard", -] - [[package]] name = "lock_api" version = "0.4.4" @@ -1829,7 +1891,8 @@ dependencies = [ [[package]] name = "magnum-opus" -version = "0.3.4" +version = "0.3.4-1" +source = "git+https://github.com/open-trade/magnum-opus#86b58e5c6000dc15dddebc17329dd50332d99e8d" dependencies = [ "bindgen 0.53.1", "target_build_utils", @@ -1844,28 +1907,12 @@ dependencies = [ "libc", ] -[[package]] -name = "maybe-uninit" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" - [[package]] name = "memchr" version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b16bd47d9e329435e309c58469fe0791c2d0d1ba96ec0954152a5ae2b04387dc" -[[package]] -name = "memmap" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6585fd95e7bb50d6cc31e20d4cf9afb4e2ba16c5846fc76793f11218da9c475b" -dependencies = [ - "libc", - "winapi 0.3.9", -] - [[package]] name = "memmap2" version = "0.1.0" @@ -1950,6 +1997,12 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "muldiv" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0419348c027fa7be448d2ae7ea0e4e04c2334c31dc4e74ab29f00a2a7ca69204" + [[package]] name = "ndk" version = "0.3.0" @@ -1984,8 +2037,8 @@ checksum = "05d1c6307dc424d0f65b9b06e94f88248e6305726b14729fd67a5e47b2dc481d" dependencies = [ "darling", "proc-macro-crate", - "proc-macro2 1.0.26", - "quote 1.0.9", + "proc-macro2", + "quote", "syn", ] @@ -2006,19 +2059,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "nix" -version = "0.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c722bee1037d430d0f8e687bbdbf222f27cc6e4e68d5caf630857bb2b6dbdce" -dependencies = [ - "bitflags", - "cc", - "cfg-if 0.1.10", - "libc", - "void", -] - [[package]] name = "nix" version = "0.17.0" @@ -2103,8 +2143,8 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d" dependencies = [ - "proc-macro2 1.0.26", - "quote 1.0.9", + "proc-macro2", + "quote", "syn", ] @@ -2118,6 +2158,17 @@ dependencies = [ "num-traits 0.2.14", ] +[[package]] +name = "num-rational" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12ac428b1cb17fce6f731001d307d351ec70a6d202fc2e60f7d4c5e42d8f4f07" +dependencies = [ + "autocfg 1.0.1", + "num-integer", + "num-traits 0.2.14", +] + [[package]] name = "num-traits" version = "0.1.43" @@ -2163,8 +2214,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c0fd9eba1d5db0994a239e09c1be402d35622277e35468ba891aa5e3188ce7e" dependencies = [ "proc-macro-crate", - "proc-macro2 1.0.26", - "quote 1.0.9", + "proc-macro2", + "quote", "syn", ] @@ -2244,15 +2295,6 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" -[[package]] -name = "ordered-float" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3305af35278dd29f46fcdd139e0b1fbfae2153f0e5928b39b035542dd31e37b7" -dependencies = [ - "num-traits 0.2.14", -] - [[package]] name = "pango" version = "0.9.1" @@ -2283,6 +2325,7 @@ dependencies = [ [[package]] name = "parity-tokio-ipc" version = "0.7.2" +source = "git+https://github.com/open-trade/parity-tokio-ipc#0c21a9bc85c9951a66c92e5aa263d14a09974dd2" dependencies = [ "futures", "libc", @@ -2294,17 +2337,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "parking_lot" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252" -dependencies = [ - "lock_api 0.3.4", - "parking_lot_core 0.6.2", - "rustc_version", -] - [[package]] name = "parking_lot" version = "0.11.1" @@ -2312,23 +2344,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb" dependencies = [ "instant", - "lock_api 0.4.4", - "parking_lot_core 0.8.3", -] - -[[package]] -name = "parking_lot_core" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b876b1b9e7ac6e1a74a6da34d25c42e17e8862aa409cbbbdcfc8d86c6f3bc62b" -dependencies = [ - "cfg-if 0.1.10", - "cloudabi", - "libc", - "redox_syscall 0.1.57", - "rustc_version", - "smallvec 0.6.14", - "winapi 0.3.9", + "lock_api", + "parking_lot_core", ] [[package]] @@ -2340,23 +2357,23 @@ dependencies = [ "cfg-if 1.0.0", "instant", "libc", - "redox_syscall 0.2.7", - "smallvec 1.6.1", + "redox_syscall", + "smallvec", "winapi 0.3.9", ] +[[package]] +name = "paste" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf547ad0c65e31259204bd90935776d1c693cec2f4ff7abb7a1bbbd40dfe58" + [[package]] name = "peeking_take_while" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" -[[package]] -name = "percent-encoding" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" - [[package]] name = "phf" version = "0.7.24" @@ -2431,6 +2448,12 @@ version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" +[[package]] +name = "pretty-hex" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc5c99d529f0d30937f6f4b8a86d988047327bb88d04d2c4afc356de74722131" + [[package]] name = "proc-macro-crate" version = "0.1.5" @@ -2447,8 +2470,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" dependencies = [ "proc-macro-error-attr", - "proc-macro2 1.0.26", - "quote 1.0.9", + "proc-macro2", + "quote", "syn", "version_check 0.9.3", ] @@ -2459,8 +2482,8 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" dependencies = [ - "proc-macro2 1.0.26", - "quote 1.0.9", + "proc-macro2", + "quote", "version_check 0.9.3", ] @@ -2476,22 +2499,13 @@ version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086" -[[package]] -name = "proc-macro2" -version = "0.4.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" -dependencies = [ - "unicode-xid 0.1.0", -] - [[package]] name = "proc-macro2" version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a152013215dca273577e18d2bf00fa862b89b24169fb78c4c95aeb07992c9cec" dependencies = [ - "unicode-xid 0.2.2", + "unicode-xid", ] [[package]] @@ -2591,22 +2605,13 @@ dependencies = [ "webpki", ] -[[package]] -name = "quote" -version = "0.6.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" -dependencies = [ - "proc-macro2 0.4.30", -] - [[package]] name = "quote" version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" dependencies = [ - "proc-macro2 1.0.26", + "proc-macro2", ] [[package]] @@ -2796,15 +2801,6 @@ dependencies = [ "rand_core 0.3.1", ] -[[package]] -name = "raw-window-handle" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a441a7a6c80ad6473bd4b74ec1c9a4c951794285bf941c2126f607c72e48211" -dependencies = [ - "libc", -] - [[package]] name = "rdrand" version = "0.4.0" @@ -2814,12 +2810,6 @@ dependencies = [ "rand_core 0.3.1", ] -[[package]] -name = "redox_syscall" -version = "0.1.57" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" - [[package]] name = "redox_syscall" version = "0.2.7" @@ -2836,7 +2826,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64" dependencies = [ "getrandom 0.2.2", - "redox_syscall 0.2.7", + "redox_syscall", ] [[package]] @@ -2924,6 +2914,7 @@ dependencies = [ [[package]] name = "rust-pulsectl" version = "0.2.10" +source = "git+https://github.com/open-trade/pulsectl#53beb1d5b45f8bff725f32cf2f786d7e091f83b5" dependencies = [ "libpulse-binding", ] @@ -2940,28 +2931,19 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" -[[package]] -name = "rustc_version" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -dependencies = [ - "semver", -] - [[package]] name = "rustdesk" -version = "1.1.2" +version = "1.1.6" dependencies = [ "android_logger", "async-trait", "cc", "cfg-if 1.0.0", "clap", - "cocoa 0.24.0", + "cocoa", "copypasta", "core-foundation 0.9.1", - "core-graphics 0.22.2", + "core-graphics", "cpal", "crc32fast", "ctrlc", @@ -3025,26 +3007,6 @@ dependencies = [ "security-framework", ] -[[package]] -name = "rusttype" -version = "0.7.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "310942406a39981bed7e12b09182a221a29e0990f3e7e0c971f131922ed135d5" -dependencies = [ - "rusttype 0.8.3", -] - -[[package]] -name = "rusttype" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f61411055101f7b60ecf1041d87fb74205fb20b0c7a723f07ef39174cf6b4c0" -dependencies = [ - "approx", - "ordered-float", - "stb_truetype", -] - [[package]] name = "rustversion" version = "1.0.4" @@ -3078,15 +3040,13 @@ dependencies = [ [[package]] name = "sciter-rs" -version = "0.5.53" +version = "0.5.57" +source = "git+https://github.com/sciter-sdk/rust-sciter#1b610fcb7414b3257f6723821e2d9c0cc5aed6ed" dependencies = [ "lazy_static", "libc", "objc", "objc-foundation", - "raw-window-handle", - "winapi 0.3.9", - "winit", ] [[package]] @@ -3108,13 +3068,18 @@ dependencies = [ "bindgen 0.53.1", "block", "cfg-if 1.0.0", + "dbus", "docopt", + "gstreamer", + "gstreamer-app", + "gstreamer-video", "libc", "num_cpus", "quest", "repng", "serde 1.0.125", "target_build_utils", + "tracing", "webm", "winapi 0.3.9", ] @@ -3152,21 +3117,6 @@ dependencies = [ "libc", ] -[[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -dependencies = [ - "semver-parser", -] - -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" - [[package]] name = "serde" version = "0.9.15" @@ -3188,8 +3138,8 @@ version = "1.0.125" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b093b7a2bb58203b5da3056c05b4ec1fed827dcfdb37347a8841695263b3d06d" dependencies = [ - "proc-macro2 1.0.26", - "quote 1.0.9", + "proc-macro2", + "quote", "syn", ] @@ -3216,18 +3166,6 @@ dependencies = [ "serde 1.0.125", ] -[[package]] -name = "serde_yaml" -version = "0.8.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15654ed4ab61726bf918a39cb8d98a2e2995b002387807fa6ba58fdf7f59bb23" -dependencies = [ - "dtoa", - "linked-hash-map", - "serde 1.0.125", - "yaml-rust", -] - [[package]] name = "sha2" version = "0.9.3" @@ -3268,38 +3206,12 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f173ac3d1a7e3b28003f40de0b5ce7fe2710f9b9dc3fc38664cebee46b3b6527" -[[package]] -name = "smallvec" -version = "0.6.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97fcaeba89edba30f044a10c6a3cc39df9c3f17d7cd829dd1446cab35f890e0" -dependencies = [ - "maybe-uninit", -] - [[package]] name = "smallvec" version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" -[[package]] -name = "smithay-client-toolkit" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ccb8c57049b2a34d2cc2b203fa785020ba0129d31920ef0d317430adaf748fa" -dependencies = [ - "andrew", - "bitflags", - "dlib 0.4.2", - "lazy_static", - "memmap", - "nix 0.14.1", - "wayland-client 0.21.13", - "wayland-commons 0.21.13", - "wayland-protocols 0.21.13", -] - [[package]] name = "smithay-client-toolkit" version = "0.12.3" @@ -3312,9 +3224,9 @@ dependencies = [ "log", "memmap2", "nix 0.18.0", - "wayland-client 0.28.5", + "wayland-client", "wayland-cursor", - "wayland-protocols 0.28.5", + "wayland-protocols", ] [[package]] @@ -3323,8 +3235,8 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06384dfaf645908220d976ae24ed39f6cf92efecb0225ea0a948e403014de527" dependencies = [ - "smithay-client-toolkit 0.12.3", - "wayland-client 0.28.5", + "smithay-client-toolkit", + "wayland-client", ] [[package]] @@ -3355,15 +3267,6 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" -[[package]] -name = "stb_truetype" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f77b6b07e862c66a9f3e62a07588fee67cd90a9135a2b942409f195507b4fb51" -dependencies = [ - "byteorder", -] - [[package]] name = "stdweb" version = "0.1.3" @@ -3401,8 +3304,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "87c85aa3f8ea653bfd3ddf25f7ee357ee4d204731f6aa9ad04002306f6e2774c" dependencies = [ "heck", - "proc-macro2 1.0.26", - "quote 1.0.9", + "proc-macro2", + "quote", "syn", ] @@ -3412,9 +3315,9 @@ version = "1.0.71" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ad184cc9470f9117b2ac6817bfe297307418819ba40552f9b3846f05c33d5373" dependencies = [ - "proc-macro2 1.0.26", - "quote 1.0.9", - "unicode-xid 0.2.2", + "proc-macro2", + "quote", + "unicode-xid", ] [[package]] @@ -3423,10 +3326,10 @@ version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b834f2d66f734cb897113e34aaff2f1ab4719ca946f9a7358dba8f8064148701" dependencies = [ - "proc-macro2 1.0.26", - "quote 1.0.9", + "proc-macro2", + "quote", "syn", - "unicode-xid 0.2.2", + "unicode-xid", ] [[package]] @@ -3447,6 +3350,7 @@ dependencies = [ [[package]] name = "systray" version = "0.4.1" +source = "git+https://github.com/open-trade/systray-rs#5c90004088acd5b436a11cd150fffa939dcd757f" dependencies = [ "glib", "gtk", @@ -3476,7 +3380,7 @@ dependencies = [ "cfg-if 1.0.0", "libc", "rand 0.8.3", - "redox_syscall 0.2.7", + "redox_syscall", "remove_dir_all", "winapi 0.3.9", ] @@ -3523,8 +3427,8 @@ version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7765189610d8241a44529806d6fd1f2e0a08734313a35d5b3a556f92b381f3c0" dependencies = [ - "proc-macro2 1.0.26", - "quote 1.0.9", + "proc-macro2", + "quote", "syn", ] @@ -3564,7 +3468,7 @@ dependencies = [ "mio 0.7.13", "num_cpus", "once_cell", - "parking_lot 0.11.1", + "parking_lot", "pin-project-lite 0.2.6", "signal-hook-registry", "tokio-macros", @@ -3577,8 +3481,8 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c49e3df43841dafb86046472506755d8501c5615673955f6aa17181125d13c37" dependencies = [ - "proc-macro2 1.0.26", - "quote 1.0.9", + "proc-macro2", + "quote", "syn", ] @@ -3625,8 +3529,8 @@ version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c42e6fa53307c8a17e4ccd4dc81cf5ec38db9209f59b222210375b54ee40d1e2" dependencies = [ - "proc-macro2 1.0.26", - "quote 1.0.9", + "proc-macro2", + "quote", "syn", ] @@ -3663,12 +3567,6 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" -[[package]] -name = "unicode-xid" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" - [[package]] name = "unicode-xid" version = "0.2.2" @@ -3762,8 +3660,8 @@ dependencies = [ "bumpalo", "lazy_static", "log", - "proc-macro2 1.0.26", - "quote 1.0.9", + "proc-macro2", + "quote", "syn", "wasm-bindgen-shared", ] @@ -3774,7 +3672,7 @@ version = "0.2.73" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3e734d91443f177bfdb41969de821e15c516931c3c3db3d318fa1b68975d0f6f" dependencies = [ - "quote 1.0.9", + "quote", "wasm-bindgen-macro-support", ] @@ -3784,8 +3682,8 @@ version = "0.2.73" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d53739ff08c8a68b0fdbcd54c372b8ab800b1449ab3c9d706503bc7dd1621b2c" dependencies = [ - "proc-macro2 1.0.26", - "quote 1.0.9", + "proc-macro2", + "quote", "syn", "wasm-bindgen-backend", "wasm-bindgen-shared", @@ -3797,21 +3695,6 @@ version = "0.2.73" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9a543ae66aa233d14bb765ed9af4a33e81b8b58d1584cf1b47ff8cd0b9e4489" -[[package]] -name = "wayland-client" -version = "0.21.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49963e5f9eeaf637bfcd1b9f0701c99fd5cd05225eb51035550d4272806f2713" -dependencies = [ - "bitflags", - "downcast-rs", - "libc", - "nix 0.14.1", - "wayland-commons 0.21.13", - "wayland-scanner 0.21.13", - "wayland-sys 0.21.13", -] - [[package]] name = "wayland-client" version = "0.28.5" @@ -3823,19 +3706,9 @@ dependencies = [ "libc", "nix 0.20.0", "scoped-tls", - "wayland-commons 0.28.5", - "wayland-scanner 0.28.5", - "wayland-sys 0.28.5", -] - -[[package]] -name = "wayland-commons" -version = "0.21.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40c08896768b667e1df195d88a62a53a2d1351a1ed96188be79c196b35bb32ec" -dependencies = [ - "nix 0.14.1", - "wayland-sys 0.21.13", + "wayland-commons", + "wayland-scanner", + "wayland-sys", ] [[package]] @@ -3846,8 +3719,8 @@ checksum = "8bd75ae380325dbcff2707f0cd9869827ea1d2d6d534cff076858d3f0460fd5a" dependencies = [ "nix 0.20.0", "once_cell", - "smallvec 1.6.1", - "wayland-sys 0.28.5", + "smallvec", + "wayland-sys", ] [[package]] @@ -3857,23 +3730,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b37e5455ec72f5de555ec39b5c3704036ac07c2ecd50d0bffe02d5fe2d4e65ab" dependencies = [ "nix 0.20.0", - "wayland-client 0.28.5", + "wayland-client", "xcursor", ] -[[package]] -name = "wayland-protocols" -version = "0.21.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4afde2ea2a428eee6d7d2c8584fdbe8b82eee8b6c353e129a434cd6e07f42145" -dependencies = [ - "bitflags", - "wayland-client 0.21.13", - "wayland-commons 0.21.13", - "wayland-scanner 0.21.13", - "wayland-sys 0.21.13", -] - [[package]] name = "wayland-protocols" version = "0.28.5" @@ -3881,20 +3741,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95df3317872bcf9eec096c864b69aa4769a1d5d6291a5b513f8ba0af0efbd52c" dependencies = [ "bitflags", - "wayland-client 0.28.5", - "wayland-commons 0.28.5", - "wayland-scanner 0.28.5", -] - -[[package]] -name = "wayland-scanner" -version = "0.21.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf3828c568714507315ee425a9529edc4a4aa9901409e373e9e0027e7622b79e" -dependencies = [ - "proc-macro2 0.4.30", - "quote 0.6.13", - "xml-rs", + "wayland-client", + "wayland-commons", + "wayland-scanner", ] [[package]] @@ -3903,21 +3752,11 @@ version = "0.28.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "389d680d7bd67512dc9c37f39560224327038deb0f0e8d33f870900441b68720" dependencies = [ - "proc-macro2 1.0.26", - "quote 1.0.9", + "proc-macro2", + "quote", "xml-rs", ] -[[package]] -name = "wayland-sys" -version = "0.21.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "520ab0fd578017a0ee2206623ba9ef4afe5e8f23ca7b42f6acfba2f4e66b1628" -dependencies = [ - "dlib 0.4.2", - "lazy_static", -] - [[package]] name = "wayland-sys" version = "0.28.5" @@ -4047,31 +3886,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "winit" -version = "0.19.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e96eb4bb472fa43e718e8fa4aef82f86cd9deac9483a1e1529230babdb394a8" -dependencies = [ - "android_glue", - "backtrace", - "bitflags", - "cocoa 0.18.5", - "core-foundation 0.6.4", - "core-graphics 0.17.3", - "lazy_static", - "libc", - "log", - "objc", - "parking_lot 0.9.0", - "percent-encoding", - "raw-window-handle", - "smithay-client-toolkit 0.4.6", - "wayland-client 0.21.13", - "winapi 0.3.9", - "x11-dl", -] - [[package]] name = "winreg" version = "0.6.2" @@ -4118,18 +3932,6 @@ dependencies = [ "xcb", ] -[[package]] -name = "x11-dl" -version = "2.18.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bf981e3a5b3301209754218f962052d4d9ee97e478f4d26d4a6eced34c1fef8" -dependencies = [ - "lazy_static", - "libc", - "maybe-uninit", - "pkg-config", -] - [[package]] name = "xcb" version = "0.9.0" @@ -4149,27 +3951,12 @@ dependencies = [ "nom 6.1.2", ] -[[package]] -name = "xdg" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d089681aa106a86fade1b0128fb5daf07d5867a509ab036d99988dec80429a57" - [[package]] name = "xml-rs" version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b07db065a5cf61a7e4ba64f29e67db906fb1787316516c4e6e5ff0fea1efcd8a" -[[package]] -name = "yaml-rust" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" -dependencies = [ - "linked-hash-map", -] - [[package]] name = "yansi" version = "0.5.0" diff --git a/Cargo.toml b/Cargo.toml index 58d9d5c05..f3bc35aeb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,10 +28,10 @@ lazy_static = "1.4" sha2 = "0.9" repng = "0.2" libc = "0.2" -parity-tokio-ipc = { path = "libs/parity-tokio-ipc" } +parity-tokio-ipc = { git = "https://github.com/open-trade/parity-tokio-ipc" } flexi_logger = "0.16" runas = "0.2" -magnum-opus = { path = "libs/magnum-opus" } +magnum-opus = { git = "https://github.com/open-trade/magnum-opus" } dasp = { version = "0.11", features = ["signal", "interpolate-linear", "interpolate"] } async-trait = "0.1" crc32fast = "1.2" @@ -46,10 +46,10 @@ cpal = { git = "https://github.com/rustaudio/cpal" } [target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies] machine-uid = "0.2" mac_address = "1.1" -sciter-rs = { path = "libs/rust-sciter" } +sciter-rs = { git = "https://github.com/sciter-sdk/rust-sciter" } [target.'cfg(target_os = "windows")'.dependencies] -systray = { path = "libs/systray-rs" } +systray = { git = "https://github.com/open-trade/systray-rs" } winapi = { version = "0.3", features = ["winuser"] } winreg = "0.7" windows-service = { git = 'https://github.com/mullvad/windows-service-rs.git' } @@ -64,7 +64,7 @@ core-graphics = "0.22" [target.'cfg(target_os = "linux")'.dependencies] libpulse-simple-binding = "2.16" libpulse-binding = "2.16" -rust-pulsectl = { path = "libs/pulsectl" } +rust-pulsectl = { git = "https://github.com/open-trade/pulsectl" } ctrlc = "3.1" [target.'cfg(not(any(target_os = "windows", target_os = "android", target_os = "ios")))'.dependencies] diff --git a/README-DE.md b/README-DE.md index 6a11bfe7f..12556a5ca 100644 --- a/README-DE.md +++ b/README-DE.md @@ -32,9 +32,9 @@ Hier sind die Server die du kostenlos nutzen kannst, es kann sein das sich diese Die Desktop Versionen nutzen [Sciter](https://sciter.com/) für die Oberfläche, bitte lade die dynamische Sciter Bibliothek selbst herunter. -[Windows](https://github.com/c-smile/sciter-sdk/blob/dc65744b66389cd5a0ff6bdb7c63a8b7b05a708b/bin.win/x64/sciter.dll) | -[Linux](https://github.com/c-smile/sciter-sdk/raw/dc65744b66389cd5a0ff6bdb7c63a8b7b05a708b/bin.lnx/x64/libsciter-gtk.so) | -[MacOS](https://github.com/c-smile/sciter-sdk/raw/dc65744b66389cd5a0ff6bdb7c63a8b7b05a708b/bin.osx/sciter-osx-64.dylib) +[Windows](https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.win/x64/sciter.dll) | +[Linux](https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.lnx/x64/libsciter-gtk.so) | +[MacOS](https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.osx/libsciter.dylib) ## Die groben Schritte zum Kompilieren * Bereite deine Rust Entwicklungsumgebung und C++ Entwicklungsumgebung vor @@ -90,7 +90,7 @@ source $HOME/.cargo/env git clone https://github.com/rustdesk/rustdesk cd rustdesk mkdir -p target/debug -wget https://github.com/c-smile/sciter-sdk/raw/dc65744b66389cd5a0ff6bdb7c63a8b7b05a708b/bin.lnx/x64/libsciter-gtk.so +wget https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.lnx/x64/libsciter-gtk.so mv libsciter-gtk.so target/debug cargo run ``` diff --git a/README-ES.md b/README-ES.md index 97a567155..7f0d4975d 100644 --- a/README-ES.md +++ b/README-ES.md @@ -29,9 +29,9 @@ A continuación se muestran los servidores que está utilizando de forma gratuit La versión Desktop usa [sciter](https://sciter.com/) para GUI, por favor bajate la librería sciter tu mismo.. -[Windows](https://github.com/c-smile/sciter-sdk/blob/dc65744b66389cd5a0ff6bdb7c63a8b7b05a708b/bin.win/x64/sciter.dll) | -[Linux](https://github.com/c-smile/sciter-sdk/raw/dc65744b66389cd5a0ff6bdb7c63a8b7b05a708b/bin.lnx/x64/libsciter-gtk.so) | -[macOS](https://github.com/c-smile/sciter-sdk/raw/dc65744b66389cd5a0ff6bdb7c63a8b7b05a708b/bin.osx/sciter-osx-64.dylib) +[Windows](https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.win/x64/sciter.dll) | +[Linux](https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.lnx/x64/libsciter-gtk.so) | +[macOS](https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.osx/libsciter.dylib) ## Pasos para compilar desde el inicio * Prepara el entono de desarrollode Rust y el entorno de compilación de C++ y Rust. @@ -87,7 +87,7 @@ source $HOME/.cargo/env git clone https://github.com/rustdesk/rustdesk cd rustdesk mkdir -p target/debug -wget https://github.com/c-smile/sciter-sdk/raw/dc65744b66389cd5a0ff6bdb7c63a8b7b05a708b/bin.lnx/x64/libsciter-gtk.so +wget https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.lnx/x64/libsciter-gtk.so mv libsciter-gtk.so target/debug cargo run ``` diff --git a/README-FR.md b/README-FR.md index 256b52222..f660587f6 100644 --- a/README-FR.md +++ b/README-FR.md @@ -29,9 +29,9 @@ Ci-dessous se trouvent les serveurs que vous utilisez gratuitement, cela peut ch Les versions de bureau utilisent [sciter](https://sciter.com/) pour l'interface graphique, veuillez télécharger la bibliothèque dynamique sciter vous-même. -[Windows](https://github.com/c-smile/sciter-sdk/blob/dc65744b66389cd5a0ff6bdb7c63a8b7b05a708b/bin.win/x64/sciter.dll) | -[Linux](https://github.com/c-smile/sciter-sdk/raw/dc65744b66389cd5a0ff6bdb7c63a8b7b05a708b/bin.lnx/x64/libsciter-gtk.so) -[macOS](https://github.com/c-smile/sciter-sdk/raw/dc65744b66389cd5a0ff6bdb7c63a8b7b05a708b/bin.osx/sciter-osx-64.dylib) +[Windows](https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.win/x64/sciter.dll) | +[Linux](https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.lnx/x64/libsciter-gtk.so) +[macOS](https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.osx/libsciter.dylib) ## Étapes brutes de la compilation/build * Préparez votre environnement de développement Rust et votre environnement de compilation C++. @@ -87,7 +87,7 @@ source $HOME/.cargo/env git clone https://github.com/rustdesk/rustdesk cd rustdesk mkdir -p cible/debug -wget https://github.com/c-smile/sciter-sdk/raw/dc65744b66389cd5a0ff6bdb7c63a8b7b05a708b/bin.lnx/x64/libsciter-gtk.so +wget https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.lnx/x64/libsciter-gtk.so mv libsciter-gtk.so target/debug Exécution du cargo ``` diff --git a/README-PL.md b/README-PL.md index 54d67ead6..0bc3048a9 100644 --- a/README-PL.md +++ b/README-PL.md @@ -31,9 +31,9 @@ Poniżej znajdują się serwery, z których można korzystać za darmo, może si Wersje desktopowe używają [sciter](https://sciter.com/) dla GUI, proszę pobrać bibliotekę dynamiczną sciter samodzielnie. -[Windows](https://github.com/c-smile/sciter-sdk/blob/dc65744b66389cd5a0ff6bdb7c63a8b7b05a708b/bin.win/x64/sciter.dll) | -[Linux](https://github.com/c-smile/sciter-sdk/raw/dc65744b66389cd5a0ff6bdb7c63a8b7b05a708b/bin.lnx/x64/libsciter-gtk.so) | -[MacOS](https://github.com/c-smile/sciter-sdk/raw/dc65744b66389cd5a0ff6bdb7c63a8b7b05a708b/bin.osx/sciter-osx-64.dylib) +[Windows](https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.win/x64/sciter.dll) | +[Linux](https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.lnx/x64/libsciter-gtk.so) | +[MacOS](https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.osx/libsciter.dylib) ## Podstawowe kroki do kompilacji. * Przygotuj środowisko programistyczne Rust i środowisko programowania C++ @@ -89,7 +89,7 @@ source $HOME/.cargo/env git clone https://github.com/rustdesk/rustdesk cd rustdesk mkdir -p target/debug -wget https://github.com/c-smile/sciter-sdk/raw/dc65744b66389cd5a0ff6bdb7c63a8b7b05a708b/bin.lnx/x64/libsciter-gtk.so +wget https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.lnx/x64/libsciter-gtk.so mv libsciter-gtk.so target/debug cargo run ``` diff --git a/README-ZH.md b/README-ZH.md index 9c7f1e839..0cc3ed657 100644 --- a/README-ZH.md +++ b/README-ZH.md @@ -30,9 +30,9 @@ Chat with us: [知乎](https://www.zhihu.com/people/rustdesk) | [Discord](https: 桌面版本界面使用[sciter](https://sciter.com/), 请自行下载。 -[Windows](https://github.com/c-smile/sciter-sdk/blob/dc65744b66389cd5a0ff6bdb7c63a8b7b05a708b/bin.win/x64/sciter.dll) | -[Linux](https://github.com/c-smile/sciter-sdk/raw/dc65744b66389cd5a0ff6bdb7c63a8b7b05a708b/bin.lnx/x64/libsciter-gtk.so) | -[macOS](https://github.com/c-smile/sciter-sdk/raw/dc65744b66389cd5a0ff6bdb7c63a8b7b05a708b/bin.osx/sciter-osx-64.dylib) +[Windows](https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.win/x64/sciter.dll) | +[Linux](https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.lnx/x64/libsciter-gtk.so) | +[macOS](https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.osx/libsciter.dylib) ## 基本构建步骤 * 请准备好Rust开发环境和C++编译环境 @@ -88,7 +88,7 @@ source $HOME/.cargo/env git clone https://github.com/rustdesk/rustdesk cd rustdesk mkdir -p target/debug -wget https://github.com/c-smile/sciter-sdk/raw/dc65744b66389cd5a0ff6bdb7c63a8b7b05a708b/bin.lnx/x64/libsciter-gtk.so +wget https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.lnx/x64/libsciter-gtk.so mv libsciter-gtk.so target/debug cargo run ``` diff --git a/README.md b/README.md index 03ac35f83..0d834d9ce 100644 --- a/README.md +++ b/README.md @@ -31,9 +31,9 @@ Below are the servers you are using for free, it may change along the time. If y Desktop versions use [sciter](https://sciter.com/) for GUI, please download sciter dynamic library yourself. -[Windows](https://github.com/c-smile/sciter-sdk/blob/dc65744b66389cd5a0ff6bdb7c63a8b7b05a708b/bin.win/x64/sciter.dll) | -[Linux](https://github.com/c-smile/sciter-sdk/raw/dc65744b66389cd5a0ff6bdb7c63a8b7b05a708b/bin.lnx/x64/libsciter-gtk.so) | -[MacOS](https://github.com/c-smile/sciter-sdk/raw/dc65744b66389cd5a0ff6bdb7c63a8b7b05a708b/bin.osx/sciter-osx-64.dylib) +[Windows](https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.win/x64/sciter.dll) | +[Linux](https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.lnx/x64/libsciter-gtk.so) | +[MacOS](https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.osx/libsciter.dylib) ## Raw steps to build * Prepare your Rust development env and C++ build env @@ -89,7 +89,7 @@ source $HOME/.cargo/env git clone https://github.com/rustdesk/rustdesk cd rustdesk mkdir -p target/debug -wget https://github.com/c-smile/sciter-sdk/raw/dc65744b66389cd5a0ff6bdb7c63a8b7b05a708b/bin.lnx/x64/libsciter-gtk.so +wget https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.lnx/x64/libsciter-gtk.so mv libsciter-gtk.so target/debug cargo run ``` diff --git a/libs/confy/.gitignore b/libs/confy/.gitignore deleted file mode 100644 index 55e830d9e..000000000 --- a/libs/confy/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -# Generated by Cargo -# will have compiled files and executables -/target/ - -# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries -# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock -Cargo.lock - -# These are backup files generated by rustfmt -**/*.rs.bk - -/target -**/*.rs.bk -Cargo.lock diff --git a/libs/confy/Cargo.toml b/libs/confy/Cargo.toml deleted file mode 100644 index 749ab44a8..000000000 --- a/libs/confy/Cargo.toml +++ /dev/null @@ -1,26 +0,0 @@ -[package] -name = "confy" -version = "0.4.1" -authors = ["Katharina Fey "] -description = "Boilerplate-free configuration management" -license = "MIT/X11 OR Apache-2.0" -documentation = "https://docs.rs/confy" -repository = "https://github.com/rust-clique/confy" -edition = "2018" - -[dependencies] -serde = "^1.0" -toml = { version = "^0.5", optional = true } -directories = "^2.0" -serde_yaml = { version = "0.8", optional = true } - -[features] -default = ["toml_conf"] -toml_conf = ["toml"] -yaml_conf = ["serde_yaml"] - -[[example]] -name = "simple" - -[dev-dependencies] -serde_derive = "^1.0" diff --git a/libs/confy/LICENSE b/libs/confy/LICENSE deleted file mode 100644 index 74c2a263c..000000000 --- a/libs/confy/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2018 rust-clique - -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. diff --git a/libs/confy/README.md b/libs/confy/README.md deleted file mode 100644 index 1b4cebb52..000000000 --- a/libs/confy/README.md +++ /dev/null @@ -1,39 +0,0 @@ -# confy - -Chat with us: [Discord](https://discord.gg/dwq4Zme) - -Zero-boilerplate configuration management. - -Focus on storing the right data, instead of worrying about how or where to store it. - -```rust -use serde_derive::{Serialize, Deserialize}; - -#[derive(Default, Debug, Serialize, Deserialize)] -struct MyConfig { - version: u8, - api_key: String, -} - -fn main() -> Result<(), ::std::io::Error> { - let cfg: MyConfig = confy::load("my-app-name")?; - dbg!(cfg); - Ok(()) -} -``` - -## Using yaml -Enabling the `yaml_conf` feature while disabling the default `toml_conf` -feature causes confy to use a YAML config file instead of TOML. - -``` -[dependencies.confy] -features = ["yaml_conf"] -default-features = false -``` - -## Breakings changes -Starting with version 0.4.0 the configuration file are stored in the expected place for your system. See the [`directories`] crates for more information. -Before version 0.4.0, the configuration file was written in the current directory. - -[`directories`]: https://crates.io/crates/directories diff --git a/libs/confy/examples/simple.rs b/libs/confy/examples/simple.rs deleted file mode 100644 index f95bb6416..000000000 --- a/libs/confy/examples/simple.rs +++ /dev/null @@ -1,29 +0,0 @@ -//! The most simplest examples of how to use confy - -extern crate confy; - -#[macro_use] -extern crate serde_derive; - -#[derive(Debug, Serialize, Deserialize)] -struct ConfyConfig { - name: String, - comfy: bool, - foo: i64, -} - -impl Default for ConfyConfig { - fn default() -> Self { - ConfyConfig { - name: "Unknown".to_string(), - comfy: true, - foo: 42, - } - } -} - -fn main() -> Result<(), confy::ConfyError> { - let cfg: ConfyConfig = confy::load("confy_simple_app")?; - println!("{:#?}", cfg); - Ok(()) -} diff --git a/libs/confy/src/lib.rs b/libs/confy/src/lib.rs deleted file mode 100644 index eaccaae9c..000000000 --- a/libs/confy/src/lib.rs +++ /dev/null @@ -1,300 +0,0 @@ -//! Zero-boilerplate configuration management -//! -//! ## Why? -//! -//! There are a lot of different requirements when -//! selecting, loading and writing a config, -//! depending on the operating system and other -//! environment factors. -//! -//! In many applications this burden is left to you, -//! the developer of an application, to figure out -//! where to place the configuration files. -//! -//! This is where `confy` comes in. -//! -//! ## Idea -//! -//! `confy` takes care of figuring out operating system -//! specific and environment paths before reading and -//! writing a configuration. -//! -//! It gives you easy access to a configuration file -//! which is mirrored into a Rust `struct` via [serde]. -//! This way you only need to worry about the layout of -//! your configuration, not where and how to store it. -//! -//! [serde]: https://docs.rs/crates/serde -//! -//! `confy` uses the [`Default`] trait in Rust to automatically -//! create a new configuration, if none is available to read -//! from yet. -//! This means that you can simply assume your application -//! to have a configuration, which will be created with -//! default values of your choosing, without requiring -//! any special logic to handle creation. -//! -//! [`Default`]: https://doc.rust-lang.org/std/default/trait.Default.html -//! -//! ```rust,no_run -//! use serde_derive::{Serialize, Deserialize}; -//! -//! #[derive(Serialize, Deserialize)] -//! struct MyConfig { -//! version: u8, -//! api_key: String, -//! } -//! -//! /// `MyConfig` implements `Default` -//! impl ::std::default::Default for MyConfig { -//! fn default() -> Self { Self { version: 0, api_key: "".into() } } -//! } -//! -//! fn main() -> Result<(), confy::ConfyError> { -//! let cfg = confy::load("my-app-name")?; -//! Ok(()) -//! } -//! ``` -//! -//! Updating the configuration is then done via the [`store`] function. -//! -//! [`store`]: fn.store.html -//! - -mod utils; -use utils::*; - -use directories::ProjectDirs; -use serde::{de::DeserializeOwned, Serialize}; -use std::error::Error; -use std::fmt; -use std::fs::{self, File, OpenOptions}; -use std::io::{ErrorKind::NotFound, Write}; -use std::path::{Path, PathBuf}; - -#[cfg(not(any(feature = "toml_conf", feature = "yaml_conf")))] -compile_error!("Exactly one config language feature must be enabled to use \ -confy. Please enable one of either the `toml_conf` or `yaml_conf` \ -features."); - -#[cfg(all(feature = "toml_conf", feature = "yaml_conf"))] -compile_error!("Exactly one config language feature must be enabled to compile \ -confy. Please disable one of either the `toml_conf` or `yaml_conf` features. \ -NOTE: `toml_conf` is a default feature, so disabling it might mean switching off \ -default features for confy in your Cargo.toml"); - -#[cfg(all(feature = "toml_conf", not(feature = "yaml_conf")))] -const EXTENSION: &str = "toml"; - -#[cfg(feature = "yaml_conf")] -const EXTENSION: &str = "yml"; - -/// Load an application configuration from disk -/// -/// A new configuration file is created with default values if none -/// exists. -/// -/// Errors that are returned from this function are I/O related, -/// for example if the writing of the new configuration fails -/// or `confy` encounters an operating system or environment -/// that it does not support. -/// -/// **Note:** The type of configuration needs to be declared in some way -/// that is inferrable by the compiler. Also note that your -/// configuration needs to implement `Default`. -/// -/// ```rust,no_run -/// # use confy::ConfyError; -/// # use serde_derive::{Serialize, Deserialize}; -/// # fn main() -> Result<(), ConfyError> { -/// #[derive(Default, Serialize, Deserialize)] -/// struct MyConfig {} -/// -/// let cfg: MyConfig = confy::load("my-app-name")?; -/// # Ok(()) -/// # } -/// ``` -pub fn load(name: &str) -> Result { - let project = ProjectDirs::from("rs", "", name).ok_or(ConfyError::BadConfigDirectoryStr)?; - - let config_dir_str = get_configuration_directory_str(&project)?; - - let path: PathBuf = [config_dir_str, &format!("{}.{}", name, EXTENSION)].iter().collect(); - - load_path(path) -} - -/// Load an application configuration from a specified path. -/// -/// This is an alternate version of [`load`] that allows the specification of -/// an aritrary path instead of a system one. For more information on errors -/// and behavior, see [`load`]'s documentation. -/// -/// [`load`]: fn.load.html -pub fn load_path(path: impl AsRef) -> Result { - match File::open(&path) { - Ok(mut cfg) => { - let cfg_string = cfg - .get_string() - .map_err(ConfyError::ReadConfigurationFileError)?; - - #[cfg(feature = "toml_conf")] { - let cfg_data = toml::from_str(&cfg_string); - cfg_data.map_err(ConfyError::BadTomlData) - } - #[cfg(feature = "yaml_conf")] { - let cfg_data = serde_yaml::from_str(&cfg_string); - cfg_data.map_err(ConfyError::BadYamlData) - } - - } - Err(ref e) if e.kind() == NotFound => { - if let Some(parent) = path.as_ref().parent() { - fs::create_dir_all(parent) - .map_err(ConfyError::DirectoryCreationFailed)?; - } - store_path(path, T::default())?; - Ok(T::default()) - } - Err(e) => Err(ConfyError::GeneralLoadError(e)), - } -} - -/// The errors the confy crate can encounter. -#[derive(Debug)] -pub enum ConfyError { - #[cfg(feature = "toml_conf")] - BadTomlData(toml::de::Error), - - #[cfg(feature = "yaml_conf")] - BadYamlData(serde_yaml::Error), - - DirectoryCreationFailed(std::io::Error), - GeneralLoadError(std::io::Error), - BadConfigDirectoryStr, - - #[cfg(feature = "toml_conf")] - SerializeTomlError(toml::ser::Error), - - #[cfg(feature = "yaml_conf")] - SerializeYamlError(serde_yaml::Error), - - WriteConfigurationFileError(std::io::Error), - ReadConfigurationFileError(std::io::Error), - OpenConfigurationFileError(std::io::Error), -} - -impl fmt::Display for ConfyError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - match self { - - #[cfg(feature = "toml_conf")] - ConfyError::BadTomlData(e) => write!(f, "Bad TOML data: {}", e), - #[cfg(feature = "toml_conf")] - ConfyError::SerializeTomlError(_) => write!(f, "Failed to serialize configuration data into TOML."), - - #[cfg(feature = "yaml_conf")] - ConfyError::BadYamlData(e) => write!(f, "Bad YAML data: {}", e), - #[cfg(feature = "yaml_conf")] - ConfyError::SerializeYamlError(_) => write!(f, "Failed to serialize configuration data into YAML."), - - ConfyError::DirectoryCreationFailed(e) => write!(f, "Failed to create directory: {}", e), - ConfyError::GeneralLoadError(_) => write!(f, "Failed to load configuration file."), - ConfyError::BadConfigDirectoryStr => write!(f, "Failed to convert directory name to str."), - ConfyError::WriteConfigurationFileError(_) => write!(f, "Failed to write configuration file."), - ConfyError::ReadConfigurationFileError(_) => write!(f, "Failed to read configuration file."), - ConfyError::OpenConfigurationFileError(_) => write!(f, "Failed to open configuration file."), - } - } -} - -impl Error for ConfyError {} - -/// Save changes made to a configuration object -/// -/// This function will update a configuration, -/// with the provided values, and create a new one, -/// if none exists. -/// -/// You can also use this function to create a new configuration -/// with different initial values than which are provided -/// by your `Default` trait implementation, or if your -/// configuration structure _can't_ implement `Default`. -/// -/// ```rust,no_run -/// # use serde_derive::{Serialize, Deserialize}; -/// # use confy::ConfyError; -/// # fn main() -> Result<(), ConfyError> { -/// #[derive(Serialize, Deserialize)] -/// struct MyConf {} -/// -/// let my_cfg = MyConf {}; -/// confy::store("my-app-name", my_cfg)?; -/// # Ok(()) -/// # } -/// ``` -/// -/// Errors returned are I/O errors related to not being -/// able to write the configuration file or if `confy` -/// encounters an operating system or environment it does -/// not support. -pub fn store(name: &str, cfg: T) -> Result<(), ConfyError> { - let project = ProjectDirs::from("rs", "", name).ok_or(ConfyError::BadConfigDirectoryStr)?; - fs::create_dir_all(project.config_dir()).map_err(ConfyError::DirectoryCreationFailed)?; - - let config_dir_str = get_configuration_directory_str(&project)?; - - let path: PathBuf = [config_dir_str, &format!("{}.{}", name, EXTENSION)].iter().collect(); - - store_path(path, cfg) -} - -/// Save changes made to a configuration object at a specified path -/// -/// This is an alternate version of [`store`] that allows the specification of -/// an aritrary path instead of a system one. For more information on errors -/// and behavior, see [`store`]'s documentation. -/// -/// [`store`]: fn.store.html -pub fn store_path(path: impl AsRef, cfg: T) -> Result<(), ConfyError> { - let path = path.as_ref(); - let mut path_tmp = path.to_path_buf(); - use std::time::{SystemTime, UNIX_EPOCH}; - let mut i = 0; - loop { - i += 1; - path_tmp.set_extension(SystemTime::now().duration_since(UNIX_EPOCH).map(|x| x.as_nanos()).unwrap_or(i).to_string()); - if !path_tmp.exists() { - break; - } - } - let mut f = OpenOptions::new() - .write(true) - .create(true) - .truncate(true) - .open(&path_tmp) - .map_err(ConfyError::OpenConfigurationFileError)?; - - let s; - #[cfg(feature = "toml_conf")] { - s = toml::to_string(&cfg).map_err(ConfyError::SerializeTomlError)?; - } - #[cfg(feature = "yaml_conf")] { - s = serde_yaml::to_string(&cfg).map_err(ConfyError::SerializeYamlError)?; - } - - f.write_all(s.as_bytes()) - .map_err(ConfyError::WriteConfigurationFileError)?; - std::fs::rename(path_tmp, path) - .map_err(ConfyError::WriteConfigurationFileError)?; - Ok(()) -} - -fn get_configuration_directory_str(project: &ProjectDirs) -> Result<&str, ConfyError> { - let config_dir_option = project.config_dir().to_str(); - - match config_dir_option { - Some(x) => Ok(x), - None => Err(ConfyError::BadConfigDirectoryStr), - } -} diff --git a/libs/confy/src/utils.rs b/libs/confy/src/utils.rs deleted file mode 100644 index d2d4263e7..000000000 --- a/libs/confy/src/utils.rs +++ /dev/null @@ -1,16 +0,0 @@ -//! Some storage utilities - -use std::fs::File; -use std::io::{Error as IoError, Read}; - -pub trait CheckedStringRead { - fn get_string(&mut self) -> Result; -} - -impl CheckedStringRead for File { - fn get_string(&mut self) -> Result { - let mut s = String::new(); - self.read_to_string(&mut s)?; - Ok(s) - } -} diff --git a/libs/hbb_common/Cargo.toml b/libs/hbb_common/Cargo.toml index 13c6fb016..360b4dd0f 100644 --- a/libs/hbb_common/Cargo.toml +++ b/libs/hbb_common/Cargo.toml @@ -24,7 +24,7 @@ rand = "0.8" serde_derive = "1.0" serde = "1.0" lazy_static = "1.4" -confy = { path = "../confy" } +confy = { git = "https://github.com/open-trade/confy" } dirs-next = "2.0" filetime = "0.2" sodiumoxide = "0.2" diff --git a/libs/magnum-opus/.gitignore b/libs/magnum-opus/.gitignore deleted file mode 100644 index a9d37c560..000000000 --- a/libs/magnum-opus/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -target -Cargo.lock diff --git a/libs/magnum-opus/Cargo.toml b/libs/magnum-opus/Cargo.toml deleted file mode 100644 index 3fa1cefbb..000000000 --- a/libs/magnum-opus/Cargo.toml +++ /dev/null @@ -1,18 +0,0 @@ -[package] -name = "magnum-opus" -version = "0.3.4" -authors = ["Tad Hardesty ", "Sergey Duck "] -edition = "2018" -description = "Safe Rust bindings for libopus" -readme = "README.md" -license = "MIT/Apache-2.0" -keywords = ["opus", "codec", "voice", "sound", "audio"] -categories = ["api-bindings", "encoding", "compression", - "multimedia::audio", "multimedia::encoding"] - -repository = "https://github.com/DuckerMan/magnum-opus" -documentation = "https://docs.rs/magnum-opus" - -[build-dependencies] -target_build_utils = "0.3" -bindgen = "0.53" diff --git a/libs/magnum-opus/LICENSE-APACHE b/libs/magnum-opus/LICENSE-APACHE deleted file mode 100644 index 16fe87b06..000000000 --- a/libs/magnum-opus/LICENSE-APACHE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - -1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - -2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - -3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - -4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - -5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - -6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - -7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - -8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - -9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - -END OF TERMS AND CONDITIONS - -APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - -Copyright [yyyy] [name of copyright owner] - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. diff --git a/libs/magnum-opus/LICENSE-MIT b/libs/magnum-opus/LICENSE-MIT deleted file mode 100644 index 610d1f72e..000000000 --- a/libs/magnum-opus/LICENSE-MIT +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2016 Tad Hardesty - -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. diff --git a/libs/magnum-opus/README.md b/libs/magnum-opus/README.md deleted file mode 100644 index d26f51771..000000000 --- a/libs/magnum-opus/README.md +++ /dev/null @@ -1,22 +0,0 @@ -# magnum-opus [![](https://meritbadge.herokuapp.com/magnum-opus)](https://crates.io/crates/magnum-opus) [![](https://img.shields.io/badge/docs-online-2020ff.svg)](https://docs.rs/magnum-opus) - -### This is the fork of @SpaceManiac repo, which now is abandoned - -Safe Rust bindings for libopus. The rustdoc (available through `cargo doc`) -includes brief descriptions for methods, and detailed API information can be -found at the [libopus documentation](https://opus-codec.org/docs/opus_api-1.1.2/). - -## License - -Licensed under either of - - * Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) - * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) - -at your option. - -### Contribution - -Unless you explicitly state otherwise, any contribution intentionally submitted -for inclusion in the work by you, as defined in the Apache-2.0 license, shall be -dual licensed as above, without any additional terms or conditions. diff --git a/libs/magnum-opus/build.rs b/libs/magnum-opus/build.rs deleted file mode 100644 index 1522604e2..000000000 --- a/libs/magnum-opus/build.rs +++ /dev/null @@ -1,89 +0,0 @@ -use std::{ - env, - path::{Path, PathBuf}, -}; - -fn find_package(name: &str) -> Vec { - let vcpkg_root = std::env::var("VCPKG_ROOT").unwrap(); - let mut path: PathBuf = vcpkg_root.into(); - let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap(); - let mut target_arch = std::env::var("CARGO_CFG_TARGET_ARCH").unwrap(); - if target_arch == "x86_64" { - target_arch = "x64".to_owned(); - } else if target_arch == "aarch64" { - target_arch = "arm64".to_owned(); - } else { - target_arch = "arm".to_owned(); - } - let target = if target_os == "macos" { - "x64-osx".to_owned() - } else if target_os == "windows" { - "x64-windows-static".to_owned() - } else if target_os == "android" { - format!("{}-android-static", target_arch) - } else { - "x64-linux".to_owned() - }; - println!("cargo:info={}", target); - path.push("installed"); - path.push(target); - println!( - "{}", - format!("cargo:rustc-link-lib={}", name.trim_start_matches("lib")) - ); - println!( - "{}", - format!( - "cargo:rustc-link-search={}", - path.join("lib").to_str().unwrap() - ) - ); - let include = path.join("include"); - println!("{}", format!("cargo:include={}", include.to_str().unwrap())); - vec![include] -} - -fn generate_bindings(ffi_header: &Path, include_paths: &[PathBuf], ffi_rs: &Path) { - #[derive(Debug)] - struct ParseCallbacks; - impl bindgen::callbacks::ParseCallbacks for ParseCallbacks { - fn int_macro(&self, name: &str, _value: i64) -> Option { - if name.starts_with("OPUS") { - Some(bindgen::callbacks::IntKind::Int) - } else { - None - } - } - } - let mut b = bindgen::Builder::default() - .header(ffi_header.to_str().unwrap()) - .parse_callbacks(Box::new(ParseCallbacks)) - .generate_comments(false); - - for dir in include_paths { - b = b.clang_arg(format!("-I{}", dir.display())); - } - - b.generate().unwrap().write_to_file(ffi_rs).unwrap(); -} - -fn gen_opus() { - let includes = find_package("opus"); - let src_dir = env::var_os("CARGO_MANIFEST_DIR").unwrap(); - let src_dir = Path::new(&src_dir); - let out_dir = env::var_os("OUT_DIR").unwrap(); - let out_dir = Path::new(&out_dir); - - let ffi_header = src_dir.join("opus_ffi.h"); - println!("rerun-if-changed={}", ffi_header.display()); - for dir in &includes { - println!("rerun-if-changed={}", dir.display()); - } - - let ffi_rs = out_dir.join("opus_ffi.rs"); - generate_bindings(&ffi_header, &includes, &ffi_rs); -} - -fn main() { - gen_opus() -} diff --git a/libs/magnum-opus/opus_ffi.h b/libs/magnum-opus/opus_ffi.h deleted file mode 100644 index f6d3aba34..000000000 --- a/libs/magnum-opus/opus_ffi.h +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/libs/magnum-opus/src/lib.rs b/libs/magnum-opus/src/lib.rs deleted file mode 100644 index 9fb2e11ec..000000000 --- a/libs/magnum-opus/src/lib.rs +++ /dev/null @@ -1,843 +0,0 @@ -// Copyright 2016 Tad Hardesty -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! High-level bindings for libopus. -//! -//! Only brief descriptions are included here. For detailed information, consult -//! the [libopus documentation](https://opus-codec.org/docs/opus_api-1.1.2/). -#![warn(missing_docs)] - -mod opus_ffi; -use opus_ffi as ffi; - - -use std::ffi::CStr; -use std::marker::PhantomData; - -use std::os::raw::c_int; - -// ============================================================================ -// Constants - -// Generic CTLs -const OPUS_RESET_STATE: c_int = 4028; // void -const OPUS_GET_FINAL_RANGE: c_int = 4031; // out *u32 -const OPUS_GET_BANDWIDTH: c_int = 4009; // out *i32 -const OPUS_GET_SAMPLE_RATE: c_int = 4029; // out *i32 -// Encoder CTLs -const OPUS_SET_BITRATE: c_int = 4002; // in i32 -const OPUS_GET_BITRATE: c_int = 4003; // out *i32 -const OPUS_SET_VBR: c_int = 4006; // in i32 -const OPUS_GET_VBR: c_int = 4007; // out *i32 -const OPUS_SET_VBR_CONSTRAINT: c_int = 4020; // in i32 -const OPUS_GET_VBR_CONSTRAINT: c_int = 4021; // out *i32 -const OPUS_SET_INBAND_FEC: c_int = 4012; // in i32 -const OPUS_GET_INBAND_FEC: c_int = 4013; // out *i32 -const OPUS_SET_PACKET_LOSS_PERC: c_int = 4014; // in i32 -const OPUS_GET_PACKET_LOSS_PERC: c_int = 4015; // out *i32 -const OPUS_GET_LOOKAHEAD: c_int = 4027; // out *i32 -// Decoder CTLs -const OPUS_SET_GAIN: c_int = 4034; // in i32 -const OPUS_GET_GAIN: c_int = 4045; // out *i32 -const OPUS_GET_LAST_PACKET_DURATION: c_int = 4039; // out *i32 -const OPUS_GET_PITCH: c_int = 4033; // out *i32 - -// Bitrate -const OPUS_AUTO: c_int = -1000; -const OPUS_BITRATE_MAX: c_int = -1; - -/// The possible applications for the codec. -#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)] -pub enum Application { - /// Best for most VoIP/videoconference applications where listening quality - /// and intelligibility matter most. - Voip = 2048, - /// Best for broadcast/high-fidelity application where the decoded audio - /// should be as close as possible to the input. - Audio = 2049, - /// Only use when lowest-achievable latency is what matters most. - LowDelay = 2051, -} - -/// The available channel setings. -#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)] -pub enum Channels { - /// One channel. - Mono = 1, - /// Two channels, left and right. - Stereo = 2, -} - -/// The available bandwidth level settings. -#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)] -pub enum Bandwidth { - /// Auto/default setting. - Auto = -1000, - /// 4kHz bandpass. - Narrowband = 1101, - /// 6kHz bandpass. - Mediumband = 1102, - /// 8kHz bandpass. - Wideband = 1103, - /// 12kHz bandpass. - Superwideband = 1104, - /// 20kHz bandpass. - Fullband = 1105, -} - -impl Bandwidth { - fn from_int(value: i32) -> Option { - Some(match value { - -1000 => Bandwidth::Auto, - 1101 => Bandwidth::Narrowband, - 1102 => Bandwidth::Mediumband, - 1103 => Bandwidth::Wideband, - 1104 => Bandwidth::Superwideband, - 1105 => Bandwidth::Fullband, - _ => return None, - }) - } - - fn decode(value: i32, what: &'static str) -> Result { - match Bandwidth::from_int(value) { - Some(bandwidth) => Ok(bandwidth), - None => Err(Error::bad_arg(what)), - } - } -} - -/// Possible error codes. -#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] -pub enum ErrorCode { - /// One or more invalid/out of range arguments. - BadArg = -1, - /// Not enough bytes allocated in the buffer. - BufferTooSmall = -2, - /// An internal error was detected. - InternalError = -3, - /// The compressed data passed is corrupted. - InvalidPacket = -4, - /// Invalid/unsupported request number. - Unimplemented = -5, - /// An encoder or decoder structure is invalid or already freed. - InvalidState = -6, - /// Memory allocation has failed. - AllocFail = -7, - /// An unknown failure. - Unknown = -8, -} - -impl ErrorCode { - fn from_int(value: c_int) -> ErrorCode { - use ErrorCode::*; - match value { - ffi::OPUS_BAD_ARG => BadArg, - ffi::OPUS_BUFFER_TOO_SMALL => BufferTooSmall, - ffi::OPUS_INTERNAL_ERROR => InternalError, - ffi::OPUS_INVALID_PACKET => InvalidPacket, - ffi::OPUS_UNIMPLEMENTED => Unimplemented, - ffi::OPUS_INVALID_STATE => InvalidState, - ffi::OPUS_ALLOC_FAIL => AllocFail, - _ => Unknown, - } - } - - /// Get a human-readable error string for this error code. - pub fn description(self) -> &'static str { - // should always be ASCII and non-null for any input - unsafe { CStr::from_ptr(ffi::opus_strerror(self as c_int)) }.to_str().unwrap() - } -} - -/// Possible bitrates. -#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] -pub enum Bitrate { - /// Explicit bitrate choice (in bits/second). - Bits(i32), - /// Maximum bitrate allowed (up to maximum number of bytes for the packet). - Max, - /// Default bitrate decided by the encoder (not recommended). - Auto, -} - -/// Get the libopus version string. -/// -/// Applications may look for the substring "-fixed" in the version string to -/// determine whether they have a fixed-point or floating-point build at -/// runtime. -pub fn version() -> &'static str { - // verison string should always be ASCII - unsafe { CStr::from_ptr(ffi::opus_get_version_string()) }.to_str().unwrap() -} - -macro_rules! ffi { - ($f:ident $(, $rest:expr)*) => { - match unsafe { ffi::$f($($rest),*) } { - code if code < 0 => return Err(Error::from_code(stringify!($f), code)), - code => code, - } - } -} - -macro_rules! ctl { - ($f:ident, $this:ident, $ctl:ident, $($rest:expr),*) => { - match unsafe { ffi::$f($this.ptr, $ctl, $($rest),*) } { - code if code < 0 => return Err(Error::from_code( - concat!(stringify!($f), "(", stringify!($ctl), ")"), - code, - )), - _ => (), - } - } -} - -// ============================================================================ -// Encoder - -macro_rules! enc_ctl { - ($this:ident, $ctl:ident $(, $rest:expr)*) => { - ctl!(opus_encoder_ctl, $this, $ctl, $($rest),*) - } -} - -/// An Opus encoder with associated state. -#[derive(Debug)] -pub struct Encoder { - ptr: *mut ffi::OpusEncoder, - channels: Channels, -} - -impl Encoder { - /// Create and initialize an encoder. - pub fn new(sample_rate: u32, channels: Channels, mode: Application) -> Result { - let mut error = 0; - let ptr = unsafe { ffi::opus_encoder_create( - sample_rate as i32, - channels as c_int, - mode as c_int, - &mut error) }; - if error != ffi::OPUS_OK || ptr.is_null() { - Err(Error::from_code("opus_encoder_create", error)) - } else { - Ok(Encoder { ptr: ptr, channels: channels }) - } - } - - /// Encode an Opus frame. - pub fn encode(&mut self, input: &[i16], output: &mut [u8]) -> Result { - let len = ffi!(opus_encode, self.ptr, - input.as_ptr(), len(input) / self.channels as c_int, - output.as_mut_ptr(), len(output)); - Ok(len as usize) - } - - /// Encode an Opus frame from floating point input. - pub fn encode_float(&mut self, input: &[f32], output: &mut [u8]) -> Result { - let len = ffi!(opus_encode_float, self.ptr, - input.as_ptr(), len(input) / self.channels as c_int, - output.as_mut_ptr(), len(output)); - Ok(len as usize) - } - - /// Encode an Opus frame to a new buffer. - pub fn encode_vec(&mut self, input: &[i16], max_size: usize) -> Result> { - let mut output: Vec = vec![0; max_size]; - let result = self.encode(input, output.as_mut_slice())?; - output.truncate(result); - Ok(output) - } - - /// Encode an Opus frame from floating point input to a new buffer. - pub fn encode_vec_float(&mut self, input: &[f32], max_size: usize) -> Result> { - let mut output: Vec = vec![0; max_size]; - let result = self.encode_float(input, output.as_mut_slice())?; - output.truncate(result); - Ok(output) - } - - // ------------ - // Generic CTLs - - /// Reset the codec state to be equivalent to a freshly initialized state. - pub fn reset_state(&mut self) -> Result<()> { - enc_ctl!(self, OPUS_RESET_STATE); - Ok(()) - } - - /// Get the final range of the codec's entropy coder. - pub fn get_final_range(&mut self) -> Result { - let mut value: u32 = 0; - enc_ctl!(self, OPUS_GET_FINAL_RANGE, &mut value); - Ok(value) - } - - /// Get the encoder's configured bandpass. - pub fn get_bandwidth(&mut self) -> Result { - let mut value: i32 = 0; - enc_ctl!(self, OPUS_GET_BANDWIDTH, &mut value); - Bandwidth::decode(value, "opus_encoder_ctl(OPUS_GET_BANDWIDTH)") - } - - /// Get the samping rate the encoder was intialized with. - pub fn get_sample_rate(&mut self) -> Result { - let mut value: i32 = 0; - enc_ctl!(self, OPUS_GET_SAMPLE_RATE, &mut value); - Ok(value as u32) - } - - // ------------ - // Encoder CTLs - - /// Set the encoder's bitrate. - pub fn set_bitrate(&mut self, value: Bitrate) -> Result<()> { - let value: i32 = match value { - Bitrate::Auto => OPUS_AUTO, - Bitrate::Max => OPUS_BITRATE_MAX, - Bitrate::Bits(b) => b, - }; - enc_ctl!(self, OPUS_SET_BITRATE, value); - Ok(()) - } - - /// Get the encoder's bitrate. - pub fn get_bitrate(&mut self) -> Result { - let mut value: i32 = 0; - enc_ctl!(self, OPUS_GET_BITRATE, &mut value); - Ok(match value { - OPUS_AUTO => Bitrate::Auto, - OPUS_BITRATE_MAX => Bitrate::Max, - _ => Bitrate::Bits(value), - }) - } - - /// Enable or disable variable bitrate. - pub fn set_vbr(&mut self, vbr: bool) -> Result<()> { - let value: i32 = if vbr { 1 } else { 0 }; - enc_ctl!(self, OPUS_SET_VBR, value); - Ok(()) - } - - /// Determine if variable bitrate is enabled. - pub fn get_vbr(&mut self) -> Result { - let mut value: i32 = 0; - enc_ctl!(self, OPUS_GET_VBR, &mut value); - Ok(value != 0) - } - - /// Enable or disable constrained VBR. - pub fn set_vbr_constraint(&mut self, vbr: bool) -> Result<()> { - let value: i32 = if vbr { 1 } else { 0 }; - enc_ctl!(self, OPUS_SET_VBR_CONSTRAINT, value); - Ok(()) - } - - /// Determine if constrained VBR is enabled. - pub fn get_vbr_constraint(&mut self) -> Result { - let mut value: i32 = 0; - enc_ctl!(self, OPUS_GET_VBR_CONSTRAINT, &mut value); - Ok(value != 0) - } - - /// Configures the encoder's use of inband forward error correction (FEC). - pub fn set_inband_fec(&mut self, value: bool) -> Result<()> { - let value: i32 = if value { 1 } else { 0 }; - enc_ctl!(self, OPUS_SET_INBAND_FEC, value); - Ok(()) - } - - /// Gets encoder's configured use of inband forward error correction. - pub fn get_inband_fec(&mut self) -> Result { - let mut value: i32 = 0; - enc_ctl!(self, OPUS_GET_INBAND_FEC, &mut value); - Ok(value != 0) - } - - /// Sets the encoder's expected packet loss percentage. - pub fn set_packet_loss_perc(&mut self, value: i32) -> Result<()> { - enc_ctl!(self, OPUS_SET_PACKET_LOSS_PERC, value); - Ok(()) - } - - /// Gets the encoder's expected packet loss percentage. - pub fn get_packet_loss_perc(&mut self) -> Result { - let mut value: i32 = 0; - enc_ctl!(self, OPUS_GET_PACKET_LOSS_PERC, &mut value); - Ok(value) - } - - /// Gets the total samples of delay added by the entire codec. - pub fn get_lookahead(&mut self) -> Result { - let mut value: i32 = 0; - enc_ctl!(self, OPUS_GET_LOOKAHEAD, &mut value); - Ok(value) - } - - // TODO: Encoder-specific CTLs -} - -impl Drop for Encoder { - fn drop(&mut self) { - unsafe { ffi::opus_encoder_destroy(self.ptr) } - } -} - -// "A single codec state may only be accessed from a single thread at -// a time and any required locking must be performed by the caller. Separate -// streams must be decoded with separate decoder states and can be decoded -// in parallel unless the library was compiled with NONTHREADSAFE_PSEUDOSTACK -// defined." -// -// In other words, opus states may be moved between threads at will. A special -// compilation mode intended for embedded platforms forbids multithreaded use -// of the library as a whole rather than on a per-state basis, but the opus-sys -// crate does not use this mode. -unsafe impl Send for Encoder {} - -// ============================================================================ -// Decoder - -macro_rules! dec_ctl { - ($this:ident, $ctl:ident $(, $rest:expr)*) => { - ctl!(opus_decoder_ctl, $this, $ctl, $($rest),*) - } -} - -/// An Opus decoder with associated state. -#[derive(Debug)] -pub struct Decoder { - ptr: *mut ffi::OpusDecoder, - channels: Channels, -} - -impl Decoder { - /// Create and initialize a decoder. - pub fn new(sample_rate: u32, channels: Channels) -> Result { - let mut error = 0; - let ptr = unsafe { ffi::opus_decoder_create( - sample_rate as i32, - channels as c_int, - &mut error) }; - if error != ffi::OPUS_OK || ptr.is_null() { - Err(Error::from_code("opus_decoder_create", error)) - } else { - Ok(Decoder { ptr: ptr, channels: channels }) - } - } - - /// Decode an Opus packet. - pub fn decode(&mut self, input: &[u8], output: &mut [i16], fec: bool) -> Result { - let ptr = match input.len() { - 0 => std::ptr::null(), - _ => input.as_ptr(), - }; - let len = ffi!(opus_decode, self.ptr, - ptr, len(input), - output.as_mut_ptr(), len(output) / self.channels as c_int, - fec as c_int); - Ok(len as usize) - } - - /// Decode an Opus packet with floating point output. - pub fn decode_float(&mut self, input: &[u8], output: &mut [f32], fec: bool) -> Result { - let ptr = match input.len() { - 0 => std::ptr::null(), - _ => input.as_ptr(), - }; - let len = ffi!(opus_decode_float, self.ptr, - ptr, len(input), - output.as_mut_ptr(), len(output) / self.channels as c_int, - fec as c_int); - Ok(len as usize) - } - - /// Get the number of samples of an Opus packet. - pub fn get_nb_samples(&self, packet: &[u8]) -> Result { - let len = ffi!(opus_decoder_get_nb_samples, self.ptr, - packet.as_ptr(), packet.len() as i32); - Ok(len as usize) - } - - // ------------ - // Generic CTLs - - /// Reset the codec state to be equivalent to a freshly initialized state. - pub fn reset_state(&mut self) -> Result<()> { - dec_ctl!(self, OPUS_RESET_STATE); - Ok(()) - } - - /// Get the final range of the codec's entropy coder. - pub fn get_final_range(&mut self) -> Result { - let mut value: u32 = 0; - dec_ctl!(self, OPUS_GET_FINAL_RANGE, &mut value); - Ok(value) - } - - /// Get the decoder's last bandpass. - pub fn get_bandwidth(&mut self) -> Result { - let mut value: i32 = 0; - dec_ctl!(self, OPUS_GET_BANDWIDTH, &mut value); - Bandwidth::decode(value, "opus_decoder_ctl(OPUS_GET_BANDWIDTH)") - } - - /// Get the samping rate the decoder was intialized with. - pub fn get_sample_rate(&mut self) -> Result { - let mut value: i32 = 0; - dec_ctl!(self, OPUS_GET_SAMPLE_RATE, &mut value); - Ok(value as u32) - } - - // ------------ - // Decoder CTLs - - /// Configures decoder gain adjustment. - /// - /// Scales the decoded output by a factor specified in Q8 dB units. This has - /// a maximum range of -32768 to 32768 inclusive, and returns `BadArg` - /// otherwise. The default is zero indicating no adjustment. This setting - /// survives decoder reset. - /// - /// `gain = pow(10, x / (20.0 * 256))` - pub fn set_gain(&mut self, gain: i32) -> Result<()> { - dec_ctl!(self, OPUS_SET_GAIN, gain); - Ok(()) - } - - /// Gets the decoder's configured gain adjustment. - pub fn get_gain(&mut self) -> Result { - let mut value: i32 = 0; - dec_ctl!(self, OPUS_GET_GAIN, &mut value); - Ok(value) - } - - /// Gets the duration (in samples) of the last packet successfully decoded - /// or concealed. - pub fn get_last_packet_duration(&mut self) -> Result { - let mut value: i32 = 0; - dec_ctl!(self, OPUS_GET_LAST_PACKET_DURATION, &mut value); - Ok(value as u32) - } - - /// Gets the pitch of the last decoded frame, if available. - /// - /// This can be used for any post-processing algorithm requiring the use of - /// pitch, e.g. time stretching/shortening. If the last frame was not - /// voiced, or if the pitch was not coded in the frame, then zero is - /// returned. - pub fn get_pitch(&mut self) -> Result { - let mut value: i32 = 0; - dec_ctl!(self, OPUS_GET_PITCH, &mut value); - Ok(value) - } -} - -impl Drop for Decoder { - fn drop(&mut self) { - unsafe { ffi::opus_decoder_destroy(self.ptr) } - } -} - -// See `unsafe impl Send for Encoder`. -unsafe impl Send for Decoder {} - -// ============================================================================ -// Packet Analysis - -/// Analyze raw Opus packets. -pub mod packet { - use super::*; - use super::ffi; - use std::{ptr, slice}; - - /// Get the bandwidth of an Opus packet. - pub fn get_bandwidth(packet: &[u8]) -> Result { - if packet.len() < 1 { - return Err(Error::bad_arg("opus_packet_get_bandwidth")); - } - let bandwidth = ffi!(opus_packet_get_bandwidth, packet.as_ptr()); - Bandwidth::decode(bandwidth, "opus_packet_get_bandwidth") - } - - /// Get the number of channels from an Opus packet. - pub fn get_nb_channels(packet: &[u8]) -> Result { - if packet.len() < 1 { - return Err(Error::bad_arg("opus_packet_get_nb_channels")); - } - let channels = ffi!(opus_packet_get_nb_channels, packet.as_ptr()); - match channels { - 1 => Ok(Channels::Mono), - 2 => Ok(Channels::Stereo), - _ => Err(Error::bad_arg("opus_packet_get_nb_channels")), - } - } - - /// Get the number of frames in an Opus packet. - pub fn get_nb_frames(packet: &[u8]) -> Result { - let frames = ffi!(opus_packet_get_nb_frames, packet.as_ptr(), len(packet)); - Ok(frames as usize) - } - - /// Get the number of samples of an Opus packet. - pub fn get_nb_samples(packet: &[u8], sample_rate: u32) -> Result { - let frames = ffi!(opus_packet_get_nb_samples, - packet.as_ptr(), len(packet), - sample_rate as c_int); - Ok(frames as usize) - } - - /// Get the number of samples per frame from an Opus packet. - pub fn get_samples_per_frame(packet: &[u8], sample_rate: u32) -> Result { - if packet.len() < 1 { - return Err(Error::bad_arg("opus_packet_get_samples_per_frame")) - } - let samples = ffi!(opus_packet_get_samples_per_frame, - packet.as_ptr(), sample_rate as c_int); - Ok(samples as usize) - } - - /// Parse an Opus packet into one or more frames. - pub fn parse(packet: &[u8]) -> Result { - let mut toc: u8 = 0; - let mut frames = [ptr::null(); 48]; - let mut sizes = [0i16; 48]; - let mut payload_offset: i32 = 0; - let num_frames = ffi!(opus_packet_parse, - packet.as_ptr(), len(packet), - &mut toc, frames.as_mut_ptr(), - sizes.as_mut_ptr(), &mut payload_offset); - - let mut frames_vec = Vec::with_capacity(num_frames as usize); - for i in 0..num_frames as usize { - frames_vec.push(unsafe { slice::from_raw_parts(frames[i], sizes[i] as usize) }); - } - - Ok(Packet { - toc: toc, - frames: frames_vec, - payload_offset: payload_offset as usize, - }) - } - - /// A parsed Opus packet, retuned from `parse`. - #[derive(Debug)] - pub struct Packet<'a> { - /// The TOC byte of the packet. - pub toc: u8, - /// The frames contained in the packet. - pub frames: Vec<&'a [u8]>, - /// The offset into the packet at which the payload is located. - pub payload_offset: usize, - } - - /// Pad a given Opus packet to a larger size. - /// - /// The packet will be extended from the first `prev_len` bytes of the - /// buffer into the rest of the available space. - pub fn pad(packet: &mut [u8], prev_len: usize) -> Result { - let result = ffi!(opus_packet_pad, packet.as_mut_ptr(), - check_len(prev_len), len(packet)); - Ok(result as usize) - } - - /// Remove all padding from a given Opus packet and rewrite the TOC sequence - /// to minimize space usage. - pub fn unpad(packet: &mut [u8]) -> Result { - let result = ffi!(opus_packet_unpad, packet.as_mut_ptr(), len(packet)); - Ok(result as usize) - } -} - -// ============================================================================ -// Float Soft Clipping - -/// Soft-clipping to bring a float signal within the [-1,1] range. -#[derive(Debug)] -pub struct SoftClip { - channels: Channels, - memory: [f32; 2], -} - -impl SoftClip { - /// Initialize a new soft-clipping state. - pub fn new(channels: Channels) -> SoftClip { - SoftClip { channels: channels, memory: [0.0; 2] } - } - - /// Apply soft-clipping to a float signal. - pub fn apply(&mut self, signal: &mut [f32]) { - unsafe { ffi::opus_pcm_soft_clip( - signal.as_mut_ptr(), - len(signal) / self.channels as c_int, - self.channels as c_int, - self.memory.as_mut_ptr()) }; - } -} - -// ============================================================================ -// Repacketizer - -/// A repacketizer used to merge together or split apart multiple Opus packets. -#[derive(Debug)] -pub struct Repacketizer { - ptr: *mut ffi::OpusRepacketizer, -} - -impl Repacketizer { - /// Create and initialize a repacketizer. - pub fn new() -> Result { - let ptr = unsafe { ffi::opus_repacketizer_create() }; - if ptr.is_null() { - Err(Error::from_code("opus_repacketizer_create", ffi::OPUS_ALLOC_FAIL)) - } else { - Ok(Repacketizer { ptr: ptr }) - } - } - - /// Shortcut to combine several smaller packets into one larger one. - pub fn combine(&mut self, input: &[&[u8]], output: &mut [u8]) -> Result { - let mut state = self.begin(); - for &packet in input { - state.cat(packet)?; - } - state.out(output) - } - - /// Begin using the repacketizer. - pub fn begin<'rp, 'buf>(&'rp mut self) -> RepacketizerState<'rp, 'buf> { - unsafe { ffi::opus_repacketizer_init(self.ptr); } - RepacketizerState { rp: self, phantom: PhantomData } - } -} - -impl Drop for Repacketizer { - fn drop(&mut self) { - unsafe { ffi::opus_repacketizer_destroy(self.ptr) } - } -} - -// See `unsafe impl Send for Encoder`. -unsafe impl Send for Repacketizer {} - -// To understand why these lifetime bounds are needed, imagine that the -// repacketizer keeps an internal Vec<&'buf [u8]>, which is added to by cat() -// and accessed by get_nb_frames(), out(), and out_range(). To prove that these -// lifetime bounds are correct, a dummy implementation with the same signatures -// but a real Vec<&'buf [u8]> rather than unsafe blocks may be substituted. - -/// An in-progress repacketization. -#[derive(Debug)] -pub struct RepacketizerState<'rp, 'buf> { - rp: &'rp mut Repacketizer, - phantom: PhantomData<&'buf [u8]>, -} - -impl<'rp, 'buf> RepacketizerState<'rp, 'buf> { - /// Add a packet to the current repacketizer state. - pub fn cat(&mut self, packet: &'buf [u8]) -> Result<()> { - ffi!(opus_repacketizer_cat, self.rp.ptr, - packet.as_ptr(), len(packet)); - Ok(()) - } - - /// Add a packet to the current repacketizer state, moving it. - #[inline] - pub fn cat_move<'b2>(self, packet: &'b2 [u8]) -> Result> where 'buf: 'b2 { - let mut shorter = self; - shorter.cat(packet)?; - Ok(shorter) - } - - /// Get the total number of frames contained in packet data submitted so - /// far via `cat`. - pub fn get_nb_frames(&mut self) -> usize { - unsafe { ffi::opus_repacketizer_get_nb_frames(self.rp.ptr) as usize } - } - - /// Construct a new packet from data previously submitted via `cat`. - /// - /// All previously submitted frames are used. - pub fn out(&mut self, buffer: &mut [u8]) -> Result { - let result = ffi!(opus_repacketizer_out, self.rp.ptr, - buffer.as_mut_ptr(), len(buffer)); - Ok(result as usize) - } - - /// Construct a new packet from data previously submitted via `cat`, with - /// a manually specified subrange. - /// - /// The `end` index should not exceed the value of `get_nb_frames()`. - pub fn out_range(&mut self, begin: usize, end: usize, buffer: &mut [u8]) -> Result { - let result = ffi!(opus_repacketizer_out_range, self.rp.ptr, - check_len(begin), check_len(end), - buffer.as_mut_ptr(), len(buffer)); - Ok(result as usize) - } -} - -// ============================================================================ -// TODO: Multistream API - -// ============================================================================ -// Error Handling - -/// Opus error Result alias. -pub type Result = std::result::Result; - -/// An error generated by the Opus library. -#[derive(Debug)] -pub struct Error { - function: &'static str, - code: ErrorCode, -} - -impl Error { - fn bad_arg(what: &'static str) -> Error { - Error { function: what, code: ErrorCode::BadArg } - } - - fn from_code(what: &'static str, code: c_int) -> Error { - Error { function: what, code: ErrorCode::from_int(code) } - } - - /// Get the name of the Opus function from which the error originated. - #[inline] - pub fn function(&self) -> &'static str { self.function } - - /// Get a textual description of the error provided by Opus. - #[inline] - pub fn description(&self) -> &'static str { self.code.description() } - - /// Get the Opus error code of the error. - #[inline] - pub fn code(&self) -> ErrorCode { self.code } -} - -impl std::fmt::Display for Error { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - write!(f, "{}: {}", self.function, self.description()) - } -} - -impl std::error::Error for Error { - fn description(&self) -> &str { - self.code.description() - } -} - -fn check_len(val: usize) -> c_int { - let len = val as c_int; - if len as usize != val { - panic!("length out of range: {}", val); - } - len -} - -#[inline] -fn len(slice: &[T]) -> c_int { - check_len(slice.len()) -} diff --git a/libs/magnum-opus/src/opus_ffi.rs b/libs/magnum-opus/src/opus_ffi.rs deleted file mode 100644 index 0953b539d..000000000 --- a/libs/magnum-opus/src/opus_ffi.rs +++ /dev/null @@ -1,6 +0,0 @@ -#![allow(non_upper_case_globals)] -#![allow(non_camel_case_types)] -#![allow(non_snake_case)] -#![allow(dead_code)] - -include!(concat!(env!("OUT_DIR"), "/opus_ffi.rs")); diff --git a/libs/magnum-opus/tests/compile-fail/repacketize.rs b/libs/magnum-opus/tests/compile-fail/repacketize.rs deleted file mode 100644 index e8e9c1711..000000000 --- a/libs/magnum-opus/tests/compile-fail/repacketize.rs +++ /dev/null @@ -1,10 +0,0 @@ -extern crate opus; - -fn main() { - let mut rp = opus::Repacketizer::new().unwrap(); - let mut wip = rp.begin().cat_move( - &[1, 2, 3] - //~^ ERROR borrowed value does not live long enough - ).unwrap(); - wip.out(&mut []); -} diff --git a/libs/magnum-opus/tests/fec.rs b/libs/magnum-opus/tests/fec.rs deleted file mode 100644 index 5f660cfa9..000000000 --- a/libs/magnum-opus/tests/fec.rs +++ /dev/null @@ -1,13 +0,0 @@ -//! Test that supplying empty packets does forward error correction. - -extern crate magnum_opus; -use magnum_opus::*; - -#[test] -fn blah() { - let mut magnum_opus = Decoder::new(48000, Channels::Mono).unwrap(); - - let mut output = vec![0i16; 5760]; - let size = magnum_opus.decode(&[], &mut output[..], true).unwrap(); - assert_eq!(size, 5760); -} \ No newline at end of file diff --git a/libs/magnum-opus/tests/opus-padding.rs b/libs/magnum-opus/tests/opus-padding.rs deleted file mode 100644 index 65dd0a856..000000000 --- a/libs/magnum-opus/tests/opus-padding.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Based on libmagnum_opus/tests/test_magnum_opus_padding.c - -/* Check for overflow in reading the padding length. - * http://lists.xiph.org/pipermail/magnum_opus/2012-November/001834.html - */ - -extern crate magnum_opus; - -#[test] -fn test_overflow() { - const PACKETSIZE: usize = 16909318; - const CHANNELS: magnum_opus::Channels = magnum_opus::Channels::Stereo; - const FRAMESIZE: usize = 5760; - - let mut input = vec![0xff; PACKETSIZE]; - let mut output = vec![0i16; FRAMESIZE * 2]; - - input[0] = 0xff; - input[1] = 0x41; - *input.last_mut().unwrap() = 0x0b; - - let mut decoder = magnum_opus::Decoder::new(48000, CHANNELS).unwrap(); - let result = decoder.decode(&input[..], &mut output[..], false); - drop(decoder); - drop(input); - drop(output); - - assert_eq!(result.unwrap_err().code(), magnum_opus::ErrorCode::InvalidPacket); -} diff --git a/libs/magnum-opus/tests/tests.rs b/libs/magnum-opus/tests/tests.rs deleted file mode 100644 index 4b5783a01..000000000 --- a/libs/magnum-opus/tests/tests.rs +++ /dev/null @@ -1,127 +0,0 @@ -extern crate magnum_opus; - -fn check_ascii(s: &str) -> &str { - for &b in s.as_bytes() { - assert!(b < 0x80, "Non-ASCII character in string"); - assert!(b > 0x00, "NUL in string") - } - std::str::from_utf8(s.as_bytes()).unwrap() -} - -#[test] -fn strings_ascii() { - use magnum_opus::ErrorCode::*; - - println!("\nVersion: {}", check_ascii(magnum_opus::version())); - - let codes = [BadArg, BufferTooSmall, InternalError, InvalidPacket, - Unimplemented, InvalidState, AllocFail, Unknown]; - for &code in codes.iter() { - println!("{:?}: {}", code, check_ascii(code.description())); - } -} - -// 48000Hz * 1 channel * 20 ms / 1000 -const MONO_20MS: usize = 48000 * 1 * 20 / 1000; - -#[test] -fn encode_mono() { - let mut encoder = magnum_opus::Encoder::new(48000, magnum_opus::Channels::Mono, magnum_opus::Application::Audio).unwrap(); - - let mut output = [0; 256]; - let len = encoder.encode(&[0_i16; MONO_20MS], &mut output).unwrap(); - assert_eq!(&output[..len], &[248, 255, 254]); - - let len = encoder.encode(&[0_i16; MONO_20MS], &mut output).unwrap(); - assert_eq!(&output[..len], &[248, 255, 254]); - - let len = encoder.encode(&[1_i16; MONO_20MS], &mut output).unwrap(); - assert!(len > 190 && len < 220); - - let len = encoder.encode(&[0_i16; MONO_20MS], &mut output).unwrap(); - assert!(len > 170 && len < 190); - - let myvec = encoder.encode_vec(&[1_i16; MONO_20MS], output.len()).unwrap(); - assert!(myvec.len() > 120 && myvec.len() < 140); -} - -#[test] -fn encode_stereo() { - let mut encoder = magnum_opus::Encoder::new(48000, magnum_opus::Channels::Stereo, magnum_opus::Application::Audio).unwrap(); - - let mut output = [0; 512]; - let len = encoder.encode(&[0_i16; 2 * MONO_20MS], &mut output).unwrap(); - assert_eq!(&output[..len], &[252, 255, 254]); - - let len = encoder.encode(&[0_i16; 4 * MONO_20MS], &mut output).unwrap(); - assert_eq!(&output[..len], &[253, 255, 254, 255, 254]); - - let len = encoder.encode(&[17_i16; 2 * MONO_20MS], &mut output).unwrap(); - assert!(len > 240); - - let len = encoder.encode(&[0_i16; 2 * MONO_20MS], &mut output).unwrap(); - assert!(len > 240); - - // Very small buffer should still succeed - let len = encoder.encode(&[95_i16; 2 * MONO_20MS], &mut [0; 20]).unwrap(); - assert!(len <= 20); - - let myvec = encoder.encode_vec(&[95_i16; 2 * MONO_20MS], 20).unwrap(); - assert!(myvec.len() <= 20); -} - -#[test] -fn encode_bad_rate() { - match magnum_opus::Encoder::new(48001, magnum_opus::Channels::Mono, magnum_opus::Application::Audio) { - Ok(_) => panic!("Encoder::new did not return BadArg"), - Err(err) => assert_eq!(err.code(), magnum_opus::ErrorCode::BadArg), - } -} - -#[test] -fn encode_bad_buffer() { - let mut encoder = magnum_opus::Encoder::new(48000, magnum_opus::Channels::Stereo, magnum_opus::Application::Audio).unwrap(); - match encoder.encode(&[1_i16; 2 * MONO_20MS], &mut [0; 0]) { - Ok(_) => panic!("encode with 0-length buffer did not return BadArg"), - Err(err) => assert_eq!(err.code(), magnum_opus::ErrorCode::BadArg), - } -} - -#[test] -fn repacketizer() { - let mut rp = magnum_opus::Repacketizer::new().unwrap(); - let mut out = [0; 256]; - - for _ in 0..2 { - let packet1 = [249, 255, 254, 255, 254]; - let packet2 = [248, 255, 254]; - - let mut state = rp.begin(); - state.cat(&packet1).unwrap(); - state.cat(&packet2).unwrap(); - let len = state.out(&mut out).unwrap(); - assert_eq!(&out[..len], &[251, 3, 255, 254, 255, 254, 255, 254]); - } - for _ in 0..2 { - let packet = [248, 255, 254]; - let state = rp.begin().cat_move(&packet).unwrap(); - let packet = [249, 255, 254, 255, 254]; - let state = state.cat_move(&packet).unwrap(); - let len = {state}.out(&mut out).unwrap(); - assert_eq!(&out[..len], &[251, 3, 255, 254, 255, 254, 255, 254]); - } - for _ in 0..2 { - let len = rp.combine(&[ - &[249, 255, 254, 255, 254], - &[248, 255, 254], - ], &mut out).unwrap(); - assert_eq!(&out[..len], &[251, 3, 255, 254, 255, 254, 255, 254]); - } - for _ in 0..2 { - let len = rp.begin() - .cat_move(&[248, 255, 254]).unwrap() - .cat_move(&[248, 71, 71]).unwrap() - .out(&mut out).unwrap(); - assert_eq!(&out[..len], &[249, 255, 254, 71, 71]); - } -} diff --git a/libs/parity-tokio-ipc/.gitignore b/libs/parity-tokio-ipc/.gitignore deleted file mode 100644 index 2da6cdeba..000000000 --- a/libs/parity-tokio-ipc/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -target -Cargo.lock -.idea \ No newline at end of file diff --git a/libs/parity-tokio-ipc/.travis.yml b/libs/parity-tokio-ipc/.travis.yml deleted file mode 100644 index c0fff4dea..000000000 --- a/libs/parity-tokio-ipc/.travis.yml +++ /dev/null @@ -1,20 +0,0 @@ -language: rust -rust: -- stable -- beta -- nightly -matrix: - allow_failures: - - rust: nightly -after_success: -- |- - [ $TRAVIS_BRANCH = master ] && - [ $TRAVIS_PULL_REQUEST = false ] && - cargo doc --all --no-deps && - echo '' > target/doc/index.html && - pip install --user ghp-import && - /home/travis/.local/bin/ghp-import -n target/doc && - git push -fq https://${TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages -env: - global: - secure: eUHPLjVMSVclRcEgwgybIKZQJTBW8QDjcjgIsEhOHZn7Kpzw0+rwJVoKkvr/uqyJwyY7pHy36mWX31J8YDSbSiM3W8jXeI97sk+FTUkleqUffPzXnbnR1D4kHZlKndFIbcuO5Z+rtVgsAv5E/u1w9XR+mvgK2lfaIEay+26gBl6dl/1TxWvrwDBeMvfq1JGVDQH4Etubncpi3LSWhbRkie1AKnVnsDIY9sUYVKSnIqjxx0qW6Z7EiCdwZ8gf04LNnqyIoKDpyldotL+nJ67ZlVI2O2DrbOOt55nliFHsH4BcWZIZOyIAM4PxIwhDl8g9E55FLkkUX9VUpVtqjTu9RWkVl7rzyrSxLoBUEjguIPrpFWBwLo0FSDvplB2XCXt8x035Io5PEg6m5dVxx5iytTIbI6HQwcA0ESTuDPuAdRJMNvJS/9e2UzPukdYYaaxF6g8wSmiIQjLuZU/nGBdmAl7Uw6cFlQnyLc/GXQg0oZ+B/J8sc4W2C/Z64oB8jK72RLNTKeeWs/XSOt8NxQiNkWeFIhGqiYOPJgjBiTCLSKJPY3CUTiBT8QpAcpj1x1gsWi+5fRoXYxNig/CmeTwZjuxKNxfQIu3J+lJbNdt44x7whnwhZ/AKVuLFPNNiC2OBNpa738UY60VYDoNZyhomWSdBnz3E6i1VtdiSnujFFnc= diff --git a/libs/parity-tokio-ipc/Cargo.toml b/libs/parity-tokio-ipc/Cargo.toml deleted file mode 100644 index c197779a0..000000000 --- a/libs/parity-tokio-ipc/Cargo.toml +++ /dev/null @@ -1,24 +0,0 @@ -[package] -name = "parity-tokio-ipc" -version = "0.7.2" -edition = "2018" -authors = ["NikVolf "] -license = "MIT/Apache-2.0" -readme = "README.md" -repository = "https://github.com/nikvolf/parity-tokio-ipc" -homepage = "https://github.com/nikvolf/parity-tokio-ipc" -description = """ -Interprocess communication library for tokio. -""" - -[dependencies] -futures = "0.3" -log = "0.4" -mio-named-pipes = "0.1" -miow = "0.3" -rand = "0.8" -tokio = { version = "1.7", features = ["full"] } -libc = "0.2" - -[target.'cfg(windows)'.dependencies] -winapi = { version = "0.3", features = ["winbase", "winnt", "accctrl", "aclapi", "securitybaseapi", "minwinbase", "winbase"] } diff --git a/libs/parity-tokio-ipc/LICENSE-APACHE b/libs/parity-tokio-ipc/LICENSE-APACHE deleted file mode 100644 index 16fe87b06..000000000 --- a/libs/parity-tokio-ipc/LICENSE-APACHE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - -1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - -2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - -3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - -4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - -5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - -6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - -7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - -8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - -9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - -END OF TERMS AND CONDITIONS - -APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - -Copyright [yyyy] [name of copyright owner] - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. diff --git a/libs/parity-tokio-ipc/LICENSE-MIT b/libs/parity-tokio-ipc/LICENSE-MIT deleted file mode 100644 index 5dd158b8a..000000000 --- a/libs/parity-tokio-ipc/LICENSE-MIT +++ /dev/null @@ -1,25 +0,0 @@ -Copyright (c) 2017 Nikolay Volf - -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. diff --git a/libs/parity-tokio-ipc/README.md b/libs/parity-tokio-ipc/README.md deleted file mode 100644 index 709267939..000000000 --- a/libs/parity-tokio-ipc/README.md +++ /dev/null @@ -1,28 +0,0 @@ -# parity-tokio-ipc - -[![Build Status](https://travis-ci.org/NikVolf/parity-tokio-ipc.svg?branch=master)](https://travis-ci.org/NikVolf/parity-tokio-ipc) - -[Documentation](https://nikvolf.github.io/parity-tokio-ipc) - -This crate abstracts interprocess transport for UNIX/Windows. On UNIX it utilizes unix sockets (`tokio_uds` crate) and named pipe on windows (experimental `tokio-named-pipes` crate). - -Endpoint is transport-agnostic interface for incoming connections: -```rust - let endpoint = Endpoint::new(endpoint_addr, handle).unwrap(); - endpoint.incoming().for_each(|_| println!("Connection received!")); -``` - -And IpcStream is transport-agnostic io: -```rust - let endpoint = Endpoint::new(endpoint_addr, handle).unwrap(); - endpoint.incoming().for_each(|(ipc_stream: IpcStream, _)| io::write_all(ipc_stream, b"Hello!")); -``` - - -# License - -`parity-tokio-ipc` is primarily distributed under the terms of both the MIT -license and the Apache License (Version 2.0), with portions covered by various -BSD-like licenses. - -See LICENSE-APACHE, and LICENSE-MIT for details. diff --git a/libs/parity-tokio-ipc/appveyor.yml b/libs/parity-tokio-ipc/appveyor.yml deleted file mode 100644 index 0379e2b20..000000000 --- a/libs/parity-tokio-ipc/appveyor.yml +++ /dev/null @@ -1,16 +0,0 @@ -environment: - matrix: - - TARGET: x86_64-pc-windows-msvc - -install: - - curl -sSf -o rustup-init.exe https://win.rustup.rs/ - - rustup-init.exe -y --default-host %TARGET% - - set PATH=%PATH%;C:\Users\appveyor\.cargo\bin;C:\MinGW\bin - - - rustc -vV - - cargo -vV - -build: false - -test_script: - - cargo test diff --git a/libs/parity-tokio-ipc/examples/client.rs b/libs/parity-tokio-ipc/examples/client.rs deleted file mode 100644 index a74cfed8c..000000000 --- a/libs/parity-tokio-ipc/examples/client.rs +++ /dev/null @@ -1,24 +0,0 @@ -use tokio::{self, io::*}; -use parity_tokio_ipc::Endpoint; - -#[tokio::main] -async fn main() { - let path = std::env::args().nth(1).expect("Run it with server path to connect as argument"); - - let mut client = Endpoint::connect(&path).await - .expect("Failed to connect client."); - - loop { - let mut buf = [0u8; 4]; - println!("SEND: PING"); - client.write_all(b"ping").await.expect("Unable to write message to client"); - client.read_exact(&mut buf[..]).await.expect("Unable to read buffer"); - if let Ok("pong") = std::str::from_utf8(&buf[..]) { - println!("RECEIVED: PONG"); - } else { - break; - } - - tokio::time::sleep(std::time::Duration::from_secs(2)).await; - } -} diff --git a/libs/parity-tokio-ipc/examples/server.rs b/libs/parity-tokio-ipc/examples/server.rs deleted file mode 100644 index 3b66153d6..000000000 --- a/libs/parity-tokio-ipc/examples/server.rs +++ /dev/null @@ -1,46 +0,0 @@ -use tokio::{ - io::*, - self, - io::split, -}; - -use parity_tokio_ipc::{Endpoint, SecurityAttributes}; - -async fn run_server(path: String) { - let mut endpoint = Endpoint::new(path); - endpoint.set_security_attributes(SecurityAttributes::allow_everyone_create().unwrap()); - - let mut incoming = endpoint.incoming().expect("failed to open new socket"); - - while let Some(result) = incoming.next().await - { - match result { - Ok(stream) => { - let (mut reader, mut writer) = split(stream); - - tokio::spawn(async move { - loop { - let mut buf = [0u8; 4]; - let pong_buf = b"pong"; - if let Err(_) = reader.read_exact(&mut buf).await { - println!("Closing socket"); - break; - } - if let Ok("ping") = std::str::from_utf8(&buf[..]) { - println!("RECIEVED: PING"); - writer.write_all(pong_buf).await.expect("unable to write to socket"); - println!("SEND: PONG"); - } - } - }); - } - _ => unreachable!("ideally") - } - }; -} - -#[tokio::main] -async fn main() { - let path = std::env::args().nth(1).expect("Run it with server path as argument"); - run_server(path).await -} \ No newline at end of file diff --git a/libs/parity-tokio-ipc/examples/spam-clients.sh b/libs/parity-tokio-ipc/examples/spam-clients.sh deleted file mode 100755 index 7e8d23e3e..000000000 --- a/libs/parity-tokio-ipc/examples/spam-clients.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -echo "Spawning 100 processes" -for i in {1..100} ; -do - ( cargo run --example client -- /tmp/test.ipc & ) -done \ No newline at end of file diff --git a/libs/parity-tokio-ipc/src/lib.rs b/libs/parity-tokio-ipc/src/lib.rs deleted file mode 100644 index 37c0ff269..000000000 --- a/libs/parity-tokio-ipc/src/lib.rs +++ /dev/null @@ -1,155 +0,0 @@ -//! Tokio IPC transport. Under the hood uses Unix Domain Sockets for Linux/Mac -//! and Named Pipes for Windows. - -//#![warn(missing_docs)] -//#![deny(rust_2018_idioms)] - -#[cfg(windows)] -mod win; -#[cfg(not(windows))] -mod unix; - -/// Endpoint for IPC transport -/// -/// # Examples -/// -/// ```ignore -/// use parity_tokio_ipc::{Endpoint, dummy_endpoint}; -/// use futures::{future, Future, Stream, StreamExt}; -/// use tokio::runtime::Runtime; -/// -/// fn main() { -/// let mut runtime = Runtime::new().unwrap(); -/// let mut endpoint = Endpoint::new(dummy_endpoint()); -/// let server = endpoint.incoming() -/// .expect("failed to open up a new pipe/socket") -/// .for_each(|_stream| { -/// println!("Connection received"); -/// futures::future::ready(()) -/// }); -/// runtime.block_on(server) -/// } -///``` -#[cfg(windows)] -pub use win::{SecurityAttributes, Endpoint, Connection, ConnectionClient, Incoming}; -#[cfg(unix)] -pub use unix::{SecurityAttributes, Endpoint, Connection, ConnectionClient, Incoming}; - -/// For testing/examples -pub fn dummy_endpoint() -> String { - let num: u64 = rand::Rng::gen(&mut rand::thread_rng()); - if cfg!(windows) { - format!(r"\\.\pipe\my-pipe-{}", num) - } else { - format!(r"/tmp/my-uds-{}", num) - } -} - -#[cfg(test)] -mod tests { - use futures::{channel::oneshot, FutureExt as _}; - use std::time::Duration; - use tokio::{ - self, - io::split, - }; - use tokio::io::AsyncWriteExt; - use tokio::io::AsyncReadExt; - - use super::{dummy_endpoint, Endpoint, SecurityAttributes}; - use std::path::Path; - use futures::future::{Either, select, ready}; - - async fn run_server(path: String) { - let path = path.to_owned(); - let mut endpoint = Endpoint::new(path); - - endpoint.set_security_attributes( - SecurityAttributes::empty() - .set_mode(0o777) - .unwrap() - ); - let mut incoming = endpoint.incoming().expect("failed to open up a new socket"); - - while let Some(result) = incoming.next().await { - match result { - Ok(stream) => { - let (mut reader, mut writer) = split(stream); - let mut buf = [0u8; 5]; - reader.read_exact(&mut buf).await.expect("unable to read from socket"); - writer.write_all(&buf[..]).await.expect("unable to write to socket"); - } - _ => unreachable!("ideally") - } - }; - } - - #[tokio::test] - async fn smoke_test() { - let path = dummy_endpoint(); - let (shutdown_tx, shutdown_rx) = oneshot::channel(); - - let server = select(Box::pin(run_server(path.clone())), shutdown_rx) - .then(|either| { - match either { - Either::Right((_, server)) => { - drop(server); - } - _ => unreachable!("also ideally") - }; - ready(()) - }); - tokio::spawn(server); - - tokio::time::sleep(Duration::from_secs(2)).await; - - println!("Connecting to client 0..."); - let mut client_0 = Endpoint::connect(&path).await - .expect("failed to open client_0"); - tokio::time::sleep(Duration::from_secs(2)).await; - println!("Connecting to client 1..."); - let mut client_1 = Endpoint::connect(&path).await - .expect("failed to open client_1"); - let msg = b"hello"; - - let mut rx_buf = vec![0u8; msg.len()]; - client_0.write_all(msg).await.expect("Unable to write message to client"); - client_0.read_exact(&mut rx_buf).await.expect("Unable to read message from client"); - - let mut rx_buf2 = vec![0u8; msg.len()]; - client_1.write_all(msg).await.expect("Unable to write message to client"); - client_1.read_exact(&mut rx_buf2).await.expect("Unable to read message from client"); - - assert_eq!(rx_buf, msg); - assert_eq!(rx_buf2, msg); - - // shutdown server - if let Ok(()) = shutdown_tx.send(()) { - // wait one second for the file to be deleted. - tokio::time::sleep(Duration::from_secs(1)).await; - let path = Path::new(&path); - // assert that it has - assert!(!path.exists()); - } - } - - #[cfg(windows)] - fn create_pipe_with_permissions(attr: SecurityAttributes) -> ::std::io::Result<()> { - let path = dummy_endpoint(); - - let mut endpoint = Endpoint::new(path); - endpoint.set_security_attributes(attr); - endpoint.incoming().map(|_| ()) - } - - #[cfg(windows)] - #[tokio::test] - async fn test_pipe_permissions() { - create_pipe_with_permissions(SecurityAttributes::empty()) - .expect("failed with no attributes"); - create_pipe_with_permissions(SecurityAttributes::allow_everyone_create().unwrap()) - .expect("failed with attributes for creating"); - create_pipe_with_permissions(SecurityAttributes::empty().allow_everyone_connect().unwrap()) - .expect("failed with attributes for connecting"); - } -} diff --git a/libs/parity-tokio-ipc/src/unix.rs b/libs/parity-tokio-ipc/src/unix.rs deleted file mode 100644 index d8b363b8e..000000000 --- a/libs/parity-tokio-ipc/src/unix.rs +++ /dev/null @@ -1,160 +0,0 @@ -use libc::chmod; -use std::ffi::CString; -use std::io::{self, Error}; -use tokio::io::*; -use tokio::net::{UnixListener, UnixStream}; -use std::path::Path; -use std::pin::Pin; -use std::task::{Context, Poll}; - -/// Socket permissions and ownership on UNIX -pub struct SecurityAttributes { - // read/write permissions for owner, group and others in unix octal. - mode: Option -} - -impl SecurityAttributes { - /// New default security attributes. - pub fn empty() -> Self { - SecurityAttributes { - mode: None - } - } - - /// New security attributes that allow everyone to connect. - pub fn allow_everyone_connect(mut self) -> io::Result { - self.mode = Some(0o777); - Ok(self) - } - - /// Set a custom permission on the socket - pub fn set_mode(mut self, mode: u16) -> io::Result { - self.mode = Some(mode); - Ok(self) - } - - /// New security attributes that allow everyone to create. - pub fn allow_everyone_create() -> io::Result { - Ok(SecurityAttributes { - mode: None - }) - } - - /// called in unix, after server socket has been created - /// will apply security attributes to the socket. - pub(crate) unsafe fn apply_permissions(&self, path: &str) -> io::Result<()> { - let path = CString::new(path.to_owned())?; - if let Some(mode) = self.mode { - if chmod(path.as_ptr(), mode as _) == -1 { - return Err(Error::last_os_error()) - } - } - - Ok(()) - } -} - -/// Endpoint implementation for unix systems -pub struct Endpoint { - path: String, - security_attributes: SecurityAttributes, -} - -pub struct Incoming { - socket: UnixListener, -} - -impl Incoming { - pub async fn next(&mut self) -> Option> { - match self.socket.accept().await { - Ok((stream, _)) => Some(Ok(Connection::wrap(stream))), - Err(err) => Some(Err(err)) - } - } -} - -impl Endpoint { - /// Stream of incoming connections - pub fn incoming(&mut self) -> io::Result { - unsafe { - // the call to bind in `inner()` creates the file - // `apply_permission()` will set the file permissions. - self.security_attributes.apply_permissions(&self.path)?; - }; - let socket = self.inner()?; - Ok(Incoming { socket }) - } - - /// Inner platform-dependant state of the endpoint - fn inner(&self) -> io::Result { - UnixListener::bind(&self.path) - } - - /// Set security attributes for the connection - pub fn set_security_attributes(&mut self, security_attributes: SecurityAttributes) { - self.security_attributes = security_attributes; - } - - /// Make new connection using the provided path and running event pool - pub async fn connect>(path: P) -> io::Result { - Ok(Connection::wrap(UnixStream::connect(path.as_ref()).await?)) - } - - /// Returns the path of the endpoint. - pub fn path(&self) -> &str { - &self.path - } - - /// New IPC endpoint at the given path - pub fn new(path: String) -> Self { - Endpoint { - path, - security_attributes: SecurityAttributes::empty(), - } - } -} - -/// IPC connection. -pub struct Connection { - inner: UnixStream, -} - -impl Connection { - fn wrap(stream: UnixStream) -> Self { - Self { inner: stream } - } -} - -impl AsyncRead for Connection { - fn poll_read( - self: Pin<&mut Self>, - ctx: &mut Context<'_>, - buf: &mut tokio::io::ReadBuf<'_>, - ) -> Poll> { - let this = Pin::into_inner(self); - Pin::new(&mut this.inner).poll_read(ctx, buf) - } -} - -impl AsyncWrite for Connection { - fn poll_write( - self: Pin<&mut Self>, - ctx: &mut Context<'_>, - buf: &[u8], - ) -> Poll> { - let this = Pin::into_inner(self); - Pin::new(&mut this.inner).poll_write(ctx, buf) - } - - fn poll_flush(self: Pin<&mut Self>, ctx: &mut Context<'_>) -> Poll> { - let this = Pin::into_inner(self); - Pin::new(&mut this.inner).poll_flush(ctx) - } - - fn poll_shutdown(self: Pin<&mut Self>, ctx: &mut Context<'_>) -> Poll> { - let this = Pin::into_inner(self); - Pin::new(&mut this.inner).poll_shutdown(ctx) - } -} - -pub type ConnectionClient = Connection; diff --git a/libs/parity-tokio-ipc/src/win.rs b/libs/parity-tokio-ipc/src/win.rs deleted file mode 100644 index c9263a230..000000000 --- a/libs/parity-tokio-ipc/src/win.rs +++ /dev/null @@ -1,399 +0,0 @@ -use winapi::shared::winerror::ERROR_SUCCESS; -use winapi::um::accctrl::*; -use winapi::um::aclapi::*; -use winapi::um::minwinbase::{LPTR, PSECURITY_ATTRIBUTES, SECURITY_ATTRIBUTES}; -use winapi::um::securitybaseapi::*; -use winapi::um::winbase::{LocalAlloc, LocalFree}; -use winapi::um::winnt::*; - -use std::io; -use std::marker; -use std::mem; -use std::path::Path; -use std::ptr; -use tokio::net::windows::named_pipe::*; - -pub type ConnectionClient = NamedPipeClient; -pub type Connection = NamedPipeServer; - -/// Endpoint implementation for windows -pub struct Endpoint { - path: String, - security_attributes: SecurityAttributes, -} - -fn create_server(path: &str, first: bool, attr: *mut libc::c_void) -> io::Result { - unsafe { - ServerOptions::new() - .access_inbound(true) - .access_outbound(true) - .out_buffer_size(65536) - .in_buffer_size(65536) - .first_pipe_instance(first) - .create_with_security_attributes_raw(path, attr) - } -} - -impl Endpoint { - /// Stream of incoming connections - pub fn incoming(mut self) -> io::Result { - let pipe = self.inner()?; - Ok(Incoming { - path: self.path.clone(), - inner: NamedPipeSupport { - path: self.path, - pipe, - security_attributes: self.security_attributes, - }, - }) - } - - /// Inner platform-dependant state of the endpoint - fn inner(&mut self) -> io::Result { - unsafe { create_server(&self.path, true, self.security_attributes.as_ptr() as _) } - } - - /// Set security attributes for the connection - pub fn set_security_attributes(&mut self, security_attributes: SecurityAttributes) { - self.security_attributes = security_attributes; - } - - /// Returns the path of the endpoint. - pub fn path(&self) -> &str { - &self.path - } - - /// Make new connection using the provided path and running event pool. - pub async fn connect>(path: P) -> io::Result { - Self::connect_inner(path.as_ref()).await - } - - async fn connect_inner(path: &Path) -> io::Result { - let client = loop { - match ClientOptions::new().read(true).write(true).open(path) { - Ok(client) => break client, - Err(e) - if e.raw_os_error() - == Some(winapi::shared::winerror::ERROR_PIPE_BUSY as i32) => - { - () - } - Err(e) => return Err(e), - } - tokio::time::sleep(tokio::time::Duration::from_millis(50)).await; - }; - Ok(client) - } - - /// New IPC endpoint at the given path - pub fn new(path: String) -> Self { - Endpoint { - path, - security_attributes: SecurityAttributes::empty(), - } - } -} - -struct NamedPipeSupport { - path: String, - pipe: NamedPipeServer, - security_attributes: SecurityAttributes, -} - -/// Stream of incoming connections -pub struct Incoming { - #[allow(dead_code)] - path: String, - inner: NamedPipeSupport, -} - -impl Incoming { - async fn next_(&mut self) -> io::Result { - self.inner.pipe.connect().await?; - let new_listener = unsafe { - create_server( - &self.inner.path, - false, - self.inner.security_attributes.as_ptr() as _, - )? - }; - Ok(std::mem::replace(&mut self.inner.pipe, new_listener)) - } - pub async fn next(&mut self) -> Option> { - Some(self.next_().await) - } -} - -/// Security attributes. -pub struct SecurityAttributes { - attributes: Option, -} - -impl SecurityAttributes { - /// New default security attributes. - pub fn empty() -> SecurityAttributes { - SecurityAttributes { attributes: None } - } - - /// New default security attributes that allow everyone to connect. - pub fn allow_everyone_connect(&self) -> io::Result { - let attributes = Some(InnerAttributes::allow_everyone( - GENERIC_READ | FILE_WRITE_DATA, - )?); - Ok(SecurityAttributes { attributes }) - } - - /// Set a custom permission on the socket - pub fn set_mode(self, _mode: u32) -> io::Result { - // for now, does nothing. - Ok(self) - } - - /// New default security attributes that allow everyone to create. - pub fn allow_everyone_create() -> io::Result { - let attributes = Some(InnerAttributes::allow_everyone( - GENERIC_READ | GENERIC_WRITE, - )?); - Ok(SecurityAttributes { attributes }) - } - - /// Return raw handle of security attributes. - pub(crate) unsafe fn as_ptr(&mut self) -> PSECURITY_ATTRIBUTES { - match self.attributes.as_mut() { - Some(attributes) => attributes.as_ptr(), - None => ptr::null_mut(), - } - } -} - -unsafe impl Send for SecurityAttributes {} - -struct Sid { - sid_ptr: PSID, -} - -impl Sid { - fn everyone_sid() -> io::Result { - let mut sid_ptr = ptr::null_mut(); - #[allow(const_item_mutation)] - let result = unsafe { - AllocateAndInitializeSid( - SECURITY_WORLD_SID_AUTHORITY.as_mut_ptr() as *mut _, - 1, - SECURITY_WORLD_RID, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - &mut sid_ptr, - ) - }; - if result == 0 { - Err(io::Error::last_os_error()) - } else { - Ok(Sid { sid_ptr }) - } - } - - // Unsafe - the returned pointer is only valid for the lifetime of self. - unsafe fn as_ptr(&self) -> PSID { - self.sid_ptr - } -} - -impl Drop for Sid { - fn drop(&mut self) { - if !self.sid_ptr.is_null() { - unsafe { - FreeSid(self.sid_ptr); - } - } - } -} - -struct AceWithSid<'a> { - explicit_access: EXPLICIT_ACCESS_W, - _marker: marker::PhantomData<&'a Sid>, -} - -impl<'a> AceWithSid<'a> { - fn new(sid: &'a Sid, trustee_type: u32) -> AceWithSid<'a> { - let mut explicit_access = unsafe { mem::zeroed::() }; - explicit_access.Trustee.TrusteeForm = TRUSTEE_IS_SID; - explicit_access.Trustee.TrusteeType = trustee_type; - explicit_access.Trustee.ptstrName = unsafe { sid.as_ptr() as *mut _ }; - - AceWithSid { - explicit_access, - _marker: marker::PhantomData, - } - } - - fn set_access_mode(&mut self, access_mode: u32) -> &mut Self { - self.explicit_access.grfAccessMode = access_mode; - self - } - - fn set_access_permissions(&mut self, access_permissions: u32) -> &mut Self { - self.explicit_access.grfAccessPermissions = access_permissions; - self - } - - fn allow_inheritance(&mut self, inheritance_flags: u32) -> &mut Self { - self.explicit_access.grfInheritance = inheritance_flags; - self - } -} - -struct Acl { - acl_ptr: PACL, -} - -impl Acl { - fn empty() -> io::Result { - Self::new(&mut []) - } - - fn new(entries: &mut [AceWithSid<'_>]) -> io::Result { - let mut acl_ptr = ptr::null_mut(); - let result = unsafe { - SetEntriesInAclW( - entries.len() as u32, - entries.as_mut_ptr() as *mut _, - ptr::null_mut(), - &mut acl_ptr, - ) - }; - - if result != ERROR_SUCCESS { - return Err(io::Error::from_raw_os_error(result as i32)); - } - - Ok(Acl { acl_ptr }) - } - - unsafe fn as_ptr(&self) -> PACL { - self.acl_ptr - } -} - -impl Drop for Acl { - fn drop(&mut self) { - if !self.acl_ptr.is_null() { - unsafe { LocalFree(self.acl_ptr as *mut _) }; - } - } -} - -struct SecurityDescriptor { - descriptor_ptr: PSECURITY_DESCRIPTOR, -} - -impl SecurityDescriptor { - fn new() -> io::Result { - let descriptor_ptr = unsafe { LocalAlloc(LPTR, SECURITY_DESCRIPTOR_MIN_LENGTH) }; - if descriptor_ptr.is_null() { - return Err(io::Error::new( - io::ErrorKind::Other, - "Failed to allocate security descriptor", - )); - } - - if unsafe { - InitializeSecurityDescriptor(descriptor_ptr, SECURITY_DESCRIPTOR_REVISION) == 0 - } { - return Err(io::Error::last_os_error()); - }; - - Ok(SecurityDescriptor { descriptor_ptr }) - } - - fn set_dacl(&mut self, acl: &Acl) -> io::Result<()> { - if unsafe { - SetSecurityDescriptorDacl(self.descriptor_ptr, true as i32, acl.as_ptr(), false as i32) - == 0 - } { - return Err(io::Error::last_os_error()); - } - Ok(()) - } - - unsafe fn as_ptr(&self) -> PSECURITY_DESCRIPTOR { - self.descriptor_ptr - } -} - -impl Drop for SecurityDescriptor { - fn drop(&mut self) { - if !self.descriptor_ptr.is_null() { - unsafe { LocalFree(self.descriptor_ptr) }; - self.descriptor_ptr = ptr::null_mut(); - } - } -} - -struct InnerAttributes { - descriptor: SecurityDescriptor, - acl: Acl, - attrs: SECURITY_ATTRIBUTES, -} - -impl InnerAttributes { - fn empty() -> io::Result { - let descriptor = SecurityDescriptor::new()?; - let mut attrs = unsafe { mem::zeroed::() }; - attrs.nLength = mem::size_of::() as u32; - attrs.lpSecurityDescriptor = unsafe { descriptor.as_ptr() }; - attrs.bInheritHandle = false as i32; - - let acl = Acl::empty().expect("this should never fail"); - - Ok(InnerAttributes { - acl, - descriptor, - attrs, - }) - } - - fn allow_everyone(permissions: u32) -> io::Result { - let mut attributes = Self::empty()?; - let sid = Sid::everyone_sid()?; - - let mut everyone_ace = AceWithSid::new(&sid, TRUSTEE_IS_WELL_KNOWN_GROUP); - everyone_ace - .set_access_mode(SET_ACCESS) - .set_access_permissions(permissions) - .allow_inheritance(false as u32); - - let mut entries = vec![everyone_ace]; - attributes.acl = Acl::new(&mut entries)?; - attributes.descriptor.set_dacl(&attributes.acl)?; - - Ok(attributes) - } - - unsafe fn as_ptr(&mut self) -> PSECURITY_ATTRIBUTES { - &mut self.attrs as *mut _ - } -} - -#[cfg(test)] -mod test { - use super::SecurityAttributes; - - #[test] - fn test_allow_everyone_everything() { - SecurityAttributes::allow_everyone_create() - .expect("failed to create security attributes that allow everyone to create a pipe"); - } - - #[test] - fn test_allow_eveyone_read_write() { - SecurityAttributes::empty() - .allow_everyone_connect() - .expect("failed to create security attributes that allow everyone to read and write to/from a pipe"); - } -} diff --git a/libs/pulsectl/.gitignore b/libs/pulsectl/.gitignore deleted file mode 100644 index 12dd8a677..000000000 --- a/libs/pulsectl/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -**/target -/target -**/*.rs.bk -.idea/ diff --git a/libs/pulsectl/Cargo.lock b/libs/pulsectl/Cargo.lock deleted file mode 100644 index 4be170015..000000000 --- a/libs/pulsectl/Cargo.lock +++ /dev/null @@ -1,129 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -[[package]] -name = "autocfg" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" - -[[package]] -name = "libc" -version = "0.2.65" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a31a0627fdf1f6a39ec0dd577e101440b7db22672c0901fe00a9a6fbb5c24e8" - -[[package]] -name = "libpulse-binding" -version = "2.18.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe925a4d3a96961316c9c1488f97a95938a6093f0d4691eec888776057ce965e" -dependencies = [ - "libc", - "libpulse-sys", - "num-derive", - "num-traits", - "winapi", -] - -[[package]] -name = "libpulse-sys" -version = "1.15.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d9073c83dda6aff9b611dc368e8db6e0aa29027546d8800a18b4417e182b4d5" -dependencies = [ - "libc", - "num-derive", - "num-traits", - "pkg-config", - "winapi", -] - -[[package]] -name = "num-derive" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "num-traits" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" -dependencies = [ - "autocfg", -] - -[[package]] -name = "pkg-config" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05da548ad6865900e60eaba7f589cc0783590a92e940c26953ff81ddbab2d677" - -[[package]] -name = "proc-macro2" -version = "1.0.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" -dependencies = [ - "unicode-xid", -] - -[[package]] -name = "quote" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "rust-pulsectl" -version = "0.2.9" -dependencies = [ - "libpulse-binding", -] - -[[package]] -name = "syn" -version = "1.0.51" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b4f34193997d92804d359ed09953e25d5138df6bcc055a71bf68ee89fdf9223" -dependencies = [ - "proc-macro2", - "quote", - "unicode-xid", -] - -[[package]] -name = "unicode-xid" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/libs/pulsectl/Cargo.toml b/libs/pulsectl/Cargo.toml deleted file mode 100644 index e309ca81c..000000000 --- a/libs/pulsectl/Cargo.toml +++ /dev/null @@ -1,19 +0,0 @@ -[package] -name = "rust-pulsectl" -version = "0.2.10" -authors = ["Kristopher Ruzic "] -edition = "2018" -license = "GPL-3.0+" -description = "A higher level API for libpulse_binding" -readme = "README.md" -keywords = ["pulse", "pulseaudio", "binding", "audio", "api"] -categories = ["api-bindings", "multimedia::audio"] -homepage = "https://github.com/krruzic/pulsectl" -repository = "https://github.com/krruzic/pulsectl" - -[lib] -name = "pulsectl" -path = "src/lib.rs" - -[dependencies] -libpulse-binding = "2.21" diff --git a/libs/pulsectl/LICENSE.md b/libs/pulsectl/LICENSE.md deleted file mode 100644 index c8a328965..000000000 --- a/libs/pulsectl/LICENSE.md +++ /dev/null @@ -1,13 +0,0 @@ -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . - diff --git a/libs/pulsectl/README.md b/libs/pulsectl/README.md deleted file mode 100644 index ca8703b1e..000000000 --- a/libs/pulsectl/README.md +++ /dev/null @@ -1,43 +0,0 @@ -Rust PulsecAudio API -==================== - -`pulsectl-rust` is a API wrapper for `libpulse_binding` to make pulseaudio application development easier. -This is a wrapper around the introspector, and thus this library is only capable of modifying PulseAudio data (changing volume, routing applications and muting right now). - -### Usage - -Add this to your `Cargo.toml`: -```toml -[dependencies] -rust-pulsectl = "0.2.6" -``` - -Then, connect to PulseAudio by creating a `SinkController` for audio playback devices and apps or a `SourceController` for audio recording devices and apps. - -```rust -// Simple application that lists all playback devices and their status -// See examples/change_device_vol.rs for a more complete example -extern crate pulsectl; - -use std::io; - -use pulsectl::controllers::SinkController; -use pulsectl::controllers::DeviceControl; -fn main() { - // create handler that calls functions on playback devices and apps - let mut handler = SinkController::create(); - let devices = handler - .list_devices() - .expect("Could not get list of playback devices"); - println!("Playback Devices"); - for dev in devices.clone() { - println!( - "[{}] {}, [Volume: {}]", - dev.index, - dev.description.as_ref().unwrap(), - dev.volume.print() - ); - } -} -``` - diff --git a/libs/pulsectl/examples/change_device_vol.rs b/libs/pulsectl/examples/change_device_vol.rs deleted file mode 100644 index 49bb3eac9..000000000 --- a/libs/pulsectl/examples/change_device_vol.rs +++ /dev/null @@ -1,34 +0,0 @@ -extern crate pulsectl; - -use std::io; - -use pulsectl::controllers::DeviceControl; -use pulsectl::controllers::SinkController; - -fn main() { - // create handler that calls functions on playback devices and apps - let mut handler = SinkController::create().unwrap(); - let devices = handler - .list_devices() - .expect("Could not get list of playback devices"); - - println!("Playback Devices"); - for dev in devices.clone() { - println!( - "[{}] {}, [Volume: {}]", - dev.index, - dev.description.as_ref().unwrap(), - dev.volume.print() - ); - } - let mut selection = String::new(); - - io::stdin() - .read_line(&mut selection) - .expect("error: unable to read user input"); - for dev in devices.clone() { - if let true = selection.trim() == dev.index.to_string() { - handler.increase_device_volume_by_percent(dev.index, 0.05); - } - } -} diff --git a/libs/pulsectl/src/controllers/errors.rs b/libs/pulsectl/src/controllers/errors.rs deleted file mode 100644 index f4e50292e..000000000 --- a/libs/pulsectl/src/controllers/errors.rs +++ /dev/null @@ -1,51 +0,0 @@ -use std::fmt; - -use crate::PulseCtlError; - -/// if the error occurs within the Mainloop, we bubble up the error with -/// this conversion -impl From for ControllerError { - fn from(error: super::errors::PulseCtlError) -> Self { - ControllerError { - error: ControllerErrorType::PulseCtlError, - message: format!("{:?}", error), - } - } -} - -impl fmt::Debug for ControllerError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let mut error_string = String::new(); - match self.error { - ControllerErrorType::PulseCtlError => { - error_string.push_str("PulseCtlError"); - } - ControllerErrorType::GetInfoError => { - error_string.push_str("GetInfoError"); - } - } - write!(f, "[{}]: {}", error_string, self.message) - } -} - -pub(crate) enum ControllerErrorType { - PulseCtlError, - GetInfoError, -} - -/// Error thrown while fetching data from pulseaudio, -/// has two variants: PulseCtlError for when PulseAudio returns an error code -/// and GetInfoError when a request for data fails for whatever reason -pub struct ControllerError { - error: ControllerErrorType, - message: String, -} - -impl ControllerError { - pub(crate) fn new(err: ControllerErrorType, msg: &str) -> Self { - ControllerError { - error: err, - message: msg.to_string(), - } - } -} diff --git a/libs/pulsectl/src/controllers/mod.rs b/libs/pulsectl/src/controllers/mod.rs deleted file mode 100644 index 2fb1aa92a..000000000 --- a/libs/pulsectl/src/controllers/mod.rs +++ /dev/null @@ -1,595 +0,0 @@ -/// Source = microphone etc. something that takes in audio -/// Source Output = application consuming that audio -/// -/// Sink = headphones etc. something that plays out audio -/// Sink Input = application producing that audio -/// When you create a `SinkController`, you are working with audio playback devices and applications -/// if you want to manipulate recording devices such as microphone volume, -/// you'll need to use a `SourceController`. Both of these implement the same api, defined by -/// the traits DeviceControl and AppControl -use std::cell::RefCell; -use std::clone::Clone; -use std::rc::Rc; - -use pulse::{ - callbacks::ListResult, - context::introspect, - volume::{ChannelVolumes, Volume}, -}; - -use errors::{ControllerError, ControllerErrorType::*}; -use types::{ApplicationInfo, DeviceInfo, ServerInfo}; - -use crate::Handler; - -pub(crate) mod errors; -pub mod types; - -pub trait DeviceControl { - fn get_default_device(&mut self) -> Result; - fn set_default_device(&mut self, name: &str) -> Result; - - fn list_devices(&mut self) -> Result, ControllerError>; - fn get_device_by_index(&mut self, index: u32) -> Result; - fn get_device_by_name(&mut self, name: &str) -> Result; - fn set_device_volume_by_index(&mut self, index: u32, volume: &ChannelVolumes); - fn set_device_volume_by_name(&mut self, name: &str, volume: &ChannelVolumes); - fn increase_device_volume_by_percent(&mut self, index: u32, delta: f64); - fn decrease_device_volume_by_percent(&mut self, index: u32, delta: f64); -} - -pub trait AppControl { - fn list_applications(&mut self) -> Result, ControllerError>; - - fn get_app_by_index(&mut self, index: u32) -> Result; - fn increase_app_volume_by_percent(&mut self, index: u32, delta: f64); - fn decrease_app_volume_by_percent(&mut self, index: u32, delta: f64); - - fn move_app_by_index( - &mut self, - stream_index: u32, - device_index: u32, - ) -> Result; - fn move_app_by_name( - &mut self, - stream_index: u32, - device_name: &str, - ) -> Result; - fn set_app_mute(&mut self, index: u32, mute: bool) -> Result; -} - -fn volume_from_percent(volume: f64) -> f64 { - (volume * 100.0) * (f64::from(pulse::volume::VOLUME_NORM.0) / 100.0) -} - -pub struct SinkController { - pub handler: Handler, -} - -impl SinkController { - pub fn create() -> Result { - let handler = Handler::connect("SinkController")?; - Ok(SinkController { handler }) - } - - pub fn get_server_info(&mut self) -> Result { - let server = Rc::new(RefCell::new(Some(None))); - let server_ref = server.clone(); - - let op = self.handler.introspect.get_server_info(move |res| { - server_ref - .borrow_mut() - .as_mut() - .unwrap() - .replace(res.into()); - }); - self.handler.wait_for_operation(op)?; - let mut result = server.borrow_mut(); - result.take().unwrap().ok_or(ControllerError::new( - GetInfoError, - "Error getting information about the server", - )) - } -} - -impl DeviceControl for SinkController { - fn get_default_device(&mut self) -> Result { - let server_info = self.get_server_info(); - match server_info { - Ok(info) => self.get_device_by_name(info.default_sink_name.unwrap().as_ref()), - Err(e) => Err(e), - } - } - fn set_default_device(&mut self, name: &str) -> Result { - let success = Rc::new(RefCell::new(false)); - let success_ref = success.clone(); - - let op = self - .handler - .context - .borrow_mut() - .set_default_sink(name, move |res| success_ref.borrow_mut().clone_from(&res)); - self.handler.wait_for_operation(op)?; - let result = success.borrow_mut().clone(); - Ok(result) - } - - fn list_devices(&mut self) -> Result, ControllerError> { - let list = Rc::new(RefCell::new(Some(Vec::new()))); - let list_ref = list.clone(); - - let op = self.handler.introspect.get_sink_info_list( - move |sink_list: ListResult<&introspect::SinkInfo>| { - if let ListResult::Item(item) = sink_list { - list_ref.borrow_mut().as_mut().unwrap().push(item.into()); - } - }, - ); - self.handler.wait_for_operation(op)?; - let mut result = list.borrow_mut(); - result.take().ok_or(ControllerError::new( - GetInfoError, - "Error getting device list", - )) - } - fn get_device_by_index(&mut self, index: u32) -> Result { - let device = Rc::new(RefCell::new(Some(None))); - let dev_ref = device.clone(); - let op = self.handler.introspect.get_sink_info_by_index( - index, - move |sink_list: ListResult<&introspect::SinkInfo>| { - if let ListResult::Item(item) = sink_list { - dev_ref.borrow_mut().as_mut().unwrap().replace(item.into()); - } - }, - ); - self.handler.wait_for_operation(op)?; - let mut result = device.borrow_mut(); - result.take().unwrap().ok_or(ControllerError::new( - GetInfoError, - "Error getting requested device", - )) - } - fn get_device_by_name(&mut self, name: &str) -> Result { - let device = Rc::new(RefCell::new(Some(None))); - let dev_ref = device.clone(); - let op = self.handler.introspect.get_sink_info_by_name( - name, - move |sink_list: ListResult<&introspect::SinkInfo>| { - if let ListResult::Item(item) = sink_list { - dev_ref.borrow_mut().as_mut().unwrap().replace(item.into()); - } - }, - ); - self.handler.wait_for_operation(op)?; - let mut result = device.borrow_mut(); - result.take().unwrap().ok_or(ControllerError::new( - GetInfoError, - "Error getting requested device", - )) - } - - fn set_device_volume_by_index(&mut self, index: u32, volume: &ChannelVolumes) { - let op = self - .handler - .introspect - .set_sink_volume_by_index(index, volume, None); - self.handler.wait_for_operation(op).ok(); - } - fn set_device_volume_by_name(&mut self, name: &str, volume: &ChannelVolumes) { - let op = self - .handler - .introspect - .set_sink_volume_by_name(name, volume, None); - self.handler.wait_for_operation(op).ok(); - } - fn increase_device_volume_by_percent(&mut self, index: u32, delta: f64) { - if let Ok(mut dev_ref) = self.get_device_by_index(index) { - let new_vol = Volume::from(Volume(volume_from_percent(delta) as u32)); - if let Some(volumes) = dev_ref.volume.increase(new_vol) { - let op = self - .handler - .introspect - .set_sink_volume_by_index(index, &volumes, None); - self.handler.wait_for_operation(op).ok(); - } - } - } - fn decrease_device_volume_by_percent(&mut self, index: u32, delta: f64) { - if let Ok(mut dev_ref) = self.get_device_by_index(index) { - let new_vol = Volume::from(Volume(volume_from_percent(delta) as u32)); - if let Some(volumes) = dev_ref.volume.decrease(new_vol) { - let op = self - .handler - .introspect - .set_sink_volume_by_index(index, &volumes, None); - self.handler.wait_for_operation(op).ok(); - } - } - } -} - -impl AppControl for SinkController { - fn list_applications(&mut self) -> Result, ControllerError> { - let list = Rc::new(RefCell::new(Some(Vec::new()))); - let list_ref = list.clone(); - - let op = self.handler.introspect.get_sink_input_info_list( - move |sink_list: ListResult<&introspect::SinkInputInfo>| { - if let ListResult::Item(item) = sink_list { - list_ref.borrow_mut().as_mut().unwrap().push(item.into()); - } - }, - ); - self.handler.wait_for_operation(op)?; - let mut result = list.borrow_mut(); - result.take().ok_or(ControllerError::new( - GetInfoError, - "Error getting application list", - )) - } - - fn get_app_by_index(&mut self, index: u32) -> Result { - let app = Rc::new(RefCell::new(Some(None))); - let app_ref = app.clone(); - let op = self.handler.introspect.get_sink_input_info( - index, - move |sink_list: ListResult<&introspect::SinkInputInfo>| { - if let ListResult::Item(item) = sink_list { - app_ref.borrow_mut().as_mut().unwrap().replace(item.into()); - } - }, - ); - self.handler.wait_for_operation(op)?; - let mut result = app.borrow_mut(); - result.take().unwrap().ok_or(ControllerError::new( - GetInfoError, - "Error getting requested app", - )) - } - - fn increase_app_volume_by_percent(&mut self, index: u32, delta: f64) { - if let Ok(mut app_ref) = self.get_app_by_index(index) { - let new_vol = Volume::from(Volume(volume_from_percent(delta) as u32)); - if let Some(volumes) = app_ref.volume.increase(new_vol) { - let op = self - .handler - .introspect - .set_sink_input_volume(index, &volumes, None); - self.handler.wait_for_operation(op).ok(); - } - } - } - - fn decrease_app_volume_by_percent(&mut self, index: u32, delta: f64) { - if let Ok(mut app_ref) = self.get_app_by_index(index) { - let new_vol = Volume::from(Volume(volume_from_percent(delta) as u32)); - if let Some(volumes) = app_ref.volume.decrease(new_vol) { - let op = self - .handler - .introspect - .set_sink_input_volume(index, &volumes, None); - self.handler.wait_for_operation(op).ok(); - } - } - } - - fn move_app_by_index( - &mut self, - stream_index: u32, - device_index: u32, - ) -> Result { - let success = Rc::new(RefCell::new(false)); - let success_ref = success.clone(); - let op = self.handler.introspect.move_sink_input_by_index( - stream_index, - device_index, - Some(Box::new(move |res| { - success_ref.borrow_mut().clone_from(&res) - })), - ); - self.handler.wait_for_operation(op)?; - let result = success.borrow_mut().clone(); - Ok(result) - } - - fn move_app_by_name( - &mut self, - stream_index: u32, - device_name: &str, - ) -> Result { - let success = Rc::new(RefCell::new(false)); - let success_ref = success.clone(); - let op = self.handler.introspect.move_sink_input_by_name( - stream_index, - device_name, - Some(Box::new(move |res| { - success_ref.borrow_mut().clone_from(&res) - })), - ); - self.handler.wait_for_operation(op)?; - let result = success.borrow_mut().clone(); - Ok(result) - } - - fn set_app_mute(&mut self, index: u32, mute: bool) -> Result { - let success = Rc::new(RefCell::new(false)); - let success_ref = success.clone(); - let op = self.handler.introspect.set_sink_input_mute( - index, - mute, - Some(Box::new(move |res| { - success_ref.borrow_mut().clone_from(&res) - })), - ); - self.handler.wait_for_operation(op)?; - let result = success.borrow_mut().clone(); - Ok(result) - } -} - -pub struct SourceController { - pub handler: Handler, -} - -impl SourceController { - pub fn create() -> Result { - let handler = Handler::connect("SourceController")?; - Ok(SourceController { handler }) - } - - pub fn get_server_info(&mut self) -> Result { - let server = Rc::new(RefCell::new(Some(None))); - let server_ref = server.clone(); - - let op = self.handler.introspect.get_server_info(move |res| { - server_ref - .borrow_mut() - .as_mut() - .unwrap() - .replace(res.into()); - }); - self.handler.wait_for_operation(op)?; - let mut result = server.borrow_mut(); - result.take().unwrap().ok_or(ControllerError::new( - GetInfoError, - "Error getting application list", - )) - } -} - -impl DeviceControl for SourceController { - fn get_default_device(&mut self) -> Result { - let server_info = self.get_server_info(); - match server_info { - Ok(info) => self.get_device_by_name(info.default_sink_name.unwrap().as_ref()), - Err(e) => Err(e), - } - } - fn set_default_device(&mut self, name: &str) -> Result { - let success = Rc::new(RefCell::new(false)); - let success_ref = success.clone(); - - let op = self - .handler - .context - .borrow_mut() - .set_default_source(name, move |res| success_ref.borrow_mut().clone_from(&res)); - self.handler.wait_for_operation(op)?; - let result = success.borrow_mut().clone(); - Ok(result) - } - - fn list_devices(&mut self) -> Result, ControllerError> { - let list = Rc::new(RefCell::new(Some(Vec::new()))); - let list_ref = list.clone(); - - let op = self.handler.introspect.get_source_info_list( - move |sink_list: ListResult<&introspect::SourceInfo>| { - if let ListResult::Item(item) = sink_list { - list_ref.borrow_mut().as_mut().unwrap().push(item.into()); - } - }, - ); - self.handler.wait_for_operation(op)?; - let mut result = list.borrow_mut(); - result.take().ok_or(ControllerError::new( - GetInfoError, - "Error getting application list", - )) - } - fn get_device_by_index(&mut self, index: u32) -> Result { - let device = Rc::new(RefCell::new(Some(None))); - let dev_ref = device.clone(); - let op = self.handler.introspect.get_source_info_by_index( - index, - move |sink_list: ListResult<&introspect::SourceInfo>| { - if let ListResult::Item(item) = sink_list { - dev_ref.borrow_mut().as_mut().unwrap().replace(item.into()); - } - }, - ); - self.handler.wait_for_operation(op)?; - let mut result = device.borrow_mut(); - result.take().unwrap().ok_or(ControllerError::new( - GetInfoError, - "Error getting application list", - )) - } - fn get_device_by_name(&mut self, name: &str) -> Result { - let device = Rc::new(RefCell::new(Some(None))); - let dev_ref = device.clone(); - let op = self.handler.introspect.get_source_info_by_name( - name, - move |sink_list: ListResult<&introspect::SourceInfo>| { - if let ListResult::Item(item) = sink_list { - dev_ref.borrow_mut().as_mut().unwrap().replace(item.into()); - } - }, - ); - self.handler.wait_for_operation(op)?; - let mut result = device.borrow_mut(); - result.take().unwrap().ok_or(ControllerError::new( - GetInfoError, - "Error getting application list", - )) - } - - fn set_device_volume_by_index(&mut self, index: u32, volume: &ChannelVolumes) { - let op = self - .handler - .introspect - .set_source_volume_by_index(index, volume, None); - self.handler.wait_for_operation(op).ok(); - } - fn set_device_volume_by_name(&mut self, name: &str, volume: &ChannelVolumes) { - let op = self - .handler - .introspect - .set_source_volume_by_name(name, volume, None); - self.handler.wait_for_operation(op).ok(); - } - fn increase_device_volume_by_percent(&mut self, index: u32, delta: f64) { - if let Ok(mut dev_ref) = self.get_device_by_index(index) { - let new_vol = Volume::from(Volume(volume_from_percent(delta) as u32)); - if let Some(volumes) = dev_ref.volume.increase(new_vol) { - let op = self - .handler - .introspect - .set_source_volume_by_index(index, &volumes, None); - self.handler.wait_for_operation(op).ok(); - } - } - } - fn decrease_device_volume_by_percent(&mut self, index: u32, delta: f64) { - if let Ok(mut dev_ref) = self.get_device_by_index(index) { - let new_vol = Volume::from(Volume(volume_from_percent(delta) as u32)); - if let Some(volumes) = dev_ref.volume.decrease(new_vol) { - let op = self - .handler - .introspect - .set_source_volume_by_index(index, &volumes, None); - self.handler.wait_for_operation(op).ok(); - } - } - } -} - -impl AppControl for SourceController { - fn list_applications(&mut self) -> Result, ControllerError> { - let list = Rc::new(RefCell::new(Some(Vec::new()))); - let list_ref = list.clone(); - - let op = self.handler.introspect.get_source_output_info_list( - move |sink_list: ListResult<&introspect::SourceOutputInfo>| { - if let ListResult::Item(item) = sink_list { - list_ref.borrow_mut().as_mut().unwrap().push(item.into()); - } - }, - ); - self.handler.wait_for_operation(op)?; - let mut result = list.borrow_mut(); - result.take().ok_or(ControllerError::new( - GetInfoError, - "Error getting application list", - )) - } - - fn get_app_by_index(&mut self, index: u32) -> Result { - let app = Rc::new(RefCell::new(Some(None))); - let app_ref = app.clone(); - let op = self.handler.introspect.get_source_output_info( - index, - move |sink_list: ListResult<&introspect::SourceOutputInfo>| { - if let ListResult::Item(item) = sink_list { - app_ref.borrow_mut().as_mut().unwrap().replace(item.into()); - } - }, - ); - self.handler.wait_for_operation(op)?; - let mut result = app.borrow_mut(); - result.take().unwrap().ok_or(ControllerError::new( - GetInfoError, - "Error getting application list", - )) - } - - fn increase_app_volume_by_percent(&mut self, index: u32, delta: f64) { - if let Ok(mut app_ref) = self.get_app_by_index(index) { - let new_vol = Volume::from(Volume(volume_from_percent(delta) as u32)); - if let Some(volumes) = app_ref.volume.increase(new_vol) { - let op = self - .handler - .introspect - .set_source_output_volume(index, &volumes, None); - self.handler.wait_for_operation(op).ok(); - } - } - } - - fn decrease_app_volume_by_percent(&mut self, index: u32, delta: f64) { - if let Ok(mut app_ref) = self.get_app_by_index(index) { - let new_vol = Volume::from(Volume(volume_from_percent(delta) as u32)); - if let Some(volumes) = app_ref.volume.decrease(new_vol) { - let op = self - .handler - .introspect - .set_source_output_volume(index, &volumes, None); - self.handler.wait_for_operation(op).ok(); - } - } - } - - fn move_app_by_index( - &mut self, - stream_index: u32, - device_index: u32, - ) -> Result { - let success = Rc::new(RefCell::new(false)); - let success_ref = success.clone(); - let op = self.handler.introspect.move_source_output_by_index( - stream_index, - device_index, - Some(Box::new(move |res| { - success_ref.borrow_mut().clone_from(&res) - })), - ); - self.handler.wait_for_operation(op)?; - let result = success.borrow_mut().clone(); - Ok(result) - } - - fn move_app_by_name( - &mut self, - stream_index: u32, - device_name: &str, - ) -> Result { - let success = Rc::new(RefCell::new(false)); - let success_ref = success.clone(); - let op = self.handler.introspect.move_source_output_by_name( - stream_index, - device_name, - Some(Box::new(move |res| { - success_ref.borrow_mut().clone_from(&res) - })), - ); - self.handler.wait_for_operation(op)?; - let result = success.borrow_mut().clone(); - Ok(result) - } - - fn set_app_mute(&mut self, index: u32, mute: bool) -> Result { - let success = Rc::new(RefCell::new(false)); - let success_ref = success.clone(); - let op = self.handler.introspect.set_source_mute_by_index( - index, - mute, - Some(Box::new(move |res| { - success_ref.borrow_mut().clone_from(&res) - })), - ); - self.handler.wait_for_operation(op)?; - let result = success.borrow_mut().clone(); - Ok(result) - } -} diff --git a/libs/pulsectl/src/controllers/types.rs b/libs/pulsectl/src/controllers/types.rs deleted file mode 100644 index c61ad2f44..000000000 --- a/libs/pulsectl/src/controllers/types.rs +++ /dev/null @@ -1,354 +0,0 @@ -use pulse::{ - channelmap, - context::introspect, - def, - def::PortAvailable, - format, - proplist::Proplist, - sample, - time::MicroSeconds, - volume::{ChannelVolumes, Volume}, -}; - -/// These structs are direct representations of what libpulse_binding gives -/// created to be copyable / cloneable for use in and out of callbacks - -/// This is a wrapper around SinkPortInfo and SourcePortInfo as they have the same members -#[derive(Clone)] -pub struct DevicePortInfo { - /// Name of the sink. - pub name: Option, - /// Description of this sink. - pub description: Option, - /// The higher this value is, the more useful this port is as a default. - pub priority: u32, - /// A flag indicating availability status of this port. - pub available: PortAvailable, -} - -impl<'a> From<&'a Box>> for DevicePortInfo { - fn from(item: &'a Box>) -> Self { - DevicePortInfo { - name: item.name.as_ref().map(|cow| cow.to_string()), - description: item.description.as_ref().map(|cow| cow.to_string()), - priority: item.priority, - available: item.available, - } - } -} - -impl<'a> From<&'a introspect::SinkPortInfo<'a>> for DevicePortInfo { - fn from(item: &'a introspect::SinkPortInfo<'a>) -> Self { - DevicePortInfo { - name: item.name.as_ref().map(|cow| cow.to_string()), - description: item.description.as_ref().map(|cow| cow.to_string()), - priority: item.priority, - available: item.available, - } - } -} - -impl<'a> From<&'a Box>> for DevicePortInfo { - fn from(item: &'a Box>) -> Self { - DevicePortInfo { - name: item.name.as_ref().map(|cow| cow.to_string()), - description: item.description.as_ref().map(|cow| cow.to_string()), - priority: item.priority, - available: item.available, - } - } -} - -impl<'a> From<&'a introspect::SourcePortInfo<'a>> for DevicePortInfo { - fn from(item: &'a introspect::SourcePortInfo<'a>) -> Self { - DevicePortInfo { - name: item.name.as_ref().map(|cow| cow.to_string()), - description: item.description.as_ref().map(|cow| cow.to_string()), - priority: item.priority, - available: item.available, - } - } -} - -/// This is a wrapper around SinkState and SourceState as they have the same values -#[derive(Debug, Copy, Clone, PartialEq, Eq)] -pub enum DevState { - /// This state is used when the server does not support sink state introspection. - Invalid = -1, - /// Running, sink is playing and used by at least one non-corked sink-input. - Running = 0, - /// When idle, the sink is playing but there is no non-corked sink-input attached to it. - Idle = 1, - /// When suspended, actual sink access can be closed, for instance. - Suspended = 2, -} - -impl<'a> From for DevState { - fn from(s: def::SourceState) -> Self { - match s { - def::SourceState::Idle => DevState::Idle, - def::SourceState::Invalid => DevState::Invalid, - def::SourceState::Running => DevState::Running, - def::SourceState::Suspended => DevState::Suspended, - } - } -} - -impl<'a> From for DevState { - fn from(s: def::SinkState) -> Self { - match s { - def::SinkState::Idle => DevState::Idle, - def::SinkState::Invalid => DevState::Invalid, - def::SinkState::Running => DevState::Running, - def::SinkState::Suspended => DevState::Suspended, - } - } -} - -#[derive(Clone)] -pub enum Flags { - SourceFLags(def::SourceFlagSet), - SinkFlags(def::SinkFlagSet), -} - -#[derive(Clone)] -pub struct DeviceInfo { - /// Index of the sink. - pub index: u32, - /// Name of the sink. - pub name: Option, - /// Description of this sink. - pub description: Option, - /// Sample spec of this sink. - pub sample_spec: sample::Spec, - /// Channel map. - pub channel_map: channelmap::Map, - /// Index of the owning module of this sink, or `None` if is invalid. - pub owner_module: Option, - /// Volume of the sink. - pub volume: ChannelVolumes, - /// Mute switch of the sink. - pub mute: bool, - /// Index of the monitor source connected to this sink. - pub monitor: Option, - /// The name of the monitor source. - pub monitor_name: Option, - /// Length of queued audio in the output buffer. - pub latency: MicroSeconds, - /// Driver name. - pub driver: Option, - /// Flags. - pub flags: Flags, - /// Property list. - pub proplist: Proplist, - /// The latency this device has been configured to. - pub configured_latency: MicroSeconds, - /// Some kind of “base” volume that refers to unamplified/unattenuated volume in the context of - /// the output device. - pub base_volume: Volume, - /// State. - pub state: DevState, - /// Number of volume steps for sinks which do not support arbitrary volumes. - pub n_volume_steps: u32, - /// Card index, or `None` if invalid. - pub card: Option, - /// Set of available ports. - pub ports: Vec, - // Pointer to active port in the set, or None. - pub active_port: Option, - /// Set of formats supported by the sink. - pub formats: Vec, -} - -impl<'a> From<&'a introspect::SinkInfo<'a>> for DeviceInfo { - fn from(item: &'a introspect::SinkInfo<'a>) -> Self { - DeviceInfo { - name: item.name.as_ref().map(|cow| cow.to_string()), - index: item.index, - description: item.description.as_ref().map(|cow| cow.to_string()), - sample_spec: item.sample_spec, - channel_map: item.channel_map, - owner_module: item.owner_module, - volume: item.volume, - mute: item.mute, - monitor: Some(item.monitor_source), - monitor_name: item.monitor_source_name.as_ref().map(|cow| cow.to_string()), - latency: item.latency, - driver: item.driver.as_ref().map(|cow| cow.to_string()), - flags: Flags::SinkFlags(item.flags), - proplist: item.proplist.clone(), - configured_latency: item.configured_latency, - base_volume: item.base_volume, - state: DevState::from(item.state), - n_volume_steps: item.n_volume_steps, - card: item.card, - ports: item.ports.iter().map(From::from).collect(), - active_port: item.active_port.as_ref().map(From::from), - formats: item.formats.clone(), - } - } -} - -impl<'a> From<&'a introspect::SourceInfo<'a>> for DeviceInfo { - fn from(item: &'a introspect::SourceInfo<'a>) -> Self { - DeviceInfo { - name: item.name.as_ref().map(|cow| cow.to_string()), - index: item.index, - description: item.description.as_ref().map(|cow| cow.to_string()), - sample_spec: item.sample_spec, - channel_map: item.channel_map, - owner_module: item.owner_module, - volume: item.volume, - mute: item.mute, - monitor: item.monitor_of_sink, - monitor_name: item - .monitor_of_sink_name - .as_ref() - .map(|cow| cow.to_string()), - latency: item.latency, - driver: item.driver.as_ref().map(|cow| cow.to_string()), - flags: Flags::SourceFLags(item.flags), - proplist: item.proplist.clone(), - configured_latency: item.configured_latency, - base_volume: item.base_volume, - state: DevState::from(item.state), - n_volume_steps: item.n_volume_steps, - card: item.card, - ports: item.ports.iter().map(From::from).collect(), - active_port: item.active_port.as_ref().map(From::from), - formats: item.formats.clone(), - } - } -} - -#[derive(Clone)] -pub struct ApplicationInfo { - /// Index of the sink input. - pub index: u32, - /// Name of the sink input. - pub name: Option, - /// Index of the module this sink input belongs to, or `None` when it does not belong to any - /// module. - pub owner_module: Option, - /// Index of the client this sink input belongs to, or invalid when it does not belong to any - /// client. - pub client: Option, - /// Index of the connected sink/source. - pub connection_id: u32, - /// The sample specification of the sink input. - pub sample_spec: sample::Spec, - /// Channel map. - pub channel_map: channelmap::Map, - /// The volume of this sink input. - pub volume: ChannelVolumes, - /// Latency due to buffering in sink input, see - /// [`def::TimingInfo`](../../def/struct.TimingInfo.html) for details. - pub buffer_usec: MicroSeconds, - /// Latency of the sink device, see - /// [`def::TimingInfo`](../../def/struct.TimingInfo.html) for details. - pub connection_usec: MicroSeconds, - /// The resampling method used by this sink input. - pub resample_method: Option, - /// Driver name. - pub driver: Option, - /// Stream muted. - pub mute: bool, - /// Property list. - pub proplist: Proplist, - /// Stream corked. - pub corked: bool, - /// Stream has volume. If not set, then the meaning of this struct’s volume member is unspecified. - pub has_volume: bool, - /// The volume can be set. If not set, the volume can still change even though clients can’t - /// control the volume. - pub volume_writable: bool, - /// Stream format information. - pub format: format::Info, -} - -impl<'a> From<&'a introspect::SinkInputInfo<'a>> for ApplicationInfo { - fn from(item: &'a introspect::SinkInputInfo<'a>) -> Self { - ApplicationInfo { - index: item.index, - name: item.name.as_ref().map(|cow| cow.to_string()), - owner_module: item.owner_module, - client: item.client, - connection_id: item.sink, - sample_spec: item.sample_spec, - channel_map: item.channel_map, - volume: item.volume, - buffer_usec: item.buffer_usec, - connection_usec: item.sink_usec, - resample_method: item.resample_method.as_ref().map(|cow| cow.to_string()), - driver: item.driver.as_ref().map(|cow| cow.to_string()), - mute: item.mute, - proplist: item.proplist.clone(), - corked: item.corked, - has_volume: item.has_volume, - volume_writable: item.volume_writable, - format: item.format.clone(), - } - } -} - -impl<'a> From<&'a introspect::SourceOutputInfo<'a>> for ApplicationInfo { - fn from(item: &'a introspect::SourceOutputInfo<'a>) -> Self { - ApplicationInfo { - index: item.index, - name: item.name.as_ref().map(|cow| cow.to_string()), - owner_module: item.owner_module, - client: item.client, - connection_id: item.source, - sample_spec: item.sample_spec, - channel_map: item.channel_map, - volume: item.volume, - buffer_usec: item.buffer_usec, - connection_usec: item.source_usec, - resample_method: item.resample_method.as_ref().map(|cow| cow.to_string()), - driver: item.driver.as_ref().map(|cow| cow.to_string()), - mute: item.mute, - proplist: item.proplist.clone(), - corked: item.corked, - has_volume: item.has_volume, - volume_writable: item.volume_writable, - format: item.format.clone(), - } - } -} - -pub struct ServerInfo { - /// User name of the daemon process. - pub user_name: Option, - /// Host name the daemon is running on. - pub host_name: Option, - /// Version string of the daemon. - pub server_version: Option, - /// Server package name (usually “pulseaudio”). - pub server_name: Option, - /// Default sample specification. - pub sample_spec: sample::Spec, - /// Name of default sink. - pub default_sink_name: Option, - /// Name of default source. - pub default_source_name: Option, - /// A random cookie for identifying this instance of PulseAudio. - pub cookie: u32, - /// Default channel map. - pub channel_map: channelmap::Map, -} - -impl<'a> From<&'a introspect::ServerInfo<'a>> for ServerInfo { - fn from(info: &'a introspect::ServerInfo<'a>) -> Self { - ServerInfo { - user_name: info.user_name.as_ref().map(|cow| cow.to_string()), - host_name: info.host_name.as_ref().map(|cow| cow.to_string()), - server_version: info.server_version.as_ref().map(|cow| cow.to_string()), - server_name: info.server_name.as_ref().map(|cow| cow.to_string()), - sample_spec: info.sample_spec, - default_sink_name: info.default_sink_name.as_ref().map(|cow| cow.to_string()), - default_source_name: info.default_source_name.as_ref().map(|cow| cow.to_string()), - cookie: info.cookie, - channel_map: info.channel_map, - } - } -} diff --git a/libs/pulsectl/src/errors.rs b/libs/pulsectl/src/errors.rs deleted file mode 100644 index b75a8f533..000000000 --- a/libs/pulsectl/src/errors.rs +++ /dev/null @@ -1,54 +0,0 @@ -use std::fmt; - -use pulse::error::{PAErr}; - -impl From for PulseCtlError { - fn from(error: PAErr) -> Self { - PulseCtlError { - error: PulseCtlErrorType::PulseAudioError, - message: format!("PulseAudio returned error: {}", error.to_string().unwrap_or("Unknown".to_owned())), - } - } -} - -impl fmt::Debug for PulseCtlError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let mut error_string = String::new(); - match self.error { - PulseCtlErrorType::ConnectError => { - error_string.push_str("ConnectError"); - } - PulseCtlErrorType::OperationError => { - error_string.push_str("OperationError"); - } - PulseCtlErrorType::PulseAudioError => { - error_string.push_str("PulseAudioError"); - } - } - write!(f, "[{}]: {}", error_string, self.message) - } -} - -pub(crate) enum PulseCtlErrorType { - ConnectError, - OperationError, - PulseAudioError, -} - -/// Error thrown when PulseAudio throws an error code, there are 3 variants -/// `PulseCtlErrorType::ConnectError` when there's an error establishing a connection -/// `PulseCtlErrorType::OperationError` when the requested operation quis unexpecdatly or is cancelled -/// `PulseCtlErrorType::PulseAudioError` when PulseAudio returns an error code in any circumstance -pub struct PulseCtlError { - error: PulseCtlErrorType, - message: String, -} - -impl PulseCtlError { - pub(crate) fn new(err: PulseCtlErrorType, msg: &str) -> Self { - PulseCtlError { - error: err, - message: msg.to_string(), - } - } -} diff --git a/libs/pulsectl/src/lib.rs b/libs/pulsectl/src/lib.rs deleted file mode 100644 index 073902fd9..000000000 --- a/libs/pulsectl/src/lib.rs +++ /dev/null @@ -1,166 +0,0 @@ -/// `pulsectl` is a high level wrapper around the PulseAudio bindings supplied by -/// `libpulse_binding`. It provides simple access to sinks, inputs, sources and outputs allowing -/// one to write audio control programs with ease. -/// -/// ## Quick Example -/// -/// The following example demonstrates listing all of the playback devices currently connected -/// -/// See examples/change_device_vol.rs for a more complete example -/// ```no_run -/// extern crate pulsectl; -/// -/// use std::io; -/// -/// use pulsectl::controllers::SinkController; -/// use pulsectl::controllers::DeviceControl; -/// fn main() { -/// // create handler that calls functions on playback devices and apps -/// let mut handler = SinkController::create().unwrap(); -/// let devices = handler -/// .list_devices() -/// .expect("Could not get list of playback devices"); -/// -/// println!("Playback Devices"); -/// for dev in devices.clone() { -/// println!( -/// "[{}] {}, Volume: {}", -/// dev.index, -/// dev.description.as_ref().unwrap(), -/// dev.volume.print() -/// ); -/// } -/// } -/// ``` -extern crate libpulse_binding as pulse; - -use std::cell::RefCell; -use std::ops::Deref; -use std::rc::Rc; - -use pulse::{ - context::{introspect, Context}, - mainloop::standard::{IterateResult, Mainloop}, - operation::{Operation, State}, - proplist::Proplist, -}; - -use crate::errors::{PulseCtlError, PulseCtlErrorType::*}; - -pub mod controllers; -mod errors; - -pub struct Handler { - pub mainloop: Rc>, - pub context: Rc>, - pub introspect: introspect::Introspector, -} - -fn connect_error(err: &str) -> PulseCtlError { - PulseCtlError::new(ConnectError, err) -} - -impl Handler { - pub fn connect(name: &str) -> Result { - let mut proplist = Proplist::new().unwrap(); - proplist - .set_str(pulse::proplist::properties::APPLICATION_NAME, name) - .unwrap(); - - let mainloop; - if let Some(m) = Mainloop::new() { - mainloop = Rc::new(RefCell::new(m)); - } else { - return Err(connect_error("Failed to create mainloop")); - } - - let context; - if let Some(c) = - Context::new_with_proplist(mainloop.borrow().deref(), "MainConn", &proplist) - { - context = Rc::new(RefCell::new(c)); - } else { - return Err(connect_error("Failed to create new context")); - } - - context - .borrow_mut() - .connect(None, pulse::context::flags::NOFLAGS, None) - .map_err(|_| connect_error("Failed to connect context"))?; - - loop { - match mainloop.borrow_mut().iterate(false) { - IterateResult::Err(e) => { - eprintln!("iterate state was not success, quitting..."); - return Err(e.into()); - } - IterateResult::Success(_) => {} - IterateResult::Quit(_) => { - eprintln!("iterate state was not success, quitting..."); - return Err(PulseCtlError::new( - ConnectError, - "Iterate state quit without an error", - )); - } - } - - match context.borrow().get_state() { - pulse::context::State::Ready => break, - pulse::context::State::Failed | pulse::context::State::Terminated => { - eprintln!("context state failed/terminated, quitting..."); - return Err(PulseCtlError::new( - ConnectError, - "Context state failed/terminated without an error", - )); - } - _ => {} - } - } - - let introspect = context.borrow_mut().introspect(); - Ok(Handler { - mainloop, - context, - introspect, - }) - } - - // loop until the passed operation is completed - pub fn wait_for_operation( - &mut self, - op: Operation, - ) -> Result<(), errors::PulseCtlError> { - loop { - match self.mainloop.borrow_mut().iterate(false) { - IterateResult::Err(e) => return Err(e.into()), - IterateResult::Success(_) => {} - IterateResult::Quit(_) => { - return Err(PulseCtlError::new( - OperationError, - "Iterate state quit without an error", - )); - } - } - match op.get_state() { - State::Done => { - break; - } - State::Running => {} - State::Cancelled => { - return Err(PulseCtlError::new( - OperationError, - "Operation cancelled without an error", - )); - } - } - } - Ok(()) - } -} - -impl Drop for Handler { - fn drop(&mut self) { - self.context.borrow_mut().disconnect(); - self.mainloop.borrow_mut().quit(pulse::def::Retval(0)); - } -} diff --git a/libs/rust-sciter/.appveyor.yml b/libs/rust-sciter/.appveyor.yml deleted file mode 100644 index 151f37d83..000000000 --- a/libs/rust-sciter/.appveyor.yml +++ /dev/null @@ -1,98 +0,0 @@ -version: 0.5.0.{build} - -branches: - only: - - master - - travis - -image: - - Visual Studio 2017 - -environment: - matrix: - - TARGET: x86_64-pc-windows-msvc - CHANNEL: stable - ARCH: 64 - - - TARGET: i686-pc-windows-msvc - CHANNEL: stable - ARCH: 32 - - - TARGET: x86_64-pc-windows-msvc - CHANNEL: stable - ARCH: 64skia - - - TARGET: i686-pc-windows-msvc - CHANNEL: stable - ARCH: 32skia - - - TARGET: x86_64-pc-windows-msvc - CHANNEL: stable - ARCH: 64 - FEATURES: --features "dynamic" - - - TARGET: i686-pc-windows-msvc - CHANNEL: stable - ARCH: 32 - FEATURES: --features "dynamic" - - - TARGET: x86_64-pc-windows-msvc - CHANNEL: nightly - ARCH: 64 - - - TARGET: i686-pc-windows-msvc - CHANNEL: nightly - ARCH: 32 - - - TARGET: x86_64-pc-windows-msvc - CHANNEL: 1.38.0 - ARCH: 64 - - - TARGET: i686-pc-windows-msvc - CHANNEL: 1.38.0 - ARCH: 32 - - - TARGET: x86_64-pc-windows-msvc - CHANNEL: 1.38.0 - ARCH: 64 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 - - -cache: - - C:\Users\appveyor\.cargo\registry - #- C:\projects\deps -> appveyor.yml - #- target - -install: - - cmd: echo Testing sciter%ARCH% with Rust %CHANNEL%. - - cmd: echo Current directory is %APPVEYOR_BUILD_FOLDER% - - cmd: mkdir ..\deps - - curl -sSLo "..\deps\sciter.dll" "https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.win/x%ARCH%/sciter.dll" - - curl -sSLo "..\deps\rustup-init.exe" "https://win.rustup.rs/" - - ..\deps\rustup-init.exe -y --default-host %TARGET% --default-toolchain %CHANNEL% - - cmd: set PATH=%PATH%;C:\Users\appveyor\.cargo\bin;C:\projects\deps - -before_build: - - cmd: cd - - rustc --version - - cargo update - -build_script: - - cmd: echo Building library - - cargo build --release --all %FEATURES% - - - cmd: echo Building examples - - cargo build --example first --verbose - - cargo build --example windowless --features windowless - - cargo build --release --examples %FEATURES% - -test_script: - - cargo run --example first %FEATURES% - - cargo run --example first %FEATURES% - - cargo run --example first %FEATURES% -- C:/projects/deps/sciter.dll - - - cargo test -p sciter-rs %FEATURES% - - cargo test -p sciter-rs %FEATURES% --release - - - cargo test -p sciter-serde %FEATURES% - - cargo test -p sciter-serde %FEATURES% --release diff --git a/libs/rust-sciter/.clippy.toml b/libs/rust-sciter/.clippy.toml deleted file mode 100644 index 9f92aa166..000000000 --- a/libs/rust-sciter/.clippy.toml +++ /dev/null @@ -1 +0,0 @@ -doc-valid-idents = ["TIScript"] diff --git a/libs/rust-sciter/.editorconfig b/libs/rust-sciter/.editorconfig deleted file mode 100644 index 45e1f5cc6..000000000 --- a/libs/rust-sciter/.editorconfig +++ /dev/null @@ -1,20 +0,0 @@ -# EditorConfig is awesome: http://EditorConfig.org - -[*] -charset = utf-8 -end_of_line = lf -insert_final_newline = true -trim_trailing_whitespace = true - -[*.rs] -indent_style = tab -indent_size = 2 -tab_width = 2 - -[*.{yml,toml,md}] -indent_style = space -indent_size = 2 -tab_width = 2 - -[*.md] -trim_trailing_whitespace = false diff --git a/libs/rust-sciter/.github/workflows/cargo.yml b/libs/rust-sciter/.github/workflows/cargo.yml deleted file mode 100644 index 00ac30dca..000000000 --- a/libs/rust-sciter/.github/workflows/cargo.yml +++ /dev/null @@ -1,115 +0,0 @@ -name: Build-n-Test - -on: - push: - branches: - - master - - travis - - pull_request: - branches: - - master - -# Look: -# https://github.com/actions/starter-workflows/blob/master/ci/rust.yml -# -# Simple, right? Right. -# But we need to: -# * download a specific Sciter library matching the running OS -# * figure out where to save it -# * add it to the $PATH -# -# yet, -# * in case of macOS realize that it doesn't have Rust installed, so -# * install it manually and don't forget to add cargo and rustc to the $PATH on each step -# * and in case of Linux install additional packages for GTK3 -# -# So, now we're ended up with this ugly script. - -jobs: - fetch: - name: Fetch dependencies - - runs-on: ${{ matrix.os }} - strategy: - matrix: - # macOS doesn't have Rust installed - # https://help.github.com/en/actions/automating-your-workflow-with-github-actions/software-installed-on-github-hosted-runners#macos-1015 - # we will try to install it manually below. - os: [macos-latest, ubuntu-latest, windows-latest] - - steps: - - name: Environment - shell: bash - env: - RUNNER_CONTEXT: ${{ toJson(runner) }} - SCITER_DEPS: ${{ runner.workspace }} - run: | - echo HOME is "$HOME" - echo workspace is "$SCITER_DEPS" - echo temp is "$TEMP" - echo runner is "$RUNNER_CONTEXT" - echo cargo is at `which cargo` - echo rustc is at `which rustc` - command -v cargo && rustc -vV - echo done - - build: - needs: [fetch] - name: Build and test - - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [macos-latest, ubuntu-latest, windows-latest] - - steps: - - uses: actions/checkout@v2 - - - name: Windows deps - if: runner.os == 'Windows' - # Windows: download sciter library - run: curl -sSLo "%SCITER_DEPS%/sciter.dll" "https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.win/x64/sciter.dll" - shell: cmd - env: - SCITER_DEPS: ${{ runner.workspace }} - - - name: Linux deps - if: runner.os == 'Linux' - # Linux: download sciter library && install libgtk-3-dev - run: | - curl -so "$SCITER_DEPS/libsciter-gtk.so" "https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.lnx/x64/libsciter-gtk.so" - sudo apt-get update -y && sudo apt-get install libgtk-3-dev libgtk-3-0 libstdc++-6-pic -y - env: - SCITER_DEPS: ${{ runner.workspace }} - - - name: macOS deps - if: runner.os == 'macOS' - # OSX: download sciter library && install rustup - run: | - curl -so "$SCITER_DEPS/sciter-osx-64.dylib" "https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.osx/sciter-osx-64.dylib" - curl https://sh.rustup.rs -sSf | sh -s -- --profile minimal -y - test -f $HOME/.cargo/env && source $HOME/.cargo/env - echo cargo is at `which cargo` - echo rustc is at `which rustc` - env: - SCITER_DEPS: ${{ runner.workspace }} - - - name: Build - shell: bash - run: | - test -f $HOME/.cargo/env && source $HOME/.cargo/env - cargo build --all - cargo build --examples - - - name: Tests - shell: bash - run: | - test -f $HOME/.cargo/env && source $HOME/.cargo/env - export PATH="$PATH:$SCITER_DEPS" - cargo run --example first - cargo test -p sciter-rs - cargo test -p sciter-serde - env: - SCITER_DEPS: ${{ runner.workspace }} diff --git a/libs/rust-sciter/.gitignore b/libs/rust-sciter/.gitignore deleted file mode 100644 index 387f95a08..000000000 --- a/libs/rust-sciter/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -target -Cargo.lock -.vscode/ -.vs/ diff --git a/libs/rust-sciter/.rustfmt.toml b/libs/rust-sciter/.rustfmt.toml deleted file mode 100644 index 192299b3c..000000000 --- a/libs/rust-sciter/.rustfmt.toml +++ /dev/null @@ -1,6 +0,0 @@ -# `rustfmt --config-help` for formatting options -max_width = 140 -ideal_width = 120 -tab_spaces = 2 -hard_tabs = true -blank_lines_upper_bound = 2 diff --git a/libs/rust-sciter/.travis.yml b/libs/rust-sciter/.travis.yml deleted file mode 100644 index 491549cb5..000000000 --- a/libs/rust-sciter/.travis.yml +++ /dev/null @@ -1,99 +0,0 @@ -# Based on the "trust" template v0.1.2 -# https://github.com/japaric/trust/tree/v0.1.2 - -dist: xenial -sudo: false -language: rust -compiler: gcc - -os: - - linux - - osx - -rust: - - stable - - nightly - - 1.40.0 - -matrix: - include: - - os: osx - osx_image: xcode8 - - os: osx - osx_image: xcode11 - -branches: - only: - - master - - travis - -notifications: - email: change - - -cache: cargo -before_cache: - # Travis can't cache files that are not readable by "others" - - chmod -R a+r $HOME/.cargo - -addons: - apt: - sources: - - ubuntu-toolchain-r-test - - packages: - - libgtk-3-dev - - libgtk-3-0 - - libstdc++-6-pic - - -before_install: - - set -e - - rustup self update - -install: - - source ~/.cargo/env || true - - export SDK_URL=https://raw.githubusercontent.com/c-smile/sciter-sdk/master - - if [ "$TRAVIS_OS_NAME" = "osx" ]; then export SDK_DLL="$TRAVIS_BUILD_DIR/sciter-osx-64.dylib"; fi - - if [ "$TRAVIS_OS_NAME" = "linux" ]; then export SDK_DLL="$TRAVIS_BUILD_DIR/libsciter-gtk.so"; fi - - - if [ "$TRAVIS_OS_NAME" = "osx" ]; then curl -so "$SDK_DLL" $SDK_URL/bin.osx/sciter-osx-64.dylib; fi - - if [ "$TRAVIS_OS_NAME" = "linux" ]; then curl -so "$SDK_DLL" $SDK_URL/bin.lnx/x64/libsciter-gtk.so; fi - -before_script: - - if [ "$TRAVIS_OS_NAME" = "osx" ]; then export DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:$TRAVIS_BUILD_DIR"; fi - - if [ "$TRAVIS_OS_NAME" = "osx" ]; then cp "$TRAVIS_BUILD_DIR/sciter-osx-64.dylib" "$TRAVIS_BUILD_DIR/libsciter-osx-64.dylib"; fi - - - if [ "$TRAVIS_OS_NAME" = "linux" ]; then export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$TRAVIS_BUILD_DIR"; fi - - if [ "$TRAVIS_OS_NAME" = "linux" ]; then export RUSTFLAGS='-C link-arg=-Wl,--unresolved-symbols=ignore-in-shared-libs'; fi - - - export PATH="$PATH:$TRAVIS_BUILD_DIR" - - export LIBRARY_PATH="$LIBRARY_PATH:$TRAVIS_BUILD_DIR" - - export RUST_BACKTRACE=full - - - #ls /usr/lib/x86_64-linux-gnu/libstdc++* - - #strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep GLIBC - - #file $SDK_DLL - - gcc --version - - rustc --version - -script: - - cargo update - - - cargo build --example first --verbose - - cargo run --example first - - cargo run --example first --features "dynamic" - - cargo run --example first --features "dynamic" -- "$SDK_DLL" - - - cargo build --all - - cargo build --all --release - - cargo build --examples --release - - cargo build --example windowless --features windowless - - - cargo test -p sciter-rs - - cargo test -p sciter-rs --release - - - cargo test -p sciter-serde - - cargo test -p sciter-serde --release - -after_script: set +e diff --git a/libs/rust-sciter/Cargo.toml b/libs/rust-sciter/Cargo.toml deleted file mode 100644 index 27eec9958..000000000 --- a/libs/rust-sciter/Cargo.toml +++ /dev/null @@ -1,111 +0,0 @@ -[package] -name = "sciter-rs" -version = "0.5.53" -description = "Rust bindings for Sciter - Embeddable HTML/CSS/script engine (cross-platform desktop GUI toolkit). Also capable with DirectX / OpenGL." -keywords = ["gui", "gtk", "cocoa", "opengl", "skia"] -categories = ["gui", "web-programming", "rendering::graphics-api", "api-bindings"] - -authors = ["pravic "] -repository = "https://github.com/sciter-sdk/rust-sciter" -documentation = "https://docs.rs/sciter-rs" -readme = "README.md" -license = "MIT" - -exclude = [".gitignore", ".editorconfig", ".appveyor.yml", "clippy.toml"] - -[badges] -appveyor = { repository = "sciter-sdk/rust-sciter" } -travis-ci = { repository = "sciter-sdk/rust-sciter" } - -maintenance = { status = "passively-maintained" } - -[lib] -name = "sciter" -path = "src/lib.rs" -crate-type = ["rlib"] - -[features] -default = ["dynamic"] - -# Enable nightly compiler features (currently doesn't use any). -nightly = [] - -# Build as a Sciter extension library. -# see "examples/extension" -# note: this feature can't be tested. -extension = [] - -# Load Sciter DLL dynamically from the path specified by `sciter::set_library`. -# Otherwise, links statically to `libsciter-gtk.so` or `sciter-osx-64.dylib`. -dynamic = [] - -# Build this crate specifically for Sciter.Lite versions -# which are incompatible with the regular ones. -windowless = [] - - -[dependencies] -libc = "0.2" -lazy_static = "1.4" - -[target.x86_64-apple-darwin.dependencies] -objc = "0.2" -objc-foundation = "0.1" - -[dev-dependencies] -winit = "0.19" -winapi = { version = "0.3", features = [ - "impl-default", - "winuser", - "wingdi", - "sysinfoapi", -] } -raw-window-handle = "0.3" - -[[example]] -name = "first" -path = "examples/first.rs" - -[[example]] -name = "minimal" -path = "examples/minimal.rs" - -[[example]] -name = "download" -path = "examples/download.rs" - -[[example]] -name = "dom" -path = "examples/dom.rs" - -[[example]] -name = "fire_event" -path = "examples/fire_event.rs" - -[[example]] -name = "interop" -path = "examples/interop.rs" - -[[example]] -name = "threads" -path = "examples/threads.rs" - -[[example]] -name = "archived" -path = "examples/archived.rs" - -[[example]] -name = "video" -path = "examples/video.rs" - -[[example]] -name = "clock" -path = "examples/clock.rs" - -[[example]] -name = "windowless" -path = "examples/windowless.rs" - -[[example]] -name = "som" -path = "examples/som.rs" diff --git a/libs/rust-sciter/LICENSE b/libs/rust-sciter/LICENSE deleted file mode 100644 index 11cf6de15..000000000 --- a/libs/rust-sciter/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright 2019 pravic - -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. diff --git a/libs/rust-sciter/README.md b/libs/rust-sciter/README.md deleted file mode 100644 index 3817eb356..000000000 --- a/libs/rust-sciter/README.md +++ /dev/null @@ -1,159 +0,0 @@ -# Rust bindings for Sciter - -[![Build status](https://ci.appveyor.com/api/projects/status/cbrisyh792mmmd08/branch/master?svg=true)](https://ci.appveyor.com/project/pravic/rust-sciter) -[![Build Status](https://img.shields.io/travis/sciter-sdk/rust-sciter/master.svg)](https://travis-ci.org/sciter-sdk/rust-sciter) -[![Minimum supported Rust version](https://img.shields.io/badge/rustc-1.38+-green.svg)](https://github.com/sciter-sdk/rust-sciter/commits/master/.travis.yml) -[![Current Version](https://img.shields.io/crates/v/sciter-rs.svg)](https://crates.io/crates/sciter-rs) -[![Documentation](https://docs.rs/sciter-rs/badge.svg)](https://docs.rs/sciter-rs) -[![License](https://img.shields.io/crates/l/sciter-rs.svg)](https://crates.io/crates/sciter-rs) -[![Join the forums at https://sciter.com/forums](https://img.shields.io/badge/forum-sciter.com-orange.svg)](https://sciter.com/forums) - -Check [this page](https://sciter.com/developers/sciter-sdk-bindings/) for other language bindings (Delphi / D / Go / .NET / Python / Rust). - ----- - - -## Introduction - -Sciter is an embeddable [multiplatform](https://sciter.com/sciter/crossplatform/) HTML/CSS/script engine with GPU accelerated rendering designed to render modern desktop application UI. It's a compact, single dll/dylib/so file (4-8 mb) engine without any additional dependencies. - - -## Screenshots - -Check the [screenshot gallery](https://github.com/oskca/sciter#sciter-desktop-ui-examples) of desktop UI examples -and [DirectX UI integration](https://github.com/pravic/rust-gfx-sciter) via [Rust GFX](https://github.com/gfx-rs/gfx). - - -## Description - -Physically Sciter is a mono library which contains: - -* [HTML and CSS](https://sciter.com/developers/for-web-programmers/) rendering engine based on the H-SMILE core used in [HTMLayout](https://terrainformatica.com/a-homepage-section/htmlayout/), -* JavaScript alike [Scripting engine](https://sciter.com/developers/sciter-docs/) – core of [TIScript](https://sciter.com/developers/for-web-programmers/tiscript-vs-javascript/) which by itself is based on [c-smile](https://c-smile.sourceforge.net/) engine, -* Persistent [Database](https://sciter.com/docs/content/script/Storage.htm) (a.k.a. [JSON DB](https://terrainformatica.com/2006/10/what-the-hell-is-that-json-db/)) based on excellent DB products of [Konstantin Knizhnik](http://garret.ru/databases.html). -* [Graphics](https://sciter.com/docs/content/sciter/Graphics.htm) module that uses native graphics primitives provided by supported platforms: Direct2D on Windows 7 and above, GDI+ on Windows XP, CoreGraphics on MacOS, Cairo on Linux/GTK. Yet there is an option to use built-in [Skia/OpenGL](https://skia.org/) backend on each platform. -* Network communication module, it relies on platform HTTP client primitives and/or [Libcurl](https://curl.haxx.se/). - - -Internally it contains the following modules: - -* **CSS** – CSS parser and the collection of parsed CSS rules, etc. -* **HTML DOM** – HTML parser and DOM tree implementation. -* **layout managers** – collection of various layout managers – text layout, default block layout, flex layouts. Support of positioned floating elements is also here. This module does the layout calculations heavy lifting. This module is also responsible for the rendering of layouts. -* **input behaviors** – a collection of built-in behaviors – code behind "active" DOM elements: ``, `