android: camera_stream: Fetch format and size from configuration

Fetch the format and size of the libcamera::StreamConfiguration
associated with a CameraStream by accessing the configuration by
index.

This removes the need to store the libcamera stream format and sizes
as class members and avoid duplicating information that might get out
of sync.

It also allows to remove the StreamConfiguration from the constructor
parameters list, as it can be identified by its index. While at it,
re-order the constructor parameters order.

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
Jacopo Mondi 2020-10-03 12:00:54 +02:00
parent 216030aa9d
commit e3393f147e
3 changed files with 12 additions and 29 deletions

View file

@ -17,18 +17,13 @@ using namespace libcamera;
LOG_DECLARE_CATEGORY(HAL);
CameraStream::CameraStream(CameraDevice *cameraDevice,
camera3_stream_t *camera3Stream,
const libcamera::StreamConfiguration &cfg,
Type type, unsigned int index)
: cameraDevice_(cameraDevice), camera3Stream_(camera3Stream),
type_(type), index_(index)
CameraStream::CameraStream(CameraDevice *cameraDevice, Type type,
camera3_stream_t *camera3Stream, unsigned int index)
: cameraDevice_(cameraDevice), type_(type),
camera3Stream_(camera3Stream), index_(index)
{
config_ = cameraDevice_->cameraConfiguration();
format_ = cfg.pixelFormat;
size_ = cfg.size;
if (type_ == Type::Internal || type_ == Type::Mapped)
encoder_ = std::make_unique<EncoderLibJpeg>();
}
@ -63,7 +58,7 @@ int CameraStream::process(const libcamera::FrameBuffer &source,
exif.setMake("libcamera");
exif.setModel("cameraModel");
exif.setOrientation(cameraDevice_->orientation());
exif.setSize(size_);
exif.setSize(configuration().size);
/*
* We set the frame's EXIF timestamp as the time of encode.
* Since the precision we need for EXIF timestamp is only one