configmanagers/imagingconfigmanager/src/imagingconfigmanager.cpp
changeset 0 9b3e960ffc8a
equal deleted inserted replaced
-1:000000000000 0:9b3e960ffc8a
       
     1 /*
       
     2 * Copyright (c) 2006-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:  Configuration manager using Central Repositary for retrieving
       
    15 *                settings for clients such as CamcorderMMFPlugin
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #include <centralrepository.h>
       
    21 #include "imagingconfigmanager.h"
       
    22 #include "icmcenrepkeys.h"
       
    23 
       
    24 /*
       
    25 * These constant literals are used for parsing the Central Repository strings
       
    26 *
       
    27 */
       
    28 _LIT( KPeriod, "." );
       
    29 
       
    30 _LIT( KComma, "," );
       
    31 _LIT( KQualitySetLevel, "QualitySetLevel" );
       
    32 _LIT( KVideoFileMimeType, "VideoFileMimeType" );
       
    33 _LIT( KVideoCodecMimeType, "VideoCodecMimeType" );
       
    34 _LIT( KVideoWidth, "VideoWidth" );
       
    35 _LIT( KVideoHeight, "VideoHeight" );
       
    36 _LIT( KVideoFrameRate, "VideoFrameRate" );
       
    37 _LIT( KVideoBitRate, "VideoBitRate" );
       
    38 _LIT( KVideoEncoderUID, "VideoEncoderUID=0" ); // "=0" there is a way to
       
    39                                              // ignore the "0x" from the
       
    40                                              // beginning of hex-number
       
    41 _LIT( KRandomAccessRate, "RandomAccessRate" );
       
    42 _LIT( KVideoPixelAspectRatioNum, "VideoPixelAspectRatioNum" );
       
    43 _LIT( KVideoPixelAspectRatioDenom, "VideoPixelAspectRatioDenom" );
       
    44 _LIT( KPreferredSupplier, "PreferredSupplier" );
       
    45 _LIT( KAudioFourCCType, "AudioFourCCType" );
       
    46 _LIT( KAudioBitrate, "AudioBitrate" );
       
    47 _LIT( KAudioSamplingRate, "AudioSamplingRate" );
       
    48 _LIT( KAudioChannels, "AudioChannels" );
       
    49 _LIT( KAudioEncoderUID, "AudioEncoderUID=0" ); // "=0" there is a way to
       
    50                                              // ignore the "0x" from the
       
    51                                              // beginning of hex-number
       
    52 _LIT( KAVSyncStartDelay, "AVSyncStartDelay" );
       
    53 _LIT( KAVSyncResumeDelay, "AVSyncResumeDelay" );
       
    54 _LIT( KCameraDisplayId, "CameraDisplayId" );
       
    55 _LIT( KCamcorderVisible, "CamcorderVisible" );
       
    56 _LIT( KVideoNightFrameRate, "VideoNightFrameRate" );
       
    57 _LIT( KCMRAvgVideoBitRateScaler, "CMRAvgVideoBitRateScaler" );
       
    58 _LIT( KVideoComplexitySetting, "VideoComplexitySetting" );
       
    59 _LIT( KCMRLatencyQualityTradeoff, "CMRLatencyQualityTradeoff" );
       
    60 _LIT( KCMRPictureQuality, "CMRPictureQuality" );
       
    61 _LIT( KCMRQualityTemporalTradeoff, "CMRQualityTemporalTradeoff" );
       
    62 _LIT( KCMRNumCameraBuffers, "CMRNumCameraBuffers" );
       
    63 _LIT( KCMRNumCameraBuffersARM, "CMRNumCameraBuffersARM" );
       
    64 _LIT( KCMRMinNumOutputBuffers, "CMRMinNumOutputBuffers" );
       
    65 _LIT( KImageFileMimeType, "ImageFileMimeType" );
       
    66 _LIT( KImageWidth, "ImageWidth" );
       
    67 _LIT( KImageHeight, "ImageHeight" );
       
    68 _LIT( KImageFileExtension, "ImageFileExtension" );
       
    69 _LIT( KImageEncoderUID, "ImageEncoderUID=0" ); // "=0" there is a way to
       
    70                                              // ignore the "0x" from the
       
    71                                              // beginning of hex-number
       
    72 _LIT( KCompressionQuality, "CompressionQuality" );
       
    73 _LIT( KEstimatedSize, "EstimatedSize" );
       
    74 
       
    75 // Constants used in Central Repository parsing and granularity
       
    76 const TInt KGranularity = 1;
       
    77 const TUint32 KRowMask = 0xFFFF0000;
       
    78 const TUint32 KRowVideo = 1 << 16;  // VideoQualitySets' offset
       
    79 const TUint32 KRowCCor = 2 << 16;   // CamcorderMMFPluginSettings' offset
       
    80 const TUint32 KRowImage = 3 << 16;  // ImageQualitySets' offset
       
    81 const TText8 KZero = '\0';          // null-termination mark of strings
       
    82 const TInt KInitBufSize = 1;        // Initial size of reserved buffer
       
    83 const TInt KUndefined = -1;         // used as initial undefined value
       
    84 
       
    85 // ======== MEMBER FUNCTIONS ========
       
    86 
       
    87 // ---------------------------------------------------------------------------
       
    88 // Constructor of CImagingConfigManager
       
    89 // ---------------------------------------------------------------------------
       
    90 //
       
    91 CImagingConfigManager::CImagingConfigManager()
       
    92     {
       
    93     }
       
    94 
       
    95 // ---------------------------------------------------------------------------
       
    96 // Destructor of CImagingConfigManager
       
    97 // ---------------------------------------------------------------------------
       
    98 //
       
    99 CImagingConfigManager::~CImagingConfigManager()
       
   100     {
       
   101     if( iVideoQualitySets )
       
   102         {
       
   103         iVideoQualitySets->Reset();
       
   104         delete iVideoQualitySets;
       
   105         }
       
   106     if( iImageQualitySets )
       
   107         {
       
   108         iImageQualitySets->Reset();
       
   109         delete iImageQualitySets;
       
   110         }
       
   111     }
       
   112 
       
   113 // ---------------------------------------------------------------------------
       
   114 // ConstructL() of CImagingConfigManager
       
   115 // ---------------------------------------------------------------------------
       
   116 //
       
   117 void CImagingConfigManager::ConstructL()
       
   118     {
       
   119     RArray< TUint32 > foundCols; // This is used for fetching the columns of
       
   120                                  // data from Central Repository
       
   121     TInt buffersize = KInitBufSize; // buffer variable's size
       
   122     HBufC* buffer = NULL;        // Common buffer to be used for temporary
       
   123                                  // storage for reads from Central Repository
       
   124     TInt keyCount;               // Number of keys found from CenRep
       
   125     TUint uidtemp = 0;           // Temp TUint storage for UIDs
       
   126 
       
   127     // Create the repository
       
   128     CRepository *repository = CRepository::NewLC( KCRUidImagingConfigManager );
       
   129 
       
   130     // Alloc quality sets
       
   131     iVideoQualitySets =
       
   132             new ( ELeave ) CArrayFixFlat< TVideoQualitySet >( KGranularity );
       
   133     iImageQualitySets =
       
   134             new ( ELeave ) CArrayFixFlat< TImageQualitySet >( KGranularity );
       
   135     
       
   136     // Find video quality setting sets by using the KRowMask
       
   137     User::LeaveIfError( repository->FindL( KRowVideo, KRowMask, foundCols ) );
       
   138 
       
   139     buffer = HBufC::NewLC( buffersize );
       
   140     keyCount = foundCols.Count();
       
   141     
       
   142     // For each key, parse the settings into the TVideoQualitySet
       
   143     for ( TInt i = 0 ; i < keyCount ; i++ )
       
   144         {
       
   145         TVideoQualitySet tmpVideoQualitySet;
       
   146         TPtr ptr = buffer->Des();
       
   147         buffersize = 0;
       
   148         // String with settings is fetched from CenRep
       
   149         TInt ret = repository->Get( foundCols[ i ], ptr, buffersize );
       
   150         // KErrOverFlow is returned if and when 1 is not big enough size
       
   151         // for buffer
       
   152         if ( ret == KErrOverflow )
       
   153             {
       
   154             // More space is reserved
       
   155             CleanupStack::PopAndDestroy(); // buffer
       
   156             buffer = HBufC::NewLC( buffersize );
       
   157             ptr.Set( buffer->Des() );
       
   158             User::LeaveIfError( repository->Get( foundCols[ i ], ptr ) );
       
   159             }
       
   160         else
       
   161             {
       
   162             User::LeaveIfError( ret );
       
   163             }
       
   164         // Fetched string is parsed right and left and the value is stored
       
   165         // to suitable form into the TVideoQualitySet
       
   166         TPtrC temp = GetRightPartL( ptr, KQualitySetLevel() );
       
   167         TLex lextemp = GetLeftPart( temp );
       
   168         TBuf<1024> treal;
       
   169         User::LeaveIfError( lextemp.Val(
       
   170                     tmpVideoQualitySet.iVideoQualitySetLevel, EDecimal ) );
       
   171         
       
   172         temp.Set( GetRightPartL( ptr, KVideoFileMimeType() ) );
       
   173         temp.Set( GetLeftPart( temp ) );
       
   174         SetTextStringL( temp, tmpVideoQualitySet.iVideoFileMimeType );
       
   175         
       
   176         temp.Set( GetRightPartL( ptr, KVideoCodecMimeType() ) );
       
   177         temp.Set( GetLeftPart( temp ) );
       
   178         SetTextStringL( temp, tmpVideoQualitySet.iVideoCodecMimeType );
       
   179         
       
   180         temp.Set( GetRightPartL( ptr, KVideoWidth() ) );
       
   181         lextemp = GetLeftPart( temp );
       
   182         User::LeaveIfError( lextemp.Val( tmpVideoQualitySet.iVideoWidth ) );
       
   183         
       
   184         temp.Set( GetRightPartL( ptr, KVideoHeight() ) );
       
   185         lextemp = GetLeftPart( temp );
       
   186         User::LeaveIfError( lextemp.Val( tmpVideoQualitySet.iVideoHeight ) );
       
   187         
       
   188         temp.Set( GetRightPartL( ptr, KVideoFrameRate() ) );
       
   189         temp.Set( GetLeftPart( temp ) );
       
   190         treal = temp;
       
   191         TLocale tlocale;
       
   192         TChar ch = tlocale.DecimalSeparator();
       
   193         if( temp.Find( KPeriod ) >= 0 )
       
   194             {
       
   195             treal[temp.Find( KPeriod )] = ch;
       
   196             }
       
   197         lextemp = treal;
       
   198         User::LeaveIfError( lextemp.Val( tmpVideoQualitySet.iVideoFrameRate ) );
       
   199         
       
   200         temp.Set( GetRightPartL( ptr, KVideoBitRate() ) );
       
   201         lextemp = GetLeftPart( temp );
       
   202         User::LeaveIfError( lextemp.Val( tmpVideoQualitySet.iVideoBitRate ) );
       
   203         
       
   204         temp.Set( GetRightPartL( ptr, KVideoEncoderUID() ) );
       
   205         lextemp = GetLeftPart( temp );
       
   206         User::LeaveIfError( lextemp.Val( uidtemp, EHex ) );
       
   207         tmpVideoQualitySet.iVideoEncoderUID.iUid = uidtemp;
       
   208         
       
   209         temp.Set( GetRightPartL( ptr, KRandomAccessRate() ) );
       
   210         temp.Set( GetLeftPart( temp ) );
       
   211         treal = temp;
       
   212         if( temp.Find( KPeriod ) >= 0 )
       
   213             {
       
   214             treal[temp.Find( KPeriod )] = ch;
       
   215             }
       
   216         lextemp = treal;
       
   217         User::LeaveIfError( lextemp.Val( tmpVideoQualitySet.iRandomAccessRate ) );
       
   218         
       
   219         temp.Set( GetRightPartL( ptr, KVideoPixelAspectRatioNum() ) );
       
   220         lextemp = GetLeftPart( temp );
       
   221         User::LeaveIfError( lextemp.Val(
       
   222                     tmpVideoQualitySet.iVideoPixelAspectRatioNum ) );
       
   223         
       
   224         temp.Set( GetRightPartL( ptr, KVideoPixelAspectRatioDenom() ) );
       
   225         lextemp = GetLeftPart( temp );
       
   226         User::LeaveIfError( lextemp.Val(
       
   227                     tmpVideoQualitySet.iVideoPixelAspectRatioDenom ) );
       
   228         
       
   229         temp.Set( GetRightPartL( ptr, KPreferredSupplier() ) );
       
   230         temp.Set( GetLeftPart( temp ) );
       
   231         SetTextStringL( temp, tmpVideoQualitySet.iPreferredSupplier );
       
   232         
       
   233         temp.Set( GetRightPartL( ptr, KAudioFourCCType() ) );
       
   234         temp.Set( GetLeftPart( temp ) );
       
   235         TBuf8<4> fourccbuf8;
       
   236         fourccbuf8.Copy(temp);
       
   237         tmpVideoQualitySet.iAudioFourCCType.Set(fourccbuf8);
       
   238         
       
   239         TUint32 intti = tmpVideoQualitySet.iAudioFourCCType.FourCC();
       
   240         
       
   241         temp.Set( GetRightPartL( ptr, KAudioBitrate() ) );
       
   242         lextemp = GetLeftPart( temp );
       
   243         User::LeaveIfError( lextemp.Val( tmpVideoQualitySet.iAudioBitRate ) );
       
   244         
       
   245         temp.Set( GetRightPartL( ptr, KAudioSamplingRate() ) );
       
   246         lextemp = GetLeftPart( temp );
       
   247         User::LeaveIfError( lextemp.Val(
       
   248                     tmpVideoQualitySet.iAudioSamplingRate ) );
       
   249         
       
   250         temp.Set( GetRightPartL( ptr, KAudioChannels() ) );
       
   251         lextemp = GetLeftPart( temp );
       
   252         User::LeaveIfError( lextemp.Val( tmpVideoQualitySet.iAudioChannels ) );
       
   253         
       
   254         temp.Set( GetRightPartL( ptr, KAudioEncoderUID() ) );
       
   255         lextemp = GetLeftPart( temp );
       
   256         User::LeaveIfError( lextemp.Val( uidtemp, EHex ) );
       
   257         tmpVideoQualitySet.iAudioEncoderUID.iUid = uidtemp;
       
   258         
       
   259         temp.Set( GetRightPartL( ptr, KAVSyncStartDelay() ) );
       
   260         lextemp = GetLeftPart( temp );
       
   261         User::LeaveIfError( lextemp.Val( tmpVideoQualitySet.iAVSyncStartDelay ) );
       
   262         
       
   263         temp.Set( GetRightPartL( ptr, KAVSyncResumeDelay() ) );
       
   264         lextemp = GetLeftPart( temp );
       
   265         User::LeaveIfError( lextemp.Val(
       
   266                     tmpVideoQualitySet.iAVSyncResumeDelay ) );
       
   267         
       
   268         temp.Set( GetRightPartL( ptr, KCameraDisplayId() ) );
       
   269         lextemp = GetLeftPart( temp );
       
   270         User::LeaveIfError( lextemp.Val( tmpVideoQualitySet.iCameraDisplayId ) );
       
   271         
       
   272         temp.Set( GetRightPartL( ptr, KCamcorderVisible() ) );
       
   273         lextemp = GetLeftPart( temp );
       
   274         User::LeaveIfError( lextemp.Val( tmpVideoQualitySet.iCamcorderVisible ) );
       
   275         
       
   276         iVideoQualitySets->AppendL( tmpVideoQualitySet );
       
   277         }
       
   278 
       
   279     for( TInt i = foundCols.Count() - 1 ; i >= 0 ; i-- )
       
   280         {
       
   281         foundCols.Remove( i );
       
   282         }
       
   283     User::LeaveIfError( repository->FindL( KRowCCor, KRowMask, foundCols ) );
       
   284     keyCount = foundCols.Count();
       
   285     for ( TInt i = 0 ; i < keyCount ; i++ )
       
   286         {
       
   287         TPtr ptr = buffer->Des();
       
   288         buffersize = 0;
       
   289         TInt ret = repository->Get( foundCols[ i ], ptr, buffersize );
       
   290         if ( ret == KErrOverflow )
       
   291             {
       
   292             CleanupStack::PopAndDestroy(); // buffer
       
   293             buffer = HBufC::NewLC( buffersize );
       
   294             ptr.Set( buffer->Des() );
       
   295             User::LeaveIfError( repository->Get( foundCols[ i ], ptr ) );
       
   296             }
       
   297         else if( ret != KErrNone )
       
   298             {
       
   299             User::LeaveIfError( ret );
       
   300             }
       
   301         else
       
   302             {
       
   303             }
       
   304         
       
   305         TBuf<1024> treal;    
       
   306         TPtrC temp = GetRightPartL( ptr, KVideoNightFrameRate() );
       
   307         temp.Set( GetLeftPart( temp ) );
       
   308         treal = temp;
       
   309         TLocale tlocale;
       
   310         TChar ch = tlocale.DecimalSeparator();
       
   311         if( temp.Find( KPeriod ) >= 0 )
       
   312             {
       
   313             treal[temp.Find( KPeriod )] = ch;
       
   314             }
       
   315         TLex lextemp(treal);
       
   316         User::LeaveIfError( lextemp.Val(
       
   317                     iCamcorderMMFPluginSettings.iVideoNightFrameRate ) );
       
   318         
       
   319         temp.Set( GetRightPartL( ptr, KCMRAvgVideoBitRateScaler() ) );
       
   320         temp.Set( GetLeftPart( temp ) );
       
   321         treal = temp;
       
   322         if( temp.Find( KPeriod ) >= 0 )
       
   323             {
       
   324             treal[temp.Find( KPeriod )] = ch;
       
   325             }
       
   326         lextemp = treal;
       
   327         User::LeaveIfError( lextemp.Val(
       
   328                     iCamcorderMMFPluginSettings.iCMRAvgVideoBitRateScaler ) );
       
   329         
       
   330         temp.Set( GetRightPartL(ptr, KVideoComplexitySetting() ) );
       
   331         lextemp = GetLeftPart( temp );
       
   332         User::LeaveIfError( lextemp.Val(
       
   333                     iCamcorderMMFPluginSettings.iVideoComplexitySetting ) );
       
   334         
       
   335         temp.Set( GetRightPartL( ptr, KCMRLatencyQualityTradeoff() ) );
       
   336         temp.Set( GetLeftPart( temp ) );
       
   337         treal = temp;
       
   338         if( temp.Find( KPeriod ) >= 0 )
       
   339             {
       
   340             treal[temp.Find( KPeriod )] = ch;
       
   341             }
       
   342         lextemp = treal;
       
   343         User::LeaveIfError( lextemp.Val(
       
   344                     iCamcorderMMFPluginSettings.iCMRLatencyQualityTradeoff ) );
       
   345         
       
   346         temp.Set( GetRightPartL( ptr, KCMRPictureQuality() ) );
       
   347         lextemp = GetLeftPart( temp );
       
   348         User::LeaveIfError( lextemp.Val(
       
   349                     iCamcorderMMFPluginSettings.iCMRPictureQuality ) );
       
   350         
       
   351         temp.Set( GetRightPartL( ptr, KCMRQualityTemporalTradeoff() ) );
       
   352         temp.Set( GetLeftPart( temp ) );
       
   353         treal = temp;
       
   354         if( temp.Find( KPeriod ) >= 0 )
       
   355             {
       
   356             treal[temp.Find( KPeriod )] = ch;
       
   357             }
       
   358         lextemp = treal;
       
   359         User::LeaveIfError( lextemp.Val(
       
   360                     iCamcorderMMFPluginSettings.iCMRQualityTemporalTradeoff ) );
       
   361         
       
   362         if(ptr.Find(KCMRNumCameraBuffers()) >= 0)
       
   363             {
       
   364             temp.Set( GetRightPartL( ptr, KCMRNumCameraBuffers() ) );
       
   365             lextemp = GetLeftPart( temp );
       
   366             User::LeaveIfError( lextemp.Val(
       
   367                         iCamcorderMMFPluginSettings.iCMRNumCameraBuffers ) );
       
   368             
       
   369             temp.Set( GetRightPartL( ptr, KCMRNumCameraBuffersARM() ) );
       
   370             lextemp = GetLeftPart( temp );
       
   371             User::LeaveIfError( lextemp.Val(
       
   372                         iCamcorderMMFPluginSettings.iCMRNumCameraBuffersARM ) );
       
   373             
       
   374             temp.Set( GetRightPartL( ptr, KCMRMinNumOutputBuffers() ) );
       
   375             lextemp = GetLeftPart( temp );
       
   376             User::LeaveIfError( lextemp.Val(
       
   377                         iCamcorderMMFPluginSettings.iCMRMinNumOutputBuffers ) );
       
   378             }
       
   379         else
       
   380             {
       
   381             // To ensure backwards compatibility we give these three new
       
   382             // settings default values of 2, 1 and 4 respectively according
       
   383             // to old implementation in MMFPlug-in
       
   384             iCamcorderMMFPluginSettings.iCMRNumCameraBuffers = 2;
       
   385             iCamcorderMMFPluginSettings.iCMRNumCameraBuffersARM = 1;
       
   386             iCamcorderMMFPluginSettings.iCMRMinNumOutputBuffers = 4;
       
   387             }
       
   388         }
       
   389 
       
   390     for( TInt i = foundCols.Count() - 1 ; i >= 0 ; i-- )
       
   391         {
       
   392         foundCols.Remove( i );
       
   393         }
       
   394     User::LeaveIfError( repository->FindL( KRowImage, KRowMask, foundCols ) );
       
   395     keyCount = foundCols.Count();
       
   396     for (TInt i = 0 ; i < keyCount ; i++)
       
   397         {
       
   398         TPtr ptr = buffer->Des();
       
   399         buffersize = 0;
       
   400         TInt ret = repository->Get( foundCols[ i ], ptr, buffersize );
       
   401         if ( ret == KErrOverflow )
       
   402             {
       
   403             CleanupStack::PopAndDestroy(); // buffer
       
   404             buffer = HBufC::NewLC( buffersize );
       
   405             ptr.Set( buffer->Des() );
       
   406             User::LeaveIfError( repository->Get( foundCols[ i ], ptr ) );
       
   407             }
       
   408         else if( ret != KErrNone )
       
   409             {
       
   410             User::LeaveIfError( ret );
       
   411             }
       
   412         else
       
   413             {
       
   414             }
       
   415 
       
   416         TImageQualitySet tmpImageQualitySet;
       
   417 
       
   418         TPtrC temp = GetRightPartL( ptr, KQualitySetLevel() );
       
   419         TLex lextemp( GetLeftPart( temp ) );
       
   420         User::LeaveIfError( lextemp.Val( tmpImageQualitySet.iImageQualitySetLevel,
       
   421                                        EDecimal ) );
       
   422 
       
   423         temp.Set( GetRightPartL( ptr, KImageFileMimeType() ) );
       
   424         temp.Set( GetLeftPart( temp ) );
       
   425         SetTextStringL( temp, tmpImageQualitySet.iImageFileMimeType );
       
   426 
       
   427         temp.Set( GetRightPartL( ptr, KImageWidth() ) );
       
   428         lextemp = GetLeftPart( temp );
       
   429         User::LeaveIfError( lextemp.Val( tmpImageQualitySet.iImageWidth ) );
       
   430 
       
   431         temp.Set( GetRightPartL( ptr, KImageHeight() ) );
       
   432         lextemp = GetLeftPart( temp );
       
   433         User::LeaveIfError( lextemp.Val( tmpImageQualitySet.iImageHeight ) );
       
   434 
       
   435         temp.Set( GetRightPartL( ptr, KImageFileExtension() ) );
       
   436         temp.Set( GetLeftPart( temp ) );
       
   437         SetTextStringL( temp, tmpImageQualitySet.iImageFileExtension );
       
   438 
       
   439         temp.Set( GetRightPartL( ptr, KImageEncoderUID() ) );
       
   440         lextemp = GetLeftPart( temp );
       
   441         User::LeaveIfError( lextemp.Val( uidtemp, EHex ) );
       
   442         tmpImageQualitySet.iImageEncoderUID.iUid = uidtemp;
       
   443         
       
   444         temp.Set( GetRightPartL( ptr, KCompressionQuality() ) );
       
   445         lextemp = GetLeftPart( temp );
       
   446         User::LeaveIfError( lextemp.Val( tmpImageQualitySet.iCompressionQuality ) );
       
   447 
       
   448         temp.Set( GetRightPartL( ptr, KEstimatedSize() ) );
       
   449         lextemp = GetLeftPart( temp );
       
   450         User::LeaveIfError( lextemp.Val( tmpImageQualitySet.iEstimatedSize ) );
       
   451         
       
   452         temp.Set( GetRightPartL( ptr, KCameraDisplayId() ) );
       
   453         lextemp = GetLeftPart( temp );
       
   454         User::LeaveIfError( lextemp.Val( tmpImageQualitySet.iCameraDisplayId ) );
       
   455         
       
   456         temp.Set( GetRightPartL( ptr, KCamcorderVisible() ) );
       
   457         lextemp = GetLeftPart( temp );
       
   458         User::LeaveIfError( lextemp.Val( tmpImageQualitySet.iCamcorderVisible ) );
       
   459         
       
   460         iImageQualitySets->AppendL( tmpImageQualitySet );
       
   461         }
       
   462 
       
   463     foundCols.Close();
       
   464     CleanupStack::PopAndDestroy(); // buffer
       
   465     CleanupStack::PopAndDestroy( repository );
       
   466     }
       
   467 
       
   468 // ---------------------------------------------------------------------------
       
   469 // CheckIfNegative( TInt aValue ) of CImagingConfigManager, private method
       
   470 // ---------------------------------------------------------------------------
       
   471 //
       
   472 TBool CImagingConfigManager::CheckIfNegative( const TInt aValue ) const
       
   473     {
       
   474     TBool retval = EFalse;
       
   475     if( aValue < 0 )
       
   476         {
       
   477         retval = ETrue;
       
   478         }
       
   479     return retval;
       
   480     }
       
   481 
       
   482 // ---------------------------------------------------------------------------
       
   483 // GetRightPartL( TPtr aPtr, const TDesC& aSearchable ) of 
       
   484 // CImagingConfigManager, private method
       
   485 // ---------------------------------------------------------------------------
       
   486 //
       
   487 TPtrC CImagingConfigManager::GetRightPartL( const TPtr& aPtr,
       
   488                                             const TDesC& aSearchable ) const
       
   489     {
       
   490     // First verify the values so that we know if they aren't legal
       
   491     if( CheckIfNegative( aPtr.Find( aSearchable ) ) ||
       
   492         CheckIfNegative( ( ( aPtr.Length() -
       
   493                              aPtr.Find( aSearchable ) ) -
       
   494                            aSearchable.Length() ) - 1 ) )
       
   495         {
       
   496         User::Leave( KErrGeneral );
       
   497         }
       
   498     return aPtr.Right( ( ( aPtr.Length() -
       
   499                            aPtr.Find( aSearchable ) ) -
       
   500                          aSearchable.Length() ) - 1 );
       
   501     }
       
   502 
       
   503 // ---------------------------------------------------------------------------
       
   504 // GetLeftPartL( TPtrC aPtrc ) of CImagingConfigManager, private method
       
   505 // ---------------------------------------------------------------------------
       
   506 //
       
   507 TPtrC CImagingConfigManager::GetLeftPart( const TPtrC& aPtrc ) const
       
   508     {
       
   509     if( CheckIfNegative( aPtrc.Find( KComma ) ) )
       
   510         {
       
   511         return aPtrc;
       
   512         }
       
   513     return aPtrc.Left( aPtrc.Find( KComma ) );
       
   514     }
       
   515 
       
   516 // ---------------------------------------------------------------------------
       
   517 // SetTextStringL( TPtrC& aPtr, TText8& aStringToFill ) of
       
   518 // CImagingConfigManager,private method
       
   519 // ---------------------------------------------------------------------------
       
   520 //
       
   521 void CImagingConfigManager::SetTextStringL( const TPtrC& aPtr,
       
   522                                             TText8* aStringToFill ) const
       
   523     {
       
   524     if( static_cast< TUint >( aPtr.Length() ) > KMaxStringLength )
       
   525         {
       
   526         User::Leave( KErrOverflow );
       
   527         }
       
   528     if( aStringToFill == NULL )
       
   529         {
       
   530         User::Leave( KErrGeneral );
       
   531         }
       
   532     for( TInt j = 0 ; j < aPtr.Length() ; j++ )
       
   533         {
       
   534         aStringToFill[ j ] = ( aPtr[ j ] & 0xff);
       
   535         }
       
   536     for( TUint j = aPtr.Length() ; j < KMaxStringLength ; j++ )
       
   537         {
       
   538         aStringToFill[ j ] = KZero;
       
   539         }
       
   540     }
       
   541 
       
   542 // ---------------------------------------------------------------------------
       
   543 // NewL() of CImagingConfigManager
       
   544 // ---------------------------------------------------------------------------
       
   545 //
       
   546 EXPORT_C CImagingConfigManager* CImagingConfigManager::NewL()
       
   547     {
       
   548     CImagingConfigManager* self = CImagingConfigManager::NewLC();
       
   549     CleanupStack::Pop( self );
       
   550     return self;
       
   551     }
       
   552 
       
   553 // ---------------------------------------------------------------------------
       
   554 // NelLC() of CImagingConfigManager
       
   555 // ---------------------------------------------------------------------------
       
   556 //
       
   557 EXPORT_C CImagingConfigManager* CImagingConfigManager::NewLC()
       
   558     {
       
   559     CImagingConfigManager* self = new( ELeave ) CImagingConfigManager;
       
   560     CleanupStack::PushL( self );
       
   561     self->ConstructL();
       
   562     return self;
       
   563     }
       
   564 
       
   565 // ---------------------------------------------------------------------------
       
   566 // Get number of defined video quality levels. This is always at least
       
   567 // KNumberOfNominalLevels but can be higher
       
   568 // ---------------------------------------------------------------------------
       
   569 //
       
   570 EXPORT_C TInt CImagingConfigManager::NumberOfVideoQualityLevels() const
       
   571     {
       
   572     TInt retval = 0;
       
   573     if( iVideoQualitySets )
       
   574         {
       
   575         retval = iVideoQualitySets->Count();
       
   576         }
       
   577     return retval;
       
   578     }
       
   579 
       
   580 // ---------------------------------------------------------------------------
       
   581 // Get an array of video quality levels that are in use with the current
       
   582 // product with given Camera/Display ID. If the ID is zero, then all levels
       
   583 // dispite of the ID value are returned.
       
   584 // ---------------------------------------------------------------------------
       
   585 //
       
   586 EXPORT_C TInt CImagingConfigManager::GetVideoQualityLevelsL(
       
   587                                         CArrayFixFlat<TUint>& aLevels,
       
   588                                         TUint aCameraDisplayID )
       
   589     {
       
   590     TKeyArrayFix key(0,ECmpTUint);
       
   591     aLevels.Reset();
       
   592     // We know the total size beforehand so reserve all the space at once
       
   593     aLevels.SetReserveL( iVideoQualitySets->Count() );
       
   594     for( TInt i = 0 ; i < iVideoQualitySets->Count() ; i++ )
       
   595         {
       
   596         if( aCameraDisplayID == 0 ||
       
   597             iVideoQualitySets->At( i ).iCameraDisplayId == aCameraDisplayID )
       
   598             {
       
   599             aLevels.AppendL(
       
   600                 iVideoQualitySets->At( i ).iVideoQualitySetLevel );
       
   601             }
       
   602         }
       
   603     User::LeaveIfError(aLevels.Sort(key));
       
   604     return KErrNone;
       
   605     }
       
   606 
       
   607 // ---------------------------------------------------------------------------
       
   608 // Get video quality set associated with the given level and Camera/Display ID
       
   609 // if it is nonzero. If the ID is zero, smallest matching ID set is returned.
       
   610 // If there is no set associated with given intermediate
       
   611 // level, then set from a nearest nominal level is returned (dividable by
       
   612 // KBasicQualityGranularity).
       
   613 // ---------------------------------------------------------------------------
       
   614 //
       
   615 EXPORT_C TInt CImagingConfigManager::GetVideoQualitySet(
       
   616                                         TVideoQualitySet& aSet,
       
   617                                         TInt aLevel,
       
   618                                         TUint aCameraDisplayID )
       
   619     {
       
   620     for( TUint i = 0 ; i < KMaxStringLength ; i++ )
       
   621         {
       
   622         aSet.iVideoFileMimeType[ i ] = NULL;
       
   623         aSet.iVideoCodecMimeType[ i ] = NULL;
       
   624         aSet.iPreferredSupplier[ i ] = NULL;
       
   625         }
       
   626     aSet.iVideoQualitySetLevel = 0;
       
   627     aSet.iVideoWidth = 0;
       
   628     aSet.iVideoHeight = 0;
       
   629     aSet.iVideoFrameRate = 0.0;
       
   630     aSet.iVideoBitRate = 0;
       
   631     aSet.iVideoEncoderUID.iUid = 0;
       
   632     aSet.iRandomAccessRate = 0;
       
   633     aSet.iVideoPixelAspectRatioNum = 0;
       
   634     aSet.iVideoPixelAspectRatioDenom = 0;
       
   635     aSet.iAudioFourCCType = 0;
       
   636     aSet.iAudioBitRate = 0;
       
   637     aSet.iAudioSamplingRate = 0;
       
   638     aSet.iAudioChannels = 0;
       
   639     aSet.iAudioEncoderUID.iUid = 0;
       
   640     aSet.iAVSyncStartDelay = 0;
       
   641     aSet.iAVSyncResumeDelay = 0;
       
   642     aSet.iCameraDisplayId = 0;
       
   643     aSet.iCamcorderVisible = 0;
       
   644     
       
   645     TInt diff; // This is used to get the nearest nominal level if the exact
       
   646                // level isn't available
       
   647     TInt min = KMaxTInt; // set to as big number as possible initially
       
   648     TInt minIndex = KUndefined;
       
   649     TBool paramSet = EFalse;
       
   650     TUint smallestCameraDisplayID = KMaxTUint;
       
   651     
       
   652     for( TInt i = 0 ;
       
   653          i < iVideoQualitySets->Count() && aCameraDisplayID == 0 ;
       
   654          i++ )
       
   655         {
       
   656         if(iVideoQualitySets->At( i ).iCameraDisplayId < smallestCameraDisplayID)
       
   657             {
       
   658             smallestCameraDisplayID =
       
   659                iVideoQualitySets->At( i ).iCameraDisplayId;
       
   660             }
       
   661         }
       
   662 
       
   663     for( TInt i = 0 ; i < iVideoQualitySets->Count() && paramSet == EFalse ; i++ )
       
   664         {
       
   665         if( ( aCameraDisplayID == 0 &&
       
   666               iVideoQualitySets->At( i ).iCameraDisplayId ==
       
   667                    smallestCameraDisplayID ) ||
       
   668             iVideoQualitySets->At( i ).iCameraDisplayId == aCameraDisplayID )
       
   669             {
       
   670             if( iVideoQualitySets->At( i ).iVideoQualitySetLevel == aLevel )
       
   671                 {
       
   672                 aSet = iVideoQualitySets->At( i );
       
   673                 paramSet = ETrue;
       
   674                 }
       
   675             else
       
   676                 {
       
   677                 diff = iVideoQualitySets->At( i ).iVideoQualitySetLevel - aLevel;
       
   678                 if( static_cast< TInt >(
       
   679                        iVideoQualitySets->At( i ).iVideoQualitySetLevel )
       
   680                        < aLevel )
       
   681                     {
       
   682                     diff = - diff;
       
   683                     }
       
   684                 if( min > diff )
       
   685                     {
       
   686                     min = diff;
       
   687                     minIndex = i;
       
   688                     }
       
   689                 else if( min == diff && i > minIndex )
       
   690                     {
       
   691                     //If the difference is the same between two sets from the
       
   692                     //asked set, let's take the bigger one. Eg. 101 over 99
       
   693                     //if 100 was asked, but isn't present
       
   694                     minIndex = i;
       
   695                     }
       
   696                 }
       
   697             }
       
   698         }
       
   699     if( minIndex != KUndefined && paramSet == EFalse )
       
   700         {
       
   701         aSet = iVideoQualitySets->At( minIndex );
       
   702         }
       
   703     else
       
   704         {
       
   705         return KErrGeneral; // No Quality sets were read from CenRep
       
   706         }
       
   707     return KErrNone;
       
   708     }
       
   709 
       
   710 // ---------------------------------------------------------------------------
       
   711 // Get quality set associated with the given video resolution, its MIME-type,
       
   712 // audio fourCC and Camera/Display ID (which can be zero for all possible ID
       
   713 // values). All of these are needed to be uniquely able to select
       
   714 // a single quality setting set. If certain pixel aspect ratio is wanted for
       
   715 // the video, it can be requested with aVideoPixelAspectRatioNum and
       
   716 // aVideoPixelAspectRatioDenom parameters. Otherwise they should be set to
       
   717 // zero.
       
   718 // ---------------------------------------------------------------------------
       
   719 //
       
   720 EXPORT_C TInt CImagingConfigManager::GetVideoQualitySet(
       
   721                                     TVideoQualitySet& aSet,
       
   722                                     const TSize& aVideoResolution,
       
   723                                     const TDesC8& aVideoCodecMimeType,
       
   724                                     TUint aVideoPixelAspectRatioNum,
       
   725                                     TUint aVideoPixelAspectRatioDenom,
       
   726                                     TFourCC aAudioFourCCType,
       
   727                                     TUint aCameraDisplayID )
       
   728     {
       
   729     for( TUint i = 0 ; i < KMaxStringLength ; i++ )
       
   730         {
       
   731         aSet.iVideoFileMimeType[ i ] = NULL;
       
   732         aSet.iVideoCodecMimeType[ i ] = NULL;
       
   733         aSet.iPreferredSupplier[ i ] = NULL;
       
   734         }
       
   735     aSet.iVideoQualitySetLevel = 0;
       
   736     aSet.iVideoWidth = 0;
       
   737     aSet.iVideoHeight = 0;
       
   738     aSet.iVideoFrameRate = 0.0;
       
   739     aSet.iVideoBitRate = 0;
       
   740     aSet.iVideoEncoderUID.iUid = 0;
       
   741     aSet.iRandomAccessRate = 0;
       
   742     aSet.iVideoPixelAspectRatioNum = 0;
       
   743     aSet.iVideoPixelAspectRatioDenom = 0;
       
   744     aSet.iAudioFourCCType = 0;
       
   745     aSet.iAudioBitRate = 0;
       
   746     aSet.iAudioSamplingRate = 0;
       
   747     aSet.iAudioChannels = 0;
       
   748     aSet.iAudioEncoderUID.iUid = 0;
       
   749     aSet.iAVSyncStartDelay = 0;
       
   750     aSet.iAVSyncResumeDelay = 0;
       
   751     aSet.iCameraDisplayId = 0;
       
   752     aSet.iCamcorderVisible = 0;
       
   753     
       
   754     TBool paramSet = EFalse;
       
   755     TUint smallestCameraDisplayID = KMaxTUint;
       
   756     
       
   757     for( TInt i = 0 ;
       
   758          i < iVideoQualitySets->Count() && aCameraDisplayID == 0 ;
       
   759          i++ )
       
   760         {
       
   761         if(iVideoQualitySets->At( i ).iCameraDisplayId < smallestCameraDisplayID)
       
   762             {
       
   763             smallestCameraDisplayID =
       
   764                iVideoQualitySets->At( i ).iCameraDisplayId;
       
   765             }
       
   766         }
       
   767     
       
   768     for( TInt i = 0 ;
       
   769          i < iVideoQualitySets->Count() && paramSet == EFalse ;
       
   770          i++ )
       
   771         {
       
   772         // videoCodecMimeTypeLength & audioFourCCTypeLength are used with
       
   773         // memcompare to compare strings
       
   774         TUint videoCodecMimeTypeLength = KMaxStringLength;
       
   775         for( TUint j = 0 ;
       
   776              j < KMaxStringLength &&
       
   777              videoCodecMimeTypeLength == KMaxStringLength ;
       
   778              j++ )
       
   779             {
       
   780             if( iVideoQualitySets->At( i ).iVideoCodecMimeType[ j ] == KZero )
       
   781                 {
       
   782                 videoCodecMimeTypeLength = j;
       
   783                 }
       
   784             }
       
   785 
       
   786         // Check that all given parameters match with the current set
       
   787         if( iVideoQualitySets->At( i ).iVideoWidth ==
       
   788                 aVideoResolution.iWidth &&
       
   789             iVideoQualitySets->At( i ).iVideoHeight ==
       
   790                 aVideoResolution.iHeight &&
       
   791            memcompare( iVideoQualitySets->At( i ).iVideoCodecMimeType,
       
   792                 videoCodecMimeTypeLength,
       
   793                 aVideoCodecMimeType.Ptr(),
       
   794                 aVideoCodecMimeType.Length() ) == 0 &&
       
   795            (iVideoQualitySets->At( i ).iAudioFourCCType.FourCC() == aAudioFourCCType.FourCC() ) &&
       
   796            ( ( aCameraDisplayID == 0 &&
       
   797                iVideoQualitySets->At( i ).iCameraDisplayId ==
       
   798                    smallestCameraDisplayID ) ||
       
   799              iVideoQualitySets->At( i ).iCameraDisplayId == aCameraDisplayID ) )
       
   800             {
       
   801             if( aVideoPixelAspectRatioNum == 0 &&
       
   802                 aVideoPixelAspectRatioDenom == 0 )
       
   803                 {
       
   804                 aSet = iVideoQualitySets->At( i );
       
   805                 paramSet = ETrue;
       
   806                 }
       
   807             else if( iVideoQualitySets->At( i ).iVideoPixelAspectRatioNum ==
       
   808                         aVideoPixelAspectRatioNum &&
       
   809                     iVideoQualitySets->At( i ).iVideoPixelAspectRatioDenom ==
       
   810                         aVideoPixelAspectRatioDenom )
       
   811                 {
       
   812                 aSet = iVideoQualitySets->At( i );
       
   813                 paramSet = ETrue;
       
   814                 }
       
   815             else
       
   816                 {
       
   817                 }
       
   818             }
       
   819         }
       
   820     if(paramSet == EFalse)
       
   821         {
       
   822         return KErrGeneral;
       
   823         }
       
   824     return KErrNone;
       
   825     }
       
   826 
       
   827 // ---------------------------------------------------------------------------
       
   828 // Get all settings for Camcorder
       
   829 // ---------------------------------------------------------------------------
       
   830 //
       
   831 EXPORT_C TInt CImagingConfigManager::GetCamcorderMMFPluginSettings(
       
   832                                 TCamcorderMMFPluginSettings& aSet ) const
       
   833     {
       
   834     aSet = iCamcorderMMFPluginSettings;
       
   835     return KErrNone;
       
   836     }
       
   837 
       
   838 // ---------------------------------------------------------------------------
       
   839 // Get number of defined image quality levels. This is always at least
       
   840 // KNumberOfNominalLevels but can be higher
       
   841 // ---------------------------------------------------------------------------
       
   842 //
       
   843 EXPORT_C TInt CImagingConfigManager::NumberOfImageQualityLevels() const
       
   844     {
       
   845     TInt retval = 0;
       
   846     if( iImageQualitySets )
       
   847     {
       
   848         retval = iImageQualitySets->Count();
       
   849     }
       
   850     return retval;
       
   851     }
       
   852 
       
   853 // ---------------------------------------------------------------------------
       
   854 // Get an array of image quality levels that are in use with the current
       
   855 // product with given Camera/Display ID. If the ID is zero, then all levels
       
   856 // dispite of the ID value are returned.
       
   857 // ---------------------------------------------------------------------------
       
   858 //
       
   859 EXPORT_C TInt CImagingConfigManager::GetImageQualityLevelsL(
       
   860                                         CArrayFixFlat<TUint>& aLevels,
       
   861                                         TUint aCameraDisplayID )
       
   862     {
       
   863     TKeyArrayFix key(0,ECmpTUint);
       
   864     aLevels.Reset();
       
   865     for( TInt i = 0 ; i < iImageQualitySets->Count() ; i++ )
       
   866         {
       
   867         if( aCameraDisplayID == 0 ||
       
   868             iImageQualitySets->At( i ).iCameraDisplayId == aCameraDisplayID )
       
   869             {
       
   870             aLevels.AppendL(
       
   871                 iImageQualitySets->At( i ).iImageQualitySetLevel );
       
   872             }
       
   873         }
       
   874     User::LeaveIfError(aLevels.Sort(key));
       
   875     return KErrNone;
       
   876     }
       
   877 
       
   878 // ---------------------------------------------------------------------------
       
   879 // Get image quality set associated with the given level and Camera/Display ID
       
   880 // if it is nonzero. If the ID is zero, smallest matching ID set is returned.
       
   881 // If there is no set associated with given intermediate
       
   882 // level, then set from a nearest level is returned (dividable by
       
   883 // KBasicQualityGranularity).
       
   884 // ---------------------------------------------------------------------------
       
   885 //
       
   886 EXPORT_C TInt CImagingConfigManager::GetImageQualitySet(
       
   887                                         TImageQualitySet& aSet,
       
   888                                         TInt aLevel,
       
   889                                         TUint aCameraDisplayID )
       
   890     {
       
   891     for( TUint i = 0 ; i < KMaxStringLength ; i++ )
       
   892         {
       
   893         aSet.iImageFileMimeType[ i ] = NULL;
       
   894         aSet.iImageFileExtension[ i ] = NULL;
       
   895         }
       
   896     aSet.iImageQualitySetLevel = 0;
       
   897     aSet.iImageWidth = 0;
       
   898     aSet.iImageHeight = 0;
       
   899     aSet.iImageEncoderUID.iUid = 0;
       
   900     aSet.iCompressionQuality = 0;
       
   901     aSet.iEstimatedSize = 0;
       
   902     aSet.iCameraDisplayId = 0;
       
   903     aSet.iCamcorderVisible = 0;
       
   904 
       
   905     TInt diff;
       
   906     TInt min = KMaxTInt; // set to as big number as possible initially
       
   907     TInt minIndex = KUndefined;
       
   908     TBool paramSet = EFalse;
       
   909     TUint smallestCameraDisplayID = KMaxTUint;
       
   910     
       
   911     for( TInt i = 0 ;
       
   912          i < iImageQualitySets->Count() && aCameraDisplayID == 0 ;
       
   913          i++ )
       
   914         {
       
   915         if(iImageQualitySets->At( i ).iCameraDisplayId < smallestCameraDisplayID)
       
   916             {
       
   917             smallestCameraDisplayID =
       
   918                iImageQualitySets->At( i ).iCameraDisplayId;
       
   919             }
       
   920         }
       
   921     
       
   922     for( TInt i = 0 ; i < iImageQualitySets->Count() && paramSet == EFalse ; i++ )
       
   923         {
       
   924         if( ( aCameraDisplayID == 0 &&
       
   925               iImageQualitySets->At( i ).iCameraDisplayId ==
       
   926                    smallestCameraDisplayID ) ||
       
   927             iImageQualitySets->At( i ).iCameraDisplayId == aCameraDisplayID )
       
   928             {
       
   929             if( iImageQualitySets->At( i ).iImageQualitySetLevel == aLevel )
       
   930                 {
       
   931                 aSet = iImageQualitySets->At( i );
       
   932                 paramSet = ETrue;
       
   933                 }
       
   934             else
       
   935                 {
       
   936                 diff = iImageQualitySets->At( i ).iImageQualitySetLevel - aLevel;
       
   937                 if( static_cast< TInt >( iImageQualitySets->At( i ).iImageQualitySetLevel ) < aLevel )
       
   938                     {
       
   939                     diff = -diff;
       
   940                     }
       
   941                 if( min > diff )
       
   942                     {
       
   943                     min = diff;
       
   944                     minIndex = i;
       
   945                     }
       
   946                 else if( min == diff && i > minIndex )
       
   947                     {
       
   948                     //If the difference is the same between two sets from the
       
   949                     //asked set, let's take the bigger one. Eg. 101 over 99
       
   950                     //if 100 was asked, but isn't present
       
   951                     minIndex = i;
       
   952                     }
       
   953                 }
       
   954             }
       
   955         }
       
   956     if( minIndex != KUndefined && paramSet == EFalse )
       
   957         {
       
   958         aSet = iImageQualitySets->At( minIndex );
       
   959         }
       
   960     else
       
   961         {
       
   962         return KErrGeneral; // No Quality sets were read from CenRep
       
   963         }
       
   964     return KErrNone;
       
   965     }
       
   966 
       
   967 // ---------------------------------------------------------------------------
       
   968 // Get quality set associated with the given image resolution and its
       
   969 // Camera/Display ID (which can be zero for all possible ID
       
   970 // values). All of these are needed to be uniquely able to select
       
   971 // a single quality setting set.
       
   972 // ---------------------------------------------------------------------------
       
   973 //
       
   974 EXPORT_C TInt CImagingConfigManager::GetImageQualitySet(
       
   975                     TImageQualitySet& aSet,
       
   976                     const TSize& aImageResolution,
       
   977                     TUint aCameraDisplayID )
       
   978     {
       
   979     for( TUint i = 0 ; i < KMaxStringLength ; i++ )
       
   980         {
       
   981         aSet.iImageFileMimeType[ i ] = NULL;
       
   982         aSet.iImageFileExtension[ i ] = NULL;
       
   983         }
       
   984     aSet.iImageQualitySetLevel = 0;
       
   985     aSet.iImageWidth = 0;
       
   986     aSet.iImageHeight = 0;
       
   987     aSet.iImageEncoderUID.iUid = 0;
       
   988     aSet.iCompressionQuality = 0;
       
   989     aSet.iEstimatedSize = 0;
       
   990     aSet.iCameraDisplayId = 0;
       
   991     aSet.iCamcorderVisible = 0;
       
   992 
       
   993     TBool paramSet = EFalse;
       
   994     TUint smallestCameraDisplayID = KMaxTUint;
       
   995     
       
   996     for( TInt i = 0 ;
       
   997          i < iImageQualitySets->Count() && aCameraDisplayID == 0 ;
       
   998          i++ )
       
   999         {
       
  1000         if(iImageQualitySets->At( i ).iCameraDisplayId < smallestCameraDisplayID)
       
  1001             {
       
  1002             smallestCameraDisplayID =
       
  1003                iImageQualitySets->At( i ).iCameraDisplayId;
       
  1004             }
       
  1005         }
       
  1006     
       
  1007     for( TInt i = 0 ; i < iImageQualitySets->Count() && paramSet == EFalse; i++ )
       
  1008         {
       
  1009         if( iImageQualitySets->At( i ).iImageWidth ==
       
  1010             aImageResolution.iWidth &&
       
  1011             iImageQualitySets->At( i ).iImageHeight ==
       
  1012             aImageResolution.iHeight &&
       
  1013             ( ( aCameraDisplayID == 0 &&
       
  1014                iImageQualitySets->At( i ).iCameraDisplayId ==
       
  1015                    smallestCameraDisplayID ) ||
       
  1016               iImageQualitySets->At( i ).iCameraDisplayId == aCameraDisplayID ) )
       
  1017             {
       
  1018             aSet = iImageQualitySets->At( i );
       
  1019             paramSet = ETrue;
       
  1020             }
       
  1021         }
       
  1022     if(paramSet == EFalse)
       
  1023         {
       
  1024         return KErrGeneral;
       
  1025         }
       
  1026     return KErrNone;
       
  1027     }