示例#1
0
 async def c__activateFMP4Client(self,
                                 name=None,
                                 n_ringbuffer=None,
                                 n_size=None,
                                 ipc_index=None):
     """This will activate a shared memory client that reads the frag-mp4 fragments
     from shared memory
     """
     try:
         print("activateFMP4Client__: ", name, n_ringbuffer, n_size,
               ipc_index)
         client = FragMP4ShmemClient(name=name,
                                     n_ringbuffer=n_ringbuffer,
                                     n_size=n_size,
                                     mstimeout=self.mstimeout)
         eventfd = getEventFd(ipc_index)
         # let's get a posix file descriptor, i.e. a plain integer:
         fd = eventfd.getFd()
         self.client_by_fd[fd] = client
         # tell asyncio to listen to a file-descriptor and
         # launch a callback when that file-descriptor triggers
         asyncio.get_event_loop().add_reader(fd, self.fmp4callback__, fd)
         self.count_by_fd[fd] = 0
         # .. that callback must be normal (not asyncio) python
         # finally, let's send a message to the main python process:
     except Exception as e:
         print("activateFMP4Client__: failed with", e)
         raise
示例#2
0
 async def c__deactivateFMP4Client(self, ipc_index=None):
     eventfd = getEventFd(ipc_index)
     fd = eventfd.getFd()
     try:
         self.client_by_fd.pop(fd)
         self.count_by_fd.pop(fd)
     except KeyError:
         print("deactivateFMP4Client__ : no client at ipc_index", ipc_index)
         raise
     asyncio.get_event_loop().remove_reader(fd)
示例#3
0
 def c__deactivateRGB24Client(self,
                              ipc_index=None,
                              event_index=None
                              ):
     eventfd = getEventFd(ipc_index)
     # let's get a posix file descriptor, i.e. a plain integer
     fd = eventfd.getFd()
     try:
         self.client_by_fd.pop(fd)
     except KeyError:
         print("c__deactivateRGB24Client : no client at ipc_index", ipc_index)
     # inform multiprocessing frontend (= main python process)
     # that this command has been finalized:
     self.eg.set(event_index)
示例#4
0
 def c__listenIntercom(self,
                       name = None,
                       n_ringbuffer = None,
                       n_bytes = None,
                       ipc_index = None,
                       ):
     client = ShmemClient(
         name = name,
         n_ringbuffer = n_ringbuffer,
         n_bytes = n_bytes,
         mstimeout = self.mstimeout
     )
     eventfd = getEventFd(ipc_index)
     client.useEventFd(eventfd)
     fd = eventfd.getFd()
     # self.intercom_client_by_fd[fd] = client #if you would be listening many clients at a time
     self.intercom_client = client
     self.intercom_fd = fd
示例#5
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