Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
154 changes: 154 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
name: Build

on:
push:
branches: [ "main" ]
tags: [ "v*" ]
pull_request:
branches: [ "main" ]

jobs:
# ---------------------------------------------------------------------------
# Linux build
# ---------------------------------------------------------------------------
build-linux:
name: Linux (GCC)
runs-on: ubuntu-24.04
permissions:
contents: read

steps:
- uses: actions/checkout@v4

- name: Install dependencies
run: |
sudo apt-get update -y
sudo apt-get install -y \
build-essential cmake ninja-build pkg-config \
libssl-dev \
freerdp3-dev libwinpr3-dev

- name: Configure (Release)
run: |
cmake -S . -B build \
-G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DRDPBRIDGE_BUILD_EXAMPLES=ON

- name: Build
run: cmake --build build --config Release

- name: Verify shared library exists
run: ls -lh build/libRdpBridge.so

# -----------------------------------------------------------------------
# Package the SDK: header + shared library
# -----------------------------------------------------------------------
- name: Package SDK (Linux)
run: |
mkdir -p sdk-linux/include sdk-linux/lib
cp include/rdp_bridge.h sdk-linux/include/
cp build/libRdpBridge.so sdk-linux/lib/
tar -czf RdpBridge-linux-x64.tar.gz -C sdk-linux .

- name: Upload artifact (Linux)
uses: actions/upload-artifact@v4
with:
name: RdpBridge-linux-x64
path: RdpBridge-linux-x64.tar.gz

# ---------------------------------------------------------------------------
# Windows build
# ---------------------------------------------------------------------------
build-windows:
name: Windows (MSVC)
runs-on: windows-2022
permissions:
contents: read

steps:
- uses: actions/checkout@v4

# Install FreeRDP via vcpkg (bundled on the runner)
- name: Set up vcpkg
run: |
git clone --depth=1 https://github.com/microsoft/vcpkg "${{ github.workspace }}/vcpkg"
"${{ github.workspace }}/vcpkg/bootstrap-vcpkg.bat" -disableMetrics
shell: cmd

- name: Install FreeRDP via vcpkg
run: |
"${{ github.workspace }}/vcpkg/vcpkg.exe" install freerdp:x64-windows openssl:x64-windows
shell: cmd

- name: Configure (Release)
run: |
cmake -S . -B build `
-G "Visual Studio 17 2022" -A x64 `
-DCMAKE_BUILD_TYPE=Release `
-DRDPBRIDGE_BUILD_EXAMPLES=ON `
-DCMAKE_TOOLCHAIN_FILE="${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake"
shell: pwsh

- name: Build
run: cmake --build build --config Release
shell: pwsh

- name: Verify DLL exists
run: |
if (!(Test-Path "build/Release/RdpBridge.dll")) {
Write-Error "RdpBridge.dll not found"
exit 1
}
Get-Item "build/Release/RdpBridge.dll"
shell: pwsh

# -----------------------------------------------------------------------
# Package the SDK: header + DLL + import library
# -----------------------------------------------------------------------
- name: Package SDK (Windows)
run: |
New-Item -ItemType Directory -Force sdk-windows/include | Out-Null
New-Item -ItemType Directory -Force sdk-windows/lib | Out-Null
New-Item -ItemType Directory -Force sdk-windows/bin | Out-Null
Copy-Item include/rdp_bridge.h sdk-windows/include/
Copy-Item build/Release/RdpBridge.dll sdk-windows/bin/
Copy-Item build/Release/RdpBridge.lib sdk-windows/lib/ -ErrorAction SilentlyContinue
Compress-Archive -Path sdk-windows/* -DestinationPath RdpBridge-windows-x64.zip
shell: pwsh

- name: Upload artifact (Windows)
uses: actions/upload-artifact@v4
with:
name: RdpBridge-windows-x64
path: RdpBridge-windows-x64.zip

# ---------------------------------------------------------------------------
# GitHub Release (tag pushes only)
# ---------------------------------------------------------------------------
release:
name: Publish Release
if: startsWith(github.ref, 'refs/tags/v')
needs: [ build-linux, build-windows ]
runs-on: ubuntu-24.04
permissions:
contents: write

steps:
- name: Download Linux artifact
uses: actions/download-artifact@v4
with:
name: RdpBridge-linux-x64

- name: Download Windows artifact
uses: actions/download-artifact@v4
with:
name: RdpBridge-windows-x64

- name: Publish GitHub Release
uses: softprops/action-gh-release@v2
with:
files: |
RdpBridge-linux-x64.tar.gz
RdpBridge-windows-x64.zip
generate_release_notes: true
92 changes: 92 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
cmake_minimum_required(VERSION 3.22)
project(RdpBridge VERSION 1.0.0 LANGUAGES C CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

# ---------------------------------------------------------------------------
# Options
# ---------------------------------------------------------------------------
option(RDPBRIDGE_BUILD_EXAMPLES "Build usage examples" ON)

# ---------------------------------------------------------------------------
# Dependencies
# ---------------------------------------------------------------------------
find_package(FreeRDP REQUIRED CONFIG)
find_package(WinPR REQUIRED CONFIG)
find_package(OpenSSL REQUIRED)

find_path(FREERDP_INCLUDE_DIR NAMES freerdp/freerdp.h PATH_SUFFIXES freerdp3)

# ---------------------------------------------------------------------------
# RdpBridge shared library
# ---------------------------------------------------------------------------
add_library(RdpBridge SHARED
src/RdpBridge/rdp_bridge.cpp
include/rdp_bridge.h
)

target_include_directories(RdpBridge
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
PRIVATE
${FREERDP_INCLUDE_DIR}
)

target_link_libraries(RdpBridge
PRIVATE
freerdp
winpr
OpenSSL::Crypto
)

target_compile_definitions(RdpBridge PRIVATE RDP_BRIDGE_EXPORTS)

# Platform-specific library naming and RPATH
if(WIN32)
set_target_properties(RdpBridge PROPERTIES PREFIX "")
set_target_properties(RdpBridge PROPERTIES OUTPUT_NAME "RdpBridge")
elseif(APPLE)
set_target_properties(RdpBridge PROPERTIES
INSTALL_RPATH "@loader_path"
BUILD_WITH_INSTALL_RPATH TRUE
OUTPUT_NAME "RdpBridge"
)
else()
set_target_properties(RdpBridge PROPERTIES
INSTALL_RPATH "$ORIGIN"
BUILD_WITH_INSTALL_RPATH TRUE
OUTPUT_NAME "RdpBridge"
)
endif()

# ---------------------------------------------------------------------------
# Install rules
# ---------------------------------------------------------------------------
include(GNUInstallDirs)

install(TARGETS RdpBridge
EXPORT RdpBridgeTargets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)

install(FILES include/rdp_bridge.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)

install(EXPORT RdpBridgeTargets
FILE RdpBridgeTargets.cmake
NAMESPACE RdpBridge::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/RdpBridge
)
Comment on lines +81 to +85

# ---------------------------------------------------------------------------
# Examples
# ---------------------------------------------------------------------------
if(RDPBRIDGE_BUILD_EXAMPLES)
add_subdirectory(examples/minimal)
endif()
90 changes: 89 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,89 @@
# rdp-bridge
# RdpBridge

A production-grade native RDP SDK built on [FreeRDP](https://www.freerdp.com/),
exposing a clean **C ABI** suitable for P/Invoke from C#, Avalonia, and other
languages.

## Features

- **Session lifecycle** – create, connect, disconnect, destroy
- **BGRA32 framebuffer callbacks** – zero-copy raw pixel delivery
- **Input** – mouse (move / click / wheel), keyboard scancode, Unicode input
- **Security profiles** – automatic NLA → TLS → RDP → negotiate fallback
- **Thread-safe** – connection on a dedicated worker thread, atomic session state
- **Cross-platform** – Windows (MSVC → `RdpBridge.dll`) and Linux (GCC/Clang → `libRdpBridge.so`)

---

## Quick Start

### Build (Linux)

```bash
sudo apt-get install -y build-essential cmake ninja-build \
libssl-dev freerdp3-dev libwinpr3-dev

cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release
cmake --build build
```

### Build (Windows)

```powershell
# Prerequisites: Visual Studio 2022, CMake, vcpkg
vcpkg install freerdp:x64-windows openssl:x64-windows

cmake -S . -B build -G "Visual Studio 17 2022" -A x64 `
-DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake"
cmake --build build --config Release
```

---

## C API

```c
#include "rdp_bridge.h"

void* session = RdpBridge_create();

RdpBridge_set_callbacks(session, on_frame, on_status, on_disconnect, user_data);

RdpBridge_connect(session, "192.168.1.1", 3389, "Administrator", "password", 1920, 1080);

// ... run your event loop ...

RdpBridge_disconnect(session);
RdpBridge_destroy(session);
```

Full API reference: [`include/rdp_bridge.h`](include/rdp_bridge.h)

---

## Repository Layout

```
/include Public header (rdp_bridge.h)
/src/RdpBridge Core implementation (rdp_bridge.cpp)
/cmake (reserved for future CMake helpers)
/examples/minimal Minimal C usage example
/.github/workflows CI/CD (build.yml)
```

---

## CI / CD

| Event | Action |
|---|---|
| Push to `main` | Build Linux SO + Windows DLL |
| Tag `v*` | Build + package + upload to GitHub Release |

---

## License

This project is derived from
[CxShell/CxRdpBridge](https://github.com/xiaochengzjc/CxShell/tree/master/native/CxRdpBridge).
See [LICENSE](LICENSE) for details.
17 changes: 17 additions & 0 deletions examples/minimal/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
cmake_minimum_required(VERSION 3.22)
project(RdpBridgeMinimalExample LANGUAGES C CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# When built standalone (outside the SDK tree) find the installed package.
# When built as part of the top-level CMakeLists.txt the target already exists.
if(NOT TARGET RdpBridge)
find_package(RdpBridge REQUIRED CONFIG)
set(RDPBRIDGE_TARGET RdpBridge::RdpBridge)
else()
set(RDPBRIDGE_TARGET RdpBridge)
endif()

add_executable(rdp_example main.c)
target_link_libraries(rdp_example PRIVATE ${RDPBRIDGE_TARGET})
Loading
Loading