Skip to content

Commit 3e738a9

Browse files
authored
feat(server): add builder option to set remotefx (#569)
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
1 parent 5ea39d0 commit 3e738a9

File tree

3 files changed

+23
-11
lines changed

3 files changed

+23
-11
lines changed

crates/ironrdp-server/src/builder.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ pub struct WantsDisplay {
2525
pub struct BuilderDone {
2626
addr: SocketAddr,
2727
security: RdpServerSecurity,
28+
with_remote_fx: bool,
2829
handler: Box<dyn RdpServerInputHandler>,
2930
display: Box<dyn RdpServerDisplay>,
3031
cliprdr_factory: Option<Box<dyn CliprdrServerFactory>>,
@@ -123,6 +124,7 @@ impl RdpServerBuilder<WantsDisplay> {
123124
display: Box::new(display),
124125
sound_factory: None,
125126
cliprdr_factory: None,
127+
with_remote_fx: true,
126128
},
127129
}
128130
}
@@ -136,6 +138,7 @@ impl RdpServerBuilder<WantsDisplay> {
136138
display: Box::new(NoopDisplay),
137139
sound_factory: None,
138140
cliprdr_factory: None,
141+
with_remote_fx: true,
139142
},
140143
}
141144
}
@@ -152,11 +155,17 @@ impl RdpServerBuilder<BuilderDone> {
152155
self
153156
}
154157

158+
pub fn with_remote_fx(mut self, enabled: bool) -> Self {
159+
self.state.with_remote_fx = enabled;
160+
self
161+
}
162+
155163
pub fn build(self) -> RdpServer {
156164
RdpServer::new(
157165
RdpServerOptions {
158166
addr: self.state.addr,
159167
security: self.state.security,
168+
with_remote_fx: self.state.with_remote_fx,
160169
},
161170
self.state.handler,
162171
self.state.display,

crates/ironrdp-server/src/capabilities.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use ironrdp_pdu::rdp::capability_sets::{self, GeneralExtraFlags};
22

33
use crate::{DesktopSize, RdpServerOptions};
44

5-
pub(crate) fn capabilities(_opts: &RdpServerOptions, size: DesktopSize) -> Vec<capability_sets::CapabilitySet> {
5+
pub(crate) fn capabilities(opts: &RdpServerOptions, size: DesktopSize) -> Vec<capability_sets::CapabilitySet> {
66
vec![
77
capability_sets::CapabilitySet::General(general_capabilities()),
88
capability_sets::CapabilitySet::Bitmap(bitmap_capabilities(&size)),
@@ -12,7 +12,7 @@ pub(crate) fn capabilities(_opts: &RdpServerOptions, size: DesktopSize) -> Vec<c
1212
capability_sets::CapabilitySet::Input(input_capabilities()),
1313
capability_sets::CapabilitySet::VirtualChannel(virtual_channel_capabilities()),
1414
capability_sets::CapabilitySet::MultiFragmentUpdate(multifragment_update()),
15-
capability_sets::CapabilitySet::BitmapCodecs(bitmap_codecs()),
15+
capability_sets::CapabilitySet::BitmapCodecs(bitmap_codecs(opts.with_remote_fx)),
1616
]
1717
}
1818

@@ -86,17 +86,19 @@ fn multifragment_update() -> capability_sets::MultifragmentUpdate {
8686
}
8787
}
8888

89-
fn bitmap_codecs() -> capability_sets::BitmapCodecs {
90-
capability_sets::BitmapCodecs(vec![
91-
capability_sets::Codec {
89+
fn bitmap_codecs(with_remote_fx: bool) -> capability_sets::BitmapCodecs {
90+
let mut codecs = Vec::new();
91+
if with_remote_fx {
92+
codecs.push(capability_sets::Codec {
9293
id: 0,
9394
property: capability_sets::CodecProperty::RemoteFx(capability_sets::RemoteFxContainer::ServerContainer(1)),
94-
},
95-
capability_sets::Codec {
95+
});
96+
codecs.push(capability_sets::Codec {
9697
id: 0,
9798
property: capability_sets::CodecProperty::ImageRemoteFx(
9899
capability_sets::RemoteFxContainer::ServerContainer(1),
99100
),
100-
},
101-
])
101+
});
102+
}
103+
capability_sets::BitmapCodecs(codecs)
102104
}

crates/ironrdp-server/src/server.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ use crate::{builder, capabilities, SoundServerFactory};
3838
pub struct RdpServerOptions {
3939
pub addr: SocketAddr,
4040
pub security: RdpServerSecurity,
41+
pub with_remote_fx: bool,
4142
}
4243

4344
#[derive(Clone)]
@@ -694,14 +695,14 @@ impl RdpServer {
694695
// the last parsed here.
695696
rdp::capability_sets::CodecProperty::RemoteFx(
696697
rdp::capability_sets::RemoteFxContainer::ClientContainer(c),
697-
) => {
698+
) if self.opts.with_remote_fx => {
698699
for caps in c.caps_data.0 .0 {
699700
rfxcodec = Some((caps.entropy_bits, codec.id));
700701
}
701702
}
702703
rdp::capability_sets::CodecProperty::ImageRemoteFx(
703704
rdp::capability_sets::RemoteFxContainer::ClientContainer(c),
704-
) => {
705+
) if self.opts.with_remote_fx => {
705706
for caps in c.caps_data.0 .0 {
706707
rfxcodec = Some((caps.entropy_bits, codec.id));
707708
}

0 commit comments

Comments
 (0)