{"id":10621,"url":"https://patchwork.libcamera.org/api/1.1/patches/10621/?format=json","web_url":"https://patchwork.libcamera.org/patch/10621/","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":"<20201209055410.3232987-2-hiroh@chromium.org>","date":"2020-12-09T05:54:09","name":"[libcamera-devel,v5,2/3] android: camera_device: Use Camera3StreamConfig in configureStreams()","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"90ae78b004a212285a438d1a67d604908e283882","submitter":{"id":63,"url":"https://patchwork.libcamera.org/api/1.1/people/63/?format=json","name":"Hirokazu Honda","email":"hiroh@chromium.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/10621/mbox/","series":[{"id":1517,"url":"https://patchwork.libcamera.org/api/1.1/series/1517/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1517","date":"2020-12-09T05:54:08","name":"[libcamera-devel,v5,1/3] android: camera_device: Introduce Camera3StreamConfig","version":5,"mbox":"https://patchwork.libcamera.org/series/1517/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/10621/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/10621/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 82C70BDE19\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  9 Dec 2020 05:54:21 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 561BF67F35;\n\tWed,  9 Dec 2020 06:54:21 +0100 (CET)","from mail-pl1-x644.google.com (mail-pl1-x644.google.com\n\t[IPv6:2607:f8b0:4864:20::644])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C114967F30\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  9 Dec 2020 06:54:18 +0100 (CET)","by mail-pl1-x644.google.com with SMTP id t18so380252plo.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 08 Dec 2020 21:54:18 -0800 (PST)","from hiroh.c.googlers.com.com\n\t(128.141.236.35.bc.googleusercontent.com. [35.236.141.128])\n\tby smtp.gmail.com with ESMTPSA id\n\toc13sm641275pjb.5.2020.12.08.21.54.15\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 08 Dec 2020 21:54:16 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"MKNylucY\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=6VIwJqNsRrz20X5OvIZRqQ98fMAo2kwuGK5JAcIcoNI=;\n\tb=MKNylucY2CpiAPRwVSt0DfY9Gik7LE8t5kNPmw6UZoGvmQRhVnwsMAVXMBYNWhMbG/\n\tMYHFIrMouGLjZxGK8j2ZK86Gg/Df6k8Ve6pb/e5GSVFYITTm7+ZKT9n3kXNGbmhvG4Zs\n\tOSVJ8x2ojm/yUzGyftclF5RS9Mn4zMuJei0n8=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=6VIwJqNsRrz20X5OvIZRqQ98fMAo2kwuGK5JAcIcoNI=;\n\tb=Fh6p1wv+q+yAEUIU8Go9JCkIXSoXib/d9RgtUiuGOMw+LQ7h2+gh7SarjCSAcmF4Mp\n\tVKhSy5OUeONXNtm3fznMC4zt0IaVkp9dLvEPTWeLX0lEyHocdX/q59Ux3DfysNqcK2AU\n\thLvF9XAZ3vmMqJ9RXuYq4ArdxLEoj2AXp90BxkZMPMTVWNKcM2GVI+TDMTmy1MbvAjq/\n\tGDRxY0PmuuEXnC2Mts8baH+zJuVYRRPlBWPYCt+lgRvgDqixl1r5pckO8a1xqjhI88nb\n\tX1lXBPhjNxYBZvikpmSRusjb0bMbuLpJRiI7M48W3X1yvkMGlO+qaz077850NzMG28un\n\tsC9w==","X-Gm-Message-State":"AOAM532lp90D9ZEh/VfXZHiKgIu+rpXQHoSd3n2Mu8Gk1hNFE3dLHWwI\n\tkhst4//OD1GyxDRMbUq6xJTrwUvSge4L9A==","X-Google-Smtp-Source":"ABdhPJy6jfdWH08ZYDiJ11GEcw5qWR3Iazcn0mBLEfKtnXnxIHv5wPfpnb51sLdpApY1hrM1lYWYtA==","X-Received":"by 2002:a17:90a:6842:: with SMTP id\n\te2mr773777pjm.190.1607493257156; \n\tTue, 08 Dec 2020 21:54:17 -0800 (PST)","From":"Hirokazu Honda <hiroh@chromium.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Wed,  9 Dec 2020 05:54:09 +0000","Message-Id":"<20201209055410.3232987-2-hiroh@chromium.org>","X-Mailer":"git-send-email 2.29.2.576.ga3fc446d84-goog","In-Reply-To":"<20201209055410.3232987-1-hiroh@chromium.org>","References":"<20201209055410.3232987-1-hiroh@chromium.org>","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH v5 2/3] android: camera_device: Use\n\tCamera3StreamConfig in configureStreams()","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":"Use the newly introduced Camera3StreamConfig to associate the\nAndroid requested streams with the associated StreamConfiguration\nin a vector of configurations.\n\nThis change prepares to sort the vector of configuration before using\nit to configure the Camera and populate the streams_ vector.\n\nNo functional changes intended.\n\nSigned-off-by: Hirokazu Honda <hiroh@chromium.org>\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/android/camera_device.cpp | 52 +++++++++++++++++++++--------------\n 1 file changed, 31 insertions(+), 21 deletions(-)\n\n--\n2.29.2.576.ga3fc446d84-goog","diff":"diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex 09269d95..b7bf3d88 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -1240,6 +1240,9 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)\n \tstreams_.clear();\n \tstreams_.reserve(stream_list->num_streams);\n\n+\tstd::vector<Camera3StreamConfig> streamConfigs;\n+\tstreamConfigs.reserve(stream_list->num_streams);\n+\n \t/* First handle all non-MJPEG streams. */\n \tcamera3_stream_t *jpegStream = nullptr;\n \tfor (unsigned int i = 0; i < stream_list->num_streams; ++i) {\n@@ -1270,14 +1273,12 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)\n \t\t\tcontinue;\n \t\t}\n\n-\t\tStreamConfiguration streamConfiguration;\n-\t\tstreamConfiguration.size = size;\n-\t\tstreamConfiguration.pixelFormat = format;\n-\n-\t\tconfig_->addConfiguration(streamConfiguration);\n-\t\tstreams_.emplace_back(this, CameraStream::Type::Direct,\n-\t\t\t\t      stream, config_->size() - 1);\n-\t\tstream->priv = static_cast<void *>(&streams_.back());\n+\t\tCamera3StreamConfig streamConfig;\n+\t\tstreamConfig.streams = { stream };\n+\t\tstreamConfig.types = { CameraStream::Type::Direct };\n+\t\tstreamConfig.config.size = size;\n+\t\tstreamConfig.config.pixelFormat = format;\n+\t\tstreamConfigs.push_back(std::move(streamConfig));\n \t}\n\n \t/* Now handle the MJPEG streams, adding a new stream if required. */\n@@ -1286,9 +1287,8 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)\n \t\tint index = -1;\n\n \t\t/* Search for a compatible stream in the non-JPEG ones. */\n-\t\tfor (unsigned int i = 0; i < config_->size(); i++) {\n-\t\t\tStreamConfiguration &cfg = config_->at(i);\n-\n+\t\tfor (size_t i = 0; i < streamConfigs.size(); ++i) {\n+\t\t\tconst auto &cfg = streamConfigs[i].config;\n \t\t\t/*\n \t\t\t * \\todo The PixelFormat must also be compatible with\n \t\t\t * the encoder.\n@@ -1310,28 +1310,38 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)\n \t\t * introduce a new stream to satisfy the request requirements.\n \t\t */\n \t\tif (index < 0) {\n-\t\t\tStreamConfiguration streamConfiguration;\n-\n \t\t\t/*\n \t\t\t * \\todo The pixelFormat should be a 'best-fit' choice\n \t\t\t * and may require a validation cycle. This is not yet\n \t\t\t * handled, and should be considered as part of any\n \t\t\t * stream configuration reworks.\n \t\t\t */\n-\t\t\tstreamConfiguration.size.width = jpegStream->width;\n-\t\t\tstreamConfiguration.size.height = jpegStream->height;\n-\t\t\tstreamConfiguration.pixelFormat = formats::NV12;\n+\t\t\tCamera3StreamConfig streamConfig;\n+\t\t\tstreamConfig.config.size.width = jpegStream->width;\n+\t\t\tstreamConfig.config.size.height = jpegStream->height;\n+\t\t\tstreamConfig.config.pixelFormat = formats::NV12;\n+\t\t\tstreamConfigs.push_back(std::move(streamConfig));\n\n-\t\t\tLOG(HAL, Info) << \"Adding \" << streamConfiguration.toString()\n+\t\t\tLOG(HAL, Info) << \"Adding \" << streamConfig.config.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\tindex = streamConfigs.size() - 1;\n \t\t}\n\n-\t\tstreams_.emplace_back(this, type, jpegStream, index);\n-\t\tjpegStream->priv = static_cast<void *>(&streams_.back());\n+\t\tstreamConfigs[index].streams.push_back(jpegStream);\n+\t\tstreamConfigs[index].types.push_back(type);\n+\t}\n+\n+\tfor (const auto &streamConfig : streamConfigs) {\n+\t\tconfig_->addConfiguration(streamConfig.config);\n+\t\tfor (size_t i = 0; i < streamConfig.streams.size(); ++i) {\n+\t\t\tcamera3_stream_t *stream = streamConfig.streams[i];\n+\t\t\tconst CameraStream::Type type = streamConfig.types[i];\n+\t\t\tstreams_.emplace_back(this, type,\n+\t\t\t\t\t      stream, config_->size() - 1);\n+\t\t\tstream->priv = static_cast<void*>(&streams_.back());\n+\t\t}\n \t}\n\n \tswitch (config_->validate()) {\n","prefixes":["libcamera-devel","v5","2/3"]}