1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the Qt Mobility Components. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #ifndef V4LCAMERASESSION_H |
|
43 #define V4LCAMERASESSION_H |
|
44 |
|
45 #include <QtCore/qobject.h> |
|
46 #include <QSocketNotifier> |
|
47 #include <QTime> |
|
48 #include <QUrl> |
|
49 #include <QFile> |
|
50 |
|
51 #include <qmediarecorder.h> |
|
52 #include <experimental/qcamera.h> |
|
53 #include <QtMultimedia/qvideoframe.h> |
|
54 #include <QtMultimedia/qabstractvideosurface.h> |
|
55 |
|
56 #include "cameraformatconverter.h" |
|
57 QTM_USE_NAMESPACE |
|
58 |
|
59 class V4LVideoRenderer; |
|
60 |
|
61 struct video_buffer { |
|
62 void* start; |
|
63 size_t length; |
|
64 }; |
|
65 |
|
66 class V4LCameraSession : public QObject |
|
67 { |
|
68 Q_OBJECT |
|
69 public: |
|
70 V4LCameraSession(QObject *parent = 0); |
|
71 ~V4LCameraSession(); |
|
72 |
|
73 bool deviceReady(); |
|
74 |
|
75 // camera controls |
|
76 |
|
77 int framerate() const; |
|
78 void setFrameRate(int rate); |
|
79 int brightness() const; |
|
80 void setBrightness(int b); |
|
81 int contrast() const; |
|
82 void setContrast(int c); |
|
83 int saturation() const; |
|
84 void setSaturation(int s); |
|
85 int hue() const; |
|
86 void setHue(int h); |
|
87 int sharpness() const; |
|
88 void setSharpness(int s); |
|
89 int zoom() const; |
|
90 void setZoom(int z); |
|
91 bool backlightCompensation() const; |
|
92 void setBacklightCompensation(bool); |
|
93 int whitelevel() const; |
|
94 void setWhitelevel(int w); |
|
95 int rotation() const; |
|
96 void setRotation(int r); |
|
97 bool flash() const; |
|
98 void setFlash(bool f); |
|
99 bool autofocus() const; |
|
100 void setAutofocus(bool f); |
|
101 |
|
102 QSize frameSize() const; |
|
103 void setFrameSize(const QSize& s); |
|
104 void setDevice(const QString &device); |
|
105 QList<QVideoFrame::PixelFormat> supportedPixelFormats(); |
|
106 QVideoFrame::PixelFormat pixelFormat() const; |
|
107 void setPixelFormat(QVideoFrame::PixelFormat fmt); |
|
108 QList<QSize> supportedResolutions(); |
|
109 |
|
110 // media control |
|
111 |
|
112 bool setOutputLocation(const QUrl &sink); |
|
113 QUrl outputLocation() const; |
|
114 qint64 position() const; |
|
115 QMediaRecorder::State state() const; |
|
116 void record(); |
|
117 void pause(); |
|
118 void stop(); |
|
119 |
|
120 void setSurface(QAbstractVideoSurface* surface); |
|
121 |
|
122 void captureImage(const QString &fileName); |
|
123 |
|
124 void previewMode(bool value); |
|
125 void captureToFile(bool value); |
|
126 |
|
127 Q_SIGNALS: |
|
128 void cameraStateChanged(QCamera::State); |
|
129 void recordStateChanged(QMediaRecorder::State); |
|
130 void imageCaptured(const QString &fileName, const QImage &img); |
|
131 |
|
132 private Q_SLOTS: |
|
133 void captureFrame(); |
|
134 |
|
135 private: |
|
136 bool isFormatSupported(QVideoFrame::PixelFormat fmt); |
|
137 |
|
138 QSocketNotifier *notifier; |
|
139 QList<video_buffer> buffers; |
|
140 |
|
141 int sfd; |
|
142 QTime timeStamp; |
|
143 bool available; |
|
144 bool preview; |
|
145 bool toFile; |
|
146 bool active; |
|
147 QMediaRecorder::State m_state; |
|
148 QByteArray m_device; |
|
149 QUrl m_sink; |
|
150 QFile m_file; |
|
151 V4LVideoRenderer* m_output; |
|
152 QAbstractVideoSurface* m_surface; |
|
153 QVideoFrame::PixelFormat pixelF; |
|
154 QVideoFrame::PixelFormat savedPixelF; |
|
155 QSize m_windowSize; |
|
156 QList<QSize> resolutions; |
|
157 QList<unsigned int> formats; |
|
158 |
|
159 CameraFormatConverter* converter; |
|
160 |
|
161 QString m_snapshot; |
|
162 }; |
|
163 |
|
164 #endif |
|