Skip to content

Commit 8c7675f

Browse files
committed
make scaling client persistent and applied on land
1 parent 6e1ca3c commit 8c7675f

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

addons/gst-web-core/selkies-core.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ let wakeLockSentinel = null;
5858
let currentEncoderMode = 'x264enc-stiped';
5959
let useCssScaling = false;
6060
let trackpadMode = false;
61+
let scalingDPI = 96;
6162
function setRealViewportHeight() {
6263
const vh = window.innerHeight * 0.01;
6364
document.documentElement.style.setProperty('--vh', `${vh}px`);
@@ -267,6 +268,8 @@ useCssScaling = getBoolParam('useCssScaling', false);
267268
setBoolParam('useCssScaling', useCssScaling);
268269
trackpadMode = getBoolParam('trackpadMode', false);
269270
setBoolParam('trackpadMode', trackpadMode);
271+
scalingDPI = getIntParam('SCALING_DPI', 96);
272+
setIntParam('SCALING_DPI', scalingDPI);
270273

271274
if (isSharedMode) {
272275
manualWidth = 1280;
@@ -1897,6 +1900,8 @@ function handleSettingsMessage(settings) {
18971900
if (settings.SCALING_DPI !== undefined) {
18981901
const dpi = parseInt(settings.SCALING_DPI, 10);
18991902
if (!isNaN(dpi)) {
1903+
scalingDPI = dpi;
1904+
setIntParam('SCALING_DPI', scalingDPI);
19001905
console.log(`Applied SCALING_DPI setting: ${dpi}.`);
19011906
if (!isSharedMode && websocket && websocket.readyState === WebSocket.OPEN) {
19021907
const message = `s,${dpi}`;
@@ -2597,6 +2602,7 @@ function handleDecodedFrame(frame) { // frame.codedWidth/Height are physical pix
25972602
else if (unprefixedKey === 'h264_paintover_crf') serverExpectedKey = 'pixelflux_h264_paintover_crf';
25982603
else if (unprefixedKey === 'h264_paintover_burst_frames') serverExpectedKey = 'pixelflux_h264_paintover_burst_frames';
25992604
else if (unprefixedKey === 'use_paint_over_quality') serverExpectedKey = 'pixelflux_use_paint_over_quality';
2605+
else if (unprefixedKey === 'SCALING_DPI') serverExpectedKey = 'webrtc_SCALING_DPI';
26002606

26012607
if (serverExpectedKey) {
26022608
let value = localStorage.getItem(key);
@@ -2618,6 +2624,7 @@ function handleDecodedFrame(frame) { // frame.codedWidth/Height are physical pix
26182624
'pixelflux_paint_over_jpeg_quality',
26192625
'pixelflux_h264_paintover_crf',
26202626
'pixelflux_h264_paintover_burst_frames',
2627+
'webrtc_SCALING_DPI',
26212628
];
26222629
if (booleanSettingKeys.includes(serverExpectedKey)) {
26232630
value = (value === 'true');

addons/selkies-dashboard/src/components/Sidebar.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ function Sidebar({ isOpen }) {
694694
localStorage.getItem(getPrefixedKey("h264_streaming_mode")) === "true"
695695
);
696696
const [selectedDpi, setSelectedDpi] = useState(
697-
parseInt(localStorage.getItem("scalingDPI"), 10) || DEFAULT_SCALING_DPI
697+
parseInt(localStorage.getItem(getPrefixedKey("SCALING_DPI")), 10) || DEFAULT_SCALING_DPI
698698
);
699699
const [manualWidth, setManualWidth] = useState(localStorage.getItem(getPrefixedKey("manualWidth")) || "");
700700
const [manualHeight, setManualHeight] = useState(localStorage.getItem(getPrefixedKey("manualHeight")) || "");

src/selkies/selkies.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1584,6 +1584,7 @@ def get_str(k, d):
15841584
parsed["h264_paintover_crf"] = get_int("pixelflux_h264_paintover_crf", self.h264_paintover_crf)
15851585
parsed["h264_paintover_burst_frames"] = get_int("pixelflux_h264_paintover_burst_frames", self.h264_paintover_burst_frames)
15861586
parsed["use_paint_over_quality"] = get_bool("pixelflux_use_paint_over_quality", self.use_paint_over_quality)
1587+
parsed["scaling_dpi"] = get_int("webrtc_SCALING_DPI", 96)
15871588
data_logger.debug(f"Parsed client settings: {parsed}")
15881589
return parsed
15891590

@@ -1695,6 +1696,23 @@ async def _apply_client_settings(
16951696
if self.app.audio_bitrate != settings["audioBitRate"]:
16961697
self.app.audio_bitrate = settings["audioBitRate"]
16971698

1699+
if "scaling_dpi" in settings:
1700+
dpi_value = settings["scaling_dpi"]
1701+
data_logger.info(f"Applying SCALING_DPI from initial settings: {dpi_value}")
1702+
if await set_dpi(dpi_value):
1703+
data_logger.info(f"Successfully set DPI to {dpi_value} from initial settings.")
1704+
else:
1705+
data_logger.error(f"Failed to set DPI to {dpi_value} from initial settings.")
1706+
1707+
if CURSOR_SIZE > 0:
1708+
calculated_cursor_size = int(round(dpi_value / 96.0 * CURSOR_SIZE))
1709+
new_cursor_size = max(1, calculated_cursor_size)
1710+
data_logger.info(f"Attempting to set cursor size to {new_cursor_size} based on initial DPI.")
1711+
if await set_cursor_size(new_cursor_size):
1712+
data_logger.info(f"Successfully set cursor size to {new_cursor_size}.")
1713+
else:
1714+
data_logger.error(f"Failed to set cursor size to {new_cursor_size}.")
1715+
16981716
if "videoBufferSize" in settings:
16991717
setattr(self.app, "video_buffer_size", settings["videoBufferSize"])
17001718
async with self._pipeline_lock:

0 commit comments

Comments
 (0)