@@ -98,28 +98,40 @@ static int configureStreams(Camera *camera, std::set<Stream *> &streams)
return camera->configureStreams(config);
}
-static void requestComplete(Request *request, const std::map<Stream *, Buffer *> &buffers)
+static void requestComplete(Request *request,
+ const std::map<Stream *, Buffer *> &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<Stream *> 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<Stream *, Buffer *>
return;
}
- request->setBuffers(buffers);
+ request->setBuffers(streamMap);
camera->queueRequest(request);
}
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 <jacopo@jmondi.org> --- src/cam/main.cpp | 42 +++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-)