starting to create a new file format

This commit is contained in:
betzalel 2017-08-24 14:33:53 +03:00
parent e06ad806db
commit 7852f11ceb
6 changed files with 33 additions and 13 deletions

View File

@ -116,9 +116,9 @@ func (c *ClientConn) Read(bytes []byte) (n int, err error) {
return c.conn.Read(bytes)
}
func (c *ClientConn) CurrentColorMap() *common.ColorMap {
return &c.ColorMap
}
// func (c *ClientConn) CurrentColorMap() *common.ColorMap {
// return &c.ColorMap
// }
// CutText tells the server that the client has new text in its cut buffer.
// The text string MUST only contain Latin-1 characters. This encoding

View File

@ -175,9 +175,9 @@ func (m *MsgSetColorMapEntries) Read(c common.IClientConn, r *common.RfbReadHelp
return nil, err
}
}
cmap := c.CurrentColorMap()
// Update the connection's color map
cmap[result.FirstColor+i] = *color
// cmap := c.CurrentColorMap()
// // Update the connection's color map
// cmap[result.FirstColor+i] = *color
}
r.SendMessageEnd(common.ServerMessageType(m.Type()))
return &result, nil

View File

@ -25,6 +25,6 @@ type IServerConn interface {
type IClientConn interface {
CurrentPixelFormat() *PixelFormat
CurrentColorMap() *ColorMap
//CurrentColorMap() *ColorMap
Encodings() []IEncoding
}

View File

@ -3,17 +3,25 @@ package player
import (
"encoding/binary"
"io"
"time"
"vncproxy/client"
"vncproxy/common"
"vncproxy/logger"
"vncproxy/server"
)
type VncStreamFileReader interface {
io.Reader
CurrentTimestamp() int
ReadStartSession() (*common.ServerInit, error)
CurrentPixelFormat() *common.PixelFormat
Encodings() []common.IEncoding
}
type FBSPlayListener struct {
Conn *server.ServerConn
Fbs *FbsReader
Fbs VncStreamFileReader
serverMessageMap map[uint8]common.ServerMessage
firstSegDone bool
startTime int
@ -88,7 +96,7 @@ func (h *FBSPlayListener) sendFbsMessage() {
return
}
timeSinceStart := int(time.Now().UnixNano()/int64(time.Millisecond)) - h.startTime
timeToSleep := fbs.currentTimestamp - timeSinceStart
timeToSleep := fbs.CurrentTimestamp() - timeSinceStart
if timeToSleep > 0 {
time.Sleep(time.Duration(timeToSleep) * time.Millisecond)
}

View File

@ -18,6 +18,10 @@ type FbsReader struct {
encodings []common.IEncoding
}
func (fbs *FbsReader) CurrentTimestamp() int {
return fbs.currentTimestamp
}
func (fbs *FbsReader) Read(p []byte) (n int, err error) {
if fbs.buffer.Len() < len(p) {
seg, err := fbs.ReadSegment()
@ -33,8 +37,9 @@ func (fbs *FbsReader) Read(p []byte) (n int, err error) {
}
func (fbs *FbsReader) CurrentPixelFormat() *common.PixelFormat { return fbs.pixelFormat }
func (fbs *FbsReader) CurrentColorMap() *common.ColorMap { return &common.ColorMap{} }
func (fbs *FbsReader) Encodings() []common.IEncoding { return fbs.encodings }
//func (fbs *FbsReader) CurrentColorMap() *common.ColorMap { return &common.ColorMap{} }
func (fbs *FbsReader) Encodings() []common.IEncoding { return fbs.encodings }
func NewFbsReader(fbsFile string) (*FbsReader, error) {

View File

@ -6,4 +6,11 @@
* code stuff:
* move encodings to be on the framebufferupdate message object
* clear all messages read functions from updating stuff, move modification logic to another listener
* message read function should accept only an io.Reader, move read helper logic (readuint8) to an actual helper class
* message read function should accept only an io.Reader, move read helper logic (readuint8) to an actual helper class
* new recording format:
* rfb extension
* save FBResponse messages with additional fields
* timestamp
* is incremental
* size (bytes)
* have a header which contains an index of messages, holding timestamps & file positions for seeking