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