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 #include "s60videoencoder.h" |
|
43 #include "s60camerasession.h" |
|
44 |
|
45 #include <QtCore/qdebug.h> |
|
46 |
|
47 S60VideoEncoder::S60VideoEncoder(QObject *parent) |
|
48 :QVideoEncoderControl(parent) |
|
49 { |
|
50 } |
|
51 |
|
52 S60VideoEncoder::S60VideoEncoder(QObject *session, QObject *parent) |
|
53 :QVideoEncoderControl(parent) |
|
54 { |
|
55 // use cast if we want to change session class later on.. |
|
56 m_session = qobject_cast<S60CameraSession*>(session); |
|
57 } |
|
58 |
|
59 S60VideoEncoder::~S60VideoEncoder() |
|
60 { |
|
61 } |
|
62 |
|
63 QStringList S60VideoEncoder::supportedVideoCodecs() const |
|
64 { |
|
65 return m_session->supportedVideoCaptureCodecs(); |
|
66 } |
|
67 |
|
68 QString S60VideoEncoder::videoCodecDescription(const QString &codecName) const |
|
69 { |
|
70 return m_session->videoCaptureCodecDescription(codecName); |
|
71 } |
|
72 |
|
73 QString S60VideoEncoder::videoCodec() const |
|
74 { |
|
75 return m_session->videoCaptureCodec(); |
|
76 } |
|
77 |
|
78 void S60VideoEncoder::setVideoCodec(const QString &codecName) |
|
79 { |
|
80 m_session->setVideoCaptureCodec(codecName); |
|
81 } |
|
82 |
|
83 int S60VideoEncoder::bitRate() const |
|
84 { |
|
85 return m_session->bitrate(); |
|
86 } |
|
87 void S60VideoEncoder::setBitRate(int bitRate) |
|
88 { |
|
89 m_session->setBitrate(bitRate); |
|
90 } |
|
91 |
|
92 QtMedia::EncodingQuality S60VideoEncoder::quality() const |
|
93 { |
|
94 return m_session->captureQuality(); |
|
95 } |
|
96 |
|
97 void S60VideoEncoder::setQuality(QtMedia::EncodingQuality quality) |
|
98 { |
|
99 m_session->setCaptureQuality(quality); |
|
100 } |
|
101 |
|
102 QList< qreal > S60VideoEncoder::supportedFrameRates(const QVideoEncoderSettings &settings, bool *continuous) const |
|
103 { |
|
104 return m_session->supportedVideoFrameRates(); |
|
105 } |
|
106 |
|
107 qreal S60VideoEncoder::minimumFrameRate() const |
|
108 { |
|
109 QList<qreal> rates = m_session->supportedVideoFrameRates(); |
|
110 qreal minRate = 30.0; |
|
111 foreach (qreal rate, rates) |
|
112 minRate = qMin(minRate, rate); |
|
113 return minRate; |
|
114 } |
|
115 |
|
116 qreal S60VideoEncoder::maximumFrameRate() const |
|
117 { |
|
118 QList<qreal> rates = m_session->supportedVideoFrameRates(); |
|
119 qreal maxRate = 0.0; |
|
120 foreach (qreal rate, rates) |
|
121 maxRate = qMax(maxRate, rate); |
|
122 return maxRate; |
|
123 } |
|
124 |
|
125 qreal S60VideoEncoder::frameRate() const |
|
126 { |
|
127 return m_session->framerate(); |
|
128 } |
|
129 void S60VideoEncoder::setFrameRate(qreal frameRate) |
|
130 { |
|
131 m_session->setFrameRate(frameRate); |
|
132 } |
|
133 |
|
134 QList<QSize> S60VideoEncoder::supportedResolutions(const QVideoEncoderSettings &settings, bool *continuous) const |
|
135 { |
|
136 return m_session->supportedVideoResolutions(); |
|
137 } |
|
138 |
|
139 QSize S60VideoEncoder::minimumResolution() const |
|
140 { |
|
141 QSize minimumSize; |
|
142 QList<QSize> sizes = m_session->supportedVideoResolutions(); |
|
143 |
|
144 minimumSize = sizes.first(); |
|
145 |
|
146 for(int i=0;i<sizes.size();i++) { |
|
147 if(sizes.at(i).width() < minimumSize.width()) |
|
148 minimumSize = sizes.at(i); |
|
149 } |
|
150 |
|
151 return minimumSize; |
|
152 } |
|
153 |
|
154 QSize S60VideoEncoder::maximumResolution() const |
|
155 { |
|
156 QSize maxSize; |
|
157 QList<QSize> sizes = m_session->supportedVideoResolutions(); |
|
158 |
|
159 maxSize = sizes.first(); |
|
160 |
|
161 for(int i=0;i<sizes.size();i++) { |
|
162 if(sizes.at(i).width() > maxSize.width()) |
|
163 maxSize = sizes.at(i); |
|
164 } |
|
165 |
|
166 return maxSize; |
|
167 } |
|
168 |
|
169 QSize S60VideoEncoder::videoResolution() const |
|
170 { |
|
171 return m_session->videoResolution(); |
|
172 } |
|
173 |
|
174 void S60VideoEncoder::setResolution(const QSize resolution) |
|
175 { |
|
176 m_session->setVideoResolution(resolution); |
|
177 } |
|
178 |
|
179 QStringList S60VideoEncoder::supportedEncodingOptions(const QString &codec) const |
|
180 { |
|
181 Q_UNUSED(codec) |
|
182 QStringList list; |
|
183 return list; |
|
184 } |
|
185 |
|
186 QVariant S60VideoEncoder::encodingOption(const QString &codec, const QString &name) const |
|
187 { |
|
188 Q_UNUSED(codec) |
|
189 |
|
190 if(qstrcmp(name.toLocal8Bit().constData(), "bitrate") == 0) { |
|
191 return QVariant(m_session->bitrate()); |
|
192 } |
|
193 else if(qstrcmp(name.toLocal8Bit().constData(), "quality") == 0) { |
|
194 return QVariant(m_session->captureQuality()); |
|
195 } |
|
196 else if(qstrcmp(name.toLocal8Bit().constData(), "framerate") == 0) { |
|
197 return QVariant(m_session->framerate()); |
|
198 } |
|
199 else if(qstrcmp(name.toLocal8Bit().constData(), "resolution") == 0) { |
|
200 return QVariant(m_session->videoResolution()); |
|
201 } |
|
202 else |
|
203 return QVariant(); |
|
204 } |
|
205 |
|
206 void S60VideoEncoder::setEncodingOption( |
|
207 const QString &codec, const QString &name, const QVariant &value) |
|
208 { |
|
209 Q_UNUSED(codec) |
|
210 |
|
211 if(qstrcmp(name.toLocal8Bit().constData(), "bitrate") == 0) { |
|
212 setBitRate(value.toInt()); |
|
213 } |
|
214 else if(qstrcmp(name.toLocal8Bit().constData(), "quality") == 0) { |
|
215 setQuality((QtMedia::EncodingQuality)value.toInt()); |
|
216 } |
|
217 else if(qstrcmp(name.toLocal8Bit().constData(), "framerate") == 0) { |
|
218 setFrameRate(value.toInt()); |
|
219 } |
|
220 else if(qstrcmp(name.toLocal8Bit().constData(), "resolution") == 0) { |
|
221 setResolution(value.toSize()); |
|
222 } |
|
223 else |
|
224 qWarning() << "option: " << name << " is an unknown option!"; |
|
225 } |
|
226 |
|
227 QVideoEncoderSettings S60VideoEncoder::videoSettings() const |
|
228 { |
|
229 QVideoEncoderSettings settings; |
|
230 m_session->getCurrentVideoEncoderSettings(settings); |
|
231 return settings; |
|
232 } |
|
233 |
|
234 void S60VideoEncoder::setVideoSettings(const QVideoEncoderSettings &settings) |
|
235 { |
|
236 QVideoEncoderSettings tempSettings = settings; |
|
237 m_session->saveVideoEncoderSettings(tempSettings); |
|
238 } |
|
239 |
|
240 |
|
241 |
|