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

@ -1206,9 +1206,8 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)
streamConfiguration.pixelFormat = format; streamConfiguration.pixelFormat = format;
config_->addConfiguration(streamConfiguration); config_->addConfiguration(streamConfiguration);
unsigned int index = config_->size() - 1; streams_.emplace_back(this, CameraStream::Type::Direct,
streams_.emplace_back(this, stream, streamConfiguration, stream, config_->size() - 1);
CameraStream::Type::Direct, index);
stream->priv = static_cast<void *>(&streams_.back()); stream->priv = static_cast<void *>(&streams_.back());
} }
@ -1262,8 +1261,7 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)
index = config_->size() - 1; index = config_->size() - 1;
} }
StreamConfiguration &cfg = config_->at(index); streams_.emplace_back(this, type, jpegStream, index);
streams_.emplace_back(this, jpegStream, cfg, type, index);
jpegStream->priv = static_cast<void *>(&streams_.back()); jpegStream->priv = static_cast<void *>(&streams_.back());
} }

View file

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

View file

@ -106,16 +106,11 @@ public:
Internal, Internal,
Mapped, Mapped,
}; };
CameraStream(CameraDevice *cameraDevice, CameraStream(CameraDevice *cameraDevice, Type type,
camera3_stream_t *androidStream, camera3_stream_t *camera3Stream, unsigned int index);
const libcamera::StreamConfiguration &cfg,
Type type, unsigned int index);
const camera3_stream_t &camera3Stream() const { return *camera3Stream_; }
const libcamera::PixelFormat &format() const { return format_; }
const libcamera::Size &size() const { return size_; }
Type type() const { return type_; } Type type() const { return type_; }
const camera3_stream_t &camera3Stream() const { return *camera3Stream_; }
const libcamera::StreamConfiguration &configuration() const; const libcamera::StreamConfiguration &configuration() const;
libcamera::Stream *stream() const; libcamera::Stream *stream() const;
@ -126,13 +121,8 @@ public:
private: private:
CameraDevice *cameraDevice_; CameraDevice *cameraDevice_;
libcamera::CameraConfiguration *config_; libcamera::CameraConfiguration *config_;
camera3_stream_t *camera3Stream_;
Type type_; Type type_;
camera3_stream_t *camera3Stream_;
/* Libcamera facing format and sizes. */
libcamera::PixelFormat format_;
libcamera::Size size_;
/* /*
* The index of the libcamera StreamConfiguration as added during * The index of the libcamera StreamConfiguration as added during
* configureStreams(). A single libcamera Stream may be used to deliver * configureStreams(). A single libcamera Stream may be used to deliver