Skip to content

Commit ac2f253

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

1 file changed

Lines changed: 22 additions & 10 deletions

File tree

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
use std::io;
@@ -226,6 +227,10 @@ struct Args {
226227
/// The clipboard type
227228
#[clap(long, value_enum, value_parser, default_value_t = ClipboardType::Default)]
228229
clipboard_type: ClipboardType,
230+
231+
/// The bitmap codecs to use (remotefx:on, ...)
232+
#[clap(long, value_parser, num_args = 1.., value_delimiter = ',')]
233+
codecs: Vec<String>,
229234
}
230235

231236
impl Config {
@@ -256,18 +261,25 @@ impl Config {
256261
.context("Password prompt")?
257262
};
258263

259-
let bitmap = if let Some(color_depth) = args.color_depth {
264+
let codecs: Vec<_> = args.codecs.iter().map(|s| s.as_str()).collect();
265+
let codecs = match client_codecs_capabilities(&codecs) {
266+
Ok(codecs) => codecs,
267+
Err(help) => {
268+
print!("{}", help);
269+
std::process::exit(0);
270+
}
271+
};
272+
let mut bitmap = connector::BitmapConfig {
273+
color_depth: 32,
274+
lossy_compression: true,
275+
codecs,
276+
};
277+
278+
if let Some(color_depth) = args.color_depth {
260279
if color_depth != 16 && color_depth != 32 {
261280
anyhow::bail!("Invalid color depth. Only 16 and 32 bit color depths are supported.");
262281
}
263-
264-
Some(connector::BitmapConfig {
265-
color_depth,
266-
lossy_compression: true,
267-
codecs: client_codecs_capabilities(&[]).unwrap(),
268-
})
269-
} else {
270-
None
282+
bitmap.color_depth = color_depth;
271283
};
272284

273285
let clipboard_type = if args.clipboard_type == ClipboardType::Default {
@@ -299,7 +311,7 @@ impl Config {
299311
height: DEFAULT_HEIGHT,
300312
},
301313
desktop_scale_factor: 0, // Default to 0 per FreeRDP
302-
bitmap,
314+
bitmap: Some(bitmap),
303315
client_build: semver::Version::parse(env!("CARGO_PKG_VERSION"))
304316
.map(|version| version.major * 100 + version.minor * 10 + version.patch)
305317
.unwrap_or(0)

0 commit comments

Comments
 (0)