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>
This commit is contained in:
parent
3c84d88193
commit
160bb0998b
4 changed files with 36 additions and 10 deletions
|
@ -1216,8 +1216,8 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)
|
||||||
|
|
||||||
config_->addConfiguration(streamConfiguration);
|
config_->addConfiguration(streamConfiguration);
|
||||||
unsigned int index = config_->size() - 1;
|
unsigned int index = config_->size() - 1;
|
||||||
streams_.emplace_back(format, size, CameraStream::Type::Direct,
|
streams_.emplace_back(this, stream, streamConfiguration,
|
||||||
index);
|
CameraStream::Type::Direct, index);
|
||||||
stream->priv = static_cast<void *>(&streams_.back());
|
stream->priv = static_cast<void *>(&streams_.back());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1272,8 +1272,7 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)
|
||||||
}
|
}
|
||||||
|
|
||||||
StreamConfiguration &cfg = config_->at(index);
|
StreamConfiguration &cfg = config_->at(index);
|
||||||
|
streams_.emplace_back(this, jpegStream, cfg, type, index);
|
||||||
streams_.emplace_back(formats::MJPEG, cfg.size, type, index);
|
|
||||||
jpegStream->priv = static_cast<void *>(&streams_.back());
|
jpegStream->priv = static_cast<void *>(&streams_.back());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1405,7 +1404,7 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques
|
||||||
descriptor->buffers[i].buffer = camera3Buffers[i].buffer;
|
descriptor->buffers[i].buffer = camera3Buffers[i].buffer;
|
||||||
|
|
||||||
/* Software streams are handled after hardware streams complete. */
|
/* Software streams are handled after hardware streams complete. */
|
||||||
if (cameraStream->format() == formats::MJPEG)
|
if (cameraStream->camera3Stream().format == HAL_PIXEL_FORMAT_BLOB)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1469,7 +1468,7 @@ void CameraDevice::requestComplete(Request *request)
|
||||||
CameraStream *cameraStream =
|
CameraStream *cameraStream =
|
||||||
static_cast<CameraStream *>(descriptor->buffers[i].stream->priv);
|
static_cast<CameraStream *>(descriptor->buffers[i].stream->priv);
|
||||||
|
|
||||||
if (cameraStream->format() != formats::MJPEG)
|
if (cameraStream->camera3Stream().format != HAL_PIXEL_FORMAT_BLOB)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Encoder *encoder = cameraStream->encoder();
|
Encoder *encoder = cameraStream->encoder();
|
||||||
|
|
|
@ -43,6 +43,10 @@ public:
|
||||||
unsigned int id() const { return id_; }
|
unsigned int id() const { return id_; }
|
||||||
camera3_device_t *camera3Device() { return &camera3Device_; }
|
camera3_device_t *camera3Device() { return &camera3Device_; }
|
||||||
const libcamera::Camera *camera() const { return camera_.get(); }
|
const libcamera::Camera *camera() const { return camera_.get(); }
|
||||||
|
libcamera::CameraConfiguration *cameraConfiguration() const
|
||||||
|
{
|
||||||
|
return config_.get();
|
||||||
|
}
|
||||||
|
|
||||||
int facing() const { return facing_; }
|
int facing() const { return facing_; }
|
||||||
int orientation() const { return orientation_; }
|
int orientation() const { return orientation_; }
|
||||||
|
|
|
@ -7,14 +7,24 @@
|
||||||
|
|
||||||
#include "camera_stream.h"
|
#include "camera_stream.h"
|
||||||
|
|
||||||
|
#include "camera_device.h"
|
||||||
#include "jpeg/encoder.h"
|
#include "jpeg/encoder.h"
|
||||||
#include "jpeg/encoder_libjpeg.h"
|
#include "jpeg/encoder_libjpeg.h"
|
||||||
|
|
||||||
using namespace libcamera;
|
using namespace libcamera;
|
||||||
|
|
||||||
CameraStream::CameraStream(PixelFormat format, Size size, Type type, unsigned int index)
|
CameraStream::CameraStream(CameraDevice *cameraDevice,
|
||||||
: format_(format), size_(size), type_(type), index_(index)
|
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)
|
if (type_ == Type::Internal || type_ == Type::Mapped)
|
||||||
encoder_ = std::make_unique<EncoderLibJpeg>();
|
encoder_ = std::make_unique<EncoderLibJpeg>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,9 +9,13 @@
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
#include <hardware/camera3.h>
|
||||||
|
|
||||||
|
#include <libcamera/camera.h>
|
||||||
#include <libcamera/geometry.h>
|
#include <libcamera/geometry.h>
|
||||||
#include <libcamera/pixel_format.h>
|
#include <libcamera/pixel_format.h>
|
||||||
|
|
||||||
|
class CameraDevice;
|
||||||
class Encoder;
|
class Encoder;
|
||||||
|
|
||||||
class CameraStream
|
class CameraStream
|
||||||
|
@ -99,9 +103,12 @@ public:
|
||||||
Internal,
|
Internal,
|
||||||
Mapped,
|
Mapped,
|
||||||
};
|
};
|
||||||
CameraStream(libcamera::PixelFormat format, libcamera::Size size,
|
CameraStream(CameraDevice *cameraDevice,
|
||||||
|
camera3_stream_t *androidStream,
|
||||||
|
const libcamera::StreamConfiguration &cfg,
|
||||||
Type type, unsigned int index);
|
Type type, unsigned int index);
|
||||||
|
|
||||||
|
const camera3_stream_t &camera3Stream() const { return *camera3Stream_; }
|
||||||
const libcamera::PixelFormat &format() const { return format_; }
|
const libcamera::PixelFormat &format() const { return format_; }
|
||||||
const libcamera::Size &size() const { return size_; }
|
const libcamera::Size &size() const { return size_; }
|
||||||
Type type() const { return type_; }
|
Type type() const { return type_; }
|
||||||
|
@ -111,9 +118,15 @@ public:
|
||||||
int configure(const libcamera::StreamConfiguration &cfg);
|
int configure(const libcamera::StreamConfiguration &cfg);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
CameraDevice *cameraDevice_;
|
||||||
|
libcamera::CameraConfiguration *config_;
|
||||||
|
camera3_stream_t *camera3Stream_;
|
||||||
|
Type type_;
|
||||||
|
|
||||||
|
/* Libcamera facing format and sizes. */
|
||||||
libcamera::PixelFormat format_;
|
libcamera::PixelFormat format_;
|
||||||
libcamera::Size size_;
|
libcamera::Size size_;
|
||||||
Type type_;
|
|
||||||
/*
|
/*
|
||||||
* 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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue