Ejemplo n.º 1
0
    def stream_video_to_display(self, fps=5):
        if self.__omxplayer_running:
            log.print_high("pitft: stream_video_to_display: Omxplayer already running")
            return
        log.print_high("pitft: stream_video_to_display: Entered")
        xml = XML_Object()
        tcp_ip = xml.get_remote_cam_server_ip()
        tcp_port = xml.get_remote_cam_server_port()
        timeout = 10
        log.print_high("Starting omxplayer")
        Popen(
            "/usr/bin/omxplayer --live --no-keys --fps 10 http://"
            + str(tcp_ip)
            + ":"
            + str(tcp_port)
            + "/?action=stream",
            shell=True,
            stdout=PIPE,
        )
        print "/usr/bin/omxplayer --live --no-keys --fps 10 http://" + str(tcp_ip) + ":" + str(
            tcp_port
        ) + "/?action=stream"
        sleep(0.1)
        # Check if the process is running. If not, restart the process
        while ((is_process_running("omxplayer.bin") == False) and (is_process_running("omxplayer") == False)) and (
            timeout > 0
        ):
            Popen(
                "/usr/bin/omxplayer --live --no-keys --fps 10 http://"
                + str(tcp_ip)
                + ":"
                + str(tcp_port)
                + "/?action=stream",
                shell=True,
                stdout=PIPE,
            )
            timeout = timeout - 1
            log.print_high("Starting omxplayer. Number retries left: " + str(timeout))
            sleep(0.5)

        if is_process_running("omxplayer.bin") or is_process_running("omxplayer"):
            self.__omxplayer_running = True
        log.print_high("pitft: stream_video_to_display: Exit")