Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 35 additions & 2 deletions app/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -1104,13 +1104,15 @@ const UI = {
if (val === null) {
val = WebUtil.readSetting(name, defVal);
}
val = UI.sanitizeSetting(name, val);
WebUtil.setSetting(name, val);
UI.updateSetting(name);
return val;
},

// Set the new value, update and disable form control setting
forceSetting(name, val, disable=true) {
val = UI.sanitizeSetting(name, val);
WebUtil.setSetting(name, val);
UI.updateSetting(name);
if (disable) {
Expand Down Expand Up @@ -1149,6 +1151,26 @@ const UI = {
}
},

// Ensure settings stay within supported bounds
sanitizeSetting(name, value) {
switch (name) {
case 'framerate': {
let numeric = parseInt(value, 10);
if (!Number.isFinite(numeric)) {
numeric = 30;
}
if (numeric < 10) {
numeric = 10;
} else if (numeric > 120) {
numeric = 120;
}
return String(numeric);
}
default:
return value;
}
},

// Save control setting to cookie
saveSetting(name) {
const ctrl = document.getElementById('noVNC_setting_' + name);
Expand All @@ -1160,6 +1182,13 @@ const UI = {
} else {
val = ctrl.value;
}
const sanitized = UI.sanitizeSetting(name, val);
if (sanitized !== val) {
if (ctrl && typeof ctrl.value !== 'undefined') {
ctrl.value = sanitized;
}
val = sanitized;
}
WebUtil.writeSetting(name, val);
//Log.Debug("Setting saved '" + name + "=" + val + "'");
return val;
Expand All @@ -1179,8 +1208,12 @@ const UI = {
val = true;
}
}

return val;
const sanitized = UI.sanitizeSetting(name, val);
const currentStr = (val === null || typeof val === 'undefined') ? null : String(val);
if (sanitized !== val && sanitized !== currentStr) {
WebUtil.writeSetting(name, sanitized);
}
return sanitized;
},

// These helpers compensate for the lack of parent-selectors and
Expand Down
4 changes: 2 additions & 2 deletions core/encodings.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ export const encodings = {
pseudoEncodingVideoTimeLevel0: -870,
pseudoEncodingVideoTimeLevel100: -770,

pseudoEncodingFrameRateLevel10: -2048,
pseudoEncodingFrameRateLevel60: -1998,
pseudoEncodingFrameRateLevel10: -4096,
pseudoEncodingFrameRateLevel120: -3986,
pseudoEncodingMaxVideoResolution: -1997,
pseudoEncodingVideoScalingLevel0: -1996,
pseudoEncodingVideoScalingLevel9: -1987,
Expand Down
10 changes: 7 additions & 3 deletions core/rfb.js
Original file line number Diff line number Diff line change
Expand Up @@ -622,8 +622,8 @@ export default class RFB extends EventTargetMixin {

get frameRate() { return this._frameRate; }
set frameRate(value) {
if (!Number.isInteger(value) || value < 1 || value > 120) {
Log.Error("frame rate must be an integer between 1 and 120");
if (!Number.isInteger(value) || value < 10 || value > 120) {
Log.Error("frame rate must be an integer between 10 and 120");
return;
}

Expand Down Expand Up @@ -3179,7 +3179,11 @@ export default class RFB extends EventTargetMixin {
encs.push(encodings.pseudoEncodingVideoTimeLevel0 + this.videoTime);
encs.push(encodings.pseudoEncodingVideoOutTimeLevel1 + this.videoOutTime - 1);
encs.push(encodings.pseudoEncodingVideoScalingLevel0 + this.videoScaling);
encs.push(encodings.pseudoEncodingFrameRateLevel10 + this.frameRate - 10);
const frameRate = Math.round(Math.max(10, Math.min(120, this.frameRate)));
if (frameRate !== this.frameRate) {
Log.Warn("Frame rate value " + this.frameRate + " adjusted to " + frameRate);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this.frameRate be assigned frameRate?

encs.push(encodings.pseudoEncodingFrameRateLevel10 + frameRate - 10);
encs.push(encodings.pseudoEncodingMaxVideoResolution);

// preferBandwidth choses preset settings. Since we expose all the settings, lets not pass this
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ <h1 class="noVNC_logo">
</li>
<li>
<label for="noVNC_setting_framerate">Frame Rate:</label>
<input id="noVNC_setting_framerate" type="number" min="1" max="120" value="30">
<input id="noVNC_setting_framerate" type="number" min="10" max="120" step="1" value="30">
</li>
<li>
<label for="noVNC_setting_jpeg_video_quality">Video JPEG Quality:</label>
Expand Down