Added QtCamAutoFocus::setRegionOfInterest()
[harmattan/cameraplus] / lib / qtcamdevice.cpp
index 793eefa..c9cce2b 100644 (file)
@@ -30,8 +30,6 @@
 #include "qtcamvideomode.h"
 #include "qtcamnotifications.h"
 
-// TODO: we want the ability to change the image and video gep from the app.
-
 QtCamDevice::QtCamDevice(QtCamConfig *config, const QString& name,
                         const QVariant& id, QObject *parent) :
   QObject(parent), d_ptr(new QtCamDevicePrivate) {
@@ -63,7 +61,6 @@ QtCamDevice::QtCamDevice(QtCamConfig *config, const QString& name,
   // TODO: audio bitrate
   // TODO: video bitrate
   // TODO: filters
-  // TODO: capabilities
   // TODO: custom properties for jifmux, mp4mux, audio encoder, video encoder, sink & video source
   d_ptr->listener = new QtCamGStreamerMessageListener(gst_element_get_bus(d_ptr->cameraBin),
                                                      d_ptr, this);
@@ -87,7 +84,7 @@ QtCamDevice::QtCamDevice(QtCamConfig *config, const QString& name,
 }
 
 QtCamDevice::~QtCamDevice() {
-  stop();
+  stop(true);
 
   d_ptr->image->deactivate();
   d_ptr->video->deactivate();
@@ -131,6 +128,10 @@ bool QtCamDevice::setViewfinder(QtCamViewfinder *viewfinder) {
   return true;
 }
 
+QtCamViewfinder *QtCamDevice::viewfinder() const {
+  return d_ptr->viewfinder;
+}
+
 bool QtCamDevice::start() {
   if (d_ptr->error) {
     qWarning() << "Pipeline must be stopped first because of an error.";
@@ -192,7 +193,7 @@ bool QtCamDevice::start() {
   return true;
 }
 
-bool QtCamDevice::stop() {
+bool QtCamDevice::stop(bool force) {
   if (!d_ptr->cameraBin) {
     return true;
   }
@@ -200,6 +201,9 @@ bool QtCamDevice::stop() {
   if (d_ptr->error) {
     gst_element_set_state(d_ptr->cameraBin, GST_STATE_NULL);
     d_ptr->error = false;
+
+    d_ptr->viewfinder->stop();
+
     return true;
   }
 
@@ -212,11 +216,11 @@ bool QtCamDevice::stop() {
   }
 
   if (!isIdle()) {
-    return false;
+    if (!force) {
+      return false;
+    }
   }
 
-  d_ptr->viewfinder->stop();
-
   // First we go to ready:
   GstStateChangeReturn st = gst_element_set_state(d_ptr->cameraBin, GST_STATE_READY);
   if (st != GST_STATE_CHANGE_FAILURE) {
@@ -227,6 +231,8 @@ bool QtCamDevice::stop() {
   // Now to NULL
   gst_element_set_state(d_ptr->cameraBin, GST_STATE_NULL);
 
+  d_ptr->viewfinder->stop();
+
   return true;
 }