MCPcopy Create free account
hub / github.com/TigerVNC/tigervnc / autoSelectFormatAndEncoding

Method autoSelectFormatAndEncoding

java/com/tigervnc/vncviewer/CConn.java:377–427  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

375 // with something more intelligent at the server end.
376 //
377 private void autoSelectFormatAndEncoding()
378 {
379 long kbitsPerSecond = sock.inStream().kbitsPerSecond();
380 long timeWaited = sock.inStream().timeWaited();
381 boolean newFullColour = fullColor.getValue();
382 int newQualityLevel = qualityLevel.getValue();
383
384 // Always use Tight
385 setPreferredEncoding(Encodings.encodingTight);
386
387 // Check that we have a decent bandwidth measurement
388 if ((kbitsPerSecond == 0) || (timeWaited < 100))
389 return;
390
391 // Select appropriate quality level
392 if (!noJpeg.getValue()) {
393 if (kbitsPerSecond > 16000)
394 newQualityLevel = 8;
395 else
396 newQualityLevel = 6;
397
398 if (newQualityLevel != qualityLevel.getValue()) {
399 vlog.info("Throughput "+kbitsPerSecond+
400 " kbit/s - changing to quality "+newQualityLevel);
401 qualityLevel.setParam(newQualityLevel);
402 setQualityLevel(newQualityLevel);
403 }
404 }
405
406 if (server.beforeVersion(3, 8)) {
407 // Xvnc from TightVNC 1.2.9 sends out FramebufferUpdates with
408 // cursors "asynchronously". If this happens in the middle of a
409 // pixel format change, the server will encode the cursor with
410 // the old format, but the client will try to decode it
411 // according to the new format. This will lead to a
412 // crash. Therefore, we do not allow automatic format change for
413 // old servers.
414 return;
415 }
416
417 // Select best color level
418 newFullColour = (kbitsPerSecond > 256);
419 if (newFullColour != fullColor.getValue()) {
420 if (newFullColour)
421 vlog.info("Throughput "+kbitsPerSecond+ " kbit/s - full color is now enabled");
422 else
423 vlog.info("Throughput "+kbitsPerSecond+ " kbit/s - full color is now disabled");
424 fullColor.setParam(newFullColour);
425 updatePixelFormat();
426 }
427 }
428
429 // updatePixelFormat() requests an update from the server, having set the
430 // format and encoding appropriately.

Callers 1

framebufferUpdateEndMethod · 0.95

Calls 10

updatePixelFormatMethod · 0.95
inStreamMethod · 0.80
infoMethod · 0.80
getValueMethod · 0.65
kbitsPerSecondMethod · 0.45
timeWaitedMethod · 0.45
setPreferredEncodingMethod · 0.45
setParamMethod · 0.45
setQualityLevelMethod · 0.45
beforeVersionMethod · 0.45

Tested by

no test coverage detected