1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
|
/*
* ========================================================================== *
* *
* This file is part of the Openterface Mini KVM App QT version *
* *
* Copyright (C) 2024 <info@openterface.com> *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation version 3. *
* *
* This program is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
* ========================================================================== *
*/
#ifndef VIDEOPAGE_H
#define VIDEOPAGE_H
#include <QWidget>
#include <QComboBox>
#include <QLabel>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QSize>
#include <QMap>
#include <set>
#include "fontstyle.h"
#include "host/cameramanager.h"
#include <QSettings>
#include "globalsetting.h"
#include "global.h"
QT_BEGIN_NAMESPACE
class QCameraFormat;
QT_END_NAMESPACE
// Struct to represent a video format key, used for comparing and sorting video formats
// It includes resolution, frame rate range, and pixel format
struct VideoFormatKey {
QSize resolution;
int minFrameRate;
int maxFrameRate;
QVideoFrameFormat::PixelFormat pixelFormat;
bool operator<(const VideoFormatKey &other) const {
if (resolution.width() != other.resolution.width())
return resolution.width() < other.resolution.width();
if (resolution.height() != other.resolution.height())
return resolution.height() < other.resolution.height();
if (minFrameRate != other.minFrameRate)
return minFrameRate < other.minFrameRate;
if (maxFrameRate != other.maxFrameRate)
return maxFrameRate < other.maxFrameRate;
return pixelFormat < other.pixelFormat;
}
};
struct QSizeComparator {
bool operator()(const QSize& lhs, const QSize& rhs) const {
if (lhs.width() == rhs.width()) {
return lhs.height() > rhs.height(); // Compare heights in descending order
}
return lhs.width() > rhs.width(); // Compare widths in descending order
}
};
class VideoPage : public QWidget
{
Q_OBJECT
public:
explicit VideoPage(CameraManager *cameraManager, QWidget *parent = nullptr);
~VideoPage();
void setupUI();
void initVideoSettings();
void applyVideoSettings();
signals:
void videoSettingsChanged(int width, int height);
private:
CameraManager *m_cameraManager;
QSize m_currentResolution;
bool m_updatingFormats = false;
std::map<VideoFormatKey, QCameraFormat> videoFormatMap;
QLabel *videoLabel;
QLabel *resolutionsLabel;
QComboBox *videoFormatBox;
QLabel *framerateLabel;
QComboBox *fpsComboBox;
QLabel *formatLabel;
QComboBox *pixelFormatBox;
void populateResolutionBox(const QList<QCameraFormat> &videoFormats);
void setFpsRange(const std::set<int> &fpsValues);
QVariant boxValue(const QComboBox *) const;
void updatePixelFormats();
QCameraFormat getVideoFormat(const QSize &resolution, int desiredFrameRate, QVideoFrameFormat::PixelFormat pixelFormat) const;
};
#endif // VIDEOPAGE_H
|