{"id":27099,"url":"https://patchwork.libcamera.org/api/patches/27099/?format=json","web_url":"https://patchwork.libcamera.org/patch/27099/","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":"<20260629163017.863145-22-barnabas.pocze@ideasonboard.com>","date":"2026-06-29T16:29:44","name":"[RFC,v1,21/54] libcamera: camera: Add `StreamData`","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"2d5f69acde78670d76aafa94778b6666bc415af5","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/people/216/?format=json","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/27099/mbox/","series":[{"id":6025,"url":"https://patchwork.libcamera.org/api/series/6025/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=6025","date":"2026-06-29T16:29:23","name":"libcamera: Split requests and buffers","version":1,"mbox":"https://patchwork.libcamera.org/series/6025/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/27099/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/27099/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 8BFFAC3261\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 29 Jun 2026 16:31:08 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5A42765F96;\n\tMon, 29 Jun 2026 18:31:01 +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 CC90265F46\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 29 Jun 2026 18:30:25 +0200 (CEST)","from pb-laptop.local (185.221.140.128.nat.pool.zt.hu\n\t[185.221.140.128])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id A363AE91\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 29 Jun 2026 18:29:42 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"Vzzh3iR/\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1782750582;\n\tbh=GSAt56pEicC5fChkWf1srdN1G08/7viSQOP33NdqEok=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=Vzzh3iR/yFdI6Zg+qsYe9gpv4tWwrHjHLZCH/oB+KWnGwcZu8kGhKgqnpEMWiGbpq\n\tB3U1CurYTb5gCGaUCDDuXPmVUu+FcCwJQ5qPHtTbd7limFIw0rGC+E58WKp9WtXIIK\n\t9dkxAQW76/r8u9m3SWHxsdIaDOZaJjDGcov9Qfyg=","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Subject":"[RFC PATCH v1 21/54] libcamera: camera: Add `StreamData`","Date":"Mon, 29 Jun 2026 18:29:44 +0200","Message-ID":"<20260629163017.863145-22-barnabas.pocze@ideasonboard.com>","X-Mailer":"git-send-email 2.54.0","In-Reply-To":"<20260629163017.863145-1-barnabas.pocze@ideasonboard.com>","References":"<20260629163017.863145-1-barnabas.pocze@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Add an internal `StreamData` type that contains private data about the\nstreams of a camera. This currently replaces the separate `activeStreams_`\n`std::set`. The `streams_` member is not merged as that is exposed via\n`Camera::streams()`.\n\nSigned-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n---\n include/libcamera/internal/camera.h |  7 ++++++-\n src/libcamera/camera.cpp            | 29 ++++++++++++++++++++++-------\n 2 files changed, 28 insertions(+), 8 deletions(-)","diff":"diff --git a/include/libcamera/internal/camera.h b/include/libcamera/internal/camera.h\nindex 8a2e9ed589..43b6a6e4a2 100644\n--- a/include/libcamera/internal/camera.h\n+++ b/include/libcamera/internal/camera.h\n@@ -14,6 +14,7 @@\n #include <set>\n #include <stdint.h>\n #include <string>\n+#include <unordered_map>\n \n #include <libcamera/base/class.h>\n \n@@ -54,6 +55,10 @@ private:\n \t\tCameraRunning,\n \t};\n \n+\tstruct StreamData {\n+\t\tbool active = false;\n+\t};\n+\n \tbool isAcquired() const;\n \tbool isRunning() const;\n \tint isAccessAllowed(State state, bool allowDisconnected = false,\n@@ -68,7 +73,7 @@ private:\n \tstd::shared_ptr<PipelineHandler> pipe_;\n \tstd::string id_;\n \tstd::set<Stream *> streams_;\n-\tstd::set<const Stream *> activeStreams_;\n+\tstd::unordered_map<const Stream *, StreamData> streamData_;\n \n \tbool disconnected_;\n \tstd::atomic<State> state_;\ndiff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\nindex 93b9e603dd..aa5682f9d7 100644\n--- a/src/libcamera/camera.cpp\n+++ b/src/libcamera/camera.cpp\n@@ -934,6 +934,11 @@ Camera::Camera(std::unique_ptr<Private> d, const std::string &id,\n \t_d()->properties_.set(properties::PipelineHandler, _d()->pipe_->name());\n \t_d()->streams_ = streams;\n \t_d()->validator_ = std::make_unique<CameraControlValidator>(this);\n+\n+\tfor (const Stream *s : streams) {\n+\t\t[[maybe_unused]] auto [it, inserted] = _d()->streamData_.try_emplace(s);\n+\t\tASSERT(inserted);\n+\t}\n }\n \n Camera::~Camera()\n@@ -969,10 +974,11 @@ int Camera::exportFrameBuffers(Stream *stream,\n \tif (ret < 0)\n \t\treturn ret;\n \n-\tif (streams().find(stream) == streams().end())\n+\tauto it = d->streamData_.find(stream);\n+\tif (it == d->streamData_.end())\n \t\treturn -EINVAL;\n \n-\tif (d->activeStreams_.find(stream) == d->activeStreams_.end())\n+\tif (!it->second.active)\n \t\treturn -EINVAL;\n \n \treturn d->pipe_->invokeMethod(&PipelineHandler::exportFrameBuffers,\n@@ -1220,21 +1226,29 @@ int Camera::configure(CameraConfiguration *config)\n \tif (ret)\n \t\treturn ret;\n \n-\td->activeStreams_.clear();\n+\tauto resetStreamData = [&] {\n+\t\tfor (auto &[stream, data] : d->streamData_)\n+\t\t\tdata.active = false;\n+\t};\n+\tutils::scope_exit streamDataGuard(std::ref(resetStreamData));\n+\n+\tresetStreamData();\n \tfor (const StreamConfiguration &cfg : *config) {\n \t\tStream *stream = cfg.stream();\n-\t\tif (!stream) {\n+\t\tauto it = d->streamData_.find(stream);\n+\n+\t\tif (it == d->streamData_.end() || it->second.active) {\n \t\t\tLOG(Camera, Fatal)\n \t\t\t\t<< \"Pipeline handler failed to update stream configuration\";\n-\t\t\td->activeStreams_.clear();\n \t\t\treturn -EINVAL;\n \t\t}\n \n \t\tstream->configuration_ = cfg;\n-\t\td->activeStreams_.insert(stream);\n+\t\tit->second.active = true;\n \t}\n \n \td->setState(Private::CameraConfigured);\n+\tstreamDataGuard.release();\n \n \treturn 0;\n }\n@@ -1364,7 +1378,8 @@ int Camera::queueRequest(Request *request)\n \t}\n \n \tfor (const auto &[stream, buffer] : request->buffers()) {\n-\t\tif (d->activeStreams_.find(stream) == d->activeStreams_.end()) {\n+\t\tauto it = d->streamData_.find(stream);\n+\t\tif (it == d->streamData_.end() || !it->second.active) {\n \t\t\tLOG(Camera, Error) << \"Invalid request\";\n \t\t\treturn -EINVAL;\n \t\t}\n","prefixes":["RFC","v1","21/54"]}