summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-05-02 21:45:21 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-05-03 04:32:46 +0300
commit585252eae349ab2871c95a4e37c1e573d0d0d0a3 (patch)
treed897ab71743657d38eb140c1b64e1a198241369e
parent3d42c67aab49be609d871dc6980537557c0a7fe1 (diff)
qcam: Pass request metadata to DNG writer
The DNG writer will use the metadata to populate DNG tags. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
-rw-r--r--src/qcam/dng_writer.cpp1
-rw-r--r--src/qcam/dng_writer.h2
-rw-r--r--src/qcam/main_window.cpp18
-rw-r--r--src/qcam/main_window.h22
4 files changed, 32 insertions, 11 deletions
diff --git a/src/qcam/dng_writer.cpp b/src/qcam/dng_writer.cpp
index 7d51965d..b1984c66 100644
--- a/src/qcam/dng_writer.cpp
+++ b/src/qcam/dng_writer.cpp
@@ -101,6 +101,7 @@ static const std::map<PixelFormat, FormatInfo> formatInfo = {
int DNGWriter::write(const char *filename, const Camera *camera,
const StreamConfiguration &config,
+ const ControlList &metadata,
const FrameBuffer *buffer, const void *data)
{
const auto it = formatInfo.find(config.pixelFormat);
diff --git a/src/qcam/dng_writer.h b/src/qcam/dng_writer.h
index 88b21875..d74d73d0 100644
--- a/src/qcam/dng_writer.h
+++ b/src/qcam/dng_writer.h
@@ -12,6 +12,7 @@
#include <libcamera/buffer.h>
#include <libcamera/camera.h>
+#include <libcamera/controls.h>
#include <libcamera/stream.h>
using namespace libcamera;
@@ -21,6 +22,7 @@ class DNGWriter
public:
static int write(const char *filename, const Camera *camera,
const StreamConfiguration &config,
+ const ControlList &metadata,
const FrameBuffer *buffer, const void *data);
};
diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp
index 8720c6c6..7de08957 100644
--- a/src/qcam/main_window.cpp
+++ b/src/qcam/main_window.cpp
@@ -549,7 +549,7 @@ void MainWindow::captureRaw()
captureRaw_ = true;
}
-void MainWindow::processRaw(FrameBuffer *buffer)
+void MainWindow::processRaw(FrameBuffer *buffer, const ControlList &metadata)
{
#ifdef HAVE_DNG
QString defaultPath = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation);
@@ -559,7 +559,7 @@ void MainWindow::processRaw(FrameBuffer *buffer)
if (!filename.isEmpty()) {
const MappedBuffer &mapped = mappedBuffers_[buffer];
DNGWriter::write(filename.toStdString().c_str(), camera_.get(),
- rawStream_->configuration(), buffer,
+ rawStream_->configuration(), metadata, buffer,
mapped.memory);
}
#endif
@@ -586,7 +586,7 @@ void MainWindow::requestComplete(Request *request)
*/
{
QMutexLocker locker(&mutex_);
- doneQueue_.enqueue(request->buffers());
+ doneQueue_.enqueue({ request->buffers(), request->metadata() });
}
QCoreApplication::postEvent(this, new CaptureEvent);
@@ -599,22 +599,22 @@ void MainWindow::processCapture()
* if stopCapture() has been called while a CaptureEvent was posted but
* not processed yet. Return immediately in that case.
*/
- std::map<Stream *, FrameBuffer *> buffers;
+ CaptureRequest request;
{
QMutexLocker locker(&mutex_);
if (doneQueue_.isEmpty())
return;
- buffers = doneQueue_.dequeue();
+ request = doneQueue_.dequeue();
}
/* Process buffers. */
- if (buffers.count(vfStream_))
- processViewfinder(buffers[vfStream_]);
+ if (request.buffers_.count(vfStream_))
+ processViewfinder(request.buffers_[vfStream_]);
- if (buffers.count(rawStream_))
- processRaw(buffers[rawStream_]);
+ if (request.buffers_.count(rawStream_))
+ processRaw(request.buffers_[rawStream_], request.metadata_);
}
void MainWindow::processViewfinder(FrameBuffer *buffer)
diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h
index 295ecc53..59fa2d98 100644
--- a/src/qcam/main_window.h
+++ b/src/qcam/main_window.h
@@ -20,6 +20,7 @@
#include <libcamera/buffer.h>
#include <libcamera/camera.h>
#include <libcamera/camera_manager.h>
+#include <libcamera/controls.h>
#include <libcamera/framebuffer_allocator.h>
#include <libcamera/stream.h>
@@ -37,6 +38,23 @@ enum {
OptStream = 's',
};
+class CaptureRequest
+{
+public:
+ CaptureRequest()
+ {
+ }
+
+ CaptureRequest(const std::map<Stream *, FrameBuffer *> &buffers,
+ const ControlList &metadata)
+ : buffers_(buffers), metadata_(metadata)
+ {
+ }
+
+ std::map<Stream *, FrameBuffer *> buffers_;
+ ControlList metadata_;
+};
+
class MainWindow : public QMainWindow
{
Q_OBJECT
@@ -56,7 +74,7 @@ private Q_SLOTS:
void saveImageAs();
void captureRaw();
- void processRaw(FrameBuffer *buffer);
+ void processRaw(FrameBuffer *buffer, const ControlList &metadata);
void queueRequest(FrameBuffer *buffer);
@@ -103,7 +121,7 @@ private:
Stream *vfStream_;
Stream *rawStream_;
std::map<Stream *, QQueue<FrameBuffer *>> freeBuffers_;
- QQueue<std::map<Stream *, FrameBuffer *>> doneQueue_;
+ QQueue<CaptureRequest> doneQueue_;
QMutex mutex_; /* Protects freeBuffers_ and doneQueue_ */
uint64_t lastBufferTime_;