|
1 | 1 | #[cfg(test)] |
2 | 2 | mod tests; |
3 | 3 |
|
| 4 | +use core::fmt::{self, Debug}; |
| 5 | + |
4 | 6 | use bitflags::bitflags; |
5 | 7 | use ironrdp_core::{ |
6 | 8 | cast_length, decode, ensure_fixed_part_size, ensure_size, invalid_field_err, other_err, Decode, DecodeResult, |
@@ -97,7 +99,7 @@ impl<'de> Decode<'de> for Guid { |
97 | 99 | } |
98 | 100 | } |
99 | 101 |
|
100 | | -#[derive(Debug, PartialEq, Eq, Clone)] |
| 102 | +#[derive(Debug, PartialEq, Eq, Clone, Default)] |
101 | 103 | pub struct BitmapCodecs(pub Vec<Codec>); |
102 | 104 |
|
103 | 105 | impl BitmapCodecs { |
@@ -617,3 +619,47 @@ bitflags! { |
617 | 619 | const CODEC_MODE = 2; |
618 | 620 | } |
619 | 621 | } |
| 622 | + |
| 623 | +// Those IDs are hard-coded for practical reasons, they are implementation |
| 624 | +// details of the IronRDP client. The server should respect the client IDs. |
| 625 | +#[derive(Copy, Clone, PartialEq, Eq)] |
| 626 | +pub struct CodecId(u8); |
| 627 | + |
| 628 | +pub const CODEC_ID_NONE: CodecId = CodecId(0); |
| 629 | +pub const CODEC_ID_REMOTEFX: CodecId = CodecId(3); |
| 630 | + |
| 631 | +impl Debug for CodecId { |
| 632 | + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
| 633 | + let name = match self.0 { |
| 634 | + 0 => "None", |
| 635 | + 3 => "RemoteFx", |
| 636 | + _ => "unknown", |
| 637 | + }; |
| 638 | + write!(f, "CodecId({})", name) |
| 639 | + } |
| 640 | +} |
| 641 | + |
| 642 | +impl CodecId { |
| 643 | + pub const fn from_u8(value: u8) -> Option<Self> { |
| 644 | + match value { |
| 645 | + 0 => Some(CODEC_ID_NONE), |
| 646 | + 3 => Some(CODEC_ID_REMOTEFX), |
| 647 | + _ => None, |
| 648 | + } |
| 649 | + } |
| 650 | +} |
| 651 | + |
| 652 | +pub fn client_codecs_capabilities() -> BitmapCodecs { |
| 653 | + let codecs = vec![Codec { |
| 654 | + id: CODEC_ID_REMOTEFX.0, |
| 655 | + property: CodecProperty::RemoteFx(RemoteFxContainer::ClientContainer(RfxClientCapsContainer { |
| 656 | + capture_flags: CaptureFlags::empty(), |
| 657 | + caps_data: RfxCaps(RfxCapset(vec![RfxICap { |
| 658 | + flags: RfxICapFlags::empty(), |
| 659 | + entropy_bits: EntropyBits::Rlgr3, |
| 660 | + }])), |
| 661 | + })), |
| 662 | + }]; |
| 663 | + |
| 664 | + BitmapCodecs(codecs) |
| 665 | +} |
0 commit comments