|
| 1 | +#![allow(clippy::print_stdout)] |
1 | 2 | use core::num::ParseIntError; |
2 | 3 | use core::str::FromStr; |
3 | 4 | use std::io; |
@@ -226,6 +227,10 @@ struct Args { |
226 | 227 | /// The clipboard type |
227 | 228 | #[clap(long, value_enum, value_parser, default_value_t = ClipboardType::Default)] |
228 | 229 | 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>, |
229 | 234 | } |
230 | 235 |
|
231 | 236 | impl Config { |
@@ -256,18 +261,25 @@ impl Config { |
256 | 261 | .context("Password prompt")? |
257 | 262 | }; |
258 | 263 |
|
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 { |
260 | 279 | if color_depth != 16 && color_depth != 32 { |
261 | 280 | anyhow::bail!("Invalid color depth. Only 16 and 32 bit color depths are supported."); |
262 | 281 | } |
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; |
271 | 283 | }; |
272 | 284 |
|
273 | 285 | let clipboard_type = if args.clipboard_type == ClipboardType::Default { |
@@ -299,7 +311,7 @@ impl Config { |
299 | 311 | height: DEFAULT_HEIGHT, |
300 | 312 | }, |
301 | 313 | desktop_scale_factor: 0, // Default to 0 per FreeRDP |
302 | | - bitmap, |
| 314 | + bitmap: Some(bitmap), |
303 | 315 | client_build: semver::Version::parse(env!("CARGO_PKG_VERSION")) |
304 | 316 | .map(|version| version.major * 100 + version.minor * 10 + version.patch) |
305 | 317 | .unwrap_or(0) |
|
0 commit comments