|
| 1 | +#![allow(clippy::print_stdout)] |
1 | 2 | use core::num::ParseIntError; |
2 | 3 | use core::str::FromStr; |
3 | 4 |
|
@@ -232,6 +233,10 @@ struct Args { |
232 | 233 | /// The clipboard type |
233 | 234 | #[clap(long, value_enum, value_parser, default_value_t = ClipboardType::Default)] |
234 | 235 | 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>, |
235 | 240 | } |
236 | 241 |
|
237 | 242 | impl Config { |
@@ -262,18 +267,25 @@ impl Config { |
262 | 267 | .context("Password prompt")? |
263 | 268 | }; |
264 | 269 |
|
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 { |
266 | 285 | if color_depth != 16 && color_depth != 32 { |
267 | 286 | anyhow::bail!("Invalid color depth. Only 16 and 32 bit color depths are supported."); |
268 | 287 | } |
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; |
277 | 289 | }; |
278 | 290 |
|
279 | 291 | let clipboard_type = if args.clipboard_type == ClipboardType::Default { |
@@ -305,7 +317,7 @@ impl Config { |
305 | 317 | height: DEFAULT_HEIGHT, |
306 | 318 | }, |
307 | 319 | desktop_scale_factor: 0, // Default to 0 per FreeRDP |
308 | | - bitmap, |
| 320 | + bitmap: Some(bitmap), |
309 | 321 | client_build: semver::Version::parse(env!("CARGO_PKG_VERSION")) |
310 | 322 | .map(|version| version.major * 100 + version.minor * 10 + version.patch) |
311 | 323 | .unwrap_or(0) |
|
0 commit comments