Documentation
¶
Overview ¶
Package rdpgfx implements the RDP Graphics Pipeline Extension channel (MS-RDPEGFX), the modern drawing path where a server composites surfaces and sends them as compressed bitmaps.
It is a dynamic virtual channel, so it only starts once the drdynvc layer has created it and both sides have exchanged capabilities.
Index ¶
Constants ¶
const ( CapsVersion8 = 0x00080004 CapsVersion81 = 0x00080105 // CapsVersion10 is the first capability version whose flags control AVC444: // a server offers it only when the client advertises a 10.0 or later set // and does not set RDPGFX_CAPS_FLAG_AVC_DISABLED in it (MS-RDPEGFX 2.2.3.3). CapsVersion10 = 0x000A0002 )
Capability versions. 8.0 and 8.1 are the ones a decoder of RemoteFX and raw bitmaps can honestly claim; a 10.0 set is added only when a caller installs a decoder that can decode AVC444.
0x00080105 rather than 0x00080100: the low byte is part of the version, not padding. See MS-RDPEGFX 2.2.3.2.
const DVCChannelName = "Microsoft::Windows::RDS::Graphics"
RDPGFX_DVC_CHANNEL_NAME is the dynamic virtual channel name.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AVCDecoder ¶ added in v0.6.0
type AVCDecoder interface {
// SupportsAVCCodec reports whether the decoder can decode codecID, one of
// codecAVC420, codecAVC444 or codecAVC444v2. The client advertises exactly
// the codecs this reports true for, so a decoder that handles only one
// variant does not offer the other.
SupportsAVCCodec(codecID uint16) bool
// DecodeAVC turns one parsed access unit into BGRA pixels for a width x
// height surface. codecID is the RDPGFX codec id the unit came from, which
// tells AVC444 (0x0E) from AVC444v2 (0x0F). The returned slice must hold at
// least width*height*4 bytes, top down, 4 bytes per pixel; the client copies
// only the access unit's region rectangles out of it, matching the regions
// the server marked as changed.
DecodeAVC(codecID uint16, au *codec.AVCAccessUnit, width, height int) ([]byte, error)
}
AVCDecoder is an H.264 decoder for the EGFX AVC surface codecs. Servers send AVC420 (RDPGFX_CODECID_AVC420) and AVC444 (AVC444 or AVC444v2) surface data when the client advertises them; a client that has a decoder implements this and installs it with SetDecoder, and one that has none leaves it unset and keeps declining those codecs. This package deliberately ships no H.264 decoder of its own: parsing the AVC messages is pure framing (codec.ParseAVC420 and codec.ParseAVC444), while turning the bitstream into pixels is the caller's job.
type Frame ¶
Frame is one completed frame: the id the server assigned and the surfaces that were touched. The pixels live on the surfaces.
type GfxClient ¶
GfxClient is the RDPGFX channel handler.
func (*GfxClient) OnData ¶
OnData implements drdynvc.DynChannel. The payload is a ZGFX stream that may hold several PDUs.
func (*GfxClient) SetDecoder ¶ added in v0.6.0
func (c *GfxClient) SetDecoder(d AVCDecoder)
SetDecoder installs the H.264 decoder used for the AVC420 and AVC444 surface codecs. It has to be called before the channel is opened, because the codecs the decoder supports are advertised in the capability PDU. Never calling it, or passing nil, leaves the AVC codecs unadvertised and refused, exactly as a client with no H.264 decoder should behave.
type Reset ¶
type Reset struct {
Width, Height int
}
Reset describes a Reset Graphics PDU: the size of the desktop the server will composite into. Any previously known surfaces are gone.
type Surface ¶
type Surface struct {
ID uint16
Width int
Height int
PixelFormat uint8
// contains filtered or unexported fields
}
Surface is a decoded surface: a set of pixels that the server composites into frames. Surfaces are addressed by a 16 bit id.
func (*Surface) CompositePixels ¶ added in v0.5.0
CompositePixels returns the pixels to composite for this surface and the size to composite them at. When the server mapped the surface to the output with a target size (MapSurfaceToScaledOutput), the pixels are resampled to that size so the surface is drawn at the size the server asked for. In every other case the native pixels and size are returned, so a compositor can always draw the result at the size this returns.
The two window mappings carry a target size as well, but they are not resampled: the surface belongs at a position inside a window this client has no model for, and scaling it without a destination would not be faithful. Placement reports what was recorded for them.
func (*Surface) Origin ¶ added in v0.3.0
Origin returns where the surface is mapped on the desktop. A client that composites surfaces itself has to offset them by this, or everything ends up in the top left corner. A window mapping carries no desktop origin, so the last output origin is kept and this never moves a surface to the corner.
func (*Surface) Pixels ¶
Pixels returns a copy of the surface contents as BGRA, top down, at the surface's native size.
func (*Surface) Placement ¶ added in v0.5.0
func (s *Surface) Placement() SurfacePlacement
Placement returns the mapping the server most recently applied to this surface: the output origin from an output mapping, or the window id and the mapped and target sizes from a window mapping. A surface that was never mapped reports the zero placement.
type SurfacePlacement ¶ added in v0.3.0
type SurfacePlacement struct {
ID uint16
// X, Y is the desktop origin, from the two output mappings. A window
// mapping carries no desktop origin, so it keeps the last one.
X, Y int
// Windowed is set for MapSurfaceToWindow and MapSurfaceToScaledWindow.
Windowed bool
// WindowID identifies the window a Windowed placement belongs to.
WindowID uint64
// MappedWidth, MappedHeight is the surface's size within that window.
MappedWidth, MappedHeight int
// TargetWidth, TargetHeight is the size the server asked the surface to be
// resampled to, from the two scaled mappings. Zero when the mapping does
// not scale.
TargetWidth, TargetHeight int
}
SurfacePlacement reports where the server mapped a surface. The four mapping orders carry different geometry and only some of it can be applied:
- MapSurfaceToOutput and MapSurfaceToScaledOutput place the surface on the desktop at X,Y. The scaled form additionally asks for it to be resampled to TargetWidth x TargetHeight, which CompositePixels applies.
- MapSurfaceToWindow and MapSurfaceToScaledWindow place the surface inside a window. This client has no window model, so the window id and the mapped and target sizes are recorded and left for a consumer that has one; CompositePixels deliberately does not resample them.