@@ -40,6 +40,9 @@ const GUID_REMOTEFX: Guid = Guid(0x7677_2f12, 0xbd72, 0x4463, 0xaf, 0xb3, 0xb7,
4040const GUID_IMAGE_REMOTEFX : Guid = Guid ( 0x2744_ccd4 , 0x9d8a , 0x4e74 , 0x80 , 0x3c , 0x0e , 0xcb , 0xee , 0xa1 , 0x9c , 0x54 ) ;
4141#[ rustfmt:: skip]
4242const GUID_IGNORE : Guid = Guid ( 0x9c43_51a6 , 0x3535 , 0x42ae , 0x91 , 0x0c , 0xcd , 0xfc , 0xe5 , 0x76 , 0x0b , 0x58 ) ;
43+ #[ rustfmt:: skip]
44+ #[ cfg( feature="qoi" ) ]
45+ const GUID_QOI : Guid = Guid ( 0x4dae_9af8 , 0xb399 , 0x4df6 , 0xb4 , 0x3a , 0x66 , 0x2f , 0xd9 , 0xc0 , 0xf5 , 0xd6 ) ;
4346
4447#[ derive( Debug , PartialEq , Eq ) ]
4548pub struct Guid ( u32 , u16 , u16 , u8 , u8 , u8 , u8 , u8 , u8 , u8 , u8 ) ;
@@ -167,6 +170,8 @@ impl Encode for Codec {
167170 CodecProperty :: RemoteFx ( _) => GUID_REMOTEFX ,
168171 CodecProperty :: ImageRemoteFx ( _) => GUID_IMAGE_REMOTEFX ,
169172 CodecProperty :: Ignore => GUID_IGNORE ,
173+ #[ cfg( feature = "qoi" ) ]
174+ CodecProperty :: Qoi => GUID_QOI ,
170175 _ => return Err ( other_err ! ( "invalid codec" ) ) ,
171176 } ;
172177 guid. encode ( dst) ?;
@@ -204,6 +209,8 @@ impl Encode for Codec {
204209 }
205210 } ;
206211 }
212+ #[ cfg( feature = "qoi" ) ]
213+ CodecProperty :: Qoi => dst. write_u16 ( 0 ) ,
207214 CodecProperty :: Ignore => dst. write_u16 ( 0 ) ,
208215 CodecProperty :: None => dst. write_u16 ( 0 ) ,
209216 } ;
@@ -227,6 +234,8 @@ impl Encode for Codec {
227234 RemoteFxContainer :: ClientContainer ( container) => container. size ( ) ,
228235 RemoteFxContainer :: ServerContainer ( size) => * size,
229236 } ,
237+ #[ cfg( feature = "qoi" ) ]
238+ CodecProperty :: Qoi => 0 ,
230239 CodecProperty :: Ignore => 0 ,
231240 CodecProperty :: None => 0 ,
232241 }
@@ -264,6 +273,13 @@ impl<'de> Decode<'de> for Codec {
264273 }
265274 }
266275 GUID_IGNORE => CodecProperty :: Ignore ,
276+ #[ cfg( feature = "qoi" ) ]
277+ GUID_QOI => {
278+ if !property_buffer. is_empty ( ) {
279+ return Err ( invalid_field_err ! ( "qoi property" , "must be empty" ) ) ;
280+ }
281+ CodecProperty :: Qoi
282+ }
267283 _ => CodecProperty :: None ,
268284 } ;
269285
@@ -283,6 +299,8 @@ pub enum CodecProperty {
283299 RemoteFx ( RemoteFxContainer ) ,
284300 ImageRemoteFx ( RemoteFxContainer ) ,
285301 Ignore ,
302+ #[ cfg( feature = "qoi" ) ]
303+ Qoi ,
286304 None ,
287305}
288306
@@ -620,12 +638,14 @@ pub struct CodecId(u8);
620638
621639pub const CODEC_ID_NONE : CodecId = CodecId ( 0 ) ;
622640pub const CODEC_ID_REMOTEFX : CodecId = CodecId ( 3 ) ;
641+ pub const CODEC_ID_QOI : CodecId = CodecId ( 0x0A ) ;
623642
624643impl Debug for CodecId {
625644 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
626645 let name = match self . 0 {
627646 0 => "None" ,
628647 3 => "RemoteFx" ,
648+ 0x0A => "QOI" ,
629649 _ => "unknown" ,
630650 } ;
631651 write ! ( f, "CodecId({})" , name)
@@ -637,6 +657,7 @@ impl CodecId {
637657 match value {
638658 0 => Some ( CODEC_ID_NONE ) ,
639659 3 => Some ( CODEC_ID_REMOTEFX ) ,
660+ 0x0A => Some ( CODEC_ID_QOI ) ,
640661 _ => None ,
641662 }
642663 }
@@ -678,6 +699,7 @@ fn parse_codecs_config<'a>(codecs: &'a [&'a str]) -> Result<HashMap<&'a str, boo
678699/// # List of codecs
679700///
680701/// * `remotefx` (on by default)
702+ /// * `qoi` (on by default, when feature "qoi")
681703///
682704/// # Returns
683705///
@@ -688,6 +710,7 @@ pub fn client_codecs_capabilities(config: &[&str]) -> Result<BitmapCodecs, Strin
688710 return Err ( r#"
689711List of codecs:
690712- `remotefx` (on by default)
713+ - `qoi` (on by default, when feature "qoi")
691714"#
692715 . to_owned ( ) ) ;
693716 }
@@ -708,6 +731,14 @@ List of codecs:
708731 } ) ;
709732 }
710733
734+ #[ cfg( feature = "qoi" ) ]
735+ if config. remove ( "qoi" ) . unwrap_or ( true ) {
736+ codecs. push ( Codec {
737+ id : CODEC_ID_QOI . 0 ,
738+ property : CodecProperty :: Qoi ,
739+ } ) ;
740+ }
741+
711742 let codec_names = config. keys ( ) . copied ( ) . collect :: < Vec < _ > > ( ) . join ( ", " ) ;
712743 if !codec_names. is_empty ( ) {
713744 return Err ( format ! ( "Unknown codecs: {}" , codec_names) ) ;
@@ -729,6 +760,7 @@ List of codecs:
729760/// # List of codecs
730761///
731762/// * `remotefx` (on by default)
763+ /// * `qoi` (on by default, when feature "qoi")
732764///
733765/// # Returns
734766///
@@ -738,6 +770,7 @@ pub fn server_codecs_capabilities(config: &[&str]) -> Result<BitmapCodecs, Strin
738770 return Err ( r#"
739771List of codecs:
740772- `remotefx` (on by default)
773+ - `qoi` (on by default, when feature "qoi")
741774"#
742775 . to_owned ( ) ) ;
743776 }
@@ -756,6 +789,14 @@ List of codecs:
756789 } ) ;
757790 }
758791
792+ #[ cfg( feature = "qoi" ) ]
793+ if config. remove ( "qoi" ) . unwrap_or ( true ) {
794+ codecs. push ( Codec {
795+ id : 0 ,
796+ property : CodecProperty :: Qoi ,
797+ } ) ;
798+ }
799+
759800 let codec_names = config. keys ( ) . copied ( ) . collect :: < Vec < _ > > ( ) . join ( ", " ) ;
760801 if !codec_names. is_empty ( ) {
761802 return Err ( format ! ( "Unknown codecs: {}" , codec_names) ) ;
0 commit comments