summaryrefslogtreecommitdiffstats
path: root/src/multimedia/platform/qplatformcamera.cpp
blob: cf2170fa000d2d235cf71fe43a1fcab36382467c (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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 3 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL3 included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 3 requirements
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 2.0 or (at your option) the GNU General
** Public license version 3 or any later version approved by the KDE Free
** Qt Foundation. The licenses are as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
** https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/

#include "qplatformcamera_p.h"

QT_BEGIN_NAMESPACE

/*!
    \class QPlatformCamera
    \obsolete



    \brief The QPlatformCamera class is an abstract base class for
    classes that control still cameras or video cameras.

    \inmodule QtMultimedia

    \ingroup multimedia_control
*/

/*!
    Constructs a camera control object with \a parent.
*/

QPlatformCamera::QPlatformCamera(QCamera *parent)
  : QObject(parent),
    m_camera(parent)
{
}

QCameraFormat QPlatformCamera::findBestCameraFormat(const QCameraInfo &camera)
{
    QCameraFormat f;
    const auto formats = camera.videoFormats();
    for (const auto &fmt : formats) {
        // check if fmt is better. We try to find the highest resolution that offers
        // at least 30 FPS
        if (f.maxFrameRate() < 30 && fmt.maxFrameRate() > f.maxFrameRate())
            f = fmt;
        else if (f.maxFrameRate() == fmt.maxFrameRate() &&
                 f.resolution().width()*f.resolution().height() < fmt.resolution().width()*fmt.resolution().height())
            f = fmt;
    }
    return f;
}

/*!
    \fn QPlatformCamera::state() const

    Returns the state of the camera service.

    \sa QCamera::state
*/

/*!
    \fn QPlatformCamera::setState(QCamera::State state)

    Sets the camera \a state.

    State changes are synchronous and indicate user intention,
    while camera status is used as a feedback mechanism to inform application about backend status.
    Status changes are reported asynchronously with QPlatformCamera::statusChanged() signal.

    \sa QCamera::State
*/

/*!
    \fn void QPlatformCamera::stateChanged(QCamera::State state)

    Signal emitted when the camera \a state changes.

    In most cases the state chage is caused by QPlatformCamera::setState(),
    but if critical error has occurred the state changes to QCamera::UnloadedState.
*/

/*!
    \fn QPlatformCamera::status() const

    Returns the status of the camera service.

    \sa QCamera::state
*/

/*!
    \fn void QPlatformCamera::statusChanged(QCamera::Status status)

    Signal emitted when the camera \a status changes.
*/


/*!
    \fn void QPlatformCamera::error(int error, const QString &errorString)

    Signal emitted when an error occurs with error code \a error and
    a description of the error \a errorString.
*/

/*!
    \fn QPlatformCamera::supportedViewfinderSettings() const

    Returns a list of supported camera viewfinder settings.

    The list is ordered by preference; preferred settings come first.
*/

/*!
    \fn QPlatformCamera::viewfinderSettings() const

    Returns the viewfinder settings.

    If undefined or unsupported values are passed to QPlatformCamera::setViewfinderSettings(),
    this function returns the actual settings used by the camera viewfinder. These may be available
    only once the camera is active.
*/

/*!
    \fn QPlatformCamera::setViewfinderSettings(const QCameraViewfinderSettings &settings)

    Sets the camera viewfinder \a settings.
*/


void QPlatformCamera::statusChanged(QCamera::Status s)
{
    if (s == m_status)
        return;
    m_status = s;
    emit m_camera->statusChanged(s);
}

void QPlatformCamera::minimumZoomFactorChanged(float factor)
{
    if (m_minZoom == factor)
        return;
    m_minZoom = factor;
    emit m_camera->minimumZoomFactorChanged(factor);
}

void QPlatformCamera::maximumZoomFactorChanged(float factor)
{
    if (m_maxZoom == factor)
        return;
    m_maxZoom = factor;
    emit m_camera->maximumZoomFactorChanged(factor);
}

void QPlatformCamera::focusModeChanged(QCamera::FocusMode mode)
{
    if (m_focusMode == mode)
        return;
    m_focusMode = mode;
    emit m_camera->focusModeChanged();
}

void QPlatformCamera::customFocusPointChanged(const QPointF &point)
{
    if (m_customFocusPoint == point)
        return;
    m_customFocusPoint = point;
    emit m_camera->customFocusPointChanged();
}


void QPlatformCamera::zoomFactorChanged(float zoom)
{
    if (m_zoomFactor == zoom)
        return;
    m_zoomFactor = zoom;
    emit m_camera->zoomFactorChanged(zoom);
}


void QPlatformCamera::focusDistanceChanged(float d)
{
    if (m_focusDistance == d)
        return;
    m_focusDistance = d;
    emit m_camera->focusDistanceChanged(m_focusDistance);
}


QT_END_NAMESPACE

#include "moc_qplatformcamera_p.cpp"