Set media.name to '*'.
[harmattan/cameraplus] / lib / qtcamimagemode.cpp
index b73dee4..e3217c4 100644 (file)
@@ -1,7 +1,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
@@ -42,7 +42,9 @@ public:
 };
 
 QtCamImageMode::QtCamImageMode(QtCamDevicePrivate *dev, QObject *parent) :
-  QtCamMode(new QtCamImageModePrivate(dev), "mode-image", "image-done", parent) {
+  QtCamMode(new QtCamImageModePrivate(dev), "mode-image", parent) {
+
+  d_ptr->init(new DoneHandler(d_ptr, "image-done", this));
 
   d = (QtCamImageModePrivate *)d_ptr;
 
@@ -62,7 +64,7 @@ QtCamImageMode::~QtCamImageMode() {
 }
 
 bool QtCamImageMode::canCapture() {
-  return QtCamMode::canCapture() && d_ptr->dev->isWrapperReady();
+  return QtCamMode::canCapture() && d_ptr->dev->isReadyForCapture();
 }
 
 void QtCamImageMode::applySettings() {
@@ -78,14 +80,15 @@ void QtCamImageMode::applySettings() {
   // we use. For now we will not set any FPS.
   d_ptr->setCaps("image-capture-caps", d->resolution.captureResolution(), -1);
 
-  setPreviewSize(d->resolution.previewResolution());
+  enablePreview();
 
-  // TODO: ?
-  // d_ptr->resetCaps("video-capture-caps");
+  // If we don't reset the caps then: if we switch from video to image then we fail
+  // the next time we restart the pipeline.
+  d_ptr->resetCaps("video-capture-caps");
 }
 
 void QtCamImageMode::start() {
-  // Nothing
+  d_ptr->enableViewfinderFilters();
 }
 
 void QtCamImageMode::stop() {
@@ -101,7 +104,7 @@ bool QtCamImageMode::capture(const QString& fileName) {
     return false;
   }
 
-  setFileName(fileName);
+  d_ptr->setFileName(fileName);
 
   g_object_set(d_ptr->dev->cameraBin, "location", fileName.toUtf8().data(), NULL);
   g_signal_emit_by_name(d_ptr->dev->cameraBin, "start-capture", NULL);
@@ -140,3 +143,11 @@ void QtCamImageMode::setProfile(GstEncodingProfile *profile) {
 QtCamImageSettings *QtCamImageMode::settings() const {
   return d->settings;
 }
+
+QtCamImageResolution QtCamImageMode::currentResolution() {
+  return d->resolution;
+}
+
+void QtCamImageMode::enablePreview() {
+  d_ptr->setPreviewSize(d->resolution.previewResolution());
+}