# Phantom Oden Integration

## Audio configuration
Please see the docs in Oden for more details (Top menu -> Help -> Manual).

JACK is needed for low latency audio streaming on Linux.

```shell
sudo apt install -y jackd2
```

### Jabra Speakerphone specifics
Start `jackd` with these settings (should be run at before Oden is started):
```shell
JACK_NO_AUDIO_RESERVATION=1 pasuspender -- /usr/bin/jackd -d alsa -d hw:USB -r 48000 -p 240 -n 3 -C -i 1 &
alsa_out -d hw:USB -r 48000 -p 240 -n 3 -c 2 &
```

This starts `jackd` with a single input channel from the USB device and then adds a output device using `alsa_out`.

### Other audio devices
See the Oden docs (Top menu -> Help -> Manual)

## Startup script
Configuration script(start_oden_streamer.sh):
```bash
#!/bin/bash

trap "pkill -P $$" EXIT

sudo /usr/bin/jetson_clocks

JACK_NO_AUDIO_RESERVATION=1 pasuspender -- /usr/bin/jackd -d alsa -d hw:USB -r 48000 -p 240 -n 3 -C -i 1 &
alsa_out -d hw:USB -r 48000 -p 240 -n 3 -c 2 &

sleep 15

cd /opt/oden-streamer
/opt/oden-streamer/oden-streamer --headless --configurator
```

## Oden Service:
Setup service for oden to be runned at startup(oden.service):
```
[Unit]
After=NetworkManager-wait-online.service
After=nvargus-daemon.service

[Service]
WorkingDirectory=/opt/oden-streamer
Environment=HOME=/home/voysys
ExecStart=/home/voysys/start_oden_streamer.sh
Restart=on-failure

[Install]
WantedBy=multi-user.target
```

Copy the oden.service and enable it:
```shell
sudo cp ./oden.service /etc/systemd/system/oden.service
sudo systemctl enable oden
```

## Barcode Scanner
The barcode scanner is currently only supported on Linux and Arm.
### Setup
For the barcode scanner to work some steps are necessary besides just compiling.

- The barcode scanner needs a license to be used, the plugin reads the license from the environment variable ```SCANNER_LICENSE``` which needs to be set. If the enviroment variable is not set it will look for the license in the same location as the Oden binary. The license lies in folder ```./barcode-reader-sys/thirdparty/DynamSoft/license.txt```
- The file ```libDynamsoftBarcodeReader.so``` need to be placed in the same location as the Phantom Streamer binary. The file is located at ```./barcode-reader-sys/thirdparty/DynamSoft/lib/amd64/``` or ```./barcode-reader-sys/thirdparty/DynamSoft/lib/aarch64/``` depending on architecture.
- The barcode scanner need a settings file. The plugin tries to get the path from env variable ```SNAP_USER_COMMON``` and open the file from that folder. If the env variable is not set it will look for the settings file in the same location as the binary. The file is located in ```./barcode-reader-sys/thirdparty/DynamSoft/scanner_config.json```
- The 2D video entity should have the same name as the ```stream_label``` in the QRRequest.
