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
25QT_BEGIN_NAMESPACE
26
27class QFFmpegImageCapture : public QPlatformImageCapture
28{
29 Q_OBJECT
30public:
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 void cancelPendingImage(QImageCapture::Error error, const QString &errorMsg);
44
45protected:
46 virtual int doCapture(const QString &fileName);
47 virtual void setupVideoSourceConnections();
48 QPlatformVideoSource *videoSource() const;
49 void updateReadyForCapture();
50
51protected Q_SLOTS:
52 void newVideoFrame(const QVideoFrame &frame);
53 void onVideoSourceChanged();
54
55private:
56 QFFmpegMediaCaptureSession *m_session = nullptr;
57 QPointer<QPlatformVideoSource> m_videoSource;
58 int m_lastId = 0;
59 QImageEncoderSettings m_settings;
60
61 struct PendingImage {
62 int id;
63 QString filename;
64 QMediaMetaData metaData;
65 };
66
67 QQueue<PendingImage> m_pendingImages;
68 bool m_isReadyForCapture = false;
69};
70
71QT_END_NAMESPACE
72
73#endif // QFFMPEGIMAGECAPTURE_H
74

source code of qtmultimedia/src/plugins/multimedia/ffmpeg/qffmpegimagecapture_p.h