default jpeg

This commit is contained in:
KingKDot
2026-07-30 14:39:10 -05:00
parent 9979955a49
commit 91e9b3196a
5 changed files with 47 additions and 96 deletions
+4 -29
View File
@@ -1736,11 +1736,7 @@ func desktopCodec() string {
}
func backstageCodec() string {
codec := selectedCodec(&backstageOverrideCodec)
if codec == "hevc" {
return "jpeg"
}
return codec
return "jpeg"
}
func SetDesktopQualityAndCodec(quality int, codec string) {
@@ -1792,36 +1788,15 @@ func SetDesktopQualityAndCodec(quality int, codec string) {
}
}
func SetBackstageQualityAndCodec(quality int, codec string) {
previousCodec := backstageCodec()
func SetBackstageQualityAndCodec(quality int, _ string) {
if quality > 0 {
if quality > 100 {
quality = 100
}
backstageOverrideQuality.Store(int64(quality))
}
s := strings.ToLower(strings.TrimSpace(codec))
if s == "h264" && !h264Available() {
detail := h264AvailabilityDetail()
log.Printf("capture: requested backstage codec=h264 but unavailable (%s); forcing codec=jpeg", detail)
s = "jpeg"
}
switch s {
case "raw", "rgba", "jpeg", "h264":
backstageOverrideCodec.Store(s)
backstageH264WarnOnce = sync.Once{}
if s != "h264" {
resetH264Encoderbackstage()
}
if previousCodec != s && s == "h264" {
backstageLastKeyframe.Store(0)
webrtcpub.RequestKeyframe(webrtcpub.Kindbackstage)
}
case "":
default:
backstageOverrideCodec.Store("jpeg")
resetH264Encoderbackstage()
}
backstageOverrideCodec.Store("jpeg")
resetH264Encoderbackstage()
}
func Nowbackstage(ctx context.Context, env *rt.Env) error {
@@ -77,6 +77,20 @@ func TestDesktopAndBackstageCodecSelectionsAreIndependent(t *testing.T) {
}
}
func TestBackstageCodecIsAlwaysJPEG(t *testing.T) {
t.Cleanup(resetCodecSelectionForTest)
for _, requested := range []string{"", "raw", "rgba", "h264", "hevc", "invalid-codec"} {
SetBackstageQualityAndCodec(73, requested)
if got := backstageCodec(); got != "jpeg" {
t.Fatalf("backstage codec = %q after requesting %q, want jpeg", got, requested)
}
}
if got := backstageJPEGQuality(); got != 73 {
t.Fatalf("backstage quality = %d, want 73", got)
}
}
func TestSwitchingToH264RequestsRecoveryPoint(t *testing.T) {
if !h264Available() {
t.Skip("h264 is unavailable in this build")