feat(stream): per-session quality cap from web

Adds WebRTCSession.Quality to the sync payload so the daemon can pick a
MaxHeight + bitrate per session instead of using the global config cap.

resolveQualityCap() maps the label to a (height, b:v) pair and
buildStreamSource() promotes a passthrough decision to ActionTranscodeVideo
when the source resolution exceeds the cap (4K source on a phone client
with quality="720p" must transcode, not pass-through).

Also lands the transcode-on-by-default fix for legacy configs without a
[downloads.transcode] section so existing installs pick up h264+aac
fallback for HEVC/AC3 content without re-running setup.
This commit is contained in:
Deivid Soto 2026-05-07 10:13:45 +02:00
parent 66ac79664b
commit 70f7337226
4 changed files with 97 additions and 4 deletions

View file

@ -199,6 +199,32 @@ func Load(path string) (Config, error) {
"stun:stun1.l.google.com:19302",
}
}
// Auto-enable transcode for the in-browser player when WebRTC is on
// AND the user hasn't explicitly opted out. The struct's Enabled
// field is `false` for legacy configs because the field didn't
// exist when they were written; we treat "no transcode section at
// all" as "use defaults" rather than "off".
tc := &cfg.Download.Transcode
if !tc.Enabled && tc.HWAccel == "" && tc.Preset == "" && tc.VideoBitrate == "" {
tc.Enabled = true
}
if tc.Enabled {
if tc.HWAccel == "" {
tc.HWAccel = "auto"
}
if tc.Preset == "" {
tc.Preset = "veryfast"
}
if tc.VideoBitrate == "" {
tc.VideoBitrate = "5M"
}
if tc.AudioBitrate == "" {
tc.AudioBitrate = "192k"
}
if tc.MaxConcurrent == 0 {
tc.MaxConcurrent = 2
}
}
}
return cfg, nil