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 QGSTREAMERCAMERACONTROL_H
5#define QGSTREAMERCAMERACONTROL_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 <QHash>
19#include <private/qplatformcamera_p.h>
20#include <private/qmultimediautils_p.h>
21#include "qgstreamermediacapture_p.h"
22#include <qgst_p.h>
23
24QT_BEGIN_NAMESPACE
25
26class QGstreamerCamera : public QPlatformCamera
27{
28 Q_OBJECT
29public:
30 static QMaybe<QPlatformCamera *> create(QCamera *camera);
31
32 virtual ~QGstreamerCamera();
33
34 bool isActive() const override;
35 void setActive(bool active) override;
36
37 void setCamera(const QCameraDevice &camera) override;
38 bool setCameraFormat(const QCameraFormat &format) override;
39
40 QGstElement gstElement() const { return gstCameraBin.element(); }
41#if QT_CONFIG(gstreamer_photography)
42 GstPhotography *photography() const;
43#endif
44
45 void setFocusMode(QCamera::FocusMode mode) override;
46 bool isFocusModeSupported(QCamera::FocusMode mode) const override;
47
48 void setFlashMode(QCamera::FlashMode mode) override;
49 bool isFlashModeSupported(QCamera::FlashMode mode) const override;
50 bool isFlashReady() const override;
51
52 void setExposureMode(QCamera::ExposureMode) override;
53 bool isExposureModeSupported(QCamera::ExposureMode mode) const override;
54 void setExposureCompensation(float) override;
55 void setManualIsoSensitivity(int) override;
56 int isoSensitivity() const override;
57 void setManualExposureTime(float) override;
58 float exposureTime() const override;
59
60 bool isWhiteBalanceModeSupported(QCamera::WhiteBalanceMode mode) const override;
61 void setWhiteBalanceMode(QCamera::WhiteBalanceMode mode) override;
62 void setColorTemperature(int temperature) override;
63
64 QString v4l2Device() const { return m_v4l2Device; }
65 bool isV4L2Camera() const { return !m_v4l2Device.isEmpty(); }
66
67private:
68 QGstreamerCamera(QGstElement videotestsrc, QGstElement capsFilter, QGstElement videoconvert,
69 QGstElement videoscale, QCamera *camera);
70
71 void updateCameraProperties();
72#if QT_CONFIG(linux_v4l)
73 void initV4L2Controls();
74 int setV4L2ColorTemperature(int temperature);
75 bool setV4L2Parameter(quint32 id, qint32 value);
76 int getV4L2Parameter(quint32 id) const;
77
78 bool v4l2AutoWhiteBalanceSupported = false;
79 bool v4l2ColorTemperatureSupported = false;
80 bool v4l2AutoExposureSupported = false;
81 bool v4l2ManualExposureSupported = false;
82 qint32 v4l2MinColorTemp = 5600; // Daylight...
83 qint32 v4l2MaxColorTemp = 5600;
84 qint32 v4l2MinExposure = 0;
85 qint32 v4l2MaxExposure = 0;
86 qint32 v4l2MinExposureAdjustment = 0;
87 qint32 v4l2MaxExposureAdjustment = 0;
88 int v4l2FileDescriptor = -1;
89#endif
90
91 QCameraDevice m_cameraDevice;
92
93 QGstBin gstCameraBin;
94 QGstElement gstCamera;
95 QGstElement gstCapsFilter;
96 QGstElement gstDecode;
97 QGstElement gstVideoConvert;
98 QGstElement gstVideoScale;
99
100 bool m_active = false;
101 QString m_v4l2Device;
102};
103
104QT_END_NAMESPACE
105
106#endif // QGSTREAMERCAMERACONTROL_H
107

source code of qtmultimedia/src/plugins/multimedia/gstreamer/mediacapture/qgstreamercamera_p.h