Patch Detail
Show a patch.
GET /api/1.1/patches/22964/?format=api
{ "id": 22964, "url": "https://patchwork.libcamera.org/api/1.1/patches/22964/?format=api", "web_url": "https://patchwork.libcamera.org/patch/22964/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20250314202943.112109-5-mzamazal@redhat.com>", "date": "2025-03-14T20:29:32", "name": "[RFC,4/7] apps: cam: Add support for multiple sinks", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "a111703dd9dcae72eecced665cb0761b8b007f4c", "submitter": { "id": 177, "url": "https://patchwork.libcamera.org/api/1.1/people/177/?format=api", "name": "Milan Zamazal", "email": "mzamazal@redhat.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/22964/mbox/", "series": [ { "id": 5062, "url": "https://patchwork.libcamera.org/api/1.1/series/5062/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5062", "date": "2025-03-14T20:29:28", "name": "Support different outputs for cam streams", "version": 1, "mbox": "https://patchwork.libcamera.org/series/5062/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/22964/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/22964/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 BD2C9C32F7\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 14 Mar 2025 20:30:17 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4D52768956;\n\tFri, 14 Mar 2025 21:30:17 +0100 (CET)", "from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.133.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 112576894E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 14 Mar 2025 21:30:10 +0100 (CET)", "from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com\n\t(ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63])\n\tby relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n\tcipher=TLS_AES_256_GCM_SHA384) id us-mta-142-a5RqhAKANmipHIMP1M6xxw-1;\n\tFri, 14 Mar 2025 16:30:06 -0400", "from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com\n\t(mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com\n\t[10.30.177.40])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\tkey-exchange X25519 server-signature RSA-PSS (2048 bits)\n\tserver-digest SHA256) (No client certificate requested)\n\tby mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTPS id 885C819560AF; Fri, 14 Mar 2025 20:30:05 +0000 (UTC)", "from mzamazal-thinkpadp1gen7.tpbc.com (unknown [10.44.32.19])\n\tby mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTP id 02C001954B32; Fri, 14 Mar 2025 20:30:03 +0000 (UTC)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=redhat.com header.i=@redhat.com\n\theader.b=\"QlWpuQ4T\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1741984210;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tcontent-transfer-encoding:content-transfer-encoding:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=mTa4WA1lPtOXS3wfmXBW4JQBLLvsUIU3xGZw/Ji+tP0=;\n\tb=QlWpuQ4T/gZ7EJD5pWLuP4csjDe718A3Sd9qikJEWwb+oTwNAY6H+tUe8YhpSbAxZME3ro\n\tYaYWUIdpgT9TohJDHs2HBWp+oEhapPIERPrhqcZLryK2TewMgCknzcKmrAqWLMZ4tzqQOP\n\t7FKYYpCLwiu4yZ0CZgDzbEkyLoIKeyg=", "X-MC-Unique": "a5RqhAKANmipHIMP1M6xxw-1", "X-Mimecast-MFC-AGG-ID": "a5RqhAKANmipHIMP1M6xxw_1741984205", "From": "Milan Zamazal <mzamazal@redhat.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "Milan Zamazal <mzamazal@redhat.com>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>", "Subject": "[RFC PATCH 4/7] apps: cam: Add support for multiple sinks", "Date": "Fri, 14 Mar 2025 21:29:32 +0100", "Message-ID": "<20250314202943.112109-5-mzamazal@redhat.com>", "In-Reply-To": "<20250314202943.112109-1-mzamazal@redhat.com>", "References": "<20250314202943.112109-1-mzamazal@redhat.com>", "MIME-Version": "1.0", "X-Scanned-By": "MIMEDefang 3.0 on 10.30.177.40", "X-Mimecast-Spam-Score": "0", "X-Mimecast-MFC-PROC-ID": "1nUbPO54ro-I-hizt4eCRgpWSZ63TXjSRk-irIx56SI_1741984205", "X-Mimecast-Originator": "redhat.com", "Content-Transfer-Encoding": "8bit", "content-type": "text/plain; charset=\"US-ASCII\"; x-default=true", "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": "It would be useful if cam supported output to different sinks when run\nwith multiple streams. For example, a processed stream could be\ndisplayed while a raw stream would be sent to files. Or a processed\nstream could be output to PPM files while a raw stream to raw files.\n\nLet's start with replacing the single CameraSession::sink_ with a vector\nof sinks_. We put just the default sink there for now, more\nfunctionality will be added in followup patches.\n\nSigned-off-by: Milan Zamazal <mzamazal@redhat.com>\n---\n src/apps/cam/camera_session.cpp | 51 +++++++++++++++++++++------------\n src/apps/cam/camera_session.h | 2 +-\n 2 files changed, 33 insertions(+), 20 deletions(-)", "diff": "diff --git a/src/apps/cam/camera_session.cpp b/src/apps/cam/camera_session.cpp\nindex 937a56b5..54073cdf 100644\n--- a/src/apps/cam/camera_session.cpp\n+++ b/src/apps/cam/camera_session.cpp\n@@ -20,6 +20,7 @@\n \n #include \"capture_script.h\"\n #include \"file_sink.h\"\n+#include \"frame_sink.h\"\n #ifdef HAVE_KMS\n #include \"kms_sink.h\"\n #endif\n@@ -255,14 +256,17 @@ int CameraSession::start()\n \n \tcamera_->requestCompleted.connect(this, &CameraSession::requestComplete);\n \n+\tsinks_.clear();\n+\tstd::unique_ptr<FrameSink> defaultSink;\n #ifdef HAVE_KMS\n \tif (options_.isSet(OptDisplay))\n-\t\tsink_ = std::make_unique<KMSSink>(options_[OptDisplay].toString());\n+\t\tdefaultSink =\n+\t\t\tstd::make_unique<KMSSink>(options_[OptDisplay].toString());\n #endif\n \n #ifdef HAVE_SDL\n \tif (options_.isSet(OptSDL))\n-\t\tsink_ = std::make_unique<SDLSink>();\n+\t\tdefaultSink = std::make_unique<SDLSink>();\n #endif\n \n \tif (options_.isSet(OptFile)) {\n@@ -275,18 +279,21 @@ int CameraSession::start()\n \t\t\t\treturn ret;\n \t\t}\n \n-\t\tsink_ = std::move(sink);\n+\t\tdefaultSink = std::move(sink);\n \t}\n \n-\tif (sink_) {\n-\t\tret = sink_->configure(*config_);\n+\tif (defaultSink)\n+\t\tsinks_.push_back(std::move(defaultSink));\n+\n+\tfor (auto &sink : sinks_) {\n+\t\tret = sink->configure(*config_);\n \t\tif (ret < 0) {\n \t\t\tstd::cout << \"Failed to configure frame sink\"\n \t\t\t\t << std::endl;\n \t\t\treturn ret;\n \t\t}\n \n-\t\tsink_->requestProcessed.connect(this, &CameraSession::sinkRelease);\n+\t\tsink->requestProcessed.connect(this, &CameraSession::sinkRelease);\n \t}\n \n \tallocator_ = std::make_unique<FrameBufferAllocator>(camera_);\n@@ -300,13 +307,14 @@ void CameraSession::stop()\n \tif (ret)\n \t\tstd::cout << \"Failed to stop capture\" << std::endl;\n \n-\tif (sink_) {\n-\t\tret = sink_->stop();\n+\tfor (auto &sink : sinks_) {\n+\t\tret = sink->stop();\n \t\tif (ret)\n \t\t\tstd::cout << \"Failed to stop frame sink\" << std::endl;\n \t}\n \n-\tsink_.reset();\n+\tfor (auto &sink : sinks_)\n+\t\tsink.reset();\n \n \trequests_.clear();\n \n@@ -355,15 +363,15 @@ int CameraSession::startCapture()\n \t\t\t\treturn ret;\n \t\t\t}\n \n-\t\t\tif (sink_)\n-\t\t\t\tsink_->mapBuffer(buffer.get());\n+\t\t\tfor (auto &sink : sinks_)\n+\t\t\t\tsink->mapBuffer(buffer.get());\n \t\t}\n \n \t\trequests_.push_back(std::move(request));\n \t}\n \n-\tif (sink_) {\n-\t\tret = sink_->start();\n+\tfor (auto &sink : sinks_) {\n+\t\tret = sink->start();\n \t\tif (ret) {\n \t\t\tstd::cout << \"Failed to start frame sink\" << std::endl;\n \t\t\treturn ret;\n@@ -373,8 +381,8 @@ int CameraSession::startCapture()\n \tret = camera_->start();\n \tif (ret) {\n \t\tstd::cout << \"Failed to start capture\" << std::endl;\n-\t\tif (sink_)\n-\t\t\tsink_->stop();\n+\t\tfor (auto &sink : sinks_)\n+\t\t\tsink->stop();\n \t\treturn ret;\n \t}\n \n@@ -383,8 +391,8 @@ int CameraSession::startCapture()\n \t\tif (ret < 0) {\n \t\t\tstd::cerr << \"Can't queue request\" << std::endl;\n \t\t\tcamera_->stop();\n-\t\t\tif (sink_)\n-\t\t\t\tsink_->stop();\n+\t\t\tfor (auto &sink : sinks_)\n+\t\t\t\tsink->stop();\n \t\t\treturn ret;\n \t\t}\n \t}\n@@ -471,9 +479,14 @@ void CameraSession::processRequest(Request *request)\n \t\t}\n \t}\n \n-\tif (sink_) {\n-\t\tif (!sink_->processRequest(request))\n+\tfor (auto &sink : sinks_) {\n+\t\tif (!sink->processRequest(request)) {\n+\t\t\t/*\n+\t\t\t * \\todo What happens with the other sinks when the whole request\n+\t\t\t * gets requeued?\n+\t\t\t */\n \t\t\trequeue = false;\n+\t\t}\n \t}\n \n \tstd::cout << info.str() << std::endl;\ndiff --git a/src/apps/cam/camera_session.h b/src/apps/cam/camera_session.h\nindex 4442fd9b..056091e5 100644\n--- a/src/apps/cam/camera_session.h\n+++ b/src/apps/cam/camera_session.h\n@@ -64,7 +64,7 @@ private:\n \tstd::unique_ptr<CaptureScript> script_;\n \n \tstd::map<const libcamera::Stream *, std::string> streamNames_;\n-\tstd::unique_ptr<FrameSink> sink_;\n+\tstd::vector<std::unique_ptr<FrameSink>> sinks_;\n \tunsigned int cameraIndex_;\n \n \tuint64_t last_;\n", "prefixes": [ "RFC", "4/7" ] }