Fix build with gtk+4 >=4.20.0

Index: video/gtk4/src/sink/frame.rs
--- video/gtk4/src/sink/frame.rs.orig
+++ video/gtk4/src/sink/frame.rs
@@ -228,78 +228,6 @@ impl AsRef<[u8]> for FrameWrapper {
 
 fn video_format_to_memory_format(f: gst_video::VideoFormat) -> gdk::MemoryFormat {
     match f {
-        #[cfg(feature = "gtk_v4_20")]
-        gst_video::VideoFormat::Yuy2 => gdk::MemoryFormat::G8b8g8r8422,
-        #[cfg(feature = "gtk_v4_20")]
-        gst_video::VideoFormat::Yvyu => gdk::MemoryFormat::G8r8g8b8422,
-        #[cfg(feature = "gtk_v4_20")]
-        gst_video::VideoFormat::Uyvy => gdk::MemoryFormat::B8g8r8g8422,
-        #[cfg(feature = "gtk_v4_20")]
-        gst_video::VideoFormat::Vyuy => gdk::MemoryFormat::R8g8b8g8422,
-        #[cfg(feature = "gtk_v4_20")]
-        gst_video::VideoFormat::Nv12 => gdk::MemoryFormat::G8B8r8420,
-        #[cfg(feature = "gtk_v4_20")]
-        gst_video::VideoFormat::Nv21 => gdk::MemoryFormat::G8R8b8420,
-        #[cfg(feature = "gtk_v4_20")]
-        gst_video::VideoFormat::Nv16 => gdk::MemoryFormat::G8B8r8422,
-        #[cfg(feature = "gtk_v4_20")]
-        gst_video::VideoFormat::Nv61 => gdk::MemoryFormat::G8R8b8422,
-        #[cfg(feature = "gtk_v4_20")]
-        gst_video::VideoFormat::Nv24 => gdk::MemoryFormat::G8B8r8444,
-        #[cfg(feature = "gtk_v4_20")]
-        gst_video::VideoFormat::P01010le => gdk::MemoryFormat::G10x6B10x6r10x6420,
-        #[cfg(feature = "gtk_v4_20")]
-        gst_video::VideoFormat::P01010be => gdk::MemoryFormat::G10x6B10x6r10x6420,
-        #[cfg(feature = "gtk_v4_20")]
-        gst_video::VideoFormat::P012Le => gdk::MemoryFormat::G12x4B12x4r12x4420,
-        #[cfg(feature = "gtk_v4_20")]
-        gst_video::VideoFormat::P012Be => gdk::MemoryFormat::G12x4B12x4r12x4420,
-        #[cfg(feature = "gtk_v4_20")]
-        gst_video::VideoFormat::P016Le => gdk::MemoryFormat::G16B16r16420,
-        #[cfg(feature = "gtk_v4_20")]
-        gst_video::VideoFormat::P016Be => gdk::MemoryFormat::G16B16r16420,
-        #[cfg(feature = "gtk_v4_20")]
-        gst_video::VideoFormat::Yuv9 => gdk::MemoryFormat::G8B8R8410,
-        #[cfg(feature = "gtk_v4_20")]
-        gst_video::VideoFormat::Yvu9 => gdk::MemoryFormat::G8R8B8410,
-        #[cfg(feature = "gtk_v4_20")]
-        gst_video::VideoFormat::Y41b => gdk::MemoryFormat::G8B8R8411,
-        #[cfg(feature = "gtk_v4_20")]
-        gst_video::VideoFormat::I420 => gdk::MemoryFormat::G8B8R8420,
-        #[cfg(feature = "gtk_v4_20")]
-        gst_video::VideoFormat::Yv12 => gdk::MemoryFormat::G8R8B8420,
-        #[cfg(feature = "gtk_v4_20")]
-        gst_video::VideoFormat::Y42b => gdk::MemoryFormat::G8B8R8422,
-        #[cfg(feature = "gtk_v4_20")]
-        gst_video::VideoFormat::Y444 => gdk::MemoryFormat::G8B8R8444,
-        #[cfg(feature = "gtk_v4_20")]
-        gst_video::VideoFormat::I42010le => gdk::MemoryFormat::X6g10X6b10X6r10420,
-        #[cfg(feature = "gtk_v4_20")]
-        gst_video::VideoFormat::I42010be => gdk::MemoryFormat::X6g10X6b10X6r10420,
-        #[cfg(feature = "gtk_v4_20")]
-        gst_video::VideoFormat::I42210le => gdk::MemoryFormat::X6g10X6b10X6r10422,
-        #[cfg(feature = "gtk_v4_20")]
-        gst_video::VideoFormat::I42210be => gdk::MemoryFormat::X6g10X6b10X6r10422,
-        #[cfg(feature = "gtk_v4_20")]
-        gst_video::VideoFormat::Y44410le => gdk::MemoryFormat::X6g10X6b10X6r10444,
-        #[cfg(feature = "gtk_v4_20")]
-        gst_video::VideoFormat::Y44410be => gdk::MemoryFormat::X6g10X6b10X6r10444,
-        #[cfg(feature = "gtk_v4_20")]
-        gst_video::VideoFormat::I42012le => gdk::MemoryFormat::X4g12X4b12X4r12420,
-        #[cfg(feature = "gtk_v4_20")]
-        gst_video::VideoFormat::I42012be => gdk::MemoryFormat::X4g12X4b12X4r12420,
-        #[cfg(feature = "gtk_v4_20")]
-        gst_video::VideoFormat::I42212le => gdk::MemoryFormat::X4g12X4b12X4r12422,
-        #[cfg(feature = "gtk_v4_20")]
-        gst_video::VideoFormat::I42212be => gdk::MemoryFormat::X4g12X4b12X4r12422,
-        #[cfg(feature = "gtk_v4_20")]
-        gst_video::VideoFormat::Y44412le => gdk::MemoryFormat::X4g12X4b12X4r12444,
-        #[cfg(feature = "gtk_v4_20")]
-        gst_video::VideoFormat::Y44412be => gdk::MemoryFormat::X4g12X4b12X4r12444,
-        #[cfg(feature = "gtk_v4_20")]
-        gst_video::VideoFormat::Y44416le => gdk::MemoryFormat::G16B16R16444,
-        #[cfg(feature = "gtk_v4_20")]
-        gst_video::VideoFormat::Y44416be => gdk::MemoryFormat::G16B16R16444,
         #[cfg(feature = "gtk_v4_14")]
         gst_video::VideoFormat::Bgrx => gdk::MemoryFormat::B8g8r8x8,
         #[cfg(feature = "gtk_v4_14")]
@@ -318,59 +246,6 @@ fn video_format_to_memory_format(f: gst_video::VideoFo
     }
 }
 
-#[cfg(feature = "gtk_v4_20")]
-fn videoinfo_to_color_state(info: &gst_video::VideoInfo) -> Option<gdk::ColorState> {
-    let colorimetry = info.colorimetry();
-    let color_params = gdk::CicpParams::new();
-
-    let range = match (colorimetry.range(), info.is_rgb()) {
-        (gst_video::VideoColorRange::Range0_255, ..) => gdk::CicpRange::Full,
-        (gst_video::VideoColorRange::Range16_235, ..) => gdk::CicpRange::Narrow,
-        (.., true) => gdk::CicpRange::Full,
-        (.., false) => gdk::CicpRange::Narrow,
-    };
-    color_params.set_range(range);
-
-    let matrix = match (colorimetry.matrix(), info.is_rgb()) {
-        (gst_video::VideoColorMatrix::Unknown, true) => gst_video::VideoColorMatrix::Rgb.to_iso(),
-        (gst_video::VideoColorMatrix::Unknown, false) => {
-            gst_video::VideoColorMatrix::Bt709.to_iso()
-        }
-        _ => colorimetry.matrix().to_iso(),
-    };
-    color_params.set_matrix_coefficients(matrix);
-
-    let tf = match (colorimetry.transfer(), info.is_rgb()) {
-        (gst_video::VideoTransferFunction::Unknown, true) => {
-            gst_video::VideoTransferFunction::Srgb.to_iso()
-        }
-        (gst_video::VideoTransferFunction::Unknown, false) => {
-            gst_video::VideoTransferFunction::Bt709.to_iso()
-        }
-        _ => colorimetry.transfer().to_iso(),
-    };
-    color_params.set_transfer_function(tf);
-
-    let primaries = match (colorimetry.primaries(), info.is_rgb()) {
-        (gst_video::VideoColorPrimaries::Unknown, true) => {
-            gst_video::VideoColorPrimaries::Bt709.to_iso()
-        }
-        (gst_video::VideoColorPrimaries::Unknown, false) => {
-            gst_video::VideoColorPrimaries::Bt709.to_iso()
-        }
-        _ => colorimetry.primaries().to_iso(),
-    };
-    color_params.set_color_primaries(primaries);
-
-    match color_params.build_color_state() {
-        Ok(color_state) => Some(color_state),
-        Err(error) => {
-            println!("Could not build color state: {}", error);
-            None
-        }
-    }
-}
-
 fn video_frame_to_memory_texture(
     frame: gst_video::VideoFrame<gst_video::video_frame::Readable>,
     cached_textures: &mut HashMap<TextureCacheId, gdk::Texture>,
@@ -391,29 +266,7 @@ fn video_frame_to_memory_texture(
     let height = frame.height();
 
     let texture = {
-        #[cfg(feature = "gtk_v4_20")]
         {
-            let mut builder = gdk::MemoryTextureBuilder::new()
-                .set_width(width as i32)
-                .set_height(height as i32)
-                .set_format(format);
-
-            if let Some(color_state) = videoinfo_to_color_state(frame.info()) {
-                builder = builder.set_color_state(&color_state);
-            }
-
-            for plane in 0..(frame.n_planes() as usize) {
-                builder = builder
-                    .set_offset(plane as u32, frame.plane_offset()[plane] as usize)
-                    .set_stride_for_plane(plane as u32, frame.plane_stride()[plane] as usize);
-            }
-
-            builder = builder.set_bytes(Some(&glib::Bytes::from_owned(FrameWrapper(frame))));
-
-            builder.build()
-        }
-        #[cfg(not(feature = "gtk_v4_20"))]
-        {
             let stride = frame.plane_stride()[0] as usize;
 
             gdk::MemoryTexture::new(
@@ -503,23 +356,7 @@ fn video_frame_to_gl_texture(
             let sync_point = (*sync_meta.as_ptr()).data;
 
             let builder = {
-                #[cfg(feature = "gtk_v4_20")]
                 {
-                    let mut mut_builder = gdk::GLTextureBuilder::new()
-                        .set_context(Some(gdk_context))
-                        .set_id(texture_id as u32)
-                        .set_width(width as i32)
-                        .set_height(height as i32)
-                        .set_format(format)
-                        .set_sync(Some(sync_point));
-
-                    if let Some(color_state) = videoinfo_to_color_state(frame.info()) {
-                        mut_builder = mut_builder.set_color_state(&color_state);
-                    }
-                    mut_builder
-                }
-                #[cfg(not(feature = "gtk_v4_20"))]
-                {
                     gdk::GLTextureBuilder::new()
                         .set_context(Some(gdk_context))
                         .set_id(texture_id as u32)
@@ -587,20 +424,6 @@ fn video_frame_to_dmabuf_texture(
         .set_width(width)
         .set_height(height)
         .set_n_planes(n_planes);
-
-    #[cfg(feature = "gtk_v4_20")]
-    {
-        // Convert DRM fourcc to Gst VideoFormat if possible so we know whether the format is RGB or
-        // YCbCr. This is needed for cases where the colorimetry is not fully set. The fallback uses
-        // the DMA_DRM format which we assume is YCbCr.
-        let color_state = match info.to_video_info() {
-            Ok(v) => videoinfo_to_color_state(&v),
-            Err(_) => videoinfo_to_color_state(info),
-        };
-        if color_state.is_some() {
-            builder = builder.set_color_state(color_state.as_ref());
-        }
-    }
 
     for plane in 0..(n_planes as usize) {
         unsafe {
