timeout if no frame is found

This commit is contained in:
j 2009-06-21 16:25:38 -04:00
parent e7309c6d44
commit 3fdef4796f

View file

@ -125,8 +125,18 @@ class Video(gst.Pipeline):
def callback(frame, timestamp): def callback(frame, timestamp):
self._frames[timestamp] = frame self._frames[timestamp] = frame
self.mainloop.quit() self.mainloop.quit()
self._quit = False
def quit():
if self._quit:
self.mainloop.quit()
return False
else:
self._quit = True
return True
gobject.timeout_add(1000, quit)
if self.getFrame(timestamp, callback): if self.getFrame(timestamp, callback):
self.mainloop.run() self.mainloop.run()
frame = self._frames[timestamp] frame = self._frames[timestamp]
del self._frames[timestamp] del self._frames[timestamp]
return frame return frame