Refactor and rename isWrapperReady to isReadyForCapture()
[harmattan/cameraplus] / lib / qtcamdevice_p.h
index d532ab5..b0cb65d 100644 (file)
@@ -3,7 +3,7 @@
 /*!
  * This file is part of CameraPlus.
  *
- * Copyright (C) 2012 Mohammed Sameer <msameer@foolab.org>
+ * Copyright (C) 2012-2013 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
@@ -49,12 +49,13 @@ public:
     viewfinder(0),
     conf(0),
     error(false),
-    notifications(0) {
+    notifications(0),
+    viewfinderFilters(0) {
 
   }
 
   GstElement *createAndAddElement(const QString& elementName, const char *prop, const char *name) {
-    GstElement *elem = gst_element_factory_make(elementName.toAscii(), name);
+    GstElement *elem = gst_element_factory_make(elementName.toLatin1(), name);
     if (!elem) {
       qWarning() << "Failed to create" << elementName;
       return 0;
@@ -100,8 +101,22 @@ public:
     }
   }
 
+  void setDevicePoperty() {
+    if (videoSource) {
+      if (conf->deviceScannerType() == SCANNER_TYPE_ENUM) {
+       int dev = id.toInt();
+       g_object_set(videoSource, conf->deviceScannerProperty().toLatin1().constData(), dev, NULL);
+      }
+      else {
+       QString dev = id.toString();
+       g_object_set(videoSource, conf->deviceScannerProperty().toLatin1().constData(),
+                    dev.toLatin1().constData(), NULL);
+      }
+    }
+  }
+
   bool setViewfinderSink() {
-    GstElement *sink;
+    GstElement *sink = 0;
     g_object_get(cameraBin, "viewfinder-sink", &sink, NULL);
 
     if (sink) {
@@ -158,7 +173,7 @@ public:
   void setAudioCaptureCaps() {
     QString captureCaps = conf->audioCaptureCaps();
     if (!captureCaps.isEmpty()) {
-      GstCaps *caps = gst_caps_from_string(captureCaps.toAscii().data());
+      GstCaps *caps = gst_caps_from_string(captureCaps.toLatin1().data());
       if (caps) {
        g_object_set(cameraBin, "audio-capture-caps", caps, NULL);
        gst_caps_unref(caps);
@@ -166,13 +181,18 @@ public:
     }
   }
 
-  bool isWrapperReady() {
-    if (!wrapperVideoSource) {
+  bool isReadyForCapture() {
+    GstElement *src = videoSource;
+    if (wrapperVideoSource) {
+      src = wrapperVideoSource;
+    }
+
+    if (!src) {
       return false;
     }
 
     gboolean ready = FALSE;
-    g_object_get(wrapperVideoSource, "ready-for-capture", &ready, NULL);
+    g_object_get(src, "ready-for-capture", &ready, NULL);
 
     return ready == TRUE;
   }