Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a setting to limit the bitrate. #50

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,11 @@
"LIVEKITAVCLIENT.WarningCannotBroadcastUserVideo": "You cannot enable the user's camera because they to not have permission to broadcast their video feed.",
"LIVEKITAVCLIENT.WarningCannotBroadcastUserAudio": "You cannot enable the user's microphone because they to not have permission to broadcast their audio feed.",
"LIVEKITAVCLIENT.WarningCannotEnableUserVideo": "You cannot enable the user's camera because they have hidden themselves.",
"LIVEKITAVCLIENT.WarningCannotEnableUserAudio": "You cannot enable the user's microphone because they have muted themselves."
"LIVEKITAVCLIENT.WarningCannotEnableUserAudio": "You cannot enable the user's microphone because they have muted themselves.",
"LIVEKITAVCLIENT.limitBitRate": "Limit Bitrate",
"LIVEKITAVCLIENT.limitBitRateHint": "Set a maximum bitrate and framerate values to conserve bandwidth.",
"LIVEKITAVCLIENT.maximumVideoRate": "Maximum bitrate (kbps)",
"LIVEKITAVCLIENT.maximumVideoRateHint": "The maximum bitrate that will be used for both audio and video tracks.",
"LIVEKITAVCLIENT.maximumFrameRate": "Maximum frame rate (kbps)",
"LIVEKITAVCLIENT.maximumFrameRateHint": "The maximum frame rate of the video tracks. Limit this to conserve bandwidth."
}
8 changes: 7 additions & 1 deletion lang/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,11 @@
"LIVEKITAVCLIENT.WarningCannotBroadcastUserVideo": "No puede habilitar la cámara del usuario porque no tiene permisos para enviar vídeo",
"LIVEKITAVCLIENT.WarningCannotBroadcastUserAudio": "No puede habilitar el micrófono del usuario porque no tiene permisos para enviar vídeo",
"LIVEKITAVCLIENT.WarningCannotEnableUserVideo": "No puede habilitar la cámara porque el usuario la ha desactivado",
"LIVEKITAVCLIENT.WarningCannotEnableUserAudio": "No puede habilitar el micrófono porque el usuario se ha silenciado"
"LIVEKITAVCLIENT.WarningCannotEnableUserAudio": "No puede habilitar el micrófono porque el usuario se ha silenciado",
"LIVEKITAVCLIENT.limitBitRate": "Limitar el Bitrate",
"LIVEKITAVCLIENT.limitBitRateHint": "Limitar el bitrate máximo para reducir el consumo de ancho de banda",
"LIVEKITAVCLIENT.maximumVideoRate": "Bitrate máximo (kbps)",
"LIVEKITAVCLIENT.maximumVideoRateHint": "El bitrate máximo que se usara para la videoconferencia.",
"LIVEKITAVCLIENT.maximumFrameRate": "Fotogramas máximos (kbps)",
"LIVEKITAVCLIENT.maximumFrameRateHint": "El número máximo de fotogramas por minuto. Poner un valor más pequeño para reducir el consumo de ancho de banda"
}
10 changes: 10 additions & 0 deletions src/LiveKitClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1467,6 +1467,16 @@ export default class LiveKitClient {
simulcast: true,
videoSimulcastLayers: [VideoPresets43.h120, VideoPresets43.h240],
};
if (getGame().settings.get(MODULE_NAME, "limitBitRate")) {
const maxBitRate = getGame().settings.get(MODULE_NAME, "maximumVideoRate") as number;
const maxFrameRate = getGame().settings.get(MODULE_NAME, "maximumFrameRate") as number;
if (maxBitRate && maxFrameRate) {
trackPublishOptions.videoEncoding =
{maxBitrate: maxBitRate * 1000, maxFramerate: maxFrameRate}
} else {
log.warn("Invalid video encoding settings");
}
}

if (getGame().settings.get(MODULE_NAME, "audioMusicMode")) {
const audioMusicModeRate =
Expand Down
28 changes: 28 additions & 0 deletions src/utils/registerModuleSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,32 @@ export default function registerModuleSettings(): void {
type: Boolean,
onChange: () => delayReload(),
});

registerModuleSetting({
name: "limitBitRate",
scope: "world",
config: true,
default: false,
type: Boolean,
onChange: () => delayReload(),
});

registerModuleSetting<number>({
name: "maximumVideoRate",
scope: "world",
config: getGame().settings.get(MODULE_NAME, "limitBitRate") === true,
default: 300,
type: Number,
onChange: () => delayReload(),
});

registerModuleSetting<number>({
name: "maximumFrameRate",
scope: "world",
config: getGame().settings.get(MODULE_NAME, "limitBitRate") === true,
default: 60,
type: Number,
onChange: () => delayReload(),
});

}