コード例 #1
0
    def c__registerClient(self,
                          n_buffer: int = None,
                          image_dimensions: tuple = None,
                          shmem_name: str = None,
                          ipc_index: int = None):
        """Shared mem info is given.  Now we can create the shmem client

        There can be several shmem clients
        """
        self.logger.debug("c__registerClient")

        event_fd, pipe = singleton.ipc.get2(ipc_index)
        singleton.ipc.wait(
            ipc_index)  # wait till the shmem server has been created
        # this flag is controlled by QShmemClientProcess.c__setMasterProcess
        singleton.ipc.clear(ipc_index)
        shmem_client = ShmemRGBClient(
            name=shmem_name,
            n_ringbuffer=n_buffer,  # size of ring buffer
            width=image_dimensions[0],
            height=image_dimensions[1],
            # client timeouts if nothing has been received in 1000 milliseconds
            mstimeout=1000,
            verbose=False)
        shmem_client.useEventFd(event_fd)

        fd = event_fd.getFd()

        client = self.Client(fd=fd, pipe=pipe, shmem_client=shmem_client)

        self.clients[ipc_index] = client
        self.clients_by_fd[fd] = client
        self.logger.debug("c__registerClient: fd=%s", fd)
        self.rlis.append(fd)

        if len(self.clients) == 1:
            self.logger.debug("c__registerClient: first client registered")
            self.firstClientRegistered_()

        self.logger.debug("c__registerClient: number of clients is %s",
                          len(self.clients))
コード例 #2
0
 def c__activateRGB24Client(self,
                            name=None,
                            n_ringbuffer=None,
                            width=None,
                            height=None,
                            ipc_index=None
                            ):
     """This will activate a shared memory client that reads RGB24 frames
     from shared memory libValkka c++ side (as defined in your filterchain)
     """
     print("c__activateRGB24Client called with", name, n_ringbuffer, width, height)
     client = ShmemRGBClient(
         name=name,
         n_ringbuffer=n_ringbuffer,
         width=width,
         height=height,
         mstimeout=self.mstimeout,
         verbose=False
     )
     eventfd = getEventFd(ipc_index)
     client.useEventFd(eventfd)  # do not forget!
     # let's get a posix file descriptor, i.e. a plain integer:
     fd = eventfd.getFd()
     self.client_by_fd[fd] = client