@@ -39,6 +39,9 @@ const GUID_REMOTEFX: Guid = Guid(0x7677_2f12, 0xbd72, 0x4463, 0xaf, 0xb3, 0xb7,
3939const GUID_IMAGE_REMOTEFX : Guid = Guid ( 0x2744_ccd4 , 0x9d8a , 0x4e74 , 0x80 , 0x3c , 0x0e , 0xcb , 0xee , 0xa1 , 0x9c , 0x54 ) ;
4040#[ rustfmt:: skip]
4141const GUID_IGNORE : Guid = Guid ( 0x9c43_51a6 , 0x3535 , 0x42ae , 0x91 , 0x0c , 0xcd , 0xfc , 0xe5 , 0x76 , 0x0b , 0x58 ) ;
42+ #[ rustfmt:: skip]
43+ #[ cfg( feature="qoi" ) ]
44+ const GUID_QOI : Guid = Guid ( 0x4dae_9af8 , 0xb399 , 0x4df6 , 0xb4 , 0x3a , 0x66 , 0x2f , 0xd9 , 0xc0 , 0xf5 , 0xd6 ) ;
4245
4346#[ derive( Debug , PartialEq , Eq ) ]
4447pub struct Guid ( u32 , u16 , u16 , u8 , u8 , u8 , u8 , u8 , u8 , u8 , u8 ) ;
@@ -166,6 +169,8 @@ impl Encode for Codec {
166169 CodecProperty :: RemoteFx ( _) => GUID_REMOTEFX ,
167170 CodecProperty :: ImageRemoteFx ( _) => GUID_IMAGE_REMOTEFX ,
168171 CodecProperty :: Ignore => GUID_IGNORE ,
172+ #[ cfg( feature = "qoi" ) ]
173+ CodecProperty :: Qoi => GUID_QOI ,
169174 _ => return Err ( other_err ! ( "invalid codec" ) ) ,
170175 } ;
171176 guid. encode ( dst) ?;
@@ -203,6 +208,8 @@ impl Encode for Codec {
203208 }
204209 } ;
205210 }
211+ #[ cfg( feature = "qoi" ) ]
212+ CodecProperty :: Qoi => dst. write_u16 ( 0 ) ,
206213 CodecProperty :: Ignore => dst. write_u16 ( 0 ) ,
207214 CodecProperty :: None => dst. write_u16 ( 0 ) ,
208215 } ;
@@ -226,6 +233,8 @@ impl Encode for Codec {
226233 RemoteFxContainer :: ClientContainer ( container) => container. size ( ) ,
227234 RemoteFxContainer :: ServerContainer ( size) => * size,
228235 } ,
236+ #[ cfg( feature = "qoi" ) ]
237+ CodecProperty :: Qoi => 0 ,
229238 CodecProperty :: Ignore => 0 ,
230239 CodecProperty :: None => 0 ,
231240 }
@@ -260,6 +269,8 @@ impl<'de> Decode<'de> for Codec {
260269 _ => unreachable ! ( ) ,
261270 }
262271 }
272+ #[ cfg( feature = "qoi" ) ]
273+ GUID_QOI => CodecProperty :: Qoi ,
263274 GUID_IGNORE => CodecProperty :: Ignore ,
264275 _ => CodecProperty :: None ,
265276 }
@@ -271,6 +282,8 @@ impl<'de> Decode<'de> for Codec {
271282 "invalid codec property length"
272283 ) ) ;
273284 }
285+ #[ cfg( feature = "qoi" ) ]
286+ GUID_QOI => CodecProperty :: Qoi ,
274287 GUID_IGNORE => CodecProperty :: Ignore ,
275288 _ => CodecProperty :: None ,
276289 }
@@ -292,6 +305,8 @@ pub enum CodecProperty {
292305 RemoteFx ( RemoteFxContainer ) ,
293306 ImageRemoteFx ( RemoteFxContainer ) ,
294307 Ignore ,
308+ #[ cfg( feature = "qoi" ) ]
309+ Qoi ,
295310 None ,
296311}
297312
@@ -625,15 +640,19 @@ bitflags! {
625640#[ derive( Debug , Copy , Clone , PartialEq , Eq ) ]
626641#[ repr( u8 ) ]
627642pub enum CodecId {
628- None = 0x0 ,
629- RemoteFx = 0x3 ,
643+ None = 0x00 ,
644+ RemoteFx = 0x03 ,
645+ #[ cfg( feature = "qoi" ) ]
646+ Qoi = 0x0A ,
630647}
631648
632649impl CodecId {
633650 pub const fn from_u8 ( value : u8 ) -> Option < Self > {
634651 match value {
635- 0 => Some ( Self :: None ) ,
636- 3 => Some ( Self :: RemoteFx ) ,
652+ 0x00 => Some ( Self :: None ) ,
653+ 0x03 => Some ( Self :: RemoteFx ) ,
654+ #[ cfg( feature = "qoi" ) ]
655+ 0x0A => Some ( Self :: Qoi ) ,
637656 _ => None ,
638657 }
639658 }
@@ -696,6 +715,14 @@ pub fn client_codecs_capabilities(config: &[&str]) -> Result<BitmapCodecs, Strin
696715 } ) ;
697716 }
698717
718+ #[ cfg( feature = "qoi" ) ]
719+ if config. remove ( "qoi" ) . unwrap_or ( true ) {
720+ codecs. push ( Codec {
721+ id : CodecId :: Qoi as u8 ,
722+ property : CodecProperty :: Qoi ,
723+ } ) ;
724+ }
725+
699726 let codec_names = config. keys ( ) . copied ( ) . collect :: < Vec < _ > > ( ) . join ( ", " ) ;
700727 if !codec_names. is_empty ( ) {
701728 return Err ( format ! ( "Unknown codecs: {}" , codec_names) ) ;
@@ -717,6 +744,7 @@ pub fn client_codecs_capabilities(config: &[&str]) -> Result<BitmapCodecs, Strin
717744/// # List of codecs
718745///
719746/// * `remotefx` (on by default)
747+ /// * `qoi` (on by default, when feature "qoi")
720748///
721749/// # Returns
722750///
@@ -736,6 +764,14 @@ pub fn server_codecs_capabilities(config: &[&str]) -> Result<BitmapCodecs, Strin
736764 } ) ;
737765 }
738766
767+ #[ cfg( feature = "qoi" ) ]
768+ if config. remove ( "qoi" ) . unwrap_or ( true ) {
769+ codecs. push ( Codec {
770+ id : 0 ,
771+ property : CodecProperty :: Qoi ,
772+ } ) ;
773+ }
774+
739775 let codec_names = config. keys ( ) . copied ( ) . collect :: < Vec < _ > > ( ) . join ( ", " ) ;
740776 if !codec_names. is_empty ( ) {
741777 return Err ( format ! ( "Unknown codecs: {}" , codec_names) ) ;
0 commit comments