diff --git a/pkg/api/worker.go b/pkg/api/worker.go
index 045fa429..2b2fc4dd 100644
--- a/pkg/api/worker.go
+++ b/pkg/api/worker.go
@@ -64,6 +64,7 @@ type (
AppVideoInfo struct {
W int `json:"w"`
H int `json:"h"`
+ S int `json:"s"`
A float32 `json:"a"`
}
)
diff --git a/pkg/worker/caged/app/app.go b/pkg/worker/caged/app/app.go
index fcf34fd9..2fd0704b 100644
--- a/pkg/worker/caged/app/app.go
+++ b/pkg/worker/caged/app/app.go
@@ -6,6 +6,7 @@ type App interface {
AspectEnabled() bool
Init() error
ViewportSize() (int, int)
+ Scale() float64
Start()
Close()
diff --git a/pkg/worker/coordinatorhandlers.go b/pkg/worker/coordinatorhandlers.go
index d5d9dd8e..336af811 100644
--- a/pkg/worker/coordinatorhandlers.go
+++ b/pkg/worker/coordinatorhandlers.go
@@ -130,6 +130,7 @@ func (c *coordinator) HandleGameStart(rq api.StartGameRequest[com.Uid], w *Worke
W: m.VideoW,
H: m.VideoH,
A: app.AspectRatio(),
+ S: int(app.Scale()),
}})
if err != nil {
c.log.Error().Err(err).Msgf("wrap")
@@ -176,7 +177,7 @@ func (c *coordinator) HandleGameStart(rq api.StartGameRequest[com.Uid], w *Worke
response := api.StartGameResponse{Room: api.Room{Rid: r.Id()}, Record: w.conf.Recording.Enabled}
if r.App().AspectEnabled() {
ww, hh := r.App().ViewportSize()
- response.AV = &api.AppVideoInfo{W: ww, H: hh, A: r.App().AspectRatio()}
+ response.AV = &api.AppVideoInfo{W: ww, H: hh, A: r.App().AspectRatio(), S: int(r.App().Scale())}
}
return api.Out{Payload: response}
diff --git a/web/index.html b/web/index.html
index a760c3fc..87cdfe68 100644
--- a/web/index.html
+++ b/web/index.html
@@ -127,7 +127,7 @@
-
+
diff --git a/web/js/stream/stream.js b/web/js/stream/stream.js
index e1a0ef4b..1ec88d8e 100644
--- a/web/js/stream/stream.js
+++ b/web/js/stream/stream.js
@@ -175,19 +175,22 @@ const stream = (() => {
const fit = 'contain'
event.sub(APP_VIDEO_CHANGED, (payload) => {
- const {w, h, a} = payload
+ const {w, h, a, s} = payload
+
+ const scale = !s ? 1 : s;
+ const ww = w * scale;
+ const hh = h * scale;
state.aspect = a
- const a2 = w / h
+ const a2 = ww / hh
state.screen.style['object-fit'] = a.toFixed(6) !== a2.toFixed(6) ? 'fill' : fit
- state.h = payload.h
- state.w = Math.floor(payload.h * payload.a)
- // payload.a > 0 && (state.aspect = payload.a)
- state.screen.setAttribute('width', payload.w)
- state.screen.setAttribute('height', payload.h)
- state.screen.style.aspectRatio = state.aspect
+ state.h = hh
+ state.w = Math.floor(hh * a)
+ state.screen.setAttribute('width', '' + ww)
+ state.screen.setAttribute('height', '' + hh)
+ state.screen.style.aspectRatio = '' + state.aspect
})
return {