Skip to content

Commit 4d9a29d

Browse files
committed
feat(client): add --codecs
Signed-off-by: Marc-André Lureau <[email protected]>
1 parent 365d550 commit 4d9a29d

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

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

238243
impl Config {
@@ -263,18 +268,25 @@ impl Config {
263268
.context("Password prompt")?
264269
};
265270

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

280292
let clipboard_type = if args.clipboard_type == ClipboardType::Default {
@@ -306,7 +318,7 @@ impl Config {
306318
height: DEFAULT_HEIGHT,
307319
},
308320
desktop_scale_factor: 0, // Default to 0 per FreeRDP
309-
bitmap,
321+
bitmap: Some(bitmap),
310322
client_build: semver::Version::parse(env!("CARGO_PKG_VERSION"))
311323
.map(|version| version.major * 100 + version.minor * 10 + version.patch)
312324
.unwrap_or(0)

0 commit comments

Comments
 (0)