summaryrefslogtreecommitdiff
path: root/src/imports/multimedia/qdeclarativecameraviewfinder.cpp
diff options
context:
space:
mode:
authorYoann Lopes <yoann.lopes@theqtcompany.com>2014-12-12 12:00:06 +0100
committerYoann Lopes <yoann.lopes@theqtcompany.com>2015-01-13 13:34:41 +0100
commitfe21ee675e72f7cb3936db6aa01862cfd322ce50 (patch)
tree8d2caa1d13b79cff554a7fbb8b98051c0695d683 /src/imports/multimedia/qdeclarativecameraviewfinder.cpp
parentc31d8cddd0a2e1f1ee622bc9ea07d038191ceea2 (diff)
downloadqtmultimedia-fe21ee675e72f7cb3936db6aa01862cfd322ce50.tar.gz
New camera viewfinder settings API.
There already was a control interface for the viewfinder settings but no real public C++ API and a partial QML API. This patch adds a new C++ API and improves the QML API. Supported viewfinder settings are resolution, minimumFrameRate, maximumFrameRate and pixelFormat. The camera can be queried for the supported values for each of these settings. A new control interface was created to match the new API. Change-Id: I289fea038fe46277a5516c956a64280da09ed985 Reviewed-by: Andrew den Exter <andrew.den.exter@qinetic.com.au>
Diffstat (limited to 'src/imports/multimedia/qdeclarativecameraviewfinder.cpp')
-rw-r--r--src/imports/multimedia/qdeclarativecameraviewfinder.cpp60
1 files changed, 34 insertions, 26 deletions
diff --git a/src/imports/multimedia/qdeclarativecameraviewfinder.cpp b/src/imports/multimedia/qdeclarativecameraviewfinder.cpp
index 66d4e1bbc..abb0b6290 100644
--- a/src/imports/multimedia/qdeclarativecameraviewfinder.cpp
+++ b/src/imports/multimedia/qdeclarativecameraviewfinder.cpp
@@ -42,68 +42,76 @@ QT_BEGIN_NAMESPACE
QDeclarativeCameraViewfinder::QDeclarativeCameraViewfinder(QCamera *camera, QObject *parent)
: QObject(parent)
, m_camera(camera)
- , m_control(0)
{
- if (QMediaService *service = m_camera->service())
- m_control = service->requestControl<QCameraViewfinderSettingsControl *>();
+ connect(m_camera, &QCamera::statusChanged,
+ this, &QDeclarativeCameraViewfinder::_q_cameraStatusChanged);
}
QDeclarativeCameraViewfinder::~QDeclarativeCameraViewfinder()
{
- if (m_control) {
- if (QMediaService *service = m_camera->service())
- service->releaseControl(m_control);
- }
}
QSize QDeclarativeCameraViewfinder::resolution() const
{
- return m_control
- ? m_control->viewfinderParameter(QCameraViewfinderSettingsControl::Resolution).value<QSize>()
- : QSize();
+ return m_settings.resolution();
}
-void QDeclarativeCameraViewfinder::setResolution(const QSize &resolution)
+void QDeclarativeCameraViewfinder::setResolution(const QSize &res)
{
- if (m_control) {
- m_control->setViewfinderParameter(
- QCameraViewfinderSettingsControl::Resolution, resolution);
+ if (res != m_settings.resolution()) {
+ m_settings = m_camera->viewfinderSettings();
+ m_settings.setResolution(res);
+ m_camera->setViewfinderSettings(m_settings);
emit resolutionChanged();
}
}
qreal QDeclarativeCameraViewfinder::minimumFrameRate() const
{
- return m_control
- ? m_control->viewfinderParameter(QCameraViewfinderSettingsControl::MinimumFrameRate).value<qreal>()
- : 0.0;
+ return m_settings.minimumFrameRate();
}
void QDeclarativeCameraViewfinder::setMinimumFrameRate(qreal frameRate)
{
- if (m_control) {
- m_control->setViewfinderParameter(
- QCameraViewfinderSettingsControl::MinimumFrameRate, frameRate);
+ if (frameRate != minimumFrameRate()) {
+ m_settings = m_camera->viewfinderSettings();
+ m_settings.setMinimumFrameRate(frameRate);
+ m_camera->setViewfinderSettings(m_settings);
emit minimumFrameRateChanged();
}
}
qreal QDeclarativeCameraViewfinder::maximumFrameRate() const
{
- return m_control
- ? m_control->viewfinderParameter(QCameraViewfinderSettingsControl::MaximumFrameRate).value<qreal>()
- : 0.0;
+ return m_settings.maximumFrameRate();
}
void QDeclarativeCameraViewfinder::setMaximumFrameRate(qreal frameRate)
{
- if (m_control) {
- m_control->setViewfinderParameter(
- QCameraViewfinderSettingsControl::MaximumFrameRate, frameRate);
+ if (frameRate != maximumFrameRate()) {
+ m_settings = m_camera->viewfinderSettings();
+ m_settings.setMaximumFrameRate(frameRate);
+ m_camera->setViewfinderSettings(m_settings);
emit maximumFrameRateChanged();
}
}
+void QDeclarativeCameraViewfinder::_q_cameraStatusChanged(QCamera::Status status)
+{
+ // Settings values might change when the camera starts, for example if the settings are
+ // undefined, if unsupported values were set or if the settings conflict with capture settings.
+ if (status == QCamera::ActiveStatus) {
+ QCameraViewfinderSettings oldSettings = m_settings;
+ m_settings = m_camera->viewfinderSettings();
+ if (oldSettings.resolution() != m_settings.resolution())
+ emit resolutionChanged();
+ if (oldSettings.minimumFrameRate() != m_settings.minimumFrameRate())
+ emit minimumFrameRateChanged();
+ if (oldSettings.maximumFrameRate() != m_settings.maximumFrameRate())
+ emit maximumFrameRateChanged();
+ }
+}
+
QT_END_NAMESPACE
#include "moc_qdeclarativecameraviewfinder_p.cpp"