HEADERS += plugin.h previewprovider.h camera.h mode.h imagemode.h videomode.h \
capability.h zoom.h flash.h scene.h evcomp.h videotorch.h whitebalance.h \
colortone.h exposure.h aperture.h iso.h noisereduction.h \
- flickerreduction.h mute.h metadata.h imagesettings.h imageresolutionmodel.h
+ flickerreduction.h mute.h metadata.h imagesettings.h imageresolutionmodel.h \
+ videosettings.h videoresolutionmodel.h
SOURCES += plugin.cpp previewprovider.cpp camera.cpp mode.cpp imagemode.cpp videomode.cpp \
capability.cpp zoom.cpp flash.cpp scene.cpp evcomp.cpp videotorch.cpp whitebalance.cpp \
colortone.cpp exposure.cpp aperture.cpp iso.cpp noisereduction.cpp \
- flickerreduction.cpp mute.cpp metadata.cpp imagesettings.cpp imageresolutionmodel.cpp
+ flickerreduction.cpp mute.cpp metadata.cpp imagesettings.cpp imageresolutionmodel.cpp \
+ videosettings.cpp videoresolutionmodel.cpp
#include "metadata.h"
#include "imagesettings.h"
#include "imageresolutionmodel.h"
+#include "videosettings.h"
+#include "videoresolutionmodel.h"
#include <QtDeclarative>
qmlRegisterType<Mute>(URI, MAJOR, MINOR, "Mute");
qmlRegisterType<MetaData>(URI, MAJOR, MINOR, "MetaData");
qmlRegisterType<ImageSettings>(URI, MAJOR, MINOR, "ImageSettings");
+ qmlRegisterType<VideoSettings>(URI, MAJOR, MINOR, "VideoSettings");
qmlRegisterUncreatableType<ImageResolutionModel>(URI, MAJOR, MINOR, "ImageResolutionModel",
"ImageResolutionModel can be obtained from ImageSettings");
+ qmlRegisterUncreatableType<VideoResolutionModel>(URI, MAJOR, MINOR, "VideoResolutionModel",
+ "VideoResolutionModel can be obtained from VideoSettings");
+
qmlRegisterType<Mode>();
qmlRegisterType<Capability>();
--- /dev/null
+/*!
+ * This file is part of CameraPlus.
+ *
+ * Copyright (C) 2012 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
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "videoresolutionmodel.h"
+#include "qtcamvideosettings.h"
+#include <QDebug>
+
+VideoResolutionModel::VideoResolutionModel(QtCamVideoSettings *settings, QObject *parent) :
+ QAbstractListModel(parent), m_settings(settings) {
+
+ QHash<int, QByteArray> roles;
+ roles[IdRole] = "resolutionId";
+ roles[NameRole] = "resolutionName";
+ roles[CaptureRole] = "captureResolution";
+ roles[PreviewRole] = "previewResolution";
+ roles[FpsRole] = "frameRate";
+ roles[NightFpsRole] = "nightFrameRate";
+ roles[ResolutionRole] = "resolution";
+ roles[AspectRatioRole] = "resolutionAspectRatio";
+
+ setRoleNames(roles);
+
+ m_resolutions = m_settings->resolutions(m_aspectRatio);
+}
+
+VideoResolutionModel::~VideoResolutionModel() {
+ m_settings = 0;
+}
+
+int VideoResolutionModel::rowCount(const QModelIndex& parent) const {
+ if (!parent.isValid()) {
+ return m_resolutions.size();
+ }
+
+ return 0;
+}
+
+QVariant VideoResolutionModel::data(const QModelIndex& index, int role) const {
+ if (index.row() < 0 || index.row() > m_resolutions.size()) {
+ return QVariant();
+ }
+
+ const QtCamVideoResolution& res = m_resolutions[index.row()];
+
+ switch (role) {
+ case IdRole:
+ return res.id();
+
+ case NameRole:
+ return res.name();
+
+ case CaptureRole:
+ return res.captureResolution();
+
+ case PreviewRole:
+ return res.previewResolution();
+
+ case FpsRole:
+ return res.frameRate();
+
+ case NightFpsRole:
+ return res.nightFrameRate();
+
+ case ResolutionRole:
+ return res.resolution();
+
+ case AspectRatioRole:
+ return res.aspectRatio();
+
+ default:
+ return QVariant();
+ }
+}
+
+QString VideoResolutionModel::aspectRatio() const {
+ return m_aspectRatio;
+}
+
+void VideoResolutionModel::setAspectRatio(const QString& aspectRatio) {
+ if (aspectRatio != m_aspectRatio) {
+
+ m_aspectRatio = aspectRatio;
+
+ emit aspectRatioChanged();
+
+ beginResetModel();
+
+ m_resolutions = m_settings->resolutions(m_aspectRatio);
+
+ endResetModel();
+ }
+}
--- /dev/null
+// -*- c++ -*-
+
+/*!
+ * This file is part of CameraPlus.
+ *
+ * Copyright (C) 2012 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
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef VIDEO_RESOLUTION_MODEL_H
+#define VIDEO_RESOLUTION_MODEL_H
+
+#include <QAbstractListModel>
+
+class QtCamVideoSettings;
+class QtCamVideoResolution;
+
+class VideoResolutionModel : public QAbstractListModel {
+ Q_OBJECT
+
+ Q_PROPERTY(QString aspectRatio READ aspectRatio WRITE setAspectRatio NOTIFY aspectRatioChanged);
+
+public:
+
+ enum ResolutionRoles {
+ IdRole = Qt::UserRole + 1,
+ NameRole,
+ CaptureRole,
+ PreviewRole,
+ FpsRole,
+ NightFpsRole,
+ ResolutionRole,
+ AspectRatioRole,
+ };
+
+ VideoResolutionModel(QtCamVideoSettings *settings, QObject *parent = 0);
+ ~VideoResolutionModel();
+
+ int rowCount(const QModelIndex& parent = QModelIndex()) const;
+
+ QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
+
+ QString aspectRatio() const;
+ void setAspectRatio(const QString& aspectRatio);
+
+signals:
+ void aspectRatioChanged();
+
+private:
+ QString m_aspectRatio;
+
+ QtCamVideoSettings *m_settings;
+
+ QList<QtCamVideoResolution> m_resolutions;
+};
+
+#endif /* VIDEO_RESOLUTION_MODEL_H */
--- /dev/null
+/*!
+ * This file is part of CameraPlus.
+ *
+ * Copyright (C) 2012 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
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "videosettings.h"
+#include "qtcamvideosettings.h"
+#include "camera.h"
+#include "qtcamdevice.h"
+#include "qtcamvideomode.h"
+#include "videoresolutionmodel.h"
+#include <QDebug>
+
+VideoSettings::VideoSettings(QObject *parent) :
+ QObject(parent), m_cam(0), m_settings(0), m_resolutions(0) {
+
+}
+
+VideoSettings::~VideoSettings() {
+ m_settings = 0;
+}
+
+QString VideoSettings::suffix() const {
+ return m_settings ? m_settings->suffix() : QString();
+}
+
+QStringList VideoSettings::aspectRatios() const {
+ return m_settings ? m_settings->aspectRatios() : QStringList();
+}
+
+Camera *VideoSettings::camera() {
+ return m_cam;
+}
+
+void VideoSettings::setCamera(Camera *camera) {
+ if (camera == m_cam) {
+ return;
+ }
+
+ if (m_cam) {
+ QObject::disconnect(m_cam, SIGNAL(deviceChanged()), this, SLOT(deviceChanged()));
+ }
+
+ m_cam = camera;
+
+ if (m_cam) {
+ QObject::connect(m_cam, SIGNAL(deviceChanged()), this, SLOT(deviceChanged()));
+ }
+
+ emit cameraChanged();
+
+ if (m_cam->device()) {
+ deviceChanged();
+ }
+}
+
+void VideoSettings::deviceChanged() {
+ m_settings = m_cam->device()->videoMode()->settings();
+
+ emit settingsChanged();
+
+ emit readyChanged();
+
+ delete m_resolutions;
+ m_resolutions = 0;
+
+ emit resolutionsChanged();
+}
+
+VideoResolutionModel *VideoSettings::resolutions() {
+ if (!m_settings) {
+ return 0;
+ }
+
+
+ if (!m_resolutions) {
+ m_resolutions = new VideoResolutionModel(m_settings, this);
+ }
+
+ return m_resolutions;
+}
+
+bool VideoSettings::isReady() const {
+ return m_settings;
+}
+
+bool VideoSettings::setResolution(const QString& aspectRatio, const QString& resolution) {
+ if (!isReady()) {
+ return false;
+ }
+
+ QList<QtCamVideoResolution> res = m_settings->resolutions(aspectRatio);
+
+ foreach (const QtCamVideoResolution& r, res) {
+ if (r.name() == resolution) {
+ return m_cam->device()->videoMode()->setResolution(r);
+ }
+ }
+
+ return false;
+}
--- /dev/null
+// -*- c++ -*-
+
+/*!
+ * This file is part of CameraPlus.
+ *
+ * Copyright (C) 2012 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
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef VIDEO_SETTINGS_H
+#define VIDEO_SETTINGS_H
+
+#include <QObject>
+#include <QStringList>
+
+class Camera;
+class QtCamVideoSettings;
+class VideoResolutionModel;
+
+class VideoSettings : public QObject {
+ Q_OBJECT
+
+ Q_PROPERTY(Camera* camera READ camera WRITE setCamera NOTIFY cameraChanged);
+ Q_PROPERTY(QString suffix READ suffix NOTIFY settingsChanged);
+ Q_PROPERTY(QStringList aspectRatios READ aspectRatios NOTIFY settingsChanged);
+ Q_PROPERTY(VideoResolutionModel *resolutions READ resolutions NOTIFY resolutionsChanged);
+ Q_PROPERTY(bool ready READ isReady NOTIFY readyChanged);
+
+public:
+ VideoSettings(QObject *parent = 0);
+ ~VideoSettings();
+
+ QString suffix() const;
+ QStringList aspectRatios() const;
+
+ Camera *camera();
+ void setCamera(Camera *camera);
+
+ VideoResolutionModel *resolutions();
+
+ bool isReady() const;
+
+ Q_INVOKABLE bool setResolution(const QString& aspectRatio, const QString& resolution);
+
+signals:
+ void settingsChanged();
+ void cameraChanged();
+ void resolutionsChanged();
+ void readyChanged();
+
+private slots:
+ void deviceChanged();
+
+private:
+ Camera *m_cam;
+ QtCamVideoSettings *m_settings;
+ VideoResolutionModel *m_resolutions;
+};
+
+#endif /* VIDEO_SETTINGS_H */
}
}
+ SectionHeader {
+ text: qsTr("Resolution");
+ }
+
+ ButtonRow {
+ anchors.horizontalCenter: parent.horizontalCenter
+ exclusive: false
+
+ Repeater {
+ id: resolutions
+
+ model: videoSettings.resolutions
+
+ function name(name, res) {
+ return name.charAt(0).toUpperCase() + name.slice(1) + " " + res;
+ }
+
+ delegate: Button {
+ text: resolutions.name(resolutionName, resolution);
+ checked: settings.videoResolution == resolutionName;
+ onClicked: {
+ if (!cam.idle) {
+ showError(qsTr("Camera is busy saving."));
+ return;
+ }
+
+ settings.videoResolution = resolutionName;
+ }
+ }
+ }
+ }
+
CameraSettings {
anchors.horizontalCenter: parent.horizontalCenter
}
}
}
+ VideoSettings {
+ id: videoSettings
+ camera: cam
+
+ function setVideoResolution() {
+ if (!videoSettings.setResolution(settings.videoAspectRatio, settings.videoResolution)) {
+ showError(qsTr("Failed to set required resolution"));
+ }
+ }
+
+ onReadyChanged: {
+ if (ready) {
+ videoSettings.setVideoResolution();
+ }
+ }
+ }
+
Connections {
target: settings
+
onImageAspectRatioChanged: {
imageSettings.setImageResolution();
}
onImageResolutionChanged: {
imageSettings.setImageResolution();
}
+
+ onVideoResolutionChanged: {
+ videoSettings.setVideoResolution();
+ }
}
Camera {
// TODO: hardcoding device id
Component.onCompleted: { cam.deviceId = 0; mode = settings.mode; }
+ Component.onDestruction: {
+ console.log("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
+ }
// TODO: Hack
z: -1
#define DEFAULT_IMAGE_ISO 0
#define DEFAULT_IMAGE_RESOLUTION "high"
#define DEFAULT_IMAGE_ASPECT_RATIO "16:9"
+#define DEFAULT_VIDEO_RESOLUTION "high"
Settings::Settings(QObject *parent) :
QObject(parent),
emit imageResolutionChanged();
}
}
+
+QString Settings::videoAspectRatio() const {
+ // This is not used for anything so we will return an empty string for now
+ // which will make the backend return all resolutions.
+
+ return QString();
+}
+
+void Settings::setVideoAspectRatio(const QString& aspectRatio) {
+ Q_UNUSED(aspectRatio);
+
+ // This is not used for anything so we will just ignore it.
+}
+
+QString Settings::videoResolution() const {
+ return m_settings->value("video/resolution", DEFAULT_VIDEO_RESOLUTION).toString();
+}
+
+void Settings::setVideoResolution(const QString& resolution) {
+ if (resolution != videoResolution()) {
+ m_settings->setValue("video/resolution", resolution);
+ emit videoResolutionChanged();
+ }
+}
Q_PROPERTY(QString imageAspectRatio READ imageAspectRatio WRITE setImageAspectRatio NOTIFY imageAspectRatioChanged);
Q_PROPERTY(QString imageResolution READ imageResolution WRITE setImageResolution NOTIFY imageResolutionChanged);
+ Q_PROPERTY(QString videoAspectRatio READ videoAspectRatio WRITE setVideoAspectRatio NOTIFY videoAspectRatioChanged);
+ Q_PROPERTY(QString videoResolution READ videoResolution WRITE setVideoResolution NOTIFY videoResolutionChanged);
+
public:
Settings(QObject *parent = 0);
~Settings();
QString imageResolution() const;
void setImageResolution(const QString& resolution);
+ QString videoAspectRatio() const;
+ void setVideoAspectRatio(const QString& aspectRatio);
+
+ QString videoResolution() const;
+ void setVideoResolution(const QString& resolution);
+
signals:
void modeChanged();
void creatorNameChanged();
void imageIsoChanged();
void imageAspectRatioChanged();
void imageResolutionChanged();
+ void videoAspectRatioChanged();
+ void videoResolutionChanged();
private:
QSettings *m_settings;