feat: screen capture scaling / downsampling
Add a Scale option (1.0 native, 0.5 half, etc.) that downsamples the captured BGRA frame with bilinear interpolation before JPEG encoding. Config carries the scale factor; the GUI exposes a Scale dropdown (100%/75%/50%/25%) that applies live via SetConfig. Verified: OBS displays the image at the reduced resolution matching the selected scale, without restarting the stream.
This commit is contained in:
@@ -16,13 +16,14 @@ import (
|
||||
|
||||
// Config mirrors flinger.Config with JSON tags for persistence.
|
||||
type Config struct {
|
||||
Name string `json:"name"`
|
||||
Port int `json:"port"`
|
||||
Quality int `json:"quality"`
|
||||
FPS int `json:"fps"`
|
||||
Source string `json:"source"`
|
||||
Audio bool `json:"audio"`
|
||||
StreamIndex int `json:"stream_index"`
|
||||
Name string `json:"name"`
|
||||
Port int `json:"port"`
|
||||
Quality int `json:"quality"`
|
||||
FPS int `json:"fps"`
|
||||
Source string `json:"source"`
|
||||
Audio bool `json:"audio"`
|
||||
StreamIndex int `json:"stream_index"`
|
||||
Scale float64 `json:"scale"`
|
||||
// Announce is a *bool so an absent JSON key (older config files) keeps
|
||||
// the default instead of silently disabling announcements.
|
||||
Announce *bool `json:"announce"`
|
||||
@@ -40,6 +41,7 @@ func Default() Config {
|
||||
Source: c.Source,
|
||||
Audio: c.Audio,
|
||||
StreamIndex: c.StreamIndex,
|
||||
Scale: c.Scale,
|
||||
Announce: &announce,
|
||||
}
|
||||
}
|
||||
@@ -58,6 +60,7 @@ func (c Config) ToFlinger() flinger.Config {
|
||||
Source: c.Source,
|
||||
Audio: c.Audio,
|
||||
StreamIndex: c.StreamIndex,
|
||||
Scale: c.Scale,
|
||||
Announce: announce,
|
||||
}
|
||||
}
|
||||
@@ -111,6 +114,9 @@ func LoadFrom(path string) (Config, error) {
|
||||
if c.Source == "" {
|
||||
c.Source = d.Source
|
||||
}
|
||||
if c.Scale <= 0 || c.Scale > 1 {
|
||||
c.Scale = d.Scale
|
||||
}
|
||||
if c.Announce == nil {
|
||||
announce := true
|
||||
c.Announce = &announce
|
||||
|
||||
Reference in New Issue
Block a user