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 | #ifndef QGSTREAMERIMAGECAPTURECONTROL_H |
5 | #define QGSTREAMERIMAGECAPTURECONTROL_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 <private/qplatformimagecapture_p.h> |
19 | #include <private/qmultimediautils_p.h> |
20 | #include "qgstreamermediacapture_p.h" |
21 | #include "qgstreamerbufferprobe_p.h" |
22 | |
23 | #include <qqueue.h> |
24 | |
25 | #include <qgst_p.h> |
26 | #include <gst/video/video.h> |
27 | |
28 | QT_BEGIN_NAMESPACE |
29 | |
30 | class QGstreamerImageCapture : public QPlatformImageCapture, private QGstreamerBufferProbe |
31 | |
32 | { |
33 | Q_OBJECT |
34 | public: |
35 | static QMaybe<QPlatformImageCapture *> create(QImageCapture *parent); |
36 | virtual ~QGstreamerImageCapture(); |
37 | |
38 | bool isReadyForCapture() const override; |
39 | int capture(const QString &fileName) override; |
40 | int captureToBuffer() override; |
41 | |
42 | QImageEncoderSettings imageSettings() const override; |
43 | void setImageSettings(const QImageEncoderSettings &settings) override; |
44 | |
45 | bool probeBuffer(GstBuffer *buffer) override; |
46 | |
47 | void setCaptureSession(QPlatformMediaCaptureSession *session); |
48 | |
49 | QGstElement gstElement() const { return bin.element(); } |
50 | |
51 | public Q_SLOTS: |
52 | void cameraActiveChanged(bool active); |
53 | void onCameraChanged(); |
54 | |
55 | private: |
56 | QGstreamerImageCapture(QGstElement videoconvert, QGstElement jpegenc, QGstElement jifmux, |
57 | QImageCapture *parent); |
58 | |
59 | void setResolution(const QSize &resolution); |
60 | int doCapture(const QString &fileName); |
61 | static gboolean saveImageFilter(GstElement *element, GstBuffer *buffer, GstPad *pad, void *appdata); |
62 | |
63 | QGstreamerMediaCapture *m_session = nullptr; |
64 | int m_lastId = 0; |
65 | QImageEncoderSettings m_settings; |
66 | |
67 | struct PendingImage { |
68 | int id; |
69 | QString filename; |
70 | QMediaMetaData metaData; |
71 | }; |
72 | |
73 | QQueue<PendingImage> pendingImages; |
74 | |
75 | QGstBin bin; |
76 | QGstElement queue; |
77 | QGstElement filter; |
78 | QGstElement videoConvert; |
79 | QGstElement encoder; |
80 | QGstElement muxer; |
81 | QGstElement sink; |
82 | QGstPad videoSrcPad; |
83 | |
84 | bool passImage = false; |
85 | bool cameraActive = false; |
86 | }; |
87 | |
88 | QT_END_NAMESPACE |
89 | |
90 | #endif // QGSTREAMERCAPTURECORNTROL_H |
91 |