Added ImageSettings::currentResolution and methods to find ImageResolution and set it
[harmattan/cameraplus] / declarative / camera.h
1 // -*- c++ -*-
2
3 /*!
4  * This file is part of CameraPlus.
5  *
6  * Copyright (C) 2012-2013 Mohammed Sameer <msameer@foolab.org>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
21  */
22
23 #ifndef CAMERA_H
24 #define CAMERA_H
25
26 #include <QObject>
27 #include <QVariant>
28 #include <QPointer>
29
30 class QtCamera;
31 class QtCamDevice;
32 class Sounds;
33 class NotificationsContainer;
34 class Zoom;
35 class Flash;
36 class Scene;
37 class EvComp;
38 class WhiteBalance;
39 class ColorTone;
40 class Iso;
41 class Exposure;
42 class Aperture;
43 class NoiseReduction;
44 class FlickerReduction;
45 class Focus;
46 class AutoFocus;
47 class Roi;
48 class VideoMute;
49 class VideoTorch;
50 class CameraConfig;
51
52 class Camera : public QObject {
53   Q_OBJECT
54
55   Q_PROPERTY(int deviceCount READ deviceCount NOTIFY deviceCountChanged)
56   Q_PROPERTY(QVariant deviceId READ deviceId NOTIFY deviceIdChanged);
57   Q_PROPERTY(CameraMode mode READ mode NOTIFY modeChanged);
58   Q_PROPERTY(bool idle READ isIdle NOTIFY idleStateChanged);
59   Q_PROPERTY(bool running READ isRunning NOTIFY runningStateChanged);
60   Q_PROPERTY(QString imageSuffix READ imageSuffix CONSTANT);
61   Q_PROPERTY(QString videoSuffix READ videoSuffix CONSTANT);
62   Q_PROPERTY(Sounds *sounds READ sounds WRITE setSounds NOTIFY soundsChanged);
63
64   Q_PROPERTY(Zoom *zoom READ zoom NOTIFY zoomChanged);
65   Q_PROPERTY(Flash *flash READ flash NOTIFY flashChanged);
66   Q_PROPERTY(Scene *scene READ scene NOTIFY sceneChanged);
67   Q_PROPERTY(EvComp *evComp READ evComp NOTIFY evCompChanged);
68   Q_PROPERTY(WhiteBalance *whiteBalance READ whiteBalance NOTIFY whiteBalanceChanged);
69   Q_PROPERTY(ColorTone *colorTone READ colorTone NOTIFY colorToneChanged);
70   Q_PROPERTY(Iso *iso READ iso NOTIFY isoChanged);
71   Q_PROPERTY(Exposure *exposure READ exposure NOTIFY exposureChanged);
72   Q_PROPERTY(Aperture *aperture READ aperture NOTIFY apertureChanged);
73   Q_PROPERTY(NoiseReduction *noiseReduction READ noiseReduction NOTIFY noiseReductionChanged);
74   Q_PROPERTY(FlickerReduction *flickerReduction READ flickerReduction NOTIFY flickerReductionChanged);
75   Q_PROPERTY(Focus *focus READ focus NOTIFY focusChanged);
76   Q_PROPERTY(AutoFocus *autoFocus READ autoFocus NOTIFY autoFocusChanged);
77   Q_PROPERTY(Roi *roi READ roi NOTIFY roiChanged);
78
79   Q_PROPERTY(VideoMute *videoMute READ videoMute NOTIFY videoMuteChanged);
80   Q_PROPERTY(VideoTorch *videoTorch READ videoTorch NOTIFY videoTorchChanged);
81
82   // TODO: We need a setter here too.
83   Q_PROPERTY(CameraConfig *cameraConfig READ cameraConfig CONSTANT);
84
85   Q_ENUMS(CameraMode);
86
87 public:
88   typedef enum {
89     UnknownMode,
90     ImageMode,
91     VideoMode
92   } CameraMode;
93
94   Camera(QObject *parent = 0);
95   ~Camera();
96
97   int deviceCount() const;
98   Q_INVOKABLE QString deviceName(int index) const;
99   Q_INVOKABLE QVariant deviceId(int index) const;
100
101   Q_INVOKABLE bool reset(const QVariant& deviceId, const CameraMode& mode);
102
103   QVariant deviceId() const;
104
105   CameraMode mode();
106
107   QtCamDevice *device() const;
108
109   Q_INVOKABLE bool start();
110   Q_INVOKABLE bool stop(bool force = false);
111
112   bool isIdle();
113   bool isRunning();
114
115   QString imageSuffix() const;
116   QString videoSuffix() const;
117
118   Sounds *sounds() const;
119   void setSounds(Sounds *sounds);
120
121   Zoom *zoom() const;
122   Flash *flash() const;
123   Scene *scene() const;
124   EvComp *evComp() const;
125   WhiteBalance *whiteBalance() const;
126   ColorTone *colorTone() const;
127   Iso *iso() const;
128   Exposure *exposure() const;
129   Aperture *aperture() const;
130   NoiseReduction *noiseReduction() const;
131   FlickerReduction *flickerReduction() const;
132   Focus *focus() const;
133   AutoFocus *autoFocus() const;
134   Roi *roi() const;
135
136   VideoMute *videoMute() const;
137   VideoTorch *videoTorch() const;
138
139   CameraConfig *cameraConfig() const;
140
141 signals:
142   void deviceCountChanged();
143   void deviceIdChanged();
144   void prepareForDeviceChange();
145   void deviceChanged();
146   void modeChanged();
147   void idleStateChanged();
148   void runningStateChanged();
149   void error(const QString& message, int code, const QString& debug);
150   void soundsChanged();
151   void renderAreaChanged();
152   void videoResolutionChanged();
153
154   void zoomChanged();
155   void flashChanged();
156   void sceneChanged();
157   void evCompChanged();
158   void whiteBalanceChanged();
159   void colorToneChanged();
160   void isoChanged();
161   void exposureChanged();
162   void apertureChanged();
163   void noiseReductionChanged();
164   void flickerReductionChanged();
165   void focusChanged();
166   void autoFocusChanged();
167   void roiChanged();
168
169   void videoMuteChanged();
170   void videoTorchChanged();
171   void renderingEnabledChanged();
172
173 private:
174   bool applyMode();
175   bool setDeviceId(const QVariant& deviceId);
176   bool setMode(const CameraMode& mode);
177
178   void resetCapabilities();
179
180   QtCamera *m_cam;
181   QtCamDevice *m_dev;
182   QVariant m_id;
183   CameraMode m_mode;
184   NotificationsContainer *m_notifications;
185
186   Zoom *m_zoom;
187   Flash *m_flash;
188   Scene *m_scene;
189   EvComp *m_evComp;
190   WhiteBalance *m_whiteBalance;
191   ColorTone *m_colorTone;
192   Iso *m_iso;
193   Exposure *m_exposure;
194   Aperture *m_aperture;
195   NoiseReduction *m_noiseReduction;
196   FlickerReduction *m_flickerReduction;
197   Focus *m_focus;
198   AutoFocus *m_autoFocus;
199   Roi *m_roi;
200
201   VideoMute *m_videoMute;
202   VideoTorch *m_videoTorch;
203   CameraConfig *m_config;
204 };
205
206 #endif /* CAMERA_H */