|
| 1 | +# Voice |
| 2 | + |
| 3 | +**Currently only WebRTC connections are supported. UDP connections will be dropped** |
| 4 | + |
| 5 | +Voice support is left as an optional dependency in {{ project.name }}, which means that it is disabled by default unless you decide to install additional dependencies. {{ project.name }} is designed so that anyone can develop a voice package compatible with the project as long as the implementation adheres to the [WebRTC types]({{ repositories.base_url }}/{{ repositories.voice_types }}). Currently there are two sample implementations which can be used: |
| 6 | + |
| 7 | +- [Medooze Implementation]({{ repositories.base_url }}/{{ repositories.voice_medooze }}) - Supports video&audio for guild voice, DM voice, as well as GoLive streams. Only supports Linux & MacOS environments. |
| 8 | +- [Mediasoup Implementation]({{ repositories.base_url }}/{{ repositories.voice_mediasoup }}) - Supports audio only for guild voice, DM voice, and GoLive streams. Supports Windows, Linux, and MacOS environments |
| 9 | + |
| 10 | +## Configuring Voice Gateway |
| 11 | + |
| 12 | +By default the Voice Gateway is set to run on port 3004. You can change this default configuration by setting your desired port it in your `.env`: |
| 13 | + |
| 14 | +```.env |
| 15 | +WRTC_WS_PORT=3004 |
| 16 | +``` |
| 17 | + |
| 18 | +You also have to configure the Voice Gateway endpoint in your database. In table `config` you can set the default region endpoint to your Voice Gateway domain. It is set to `localhost:3004` by default: |
| 19 | + |
| 20 | +``` |
| 21 | +"regions_available_0_endpoint": "localhost:3004" |
| 22 | +``` |
| 23 | + |
| 24 | +### Nginx reverse proxy for Voice Gateway |
| 25 | + |
| 26 | +You will likely want to set your voice gateway behind a reverse proxy. Here's a sample Nginx configuration: |
| 27 | + |
| 28 | +```nginx |
| 29 | +server { |
| 30 | + # Change server_name |
| 31 | + server_name voice.example.com; |
| 32 | + listen 80; |
| 33 | +
|
| 34 | + location / { |
| 35 | + # Only change this if Nginx and {{ project.name }} are not on the same machine. |
| 36 | + proxy_pass http://127.0.0.1:3004; |
| 37 | + proxy_set_header Host $host; |
| 38 | + proxy_pass_request_headers on; |
| 39 | + add_header Last-Modified $date_gmt; |
| 40 | + add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0'; |
| 41 | + proxy_set_header X-Real-IP $remote_addr; |
| 42 | + proxy_set_header X-Forwarded-Proto https; |
| 43 | + proxy_set_header X-Forwarded-For $remote_addr; |
| 44 | + proxy_set_header X-Forwarded-Host $remote_addr; |
| 45 | + proxy_no_cache 1; |
| 46 | + proxy_cache_bypass 1; |
| 47 | +
|
| 48 | + # This is important. It allows Websocket connections through NGINX. |
| 49 | + proxy_set_header Upgrade $http_upgrade; |
| 50 | + proxy_set_header Connection "upgrade"; |
| 51 | + } |
| 52 | +} |
| 53 | +``` |
| 54 | + |
| 55 | +## Configuring Voice Library |
| 56 | + |
| 57 | +You can install one of the provided sample implementations or you can choose to install another third-party one. Installation process will be the same regardless: |
| 58 | + |
| 59 | +### Medooze implementation installation |
| 60 | + |
| 61 | +1. First install the package in your {{ project.name }} server: |
| 62 | + |
| 63 | + ``` |
| 64 | + npm install {{ npm_packages.voice_medooze }} --no-save |
| 65 | + ``` |
| 66 | +
|
| 67 | +2. Configure the package name in your {{ project.name }} server `.env`: |
| 68 | +
|
| 69 | + ``` |
| 70 | + WRTC_LIBRARY={{ npm_packages.voice_medooze }} |
| 71 | + ``` |
| 72 | +
|
| 73 | +3. Configure the public IP for your WebRTC server in your {{ project.name }} server `.env`. This should be a public IP that can be accessed from the internet if this is a production instance. It will be the address that will get sent to the client during the WebRTC connection negotiation: |
| 74 | +
|
| 75 | + ``` |
| 76 | + WRTC_PUBLIC_IP=127.0.0.1 |
| 77 | + ``` |
| 78 | +
|
| 79 | +### Mediasoup implementation installation |
| 80 | +
|
| 81 | +The process is exactly the same as the Medooze installation, just replace the package name in the commands with ` {{ npm_packages.voice_mediasoup }} ` |
0 commit comments