camerauis/cameraxui/cxengine/inc/api/cxecameradevicecontrol.h
changeset 19 d9aefe59d544
equal deleted inserted replaced
3:8b2d6d0384b0 19:d9aefe59d544
       
     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 #ifndef CXECAMERADEVICECONTROL_H
       
    18 #define CXECAMERADEVICECONTROL_H
       
    19 
       
    20 #include <QObject>
       
    21 #include "cxenamespace.h"
       
    22 #include "cxeerror.h"
       
    23 
       
    24 class CxeViewfinderControl;
       
    25 
       
    26 /**
       
    27  * CxeCameraDeviceControl is responsible for reserving and powering on the camera module.
       
    28  * It also routes all camera adaptation events to other engine internal controls.
       
    29  * The device control API is also used to control the operating mode (Cxe::CameraMode) of
       
    30  * the engine
       
    31  */
       
    32 class CxeCameraDeviceControl : public QObject
       
    33 {
       
    34     Q_OBJECT
       
    35 public:
       
    36 
       
    37     /**
       
    38      * Camera device control state.
       
    39      */
       
    40     enum State
       
    41         {
       
    42         //! Camera power off/unreserved
       
    43         Idle            = 0x01,
       
    44 
       
    45         //! Reserving and powering on camera
       
    46         Initializing    = 0x02,
       
    47         
       
    48         //! Camera device is reserved and powered on
       
    49         Ready           = 0x04,
       
    50 
       
    51         //! Camera device release pending
       
    52         PendingRelease  = 0x08
       
    53         };
       
    54 
       
    55     /**
       
    56      * Get current camera mode.
       
    57      */
       
    58     virtual Cxe::CameraMode mode() const = 0;
       
    59 
       
    60     /**
       
    61      * Set current camera mode.
       
    62      */
       
    63     virtual void setMode(Cxe::CameraMode mode) = 0;
       
    64 
       
    65     virtual void init() = 0;
       
    66 
       
    67     /**
       
    68      * Reserve camera device for exclusive use.
       
    69      */
       
    70     virtual void reserve() = 0;
       
    71 
       
    72     /**
       
    73      * Cancel all operations and release camera for other applications to use.
       
    74      * Camera module is also powered off.
       
    75      */
       
    76     virtual void release() = 0;
       
    77 
       
    78     /**
       
    79      * Get current camera index (primary or secondary).
       
    80      *
       
    81      * @return Current camera index
       
    82      */
       
    83     virtual Cxe::CameraIndex cameraIndex() const = 0;
       
    84 
       
    85     /**
       
    86      * Switch between primary and secondary camera.
       
    87      *
       
    88      * @param index New camera index
       
    89      */
       
    90     virtual CxeError::Id switchCamera(Cxe::CameraIndex index) = 0;
       
    91 
       
    92     /**
       
    93      * Get current device control state.
       
    94      *
       
    95      * @return Current state
       
    96      */
       
    97     virtual State state() const = 0;
       
    98 
       
    99 signals:
       
   100     /**
       
   101      * Initializing current mode has completed. The engine is now ready to capture
       
   102      * images or videos (unless a non-zero error code was given.
       
   103      *
       
   104      * @param error Error code
       
   105      */
       
   106     void initModeComplete(CxeError::Id error);
       
   107 
       
   108     /**
       
   109      * Camera device control state has changed.
       
   110      *
       
   111      * @param newState New device control state
       
   112      * @param error    Error code
       
   113      */
       
   114     void stateChanged(CxeCameraDeviceControl::State newState, CxeError::Id error);
       
   115 
       
   116 protected:
       
   117     CxeCameraDeviceControl() {}
       
   118 
       
   119 private:
       
   120     Q_DISABLE_COPY(CxeCameraDeviceControl)
       
   121 };
       
   122 
       
   123 Q_DECLARE_METATYPE(CxeCameraDeviceControl::State)
       
   124 
       
   125 #endif // CXECAMERADEVICECONTROL_H