Documentation
¶
Overview ¶
patch_solidping.go carries the SolidPing patches to this vendored grdp fork, kept in ONE file deliberately: every SolidPing need that upstream grdp does not already expose lives here, and nothing else in the fork is modified beyond the import-path rewrite and the deletion of the cgo-only codec plugins. See README-solidping.md.
Index ¶
- func SwapRB(p []byte)
- type Bitmap
- type RdpClient
- func (g *RdpClient) Close()
- func (g *RdpClient) DisableAVC444() *RdpClient
- func (g *RdpClient) EventReady() bool
- func (g *RdpClient) Height() int
- func (g *RdpClient) KeyDown(sc int)
- func (g *RdpClient) KeyUp(sc int)
- func (g *RdpClient) Login(domain string, user string, password string) error
- func (g *RdpClient) MouseDown(button int, x, y int)
- func (g *RdpClient) MouseMove(x, y int)
- func (g *RdpClient) MouseUp(button int, x, y int)
- func (g *RdpClient) MouseWheel(delta float64)
- func (g *RdpClient) NotifyClipboardChanged()
- func (g *RdpClient) OnAudio(f func(rdpsnd.AudioFormat, []byte)) *RdpClient
- func (g *RdpClient) OnAudioReset(f func()) *RdpClient
- func (g *RdpClient) OnBitmap(paint func([]Bitmap)) *RdpClient
- func (g *RdpClient) OnClipboard(onRemote func(text string), getLocal func() string) *RdpClient
- func (g *RdpClient) OnClose(f func()) *RdpClient
- func (g *RdpClient) OnDecoderBroken(f func()) *RdpClient
- func (g *RdpClient) OnError(f func(e error)) *RdpClient
- func (g *RdpClient) OnH264I420(...) *RdpClient
- func (g *RdpClient) OnH264NV12(...) *RdpClient
- func (g *RdpClient) OnH264Raw(fn func(destX, destY, w, h int, isKey bool, data []byte)) *RdpClient
- func (g *RdpClient) OnPointerCached(f func(uint16)) *RdpClient
- func (g *RdpClient) OnPointerHide(f func()) *RdpClient
- func (g *RdpClient) OnPointerUpdate(f func(uint16, uint16, uint16, uint16, uint16, uint16, []byte, []byte)) *RdpClient
- func (g *RdpClient) OnReady(f func()) *RdpClient
- func (g *RdpClient) OnSuccess(f func()) *RdpClient
- func (g *RdpClient) Reconnect(width, height int) error
- func (g *RdpClient) RequestKeyframe()
- func (g *RdpClient) SendLogoff()
- func (g *RdpClient) SendScancode(sc uint16, release bool)
- func (g *RdpClient) SendUnicodeKey(r rune)
- func (g *RdpClient) SetKeyboardLayout(layout string)
- func (g *RdpClient) SetKeyboardType(keyboardType string)
- func (g *RdpClient) SetQueueDepthHint(depth uint32)
- func (g *RdpClient) SetResolution(width, height int)
- func (g *RdpClient) Width() int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SwapRB ¶
func SwapRB(p []byte)
SwapRB swaps the red and blue byte of every 32-bit pixel in p in place and forces the alpha byte to 0xFF, converting between RGBA and BGRA byte order (the operation is its own inverse). It reuses the SIMD-accelerated batch converter (SSE2 on amd64, NEON on arm64), so callers that need BGRA pixels for an SDL_PIXELFORMAT_BGRA32 texture can convert an *image.RGBA buffer with a single vectorised pass instead of a scalar per-byte swap loop. len(p) must be a multiple of 4; any trailing bytes are ignored.
Types ¶
type Bitmap ¶
type Bitmap struct {
DestLeft int
DestTop int
DestRight int
DestBottom int
Width int
Height int
BitsPerPixel int
Data []byte
}
Bitmap is a single rendered region delivered to the OnBitmap callback.
Lifecycle: Bitmap.Data is borrowed from an internal buffer pool and is only valid for the duration of the synchronous OnBitmap callback. After the callback returns the slice may be returned to the pool and overwritten by subsequent updates. Callers that need to retain the pixels (e.g. to hand them to an asynchronous paint goroutine) MUST copy the bytes before the callback returns.
func (*Bitmap) FillBGRA ¶
FillBGRA converts the bitmap pixel data into packed BGRA32 (4 bytes/pixel, B at offset 0) and writes it into dst, growing dst if necessary. The caller may pass a previously returned slice to reuse the allocation across calls (common for tiled rendering where many same-sized bitmaps are converted in a loop). The returned slice has length == bm.Width * bm.Height * 4.
Unlike RGBA() + SwapRB, FillBGRA avoids an intermediate *image.RGBA allocation and the second-pass R/B swap for BGR24/BGRA32 inputs. For BGR24 the output is a single-pass direct pack; for BGRA32 it is a memcopy.
func (*Bitmap) FillRGBA ¶
FillRGBA converts the bitmap's pixel data to RGBA format, writing into dst. If dst is nil or has the wrong dimensions a new *image.RGBA is allocated. Callers that process tiles of stable dimensions can reuse the same *image.RGBA across frames to avoid repeated heap allocations:
var tile *image.RGBA tile = bm.FillRGBA(tile)
type RdpClient ¶
type RdpClient struct {
// contains filtered or unexported fields
}
func NewRdpClient ¶
func (*RdpClient) DisableAVC444 ¶
DisableAVC444 prevents the client from advertising AVC444/AVC444v2 support. When called before Login, the RDPGFX CAPS_ADVERTISE is limited to v8.1 (AVC420 only), so the server will never send LC=2 chroma-upgrade frames. This avoids the colour distortion seen with VirtualBox VRDE, which sends LC=2 data but does not include stream2 in LC=0 IDR packets. The setting is preserved across automatic reconnects.
func (*RdpClient) EventReady ¶
EventReady reports whether the session accepts input events. A script can poll it instead of acting blind after a session drop.
func (*RdpClient) MouseMove ¶
MouseMove queues a mouse-move event. Successive moves within mouseCoalesceInterval are collapsed: only the latest (x,y) is sent. The first move in a burst is sent immediately so the server sees no extra latency for a single isolated motion.
func (*RdpClient) MouseWheel ¶
MouseWheel sends a vertical scroll event to the remote desktop. delta is the rotation amount in physical notches (1.0 = one click of a scroll wheel = Windows WHEEL_DELTA). Fractional values are accepted for smooth / high-resolution input devices such as trackpads. Positive values scroll up (away from the user); negative values scroll down.
func (*RdpClient) NotifyClipboardChanged ¶
func (g *RdpClient) NotifyClipboardChanged()
NotifyClipboardChanged tells the server that the local clipboard has changed. The UI should call this when it detects a system clipboard change (e.g. via polling or a platform clipboard-change signal).
func (*RdpClient) OnAudio ¶
func (g *RdpClient) OnAudio(f func(rdpsnd.AudioFormat, []byte)) *RdpClient
OnAudio registers a callback for server audio data. The callback receives the AudioFormat describing the PCM data and the raw audio bytes. Must be called before Login.
func (*RdpClient) OnAudioReset ¶
OnAudioReset registers a callback that is called when the server closes the audio channel (e.g. media seek or stream restart). The application should flush its audio playback buffer so that stale audio does not keep playing. Must be called before Login.
func (*RdpClient) OnBitmap ¶
OnBitmap registers a callback for bitmap update events. For compressed bitmaps, Bitmap.Data is borrowed from an internal pool and is valid only for the duration of the paint call. If you need to retain the raw pixel data beyond paint, copy it or call bm.RGBA() inside paint.
func (*RdpClient) OnClipboard ¶
OnClipboard registers callbacks for bidirectional clipboard sharing.
- onRemote is called with the text when the RDP server's clipboard content is received (server → client).
- getLocal is called to retrieve the current local clipboard text when the server requests it (client → server).
Must be called before Login.
func (*RdpClient) OnDecoderBroken ¶
OnDecoderBroken registers a callback that is invoked when the H.264 decoder enters an unrecoverable state (all hard-reset attempts exhausted). When this callback is set, grdp does NOT automatically call Reconnect; the application is responsible for deciding when to reconnect (e.g. via its own stall watchdog). If no callback is registered, grdp falls back to the previous behaviour of reconnecting immediately.
func (*RdpClient) OnH264I420 ¶
func (g *RdpClient) OnH264I420(fn func(destX, destY, w, h int, y []byte, yStride int, u []byte, uStride int, v []byte, vStride int)) *RdpClient
OnH264I420 registers a callback that receives decoded H.264 frames in I420 planar format (Y, U, V planes with associated strides). When set, the decoded frame is NOT delivered via OnBitmap; the caller is responsible for rendering it directly (e.g. via an SDL2 IYUV texture for GPU-accelerated YUV→RGB conversion). When I420 extraction is unavailable for a frame (e.g. non-YUV420P/NV12 formats), grdp falls back to OnBitmap delivery. destX, destY are top-left canvas coordinates; w, h are frame dimensions. The plane slices are only valid for the duration of the callback; copy them if they need to be retained beyond the callback's return.
func (*RdpClient) OnH264NV12 ¶
func (g *RdpClient) OnH264NV12(fn func(destX, destY, w, h int, y []byte, yStride int, uv []byte, uvStride int)) *RdpClient
OnH264NV12 registers a callback that receives decoded H.264 frames in NV12 format (Y plane plus interleaved UV plane). This is the fastest SDL2 path on platforms whose hardware decoder already outputs NV12 (notably macOS VideoToolbox), because callers can upload the planes directly with an NV12 texture and avoid NV12->I420 deinterleaving in grdp. When NV12 extraction is unavailable for a frame, grdp falls back to OnBitmap delivery. destX, destY are top-left canvas coordinates; w, h are frame dimensions. The plane slices are only valid for the duration of the callback; copy them if they need to be retained beyond the callback's return.
func (*RdpClient) OnH264Raw ¶
OnH264Raw registers a callback that receives raw H.264 NAL unit data when the built-in decoder is unavailable (e.g. WASM builds without CGo). destX, destY are the top-left canvas coordinates; isKey flags an IDR frame. The caller owns data and may retain it beyond the callback.
func (*RdpClient) OnPointerCached ¶
func (*RdpClient) OnPointerHide ¶
func (*RdpClient) OnPointerUpdate ¶
func (*RdpClient) RequestKeyframe ¶
func (g *RdpClient) RequestKeyframe()
RequestKeyframe asks the server to send a fresh full-screen IDR keyframe via the SuppressOutput off→on toggle (SendForceRefresh). It is the same request the RDPGFX decoder issues internally when it stalls, exposed publicly so the frontend's black-screen watchdog can recover an initial all-black session — where the server sent its first IDR before the desktop finished painting (decoded as a black warm-up frame and dropped) and then went idle — without the cost of a full reconnect. Safe to call from the render loop goroutine.
func (*RdpClient) SendLogoff ¶
func (g *RdpClient) SendLogoff()
SendLogoff asks the SERVER to end the session by sending the TS_SHUTDOWN_REQUEST data PDU (MS-RDPBCGR 2.2.9.3 — the protocol's "log me off" verb; the server acknowledges with TS_SHUTDOWN_DENIED-prefixed teardown and removes the session). This is what `end_session: logoff` sends, and what a script's logoff() triggers.
Compare Close(), which only drops the transport: that is a DISCONNECT — the session survives on the server until its idle policy ends it, and the next connect reattaches to it.
No-op when the session is not ready: a log-off request before the session exists is meaningless, and the caller's logoff error reporting treats a closed session the same way.
func (*RdpClient) SendScancode ¶
SendScancode sends one scancode key event: press when release is false, release when true. sc may carry the 0xE0 extended prefix (0xE04B for Left Arrow); it is stripped and translated into KBDFLAGS_EXTENDED, which is the form both the slow-path serializer and the fast-path encoder expect.
`key()` composes named keys and combos out of these — scancodes, not Unicode, because named keys and combos (Enter, ctrl+alt+end, win+r) have no Unicode position.
func (*RdpClient) SendUnicodeKey ¶
SendUnicodeKey sends one Unicode character as a TS_UNICODE_KEYBOARD_EVENT press followed by its release (MS-RDPBCGR §2.2.8.1.2.2.5 fast-path, with a slow-path fallback through SendInputEvents).
Unicode input is what `type()` is built on: it carries the character itself, so the target's keyboard layout is irrelevant — "hello" arrives as h-e-l-l-o on a French AZERTY exactly as on a US QWERTY. `key()` uses scancodes instead, because named keys and combos (Enter, ctrl+alt+end) have no Unicode position.
No-op when the session is not ready: an event sent before the connection sequence finishes is dropped by the server, and silently dropping it here keeps the check's script from having to poll readiness between actions.
func (*RdpClient) SetKeyboardLayout ¶
SetKeyboardLayout sets the keyboard layout by name (e.g. "US", "FRENCH"). Must be called before Login.
func (*RdpClient) SetKeyboardType ¶
SetKeyboardType sets the keyboard type by name (e.g. "IBM_101_102_KEYS"). Must be called before Login.
func (*RdpClient) SetQueueDepthHint ¶
SetQueueDepthHint controls the frame-rate and encoding quality reported to the server via the RDPGFX FRAME_ACKNOWLEDGE queueDepth field (MS-RDPEGFX 2.2.2.8).
A higher value signals a larger client decode backlog, causing the server to slow down or reduce H.264/RFX encoding quality. 0 (default) means "report the real decode-queue length" — no artificial throttling.
Typical values: 0 = off, 10–50 = moderate throttle, 100+ = heavy throttle. Use 0xFFFFFFFF to pause new frames entirely (the stream resumes when hint is reduced or cleared).
func (*RdpClient) SetResolution ¶
SetResolution requests a desktop resolution change via the MS-RDPEDISP Display Update Virtual Channel. The server will reshape the desktop to the given dimensions and send a fresh RDPGFX ResetGraphics command.
width must be even and both width and height must be >= 200. This method is a no-op when the RDPEDISP channel has not been established (e.g. when the server does not support it).
Directories
¶
| Path | Synopsis |
|---|---|
|
cliprdr
Generic, OS-independent clipboard support with text format only
|
Generic, OS-independent clipboard support with text format only |
|
rail
rail.go
|
rail.go |
|
rdpedisp
Package rdpedisp implements the RDP Display Update Virtual Channel (MS-RDPEDISP), which allows the client to request a resolution change while connected.
|
Package rdpedisp implements the RDP Display Update Virtual Channel (MS-RDPEDISP), which allows the client to request a resolution change while connected. |
|
rdpsnd
Package rdpsnd implements the RDPSND (Audio Output Virtual Channel Extension) protocol (MS-RDPEA) for server-to-client audio redirection.
|
Package rdpsnd implements the RDPSND (Audio Output Virtual Channel Extension) protocol (MS-RDPEA) for server-to-client audio redirection. |
|
protocol
|
|