Skip to content

Commit 04d78b6

Browse files
author
Isaiah Becker-Mayer
authored
refactor: dynamic resize follow up (#425)
1 parent 8e84fe5 commit 04d78b6

File tree

21 files changed

+32
-76
lines changed

21 files changed

+32
-76
lines changed

crates/ironrdp-client/src/config.rs

-21
Original file line numberDiff line numberDiff line change
@@ -181,14 +181,6 @@ struct Args {
181181
#[clap(long, value_parser, default_value_t = String::from(""))]
182182
dig_product_id: String,
183183

184-
/// Enable AVC444
185-
#[clap(long, group = "avc")]
186-
avc444: bool,
187-
188-
/// Enable H264
189-
#[clap(long, group = "avc")]
190-
h264: bool,
191-
192184
/// Enable thin client
193185
#[clap(long)]
194186
thin_client: bool,
@@ -277,18 +269,6 @@ impl Config {
277269
None
278270
};
279271

280-
let graphics = if args.avc444 || args.h264 {
281-
Some(connector::GraphicsConfig {
282-
avc444: args.avc444,
283-
h264: args.h264,
284-
thin_client: args.thin_client,
285-
small_cache: args.small_cache,
286-
capabilities: args.capabilities,
287-
})
288-
} else {
289-
None
290-
};
291-
292272
let clipboard_type = if args.clipboard_type == ClipboardType::Default {
293273
#[cfg(windows)]
294274
{
@@ -316,7 +296,6 @@ impl Config {
316296
width: DEFAULT_WIDTH,
317297
height: DEFAULT_HEIGHT,
318298
},
319-
graphics,
320299
bitmap,
321300
client_build: semver::Version::parse(env!("CARGO_PKG_VERSION"))
322301
.map(|version| version.major * 100 + version.minor * 10 + version.patch)

crates/ironrdp-cliprdr-native/src/stub.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ use ironrdp_cliprdr::pdu::{
66
use ironrdp_svc::impl_as_any;
77
use tracing::debug;
88

9-
pub struct StubClipboard {}
9+
pub struct StubClipboard;
1010

1111
impl StubClipboard {
1212
pub fn new() -> Self {
13-
Self {}
13+
Self
1414
}
1515

1616
pub fn backend_factory(&self) -> Box<dyn CliprdrBackendFactory + Send> {
@@ -33,13 +33,13 @@ impl CliprdrBackendFactory for StubCliprdrBackendFactory {
3333
}
3434

3535
#[derive(Debug)]
36-
pub(crate) struct StubCliprdrBackend {}
36+
pub(crate) struct StubCliprdrBackend;
3737

3838
impl_as_any!(StubCliprdrBackend);
3939

4040
impl StubCliprdrBackend {
4141
pub(crate) fn new() -> Self {
42-
Self {}
42+
Self
4343
}
4444
}
4545

crates/ironrdp-connector/src/connection.rs

-6
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ pub struct ConnectionResult {
2222
pub user_channel_id: u16,
2323
pub static_channels: StaticChannelSet,
2424
pub desktop_size: DesktopSize,
25-
pub graphics_config: Option<crate::GraphicsConfig>,
2625
pub no_server_pointer: bool,
2726
pub pointer_software_rendering: bool,
2827
pub connection_activation: ConnectionActivationSequence,
@@ -558,7 +557,6 @@ impl Sequence for ClientConnector {
558557
user_channel_id,
559558
static_channels: mem::take(&mut self.static_channels),
560559
desktop_size,
561-
graphics_config: self.config.graphics.clone(),
562560
no_server_pointer: self.config.no_server_pointer,
563561
pointer_software_rendering: self.config.pointer_software_rendering,
564562
connection_activation,
@@ -651,10 +649,6 @@ fn create_gcc_blocks<'a>(
651649

652650
// TODO(#136): support for ClientEarlyCapabilityFlags::SUPPORT_STATUS_INFO_PDU
653651

654-
if config.graphics.is_some() {
655-
early_capability_flags |= ClientEarlyCapabilityFlags::SUPPORT_DYN_VC_GFX_PROTOCOL;
656-
}
657-
658652
if max_color_depth == 32 {
659653
early_capability_flags |= ClientEarlyCapabilityFlags::WANT_32_BPP_SESSION;
660654
}

crates/ironrdp-connector/src/lib.rs

-11
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,6 @@ pub struct DesktopSize {
3838
pub height: u16,
3939
}
4040

41-
#[derive(Debug, Clone)]
42-
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
43-
pub struct GraphicsConfig {
44-
pub avc444: bool,
45-
pub h264: bool,
46-
pub thin_client: bool,
47-
pub small_cache: bool,
48-
pub capabilities: u32,
49-
}
50-
5141
#[derive(Debug, Clone)]
5242
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
5343
pub struct BitmapConfig {
@@ -140,7 +130,6 @@ pub struct Config {
140130
pub keyboard_subtype: u32,
141131
pub keyboard_functional_keys_count: u32,
142132
pub ime_file_name: String,
143-
pub graphics: Option<GraphicsConfig>,
144133
pub bitmap: Option<BitmapConfig>,
145134
pub dig_product_id: String,
146135
pub client_dir: String,

crates/ironrdp-displaycontrol/src/client.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use ironrdp_svc::{impl_as_any, ChannelFlags, SvcMessage};
88
use tracing::debug;
99

1010
/// A client for the Display Control Virtual Channel.
11-
pub struct DisplayControlClient {}
11+
pub struct DisplayControlClient;
1212

1313
impl_as_any!(DisplayControlClient);
1414

@@ -33,7 +33,7 @@ impl DvcClientProcessor for DisplayControlClient {}
3333

3434
impl DisplayControlClient {
3535
pub fn new() -> Self {
36-
Self {}
36+
Self
3737
}
3838

3939
/// Fully encodes a [`MonitorLayoutPdu`] with the given monitors.

crates/ironrdp-displaycontrol/src/server.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::{
99
};
1010

1111
/// A server for the Display Control Virtual Channel.
12-
pub struct DisplayControlServer {}
12+
pub struct DisplayControlServer;
1313

1414
impl_as_any!(DisplayControlServer);
1515

crates/ironrdp-dvc/src/complete_data.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl CompleteData {
4949
return Ok(Some(data.data));
5050
}
5151

52-
// message is fragmented so need to reassemble it
52+
// The message is fragmented and needs to be reassembled.
5353
match self.data.len().checked_add(data.data.len()) {
5454
Some(actual_data_length) => {
5555
match actual_data_length.cmp(&(self.total_size)) {

crates/ironrdp-dvc/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#![cfg_attr(not(feature = "std"), no_std)]
22

3-
use crate::alloc::borrow::ToOwned;
43
#[macro_use]
54
extern crate tracing;
65

76
extern crate alloc;
87

8+
use crate::alloc::borrow::ToOwned;
99
use alloc::string::String;
1010
use core::any::TypeId;
1111
use pdu::DrdynvcDataPdu;

crates/ironrdp-dvc/src/pdu.rs

+7-10
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ use ironrdp_pdu::{
66
cast_length,
77
cursor::{ReadCursor, WriteCursor},
88
ensure_fixed_part_size, ensure_size, invalid_message_err, unsupported_pdu_err,
9-
utils::{
10-
checked_sum, checked_sum_or_panic, encoded_str_len, read_string_from_cursor, write_string_to_cursor,
11-
CharacterSet,
12-
},
9+
utils::{checked_sum, encoded_str_len, read_string_from_cursor, strict_sum, write_string_to_cursor, CharacterSet},
1310
PduDecode, PduEncode, PduError, PduResult,
1411
};
1512
use ironrdp_svc::SvcPduEncode;
@@ -354,7 +351,7 @@ impl DataFirstPdu {
354351
}
355352

356353
fn size(&self) -> usize {
357-
checked_sum_or_panic(&[
354+
strict_sum(&[
358355
Header::size(),
359356
self.header.cb_id.size_of_val(),
360357
self.header.sp.size_of_val(),
@@ -473,7 +470,7 @@ impl DataPdu {
473470
}
474471

475472
fn size(&self) -> usize {
476-
checked_sum_or_panic(&[
473+
strict_sum(&[
477474
Header::size(),
478475
self.header.cb_id.size_of_val(), // ChannelId
479476
self.data.len(), // Data
@@ -524,14 +521,14 @@ impl CreateResponsePdu {
524521
}
525522

526523
fn headerless_size(header: &Header) -> usize {
527-
checked_sum_or_panic(&[
524+
strict_sum(&[
528525
header.cb_id.size_of_val(), // ChannelId
529526
CreationStatus::size(), // CreationStatus
530527
])
531528
}
532529

533530
fn size(&self) -> usize {
534-
checked_sum_or_panic(&[Header::size(), Self::headerless_size(&self.header)])
531+
strict_sum(&[Header::size(), Self::headerless_size(&self.header)])
535532
}
536533
}
537534

@@ -606,7 +603,7 @@ impl ClosePdu {
606603
}
607604

608605
fn size(&self) -> usize {
609-
checked_sum_or_panic(&[Header::size(), Self::headerless_size(&self.header)])
606+
strict_sum(&[Header::size(), Self::headerless_size(&self.header)])
610607
}
611608
}
612609

@@ -840,7 +837,7 @@ impl CreateRequestPdu {
840837
}
841838

842839
fn size(&self) -> usize {
843-
checked_sum_or_panic(&[
840+
strict_sum(&[
844841
Header::size(),
845842
Self::headerless_fixed_part_size(&self.header), // ChannelId
846843
encoded_str_len(&self.channel_name, CharacterSet::Ansi, true), // ChannelName + Null terminator

crates/ironrdp-graphics/src/rdp6/rle.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,7 @@ impl<I: Iterator<Item = u8>> Iterator for RleEncoderScanlineIterator<I> {
199199
type Item = I::Item;
200200

201201
fn next(&mut self) -> Option<Self::Item> {
202-
let Some((idx, mut next)) = self.inner.next() else {
203-
return None;
204-
};
202+
let (idx, mut next) = self.inner.next()?;
205203

206204
let prev = std::mem::replace(&mut self.prev_scanline[idx % self.width], next);
207205
if idx >= self.width {

crates/ironrdp-pdu/src/gcc/message_channel_data.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ impl<'de> PduDecode<'de> for ClientMessageChannelData {
3737

3838
let _flags = src.read_u32(); // is unused
3939

40-
Ok(Self {})
40+
Ok(Self)
4141
}
4242
}
4343

crates/ironrdp-pdu/src/rdp/headers.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ impl PduDecode<'_> for ServerDeactivateAll {
530530
let length_source_descriptor = src.read_u16();
531531
ensure_size!(in: src, size: length_source_descriptor.into());
532532
let _ = src.read_slice(length_source_descriptor.into());
533-
Ok(Self {})
533+
Ok(Self)
534534
}
535535
}
536536

crates/ironrdp-pdu/src/utils.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -274,20 +274,20 @@ where
274274
T: CheckedAdd + Copy + Debug,
275275
{
276276
values.split_first().map_or_else(
277-
|| Err(other_err!("Empty array provided to checked_sum")),
277+
|| Err(other_err!("empty array provided to checked_sum")),
278278
|(&first, rest)| {
279279
rest.iter().try_fold(first, |acc, &val| {
280280
acc.checked_add(val)
281-
.ok_or_else(|| other_err!("Overflow detected during addition"))
281+
.ok_or_else(|| other_err!("overflow detected during addition"))
282282
})
283283
},
284284
)
285285
}
286286

287287
// Utility function that panics on overflow
288-
pub fn checked_sum_or_panic<T>(values: &[T]) -> T
288+
pub fn strict_sum<T>(values: &[T]) -> T
289289
where
290290
T: CheckedAdd + Copy + Debug,
291291
{
292-
checked_sum::<T>(values).expect("Overflow detected during addition")
292+
checked_sum::<T>(values).expect("overflow detected during addition")
293293
}

crates/ironrdp-rdpsnd/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ impl Rdpsnd {
1313
pub const NAME: ChannelName = ChannelName::from_static(b"rdpsnd\0\0");
1414

1515
pub fn new() -> Self {
16-
Self {}
16+
Self
1717
}
1818
}
1919

crates/ironrdp-server/src/encoder/bitmap.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@ impl BitmapEncoder {
5555
right: bitmap.left + bitmap.width.get() - 1,
5656
bottom: u16::try_from(top + height - 1).unwrap(),
5757
},
58-
width: u16::try_from(bitmap.width).unwrap(),
58+
width: u16::from(bitmap.width),
5959
height: u16::try_from(height).unwrap(),
6060
bits_per_pixel: u16::from(bitmap.format.bytes_per_pixel()) * 8,
6161
compression_flags: Compression::BITMAP_COMPRESSION,
6262
compressed_data_header: Some(bitmap::CompressedDataHeader {
6363
main_body_size: u16::try_from(len).unwrap(),
64-
scan_width: u16::try_from(bitmap.width).unwrap(),
64+
scan_width: u16::from(bitmap.width),
6565
uncompressed_size: u16::try_from(chunk.len()).unwrap(),
6666
}),
6767
bitmap_data: &self.buffer[..len],

crates/ironrdp-server/src/server.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ impl RdpServer {
188188
.with_dynamic_channel(AInputHandler {
189189
handler: Arc::clone(&self.handler),
190190
})
191-
.with_dynamic_channel(DisplayControlServer {});
191+
.with_dynamic_channel(DisplayControlServer);
192192
acceptor.attach_static_channel(dvc);
193193

194194
match ironrdp_acceptor::accept_begin(framed, &mut acceptor).await {

crates/ironrdp-svc/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ impl<P: SvcProcessor> From<SvcProcessorMessages<P>> for Vec<SvcMessage> {
6060
pub trait SvcPduEncode: PduEncode + Send {}
6161

6262
/// For legacy reasons, we implement [`SvcPduEncode`] for [`Vec<u8>`].
63+
// FIXME: legacy code
6364
impl SvcPduEncode for Vec<u8> {}
6465

6566
/// Encodable PDU to be sent over a static virtual channel.

crates/ironrdp-web/src/image.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub(crate) fn extract_partial_image(image: &DecodedImage, region: InclusiveRecta
1616
fn extract_smallest_rectangle(image: &DecodedImage, region: InclusiveRectangle) -> (InclusiveRectangle, Vec<u8>) {
1717
let pixel_size = usize::from(image.pixel_format().bytes_per_pixel());
1818

19-
let image_width = usize::try_from(image.width()).unwrap();
19+
let image_width = usize::from(image.width());
2020
let image_stride = image_width * pixel_size;
2121

2222
let region_top = usize::from(region.top);
@@ -49,7 +49,7 @@ fn extract_smallest_rectangle(image: &DecodedImage, region: InclusiveRectangle)
4949
fn extract_whole_rows(image: &DecodedImage, region: InclusiveRectangle) -> (InclusiveRectangle, Vec<u8>) {
5050
let pixel_size = usize::from(image.pixel_format().bytes_per_pixel());
5151

52-
let image_width = usize::try_from(image.width()).unwrap();
52+
let image_width = usize::from(image.width());
5353
let image_stride = image_width * pixel_size;
5454

5555
let region_top = usize::from(region.top);

crates/ironrdp-web/src/session.rs

-1
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,6 @@ fn build_config(
741741
width: desktop_size.width,
742742
height: desktop_size.height,
743743
},
744-
graphics: None,
745744
bitmap: Some(connector::BitmapConfig {
746745
color_depth: 16,
747746
lossy_compression: true,

crates/ironrdp/examples/screenshot.rs

-1
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ fn build_config(username: String, password: String, domain: Option<String>) -> c
188188
width: 1280,
189189
height: 1024,
190190
},
191-
graphics: None,
192191
bitmap: None,
193192
client_build: 0,
194193
client_name: "ironrdp-screenshot-example".to_owned(),

crates/ironrdp/examples/server.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,11 @@ fn acceptor(cert_path: &str, key_path: &str) -> anyhow::Result<TlsAcceptor> {
120120
}
121121

122122
#[derive(Clone, Debug)]
123-
struct Handler {}
123+
struct Handler;
124124

125125
impl Handler {
126126
fn new() -> Self {
127-
Self {}
127+
Self
128128
}
129129
}
130130

0 commit comments

Comments
 (0)