camerauis/cameraxui/cxengine/src/cxesettingsmappersymbian.cpp
changeset 46 c826656d6714
parent 28 3075d9b614e6
equal deleted inserted replaced
42:feebad15db8c 46:c826656d6714
     1 /*
     1 /*
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:
    14 * Description:
    15 *
    15 *
    16 */
    16 */
    17 /*
    17 
    18 * Symbian specific settings handling
    18 #include <QRegExp>
    19 */
       
    20 
       
    21 #include <ecamadvsettingsuids.hrh>
    19 #include <ecamadvsettingsuids.hrh>
    22 
    20 
    23 #include "cxeautofocuscontrol.h"
    21 #include "cxeautofocuscontrol.h"
    24 #include "cxesettingsmappersymbian.h"
    22 #include "cxesettingsmappersymbian.h"
    25 #include "cxutils.h"
    23 #include "cxutils.h"
    26 #include "cxenamespace.h"
    24 #include "cxenamespace.h"
    27 
    25 
    28 using namespace Cxe;
    26 using namespace Cxe;
    29 
    27 
    30 /*
    28 
    31 * Map White balance UI value to its corresponding CCamera value
    29 
    32 */
    30 /*!
    33 
    31     Map Cxe::Whitebalance value to its corresponding CCamera value.
    34 CCamera::TWhiteBalance
    32 */
    35 CxeSettingsMapperSymbian::Map2CameraWb(int wbId )
    33 CCamera::TWhiteBalance CxeSettingsMapperSymbian::Map2CameraWb(
    36 {
    34         Cxe::Whitebalance whiteBalance )
    37   CCamera::TWhiteBalance wb( CCamera::EWBAuto );
    35 {
    38   switch(wbId) {
    36     CCamera::TWhiteBalance wb(CCamera::EWBAuto);
    39     case WhitebalanceAutomatic:         wb = CCamera::EWBAuto;        break;
    37 
    40     case WhitebalanceSunny:             wb = CCamera::EWBDaylight;    break;
    38     switch (whiteBalance) {
    41     case WhitebalanceCloudy:            wb = CCamera::EWBCloudy;      break;
    39         case WhitebalanceSunny:
    42     case WhitebalanceIncandescent:      wb = CCamera::EWBTungsten;    break;
    40             wb = CCamera::EWBDaylight;
    43     case WhitebalanceFluorescent:       wb = CCamera::EWBFluorescent; break;
    41             break;
    44     default:                  
    42         case WhitebalanceCloudy:
    45       break;
    43             wb = CCamera::EWBCloudy;
    46   }
    44             break;
    47   return wb;
    45         case WhitebalanceIncandescent:
    48 }
    46             wb = CCamera::EWBTungsten;
    49 
    47             break;
    50 
    48         case WhitebalanceFluorescent:
    51 
    49             wb = CCamera::EWBFluorescent;
    52 // Map2CameraFlash
    50             break;
    53 
    51         case WhitebalanceAutomatic:
    54 CCamera::TFlash
    52         default:
    55 CxeSettingsMapperSymbian::Map2CameraFlash(int flashId)
    53             wb = CCamera::EWBAuto;
    56 {
    54             break;
    57   CCamera::TFlash flash( CCamera::EFlashAuto );
    55     }
    58   switch (flashId) {
    56     return wb;
    59     case FlashAuto:            flash = CCamera::EFlashAuto;          break;
    57 }
    60     case FlashAntiRedEye:      flash = CCamera::EFlashRedEyeReduce;  break;
    58 
    61     case FlashOn:              flash = CCamera::EFlashForced;        break;
    59 
    62     case FlashOff:             flash = CCamera::EFlashNone;          break;
    60 /*!
    63     default:                  
    61     Map Cxe::FlashMode to its corresponding CCamera value.
    64       break;
    62 */
    65   }
    63 CCamera::TFlash CxeSettingsMapperSymbian::Map2CameraFlash(
    66   return flash;
    64         Cxe::FlashMode flashMode)
    67 }
    65 {
    68 
    66     CCamera::TFlash flash(CCamera::EFlashAuto);
    69 
    67 
    70 // ---------------------------------------------------------------------------
    68     switch (flashMode) {
    71 // Map2CameraExposureMode
    69         case FlashAntiRedEye:
    72 // ---------------------------------------------------------------------------
    70             flash = CCamera::EFlashRedEyeReduce;
    73 //
    71             break;
    74 CCamera::TExposure
    72         case FlashOn:
    75 CxeSettingsMapperSymbian::Map2CameraExposureMode(int expModeId )
    73             flash = CCamera::EFlashForced;
    76   {
    74             break;
    77   CCamera::TExposure expo( CCamera::EExposureAuto );
    75         case FlashOff:
    78 
    76             flash = CCamera::EFlashNone;
    79   switch ( expModeId )
    77             break;
       
    78         case FlashAuto:
       
    79         default:
       
    80             flash = CCamera::EFlashAuto;
       
    81             break;
       
    82     }
       
    83     return flash;
       
    84 }
       
    85 
       
    86 
       
    87 /*!
       
    88     Map Cxe::ExposureMode to its corresponding CCamera value.
       
    89 */
       
    90 CCamera::TExposure CxeSettingsMapperSymbian::Map2CameraExposureMode(
       
    91         Cxe::ExposureMode exposureMode)
       
    92 {
       
    93     CCamera::TExposure expo(CCamera::EExposureAuto);
       
    94 
       
    95     switch (exposureMode) {
       
    96         case ExposureNight:
       
    97             expo = CCamera::EExposureNight;
       
    98             break;
       
    99         case ExposureBacklight:
       
   100             expo = CCamera::EExposureBacklight;
       
   101             break;
       
   102         case ExposureSport:
       
   103             expo = CCamera::EExposureSport;
       
   104             break;
       
   105         case ExposureAuto:
       
   106         default:
       
   107             expo = CCamera::EExposureAuto;
       
   108             break;
       
   109     }
       
   110 
       
   111     return expo;
       
   112 }
       
   113 
       
   114 
       
   115 /*!
       
   116     Map Cxe::ExposureMode to its corresponding CCamera value.
       
   117 */
       
   118 CCamera::CCameraImageProcessing::TEffect
       
   119         CxeSettingsMapperSymbian::Map2CameraEffect(Cxe::Colortone colorTone)
       
   120 {
       
   121     CCamera::CCameraImageProcessing::TEffect effect(
       
   122             CCamera::CCameraImageProcessing::EEffectNone);
       
   123 
       
   124     switch(colorTone) {
       
   125         case ColortoneBlackAndWhite:
       
   126             effect = CCamera::CCameraImageProcessing::EEffectMonochrome;
       
   127             break;
       
   128         case ColortoneSepia:
       
   129             effect = CCamera::CCameraImageProcessing::EEffectSepia;
       
   130             break;
       
   131         case ColortoneNegative:
       
   132             effect = CCamera::CCameraImageProcessing::EEffectNegative;
       
   133             break;
       
   134         case ColortoneVivid:
       
   135             effect = CCamera::CCameraImageProcessing::EEffectVivid;
       
   136             break;
       
   137         case ColortoneNormal:
       
   138         default:
       
   139             effect = CCamera::CCameraImageProcessing::EEffectNone;
       
   140             break;
       
   141     }
       
   142     return effect;
       
   143 }
       
   144 
       
   145 /*!
       
   146     Map CxeAutoFocusControl::Mode to its corresponding CCamera value.
       
   147 */
       
   148 CCamera::CCameraAdvancedSettings::TFocusRange
       
   149 CxeSettingsMapperSymbian::Map2CameraAutofocus(CxeAutoFocusControl::Mode afMode)
       
   150 {
       
   151     CCamera::CCameraAdvancedSettings::TFocusRange value;
       
   152 
       
   153     switch (afMode) {
       
   154         case CxeAutoFocusControl::Macro:
       
   155             value = CCamera::CCameraAdvancedSettings::EFocusRangeMacro;
       
   156             break;
       
   157         case CxeAutoFocusControl::Portrait:
       
   158             value = CCamera::CCameraAdvancedSettings::EFocusRangeAuto;
       
   159             break;
       
   160         case CxeAutoFocusControl::Infinity:
       
   161             value = CCamera::CCameraAdvancedSettings::EFocusRangeInfinite;
       
   162             break;
       
   163         case CxeAutoFocusControl::Hyperfocal:
       
   164             value = CCamera::CCameraAdvancedSettings::EFocusRangeHyperfocal;
       
   165             break;
       
   166         case CxeAutoFocusControl::Auto:     // Fall through
       
   167         default:
       
   168             value = CCamera::CCameraAdvancedSettings::EFocusRangeAuto;
       
   169             break;
       
   170     }
       
   171     return value;
       
   172 }
       
   173 
       
   174 
       
   175 
       
   176 /*!
       
   177     Map Cxe::DeviceOrientation to MCameraOrientation.
       
   178 */
       
   179 MCameraOrientation::TOrientation
       
   180         CxeSettingsMapperSymbian::Map2CameraOrientation(Cxe::DeviceOrientation
       
   181                                                         uiOrientation)
       
   182 {
       
   183     MCameraOrientation::TOrientation cameraOrientation;
       
   184 
       
   185     switch (uiOrientation) {
       
   186         case Orientation90:
       
   187             cameraOrientation = MCameraOrientation::EOrientation90;
       
   188             break;
       
   189         case Orientation180:
       
   190             cameraOrientation = MCameraOrientation::EOrientation180;
       
   191             break;
       
   192         case Orientation270:
       
   193             cameraOrientation = MCameraOrientation::EOrientation270;
       
   194             break;
       
   195         case Orientation0: // default
       
   196         default:
       
   197             cameraOrientation = MCameraOrientation::EOrientation0;
       
   198             break;
       
   199         }
       
   200     return cameraOrientation;
       
   201 }
       
   202 
       
   203 /*!
       
   204     Helper data structure to define how MIME types are mapped to
       
   205     MCameraUseCaseHint enumerations.
       
   206 */
       
   207 class CxeCodecMapping
       
   208 {
       
   209 public:
       
   210     CxeCodecMapping(const char *regexp, MCameraUseCaseHint::TVideoCodec codec,
       
   211                     MCameraUseCaseHint::TVideoProfile profile) :
       
   212     mRegExp(regexp),
       
   213     mCodec(codec),
       
   214     mProfile(profile)
    80     {
   215     {
    81     case ExposureAuto:       expo = CCamera::EExposureAuto; break;
   216     // No implementation needed
    82     case ExposureNight:      expo = CCamera::EExposureNight; break;
   217     }
    83     case ExposureBacklight:  expo = CCamera::EExposureBacklight; break;
   218 
    84     case ExposureSport:      expo = CCamera::EExposureSport; break;
   219 public:
    85     default:
   220     QString mRegExp;
    86       break;
   221     MCameraUseCaseHint::TVideoCodec mCodec;
    87     }
   222     MCameraUseCaseHint::TVideoProfile mProfile;
    88 
   223 };
    89   return expo;
   224 
    90   }
   225 /*!
    91 
   226     Map video codec MIME type from ICM to enumerations used by the
    92 
   227     MCameraUseCaseHint custom interface
    93 
   228 
    94 
   229     \param[in] videoDetails CxeVideoDetails defining the current video quality.
    95 // ---------------------------------------------------------------------------
   230     \param[out] codec       Reference where to store the video codec info.
    96 // Map2CameraEffect
   231                             MCameraUseCaseHint::ECodecUnknown if not known.
    97 // ---------------------------------------------------------------------------
   232     \param[out] profile     Reference where to store the video profile info.
    98 //
   233                             MCameraUseCaseHint::EProfileUnknown if not known.
    99 CCamera::CCameraImageProcessing::TEffect
   234 */
   100 CxeSettingsMapperSymbian::Map2CameraEffect(int colourFilterId)
   235 void CxeSettingsMapperSymbian::Map2UseCaseHintVideoParameters(
   101   {
   236         const CxeVideoDetails &videoDetails,
   102   CCamera::CCameraImageProcessing::TEffect effect(
   237         MCameraUseCaseHint::TVideoCodec &codec,
   103             CCamera::CCameraImageProcessing::EEffectNone );
   238         MCameraUseCaseHint::TVideoProfile &profile)
   104 
   239 {
   105   switch( colourFilterId )
   240     typedef QPair<MCameraUseCaseHint::TVideoCodec,
   106     {
   241                   MCameraUseCaseHint::TVideoProfile> CxeCodecAndProfile;
   107     case ColortoneNormal:        effect = CCamera::CCameraImageProcessing::EEffectNone;       break;
   242 
   108     case ColortoneBlackAndWhite: effect = CCamera::CCameraImageProcessing::EEffectMonochrome; break;
   243     codec = MCameraUseCaseHint::ECodecUnknown;
   109     case ColortoneSepia:         effect = CCamera::CCameraImageProcessing::EEffectSepia;      break;
   244     profile = MCameraUseCaseHint::EProfileUnknown;
   110     case ColortoneNegative:      effect = CCamera::CCameraImageProcessing::EEffectNegative;   break;
   245 
   111     case ColortoneVivid:         effect = CCamera::CCameraImageProcessing::EEffectVivid;      break;
   246     // Create a mapping table for mapping from the MIME type string
   112     default:
   247     // to MCameraUseCaseHint codec and profile enums using QRegExp. Specific
   113       break;
   248     // rules should be before more generic ones because the map is iterated in
   114     }
   249     // order.
   115   return effect;
   250     QList<CxeCodecMapping> mappingTable;
   116   }
   251 
   117 
   252     mappingTable << CxeCodecMapping("^video/H263-2000",
   118 
   253                                     MCameraUseCaseHint::ECodecH263,
   119 
   254                                     MCameraUseCaseHint::EProfileH263P0L10)
   120 // ---------------------------------------------------------------------------
   255 
   121 // CxeSettingsMapperSymbian::Map2CameraAutofocus
   256                  << CxeCodecMapping("^video/H264.*profile-level-id=42801E",
   122 // ---------------------------------------------------------------------------
   257                                     MCameraUseCaseHint::ECodecH264,
   123 //
   258                                     MCameraUseCaseHint::EProfileH264BpL3)
   124 CCamera::CCameraAdvancedSettings::TFocusRange
   259 
   125 CxeSettingsMapperSymbian::Map2CameraAutofocus(CxeAutoFocusControl::Mode afMode )
   260                  << CxeCodecMapping("^video/H264.*profile-level-id=42801F",
   126 {
   261                                     MCameraUseCaseHint::ECodecH264,
   127   CCamera::CCameraAdvancedSettings::TFocusRange value;
   262                                     MCameraUseCaseHint::EProfileH264BpL3_1)
   128   switch( afMode ) {
   263 
   129     case CxeAutoFocusControl::Macro:
   264                  << CxeCodecMapping("^video/H264", // Other H.264 profile
   130       value = CCamera::CCameraAdvancedSettings::EFocusRangeMacro;
   265                                     MCameraUseCaseHint::ECodecH264,
   131       break;
   266                                     MCameraUseCaseHint::EProfileUnknown)
   132     case CxeAutoFocusControl::Portrait:
   267 
   133       value = CCamera::CCameraAdvancedSettings::EFocusRangeAuto;
   268                  << CxeCodecMapping("^video/mp4v-es.*profile-level-id=2",
   134       break;
   269                                     MCameraUseCaseHint::ECodecMpeg4,
   135     case CxeAutoFocusControl::Infinity:
   270                                     MCameraUseCaseHint::EProfileMPEG4SpL2)
   136       value = CCamera::CCameraAdvancedSettings::EFocusRangeInfinite;
   271 
   137       break;
   272                  << CxeCodecMapping("^video/mp4v-es.*profile-level-id=3",
   138     case CxeAutoFocusControl::Hyperfocal:
   273                                     MCameraUseCaseHint::ECodecMpeg4,
   139       value = CCamera::CCameraAdvancedSettings::EFocusRangeHyperfocal;
   274                                     MCameraUseCaseHint::EProfileMPEG4SpL3)
   140       break;
   275 
   141     case CxeAutoFocusControl::Auto:     // Fall through
   276                  << CxeCodecMapping("^video/mp4v-es.*profile-level-id=4",
   142     default:
   277                                     MCameraUseCaseHint::ECodecMpeg4,
   143       value = CCamera::CCameraAdvancedSettings::EFocusRangeAuto;
   278                                     MCameraUseCaseHint::EProfileMPEG4SpL4a)
   144       break;
   279 
   145   }
   280                  << CxeCodecMapping("^video/mp4v-es", // Other MPEG-4 profile
   146   return value;
   281                                     MCameraUseCaseHint::ECodecMpeg4,
   147 }
   282                                     MCameraUseCaseHint::EProfileUnknown);
   148 
   283 
   149 
   284     bool found = false;
   150 
   285     for (int i = 0; i < mappingTable.count() && !found; i++) {
   151 // CxeSettingsMapperSymbian::Map2CameraOrientation
   286         QRegExp regExp(mappingTable[i].mRegExp, Qt::CaseInsensitive);
   152 
   287         if (regExp.indexIn(videoDetails.mVideoCodecMimeType) >= 0) {
   153 MCameraOrientation::TOrientation 
   288             found = true;
   154 CxeSettingsMapperSymbian::Map2CameraOrientation(DeviceOrientation uiOrientation)
   289             codec = mappingTable[i].mCodec;
   155 {
   290             profile = mappingTable[i].mProfile;
   156   MCameraOrientation::TOrientation cameraOrientation;
   291 
   157   switch(uiOrientation) {
   292             CX_DEBUG(("Matched codec %d, profile 0x%x for '%s'", codec, profile,
   158     case Orientation90:
   293                      videoDetails.mVideoCodecMimeType.toAscii().constData()));
   159 	    cameraOrientation = MCameraOrientation::EOrientation90;
   294         }
   160 		break;
   295     }
   161     case Orientation180:
   296 
   162 	    cameraOrientation = MCameraOrientation::EOrientation180;
   297     if (!found) {
   163 		break;
   298         CX_DEBUG(("No codec/profile found for '%s'",
   164     case Orientation270:
   299                  videoDetails.mVideoCodecMimeType.toAscii().constData()));
   165 	    cameraOrientation = MCameraOrientation::EOrientation270;
   300     }
   166 		break;
       
   167     case Orientation0: // default
       
   168     default:                  
       
   169 	    cameraOrientation = MCameraOrientation::EOrientation0;
       
   170 		break;
       
   171     }
       
   172   return cameraOrientation;
       
   173 }
   301 }
   174 
   302 
   175 // end of file
   303 // end of file