Skip to content

Commit

Permalink
Merge branch 'master' into v20
Browse files Browse the repository at this point in the history
  • Loading branch information
zmerp committed Jan 10, 2024
2 parents 0a03dcf + da30886 commit 70375ef
Show file tree
Hide file tree
Showing 22 changed files with 247 additions and 171 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,14 @@ jobs:
- uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: '11'
java-version: '17'
- uses: android-actions/setup-android@v3
with:
packages: 'platforms;android-29'
- uses: nttld/setup-ndk@v1
id: setup-ndk
with:
ndk-version: r25c
ndk-version: r26b

- name: Build and package ALVR
id: build
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,17 @@ jobs:
target: aarch64-linux-android
override: true
- uses: Swatinem/rust-cache@v1
- uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: '17'
- uses: android-actions/setup-android@v3
with:
packages: 'platforms;android-29'
- uses: nttld/setup-ndk@v1
id: setup-ndk
with:
ndk-version: r25c
ndk-version: r26b

- name: Install deps
uses: actions-rs/cargo@v1
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Changelog

## v20.6.0

* Add tongue tracking for Quest Pro (by @zarik5)
* This is a breaking change in the protocol, but only affects Quest Pro users.
* Only VRCFT ALVR module v1.2.0 and up is supported
* Add Quest 3 emulation mode + icons for SteamVR HUD (by @Goodguy140 #1926)
* Add Type of Service (ToS) socket settings, tested only on Linux (by @Vixea #1946)
* Add software decoding option and fallback (by @20kdc #1933)
* Add Baseline encoding option for h264 (by @20kdc #1932)
* Fix ADB connection (by @The-personified-devil #1942)
* Fix rare bug preventing reconnections on wifi (by @zarik5)

## v20.5.0

* Fix Vulkan layer GPU loading (by @nairaner #1847)
Expand Down
2 changes: 1 addition & 1 deletion alvr/dashboard/src/dashboard/components/setup_wizard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ fn download_and_prepare_audio_script() -> alvr_common::anyhow::Result<std::path:
)
.call()?;

fs::write(&audio_script_path, response.into_string()?).unwrap();
fs::write(&audio_script_path, response.into_string()?)?;
fs::set_permissions(&audio_script_path, fs::Permissions::from_mode(0o755))?;

Ok(audio_script_path)
Expand Down
76 changes: 44 additions & 32 deletions alvr/xtask/flatpak/audio-flatpak-setup.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
#!/bin/bash

function get_alvr_playback_source_id() {
# Set either to 0 to prevent from creating audio or microphone sinks and instead you using own headset or microphone
USE_HEADSET_AUDIO=1
USE_HEADSET_MIC=1

function get_playback_sink_input_id() {
get_playback_id sink-inputs 'Sink Input' "$1"
}

function get_playback_source_output_id() {
get_playback_id source-outputs 'Source Output' "$1"
}

function get_playback_id() {
local last_node_name=''
local last_node_id=''
pactl list $1 | while read -r line; do
pactl list "$1" | while read -r line; do
node_id=$(echo "$line" | grep -oP "$2 #\K.+" | sed -e 's/^[ \t]*//')
node_name=$(echo "$line" | grep -oP 'node.name = "\K[^"]+' | sed -e 's/^[ \t]*//')
if [[ "$node_id" != '' ]] && [[ "$last_node_id" != "$node_id" ]]; then
Expand All @@ -19,52 +31,52 @@ function get_alvr_playback_source_id() {
done
}

function get_sink_id() {
function get_sink_id_by_name() {
local sink_name
sink_name=$1
pactl list short sinks | grep "$sink_name" | cut -d$'\t' -f1
}

function setup_mic() {
echo "Creating microphone sink & source and linking alvr playback to it"
# This sink is required so that it persistently auto-connects to alvr playback later
pactl load-module module-null-sink sink_name=ALVR-MIC-Sink media.class=Audio/Sink
# This source is required so that any app can use it as microphone
pactl load-module module-null-sink sink_name=ALVR-MIC-Source media.class=Audio/Source/Virtual
# We link them together
pw-link ALVR-MIC-Sink ALVR-MIC-Source
# And we assign playback of pipewire alsa playback to created alvr sink
pactl move-sink-input "$(get_alvr_playback_source_id sink-inputs 'Sink Input' 'ALSA plug-in [vrserver]')" "$(get_sink_id ALVR-MIC-Sink)"
if [[ $USE_HEADSET_MIC == 1 ]]; then
echo "Creating microphone sink & source and linking alvr playback to it"
# This sink is required so that it persistently auto-connects to alvr playback later
pactl load-module module-null-sink sink_name=ALVR-MIC-Sink media.class=Audio/Sink | tee -a /run/user/1000/alvr-audio
# This source is required so that any app can use it as microphone
pactl load-module module-null-sink sink_name=ALVR-MIC-Source media.class=Audio/Source/Virtual | tee -a /run/user/1000/alvr-audio
# We link them together
pw-link ALVR-MIC-Sink:monitor_FL ALVR-MIC-Source:input_FL
pw-link ALVR-MIC-Sink:monitor_FR ALVR-MIC-Source:input_FR
# And we assign playback of pipewire alsa playback to created alvr sink
pactl move-sink-input "$(get_playback_sink_input_id 'ALSA plug-in [vrserver]')" "$(get_sink_id_by_name ALVR-MIC-Sink)"
pactl set-default-source ALVR-MIC-Source
fi
}

function setup_audio() {
echo "Setting up audio"
pactl load-module module-null-sink sink_name=ALVR-AUDIO-Sink media.class=Audio/Sink
pactl set-default-sink ALVR-AUDIO-Sink
pactl move-source-output "$(get_alvr_playback_source_id source-outputs 'Source Output' 'ALSA plug-in [vrserver]')" "$(get_sink_id ALVR-AUDIO-Sink)"
function unload_modules() {
echo "Unloading audio, microphone sink & source"
while read -r line; do
pactl unload-module "$line"
done <"/run/user/1000/alvr-audio"
>/run/user/1000/alvr-audio
}

function unload_mic() {
echo "Unloading microphone sink & source"
pw-cli destroy ALVR-MIC-Sink
pw-cli destroy ALVR-MIC-Source
}

function unload_sink() {
echo "Unloading audio sink"
pw-cli destroy ALVR-AUDIO-Sink
function setup_audio() {
if [[ $USE_HEADSET_AUDIO == 1 ]]; then
echo "Setting up audio"
pactl load-module module-null-sink sink_name=ALVR-AUDIO-Sink media.class=Audio/Sink | tee -a /run/user/1000/alvr-audio
pactl set-default-sink ALVR-AUDIO-Sink
pactl move-source-output "$(get_playback_source_output_id 'ALSA plug-in [vrserver]')" "$(get_sink_id_by_name ALVR-AUDIO-Sink)"
fi
}

case $ACTION in
connect)
unload_sink
unload_mic
sleep 1
setup_mic
unload_modules
setup_audio
setup_mic
;;
disconnect)
unload_mic
unload_sink
unload_modules
;;
esac
3 changes: 3 additions & 0 deletions wiki/ALVR-Checklist.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* [ ] A 5Ghz router/access point or my PC can create its own 5Ghz hotspot

## Network settings

* [ ] My PC has a wired connection to the router/access point
* [ ] The access point is placed in sight of my designated playspace without any obstructions
* [ ] I'm using the 5ghz antenna of the router/access point
Expand All @@ -16,10 +17,12 @@
* [ ] The 5Ghz and 2.4Ghz parts of the access point have different SSIDs to prevent switching to 2.4ghz

## Software settings

* [ ] I have the latest Windows 10 updates
* [ ] I have a recent version of SteamVR

## Troubleshooting

* [ ] The firewall settings where successfully applied with the setup of ALVR
* [ ] I did not change the network settings since the installation of ALVR (Private/Public/Work)
* [ ] I did not move the installation folder of ALVR since the setup
Expand Down
26 changes: 11 additions & 15 deletions wiki/ALVR-client-and-streamer-on-separate-networks.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Here are explained two methods to connect PC and headset remotely, port-forwarding and ZeroTier. The primary purpose of this is connecting the headset to a Cloud PC (like ShadowPC).

## Port-forwarding

Port-forwarding allows to connect devices that are behind different NATs, i.e. local networks. You need to have administrator access to your router. This method has the best streaming performance.

**IMPORTANT**: ALVR does not use end-to-end encryption of the stream data. By using this method you need to be aware that the connection is vulnerable to "Man In The Middle" attacks.
Expand All @@ -24,22 +25,27 @@ You can now use ALVR to connect to your remote PC.
Comparing this to the port-forwarding method:

Pros:

* Does not require access to the router interface.
* You don't need to update the public IP often on the streamer.
* The connection in encrypted.

Cons:

* The streaming performance is worse. You may experience more glitches and loss of quality in the image and audio.

### Requirements

- [ZeroTier](https://www.zerotier.com/) for your PC
- ZeroTier APK for your Quest (you can find it online)
- SideQuest or some other method to install the ZeroTier APK onto your headset

### Installation

Use the "Install APK" function of SideQuest to install the ZeroTier APK to your Quest, and also download and install ZeroTier on your PC. After you've installed ZeroTier, follow Zerotier's official [Getting Started](https://zerotier.atlassian.net/wiki/spaces/SD/pages/8454145/Getting+Started+with+ZeroTier) guide to setup a network for ALVR. Join the network on both the Quest and the PC. On the Quest, make sure that the network is enabled by switching on the slider on the network in the list in the ZeroTier app (you may be prompted to allow ZeroTier to create a VPN connection).

After both your PC and your Quest are connected to the same ZeroTier network, we'll need to manually add your quest to the ALVR dashboard. To do so, we'll need to find your Quest's ZeroTier IP. There are two ways to do this.

- Go the the ZeroTier network page, find your quest under "Members", and copy the managed IP from there
- Or, in the ZeroTier app on your quest, click on the network you created. The IP is under the "Managed IPs" section at the bottom.

Expand All @@ -50,6 +56,7 @@ Next, we'll need to add the Quest to the ALVR dashboard. On your headset, launch
At this point, you should be ready to go. Have fun in VR!

### Troubleshooting

- If you can't get your Quest to connect to ALVR, and are stuck on the "Trust" screen, try to ping your Quest's managed IP address (the one we got earlier). If it says "no route to host" or something similar, your Quest can't see your PC. Try running through the steps above to make sure you didn't miss anything.

## Tailscale
Expand All @@ -64,6 +71,7 @@ https://tailscale.com/
Its pros and cons are similar to ZeroTier, but it's self-hosted and open-source if you care about privacy, though instead you need some knowledge about networking and server deploying.

### Requirements

- Compile [n2n](https://github.com/ntop/n2n) from source
- Or you can grab pre-built binaries from [here](https://github.com/lucktu/n2n) directly, compiled by lucktu.
- Some Linux distribution may have n2n, but be sure you're using the same version. Since the source code is v3, the following steps will also use v3 in the example below.
Expand All @@ -73,6 +81,7 @@ Its pros and cons are similar to ZeroTier, but it's self-hosted and open-source
- SideQuest or some other method to install the hin2n APK onto your headset

### Installation

We're going to use n2n v3, and set the port of _supernode_ to `1234` as the example. You can change `1234` to any port, but below `1024` requires root.

- Open port `1234` on your server's firewall (usually `iptables`, if you don't know what to do, ask Google).
Expand All @@ -94,27 +103,14 @@ We're going to use n2n v3, and set the port of _supernode_ to `1234` as the exam
- Once it's done, you're all set.

### Troubleshooting

- Make sure you can access to the supernode, your supernode should be run on a server with public IP, and you can ping it on your PC.
- If your Quest cannot connect to ALVR dashboard, ping the IP you assigned to Quest in hin2n. If it fails, try redoing the setup steps.
- If the edge binary or hin2n says the IP has already been assigned and not released by supernode, you can set IP address to another one in the same subnet like `192.168.100.123` to reassign a new IP to the device.
- If you're playing over WAN, you may see more glitches, higher stream latency, or lagger response with TCP. Use adaptive bitrate and UDP may improve your experience.

# ALVR v11 and Below

ALVR version Experimental v7 or newer is recommended for this configuration.

This configuration is **NOT** supported in ALVR v12. The latest release to still support this is v11.

To run ALVR client and ALVR streamer on separate networks (broadcast domains) the following things must be done:
1. UDP ports 9943 and 9944 of ALVR streamer must be accessible from Oculus Quest device (i.e. firewall openings must be made to allow Oculus Quest to connect to ALVR streamer UDP ports 9943 and 9944).
1. Oculus Quest must be connected to computer and command-line `adb shell am startservice -n "com.polygraphene.alvr/.ChangeSettings" --es "targetServers" "10.10.10.10"` must be run in Command Prompt to specify IP address of ALVR streamer (`10.10.10.10` must be substituted with IP address of ALVR streamer; the long line is a single command-line).
1. Next time when ALVR client will be started it should try to connect to the specified ALVR streamer. ALVR streamer should display the client in _Server_ tab (the same way local-network clients are displayed).


ALVR does **NOT** provide any kind of tunnel, NAT traversal etc. UDP ports 9943 and 9944 of ALVR streamer (VR gaming PC) must be accessible from ALVR client (Oculus Quest) otherwise this won't work.


**Important notes on security!**

* ALVR protocol does not have any encryption or authentication (apart from ALVR client IP address shown in ALVR streamer and the requirement to click _Connect_ on ALVR streamer).
* It is recommended to run ALVR via encrypted tunnel (VPN) over the internet. In case VPN is not an option, access to ALVR streamer (UDP ports 9943 and 9944) should be restricted by Windows Firewall (only connections from known IP addresses of ALVR clients should be allowed) and ALVR streamer should not be left running unattended.
* **Warning!** SteamVR allows to control desktop from VR headset (i.e. a **malicious ALVR client could take over the PC**).
Expand Down
28 changes: 7 additions & 21 deletions wiki/ALVR-in-distrobox.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ For installing you only really need couple of dependencies on host:
3. `sed` (for removing color in logs)
4. `pipewire` for fully automatic microphone, `pulseaudio` for basic audio support (automatic microphone is unsupported with it)
5. For nvidia - `CUDA` (distrobox passes through it and driver as well into the container and CUDA contains NVENC encoder for streaming)
6. If you don't have `newgidmap` command available, you need to install `shadow-utils`. (packages ubuntu-like: `newuidmap`, arch-like: `shadow`, mint: `uidmap`)

After you have installed required dependencies for your installation from above, open terminal in this repository folder and do:

Expand All @@ -31,13 +30,9 @@ After you have installed required dependencies for your installation from above,

In case if have errors during installation, please report the full log as-is (remove private info if you happen to have some) as an Issue.

But if you are just reinstalling it, please run `./uninstall.sh` first before trying to install again.

After full installation, you can use `./start-alvr.sh` to launch alvr automatically.

Script also downloads related apk file to install to headset into `installation` folder for you. Use Sidequest or ADB to install it.

**Experimental:** Prefixed installation is now available, which allows you to specify where to install relative to this folder. Use --prefix and --container-name to specify folder name and container name (you should specify both for this to work)

## Post-install ALVR & SteamVR Configuration

Expand All @@ -49,21 +44,17 @@ After installing ALVR you may want to configure it and steamvr to run at best qu

2. **Preferred framerate:** If you know that you will have lower fps than usual (for instance, VRChat), run at lower fps. This is because when reprojection (this is what allows for smooth view despite being at low fps) goes lower than twice the amount of specified framerate - it fails to reproject and will look worse. So for example, you can run at 72hz if you know you're expecting low framerate, and 120hz if you are going to play something like Beat Saber, which is unlikely to run at low fps.

3. **Encoder preset:** Balanced

4. **Game Audio & Microphone:** Set to pipewire as has been said in installation. ALVR uses default audio sink for audio, and doesn't care about volume (it's controlled only onboard audio on headset), and automatic audio scripts mutes default audio by default to prevent mirroring. As for microphone, every time ALVR is connected on headset, on connect script creates audio source named **ALVR-MIC-Source**, which can be used in game as default microphone, if you set it at least once. No need to un-set it back to default. And when headset disconnects it automatically clears audio source and restores back to previous microphone.
3. **Encoder preset:** Speed

5. **Bitrate:** Constant, bitrate: 350-450 mbps for h264 wireless/700 mbit-1 gbit cabled, 100-150 mbps for HEVC.
4. **Bitrate:** Constant, bitrate: 350-450 mbps for h264 wireless/700 mbit-1 gbit cabled, 100-150 mbps for HEVC (tested on Pico 4 ).

6. **Foveated rendering:** This highly depends on given headset, but generally default settings should be OK for Quest 2. For **pico neo 3** i would recommend setting center region width to 0.8 and height to 0.75, shifts to 0 and edge ratios can be set at 6-7, and for the same **pico neo 3** disable oculus foveation level and dynamic oculus foveation.
5. **Foveated rendering:** This highly depends on given headset, but generally default settings should be OK for Quest 2. For **pico neo 3** i would recommend setting center region width to 0.8 and height to 0.75, shifts to 0 and edge ratios can be set at 6-7, and for the same **pico neo 3** disable oculus foveation level and dynamic oculus foveation.

7. **Color correction:** Set sharpening to 1and if you like oversaturated image, bump saturation to 0.6.
6. **Color correction:** Set sharpening to 1and if you like oversaturated image, bump saturation to 0.6.

8. For **pico neo 3** left controller offsets (from top to bottom): Position -0.06, -0.03, -0.1; Rotation: 0, 3, 17.
7. For **pico neo 3** left controller offsets (from top to bottom): Position -0.06, -0.03, -0.1; Rotation: 0, 3, 17.

9. **Connection -> Stream Protocol:** TCP. This ensures that there would be no heavy artifacts if packet loss happens (until it's too severe), only slowdowns.

10. **Linux async reprojection:** keep it off, it's not needed anymore and client does reprojection better
8. **Connection -> Stream Protocol:** TCP. This ensures that there would be no heavy artifacts if packet loss happens (until it's too severe), only slowdowns.

### AMD-specific configuration:

Expand Down Expand Up @@ -95,12 +86,7 @@ Inside SteamVR you also may need to change settings to improve experience. Open

### Distrobox note:

* To enter container (for updating archlinux, installing additional software, and other reasons) you need to do the following:
1. `source ./setup-env.sh`

2. `distrobox-enter arch-alvr`

        This enters the container. Do note that `sudo` inside container doesn't have privliges to do anything as `root`, but that container has almost exactly the same rights as regular user, so deleting user files from that container **is** possible.
* Do note that `sudo` inside container doesn't have privliges to do anything as `root`, but that container has almost exactly the same rights as regular user, so deleting user files from that container **is** possible.

* You can add your steam library from outside the container after alvr installation as for container, `/home/user` folder is the same as on your host, so you can add it from inside distrobox steam.

Expand Down
Loading

0 comments on commit 70375ef

Please sign in to comment.