{"id":10643,"url":"https://patchwork.libcamera.org/api/patches/10643/?format=json","web_url":"https://patchwork.libcamera.org/patch/10643/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20201211095336.40500-2-hiroh@chromium.org>","date":"2020-12-11T09:53:35","name":"[libcamera-devel,v7,2/3] android: camera_device: Use Camera3StreamConfig in configureStreams()","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"f38e3918f1b46005d82b4fa0ae2b9e7c9c0728dc","submitter":{"id":63,"url":"https://patchwork.libcamera.org/api/people/63/?format=json","name":"Hirokazu Honda","email":"hiroh@chromium.org"},"delegate":{"id":15,"url":"https://patchwork.libcamera.org/api/users/15/?format=json","username":"jmondi","first_name":"Jacopo","last_name":"Mondi","email":"jacopo@jmondi.org"},"mbox":"https://patchwork.libcamera.org/patch/10643/mbox/","series":[{"id":1525,"url":"https://patchwork.libcamera.org/api/series/1525/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1525","date":"2020-12-11T09:53:34","name":"[libcamera-devel,v7,1/3] android: camera_device: Introduce Camera3StreamConfig","version":7,"mbox":"https://patchwork.libcamera.org/series/1525/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/10643/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/10643/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 2FB0DBD80A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 11 Dec 2020 09:53:50 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id ED4446346D;\n\tFri, 11 Dec 2020 10:53:49 +0100 (CET)","from mail-pl1-x643.google.com (mail-pl1-x643.google.com\n\t[IPv6:2607:f8b0:4864:20::643])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E0CB86346D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 11 Dec 2020 10:53:46 +0100 (CET)","by mail-pl1-x643.google.com with SMTP id bj5so4336019plb.4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 11 Dec 2020 01:53:46 -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\ta17sm8363364pgw.80.2020.12.11.01.53.43\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 11 Dec 2020 01:53:44 -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=\"hkvj0clT\"; 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=yoK5XFHb4HhZWfB4dpOlsDWxHSKmTJdiIr+Nywe5htw=;\n\tb=hkvj0clTbHToFNIvlV2FkKDsw98qFt8AF5iJ/B7Eqdw4wnkkfzoL62GNktSj93YVtj\n\tett/DSHE5mbV8+uqi9+7u87xOE/+CZXi1v/qbqEpuJNA5ZFaY6QQZugHvKTwkwU4GQ5p\n\tRzOZ9ng+h87Y4Wpe+284DcRqXpjvJe9yi5Nh4=","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=yoK5XFHb4HhZWfB4dpOlsDWxHSKmTJdiIr+Nywe5htw=;\n\tb=fxYva9ab/VjxQI7wDB1zI4Mr6s+bZwH82yOThnXcO/aoW2f8Q9OzSSUWxbsWi2tZbh\n\tVuwtTHVM4vWVNvfTsX7/rHb0dWp10ZQFVA7YteGjwCDIj9a7D3kY1ScTdUnqDPXTDHV6\n\t4/HKnuINbOECYr05ICzAPe0wFN5cVB8er7KmbYxC1DIXG+3iDGKfTU8F+xGOjm3fFaGP\n\tMk6jipMPkR6qv3BND22s9rLMpgXzfMS7Ha0ylmvQXqfXknarSaxtnUfAGwdCSiJ6aI/Z\n\t3rx0kJZw41bZhwTHEYKHLsSneyvrZnhZgfpog+S8iaC3EGmpXN3tXLB1RchzaP9Uukbw\n\t0vvg==","X-Gm-Message-State":"AOAM530a2nAHGwS47kwDu5yIYInhGNGZXmrEtKdHjHAAxPTekwQJ6Tlz\n\thfLWoEMRI8Bfw3gxcETddVxrRHQKcLhFTtcN","X-Google-Smtp-Source":"ABdhPJx6UfOTyL07m2KOI3kXBWF4V33TkiSlzkDi0zOWMIZgNCCfOkmEZAx5iDK+kYCZuqihWsBM9w==","X-Received":"by 2002:a17:90a:970b:: with SMTP id\n\tx11mr12334836pjo.16.1607680425310; \n\tFri, 11 Dec 2020 01:53:45 -0800 (PST)","From":"Hirokazu Honda <hiroh@chromium.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Fri, 11 Dec 2020 09:53:35 +0000","Message-Id":"<20201211095336.40500-2-hiroh@chromium.org>","X-Mailer":"git-send-email 2.29.2.576.ga3fc446d84-goog","In-Reply-To":"<20201211095336.40500-1-hiroh@chromium.org>","References":"<20201211095336.40500-1-hiroh@chromium.org>","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH v7 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>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nReviewed-by: Umang Jain <email@uajain.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/android/camera_device.cpp | 48 ++++++++++++++++++++---------------\n 1 file changed, 28 insertions(+), 20 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 f4a6fb6b..7e8b2818 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -1264,6 +1264,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@@ -1294,14 +1297,11 @@ 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, 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@@ -1310,8 +1310,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+\t\tfor (size_t i = 0; i < streamConfigs.size(); ++i) {\n+\t\t\tconst auto &cfg = streamConfigs[i].config;\n\n \t\t\t/*\n \t\t\t * \\todo The PixelFormat must also be compatible with\n@@ -1334,28 +1334,36 @@ 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, type });\n+\t}\n+\n+\tfor (const auto &streamConfig : streamConfigs) {\n+\t\tconfig_->addConfiguration(streamConfig.config);\n+\n+\t\tfor (auto &stream : streamConfig.streams) {\n+\t\t\tstreams_.emplace_back(this, stream.type, stream.stream,\n+\t\t\t\t\t      config_->size() - 1);\n+\t\t\tstream.stream->priv = static_cast<void *>(&streams_.back());\n+\t\t}\n \t}\n\n \tswitch (config_->validate()) {\n","prefixes":["libcamera-devel","v7","2/3"]}