{"id":9996,"url":"https://patchwork.libcamera.org/api/1.1/patches/9996/?format=json","web_url":"https://patchwork.libcamera.org/patch/9996/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20201007101745.15104-5-jacopo@jmondi.org>","date":"2020-10-07T10:17:36","name":"[libcamera-devel,v3,04/13] android: camera_stream: Construct with Android stream","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"4fe1331d8d752aaab5e122d8a1734c344c748a4b","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/1.1/people/3/?format=json","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/9996/mbox/","series":[{"id":1361,"url":"https://patchwork.libcamera.org/api/1.1/series/1361/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1361","date":"2020-10-07T10:17:32","name":"android: CameraStream rework","version":3,"mbox":"https://patchwork.libcamera.org/series/1361/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/9996/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/9996/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 1D49CBEEE1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  7 Oct 2020 10:13:57 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id ED98C6054D;\n\tWed,  7 Oct 2020 12:13:56 +0200 (CEST)","from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net\n\t[217.70.183.195])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2E71E60396\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  7 Oct 2020 12:13:56 +0200 (CEST)","from uno.lan (93-34-118-233.ip49.fastwebnet.it [93.34.118.233])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay3-d.mail.gandi.net (Postfix) with ESMTPSA id A5E1C60005;\n\tWed,  7 Oct 2020 10:13:55 +0000 (UTC)"],"X-Originating-IP":"93.34.118.233","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Wed,  7 Oct 2020 12:17:36 +0200","Message-Id":"<20201007101745.15104-5-jacopo@jmondi.org>","X-Mailer":"git-send-email 2.28.0","In-Reply-To":"<20201007101745.15104-1-jacopo@jmondi.org>","References":"<20201007101745.15104-1-jacopo@jmondi.org>","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH v3 04/13] android: camera_stream:\n\tConstruct with Android stream","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Pass the android camera3_stream_t, and a libcamera::StreamConfiguration\nto identify the source and destination parameters of this stream.\n\nPass a CameraDevice pointer to the CameraStream constructor to allow\nretrieval of the StreamConfiguration associated with the CameraStream.\n\nAlso change the format on which the CameraDevice performs checks to\ndecide if post-processing is required, as the libcamera facing format is\nnot meaningful anymore, but the Android requested format should be used\ninstead.\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/android/camera_device.cpp | 11 +++++------\n src/android/camera_device.h   |  4 ++++\n src/android/camera_stream.cpp | 14 ++++++++++++--\n src/android/camera_stream.h   | 17 +++++++++++++++--\n 4 files changed, 36 insertions(+), 10 deletions(-)","diff":"diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex 9c9a5cfa3c2f..68970eb4a94c 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -1216,8 +1216,8 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)\n \n \t\tconfig_->addConfiguration(streamConfiguration);\n \t\tunsigned int index = config_->size() - 1;\n-\t\tstreams_.emplace_back(format, size, CameraStream::Type::Direct,\n-\t\t\t\t      index);\n+\t\tstreams_.emplace_back(this, stream, streamConfiguration,\n+\t\t\t\t      CameraStream::Type::Direct, index);\n \t\tstream->priv = static_cast<void *>(&streams_.back());\n \t}\n \n@@ -1272,8 +1272,7 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)\n \t\t}\n \n \t\tStreamConfiguration &cfg = config_->at(index);\n-\n-\t\tstreams_.emplace_back(formats::MJPEG, cfg.size, type, index);\n+\t\tstreams_.emplace_back(this, jpegStream, cfg, type, index);\n \t\tjpegStream->priv = static_cast<void *>(&streams_.back());\n \t}\n \n@@ -1405,7 +1404,7 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques\n \t\tdescriptor->buffers[i].buffer = camera3Buffers[i].buffer;\n \n \t\t/* Software streams are handled after hardware streams complete. */\n-\t\tif (cameraStream->format() == formats::MJPEG)\n+\t\tif (cameraStream->camera3Stream().format == HAL_PIXEL_FORMAT_BLOB)\n \t\t\tcontinue;\n \n \t\t/*\n@@ -1469,7 +1468,7 @@ void CameraDevice::requestComplete(Request *request)\n \t\tCameraStream *cameraStream =\n \t\t\tstatic_cast<CameraStream *>(descriptor->buffers[i].stream->priv);\n \n-\t\tif (cameraStream->format() != formats::MJPEG)\n+\t\tif (cameraStream->camera3Stream().format != HAL_PIXEL_FORMAT_BLOB)\n \t\t\tcontinue;\n \n \t\tEncoder *encoder = cameraStream->encoder();\ndiff --git a/src/android/camera_device.h b/src/android/camera_device.h\nindex 52923ec979a7..4e326fa3e1fb 100644\n--- a/src/android/camera_device.h\n+++ b/src/android/camera_device.h\n@@ -43,6 +43,10 @@ public:\n \tunsigned int id() const { return id_; }\n \tcamera3_device_t *camera3Device() { return &camera3Device_; }\n \tconst libcamera::Camera *camera() const { return camera_.get(); }\n+\tlibcamera::CameraConfiguration *cameraConfiguration() const\n+\t{\n+\t\treturn config_.get();\n+\t}\n \n \tint facing() const { return facing_; }\n \tint orientation() const { return orientation_; }\ndiff --git a/src/android/camera_stream.cpp b/src/android/camera_stream.cpp\nindex 2d0c6ff99ac6..b3d345afc61a 100644\n--- a/src/android/camera_stream.cpp\n+++ b/src/android/camera_stream.cpp\n@@ -7,14 +7,24 @@\n \n #include \"camera_stream.h\"\n \n+#include \"camera_device.h\"\n #include \"jpeg/encoder.h\"\n #include \"jpeg/encoder_libjpeg.h\"\n \n using namespace libcamera;\n \n-CameraStream::CameraStream(PixelFormat format, Size size, Type type, unsigned int index)\n-\t: format_(format), size_(size), type_(type), index_(index)\n+CameraStream::CameraStream(CameraDevice *cameraDevice,\n+\t\t\t   camera3_stream_t *camera3Stream,\n+\t\t\t   const libcamera::StreamConfiguration &cfg,\n+\t\t\t   Type type, unsigned int index)\n+\t: cameraDevice_(cameraDevice), camera3Stream_(camera3Stream),\n+\t  type_(type), index_(index)\n {\n+\tconfig_ = cameraDevice_->cameraConfiguration();\n+\n+\tformat_ = cfg.pixelFormat;\n+\tsize_ = cfg.size;\n+\n \tif (type_ == Type::Internal || type_ == Type::Mapped)\n \t\tencoder_ = std::make_unique<EncoderLibJpeg>();\n }\ndiff --git a/src/android/camera_stream.h b/src/android/camera_stream.h\nindex 2f49d3d41a7f..ccc822b4980f 100644\n--- a/src/android/camera_stream.h\n+++ b/src/android/camera_stream.h\n@@ -9,9 +9,13 @@\n \n #include <memory>\n \n+#include <hardware/camera3.h>\n+\n+#include <libcamera/camera.h>\n #include <libcamera/geometry.h>\n #include <libcamera/pixel_format.h>\n \n+class CameraDevice;\n class Encoder;\n \n class CameraStream\n@@ -99,9 +103,12 @@ public:\n \t\tInternal,\n \t\tMapped,\n \t};\n-\tCameraStream(libcamera::PixelFormat format, libcamera::Size size,\n+\tCameraStream(CameraDevice *cameraDevice,\n+\t\t     camera3_stream_t *androidStream,\n+\t\t     const libcamera::StreamConfiguration &cfg,\n \t\t     Type type, unsigned int index);\n \n+\tconst camera3_stream_t &camera3Stream() const { return *camera3Stream_; }\n \tconst libcamera::PixelFormat &format() const { return format_; }\n \tconst libcamera::Size &size() const { return size_; }\n \tType type() const { return type_; }\n@@ -111,9 +118,15 @@ public:\n \tint configure(const libcamera::StreamConfiguration &cfg);\n \n private:\n+\tCameraDevice *cameraDevice_;\n+\tlibcamera::CameraConfiguration *config_;\n+\tcamera3_stream_t *camera3Stream_;\n+\tType type_;\n+\n+\t/* Libcamera facing format and sizes. */\n \tlibcamera::PixelFormat format_;\n \tlibcamera::Size size_;\n-\tType type_;\n+\n \t/*\n \t * The index of the libcamera StreamConfiguration as added during\n \t * configureStreams(). A single libcamera Stream may be used to deliver\n","prefixes":["libcamera-devel","v3","04/13"]}