diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/android/camera_device.cpp | 11 | ||||
-rw-r--r-- | src/android/camera_device.h | 4 | ||||
-rw-r--r-- | src/android/camera_stream.cpp | 14 | ||||
-rw-r--r-- | src/android/camera_stream.h | 17 |
4 files changed, 36 insertions, 10 deletions
diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 9c9a5cfa..68970eb4 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -1216,8 +1216,8 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list) config_->addConfiguration(streamConfiguration); unsigned int index = config_->size() - 1; - streams_.emplace_back(format, size, CameraStream::Type::Direct, - index); + streams_.emplace_back(this, stream, streamConfiguration, + CameraStream::Type::Direct, index); 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); - - streams_.emplace_back(formats::MJPEG, cfg.size, type, index); + streams_.emplace_back(this, jpegStream, cfg, type, index); 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; /* Software streams are handled after hardware streams complete. */ - if (cameraStream->format() == formats::MJPEG) + if (cameraStream->camera3Stream().format == HAL_PIXEL_FORMAT_BLOB) continue; /* @@ -1469,7 +1468,7 @@ void CameraDevice::requestComplete(Request *request) CameraStream *cameraStream = static_cast<CameraStream *>(descriptor->buffers[i].stream->priv); - if (cameraStream->format() != formats::MJPEG) + if (cameraStream->camera3Stream().format != HAL_PIXEL_FORMAT_BLOB) continue; Encoder *encoder = cameraStream->encoder(); diff --git a/src/android/camera_device.h b/src/android/camera_device.h index 52923ec9..4e326fa3 100644 --- a/src/android/camera_device.h +++ b/src/android/camera_device.h @@ -43,6 +43,10 @@ public: unsigned int id() const { return id_; } camera3_device_t *camera3Device() { return &camera3Device_; } const libcamera::Camera *camera() const { return camera_.get(); } + libcamera::CameraConfiguration *cameraConfiguration() const + { + return config_.get(); + } int facing() const { return facing_; } int orientation() const { return orientation_; } diff --git a/src/android/camera_stream.cpp b/src/android/camera_stream.cpp index 2d0c6ff9..b3d345af 100644 --- a/src/android/camera_stream.cpp +++ b/src/android/camera_stream.cpp @@ -7,14 +7,24 @@ #include "camera_stream.h" +#include "camera_device.h" #include "jpeg/encoder.h" #include "jpeg/encoder_libjpeg.h" using namespace libcamera; -CameraStream::CameraStream(PixelFormat format, Size size, Type type, unsigned int index) - : format_(format), size_(size), type_(type), index_(index) +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>(); } diff --git a/src/android/camera_stream.h b/src/android/camera_stream.h index 2f49d3d4..ccc822b4 100644 --- a/src/android/camera_stream.h +++ b/src/android/camera_stream.h @@ -9,9 +9,13 @@ #include <memory> +#include <hardware/camera3.h> + +#include <libcamera/camera.h> #include <libcamera/geometry.h> #include <libcamera/pixel_format.h> +class CameraDevice; class Encoder; class CameraStream @@ -99,9 +103,12 @@ public: Internal, Mapped, }; - CameraStream(libcamera::PixelFormat format, libcamera::Size size, + CameraStream(CameraDevice *cameraDevice, + camera3_stream_t *androidStream, + 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_; } @@ -111,9 +118,15 @@ public: int configure(const libcamera::StreamConfiguration &cfg); private: + CameraDevice *cameraDevice_; + libcamera::CameraConfiguration *config_; + camera3_stream_t *camera3Stream_; + Type type_; + + /* Libcamera facing format and sizes. */ libcamera::PixelFormat format_; libcamera::Size size_; - Type type_; + /* * The index of the libcamera StreamConfiguration as added during * configureStreams(). A single libcamera Stream may be used to deliver |