{"id":9558,"url":"https://patchwork.libcamera.org/api/1.1/patches/9558/?format=json","web_url":"https://patchwork.libcamera.org/patch/9558/","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":"<20200909155457.153907-2-jacopo@jmondi.org>","date":"2020-09-09T15:54:50","name":"[libcamera-devel,1/8] android: camera_device: Add CameraStream::Type","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"e95e78ce5698cc60b5dfb1fd79f7cc62bbc21578","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/9558/mbox/","series":[{"id":1282,"url":"https://patchwork.libcamera.org/api/1.1/series/1282/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1282","date":"2020-09-09T15:54:49","name":"android: camera_device: Allocate internal buffers","version":1,"mbox":"https://patchwork.libcamera.org/series/1282/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/9558/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/9558/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 4A6C8BDB1D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  9 Sep 2020 15:51:21 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0813662D38;\n\tWed,  9 Sep 2020 17:51:21 +0200 (CEST)","from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net\n\t[217.70.183.201])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D6FB360534\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  9 Sep 2020 17:51:18 +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 relay8-d.mail.gandi.net (Postfix) with ESMTPSA id C30F61BF212;\n\tWed,  9 Sep 2020 15:51:17 +0000 (UTC)"],"X-Originating-IP":"93.34.118.233","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Wed,  9 Sep 2020 17:54:50 +0200","Message-Id":"<20200909155457.153907-2-jacopo@jmondi.org>","X-Mailer":"git-send-email 2.28.0","In-Reply-To":"<20200909155457.153907-1-jacopo@jmondi.org>","References":"<20200909155457.153907-1-jacopo@jmondi.org>","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH 1/8] android: camera_device: Add\n\tCameraStream::Type","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>","Cc":"hanlinchen@chromium.org","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":"Define the CameraStream::Type enumeration and assign it to\neach CameraStream instance at construction time.\n\nThe CameraStream type will be used to decide if memory needs to be\nallocated on its behalf or if the stream is backed by memory externally\nallocated by the Android framework.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/android/camera_device.cpp | 14 ++++--\n src/android/camera_device.h   | 87 ++++++++++++++++++++++++++++++++++-\n 2 files changed, 96 insertions(+), 5 deletions(-)","diff":"diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex 50923df22a8f..3c58523e528e 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -168,9 +168,11 @@ MappedCamera3Buffer::MappedCamera3Buffer(const buffer_handle_t camera3buffer,\n \t}\n }\n \n-CameraStream::CameraStream(PixelFormat format, Size size,\n+CameraStream::CameraStream(PixelFormat format, Size size, Type type,\n \t\t\t   unsigned int index, Encoder *encoder)\n-\t: format_(format), size_(size), index_(index), encoder_(encoder)\n+\n+\t: format_(format), size_(size), type_(type), index_(index),\n+\t  encoder_(encoder)\n {\n }\n \n@@ -1215,12 +1217,14 @@ 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, index);\n+\t\tstreams_.emplace_back(format, size, CameraStream::Type::Direct,\n+\t\t\t\t      index);\n \t\tstream->priv = static_cast<void *>(&streams_.back());\n \t}\n \n \t/* Now handle MJPEG streams, adding a new stream if required. */\n \tif (jpegStream) {\n+\t\tCameraStream::Type type;\n \t\tint index = -1;\n \n \t\t/* Search for a compatible stream in the non-JPEG ones. */\n@@ -1238,6 +1242,7 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)\n \t\t\tLOG(HAL, Info)\n \t\t\t\t<< \"Android JPEG stream mapped on stream \" << i;\n \n+\t\t\ttype = CameraStream::Type::Mapped;\n \t\t\tindex = i;\n \t\t\tbreak;\n \t\t}\n@@ -1262,6 +1267,7 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)\n \t\t\tLOG(HAL, Info) << \"Adding \" << streamConfiguration.toString()\n \t\t\t\t       << \" for MJPEG support\";\n \n+\t\t\ttype = CameraStream::Type::Internal;\n \t\t\tconfig_->addConfiguration(streamConfiguration);\n \t\t\tindex = config_->size() - 1;\n \t\t}\n@@ -1280,7 +1286,7 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)\n \t\t\treturn ret;\n \t\t}\n \n-\t\tstreams_.emplace_back(formats::MJPEG, cfg.size, index, encoder);\n+\t\tstreams_.emplace_back(formats::MJPEG, cfg.size, type, index, encoder);\n \t\tjpegStream->priv = static_cast<void *>(&streams_.back());\n \t}\n \ndiff --git a/src/android/camera_device.h b/src/android/camera_device.h\nindex 912c59aeb5a8..9dea7c42bdb5 100644\n--- a/src/android/camera_device.h\n+++ b/src/android/camera_device.h\n@@ -30,17 +30,102 @@ class CameraMetadata;\n class CameraStream\n {\n public:\n+\t/*\n+\t * Enumeration of CameraStream types.\n+\t *\n+\t * A camera stream associates an Android stream to a libcamera stream.\n+\t * This enumeration describes how the two streams are associated and how\n+\t * and where data produced from libcamera are delivered to the\n+\t * Android framework.\n+\t *\n+\t * Direct:\n+\t *\n+\t * The Android stream is directly mapped onto a libcamera stream: frames\n+\t * are delivered by the library directly in the memory location\n+\t * specified by the Android stream (buffer_handle_t->data) and provided\n+\t * to the framework as they are. The Android stream characteristics are\n+\t * directly translated to the libcamera stream configuration.\n+\t *\n+\t * +-----+                +-----+\n+\t * |  A  |                |  L  |\n+\t * +-----+                +-----+\n+\t *    |                      |\n+\t *    V                      V\n+\t * +-----+                +------+\n+\t * |  B  |<---------------|  FB  |\n+\t * +-----+                +------+\n+\t *\n+\t *\n+\t * Internal:\n+\t *\n+\t * Data for the Android stream are produced by processing a libcamera\n+\t * stream created by the HAL for that purpose. The libcamera stream\n+\t * needs to be supplied with intermediate buffers where the library\n+\t * delivers frames to be processed and then provided to the framework.\n+\t * The libcamera stream configuration is not a direct translation of the\n+\t * Android stream characteristics, but it describes the format and size\n+\t * required for the processing procedure to produce frames in the\n+\t * Android required format.\n+\t *\n+\t * +-----+                +-----+    +----+\n+\t * |  A  |                |  L  |--->|  B |\n+\t * +-----+                +-----+    +----+\n+\t *    |                      |         ^\n+\t *    V                      V         |\n+\t * +-----+                +------+     |\n+\t * |  B  |                |  FB  |-----+\n+\t * +-----+                +------+\n+\t *   ^                       |\n+\t *   |-------Processing------|\n+\t *\n+\t *\n+\t * Mapped:\n+\t *\n+\t * Data for the Android stream are produced by processing a libcamera\n+\t * stream associated with another CameraStream. Mapped camera streams do\n+\t * not need any memory to be reserved for them as they process data\n+\t * produced by libcamera for a different stream whose format and size\n+\t * is compatible with the processing procedure requirements to produce\n+\t * frames in the Android required format.\n+\t *\n+\t * +-----+      +-----+          +-----+\n+\t * |  A  |      |  A' |          |  L  |\n+\t * +-----+      +-----+          +-----+\n+\t *    |            |                |\n+\t *    V            V                V\n+\t * +-----+      +-----+          +------+\n+\t * |  B  |      |  B' |<---------|  FB  |\n+\t * +-----+      +-----+          +------+\n+\t *   ^              |\n+\t *   |--Processing--|\n+\t *\n+\t *\n+\t * --------------------------------------------------------------------\n+\t * A  = Android stream\n+\t * L  = libcamera stream\n+\t * B  = memory buffer\n+\t * FB = libcamera FrameBuffer\n+\t * \"Processing\" = Frame processing procedure (Encoding, scaling etc)\n+\t */\n+\tenum Type {\n+\t\tDirect,\n+\t\tInternal,\n+\t\tMapped,\n+\t};\n+\n \tCameraStream(libcamera::PixelFormat format, libcamera::Size size,\n-\t\t     unsigned int index, Encoder *encoder = nullptr);\n+\t\t     Type type, unsigned int index, Encoder *encoder = nullptr);\n \n \tconst libcamera::PixelFormat &format() const { return format_; }\n \tconst libcamera::Size &size() const { return size_; }\n \tunsigned int index() const { return index_; }\n \tEncoder *encoder() const { return encoder_.get(); }\n+\tType type() const { return type_; }\n \n private:\n \tlibcamera::PixelFormat format_;\n \tlibcamera::Size size_;\n+\tType type_;\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","1/8"]}