From patchwork Sat Dec 12 00:41:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 10652 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 957C6BD80A for ; Sat, 12 Dec 2020 01:31:41 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0B97E68054; Sat, 12 Dec 2020 02:31:41 +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="KwJFAE3M"; dkim-atps=neutral Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DE45268053 for ; Sat, 12 Dec 2020 02:31:38 +0100 (CET) Received: by mail-pg1-x544.google.com with SMTP id w4so8349563pgg.13 for ; Fri, 11 Dec 2020 17:31:38 -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=KwJFAE3MNkZBphNYC87+9UbYty5mYeW5guqwgSKGoN85veVZZutgcGaYqpsRPd4J10 Y8HtYJqZZlRyODcip/tkhO564/uNnQAEfg11qIPDymVW2/V76945i0rfVF7ifoqpo1j1 9b4QTr3ZHInCUhRPS4imDnsNufRo0DJBaVAe4= 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=V7fDL6fK/I7XGgAknCNFMoXDfh0wb1CQt24htZGb8T9Yl8jePEgOZ2AUFYbtoH3AKb 8/FC7dZR+1CUKWj4AulHoQiTf4sPfSUON/h08uc99MNnM4BU62hw9NrXFnXaiRH9f0IK G6owmu7GkY1maLRf+4cYgwM8upPO1XybUdPs6RJ5NQ2jiKv2LR7oV+S6a4zDHn9FZ8yp d63ivJQ8FLcgCzq94fvSpXW1vBWqhHNFRKNKcaEgbRWIdeD+EHybugrQNa42bPHuop7s 7RaBcsL58UBSk4XYdXzyOksO3+D1Vn1sU+RdT2apxfBWb6VPbCOG2104yPwYxtrN330Y sxpA== X-Gm-Message-State: AOAM531Gqjz0ZeLbDceOIh2on837sEbx2EFoKC8bRZp/CMZ8zQAQdAHO 8+X6crSErI9tb/RhVjGsyk8ylfoIVdptsl6R X-Google-Smtp-Source: ABdhPJzfqWiocUIvj+eIeyWhRYWXBRLqNN27rsD410zi/YIv3vjD81Wf+LUbK+AdA++oOV7ujg4Srw== X-Received: by 2002:a63:c04b:: with SMTP id z11mr13569054pgi.74.1607733717045; Fri, 11 Dec 2020 16:41:57 -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 x188sm11558534pfd.43.2020.12.11.16.41.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Dec 2020 16:41:56 -0800 (PST) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Sat, 12 Dec 2020 00:41:48 +0000 Message-Id: <20201212004149.158801-2-hiroh@chromium.org> X-Mailer: git-send-email 2.29.2.576.ga3fc446d84-goog In-Reply-To: <20201212004149.158801-1-hiroh@chromium.org> References: <20201212004149.158801-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v8 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()) {