Skip to content
rophyPublic
forked from x6nux/macrdp

About

RDP server for macOS, with H.264 screen streaming.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

 
 

Latest commit

 

History

209 Commits

Folders and files

Repository files navigation

macrdp

License: GPL v3 Rust macOS

An RDP server for macOS. Connect to a Mac from Windows (mstsc), Linux (FreeRDP) or any other RDP client that supports the RDP graphics pipeline (EGFX), preferably with H.264.

This is a fork of x6nux/macrdp, built on IronRDP. Changes are listed in the release notes.


Why

macOS has no RDP server. Its built-in Screen Sharing (VNC) sends lossless ZRLE to third-party viewers, so it is slow over normal networks, and RDP clients are what Windows and most thin clients already have. macrdp encodes the screen as H.264 with the Mac's hardware encoder and sends it over RDP, so that a Mac feels like a Windows remote desktop: smooth motion, a local-feeling cursor, low input latency and sharp text.

See comparisons with other remote desktop products.


Design

  • H.264 over the RDP graphics pipeline (EGFX), hardware encoded. The frame rate and bitrate follow screen activity and the network; an idle screen sends almost nothing.
  • Lossless where it matters — when the screen stops changing, text and UI areas are sent again losslessly, so text is sharp without the cost of lossless video.
  • The cursor is not in the video — it goes as RDP pointer updates with its real shapes, and the client draws it locally.
  • The client decides the size — the session follows the client window, and the picture is scaled to fit when the client is larger than the Mac display.
  • Windows-like input — keyboard, mouse and wheel behave as a Windows user expects.
  • One session at a time — a new authenticated connection takes over the current one.
  • Audio from the Mac to the client, and clipboard (text and files) in both directions.
  • Runs as a signed LaunchAgent with TLS and NLA; no desktop UI.

Tested clients

Client Notes
Windows mstsc (Windows 10 22H2) Works with default settings
FreeRDP 3.x with H.264 Use /gfx:AVC420 (or /gfx:AVC444); add /sound for audio

The client must support the RDP graphics pipeline (EGFX). If a client opens EGFX with AVC (H.264) disabled, for example FreeRDP /gfx without :AVC420, the server sends bitmap updates. A client without EGFX gets no video.


Requirements

  • macOS 14 (Sonoma) or later. Apple Silicon is tested.
  • To build from source: Rust 1.94 or later, and Xcode or the Command Line Tools.
  • Permissions for the macrdp-server binary (System Settings → Privacy & Security):
    • Screen Recording — capture
    • Accessibility — keyboard and mouse injection

macOS grants these permissions per binary path and signature. Release binaries keep them across upgrades; after each local rebuild, you may have to grant them again.


Install

Download macrdp-vX.Y.Z-macos-arm64.tar.gz and SHA256SUMS from Releases (Apple Silicon, signed and notarized), then:

shasum -a 256 -c SHA256SUMS
tar xzf macrdp-vX.Y.Z-macos-arm64.tar.gz
cd macrdp-vX.Y.Z-macos-arm64
./install.sh

install.sh runs as your user (no sudo). It:

  • copies macrdp-server to ~/.local/bin (set PREFIX to change)
  • creates ~/.config/macrdp/config.toml with your user name and a random password, if it does not exist
  • starts the LaunchAgent io.github.rophy.macrdp; the log is ~/Library/Logs/macrdp/macrdp.log

Then give macrdp-server Screen Recording and Accessibility permission and restart it (install.sh prints the command). The binary is signed with a fixed identity, so the permissions stay valid after an upgrade. ./uninstall.sh removes the binary and the LaunchAgent and keeps your config and logs.


Build and run

cargo build --release --bin macrdp-server
./target/release/macrdp-server --config config.toml

Connect your RDP client to <mac-ip>:<port>.

The server appends its log to macrdp.log in the current directory. At start, a log larger than 10 MB is moved to macrdp.log.1 (one old copy is kept). When stderr is a terminal, the log is also shown there. A log problem does not stop the server: when the move fails, the server appends to the old log; when the log cannot be opened, the log goes to stderr.

Command-line options:

Option Meaning
-c, --config <path> Config file
-p, --port <port> Listen port (default 3389; overrides the config file)
--frame-rate <n> Target frame rate
--log-level <level> trace, debug, info, warn, error
--perf Collect performance statistics and print a summary on exit

Configuration

Copy config.example.toml to config.toml and edit it.

macrdp uses the first config.toml it finds in:

  1. the current directory
  2. ~/.config/macrdp/
  3. ~/Library/Application Support/macrdp/
Key Default Meaning
port 3389 TCP port
username, password none Login. If not set, the server makes a random password for user macrdp at each start and prints it to stdout.
width, height 0 (auto) Fixed resolution. 0 follows the display and the client.
upscale true Accept a client desktop larger than the Mac display (up to 3840x2160, e.g. mstsc full screen on a 1920x1080 monitor) and scale the picture up to fill it; black bands keep the aspect ratio. false: the session is at most the display size, and a larger client shows a smaller picture with a black border. The Mac display mode does not change.
resolution auto Capture size, e.g. "3840x2160" for a sharper image on Retina displays
frame_rate 60 Target frame rate
quality high_quality low_latency, balanced or high_quality
encoder software hardware (VideoToolbox) or software (OpenH264)
chroma_mode avc420 avc420, or avc444 for full chroma
lossless_text true After 200 ms without change, send text and UI tiles again losslessly (ClearCodec); H.264 then updates only changed tiles. AVC420 only.
wifi_keep_awake true While a client uses the session, send a small ECHO request when nothing else was sent for 100 ms, so that Wi-Fi power save on the Mac does not delay input by 50-100 ms. Stops 10 minutes after the last input. Until the client opens the ECHO channel, and for clients without it (FreeRDP without /echo), a Heartbeat PDU goes instead, if the client advertises heartbeats.
ctrl_as_cmd false Keyboard for Windows users: Ctrl is Command, Alt is Option, Win is Control (Ctrl+C / Ctrl+V copy and paste). Default: Ctrl is Control, Alt is Command, Win is Option.
bitrate_mbps auto Bitrate ceiling
cursor_channel true Send the cursor as pointer updates instead of in the video
show_cursor auto Draw the cursor in the video (default: only when cursor_channel is off)
cert_path, key_path auto TLS certificate and key (PEM); generated if not set
idle_timeout_secs 0 (off) Disconnect the client after this many seconds without keyboard or mouse input. The client is told the reason (mstsc shows the idle message).
log_level info Log level, or a filter such as info,macrdp_server::display=debug. RUST_LOG overrides it. Warnings of rustls show only at error unless the filter names rustls (or is off). An invalid filter is reported on stderr; then log_level, then info, is used.
[audio] enabled true Audio forwarding
[audio] sample_rate, channels 48000, 2 Audio format
[clipboard] enabled true Clipboard sync
[clipboard] max_file_size_mb 100 Largest file for clipboard file transfer

Audio

The server sends audio only when the client asks for it. It reads the audio mode from the client's Client Info PDU:

Client setting mstsc "Remote audio" FreeRDP Server
Play on this computer default /sound sends audio
Play on remote computer "Play on remote computer" /audio-mode:1 no audio; the Mac plays it
Do not play "Do not play" default, /audio-mode:2 no audio

When no audio is requested, the Mac does not capture audio for that session.

Audio is uncompressed PCM, about 1.5 Mbps while sound plays. Silence is not sent.


Project layout

crates/
├── macrdp-server/                  server binary: config, session, display loop
├── macrdp-capture/                 ScreenCaptureKit capture (+ CoreGraphics fallback)
├── macrdp-encode/                  H.264 encoders (VideoToolbox, OpenH264), AVC444
├── macrdp-input/                   keyboard and mouse injection
├── macrdp-audio/                   system audio → rdpsnd
└── macrdp-clipboard/               clipboard and file transfer
tests/
├── e2e_test.sh                     smoke test from a Linux client
└── bench/                          macrdp vs macOS Screen Sharing benchmark

Tests

cargo test --workspace

MACRDP_USER=… MACRDP_PASS=… tests/e2e_test.sh <host> [port] runs a smoke test with FreeRDP 3 (with H.264) from a Linux machine: login, session takeover, bitmap, AVC420, no-audio and dynamic-resolution sessions. XFREERDP selects the client binary. Optional: MACRDP_AVC444=1 (server runs with chroma_mode = "avc444") adds an AVC444 test, MACRDP_LOG (server log readable by the script) checks the no-audio log line, and MACRDP_MAC_SHELL (a command that runs a script on the Mac, e.g. ssh user@mac sh) adds a clipboard file copy test. The script header has the details. tests/bench has the benchmark (see its README).


Versioning and releases

The version is in Cargo.toml ([workspace.package] version). Between releases, main carries the next version with -dev (for example 0.2.0-dev). macrdp-server --version adds git describe output to builds that are not a release tag.

To release: write the release notes to .github/release-notes/vX.Y.Z.md (without this file, GitHub generates notes from the commits), and commit version = "X.Y.Z" to main. After CI passes, the release workflow builds, signs, notarizes and publishes vX.Y.Z and creates the tag. Then commit the next -dev version. A -dev version, or a version whose tag exists, is not released.


Credits

  • x6nux/macrdp — the upstream project.
  • IronRDP — Rust RDP implementation. macrdp uses the staging branch of the fork rophy/IronRDP: upstream master plus macrdp's server changes. Fixes of general use are offered upstream.
  • FreeRDP — reference for AVC444 encoding and the client used for testing.
  • RustDesk — ideas for capture and input.

License

GNU General Public License v3.0. See LICENSE.

About

RDP server for macOS, with H.264 screen streaming.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages