py: Move MappedFrameBuffer to libcamera.utils

Move MappedFrameBuffer to libcamera.utils, instead of extending
FrameBuffer class with a new mmap() method. This keeps us more aligned
to the C++ API.

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>
This commit is contained in:
Tomi Valkeinen 2022-05-27 17:44:24 +03:00 committed by Laurent Pinchart
parent 210ce547a4
commit 9e4388cca5
6 changed files with 87 additions and 83 deletions

View file

@ -9,6 +9,7 @@
import argparse
import binascii
import libcamera as libcam
import libcamera.utils
import sys
import traceback
@ -327,7 +328,7 @@ def request_handler(state, ctx, req):
crcs = []
if ctx['opt-crc']:
with fb.mmap() as mfb:
with libcamera.utils.MappedFrameBuffer(fb) as mfb:
plane_crcs = [binascii.crc32(p) for p in mfb.planes]
crcs.append(plane_crcs)
@ -345,7 +346,7 @@ def request_handler(state, ctx, req):
print(f'\t{ctrl} = {val}')
if ctx['opt-save-frames']:
with fb.mmap() as mfb:
with libcamera.utils.MappedFrameBuffer(fb) as mfb:
filename = 'frame-{}-{}-{}.data'.format(ctx['id'], stream_name, ctx['reqs-completed'])
with open(filename, 'wb') as f:
for p in mfb.planes: