filtering pseudo encodings and setting custom compression levels

This commit is contained in:
amit bezalel 2017-11-28 00:04:27 +02:00
parent 37e11cd72e
commit f2e945c2d7
3 changed files with 57 additions and 8 deletions

View File

@ -4,6 +4,7 @@ import (
"io"
"math"
"vncproxy/common"
"vncproxy/logger"
)
type EncCursorPseudo struct {
@ -21,6 +22,8 @@ func (pe *EncCursorPseudo) Read(pf *common.PixelFormat, rect *common.Rectangle,
}
bytesPixel := int(pf.BPP / 8) //calcTightBytePerPixel(pf)
logger.Infof("EncCursorPseudo bytesPerPixel= %d", bytesPixel)
r.ReadBytes(int(rect.Width*rect.Height) * bytesPixel)
mask := ((rect.Width + 7) / 8) * rect.Height
r.ReadBytes(int(math.Floor(float64(mask))))

View File

@ -6,15 +6,15 @@ func TestProxy(t *testing.T) {
//create default session if required
proxy := &VncProxy{
WsListeningUrl: "http://localhost:7777/", // empty = not listening on ws
RecordingDir: "/Users/amitbet/vncRec", // empty = no recording
TcpListeningUrl: ":5904",
WsListeningUrl: "http://localhost:8183/", // empty = not listening on ws
RecordingDir: "", //"/Users/amitbet/vncRec", // empty = no recording
TcpListeningUrl: ":5905",
//recordingDir: "C:\\vncRec", // empty = no recording
ProxyVncPassword: "1234", //empty = no auth
ProxyVncPassword: "", //empty = no auth
SingleSession: &VncSession{
TargetHostname: "localhost",
TargetPort: "5903",
TargetPassword: "Ch_#!T@8",
TargetHostname: "192.168.1.101",
TargetPort: "5900",
TargetPassword: "ancient1", //"Ch_#!T@8", //
ID: "dummySession",
Status: SessionStatusInit,
Type: SessionTypeRecordingProxy,

View File

@ -182,13 +182,59 @@ func (c *ServerConn) handle() error {
switch parsedMsg.Type() {
case common.SetPixelFormatMsgType:
// update pixel format
logger.Debugf("ClientUpdater.Consume: updating pixel format")
logger.Debugf("IServerConn.Handle: updating pixel format")
pixFmtMsg := parsedMsg.(*MsgSetPixelFormat)
c.SetPixelFormat(&pixFmtMsg.PF)
if pixFmtMsg.PF.TrueColor != 0 {
c.SetColorMap(&common.ColorMap{})
}
case common.FramebufferUpdateRequestMsgType:
//logger.Infof("IServerConn.Handle: msgBuff update request")
//updMsg := parsedMsg.(*MsgFramebufferUpdateRequest)
//updMsg.Inc = 1
case common.SetEncodingsMsgType:
encMsg := parsedMsg.(*MsgSetEncodings)
// for i, enc := range encMsg.Encodings {
// if enc > common.EncJPEGQualityLevelPseudo1 && enc < common.EncJPEGQualityLevelPseudo10 { //common.EncCursorPseudo
// //encMsg.EncNum--
// //encMsg.Encodings = append(encMsg.Encodings[:i], encMsg.Encodings[i+1:]...)
// encMsg.Encodings[i] = encMsg.Encodings[len(encMsg.Encodings)-1]
// encMsg.Encodings[len(encMsg.Encodings)-1] = common.EncJPEGQualityLevelPseudo9
// break
// }
// // if enc == common.EncCompressionLevel3 {
// // encMsg.Encodings[i] = common.EncJPEGQualityLevelPseudo9
// // }
// // if enc == common.EncJPEGQualityLevelPseudo7 {
// // encMsg.Encodings[i] = common.EncJPEGQualityLevelPseudo9
// // }
// }
encMsg.Encodings = []common.EncodingType{
common.EncDesktopSizePseudo,
common.EncExtendedDesktopSizePseudo,
common.EncLastRectPseudo,
common.EncContinuousUpdatesPseudo,
common.EncCursorPseudo,
common.EncFencePseudo,
common.EncHextile,
common.EncCopyRect,
common.EncTight,
common.EncZRLE,
common.EncRRE,
common.EncRaw,
common.EncCompressionLevel2,
common.EncJPEGQualityLevelPseudo1,
common.EncQEMUExtendedKeyEventPseudo,
common.EncTightPng,
common.EncXvpPseudo,
}
encMsg.EncNum = uint16(len(encMsg.Encodings))
//bad: EncCopyRect EncTight EncTightPng EncHextile EncRRE EncRaw EncJPEGQualityLevelPseudo7 EncCompressionLevel3 EncDesktopSizePseudo EncLastRectPseudo EncCursorPseudo EncQEMUExtendedKeyEventPseudo EncExtendedDesktopSizePseudo EncXvpPseudo EncFencePseudo EncContinuousUpdatesPseudo
}
////////
if err != nil {