Show a patch.

GET /api/patches/9951/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 9951,
    "url": "https://patchwork.libcamera.org/api/patches/9951/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/9951/",
    "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": "<20201005104649.10812-5-laurent.pinchart@ideasonboard.com>",
    "date": "2020-10-05T10:46:38",
    "name": "[libcamera-devel,04/15] android: camera_stream: Construct with Android stream",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "aa3305910d1ae664ff328c320caee25e59c57367",
    "submitter": {
        "id": 2,
        "url": "https://patchwork.libcamera.org/api/people/2/?format=api",
        "name": "Laurent Pinchart",
        "email": "laurent.pinchart@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/9951/mbox/",
    "series": [
        {
            "id": 1349,
            "url": "https://patchwork.libcamera.org/api/series/1349/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1349",
            "date": "2020-10-05T10:46:34",
            "name": "CameraStream refactoring",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/1349/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/9951/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/9951/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 12B71C3B5D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  5 Oct 2020 10:47:39 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0684F63C4C;\n\tMon,  5 Oct 2020 12:47:38 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 275A363B27\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  5 Oct 2020 12:47:35 +0200 (CEST)",
            "from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id AC44D3B;\n\tMon,  5 Oct 2020 12:47:34 +0200 (CEST)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"aWnHfiqp\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1601894854;\n\tbh=osi4Z+RtghKoXEuYdb+n5QvnBwR7M1NC0SwQftHsfZs=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=aWnHfiqp4Py+iYiZF8eSr+Z3kg1VX8ybSzprouftu7qqcxpJ1W6H7pBYhefixPTVn\n\tw1mv5yJMXytxcKhyfV4uUbL37RQ8Kn4BTezoNhFq4AA3pWAiJxgMA2+djBbHN/EbRG\n\tXWl9kktD1K/e8jCqKLX9DCakgp+xsx6Fj3tqtydU=",
        "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Mon,  5 Oct 2020 13:46:38 +0300",
        "Message-Id": "<20201005104649.10812-5-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.27.0",
        "In-Reply-To": "<20201005104649.10812-1-laurent.pinchart@ideasonboard.com>",
        "References": "<20201005104649.10812-1-laurent.pinchart@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Subject": "[libcamera-devel] [PATCH 04/15] android: camera_stream: Construct\n\twith 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": "From: Jacopo Mondi <jacopo@jmondi.org>\n\nA CameraStream maps a stream requested by Android to a\nlibcamera::StreamConfiguration. It shall then be constructed with\nthose information clearly specified.\n\nChange the CameraStream constructor to accept an Android\ncamera3_stream_t and a libcamera::StreamConfiguration to copy the\nformat and size information in the class members as no reference can be\ntaken to the StreamConfiguration instances as they're subject to\nrelocations.\n\nPass to the CameraStream constructor a pointer to the CameraDevice class\nand make the CameraConfiguration accessible. It will be used to retrieve\nthe 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 required format should be used\ninstead.\n\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   | 18 ++++++++++++++++--\n 4 files changed, 37 insertions(+), 10 deletions(-)",
    "diff": "diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex 9c9a5cfa3c2f..2c4dd4dee28c 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->outputFormat() == 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->outputFormat() != 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 5b2b625c563b..5c1f1d7da416 100644\n--- a/src/android/camera_stream.cpp\n+++ b/src/android/camera_stream.cpp\n@@ -7,13 +7,23 @@\n \n #include \"camera_stream.h\"\n \n+#include \"camera_device.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), encoder(nullptr)\n+CameraStream::CameraStream(CameraDevice *cameraDev,\n+\t\t\t   camera3_stream_t *androidStream,\n+\t\t\t   const libcamera::StreamConfiguration &cfg,\n+\t\t\t   Type type, unsigned int index)\n+\t: cameraDevice_(cameraDev), androidStream_(androidStream), type_(type),\n+\t  index_(index), encoder_(nullptr)\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_.reset(new EncoderLibJpeg);\n }\ndiff --git a/src/android/camera_stream.h b/src/android/camera_stream.h\nindex d0dc40d81151..2d71a50c78a4 100644\n--- a/src/android/camera_stream.h\n+++ b/src/android/camera_stream.h\n@@ -9,11 +9,16 @@\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 #include \"jpeg/encoder.h\"\n \n+class CameraDevice;\n+\n class CameraStream\n {\n public:\n@@ -99,9 +104,12 @@ public:\n \t\tInternal,\n \t\tMapped,\n \t};\n-\tCameraStream(libcamera::PixelFormat format, libcamera::Size size,\n+\tCameraStream(CameraDevice *cameraDev,\n+\t\t     camera3_stream_t *androidStream,\n+\t\t     const libcamera::StreamConfiguration &cfg,\n \t\t     Type type, unsigned int index);\n \n+\tint outputFormat() const { return androidStream_->format; }\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 +119,15 @@ public:\n \tint configure(const libcamera::StreamConfiguration &cfg);\n \n private:\n+\tCameraDevice *cameraDevice_;\n+\tlibcamera::CameraConfiguration *config_;\n+\tcamera3_stream_t *androidStream_;\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",
        "04/15"
    ]
}