camerauis/cameraapp/generic/common/inc/camconfiguration.h
branchRCL_3
changeset 24 bac7acad7cb3
parent 0 1ddebce53859
equal deleted inserted replaced
23:61bc0f252b2b 24:bac7acad7cb3
       
     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 for camera dynamic configuration.
       
    15 *                
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef CAMCONFIGURATION_H
       
    21 #define CAMCONFIGURATION_H
       
    22 
       
    23 // INCLUDES
       
    24 
       
    25 #include <e32base.h>
       
    26 #include "CamSettingsInternal.hrh"
       
    27 #include "CamPSI.h"
       
    28 #include "camconfigurationtypes.h"
       
    29 #include "imagingconfigmanager.h"
       
    30 #include "CamSettings.hrh"
       
    31 
       
    32 // FORWARD DECLARATIONS
       
    33 
       
    34 class CImagingConfigManager;
       
    35 struct TVideoQualitySet;
       
    36 struct TImageQualitySet;
       
    37 
       
    38 // CLASS DECLARATION
       
    39 
       
    40 /**
       
    41 * Class CCamConfiguration
       
    42 * Queries supported image and video qualities for ICM and creates the related 
       
    43 * data and does the mappings needed by cameraapp application. These include
       
    44 * quality descriptions and icons.
       
    45 * 
       
    46 * In the initial phase, emulates the product specific configuration code,
       
    47 * so only minimal changes are needed in cameraapp UI code.
       
    48 */
       
    49 class CCamConfiguration: public CBase
       
    50 {  
       
    51   public: // Constructors and destructors
       
    52    
       
    53    	/**
       
    54     * Destructor.
       
    55     */
       
    56     ~CCamConfiguration(); 
       
    57     
       
    58     /**
       
    59     * Two-phased constructor.
       
    60     * @return pointer to the created CCamConfiguration object
       
    61     */  
       
    62     static CCamConfiguration* NewL();
       
    63     
       
    64   public: // New functions
       
    65     
       
    66     /**
       
    67     * Returns number of image qualities configured using ICM. Setting data
       
    68     * for these qualities is accessible via ImageQuality() function.
       
    69     * @return Number of qualities
       
    70     */
       
    71     TInt NumImageQualities() const;
       
    72     
       
    73     /**
       
    74     * Returns index for primary camera MMS quality
       
    75     * @return MMS quality index or KErrNotFound
       
    76     */   
       
    77     TInt MmsImageQuality() const;
       
    78     
       
    79     /**
       
    80     * Returns index for secondary camera imagequality.
       
    81     * @return Secondary image quality index or KErrNotFound
       
    82     */    
       
    83     TInt SecondaryCameraImageQuality() const;   
       
    84     
       
    85     /**
       
    86     * Returns settings of the requested quality
       
    87     * @param aIndex Index of the quality (Must be <NumImageQualities())
       
    88     * @return Quality settings
       
    89     */
       
    90     const TCamPhotoQualitySetting& ImageQuality( TInt aIndex ) const;
       
    91         
       
    92     /**
       
    93     * Returns number of video qualities configured using ICM. Setting data
       
    94     * for these qualities is accessible via VideoQuality() function.
       
    95     * @return Number of video qualities
       
    96     */
       
    97     TInt NumVideoQualities() const;
       
    98   
       
    99     /**
       
   100     * Returns number of primary camera image qualities configured using ICM.
       
   101     * Setting data for these qualities is accessible via ImageQuality( TInt aIndex ) function.
       
   102     * @return Number of primary camera image qualities
       
   103     */
       
   104     TInt NumPrimaryImageQualities() const;
       
   105 
       
   106     /**
       
   107     * Returns index for secondary camera video quality. Currently this is
       
   108     * always same as last quality for primary camera.
       
   109     * @return Secondary video quality index
       
   110     */
       
   111     TInt SecondaryCameraVideoQuality() const; 
       
   112   
       
   113     /**
       
   114     * Returns the quality setting for a required index from iVideoQualities array
       
   115     * in camera video quality.
       
   116     * @return iVideoQualities array index
       
   117     */
       
   118     TInt VideoQualitySetting( TInt aIndex ) const;
       
   119 
       
   120     /**
       
   121     * Returns settings data of the requested video quality
       
   122     * @param aIndex Index of the quality (Must be <NumImageQualities())
       
   123     * @return Quality settings
       
   124     */
       
   125     const TVideoQualitySettings& VideoQuality( TInt aIndex ) const;
       
   126     
       
   127     /**
       
   128     * Gives description id for given image/video quality
       
   129     * Image: TCamImageQualitySetting => TCamPhotoQualityDescription
       
   130     * Video:  TCamVideoQualitySettings => TCamVideoQualityDescription
       
   131     * @param aVideoMode EFalse if image mode
       
   132     * @param aQualityVal Quality value
       
   133     * @return Description id
       
   134     *
       
   135     */
       
   136     TInt MapSupportedQualityToQualityDescriptor( TBool aVideoMode,
       
   137                                                  TInt aQualityVal ) const;      
       
   138                                                  
       
   139     /**
       
   140     * Returns the the following image quality related integer arrays:
       
   141     * - ECamPsiSupportedStillResolutions
       
   142     * - ECamPsiJpegDataSizes
       
   143     * - ECamPsiSequencePostProcessDataSizes
       
   144     * - ECamPsiSupportedStillQualities
       
   145     * - ECamPsiStillQualityIconIds
       
   146     * - ECamPsiPrecapStillQualityIconIds
       
   147     * And following video quality related arrays:
       
   148     * - ECamPsiSupportedVideoQualities
       
   149     * - ECamPsiPrecapVideoQualityIconIds
       
   150     * - ECamPsiVideoQualityIconIds
       
   151     * - ECamPsiVideoQualityFileTypeId
       
   152     *
       
   153     * @param aKey   Key
       
   154     * @param aArray Destination array
       
   155     */
       
   156     void GetPsiIntArrayL( TCamPsiKey aKey, RArray<TInt>& aArray ) const; 
       
   157                                                  
       
   158     /**
       
   159     * Provides mapping between TCamImageResolution and TCamPhotoSizeId types
       
   160     * @param aResolution
       
   161     * @return Photo Size
       
   162     */
       
   163     static TCamPhotoSizeId MapResolutionToPhotoSize( TCamImageResolution aResolution );
       
   164       
       
   165     /**
       
   166     * Provides mapping between TCamPhotoSizeId and TCamImageResolution types
       
   167     * @param aSizeId
       
   168     * @return Resolution
       
   169     */  
       
   170     static TCamImageResolution MapPhotoSizeToResolution( TCamPhotoSizeId aSizeId );  
       
   171   
       
   172     /**
       
   173     * Calculate number of images than can still be taken with the current
       
   174     * image size
       
   175     * @param aStorage Storage media
       
   176     * @param aSizeId The current photo resolution setting
       
   177     * @param aCriticalLevel Critical threshold on the specified drive 
       
   178     * @param aBurstActive Whether or not burst mode is active
       
   179     * @return Number of images
       
   180     */        
       
   181     TInt ImagesRemaining( TCamMediaStorage aStorage,
       
   182                           TCamPhotoSizeId aSizeId, 
       
   183                           TInt aCriticalLevel, 
       
   184                           TBool aBurstActive ) const;          
       
   185                           
       
   186     /**
       
   187     * Returns the CMR average video bitrate scaler (obtained from ICM)
       
   188     * This is used to scale bitrates for remaining video time calculation
       
   189     * @return scaler
       
   190     */
       
   191     TReal CMRAvgVideoBitRateScaler() const;
       
   192     
       
   193     /**
       
   194     * Returns the default VideoQuality setting which has the highest 
       
   195     * iVideoQualitySetLevel value (obtained from ICM)
       
   196     * This is used to get the default video quality setting when restore
       
   197     * settings or frist start camera
       
   198     * @return video quality
       
   199     */
       
   200 	TCamVideoQualitySettings GetDefaultVideoQualityFromIcmL();
       
   201     
       
   202     /** 
       
   203     * Returns the index to the image quality required by embedding application
       
   204     * @return index to icm image configuration array
       
   205     */
       
   206     TInt GetRequiredImageQualityIndex( const TSize& aResolution ) const;
       
   207 
       
   208     /** 
       
   209     * Returns the resolution that matches closest to the required resolution by embedding application
       
   210     * @return TSize of the resolution
       
   211     */
       
   212     TSize MapRequiredResolutionToActualResolutionPhoto( const TSize& aRequiredResolution ) const;
       
   213 
       
   214     /** 
       
   215     * Returns the index to the video quality required by embedding application
       
   216     * @return index to icm video configuration array
       
   217     */
       
   218     TInt GetRequiredVideoQualityIndex( const TSize& aResolution ) const;
       
   219 
       
   220     /** 
       
   221     * Returns the resolution that matches closest to the required resolution by embedding application
       
   222     * @return TSize of the resolution
       
   223     */
       
   224     TSize MapRequiredResolutionToActualResolutionVideo( const TSize& aRequiredResolution ) const;
       
   225 
       
   226                                                  
       
   227   private:  
       
   228     /**
       
   229     * C++ default constructor.
       
   230     * @since 2.8
       
   231     */        
       
   232     CCamConfiguration();
       
   233     
       
   234     /**
       
   235     * 2nd phase constructor.
       
   236     */
       
   237     void ConstructL();
       
   238     
       
   239     /**
       
   240     * Queries image qualities from ICM, converts enabled qualities to internal
       
   241     * data formats and adds them to ordered arrays.
       
   242     */
       
   243     void InitializeImageQualitiesL();
       
   244     
       
   245     /**
       
   246     * Initializes TCamImageQualityData contents based on TImageQualitySet, which
       
   247     * we have received from the ICM.
       
   248     * @param aSet Image quality set from ICM
       
   249     * @param aData CamConfiguration image quality data structure
       
   250     */
       
   251     void InitializeImageQualityL( const TImageQualitySet& aSet, TCamImageQualityData& aData );
       
   252     
       
   253     /**
       
   254     * Returns all data of the requested quality
       
   255     * @param aIndex Index of the quality (Must be <NumImageQualities())
       
   256     * @return Quality data
       
   257     */
       
   258     const TCamImageQualityData& ImageQualityData( TInt aIndex ) const;    
       
   259     
       
   260     /**
       
   261     * Queries video qualities from ICM, converts enabled qualities to internal
       
   262     * data formats and adds them to ordered arrays.
       
   263     */    
       
   264     void InitializeVideoQualitiesL();
       
   265     
       
   266     /**
       
   267     * Creates TCamVideoQualityData contents based on TVideoQualitySet, which we
       
   268     * have received from ICM. Not const, because memory allocations are needed
       
   269     * for string data.
       
   270     * @param aSet ICM video quality data
       
   271     * @return Video quality data in CamConfiguration data structure
       
   272     */
       
   273     TCamVideoQualityData CreateVideoQualityDataL( const TVideoQualitySet& aSet );
       
   274        
       
   275     /**
       
   276     * Adds the given image quality data to correct place in ordered image
       
   277     * qualities data array. Ordering is done based on number of pixels in the
       
   278     * image quality.
       
   279     * @param aQuality Image quality data
       
   280     * @param aArray Ordered image quality data array
       
   281     */
       
   282     static void AddToOrderedImageQualitiesArrayL( TCamImageQualityData& aQuality, 
       
   283                                                   RArray<TCamImageQualityData>& aArray );
       
   284 
       
   285     /**
       
   286     * Adds the given video quality data to correct place in ordered video
       
   287     * qualities data array. Ordering is done based on the image quality
       
   288     * description enumeration. (Highest quality first)
       
   289     * @param aQuality Image quality data
       
   290     * @param aArray Ordered image quality data array
       
   291     */                                                  
       
   292     static void AddToOrderedVideoQualitiesArrayL( TCamVideoQualityData& aQuality,
       
   293                                                   RArray<TCamVideoQualityData>& aArray );   
       
   294                                                                                               
       
   295     /**
       
   296     * Checks if the value for aValue is used for type aCheckType if the 
       
   297     * supported image qualities. If so, Appends the aAppendType value 
       
   298     * (or aValue, if aAppendType is ECamItemSame) of that quality to
       
   299     * the array.
       
   300     * 
       
   301     * @param aCheckType Type for checking existence of value
       
   302     * @param aValue Item value (of checking type)
       
   303     * @param aArray Integer array
       
   304     * @param aAppendType Type of correspondin value to be appended
       
   305     */                                                  
       
   306     void AppendIfSupportedL( TCamItemType aCheckType, TInt aValue,
       
   307                              RArray<TInt>&aArray, TCamItemType aAppendType=ECamItemSame ) const;
       
   308    
       
   309     /**
       
   310     * Appends value of item of type aType from image quality data to aArray.
       
   311     * @param aType Item type
       
   312     * @param aArray Destination array
       
   313     * @param aData Image quality data
       
   314     */                          
       
   315     static void AppendTypeL( TCamItemType aType, RArray<TInt>&aArray, const TCamImageQualityData& aData );
       
   316     
       
   317     /**
       
   318     * @param aValue Video resolution value
       
   319     * @param aArray Destination array
       
   320     */
       
   321     void AppendVideoResIfSupportedL( TInt aValue, RArray<TInt>&aArray ) const;
       
   322   
       
   323     /**
       
   324     * Allocates memory for asciiz string given in aData. Returns pointer to the
       
   325     * string in the allocated memory.
       
   326     * @param aData
       
   327     * @return String
       
   328     */  
       
   329     const TUint8*  AllocString8L( const TUint8* aData );
       
   330     
       
   331     /**
       
   332     * Allocates memory for asciiz string given in aData, converts it to 16-bit
       
   333     * and returns pointer to the 16-bit string in the allocated memory.
       
   334     * @param aData
       
   335     * @return String
       
   336     */      
       
   337     const TUint16* AllocString16L( const TUint8* aData ); 
       
   338   
       
   339   private: // Data
       
   340   
       
   341     // Imaging configuration manager 
       
   342     CImagingConfigManager* iIcm;
       
   343     
       
   344     // Camera display ids. Used when querying ICM for supported image and 
       
   345     // video qualities.
       
   346     TInt iPrimaryCameraDisplayId;
       
   347     TInt iSecondaryCameraDisplayId;
       
   348     
       
   349     // Image qualities data for primary and secondary camera
       
   350     RArray<TCamImageQualityData> iPrimaryCameraPhotoQualities;
       
   351     RArray<TCamImageQualityData> iSecondaryCameraPhotoQualities;
       
   352     
       
   353     // Video quality data. Last item is shared between primary camera MMS
       
   354     // quality and secondary camera.
       
   355     RArray<TCamVideoQualityData> iVideoQualities;  
       
   356     TInt                         iSecondaryVideoQualityIndex;
       
   357     
       
   358     // Arrays for storing (video qualities) string data from ICM
       
   359     // All the content is owned by CCamConfiguration
       
   360     RPointerArray<HBufC8> iStrings8;
       
   361     RPointerArray<HBufC16> iStrings16;  
       
   362     
       
   363     // Average video bitrate scaler - needed for remaining time calculation
       
   364     TReal iCMRAvgVideoBitRateScaler;
       
   365 };
       
   366 
       
   367 #endif // CAMCONFIGURATION_H
       
   368 
       
   369 // End of file
       
   370