summaryrefslogtreecommitdiffstats
path: root/src/plugins/symbian/ecam/s60cameracontrol.h
blob: d5f9e19e5bfbab47e097da3a1519ec5059f027cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Mobility Components.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/

#ifndef S60CAMERACONTROL_H
#define S60CAMERACONTROL_H

#include <qcameracontrol.h>

#include "s60cameraengineobserver.h"    // MCameraEngineObserver
#include "s60videocapturesession.h"     // TVideoCaptureState
#include "s60cameraviewfinderengine.h"  // ViewfinderOutputType

#include <e32base.h>
#include <fbs.h>

QT_USE_NAMESPACE

class S60CameraService;
class S60ImageCaptureSession;
class S60VideoCaptureSession;
class S60CameraSettings;
class CCameraEngine;
class S60CameraViewfinderEngine;
class QTimer;

/*
 * Control for controlling camera base operations (e.g. start/stop and capture
 * mode).
 */
class S60CameraControl : public QCameraControl, public MCameraEngineObserver
{
    Q_OBJECT

public: // Constructors & Destructor

    S60CameraControl(QObject *parent = 0);
    S60CameraControl(S60VideoCaptureSession *videosession,
                     S60ImageCaptureSession *imagesession,
                     QObject *parent = 0);
    ~S60CameraControl();

public: // QCameraControl

    // State
    QCamera::State state() const;
    void setState(QCamera::State state);

    // Status
    QCamera::Status status() const;

    // Capture Mode
    QCamera::CaptureMode captureMode() const;
    void setCaptureMode(QCamera::CaptureMode);
    bool isCaptureModeSupported(QCamera::CaptureMode mode) const;

    // Property Setting
    bool canChangeProperty(QCameraControl::PropertyChangeType changeType, QCamera::Status status) const;

/*
Q_SIGNALS:
    void stateChanged(QCamera::State);
    void statusChanged(QCamera::Status);
    void error(int error, const QString &errorString);
    void captureModeChanged(QCamera::CaptureMode);
*/

public: // Internal

    void setError(const TInt error, const QString &description);
    void resetCameraOrientation();

    // To provide QVideoDeviceControl info
    static int deviceCount();
    static QString name(const int index);
    static QString description(const int index);
    int defaultDevice() const;
    int selectedDevice() const;
    void setSelectedDevice(const int index);

    void setVideoOutput(QObject *output,
                        const S60CameraViewfinderEngine::ViewfinderOutputType type);
    void releaseVideoOutput(const S60CameraViewfinderEngine::ViewfinderOutputType type);

private slots: // Internal Slots

    void videoStateChanged(const S60VideoCaptureSession::TVideoCaptureState state);
    // Needed to detect image capture completion when trying to rotate the camera
    void imageCaptured(const int imageId, const QImage& preview);
    /*
     * This method moves the camera to the StandBy status:
     *    - If camera access was lost
     *    - If camera has been inactive in LoadedStatus for a long time
     */
    void toStandByStatus();
    void advancedSettingsCreated();

protected: // MCameraEngineObserver

    void MceoCameraReady();
    void MceoHandleError(TCameraEngineError aErrorType, TInt aError);

private: // Internal

    QCamera::Error fromSymbianErrorToQtMultimediaError(int aError);

    void loadCamera();
    void unloadCamera();
    void startCamera();
    void stopCamera();

    void resetCamera(bool errorHandling = false);
    void setCameraHandles();

signals: // Internal Signals

    void cameraReadyChanged(bool);
    void devicesChanged();

private: // Data

    CCameraEngine               *m_cameraEngine;
    S60CameraViewfinderEngine   *m_viewfinderEngine;
    S60ImageCaptureSession      *m_imageSession;
    S60VideoCaptureSession      *m_videoSession;
    S60CameraSettings           *m_advancedSettings;
    QObject                     *m_videoOutput;
    QTimer                      *m_inactivityTimer;
    QCamera::CaptureMode        m_captureMode;
    QCamera::CaptureMode        m_requestedCaptureMode;
    bool                        m_settingCaptureModeInternally;
    QCamera::Status             m_internalState;
    QCamera::State              m_requestedState;
    int                         m_deviceIndex;
    mutable int                 m_error;
    bool                        m_changeCaptureModeWhenReady;
    bool                        m_rotateCameraWhenReady;
    S60VideoCaptureSession::TVideoCaptureState m_videoCaptureState;
};

#endif // S60CAMERACONTROL_H