From patchwork Fri Dec 11 09:53:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 10643 X-Patchwork-Delegate: jacopo@jmondi.org Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 2FB0DBD80A for ; Fri, 11 Dec 2020 09:53:50 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id ED4446346D; Fri, 11 Dec 2020 10:53:49 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="hkvj0clT"; dkim-atps=neutral Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E0CB86346D for ; Fri, 11 Dec 2020 10:53:46 +0100 (CET) Received: by mail-pl1-x643.google.com with SMTP id bj5so4336019plb.4 for ; Fri, 11 Dec 2020 01:53:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yoK5XFHb4HhZWfB4dpOlsDWxHSKmTJdiIr+Nywe5htw=; b=hkvj0clTbHToFNIvlV2FkKDsw98qFt8AF5iJ/B7Eqdw4wnkkfzoL62GNktSj93YVtj ett/DSHE5mbV8+uqi9+7u87xOE/+CZXi1v/qbqEpuJNA5ZFaY6QQZugHvKTwkwU4GQ5p RzOZ9ng+h87Y4Wpe+284DcRqXpjvJe9yi5Nh4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yoK5XFHb4HhZWfB4dpOlsDWxHSKmTJdiIr+Nywe5htw=; b=fxYva9ab/VjxQI7wDB1zI4Mr6s+bZwH82yOThnXcO/aoW2f8Q9OzSSUWxbsWi2tZbh VuwtTHVM4vWVNvfTsX7/rHb0dWp10ZQFVA7YteGjwCDIj9a7D3kY1ScTdUnqDPXTDHV6 4/HKnuINbOECYr05ICzAPe0wFN5cVB8er7KmbYxC1DIXG+3iDGKfTU8F+xGOjm3fFaGP Mk6jipMPkR6qv3BND22s9rLMpgXzfMS7Ha0ylmvQXqfXknarSaxtnUfAGwdCSiJ6aI/Z 3rx0kJZw41bZhwTHEYKHLsSneyvrZnhZgfpog+S8iaC3EGmpXN3tXLB1RchzaP9Uukbw 0vvg== X-Gm-Message-State: AOAM530a2nAHGwS47kwDu5yIYInhGNGZXmrEtKdHjHAAxPTekwQJ6Tlz hfLWoEMRI8Bfw3gxcETddVxrRHQKcLhFTtcN X-Google-Smtp-Source: ABdhPJx6UfOTyL07m2KOI3kXBWF4V33TkiSlzkDi0zOWMIZgNCCfOkmEZAx5iDK+kYCZuqihWsBM9w== X-Received: by 2002:a17:90a:970b:: with SMTP id x11mr12334836pjo.16.1607680425310; Fri, 11 Dec 2020 01:53:45 -0800 (PST) Received: from hiroh.c.googlers.com.com (128.141.236.35.bc.googleusercontent.com. [35.236.141.128]) by smtp.gmail.com with ESMTPSA id a17sm8363364pgw.80.2020.12.11.01.53.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Dec 2020 01:53:44 -0800 (PST) From: Hirokazu Honda 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 Camera3StreamConfig in configureStreams() X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Use the newly introduced Camera3StreamConfig to associate the Android requested streams with the associated StreamConfiguration in a vector of configurations. This change prepares to sort the vector of configuration before using it to configure the Camera and populate the streams_ vector. No functional changes intended. Signed-off-by: Hirokazu Honda Reviewed-by: Jacopo Mondi Reviewed-by: Kieran Bingham Reviewed-by: Umang Jain Reviewed-by: Laurent Pinchart --- src/android/camera_device.cpp | 48 ++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 20 deletions(-) -- 2.29.2.576.ga3fc446d84-goog diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index f4a6fb6b..7e8b2818 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -1264,6 +1264,9 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list) streams_.clear(); streams_.reserve(stream_list->num_streams); + std::vector streamConfigs; + streamConfigs.reserve(stream_list->num_streams); + /* First handle all non-MJPEG streams. */ camera3_stream_t *jpegStream = nullptr; for (unsigned int i = 0; i < stream_list->num_streams; ++i) { @@ -1294,14 +1297,11 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list) continue; } - StreamConfiguration streamConfiguration; - streamConfiguration.size = size; - streamConfiguration.pixelFormat = format; - - config_->addConfiguration(streamConfiguration); - streams_.emplace_back(this, CameraStream::Type::Direct, - stream, config_->size() - 1); - stream->priv = static_cast(&streams_.back()); + Camera3StreamConfig streamConfig; + streamConfig.streams = { { stream, CameraStream::Type::Direct } }; + streamConfig.config.size = size; + streamConfig.config.pixelFormat = format; + streamConfigs.push_back(std::move(streamConfig)); } /* Now handle the MJPEG streams, adding a new stream if required. */ @@ -1310,8 +1310,8 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list) int index = -1; /* Search for a compatible stream in the non-JPEG ones. */ - for (unsigned int i = 0; i < config_->size(); i++) { - StreamConfiguration &cfg = config_->at(i); + for (size_t i = 0; i < streamConfigs.size(); ++i) { + const auto &cfg = streamConfigs[i].config; /* * \todo The PixelFormat must also be compatible with @@ -1334,28 +1334,36 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list) * introduce a new stream to satisfy the request requirements. */ if (index < 0) { - StreamConfiguration streamConfiguration; - /* * \todo The pixelFormat should be a 'best-fit' choice * and may require a validation cycle. This is not yet * handled, and should be considered as part of any * stream configuration reworks. */ - streamConfiguration.size.width = jpegStream->width; - streamConfiguration.size.height = jpegStream->height; - streamConfiguration.pixelFormat = formats::NV12; + Camera3StreamConfig streamConfig; + streamConfig.config.size.width = jpegStream->width; + streamConfig.config.size.height = jpegStream->height; + streamConfig.config.pixelFormat = formats::NV12; + streamConfigs.push_back(std::move(streamConfig)); - LOG(HAL, Info) << "Adding " << streamConfiguration.toString() + LOG(HAL, Info) << "Adding " << streamConfig.config.toString() << " for MJPEG support"; type = CameraStream::Type::Internal; - config_->addConfiguration(streamConfiguration); - index = config_->size() - 1; + index = streamConfigs.size() - 1; } - streams_.emplace_back(this, type, jpegStream, index); - jpegStream->priv = static_cast(&streams_.back()); + streamConfigs[index].streams.push_back({ jpegStream, type }); + } + + for (const auto &streamConfig : streamConfigs) { + config_->addConfiguration(streamConfig.config); + + for (auto &stream : streamConfig.streams) { + streams_.emplace_back(this, stream.type, stream.stream, + config_->size() - 1); + stream.stream->priv = static_cast(&streams_.back()); + } } switch (config_->validate()) {