code: def new_frame_event(self):
          for out_pool in self.outframe_pool.values():
              if not out_pool.available():
                  return
          frame_nos = {}
          for in_buff in self.input_buffer.values():
              if not in_buff.available():
                  return
              in_frame = in_buff.peek()
              if in_frame is None:
                  raise StopIteration()
              if in_frame.frame_no >= 0:
                  frame_nos[in_buff] = in_frame.frame_no
              else:
                  while in_buff.available() > 1 and in_buff.peek(1) is not None:
                      in_buff.get()
          if len(frame_nos) > 1:
              frame_no = max(frame_nos.values())
              for in_buff in frame_nos:
                  while frame_nos[in_buff] < frame_no and in_buff.available() > 1:
                      in_buff.get()
                      in_frame = in_buff.peek()
                      if in_frame is None:
                          raise StopIteration()
                      frame_nos[in_buff] = in_frame.frame_no
              if min(frame_nos.values()) != max(frame_nos.values()):
                  return
          try:
              self.process_frame()
          except StopIteration:
              raise
          except Exception as ex:
              self.logger.exception(ex)
              raise StopIteration()