fix(casting): apply conservative bitrate cap on downgrade retry

The status-2100 downgrade retry overrode only the device profile's
MaxStreamingBitrate. Jellyfin uses the explicit getStreamUrl maxBitrate
request param as the effective ceiling, so a quality-menu bitrate would
survive the retry. Clamp options.maxBitrate to the fallback cap too.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Uruk
2026-05-21 02:36:25 +02:00
parent 5cfd110ad5
commit 73214f5d45

View File

@@ -120,13 +120,27 @@ export const loadCastMedia = async (
return { ok: false, error };
}
// Downgrade-on-failure: one retry with the safest possible profile.
// The bitrate cap must also be applied to the explicit getStreamUrl
// `maxBitrate` request param — Jellyfin uses that as the effective
// ceiling, so the conservative profile alone would not lower it.
try {
const fallback = detectCapabilities(params.device, {
profileMode: "force-h264",
});
await attemptLoad(params, {
const FALLBACK_MAX_BITRATE = 4_000_000;
const fallbackParams: CastLoadParams = {
...params,
options: {
...params.options,
maxBitrate: Math.min(
params.options?.maxBitrate ?? Number.POSITIVE_INFINITY,
FALLBACK_MAX_BITRATE,
),
},
};
await attemptLoad(fallbackParams, {
...fallback,
maxVideoBitrate: 4_000_000,
maxVideoBitrate: FALLBACK_MAX_BITRATE,
maxAudioChannels: 2,
});
return { ok: true };