from ctypes import Structure, c_uint16, c_uint32


class HdmiCrc(Structure):
    _fields_ = [
        ('r', c_uint16),
        ('g', c_uint16),
        ('b', c_uint16)
    ]


class HdmiVideoMode(Structure):
    _fields_ = [
        ('h_total', c_uint32),
        ('v_total', c_uint32),
        ('h_active', c_uint32),
        ('v_active', c_uint32),
        ('f_rate', c_uint32),
        ('color_mode', c_uint32),
        ('colorimetry', c_uint32),
        ('bpp', c_uint32),
        ('h_start', c_uint32),
        ('v_start', c_uint32),
        ('h_sync_width', c_uint32),
        ('v_sync_width', c_uint32),
        ('bpc', c_uint32)
    ]


class HdmiVideoModeInfo:

    def __init__(self, hdmi_vm: HdmiVideoMode):
        self.h_total = hdmi_vm.h_total
        self.v_total = hdmi_vm.v_total
        self.h_active = hdmi_vm.h_active
        self.v_active = hdmi_vm.v_active
        self.h_start = hdmi_vm.h_start
        self.v_start = hdmi_vm.v_start
        self.h_sync_width = hdmi_vm.h_sync_width
        self.v_sync_width = hdmi_vm.v_sync_width
        self.frame_rate = hdmi_vm.f_rate
        self.bpp = hdmi_vm.bpp
        self.color_mode = hdmi_vm.color_mode
        self.colorimetry = hdmi_vm.colorimetry
        self.bpc = hdmi_vm.bpc

    def is_eq(self, other) -> bool:
        return self.h_total == other.h_total and self.v_total == other.v_total and self.h_active == other.h_active and \
               self.v_active == other.v_active and self.h_start == other.h_start and self.v_start == other.v_start and \
               self.h_sync_width == other.h_sync_start and self.v_sync_width == other.v_sync_start and \
               self.frame_rate == other.frame_rate and self.bpp == other.bpp and self.color_mode == other.color_mode \
               and self.colorimetry == self.colorimetry and self.bpc == self.bpc
