Move qt_cam_copy_register to QtCamera
[harmattan/cameraplus] / lib / qtcamdevice.cpp
index 294edc2..ed00c5e 100644 (file)
@@ -29,7 +29,6 @@
 #include "qtcamimagemode.h"
 #include "qtcamvideomode.h"
 #include "qtcamnotifications.h"
-#include "gst/gstcopy.h"
 #include "qtcampropertysetter.h"
 #include "qtcamanalysisbin.h"
 
@@ -37,12 +36,6 @@ QtCamDevice::QtCamDevice(QtCamConfig *config, const QString& name,
                         const QVariant& id, QObject *parent) :
   QObject(parent), d_ptr(new QtCamDevicePrivate) {
 
-  static gboolean register_copy = TRUE;
-  if (register_copy) {
-    qt_cam_copy_register();
-    register_copy = FALSE;
-  }
-
   d_ptr->q_ptr = this;
   d_ptr->name = name;
   d_ptr->id = id;
@@ -102,8 +95,14 @@ QtCamDevice::QtCamDevice(QtCamConfig *config, const QString& name,
   g_signal_connect(d_ptr->cameraBin, "notify::idle",
                   G_CALLBACK(QtCamDevicePrivate::on_idle_changed), d_ptr);
 
-  g_signal_connect(d_ptr->wrapperVideoSource, "notify::ready-for-capture",
-                  G_CALLBACK(QtCamDevicePrivate::on_ready_for_capture_changed), d_ptr);
+  if (d_ptr->wrapperVideoSource) {
+    g_signal_connect(d_ptr->wrapperVideoSource, "notify::ready-for-capture",
+                    G_CALLBACK(QtCamDevicePrivate::on_ready_for_capture_changed), d_ptr);
+  }
+  else {
+    g_signal_connect(d_ptr->videoSource, "notify::ready-for-capture",
+                    G_CALLBACK(QtCamDevicePrivate::on_ready_for_capture_changed), d_ptr);
+  }
 
   d_ptr->image = new QtCamImageMode(d_ptr, this);
   d_ptr->video = new QtCamVideoMode(d_ptr, this);
@@ -142,20 +141,18 @@ bool QtCamDevice::setViewfinder(QtCamViewfinder *viewfinder) {
   }
 
   if (!viewfinder) {
-    qWarning() << "QtCamDevice: viewfinder cannot be unset.";
-    return false;
-  }
+    if (d_ptr->cameraBin) {
+      g_object_set(d_ptr->cameraBin, "viewfinder-sink", NULL, NULL);
+    }
 
-  if (d_ptr->viewfinder) {
-    qWarning() << "QtCamDevice: viewfinder cannot be replaced.";
-    return false;
-  }
+    d_ptr->sink = 0;
 
-  if (!viewfinder->setDevice(this)) {
-    return false;
+    d_ptr->viewfinder = 0;
+    return true;
   }
 
   d_ptr->viewfinder = viewfinder;
+  d_ptr->sink = 0;
 
   return true;
 }