4 * This file is part of CameraPlus.
6 * Copyright (C) 2012-2013 Mohammed Sameer <msameer@foolab.org>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 #ifndef QT_CAM_FLASH_P_H
24 #define QT_CAM_FLASH_P_H
27 #include "qtcamcapability_p.h"
28 #include "qtcamdevice.h"
29 #include "qtcamgstreamermessagelistener.h"
30 #include "qtcamgstreamermessagehandler.h"
33 // subdevsrc ./gst-libs/gst/camera/gstcamerasrc2.h
34 #define FLASH_STATUS_READY 0
35 #define FLASH_STATUS_NOT_READY 1
37 class QtCamFlashPrivate : public QObject, public QtCamCapabilityPrivate {
41 QtCamFlashPrivate(QtCamDevice *dev, QObject *parent = 0) :
43 QtCamCapabilityPrivate(dev, QtCamCapability::Flash, "flash-mode"),
48 ~QtCamFlashPrivate() {
53 QtCamGStreamerMessageListener *listener = dev->listener();
55 qWarning() << "Failed to get device listener. flash ready status will not be available";
59 QtCamGStreamerMessageHandler *handler = new QtCamGStreamerMessageHandler("flash-status", this);
60 QObject::connect(handler, SIGNAL(messageSent(GstMessage *)),
61 this, SLOT(messageSent(GstMessage *)));
62 listener->addHandler(handler);
65 bool isReady() const {
70 void flashReadyChanged();
73 void messageSent(GstMessage *message) {
74 const GstStructure *s = gst_message_get_structure(message);
75 if (QLatin1String("flash-status") != QLatin1String(gst_structure_get_name(s))) {
79 int status = FLASH_STATUS_NOT_READY;
80 if (!gst_structure_get_int(s, "status", &status)) {
84 bool newStatus = (status == FLASH_STATUS_READY);
86 if (ready != newStatus) {
88 emit flashReadyChanged();
96 #endif /* QT_CAM_FLASH_P_H */