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