Added QtCamQuirks to libQtCamera and Quirks to libdeclarativeQtCamera
[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 class Quirks;
52
53 class Camera : public QObject {
54   Q_OBJECT
55
56   Q_PROPERTY(int deviceCount READ deviceCount NOTIFY deviceCountChanged)
57   Q_PROPERTY(QVariant deviceId READ deviceId NOTIFY deviceIdChanged);
58   Q_PROPERTY(CameraMode mode READ mode NOTIFY modeChanged);
59   Q_PROPERTY(bool idle READ isIdle NOTIFY idleStateChanged);
60   Q_PROPERTY(bool running READ isRunning NOTIFY runningStateChanged);
61   Q_PROPERTY(QString imageSuffix READ imageSuffix CONSTANT);
62   Q_PROPERTY(QString videoSuffix READ videoSuffix CONSTANT);
63   Q_PROPERTY(Sounds *sounds READ sounds WRITE setSounds NOTIFY soundsChanged);
64
65   Q_PROPERTY(Zoom *zoom READ zoom NOTIFY zoomChanged);
66   Q_PROPERTY(Flash *flash READ flash NOTIFY flashChanged);
67   Q_PROPERTY(Scene *scene READ scene NOTIFY sceneChanged);
68   Q_PROPERTY(EvComp *evComp READ evComp NOTIFY evCompChanged);
69   Q_PROPERTY(WhiteBalance *whiteBalance READ whiteBalance NOTIFY whiteBalanceChanged);
70   Q_PROPERTY(ColorTone *colorTone READ colorTone NOTIFY colorToneChanged);
71   Q_PROPERTY(Iso *iso READ iso NOTIFY isoChanged);
72   Q_PROPERTY(Exposure *exposure READ exposure NOTIFY exposureChanged);
73   Q_PROPERTY(Aperture *aperture READ aperture NOTIFY apertureChanged);
74   Q_PROPERTY(NoiseReduction *noiseReduction READ noiseReduction NOTIFY noiseReductionChanged);
75   Q_PROPERTY(FlickerReduction *flickerReduction READ flickerReduction NOTIFY flickerReductionChanged);
76   Q_PROPERTY(Focus *focus READ focus NOTIFY focusChanged);
77   Q_PROPERTY(AutoFocus *autoFocus READ autoFocus NOTIFY autoFocusChanged);
78   Q_PROPERTY(Roi *roi READ roi NOTIFY roiChanged);
79
80   Q_PROPERTY(VideoMute *videoMute READ videoMute NOTIFY videoMuteChanged);
81   Q_PROPERTY(VideoTorch *videoTorch READ videoTorch NOTIFY videoTorchChanged);
82
83   Q_PROPERTY(Quirks *quirks READ quirks NOTIFY quirksChanged);
84
85   // TODO: We need a setter here too.
86   Q_PROPERTY(CameraConfig *cameraConfig READ cameraConfig CONSTANT);
87
88   Q_ENUMS(CameraMode);
89
90 public:
91   typedef enum {
92     UnknownMode,
93     ImageMode,
94     VideoMode
95   } CameraMode;
96
97   Camera(QObject *parent = 0);
98   ~Camera();
99
100   int deviceCount() const;
101   Q_INVOKABLE QString deviceName(int index) const;
102   Q_INVOKABLE QVariant deviceId(int index) const;
103
104   Q_INVOKABLE bool reset(const QVariant& deviceId, const CameraMode& mode);
105
106   QVariant deviceId() const;
107
108   CameraMode mode();
109
110   QtCamDevice *device() const;
111
112   Q_INVOKABLE bool start();
113   Q_INVOKABLE bool stop(bool force = false);
114
115   bool isIdle();
116   bool isRunning();
117
118   QString imageSuffix() const;
119   QString videoSuffix() const;
120
121   Sounds *sounds() const;
122   void setSounds(Sounds *sounds);
123
124   Zoom *zoom() const;
125   Flash *flash() const;
126   Scene *scene() const;
127   EvComp *evComp() const;
128   WhiteBalance *whiteBalance() const;
129   ColorTone *colorTone() const;
130   Iso *iso() const;
131   Exposure *exposure() const;
132   Aperture *aperture() const;
133   NoiseReduction *noiseReduction() const;
134   FlickerReduction *flickerReduction() const;
135   Focus *focus() const;
136   AutoFocus *autoFocus() const;
137   Roi *roi() const;
138
139   VideoMute *videoMute() const;
140   VideoTorch *videoTorch() const;
141
142   Quirks *quirks() const;
143
144   CameraConfig *cameraConfig() const;
145
146 signals:
147   void deviceCountChanged();
148   void deviceIdChanged();
149   void prepareForDeviceChange();
150   void deviceChanged();
151   void modeChanged();
152   void idleStateChanged();
153   void runningStateChanged();
154   void error(const QString& message, int code, const QString& debug);
155   void soundsChanged();
156   void renderAreaChanged();
157   void videoResolutionChanged();
158
159   void zoomChanged();
160   void flashChanged();
161   void sceneChanged();
162   void evCompChanged();
163   void whiteBalanceChanged();
164   void colorToneChanged();
165   void isoChanged();
166   void exposureChanged();
167   void apertureChanged();
168   void noiseReductionChanged();
169   void flickerReductionChanged();
170   void focusChanged();
171   void autoFocusChanged();
172   void roiChanged();
173
174   void videoMuteChanged();
175   void videoTorchChanged();
176   void renderingEnabledChanged();
177   void quirksChanged();
178
179 private:
180   bool applyMode();
181   bool setDeviceId(const QVariant& deviceId);
182   bool setMode(const CameraMode& mode);
183
184   void resetCapabilities();
185
186   QtCamera *m_cam;
187   QtCamDevice *m_dev;
188   QVariant m_id;
189   CameraMode m_mode;
190   NotificationsContainer *m_notifications;
191
192   Zoom *m_zoom;
193   Flash *m_flash;
194   Scene *m_scene;
195   EvComp *m_evComp;
196   WhiteBalance *m_whiteBalance;
197   ColorTone *m_colorTone;
198   Iso *m_iso;
199   Exposure *m_exposure;
200   Aperture *m_aperture;
201   NoiseReduction *m_noiseReduction;
202   FlickerReduction *m_flickerReduction;
203   Focus *m_focus;
204   AutoFocus *m_autoFocus;
205   Roi *m_roi;
206
207   VideoMute *m_videoMute;
208   VideoTorch *m_videoTorch;
209   CameraConfig *m_config;
210   Quirks *m_quirks;
211 };
212
213 #endif /* CAMERA_H */