-
Notifications
You must be signed in to change notification settings - Fork 731
GUACAMOLE-1415: RDP Camera Redirection (RDPECAM) - Server Implementation #624
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Add foundation layer for handling video streams from Guacamole clients. This infrastructure enables protocols to receive continuous video data from web clients, similar to the existing audio handler mechanism. Changes: - Add video_handler field to guac_user structure - Implement video instruction handler in user-handlers - Add video handler declaration and handshake support This is generic infrastructure not specific to RDPECAM and can be used by other protocols that need client-to-server video streaming.
Add core RDPECAM (RDP Enhanced Camera) channel implementation following the MS-RDPECAM specification. This provides the protocol layer for camera device enumeration, capability negotiation, and video streaming to remote Windows sessions. Components: - rdpecam.c/h: Main channel implementation and device management - rdpecam_caps.c/h: Capability negotiation and format handling - rdpecam_sink.c/h: Video sink for receiving and forwarding H.264 streams This channel implementation handles the low-level RDP protocol communication required for camera redirection.
Add guacrdpecam plugin that bridges Guacamole with the RDPECAM channel. This plugin handles the integration between Guacamole's video stream handling and FreeRDP's RDPECAM dynamic virtual channel. Components: - guacrdpecam.c/h: Main plugin implementation and lifecycle management - rdpecam_proto.c/h: Protocol message handling and serialization The plugin registers as a FreeRDP plugin and manages the connection between client video streams and the RDPECAM channel implementation.
Wire RDPECAM plugin into the RDP protocol handler and add configuration support. This integration connects the video handler infrastructure with the RDPECAM plugin and channel. Changes: - Load RDPECAM plugin when enabled in rdp.c - Add enable_rdpecam configuration option in settings - Register video handler in user.c for RDP connections - Add plugin declarations and initialization in rdp.h/client.c This completes the integration layer that enables camera redirection for RDP connections when the feature is enabled.
Add build configuration for RDPECAM channel and plugin components. Changes: - Add RDPECAM channel and plugin sources to Makefile.am - Add configure.ac checks and build rules This ensures the RDPECAM components are properly compiled and linked with the rest of the RDP protocol implementation.
- Add comprehensive tests for rdpecam_sink (frame queue operations) - Add tests for rdpecam_proto (protocol message building/parsing) - Add tests for rdpecam_caps (capability parsing and device name sanitization) - Update Makefile.am to include new test files - All tests follow test_SUITENAME__TESTNAME() naming convention
…tion variables - Replace usleep() polling with pthread_cond_wait() for better responsiveness - Add pthread_cond_broadcast() signals at all state change points: - When stream_channel is set/changed - When streaming starts/stops - When is_active_sender changes - When credits are granted - When device is stopping - Eliminates unnecessary CPU wake-ups and improves thread synchronization
|
As you will realize, this PR have been mostly using AI Coding. While exploring agentic AI programming, I wanted to do something actually useful and It came out pretty good. |
Similar comments, here, as on the client one - we'll need @mike-jumper's guidance on accepting/using AI-generated code, and the PR title needs to be updated to match the correct format. |
Yes, I was not sure what is the policy of Apache about AI assisted work. |
In short, registering _Device_0 up front was just defensive boilerplate; it wasn’t required by the protocol. Now that the listener is created at the point of advertisement (and only then), we avoid the extra allocation and keep the behavior identical.
|
It's a tricky question. The primary concerns would be around copyright:
ASF policy says it's OK to include output from generative tools so long as it's verified to not infringe on someone else's copyright: https://www.apache.org/legal/generative-tooling.html#include-in-contributions |
I do not think there is any copyrighted work in this implementation. I spent a full week going back and forth, reviewing, adjusting and fixing the generated chunk of code produced by the agents. I am quite sure we are OK regarding that matter. |
|
This is a solid and much-needed feature for remote users! The protocol-agnostic video handler infrastructure in the core library makes future camera/video streaming features much more maintainable across other protocols (e.g., VNC, SSH, etc.). Great to see that the pattern mirrors the audio handler work. Out of curiosity, do you foresee any unique challenges if/when adapting the video handler for non-H.264 codecs or non-RDP protocols? |
Hi @Shankhadeep1234, thank you for the positive feedback! I'm glad the protocol-agnostic design resonates with you. |
Note: This PR works in conjunction with the corresponding guacamole-client PR for complete camera redirection functionality.
Overview
This PR implements server-side support for RDP Camera Redirection using the MS-RDPECAM (RDP Enhanced Camera) protocol. This enables Apache Guacamole to forward H.264 video streams from web clients to remote Windows sessions via the RDPECAM dynamic virtual channel.
Problem Statement
Remote desktop users need the ability to use their local cameras in remote Windows sessions for video conferencing, biometric authentication, or other applications. This server-side implementation provides the protocol handling and stream management necessary to forward camera data from Guacamole clients to RDP sessions using Microsoft's RDPECAM specification.
Technical Implementation
1. Core Video Infrastructure (
5881e9ee)Added generic video handler infrastructure to Guacamole's core library, enabling protocols to receive video streams from clients:
Changes:
video_handlerfield inguac_userstructure (src/libguac/guacamole/user.h)user-handlers.c/hDesign Philosophy:
2. RDPECAM Channel Implementation (
4b59c528)Implemented the MS-RDPECAM protocol specification with three core components in
src/protocols/rdp/channels/rdpecam/:rdpecam.c/h- Channel Managementrdpecam_caps.c/h- Capability NegotiationKey Features:
rdpecam_sink.c/h- Video Frame Queue3. RDPECAM Plugin (
4ce6bf0b)FreeRDP plugin bridge in
src/protocols/rdp/plugins/guacrdpecam/:guacrdpecam.c/h- Plugin CoreThe centerpiece of the implementation, handling:
Architecture:
Key Components:
rdpecam_proto.c/h(781 lines) - Protocol MessagesLow-level MS-RDPECAM message handling:
Message Types Implemented:
ACTIVATE_DEVICE_REQUEST/RESPONSEDEACTIVATE_DEVICE_REQUESTSTART_STREAMS_REQUEST/RESPONSESTOP_STREAMS_REQUEST/RESPONSESTREAM_LIST_REQUEST/RESPONSEPROPERTY_LIST_REQUEST/RESPONSESTREAM_SAMPLE(video frame transmission)SUCCESS_RESPONSE/ERROR_RESPONSEFunctions:
4. RDP Protocol Integration (
63cca7bf,cb656338)Wired RDPECAM into the RDP protocol handler:
rdp.cmodifications:settings.c/hmodifications:enable-rdpecam(boolean, default: disabled)user.cmodifications:client.cmodifications:Build system (
configure.ac,Makefile.am):5. Dynamic Enable/Disable Support (
72de7796)Camera can be toggled during active sessions:
6. Thread Efficiency Optimization (
a00eb82c)Replaced polling-based dequeue thread with condition variables:
Before:
usleep()polling every 10msAfter:
pthread_cond_wait()with broadcast signalsSignals sent on:
7. Comprehensive Unit Tests (
3a7a8156)Added CUnit test suites in
src/protocols/rdp/tests/rdpecam/:rdpecam_sink_test.c(520 lines)Tests for frame queue operations:
rdpecam_proto_test.c(482 lines)Tests for protocol message handling:
rdpecam_caps_test.c(351 lines)Tests for capability processing:
Test Standards:
test_SUITENAME__TESTNAME()naming convention (required bygenerate-test-runner.pl)make check8. Bug Fixes and Cleanup (
8a9dbde6)Fixed device mapping cleanup:
Architecture
Component Hierarchy
Data Flow
Key Features
✅ MS-RDPECAM compliant - Full implementation of Microsoft specification
✅ H.264 video streaming - Industry-standard codec support
✅ Capability negotiation - Automatic format/resolution selection
✅ Flow control - Credit-based backpressure handling
✅ Dynamic activation - Enable/disable during active sessions
Known Limitations
Dependencies
Ready for review and merge.