Overview

Foundry Virtual Tabletop includes built-in technology to allow for audio/video (A/V) conferencing between all of the players in your game. WebRTC is an internet standard used by a number of video and audio communications softwares for Real Time Communications, using WebRTC allows Foundry VTT to connect players and GMs without the need for running a second video conferencing suite. There is some significant configuration required in order to use these functions.

If you are presently hosting your game via one of our Hosting Partners it is likely that the configuration of this feature has already been completed for you, and you simply need to enable it.

Configuring A/V Integration is an advanced feature of Foundry VTT and requires technical configuration.

This article will introduce you to the concepts of:

SSL
Secure Sockets Layer (SSL) Certificates are used to provide encrypted communication between a website and a browser. By using SSL to encrypt communications it can be reasonably assumed the communication between users is secure and private.
Peer-to-Peer Communication
All audio and video connections in Foundry VTT require every user connected to the server to also connect to all other users. If there is a breakdown in connection between a user and its peers, audio and video transmission for that user may be interrupted.
Relay Server
In addition to peer-to-peer connections, all users are connected to a relay server provided by Foundry VTT. This relay server acts as a middle-point, conveying streamed audio and video out to users who may not be able to establish peer-to-peer connections.
Signalling Server
The Signalling server is the portion of the A/V chat framework which ensures connections between users occur.

Video conferencing can consume a significant amount of bandwidth. If your upload speed is relatively low, you may wish to consider alternate services for video conferencing while running your games. This can be understandably inconvenient if the purpose of getting Foundry VTT was to contain your video and audio chat and have it display as an overlay- use of third party relay servers can help mitigate some of the network usage, but the best option if you have insufficient upload speed to support video conferencing is to host Foundry VTT through a third party service.

Note: If you are already using another program for video and audio chat during your games, do not feel obligated to configure A/V for Foundry VTT. If what you're doing presently works for you, there is no reason to switch!

Requirements

Unfortunately it isn't as easy to set up WebRTC as simply flipping a switch or checking a box. Every server is different and has different settings, which means that configuring WebRTC has a few necessary requirements before you can even begin. This process requires:

Enabling A/V Chat Integration

If you have already performed the necessary technical steps to configure the integration, set up your domain and configured your SSL Certificates, you can enable the A/V chat integration by following these steps:

  1. Access the Settings (gearwheel) sidebar tab
  2. Click 'Configure Settings'
  3. Click Configure Audio/Video
  4. Change the Audio/Video Conferencing Mode to either: transmit audio only, video only, or use both audio and video conferencing.
  5. Click Save Changes

When completed, this will enable the A/V chat UI and display frames for each connected user.

A/V Configuration

Audio Visual Configuration
The Audio/Video Configuration application.

From within the Foundry app, the AV Configuration panel is accessible from the Settings sidebar within your active World. This allows you to customize the A/V broadcast mode (including enabling or disabling it), configure a custom signalling or relay server, and designate your preferred webcam and microphone hardware. If no microphone or webcam appear in this list, the most likely cause is that the devices are already in use by another program. Refreshing the screen (ctrl+f5) after you have released the devices from other programs using them should resolve this.

Audio/Video Conferencing Mode
Used to select whether you wish to disable A/V, transmit audio only, video only, or use both audio and video conferencing.
Voice Broadcasting Mode
The method by which your microphone activates to transmit audio. If always enabled, the microphone will continually broadcast. Voice activation will activate the microphone only when it crosses a threshold of volume. Push to talk uses the assigned push-to-talk hotkey to trigger microphone activation while it is held down.
Push-to-Talk/Mute key:
Assign the keyboard key to be used to trigger Push to Talk. To assign a key, simply click into the input field and then press the keyboard key you wish to use. By default this is assigned to the backtick key: `
Video Capture Device
A list of available devices which can be used as a video source for video conferencing, choose your camera or video source here. If this list is empty or reads "Unknown Device", you may need to grant permission to use the camera for your browser, or to verify that no other programs are currently using the capture device.
Audio Capture Device
A list of available devices which can be used as an audio source, choose your microphone or audio source here. If this list is empty or reads "Unknown Device", you may need to grant permission to use the camera for your browser, or to verify that no other programs are currently using the capture device.
Audio Output Device
A list of available devices which FVTT should send audio-video to. By default, this is 'Default Device' which uses whichever device your OS uses as a primary sound output, but you can choose a specific output if you wish to output to headphones but not speakers, for example. (Please note that Firefox users will not see this option unless they have set media.setsinkid.enabled to true in their about:config).

For details on the configuration of the Server tab of A/V Configuration, please see discussion of relay and signalling servers below.

How A/V Integration Works

Peer to Peer AV
Audio/Video connections when peer-to-peer is functioning correctly.
AV Relay Server
A/V Relying upon the relay server when peer-to-peer connections are unavailable.

Audio-Video communication through Foundry VTT primarily uses peer-to-peer connections, which requires that all users (not just the server host) need to have UDP ports allowed through software firewalls and routers in order to properly connect.

The first diagram on the right shows an example of a peer-to-peer conference, all users are connected to one another. Notice how the connections are to one another, but do not actually pass through the Relay server. When one user speaks, they transmit audio and video directly to all other users in the game, and all other users receive that information directly without the user of a relay server. If the connections are not configured correctly, participants in the A/V conference may be unable to connect to each other and audio and video streams between those users will fail to appear.

The second diagram on the right demonstrates the way the Foundry VTT relay server works. If a user cannot establish a peer-to-peer connection with another user, the Foundry VTT relay server is used to pass information between those users instead. Notice that the GM as well as Player 1 and Player 2 are still connected through peer-to-peer connections, but Player 3 and Player 4 are only connected via the relay server. In this case, when the user speaks, they transmit audio and video to the relay server, which then re-transmits the stream to that user instead. This process places far more network overhead on the Foundry VTT server.

To allow connections through the FVTT Relay server, the following ports must be opened on any firewall software that is in use and a port forwarding rule must be created to direct these connections to your hosted server:

UDP primary port: 33478
UDP port range: 49152-65535

If you are self hosting Foundry VTT and you have not done any port-forwarding, then the relay server may not work correctly for you. If you are using a server such as AWS or DigitalOcean or any other VPS service, then as long as the proper ports are allowed access to the server, you shouldn't have any issues.

You can customize the signalling and relay servers used for A/V functionality within the AV Config application accessed through the Settings Sidebar. The Foundry VTT server also acts as a signalling server so there is nothing to do here either. As long as you and your users can connect to FVTT, you are good to go. FVTT also has support for using an external signalling server if you wish and the GameMaster can configure it in the Audio/Video Configuration window under the Server tab. Using a custom server might be preferred if you are having trouble setting up a relaying server, though you can also configure a custom relay server to use directly.

Configuring The Default Relay Server

Note: in addition to configuration via the options.json file, you can configure these options on a per-world basis from the Server tab of the A/V Configuration application.

Foundry VTT's relay server can be configured from the options.json file located in the Config directory, you can customize its behavior with the following fields (default values are given here if those keys are not specified) :

"turnListeningPort": 33478,
"turnListeningIps": ["0.0.0.0"],
"turnRelayIps": [],
"turnMinPort": 49152,
"turnMaxPort": 65535

Warning: If your host machine is behind a NAT you must configure port forwarding in your router to make sure UDP port 33478 and the UDP port range 49152-65535 are forwarded to your machine properly.

Using a Custom Relay Server

You may run a custom relay server using an external application such as coturn (a more advanced relay server optimized for heavy traffic, which supports many additional features). If you use such a custom relay and would like to tell Foundry VTT to use it by default for all players, or you would like to disable the use of the FVTT provided relay server entirely, you can do so by providing an array of configurations in the turnConfigs field in the options.json file.

"turnConfigs": [{
      "url": "turn:example.com:3478",
      "urls": ["turn:example.com:3478", "turns:example.com:5349"],
      "username": "my username",
      "credential": "my password"
    }
  ]

To disable Foundry's relay server, simply provide an empty list of turn configurations.

Using a Jitsi Server

Jitsi is a free, open-source voice conferencing platform which can be used to provide an alternative to peer-to-peer WebRTC communications. By using Jitsi, all users connect to the Jitsi server instead of connecting directly to each other. This often removes the necessity for port forwarding (if the Jitsi server is not hosted on your computer.) Through use of third party modules it is possible to WebRTC in Foundry Virtual Tabletop to use a Jitsi server for better performance and stability. Please see the following resources for more information about using Jitsi:

  1. The Jitsi WebRTC module.
  2. The excellent Jitsi Server Setup Instructions created by community member Solfolango.

The Signalling Server

WebRTC uses a signalling server to resolve how to connect one or more devices for the purposes of audio-video conferencing. Effectively, the Signalling server acts as a go-between which notifies users to connect peers for the purposes of peer-to-peer communications. Foundry VTT includes a default Signalling server which handles all of this, but its implementation is simplified in order to provide the most streamlined experience for users. By default, the Foundry VTT Signalling server is provided through use of the Open-easyRTC framework.

There are more complex implementations of WebRTC signalling servers, and FVTT allows you to configure and use a custom signalling server in much the same way as it allows configuration of relay servers. If you are intending to replace the signalling server with another EasyRTC server, this process is simple and can be access through the server tab of the Audio Visual Configuration as seen above.

It is possible to use other implementations of RTC signalling servers beyond EasyRTC, but this would require creating a module to override the WebRTC implementation used by Foundry VTT and is outside the scope of this article.

API References

To interact with AV programmatically, consider using the following API concepts:

AVMaster - The Master Audio/Video controller instance

AVConfig- The Audio/Video Conferencing Configuration Sheet

CameraViews - The Camera UI View