Documentation
¶
Overview ¶
Package codec implements the bitmap codecs that RDP servers use to encode bitmap update and surface command payloads.
A compressed bitmap update whose flags say the payload is codec-encoded begins with a one byte codec id (MS-RDPBCGR 2.2.9.1.1.3.1.2.2). Codec id zero means the payload is plain RLE; the other ids select an implementation in this package.
Index ¶
Constants ¶
const ( CodecIDNone = 0x00 // data is not encoded CodecIDNSCODEC = 0x01 CodecIDRemoteFX = 0x03 CodecIDImageRemoteFX = 0x04 CodecIDX264 = 0x05 CodecIDX264Image = 0x06 )
Bitmap codec ids (MS-RDPBCGR 2.2.9.2.1.1, TS_BITMAP_DATA_EX.codecID).
Variables ¶
var ErrUnsupported = errors.New("codec: unsupported bitmap codec")
ErrUnsupported reports a codec id this package cannot decode yet.
var RFXMode = RLGR1
RFXMode is the entropy coder used for RemoteFX payloads. RemoteFX data does not say which coder it used, so this has to match what was negotiated: a client advertises both ICAPs and the server picks one. RLGR1 is the safer default because every server supports it.
Change it before decoding if the session negotiated RLGR3.
Functions ¶
func DecodeRFX ¶
DecodeRFX decodes a RemoteFX message (MS-RDPRFX) and returns the pixels as BGRA, top-down, matching the other decoders in this package.
width and height describe the destination surface; tiles are clipped to it and to the rectangles the message declares.
func Decompress ¶
Decompress decodes a codec-encoded bitmap payload. codecID comes from TS_BITMAP_DATA_EX, or from the header of a cache bitmap revision 3 or EGFX surface command. A codec id of none means the payload is already raw pixels and is returned unchanged.
The result is BGRA unless the codec documents otherwise. Callers that only need to display the pixels should treat a nil error as "bpp is now 32".
func NSCodec ¶
NSCodec decodes a bitmap compressed with NSCodec (MS-RDPNSC).
The encoded form is a TS_NSC_DATA header followed by four run-length encoded planes: Y, Co, Cg and A. Colour is reconstructed with the YCoCg transform. The result is BGRA, 4 bytes per pixel, rows top to bottom, which is the layout the bitmap update path uses for 32bpp data.
Types ¶
type ZGFX ¶ added in v0.3.0
type ZGFX struct {
// contains filtered or unexported fields
}
ZGFX is the bulk compression that wraps EGFX graphics data (MS-RDPEGFX 3.1.8). The graphics channel does not carry raw RDPGFX PDUs: every message is a ZGFX stream, whether or not it is actually compressed.
The format is LZ77 with a fixed token table. A stream is one or more segments; each segment is decoded independently but they share one history buffer, which also persists across messages for the life of the channel. A decoder therefore has to be kept for as long as the connection lasts, and it has to be fed every message in order.