camerauis/cameraxui/cxengine/src/cxeenginesymbian.cpp
changeset 37 64817133cd1d
parent 36 b12f3922a74f
child 48 42ba2d16bf40
equal deleted inserted replaced
36:b12f3922a74f 37:64817133cd1d
     1 /*
     1 /*
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    37 #include "cxesensoreventhandlersymbian.h"
    37 #include "cxesensoreventhandlersymbian.h"
    38 #include "cxefilesavethread.h"
    38 #include "cxefilesavethread.h"
    39 #include "cxecameradevice.h"
    39 #include "cxecameradevice.h"
    40 #include "cxememorymonitor.h"
    40 #include "cxememorymonitor.h"
    41 #include "cxediskmonitor.h"
    41 #include "cxediskmonitor.h"
       
    42 #include "cxegeotaggingtrail.h"
    42 
    43 
    43 #include "OstTraceDefinitions.h"
    44 #include "OstTraceDefinitions.h"
    44 #ifdef OST_TRACE_COMPILER_IN_USE
    45 #ifdef OST_TRACE_COMPILER_IN_USE
    45 #include "cxeenginesymbianTraces.h"
    46 #include "cxeenginesymbianTraces.h"
    46 #endif
    47 #endif
    64       mFilenameGenerator(NULL),
    65       mFilenameGenerator(NULL),
    65       mSensorEventHandler(NULL),
    66       mSensorEventHandler(NULL),
    66       mQualityPresets(NULL),
    67       mQualityPresets(NULL),
    67       mFileSaveThread(NULL),
    68       mFileSaveThread(NULL),
    68       mDiskMonitor(NULL),
    69       mDiskMonitor(NULL),
    69       mMemoryMonitor(NULL)
    70       mMemoryMonitor(NULL),
       
    71       mGeoTaggingTrail(NULL)
    70 {
    72 {
    71     CX_DEBUG_IN_FUNCTION();
    73     CX_DEBUG_IN_FUNCTION();
    72 }
    74 }
    73 
    75 
    74 
    76 
   118         // assert if settings model fails to intialize
   120         // assert if settings model fails to intialize
   119         CX_DEBUG_ASSERT(mSettingsModel);
   121         CX_DEBUG_ASSERT(mSettingsModel);
   120 
   122 
   121         mSettings = new CxeSettingsImp(*mSettingsModel);
   123         mSettings = new CxeSettingsImp(*mSettingsModel);
   122 
   124 
       
   125         // Loading current camera mode value from settings store and updating 
       
   126 		// devicecontrol        
       
   127         Cxe::CameraMode cameraMode = Cxe::ImageMode;
       
   128         int value;
       
   129         CxeError::Id err = mSettings->get(CxeSettingIds::CAMERA_MODE, value);
       
   130         if (!err) {
       
   131             cameraMode = static_cast<Cxe::CameraMode>(value);
       
   132         }
       
   133         // set current camera mode to devicecontrol.
       
   134         mCameraDeviceControl->setMode(cameraMode);
       
   135         
   123         //! @todo a temporary hack to change the startup sequence to avoid GOOM problems
   136         //! @todo a temporary hack to change the startup sequence to avoid GOOM problems
   124         static_cast<CxeSettingsImp*>(mSettings)->loadSettings(mode());
   137         static_cast<CxeSettingsImp*>(mSettings)->loadSettings(mode());
   125 
   138 
   126 
   139 
   127         // Connect P&S key updates to settings signal.
   140         // Connect P&S key updates to settings signal.
   166         mVideoCaptureControl = new CxeVideoCaptureControlSymbian(
   179         mVideoCaptureControl = new CxeVideoCaptureControlSymbian(
   167             *mCameraDevice, *mViewfinderControl, *mSnapshotControl, *mCameraDeviceControl,
   180             *mCameraDevice, *mViewfinderControl, *mSnapshotControl, *mCameraDeviceControl,
   168             *mFilenameGenerator, *mSettings, *mQualityPresets, *mDiskMonitor);
   181             *mFilenameGenerator, *mSettings, *mQualityPresets, *mDiskMonitor);
   169 
   182 
   170         mSettingsControl = new CxeSettingsControlSymbian(*mCameraDevice, *mSettings);
   183         mSettingsControl = new CxeSettingsControlSymbian(*mCameraDevice, *mSettings);
       
   184 
       
   185         mGeoTaggingTrail = new CxeGeoTaggingTrail(*mStillCaptureControl,
       
   186                                                   *mVideoCaptureControl,
       
   187                                                   *mSettings);
   171 
   188 
   172         OstTrace0(camerax_performance, CXEENGINESYMBIAN_CREATECONTROLS_OUT, "e_CX_ENGINE_CREATE_CONTROLS 0");
   189         OstTrace0(camerax_performance, CXEENGINESYMBIAN_CREATECONTROLS_OUT, "e_CX_ENGINE_CREATE_CONTROLS 0");
   173     }
   190     }
   174 
   191 
   175     CX_DEBUG_EXIT_FUNCTION();
   192     CX_DEBUG_EXIT_FUNCTION();
   241             SLOT(prepareZoomForVideo()));
   258             SLOT(prepareZoomForVideo()));
   242 
   259 
   243     // Connect file saving thread to snapshot signals and video saved signal.
   260     // Connect file saving thread to snapshot signals and video saved signal.
   244     // Image saving it handles internally.
   261     // Image saving it handles internally.
   245     connect(mStillCaptureControl,
   262     connect(mStillCaptureControl,
   246             SIGNAL(snapshotReady(CxeError::Id, const QPixmap&, int)),
   263             SIGNAL(snapshotReady(CxeError::Id, const QImage&, int)),
   247             mFileSaveThread,
   264             mFileSaveThread,
   248             SLOT(handleSnapshotReady(CxeError::Id, const QPixmap&, int)));
   265             SLOT(handleSnapshotReady(CxeError::Id, const QImage&, int)));
   249     connect(mVideoCaptureControl,
   266     connect(mVideoCaptureControl,
   250             SIGNAL(videoComposed(CxeError::Id, const QString&)),
   267             SIGNAL(videoComposed(CxeError::Id, const QString&)),
   251             mFileSaveThread,
   268             mFileSaveThread,
   252             SLOT(handleVideoSaved(CxeError::Id, const QString&)));
   269             SLOT(handleVideoSaved(CxeError::Id, const QString&)));
   253     connect(mVideoCaptureControl,
   270     connect(mVideoCaptureControl,
   254             SIGNAL(snapshotReady(CxeError::Id, const QPixmap&, const QString&)),
   271             SIGNAL(snapshotReady(CxeError::Id, const QImage&, const QString&)),
   255             mFileSaveThread,
   272             mFileSaveThread,
   256             SLOT(handleSnapshotReady(CxeError::Id, const QPixmap&, const QString&)));
   273             SLOT(handleSnapshotReady(CxeError::Id, const QImage&, const QString&)));
       
   274 
       
   275 
       
   276     // stop location trail when releasing camera.
       
   277     connect(mCameraDevice,
       
   278             SIGNAL(prepareForRelease()),
       
   279             mGeoTaggingTrail,
       
   280             SLOT(stop()),
       
   281             Qt::UniqueConnection);
   257 
   282 
   258     OstTrace0(camerax_performance, CXEENGINESYMBIAN_CONNECTSIGNALS_OUT, "e_CX_ENGINE_CONNECT_SIGNALS 0");
   283     OstTrace0(camerax_performance, CXEENGINESYMBIAN_CONNECTSIGNALS_OUT, "e_CX_ENGINE_CONNECT_SIGNALS 0");
   259 
   284 
   260     CX_DEBUG_EXIT_FUNCTION();
   285     CX_DEBUG_EXIT_FUNCTION();
   261 }
   286 }
   262 
   287 
   263 CxeEngineSymbian::~CxeEngineSymbian()
   288 CxeEngineSymbian::~CxeEngineSymbian()
   264 {
   289 {
   265     CX_DEBUG_ENTER_FUNCTION();
   290     CX_DEBUG_ENTER_FUNCTION();
   266 
   291     
       
   292     // Saving current camera mode to cenrep
       
   293     saveMode();
       
   294     
       
   295     delete mGeoTaggingTrail;
   267     delete mAutoFocusControl;
   296     delete mAutoFocusControl;
   268     delete mZoomControl;
   297     delete mZoomControl;
   269     delete mSettingsControl;
   298     delete mSettingsControl;
   270     delete mStillCaptureControl;
   299     delete mStillCaptureControl;
   271     delete mVideoCaptureControl;
   300     delete mVideoCaptureControl;
   317 CxeZoomControl &CxeEngineSymbian::zoomControl()
   346 CxeZoomControl &CxeEngineSymbian::zoomControl()
   318 {
   347 {
   319     return *mZoomControl;
   348     return *mZoomControl;
   320 }
   349 }
   321 
   350 
   322 // Get the settings handle
   351 /*!
       
   352 Returns the settings handle
       
   353 */
   323 CxeSettings &CxeEngineSymbian::settings()
   354 CxeSettings &CxeEngineSymbian::settings()
   324 {
   355 {
   325     return *mSettings;
   356     return *mSettings;
   326 }
   357 }
   327 
   358 
   328 // Get the sensor event  handle
   359 /*! 
       
   360 Returns the sensor event  handle
       
   361 */
   329 CxeSensorEventHandler &CxeEngineSymbian::sensorEventHandler()
   362 CxeSensorEventHandler &CxeEngineSymbian::sensorEventHandler()
   330 {
   363 {
   331     return *mSensorEventHandler;
   364     return *mSensorEventHandler;
   332 }
   365 }
   333 
   366 
   336 {
   369 {
   337     return *mFeatureManager;
   370     return *mFeatureManager;
   338 }
   371 }
   339 
   372 
   340 /*!
   373 /*!
   341 * Get memory monitor utility handle.
   374 * Returns memory monitor utility handle.
   342 */
   375 */
   343 CxeMemoryMonitor &CxeEngineSymbian::memoryMonitor()
   376 CxeMemoryMonitor &CxeEngineSymbian::memoryMonitor()
   344 {
   377 {
   345     return *mMemoryMonitor;
   378     return *mMemoryMonitor;
   346 }
   379 }
   347 
   380 
   348 /*
   381 
       
   382 /*!
       
   383  Returns geotaggingtrail handle
       
   384  */
       
   385 CxeGeoTaggingTrail &CxeEngineSymbian::geoTaggingTrail()
       
   386 {
       
   387     return *mGeoTaggingTrail;
       
   388 }
       
   389 
       
   390 /*!
   349 * Returns true, if the engine is ready or else false.
   391 * Returns true, if the engine is ready or else false.
   350 */
   392 */
   351 bool CxeEngineSymbian::isEngineReady()
   393 bool CxeEngineSymbian::isEngineReady()
   352 {
   394 {
   353     bool ready = false;
   395     bool ready = false;
   380     CxeSettingsImp *settingsImp = qobject_cast<CxeSettingsImp*>(mSettings);
   422     CxeSettingsImp *settingsImp = qobject_cast<CxeSettingsImp*>(mSettings);
   381     if (settingsImp) {
   423     if (settingsImp) {
   382         settingsImp->loadSettings(mode());
   424         settingsImp->loadSettings(mode());
   383     }
   425     }
   384 
   426 
   385 
       
   386     if (mode() == Cxe::ImageMode) {
   427     if (mode() == Cxe::ImageMode) {
       
   428         // start geotagging trail in image mode.
       
   429         startGeotaggingTrail();
   387         mVideoCaptureControl->deinit();
   430         mVideoCaptureControl->deinit();
   388         mStillCaptureControl->init();
   431         mStillCaptureControl->init();
   389     } else if (mode() == Cxe::VideoMode) {
   432     } else if (mode() == Cxe::VideoMode) {
   390         mStillCaptureControl->deinit();
   433         mStillCaptureControl->deinit();
       
   434         if (mGeoTaggingTrail) {
       
   435             // in video mode, Geotagging is not supported for now.
       
   436             mGeoTaggingTrail->stop();
       
   437         }
   391         mVideoCaptureControl->init();
   438         mVideoCaptureControl->init();
   392     }
   439     }
   393 
   440 
   394     OstTrace0(camerax_performance, CXEENGINESYMBIAN_DOINIT_OUT, "e_CX_ENGINE_DO_INIT 0");
   441     OstTrace0(camerax_performance, CXEENGINESYMBIAN_DOINIT_OUT, "e_CX_ENGINE_DO_INIT 0");
   395 
   442 
   396     CX_DEBUG_EXIT_FUNCTION();
   443     CX_DEBUG_EXIT_FUNCTION();
   397 }
   444 }
   398 
   445 
       
   446 /*!
       
   447  * Returns camera mode.
       
   448  */
   399 Cxe::CameraMode CxeEngineSymbian::mode() const
   449 Cxe::CameraMode CxeEngineSymbian::mode() const
   400 {
   450 {
   401     return mCameraDeviceControl->mode();
   451     return mCameraDeviceControl->mode();
   402 }
   452 }
   403 
   453 
       
   454 /*!
       
   455  * Sets the camera mode.
       
   456  * \parama mode New camera mode
       
   457  */
       
   458 void CxeEngineSymbian::setMode(Cxe::CameraMode mode)
       
   459 {
       
   460     CX_DEBUG_ENTER_FUNCTION();
       
   461     mCameraDeviceControl->setMode(mode);
       
   462     CX_DEBUG_EXIT_FUNCTION();
       
   463 }
   404 /*!
   464 /*!
   405     Check if we need to reserve camera.
   465     Check if we need to reserve camera.
   406 */
   466 */
   407 bool CxeEngineSymbian::reserveNeeded()
   467 bool CxeEngineSymbian::reserveNeeded()
   408 {
   468 {
   526     mCameraDeviceControl->reserve();
   586     mCameraDeviceControl->reserve();
   527     emit reserveStarted();
   587     emit reserveStarted();
   528     CX_DEBUG_EXIT_FUNCTION();
   588     CX_DEBUG_EXIT_FUNCTION();
   529 }
   589 }
   530 
   590 
       
   591 
       
   592 /*!
       
   593 * Saves current mode to the cenrep
       
   594 */
       
   595 void CxeEngineSymbian::saveMode()
       
   596 {
       
   597     CX_DEBUG_ENTER_FUNCTION();
       
   598 
       
   599     if (mCameraDeviceControl && mSettings) {
       
   600         int value = mCameraDeviceControl->mode();
       
   601         mSettings->set(CxeSettingIds::CAMERA_MODE, value);
       
   602     }
       
   603 
       
   604     CX_DEBUG_EXIT_FUNCTION();
       
   605 }
       
   606 
       
   607 
       
   608 /*!
       
   609 * Start geotagging trail.
       
   610 */
       
   611 void CxeEngineSymbian::startGeotaggingTrail()
       
   612 {
       
   613     CX_DEBUG_ENTER_FUNCTION();
       
   614     
       
   615     if (mGeoTaggingTrail && mSettings) {
       
   616         // location trail is limited to image mode only for now.
       
   617         int value = Cxe::GeoTaggingDisclaimerDisabled;
       
   618         mSettings->get(CxeSettingIds::GEOTAGGING_DISCLAIMER, value);
       
   619 
       
   620         // we start location trail only when Geotagging First-time-use note is accepted by user.
       
   621         if (value == Cxe::GeoTaggingDisclaimerDisabled) {
       
   622             mGeoTaggingTrail->start();
       
   623         }
       
   624     }
       
   625     
       
   626     CX_DEBUG_EXIT_FUNCTION();
       
   627 }
       
   628 
   531 // End of file
   629 // End of file