[libcamera-devel,v4,06/15] py: simple-continuous-capture.py: Use new events support
diff mbox series

Message ID 20230309142601.70556-7-tomi.valkeinen@ideasonboard.com
State Superseded
Headers show
Series
  • py: New python bindings event handling
Related show

Commit Message

Tomi Valkeinen March 9, 2023, 2:25 p.m. UTC
Update simple-continuous-capture.py to the new event model.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/py/examples/simple-continuous-capture.py | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

Patch
diff mbox series

diff --git a/src/py/examples/simple-continuous-capture.py b/src/py/examples/simple-continuous-capture.py
index e1cb931e..37ca623c 100755
--- a/src/py/examples/simple-continuous-capture.py
+++ b/src/py/examples/simple-continuous-capture.py
@@ -83,16 +83,17 @@  class CaptureContext:
     camera_contexts: list[CameraCaptureContext] = []
 
     def handle_camera_event(self):
-        # cm.get_ready_requests() returns the ready requests, which in our case
-        # should almost always return a single Request, but in some cases there
-        # could be multiple or none.
+        # cm.get_events() returns the ready events, which in our case should
+        # almost always be a single RequestCompleted event, but in some cases
+        # there could be multiple ones, other events, or no events at all.
 
-        reqs = self.cm.get_ready_requests()
+        for ev in self.cm.get_events():
+            # We are only interested in RequestCompleted events
+            if ev.type != libcam.Event.Type.RequestCompleted:
+                continue
 
-        # Process the captured frames
-
-        for req in reqs:
-            self.handle_request(req)
+            # Process the captured frames
+            self.handle_request(ev.request)
 
         return True