Skip to content

Commit

Permalink
livekit: Add simulcast option defaulted to enabled
Browse files Browse the repository at this point in the history
This enables simulcast for the LiveKit connection.
  • Loading branch information
bekriebel committed Aug 28, 2021
1 parent 93015b9 commit 4f1910d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
2 changes: 2 additions & 0 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
"LIVEKITAVCLIENT.livekitTraceHint": "Enables trace logging of the LiveKit client library",
"LIVEKITAVCLIENT.resetRoom": "Reset meeting room ID",
"LIVEKITAVCLIENT.resetRoomHint": "Reset the meeting room ID used for your A/V",
"LIVEKITAVCLIENT.simulcast": "Simulcast enabled",
"LIVEKITAVCLIENT.simulcastHint": "Uses simulcast video tracks with LiveKit",
"LIVEKITAVCLIENT.serverTypeFVTT": "LiveKit AVClient: Foundry VTT is not supported as a signalling server. Please set a custom signalling server under Audio/Video Configuration",
"WEBRTC.FVTTSignalingServer": "Foundry VTT (Not supported)"
}
1 change: 1 addition & 0 deletions src/LiveKitAVClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ export default class LiveKitAVClient extends AVClient {
// Set the livekit connection options
const livekitConnectionOptions: ConnectOptions = {
tracks: localTracks,
simulcast: getGame().settings.get(MODULE_NAME, "simulcast") === true,
};

if (
Expand Down
8 changes: 6 additions & 2 deletions src/LiveKitClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
TrackEvent,
VideoTrack,
} from "livekit-client";
import { LANG_NAME } from "./utils/constants";
import { LANG_NAME, MODULE_NAME } from "./utils/constants";
import * as log from "./utils/logging";
import { getGame } from "./utils/helpers";
import LiveKitAVClient from "./LiveKitAVClient";
Expand Down Expand Up @@ -256,7 +256,11 @@ export default class LiveKitClient {
await this.initializeVideoTrack();
if (this.videoTrack) {
await this.liveKitRoom?.localParticipant.publishTrack(
this.videoTrack
this.videoTrack,
{
simulcast:
getGame().settings.get(MODULE_NAME, "simulcast") === true,
}
);
const userVideoElement = ui.webrtc?.getUserVideoElement(
getGame().user?.id || ""
Expand Down
9 changes: 9 additions & 0 deletions src/utils/registerModuleSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ import { delayReload, getGame, registerModuleSetting } from "./helpers";
import * as log from "./logging";

export default function registerModuleSettings(): void {
registerModuleSetting({
name: "simulcast",
scope: "world",
config: true,
default: true,
type: Boolean,
onChange: () => getGame().webrtc?.connect(),
});

registerModuleSetting({
name: "resetRoom",
scope: "world",
Expand Down

0 comments on commit 4f1910d

Please sign in to comment.