-
Notifications
You must be signed in to change notification settings - Fork 11
/
gphotocamera.cpp
729 lines (606 loc) · 23.2 KB
/
gphotocamera.cpp
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
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
#include <QCameraImageCapture>
#include <QThread>
#include <QFileInfo>
#include "gphotocamera.h"
namespace {
constexpr auto capturingFailLimit = 10;
constexpr auto cancelautofocusParameter = "cancelautofocus";
constexpr auto viewfinderParameter = "viewfinder";
constexpr auto waitForEventTimeout = 10;
}
using CameraWidgetPtr = std::unique_ptr<CameraWidget, int (*)(CameraWidget*)>;
using VoidPtr = std::unique_ptr<void, void (*)(void*)>;
QDebug operator<<(QDebug dbg, const CameraWidgetType &t)
{
switch (t) {
case GP_WIDGET_WINDOW:
dbg.nospace() << "GP_WIDGET_WINDOW";
break;
case GP_WIDGET_SECTION:
dbg.nospace() << "GP_WIDGET_SECTION";
break;
case GP_WIDGET_TEXT:
dbg.nospace() << "GP_WIDGET_TEXT";
break;
case GP_WIDGET_RANGE:
dbg.nospace() << "GP_WIDGET_RANGE";
break;
case GP_WIDGET_TOGGLE:
dbg.nospace() << "GP_WIDGET_TOGGLE";
break;
case GP_WIDGET_RADIO:
dbg.nospace() << "GP_WIDGET_RADIO";
break;
case GP_WIDGET_MENU:
dbg.nospace() << "GP_WIDGET_MENU";
break;
case GP_WIDGET_BUTTON:
dbg.nospace() << "GP_WIDGET_BUTTON";
break;
case GP_WIDGET_DATE:
dbg.nospace() << "GP_WIDGET_DATE";
break;
}
return dbg.space();
}
GPhotoCamera::GPhotoCamera(GPContext *context, const CameraAbilities &abilities,
const GPPortInfo &portInfo, int index, QObject *parent)
: QObject(parent)
, m_context(context)
, m_abilities(abilities)
, m_portInfo(portInfo)
, m_camera(nullptr, gp_camera_free)
, m_file(nullptr, gp_file_free)
, m_index(index)
{
connect(this, &GPhotoCamera::previewCaptured, this, &GPhotoCamera::capturePreview, Qt::QueuedConnection);
}
void GPhotoCamera::setIndex(int index)
{
if (m_index != index)
m_index = index;
}
GPhotoCamera::~GPhotoCamera()
{
closeCamera();
}
void GPhotoCamera::setState(QCamera::State state)
{
if (m_state == state)
return;
auto previousState = m_state;
if (QCamera::UnloadedState == previousState) {
if (QCamera::LoadedState == state) {
openCamera();
} else if (QCamera::ActiveState == state) {
startViewFinder();
}
} else if (QCamera::LoadedState == previousState) {
if (QCamera::UnloadedState == state) {
closeCamera();
} else if (QCamera::ActiveState == state) {
startViewFinder();
}
} else if (QCamera::ActiveState == previousState) {
if (QCamera::UnloadedState == state) {
closeCamera();
} else if (QCamera::LoadedState == state) {
stopViewFinder();
}
}
}
void GPhotoCamera::setCaptureMode(QCamera::CaptureModes captureMode)
{
if (m_captureMode != captureMode) {
m_captureMode = captureMode;
emit captureModeChanged(m_index, captureMode);
}
}
void GPhotoCamera::capturePhoto(int id, const QString &fileName)
{
if (!isReadyForCapture()) {
emit imageCaptureError(m_index, id, QCameraImageCapture::NotReadyError, tr("Camera is not ready"));
return;
}
setMirrorPosition(MirrorPosition::Down);
// Capture the frame from camera
// See https://github.com/gphoto/libgphoto2/issues/156 for RAW+JPEG fix
auto ret = gp_camera_trigger_capture(m_camera.get(), m_context);
if (ret < GP_OK) {
qWarning() << "GPhoto: Failed to capture frame:" << ret;
emit imageCaptureError(m_index, id, QCameraImageCapture::ResourceError, tr("Failed to capture frame"));
return;
}
CameraEvent event;
auto done = false;
do {
event = waitForNextEvent(1000); // todo: How long to wait for long exposures?
if (GP_EVENT_FILE_ADDED == event.event) {
// Download the file
CameraFile* file = nullptr;
gp_file_new(&file);
// Unique pointer will free memory on exit
auto filePtr = CameraFilePtr(file, gp_file_free);
auto ret = gp_camera_file_get(m_camera.get(), event.folderName.toLatin1(), event.fileName.toLatin1(),
GP_FILE_TYPE_NORMAL, file, m_context);
if (ret < GP_OK) {
qWarning() << "GPhoto: Failed to get file from camera:" << ret;
emit imageCaptureError(m_index, id, QCameraImageCapture::ResourceError, tr("Failed to download file from camera"));
} else {
const char* data = nullptr;
unsigned long int size = 0;
ret = gp_file_get_data_and_size(file, &data, &size);
if (ret < GP_OK) {
qWarning() << "GPhoto: Failed to get file data and size from camera:" << ret;
emit imageCaptureError(m_index, id, QCameraImageCapture::ResourceError, tr("Failed to download file from camera"));
} else {
auto format = QFileInfo(event.fileName).suffix();
if (fileName.isEmpty()) {
// no proposal file name
emit imageCaptured(m_index, id, QByteArray(data, int(size)), format, fileName);
} else {
if (QFileInfo(fileName).suffix() == format) {
// extension matches, so use proposed name:
emit imageCaptured(m_index, id, QByteArray(data, int(size)), format, fileName);
} else {
// other extension, so use empty name
emit imageCaptured(m_index, id, QByteArray(data, int(size)), format, QString());
}
}
}
}
} else if (GP_EVENT_CAPTURE_COMPLETE == event.event) {
done = true;
}
} while (!done);
setMirrorPosition(MirrorPosition::Up);
}
QVariant GPhotoCamera::parameter(const QString &name)
{
CameraWidget *root = nullptr;
auto ret = gp_camera_get_config(m_camera.get(), &root, m_context);
if (ret < GP_OK) {
qWarning() << "GPhoto: Unable to get root option from gphoto while getting parameter" << qPrintable(name);
return QVariant();
}
CameraWidget *option = nullptr;
ret = gp_widget_get_child_by_name(root, qPrintable(name), &option);
if (ret < GP_OK) {
qWarning() << "GPhoto: Unable to get config widget from gphoto";
return QVariant();
}
// Unique pointer will free memory on exit
auto optionPtr = CameraWidgetPtr(option, gp_widget_free);
CameraWidgetType type;
ret = gp_widget_get_type(option, &type);
if (ret < GP_OK) {
qWarning() << "GPhoto: Unable to get config widget type from gphoto";
return QVariant();
}
if (type == GP_WIDGET_RADIO) {
char *value;
ret = gp_widget_get_value(option, &value);
if (ret < GP_OK) {
qWarning() << "GPhoto: Unable to get value for option" << qPrintable(name) << "from gphoto";
return QVariant();
}
return QString::fromLocal8Bit(value);
}
if (type == GP_WIDGET_TOGGLE) {
auto value = 0;
ret = gp_widget_get_value(option, &value);
if (ret < GP_OK) {
qWarning() << "GPhoto: Unable to get value for option" << qPrintable(name) << "from gphoto";
return QVariant();
}
return value != 0;
}
qWarning() << "GPhoto: Options of type" << type << "are currently not supported";
return QVariant();
}
bool GPhotoCamera::setParameter(const QString &name, const QVariant &value)
{
CameraWidget *root = nullptr;
auto ret = gp_camera_get_config(m_camera.get(), &root, m_context);
if (ret < GP_OK) {
qWarning() << "GPhoto: Unable to get root option from gphoto while setting parameter" << qPrintable(name);
return false;
}
// Get widget pointer
CameraWidget *option = nullptr;
ret = gp_widget_get_child_by_name(root, qPrintable(name), &option);
if (ret < GP_OK) {
qWarning() << "GPhoto: Unable to get option" << qPrintable(name) << "from gphoto";
return false;
}
// Unique pointer will free memory on exit
auto optionPtr = CameraWidgetPtr(option, gp_widget_free);
// Get option type
CameraWidgetType type;
ret = gp_widget_get_type(option, &type);
if (ret < GP_OK) {
qWarning() << "GPhoto: Unable to get option type from gphoto";
return false;
}
if (type == GP_WIDGET_RADIO) {
if (value.type() == QVariant::String) {
// String, need no conversion
ret = gp_widget_set_value(option, qPrintable(value.toString()));
if (ret < GP_OK) {
qWarning() << "GPhoto: Failed to set value" << value << "to" << name << "option:" << ret;
return false;
}
ret = gp_camera_set_config(m_camera.get(), root, m_context);
if (ret < GP_OK) {
qWarning() << "GPhoto: Failed to set config to camera";
return false;
}
waitForOperationCompleted();
return true;
}
if (value.type() == QVariant::Double) {
// Trying to find nearest possible value (with the distance of 0.1) and set it to property
auto v = value.toDouble();
auto count = gp_widget_count_choices(option);
for (auto i = 0; i < count; ++i) {
const char *choice = nullptr;
gp_widget_get_choice(option, i, &choice);
// We use a workaround for flawed russian i18n of gphoto2 strings
auto ok = false;
auto choiceValue = QString::fromLocal8Bit(choice).replace(',', '.').toDouble(&ok);
if (!ok) {
qDebug() << "GPhoto: Failed to convert value" << choice << "to double";
continue;
}
if (qAbs(choiceValue - v) < 0.1) {
ret = gp_widget_set_value(option, choice);
if (ret < GP_OK) {
qWarning() << "GPhoto: Failed to set value" << choice << "to" << name << "option:" << ret;
return false;
}
ret = gp_camera_set_config(m_camera.get(), root, m_context);
if (ret < GP_OK) {
qWarning() << "GPhoto: Failed to set config to camera";
return false;
}
waitForOperationCompleted();
return true;
}
}
qWarning() << "GPhoto: Can't find value matching to" << v << "for option" << name;
return false;
}
if (value.type() == QVariant::Int) {
// Little hacks for 'ISO' option: if the value is -1, we pick the first non-integer value
// we found and set it as a parameter
auto v = value.toInt();
auto count = gp_widget_count_choices(option);
for (auto i = 0; i < count; ++i) {
const char *choice = nullptr;
gp_widget_get_choice(option, i, &choice);
auto ok = false;
auto choiceValue = QString::fromLocal8Bit(choice).toInt(&ok);
if ((ok && choiceValue == v) || (!ok && v == -1)) {
ret = gp_widget_set_value(option, choice);
if (ret < GP_OK) {
qWarning() << "GPhoto: Failed to set value" << choice << "to" << name << "option:" << ret;
return false;
}
ret = gp_camera_set_config(m_camera.get(), root, m_context);
if (ret < GP_OK) {
qWarning() << "GPhoto: Failed to set config to camera";
return false;
}
waitForOperationCompleted();
return true;
}
}
qWarning() << "GPhoto: Can't find value matching to" << v << "for option" << name;
return false;
}
qWarning() << "GPhoto: Failed to set value" << value << "to" << name << "option. Type" << value.type()
<< "is not supported";
return false;
}
if (type == GP_WIDGET_TOGGLE) {
auto v = 0;
if (value.canConvert<int>()) {
v = value.toInt();
} else {
qWarning() << "GPhoto: Failed to set value" << value << "to" << name << "option. Type" << value.type()
<< "is not supported";
return false;
}
ret = gp_widget_set_value(option, &v);
if (ret < GP_OK) {
qWarning() << "GPhoto: Failed to set value" << v << "to" << name << "option:" << ret;
return false;
}
ret = gp_camera_set_config(m_camera.get(), root, m_context);
if (ret < GP_OK) {
qWarning() << "GPhoto: Failed to set config to camera";
return false;
}
waitForOperationCompleted();
return true;
}
qWarning() << "GPhoto: Options of type" << type << "are currently not supported";
return false;
}
QVariantList GPhotoCamera::parameterValues(const QString &name, QMetaType::Type valueType)
{
CameraWidget *root = nullptr;
auto ret = gp_camera_get_config(m_camera.get(), &root, m_context);
if (ret < GP_OK) {
qWarning() << "GPhoto: Unable to get root option from gphoto while setting parameter" << qPrintable(name);
return {};
}
// Get widget pointer
CameraWidget *option = nullptr;
ret = gp_widget_get_child_by_name(root, qPrintable(name), &option);
if (ret < GP_OK) {
qWarning() << "GPhoto: Unable to get option" << qPrintable(name) << "from gphoto";
return {};
}
// Unique pointer will free memory on exit
auto optionPtr = CameraWidgetPtr(option, gp_widget_free);
// Get option type
CameraWidgetType type;
ret = gp_widget_get_type(option, &type);
if (ret < GP_OK) {
qWarning() << "GPhoto: Unable to get option type from gphoto";
return {};
}
QVariantList values;
if (GP_WIDGET_RANGE == type) {
auto min = 0.0F;
auto max = 0.0F;
auto step = 0.0F;
ret = gp_widget_get_range(option, &min, &max, &step);
if (ret < GP_OK) {
qWarning() << "GPhoto: Unable to get widget range from gphoto";
return {};
}
values.append(min);
while (min < max)
values.append(min += step);
values.append(max);
} else if (GP_WIDGET_RADIO == type) {
auto count = gp_widget_count_choices(option);
for (auto i = 0; i < count; ++i) {
const char *choice = nullptr;
gp_widget_get_choice(option, i, &choice);
const auto &str = QString::fromLocal8Bit(choice);
auto ok = false;
QVariant value;
switch (valueType) {
case QMetaType::Double:
// We use a workaround for flawed russian i18n of gphoto2 strings
value = QString(str).replace(',', '.').toDouble(&ok);
if (!ok) {
qWarning() << "GPhoto: Failed to convert value" << choice << "to double";
continue;
}
break;
case QMetaType::Int:
value = str.toInt(&ok);
if (!ok) {
qWarning() << "GPhoto: Failed to convert value" << choice << "to int";
continue;
}
break;
case QMetaType::QString:
value = str;
break;
default:
qWarning() << "GPhoto: Failed to convert unsupported value" << choice;
continue;
}
values.append(value);
}
}
return values;
}
void GPhotoCamera::capturePreview()
{
if (m_status != QCamera::ActiveStatus)
return;
gp_file_clean(m_file.get());
auto ret = gp_camera_capture_preview(m_camera.get(), m_file.get(), m_context);
if (GP_OK == ret) {
const char *data = nullptr;
unsigned long int size = 0;
ret = gp_file_get_data_and_size(m_file.get(), &data, &size);
if (GP_OK == ret) {
m_capturingFailCount = 0;
if (!QThread::currentThread()->isInterruptionRequested()) {
auto image = QImage::fromData(QByteArray(data, int(size)));
emit previewCaptured(m_index, image);
}
return;
}
}
qWarning() << "GPhoto: Failed retrieving preview" << ret;
++m_capturingFailCount;
if (capturingFailLimit < m_capturingFailCount) {
qWarning() << "GPhoto: Closing camera because of capturing fail";
emit error(m_index, QCamera::CameraError, tr("Unable to capture frame"));
closeCamera();
}
}
void GPhotoCamera::openCamera()
{
// Camera is already open
if (m_camera)
return;
setStatus(QCamera::LoadingStatus);
// Create camera object
Camera *camera;
auto ret = gp_camera_new(&camera);
if (ret != GP_OK) {
openCameraErrorHandle(QLatin1String("Unable to open camera"));
return;
}
auto cameraPtr = CameraPtr(camera, gp_camera_free);
ret = gp_camera_set_abilities(camera, m_abilities);
if (ret < GP_OK) {
openCameraErrorHandle(QLatin1String("Unable to set abilities for camera"));
return;
}
ret = gp_camera_set_port_info(camera, m_portInfo);
if (ret < GP_OK) {
openCameraErrorHandle(QLatin1String("Unable to set port info for camera"));
return;
}
CameraFile *file;
gp_file_new(&file);
m_file.reset(file);
m_camera = std::move(cameraPtr);
m_capturingFailCount = 0;
setStatus(QCamera::LoadedStatus);
}
void GPhotoCamera::closeCamera()
{
// Camera is already closed
if (!m_camera)
return;
if (QCamera::ActiveStatus == m_status)
stopViewFinder();
setStatus(QCamera::UnloadingStatus);
gp_file_clean(m_file.get());
m_file.reset();
gp_camera_exit(m_camera.get(), m_context);
m_camera.reset();
setStatus(QCamera::UnloadedStatus);
}
void GPhotoCamera::startViewFinder()
{
openCamera();
if (QCamera::ActiveStatus == m_status)
return;
setStatus(QCamera::StartingStatus);
setMirrorPosition(MirrorPosition::Up);
setStatus(QCamera::ActiveStatus);
capturePreview();
}
void GPhotoCamera::stopViewFinder()
{
if (m_status == QCamera::LoadedStatus)
return;
setStatus(QCamera::StoppingStatus);
setMirrorPosition(MirrorPosition::Down);
setStatus(QCamera::LoadedStatus);
}
void GPhotoCamera::setMirrorPosition(MirrorPosition pos)
{
if (parameter(QLatin1String(cancelautofocusParameter)).isValid()) {
setParameter(QLatin1String(cancelautofocusParameter), true);
}
if (parameter(QLatin1String(viewfinderParameter)).isValid()) {
auto up = (MirrorPosition::Up == pos);
if (!setParameter(QLatin1String(viewfinderParameter), up))
qWarning() << "GPhoto: Failed to flap" << (up ? "up" : "down") << "camera mirror";
}
}
bool GPhotoCamera::isReadyForCapture() const
{
if (m_captureMode & QCamera::CaptureStillImage)
return (QCamera::ActiveStatus == m_status || QCamera::LoadedStatus == m_status);
return false;
}
void GPhotoCamera::openCameraErrorHandle(const QString &errorText)
{
qWarning() << "GPhoto:" << qPrintable(errorText);
setStatus(QCamera::UnavailableStatus);
emit error(m_index, QCamera::CameraError, tr("Unable to open camera"));
}
void GPhotoCamera::logOption(const char *name)
{
CameraWidget *root;
auto ret = gp_camera_get_config(m_camera.get(), &root, m_context);
if (ret < GP_OK) {
qWarning() << "GPhoto: Unable to get root option from gphoto";
return;
}
CameraWidget *option;
ret = gp_widget_get_child_by_name(root, name, &option);
if (ret < GP_OK)
qWarning() << "GPhoto: Unable to get config widget from gphoto";
// Unique pointer will free memory on exit
auto optionPtr = CameraWidgetPtr(option, gp_widget_free);
CameraWidgetType type;
ret = gp_widget_get_type(option, &type);
if (ret < GP_OK)
qWarning() << "GPhoto: Unable to get config widget type from gphoto";
char *value;
ret = gp_widget_get_value(option, &value);
if (ret < GP_OK)
qWarning() << "GPhoto: Unable to get widget value from gphoto";
qDebug() << "GPhoto: Option" << type << name << value;
if (type == GP_WIDGET_RADIO) {
auto count = gp_widget_count_choices(option);
qDebug() << "GPhoto: Choices count:" << count;
for (auto i = 0; i < count; ++i) {
const char *choice = nullptr;
gp_widget_get_choice(option, i, &choice);
qDebug() << " value:" << choice;
}
}
}
void GPhotoCamera::waitForOperationCompleted()
{
CameraEventType type;
auto ret = GP_OK;
do {
auto dataPtr = VoidPtr(nullptr, free);
auto data = dataPtr.get();
ret = gp_camera_wait_for_event(m_camera.get(), waitForEventTimeout, &type, &data, m_context);
} while ((ret == GP_OK) && (type != GP_EVENT_TIMEOUT) && m_camera);
}
GPhotoCamera::CameraEvent GPhotoCamera::waitForNextEvent(int timeout)
{
CameraEvent event;
auto dataPtr = VoidPtr(nullptr, free);
auto data = dataPtr.get();
CameraEventType eventType = GP_EVENT_UNKNOWN;
auto ret = gp_camera_wait_for_event(m_camera.get(), timeout, &eventType, &data, m_context);
if (ret != GP_OK || GP_EVENT_UNKNOWN == eventType) {
// according to implementation of gp_camera_wait_for_event();
// if i dont get OK, no event type & data is updated.
return event;
}
event.event = eventType;
if (data) {
// if we have data, it depends on the event type whats inside...
if (GP_EVENT_FILE_ADDED == eventType || GP_EVENT_FILE_CHANGED == eventType) {
auto file = reinterpret_cast<CameraFilePath*>(data);
event.folderName = QString::fromLatin1(file->folder);
event.fileName = QString::fromLatin1(file->name);
} else if (GP_EVENT_FOLDER_ADDED == eventType) {
auto folder= reinterpret_cast<CameraFilePath*>(data);
event.folderName = QString::fromLatin1(folder->folder);
}
}
// qDebug() << "Got gphoto camera event:" << event.event << event.folderName << event.fileName;
return event;
}
void GPhotoCamera::setStatus(QCamera::Status status)
{
if (m_status != status) {
m_status = status;
if (QCamera::LoadedStatus == m_status) {
m_state = QCamera::LoadedState;
emit stateChanged(m_index, m_state);
emit readyForCaptureChanged(m_index, isReadyForCapture());
} else if (QCamera::ActiveStatus == m_status) {
m_state = QCamera::ActiveState;
emit stateChanged(m_index, m_state);
emit readyForCaptureChanged(m_index, isReadyForCapture());
} else if (QCamera::UnloadedStatus == m_status || QCamera::UnavailableStatus == m_status) {
m_state = QCamera::UnloadedState;
emit stateChanged(m_index, m_state);
emit readyForCaptureChanged(m_index, isReadyForCapture());
}
emit statusChanged(m_index, status);
}
}