camerauis/cameraxui/cxengine/src/cxesettingsmappersymbian.cpp
branchRCL_3
changeset 23 61bc0f252b2b
equal deleted inserted replaced
22:f54ad444594d 23:61bc0f252b2b
       
     1 /*
       
     2 * Copyright (c) 2009-2010 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:
       
    15 *
       
    16 */
       
    17 
       
    18 #include <QRegExp>
       
    19 #include <ecamadvsettingsuids.hrh>
       
    20 
       
    21 #include "cxeautofocuscontrol.h"
       
    22 #include "cxesettingsmappersymbian.h"
       
    23 #include "cxutils.h"
       
    24 #include "cxenamespace.h"
       
    25 
       
    26 using namespace Cxe;
       
    27 
       
    28 
       
    29 
       
    30 /*!
       
    31     Map Cxe::Whitebalance value to its corresponding CCamera value.
       
    32 */
       
    33 CCamera::TWhiteBalance CxeSettingsMapperSymbian::Map2CameraWb(
       
    34         Cxe::Whitebalance whiteBalance )
       
    35 {
       
    36     CCamera::TWhiteBalance wb(CCamera::EWBAuto);
       
    37 
       
    38     switch (whiteBalance) {
       
    39         case WhitebalanceSunny:
       
    40             wb = CCamera::EWBDaylight;
       
    41             break;
       
    42         case WhitebalanceCloudy:
       
    43             wb = CCamera::EWBCloudy;
       
    44             break;
       
    45         case WhitebalanceIncandescent:
       
    46             wb = CCamera::EWBTungsten;
       
    47             break;
       
    48         case WhitebalanceFluorescent:
       
    49             wb = CCamera::EWBFluorescent;
       
    50             break;
       
    51         case WhitebalanceAutomatic:
       
    52         default:
       
    53             wb = CCamera::EWBAuto;
       
    54             break;
       
    55     }
       
    56     return wb;
       
    57 }
       
    58 
       
    59 
       
    60 /*!
       
    61     Map Cxe::FlashMode to its corresponding CCamera value.
       
    62 */
       
    63 CCamera::TFlash CxeSettingsMapperSymbian::Map2CameraFlash(
       
    64         Cxe::FlashMode flashMode)
       
    65 {
       
    66     CCamera::TFlash flash(CCamera::EFlashAuto);
       
    67 
       
    68     switch (flashMode) {
       
    69         case FlashAntiRedEye:
       
    70             flash = CCamera::EFlashRedEyeReduce;
       
    71             break;
       
    72         case FlashOn:
       
    73             flash = CCamera::EFlashForced;
       
    74             break;
       
    75         case FlashOff:
       
    76             flash = CCamera::EFlashNone;
       
    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)
       
   215     {
       
   216     // No implementation needed
       
   217     }
       
   218 
       
   219 public:
       
   220     QString mRegExp;
       
   221     MCameraUseCaseHint::TVideoCodec mCodec;
       
   222     MCameraUseCaseHint::TVideoProfile mProfile;
       
   223 };
       
   224 
       
   225 /*!
       
   226     Map video codec MIME type from ICM to enumerations used by the
       
   227     MCameraUseCaseHint custom interface
       
   228 
       
   229     \param[in] videoDetails CxeVideoDetails defining the current video quality.
       
   230     \param[out] codec       Reference where to store the video codec info.
       
   231                             MCameraUseCaseHint::ECodecUnknown if not known.
       
   232     \param[out] profile     Reference where to store the video profile info.
       
   233                             MCameraUseCaseHint::EProfileUnknown if not known.
       
   234 */
       
   235 void CxeSettingsMapperSymbian::Map2UseCaseHintVideoParameters(
       
   236         const CxeVideoDetails &videoDetails,
       
   237         MCameraUseCaseHint::TVideoCodec &codec,
       
   238         MCameraUseCaseHint::TVideoProfile &profile)
       
   239 {
       
   240     typedef QPair<MCameraUseCaseHint::TVideoCodec,
       
   241                   MCameraUseCaseHint::TVideoProfile> CxeCodecAndProfile;
       
   242 
       
   243     codec = MCameraUseCaseHint::ECodecUnknown;
       
   244     profile = MCameraUseCaseHint::EProfileUnknown;
       
   245 
       
   246     // Create a mapping table for mapping from the MIME type string
       
   247     // to MCameraUseCaseHint codec and profile enums using QRegExp. Specific
       
   248     // rules should be before more generic ones because the map is iterated in
       
   249     // order.
       
   250     QList<CxeCodecMapping> mappingTable;
       
   251 
       
   252     mappingTable << CxeCodecMapping("^video/H263-2000",
       
   253                                     MCameraUseCaseHint::ECodecH263,
       
   254                                     MCameraUseCaseHint::EProfileH263P0L10)
       
   255 
       
   256                  << CxeCodecMapping("^video/H264.*profile-level-id=42801E",
       
   257                                     MCameraUseCaseHint::ECodecH264,
       
   258                                     MCameraUseCaseHint::EProfileH264BpL3)
       
   259 
       
   260                  << CxeCodecMapping("^video/H264.*profile-level-id=42801F",
       
   261                                     MCameraUseCaseHint::ECodecH264,
       
   262                                     MCameraUseCaseHint::EProfileH264BpL3_1)
       
   263 
       
   264                  << CxeCodecMapping("^video/H264", // Other H.264 profile
       
   265                                     MCameraUseCaseHint::ECodecH264,
       
   266                                     MCameraUseCaseHint::EProfileUnknown)
       
   267 
       
   268                  << CxeCodecMapping("^video/mp4v-es.*profile-level-id=2",
       
   269                                     MCameraUseCaseHint::ECodecMpeg4,
       
   270                                     MCameraUseCaseHint::EProfileMPEG4SpL2)
       
   271 
       
   272                  << CxeCodecMapping("^video/mp4v-es.*profile-level-id=3",
       
   273                                     MCameraUseCaseHint::ECodecMpeg4,
       
   274                                     MCameraUseCaseHint::EProfileMPEG4SpL3)
       
   275 
       
   276                  << CxeCodecMapping("^video/mp4v-es.*profile-level-id=4",
       
   277                                     MCameraUseCaseHint::ECodecMpeg4,
       
   278                                     MCameraUseCaseHint::EProfileMPEG4SpL4a)
       
   279 
       
   280                  << CxeCodecMapping("^video/mp4v-es", // Other MPEG-4 profile
       
   281                                     MCameraUseCaseHint::ECodecMpeg4,
       
   282                                     MCameraUseCaseHint::EProfileUnknown);
       
   283 
       
   284     bool found = false;
       
   285     for (int i = 0; i < mappingTable.count() && !found; i++) {
       
   286         QRegExp regExp(mappingTable[i].mRegExp, Qt::CaseInsensitive);
       
   287         if (regExp.indexIn(videoDetails.mVideoCodecMimeType) >= 0) {
       
   288             found = true;
       
   289             codec = mappingTable[i].mCodec;
       
   290             profile = mappingTable[i].mProfile;
       
   291 
       
   292             CX_DEBUG(("Matched codec %d, profile 0x%x for '%s'", codec, profile,
       
   293                      videoDetails.mVideoCodecMimeType.toAscii().constData()));
       
   294         }
       
   295     }
       
   296 
       
   297     if (!found) {
       
   298         CX_DEBUG(("No codec/profile found for '%s'",
       
   299                  videoDetails.mVideoCodecMimeType.toAscii().constData()));
       
   300     }
       
   301 }
       
   302 
       
   303 // end of file