| 1 | // Copyright (C) 2016 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 | |
| 5 | #ifndef QFFMPEGIMAGECAPTURE_H |
| 6 | #define QFFMPEGIMAGECAPTURE_H |
| 7 | |
| 8 | // |
| 9 | // W A R N I N G |
| 10 | // ------------- |
| 11 | // |
| 12 | // This file is not part of the Qt API. It exists purely as an |
| 13 | // implementation detail. This header file may change from version to |
| 14 | // version without notice, or even be removed. |
| 15 | // |
| 16 | // We mean it. |
| 17 | // |
| 18 | |
| 19 | #include <QtMultimedia/private/qplatformimagecapture_p.h> |
| 20 | #include <QtFFmpegMediaPluginImpl/private/qffmpegmediacapturesession_p.h> |
| 21 | |
| 22 | #include <QtCore/qpointer.h> |
| 23 | #include <qqueue.h> |
| 24 | |
| 25 | QT_BEGIN_NAMESPACE |
| 26 | |
| 27 | class QFFmpegImageCapture : public QPlatformImageCapture |
| 28 | { |
| 29 | Q_OBJECT |
| 30 | public: |
| 31 | QFFmpegImageCapture(QImageCapture *parent); |
| 32 | ~QFFmpegImageCapture() override; |
| 33 | |
| 34 | bool isReadyForCapture() const override; |
| 35 | int capture(const QString &fileName) override; |
| 36 | int captureToBuffer() override; |
| 37 | |
| 38 | QImageEncoderSettings imageSettings() const override; |
| 39 | void setImageSettings(const QImageEncoderSettings &settings) override; |
| 40 | |
| 41 | void setCaptureSession(QPlatformMediaCaptureSession *session); |
| 42 | |
| 43 | protected: |
| 44 | virtual int doCapture(const QString &fileName); |
| 45 | virtual void setupVideoSourceConnections(); |
| 46 | QPlatformVideoSource *videoSource() const; |
| 47 | void updateReadyForCapture(); |
| 48 | |
| 49 | protected Q_SLOTS: |
| 50 | void newVideoFrame(const QVideoFrame &frame); |
| 51 | void onVideoSourceChanged(); |
| 52 | |
| 53 | private: |
| 54 | QFFmpegMediaCaptureSession *m_session = nullptr; |
| 55 | QPointer<QPlatformVideoSource> m_videoSource; |
| 56 | int m_lastId = 0; |
| 57 | QImageEncoderSettings m_settings; |
| 58 | |
| 59 | struct PendingImage { |
| 60 | int id; |
| 61 | QString filename; |
| 62 | QMediaMetaData metaData; |
| 63 | }; |
| 64 | |
| 65 | QQueue<PendingImage> m_pendingImages; |
| 66 | bool m_isReadyForCapture = false; |
| 67 | }; |
| 68 | |
| 69 | QT_END_NAMESPACE |
| 70 | |
| 71 | #endif // QGSTREAMERCAPTURECORNTROL_H |
| 72 | |