From 84ad104499d9efc0253dae1a60ee070ed375ad95 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Thu, 20 Oct 2022 00:44:55 +0300 Subject: Move test applications to src/apps/ The cam and qcam test application share code, currently through a crude hack that references the cam source files directly from the qcam meson.build file. To prepare for the introduction of hosting that code in a static library, move all applications to src/apps/. Signed-off-by: Laurent Pinchart Reviewed-by: Paul Elder Reviewed-by: Kieran Bingham --- src/apps/qcam/main_window.h | 133 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 src/apps/qcam/main_window.h (limited to 'src/apps/qcam/main_window.h') diff --git a/src/apps/qcam/main_window.h b/src/apps/qcam/main_window.h new file mode 100644 index 00000000..95b64124 --- /dev/null +++ b/src/apps/qcam/main_window.h @@ -0,0 +1,133 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * main_window.h - qcam - Main application window + */ + +#pragma once + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../cam/stream_options.h" + +#include "viewfinder.h" + +class QAction; + +class CameraSelectorDialog; +class Image; +class HotplugEvent; + +enum { + OptCamera = 'c', + OptHelp = 'h', + OptRenderer = 'r', + OptStream = 's', + OptVerbose = 'v', +}; + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + MainWindow(libcamera::CameraManager *cm, + const OptionsParser::Options &options); + ~MainWindow(); + + bool event(QEvent *e) override; + +private Q_SLOTS: + void quit(); + void updateTitle(); + + void switchCamera(); + void toggleCapture(bool start); + + void saveImageAs(); + void captureRaw(); + void processRaw(libcamera::FrameBuffer *buffer, + const libcamera::ControlList &metadata); + + void renderComplete(libcamera::FrameBuffer *buffer); + +private: + int createToolbars(); + + std::string chooseCamera(); + int openCamera(); + + int startCapture(); + void stopCapture(); + + void addCamera(std::shared_ptr camera); + void removeCamera(std::shared_ptr camera); + + int queueRequest(libcamera::Request *request); + void requestComplete(libcamera::Request *request); + void processCapture(); + void processHotplug(HotplugEvent *e); + void processViewfinder(libcamera::FrameBuffer *buffer); + + /* UI elements */ + QToolBar *toolbar_; + QAction *startStopAction_; + QPushButton *cameraSelectButton_; + QAction *saveRaw_; + ViewFinder *viewfinder_; + + QIcon iconPlay_; + QIcon iconStop_; + + QString title_; + QTimer titleTimer_; + + CameraSelectorDialog *cameraSelectorDialog_; + + /* Options */ + const OptionsParser::Options &options_; + + /* Camera manager, camera, configuration and buffers */ + libcamera::CameraManager *cm_; + std::shared_ptr camera_; + libcamera::FrameBufferAllocator *allocator_; + + std::unique_ptr config_; + std::map> mappedBuffers_; + + /* Capture state, buffers queue and statistics */ + bool isCapturing_; + bool captureRaw_; + libcamera::Stream *vfStream_; + libcamera::Stream *rawStream_; + std::map> freeBuffers_; + QQueue doneQueue_; + QQueue freeQueue_; + QMutex mutex_; /* Protects freeBuffers_, doneQueue_, and freeQueue_ */ + + uint64_t lastBufferTime_; + QElapsedTimer frameRateInterval_; + uint32_t previousFrames_; + uint32_t framesCaptured_; + + std::vector> requests_; +}; -- cgit v1.2.1