Ignore the artist size limit. Will fix if someone complains!
[harmattan/cameraplus] / lib / qtcamdevice_p.h
index 914928b..aae2b33 100644 (file)
@@ -34,6 +34,8 @@ class QtCamGStreamerMessageListener;
 class QtCamMode;
 class QtCamImageMode;
 class QtCamVideoMode;
+class QtCamPropertySetter;
+class QtCamAnalysisBin;
 
 class QtCamDevicePrivate {
 public:
@@ -48,7 +50,7 @@ public:
     conf(0),
     error(false),
     notifications(0),
-    stopping(false) {
+    viewfinderFilters(0) {
 
   }
 
@@ -64,55 +66,57 @@ public:
     return elem;
   }
 
-  void createAndAddVideoSource() {
-    // TODO: rework this function
-    GstElement *src, *wrapper;
-    QString wrapperSrc = conf->wrapperVideoSource();
-    QString prop = conf->wrapperVideoSourceProperty();
-
-    if (!prop.isEmpty() && !wrapperSrc.isEmpty()) {
-      wrapper = gst_element_factory_make(wrapperSrc.toAscii(), "QCameraWrapperVideoSrc");
-      if (!wrapper) {
-       qCritical() << "Failed to create wrapper source" << wrapperSrc;
-       return;
-      }
-    }
+  void createAndAddVideoSourceAndWrapper() {
+    videoSource = gst_element_factory_make(conf->videoSource().toUtf8().constData(),
+                                          "QtCameraVideoSrc");
+    wrapperVideoSource = gst_element_factory_make(conf->wrapperVideoSource().toUtf8().constData(),
+                                                 "QCameraWrapperVideoSrc");
 
-    src = gst_element_factory_make(conf->videoSource().toAscii(),
-                                              "QtCameraVideoSrc");
-    if (!src) {
-      qCritical() << "Failed to create video source";
-      if (wrapper) {
-       gst_object_unref(wrapper);
-      }
-      return;
+    if (wrapperVideoSource && videoSource) {
+      g_object_set(wrapperVideoSource, conf->wrapperVideoSourceProperty().toUtf8().constData(),
+                  videoSource, NULL);
+      g_object_set(cameraBin, "camera-source", wrapperVideoSource, NULL);
     }
-
-    if (wrapper) {
-      g_object_set(wrapper, prop.toAscii(), src, NULL);
-      g_object_set(cameraBin, "camera-source", wrapper, NULL);
+    else if (wrapperVideoSource) {
+      qWarning() << "Failed to create video source";
+      g_object_set(cameraBin, "camera-source", wrapperVideoSource, NULL);
     }
-
-    videoSource = src;
-    wrapperVideoSource = wrapper;
-
-    if (!id.isValid() || id.isNull()) {
-      return;
+    else if (videoSource) {
+      qWarning() << "Failed to create wrapper source";
+      g_object_set(cameraBin, "camera-source", videoSource, NULL);
     }
+    else {
+      qWarning() << "Failed to create both video and wrapper sources";
+    }
+  }
 
-    if (conf->deviceScannerType() == SCANNER_TYPE_ENUM) {
-      int dev = id.toInt();
-      g_object_set(src, conf->deviceScannerProperty().toAscii().data(), dev, NULL);
+  void createAndAddVideoSource() {
+    videoSource = gst_element_factory_make(conf->videoSource().toUtf8().constData(),
+                                          "QtCameraVideoSrc");
+    if (!videoSource) {
+      qCritical() << "Failed to create video source";
     }
     else {
-      QString dev = id.toString();
-      g_object_set(src, conf->deviceScannerProperty().toAscii().data(),
-                  dev.toAscii().data(), NULL);
+      g_object_set(cameraBin, "camera-source", videoSource, NULL);
+    }
+  }
+
+  void setDevicePoperty() {
+    if (videoSource) {
+      if (conf->deviceScannerType() == SCANNER_TYPE_ENUM) {
+       int dev = id.toInt();
+       g_object_set(videoSource, conf->deviceScannerProperty().toAscii().constData(), dev, NULL);
+      }
+      else {
+       QString dev = id.toString();
+       g_object_set(videoSource, conf->deviceScannerProperty().toAscii().constData(),
+                    dev.toAscii().constData(), NULL);
+      }
     }
   }
 
   bool setViewfinderSink() {
-    GstElement *sink;
+    GstElement *sink = 0;
     g_object_get(cameraBin, "viewfinder-sink", &sink, NULL);
 
     if (sink) {
@@ -132,11 +136,6 @@ public:
   }
 
   void _d_error(const QString& message, int code, const QString& debug) {
-    if (stopping) {
-      // TODO: is it wise to ignore errors while stopping??
-      return;
-    }
-
     error = true;
 
     QMetaObject::invokeMethod(q_ptr, "error", Q_ARG(QString, message),
@@ -213,16 +212,6 @@ public:
                              Q_ARG(bool, d->q_ptr->isIdle()));
   }
 
-#if 0
-  void resetCapabilities() {
-    g_object_set(cameraBin, "zoom", 1.0, NULL);
-    g_object_set(videoSource, "flash-mode", 0, NULL);
-
-    // TODO: should scene mode be manual or automatic ?
-    g_object_set(videoSource, "scene-mode", 0, NULL);
-  }
-#endif
-
   QString name;
   QVariant id;
 
@@ -241,7 +230,8 @@ public:
   QtCamGStreamerMessageListener *listener;
   bool error;
   QtCamNotifications *notifications;
-  bool stopping;
+  QtCamPropertySetter *propertySetter;
+  QtCamAnalysisBin *viewfinderFilters;
 };
 
 #endif /* QT_CAM_DEVICE_P_H */