summaryrefslogtreecommitdiff
path: root/src/py/cam/cam_null.py
diff options
context:
space:
mode:
authorTomi Valkeinen <tomi.valkeinen@ideasonboard.com>2022-05-09 13:10:23 +0300
committerKieran Bingham <kieran.bingham@ideasonboard.com>2022-05-10 13:53:43 +0200
commit74ba01121a61bd02bc8f09abbf3fd04db3561ab0 (patch)
tree7b31e06de6a00c0580733ffa7befe5ac6ac98fe8 /src/py/cam/cam_null.py
parent06cb7130c4fadac3bde6e695b0a6842656c9a5d4 (diff)
py: Add cam.py
Add cam.py, which mimics the 'cam' tool. Four rendering backends are added: * null - Do nothing * kms - Use KMS with dmabufs * qt - SW render on a Qt window * qtgl - OpenGL render on a Qt window All the renderers handle only a few pixel formats, and especially the GL renderer is just a prototype. Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'src/py/cam/cam_null.py')
-rw-r--r--src/py/cam/cam_null.py47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/py/cam/cam_null.py b/src/py/cam/cam_null.py
new file mode 100644
index 00000000..a6da9671
--- /dev/null
+++ b/src/py/cam/cam_null.py
@@ -0,0 +1,47 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (C) 2022, Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
+
+import selectors
+import sys
+
+
+class NullRenderer:
+ def __init__(self, state):
+ self.state = state
+
+ self.cm = state['cm']
+ self.contexts = state['contexts']
+
+ self.running = False
+
+ def setup(self):
+ pass
+
+ def run(self):
+ print('Capturing...')
+
+ self.running = True
+
+ sel = selectors.DefaultSelector()
+ sel.register(self.cm.efd, selectors.EVENT_READ, self.readcam)
+ sel.register(sys.stdin, selectors.EVENT_READ, self.readkey)
+
+ print('Press enter to exit')
+
+ while self.running:
+ events = sel.select()
+ for key, mask in events:
+ callback = key.data
+ callback(key.fileobj)
+
+ print('Exiting...')
+
+ def readcam(self, fd):
+ self.running = self.state['event_handler'](self.state)
+
+ def readkey(self, fileobj):
+ sys.stdin.readline()
+ self.running = False
+
+ def request_handler(self, ctx, req):
+ self.state['request_prcessed'](ctx, req)