mirror of
https://github.com/openstf/stf
synced 2025-10-05 02:29:26 +02:00
Support variable bit depths. Fix color issues.
This commit is contained in:
parent
9d20484dcb
commit
977b8c198e
3 changed files with 41 additions and 10 deletions
|
@ -1,5 +1,6 @@
|
||||||
var net = require('net')
|
var net = require('net')
|
||||||
var util = require('util')
|
var util = require('util')
|
||||||
|
var os = require('os')
|
||||||
|
|
||||||
var syrup = require('stf-syrup')
|
var syrup = require('stf-syrup')
|
||||||
var Promise = require('bluebird')
|
var Promise = require('bluebird')
|
||||||
|
@ -65,6 +66,9 @@ module.exports = syrup.serial()
|
||||||
, frameHeight: 0
|
, frameHeight: 0
|
||||||
, sentFrameTime: null
|
, sentFrameTime: null
|
||||||
, updateRequests: 0
|
, updateRequests: 0
|
||||||
|
, frameConfig: {
|
||||||
|
format: jpeg.FORMAT_RGB
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var pointerTranslator = new PointerTranslator()
|
var pointerTranslator = new PointerTranslator()
|
||||||
|
@ -115,7 +119,9 @@ module.exports = syrup.serial()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var decoded = jpeg.decompressSync(connState.lastFrame)
|
var decoded = jpeg.decompressSync(
|
||||||
|
connState.lastFrame, connState.frameConfig)
|
||||||
|
|
||||||
conn.writeFramebufferUpdate([
|
conn.writeFramebufferUpdate([
|
||||||
{ xPosition: 0
|
{ xPosition: 0
|
||||||
, yPosition: 0
|
, yPosition: 0
|
||||||
|
@ -150,6 +156,35 @@ module.exports = syrup.serial()
|
||||||
maybeSendFrame()
|
maybeSendFrame()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
conn.on('formatchange', function(format) {
|
||||||
|
var same = os.endianness() == 'BE' == format.bigEndianFlag
|
||||||
|
switch (format.bitsPerPixel) {
|
||||||
|
case 8:
|
||||||
|
connState.frameConfig = {
|
||||||
|
format: jpeg.FORMAT_GRAY
|
||||||
|
}
|
||||||
|
break
|
||||||
|
case 24:
|
||||||
|
connState.frameConfig = {
|
||||||
|
format: ((format.redShift > format.blueShift) === same)
|
||||||
|
? jpeg.FORMAT_BGR
|
||||||
|
: jpeg.FORMAT_RGB
|
||||||
|
}
|
||||||
|
break
|
||||||
|
case 32:
|
||||||
|
connState.frameConfig = {
|
||||||
|
format: ((format.redShift > format.blueShift) === same)
|
||||||
|
? (format.blueShift === 0
|
||||||
|
? jpeg.FORMAT_BGRX
|
||||||
|
: jpeg.FORMAT_XBGR)
|
||||||
|
: (format.redShift === 0
|
||||||
|
? jpeg.FORMAT_RGBX
|
||||||
|
: jpeg.FORMAT_XRGB)
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
conn.on('pointer', function(event) {
|
conn.on('pointer', function(event) {
|
||||||
pointerTranslator.push(event)
|
pointerTranslator.push(event)
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
var util = require('util')
|
var util = require('util')
|
||||||
|
var os = require('os')
|
||||||
|
|
||||||
var EventEmitter = require('eventemitter3').EventEmitter
|
var EventEmitter = require('eventemitter3').EventEmitter
|
||||||
var debug = require('debug')('vnc:connection')
|
var debug = require('debug')('vnc:connection')
|
||||||
|
@ -26,7 +27,7 @@ function VncConnection(conn, options) {
|
||||||
this._serverPixelFormat = new PixelFormat({
|
this._serverPixelFormat = new PixelFormat({
|
||||||
bitsPerPixel: 24
|
bitsPerPixel: 24
|
||||||
, depth: 24
|
, depth: 24
|
||||||
, bigEndianFlag: 0
|
, bigEndianFlag: os.endianness() == 'BE' ? 1 : 0
|
||||||
, trueColorFlag: 1
|
, trueColorFlag: 1
|
||||||
, redMax: 255
|
, redMax: 255
|
||||||
, greenMax: 255
|
, greenMax: 255
|
||||||
|
@ -35,7 +36,6 @@ function VncConnection(conn, options) {
|
||||||
, greenShift: 8
|
, greenShift: 8
|
||||||
, blueShift: 0
|
, blueShift: 0
|
||||||
})
|
})
|
||||||
this._requireServerPixelFormat = true
|
|
||||||
this._serverName = this.options.name
|
this._serverName = this.options.name
|
||||||
|
|
||||||
this._clientVersion = null
|
this._clientVersion = null
|
||||||
|
@ -202,6 +202,7 @@ VncConnection.prototype._writeSecurityResult = function(result, reason) {
|
||||||
}
|
}
|
||||||
|
|
||||||
VncConnection.prototype._writeServerInit = function() {
|
VncConnection.prototype._writeServerInit = function() {
|
||||||
|
debug('server pixel format', this._serverPixelFormat)
|
||||||
var chunk = new Buffer(2 + 2 + 16 + 4 + this._serverName.length)
|
var chunk = new Buffer(2 + 2 + 16 + 4 + this._serverName.length)
|
||||||
chunk.writeUInt16BE(this._serverWidth, 0)
|
chunk.writeUInt16BE(this._serverWidth, 0)
|
||||||
chunk.writeUInt16BE(this._serverHeight, 2)
|
chunk.writeUInt16BE(this._serverHeight, 2)
|
||||||
|
@ -318,12 +319,7 @@ VncConnection.prototype._read = function() {
|
||||||
})
|
})
|
||||||
// [16b, 19b) padding
|
// [16b, 19b) padding
|
||||||
debug('client pixel format', this._clientPixelFormat)
|
debug('client pixel format', this._clientPixelFormat)
|
||||||
if (this._requireServerPixelFormat &&
|
this.emit('formatchange', this._clientPixelFormat)
|
||||||
this._clientPixelFormat.bitsPerPixel <
|
|
||||||
this._serverPixelFormat.bitsPerPixel) {
|
|
||||||
this.end()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this._changeState(VncConnection.STATE_NEED_CLIENT_MESSAGE)
|
this._changeState(VncConnection.STATE_NEED_CLIENT_MESSAGE)
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
|
|
|
@ -50,7 +50,7 @@
|
||||||
"http-proxy": "^1.11.2",
|
"http-proxy": "^1.11.2",
|
||||||
"in-publish": "^2.0.0",
|
"in-publish": "^2.0.0",
|
||||||
"jade": "^1.9.2",
|
"jade": "^1.9.2",
|
||||||
"jpeg-turbo": "^0.1.1",
|
"jpeg-turbo": "^0.2.1",
|
||||||
"jws": "^3.1.0",
|
"jws": "^3.1.0",
|
||||||
"ldapjs": "git+https://github.com/mcavage/node-ldapjs.git#acc1ca8f4314fd9d67561feabc8ce4c235076a5e",
|
"ldapjs": "git+https://github.com/mcavage/node-ldapjs.git#acc1ca8f4314fd9d67561feabc8ce4c235076a5e",
|
||||||
"lodash": "^3.10.1",
|
"lodash": "^3.10.1",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue