Merged QtCamCaf and QtCamAutoFocus
authorMohammed Sameer <msameer@foolab.org>
Wed, 31 Oct 2012 00:57:53 +0000 (02:57 +0200)
committerMohammed Sameer <msameer@foolab.org>
Wed, 31 Oct 2012 00:57:53 +0000 (02:57 +0200)
lib/lib.pro
lib/qtcamautofocus.cpp
lib/qtcamautofocus.h
lib/qtcamautofocus_p.h
lib/qtcamcaf.cpp [deleted file]
lib/qtcamcaf.h [deleted file]
lib/qtcamcaf_p.h [deleted file]

index 87fcf44..163c55b 100644 (file)
@@ -18,7 +18,7 @@ HEADERS += qtcamconfig.h qtcamera.h qtcamscanner.h qtcamdevice.h qtcamviewfinder
            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 qtcamautofocus.h
+           qtcammute.h qtcamnotifications.h qtcamfocus.h qtcamautofocus.h
 
 SOURCES += qtcamconfig.cpp qtcamera.cpp qtcamscanner.cpp qtcamdevice.cpp qtcamviewfinder.cpp \
            qtcammode.cpp qtcamgstreamermessagehandler.cpp qtcamgstreamermessagelistener.cpp \
@@ -28,9 +28,9 @@ SOURCES += qtcamconfig.cpp qtcamera.cpp qtcamscanner.cpp qtcamdevice.cpp qtcamvi
            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 qtcamautofocus.cpp
+           qtcammute.cpp qtcamnotifications.cpp qtcamfocus.cpp qtcamautofocus.cpp
 
-HEADERS += qtcammode_p.h qtcamdevice_p.h qtcamcapability_p.h qtcamcaf_p.h qtcamautofocus_p.h
+HEADERS += qtcammode_p.h qtcamdevice_p.h qtcamcapability_p.h qtcamautofocus_p.h
 
 LIBS += -lgstphotography-0.10
 
index b1cdf53..c91c1fc 100644 (file)
@@ -35,10 +35,14 @@ QtCamAutoFocus::Status QtCamAutoFocus::status() {
   return d_ptr->status;
 }
 
-bool QtCamAutoFocus::start() {
+QtCamAutoFocus::Status QtCamAutoFocus::cafStatus() {
+  return d_ptr->cafStatus;
+}
+
+bool QtCamAutoFocus::startAutoFocus() {
   return d_ptr->setEnabled(true);
 }
 
-bool QtCamAutoFocus::stop() {
+bool QtCamAutoFocus::stopAutoFocus() {
   return d_ptr->setEnabled(false);
 }
index e201e2d..9255a2b 100644 (file)
@@ -31,6 +31,7 @@ class QtCamAutoFocusPrivate;
 class QtCamAutoFocus : public QObject {
   Q_OBJECT
   Q_PROPERTY(Status status READ status NOTIFY statusChanged);
+  Q_PROPERTY(Status cafStatus READ cafStatus NOTIFY cafStatusChanged);
   Q_ENUMS(Status);
 
   friend class QtCamAutoFocusPrivate;
@@ -47,12 +48,14 @@ public:
   ~QtCamAutoFocus();
 
   Status status();
+  Status cafStatus();
 
-  bool start();
-  bool stop();
+  bool startAutoFocus();
+  bool stopAutoFocus();
 
 signals:
   void statusChanged();
+  void cafStatusChanged();
 
 private:
   QtCamAutoFocusPrivate *d_ptr;
index 097305d..0558067 100644 (file)
@@ -44,7 +44,8 @@ public:
     QObject(parent),
     dev(device),
     q_ptr(q),
-    status(QtCamAutoFocus::None) {
+    status(QtCamAutoFocus::None),
+    cafStatus(QtCamAutoFocus::None) {
 
     handler = new QtCamGStreamerMessageHandler(GST_PHOTOGRAPHY_AUTOFOCUS_DONE, this);
 
@@ -52,6 +53,13 @@ public:
                     this, SLOT(handleMessage(GstMessage *)));
 
     dev->listener()->addHandler(handler);
+
+    cafHandler = new QtCamGStreamerMessageHandler("caf-update", this);
+
+    QObject::connect(cafHandler, SIGNAL(messageSent(GstMessage *)),
+                    this, SLOT(handleCafMessage(GstMessage *)));
+
+    dev->listener()->addHandler(cafHandler);
   }
 
   ~QtCamAutoFocusPrivate() {
@@ -80,26 +88,43 @@ public:
     return true;
   }
 
-public slots:
-  void handleMessage(GstMessage *message) {
+  bool setStatus(QtCamAutoFocus::Status *status, 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();
+      if (*status != st) {
+       *status = (QtCamAutoFocus::Status) st;
+       return true;
       }
     }
+
+    return false;
+  }
+
+public slots:
+  void handleMessage(GstMessage *message) {
+    if (setStatus(&status, message)) {
+      // TODO: focus-window-rows, focus-window-columns, focus-windows and the rest
+      emit q_ptr->statusChanged();
+    }
+  }
+
+  void handleCafMessage(GstMessage *message) {
+    if (setStatus(&cafStatus, message)) {
+      emit q_ptr->cafStatusChanged();
+    }
   }
 
 public:
   QtCamDevice *dev;
   QtCamAutoFocus *q_ptr;
+
   QtCamAutoFocus::Status status;
+  QtCamAutoFocus::Status cafStatus;
+
   QtCamGStreamerMessageHandler *handler;
+  QtCamGStreamerMessageHandler *cafHandler;
 };
 
 #endif /* QT_CAM_AUTO_FOCUS_P_H */
diff --git a/lib/qtcamcaf.cpp b/lib/qtcamcaf.cpp
deleted file mode 100644 (file)
index 9f4722b..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/*!
- * 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 "qtcamcaf.h"
-#include "qtcamdevice.h"
-#include "qtcamcaf_p.h"
-
-QtCamCaf::QtCamCaf(QtCamDevice *dev, QObject *parent) :
-  QObject(parent), d_ptr(new QtCamCafPrivate(dev, this, this)) {
-}
-
-QtCamCaf::~QtCamCaf() {
-  delete d_ptr; d_ptr = 0;
-}
-
-QtCamCaf::Status QtCamCaf::status() {
-  return d_ptr->status;
-}
diff --git a/lib/qtcamcaf.h b/lib/qtcamcaf.h
deleted file mode 100644 (file)
index 68510ed..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-// -*- 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_CAF_H
-#define QT_CAM_CAF_H
-
-#include <QObject>
-
-class QtCamDevice;
-class QtCamCafPrivate;
-
-class QtCamCaf : public QObject {
-  Q_OBJECT
-  Q_PROPERTY(Status status READ status NOTIFY statusChanged);
-  Q_ENUMS(Status);
-
-  friend class QtCamCafPrivate;
-
-public:
-  typedef enum {
-    None = 0,
-    Running = 1,
-    Fail = 2,
-    Success = 3,
-  } Status;
-
-  QtCamCaf(QtCamDevice *dev, QObject *parent = 0);
-  ~QtCamCaf();
-
-  Status status();
-
-signals:
-  void statusChanged();
-
-private:
-  QtCamCafPrivate *d_ptr;
-};
-
-#endif /* QT_CAM_CAF_H */
diff --git a/lib/qtcamcaf_p.h b/lib/qtcamcaf_p.h
deleted file mode 100644 (file)
index 62e525b..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-// -*- 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_CAF_P_H
-#define QT_CAM_CAF_P_H
-
-#include "qtcamcaf.h"
-#include "qtcamgstreamermessagehandler.h"
-#include "qtcamgstreamermessagelistener.h"
-#include "qtcamdevice.h"
-#include <QDebug>
-#ifndef GST_USE_UNSTABLE_API
-#define GST_USE_UNSTABLE_API
-#endif /* GST_USE_UNSTABLE_API */
-#include <gst/interfaces/photography.h>
-
-class QtCamCafPrivate : public QObject {
-  Q_OBJECT
-
-public:
-  QtCamCafPrivate(QtCamDevice *device, QtCamCaf *q, QObject *parent = 0) :
-    QObject(parent),
-    dev(device),
-    q_ptr(q),
-    status(QtCamCaf::None) {
-
-    handler = new QtCamGStreamerMessageHandler("caf-update", this);
-
-    QObject::connect(handler, SIGNAL(messageSent(GstMessage *)),
-                    this, SLOT(handleMessage(GstMessage *)));
-
-    dev->listener()->addHandler(handler);
-  }
-
-  ~QtCamCafPrivate() {
-    dev->listener()->removeHandler(handler);
-    delete handler; handler = 0;
-    dev = 0;
-    q_ptr = 0;
-  }
-
-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 = (QtCamCaf::Status) st;
-
-       emit q_ptr->statusChanged();
-      }
-    }
-  }
-
-public:
-  QtCamDevice *dev;
-  QtCamCaf *q_ptr;
-  QtCamCaf::Status status;
-  QtCamGStreamerMessageHandler *handler;
-};
-
-#endif /* QT_CAM_CAF_P_H */