camerauis/cameraxui/cxui/tsrc/cxuifakestillcapturecontrol.cpp
branchRCL_3
changeset 24 bac7acad7cb3
parent 23 61bc0f252b2b
child 25 2c87b2808fd7
equal deleted inserted replaced
23:61bc0f252b2b 24:bac7acad7cb3
     1 /*
       
     2 * Copyright (c) 2009 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 #include <QImage>
       
    18 #include <QObject>
       
    19 #include <fbs.h>
       
    20 #include "cxestillcapturecontrolsymbian.h"
       
    21 #include "cxecameradevicecontrol.h" // CxeCameraDevice
       
    22 #include "cxeimagedataqueuesymbian.h"
       
    23 #include "cxefilenamegeneratorsymbian.h"
       
    24 #include "cxutils.h"
       
    25 #include "cxuifakestillcapturecontrol.h"
       
    26 #include "cxesoundplayersymbian.h"
       
    27 #include "cxestillimagesymbian.h"
       
    28 #include "cxeviewfindercontrol.h"
       
    29 #include "cxesettingsmappersymbian.h"
       
    30 
       
    31 
       
    32 CxuiFakeStillCaptureControl::CxuiFakeStillCaptureControl(
       
    33     CxeCameraDevice &cameraDevice,
       
    34     CxeViewfinderControl &viewfinderControl,
       
    35     CxeCameraDeviceControl &cameraDeviceControl, CxeSoundPlayerSymbian &soundPlayer,
       
    36     CxeFilenameGenerator &nameGenerator)
       
    37     : CxeStillCaptureControlSymbian(cameraDevice,viewfinderControl, cameraDeviceControl, soundPlayer,nameGenerator),
       
    38       iCameraSnapshot(NULL),
       
    39       mCameraDevice(cameraDevice),
       
    40       mViewfinderControl(viewfinderControl),
       
    41       mCameraDeviceControl(cameraDeviceControl),
       
    42       mSoundPlayer(soundPlayer),
       
    43       mFilenameGenerator(nameGenerator)
       
    44 {
       
    45     CX_DEBUG_IN_FUNCTION();
       
    46 }
       
    47 
       
    48 
       
    49 CxuiFakeStillCaptureControl::~CxuiFakeStillCaptureControl()
       
    50 {
       
    51     CX_DEBUG_ENTER_FUNCTION();
       
    52 
       
    53     delete mImageDataQueue;
       
    54     delete iCameraSnapshot;
       
    55 
       
    56     qDeleteAll(mImages);
       
    57 
       
    58     CX_DEBUG_EXIT_FUNCTION();
       
    59 }
       
    60 
       
    61 void CxuiFakeStillCaptureControl::init()
       
    62 {
       
    63     CX_DEBUG_ENTER_FUNCTION();
       
    64 
       
    65     if (state() == Uninitialized) {
       
    66         prepare();
       
    67     }
       
    68 
       
    69     CX_DEBUG_EXIT_FUNCTION();
       
    70 }
       
    71 
       
    72 void CxuiFakeStillCaptureControl::deinit()
       
    73 {
       
    74     CX_DEBUG_ENTER_FUNCTION();
       
    75     setState( Uninitialized );
       
    76     CX_DEBUG_EXIT_FUNCTION();
       
    77 }
       
    78 
       
    79 int CxuiFakeStillCaptureControl::prepare()
       
    80 {
       
    81     CX_DEBUG_ENTER_FUNCTION();
       
    82 
       
    83     CX_DEBUG_ASSERT(mCameraDevice.camera());
       
    84 
       
    85     int err = KErrNone;
       
    86     int cameraIndex = mCameraDeviceControl.cameraIndex();
       
    87 
       
    88     TSize snapSize(480, 360);
       
    89     CCamera::TFormat imgFormat = CCamera::EFormatExif;
       
    90     CCamera::TFormat snapFormat = CCamera::EFormatFbsBitmapColor16MU;
       
    91 
       
    92     if ( cameraIndex == Cxe::SecondaryCameraIndex ) {
       
    93         CX_DEBUG(("Preparing secondary camera"));
       
    94         imgFormat = CCamera::EFormatFbsBitmapColor16M;
       
    95         snapSize.SetSize(320, 240);
       
    96     }
       
    97 
       
    98     setState(Ready);
       
    99 
       
   100     // Inform interested parties that image mode has been prepared for capture
       
   101     emit imagePrepareComplete(err);
       
   102 
       
   103     CX_DEBUG_EXIT_FUNCTION();
       
   104     return err;
       
   105 }
       
   106 
       
   107 void CxuiFakeStillCaptureControl::capture()
       
   108 {
       
   109     CX_DEBUG_ENTER_FUNCTION();
       
   110 
       
   111     emit snapshotReady(0);
       
   112 
       
   113     CX_DEBUG_EXIT_FUNCTION();
       
   114 }
       
   115 
       
   116 /*
       
   117 * Image Scene mode changed, needs updated
       
   118 */
       
   119 void CxuiFakeStillCaptureControl::handleSceneChanged(CxeScene* scene)
       
   120 {
       
   121     CX_DEBUG_IN_FUNCTION();
       
   122 }
       
   123 
       
   124 
       
   125 /*
       
   126 * Ecam reference changing, release resources
       
   127 */
       
   128 
       
   129 void CxuiFakeStillCaptureControl::prepareForCameraDelete()
       
   130 {
       
   131     CX_DEBUG_ENTER_FUNCTION();
       
   132 
       
   133     delete iCameraSnapshot;
       
   134     iCameraSnapshot = NULL;
       
   135 
       
   136     setState(Uninitialized);
       
   137 
       
   138     CX_DEBUG_EXIT_FUNCTION();
       
   139 }
       
   140 
       
   141 void CxuiFakeStillCaptureControl::prepareForRelease()
       
   142 {
       
   143     CX_DEBUG_ENTER_FUNCTION();
       
   144 
       
   145     if (state() == Capturing) {
       
   146         mCameraDevice.camera()->CancelCaptureImage();
       
   147     }
       
   148 
       
   149     setState(Uninitialized);
       
   150 
       
   151     CX_DEBUG_EXIT_FUNCTION();
       
   152 }
       
   153 
       
   154 /*
       
   155 * new camera available,
       
   156 */
       
   157 
       
   158 void CxuiFakeStillCaptureControl::handleCameraAllocated(CxeError::Id error)
       
   159 {
       
   160     CX_DEBUG_ENTER_FUNCTION();
       
   161 
       
   162     setState(CxeStillCaptureControl::Uninitialized);
       
   163 
       
   164     CX_DEBUG_EXIT_FUNCTION();
       
   165 }
       
   166 
       
   167 void CxuiFakeStillCaptureControl::setFakeState(CxeStillCaptureControl::State aState)
       
   168 {
       
   169     CX_DEBUG_ENTER_FUNCTION();
       
   170     setState(aState);
       
   171     CX_DEBUG_EXIT_FUNCTION();
       
   172 }
       
   173 
       
   174 // end of file