from .rx import *
from .modules.edid.edid import EdidSink
from .modules.link.hdmi.link import HdmiLinkRx
from .modules.hdcp import HdcpSink
from .modules.cec.cec_rx import CecRx
from .modules.capturer.event.event_capturer import EventCapturer, EventFilterHdRx
from UniTAP.libs.lib_tsi.tsi_types import TSI_HDRX_HDCP_CAPS_R, TSI_HDRX_HDCP_STATUS_R
from UniTAP.libs.lib_tsi.tsi_types import TSI_HDRX_LOG_CONTROL


class HDRX(RX):

    """

    Main class of `HDRX` object.
    Inherited from class `RX`.
    Class describes capabilities of 300th (3XX) series of HDMI devices in Sink (RX - receiver) role.

    Attributes:
        __link (HdmiLinkRx): object of `HdmiLinkRx`.
        __edid (EdidSink): object of `EdidSink`.
        __hdcp (HdcpSink): object of `HdcpSink`.
        __event_capturer (EventCapturer): object of `EventCapturer`.
        __video_capturer (VideoCapturer): object of `VideoCapturerHDMI`.
        __cec (CecRx): object of `CecRx`.
    """

    def __init__(self, port_io: PortIO, memory_manager: MemoryManager, capturer: Capturer):
        super().__init__(port_io, memory_manager, capturer)

        self.__link = HdmiLinkRx(port_io)
        self.__edid = EdidSink(port_io, 1)
        self.__hdcp = HdcpSink(port_io, TSI_HDRX_HDCP_CAPS_R, TSI_HDRX_HDCP_STATUS_R)
        self.__event_capturer = EventCapturer(capturer, port_io.index(), [EventFilterHdRx(0)])
        self.__video_capturer = VideoCapturerHDMI(capturer, 1)
        self.__cec = CecRx(port_io)

    @property
    def link(self) -> HdmiLinkRx:
        """

        Should be used to control link capabilities on Sink (RX - receiver) role.

        Returns:
            object of `HdmiLinkRx` type.
        """
        return self.__link

    @property
    def edid(self) -> EdidSink:
        """

        Should be used to work with EDID on Sink (RX - receiver) role.

        Returns:
            object of `EdidSink` type.
        """
        return self.__edid

    @property
    def hdcp(self) -> HdcpSink:
        """

        Should be used to work with HDCP on Sink (RX - receiver) role.

        Returns:
            object of `HdcpSink`.
        """
        return self.__hdcp

    @property
    def event_capturer(self) -> EventCapturer:
        """

        Should be used to control `EventCapturer` on Sink (RX - receiver) role.

        Returns:
            object of `EventCapturer` type.
        """
        return self.__event_capturer

    @property
    def video_capturer(self) -> VideoCapturerHDMI:
        """

        Should be used to control `VideoCapturerHDMI` on Sink (RX - receiver) role.

        Returns:
            object of `VideoCapturerHDMI` type.
        """
        return self.__video_capturer

    @property
    def cec(self) -> CecRx:
        """

        Should be used to control `CecRx` on Sink (RX - receiver) role.

        Returns:
            object of `CecRx` type.
        """
        return self.__cec
