From patchwork Wed Mar 20 16:30:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 775 Return-Path: Received: from relay12.mail.gandi.net (relay12.mail.gandi.net [217.70.178.232]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 614496135F for ; Wed, 20 Mar 2019 17:30:46 +0100 (CET) Received: from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay12.mail.gandi.net (Postfix) with ESMTPSA id F050620000F; Wed, 20 Mar 2019 16:30:45 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Wed, 20 Mar 2019 17:30:53 +0100 Message-Id: <20190320163055.22056-30-jacopo@jmondi.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190320163055.22056-1-jacopo@jmondi.org> References: <20190320163055.22056-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 29/31] src: cam: Handle multiple streams in request complete X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Mar 2019 16:30:47 -0000 Add support for requests with multiple streams in 'requestComplete()' method. Each stream content is optionally dumped to disk with its output name. Signed-off-by: Jacopo Mondi --- src/cam/main.cpp | 42 +++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/src/cam/main.cpp b/src/cam/main.cpp index 201dbda765fe..a2364ef92bad 100644 --- a/src/cam/main.cpp +++ b/src/cam/main.cpp @@ -98,28 +98,40 @@ static int configureStreams(Camera *camera, std::set &streams) return camera->configureStreams(config); } -static void requestComplete(Request *request, const std::map &buffers) +static void requestComplete(Request *request, + const std::map &streamMap) { static uint64_t last = 0; if (request->status() == Request::RequestCancelled) return; - Buffer *buffer = buffers.begin()->second; - - double fps = buffer->timestamp() - last; - fps = last && fps ? 1000000000.0 / fps : 0.0; - last = buffer->timestamp(); + Camera *camera = request->camera(); + std::set streams = camera->streams(); + for (const auto &completedStream : streamMap) { + Stream *stream = completedStream.first; + Buffer *buffer = completedStream.second; + + /* Dump the buffer content! */ + double fps = buffer->timestamp() - last; + fps = last && fps ? 1000000000.0 / fps : 0.0; + last = buffer->timestamp(); + + std::string streamName = stream == (*streams.begin()) ? + "output" : "viewfinder"; + std::cout << "stream: " << streamName + << " seq: " << std::setw(6) << std::setfill('0') + << buffer->sequence() + << " buf: " << buffer->index() + << " bytesused: " << buffer->bytesused() + << " timestamp: " << buffer->timestamp() + << " fps: " << std::fixed << std::setprecision(2) << fps + << std::endl; - std::cout << "seq: " << std::setw(6) << std::setfill('0') << buffer->sequence() - << " buf: " << buffer->index() - << " bytesused: " << buffer->bytesused() - << " timestamp: " << buffer->timestamp() - << " fps: " << std::fixed << std::setprecision(2) << fps - << std::endl; - if (writer) - writer->write(buffer); + if (writer) + writer->write(buffer, streamName); + } request = camera->createRequest(); if (!request) { @@ -127,7 +139,7 @@ static void requestComplete(Request *request, const std::map return; } - request->setBuffers(buffers); + request->setBuffers(streamMap); camera->queueRequest(request); }