mirror of
https://github.com/amitbet/vnc2video.git
synced 2025-08-15 19:23:26 +00:00
name change now: vnc2video,
initial implementation for hextile, cursor
This commit is contained in:
parent
1a112dbead
commit
afc94572a3
1
LICENSE
1
LICENSE
@ -3,6 +3,7 @@ MIT License
|
||||
Copyright (c) 2013 Mitchell Hashimoto
|
||||
Copyright (c) 2016-2017 Kate Ward
|
||||
Copyright (c) 2017 Vasiliy Tolstov
|
||||
Copyright (c) 2018 Amit Bezalel
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Code generated by "stringer -type=Button"; DO NOT EDIT.
|
||||
|
||||
package vnc2webm
|
||||
package vnc2video
|
||||
|
||||
import "fmt"
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
package vnc2webm
|
||||
package vnc2video
|
||||
|
||||
// Button represents a mask of pointer presses/releases.
|
||||
type Button uint8
|
||||
|
@ -1,4 +1,4 @@
|
||||
package vnc2webm
|
||||
package vnc2video
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
@ -7,7 +7,7 @@ import (
|
||||
"fmt"
|
||||
"net"
|
||||
"sync"
|
||||
"vnc2webm/logger"
|
||||
"vnc2video/logger"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Code generated by "stringer -type=ClientMessageType"; DO NOT EDIT.
|
||||
|
||||
package vnc2webm
|
||||
package vnc2video
|
||||
|
||||
import "fmt"
|
||||
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"vnc2webm/logger"
|
||||
"vnc2video/logger"
|
||||
)
|
||||
|
||||
type DV8ImageEncoder struct {
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"vnc2webm/logger"
|
||||
"vnc2video/logger"
|
||||
)
|
||||
|
||||
type DV9ImageEncoder struct {
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
"image"
|
||||
"image/jpeg"
|
||||
"strings"
|
||||
"vnc2webm/logger"
|
||||
"vnc2video/logger"
|
||||
|
||||
"github.com/icza/mjpeg"
|
||||
)
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"vnc2webm/logger"
|
||||
"vnc2video/logger"
|
||||
)
|
||||
|
||||
type X264ImageEncoder struct {
|
||||
|
@ -1,4 +1,4 @@
|
||||
package vnc2webm
|
||||
package vnc2video
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
@ -1,4 +1,4 @@
|
||||
package vnc2webm
|
||||
package vnc2video
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
|
@ -1,4 +1,4 @@
|
||||
package vnc2webm
|
||||
package vnc2video
|
||||
|
||||
import "encoding/binary"
|
||||
|
||||
|
60
encoding_corre.go
Normal file
60
encoding_corre.go
Normal file
@ -0,0 +1,60 @@
|
||||
package vnc2video
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"io"
|
||||
)
|
||||
|
||||
type CoRREEncoding struct {
|
||||
numSubRects uint32
|
||||
backgroundColor []byte
|
||||
subRectData []byte
|
||||
}
|
||||
|
||||
func (z *CoRREEncoding) Type() int32 {
|
||||
return 4
|
||||
}
|
||||
|
||||
func (z *CoRREEncoding) WriteTo(w io.Writer) (n int, err error) {
|
||||
binary.Write(w, binary.BigEndian, z.numSubRects)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
w.Write(z.backgroundColor)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
w.Write(z.subRectData)
|
||||
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
b := len(z.backgroundColor) + len(z.subRectData) + 4
|
||||
return b, nil
|
||||
}
|
||||
func (z *CoRREEncoding) Read(r Conn, rect *Rectangle) error {
|
||||
//func (z *CoRREEncoding) Read(pixelFmt *PixelFormat, rect *Rectangle, r io.Reader) (Encoding, error) {
|
||||
bytesPerPixel := int(r.PixelFormat().BPP / 8)
|
||||
var numOfSubrectangles uint32
|
||||
if err := binary.Read(r, binary.BigEndian, &numOfSubrectangles); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
z.numSubRects = numOfSubrectangles
|
||||
var err error
|
||||
//read whole-rect background color
|
||||
z.backgroundColor, err = ReadBytes(bytesPerPixel, r)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
//read all individual rects (color=BPP + x=16b + y=16b + w=16b + h=16b)
|
||||
z.subRectData, err = ReadBytes(int(numOfSubrectangles)*(bytesPerPixel+4), r)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
@ -1,15 +1,15 @@
|
||||
package vnc2webm
|
||||
package vnc2video
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"image"
|
||||
"image/color"
|
||||
"image/draw"
|
||||
)
|
||||
|
||||
type CursorPseudoEncoding struct {
|
||||
Colors []Color
|
||||
BitMask []byte
|
||||
Image image.Image
|
||||
Image draw.Image
|
||||
}
|
||||
|
||||
func (*CursorPseudoEncoding) Supported(Conn) bool {
|
||||
@ -23,16 +23,36 @@ func (enc *CursorPseudoEncoding) SetTargetImage(img draw.Image) {
|
||||
func (*CursorPseudoEncoding) Type() EncodingType { return EncCursorPseudo }
|
||||
|
||||
func (enc *CursorPseudoEncoding) Read(c Conn, rect *Rectangle) error {
|
||||
rgba := make([]byte, int(rect.Height)*int(rect.Width)*int(c.PixelFormat().BPP/8))
|
||||
|
||||
if err := binary.Read(c, binary.BigEndian, &rgba); err != nil {
|
||||
return err
|
||||
//rgba := make([]byte, int(rect.Height)*int(rect.Width)*int(c.PixelFormat().BPP/8))
|
||||
numColors := int(rect.Height) * int(rect.Width)
|
||||
colors := make([]color.Color, numColors)
|
||||
var err error
|
||||
pf := c.PixelFormat()
|
||||
for i := 0; i < numColors; i++ {
|
||||
colors[i], err = ReadColor(c, &pf)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
// if err := binary.Read(c, binary.BigEndian, &rgba); err != nil {
|
||||
// return err
|
||||
// }
|
||||
|
||||
bitmask := make([]byte, int((rect.Width+7)/8*rect.Height))
|
||||
if err := binary.Read(c, binary.BigEndian, &bitmask); err != nil {
|
||||
return err
|
||||
}
|
||||
scanLine := (rect.Width + 7) / 8
|
||||
|
||||
//int[] cursorPixels = new int[rect.width * rect.height];
|
||||
for y := 0; y < int(rect.Height); y++ {
|
||||
for x := 0; x < int(rect.Width); x++ {
|
||||
offset := y*int(rect.Width) + x
|
||||
if bitmask[y*int(scanLine)+x/8]&(1<<uint(7-x%8)) > 0 {
|
||||
enc.Image.Set(x, y, colors[offset])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
rectStride := 4 * rect.Width
|
||||
@ -41,10 +61,10 @@ func (enc *CursorPseudoEncoding) Read(c Conn, rect *Rectangle) error {
|
||||
for idx, k := j/8, 7; k >= 0; k-- {
|
||||
if (bitmask[idx] & (1 << uint(k))) == 0 {
|
||||
pIdx := j*4 + i*rectStride
|
||||
rgbaBuffer[pIdx] = 0
|
||||
rgbaBuffer[pIdx+1] = 0
|
||||
rgbaBuffer[pIdx+2] = 0
|
||||
rgbaBuffer[pIdx+3] = 0
|
||||
rgba[pIdx] = 0
|
||||
rgba[pIdx+1] = 0
|
||||
rgba[pIdx+2] = 0
|
||||
rgba[pIdx+3] = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package vnc2webm
|
||||
package vnc2video
|
||||
|
||||
import "encoding/binary"
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
package vnc2webm
|
||||
package vnc2video
|
||||
|
||||
// DesktopSizePseudoEncoding represents a desktop size message from the server.
|
||||
type DesktopSizePseudoEncoding struct{}
|
||||
|
168
encoding_hextile.go
Normal file
168
encoding_hextile.go
Normal file
@ -0,0 +1,168 @@
|
||||
package vnc2video
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"image"
|
||||
"image/color"
|
||||
"image/draw"
|
||||
"io"
|
||||
"vnc2video/logger"
|
||||
)
|
||||
|
||||
const (
|
||||
HextileRaw = 1
|
||||
HextileBackgroundSpecified = 2
|
||||
HextileForegroundSpecified = 4
|
||||
HextileAnySubrects = 8
|
||||
HextileSubrectsColoured = 16
|
||||
)
|
||||
|
||||
type HextileEncoding struct {
|
||||
//Colors []Color
|
||||
bytes []byte
|
||||
Image draw.Image
|
||||
}
|
||||
|
||||
// Read unmarshal color from conn
|
||||
func ReadColor(c io.Reader, pf *PixelFormat) (*color.RGBA, error) {
|
||||
if pf.TrueColor == 0 {
|
||||
return nil, errors.New("support for non true color formats was not implemented")
|
||||
}
|
||||
order := pf.order()
|
||||
var pixel uint32
|
||||
|
||||
switch pf.BPP {
|
||||
case 8:
|
||||
var px uint8
|
||||
if err := binary.Read(c, order, &px); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
pixel = uint32(px)
|
||||
case 16:
|
||||
var px uint16
|
||||
if err := binary.Read(c, order, &px); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
pixel = uint32(px)
|
||||
case 32:
|
||||
var px uint32
|
||||
if err := binary.Read(c, order, &px); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
pixel = uint32(px)
|
||||
}
|
||||
|
||||
rgb := color.RGBA{
|
||||
R: uint8((pixel >> pf.RedShift) & uint32(pf.RedMax)),
|
||||
G: uint8((pixel >> pf.GreenShift) & uint32(pf.GreenMax)),
|
||||
B: uint8((pixel >> pf.BlueShift) & uint32(pf.BlueMax)),
|
||||
A: 1,
|
||||
}
|
||||
|
||||
return &rgb, nil
|
||||
}
|
||||
|
||||
func (z *HextileEncoding) Type() int32 {
|
||||
return 5
|
||||
}
|
||||
func (z *HextileEncoding) WriteTo(w io.Writer) (n int, err error) {
|
||||
return w.Write(z.bytes)
|
||||
}
|
||||
func (z *HextileEncoding) Read(r Conn, rect *Rectangle) error {
|
||||
//func (z *HextileEncoding) Read(pixelFmt *PixelFormat, rect *Rectangle, r io.Reader) (Encoding, error) {
|
||||
//bytesPerPixel := int(r.PixelFormat().BPP) / 8
|
||||
pf := r.PixelFormat()
|
||||
var bgCol *color.RGBA
|
||||
var fgCol *color.RGBA
|
||||
var err error
|
||||
var dimensions byte
|
||||
var subencoding byte
|
||||
|
||||
//r.StartByteCollection()
|
||||
// defer func() {
|
||||
// z.bytes = r.EndByteCollection()
|
||||
// }()
|
||||
|
||||
for ty := rect.Y; ty < rect.Y+rect.Height; ty += 16 {
|
||||
th := 16
|
||||
if rect.Y+rect.Height-ty < 16 {
|
||||
th = int(rect.Y) + int(rect.Height) - int(ty)
|
||||
}
|
||||
|
||||
for tx := rect.X; tx < rect.X+rect.Width; tx += 16 {
|
||||
tw := 16
|
||||
if rect.X+rect.Width-tx < 16 {
|
||||
tw = int(rect.X) + int(rect.Width) - int(tx)
|
||||
}
|
||||
|
||||
//handle Hextile Subrect(tx, ty, tw, th):
|
||||
subencoding, err = ReadUint8(r)
|
||||
|
||||
if err != nil {
|
||||
logger.Errorf("HextileEncoding.Read: error in hextile reader: %v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
if (subencoding & HextileRaw) != 0 {
|
||||
rawEnc := r.GetEncInstance(EncRaw)
|
||||
rawEnc.Read(r, &Rectangle{0, 0, uint16(tw), uint16(th), EncRaw, rawEnc})
|
||||
//ReadBytes(tw*th*bytesPerPixel, r)
|
||||
continue
|
||||
}
|
||||
if (subencoding & HextileBackgroundSpecified) != 0 {
|
||||
//ReadBytes(int(bytesPerPixel), r)
|
||||
|
||||
bgCol, err = ReadColor(r, &pf)
|
||||
rBounds := image.Rectangle{Min: image.Point{int(tx), int(ty)}, Max: image.Point{int(tw), int(th)}}
|
||||
FillRect(z.Image, &rBounds, bgCol)
|
||||
}
|
||||
if (subencoding & HextileForegroundSpecified) != 0 {
|
||||
fgCol, err = ReadColor(r, &pf)
|
||||
}
|
||||
if (subencoding & HextileAnySubrects) == 0 {
|
||||
//logger.Debug("hextile reader: no Subrects")
|
||||
continue
|
||||
}
|
||||
|
||||
nSubrects, err := ReadUint8(r)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
//bufsize := int(nSubrects) * 2
|
||||
colorSpecified := ((subencoding & HextileSubrectsColoured) != 0)
|
||||
for i := 0; i < int(nSubrects); i++ {
|
||||
var color *color.RGBA
|
||||
if colorSpecified {
|
||||
color, err = ReadColor(r, &pf)
|
||||
if err != nil {
|
||||
logger.Error("Hextile decoder: problem reading color from connection: ", err)
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
color = fgCol
|
||||
}
|
||||
//int color = colorSpecified ? renderer.readPixelColor(transport) : colors[FG_COLOR_INDEX];
|
||||
fgCol = color
|
||||
dimensions, err = ReadUint8(r) // bits 7-4 for x, bits 3-0 for y
|
||||
if err != nil {
|
||||
logger.Error("Hextile decoder: problem reading dimensions from connection: ", err)
|
||||
return err
|
||||
}
|
||||
subtileX := dimensions >> 4 & 0x0f
|
||||
subtileY := dimensions & 0x0f
|
||||
dimensions, err = ReadUint8(r) // bits 7-4 for w, bits 3-0 for h
|
||||
if err != nil {
|
||||
logger.Error("Hextile decoder: problem reading 2nd dimensions from connection: ", err)
|
||||
return err
|
||||
}
|
||||
subtileWidth := 1 + (dimensions >> 4 & 0x0f)
|
||||
subtileHeight := 1 + (dimensions & 0x0f)
|
||||
subrectBounds := image.Rectangle{Min: image.Point{int(tx) + int(subtileX), int(ty) + int(subtileY)}, Max: image.Point{int(subtileWidth), int(subtileHeight)}}
|
||||
FillRect(z.Image, &subrectBounds, color)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package vnc2webm
|
||||
package vnc2video
|
||||
|
||||
import "image"
|
||||
import "image/draw"
|
||||
|
64
encoding_rre.go
Normal file
64
encoding_rre.go
Normal file
@ -0,0 +1,64 @@
|
||||
package vnc2video
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"io"
|
||||
//"image/draw"
|
||||
)
|
||||
|
||||
type RREEncoding struct {
|
||||
//Colors []Color
|
||||
numSubRects uint32
|
||||
backgroundColor []byte
|
||||
subRectData []byte
|
||||
}
|
||||
|
||||
func (z *RREEncoding) WriteTo(w io.Writer) (n int, err error) {
|
||||
binary.Write(w, binary.BigEndian, z.numSubRects)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
w.Write(z.backgroundColor)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
w.Write(z.subRectData)
|
||||
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
b := len(z.backgroundColor) + len(z.subRectData) + 4
|
||||
return b, nil
|
||||
}
|
||||
|
||||
func (z *RREEncoding) Type() int32 {
|
||||
return 2
|
||||
}
|
||||
func (z *RREEncoding) Read(r Conn, rect *Rectangle) error {
|
||||
//func (z *RREEncoding) Read(pixelFmt *PixelFormat, rect *Rectangle, r io.Reader) (Encoding, error) {
|
||||
bytesPerPixel := int(r.PixelFormat().BPP / 8)
|
||||
|
||||
var numOfSubrectangles uint32
|
||||
if err := binary.Read(r, binary.BigEndian, &numOfSubrectangles); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var err error
|
||||
z.numSubRects = numOfSubrectangles
|
||||
|
||||
//read whole-rect background color
|
||||
z.backgroundColor, err = ReadBytes(bytesPerPixel, r)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
//read all individual rects (color=bytesPerPixel + x=16b + y=16b + w=16b + h=16b)
|
||||
z.subRectData, err = ReadBytes(int(numOfSubrectangles)*(bytesPerPixel+8), r) // x+y+w+h=8 bytes
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package vnc2webm
|
||||
package vnc2video
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@ -12,7 +12,7 @@ import (
|
||||
"image/jpeg"
|
||||
"io"
|
||||
"math"
|
||||
"vnc2webm/logger"
|
||||
"vnc2video/logger"
|
||||
)
|
||||
|
||||
//go:generate stringer -type=TightCompression
|
||||
@ -252,7 +252,6 @@ func (enc *TightEncoding) Read(c Conn, rect *Rectangle) error {
|
||||
dest := enc.Image.(draw.Image)
|
||||
draw.Draw(dest, dest.Bounds(), img, image.Point{int(rect.X), int(rect.Y)}, draw.Src)
|
||||
|
||||
|
||||
return nil
|
||||
default:
|
||||
|
||||
@ -530,7 +529,7 @@ func (enc *TightEncoding) readTightPalette(connReader Conn, bytesPixel int) (col
|
||||
return paletteColors, nil
|
||||
}
|
||||
|
||||
func ReadUint8(r Conn) (uint8, error) {
|
||||
func ReadUint8(r io.Reader) (uint8, error) {
|
||||
var myUint uint8
|
||||
if err := binary.Read(r, binary.BigEndian, &myUint); err != nil {
|
||||
return 0, err
|
||||
@ -538,6 +537,14 @@ func ReadUint8(r Conn) (uint8, error) {
|
||||
|
||||
return myUint, nil
|
||||
}
|
||||
func ReadUint32(r io.Reader) (uint32, error) {
|
||||
var myUint uint32
|
||||
if err := binary.Read(r, binary.BigEndian, &myUint); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return myUint, nil
|
||||
}
|
||||
|
||||
func (enc *TightEncoding) ReadTightData(dataSize int, c Conn, decoderId int) ([]byte, error) {
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
package vnc2webm
|
||||
package vnc2video
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@ -9,7 +9,7 @@ import (
|
||||
"image/draw"
|
||||
"image/png"
|
||||
"io"
|
||||
"vnc2webm/logger"
|
||||
"vnc2video/logger"
|
||||
)
|
||||
|
||||
func (*TightPngEncoding) Supported(Conn) bool {
|
||||
|
19
encoding_util.go
Normal file
19
encoding_util.go
Normal file
@ -0,0 +1,19 @@
|
||||
package vnc2video
|
||||
|
||||
import (
|
||||
"image"
|
||||
"image/color"
|
||||
"image/draw"
|
||||
)
|
||||
|
||||
func FillRect(img draw.Image, rect *image.Rectangle, c color.Color) {
|
||||
for x := 0; x < rect.Max.X; x++ {
|
||||
for y := 0; y < rect.Max.Y; y++ {
|
||||
img.Set(x, y, c)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func DrawLine(img draw.Image, rect *image.Rectangle, c color.Color) {
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package vnc2webm
|
||||
package vnc2video
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
|
38
encoding_zlib.go
Normal file
38
encoding_zlib.go
Normal file
@ -0,0 +1,38 @@
|
||||
package vnc2video
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
"io"
|
||||
)
|
||||
|
||||
type ZLibEncoding struct {
|
||||
bytes []byte
|
||||
}
|
||||
|
||||
func (z *ZLibEncoding) Type() int32 {
|
||||
return 6
|
||||
}
|
||||
func (z *ZLibEncoding) WriteTo(w io.Writer) (n int, err error) {
|
||||
return w.Write(z.bytes)
|
||||
}
|
||||
func (z *ZLibEncoding) Read(r Conn, rect *Rectangle) error {
|
||||
//func (z *ZLibEncoding) Read(pixelFmt *PixelFormat, rect *Rectangle, r io.Reader) (Encoding, error) {
|
||||
//conn := RfbReadHelper{Reader:r}
|
||||
//conn := &DataSource{conn: conn.c, PixelFormat: conn.PixelFormat}
|
||||
//bytesPerPixel := c.PixelFormat.BPP / 8
|
||||
bytes := &bytes.Buffer{}
|
||||
len, err := ReadUint32(r)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
binary.Write(bytes, binary.BigEndian, len)
|
||||
_, err = ReadBytes(int(len), r)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
//StoreBytes(bytes, bts)
|
||||
z.bytes = bytes.Bytes()
|
||||
return nil
|
||||
}
|
37
encoding_zrle.go
Normal file
37
encoding_zrle.go
Normal file
@ -0,0 +1,37 @@
|
||||
package vnc2video
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
"io"
|
||||
)
|
||||
|
||||
type ZRLEEncoding struct {
|
||||
bytes []byte
|
||||
}
|
||||
|
||||
func (z *ZRLEEncoding) Type() int32 {
|
||||
return 16
|
||||
}
|
||||
|
||||
func (z *ZRLEEncoding) WriteTo(w io.Writer) (n int, err error) {
|
||||
return w.Write(z.bytes)
|
||||
}
|
||||
func (z *ZRLEEncoding) Read(r Conn, rect *Rectangle) error {
|
||||
//func (z *ZRLEEncoding) Read(pixelFmt *PixelFormat, rect *Rectangle, r io.Reader) (Encoding, error) {
|
||||
|
||||
bytes := &bytes.Buffer{}
|
||||
len, err := ReadUint32(r)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
binary.Write(bytes, binary.BigEndian, len)
|
||||
_, err = ReadBytes(int(len), r)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
//StoreBytes(bytes, bts)
|
||||
z.bytes = bytes.Bytes()
|
||||
return nil
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
// Code generated by "stringer -type=EncodingType"; DO NOT EDIT.
|
||||
|
||||
package vnc2webm
|
||||
package vnc2video
|
||||
|
||||
import "fmt"
|
||||
|
||||
|
@ -6,9 +6,9 @@ import (
|
||||
"net"
|
||||
"os"
|
||||
"time"
|
||||
vnc "vnc2webm"
|
||||
"vnc2webm/encoders"
|
||||
"vnc2webm/logger"
|
||||
vnc "vnc2video"
|
||||
"vnc2video/encoders"
|
||||
"vnc2video/logger"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -3,9 +3,9 @@ package main
|
||||
import (
|
||||
"image"
|
||||
"os"
|
||||
vnc "vnc2webm"
|
||||
"vnc2webm/encoders"
|
||||
"vnc2webm/logger"
|
||||
vnc "vnc2video"
|
||||
"vnc2video/encoders"
|
||||
"vnc2video/logger"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
|
@ -13,8 +13,8 @@ import (
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
vnc "vnc2webm"
|
||||
"vnc2webm/logger"
|
||||
vnc "vnc2video"
|
||||
"vnc2video/logger"
|
||||
)
|
||||
|
||||
type Auth struct {
|
||||
|
@ -7,8 +7,8 @@ import (
|
||||
"math"
|
||||
"net"
|
||||
"time"
|
||||
vnc "vnc2webm"
|
||||
"vnc2webm/logger"
|
||||
vnc "vnc2video"
|
||||
"vnc2video/logger"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -1,9 +1,9 @@
|
||||
package vnc2webm
|
||||
package vnc2video
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"net"
|
||||
"vnc2webm/logger"
|
||||
"vnc2video/logger"
|
||||
|
||||
"io"
|
||||
"time"
|
||||
|
@ -1,4 +1,4 @@
|
||||
package vnc2webm
|
||||
package vnc2video
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@ -7,7 +7,7 @@ import (
|
||||
"os"
|
||||
//"vncproxy/common"
|
||||
//"vncproxy/encodings"
|
||||
"vnc2webm/logger"
|
||||
"vnc2video/logger"
|
||||
//"vncproxy/encodings"
|
||||
//"vncproxy/encodings"
|
||||
)
|
||||
|
@ -1,9 +1,9 @@
|
||||
package vnc2webm
|
||||
package vnc2video
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"vnc2webm/logger"
|
||||
"vnc2video/logger"
|
||||
)
|
||||
|
||||
// Handler represents handler of handshake
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Code generated by "stringer -type=Key"; DO NOT EDIT.
|
||||
|
||||
package vnc2webm
|
||||
package vnc2video
|
||||
|
||||
import "fmt"
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
package vnc2webm
|
||||
package vnc2video
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
|
||||
"vnc2webm/logger"
|
||||
"vnc2video/logger"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -1,4 +1,4 @@
|
||||
package vnc2webm
|
||||
package vnc2video
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Implementation of RFC 6143 §7.4 Pixel Format Data Structure.
|
||||
|
||||
package vnc2webm
|
||||
package vnc2video
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
@ -1,4 +1,4 @@
|
||||
package vnc2webm
|
||||
package vnc2video
|
||||
|
||||
type SecurityType uint8
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
package vnc2webm
|
||||
package vnc2video
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
@ -1,4 +1,4 @@
|
||||
package vnc2webm
|
||||
package vnc2video
|
||||
|
||||
type ClientAuthNone struct{}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
package vnc2webm
|
||||
package vnc2video
|
||||
|
||||
import "encoding/binary"
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
package vnc2webm
|
||||
package vnc2video
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
@ -1,4 +1,4 @@
|
||||
package vnc2webm
|
||||
package vnc2video
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Code generated by "stringer -type=SecuritySubType"; DO NOT EDIT.
|
||||
|
||||
package vnc2webm
|
||||
package vnc2video
|
||||
|
||||
import "fmt"
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Code generated by "stringer -type=SecurityType"; DO NOT EDIT.
|
||||
|
||||
package vnc2webm
|
||||
package vnc2video
|
||||
|
||||
import "fmt"
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Code generated by "stringer -type=TightCompression"; DO NOT EDIT.
|
||||
|
||||
package vnc2webm
|
||||
package vnc2video
|
||||
|
||||
import "fmt"
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Code generated by "stringer -type=TightFilter"; DO NOT EDIT.
|
||||
|
||||
package vnc2webm
|
||||
package vnc2video
|
||||
|
||||
import "fmt"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user