-
Notifications
You must be signed in to change notification settings - Fork 167
feat(server): add EGFX server integration with DVC bridge #1099
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
Open
glamberson
wants to merge
3
commits into
Devolutions:master
Choose a base branch
from
glamberson:egfx-server-integration
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+303
−14
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| //! EGFX (Graphics Pipeline Extension) server integration. | ||
| //! | ||
| //! Provides the bridge between `ironrdp-egfx`'s `GraphicsPipelineServer` and | ||
| //! `ironrdp-server`'s `RdpServer`, enabling H.264 video streaming via DVC. | ||
| //! | ||
| //! The bridge pattern (`GfxDvcBridge`) wraps an `Arc<Mutex<GraphicsPipelineServer>>` | ||
| //! so the display handler can call `send_avc420_frame()` proactively while the | ||
| //! DVC infrastructure handles client messages (capability negotiation, frame acks). | ||
|
|
||
| use std::sync::{Arc, Mutex}; | ||
|
|
||
| use ironrdp_core::impl_as_any; | ||
| use ironrdp_dvc::{DvcMessage, DvcProcessor, DvcServerProcessor}; | ||
| use ironrdp_egfx::server::{GraphicsPipelineHandler, GraphicsPipelineServer}; | ||
| use ironrdp_pdu::PduResult; | ||
| use ironrdp_svc::SvcMessage; | ||
|
|
||
| use crate::server::ServerEventSender; | ||
|
|
||
| /// Shared handle to a `GraphicsPipelineServer`. | ||
| /// | ||
| /// Uses `std::sync::Mutex` (not tokio) because `DvcProcessor` trait methods | ||
| /// are synchronous and cannot hold async locks. | ||
| pub type GfxServerHandle = Arc<Mutex<GraphicsPipelineServer>>; | ||
|
|
||
| /// Factory for creating EGFX graphics pipeline handlers. | ||
| /// | ||
| /// Implements `ServerEventSender` so the factory can signal the server event loop | ||
| /// when EGFX frames are ready to be drained and sent. | ||
| pub trait GfxServerFactory: ServerEventSender + Send { | ||
| /// Create a handler for EGFX callbacks (caps negotiation, frame acks). | ||
| fn build_gfx_handler(&self) -> Box<dyn GraphicsPipelineHandler>; | ||
|
|
||
| /// Create a bridge and shared server handle for proactive frame sending. | ||
| /// | ||
| /// When returning `Some`, the bridge is registered with DrdynvcServer for | ||
| /// client messages, and the handle is available for direct frame submission. | ||
| /// Returns `None` by default, falling back to `build_gfx_handler()`. | ||
| fn build_server_with_handle(&self) -> Option<(GfxDvcBridge, GfxServerHandle)> { | ||
| None | ||
| } | ||
| } | ||
|
|
||
| /// DVC bridge wrapping a shared `GraphicsPipelineServer`. | ||
| /// | ||
| /// Delegates all `DvcProcessor` methods to the inner server through a mutex, | ||
| /// enabling shared access from both the DVC layer and the display handler. | ||
| pub struct GfxDvcBridge { | ||
| inner: GfxServerHandle, | ||
| } | ||
|
|
||
| impl GfxDvcBridge { | ||
| pub fn new(server: GfxServerHandle) -> Self { | ||
| Self { inner: server } | ||
| } | ||
|
|
||
| pub fn server(&self) -> &GfxServerHandle { | ||
| &self.inner | ||
| } | ||
| } | ||
|
|
||
| impl_as_any!(GfxDvcBridge); | ||
|
|
||
| impl DvcProcessor for GfxDvcBridge { | ||
| fn channel_name(&self) -> &str { | ||
| ironrdp_egfx::CHANNEL_NAME | ||
| } | ||
|
|
||
| fn start(&mut self, channel_id: u32) -> PduResult<Vec<DvcMessage>> { | ||
| self.inner | ||
| .lock() | ||
| .expect("GfxServerHandle mutex poisoned") | ||
| .start(channel_id) | ||
| } | ||
|
|
||
| fn process(&mut self, channel_id: u32, payload: &[u8]) -> PduResult<Vec<DvcMessage>> { | ||
| self.inner | ||
| .lock() | ||
| .expect("GfxServerHandle mutex poisoned") | ||
| .process(channel_id, payload) | ||
| } | ||
|
|
||
| fn close(&mut self, channel_id: u32) { | ||
| self.inner | ||
| .lock() | ||
| .expect("GfxServerHandle mutex poisoned") | ||
| .close(channel_id) | ||
| } | ||
| } | ||
|
|
||
| impl DvcServerProcessor for GfxDvcBridge {} | ||
|
|
||
| /// Message for routing EGFX PDUs to the wire via `ServerEvent`. | ||
| #[derive(Debug)] | ||
| pub enum EgfxServerMessage { | ||
| /// Pre-encoded DVC messages from `GraphicsPipelineServer::drain_output()`. | ||
| SendMessages { messages: Vec<SvcMessage> }, | ||
| } | ||
|
|
||
| impl core::fmt::Display for EgfxServerMessage { | ||
| fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | ||
| match self { | ||
| Self::SendMessages { messages } => { | ||
| write!(f, "SendMessages(count={})", messages.len()) | ||
| } | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.