feat: add bitrate measurement and quality presets

- sender tracks payload bytes; engine measures stream bitrate over a
  sliding window and exposes it in Status
- GUI status label and tray tooltip show the live bitrate (e.g. 36 Mbps)
- add a Preset dropdown (Low/Medium/High/Ultra) that sets quality+fps
  together and applies live via SetConfig

Verified: 36 Mbps shown for Medium (quality 70 @ 30fps) matches the
wire measurement.
This commit is contained in:
2026-09-19 17:53:49 +01:00
parent 95f47abadb
commit 583274d9e6
4 changed files with 172 additions and 3 deletions
+10
View File
@@ -37,6 +37,7 @@ type Sender struct {
port int
dropped atomic.Int64
bytes atomic.Int64
}
// New creates an unconnected Sender.
@@ -95,6 +96,10 @@ func (s *Sender) Send(b []byte) {
s.mu.Lock()
defer s.mu.Unlock()
// Count the packet once as produced bandwidth (independent of how many
// receivers are attached).
s.bytes.Add(int64(len(b)))
for c, ch := range s.conns {
switch {
case len(ch) > dropAt:
@@ -125,6 +130,11 @@ func (s *Sender) Dropped() int64 {
return s.dropped.Load()
}
// BytesSent returns the total number of payload bytes handed to Send.
func (s *Sender) BytesSent() int64 {
return s.bytes.Load()
}
// Close shuts down the listener and waits for all writer goroutines to
// drain. After Close returns the Sender must not be reused.
func (s *Sender) Close() {