Code cleanup
[harmattan/cameraplus] / lib / qtcamvideomode.cpp
index d3d8885..1f7121f 100644 (file)
@@ -24,6 +24,7 @@
 #include "qtcamdevice_p.h"
 #include "qtcamdevice.h"
 #include "qtcamvideosettings.h"
+#include "qtcamnotifications.h"
 
 class QtCamVideoModePrivate : public QtCamModePrivate {
 public:
@@ -85,10 +86,10 @@ void QtCamVideoMode::applySettings() {
 
   d_ptr->setCaps("video-capture-caps", d->resolution.captureResolution(), fps);
 
-  setPreviewSize(d->resolution.previewResolution());
+  d_ptr->setPreviewSize(d->resolution.previewResolution());
 
-  // TODO:
-  //  d_ptr->resetCaps("image-capture-caps");
+  // Not sure this is needed but just in case.
+  d_ptr->resetCaps("image-capture-caps");
 }
 
 void QtCamVideoMode::start() {
@@ -114,7 +115,9 @@ bool QtCamVideoMode::startRecording(const QString& fileName) {
     return false;
   }
 
-  setFileName(fileName);
+  d_ptr->setFileName(fileName);
+
+  QMetaObject::invokeMethod(d_ptr->dev->notifications, "videoRecordingStarted");
 
   g_object_set(d_ptr->dev->cameraBin, "location", fileName.toUtf8().data(), NULL);
   g_signal_emit_by_name(d_ptr->dev->cameraBin, "start-capture", NULL);
@@ -135,7 +138,14 @@ void QtCamVideoMode::stopRecording() {
 bool QtCamVideoMode::setResolution(const QtCamVideoResolution& resolution) {
   d->resolution = resolution;
 
-  if (!d_ptr->dev->q_ptr->isRunning() || isRecording()) {
+  if (!d_ptr->dev->q_ptr->isRunning()) {
+    // We will return true here because setting the resolution on a non-running pipeline
+    // doesn't make much sense (Probably the only use case is as a kind of optimization only).
+    // We will set it anyway when the pipeline gets started.
+    return true;
+  }
+
+  if (isRecording()) {
     return false;
   }