enable fence sync objects because they are needed by video player.
[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 <QDeclarativeItem>
27 #include <QVariant>
28 #include <QPointer>
29
30 class QtCamera;
31 class QtCamDevice;
32 class QtCamGraphicsViewfinder;
33 class DeclarativeQtCameraNotifications;
34 class NotificationsContainer;
35 class Zoom;
36 class Flash;
37 class Scene;
38 class EvComp;
39 class WhiteBalance;
40 class ColorTone;
41 class Iso;
42 class Exposure;
43 class Aperture;
44 class NoiseReduction;
45 class FlickerReduction;
46 class Focus;
47 class AutoFocus;
48 class Roi;
49 class VideoMute;
50 class VideoTorch;
51 class CameraConfig;
52
53 class Camera : public QDeclarativeItem {
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(DeclarativeQtCameraNotifications *notifications READ notifications WRITE setNotifications NOTIFY notificationsChanged);
64
65   Q_PROPERTY(QRectF renderArea READ renderArea NOTIFY renderAreaChanged);
66   Q_PROPERTY(QSizeF videoResolution READ videoResolution NOTIFY videoResolutionChanged);
67
68   Q_PROPERTY(Zoom *zoom READ zoom NOTIFY zoomChanged);
69   Q_PROPERTY(Flash *flash READ flash NOTIFY flashChanged);
70   Q_PROPERTY(Scene *scene READ scene NOTIFY sceneChanged);
71   Q_PROPERTY(EvComp *evComp READ evComp NOTIFY evCompChanged);
72   Q_PROPERTY(WhiteBalance *whiteBalance READ whiteBalance NOTIFY whiteBalanceChanged);
73   Q_PROPERTY(ColorTone *colorTone READ colorTone NOTIFY colorToneChanged);
74   Q_PROPERTY(Iso *iso READ iso NOTIFY isoChanged);
75   Q_PROPERTY(Exposure *exposure READ exposure NOTIFY exposureChanged);
76   Q_PROPERTY(Aperture *aperture READ aperture NOTIFY apertureChanged);
77   Q_PROPERTY(NoiseReduction *noiseReduction READ noiseReduction NOTIFY noiseReductionChanged);
78   Q_PROPERTY(FlickerReduction *flickerReduction READ flickerReduction NOTIFY flickerReductionChanged);
79   Q_PROPERTY(Focus *focus READ focus NOTIFY focusChanged);
80   Q_PROPERTY(AutoFocus *autoFocus READ autoFocus NOTIFY autoFocusChanged);
81   Q_PROPERTY(Roi *roi READ roi NOTIFY roiChanged);
82
83   Q_PROPERTY(VideoMute *videoMute READ videoMute NOTIFY videoMuteChanged);
84   Q_PROPERTY(VideoTorch *videoTorch READ videoTorch NOTIFY videoTorchChanged);
85
86   Q_PROPERTY(bool renderingEnabled READ isRenderingEnabled WRITE setRenderingEnabled NOTIFY renderingEnabledChanged);
87   // TODO: We need a setter here too.
88   Q_PROPERTY(CameraConfig *cameraConfig READ cameraConfig CONSTANT);
89
90   Q_ENUMS(CameraMode);
91
92 public:
93   typedef enum {
94     UnknownMode,
95     ImageMode,
96     VideoMode
97   } CameraMode;
98
99   Camera(QDeclarativeItem *parent = 0);
100   ~Camera();
101
102   virtual void componentComplete();
103
104   int deviceCount() const;
105   Q_INVOKABLE QString deviceName(int index) const;
106   Q_INVOKABLE QVariant deviceId(int index) const;
107
108   Q_INVOKABLE bool reset(const QVariant& deviceId, const CameraMode& mode);
109
110   QVariant deviceId() const;
111
112   CameraMode mode();
113
114   QtCamDevice *device() const;
115
116   Q_INVOKABLE bool start();
117   Q_INVOKABLE bool stop(bool force = false);
118
119   bool isIdle();
120   bool isRunning();
121
122   QString imageSuffix() const;
123   QString videoSuffix() const;
124
125   DeclarativeQtCameraNotifications *notifications() const;
126   void setNotifications(DeclarativeQtCameraNotifications *notifications);
127
128   Zoom *zoom() const;
129   Flash *flash() const;
130   Scene *scene() const;
131   EvComp *evComp() const;
132   WhiteBalance *whiteBalance() const;
133   ColorTone *colorTone() const;
134   Iso *iso() const;
135   Exposure *exposure() const;
136   Aperture *aperture() const;
137   NoiseReduction *noiseReduction() const;
138   FlickerReduction *flickerReduction() const;
139   Focus *focus() const;
140   AutoFocus *autoFocus() const;
141   Roi *roi() const;
142
143   VideoMute *videoMute() const;
144   VideoTorch *videoTorch() const;
145
146   QRectF renderArea() const;
147   QSizeF videoResolution() const;
148
149   bool isRenderingEnabled() const;
150   void setRenderingEnabled(bool enabled);
151
152   CameraConfig *cameraConfig() const;
153
154 signals:
155   void deviceCountChanged();
156   void deviceIdChanged();
157   void deviceChanged();
158   void modeChanged();
159   void idleStateChanged();
160   void runningStateChanged();
161   void error(const QString& message, int code, const QString& debug);
162   void notificationsChanged();
163   void renderAreaChanged();
164   void videoResolutionChanged();
165
166   void zoomChanged();
167   void flashChanged();
168   void sceneChanged();
169   void evCompChanged();
170   void whiteBalanceChanged();
171   void colorToneChanged();
172   void isoChanged();
173   void exposureChanged();
174   void apertureChanged();
175   void noiseReductionChanged();
176   void flickerReductionChanged();
177   void focusChanged();
178   void autoFocusChanged();
179   void roiChanged();
180
181   void videoMuteChanged();
182   void videoTorchChanged();
183   void renderingEnabledChanged();
184
185 protected:
186   void geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry);
187
188 private:
189   bool applyMode();
190   bool setDeviceId(const QVariant& deviceId);
191   bool setMode(const CameraMode& mode);
192
193   void resetCapabilities();
194
195   QtCamera *m_cam;
196   QtCamDevice *m_dev;
197   QVariant m_id;
198   QtCamGraphicsViewfinder *m_vf;
199   CameraMode m_mode;
200   NotificationsContainer *m_notifications;
201
202   Zoom *m_zoom;
203   Flash *m_flash;
204   Scene *m_scene;
205   EvComp *m_evComp;
206   WhiteBalance *m_whiteBalance;
207   ColorTone *m_colorTone;
208   Iso *m_iso;
209   Exposure *m_exposure;
210   Aperture *m_aperture;
211   NoiseReduction *m_noiseReduction;
212   FlickerReduction *m_flickerReduction;
213   Focus *m_focus;
214   AutoFocus *m_autoFocus;
215   Roi *m_roi;
216
217   VideoMute *m_videoMute;
218   VideoTorch *m_videoTorch;
219   CameraConfig *m_config;
220 };
221
222 #endif /* CAMERA_H */