multimediacommsengine/tsrc/MCETestUI/src/createCameraSourceDialog.cpp
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2004 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 
       
    20 
       
    21 // INCLUDES
       
    22 #include "createCameraSourceDialog.h"
       
    23 #include "CMCETestUIEngineVideoStream.h"
       
    24 #include "CMCETestUIEngineVideoSource.h"
       
    25 #include <MCEAudioStream.h>
       
    26 #include <MCEcameraSource.h>
       
    27 #include <MCEMediaSource.h>
       
    28 #include <ecam.h>
       
    29 
       
    30 // CONSTANTS
       
    31 const TInt KMCETestUiUseDefaultCamera = 99;
       
    32 
       
    33 // ============================ MEMBER FUNCTIONS ==============================
       
    34 
       
    35 // ----------------------------------------------------------------------------
       
    36 // CCreateCameraSourceDialog::CCreateCameraSourceDialog( )
       
    37 // .
       
    38 // ----------------------------------------------------------------------------
       
    39 //
       
    40 CCreateCameraSourceDialog::CCreateCameraSourceDialog(
       
    41 						 CMCETestUIEngineVideoStream& aStream, TInt aIndex ) :
       
    42     iStream(aStream),iSourceIndex( aIndex )
       
    43     {
       
    44     
       
    45     // No implementation required
       
    46     }
       
    47 
       
    48 // ----------------------------------------------------------------------------
       
    49 // CCreateCameraSourceDialog::PreLayoutDynInitL()
       
    50 // .
       
    51 // ----------------------------------------------------------------------------
       
    52 //
       
    53 void CCreateCameraSourceDialog::PreLayoutDynInitL()
       
    54     {
       
    55     CAknForm::PreLayoutDynInitL();
       
    56     const RPointerArray<CMCETestUIEngineVideoSource>& sources = 
       
    57             iStream.SourcesL();
       
    58    
       
    59    	CMceMediaSource& mediaSource = static_cast<CMceMediaSource&>(sources[iSourceIndex]->Source());
       
    60     CMceCameraSource& camSource = static_cast<CMceCameraSource&>(mediaSource);
       
    61     	
       
    62     CEikNumberEditor* cameraIndex = static_cast<CEikNumberEditor*>(
       
    63                                   Control( ECameraSourceDialogCameraIndex ) );
       
    64     cameraIndex->SetNumber( KMCETestUiUseDefaultCamera ); // Current value cannot be retrieved from MCE API
       
    65         
       
    66     TCameraInfo camerainfo;
       
    67     camSource.GetCameraInfo( camerainfo );
       
    68     
       
    69     
       
    70     if ( camSource.ZoomFactorL() < camerainfo.iMaxZoom )
       
    71         {
       
    72         CEikNumberEditor* zoomFactor = static_cast<CEikNumberEditor*>(
       
    73                                   Control( ECameraSourceDialogCameraZoomFactor ) );
       
    74         zoomFactor->SetNumber(camSource.ZoomFactorL());
       
    75         
       
    76         //camera->SetZoomFactorL( camera->ZoomFactorL() + 1 );
       
    77         }
       
    78     else if ( camSource.DigitalZoomFactorL() < camerainfo.iMaxDigitalZoom )
       
    79         {
       
    80         CEikNumberEditor* digZoomFactor = static_cast<CEikNumberEditor*>(
       
    81                                   Control( ECameraSourceDialogCameraDigitalZoomFactor ) );
       
    82         digZoomFactor->SetNumber( camSource.DigitalZoomFactorL() );
       
    83         
       
    84         //camera->SetDigitalZoomFactorL( camera->DigitalZoomFactorL() + 1 );
       
    85         }   
       
    86 
       
    87 
       
    88     
       
    89 /*    CEikNumberEditor* maxdigital = static_cast<CEikNumberEditor*>(
       
    90                                   Control( ECameraSourceDialogZoomMax ) );
       
    91     maxdigital->SetNumber( camera.iMaxDigitalZoom );*/
       
    92     /*
       
    93     CEikNumberEditor* brightness = static_cast<CEikNumberEditor*>(
       
    94                                   Control( ECameraSourceDialogCameraBrightness ) );
       
    95     brightness->SetNumber(camSource.BrightnessL());
       
    96     
       
    97     CAknPopupFieldText* popupFieldText1 = 
       
    98         static_cast <CAknPopupFieldText*> (Control(ECameraSourceDialogExposure));
       
    99     TInt exposureState = camSource.ExposureL();
       
   100     switch(exposureState) 
       
   101     	{
       
   102     	//	case CCamera::EExposureAuto:
       
   103     		case 0:
       
   104     			{
       
   105     			popupFieldText1->SetCurrentValueIndex(0);
       
   106     			break;
       
   107     			}
       
   108     	// 	case CCamera::EExposureNight:
       
   109     		case 1:
       
   110     			{
       
   111     			popupFieldText1->SetCurrentValueIndex(1);
       
   112     			break;
       
   113     			}
       
   114     		//case CCamera::EExposureBacklight:
       
   115     		case 2:
       
   116     			{
       
   117     			popupFieldText1->SetCurrentValueIndex(2);
       
   118     			break;
       
   119     			}
       
   120     		//case CCamera::EExposureCenter:
       
   121     		case 3:
       
   122     			{
       
   123     			popupFieldText1->SetCurrentValueIndex(3);
       
   124     			break;
       
   125     			}
       
   126     		default:
       
   127     			{
       
   128     			popupFieldText1->SetCurrentValueIndex(0);
       
   129     			break;
       
   130     			}
       
   131     	}
       
   132     CAknPopupFieldText* popupFieldText2 = 
       
   133         static_cast <CAknPopupFieldText*> (Control(ECameraSourceDialogCameraWhiteBalance));
       
   134     TInt wbState = camSource.WhiteBalanceL();
       
   135     switch(wbState) 
       
   136     	{
       
   137     		//case CCamera::EWBAuto:
       
   138     		case 0:
       
   139     			{
       
   140     			popupFieldText2->SetCurrentValueIndex(0);
       
   141     			break;
       
   142     			}
       
   143     		//case CCamera::EWBDaylight:
       
   144     		case 1:
       
   145     			{
       
   146     			popupFieldText2->SetCurrentValueIndex(1);
       
   147     			break;
       
   148     			}
       
   149     		//case CCamera::EWBCloudy:
       
   150     		case 2:
       
   151     			{
       
   152     			popupFieldText2->SetCurrentValueIndex(2);
       
   153     			break;
       
   154     			}
       
   155     		//case CCamera::EWBTungsten:
       
   156     		case 3:
       
   157     			{
       
   158     			popupFieldText2->SetCurrentValueIndex(3);
       
   159     			break;
       
   160     			}
       
   161     		//case CCamera::EWBFlash:
       
   162     		case 4:
       
   163     			{
       
   164     			popupFieldText2->SetCurrentValueIndex(4);
       
   165     			break;
       
   166     			}
       
   167     		default:
       
   168     			{
       
   169     			popupFieldText2->SetCurrentValueIndex(0);
       
   170     			break;
       
   171     			}
       
   172     	}*/
       
   173     }
       
   174 
       
   175 // ----------------------------------------------------------------------------
       
   176 // CCreateCameraSourceDialog::OkToExitL( TInt )
       
   177 // .
       
   178 // ----------------------------------------------------------------------------
       
   179 //
       
   180 
       
   181 TBool CCreateCameraSourceDialog::OkToExitL( TInt aKey )
       
   182     {
       
   183     if ( aKey == EEikCmdCanceled )
       
   184         {
       
   185         // Cancel pressed. Just exit.
       
   186         return ETrue;
       
   187         }
       
   188     const RPointerArray<CMCETestUIEngineVideoSource>& sources = 
       
   189             iStream.SourcesL();
       
   190             
       
   191     if(sources[iSourceIndex]->Type() == KMceCameraSource)
       
   192     {
       
   193     	CMceMediaSource& mediaSource = static_cast<CMceMediaSource&>(sources[iSourceIndex]->Source());
       
   194     	CMceCameraSource& camSource = static_cast<CMceCameraSource&>(mediaSource);
       
   195     
       
   196 	/*    CEikNumberEditor* cameraIndex = static_cast<CEikNumberEditor*>(
       
   197 	                                  Control( ECameraSourceDialogCameraIndex ) );
       
   198 	    camSource.SetCameraIndexL(cameraIndex->Number());*/
       
   199 	    
       
   200 	    CEikNumberEditor* zoomFactor = static_cast<CEikNumberEditor*>(
       
   201 	                                  Control( ECameraSourceDialogCameraZoomFactor ) );
       
   202 	         
       
   203         TCameraInfo camerainfo;
       
   204         camSource.GetCameraInfo( camerainfo );
       
   205         
       
   206         CEikNumberEditor* digZoomFactor = static_cast<CEikNumberEditor*>(
       
   207 	                                  Control( ECameraSourceDialogCameraDigitalZoomFactor ) );
       
   208 	                                  
       
   209         if ( zoomFactor->Number() < camerainfo.iMaxZoom )
       
   210             {
       
   211             camSource.SetZoomFactorL(zoomFactor->Number());
       
   212             }
       
   213         else if ( digZoomFactor->Number() < camerainfo.iMaxDigitalZoom )
       
   214             {
       
   215             camSource.SetDigitalZoomFactorL(digZoomFactor->Number());
       
   216             }   
       
   217    
       
   218 	    CEikNumberEditor* cameraIndex = static_cast<CEikNumberEditor*>(
       
   219                                   Control( ECameraSourceDialogCameraIndex ) );  
       
   220 	    if ( camSource.CamerasAvailable() > 1 && cameraIndex->Number() != KMCETestUiUseDefaultCamera )
       
   221 	        {
       
   222 	        // Index cannot be changed if camera is in use, pause/resume
       
   223 	        //
       
   224 	        TBool enabled( camSource.IsEnabled() );
       
   225 	        if ( enabled )
       
   226 	            {
       
   227 	            camSource.DisableL();
       
   228 	            }
       
   229 	            
       
   230 	        camSource.SetCameraIndexL( cameraIndex->Number() );
       
   231 	        
       
   232 	        if( enabled )
       
   233 	            {
       
   234 	            camSource.EnableL();
       
   235 	            }
       
   236 	        }
       
   237 	        
       
   238 	/*    CEikNumberEditor* contrast = static_cast<CEikNumberEditor*>(
       
   239 	                                  Control( ECameraSourceDialogCameraContrast ) );
       
   240 	    camSource.SetContrastL(contrast->Number());
       
   241 	    
       
   242 	    CEikNumberEditor* brightness = static_cast<CEikNumberEditor*>(
       
   243 	                                  Control( ECameraSourceDialogCameraBrightness ) );
       
   244 	    camSource.SetBrightnessL(brightness->Number());
       
   245 	    
       
   246 	    CAknPopupFieldText* popupFieldText1 = 
       
   247 	        static_cast <CAknPopupFieldText*> (Control(ECameraSourceDialogExposure));
       
   248 	     switch(popupFieldText1->CurrentValueIndex())	
       
   249 	     	{
       
   250 	     		case 0:
       
   251 	     			{
       
   252 	     		//	camSource.SetExposureL(CCamera::EExposureAuto);
       
   253 	     				camSource.SetExposureL(0);
       
   254 	     			break;
       
   255 	     			}
       
   256 	     		case 1:
       
   257 	     			{
       
   258 	     			//camSource.SetExposureL(CCamera::EExposureNight);
       
   259 	     				camSource.SetExposureL(1);
       
   260 	     			break;
       
   261 	     			}
       
   262 	     		case 2:
       
   263 	     			{
       
   264 	     			//camSource.SetExposureL(CCamera::EExposureBacklight);
       
   265 	     			camSource.SetExposureL(2);
       
   266 	     			break;
       
   267 	     			}
       
   268 	     		case 3:
       
   269 	     			{
       
   270 	     			//camSource.SetExposureL(CCamera::EExposureCenter);
       
   271 	     			camSource.SetExposureL(3);
       
   272 	     			break;
       
   273 	     			}
       
   274 	     		default:
       
   275 	     			{
       
   276 	     			//camSource.SetExposureL(CCamera::EExposureAuto);
       
   277 	     			camSource.SetExposureL(0);
       
   278 	     			break;
       
   279 	     			}
       
   280 	     	}
       
   281 	    CAknPopupFieldText* popupFieldText2 = 
       
   282 	        static_cast <CAknPopupFieldText*> (Control(ECameraSourceDialogCameraWhiteBalance));
       
   283 	      switch(popupFieldText2->CurrentValueIndex())	
       
   284 	     	{
       
   285 	     		case 0:
       
   286 	     			{
       
   287 		//			camSource.SetWhiteBalanceL(CCamera::EWBAuto);
       
   288 					camSource.SetWhiteBalanceL(0);
       
   289 	     			break;
       
   290 	     			}
       
   291 	     		case 1:
       
   292 	     			{
       
   293 	     			//camSource.SetWhiteBalanceL(CCamera::EWBDaylight);
       
   294 	     			camSource.SetWhiteBalanceL(1);
       
   295 	     			break;
       
   296 	     			}
       
   297 	     		case 2:
       
   298 	     			{
       
   299 	     			//camSource.SetWhiteBalanceL(CCamera::EWBCloudy);
       
   300 	     			camSource.SetWhiteBalanceL(2);
       
   301 	     			break;
       
   302 	     			}
       
   303 	     		case 3:
       
   304 	     			{
       
   305 	     			//camSource.SetWhiteBalanceL(CCamera::EWBTungsten);
       
   306 	     			camSource.SetWhiteBalanceL(3);
       
   307 	     			break;
       
   308 	     			}
       
   309 	     		case 4:
       
   310 	     			{
       
   311 	     			camSource.SetWhiteBalanceL(4);
       
   312 	     			//camSource.SetWhiteBalanceL(CCamera::EWBFlash);
       
   313 	     			break;
       
   314 	     			}
       
   315 	     		default:
       
   316 	     			{
       
   317 	     			camSource.SetWhiteBalanceL(0);
       
   318 	     			//camSource.SetWhiteBalanceL(CCamera::EWBAuto);
       
   319 	     			break;
       
   320 	     			}
       
   321 	     	}*/
       
   322       }
       
   323     
       
   324         
       
   325     return ETrue;
       
   326     }
       
   327 
       
   328 // ----------------------------------------------------------------------------
       
   329 // CCreateCameraSourceDialog::~CCreateCameraSourceDialog)
       
   330 // .
       
   331 // ----------------------------------------------------------------------------
       
   332 //
       
   333 CCreateCameraSourceDialog::~CCreateCameraSourceDialog()
       
   334     {
       
   335     return;
       
   336     } 
       
   337 
       
   338 // End of File