camerauis/cameraxui/cxengine/src/cxeenginesymbian.cpp
changeset 21 fa6d9f75d6a6
parent 19 d9aefe59d544
child 24 2094593137f5
equal deleted inserted replaced
19:d9aefe59d544 21:fa6d9f75d6a6
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:
    14 * Description:
    15 *
    15 *
    16 */
    16 */
       
    17 
       
    18 #include <xqserviceutil.h>
       
    19 
    17 #include "cxeenginesymbian.h"
    20 #include "cxeenginesymbian.h"
    18 #include "cxecameradevicecontrolsymbian.h"
    21 #include "cxecameradevicecontrolsymbian.h"
    19 #include "cxestillcapturecontrolsymbian.h"
    22 #include "cxestillcapturecontrolsymbian.h"
    20 #include "cxevideocapturecontrolsymbian.h"
    23 #include "cxevideocapturecontrolsymbian.h"
    21 #include "cxesettingscontrolsymbian.h"
    24 #include "cxesettingscontrolsymbian.h"
    31 #include "cxesettingscenrepstore.h"
    34 #include "cxesettingscenrepstore.h"
    32 #include "cxesoundplayersymbian.h"
    35 #include "cxesoundplayersymbian.h"
    33 #include "cxesensoreventhandlersymbian.h"
    36 #include "cxesensoreventhandlersymbian.h"
    34 #include "cxefilesavethread.h"
    37 #include "cxefilesavethread.h"
    35 #include "cxecameradevice.h"
    38 #include "cxecameradevice.h"
       
    39 #include "cxememorymonitor.h"
       
    40 #include "cxediskmonitor.h"
    36 
    41 
    37 #include "OstTraceDefinitions.h"
    42 #include "OstTraceDefinitions.h"
    38 #ifdef OST_TRACE_COMPILER_IN_USE
    43 #ifdef OST_TRACE_COMPILER_IN_USE
    39 #include "cxeenginesymbianTraces.h"
    44 #include "cxeenginesymbianTraces.h"
    40 #endif
    45 #endif
    41 #include <xqserviceutil.h>
    46 
    42 
    47 
    43 //  Member Functions
    48 //  Member Functions
    44 
    49 
    45 CxeEngineSymbian::CxeEngineSymbian()
    50 CxeEngineSymbian::CxeEngineSymbian()
    46     : mCameraDeviceControl(NULL),
    51     : mCameraDeviceControl(NULL),
       
    52       mCameraDevice(NULL),
    47       mViewfinderControl(NULL),
    53       mViewfinderControl(NULL),
    48       mStillCaptureControl(NULL),
    54       mStillCaptureControl(NULL),
    49       mVideoCaptureControl(NULL),
    55       mVideoCaptureControl(NULL),
    50       mSettingsControl(NULL),
    56       mSettingsControl(NULL),
    51       mAutoFocusControl(NULL),
    57       mAutoFocusControl(NULL),
    56       mFilenameGenerator(NULL),
    62       mFilenameGenerator(NULL),
    57       mSensorEventHandler(NULL),
    63       mSensorEventHandler(NULL),
    58       mQualityPresets(NULL),
    64       mQualityPresets(NULL),
    59       mFileSaveThread(NULL)
    65       mFileSaveThread(NULL)
    60 {
    66 {
    61     CX_DEBUG_IN_FUNCTION();
    67     CX_DEBUG_ENTER_FUNCTION();
       
    68 
       
    69     // Do secondary construction during reserve call.
       
    70     connect(this, SIGNAL(reserveStarted()), this, SLOT(construct()));
       
    71 
       
    72     CxeCameraDeviceControlSymbian *deviceControl = new CxeCameraDeviceControlSymbian();
       
    73     mCameraDeviceControl = deviceControl;
       
    74     mCameraDevice = deviceControl->cameraDevice();
       
    75     CX_ASSERT_ALWAYS(mCameraDeviceControl);
       
    76     CX_ASSERT_ALWAYS(mCameraDevice);
       
    77 
       
    78     mCameraDeviceControl->init();
       
    79 
       
    80     CX_DEBUG_EXIT_FUNCTION();
    62 }
    81 }
    63 
    82 
    64 
    83 
    65 /*!
    84 /*!
    66     Create all control classes and connect relevant signals
    85     Create all control classes and connect relevant signals
    75     CX_DEBUG_EXIT_FUNCTION();
    94     CX_DEBUG_EXIT_FUNCTION();
    76 }
    95 }
    77 
    96 
    78 
    97 
    79 /*!
    98 /*!
    80     Create all control classes
    99     Create all control classes.
       
   100     Note: Throws an error, if free memory request by CxeMemoryMonitor constructor fails!
    81 */
   101 */
    82 void CxeEngineSymbian::createControls()
   102 void CxeEngineSymbian::createControls()
    83 {
   103 {
    84     CX_DEBUG_ENTER_FUNCTION();
   104     CX_DEBUG_ENTER_FUNCTION();
    85 
   105 
    86     if (!mVideoCaptureControl) {
   106     // Check we do this only once.
    87         CxeCameraDeviceControlSymbian *deviceControl =
   107     if (!mSettingsModel) {
    88                 new CxeCameraDeviceControlSymbian();
   108         OstTrace0(camerax_performance, CXEENGINESYMBIAN_CREATECONTROLS_IN, "e_CX_ENGINE_CREATE_CONTROLS 1");
    89 
   109 
    90         mCameraDeviceControl = deviceControl;
   110         CxeSettingsCenRepStore *settingsStore(NULL);
    91         CxeCameraDevice *cameraDevice = deviceControl->cameraDevice();
       
    92 
       
    93         CxeSettingsCenRepStore *settingsStore;
       
    94 
       
    95         if (XQServiceUtil::isService()) {
   111         if (XQServiceUtil::isService()) {
    96             settingsStore = new CxeSettingsLocalStore();
   112             settingsStore = new CxeSettingsLocalStore();
    97         } else {
   113         } else {
    98             settingsStore = new CxeSettingsCenRepStore();
   114             settingsStore = new CxeSettingsCenRepStore();
    99         }
   115         }
   100 
       
   101         //ownership of settings store transferred to the settings model.
   116         //ownership of settings store transferred to the settings model.
   102         mSettingsModel = new CxeSettingsModelImp(
   117         mSettingsModel = new CxeSettingsModelImp(settingsStore);
   103                 settingsStore);
       
   104 
       
   105         // assert if settings model fails to intialize
   118         // assert if settings model fails to intialize
   106         CX_DEBUG_ASSERT(mSettingsModel);
   119         CX_DEBUG_ASSERT(mSettingsModel);
       
   120 
   107         mSettings = new CxeSettingsImp(*mSettingsModel);
   121         mSettings = new CxeSettingsImp(*mSettingsModel);
   108 
   122         // Connect P&S key updates to settings signal.
   109         connect(settingsStore, SIGNAL(settingValueChanged(long int, unsigned long int, QVariant)),
   123         connect(settingsStore, SIGNAL(settingValueChanged(long int, unsigned long int, QVariant)),
   110                 mSettings, SIGNAL(settingValueChanged(long int, unsigned long int, QVariant)));
   124                 mSettings, SIGNAL(settingValueChanged(long int, unsigned long int, QVariant)));
   111 
   125 
       
   126         mFeatureManager = new CxeFeatureManagerImp(*mSettingsModel);
       
   127 
       
   128         // Memory monitor needed as early as possible to request free memory.
       
   129         // Note: Throws error if enough memory cannot be freed!
       
   130         mMemoryMonitor = new CxeMemoryMonitor(*mFeatureManager);
       
   131 
       
   132         mDiskMonitor = new CxeDiskMonitor(*mSettings);
       
   133 
   112         mQualityPresets = new CxeQualityPresetsSymbian(*mSettings);
   134         mQualityPresets = new CxeQualityPresetsSymbian(*mSettings);
   113         CX_DEBUG_ASSERT(mQualityPresets);
   135         CX_DEBUG_ASSERT(mQualityPresets);
   114 
   136 
   115         mFeatureManager = new CxeFeatureManagerImp(*mSettingsModel);
       
   116 
       
   117         // sensor event handler initialization
   137         // sensor event handler initialization
   118         mSensorEventHandler = new CxeSensorEventHandlerSymbian();
   138         mSensorEventHandler = new CxeSensorEventHandlerSymbian();
   119 
   139 
   120         mFilenameGenerator = new CxeFilenameGeneratorSymbian(*mSettings,
   140         mFilenameGenerator = new CxeFilenameGeneratorSymbian(*mSettings,
   121             mode());
   141             mode());
   122 
   142 
   123         mViewfinderControl = new CxeViewfinderControlSymbian(*cameraDevice,
   143         mViewfinderControl = new CxeViewfinderControlSymbian(*mCameraDevice,
   124             *deviceControl);
   144             *mCameraDeviceControl);
   125 
   145 
   126         mAutoFocusControl = new CxeAutoFocusControlSymbian(*cameraDevice);
   146         mAutoFocusControl = new CxeAutoFocusControlSymbian(*mCameraDevice);
   127 
   147 
   128         mFileSaveThread = CxeFileSaveThreadFactory::createFileSaveThread();
   148         mFileSaveThread = CxeFileSaveThreadFactory::createFileSaveThread();
   129 
   149 
   130         mStillCaptureControl = new CxeStillCaptureControlSymbian(
   150         mStillCaptureControl = new CxeStillCaptureControlSymbian(
   131             *cameraDevice, *mViewfinderControl, *deviceControl,
   151             *mCameraDevice, *mViewfinderControl, *mCameraDeviceControl,
   132             *mFilenameGenerator, *mSensorEventHandler, *mAutoFocusControl,
   152             *mFilenameGenerator, *mSensorEventHandler, *mAutoFocusControl,
   133             *mSettings, *mQualityPresets, *mFileSaveThread);
   153             *mSettings, *mQualityPresets, *mFileSaveThread, *mDiskMonitor);
   134 
   154 
   135         mZoomControl = new CxeZoomControlSymbian( *cameraDevice,
   155         mZoomControl = new CxeZoomControlSymbian( *mCameraDevice,
   136             *deviceControl, *mSettings, *mFeatureManager);
   156             *mCameraDeviceControl, *mSettings, *mFeatureManager);
   137 
   157 
   138         mVideoCaptureControl = new CxeVideoCaptureControlSymbian(
   158         mVideoCaptureControl = new CxeVideoCaptureControlSymbian(
   139             *cameraDevice, *mViewfinderControl, *deviceControl,
   159             *mCameraDevice, *mViewfinderControl, *mCameraDeviceControl,
   140             *mFilenameGenerator, *mSettings, *mQualityPresets);
   160             *mFilenameGenerator, *mSettings, *mQualityPresets, *mDiskMonitor);
   141 
   161 
   142         mSettingsControl = new CxeSettingsControlSymbian(*cameraDevice, *mSettings);
   162         mSettingsControl = new CxeSettingsControlSymbian(*mCameraDevice, *mSettings);
       
   163 
       
   164         OstTrace0(camerax_performance, CXEENGINESYMBIAN_CREATECONTROLS_OUT, "e_CX_ENGINE_CREATE_CONTROLS 0");
   143     }
   165     }
   144 
   166 
   145     CX_DEBUG_EXIT_FUNCTION();
   167     CX_DEBUG_EXIT_FUNCTION();
   146 }
   168 }
   147 
   169 
   149     Connect internal signals for control classes
   171     Connect internal signals for control classes
   150 */
   172 */
   151 void CxeEngineSymbian::connectSignals()
   173 void CxeEngineSymbian::connectSignals()
   152 {
   174 {
   153     CX_DEBUG_ENTER_FUNCTION();
   175     CX_DEBUG_ENTER_FUNCTION();
       
   176     OstTrace0(camerax_performance, CXEENGINESYMBIAN_CONNECTSIGNALS_IN, "e_CX_ENGINE_CONNECT_SIGNALS 1");
   154 
   177 
   155     // enabling scene setting change callbacks to Autofocus control
   178     // enabling scene setting change callbacks to Autofocus control
   156     connect(mSettings,
   179     connect(mSettings,
   157             SIGNAL(sceneChanged(CxeScene&)),
   180             SIGNAL(sceneChanged(CxeScene&)),
   158             mAutoFocusControl,
   181             mAutoFocusControl,
   217     connect(mVideoCaptureControl,
   240     connect(mVideoCaptureControl,
   218             SIGNAL(snapshotReady(CxeError::Id, const QPixmap&, const QString&)),
   241             SIGNAL(snapshotReady(CxeError::Id, const QPixmap&, const QString&)),
   219             mFileSaveThread,
   242             mFileSaveThread,
   220             SLOT(handleSnapshotReady(CxeError::Id, const QPixmap&, const QString&)));
   243             SLOT(handleSnapshotReady(CxeError::Id, const QPixmap&, const QString&)));
   221 
   244 
   222 
   245     OstTrace0(camerax_performance, CXEENGINESYMBIAN_CONNECTSIGNALS_OUT, "e_CX_ENGINE_CONNECT_SIGNALS 0");
   223 
       
   224     // init camera device control. We init the camera device control
       
   225     // when all necessary engine classes are constructed.
       
   226     mCameraDeviceControl->init();
       
   227 
   246 
   228     CX_DEBUG_EXIT_FUNCTION();
   247     CX_DEBUG_EXIT_FUNCTION();
   229 }
   248 }
   230 
   249 
   231 CxeEngineSymbian::~CxeEngineSymbian()
   250 CxeEngineSymbian::~CxeEngineSymbian()
   237     delete mSettingsControl;
   256     delete mSettingsControl;
   238     delete mStillCaptureControl;
   257     delete mStillCaptureControl;
   239     delete mVideoCaptureControl;
   258     delete mVideoCaptureControl;
   240     delete mViewfinderControl;
   259     delete mViewfinderControl;
   241     delete mFilenameGenerator;
   260     delete mFilenameGenerator;
       
   261     delete mDiskMonitor;
       
   262     delete mMemoryMonitor;
   242     delete mFeatureManager;
   263     delete mFeatureManager;
   243     delete mSettings;
   264     delete mSettings;
   244     delete mSettingsModel;
   265     delete mSettingsModel;
   245     delete mCameraDeviceControl;
   266     delete mCameraDeviceControl;
   246     delete mQualityPresets;
   267     delete mQualityPresets;
   290 {
   311 {
   291     return *mSensorEventHandler;
   312     return *mSensorEventHandler;
   292 }
   313 }
   293 
   314 
   294 
   315 
   295 CxeFeatureManager& CxeEngineSymbian::featureManager()
   316 CxeFeatureManager &CxeEngineSymbian::featureManager()
   296 {
   317 {
   297     return *mFeatureManager;
   318     return *mFeatureManager;
       
   319 }
       
   320 
       
   321 /*!
       
   322 * Get memory monitor utility handle.
       
   323 */
       
   324 CxeMemoryMonitor &CxeEngineSymbian::memoryMonitor()
       
   325 {
       
   326     return *mMemoryMonitor;
   298 }
   327 }
   299 
   328 
   300 /*
   329 /*
   301 * Returns true, if the engine is ready or else false.
   330 * Returns true, if the engine is ready or else false.
   302 */
   331 */
   323     CxeStillCaptureControl in still image mode).
   352     CxeStillCaptureControl in still image mode).
   324 */
   353 */
   325 void CxeEngineSymbian::doInit()
   354 void CxeEngineSymbian::doInit()
   326 {
   355 {
   327     CX_DEBUG_ENTER_FUNCTION();
   356     CX_DEBUG_ENTER_FUNCTION();
   328     OstTrace0(camerax_performance, CXEENGINESYMBIAN_DOINIT, "e_CX_ENGINE_DO_INIT 1");
   357     OstTrace0(camerax_performance, CXEENGINESYMBIAN_DOINIT_IN, "e_CX_ENGINE_DO_INIT 1");
   329 
   358 
   330     mFilenameGenerator->init(mode());
   359     mFilenameGenerator->init(mode());
   331     // load settings whenever we change mode or start camera or switch camera
   360     // load settings whenever we change mode or start camera or switch camera
   332     CxeSettingsImp *settingsImp = qobject_cast<CxeSettingsImp*>(mSettings);
   361     CxeSettingsImp *settingsImp = qobject_cast<CxeSettingsImp*>(mSettings);
   333     if (settingsImp) {
   362     if (settingsImp) {
   341     } else if (mode() == Cxe::VideoMode) {
   370     } else if (mode() == Cxe::VideoMode) {
   342         mStillCaptureControl->deinit();
   371         mStillCaptureControl->deinit();
   343         mVideoCaptureControl->init();
   372         mVideoCaptureControl->init();
   344     }
   373     }
   345 
   374 
   346     OstTrace0(camerax_performance, DUP1_CXEENGINESYMBIAN_DOINIT, "e_CX_ENGINE_DO_INIT 0");
   375     OstTrace0(camerax_performance, CXEENGINESYMBIAN_DOINIT_OUT, "e_CX_ENGINE_DO_INIT 0");
   347 
   376 
   348     CX_DEBUG_EXIT_FUNCTION();
   377     CX_DEBUG_EXIT_FUNCTION();
   349 }
   378 }
   350 
   379 
   351 Cxe::CameraMode CxeEngineSymbian::mode() const
   380 Cxe::CameraMode CxeEngineSymbian::mode() const
   427         // the capture control.
   456         // the capture control.
   428         if (reserveNeeded()) {
   457         if (reserveNeeded()) {
   429             // Camera needs to be reserved. Initialization will continue
   458             // Camera needs to be reserved. Initialization will continue
   430             // when we get the deviceReady() signal.
   459             // when we get the deviceReady() signal.
   431             CX_DEBUG(("initMode() - calling reserve()"));
   460             CX_DEBUG(("initMode() - calling reserve()"));
   432             mCameraDeviceControl->reserve();
   461             reserve();
   433         } else if (initNeeded()) {
   462         } else if (initNeeded()) {
   434             // Camera is reserved and ready, but we need to prepare still image control or
   463             // Camera is reserved and ready, but we need to prepare still image control or
   435             // video capture control
   464             // video capture control
   436             CX_DEBUG(("initMode() - calling doInit()"));
   465             CX_DEBUG(("initMode() - calling doInit()"));
   437             doInit();
   466             doInit();
   453         // stop the vf
   482         // stop the vf
   454         mViewfinderControl->stop();
   483         mViewfinderControl->stop();
   455 
   484 
   456         if (reserveNeeded()) {
   485         if (reserveNeeded()) {
   457             CX_DEBUG(("initMode() - calling reserve()"));
   486             CX_DEBUG(("initMode() - calling reserve()"));
   458             mCameraDeviceControl->reserve();
   487             reserve();
   459         } else if (mCameraDeviceControl->state() == CxeCameraDeviceControl::Ready) {
   488         } else if (mCameraDeviceControl->state() == CxeCameraDeviceControl::Ready) {
   460             CX_DEBUG(("initMode() - calling doInit()"));
   489             CX_DEBUG(("initMode() - calling doInit()"));
   461             // Camera device is ready... we only need to prepare video or still
   490             // Camera device is ready... we only need to prepare video or still
   462             // capture control, depending on current mode.
   491             // capture control, depending on current mode.
   463             doInit();
   492             doInit();
   470     }
   499     }
   471 
   500 
   472     CX_DEBUG_EXIT_FUNCTION();
   501     CX_DEBUG_EXIT_FUNCTION();
   473 }
   502 }
   474 
   503 
       
   504 void CxeEngineSymbian::reserve()
       
   505 {
       
   506     CX_DEBUG_ENTER_FUNCTION();
       
   507     mCameraDeviceControl->reserve();
       
   508     emit reserveStarted();
       
   509     CX_DEBUG_EXIT_FUNCTION();
       
   510 }
       
   511 
   475 // End of file
   512 // End of file