{"id":967,"url":"https://patchwork.libcamera.org/api/1.1/patches/967/?format=json","web_url":"https://patchwork.libcamera.org/patch/967/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/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":"<20190409192548.20325-13-jacopo@jmondi.org>","date":"2019-04-09T19:25:48","name":"[libcamera-devel,v4,12/12,HACK] still capture every 10 frames","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"96f174d333bc98230482daac68129b0799df7cee","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/1.1/people/3/?format=json","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/967/mbox/","series":[{"id":247,"url":"https://patchwork.libcamera.org/api/1.1/series/247/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=247","date":"2019-04-09T19:25:36","name":"libcamera: ipu3: Multiple streams support","version":4,"mbox":"https://patchwork.libcamera.org/series/247/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/967/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/967/checks/","tags":{},"headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay12.mail.gandi.net (relay12.mail.gandi.net\n\t[217.70.178.232])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 848D760DBD\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  9 Apr 2019 21:25:12 +0200 (CEST)","from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay12.mail.gandi.net (Postfix) with ESMTPSA id 2324D20000B;\n\tTue,  9 Apr 2019 19:25:11 +0000 (UTC)"],"From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Tue,  9 Apr 2019 21:25:48 +0200","Message-Id":"<20190409192548.20325-13-jacopo@jmondi.org>","X-Mailer":"git-send-email 2.21.0","In-Reply-To":"<20190409192548.20325-1-jacopo@jmondi.org>","References":"<20190409192548.20325-1-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v4 12/12] [HACK] still capture every 10\n\tframes","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","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>","X-List-Received-Date":"Tue, 09 Apr 2019 19:25:12 -0000"},"content":"Not for inclusion, just to demonstrate how an application could track\nits streams to their assigned usages.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/cam/main.cpp | 46 +++++++++++++++++++++++++++++++++++++++++++---\n 1 file changed, 43 insertions(+), 3 deletions(-)","diff":"diff --git a/src/cam/main.cpp b/src/cam/main.cpp\nindex 46aba728393c..fce694bf26d5 100644\n--- a/src/cam/main.cpp\n+++ b/src/cam/main.cpp\n@@ -28,6 +28,11 @@ std::map<Stream *, std::string> streamInfo;\n EventLoop *loop;\n BufferWriter *writer;\n \n+unsigned int streamCount = 0;\n+unsigned int outBuf = 0;\n+std::map<Stream *, StreamUsage::Role> streamMap;\n+CameraConfiguration config;\n+\n enum {\n \tOptCamera = 'c',\n \tOptCapture = 'C',\n@@ -129,6 +134,11 @@ static int prepareCameraConfig(CameraConfiguration *config)\n \t\treturn -EINVAL;\n \t}\n \n+\t/* Associate each stream returned by the Camera with its role. */\n+\tunsigned int i = 0;\n+\tfor (auto *stream : *config)\n+\t\tstreamMap[stream] = roles[i++].role();\n+\n \t/* Apply configuration explicitly requested. */\n \tCameraConfiguration::iterator it = config->begin();\n \tfor (auto const &value : streamOptions) {\n@@ -158,6 +168,7 @@ static int prepareCameraConfig(CameraConfiguration *config)\n \n static void requestComplete(Request *request, const std::map<Stream *, Buffer *> &buffers)\n {\n+\tstd::map<Stream *, Buffer *> map;\n \tstatic uint64_t now, last = 0;\n \tdouble fps = 0.0;\n \n@@ -196,13 +207,37 @@ static void requestComplete(Request *request, const std::map<Stream *, Buffer *>\n \t\treturn;\n \t}\n \n-\trequest->setBuffers(buffers);\n+\t/* Viewfinder in every request. */\n+\tfor (auto &b : buffers) {\n+\t\tStream *s = b.first;\n+\t\tif (streamMap[s] != StreamUsage::Role::Viewfinder)\n+\t\t\tcontinue;\n+\n+\t\tmap[s] = b.second;\n+\t}\n+\n+\t/* Still capture every ten requests. */\n+\tstreamCount++;\n+\tif (!(streamCount % 10)) {\n+\t\tstreamCount = 0;\n+\t\tfor (Stream *stream : config) {\n+\t\t\tif (streamMap[stream] != StreamUsage::Role::StillCapture)\n+\t\t\t\tcontinue;\n+\n+\t\t\tmap[stream] =\n+\t\t\t\t&stream->bufferPool().buffers()[outBuf];\n+\t\t\toutBuf = (outBuf + 1) %\n+\t\t\t\t stream->bufferPool().count();\n+\t\t\tbreak;\n+\t\t}\n+\t}\n+\n+\trequest->setBuffers(map);\n \tcamera->queueRequest(request);\n }\n \n static int capture()\n {\n-\tCameraConfiguration config;\n \tint ret;\n \n \tret = prepareCameraConfig(&config);\n@@ -246,8 +281,13 @@ static int capture()\n \t\t}\n \n \t\tstd::map<Stream *, Buffer *> map;\n-\t\tfor (Stream *stream : config)\n+\t\tfor (Stream *stream : config) {\n+\t\t\tif (streamMap[stream] != StreamUsage::Role::Viewfinder)\n+\t\t\t\tcontinue;\n+\n+\t\t\t/* Only require the viewfinder to begin with. */\n \t\t\tmap[stream] = &stream->bufferPool().buffers()[i];\n+\t\t}\n \n \t\tret = request->setBuffers(map);\n \t\tif (ret < 0) {\n","prefixes":["libcamera-devel","v4","12/12","HACK"]}