|
1 /* |
|
2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Helper class for CCamConfiguration |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "camlogging.h" |
|
20 #include "camconfigurationutility.h" |
|
21 #include "camconfigurationconstants.h" |
|
22 |
|
23 // --------------------------------------------------------------------------- |
|
24 // CamConfigurationUtility::PhotoSizeIndex |
|
25 // --------------------------------------------------------------------------- |
|
26 // |
|
27 TInt |
|
28 CamConfigurationUtility::PhotoSizeIndex( TInt aWidth, TInt aHeight ) |
|
29 { |
|
30 TInt index = KErrNotFound; |
|
31 for( TInt i=0; i<ECamPhotoSizeLast; i++ ) |
|
32 { |
|
33 if( KCamPhotoSizes[i].iWidth == aWidth && |
|
34 KCamPhotoSizes[i].iHeight == aHeight ) |
|
35 { |
|
36 index = i; |
|
37 break; |
|
38 } |
|
39 } |
|
40 |
|
41 return index; |
|
42 } |
|
43 |
|
44 // --------------------------------------------------------------------------- |
|
45 // CamConfigurationUtility::VideoSizeIndex |
|
46 // --------------------------------------------------------------------------- |
|
47 // |
|
48 TInt |
|
49 CamConfigurationUtility::VideoSizeIndex( TInt aWidth, TInt aHeight ) |
|
50 { |
|
51 TInt index = KErrNotFound; |
|
52 for( TInt i=0; i<ECamVideoResolutionLast; i++ ) |
|
53 { |
|
54 if( KCamVideoSizes[i].iWidth == aWidth && |
|
55 KCamVideoSizes[i].iHeight == aHeight ) |
|
56 { |
|
57 index = i; |
|
58 break; |
|
59 } |
|
60 } |
|
61 |
|
62 return index; |
|
63 } |
|
64 |
|
65 |
|
66 // --------------------------------------------------------------------------- |
|
67 // CamConfigurationUtility::AdjustPrintQualities |
|
68 // --------------------------------------------------------------------------- |
|
69 // |
|
70 void |
|
71 CamConfigurationUtility::AdjustPrintQualities( RArray<TCamImageQualityData>& aPhotoQualities ) |
|
72 { |
|
73 TInt n = aPhotoQualities.Count(); |
|
74 |
|
75 //TInt numPrint = 0; |
|
76 //TInt lastPrintIndex = KErrNotFound; |
|
77 |
|
78 for( int i=0; i<n; i++ ) |
|
79 { |
|
80 TCamImageQuality& quality( aPhotoQualities[i].iPhotoQualitySetting.iPhotoQualityId ); |
|
81 |
|
82 quality = static_cast<TCamImageQuality>( i ); |
|
83 } |
|
84 |
|
85 /* |
|
86 if( EImageQualityPrint == quality ) |
|
87 { |
|
88 if( !numPrint ) |
|
89 { |
|
90 // This is the first print quality, so it should be print high |
|
91 quality = EImageQualityPrintHigh; |
|
92 } |
|
93 |
|
94 numPrint++; |
|
95 lastPrintIndex = i; |
|
96 } |
|
97 } |
|
98 |
|
99 if( numPrint > 2 ) |
|
100 { |
|
101 // There ECamQualityPrintHigh and more than one EImageQualityPrint |
|
102 // Change last of them to ECamImageQualityPrintLow |
|
103 aPhotoQualities[lastPrintIndex].iPhotoQualitySetting.iPhotoQualityId |
|
104 = EImageQualityPrintLow; |
|
105 } |
|
106 |
|
107 */ |
|
108 } |
|
109 |
|
110 // --------------------------------------------------------------------------- |
|
111 // CamConfigurationUtility::SetVideoQualityLevels |
|
112 // --------------------------------------------------------------------------- |
|
113 // |
|
114 void |
|
115 CamConfigurationUtility::SetVideoQualityLevels( RArray<TCamVideoQualityData>& aOrderedArray ) |
|
116 { |
|
117 TInt n = aOrderedArray.Count(); |
|
118 |
|
119 // Set quality setting values for each quality |
|
120 // Only 3 or 5 qualities are supported |
|
121 if( n==3 ) |
|
122 { |
|
123 aOrderedArray[0].iQualitySetting = ECamVideoQualityHigh; |
|
124 aOrderedArray[1].iQualitySetting = ECamVideoQualityNormalHigh; |
|
125 aOrderedArray[2].iQualitySetting = ECamVideoQualitySharing; |
|
126 aOrderedArray[2].iQualitySettings.iVideoLength = ECamVideoClipShort; |
|
127 } |
|
128 else |
|
129 if( n==5 ) |
|
130 { |
|
131 aOrderedArray[0].iQualitySetting = ECamVideoQualityHigh; |
|
132 aOrderedArray[1].iQualitySetting = ECamVideoQualityNormalHigh; |
|
133 aOrderedArray[2].iQualitySetting = ECamVideoQualityNormal; |
|
134 aOrderedArray[3].iQualitySetting = ECamVideoQualityNormalLow; |
|
135 aOrderedArray[4].iQualitySetting = ECamVideoQualitySharing; |
|
136 aOrderedArray[4].iQualitySettings.iVideoLength = ECamVideoClipShort; |
|
137 } |
|
138 else |
|
139 { |
|
140 PRINT1( _L("Camera <> CamConfigurationUtility::SetVideoQualityLevels - Invalid number of levels (%d)"), n ); |
|
141 User::Panic( KCamConfigPanicId, ECamConfigPanicInvalidNumberOfQualities ); |
|
142 } |
|
143 |
|
144 // Set quality level for iQualitySettings. This is just the |
|
145 // quality's index in the array. |
|
146 for( TInt i=0; i<n; i++ ) |
|
147 { |
|
148 aOrderedArray[i].iQualitySettings.iQualityLevel = i; |
|
149 } |
|
150 |
|
151 } |
|
152 |
|
153 // --------------------------------------------------------------------------- |
|
154 // CamConfigurationUtility::AddToArrayL |
|
155 // --------------------------------------------------------------------------- |
|
156 // |
|
157 void |
|
158 CamConfigurationUtility::AddToArrayL( TInt aValue, RArray<TInt>& aArray ) |
|
159 { |
|
160 if( aArray.Find( aValue ) == KErrNotFound ) |
|
161 { |
|
162 aArray.AppendL( aValue ); |
|
163 } |
|
164 } |
|
165 |
|
166 // --------------------------------------------------------------------------- |
|
167 // CamConfigurationUtility::VideoResolution |
|
168 // --------------------------------------------------------------------------- |
|
169 // |
|
170 TInt |
|
171 CamConfigurationUtility::VideoResolution( TInt aWidth, TInt aHeight ) |
|
172 { |
|
173 RDebug::Print( _L("VideoResolution( %d, %d) "), aWidth, aHeight ); |
|
174 for( TInt i=0; i<ECamVideoResolutionLast; i++ ) |
|
175 { |
|
176 if( KCamVideoSizes[i].iWidth == aWidth && |
|
177 KCamVideoSizes[i].iHeight == aHeight ) |
|
178 { |
|
179 return KCamVideoSizes[i].iVideoRes; |
|
180 } |
|
181 } |
|
182 |
|
183 User::Panic( KCamConfigPanicId, ECamConfigPanicNoVideoRes ); |
|
184 return KErrNotSupported; |
|
185 } |
|
186 |
|
187 // --------------------------------------------------------------------------- |
|
188 // CamConfigurationUtility::CamVideoResolution |
|
189 // --------------------------------------------------------------------------- |
|
190 // |
|
191 TInt |
|
192 CamConfigurationUtility::CamVideoResolution( TInt aWidth, TInt aHeight ) |
|
193 { |
|
194 RDebug::Print( _L("VideoResolution( %d, %d) "), aWidth, aHeight ); |
|
195 for( TInt i=0; i<ECamVideoResolutionLast; i++ ) |
|
196 { |
|
197 if( KCamVideoSizes[i].iWidth == aWidth && |
|
198 KCamVideoSizes[i].iHeight == aHeight ) |
|
199 { |
|
200 return KCamVideoSizes[i].iCamVideoRes; |
|
201 } |
|
202 } |
|
203 |
|
204 User::Panic( KCamConfigPanicId, ECamConfigPanicNoVideoRes ); |
|
205 return KErrNotSupported; |
|
206 } |
|
207 |
|
208 // --------------------------------------------------------------------------- |
|
209 // CamConfigurationUtility::CamVideoResolution |
|
210 // --------------------------------------------------------------------------- |
|
211 // |
|
212 TSize |
|
213 CamConfigurationUtility::CamVideoResolution( TCamVideoResolution aResolution ) |
|
214 { |
|
215 RDebug::Print( _L("VideoResolution( TCamVideoResolution: %d) "), aResolution ); |
|
216 for( TInt i=0; i<ECamVideoResolutionLast; i++ ) |
|
217 { |
|
218 if( KCamVideoSizes[i].iCamVideoRes == aResolution ) |
|
219 { |
|
220 return TSize(KCamVideoSizes[i].iWidth, KCamVideoSizes[i].iHeight ); |
|
221 } |
|
222 } |
|
223 |
|
224 User::Panic( KCamConfigPanicId, ECamConfigPanicNoVideoRes ); |
|
225 return TSize(0,0);//KErrNotSupported; |
|
226 } |
|
227 |
|
228 // --------------------------------------------------------------------------- |
|
229 // CamConfigurationUtility::VideoType |
|
230 // --------------------------------------------------------------------------- |
|
231 // |
|
232 TInt |
|
233 CamConfigurationUtility::VideoType( const TText8* aMimeType ) |
|
234 { |
|
235 const TPtrC8 mimeType( aMimeType ); |
|
236 if( mimeType == KCamMimeMp4 ) |
|
237 { |
|
238 return ECamVideoMpeg4; |
|
239 } |
|
240 else if( mimeType == KCamMime3gpp ) |
|
241 { |
|
242 return ECamVideoH263; |
|
243 } |
|
244 |
|
245 User::Panic( KCamConfigPanicId, ECamConfigPanicNoVideoType ); |
|
246 return KErrNotSupported; |
|
247 } |
|
248 |
|
249 |
|
250 // --------------------------------------------------------------------------- |
|
251 // CamConfigurationUtility::VideoDescId |
|
252 // --------------------------------------------------------------------------- |
|
253 // |
|
254 TCamVideoQualityDescription |
|
255 CamConfigurationUtility::VideoDescId( TInt aQualityValue ) |
|
256 { |
|
257 TCamVideoQualityDescription desc = ECamVideoQualityDescSharing; |
|
258 |
|
259 for( TInt i=0; i<ECamVideoQualityDescLast; i++ ) |
|
260 { |
|
261 if( aQualityValue >= KCamVideoQualityMappings[i].iCamcorderVisibleMin ) |
|
262 { |
|
263 desc = KCamVideoQualityMappings[i].iDesc; |
|
264 break; |
|
265 } |
|
266 } |
|
267 |
|
268 return desc; |
|
269 } |
|
270 |
|
271 // --------------------------------------------------------------------------- |
|
272 // CamConfigurationUtility::ImageType |
|
273 // --------------------------------------------------------------------------- |
|
274 // |
|
275 TCamImageType |
|
276 CamConfigurationUtility::ImageType( TInt aValue ) |
|
277 { |
|
278 if( aValue >= KCamImageLargeTypeMin ) |
|
279 { |
|
280 return ECamImageTypeLarge; |
|
281 } |
|
282 else if( aValue >= KCamImageMediumTypeMin ) |
|
283 { |
|
284 return ECamImageTypeMedium; |
|
285 } |
|
286 else |
|
287 { |
|
288 return ECamImageTypeSmall; |
|
289 } |
|
290 } |
|
291 |
|
292 // --------------------------------------------------------------------------- |
|
293 // CamConfigurationUtility::IsSupported |
|
294 // --------------------------------------------------------------------------- |
|
295 // |
|
296 TBool |
|
297 CamConfigurationUtility::IsSupported( TInt aValue, TCamItemType aItemType, const TCamImageQualityData& aData ) |
|
298 { |
|
299 switch( aItemType ) |
|
300 { |
|
301 case ECamItemPhotoSize: |
|
302 { |
|
303 if( aValue == aData.iPhotoSize.iSizeId ) |
|
304 { |
|
305 return ETrue; |
|
306 } |
|
307 break; |
|
308 } |
|
309 case ECamItemPhotoQuality: |
|
310 { |
|
311 if( aValue == aData.iPhotoSize.iQualitySettingId ) |
|
312 { |
|
313 return ETrue; |
|
314 } |
|
315 break; |
|
316 } |
|
317 default: |
|
318 { |
|
319 User::Panic( KCamConfigPanicId, ECamConfigPanicInvalidItem ); |
|
320 } |
|
321 } |
|
322 return EFalse; |
|
323 } |
|
324 |
|
325 |
|
326 |
|
327 |
|
328 // --------------------------------------------------------------------------- |
|
329 // CamConfigurationUtility::MapDynamicSettingToSceneSetting |
|
330 // Get the scene setting id from dynamic setting id. |
|
331 // --------------------------------------------------------------------------- |
|
332 // |
|
333 TInt |
|
334 CamConfigurationUtility::MapDynamicSettingToSceneSetting( TInt aSettingId ) |
|
335 { |
|
336 switch( aSettingId ) |
|
337 { |
|
338 case ECamSettingItemDynamicVideoWhiteBalance: // fall through |
|
339 case ECamSettingItemDynamicPhotoWhiteBalance: |
|
340 return ECamSettingItemSceneAWBMode; |
|
341 |
|
342 case ECamSettingItemDynamicVideoExposure: // fall through |
|
343 case ECamSettingItemDynamicPhotoExposure: |
|
344 return ECamSettingItemSceneEV; |
|
345 |
|
346 case ECamSettingItemDynamicVideoFlash: // fall through |
|
347 case ECamSettingItemDynamicPhotoFlash: |
|
348 return ECamSettingItemSceneFlashMode; |
|
349 |
|
350 case ECamSettingItemDynamicVideoContrast: // fall through |
|
351 case ECamSettingItemDynamicPhotoContrast: |
|
352 return ECamSettingItemSceneContrast; |
|
353 |
|
354 case ECamSettingItemDynamicPhotoImageSharpness: |
|
355 return ECamSettingItemSceneSharpness; |
|
356 |
|
357 case ECamSettingItemDynamicVideoLightSensitivity: // fall through |
|
358 case ECamSettingItemDynamicPhotoLightSensitivity: |
|
359 return ECamSettingItemSceneISO; |
|
360 |
|
361 default: |
|
362 return KErrNotFound; |
|
363 } |
|
364 } |
|
365 |
|
366 // End of file |
|
367 |