-
Notifications
You must be signed in to change notification settings - Fork 1
/
cameradevice.h
324 lines (215 loc) · 8.96 KB
/
cameradevice.h
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
#ifndef CAMERADEVICE_H
#define CAMERADEVICE_H
#include <QtCore>
#include <QBluetoothDeviceDiscoveryAgent>
#include <QBluetoothDeviceInfo>
#include <QLowEnergyController>
#include <QBluetoothUuid>
#include <QtQmlIntegration/qqmlintegration.h>
QT_BEGIN_NAMESPACE
class QBluetoothDeviceInfo;
class QBluetoothUuid;
QT_END_NAMESPACE
class CameraDevice: public QObject
{
Q_OBJECT
Q_PROPERTY(bool controllerError READ hasControllerError NOTIFY controllerErrorChanged FINAL)
Q_PROPERTY(bool recording READ recording NOTIFY recordingChanged FINAL)
Q_PROPERTY(bool playing READ playing NOTIFY playingChanged FINAL)
Q_PROPERTY(bool connected READ isConnected NOTIFY connectedChanged FINAL)
Q_PROPERTY(QString name READ name NOTIFY nameChanged FINAL)
Q_PROPERTY(int status READ status NOTIFY statusChanged FINAL)
Q_PROPERTY(int wb READ wb NOTIFY wbChanged FINAL)
Q_PROPERTY(int tint READ tint NOTIFY tintChanged FINAL)
Q_PROPERTY(double aperture READ apterture NOTIFY apertureChanged FINAL)
Q_PROPERTY(int iso READ iso NOTIFY isoChanged)
Q_PROPERTY(int shutterSpeed READ shutterSpeed NOTIFY shutterSpeedChanged FINAL)
Q_PROPERTY(int zoom READ zoom NOTIFY zoomChanged FINAL)
Q_PROPERTY(QTime timecode READ timecode NOTIFY timecodeChanged FINAL)
Q_PROPERTY(bool timecodeDisplay READ timecodeDisplay NOTIFY timecodeDisplayChanged FINAL)
Q_PROPERTY(qint8 metaTakeNumber READ metaTakeNumber NOTIFY metaTakeNumberChanged FINAL)
Q_PROPERTY(QString metaScene READ metaScene NOTIFY metaSceneChanged FINAL)
Q_PROPERTY(QString metaCameraID READ metaCameraID NOTIFY metaCameraIDChanged FINAL)
Q_PROPERTY(QString metaCameraOperator READ metaCameraOperator NOTIFY metaCameraOperatorChanged FINAL)
Q_PROPERTY(QString metaDirector READ metaDirector NOTIFY metaDirectorChanged FINAL)
Q_PROPERTY(QString metaProjectName READ metaProjectName NOTIFY metaProjectNameChanged FINAL)
Q_PROPERTY(QString metaLensType READ metaLensType NOTIFY metaLensTypeChanged FINAL)
Q_PROPERTY(QString metaLensIris READ metaLensIris NOTIFY metaLensIrisChanged FINAL)
Q_PROPERTY(QString metaLensFocal READ metaLensFocal NOTIFY metaLensFocalChanged FINAL)
Q_PROPERTY(QString metaLensDistance READ metaLensDistance NOTIFY metaLensDistanceChanged FINAL)
Q_PROPERTY(QString metaLensFilter READ metaLensFilter NOTIFY metaLensFilterChanged FINAL)
Q_PROPERTY(QString metaSlateTarget READ metaSlateTarget NOTIFY metaSlateTargetChanged FINAL)
QML_ELEMENT
QML_SINGLETON
public:
CameraDevice();
~CameraDevice();
bool isConnected() const;
bool discovering();
bool hasControllerError() const;
bool recording() const;
QTime timecode() const;
int status() const;
int wb() const;
int tint() const;
QString name() const;
int zoom() const;
double apterture() const;
bool playing() const;
int iso() const;
int shutterSpeed() const;
bool timecodeDisplay() const;
qint8 metaTakeNumber() const { return m_meta_take_number; }
QString metaScene() const { return m_meta_scene; }
QString metaCameraID() const { return m_meta_camera_id; }
QString metaCameraOperator() const { return m_meta_camera_operator; }
QString metaDirector() const { return m_meta_director; }
QString metaProjectName() const { return m_meta_project_name; }
QString metaLensType() const { return m_meta_lens_type; }
QString metaLensIris() const { return m_meta_lens_iris; }
QString metaLensFocal() const { return m_meta_lens_focal; }
QString metaLensDistance() const { return m_meta_lens_distance; }
QString metaLensFilter() const { return m_meta_lens_filter; }
QString metaSlateTarget() const { return m_meta_slate_target; }
public slots:
void connectDevice(QBluetoothDeviceInfo *device);
void disconnectFromDevice();
bool setCameraName(const QString name);
bool autoFocus();
bool autoAperture();
bool setShutterSpeed(qint32 shutter);
bool setGain(qint8 gain);
bool setISO(qint32 is);
bool setAperture(double ap);
bool setApertureNormalized(double ap);
bool setApertureStep(quint16 apstep);
bool colorCorrectionReset();
bool record(bool record);
bool play(bool play);
bool captureStill();
bool whiteBalance(qint16 wb, qint16 tint);
bool autoWhitebalance();
bool restoreAutoWhiteBalance();
bool focus(qint16 focus, bool relative=true);
bool zoom(double zoom);
bool playback(bool next);
bool colorLift(double r, double g, double b, double l);
bool colorGamma(double r, double g, double b, double l);
bool colorGain(double r, double g, double b, double l);
bool colorOffset(double r, double g, double b, double l);
bool setDisplay(bool tc);
private slots:
void scanServices(const QString &address);
void scanServices(const QBluetoothDeviceInfo &device);
void connectToService(const QString &uuid);
void addLowEnergyService(const QBluetoothUuid &uuid);
void deviceConnected();
void errorReceived(QLowEnergyController::Error);
void serviceScanDone();
void deviceDisconnected();
void serviceDetailsDiscovered(QLowEnergyService::ServiceState newState);
void characteristicChanged(QLowEnergyCharacteristic characteristic, QByteArray value);
void serviceStateChanged(QLowEnergyService::ServiceState s);
void confirmedDescriptorWrite(const QLowEnergyDescriptor &d, const QByteArray &value);
Q_SIGNALS:
void devicesUpdated();
void updateChanged();
void disconnected();
void connectionFailure();
void controllerErrorChanged();
void connectedChanged();
void recordingChanged();
void timecodeChanged();
void statusChanged();
void wbChanged();
void tintChanged();
void nameChanged();
void autoFocusTriggered();
void zoomChanged();
void apertureChanged();
void playingChanged();
void isoChanged();
void shutterSpeedChanged();
void timecodeDisplayChanged();
void metaTakeNumberChanged();
void metaSceneChanged();
void metaCameraIDChanged();
void metaCameraOperatorChanged();
void metaDirectorChanged();
void metaProjectNameChanged();
void metaLensTypeChanged();
void metaLensIrisChanged();
void metaLensFocalChanged();
void metaLensDistanceChanged();
void metaLensFilterChanged();
void metaSlateModeChanged();
void metaSlateTargetChanged();
protected:
void handleLensData(const QByteArray &data);
void handleVideoData(const QByteArray &data);
void handleAudioData(const QByteArray &data);
void handleOutputData(const QByteArray &data);
void handleMediaData(const QByteArray &data);
void handleDisplayData(const QByteArray &data);
void handleTallyData(const QByteArray &data);
void handleReferenceData(const QByteArray &data);
void handleConfigData(const QByteArray &data);
void handleColorData(const QByteArray &data);
void handleStatusData(const QByteArray &data);
void handleMetaData(const QByteArray &data);
bool colorControl(uint8_t c, double r, double g, double b, double l);
private:
bool writeCameraCommand(const QByteArray &cmd);
bool writeCameraName(const QString &name);
QBluetoothDeviceInfo *m_currentDevice=nullptr;
QHash<QString, QBluetoothDeviceInfo *> m_cameras;
QList<QLowEnergyService *> m_services;
QHash<QBluetoothUuid, QLowEnergyService *> m_servicess;
bool m_connected = false;
QLowEnergyController *m_controller = nullptr;
QLowEnergyService *m_cameraService = nullptr;
QLowEnergyCharacteristic *m_cameraOutgoing = nullptr;
QLowEnergyCharacteristic *m_cameraName = nullptr;
bool m_discovering = false;
// Camera state
QString m_name;
qint8 m_status = 0;
QTime m_timecode;
bool m_recording = false;
bool m_playing = false;
qint8 m_gain = 0;
qint32 m_iso = 100;
qint32 m_exposure = 0;
qint16 m_zoom = 0;
qint16 m_wb = 4600;
qint16 m_tint = 0;
qint32 m_shutterSpeed=0;
double m_aperture=0.0;
double m_aperture_norm=0.0;
qint8 m_autoExposureMode=1;
bool m_timecodeDisplay=false;
quint8 m_codec=0;
quint8 m_codec_variant=0;
quint8 m_media_speed=0;
quint8 m_media_slot_1;
quint8 m_media_slot_2;
qint16 m_meta_reel;
qint8 m_meta_tags;
qint8 m_meta_location;
qint8 m_meta_day;
QString m_meta_scene;
qint8 m_meta_take_number;
qint8 m_meta_take_tags;
QString m_meta_camera_id;
QString m_meta_camera_operator;
QString m_meta_director;
QString m_meta_project_name;
QString m_meta_lens_type;
QString m_meta_lens_iris;
QString m_meta_lens_focal;
QString m_meta_lens_distance;
QString m_meta_lens_filter;
qint8 m_meta_slate_mode;
QString m_meta_slate_target;
};
#endif // CAMERADEVICE_H