Add ability to set compression level

Fixes github issue #1382.
This commit is contained in:
Samuel Mannehed
2020-05-01 16:14:15 +02:00
parent a672168d4d
commit 479d8cefd1
6 changed files with 155 additions and 1 deletions

View File

@@ -278,6 +278,7 @@ export default class RFB extends EventTargetMixin {
}
this._qualityLevel = 6;
this._compressionLevel = 2;
}
// ===== PROPERTIES =====
@@ -360,6 +361,26 @@ export default class RFB extends EventTargetMixin {
}
}
get compressionLevel() {
return this._compressionLevel;
}
set compressionLevel(compressionLevel) {
if (!Number.isInteger(compressionLevel) || compressionLevel < 0 || compressionLevel > 9) {
Log.Error("compressionLevel must be an integer between 0 and 9");
return;
}
if (this._compressionLevel === compressionLevel) {
return;
}
this._compressionLevel = compressionLevel;
if (this._rfb_connection_state === 'connected') {
this._sendEncodings();
}
}
// ===== PUBLIC METHODS =====
disconnect() {
@@ -1411,7 +1432,7 @@ export default class RFB extends EventTargetMixin {
// Psuedo-encoding settings
encs.push(encodings.pseudoEncodingQualityLevel0 + this._qualityLevel);
encs.push(encodings.pseudoEncodingCompressLevel0 + 2);
encs.push(encodings.pseudoEncodingCompressLevel0 + this._compressionLevel);
encs.push(encodings.pseudoEncodingDesktopSize);
encs.push(encodings.pseudoEncodingLastRect);