tsrc/mceclientstub/src/mcecamerasource.cpp
changeset 15 ccd8e69b5392
parent 2 b31261fd4e04
child 20 e8be2c2e049d
child 22 496ad160a278
equal deleted inserted replaced
2:b31261fd4e04 15:ccd8e69b5392
     1 /*
       
     2 * Copyright (c) 2006 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 
       
    19 #include "mcecamerasource.h"
       
    20 #include "mcesession.h"
       
    21 #include "mcemediastream.h"
       
    22 #include "mcemanager.h"
       
    23 
       
    24 
       
    25 const TInt KMinDigitalZoom = 0;
       
    26 const TInt KMinContrast = -100;
       
    27 const TInt KMaxContrast = 100;
       
    28 const TInt KMinBrightness = -100;
       
    29 const TInt KMaxBrightness = 100; 
       
    30 
       
    31 
       
    32 const TInt KInitialCameraIndex = 0;
       
    33 const TInt KInitialZoomFactor = 1;
       
    34 const TInt KInitialDigitalZoomFactor = 1;
       
    35 const TInt KInitialContrast = 0;
       
    36 const TInt KInitialBrightness = 0;
       
    37 const TInt KInitialExposure = CCamera::EExposureAuto;
       
    38 const TInt KInitialWhiteBalance = CCamera::EWBAuto;
       
    39 
       
    40 // ============================ MEMBER FUNCTIONS ===============================
       
    41 
       
    42 
       
    43 // -----------------------------------------------------------------------------
       
    44 // 
       
    45 // -----------------------------------------------------------------------------
       
    46 //
       
    47 EXPORT_C CMceCameraSource* CMceCameraSource::NewL( CMceManager& aManager )
       
    48     {
       
    49     CMceCameraSource* self = CMceCameraSource::NewLC( aManager );
       
    50     CleanupStack::Pop( self );
       
    51     return self;
       
    52     }
       
    53 
       
    54 
       
    55 // -----------------------------------------------------------------------------
       
    56 // 
       
    57 // -----------------------------------------------------------------------------
       
    58 //
       
    59 EXPORT_C CMceCameraSource* CMceCameraSource::NewLC( CMceManager& aManager )
       
    60     {
       
    61     CMceCameraSource* self = new (ELeave) CMceCameraSource();
       
    62     CleanupStack::PushL( self );
       
    63     self->ConstructL( &aManager );
       
    64     return self;
       
    65     }
       
    66 
       
    67 
       
    68 // -----------------------------------------------------------------------------
       
    69 // 
       
    70 // -----------------------------------------------------------------------------
       
    71 //
       
    72 EXPORT_C CMceCameraSource::~CMceCameraSource()
       
    73     {
       
    74     }
       
    75 
       
    76 
       
    77 // -----------------------------------------------------------------------------
       
    78 // 
       
    79 // -----------------------------------------------------------------------------
       
    80 //
       
    81 EXPORT_C void CMceCameraSource::EnableL()
       
    82     {
       
    83     CMceMediaSource::DoEnableL();
       
    84     }
       
    85 
       
    86 
       
    87 // -----------------------------------------------------------------------------
       
    88 // 
       
    89 // -----------------------------------------------------------------------------
       
    90 //
       
    91 EXPORT_C void CMceCameraSource::DisableL()
       
    92     { 
       
    93     CMceMediaSource::DoDisableL();
       
    94     }
       
    95 
       
    96 
       
    97 // -----------------------------------------------------------------------------
       
    98 // 
       
    99 // -----------------------------------------------------------------------------
       
   100 //	    
       
   101 EXPORT_C TInt CMceCameraSource::CamerasAvailable() const
       
   102     {
       
   103     return 1;
       
   104     }
       
   105 
       
   106 
       
   107 // -----------------------------------------------------------------------------
       
   108 // 
       
   109 // -----------------------------------------------------------------------------
       
   110 //
       
   111 EXPORT_C void CMceCameraSource::SetCameraIndexL( TInt aCameraIndex )	  
       
   112     {
       
   113     __ASSERT_ALWAYS( aCameraIndex >= 0 &&
       
   114                      aCameraIndex < this->CamerasAvailable(),
       
   115                      User::Leave( KErrArgument ) );
       
   116                      
       
   117    
       
   118     iCameraIndex = aCameraIndex;         
       
   119     
       
   120     }          
       
   121      
       
   122        
       
   123 // -----------------------------------------------------------------------------
       
   124 // 
       
   125 // -----------------------------------------------------------------------------
       
   126 //	     
       
   127 EXPORT_C void CMceCameraSource::GetCameraInfo( TCameraInfo& aInfo ) const
       
   128     {
       
   129     aInfo = iCameraInfo;
       
   130     }
       
   131 
       
   132 
       
   133 // -----------------------------------------------------------------------------
       
   134 // 
       
   135 // -----------------------------------------------------------------------------
       
   136 //	
       
   137 EXPORT_C void CMceCameraSource::SetZoomFactorL( TInt aZoomFactor )
       
   138     {
       
   139     __ASSERT_ALWAYS( aZoomFactor >= iCameraInfo.iMinZoom &&
       
   140                      aZoomFactor <= iCameraInfo.iMaxZoom, 
       
   141                      User::Leave( KErrArgument ) );
       
   142     
       
   143     iZoomFactor = aZoomFactor;    
       
   144     }
       
   145 
       
   146 
       
   147 // -----------------------------------------------------------------------------
       
   148 // 
       
   149 // -----------------------------------------------------------------------------
       
   150 //	
       
   151 EXPORT_C TInt CMceCameraSource::ZoomFactorL()
       
   152     {
       
   153     return iZoomFactor; 
       
   154     }
       
   155 
       
   156 
       
   157 // -----------------------------------------------------------------------------
       
   158 // 
       
   159 // -----------------------------------------------------------------------------
       
   160 //	
       
   161 EXPORT_C void CMceCameraSource::SetDigitalZoomFactorL( TInt aDigitalZoomFactor )
       
   162     {
       
   163     __ASSERT_ALWAYS( aDigitalZoomFactor >= KMinDigitalZoom &&
       
   164                      aDigitalZoomFactor <= iCameraInfo.iMaxDigitalZoom, 
       
   165                      User::Leave( KErrArgument ) );
       
   166     
       
   167     iDigitalZoomFactor = aDigitalZoomFactor;
       
   168         
       
   169     }
       
   170 
       
   171 
       
   172 // -----------------------------------------------------------------------------
       
   173 // 
       
   174 // -----------------------------------------------------------------------------
       
   175 //	
       
   176 EXPORT_C TInt CMceCameraSource::DigitalZoomFactorL()
       
   177     {
       
   178     return iDigitalZoomFactor;
       
   179     }
       
   180 
       
   181 
       
   182 // -----------------------------------------------------------------------------
       
   183 // 
       
   184 // -----------------------------------------------------------------------------
       
   185 //	
       
   186 EXPORT_C void CMceCameraSource::SetContrastL( TInt aContrast )
       
   187     {
       
   188     
       
   189     __ASSERT_ALWAYS( ( iCameraInfo.iOptionsSupported & 
       
   190                        TCameraInfo::EContrastSupported ) ==
       
   191                      TCameraInfo::EContrastSupported,
       
   192                      User::Leave( KErrNotSupported ) );
       
   193                     
       
   194     __ASSERT_ALWAYS( (( aContrast >= KMinContrast &&
       
   195                         aContrast <= KMaxContrast ) ||
       
   196                         aContrast == CCamera::EContrastAuto ),
       
   197                      User::Leave( KErrArgument ) );
       
   198                       
       
   199                                            
       
   200     iContrast = aContrast;
       
   201   
       
   202     }
       
   203 
       
   204 
       
   205 // -----------------------------------------------------------------------------
       
   206 // 
       
   207 // -----------------------------------------------------------------------------
       
   208 //	
       
   209 EXPORT_C TInt CMceCameraSource::ContrastL()
       
   210     {
       
   211     return iContrast;
       
   212     }
       
   213 
       
   214 
       
   215 // -----------------------------------------------------------------------------
       
   216 // 
       
   217 // -----------------------------------------------------------------------------
       
   218 //	
       
   219 EXPORT_C void CMceCameraSource::SetBrightnessL( TInt aBrightness )
       
   220     {
       
   221     
       
   222     __ASSERT_ALWAYS( ( iCameraInfo.iOptionsSupported & 
       
   223                        TCameraInfo::EBrightnessSupported ) ==
       
   224                      TCameraInfo::EBrightnessSupported,
       
   225                      User::Leave( KErrNotSupported ) );
       
   226                    
       
   227     __ASSERT_ALWAYS( (( aBrightness >= KMinBrightness &&
       
   228                         aBrightness <= KMaxBrightness ) ||
       
   229                         aBrightness == CCamera::EBrightnessAuto ),
       
   230                      User::Leave( KErrArgument ) );
       
   231     
       
   232     iBrightness = aBrightness;
       
   233         
       
   234     }
       
   235 
       
   236 
       
   237 // -----------------------------------------------------------------------------
       
   238 // 
       
   239 // -----------------------------------------------------------------------------
       
   240 //	
       
   241 EXPORT_C TInt CMceCameraSource::BrightnessL()
       
   242     {
       
   243     return iBrightness; 
       
   244     }
       
   245 
       
   246 
       
   247 // -----------------------------------------------------------------------------
       
   248 // 
       
   249 // -----------------------------------------------------------------------------
       
   250 //	
       
   251 EXPORT_C void CMceCameraSource::SetExposureL( CCamera::TExposure aExposure )
       
   252     {
       
   253     
       
   254     __ASSERT_ALWAYS( ( iCameraInfo.iExposureModesSupported & aExposure ) ==
       
   255                      aExposure,
       
   256                      User::Leave( KErrNotSupported ) );
       
   257   
       
   258     iExposure = aExposure;
       
   259     
       
   260     }
       
   261         
       
   262 
       
   263 
       
   264 // -----------------------------------------------------------------------------
       
   265 // 
       
   266 // -----------------------------------------------------------------------------
       
   267 //	
       
   268 EXPORT_C CCamera::TExposure CMceCameraSource::ExposureL()
       
   269     {
       
   270     
       
   271     
       
   272     return static_cast<CCamera::TExposure>( iExposure );
       
   273     }
       
   274 
       
   275 
       
   276 // -----------------------------------------------------------------------------
       
   277 // 
       
   278 // -----------------------------------------------------------------------------
       
   279 //	
       
   280 EXPORT_C void CMceCameraSource::SetWhiteBalanceL( 
       
   281                                     CCamera::TWhiteBalance aWhiteBalance )
       
   282     {
       
   283     __ASSERT_ALWAYS( 
       
   284         ( iCameraInfo.iWhiteBalanceModesSupported & aWhiteBalance ) == 
       
   285         aWhiteBalance,
       
   286         User::Leave( KErrNotSupported ) );
       
   287    
       
   288     iWhiteBalance = aWhiteBalance;   
       
   289     
       
   290     }
       
   291 
       
   292 
       
   293 // -----------------------------------------------------------------------------
       
   294 // 
       
   295 // -----------------------------------------------------------------------------
       
   296 //	
       
   297 EXPORT_C CCamera::TWhiteBalance CMceCameraSource::WhiteBalanceL()
       
   298     {
       
   299     
       
   300     return static_cast<CCamera::TWhiteBalance>( iWhiteBalance );
       
   301     }
       
   302 
       
   303 
       
   304 // -----------------------------------------------------------------------------
       
   305 //
       
   306 // -----------------------------------------------------------------------------
       
   307 //
       
   308 void CMceCameraSource::InitializeL( CMceManager* /*aManager*/ )
       
   309     {
       
   310     }
       
   311 
       
   312 
       
   313 // -----------------------------------------------------------------------------
       
   314 // 
       
   315 // -----------------------------------------------------------------------------
       
   316 //
       
   317 CMceCameraSource::CMceCameraSource()
       
   318     :CMceMediaSource(),
       
   319     iCameraIndex( 0 ),
       
   320     iZoomFactor( 1 ),
       
   321     iDigitalZoomFactor( 0 ),
       
   322     iContrast( 0 ),
       
   323     iBrightness( 0 ),
       
   324     iExposure( CCamera::EExposureAuto ),
       
   325     iWhiteBalance( CCamera::EWBAuto )
       
   326     {
       
   327     iType = KMceCameraSource;
       
   328     iCameraInfo.iMinZoom = 1;
       
   329     iCameraInfo.iMaxZoom = 3;
       
   330     iCameraInfo.iMaxDigitalZoom = 10;
       
   331     }
       
   332 
       
   333 
       
   334 // -----------------------------------------------------------------------------
       
   335 // 
       
   336 // -----------------------------------------------------------------------------
       
   337 //
       
   338 void CMceCameraSource::ConstructL( CMceManager* /*aManager*/ )
       
   339     {
       
   340     }
       
   341