blob: 7bb6d02d71f951f8d0158c8359c79e5488a48266 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QWASMCAMERA_H
#define QWASMCAMERA_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <private/qplatformcamera_p.h>
#include <private/qplatformvideodevices_p.h>
#include <common/qwasmvideooutput_p.h>
#include <QCameraDevice>
#include <QtCore/qloggingcategory.h>
#include <emscripten/val.h>
#include <emscripten/bind.h>
QT_BEGIN_NAMESPACE
Q_DECLARE_LOGGING_CATEGORY(qWasmCamera)
class QWasmMediaCaptureSession;
class QWasmCamera : public QPlatformCamera
{
Q_OBJECT
public:
explicit QWasmCamera(QCamera *camera);
~QWasmCamera();
bool isActive() const override;
void setActive(bool active) override;
void setCamera(const QCameraDevice &camera) override;
bool setCameraFormat(const QCameraFormat &format) override;
void setCaptureSession(QPlatformMediaCaptureSession *session) override;
void setFocusMode(QCamera::FocusMode mode) override;
bool isFocusModeSupported(QCamera::FocusMode mode) const override;
void setTorchMode(QCamera::TorchMode mode) override;
bool isTorchModeSupported(QCamera::TorchMode mode) const override;
void setExposureMode(QCamera::ExposureMode mode) override;
bool isExposureModeSupported(QCamera::ExposureMode mode) const override;
void setExposureCompensation(float bias) override;
void setManualExposureTime(float) override;
int isoSensitivity() const override;
void setManualIsoSensitivity(int) override;
bool isWhiteBalanceModeSupported(QCamera::WhiteBalanceMode mode) const override;
void setWhiteBalanceMode(QCamera::WhiteBalanceMode mode) override;
void setColorTemperature(int temperature) override;
QWasmVideoOutput *cameraOutput() { return m_cameraOutput.data(); }
Q_SIGNALS:
void cameraIsReady();
private:
void createCamera(const QCameraDevice &camera);
void updateCameraFeatures();
QCameraDevice m_cameraDev;
QWasmMediaCaptureSession *m_CaptureSession = nullptr;
bool m_cameraActive = false;
QScopedPointer <QWasmVideoOutput> m_cameraOutput;
emscripten::val supportedCapabilities = emscripten::val::object(); // browser
emscripten::val currentCapabilities = emscripten::val::object(); // camera track
emscripten::val currentSettings = emscripten::val::object(); // camera track
QCamera::TorchMode m_wasmTorchMode;
QCamera::ExposureMode m_wasmExposureMode;
float m_wasmExposureTime;
float m_wasmExposureCompensation;
int m_wasmIsoSensitivity;
QCamera::WhiteBalanceMode m_wasmWhiteBalanceMode;
int m_wasmColorTemperature;
bool m_cameraIsReady = false;
bool m_cameraShouldStartActive = false;
bool m_shouldBeActive = false;
};
QT_END_NAMESPACE
#endif // QWASMCAMERA_H
|