Patch Detail
Show a patch.
GET /api/patches/9971/?format=api
{ "id": 9971, "url": "https://patchwork.libcamera.org/api/patches/9971/?format=api", "web_url": "https://patchwork.libcamera.org/patch/9971/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20201006144432.22908-3-jacopo@jmondi.org>", "date": "2020-10-06T14:44:21", "name": "[libcamera-devel,v2,02/13] android: camera_stream: Add CameraStream::Type", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "f8a9d41291193981e846aef7b8453a5c8394422a", "submitter": { "id": 3, "url": "https://patchwork.libcamera.org/api/people/3/?format=api", "name": "Jacopo Mondi", "email": "jacopo@jmondi.org" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/9971/mbox/", "series": [ { "id": 1356, "url": "https://patchwork.libcamera.org/api/series/1356/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1356", "date": "2020-10-06T14:44:19", "name": "CameraStream refactor", "version": 2, "mbox": "https://patchwork.libcamera.org/series/1356/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/9971/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/9971/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 5EC2DBEEDF\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 6 Oct 2020 14:40:42 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3940763C48;\n\tTue, 6 Oct 2020 16:40:42 +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 6649263C13\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 6 Oct 2020 16:40:41 +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 A6C2160007;\n\tTue, 6 Oct 2020 14:40:39 +0000 (UTC)" ], "X-Originating-IP": "93.34.118.233", "From": "Jacopo Mondi <jacopo@jmondi.org>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Tue, 6 Oct 2020 16:44:21 +0200", "Message-Id": "<20201006144432.22908-3-jacopo@jmondi.org>", "X-Mailer": "git-send-email 2.28.0", "In-Reply-To": "<20201006144432.22908-1-jacopo@jmondi.org>", "References": "<20201006144432.22908-1-jacopo@jmondi.org>", "MIME-Version": "1.0", "Subject": "[libcamera-devel] [PATCH v2 02/13] android: camera_stream: 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>", "Content-Type": "text/plain; charset=\"utf-8\"", "Content-Transfer-Encoding": "base64", "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\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nReviewed-by: Hirokazu Honda <hiroh@chromium.org>\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/android/camera_device.cpp | 8 +++-\n src/android/camera_stream.cpp | 4 +-\n src/android/camera_stream.h | 86 ++++++++++++++++++++++++++++++++++-\n 3 files changed, 93 insertions(+), 5 deletions(-)", "diff": "diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex bbc692fe109f..0600ebc81c64 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -1216,12 +1216,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 the 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@@ -1239,6 +1241,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 to libcamera stream \" << i;\n \n+\t\t\ttype = CameraStream::Type::Mapped;\n \t\t\tindex = i;\n \t\t\tbreak;\n \t\t}\n@@ -1263,6 +1266,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@@ -1281,7 +1285,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_stream.cpp b/src/android/camera_stream.cpp\nindex cd9084aeb51b..7205721dbeb9 100644\n--- a/src/android/camera_stream.cpp\n+++ b/src/android/camera_stream.cpp\n@@ -12,7 +12,7 @@\n using namespace libcamera;\n \n CameraStream::CameraStream(PixelFormat format, Size size,\n-\t\t\t unsigned int index, Encoder *encoder)\n-\t: format_(format), size_(size), index_(index), encoder_(encoder)\n+\t\t\t Type type, unsigned int index, Encoder *encoder)\n+\t: format_(format), size_(size), type_(type), index_(index), encoder_(encoder)\n {\n }\ndiff --git a/src/android/camera_stream.h b/src/android/camera_stream.h\nindex 0de6b6fc6f8c..e54276868a19 100644\n--- a/src/android/camera_stream.h\n+++ b/src/android/camera_stream.h\n@@ -17,17 +17,101 @@ class Encoder;\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 is 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 |\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 is 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 * are 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 class Type {\n+\t\tDirect,\n+\t\tInternal,\n+\t\tMapped,\n+\t};\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+\tType type() const { return type_; }\n \tunsigned int index() const { return index_; }\n \tEncoder *encoder() const { return encoder_.get(); }\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", "v2", "02/13" ] }