qtcamzoom.h qtcamflash.h qtcamscene.h qtcamevcomp.h qtcamvideotorch.h \
qtcamwhitebalance.h qtcamcolortone.h qtcamflickerreduction.h \
qtcamnoisereduction.h qtcamiso.h qtcamaperture.h qtcamexposure.h \
- qtcammute.h qtcamnotifications.h qtcamfocus.h qtcamcaf.h
+ qtcammute.h qtcamnotifications.h qtcamfocus.h qtcamcaf.h qtcamautofocus.h
SOURCES += qtcamconfig.cpp qtcamera.cpp qtcamscanner.cpp qtcamdevice.cpp qtcamviewfinder.cpp \
qtcammode.cpp qtcamgstreamermessagehandler.cpp qtcamgstreamermessagelistener.cpp \
qtcamzoom.cpp qtcamflash.cpp qtcamscene.cpp qtcamevcomp.cpp qtcamvideotorch.cpp \
qtcamwhitebalance.cpp qtcamcolortone.cpp qtcamflickerreduction.cpp \
qtcamnoisereduction.cpp qtcamiso.cpp qtcamaperture.cpp qtcamexposure.cpp \
- qtcammute.cpp qtcamnotifications.cpp qtcamfocus.cpp qtcamcaf.cpp
+ qtcammute.cpp qtcamnotifications.cpp qtcamfocus.cpp qtcamcaf.cpp qtcamautofocus.cpp
-HEADERS += qtcammode_p.h qtcamdevice_p.h qtcamcapability_p.h qtcamcaf_p.h
+HEADERS += qtcammode_p.h qtcamdevice_p.h qtcamcapability_p.h qtcamcaf_p.h qtcamautofocus_p.h
LIBS += -lgstphotography-0.10
--- /dev/null
+/*!
+ * This file is part of CameraPlus.
+ *
+ * Copyright (C) 2012 Mohammed Sameer <msameer@foolab.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "qtcamautofocus.h"
+#include "qtcamautofocus_p.h"
+
+QtCamAutoFocus::QtCamAutoFocus(QtCamDevice *dev, QObject *parent) :
+ QObject(parent),
+ d_ptr(new QtCamAutoFocusPrivate(dev, this, this)) {
+
+}
+
+QtCamAutoFocus::~QtCamAutoFocus() {
+ delete d_ptr; d_ptr = 0;
+}
+
+QtCamAutoFocus::Status QtCamAutoFocus::status() {
+ return d_ptr->status;
+}
+
+bool QtCamAutoFocus::start() {
+ return d_ptr->setEnabled(true);
+}
+
+bool QtCamAutoFocus::stop() {
+ return d_ptr->setEnabled(false);
+}
--- /dev/null
+// -*- c++ -*-
+
+/*!
+ * This file is part of CameraPlus.
+ *
+ * Copyright (C) 2012 Mohammed Sameer <msameer@foolab.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef QT_CAM_AUTO_FOCUS_H
+#define QT_CAM_AUTO_FOCUS_H
+
+#include <QObject>
+
+class QtCamDevice;
+class QtCamAutoFocusPrivate;
+
+class QtCamAutoFocus : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(Status status READ status NOTIFY statusChanged);
+ Q_ENUMS(Status);
+
+ friend class QtCamAutoFocusPrivate;
+
+public:
+ typedef enum {
+ None = 0,
+ Running = 1,
+ Fail = 2,
+ Success = 3,
+ } Status;
+
+ QtCamAutoFocus(QtCamDevice *dev, QObject *parent = 0);
+ ~QtCamAutoFocus();
+
+ Status status();
+
+ bool start();
+ bool stop();
+
+signals:
+ void statusChanged();
+
+private:
+ QtCamAutoFocusPrivate *d_ptr;
+};
+
+#endif /* QT_CAM_AUTO_FOCUS_H */
--- /dev/null
+// -*- c++ -*-
+
+/*!
+ * This file is part of CameraPlus.
+ *
+ * Copyright (C) 2012 Mohammed Sameer <msameer@foolab.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef QT_CAM_AUTO_FOCUS_P_H
+#define QT_CAM_AUTO_FOCUS_P_H
+
+#include "qtcamautofocus.h"
+#include "qtcamgstreamermessagehandler.h"
+#include "qtcamgstreamermessagelistener.h"
+#include "qtcamdevice.h"
+#include "qtcamdevice_p.h"
+
+#include <QDebug>
+
+#ifndef GST_USE_UNSTABLE_API
+#define GST_USE_UNSTABLE_API
+#endif /* GST_USE_UNSTABLE_API */
+#include <gst/interfaces/photography.h>
+
+class QtCamAutoFocusPrivate : public QObject {
+ Q_OBJECT
+
+public:
+ QtCamAutoFocusPrivate(QtCamDevice *device, QtCamAutoFocus *q, QObject *parent = 0) :
+ QObject(parent),
+ dev(device),
+ q_ptr(q),
+ status(QtCamAutoFocus::None) {
+
+ handler = new QtCamGStreamerMessageHandler(GST_PHOTOGRAPHY_AUTOFOCUS_DONE, this);
+
+ QObject::connect(handler, SIGNAL(messageSent(GstMessage *)),
+ this, SLOT(handleMessage(GstMessage *)));
+
+ dev->listener()->addHandler(handler);
+ }
+
+ ~QtCamAutoFocusPrivate() {
+ dev->listener()->removeHandler(handler);
+ delete handler; handler = 0;
+ dev = 0;
+ q_ptr = 0;
+ }
+
+ bool setEnabled(bool enabled) {
+ if (!dev->d_ptr->videoSource) {
+ return false;
+ }
+
+ if (!GST_IS_PHOTOGRAPHY(dev->d_ptr->videoSource)) {
+ return false;
+ }
+
+ GstPhotography *photo = GST_PHOTOGRAPHY(dev->d_ptr->videoSource);
+ if (!photo) {
+ return false;
+ }
+
+ gst_photography_set_autofocus(photo, enabled ? TRUE : FALSE);
+
+ return true;
+ }
+
+public slots:
+ void handleMessage(GstMessage *message) {
+ const GstStructure *s = gst_message_get_structure(message);
+ int st = GST_PHOTOGRAPHY_FOCUS_STATUS_NONE;
+
+ if (gst_structure_get_int(s, "status", &st)) {
+ if (status != st) {
+ status = (QtCamAutoFocus::Status) st;
+
+ // TODO: focus-window-rows, focus-window-columns, focus-windows and the rest
+ emit q_ptr->statusChanged();
+ }
+ }
+ }
+
+public:
+ QtCamDevice *dev;
+ QtCamAutoFocus *q_ptr;
+ QtCamAutoFocus::Status status;
+ QtCamGStreamerMessageHandler *handler;
+};
+
+#endif /* QT_CAM_AUTO_FOCUS_P_H */
class QtCamCafPrivate;
class QtCamCaf : public QObject {
-
Q_OBJECT
-
Q_PROPERTY(Status status READ status NOTIFY statusChanged);
Q_ENUMS(Status);
friend class QtCamCapability;
friend class QtCamVideoTorch;
friend class QtCamMute;
+ friend class QtCamAutoFocusPrivate;
QtCamDevicePrivate *d_ptr;
};