2 * This file is part of CameraPlus.
4 * Copyright (C) 2012 Mohammed Sameer <msameer@foolab.org>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 #include "qtcamvideosettings.h"
23 class QtCamVideoResolutionPrivate : public QSharedData {
35 class QtCamVideoSettingsPrivate : public QSharedData {
41 QList<QtCamVideoResolution> resolutions;
44 QtCamVideoResolution::QtCamVideoResolution(const QString& id, const QString& name,
45 const QSize& capture, const QSize& preview,
46 int fps, int nightFps,
47 const QString& aspectRatio,
48 const QString& resolution) :
49 d_ptr(new QtCamVideoResolutionPrivate) {
52 d_ptr->capture = capture;
53 d_ptr->preview = preview;
55 d_ptr->nightFps = nightFps;
56 d_ptr->aspectRatio = aspectRatio;
57 d_ptr->resolution = resolution;
60 QtCamVideoResolution::QtCamVideoResolution(const QtCamVideoResolution& other) :
65 QtCamVideoResolution& QtCamVideoResolution::operator=(const QtCamVideoResolution& other) {
71 QtCamVideoResolution::~QtCamVideoResolution() {
72 // QSharedData will take care of reference counting.
75 QString QtCamVideoResolution::id() const {
79 QString QtCamVideoResolution::name() const {
83 QSize QtCamVideoResolution::captureResolution() const {
84 return d_ptr->capture;
87 QSize QtCamVideoResolution::previewResolution() const {
88 return d_ptr->preview;
91 int QtCamVideoResolution::frameRate() const {
95 int QtCamVideoResolution::nightFrameRate() const {
96 return d_ptr->nightFps;
99 QString QtCamVideoResolution::aspectRatio() const {
100 return d_ptr->aspectRatio;
103 QString QtCamVideoResolution::resolution() const {
104 return d_ptr->resolution;
107 QtCamVideoSettings::QtCamVideoSettings(const QString& id, const QString& suffix,
108 const QString& profileName,
109 const QString& profilePath,
110 const QList<QtCamVideoResolution>& resolutions) :
111 d_ptr(new QtCamVideoSettingsPrivate) {
114 d_ptr->suffix = suffix;
115 d_ptr->profileName = profileName;
116 d_ptr->profilePath = profilePath;
117 d_ptr->resolutions = resolutions;
120 QtCamVideoSettings::QtCamVideoSettings(const QtCamVideoSettings& other) :
125 QtCamVideoSettings& QtCamVideoSettings::operator=(const QtCamVideoSettings& other) {
131 QtCamVideoSettings::~QtCamVideoSettings() {
132 // QSharedData will take care of reference counting.
135 QString QtCamVideoSettings::id() const {
139 QString QtCamVideoSettings::suffix() const {
140 return d_ptr->suffix;
143 QString QtCamVideoSettings::profileName() const {
144 return d_ptr->profileName;
147 QString QtCamVideoSettings::profilePath() const {
148 return d_ptr->profilePath;
151 QtCamVideoResolution QtCamVideoSettings::defaultResolution(const QString& aspectRatio) const {
152 if (aspectRatio.isEmpty()) {
153 return d_ptr->resolutions[0];
156 foreach (const QtCamVideoResolution& r, d_ptr->resolutions) {
157 if (r.aspectRatio() == aspectRatio) {
162 return d_ptr->resolutions[0];
165 QList<QtCamVideoResolution> QtCamVideoSettings::resolutions(const QString& aspectRatio) const {
166 if (aspectRatio.isEmpty()) {
167 return d_ptr->resolutions;
170 QList<QtCamVideoResolution> res;
172 foreach (const QtCamVideoResolution& r, d_ptr->resolutions) {
173 if (r.aspectRatio() == aspectRatio) {
181 QStringList QtCamVideoSettings::aspectRatios() const {
184 foreach (const QtCamVideoResolution& r, d_ptr->resolutions) {
185 if (aspects.indexOf(r.aspectRatio()) == -1) {
186 aspects << r.aspectRatio();