File indexing completed on 2024-04-21 14:46:12

0001 /*
0002     SPDX-FileCopyrightText: 2003-2017 Jasem Mutlaq <mutlaqja@ikarustech.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "indicamera.h"
0010 #include "ui_streamform.h"
0011 #include "ui_recordingoptions.h"
0012 #include "fitsviewer/bayer.h"
0013 #include <indidevapi.h>
0014 
0015 #include <QCloseEvent>
0016 #include <QColor>
0017 #include <QIcon>
0018 #include <QImage>
0019 #include <QPaintEvent>
0020 #include <QPixmap>
0021 #include <QResizeEvent>
0022 #include <QVBoxLayout>
0023 #include <QVector>
0024 
0025 class RecordOptions : public QDialog, public Ui::recordingOptions
0026 {
0027         Q_OBJECT
0028 
0029     public:
0030         explicit RecordOptions(QWidget *parent);
0031 
0032     public slots:
0033         void selectRecordDirectory();
0034 
0035     private:
0036         QUrl dirPath;
0037 
0038         friend class StreamWG;
0039 };
0040 
0041 class StreamWG : public QDialog, public Ui::streamForm
0042 {
0043         Q_OBJECT
0044 
0045     public:
0046         explicit StreamWG(ISD::Camera *ccd);
0047         virtual ~StreamWG() override;
0048 
0049         void setColorFrame(bool color);
0050         void setSize(int wd, int ht);
0051 
0052         void enableStream(bool enable);
0053         bool isStreamEnabled()
0054         {
0055             return processStream;
0056         }
0057 
0058         void newFrame(INDI::Property prop);
0059 
0060         int getStreamWidth()
0061         {
0062             return streamWidth;
0063         }
0064         int getStreamHeight()
0065         {
0066             return streamHeight;
0067         }
0068 
0069     protected:
0070         void closeEvent(QCloseEvent *ev) override;
0071         void showEvent(QShowEvent *ev) override;
0072         QSize sizeHint() const override;
0073 
0074     public slots:
0075         void toggleRecord();
0076         void updateRecordStatus(bool enabled);
0077         void resetFrame();
0078         void syncDebayerParameters();
0079 
0080     protected slots:
0081         void setStreamingFrame(QRect newFrame);
0082         void updateFPS(double instantFPS, double averageFPS);
0083 
0084     signals:
0085         void hidden();
0086         void imageChanged(const QSharedPointer<QImage> &frame);
0087 
0088     private:
0089         bool queryDebayerParameters();
0090 
0091         bool processStream;
0092         int streamWidth, streamHeight;
0093         bool colorFrame, isRecording;
0094         bool showOverlay = false;
0095         QIcon recordIcon, stopIcon;
0096         ISD::Camera *m_Camera {nullptr};
0097 
0098         // Debayer
0099         BayerParams m_DebayerParams;
0100         uint8_t m_BBP {8};
0101         uint16_t offsetX, offsetY;
0102         double pixelX, pixelY;
0103         bool m_DebayerActive { false }, m_DebayerSupported { false };
0104 
0105         // For Canon DSLRs
0106         INDI::Property *eoszoom {nullptr}, *eoszoomposition {nullptr};
0107 
0108         // Options panels
0109         RecordOptions *options;
0110 };