libcamera/src/android/camera_stream.cpp
Jacopo Mondi 160bb0998b android: camera_stream: Construct with Android stream
Pass the android camera3_stream_t, and a libcamera::StreamConfiguration
to identify the source and destination parameters of this stream.

Pass a CameraDevice pointer to the CameraStream constructor to allow
retrieval of the StreamConfiguration associated with the CameraStream.

Also change the format on which the CameraDevice performs checks to
decide if post-processing is required, as the libcamera facing format is
not meaningful anymore, but the Android requested format should be used
instead.

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2020-10-07 16:07:44 +02:00

38 lines
897 B
C++

/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2020, Google Inc.
*
* camera_stream.cpp - Camera HAL stream
*/
#include "camera_stream.h"
#include "camera_device.h"
#include "jpeg/encoder.h"
#include "jpeg/encoder_libjpeg.h"
using namespace libcamera;
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)
{
config_ = cameraDevice_->cameraConfiguration();
format_ = cfg.pixelFormat;
size_ = cfg.size;
if (type_ == Type::Internal || type_ == Type::Mapped)
encoder_ = std::make_unique<EncoderLibJpeg>();
}
int CameraStream::configure(const libcamera::StreamConfiguration &cfg)
{
if (encoder_)
return encoder_->configure(cfg);
return 0;
}