|
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: Implementation of Dynamic Configuration |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <e32debug.h> // RDebug |
|
20 #include "camconfiguration.h" |
|
21 #include "camconfigurationutility.h" |
|
22 #include "imagingconfigmanager.h" |
|
23 #include "CamUtility.h" |
|
24 #include "camconfigurationconstants.h" |
|
25 |
|
26 const TInt KReserveedSpace = 160000; |
|
27 |
|
28 // --------------------------------------------------------------------------- |
|
29 // CCamConfiguration::CCamConfiguration |
|
30 // --------------------------------------------------------------------------- |
|
31 // |
|
32 CCamConfiguration::CCamConfiguration(): |
|
33 iPrimaryCameraDisplayId( KCamPrimaryCameraDisplayId ), |
|
34 iSecondaryCameraDisplayId( KCamSecondaryCameraDisplayId ) |
|
35 { |
|
36 } |
|
37 |
|
38 // --------------------------------------------------------------------------- |
|
39 // CCamConfiguration::~CCamConfiguration |
|
40 // --------------------------------------------------------------------------- |
|
41 // |
|
42 CCamConfiguration::~CCamConfiguration() |
|
43 { |
|
44 // Quality data arrays |
|
45 iPrimaryCameraPhotoQualities.Close(); |
|
46 iSecondaryCameraPhotoQualities.Close(); |
|
47 iVideoQualities.Close(); |
|
48 |
|
49 delete iIcm; |
|
50 |
|
51 // String data |
|
52 for( TInt i=iStrings8.Count()-1; i>=0; i-- ) |
|
53 { |
|
54 HBufC8* str = iStrings8[i]; |
|
55 iStrings8.Remove( i ); |
|
56 delete str; |
|
57 } |
|
58 iStrings8.Close(); |
|
59 for( TInt i=iStrings16.Count()-1; i>=0; i-- ) |
|
60 { |
|
61 HBufC16* str = iStrings16[i]; |
|
62 iStrings16.Remove( i ); |
|
63 delete str; |
|
64 } |
|
65 iStrings16.Close(); |
|
66 } |
|
67 |
|
68 // --------------------------------------------------------------------------- |
|
69 // CCamConfiguration::NewL |
|
70 // --------------------------------------------------------------------------- |
|
71 // |
|
72 CCamConfiguration* |
|
73 CCamConfiguration::NewL() |
|
74 { |
|
75 CCamConfiguration* self = new (ELeave) CCamConfiguration; |
|
76 CleanupStack::PushL( self ); |
|
77 self->ConstructL(); |
|
78 CleanupStack::Pop( self ); |
|
79 return self; |
|
80 } |
|
81 |
|
82 // --------------------------------------------------------------------------- |
|
83 // CCamConfiguration::ConstructL |
|
84 // --------------------------------------------------------------------------- |
|
85 // |
|
86 void |
|
87 CCamConfiguration::ConstructL() |
|
88 { |
|
89 PRINT( _L("Camera => CCamConfiguration::ConstructL") ); |
|
90 |
|
91 PRINT( _L("Camera <> CCamConfiguration::ConstructL - Instantiate ICM") ); |
|
92 iIcm = CImagingConfigManager::NewL(); |
|
93 |
|
94 PRINT( _L("Camera <> CCamConfiguration::ConstructL - Init image qualities") ); |
|
95 InitializeImageQualitiesL(); |
|
96 |
|
97 PRINT( _L("Camera <> CCamConfiguration::ConstructL - Init video qualities") ); |
|
98 InitializeVideoQualitiesL(); |
|
99 |
|
100 PRINT( _L("Camera <= CCamConfiguration::ConstructL") ); |
|
101 } |
|
102 |
|
103 // --------------------------------------------------------------------------- |
|
104 // CCamConfiguration::InitializeImageQualitiesL |
|
105 // --------------------------------------------------------------------------- |
|
106 // |
|
107 void |
|
108 CCamConfiguration::InitializeImageQualitiesL() |
|
109 { |
|
110 PRINT( _L("Camera => CCamConfiguration::InitializeImageQualitiesL") ); |
|
111 TInt totalLevels = iIcm->NumberOfImageQualityLevels(); |
|
112 |
|
113 CArrayFixFlat<TUint>* levels |
|
114 = new (ELeave) CArrayFixFlat<TUint>( totalLevels ); |
|
115 CleanupStack::PushL( levels ); |
|
116 TImageQualitySet set; |
|
117 TCamImageQualityData data; |
|
118 |
|
119 // Get primary camera levels |
|
120 if( iPrimaryCameraDisplayId ) |
|
121 { |
|
122 PRINT( _L("Camera <> CCamConfiguration::InitializeImageQualitiesL *** Primary camera qualities ***") ); |
|
123 iIcm->GetImageQualityLevelsL( *levels, iPrimaryCameraDisplayId ); |
|
124 TInt numLevels( levels->Count() ); |
|
125 PRINT1(_L("Camera <> CCamConfiguration::InitializeImageQualitiesL - Total number of levels: %d"), numLevels ); |
|
126 |
|
127 for( int i=0; i<numLevels; i++ ) |
|
128 { |
|
129 iIcm->GetImageQualitySet( set, levels->At( i ), iPrimaryCameraDisplayId ); |
|
130 if( set.iCamcorderVisible > 0 ) |
|
131 { |
|
132 PRINT1( _L("Camera <> CCamConfiguration::InitializeImageQualitiesL - Set %d CamcorderVisible"), i ); |
|
133 |
|
134 InitializeImageQualityL( set, data ); |
|
135 AddToOrderedImageQualitiesArrayL( data, iPrimaryCameraPhotoQualities ); |
|
136 } |
|
137 } |
|
138 } |
|
139 |
|
140 // Adjust print qualities - print => print high/print/print low |
|
141 CamConfigurationUtility::AdjustPrintQualities( iPrimaryCameraPhotoQualities ); |
|
142 TInt numQualities = iPrimaryCameraPhotoQualities.Count(); |
|
143 |
|
144 // Get secondary camera levels |
|
145 if( iSecondaryCameraDisplayId ) |
|
146 { |
|
147 PRINT( _L("Camera <> CCamConfiguration::InitializeImageQualitiesL() *** Secondary camera qualities ***") ); |
|
148 iIcm->GetImageQualityLevelsL( *levels, iSecondaryCameraDisplayId ); |
|
149 TInt numLevels( levels->Count() ); |
|
150 PRINT1( _L("Camera <> CCamConfiguration::InitializeImageQualitiesL - Total number of levels: %d"), numLevels ); |
|
151 |
|
152 for( int i=0; i<numLevels; i++ ) |
|
153 { |
|
154 iIcm->GetImageQualitySet( set, levels->At( i ), iSecondaryCameraDisplayId ); |
|
155 if( set.iCamcorderVisible > 0 ) |
|
156 { |
|
157 PRINT1( _L("Camera <> CCamConfiguration::InitializeImageQualitiesL - Set %d CamcorderVisible"), i ); |
|
158 |
|
159 InitializeImageQualityL( set, data ); |
|
160 |
|
161 // Force image quality to secondary |
|
162 // data.iPhotoQualitySetting.iPhotoQualityId = EImageQualitySecondary; |
|
163 data.iPhotoQualitySetting.iPhotoQualityId |
|
164 = static_cast<TCamImageQuality>( numQualities++ ); |
|
165 data.iPhotoSize.iQualitySettingId = ECamImageQualitySecondary; |
|
166 |
|
167 AddToOrderedImageQualitiesArrayL( data, iSecondaryCameraPhotoQualities ); |
|
168 } |
|
169 } |
|
170 } |
|
171 |
|
172 CleanupStack::PopAndDestroy( levels ); |
|
173 |
|
174 PRINT( _L("Camera <= CCamConfiguration::InitializeImageQualitiesL") ); |
|
175 } |
|
176 |
|
177 // --------------------------------------------------------------------------- |
|
178 // CCamConfiguration::InitializeVideoQualitiesL |
|
179 // --------------------------------------------------------------------------- |
|
180 // |
|
181 void |
|
182 CCamConfiguration::InitializeVideoQualitiesL() |
|
183 { |
|
184 PRINT(_L("Camera => CCamConfiguration::InitializeVideoQualitiesL") ); |
|
185 TInt totalLevels = iIcm->NumberOfVideoQualityLevels(); |
|
186 CArrayFixFlat<TUint>* levels |
|
187 = new (ELeave) CArrayFixFlat<TUint>( totalLevels ); |
|
188 CleanupStack::PushL( levels ); |
|
189 TVideoQualitySet set; |
|
190 |
|
191 // Get primary camera levels |
|
192 if( iPrimaryCameraDisplayId ) |
|
193 { |
|
194 iIcm->GetVideoQualityLevelsL( *levels, iPrimaryCameraDisplayId ); |
|
195 TInt numLevels( levels->Count() ); |
|
196 PRINT1(_L("Camera <> CCamConfiguration::InitializeVideoQualitiesL - Total number of levels: %d"), numLevels ); |
|
197 |
|
198 for( int i=0; i<numLevels; i++ ) |
|
199 { |
|
200 iIcm->GetVideoQualitySet( set, levels->At( i ), iPrimaryCameraDisplayId ); |
|
201 if( set.iCamcorderVisible > 0 ) |
|
202 { |
|
203 PRINT1(_L("Camera <> CCamConfiguration::InitializeVideoQualitiesL - Set %d CamcorderVisible"), i ); |
|
204 |
|
205 TCamVideoQualityData data( CreateVideoQualityDataL( set ) ); |
|
206 AddToOrderedVideoQualitiesArrayL( data, iVideoQualities ); |
|
207 } |
|
208 } |
|
209 |
|
210 // Set the video quality values now that we have all data in sorted array |
|
211 CamConfigurationUtility::SetVideoQualityLevels( iVideoQualities ); |
|
212 } |
|
213 |
|
214 // Secondary camera video qualities from ICM are ignored. |
|
215 // The last primary camera quality is used in seconcary camera as well. |
|
216 |
|
217 CleanupStack::PopAndDestroy( levels ); |
|
218 |
|
219 // Get the average video bitrate scaler |
|
220 TCamcorderMMFPluginSettings mmfPluginSettings; |
|
221 User::LeaveIfError( iIcm->GetCamcorderMMFPluginSettings( mmfPluginSettings ) ); |
|
222 iCMRAvgVideoBitRateScaler = mmfPluginSettings.iCMRAvgVideoBitRateScaler; |
|
223 |
|
224 PRINT( _L("Camera <= CCamConfiguration::InitializeVideoQualitiesL") ); |
|
225 } |
|
226 |
|
227 |
|
228 // --------------------------------------------------------------------------- |
|
229 // CCamConfiguration::InitializeVideoQualitiesL |
|
230 // --------------------------------------------------------------------------- |
|
231 // |
|
232 void |
|
233 CCamConfiguration::AddToOrderedImageQualitiesArrayL( TCamImageQualityData& aQuality, |
|
234 RArray<TCamImageQualityData>& aArray ) |
|
235 { |
|
236 TBool added = EFalse; |
|
237 TInt numQualities = aArray.Count(); |
|
238 TInt numPixels = aQuality.iPhotoSize.iWidth*aQuality.iPhotoSize.iHeight; |
|
239 |
|
240 for( TInt i=0; i<numQualities; i++ ) |
|
241 { |
|
242 if( aArray[i].iPhotoSize.iWidth*aArray[i].iPhotoSize.iHeight < numPixels ) |
|
243 { |
|
244 aArray.InsertL( aQuality, i ); |
|
245 added = ETrue; |
|
246 break; |
|
247 } |
|
248 } |
|
249 |
|
250 if( !added ) |
|
251 { |
|
252 // Item is to be last in the array |
|
253 aArray.AppendL( aQuality ); |
|
254 } |
|
255 } |
|
256 |
|
257 // --------------------------------------------------------------------------- |
|
258 // CCamConfiguration::AddToOrderedVideoQualitiesArrayL |
|
259 // --------------------------------------------------------------------------- |
|
260 // |
|
261 void |
|
262 CCamConfiguration::AddToOrderedVideoQualitiesArrayL( TCamVideoQualityData& aQuality, |
|
263 RArray<TCamVideoQualityData>& aArray ) |
|
264 { |
|
265 TBool added( EFalse ); |
|
266 const TInt numQualities( aArray.Count() ); |
|
267 const TInt currValue( aQuality.iDescription ); |
|
268 |
|
269 for( TInt i=0; i<numQualities; i++ ) |
|
270 { |
|
271 if( aArray[i].iDescription > currValue ) |
|
272 { |
|
273 // aQuality should be before quality aArray[i] |
|
274 aArray.InsertL( aQuality, i ); |
|
275 added = ETrue; |
|
276 break; |
|
277 } |
|
278 } |
|
279 |
|
280 if( !added ) |
|
281 { |
|
282 // Item is to be last in the array |
|
283 aArray.AppendL( aQuality ); |
|
284 } |
|
285 } |
|
286 |
|
287 // --------------------------------------------------------------------------- |
|
288 // CCamConfiguration::InitializeImageQualityL |
|
289 // --------------------------------------------------------------------------- |
|
290 // |
|
291 void |
|
292 CCamConfiguration::InitializeImageQualityL( const TImageQualitySet& aSet, TCamImageQualityData& aData ) |
|
293 { |
|
294 PRINT3( _L("Camera => CCamConfiguration::InitializeImageQualityL - res: (%d, %d), compression: %d" ), |
|
295 aSet.iImageWidth, aSet.iImageHeight, aSet.iCompressionQuality ); |
|
296 // Find out the image quality/resolution id for the set |
|
297 TInt index = KErrNotFound; |
|
298 for( int i=0; i<ECamPhotoSizeLast; i++ ) |
|
299 { |
|
300 if( aSet.iImageWidth == KCamPhotoSizes[i].iWidth && |
|
301 aSet.iImageHeight == KCamPhotoSizes[i].iHeight ) |
|
302 { |
|
303 index = i; |
|
304 } |
|
305 } |
|
306 |
|
307 // Check that index is valid |
|
308 User::LeaveIfError( index ); |
|
309 |
|
310 // Copy the photo size data |
|
311 aData.iPhotoSize = KCamPhotoSizes[index]; |
|
312 |
|
313 // -------------------------------- |
|
314 // Photo quality settings |
|
315 |
|
316 // Set the photo resulution value, based on photo size value |
|
317 aData.iPhotoQualitySetting.iPhotoResolution |
|
318 = MapPhotoSizeToResolution( aData.iPhotoSize.iSizeId ); |
|
319 |
|
320 // Jpeg compression |
|
321 aData.iPhotoQualitySetting.iQualityLevel = aSet.iCompressionQuality; |
|
322 |
|
323 // Estimated file size |
|
324 aData.iFileSize = aSet.iEstimatedSize; |
|
325 |
|
326 // Set correct image quality description, quality id and icons |
|
327 TCamImageType type = CamConfigurationUtility::ImageType( aSet.iCamcorderVisible ); |
|
328 aData.iDescription = KCamImageQualityMappings[index][type].iDesc; |
|
329 |
|
330 if( ECamPhotoQualityDescLast == aData.iDescription ) |
|
331 { |
|
332 // No description defined for this quality => not supported |
|
333 User::Leave( KErrNotSupported ); |
|
334 } |
|
335 |
|
336 aData.iPhotoQualitySetting.iPhotoQualityId = KCamImageQualityMappings[index][type].iQuality; |
|
337 aData.iQualityIcons = KCamImageIcons[ aData.iDescription ]; |
|
338 |
|
339 PRINT( _L("Camera <= CCamConfiguration::InitializeImageQualityL") ); |
|
340 } |
|
341 |
|
342 // --------------------------------------------------------------------------- |
|
343 // CCamConfiguration::GetPsiIntArrayL |
|
344 // --------------------------------------------------------------------------- |
|
345 // |
|
346 void |
|
347 CCamConfiguration::GetPsiIntArrayL( TCamPsiKey aKey, RArray<TInt>& aArray ) const |
|
348 { |
|
349 PRINT1( _L("Camera => CCamConfiguration::GetPsiIntArrayL Key: %d"), aKey ); |
|
350 switch( aKey ) |
|
351 { |
|
352 case ECamPsiSupportedStillResolutions: |
|
353 { |
|
354 // Despite the name, returns array of TCamPhotoSizeId |
|
355 // The array contents must be ordered in TCamPhotoSizeId enum order |
|
356 for( TInt i=0; i<ECamPhotoSizeLast; i++ ) |
|
357 { |
|
358 AppendIfSupportedL( ECamItemPhotoSize, i, aArray ); |
|
359 } |
|
360 break; |
|
361 } |
|
362 |
|
363 case ECamPsiJpegDataSizes: |
|
364 { |
|
365 // Jpeg data sizes. Must be in same order as supported still resolutions, |
|
366 // so photo size is used for indexing. |
|
367 for( TInt i=0; i<ECamPhotoSizeLast; i++ ) |
|
368 { |
|
369 AppendIfSupportedL( ECamItemPhotoSize, i, aArray, ECamItemPhotoJpegSize ); |
|
370 } |
|
371 break; |
|
372 } |
|
373 |
|
374 case ECamPsiSequencePostProcessDataSizes: |
|
375 { |
|
376 // Jpeg data sizes. Must be in same order as supported still resolutions, |
|
377 // so photo size is used for indexing. |
|
378 for( TInt i=0; i<ECamPhotoSizeLast; i++ ) |
|
379 { |
|
380 AppendIfSupportedL( ECamItemPhotoSize, i, aArray, ECamItemSeqPostProcSize ); |
|
381 } |
|
382 break; |
|
383 } |
|
384 |
|
385 case ECamPsiSupportedStillQualities: |
|
386 { |
|
387 // This is array for primary camera qualities, so do not include secondary quality. |
|
388 // The results |
|
389 for( TInt i=0; i<ECamImageQualitySecondary; i++ ) |
|
390 { |
|
391 AppendIfSupportedL( ECamItemPhotoQuality, i, aArray ); |
|
392 } |
|
393 break; |
|
394 } |
|
395 |
|
396 case ECamPsiStillQualityIconIds: |
|
397 { |
|
398 // Icon ids. Must be in the same order as ECamPsiSupportedStillQualities, |
|
399 // so that type is used for indexing. |
|
400 // This is array for primary camera qualities, so do not include secondary quality. |
|
401 for( TInt i=0; i<ECamImageQualitySecondary; i++ ) |
|
402 { |
|
403 AppendIfSupportedL( ECamItemPhotoQuality, i, aArray, ECamItemSettingsIconId ); |
|
404 } |
|
405 break; |
|
406 } |
|
407 |
|
408 case ECamPsiPrecapStillQualityIconIds: |
|
409 { |
|
410 // Secondary camera quality is included |
|
411 for( TInt i=0; i<ECamImageQualityLast; i++ ) |
|
412 { |
|
413 AppendIfSupportedL( ECamItemPhotoQuality, i, aArray, ECamItemPrecapIconId ); |
|
414 } |
|
415 break; |
|
416 } |
|
417 |
|
418 case ECamPsiSupportedVideoResolutions: |
|
419 { |
|
420 for( TInt i=0; i<ECamVideoResolutionLast; i++ ) |
|
421 { |
|
422 AppendVideoResIfSupportedL( i, aArray ); |
|
423 } |
|
424 break; |
|
425 } |
|
426 |
|
427 case ECamPsiSupportedVideoQualities: |
|
428 { |
|
429 TInt n = iVideoQualities.Count(); |
|
430 for( TInt i=0; i<n; i++ ) |
|
431 { |
|
432 aArray.AppendL( iVideoQualities[i].iQualitySetting ); |
|
433 } |
|
434 break; |
|
435 } |
|
436 |
|
437 case ECamPsiPrecapVideoQualityIconIds: |
|
438 { |
|
439 TInt n = iVideoQualities.Count(); |
|
440 for( TInt i=0; i<n; i++ ) |
|
441 { |
|
442 aArray.AppendL( iVideoQualities[i].iQualityIcons.iPrecapIconId ); |
|
443 aArray.AppendL( iVideoQualities[i].iQualityIcons.iPrecapIconMask ); |
|
444 } |
|
445 break; |
|
446 } |
|
447 |
|
448 case ECamPsiVideoQualityIconIds: |
|
449 { |
|
450 TInt n = iVideoQualities.Count(); |
|
451 for( TInt i=0; i<n; i++ ) |
|
452 { |
|
453 aArray.AppendL( iVideoQualities[i].iQualityIcons.iSettingsIconId ); |
|
454 aArray.AppendL( iVideoQualities[i].iQualityIcons.iSettingsIconMask ); |
|
455 } |
|
456 break; |
|
457 } |
|
458 |
|
459 case ECamPsiVideoQualityFileTypeId: |
|
460 { |
|
461 TInt n = iVideoQualities.Count(); |
|
462 for( TInt i=0; i<n; i++ ) |
|
463 { |
|
464 aArray.AppendL( iVideoQualities[i].iFileTypeIcons.iIconId ); |
|
465 aArray.AppendL( iVideoQualities[i].iFileTypeIcons.iMask ); |
|
466 } |
|
467 break; |
|
468 } |
|
469 |
|
470 default: |
|
471 { |
|
472 PRINT( _L("Camera <> CCamConfiguration::GetPsiIntArrayL - Unknown key!") ); |
|
473 User::Panic( KCamConfigPanicId, ECamConfigPanicUnknownKey ); |
|
474 } |
|
475 |
|
476 } |
|
477 PRINT( _L("Camera <= CCamConfiguration::GetPsiIntArrayL") ); |
|
478 } |
|
479 |
|
480 // --------------------------------------------------------------------------- |
|
481 // CCamConfiguration::AppendIfSupportedL |
|
482 // --------------------------------------------------------------------------- |
|
483 // |
|
484 void |
|
485 CCamConfiguration::AppendIfSupportedL( TCamItemType aCheckType, TInt aValue, |
|
486 RArray<TInt>&aArray, TCamItemType aAppendType ) const |
|
487 { |
|
488 TInt n( iPrimaryCameraPhotoQualities.Count() ); |
|
489 for( TInt i=0; i<n; i++ ) |
|
490 { |
|
491 if( CamConfigurationUtility::IsSupported( aValue, aCheckType, |
|
492 iPrimaryCameraPhotoQualities[i] ) ) |
|
493 { |
|
494 if( ECamItemSame == aAppendType ) |
|
495 { |
|
496 // Simply append the current value |
|
497 aArray.AppendL( aValue ); |
|
498 } |
|
499 else |
|
500 { |
|
501 // Append something else corresponding the item |
|
502 AppendTypeL( aAppendType, aArray, iPrimaryCameraPhotoQualities[i] ); |
|
503 } |
|
504 |
|
505 return; |
|
506 } |
|
507 } |
|
508 |
|
509 n = iSecondaryCameraPhotoQualities.Count(); |
|
510 for( TInt i=0; i<n; i++ ) |
|
511 { |
|
512 if( CamConfigurationUtility::IsSupported( aValue, aCheckType, |
|
513 iSecondaryCameraPhotoQualities[i] ) ) |
|
514 { |
|
515 if( ECamItemSame == aAppendType ) |
|
516 { |
|
517 // Simply append the current value |
|
518 aArray.AppendL( aValue ); |
|
519 } |
|
520 else |
|
521 { |
|
522 // Append something else corresponding the item |
|
523 AppendTypeL( aAppendType, aArray, iSecondaryCameraPhotoQualities[i] ); |
|
524 } |
|
525 return; |
|
526 } |
|
527 } |
|
528 } |
|
529 |
|
530 |
|
531 // --------------------------------------------------------------------------- |
|
532 // CCamConfiguration::AppendTypeL |
|
533 // --------------------------------------------------------------------------- |
|
534 // |
|
535 void |
|
536 CCamConfiguration::AppendTypeL( TCamItemType aType, RArray<TInt>&aArray, const TCamImageQualityData& aData ) |
|
537 { |
|
538 switch( aType ) |
|
539 { |
|
540 case ECamItemSettingsIconId: |
|
541 { |
|
542 aArray.AppendL( aData.iQualityIcons.iSettingsIconId ); |
|
543 aArray.AppendL( aData.iQualityIcons.iSettingsIconMask ); |
|
544 break; |
|
545 } |
|
546 case ECamItemPrecapIconId: |
|
547 { |
|
548 aArray.AppendL( aData.iQualityIcons.iPrecapIconId ); |
|
549 aArray.AppendL( aData.iQualityIcons.iPrecapIconMask ); |
|
550 break; |
|
551 } |
|
552 case ECamItemPhotoJpegSize: |
|
553 { |
|
554 aArray.AppendL( aData.iFileSize ); |
|
555 break; |
|
556 } |
|
557 case ECamItemSeqPostProcSize: |
|
558 { |
|
559 aArray.AppendL( aData.iFileSize ); |
|
560 break; |
|
561 } |
|
562 default: |
|
563 { |
|
564 User::Panic( KCamConfigPanicId, ECamConfigPanicUnknownType ); |
|
565 } |
|
566 } |
|
567 } |
|
568 |
|
569 // --------------------------------------------------------------------------- |
|
570 // CCamConfiguration::NumImageQualities |
|
571 // --------------------------------------------------------------------------- |
|
572 // |
|
573 TInt |
|
574 CCamConfiguration::NumImageQualities() const |
|
575 { |
|
576 TInt count( iPrimaryCameraPhotoQualities.Count() ); |
|
577 if( iSecondaryCameraPhotoQualities.Count() > 0 ) |
|
578 { |
|
579 // Only one quality currently supported for secondary cam |
|
580 count++; |
|
581 // count += iSecondaryCameraPhotoQualities.Count(); |
|
582 } |
|
583 |
|
584 return count; |
|
585 } |
|
586 |
|
587 // --------------------------------------------------------------------------- |
|
588 // CCamConfiguration::SecondaryCameraImageQuality |
|
589 // --------------------------------------------------------------------------- |
|
590 // |
|
591 TInt |
|
592 CCamConfiguration::MmsImageQuality() const |
|
593 { |
|
594 // As the primary camera image qualities are sorted, MMS quality is the |
|
595 // last one in the qualities array. |
|
596 TInt index = iPrimaryCameraPhotoQualities.Count()-1; |
|
597 |
|
598 return index < 0 ? |
|
599 KErrNotFound : |
|
600 iPrimaryCameraPhotoQualities[index].iPhotoQualitySetting.iPhotoQualityId; |
|
601 } |
|
602 |
|
603 |
|
604 // --------------------------------------------------------------------------- |
|
605 // CCamConfiguration::SecondaryCameraImageQuality |
|
606 // --------------------------------------------------------------------------- |
|
607 // |
|
608 TInt |
|
609 CCamConfiguration::SecondaryCameraImageQuality() const |
|
610 { |
|
611 if( iSecondaryCameraPhotoQualities.Count() > 0 ) |
|
612 { |
|
613 return iSecondaryCameraPhotoQualities[0].iPhotoQualitySetting.iPhotoQualityId; |
|
614 } |
|
615 |
|
616 return KErrNotFound; |
|
617 } |
|
618 |
|
619 |
|
620 // --------------------------------------------------------------------------- |
|
621 // CCamConfiguration::ImageQuality |
|
622 // --------------------------------------------------------------------------- |
|
623 // |
|
624 const TCamPhotoQualitySetting& |
|
625 CCamConfiguration::ImageQuality( TInt aIndex ) const |
|
626 { |
|
627 const TInt count( iPrimaryCameraPhotoQualities.Count() ); |
|
628 if( aIndex >= 0 && aIndex < count ) |
|
629 { |
|
630 return iPrimaryCameraPhotoQualities[aIndex].iPhotoQualitySetting; |
|
631 } |
|
632 else |
|
633 { |
|
634 TInt secIndex = aIndex - count; |
|
635 if( secIndex >= 0 && |
|
636 secIndex < iSecondaryCameraPhotoQualities.Count() ) |
|
637 { |
|
638 return iSecondaryCameraPhotoQualities[secIndex].iPhotoQualitySetting; |
|
639 } |
|
640 |
|
641 User::Panic( KCamConfigPanicId, ECamConfigPanicNoQuality ); |
|
642 return iPrimaryCameraPhotoQualities[0].iPhotoQualitySetting; // Get rid of warning |
|
643 } |
|
644 } |
|
645 |
|
646 // --------------------------------------------------------------------------- |
|
647 // CCamConfiguration::ImageQualityData |
|
648 // --------------------------------------------------------------------------- |
|
649 // |
|
650 const TCamImageQualityData& |
|
651 CCamConfiguration::ImageQualityData( TInt aIndex ) const |
|
652 { |
|
653 const TInt count( iPrimaryCameraPhotoQualities.Count() ); |
|
654 if( aIndex >= 0 && aIndex < count ) |
|
655 { |
|
656 return iPrimaryCameraPhotoQualities[aIndex]; |
|
657 } |
|
658 else |
|
659 { |
|
660 TInt secIndex = aIndex - count; |
|
661 if( secIndex >= 0 && |
|
662 secIndex < iSecondaryCameraPhotoQualities.Count() ) |
|
663 { |
|
664 return iSecondaryCameraPhotoQualities[secIndex]; |
|
665 } |
|
666 |
|
667 User::Panic( KCamConfigPanicId, ECamConfigPanicNoQuality ); |
|
668 return iPrimaryCameraPhotoQualities[0]; // Get rid of warning |
|
669 } |
|
670 } |
|
671 |
|
672 // --------------------------------------------------------------------------- |
|
673 // CCamConfiguration::NumVideoQualities |
|
674 // --------------------------------------------------------------------------- |
|
675 // |
|
676 TInt |
|
677 CCamConfiguration::NumVideoQualities() const |
|
678 { |
|
679 return iVideoQualities.Count(); |
|
680 } |
|
681 |
|
682 // --------------------------------------------------------------------------- |
|
683 // CCamConfiguration::NumPrimaryImageQualities |
|
684 // --------------------------------------------------------------------------- |
|
685 // |
|
686 TInt |
|
687 CCamConfiguration::NumPrimaryImageQualities() const |
|
688 { |
|
689 return iPrimaryCameraPhotoQualities.Count(); |
|
690 } |
|
691 |
|
692 // --------------------------------------------------------------------------- |
|
693 // CCamConfiguration::SecondaryCameraVideoQuality |
|
694 // --------------------------------------------------------------------------- |
|
695 // |
|
696 TInt |
|
697 CCamConfiguration::SecondaryCameraVideoQuality() const |
|
698 { |
|
699 // Currently always the last of the video qualities |
|
700 // Currently always the last of the video qualities |
|
701 // As the camera video qualities are sorted, sharing quality is the |
|
702 // last one in the qualities array. |
|
703 TInt index = NumVideoQualities()-1; |
|
704 |
|
705 return index < 0 ? |
|
706 KErrNotFound : |
|
707 iVideoQualities[index].iQualitySettings.iQualityLevel; |
|
708 } |
|
709 |
|
710 // --------------------------------------------------------------------------- |
|
711 // CCamConfiguration::VideoQualitySetting |
|
712 // --------------------------------------------------------------------------- |
|
713 // |
|
714 TInt |
|
715 CCamConfiguration::VideoQualitySetting( TInt aIndex ) const |
|
716 { |
|
717 return iVideoQualities[aIndex].iQualitySetting; |
|
718 } |
|
719 |
|
720 // --------------------------------------------------------------------------- |
|
721 // CCamConfiguration::VideoQuality |
|
722 // --------------------------------------------------------------------------- |
|
723 // |
|
724 const TVideoQualitySettings& |
|
725 CCamConfiguration::VideoQuality( TInt aIndex ) const |
|
726 { |
|
727 return iVideoQualities[aIndex].iQualitySettings; |
|
728 } |
|
729 |
|
730 // --------------------------------------------------------------------------- |
|
731 // CCamConfiguration::MapSupportedQualityToQualityDescriptor |
|
732 // --------------------------------------------------------------------------- |
|
733 // |
|
734 TInt |
|
735 CCamConfiguration::MapSupportedQualityToQualityDescriptor( TBool aVideoMode, |
|
736 TInt aQualityVal ) const |
|
737 { |
|
738 if( aVideoMode ) |
|
739 { |
|
740 // Video mode |
|
741 TInt n = iVideoQualities.Count(); |
|
742 for( TInt i=0; i<n; i++ ) |
|
743 { |
|
744 const TCamVideoQualityData& data = iVideoQualities[i]; |
|
745 if( aQualityVal == data.iQualitySetting ) |
|
746 { |
|
747 return data.iDescription; |
|
748 } |
|
749 } |
|
750 |
|
751 // No description found for this quality => Not supported |
|
752 User::Panic( KCamConfigPanicId, ECamConfigPanicNoDescription ); |
|
753 return KErrNotSupported; |
|
754 } |
|
755 else |
|
756 { |
|
757 // Image mode |
|
758 TInt n = iPrimaryCameraPhotoQualities.Count(); |
|
759 for( TInt i=0; i<n; i++ ) |
|
760 { |
|
761 const TCamImageQualityData& data = iPrimaryCameraPhotoQualities[i]; |
|
762 if( aQualityVal == data.iPhotoSize.iQualitySettingId ) |
|
763 { |
|
764 return data.iDescription; |
|
765 } |
|
766 } |
|
767 |
|
768 // No description found for this quality value => Not supported |
|
769 User::Panic( KCamConfigPanicId, ECamConfigPanicNoDescription ); |
|
770 return KErrNotSupported; |
|
771 } |
|
772 |
|
773 } |
|
774 |
|
775 |
|
776 // --------------------------------------------------------------------------- |
|
777 // CCamConfiguration::MapPhotoSizeToResolution |
|
778 // --------------------------------------------------------------------------- |
|
779 // |
|
780 TCamImageResolution |
|
781 CCamConfiguration::MapPhotoSizeToResolution( TCamPhotoSizeId aSizeId ) |
|
782 { |
|
783 for( TInt i=0; i<ECamPhotoSizeLast; i++ ) |
|
784 { |
|
785 if( KCamPhotoSizes[i].iSizeId == aSizeId ) |
|
786 { |
|
787 return KCamPhotoSizes[i].iResolution; |
|
788 } |
|
789 } |
|
790 // Used as deafult in previous implementation |
|
791 return EImageResolutionMMS; |
|
792 } |
|
793 |
|
794 // --------------------------------------------------------------------------- |
|
795 // CCamConfiguration::MapResolutionToPhotoSize |
|
796 // --------------------------------------------------------------------------- |
|
797 // |
|
798 TCamPhotoSizeId |
|
799 CCamConfiguration::MapResolutionToPhotoSize( TCamImageResolution aResolution ) |
|
800 { |
|
801 for( TInt i=0; i<ECamPhotoSizeLast; i++ ) |
|
802 { |
|
803 if( KCamPhotoSizes[i].iResolution == aResolution ) |
|
804 { |
|
805 return KCamPhotoSizes[i].iSizeId; |
|
806 } |
|
807 } |
|
808 // Used as deafult in previous implementation |
|
809 return ECamPhotoSizeVGA; |
|
810 } |
|
811 |
|
812 // --------------------------------------------------------------------------- |
|
813 // CCamConfiguration::ImagesRemaining |
|
814 // --------------------------------------------------------------------------- |
|
815 // |
|
816 TInt |
|
817 CCamConfiguration::ImagesRemaining( TCamMediaStorage aStorage, |
|
818 TCamPhotoSizeId aSizeId, |
|
819 TInt aCriticalLevel, |
|
820 TBool /*aBurstActive*/ ) const |
|
821 { |
|
822 // PRINT( _L("Camera => CamUtility::ImagesRemaining") ); |
|
823 TInt64 memoryfree = 0; |
|
824 |
|
825 // Get the current amount of free memory on the phone. |
|
826 switch ( aStorage ) |
|
827 { |
|
828 case ECamMediaStoragePhone: |
|
829 memoryfree |
|
830 = CamUtility::MemoryFree( DriveInfo::EDefaultPhoneMemory, |
|
831 aCriticalLevel ); |
|
832 break; |
|
833 |
|
834 case ECamMediaStorageCard: |
|
835 PRINT( _L("Camera => CamUtility::ImagesRemaining, ECamMediaStorageCard") ); |
|
836 memoryfree |
|
837 = CamUtility::MemoryFree( DriveInfo::EDefaultRemovableMassStorage, |
|
838 aCriticalLevel ); |
|
839 break; |
|
840 |
|
841 case ECamMediaStorageMassStorage: |
|
842 PRINT( _L("Camera => CamUtility::ImagesRemaining, ECamMediaStorageMassStorage") ); |
|
843 memoryfree |
|
844 = CamUtility::MemoryFree( DriveInfo::EDefaultMassStorage, |
|
845 aCriticalLevel ); |
|
846 break; |
|
847 default: |
|
848 PRINT( _L("Camera => CamUtility::ImagesRemaining, default") ); |
|
849 break; |
|
850 }; |
|
851 |
|
852 TInt size = 1; |
|
853 |
|
854 TInt n=NumImageQualities(); |
|
855 for( TInt i=0; i<n; i++ ) |
|
856 { |
|
857 const TCamImageQualityData& data( ImageQualityData( i ) ); |
|
858 if( aSizeId == data.iPhotoSize.iSizeId ) |
|
859 { |
|
860 size = data.iFileSize; |
|
861 } |
|
862 } |
|
863 |
|
864 memoryfree -= KReserveedSpace; |
|
865 // In the case of exceptional circumstances, just return zero images remaining. |
|
866 if ( memoryfree <= 0 ) |
|
867 { |
|
868 memoryfree = 0; // To handle exceptional situation, just return zero images. |
|
869 } |
|
870 |
|
871 TInt64 images = memoryfree / size; |
|
872 |
|
873 images = Min( KMaxTInt, images ); // Truncate value to max possible. |
|
874 |
|
875 // PRINT1( _L("Camera <= CamUtility::ImagesRemaining %d"), (TInt)images ); |
|
876 return static_cast<TInt>( images ); // (nothing greater than TInt) |
|
877 } |
|
878 |
|
879 |
|
880 // --------------------------------------------------------------------------- |
|
881 // CCamConfiguration::AllocString8L |
|
882 // --------------------------------------------------------------------------- |
|
883 // |
|
884 const TUint8* |
|
885 CCamConfiguration::AllocString8L( const TUint8* aData ) |
|
886 { |
|
887 TPtrC8 ptr( aData ); |
|
888 HBufC8* data = HBufC8::NewLC( ptr.Length() + 1 ); |
|
889 data->Des().Copy( ptr ); |
|
890 data->Des().Append( '\0' ); |
|
891 |
|
892 iStrings8.AppendL( data ); |
|
893 |
|
894 CleanupStack::Pop( data ); |
|
895 |
|
896 return data->Ptr(); |
|
897 } |
|
898 |
|
899 // --------------------------------------------------------------------------- |
|
900 // CCamConfiguration::AllocString16L |
|
901 // --------------------------------------------------------------------------- |
|
902 // |
|
903 const TUint16* |
|
904 CCamConfiguration::AllocString16L( const TUint8* aData ) |
|
905 { |
|
906 TPtrC8 ptr( aData ); |
|
907 HBufC16* data = HBufC16::NewLC( ptr.Length() + 1 ); |
|
908 data->Des().Copy( ptr ); |
|
909 data->Des().Append( '\0' ); |
|
910 |
|
911 iStrings16.AppendL( data ); |
|
912 |
|
913 CleanupStack::Pop( data ); |
|
914 |
|
915 return data->Ptr(); |
|
916 } |
|
917 |
|
918 // --------------------------------------------------------------------------- |
|
919 // CCamConfiguration::CreateVideoQualityDataL |
|
920 // --------------------------------------------------------------------------- |
|
921 // |
|
922 TCamVideoQualityData |
|
923 CCamConfiguration::CreateVideoQualityDataL( const TVideoQualitySet& aSet ) |
|
924 { |
|
925 PRINT3( _L("Camera => CCamConfiguration::CreateVideoQualityDataL - res: (%d, %d), video bitrate: %d" ), |
|
926 aSet.iVideoWidth, aSet.iVideoHeight, aSet.iVideoBitRate ); |
|
927 |
|
928 TInt resIndex( CamConfigurationUtility::VideoSizeIndex( |
|
929 aSet.iVideoWidth, aSet.iVideoHeight ) ); |
|
930 if( resIndex < 0 ) |
|
931 { |
|
932 User::Panic( KCamConfigPanicId, ECamConfigPanicNoVideoRes ); |
|
933 } |
|
934 |
|
935 TCamVideoQualityDescription descType |
|
936 = CamConfigurationUtility::VideoDescId( aSet.iCamcorderVisible ); |
|
937 |
|
938 TInt videoType = CamConfigurationUtility::VideoType( aSet.iVideoFileMimeType ); |
|
939 |
|
940 // Convert FourCC value from TFourCC to asciiz string |
|
941 const TInt KFourCCLength = 5; // 4 characters + '\0' |
|
942 TText8 fourCCBuf[KFourCCLength ]; |
|
943 TPtr8 fourCC( fourCCBuf, KFourCCLength ); |
|
944 aSet.iAudioFourCCType.FourCC( &fourCC ); |
|
945 fourCC.Append( '\0' ); |
|
946 |
|
947 // Initialized as here to avoid const_casts for the text pointers |
|
948 TCamVideoQualityData data = |
|
949 { |
|
950 // TVideoQualitySettings: |
|
951 { |
|
952 0, // iQualityLevel - defined later |
|
953 KCamVideoSizes[resIndex].iCamVideoRes, // iVideoResolution |
|
954 aSet.iVideoFrameRate, // iVideoFrameRate |
|
955 aSet.iVideoBitRate, // iVideoBitRate |
|
956 aSet.iAudioBitRate, // iAudioBitRate |
|
957 AllocString8L( aSet.iVideoFileMimeType ), // iVideoMimeType |
|
958 AllocString16L( aSet.iPreferredSupplier ), // iPreferredSupplier |
|
959 AllocString8L( aSet.iVideoCodecMimeType ), // iVideoCodec |
|
960 AllocString8L( fourCCBuf ), // iAudioCodec |
|
961 CamConfigurationUtility::VideoType( aSet.iVideoFileMimeType ), // iVideoFileType |
|
962 ECamVideoClipMax // iVideoLength - changed later if necessary |
|
963 }, |
|
964 |
|
965 KCamVideoSizes[resIndex].iCamVideoRes, // iVideoResolution |
|
966 ECamVideoQualitySharing, // iQualitySetting - replaced later |
|
967 descType, // iDescription |
|
968 KCamVideoIcons[descType], |
|
969 KCamVideoTypeIcons[videoType] |
|
970 }; |
|
971 |
|
972 PRINT( _L("Camera <= CCamConfiguration::CreateVideoQualityDataL" ) ); |
|
973 return data; |
|
974 } |
|
975 |
|
976 // --------------------------------------------------------------------------- |
|
977 // CCamConfiguration::AppendVideoResIfSupportedL |
|
978 // --------------------------------------------------------------------------- |
|
979 // |
|
980 void |
|
981 CCamConfiguration::AppendVideoResIfSupportedL( TInt aValue, RArray<TInt>&aArray ) const |
|
982 { |
|
983 TInt n( iVideoQualities.Count() ); |
|
984 for( TInt i=0; i<n; i++ ) |
|
985 { |
|
986 if( iVideoQualities[i].iVideoResolution == aValue ) |
|
987 { |
|
988 aArray.AppendL( aValue ); |
|
989 } |
|
990 } |
|
991 } |
|
992 |
|
993 // --------------------------------------------------------------------------- |
|
994 // CCamConfiguration::CMRAvgVideoBitRateScaler |
|
995 // --------------------------------------------------------------------------- |
|
996 // |
|
997 TReal |
|
998 CCamConfiguration::CMRAvgVideoBitRateScaler() const |
|
999 { |
|
1000 return iCMRAvgVideoBitRateScaler; |
|
1001 } |
|
1002 |
|
1003 // --------------------------------------------------------------------------- |
|
1004 // CCamConfiguration::GetRequiredImageQualityIndex |
|
1005 // --------------------------------------------------------------------------- |
|
1006 // |
|
1007 TInt CCamConfiguration::GetRequiredImageQualityIndex( const TSize& aResolution ) const |
|
1008 { |
|
1009 TInt QualityIndex = 0; |
|
1010 TInt MaxCount = NumPrimaryImageQualities(); |
|
1011 TCamImageQualityData QData; |
|
1012 for ( TInt i = 0; i < MaxCount; i++ ) |
|
1013 { |
|
1014 QData = ImageQualityData( i ); |
|
1015 if ( QData.iPhotoSize.iWidth == aResolution.iWidth |
|
1016 && QData.iPhotoSize.iHeight == aResolution.iHeight ) |
|
1017 { |
|
1018 QualityIndex = i; |
|
1019 } |
|
1020 } |
|
1021 return QualityIndex; |
|
1022 } |
|
1023 |
|
1024 // --------------------------------------------------------------------------- |
|
1025 // CCamConfiguration::MapRequiredResolutionToActualResolutionPhoto |
|
1026 // --------------------------------------------------------------------------- |
|
1027 // |
|
1028 TSize CCamConfiguration::MapRequiredResolutionToActualResolutionPhoto( const TSize& aRequiredResolution ) const { |
|
1029 PRINT2(_L("Camera <=> CCamConfiguration::MapRequiredResolutionToActualResolutionPhoto aRequiredResolution: (%d,%d)"), aRequiredResolution.iWidth, aRequiredResolution.iHeight ); |
|
1030 TInt MaxCount = NumPrimaryImageQualities(); |
|
1031 TCamImageQualityData QData; |
|
1032 TSize Reso( 0, 0 ); |
|
1033 TBool found = EFalse; |
|
1034 for ( TInt i = 0; i < MaxCount; i++ ) |
|
1035 { |
|
1036 QData = ImageQualityData( i ); |
|
1037 PRINT3(_L("Camera <=> CCamConfiguration::MapRequiredResolutionToActualResolutionPhoto index: %d PhotoSize: (%d,%d)"), i,QData.iPhotoSize.iWidth, QData.iPhotoSize.iHeight ); |
|
1038 if ( QData.iPhotoSize.iWidth == aRequiredResolution.iWidth |
|
1039 && QData.iPhotoSize.iHeight == aRequiredResolution.iHeight ) |
|
1040 { |
|
1041 Reso = aRequiredResolution; |
|
1042 found = ETrue; |
|
1043 } |
|
1044 } |
|
1045 if ( !found && aRequiredResolution != TSize(0,0) ) { // TSize(0,0) should be returned the same as it means the mms quality |
|
1046 TInt referenceQuality = aRequiredResolution.iWidth*aRequiredResolution.iHeight; |
|
1047 TInt currentQuality = 0; |
|
1048 TInt closestMatch = Abs(referenceQuality-currentQuality); |
|
1049 PRINT1(_L("Camera <=> CCamConfiguration::MapRequiredResolutionToActualResolutionPhoto closestMatch: (%d)"), closestMatch ); |
|
1050 TInt currentMatch = 0; |
|
1051 for ( TInt i = 0; i < MaxCount; i++ ) |
|
1052 { |
|
1053 QData = ImageQualityData( i ); |
|
1054 PRINT3(_L("Camera <=> CCamConfiguration::MapRequiredResolutionToActualResolutionPhoto index: %d PhotoSize: (%d,%d)"), i, QData.iPhotoSize.iWidth, QData.iPhotoSize.iHeight ); |
|
1055 currentQuality = QData.iPhotoSize.iWidth*QData.iPhotoSize.iHeight; |
|
1056 currentMatch = Abs(referenceQuality-currentQuality); |
|
1057 PRINT1(_L("Camera <=> CCamConfiguration::MapRequiredResolutionToActualResolutionPhoto currentMatch: (%d)"), currentMatch ); |
|
1058 if ( currentMatch < closestMatch ) |
|
1059 { |
|
1060 Reso.SetSize( QData.iPhotoSize.iWidth, QData.iPhotoSize.iHeight ); |
|
1061 closestMatch = currentMatch; |
|
1062 } |
|
1063 } |
|
1064 } |
|
1065 PRINT2(_L("Camera <=> CCamConfiguration::MapRequiredResolutionToActualResolutionPhoto return resolution: (%d,%d)"), Reso.iWidth, Reso.iHeight ); |
|
1066 return Reso; |
|
1067 } |
|
1068 |
|
1069 |
|
1070 // --------------------------------------------------------------------------- |
|
1071 // CCamConfiguration::GetRequiredVideoQualityIndex |
|
1072 // --------------------------------------------------------------------------- |
|
1073 // |
|
1074 TInt CCamConfiguration::GetRequiredVideoQualityIndex( const TSize& aResolution ) const |
|
1075 { |
|
1076 PRINT2(_L("Camera <=> CCamConfiguration::GetRequiredVideoQualityIndex aResolution: (%d,%d)"), aResolution.iWidth, aResolution.iHeight ); |
|
1077 TInt QualityIndex = 0; |
|
1078 TInt MaxCount = NumVideoQualities(); |
|
1079 PRINT1(_L("Camera <=> CCamConfiguration::GetRequiredVideoQualityIndex MaxCount: %d"), MaxCount ); |
|
1080 TCamVideoQualityData QData; |
|
1081 TSize VideoResolution(0,0); |
|
1082 //for ( TInt i = 0; i < MaxCount; i++ ) |
|
1083 for ( TInt i = MaxCount-1; i >= 0; i-- ) |
|
1084 { |
|
1085 QData = iVideoQualities[i]; |
|
1086 VideoResolution = CamConfigurationUtility::CamVideoResolution( QData.iVideoResolution ); |
|
1087 PRINT3(_L("Camera <=> CCamConfiguration::GetRequiredVideoQualityIndex index: %d VideoResolution: (%d,%d)"), i, VideoResolution.iWidth, VideoResolution.iHeight ); |
|
1088 if ( VideoResolution.iWidth == aResolution.iWidth |
|
1089 && VideoResolution.iHeight == aResolution.iHeight ) |
|
1090 { |
|
1091 QualityIndex = i; |
|
1092 } |
|
1093 } |
|
1094 PRINT1(_L("Camera <=> CCamConfiguration::GetRequiredVideoQualityIndex return: %d"), QualityIndex ); |
|
1095 return QualityIndex; |
|
1096 } |
|
1097 |
|
1098 // --------------------------------------------------------------------------- |
|
1099 // CCamConfiguration::MapRequiredResolutionToActualResolutionVideo |
|
1100 // --------------------------------------------------------------------------- |
|
1101 // |
|
1102 TSize CCamConfiguration::MapRequiredResolutionToActualResolutionVideo( const TSize& aRequiredResolution ) const { |
|
1103 PRINT2(_L("Camera <=> CCamConfiguration::MapRequiredResolutionToActualResolutionVideo aRequiredResolution: (%d,%d)"), aRequiredResolution.iWidth, aRequiredResolution.iHeight ); |
|
1104 TInt MaxCount = NumVideoQualities(); |
|
1105 TCamVideoQualityData QData; |
|
1106 TSize Reso( 0, 0 ); |
|
1107 TBool found = EFalse; |
|
1108 TSize VideoResolution(0,0); |
|
1109 for ( TInt i = 0; i < MaxCount; i++ ) |
|
1110 { |
|
1111 QData = iVideoQualities[i]; |
|
1112 VideoResolution = CamConfigurationUtility::CamVideoResolution( QData.iVideoResolution ); |
|
1113 PRINT3(_L("Camera <=> CCamConfiguration::MapRequiredResolutionToActualResolutionVideo index: %d VideoResolution: (%d,%d)"), i, VideoResolution.iWidth, VideoResolution.iHeight ); |
|
1114 if ( VideoResolution.iWidth == aRequiredResolution.iWidth |
|
1115 && VideoResolution.iHeight == aRequiredResolution.iHeight ) |
|
1116 { |
|
1117 Reso = aRequiredResolution; |
|
1118 found = ETrue; |
|
1119 } |
|
1120 } |
|
1121 if ( !found && aRequiredResolution != TSize(0,0) ) { // TSize(0,0) should be returned the same as it means the mms quality |
|
1122 TInt referenceQuality = aRequiredResolution.iWidth*aRequiredResolution.iHeight; |
|
1123 TInt currentQuality = 0; |
|
1124 TInt closestMatch = Abs(referenceQuality-currentQuality); |
|
1125 PRINT1(_L("Camera <=> CCamConfiguration::MapRequiredResolutionToActualResolutionVideo closestMatch: (%d)"), closestMatch ); |
|
1126 TInt currentMatch = 0; |
|
1127 for ( TInt i = 0; i < MaxCount; i++ ) |
|
1128 { |
|
1129 QData = iVideoQualities[i]; |
|
1130 VideoResolution = CamConfigurationUtility::CamVideoResolution( QData.iVideoResolution ); |
|
1131 PRINT3(_L("Camera <=> CCamConfiguration::MapRequiredResolutionToActualResolutionVideo index: %d VideoResolution: (%d,%d)"), i, VideoResolution.iWidth, VideoResolution.iHeight ); |
|
1132 currentQuality = VideoResolution.iWidth*VideoResolution.iHeight; |
|
1133 currentMatch = Abs(referenceQuality-currentQuality); |
|
1134 PRINT1(_L("Camera <=> CCamConfiguration::MapRequiredResolutionToActualResolutionVideo currentMatch: (%d)"), currentMatch ); |
|
1135 if ( currentMatch < closestMatch ) |
|
1136 { |
|
1137 Reso.SetSize( VideoResolution.iWidth, VideoResolution.iHeight ); |
|
1138 closestMatch = currentMatch; |
|
1139 } |
|
1140 } |
|
1141 } |
|
1142 PRINT2(_L("Camera <=> CCamConfiguration::MapRequiredResolutionToActualResolutionVideo return resolution: (%d,%d)"), Reso.iWidth, Reso.iHeight ); |
|
1143 return Reso; |
|
1144 } |
|
1145 |
|
1146 // --------------------------------------------------------------------------- |
|
1147 // CCamConfiguration::GetDefaultVideoQualityFromIcmL |
|
1148 // --------------------------------------------------------------------------- |
|
1149 // |
|
1150 TCamVideoQualitySettings CCamConfiguration::GetDefaultVideoQualityFromIcmL() |
|
1151 { |
|
1152 PRINT(_L("Camera => CCamConfiguration::GetDefaultVideoQualityFromIcmL") ); |
|
1153 TInt totalLevels = iIcm->NumberOfVideoQualityLevels(); |
|
1154 CArrayFixFlat<TUint>* levels |
|
1155 = new (ELeave) CArrayFixFlat<TUint>( totalLevels ); |
|
1156 CleanupStack::PushL( levels ); |
|
1157 TVideoQualitySet set; |
|
1158 TVideoQualitySet temp; |
|
1159 |
|
1160 if( iPrimaryCameraDisplayId ) |
|
1161 { |
|
1162 iIcm->GetVideoQualityLevelsL( *levels, iPrimaryCameraDisplayId ); |
|
1163 TInt numLevels( levels->Count() ); |
|
1164 PRINT1(_L("Camera <> CCamConfiguration::GetDefaultVideoQualityFromIcmL - Total number of levels: %d"), numLevels ); |
|
1165 |
|
1166 iIcm->GetVideoQualitySet( set, levels->At( 0 ), iPrimaryCameraDisplayId ); |
|
1167 |
|
1168 for( int i=1; i<numLevels; i++ ) |
|
1169 { |
|
1170 iIcm->GetVideoQualitySet( temp, levels->At( i ), iPrimaryCameraDisplayId ); |
|
1171 if( temp.iCamcorderVisible > 0 && temp.iVideoQualitySetLevel > set.iVideoQualitySetLevel ) |
|
1172 { |
|
1173 set = temp; |
|
1174 } |
|
1175 } |
|
1176 } |
|
1177 CleanupStack::PopAndDestroy( levels ); |
|
1178 |
|
1179 TInt count = iVideoQualities.Count(); |
|
1180 TCamVideoQualityDescription descType |
|
1181 = CamConfigurationUtility::VideoDescId( set.iCamcorderVisible ); |
|
1182 for(TInt i = 0; i < count; i++) |
|
1183 { |
|
1184 if(iVideoQualities[i].iDescription == descType ) |
|
1185 { |
|
1186 PRINT( _L("Camera <= CCamConfiguration::GetDefaultVideoQualityFromIcmL") ); |
|
1187 return iVideoQualities[i].iQualitySetting; |
|
1188 } |
|
1189 } |
|
1190 |
|
1191 // In normal case application should not come to here |
|
1192 // If could not find the exact video qulity setting, just return WidescreenHigh |
|
1193 // Should be fixed in other product |
|
1194 return ECamVideoQualityNormalHigh; |
|
1195 } |
|
1196 |
|
1197 // End of file |
|
1198 |