1 | // Copyright (C) 2021 The Qt Company Ltd. |
---|---|
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #ifndef QCAMERAIMAGECAPTURECONTROL_H |
5 | #define QCAMERAIMAGECAPTURECONTROL_H |
6 | |
7 | // |
8 | // W A R N I N G |
9 | // ------------- |
10 | // |
11 | // This file is not part of the Qt API. It exists purely as an |
12 | // implementation detail. This header file may change from version to |
13 | // version without notice, or even be removed. |
14 | // |
15 | // We mean it. |
16 | // |
17 | |
18 | #include <QtMultimedia/qimagecapture.h> |
19 | #include <QtMultimedia/qmediametadata.h> |
20 | #include <QtMultimedia/qimagecapture.h> |
21 | #include <QtCore/private/qglobal_p.h> |
22 | |
23 | QT_BEGIN_NAMESPACE |
24 | |
25 | class QImage; |
26 | class QPlatformMediaCaptureSession; |
27 | |
28 | class QImageEncoderSettingsPrivate; |
29 | class Q_MULTIMEDIA_EXPORT QImageEncoderSettings |
30 | { |
31 | QImageCapture::FileFormat m_format = QImageCapture::UnspecifiedFormat; |
32 | QSize m_resolution; |
33 | QImageCapture::Quality m_quality = QImageCapture::NormalQuality; |
34 | |
35 | public: |
36 | bool operator==(const QImageEncoderSettings &other) { |
37 | return m_format == other.m_format && |
38 | m_resolution == other.m_resolution && |
39 | m_quality == other.m_quality; |
40 | } |
41 | bool operator!=(const QImageEncoderSettings &other) { return !operator==(other); } |
42 | |
43 | QImageCapture::FileFormat format() const { return m_format; } |
44 | void setFormat(QImageCapture::FileFormat f) { m_format = f; } |
45 | |
46 | QSize resolution() const { return m_resolution; } |
47 | void setResolution(const QSize &s) { m_resolution = s; } |
48 | void setResolution(int width, int height) { m_resolution = QSize(width, height); } |
49 | |
50 | QImageCapture::Quality quality() const { return m_quality; } |
51 | void setQuality(QImageCapture::Quality quality) { m_quality = quality; } |
52 | }; |
53 | |
54 | class Q_MULTIMEDIA_EXPORT QPlatformImageCapture : public QObject |
55 | { |
56 | Q_OBJECT |
57 | |
58 | public: |
59 | virtual bool isReadyForCapture() const = 0; |
60 | |
61 | virtual int capture(const QString &fileName) = 0; |
62 | virtual int captureToBuffer() = 0; |
63 | |
64 | virtual QImageEncoderSettings imageSettings() const = 0; |
65 | virtual void setImageSettings(const QImageEncoderSettings &settings) = 0; |
66 | |
67 | virtual void setMetaData(const QMediaMetaData &m) { m_metaData = m; } |
68 | QMediaMetaData metaData() const { return m_metaData; } |
69 | |
70 | QImageCapture *imageCapture() { return m_imageCapture; } |
71 | |
72 | static QString msgCameraNotReady(); |
73 | static QString msgImageCaptureNotSet(); |
74 | |
75 | Q_SIGNALS: |
76 | void readyForCaptureChanged(bool ready); |
77 | |
78 | void imageExposed(int requestId); |
79 | void imageCaptured(int requestId, const QImage &preview); |
80 | void imageMetadataAvailable(int id, const QMediaMetaData &); |
81 | void imageAvailable(int requestId, const QVideoFrame &buffer); |
82 | void imageSaved(int requestId, const QString &fileName); |
83 | |
84 | void error(int id, int error, const QString &errorString); |
85 | |
86 | protected: |
87 | explicit QPlatformImageCapture(QImageCapture *parent = nullptr); |
88 | private: |
89 | QImageCapture *m_imageCapture = nullptr; |
90 | QMediaMetaData m_metaData; |
91 | }; |
92 | |
93 | QT_END_NAMESPACE |
94 | |
95 | |
96 | #endif // QCAMERAIMAGECAPTURECONTROL_H |
97 | |
98 |