feat(voice): add audio bitrate guild features and 96 kbps cap (#2703)

This commit is contained in:
Hampus authored and GitHub committed 2026-09-11 22:00:15 +02:00
1 parent cfa20b7093
commit 258fe6f742
24 files changed
+358 -61

No files matched your search

@@ -6,6 +6,7 @@ import {LimitResolver} from '@app/features/app/utils/LimitResolverAdapter';
import {isLimitToggleEnabled} from '@app/features/app/utils/LimitUtils';
import Channels from '@app/features/channel/state/Channels';
import type {VoiceState} from '@app/features/gateway/types/GatewayVoiceTypes';
import Guilds from '@app/features/guild/state/Guilds';
import Keybind from '@app/features/input/state/InputKeybind';
import {getVoiceContextEntranceSoundScope} from '@app/features/notification/utils/EntranceSoundScopes';
import {handleMediaPermissionBlocked} from '@app/features/permissions/system/commands/MacPermissionsModalCommands';
@@ -117,6 +118,7 @@ import {
getActiveVoiceProcessingMode,
resolveVoiceProcessingFromStateForDeviceLabel,
} from '@app/features/voice/utils/VoiceProcessingProfile';
import {resolveVoiceChannelBitrate} from '@fluxer/constants/src/GuildConstants';
import type {
VoiceEngineV2AudioControls,
VoiceEngineV2AudioMode,
@@ -606,7 +608,9 @@ export class VoiceEngineV2AppMediaExecutionAdapter extends Store {
}
private getMicrophonePublishOptions(channelId: string | null): TrackPublishOptions | undefined {
const channelBitrate = channelId ? Channels.getChannel(channelId)?.bitrate : null;
const channel = channelId ? Channels.getChannel(channelId) : null;
const guild = channel?.guildId ? Guilds.getGuild(channel.guildId) : null;
const channelBitrate = resolveVoiceChannelBitrate(channel?.bitrate, guild?.features);
const profile = resolveVoiceProcessingFromStateForDeviceLabel(VoiceSettings, this.resolveActiveInputDeviceLabel());
return buildMicrophonePublishOptions(channelBitrate, profile.mode);
}
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import {resolveVoiceChannelBitrate} from '@fluxer/constants/src/GuildConstants';
import {describe, expect, it} from 'vitest';
import {
buildMicrophonePublishOptions,
@@ -51,6 +52,15 @@ describe('buildMicrophonePublishOptions', () => {
red: true,
});
});
it('pins a call outside a guild to 64 kbps', () => {
expect(buildMicrophonePublishOptions(resolveVoiceChannelBitrate(null, null), 'voice')).toEqual({
audioPreset: {
maxBitrate: 64000,
priority: 'high',
},
red: true,
});
});
it('does not force stereo below the stereo voice threshold', () => {
expect(buildMicrophonePublishOptions(96000, 'studio')).toEqual({
audioPreset: {