mirror of
https://github.com/novnc/noVNC.git
synced 2026-06-07 21:04:37 +00:00
adds qualityLevel property to RFB class for updating JPEG quality level encoding on the fly
This commit is contained in:
24
core/rfb.js
24
core/rfb.js
@@ -275,6 +275,8 @@ export default class RFB extends EventTargetMixin {
|
||||
Log.Warn("Specifying showDotCursor as a RFB constructor argument is deprecated");
|
||||
this._showDotCursor = options.showDotCursor;
|
||||
}
|
||||
|
||||
this._qualityLevel = 6;
|
||||
}
|
||||
|
||||
// ===== PROPERTIES =====
|
||||
@@ -337,6 +339,26 @@ export default class RFB extends EventTargetMixin {
|
||||
get background() { return this._screen.style.background; }
|
||||
set background(cssValue) { this._screen.style.background = cssValue; }
|
||||
|
||||
get qualityLevel() {
|
||||
return this._qualityLevel;
|
||||
}
|
||||
set qualityLevel(qualityLevel) {
|
||||
if (!Number.isInteger(qualityLevel) || qualityLevel < 0 || qualityLevel > 9) {
|
||||
Log.Error("qualityLevel must be an integer between 0 and 9");
|
||||
return;
|
||||
}
|
||||
|
||||
if (this._qualityLevel === qualityLevel) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._qualityLevel = qualityLevel;
|
||||
|
||||
if (this._rfb_connection_state === 'connected') {
|
||||
this._sendEncodings();
|
||||
}
|
||||
}
|
||||
|
||||
// ===== PUBLIC METHODS =====
|
||||
|
||||
disconnect() {
|
||||
@@ -1294,7 +1316,7 @@ export default class RFB extends EventTargetMixin {
|
||||
encs.push(encodings.encodingRaw);
|
||||
|
||||
// Psuedo-encoding settings
|
||||
encs.push(encodings.pseudoEncodingQualityLevel0 + 6);
|
||||
encs.push(encodings.pseudoEncodingQualityLevel0 + this._qualityLevel);
|
||||
encs.push(encodings.pseudoEncodingCompressLevel0 + 2);
|
||||
|
||||
encs.push(encodings.pseudoEncodingDesktopSize);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* noVNC: HTML5 VNC client
|
||||
* Copyright (C) 2018 The noVNC Authors
|
||||
* Copyright (C) 2020 The noVNC Authors
|
||||
* Licensed under MPL 2.0 or any later version (see LICENSE.txt)
|
||||
*/
|
||||
|
||||
@@ -52,3 +52,10 @@ if (typeof Object.assign != 'function') {
|
||||
window.CustomEvent = CustomEvent;
|
||||
}
|
||||
})();
|
||||
|
||||
/* Number.isInteger() (taken from MDN) */
|
||||
Number.isInteger = Number.isInteger || function isInteger(value) {
|
||||
return typeof value === 'number' &&
|
||||
isFinite(value) &&
|
||||
Math.floor(value) === value;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user