a-da (ā dà) is translated as "阿大", named after a term my son likes. It is an open-source remote desktop control system.
Built on javacv + netty + swing technology, it ensures stable frame rates through streaming media transmission. Currently, it only supports the Windows operating system. If you need support for other operating systems, you can check out another open-source project of mine:https://github.com/SpringStudent/remote-desktop-control
- transport: Transmission module, responsible for remote desktop instructions and clipboard transmission
- stream: Streaming media module, responsible for remote desktop screen transmission
- registry: Registry center module, acting as a service registry center
- protocol: Protocol module, responsible for protocol definition
- common: Common module, responsible for the definition of common utility classes
- client: Client module, user-oriented
Screen capture parameter configuration RemoteGrabber.java
/**
* Video capture parameter configuration
*/
FFmpegFrameGrabber grabber = new FFmpegFrameGrabber("desktop");
// Whether capture mouse
grabber.setOption("draw_mouse", "0");
// Screen capture area
grabber.setOption("offset_x", "0");
grabber.setOption("offset_y", "0");
// Screen capture frame rate
grabber.setOption("framerate", "45");
// Automatically select hardware acceleration for screen capture
grabber.setOption("hwaccel", "auto");
// Set the number of threads used for screen capture.
grabber.setOption("threads", "auto");
// Screen size for screen capture
grabber.setOption("video_size", videoSize());
/**
* Video encoding parameter configuration
*/
recorder = new FFmpegFrameRecorder(RemoteClient.getRemoteClient().getStreamServer() + "/receive?id=" + streamId, grabber.getImageWidth(), grabber.getImageHeight());
recorder.setVideoCodec(avcodec.AV_CODEC_ID_MPEG1VIDEO);
// Video encoding format
recorder.setFormat("mpegts");
// Video frame rate
recorder.setFrameRate(45);
// Video encoding preset options, used to balance encoding speed and compression efficiency
recorder.setVideoOption("preset", "ultrafast");
// Video encoding tuning options, used to balance encoding speed and compression efficiency
recorder.setVideoOption("tune", "zerolatency");
// The quality of video encoding usually ranges from 0 to 21 or higher, with 0 being the highest quality
recorder.setVideoQuality(6);
// Set the number of threads used for encoding
recorder.setOption("threads", "auto");
- Clipboard functionality (completed)
- Distributed streaming media(completed)
- Distributed Clipboard Transfer (completed)
- Configurable resolution
- Visualized streaming media management
- Transport distribute(no plan,a lot of code change)
Given Netty's concurrency capabilities, it is perfectly feasible to support thousands to tens of thousands of long connections for the transmission of remote desktop commands. Therefore, the Netty service at the transport layer will not be distributed for the time being. Even if it were to be distributed, it would be for educational purposes rather than practical application.
In the current architectural design, the primary bottleneck in concurrency lies with streaming media. Hence, distributing the streaming media service is essential. Naturally, since the clipboard involves the transfer of large files, distribution is also necessary for this component. Fortunately, thanks to the stateless nature of both streaming media and file transfer, implementing distribution is relatively straightforward. This stands in contrast to the Netty service, which is stateful. Distributing the Netty service would require reliance on a central database such as Redis or MySQL, involving extensive modifications and complexities.
2025-03-21 Reflection: If the Netty service in the transport layer needs to be distributed, I would use the MQTT protocol to refactor the transmission and replace Netty, with MySQL or Redis as the best choices for storing connection states.