diff --git a/Cargo.lock b/Cargo.lock index ce1c2057d5..b1823d6c88 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -193,10 +193,11 @@ dependencies = [ "bincode", "bindgen", "cc", - "env_logger 0.11.0", + "env_logger 0.11.1", "glyph_brush_layout", "jni 0.21.1", "local-ip-address", + "mdns-sd", "ndk 0.8.0", "ndk-context", "ndk-sys 0.5.0+25.2.9519653", @@ -216,7 +217,7 @@ dependencies = [ "alvr_packets", "alvr_session", "eframe", - "env_logger 0.11.0", + "env_logger 0.11.1", "rand", ] @@ -268,7 +269,7 @@ dependencies = [ "chrono", "console_error_panic_hook", "eframe", - "env_logger 0.11.0", + "env_logger 0.11.1", "ewebsock", "futures", "gloo-net", @@ -360,9 +361,11 @@ dependencies = [ "cc", "chrono", "fern", + "flume", "futures", "headers", "hyper", + "mdns-sd", "pkg-config", "profiling", "reqwest", @@ -451,9 +454,9 @@ dependencies = [ [[package]] name = "android-activity" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39b801912a977c3fd52d80511fe1c0c8480c6f957f21ae2ce1b92ffe970cf4b9" +checksum = "ee91c0c2905bae44f84bfa4e044536541df26b7703fd0888deeb9060fcc44289" dependencies = [ "android-properties", "bitflags 2.4.2", @@ -525,9 +528,9 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.4" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" +checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" [[package]] name = "anstyle-parse" @@ -702,9 +705,9 @@ dependencies = [ [[package]] name = "async-io" -version = "2.3.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb41eb19024a91746eba0773aa5e16036045bbf45733766661099e182ea6a744" +checksum = "8f97ab0c5b00a7cdbe5a371b9a782ee7be1316095885c8a4ea1daf490eb0ef65" dependencies = [ "async-lock 3.3.0", "cfg-if", @@ -712,8 +715,8 @@ dependencies = [ "futures-io", "futures-lite 2.2.0", "parking", - "polling 3.3.2", - "rustix 0.38.30", + "polling 3.4.0", + "rustix 0.38.31", "slab", "tracing", "windows-sys 0.52.0", @@ -758,7 +761,7 @@ dependencies = [ "cfg-if", "event-listener 3.1.0", "futures-lite 1.13.0", - "rustix 0.38.30", + "rustix 0.38.31", "windows-sys 0.48.0", ] @@ -779,13 +782,13 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e47d90f65a225c4527103a8d747001fc56e375203592b25ad103e1ca13124c5" dependencies = [ - "async-io 2.3.0", + "async-io 2.3.1", "async-lock 2.8.0", "atomic-waker", "cfg-if", "futures-core", "futures-io", - "rustix 0.38.30", + "rustix 0.38.31", "signal-hook-registry", "slab", "windows-sys 0.48.0", @@ -918,17 +921,17 @@ dependencies = [ [[package]] name = "bindgen" -version = "0.69.2" +version = "0.69.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4c69fae65a523209d34240b60abe0c42d33d1045d445c0839d8a4894a736e2d" +checksum = "a00dc851838a2120612785d195287475a3ac45514741da670b735818822129a0" dependencies = [ "bitflags 2.4.2", "cexpr", "clang-sys", + "itertools", "lazy_static", "lazycell", "log", - "peeking_take_while", "prettyplease", "proc-macro2", "quote", @@ -1043,9 +1046,9 @@ checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" [[package]] name = "bytemuck" -version = "1.14.0" +version = "1.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6" +checksum = "ea31d69bda4949c1c1562c1e6f042a1caefac98cdc8a298260a2ff41c1e2d42b" dependencies = [ "bytemuck_derive", ] @@ -1112,8 +1115,8 @@ checksum = "fba7adb4dd5aa98e5553510223000e7148f621165ec5f9acd7113f6ca4995298" dependencies = [ "bitflags 2.4.2", "log", - "polling 3.3.2", - "rustix 0.38.30", + "polling 3.4.0", + "rustix 0.38.31", "slab", "thiserror", ] @@ -1125,7 +1128,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0f0ea9b9476c7fad82841a8dbb380e2eae480c21910feba80725b46931ed8f02" dependencies = [ "calloop", - "rustix 0.38.30", + "rustix 0.38.31", "wayland-backend", "wayland-client", ] @@ -1188,16 +1191,16 @@ dependencies = [ [[package]] name = "chrono" -version = "0.4.31" +version = "0.4.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" +checksum = "9f13690e35a5e4ace198e7beea2895d29f3a9cc55015fcebe6336bd2010af9eb" dependencies = [ "android-tzdata", "iana-time-zone", "js-sys", "num-traits", "wasm-bindgen", - "windows-targets 0.48.5", + "windows-targets 0.52.0", ] [[package]] @@ -1495,9 +1498,9 @@ dependencies = [ [[package]] name = "darling" -version = "0.20.3" +version = "0.20.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0209d94da627ab5605dcccf08bb18afa5009cfbef48d8a8b7d7bdbc79be25c5e" +checksum = "fc5d6b04b3fd0ba9926f945895de7d806260a2d7431ba82e7edaecb043c4c6b8" dependencies = [ "darling_core", "darling_macro", @@ -1505,9 +1508,9 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.20.3" +version = "0.20.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "177e3443818124b357d8e76f53be906d60937f0d3a90773a664fa63fa253e621" +checksum = "04e48a959bcd5c761246f5d090ebc2fbf7b9cd527a492b07a67510c108f1e7e3" dependencies = [ "fnv", "ident_case", @@ -1519,9 +1522,9 @@ dependencies = [ [[package]] name = "darling_macro" -version = "0.20.3" +version = "0.20.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" +checksum = "1d1545d67a2149e1d93b7e5c7752dce5a7426eb5d1357ddcfd89336b94444f77" dependencies = [ "darling_core", "quote", @@ -1806,9 +1809,9 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9eeb342678d785662fd2514be38c459bb925f02b68dd2a3e0f21d7ef82d979dd" +checksum = "05e7cf40684ae96ade6232ed84582f40ce0a66efcd43a5117aef610534f8e0b8" dependencies = [ "anstream", "anstyle", @@ -1986,6 +1989,18 @@ dependencies = [ "miniz_oxide", ] +[[package]] +name = "flume" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55ac459de2512911e4b674ce33cf20befaba382d05b62b008afc1c8b57cbf181" +dependencies = [ + "futures-core", + "futures-sink", + "nanorand", + "spin", +] + [[package]] name = "fnv" version = "1.0.7" @@ -2240,8 +2255,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" dependencies = [ "cfg-if", + "js-sys", "libc", "wasi", + "wasm-bindgen", ] [[package]] @@ -2578,9 +2595,9 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d3d0e0f38255e7fa3cf31335b3a56f05febd18025f4db5ef7a0cfb4f8da651f" +checksum = "d0c62115964e08cb8039170eb33c1d0e2388a256930279edca206fff675f82c3" [[package]] name = "hex" @@ -2722,9 +2739,9 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.59" +version = "0.1.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6a67363e2aa4443928ce15e57ebae94fd8949958fd1223c4cfc0cd473ad7539" +checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -2780,6 +2797,16 @@ dependencies = [ "unicode-normalization", ] +[[package]] +name = "if-addrs" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cabb0019d51a643781ff15c9c8a3e5dedc365c47211270f4e8f82812fedd8f0a" +dependencies = [ + "libc", + "windows-sys 0.48.0", +] + [[package]] name = "image" version = "0.24.8" @@ -2795,9 +2822,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.1.0" +version = "2.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" +checksum = "824b2ae422412366ba479e8111fd301f7b5faece8149317bb81925979a53f520" dependencies = [ "equivalent", "hashbrown", @@ -2860,6 +2887,15 @@ dependencies = [ "once_cell", ] +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.10" @@ -2954,9 +2990,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.67" +version = "0.3.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a1d36f1235bc969acba30b7f5990b864423a6068a10f7c90ae8f0112e3a59d1" +checksum = "406cda4b368d531c842222cf9d2600a9a4acce8d29423695379c6868a143a9ee" dependencies = [ "wasm-bindgen", ] @@ -3003,9 +3039,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.152" +version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "libloading" @@ -3075,9 +3111,9 @@ checksum = "b4ce301924b7887e9d637144fdade93f9dfff9b60981d4ac161db09720d39aa5" [[package]] name = "local-ip-address" -version = "0.5.6" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66357e687a569abca487dc399a9c9ac19beb3f13991ed49f00c144e02cbd42ab" +checksum = "612ed4ea9ce5acfb5d26339302528a5e1e59dfed95e9e11af3c083236ff1d15d" dependencies = [ "libc", "neli", @@ -3151,6 +3187,19 @@ dependencies = [ "rawpointer", ] +[[package]] +name = "mdns-sd" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c460fa7decb7ea827682546b0584736acb45bcb2ced0d0dd6030c6d529e012e" +dependencies = [ + "flume", + "if-addrs", + "log", + "polling 2.8.0", + "socket2 0.4.10", +] + [[package]] name = "memchr" version = "2.7.1" @@ -3159,9 +3208,9 @@ checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" [[package]] name = "memmap2" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45fd3a57831bf88bc63f8cebc0cf956116276e97fef3966103e96416209f7c92" +checksum = "fe751422e4a8caa417e13c3ea66452215d7d63e19e604f4980461212f3ae1322" dependencies = [ "libc", ] @@ -3213,9 +3262,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" dependencies = [ "adler", "simd-adler32", @@ -3281,6 +3330,15 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "nanorand" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a51313c5820b0b02bd422f4b44776fbf47961755c74ce64afc73bfad10226c3" +dependencies = [ + "getrandom", +] + [[package]] name = "native-tls" version = "0.2.11" @@ -3438,13 +3496,19 @@ dependencies = [ [[package]] name = "num-complex" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ba157ca0885411de85d6ca030ba7e2a83a28636056c7c699b07c8b6f7383214" +checksum = "23c6602fda94a57c990fe0df199a035d83576b496aa29f4e634a8ac6004e68a6" dependencies = [ "num-traits", ] +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + [[package]] name = "num-derive" version = "0.3.3" @@ -3458,11 +3522,10 @@ dependencies = [ [[package]] name = "num-integer" -version = "0.1.45" +version = "0.1.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" dependencies = [ - "autocfg", "num-traits", ] @@ -3479,9 +3542,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.17" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" dependencies = [ "autocfg", "libm", @@ -3863,12 +3926,6 @@ dependencies = [ "sha2", ] -[[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.3.1" @@ -3883,18 +3940,18 @@ checksum = "5be167a7af36ee22fe3115051bc51f6e6c7054c9348e28deb4f49bd6f705a315" [[package]] name = "pin-project" -version = "1.1.3" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fda4ed1c6c173e3fc7a83629421152e01d7b1f9b7f65fb301e490e8cfc656422" +checksum = "0302c4a0442c456bd56f841aee5c3bfd17967563f6fadc9ceb9f9c23cf3807e0" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.3" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" +checksum = "266c042b60c9c76b8d53061e52b2e0d1116abc57cefc8c5cd671619a56ac3690" dependencies = [ "proc-macro2", "quote", @@ -3961,14 +4018,14 @@ dependencies = [ [[package]] name = "polling" -version = "3.3.2" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "545c980a3880efd47b2e262f6a4bb6daad6555cf3367aa9c4e52895f69537a41" +checksum = "30054e72317ab98eddd8561db0f6524df3367636884b7b21b703e4b280a84a14" dependencies = [ "cfg-if", "concurrent-queue", "pin-project-lite", - "rustix 0.38.30", + "rustix 0.38.31", "tracing", "windows-sys 0.52.0", ] @@ -4017,23 +4074,23 @@ version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" dependencies = [ - "toml_edit 0.21.0", + "toml_edit 0.21.1", ] [[package]] name = "proc-macro2" -version = "1.0.76" +version = "1.0.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95fc56cda0b5c3325f5fbbd7ff9fda9e02bb00bb3dac51252d2f1bfa1cb8cc8c" +checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" dependencies = [ "unicode-ident", ] [[package]] name = "profiling" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d135ede8821cf6376eb7a64148901e1690b788c11ae94dc297ae917dbc91dc0e" +checksum = "0f0f7f43585c34e4fdd7497d746bc32e14458cf11c69341cc0587b1d825dde42" dependencies = [ "profiling-procmacros", "tracy-client", @@ -4041,9 +4098,9 @@ dependencies = [ [[package]] name = "profiling-procmacros" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b322d7d65c1ab449be3c890fcbd0db6e1092d0dd05d79dba2dd28032cebeb05" +checksum = "ce97fecd27bc49296e5e20518b5a1bb54a14f7d5fe6228bc9686ee2a74915cc8" dependencies = [ "quote", "syn 2.0.48", @@ -4051,9 +4108,9 @@ dependencies = [ [[package]] name = "quick-xml" -version = "0.30.0" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eff6510e86862b57b210fd8cbe8ed3f0d7d600b9c2863cd4549a2e033c66e956" +checksum = "1004a344b30a54e2ee58d66a71b32d2db2feb0a31f9a2d302bf0536f15de2a33" dependencies = [ "memchr", ] @@ -4162,13 +4219,13 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.2" +version = "1.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" +checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.3", + "regex-automata 0.4.5", "regex-syntax 0.8.2", ] @@ -4183,9 +4240,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.3" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" +checksum = "5bb987efffd3c6d0d8f5f89510bb458559eab11e4f869acb20bf845e016259cd" dependencies = [ "aho-corasick", "memchr", @@ -4212,9 +4269,9 @@ checksum = "216080ab382b992234dda86873c18d4c48358f5cfcb70fd693d7f6f2131b628b" [[package]] name = "reqwest" -version = "0.11.23" +version = "0.11.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37b1ae8d9ac08420c66222fb9096fc5de435c3c48542bc5336c51892cffafb41" +checksum = "c6920094eb85afde5e4a138be3f2de8bbdf28000f0029e72c45025a56b042251" dependencies = [ "base64", "bytes", @@ -4240,6 +4297,7 @@ dependencies = [ "serde", "serde_json", "serde_urlencoded", + "sync_wrapper", "system-configuration", "tokio", "tokio-native-tls", @@ -4353,9 +4411,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.30" +version = "0.38.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "322394588aaf33c24007e8bb3238ee3e4c5c09c084ab32bc73890b99ff326bca" +checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" dependencies = [ "bitflags 2.4.2", "errno 0.3.8", @@ -4503,18 +4561,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.195" +version = "1.0.196" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63261df402c67811e9ac6def069e4786148c4563f4b50fd4bf30aa370d626b02" +checksum = "870026e60fa08c69f064aa766c10f10b1d62db9ccd4d0abb206472bee0ce3b32" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.195" +version = "1.0.196" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46fe8f8603d81ba86327b23a2e9cdf49e1255fb94a4c5f297f6ee0547178ea2c" +checksum = "33c85360c95e7d137454dc81d9a4ed2b8efd8fbe19cee57357b32b9771fccb67" dependencies = [ "proc-macro2", "quote", @@ -4523,9 +4581,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.111" +version = "1.0.113" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "176e46fa42316f18edd598015a5166857fc835ec732f5215eac6b7bdbf0a84f4" +checksum = "69801b70b1c3dac963ecb03a364ba0ceda9cf60c71cfe475e99864759c8b8a79" dependencies = [ "itoa", "ryu", @@ -4618,9 +4676,9 @@ dependencies = [ [[package]] name = "shlex" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7cee0529a6d40f580e7a5e6c495c8fbfe21b7b52795ed4bb5e62cdf92bc6380" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "signal-hook-registry" @@ -4687,7 +4745,7 @@ dependencies = [ "libc", "log", "memmap2", - "rustix 0.38.30", + "rustix 0.38.31", "thiserror", "wayland-backend", "wayland-client", @@ -4744,6 +4802,9 @@ name = "spin" version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" +dependencies = [ + "lock_api", +] [[package]] name = "spirv" @@ -4869,6 +4930,12 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "sync_wrapper" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" + [[package]] name = "sysinfo" version = "0.30.5" @@ -4913,7 +4980,7 @@ dependencies = [ "cfg-expr", "heck", "pkg-config", - "toml 0.8.8", + "toml 0.8.10", "version-compare", ] @@ -4925,14 +4992,13 @@ checksum = "69758bda2e78f098e4ccb393021a0963bb3442eac05f135c30f61b7370bbafae" [[package]] name = "tempfile" -version = "3.9.0" +version = "3.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01ce4141aa927a6d1bd34a041795abd0db1cccba5d5f24b009f694bdf3a1f3fa" +checksum = "a365e8cd18e44762ef95d87f284f4b5cd04107fec2ff3052bd6a3e6069669e67" dependencies = [ "cfg-if", "fastrand 2.0.1", - "redox_syscall 0.4.1", - "rustix 0.38.30", + "rustix 0.38.31", "windows-sys 0.52.0", ] @@ -4977,11 +5043,12 @@ dependencies = [ [[package]] name = "time" -version = "0.3.31" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f657ba42c3f86e7680e53c8cd3af8abbe56b5491790b46e22e19c0d57463583e" +checksum = "c8248b6521bb14bc45b4067159b9b6ad792e2d6d754d6c41fb50e29fefe38749" dependencies = [ "deranged", + "num-conv", "powerfmt", "serde", "time-core", @@ -4995,9 +5062,9 @@ checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "tiny-skia" -version = "0.11.3" +version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6a067b809476893fce6a254cf285850ff69c847e6cfbade6a20b655b6c7e80d" +checksum = "83d13394d44dae3207b52a326c0c85a8bf87f1541f23b0d143811088497b09ab" dependencies = [ "arrayref", "arrayvec", @@ -5009,9 +5076,9 @@ dependencies = [ [[package]] name = "tiny-skia-path" -version = "0.11.3" +version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5de35e8a90052baaaf61f171680ac2f8e925a1e43ea9d2e3a00514772250e541" +checksum = "9c9e7fc0c2e86a30b117d0462aa261b72b7a99b7ebd7deb3a14ceda95c5bdc93" dependencies = [ "arrayref", "bytemuck", @@ -5035,9 +5102,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.35.1" +version = "1.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c89b4efa943be685f629b149f53829423f8f5531ea21249408e8e2f8671ec104" +checksum = "61285f6515fa018fb2d1e46eb21223fff441ee8db5d0f1435e8ab4f5cdb80931" dependencies = [ "backtrace", "bytes", @@ -5119,14 +5186,14 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.8" +version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1a195ec8c9da26928f773888e0742ca3ca1040c6cd859c919c9f59c1954ab35" +checksum = "9a9aad4a3066010876e8dcf5a8a06e70a558751117a145c6ce2b82c2e2054290" dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.21.0", + "toml_edit 0.22.4", ] [[package]] @@ -5151,9 +5218,20 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.21.0" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" +dependencies = [ + "indexmap", + "toml_datetime", + "winnow", +] + +[[package]] +name = "toml_edit" +version = "0.22.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d34d383cd00a163b4a5b85053df514d45bc330f6de7737edfe0a93311d1eaa03" +checksum = "0c9ffdf896f8daaabf9b66ba8e77ea1ed5ed0f72821b398aba62352e95062951" dependencies = [ "indexmap", "serde", @@ -5242,9 +5320,9 @@ dependencies = [ [[package]] name = "tracy-client-sys" -version = "0.22.1" +version = "0.22.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "078c7ed72141b0e4369671a7f7af0eecffe18d753bf0296adca9c7add7276c9d" +checksum = "9d104d610dfa9dd154535102cc9c6164ae1fa37842bc2d9e83f9ac82b0ae0882" dependencies = [ "cc", ] @@ -5348,9 +5426,9 @@ dependencies = [ [[package]] name = "unicode-segmentation" -version = "1.10.1" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" +checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" [[package]] name = "unicode-width" @@ -5468,9 +5546,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.90" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1223296a201415c7fad14792dbefaace9bd52b62d33453ade1c5b5f07555406" +checksum = "c1e124130aee3fb58c5bdd6b639a0509486b0338acaaae0c84a5124b0f588b7f" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -5478,9 +5556,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.90" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcdc935b63408d58a32f8cc9738a0bffd8f05cc7c002086c6ef20b7312ad9dcd" +checksum = "c9e7e1900c352b609c8488ad12639a311045f40a35491fb69ba8c12f758af70b" dependencies = [ "bumpalo", "log", @@ -5493,9 +5571,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.40" +version = "0.4.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bde2032aeb86bdfaecc8b261eef3cba735cc426c1f3a3416d1e0791be95fc461" +checksum = "877b9c3f61ceea0e56331985743b13f3d25c406a7098d45180fb5f09bc19ed97" dependencies = [ "cfg-if", "js-sys", @@ -5505,9 +5583,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.90" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e4c238561b2d428924c49815533a8b9121c664599558a5d9ec51f8a1740a999" +checksum = "b30af9e2d358182b5c7449424f017eba305ed32a7010509ede96cdc4696c46ed" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -5515,9 +5593,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.90" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bae1abb6806dc1ad9e560ed242107c0f6c84335f1749dd4e8ddb012ebd5e25a7" +checksum = "642f325be6301eb8107a83d12a8ac6c1e1c54345a7ef1a9261962dfefda09e66" dependencies = [ "proc-macro2", "quote", @@ -5528,9 +5606,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.90" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d91413b1c31d7539ba5ef2451af3f0b833a005eb27a631cec32bc0635a8602b" +checksum = "4f186bd2dcf04330886ce82d6f33dd75a7bfcf69ecf5763b89fcde53b6ac9838" [[package]] name = "wasm-logger" @@ -5545,9 +5623,9 @@ dependencies = [ [[package]] name = "wasm-streams" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4609d447824375f43e1ffbc051b50ad8f4b3ae8219680c94452ea05eb240ac7" +checksum = "b65dc4c90b63b118468cf747d8bf3566c1913ef60be765b5730ead9e0a3ba129" dependencies = [ "futures-util", "js-sys", @@ -5558,13 +5636,13 @@ dependencies = [ [[package]] name = "wayland-backend" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19152ddd73f45f024ed4534d9ca2594e0ef252c1847695255dae47f34df9fbe4" +checksum = "9d50fa61ce90d76474c87f5fc002828d81b32677340112b4ef08079a9d459a40" dependencies = [ "cc", "downcast-rs", - "nix 0.26.4", + "rustix 0.38.31", "scoped-tls", "smallvec", "wayland-sys", @@ -5572,12 +5650,12 @@ dependencies = [ [[package]] name = "wayland-client" -version = "0.31.1" +version = "0.31.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ca7d52347346f5473bf2f56705f360e8440873052e575e55890c4fa57843ed3" +checksum = "82fb96ee935c2cea6668ccb470fb7771f6215d1691746c2d896b447a00ad3f1f" dependencies = [ "bitflags 2.4.2", - "nix 0.26.4", + "rustix 0.38.31", "wayland-backend", "wayland-scanner", ] @@ -5595,20 +5673,20 @@ dependencies = [ [[package]] name = "wayland-cursor" -version = "0.31.0" +version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a44aa20ae986659d6c77d64d808a046996a932aa763913864dc40c359ef7ad5b" +checksum = "71ce5fa868dd13d11a0d04c5e2e65726d0897be8de247c0c5a65886e283231ba" dependencies = [ - "nix 0.26.4", + "rustix 0.38.31", "wayland-client", "xcursor", ] [[package]] name = "wayland-protocols" -version = "0.31.0" +version = "0.31.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e253d7107ba913923dc253967f35e8561a3c65f914543e46843c88ddd729e21c" +checksum = "8f81f365b8b4a97f422ac0e8737c438024b5951734506b0e1d775c73030561f4" dependencies = [ "bitflags 2.4.2", "wayland-backend", @@ -5644,9 +5722,9 @@ dependencies = [ [[package]] name = "wayland-scanner" -version = "0.31.0" +version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb8e28403665c9f9513202b7e1ed71ec56fde5c107816843fb14057910b2c09c" +checksum = "63b3a62929287001986fb58c789dce9b67604a397c15c611ad9f747300b6c283" dependencies = [ "proc-macro2", "quick-xml", @@ -5667,9 +5745,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.67" +version = "0.3.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58cd2333b6e0be7a39605f0e255892fd7418a682d8da8fe042fe25128794d2ed" +checksum = "96565907687f7aceb35bc5fc03770a8a0471d82e479f25832f54a0e3f4b28446" dependencies = [ "js-sys", "wasm-bindgen", @@ -5704,9 +5782,9 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.25.3" +version = "0.25.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1778a42e8b3b90bff8d0f5032bf22250792889a5cdc752aa0020c84abe3aaf10" +checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" [[package]] name = "wgpu" @@ -5761,9 +5839,9 @@ dependencies = [ [[package]] name = "wgpu-hal" -version = "0.19.0" +version = "0.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11f259ceb56727fb097da108d92f8a5cbdb5b74a77f9e396bd43626f67299d61" +checksum = "e3bb47856236bfafc0bc591a925eb036ac19cd987624a447ff353e7a7e7e6f72" dependencies = [ "android_system_properties", "arrayvec", @@ -5823,14 +5901,14 @@ dependencies = [ "either", "home", "once_cell", - "rustix 0.38.30", + "rustix 0.38.31", ] [[package]] name = "wide" -version = "0.7.13" +version = "0.7.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c68938b57b33da363195412cfc5fc37c9ed49aa9cfe2156fde64b8d2c9498242" +checksum = "89beec544f246e679fc25490e3f8e08003bc4bf612068f325120dad4cea02c1c" dependencies = [ "bytemuck", "safe_arch", @@ -6171,7 +6249,7 @@ dependencies = [ "raw-window-handle 0.5.2", "raw-window-handle 0.6.0", "redox_syscall 0.3.5", - "rustix 0.38.30", + "rustix 0.38.31", "sctk-adwaita", "smithay-client-toolkit", "smol_str", @@ -6192,9 +6270,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.5.34" +version = "0.5.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7cf47b659b318dccbd69cc4797a39ae128f533dce7902a1096044d1967b9c16" +checksum = "5389a154b01683d28c77f8f68f49dea75f0a4da32557a58f68ee51ebba472d29" dependencies = [ "memchr", ] @@ -6253,7 +6331,7 @@ dependencies = [ "libc", "libloading 0.8.1", "once_cell", - "rustix 0.38.30", + "rustix 0.38.31", "x11rb-protocol 0.13.0", ] @@ -6286,11 +6364,11 @@ checksum = "213b7324336b53d2414b2db8537e56544d981803139155afa84f76eeebb7a546" [[package]] name = "xdg-home" -version = "1.0.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2769203cd13a0c6015d515be729c526d041e9cf2c0cc478d57faee85f40c6dcd" +checksum = "21e5a325c3cb8398ad6cf859c1135b25dd29e186679cf2da7581d9679f63b38e" dependencies = [ - "nix 0.26.4", + "libc", "winapi", ] @@ -6342,9 +6420,9 @@ checksum = "7e2c411759b501fb9501aac2b1b2d287a6e93e5bdcf13c25306b23e1b716dd0e" [[package]] name = "zbus" -version = "3.14.1" +version = "3.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31de390a2d872e4cd04edd71b425e29853f786dc99317ed72d73d6fcf5ebb948" +checksum = "c45d06ae3b0f9ba1fb2671268b975557d8f5a84bb5ec6e43964f87e763d8bca8" dependencies = [ "async-broadcast", "async-executor", @@ -6383,9 +6461,9 @@ dependencies = [ [[package]] name = "zbus_macros" -version = "3.14.1" +version = "3.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41d1794a946878c0e807f55a397187c11fc7a038ba5d868e7db4f3bd7760bc9d" +checksum = "b4a1ba45ed0ad344b85a2bb5a1fe9830aed23d67812ea39a586e7d0136439c7d" dependencies = [ "proc-macro-crate 1.3.1", "proc-macro2", diff --git a/alvr/client_core/Cargo.toml b/alvr/client_core/Cargo.toml index bcb484331a..b63bcfbf7e 100644 --- a/alvr/client_core/Cargo.toml +++ b/alvr/client_core/Cargo.toml @@ -23,10 +23,11 @@ alvr_sockets.workspace = true app_dirs2 = "2" bincode = "1" glyph_brush_layout = "0.2" +jni = "0.21" +mdns-sd = "0.10" rand = "0.8" serde = "1" serde_json = "1" -jni = "0.21" [target.'cfg(target_os = "android")'.dependencies] android_logger = "0.13" diff --git a/alvr/client_core/src/c_api.rs b/alvr/client_core/src/c_api.rs index 6a8cf5f53f..710c7b54ad 100644 --- a/alvr/client_core/src/c_api.rs +++ b/alvr/client_core/src/c_api.rs @@ -1,6 +1,6 @@ use crate::{ opengl::{self, RenderViewInput}, - ClientCoreEvent, + storage, ClientCoreEvent, }; use alvr_common::{ debug, error, @@ -142,6 +142,23 @@ fn string_to_c_str(buffer: *mut c_char, value: &str) -> u64 { cstring.as_bytes_with_nul().len() as u64 } +#[no_mangle] +pub extern "C" fn alvr_mdns_service(service_buffer: *mut c_char) -> u64 { + string_to_c_str(service_buffer, alvr_sockets::MDNS_SERVICE_TYPE) +} + +// To make sure the value is correct, call after alvr_initialize() +#[no_mangle] +pub extern "C" fn alvr_hostname(hostname_buffer: *mut c_char) -> u64 { + string_to_c_str(hostname_buffer, &storage::Config::load().hostname) +} + +// To make sure the value is correct, call after alvr_initialize() +#[no_mangle] +pub extern "C" fn alvr_protocol_id(protocol_buffer: *mut c_char) -> u64 { + string_to_c_str(protocol_buffer, &storage::Config::load().protocol_id) +} + /// On non-Android platforms, java_vm and constext should be null. /// NB: context must be thread safe. #[allow(unused_variables)] diff --git a/alvr/client_core/src/connection.rs b/alvr/client_core/src/connection.rs index 5ed1c23083..30b85c290f 100644 --- a/alvr/client_core/src/connection.rs +++ b/alvr/client_core/src/connection.rs @@ -178,7 +178,7 @@ fn connection_pipeline( proto_control_socket .send(&ClientConnectionResult::ConnectionAccepted { - client_protocol_id: alvr_common::protocol_id(), + client_protocol_id: alvr_common::protocol_id_u64(), display_name: platform::device_model(), server_ip, streaming_capabilities: Some(VideoStreamingCapabilities { diff --git a/alvr/client_core/src/lib.rs b/alvr/client_core/src/lib.rs index 5be50287cd..77945f560b 100644 --- a/alvr/client_core/src/lib.rs +++ b/alvr/client_core/src/lib.rs @@ -105,7 +105,7 @@ pub fn initialize( #[cfg(target_os = "android")] platform::try_get_permission(platform::MICROPHONE_PERMISSION); #[cfg(target_os = "android")] - platform::acquire_wifi_lock(); + platform::set_wifi_lock(true); EXTERNAL_DECODER.set(external_decoder); *LIFECYCLE_STATE.write() = LifecycleState::Idle; @@ -123,7 +123,7 @@ pub fn destroy() { } #[cfg(target_os = "android")] - platform::release_wifi_lock(); + platform::set_wifi_lock(false); } pub fn resume() { diff --git a/alvr/client_core/src/platform/android/mod.rs b/alvr/client_core/src/platform/android/mod.rs index e822235c6f..71503b4f44 100644 --- a/alvr/client_core/src/platform/android/mod.rs +++ b/alvr/client_core/src/platform/android/mod.rs @@ -2,7 +2,7 @@ mod decoder; pub use decoder::*; -use alvr_common::OptLazy; +use alvr_common::{warn, OptLazy}; use jni::{ objects::{GlobalRef, JObject}, sys::jobject, @@ -12,8 +12,6 @@ use std::net::{IpAddr, Ipv4Addr}; pub const MICROPHONE_PERMISSION: &str = "android.permission.RECORD_AUDIO"; -static WIFI_LOCK: OptLazy = alvr_common::lazy_mut_none(); - pub fn vm() -> JavaVM { unsafe { JavaVM::from_raw(ndk_context::android_context().vm().cast()).unwrap() } } @@ -137,50 +135,68 @@ pub fn local_ip() -> IpAddr { } // This is needed to avoid wifi scans that disrupt streaming. -pub fn acquire_wifi_lock() { - let mut maybe_wifi_lock = WIFI_LOCK.lock(); - - if maybe_wifi_lock.is_none() { - let vm = vm(); - let mut env = vm.attach_current_thread().unwrap(); - - let wifi_mode = if get_api_level() >= 29 { - // Recommended for virtual reality since it disables WIFI scans - 4 // WIFI_MODE_FULL_LOW_LATENCY - } else { - 3 // WIFI_MODE_FULL_HIGH_PERF - }; - - let wifi_manager = get_system_service(&mut env, "wifi"); - let wifi_lock_jstring = env.new_string("alvr_wifi_lock").unwrap(); - let wifi_lock = env - .call_method( - wifi_manager, - "createWifiLock", - "(ILjava/lang/String;)Landroid/net/wifi/WifiManager$WifiLock;", - &[wifi_mode.into(), (&wifi_lock_jstring).into()], - ) - .unwrap() - .l() - .unwrap(); - env.call_method(&wifi_lock, "acquire", "()V", &[]).unwrap(); +// Code inspired from https://github.com/Meumeu/WiVRn/blob/master/client/application.cpp +pub fn set_wifi_lock(enabled: bool) { + let vm = vm(); + let mut env = vm.attach_current_thread().unwrap(); - *maybe_wifi_lock = Some(env.new_global_ref(wifi_lock).unwrap()); - } -} + let wifi_manager = get_system_service(&mut env, "wifi"); + let wifi_lock_jstring = env.new_string("alvr_wifi_lock").unwrap(); -pub fn release_wifi_lock() { - if let Some(wifi_lock) = WIFI_LOCK.lock().take() { - let vm = vm(); - let mut env = vm.attach_current_thread().unwrap(); + fn set_lock<'a>(env: &mut JNIEnv<'a>, lock: &JObject, enabled: bool) { + env.call_method(lock, "setReferenceCounted", "(Z)V", &[false.into()]) + .unwrap(); + env.call_method( + &lock, + if enabled { "acquire" } else { "release" }, + "()V", + &[], + ) + .unwrap(); - env.call_method(wifi_lock.as_obj(), "release", "()V", &[]) + let lock_is_aquired = env + .call_method(lock, "isHeld", "()Z", &[]) + .unwrap() + .z() .unwrap(); - // TODO: all JVM.call_method sometimes result in JavaExceptions, unwrap will only report Error as 'JavaException', ideally before unwrapping - // need to call JVM.describe_error() which will actually check if there is an exception and print error to stderr/logcat. Then unwrap. - // wifi_lock is dropped here + if lock_is_aquired != enabled { + warn!("Failed to set wifi lock: expected {enabled}, got {lock_is_aquired}"); + } } + + let wifi_lock = env + .call_method( + &wifi_manager, + "createWifiLock", + "(ILjava/lang/String;)Landroid/net/wifi/WifiManager$WifiLock;", + &[ + if get_api_level() >= 29 { + // Recommended for virtual reality since it disables WIFI scans + 4 // WIFI_MODE_FULL_LOW_LATENCY + } else { + 3 // WIFI_MODE_FULL_HIGH_PERF + } + .into(), + (&wifi_lock_jstring).into(), + ], + ) + .unwrap() + .l() + .unwrap(); + set_lock(&mut env, &wifi_lock, enabled); + + let multicast_lock = env + .call_method( + wifi_manager, + "createMulticastLock", + "(Ljava/lang/String;)Landroid/net/wifi/WifiManager$MulticastLock;", + &[(&wifi_lock_jstring).into()], + ) + .unwrap() + .l() + .unwrap(); + set_lock(&mut env, &wifi_lock, enabled); } pub fn get_battery_status() -> (f32, bool) { diff --git a/alvr/client_core/src/sockets.rs b/alvr/client_core/src/sockets.rs index e3a46228bd..914ec8f97e 100644 --- a/alvr/client_core/src/sockets.rs +++ b/alvr/client_core/src/sockets.rs @@ -14,7 +14,7 @@ impl AnnouncerSocket { let mut packet = [0; 56]; packet[0..ALVR_NAME.len()].copy_from_slice(ALVR_NAME.as_bytes()); - packet[16..24].copy_from_slice(&alvr_common::protocol_id().to_le_bytes()); + packet[16..24].copy_from_slice(&alvr_common::protocol_id_u64().to_le_bytes()); packet[24..24 + hostname.len()].copy_from_slice(hostname.as_bytes()); Ok(Self { socket, packet }) diff --git a/alvr/client_core/src/storage.rs b/alvr/client_core/src/storage.rs index c60f76cf15..35b76350ea 100644 --- a/alvr/client_core/src/storage.rs +++ b/alvr/client_core/src/storage.rs @@ -18,8 +18,8 @@ fn config_path() -> PathBuf { #[derive(Serialize, Deserialize)] pub struct Config { - pub protocol_id: u64, pub hostname: String, + pub protocol_id: String, } impl Default for Config { @@ -27,14 +27,14 @@ impl Default for Config { let mut rng = rand::thread_rng(); Self { - protocol_id: alvr_common::protocol_id(), hostname: format!( - "{}{}{}{}.client.alvr", + "{}{}{}{}.client", rng.gen_range(0..10), rng.gen_range(0..10), rng.gen_range(0..10), rng.gen_range(0..10), ), + protocol_id: alvr_common::protocol_id(), } } } diff --git a/alvr/common/src/version.rs b/alvr/common/src/version.rs index 207f2891ed..ce5ecd001d 100644 --- a/alvr/common/src/version.rs +++ b/alvr/common/src/version.rs @@ -26,14 +26,16 @@ pub fn is_stable() -> bool { // Semver compatible versions will produce the same protocol ID. Protocol IDs are not ordered // As a convention, encode/decode the protocol ID bytes as little endian. // Only makor and -pub fn protocol_id() -> u64 { - let protocol_string = if ALVR_VERSION.pre.is_empty() { +pub fn protocol_id() -> String { + if ALVR_VERSION.pre.is_empty() { ALVR_VERSION.major.to_string() } else { format!("{}-{}", ALVR_VERSION.major, ALVR_VERSION.pre) - }; + } +} - hash_string(&protocol_string) +pub fn protocol_id_u64() -> u64 { + hash_string(&protocol_id()) } // deprecated @@ -44,5 +46,5 @@ pub fn is_version_compatible(other_version: &Version) -> bool { format!("{}-{}", other_version.major, other_version.pre) }; - protocol_id() == hash_string(&protocol_string) + protocol_id_u64() == hash_string(&protocol_string) } diff --git a/alvr/server/Cargo.toml b/alvr/server/Cargo.toml index 4dbce34fc3..fa805dd28d 100644 --- a/alvr/server/Cargo.toml +++ b/alvr/server/Cargo.toml @@ -28,6 +28,7 @@ bincode = "1" bytes = "1" chrono = "0.4" fern = "0.6" +flume = "0.11" futures = "0.3" headers = "0.3" hyper = { version = "0.14", features = [ @@ -37,6 +38,7 @@ hyper = { version = "0.14", features = [ "runtime", "tcp", ] } +mdns-sd = "0.10" profiling = { version = "1", optional = true } reqwest = "0.11" # not used but webserver does not work without it. todo: investigate rosc = "0.10" diff --git a/alvr/server/src/connection.rs b/alvr/server/src/connection.rs index 6b81d858ce..d960a593c8 100644 --- a/alvr/server/src/connection.rs +++ b/alvr/server/src/connection.rs @@ -408,10 +408,10 @@ fn connection_pipeline( ClientListAction::SetDisplayName(display_name), ); - if client_protocol_id != alvr_common::protocol_id() { + if client_protocol_id != alvr_common::protocol_id_u64() { warn!( "Trusted client is incompatible! Expected protocol ID: {}, found: {}", - alvr_common::protocol_id(), + alvr_common::protocol_id_u64(), client_protocol_id, ); diff --git a/alvr/server/src/sockets.rs b/alvr/server/src/sockets.rs index 7e8e3f74aa..d5bdd809a1 100644 --- a/alvr/server/src/sockets.rs +++ b/alvr/server/src/sockets.rs @@ -1,13 +1,19 @@ -use alvr_common::{anyhow::Result, warn, ConnectionError, HandleTryAgain, ALVR_NAME}; +use alvr_common::{ + anyhow::{bail, Result}, + warn, ConnectionError, HandleTryAgain, ToAny, ALVR_NAME, +}; use alvr_sockets::{CONTROL_PORT, HANDSHAKE_PACKET_SIZE_BYTES, LOCAL_IP}; +use flume::TryRecvError; +use mdns_sd::{Receiver, ServiceDaemon, ServiceEvent}; use std::{ collections::HashMap, net::{IpAddr, UdpSocket}, }; pub struct WelcomeSocket { - socket: UdpSocket, buffer: [u8; HANDSHAKE_PACKET_SIZE_BYTES], + broadcast_receiver: UdpSocket, + mdns_receiver: Receiver, } impl WelcomeSocket { @@ -16,9 +22,12 @@ impl WelcomeSocket { // socket.set_read_timeout(Some(read_timeout))?; socket.set_nonblocking(true)?; + let mdns_receiver = ServiceDaemon::new()?.browse(alvr_sockets::MDNS_SERVICE_TYPE)?; + Ok(Self { - socket, buffer: [0; HANDSHAKE_PACKET_SIZE_BYTES], + broadcast_receiver: socket, + mdns_receiver, }) } @@ -27,7 +36,11 @@ impl WelcomeSocket { let mut clients = HashMap::new(); loop { - match self.socket.recv_from(&mut self.buffer).handle_try_again() { + match self + .broadcast_receiver + .recv_from(&mut self.buffer) + .handle_try_again() + { Ok((size, address)) => { if size == HANDSHAKE_PACKET_SIZE_BYTES && &self.buffer[..ALVR_NAME.len()] == ALVR_NAME.as_bytes() @@ -37,11 +50,11 @@ impl WelcomeSocket { protocol_id_bytes.copy_from_slice(&self.buffer[16..24]); let received_protocol_id = u64::from_le_bytes(protocol_id_bytes); - if received_protocol_id != alvr_common::protocol_id() { + if received_protocol_id != alvr_common::protocol_id_u64() { warn!( "Found incompatible client! Upgrade or downgrade\n{} {}, {} {}", "Expected protocol ID", - alvr_common::protocol_id(), + alvr_common::protocol_id_u64(), "Found", received_protocol_id ); @@ -70,6 +83,36 @@ impl WelcomeSocket { } } + loop { + match self.mdns_receiver.try_recv() { + Ok(event) => { + if let ServiceEvent::ServiceResolved(info) = event { + let hostname = info.get_hostname(); + let address = *info.get_addresses().iter().next().to_any()?; + + let protocol = info + .get_property_val_str(alvr_sockets::MDNS_PROTOCOL_KEY) + .to_any()?; + + if protocol != alvr_common::protocol_id() { + let msg = format!( + r#"Expected protocol ID "{}", found "{}""#, + alvr_common::protocol_id(), + protocol + ); + warn!( + "Found incompatible client {hostname}! Upgrade or downgrade\n{msg}" + ); + } + + clients.insert(hostname.into(), address); + } + } + Err(TryRecvError::Empty) => break, + Err(e) => bail!(e), + } + } + Ok(clients) } } diff --git a/alvr/sockets/src/lib.rs b/alvr/sockets/src/lib.rs index 3424317479..b912b79079 100644 --- a/alvr/sockets/src/lib.rs +++ b/alvr/sockets/src/lib.rs @@ -19,6 +19,9 @@ pub const HANDSHAKE_PACKET_SIZE_BYTES: usize = 56; // this may change in future pub const KEEPALIVE_INTERVAL: Duration = Duration::from_millis(500); pub const KEEPALIVE_TIMEOUT: Duration = Duration::from_secs(2); +pub const MDNS_SERVICE_TYPE: &str = "_alvr._tcp.local."; +pub const MDNS_PROTOCOL_KEY: &str = "protocol"; + fn set_socket_buffers( socket: &socket2::Socket, send_buffer_bytes: SocketBufferSize,