Skip to content

Commit 4666efb

Browse files
committed
feat(client): add --codecs
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
1 parent 46e4c67 commit 4666efb

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

crates/ironrdp-client/src/config.rs

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![allow(clippy::print_stdout)]
12
use core::num::ParseIntError;
23
use core::str::FromStr;
34

@@ -232,6 +233,10 @@ struct Args {
232233
/// The clipboard type
233234
#[clap(long, value_enum, value_parser, default_value_t = ClipboardType::Default)]
234235
clipboard_type: ClipboardType,
236+
237+
/// The bitmap codecs to use (remotefx:on, ...)
238+
#[clap(long, value_parser, num_args = 1.., value_delimiter = ',')]
239+
codecs: Vec<String>,
235240
}
236241

237242
impl Config {
@@ -262,18 +267,25 @@ impl Config {
262267
.context("Password prompt")?
263268
};
264269

265-
let bitmap = if let Some(color_depth) = args.color_depth {
270+
let codecs: Vec<_> = args.codecs.iter().map(|s| s.as_str()).collect();
271+
let codecs = match client_codecs_capabilities(&codecs) {
272+
Ok(codecs) => codecs,
273+
Err(help) => {
274+
print!("{}", help);
275+
std::process::exit(0);
276+
}
277+
};
278+
let mut bitmap = connector::BitmapConfig {
279+
color_depth: 32,
280+
lossy_compression: true,
281+
codecs,
282+
};
283+
284+
if let Some(color_depth) = args.color_depth {
266285
if color_depth != 16 && color_depth != 32 {
267286
anyhow::bail!("Invalid color depth. Only 16 and 32 bit color depths are supported.");
268287
}
269-
270-
Some(connector::BitmapConfig {
271-
color_depth,
272-
lossy_compression: true,
273-
codecs: client_codecs_capabilities(&[]).unwrap(),
274-
})
275-
} else {
276-
None
288+
bitmap.color_depth = color_depth;
277289
};
278290

279291
let clipboard_type = if args.clipboard_type == ClipboardType::Default {
@@ -305,7 +317,7 @@ impl Config {
305317
height: DEFAULT_HEIGHT,
306318
},
307319
desktop_scale_factor: 0, // Default to 0 per FreeRDP
308-
bitmap,
320+
bitmap: Some(bitmap),
309321
client_build: semver::Version::parse(env!("CARGO_PKG_VERSION"))
310322
.map(|version| version.major * 100 + version.minor * 10 + version.patch)
311323
.unwrap_or(0)

0 commit comments

Comments
 (0)