From 99667804e1c64cace1246d4ce342a218fc1fb1ba Mon Sep 17 00:00:00 2001 From: Frank Osterfeld Date: Tue, 5 Nov 2013 14:28:08 +0100 Subject: QNX: Restructure plugins Now that the MmRenderer implementation is ported to plain QNX, rename the directories and files accordingly: "blackberry" becomes "qnx", replace the Bb prefix with MmRenderer for classes concerned with mm-renderer. The legacy alsa support for plain qnx is now "qnx-audio". Change-Id: I6abd98ecdd713b2d5e554d42224dc30f13772f43 Reviewed-by: Thomas McGuire --- .../camera/bbcameraaudioencodersettingscontrol.cpp | 89 ++ .../camera/bbcameraaudioencodersettingscontrol.h | 68 ++ .../camera/bbcameracapturebufferformatcontrol.cpp | 66 ++ .../camera/bbcameracapturebufferformatcontrol.h | 61 ++ .../camera/bbcameracapturedestinationcontrol.cpp | 70 ++ .../qnx/camera/bbcameracapturedestinationcontrol.h | 66 ++ src/plugins/qnx/camera/bbcameracontrol.cpp | 92 ++ src/plugins/qnx/camera/bbcameracontrol.h | 73 ++ src/plugins/qnx/camera/bbcameraexposurecontrol.cpp | 236 ++++ src/plugins/qnx/camera/bbcameraexposurecontrol.h | 73 ++ src/plugins/qnx/camera/bbcameraflashcontrol.cpp | 113 ++ src/plugins/qnx/camera/bbcameraflashcontrol.h | 68 ++ src/plugins/qnx/camera/bbcamerafocuscontrol.cpp | 331 ++++++ src/plugins/qnx/camera/bbcamerafocuscontrol.h | 79 ++ .../qnx/camera/bbcameraimagecapturecontrol.cpp | 85 ++ .../qnx/camera/bbcameraimagecapturecontrol.h | 70 ++ .../qnx/camera/bbcameraimageprocessingcontrol.cpp | 146 +++ .../qnx/camera/bbcameraimageprocessingcontrol.h | 67 ++ src/plugins/qnx/camera/bbcameralockscontrol.cpp | 258 +++++ src/plugins/qnx/camera/bbcameralockscontrol.h | 86 ++ .../qnx/camera/bbcameramediarecordercontrol.cpp | 169 +++ .../qnx/camera/bbcameramediarecordercontrol.h | 76 ++ .../qnx/camera/bbcameraorientationhandler.cpp | 102 ++ .../qnx/camera/bbcameraorientationhandler.h | 69 ++ src/plugins/qnx/camera/bbcameraservice.cpp | 141 +++ src/plugins/qnx/camera/bbcameraservice.h | 104 ++ src/plugins/qnx/camera/bbcamerasession.cpp | 1154 ++++++++++++++++++++ src/plugins/qnx/camera/bbcamerasession.h | 217 ++++ .../camera/bbcameravideoencodersettingscontrol.cpp | 90 ++ .../camera/bbcameravideoencodersettingscontrol.h | 69 ++ .../camera/bbcameraviewfindersettingscontrol.cpp | 249 +++++ .../qnx/camera/bbcameraviewfindersettingscontrol.h | 66 ++ src/plugins/qnx/camera/bbcamerazoomcontrol.cpp | 157 +++ src/plugins/qnx/camera/bbcamerazoomcontrol.h | 79 ++ src/plugins/qnx/camera/bbimageencodercontrol.cpp | 81 ++ src/plugins/qnx/camera/bbimageencodercontrol.h | 68 ++ src/plugins/qnx/camera/bbmediastoragelocation.cpp | 119 ++ src/plugins/qnx/camera/bbmediastoragelocation.h | 66 ++ .../qnx/camera/bbvideodeviceselectorcontrol.cpp | 146 +++ .../qnx/camera/bbvideodeviceselectorcontrol.h | 79 ++ src/plugins/qnx/camera/bbvideorenderercontrol.cpp | 64 ++ src/plugins/qnx/camera/bbvideorenderercontrol.h | 65 ++ src/plugins/qnx/camera/camera.pri | 53 + 43 files changed, 5680 insertions(+) create mode 100644 src/plugins/qnx/camera/bbcameraaudioencodersettingscontrol.cpp create mode 100644 src/plugins/qnx/camera/bbcameraaudioencodersettingscontrol.h create mode 100644 src/plugins/qnx/camera/bbcameracapturebufferformatcontrol.cpp create mode 100644 src/plugins/qnx/camera/bbcameracapturebufferformatcontrol.h create mode 100644 src/plugins/qnx/camera/bbcameracapturedestinationcontrol.cpp create mode 100644 src/plugins/qnx/camera/bbcameracapturedestinationcontrol.h create mode 100644 src/plugins/qnx/camera/bbcameracontrol.cpp create mode 100644 src/plugins/qnx/camera/bbcameracontrol.h create mode 100644 src/plugins/qnx/camera/bbcameraexposurecontrol.cpp create mode 100644 src/plugins/qnx/camera/bbcameraexposurecontrol.h create mode 100644 src/plugins/qnx/camera/bbcameraflashcontrol.cpp create mode 100644 src/plugins/qnx/camera/bbcameraflashcontrol.h create mode 100644 src/plugins/qnx/camera/bbcamerafocuscontrol.cpp create mode 100644 src/plugins/qnx/camera/bbcamerafocuscontrol.h create mode 100644 src/plugins/qnx/camera/bbcameraimagecapturecontrol.cpp create mode 100644 src/plugins/qnx/camera/bbcameraimagecapturecontrol.h create mode 100644 src/plugins/qnx/camera/bbcameraimageprocessingcontrol.cpp create mode 100644 src/plugins/qnx/camera/bbcameraimageprocessingcontrol.h create mode 100644 src/plugins/qnx/camera/bbcameralockscontrol.cpp create mode 100644 src/plugins/qnx/camera/bbcameralockscontrol.h create mode 100644 src/plugins/qnx/camera/bbcameramediarecordercontrol.cpp create mode 100644 src/plugins/qnx/camera/bbcameramediarecordercontrol.h create mode 100644 src/plugins/qnx/camera/bbcameraorientationhandler.cpp create mode 100644 src/plugins/qnx/camera/bbcameraorientationhandler.h create mode 100644 src/plugins/qnx/camera/bbcameraservice.cpp create mode 100644 src/plugins/qnx/camera/bbcameraservice.h create mode 100644 src/plugins/qnx/camera/bbcamerasession.cpp create mode 100644 src/plugins/qnx/camera/bbcamerasession.h create mode 100644 src/plugins/qnx/camera/bbcameravideoencodersettingscontrol.cpp create mode 100644 src/plugins/qnx/camera/bbcameravideoencodersettingscontrol.h create mode 100644 src/plugins/qnx/camera/bbcameraviewfindersettingscontrol.cpp create mode 100644 src/plugins/qnx/camera/bbcameraviewfindersettingscontrol.h create mode 100644 src/plugins/qnx/camera/bbcamerazoomcontrol.cpp create mode 100644 src/plugins/qnx/camera/bbcamerazoomcontrol.h create mode 100644 src/plugins/qnx/camera/bbimageencodercontrol.cpp create mode 100644 src/plugins/qnx/camera/bbimageencodercontrol.h create mode 100644 src/plugins/qnx/camera/bbmediastoragelocation.cpp create mode 100644 src/plugins/qnx/camera/bbmediastoragelocation.h create mode 100644 src/plugins/qnx/camera/bbvideodeviceselectorcontrol.cpp create mode 100644 src/plugins/qnx/camera/bbvideodeviceselectorcontrol.h create mode 100644 src/plugins/qnx/camera/bbvideorenderercontrol.cpp create mode 100644 src/plugins/qnx/camera/bbvideorenderercontrol.h create mode 100644 src/plugins/qnx/camera/camera.pri (limited to 'src/plugins/qnx/camera') diff --git a/src/plugins/qnx/camera/bbcameraaudioencodersettingscontrol.cpp b/src/plugins/qnx/camera/bbcameraaudioencodersettingscontrol.cpp new file mode 100644 index 000000000..2ff800a0f --- /dev/null +++ b/src/plugins/qnx/camera/bbcameraaudioencodersettingscontrol.cpp @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Research In Motion +** Contact: http://www.qt-project.org/legal +** +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional +** rights. These rights are described in the Digia 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "bbcameraaudioencodersettingscontrol.h" + +#include "bbcamerasession.h" + +QT_BEGIN_NAMESPACE + +BbCameraAudioEncoderSettingsControl::BbCameraAudioEncoderSettingsControl(BbCameraSession *session, QObject *parent) + : QAudioEncoderSettingsControl(parent) + , m_session(session) +{ +} + +QStringList BbCameraAudioEncoderSettingsControl::supportedAudioCodecs() const +{ + return QStringList() << QLatin1String("none") << QLatin1String("aac") << QLatin1String("raw"); +} + +QString BbCameraAudioEncoderSettingsControl::codecDescription(const QString &codecName) const +{ + if (codecName == QLatin1String("none")) + return tr("No compression"); + else if (codecName == QLatin1String("aac")) + return tr("AAC compression"); + else if (codecName == QLatin1String("raw")) + return tr("PCM uncompressed"); + + return QString(); +} + +QList BbCameraAudioEncoderSettingsControl::supportedSampleRates(const QAudioEncoderSettings &settings, bool *continuous) const +{ + Q_UNUSED(settings); + Q_UNUSED(continuous); + + // no API provided by BB10 yet + return QList(); +} + +QAudioEncoderSettings BbCameraAudioEncoderSettingsControl::audioSettings() const +{ + return m_session->audioSettings(); +} + +void BbCameraAudioEncoderSettingsControl::setAudioSettings(const QAudioEncoderSettings &settings) +{ + m_session->setAudioSettings(settings); +} + +QT_END_NAMESPACE diff --git a/src/plugins/qnx/camera/bbcameraaudioencodersettingscontrol.h b/src/plugins/qnx/camera/bbcameraaudioencodersettingscontrol.h new file mode 100644 index 000000000..21fb520e7 --- /dev/null +++ b/src/plugins/qnx/camera/bbcameraaudioencodersettingscontrol.h @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Research In Motion +** Contact: http://www.qt-project.org/legal +** +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional +** rights. These rights are described in the Digia 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef BBCAMERAAUDIOENCODERSETTINGSCONTROL_H +#define BBCAMERAAUDIOENCODERSETTINGSCONTROL_H + +#include + +QT_BEGIN_NAMESPACE + +class BbCameraSession; + +class BbCameraAudioEncoderSettingsControl : public QAudioEncoderSettingsControl +{ + Q_OBJECT +public: + explicit BbCameraAudioEncoderSettingsControl(BbCameraSession *session, QObject *parent = 0); + + QStringList supportedAudioCodecs() const Q_DECL_OVERRIDE; + QString codecDescription(const QString &codecName) const Q_DECL_OVERRIDE; + QList supportedSampleRates(const QAudioEncoderSettings &settings, bool *continuous = 0) const Q_DECL_OVERRIDE; + QAudioEncoderSettings audioSettings() const Q_DECL_OVERRIDE; + void setAudioSettings(const QAudioEncoderSettings &settings) Q_DECL_OVERRIDE; + +private: + BbCameraSession *m_session; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/qnx/camera/bbcameracapturebufferformatcontrol.cpp b/src/plugins/qnx/camera/bbcameracapturebufferformatcontrol.cpp new file mode 100644 index 000000000..57f3c9fb1 --- /dev/null +++ b/src/plugins/qnx/camera/bbcameracapturebufferformatcontrol.cpp @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Research In Motion +** Contact: http://www.qt-project.org/legal +** +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional +** rights. These rights are described in the Digia 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "bbcameracapturebufferformatcontrol.h" + +QT_BEGIN_NAMESPACE + +BbCameraCaptureBufferFormatControl::BbCameraCaptureBufferFormatControl(QObject *parent) + : QCameraCaptureBufferFormatControl(parent) +{ +} + +QList BbCameraCaptureBufferFormatControl::supportedBufferFormats() const +{ + return (QList() << QVideoFrame::Format_Jpeg); +} + +QVideoFrame::PixelFormat BbCameraCaptureBufferFormatControl::bufferFormat() const +{ + return QVideoFrame::Format_Jpeg; +} + +void BbCameraCaptureBufferFormatControl::setBufferFormat(QVideoFrame::PixelFormat format) +{ + Q_UNUSED(format) + // Do nothing, we support only Jpeg for now +} + +QT_END_NAMESPACE diff --git a/src/plugins/qnx/camera/bbcameracapturebufferformatcontrol.h b/src/plugins/qnx/camera/bbcameracapturebufferformatcontrol.h new file mode 100644 index 000000000..2897cb2fd --- /dev/null +++ b/src/plugins/qnx/camera/bbcameracapturebufferformatcontrol.h @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Research In Motion +** Contact: http://www.qt-project.org/legal +** +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional +** rights. These rights are described in the Digia 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef BBCAMERACAPTUREBUFFERFORMATCONTROL_H +#define BBCAMERACAPTUREBUFFERFORMATCONTROL_H + +#include + +QT_BEGIN_NAMESPACE + +class BbCameraCaptureBufferFormatControl : public QCameraCaptureBufferFormatControl +{ + Q_OBJECT +public: + explicit BbCameraCaptureBufferFormatControl(QObject *parent = 0); + + QList supportedBufferFormats() const Q_DECL_OVERRIDE; + QVideoFrame::PixelFormat bufferFormat() const Q_DECL_OVERRIDE; + void setBufferFormat(QVideoFrame::PixelFormat format) Q_DECL_OVERRIDE; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/qnx/camera/bbcameracapturedestinationcontrol.cpp b/src/plugins/qnx/camera/bbcameracapturedestinationcontrol.cpp new file mode 100644 index 000000000..6b6bcfcb9 --- /dev/null +++ b/src/plugins/qnx/camera/bbcameracapturedestinationcontrol.cpp @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Research In Motion +** Contact: http://www.qt-project.org/legal +** +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional +** rights. These rights are described in the Digia 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "bbcameracapturedestinationcontrol.h" + +#include "bbcamerasession.h" + +QT_BEGIN_NAMESPACE + +BbCameraCaptureDestinationControl::BbCameraCaptureDestinationControl(BbCameraSession *session, QObject *parent) + : QCameraCaptureDestinationControl(parent) + , m_session(session) +{ + connect(m_session, SIGNAL(captureDestinationChanged(QCameraImageCapture::CaptureDestinations)), + this, SIGNAL(captureDestinationChanged(QCameraImageCapture::CaptureDestinations))); +} + +bool BbCameraCaptureDestinationControl::isCaptureDestinationSupported(QCameraImageCapture::CaptureDestinations destination) const +{ + return m_session->isCaptureDestinationSupported(destination); +} + +QCameraImageCapture::CaptureDestinations BbCameraCaptureDestinationControl::captureDestination() const +{ + return m_session->captureDestination();; +} + +void BbCameraCaptureDestinationControl::setCaptureDestination(QCameraImageCapture::CaptureDestinations destination) +{ + m_session->setCaptureDestination(destination); +} + +QT_END_NAMESPACE diff --git a/src/plugins/qnx/camera/bbcameracapturedestinationcontrol.h b/src/plugins/qnx/camera/bbcameracapturedestinationcontrol.h new file mode 100644 index 000000000..93a7d2d14 --- /dev/null +++ b/src/plugins/qnx/camera/bbcameracapturedestinationcontrol.h @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Research In Motion +** Contact: http://www.qt-project.org/legal +** +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional +** rights. These rights are described in the Digia 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef BBCAMERACAPTUREDESTINATIONCONTROL_H +#define BBCAMERACAPTUREDESTINATIONCONTROL_H + +#include + +QT_BEGIN_NAMESPACE + +class BbCameraSession; + +class BbCameraCaptureDestinationControl : public QCameraCaptureDestinationControl +{ + Q_OBJECT +public: + explicit BbCameraCaptureDestinationControl(BbCameraSession *session, QObject *parent = 0); + + bool isCaptureDestinationSupported(QCameraImageCapture::CaptureDestinations destination) const Q_DECL_OVERRIDE; + QCameraImageCapture::CaptureDestinations captureDestination() const Q_DECL_OVERRIDE; + void setCaptureDestination(QCameraImageCapture::CaptureDestinations destination) Q_DECL_OVERRIDE; + +private: + BbCameraSession *m_session; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/qnx/camera/bbcameracontrol.cpp b/src/plugins/qnx/camera/bbcameracontrol.cpp new file mode 100644 index 000000000..bc3c78264 --- /dev/null +++ b/src/plugins/qnx/camera/bbcameracontrol.cpp @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Research In Motion +** Contact: http://www.qt-project.org/legal +** +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional +** rights. These rights are described in the Digia 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "bbcameracontrol.h" + +#include "bbcamerasession.h" + +QT_BEGIN_NAMESPACE + +BbCameraControl::BbCameraControl(BbCameraSession *session, QObject *parent) + : QCameraControl(parent) + , m_session(session) +{ + connect(m_session, SIGNAL(statusChanged(QCamera::Status)), this, SIGNAL(statusChanged(QCamera::Status))); + connect(m_session, SIGNAL(stateChanged(QCamera::State)), this, SIGNAL(stateChanged(QCamera::State))); + connect(m_session, SIGNAL(error(int,QString)), this, SIGNAL(error(int,QString))); + connect(m_session, SIGNAL(captureModeChanged(QCamera::CaptureModes)), this, SIGNAL(captureModeChanged(QCamera::CaptureModes))); +} + +QCamera::State BbCameraControl::state() const +{ + return m_session->state(); +} + +void BbCameraControl::setState(QCamera::State state) +{ + m_session->setState(state); +} + +QCamera::CaptureModes BbCameraControl::captureMode() const +{ + return m_session->captureMode(); +} + +void BbCameraControl::setCaptureMode(QCamera::CaptureModes mode) +{ + m_session->setCaptureMode(mode); +} + +QCamera::Status BbCameraControl::status() const +{ + return m_session->status(); +} + +bool BbCameraControl::isCaptureModeSupported(QCamera::CaptureModes mode) const +{ + return m_session->isCaptureModeSupported(mode); +} + +bool BbCameraControl::canChangeProperty(PropertyChangeType /* changeType */, QCamera::Status /* status */) const +{ + return false; +} + +QT_END_NAMESPACE diff --git a/src/plugins/qnx/camera/bbcameracontrol.h b/src/plugins/qnx/camera/bbcameracontrol.h new file mode 100644 index 000000000..a5792c5df --- /dev/null +++ b/src/plugins/qnx/camera/bbcameracontrol.h @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Research In Motion +** Contact: http://www.qt-project.org/legal +** +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional +** rights. These rights are described in the Digia 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef BBCAMERACONTROL_H +#define BBCAMERACONTROL_H + +#include + +QT_BEGIN_NAMESPACE + +class BbCameraSession; + +class BbCameraControl : public QCameraControl +{ + Q_OBJECT +public: + explicit BbCameraControl(BbCameraSession *session, QObject *parent = 0); + + QCamera::State state() const Q_DECL_OVERRIDE; + void setState(QCamera::State state) Q_DECL_OVERRIDE; + + QCamera::Status status() const Q_DECL_OVERRIDE; + + QCamera::CaptureModes captureMode() const Q_DECL_OVERRIDE; + void setCaptureMode(QCamera::CaptureModes) Q_DECL_OVERRIDE; + bool isCaptureModeSupported(QCamera::CaptureModes mode) const Q_DECL_OVERRIDE; + + bool canChangeProperty(PropertyChangeType changeType, QCamera::Status status) const Q_DECL_OVERRIDE; + +private: + BbCameraSession *m_session; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/qnx/camera/bbcameraexposurecontrol.cpp b/src/plugins/qnx/camera/bbcameraexposurecontrol.cpp new file mode 100644 index 000000000..b1d637cd0 --- /dev/null +++ b/src/plugins/qnx/camera/bbcameraexposurecontrol.cpp @@ -0,0 +1,236 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Research In Motion +** Contact: http://www.qt-project.org/legal +** +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional +** rights. These rights are described in the Digia 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "bbcameraexposurecontrol.h" + +#include "bbcamerasession.h" + +#include + +QT_BEGIN_NAMESPACE + +BbCameraExposureControl::BbCameraExposureControl(BbCameraSession *session, QObject *parent) + : QCameraExposureControl(parent) + , m_session(session) + , m_requestedExposureMode(QCameraExposure::ExposureAuto) +{ + connect(m_session, SIGNAL(statusChanged(QCamera::Status)), this, SLOT(statusChanged(QCamera::Status))); +} + +bool BbCameraExposureControl::isParameterSupported(ExposureParameter parameter) const +{ + switch (parameter) { + case QCameraExposureControl::ISO: + return false; + case QCameraExposureControl::Aperture: + return false; + case QCameraExposureControl::ShutterSpeed: + return false; + case QCameraExposureControl::ExposureCompensation: + return false; + case QCameraExposureControl::FlashPower: + return false; + case QCameraExposureControl::FlashCompensation: + return false; + case QCameraExposureControl::TorchPower: + return false; + case QCameraExposureControl::SpotMeteringPoint: + return false; + case QCameraExposureControl::ExposureMode: + return true; + case QCameraExposureControl::MeteringMode: + return false; + default: + return false; + } +} + +QVariantList BbCameraExposureControl::supportedParameterRange(ExposureParameter parameter, bool *continuous) const +{ + if (parameter != QCameraExposureControl::ExposureMode) // no other parameter supported by BB10 API at the moment + return QVariantList(); + + if (m_session->status() != QCamera::ActiveStatus) // we can query supported exposure modes only with active viewfinder + return QVariantList(); + + if (continuous) + *continuous = false; + + int supported = 0; + camera_scenemode_t modes[20]; + const camera_error_t result = camera_get_scene_modes(m_session->handle(), 20, &supported, modes); + if (result != CAMERA_EOK) { + qWarning() << "Unable to retrieve supported scene modes:" << result; + return QVariantList(); + } + + QVariantList exposureModes; + for (int i = 0; i < supported; ++i) { + switch (modes[i]) { + case CAMERA_SCENE_AUTO: + exposureModes << QVariant::fromValue(QCameraExposure::ExposureAuto); + break; + case CAMERA_SCENE_SPORTS: + exposureModes << QVariant::fromValue(QCameraExposure::ExposureSports); + break; + case CAMERA_SCENE_CLOSEUP: + exposureModes << QVariant::fromValue(QCameraExposure::ExposurePortrait); + break; + case CAMERA_SCENE_ACTION: + exposureModes << QVariant::fromValue(QCameraExposure::ExposureSports); + break; + case CAMERA_SCENE_BEACHANDSNOW: + exposureModes << QVariant::fromValue(QCameraExposure::ExposureBeach) << QVariant::fromValue(QCameraExposure::ExposureSnow); + break; + case CAMERA_SCENE_NIGHT: + exposureModes << QVariant::fromValue(QCameraExposure::ExposureNight); + break; + default: break; + } + } + + return exposureModes; +} + +QVariant BbCameraExposureControl::requestedValue(ExposureParameter parameter) const +{ + if (parameter != QCameraExposureControl::ExposureMode) // no other parameter supported by BB10 API at the moment + return QVariant(); + + return QVariant::fromValue(m_requestedExposureMode); +} + +QVariant BbCameraExposureControl::actualValue(ExposureParameter parameter) const +{ +#ifndef Q_OS_BLACKBERRY_TABLET + if (parameter != QCameraExposureControl::ExposureMode) // no other parameter supported by BB10 API at the moment + return QVariantList(); + + if (m_session->status() != QCamera::ActiveStatus) // we can query actual scene modes only with active viewfinder + return QVariantList(); + + camera_scenemode_t sceneMode = CAMERA_SCENE_DEFAULT; + const camera_error_t result = camera_get_scene_mode(m_session->handle(), &sceneMode); + + if (result != CAMERA_EOK) { + qWarning() << "Unable to retrieve scene mode:" << result; + return QVariant(); + } + + switch (sceneMode) { + case CAMERA_SCENE_AUTO: + return QVariant::fromValue(QCameraExposure::ExposureAuto); + case CAMERA_SCENE_SPORTS: + return QVariant::fromValue(QCameraExposure::ExposureSports); + case CAMERA_SCENE_CLOSEUP: + return QVariant::fromValue(QCameraExposure::ExposurePortrait); + case CAMERA_SCENE_ACTION: + return QVariant::fromValue(QCameraExposure::ExposureSports); + case CAMERA_SCENE_BEACHANDSNOW: + return (m_requestedExposureMode == QCameraExposure::ExposureBeach ? QVariant::fromValue(QCameraExposure::ExposureBeach) + : QVariant::fromValue(QCameraExposure::ExposureSnow)); + case CAMERA_SCENE_NIGHT: + return QVariant::fromValue(QCameraExposure::ExposureNight); + default: + return QVariant(); + } +#else + return QVariant(); +#endif +} + +bool BbCameraExposureControl::setValue(ExposureParameter parameter, const QVariant& value) +{ + if (parameter != QCameraExposureControl::ExposureMode) // no other parameter supported by BB10 API at the moment + return false; + + if (m_session->status() != QCamera::ActiveStatus) // we can set actual scene modes only with active viewfinder + return false; + + camera_scenemode_t sceneMode = CAMERA_SCENE_DEFAULT; + + if (value.isValid()) { + m_requestedExposureMode = value.value(); + emit requestedValueChanged(QCameraExposureControl::ExposureMode); + + switch (m_requestedExposureMode) { + case QCameraExposure::ExposureAuto: + sceneMode = CAMERA_SCENE_AUTO; + break; + case QCameraExposure::ExposureSports: + sceneMode = CAMERA_SCENE_SPORTS; + break; + case QCameraExposure::ExposurePortrait: + sceneMode = CAMERA_SCENE_CLOSEUP; + break; + case QCameraExposure::ExposureBeach: + sceneMode = CAMERA_SCENE_BEACHANDSNOW; + break; + case QCameraExposure::ExposureSnow: + sceneMode = CAMERA_SCENE_BEACHANDSNOW; + break; + case QCameraExposure::ExposureNight: + sceneMode = CAMERA_SCENE_NIGHT; + break; + default: + sceneMode = CAMERA_SCENE_DEFAULT; + break; + } + } + + const camera_error_t result = camera_set_scene_mode(m_session->handle(), sceneMode); + + if (result != CAMERA_EOK) { + qWarning() << "Unable to set scene mode:" << result; + return false; + } + + emit actualValueChanged(QCameraExposureControl::ExposureMode); + + return true; +} + +void BbCameraExposureControl::statusChanged(QCamera::Status status) +{ + if (status == QCamera::ActiveStatus || status == QCamera::LoadedStatus) + emit parameterRangeChanged(QCameraExposureControl::ExposureMode); +} + +QT_END_NAMESPACE diff --git a/src/plugins/qnx/camera/bbcameraexposurecontrol.h b/src/plugins/qnx/camera/bbcameraexposurecontrol.h new file mode 100644 index 000000000..f4659b624 --- /dev/null +++ b/src/plugins/qnx/camera/bbcameraexposurecontrol.h @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Research In Motion +** Contact: http://www.qt-project.org/legal +** +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional +** rights. These rights are described in the Digia 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef BBCAMERAEXPOSURECONTROL_H +#define BBCAMERAEXPOSURECONTROL_H + +#include + +QT_BEGIN_NAMESPACE + +class BbCameraSession; + +class BbCameraExposureControl : public QCameraExposureControl +{ + Q_OBJECT +public: + explicit BbCameraExposureControl(BbCameraSession *session, QObject *parent = 0); + + virtual bool isParameterSupported(ExposureParameter parameter) const Q_DECL_OVERRIDE; + virtual QVariantList supportedParameterRange(ExposureParameter parameter, bool *continuous) const Q_DECL_OVERRIDE; + + virtual QVariant requestedValue(ExposureParameter parameter) const Q_DECL_OVERRIDE; + virtual QVariant actualValue(ExposureParameter parameter) const Q_DECL_OVERRIDE; + virtual bool setValue(ExposureParameter parameter, const QVariant& value) Q_DECL_OVERRIDE; + +private Q_SLOTS: + void statusChanged(QCamera::Status status); + +private: + BbCameraSession *m_session; + QCameraExposure::ExposureMode m_requestedExposureMode; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/qnx/camera/bbcameraflashcontrol.cpp b/src/plugins/qnx/camera/bbcameraflashcontrol.cpp new file mode 100644 index 000000000..06ebe01f6 --- /dev/null +++ b/src/plugins/qnx/camera/bbcameraflashcontrol.cpp @@ -0,0 +1,113 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Research In Motion +** Contact: http://www.qt-project.org/legal +** +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional +** rights. These rights are described in the Digia 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "bbcameraflashcontrol.h" + +#include "bbcamerasession.h" + +#include + +QT_BEGIN_NAMESPACE + +BbCameraFlashControl::BbCameraFlashControl(BbCameraSession *session, QObject *parent) + : QCameraFlashControl(parent) + , m_session(session) + , m_flashMode(QCameraExposure::FlashAuto) +{ +} + +QCameraExposure::FlashModes BbCameraFlashControl::flashMode() const +{ + return m_flashMode; +} + +void BbCameraFlashControl::setFlashMode(QCameraExposure::FlashModes mode) +{ + if (m_flashMode == mode) + return; + + if (m_session->status() != QCamera::ActiveStatus) // can only be changed when viewfinder is active + return; + + if (m_flashMode == QCameraExposure::FlashVideoLight) { + const camera_error_t result = camera_config_videolight(m_session->handle(), CAMERA_VIDEOLIGHT_OFF); + if (result != CAMERA_EOK) + qWarning() << "Unable to switch off video light:" << result; + } + + m_flashMode = mode; + + if (m_flashMode == QCameraExposure::FlashVideoLight) { + const camera_error_t result = camera_config_videolight(m_session->handle(), CAMERA_VIDEOLIGHT_ON); + if (result != CAMERA_EOK) + qWarning() << "Unable to switch on video light:" << result; + } else { + camera_flashmode_t flashMode = CAMERA_FLASH_AUTO; + + if (m_flashMode.testFlag(QCameraExposure::FlashAuto)) flashMode = CAMERA_FLASH_AUTO; + else if (mode.testFlag(QCameraExposure::FlashOff)) flashMode = CAMERA_FLASH_OFF; + else if (mode.testFlag(QCameraExposure::FlashOn)) flashMode = CAMERA_FLASH_ON; + + const camera_error_t result = camera_config_flash(m_session->handle(), flashMode); + if (result != CAMERA_EOK) + qWarning() << "Unable to configure flash:" << result; + } +} + +bool BbCameraFlashControl::isFlashModeSupported(QCameraExposure::FlashModes mode) const +{ + bool supportsVideoLight = false; + if (m_session->handle() != CAMERA_HANDLE_INVALID) { + supportsVideoLight = camera_has_feature(m_session->handle(), CAMERA_FEATURE_VIDEOLIGHT); + } + + return (mode == QCameraExposure::FlashOff || + mode == QCameraExposure::FlashOn || + mode == QCameraExposure::FlashAuto || + ((mode == QCameraExposure::FlashVideoLight) && supportsVideoLight)); +} + +bool BbCameraFlashControl::isFlashReady() const +{ + //TODO: check for flash charge-level here?!? + return true; +} + +QT_END_NAMESPACE diff --git a/src/plugins/qnx/camera/bbcameraflashcontrol.h b/src/plugins/qnx/camera/bbcameraflashcontrol.h new file mode 100644 index 000000000..d46dc8c12 --- /dev/null +++ b/src/plugins/qnx/camera/bbcameraflashcontrol.h @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Research In Motion +** Contact: http://www.qt-project.org/legal +** +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional +** rights. These rights are described in the Digia 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef BBCAMERAFLASHCONTROL_H +#define BBCAMERAFLASHCONTROL_H + +#include + +QT_BEGIN_NAMESPACE + +class BbCameraSession; + +class BbCameraFlashControl : public QCameraFlashControl +{ + Q_OBJECT +public: + explicit BbCameraFlashControl(BbCameraSession *session, QObject *parent = 0); + + QCameraExposure::FlashModes flashMode() const Q_DECL_OVERRIDE; + void setFlashMode(QCameraExposure::FlashModes mode) Q_DECL_OVERRIDE; + bool isFlashModeSupported(QCameraExposure::FlashModes mode) const Q_DECL_OVERRIDE; + bool isFlashReady() const Q_DECL_OVERRIDE; + +private: + BbCameraSession *m_session; + QCameraExposure::FlashModes m_flashMode; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/qnx/camera/bbcamerafocuscontrol.cpp b/src/plugins/qnx/camera/bbcamerafocuscontrol.cpp new file mode 100644 index 000000000..e0b57d6c6 --- /dev/null +++ b/src/plugins/qnx/camera/bbcamerafocuscontrol.cpp @@ -0,0 +1,331 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Research In Motion +** Contact: http://www.qt-project.org/legal +** +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional +** rights. These rights are described in the Digia 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "bbcamerafocuscontrol.h" + +#include "bbcamerasession.h" + +#include + +QT_BEGIN_NAMESPACE + +BbCameraFocusControl::BbCameraFocusControl(BbCameraSession *session, QObject *parent) + : QCameraFocusControl(parent) + , m_session(session) + , m_focusMode(QCameraFocus::FocusModes()) + , m_focusPointMode(QCameraFocus::FocusPointAuto) + , m_customFocusPoint(QPointF(0, 0)) +{ +} + +QCameraFocus::FocusModes BbCameraFocusControl::focusMode() const +{ + camera_focusmode_t focusMode = CAMERA_FOCUSMODE_OFF; + + const camera_error_t result = camera_get_focus_mode(m_session->handle(), &focusMode); + if (result != CAMERA_EOK) { + qWarning() << "Unable to retrieve focus mode from camera:" << result; + return QCameraFocus::FocusModes(); + } + + switch (focusMode) { + case CAMERA_FOCUSMODE_EDOF: + return QCameraFocus::HyperfocalFocus; + case CAMERA_FOCUSMODE_MANUAL: + return QCameraFocus::ManualFocus; + case CAMERA_FOCUSMODE_AUTO: + return QCameraFocus::AutoFocus; + case CAMERA_FOCUSMODE_MACRO: + return QCameraFocus::MacroFocus; + case CAMERA_FOCUSMODE_CONTINUOUS_AUTO: + return QCameraFocus::ContinuousFocus; + case CAMERA_FOCUSMODE_CONTINUOUS_MACRO: // fall through + case CAMERA_FOCUSMODE_OFF: // fall through + default: + return QCameraFocus::FocusModes(); + } +} + +void BbCameraFocusControl::setFocusMode(QCameraFocus::FocusModes mode) +{ + if (m_focusMode == mode) + return; + + camera_focusmode_t focusMode = CAMERA_FOCUSMODE_OFF; + + if (mode == QCameraFocus::HyperfocalFocus) + focusMode = CAMERA_FOCUSMODE_EDOF; + else if (mode == QCameraFocus::ManualFocus) + focusMode = CAMERA_FOCUSMODE_MANUAL; + else if (mode == QCameraFocus::AutoFocus) + focusMode = CAMERA_FOCUSMODE_AUTO; + else if (mode == QCameraFocus::MacroFocus) + focusMode = CAMERA_FOCUSMODE_MACRO; + else if (mode == QCameraFocus::ContinuousFocus) + focusMode = CAMERA_FOCUSMODE_CONTINUOUS_AUTO; + + const camera_error_t result = camera_set_focus_mode(m_session->handle(), focusMode); + + if (result != CAMERA_EOK) { + qWarning() << "Unable to set focus mode:" << result; + return; + } + + m_focusMode = mode; + emit focusModeChanged(m_focusMode); +} + +bool BbCameraFocusControl::isFocusModeSupported(QCameraFocus::FocusModes mode) const +{ + if (m_session->state() == QCamera::UnloadedState) + return false; + + if (mode == QCameraFocus::HyperfocalFocus) + return false; //TODO how to check? + else if (mode == QCameraFocus::ManualFocus) + return camera_has_feature(m_session->handle(), CAMERA_FEATURE_MANUALFOCUS); + else if (mode == QCameraFocus::AutoFocus) + return camera_has_feature(m_session->handle(), CAMERA_FEATURE_AUTOFOCUS); + else if (mode == QCameraFocus::MacroFocus) + return camera_has_feature(m_session->handle(), CAMERA_FEATURE_MACROFOCUS); + else if (mode == QCameraFocus::ContinuousFocus) + return camera_has_feature(m_session->handle(), CAMERA_FEATURE_AUTOFOCUS); + + return false; +} + +QCameraFocus::FocusPointMode BbCameraFocusControl::focusPointMode() const +{ + return m_focusPointMode; +} + +void BbCameraFocusControl::setFocusPointMode(QCameraFocus::FocusPointMode mode) +{ + if (m_session->status() != QCamera::ActiveStatus) + return; + + if (m_focusPointMode == mode) + return; + + m_focusPointMode = mode; + emit focusPointModeChanged(m_focusPointMode); + + if (m_focusPointMode == QCameraFocus::FocusPointAuto) { + //TODO: is this correct? + const camera_error_t result = camera_set_focus_regions(m_session->handle(), 0, 0); + if (result != CAMERA_EOK) { + qWarning() << "Unable to set focus region:" << result; + return; + } + + emit focusZonesChanged(); + } else if (m_focusPointMode == QCameraFocus::FocusPointCenter) { + // get the size of the viewfinder + int viewfinderWidth = 0; + int viewfinderHeight = 0; + + if (!retrieveViewfinderSize(&viewfinderWidth, &viewfinderHeight)) + return; + + // define a 40x40 pixel focus region in the center of the viewfinder + camera_region_t focusRegion; + focusRegion.left = (viewfinderWidth / 2) - 20; + focusRegion.top = (viewfinderHeight / 2) - 20; + focusRegion.width = 40; + focusRegion.height = 40; + + camera_error_t result = camera_set_focus_regions(m_session->handle(), 1, &focusRegion); + if (result != CAMERA_EOK) { + qWarning() << "Unable to set focus region:" << result; + return; + } + + // re-set focus mode to apply focus region changes + camera_focusmode_t focusMode = CAMERA_FOCUSMODE_OFF; + result = camera_get_focus_mode(m_session->handle(), &focusMode); + camera_set_focus_mode(m_session->handle(), focusMode); + + emit focusZonesChanged(); + + } else if (m_focusPointMode == QCameraFocus::FocusPointFaceDetection) { + //TODO: implement later + } else if (m_focusPointMode == QCameraFocus::FocusPointCustom) { + updateCustomFocusRegion(); + } +} + +bool BbCameraFocusControl::isFocusPointModeSupported(QCameraFocus::FocusPointMode mode) const +{ + if (m_session->state() == QCamera::UnloadedState) + return false; + + if (mode == QCameraFocus::FocusPointAuto) { + return camera_has_feature(m_session->handle(), CAMERA_FEATURE_AUTOFOCUS); + } else if (mode == QCameraFocus::FocusPointCenter) { + return camera_has_feature(m_session->handle(), CAMERA_FEATURE_REGIONFOCUS); + } else if (mode == QCameraFocus::FocusPointFaceDetection) { + return false; //TODO: implement via custom region in combination with face detection in viewfinder + } else if (mode == QCameraFocus::FocusPointCustom) { + return camera_has_feature(m_session->handle(), CAMERA_FEATURE_REGIONFOCUS); + } + + return false; +} + +QPointF BbCameraFocusControl::customFocusPoint() const +{ + return m_customFocusPoint; +} + +void BbCameraFocusControl::setCustomFocusPoint(const QPointF &point) +{ + if (m_customFocusPoint == point) + return; + + m_customFocusPoint = point; + emit customFocusPointChanged(m_customFocusPoint); + + updateCustomFocusRegion(); +} + +QCameraFocusZoneList BbCameraFocusControl::focusZones() const +{ + if (m_session->state() == QCamera::UnloadedState) + return QCameraFocusZoneList(); + + camera_region_t regions[20]; + int supported = 0; + int asked = 0; + camera_error_t result = camera_get_focus_regions(m_session->handle(), 20, &supported, &asked, regions); + + if (result != CAMERA_EOK) { + qWarning() << "Unable to retrieve focus regions:" << result; + return QCameraFocusZoneList(); + } + + // retrieve width and height of viewfinder + int viewfinderWidth = 0; + int viewfinderHeight = 0; + if (m_session->captureMode() & QCamera::CaptureStillImage) + result = camera_get_photovf_property(m_session->handle(), + CAMERA_IMGPROP_WIDTH, &viewfinderWidth, + CAMERA_IMGPROP_HEIGHT, &viewfinderHeight); + else if (m_session->captureMode() & QCamera::CaptureVideo) + result = camera_get_videovf_property(m_session->handle(), + CAMERA_IMGPROP_WIDTH, &viewfinderWidth, + CAMERA_IMGPROP_HEIGHT, &viewfinderHeight); + + if (result != CAMERA_EOK) { + qWarning() << "Unable to retrieve viewfinder size:" << result; + return QCameraFocusZoneList(); + } + + QCameraFocusZoneList list; + for (int i = 0; i < asked; ++i) { + const int x = regions[i].left; + const int y = regions[i].top; + const int width = regions[i].width; + const int height = regions[i].height; + + QRectF rect(static_cast(x)/static_cast(viewfinderWidth), + static_cast(y)/static_cast(viewfinderHeight), + static_cast(width)/static_cast(viewfinderWidth), + static_cast(height)/static_cast(viewfinderHeight)); + + list << QCameraFocusZone(rect, QCameraFocusZone::Focused); //TODO: how to know if a zone is unused/selected/focused?!? + } + + return list; +} + +void BbCameraFocusControl::updateCustomFocusRegion() +{ + // get the size of the viewfinder + int viewfinderWidth = 0; + int viewfinderHeight = 0; + + if (!retrieveViewfinderSize(&viewfinderWidth, &viewfinderHeight)) + return; + + // define a 40x40 pixel focus region around the custom focus point + camera_region_t focusRegion; + focusRegion.left = qMax(0, static_cast(m_customFocusPoint.x() * viewfinderWidth) - 20); + focusRegion.top = qMax(0, static_cast(m_customFocusPoint.y() * viewfinderHeight) - 20); + focusRegion.width = 40; + focusRegion.height = 40; + + camera_error_t result = camera_set_focus_regions(m_session->handle(), 1, &focusRegion); + if (result != CAMERA_EOK) { + qWarning() << "Unable to set focus region:" << result; + return; + } + + // re-set focus mode to apply focus region changes + camera_focusmode_t focusMode = CAMERA_FOCUSMODE_OFF; + result = camera_get_focus_mode(m_session->handle(), &focusMode); + camera_set_focus_mode(m_session->handle(), focusMode); + + emit focusZonesChanged(); +} + +bool BbCameraFocusControl::retrieveViewfinderSize(int *width, int *height) +{ + if (!width || !height) + return false; + + camera_error_t result = CAMERA_EOK; + if (m_session->captureMode() & QCamera::CaptureStillImage) + result = camera_get_photovf_property(m_session->handle(), + CAMERA_IMGPROP_WIDTH, width, + CAMERA_IMGPROP_HEIGHT, height); + else if (m_session->captureMode() & QCamera::CaptureVideo) + result = camera_get_videovf_property(m_session->handle(), + CAMERA_IMGPROP_WIDTH, width, + CAMERA_IMGPROP_HEIGHT, height); + + if (result != CAMERA_EOK) { + qWarning() << "Unable to retrieve viewfinder size:" << result; + return false; + } + + return true; +} + +QT_END_NAMESPACE diff --git a/src/plugins/qnx/camera/bbcamerafocuscontrol.h b/src/plugins/qnx/camera/bbcamerafocuscontrol.h new file mode 100644 index 000000000..052c29b4b --- /dev/null +++ b/src/plugins/qnx/camera/bbcamerafocuscontrol.h @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Research In Motion +** Contact: http://www.qt-project.org/legal +** +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional +** rights. These rights are described in the Digia 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef BBCAMERAFOCUSCONTROL_H +#define BBCAMERAFOCUSCONTROL_H + +#include + +QT_BEGIN_NAMESPACE + +class BbCameraSession; + +class BbCameraFocusControl : public QCameraFocusControl +{ + Q_OBJECT +public: + explicit BbCameraFocusControl(BbCameraSession *session, QObject *parent = 0); + + QCameraFocus::FocusModes focusMode() const Q_DECL_OVERRIDE; + void setFocusMode(QCameraFocus::FocusModes mode) Q_DECL_OVERRIDE; + bool isFocusModeSupported(QCameraFocus::FocusModes mode) const Q_DECL_OVERRIDE; + QCameraFocus::FocusPointMode focusPointMode() const Q_DECL_OVERRIDE; + void setFocusPointMode(QCameraFocus::FocusPointMode mode) Q_DECL_OVERRIDE; + bool isFocusPointModeSupported(QCameraFocus::FocusPointMode mode) const Q_DECL_OVERRIDE; + QPointF customFocusPoint() const Q_DECL_OVERRIDE; + void setCustomFocusPoint(const QPointF &point) Q_DECL_OVERRIDE; + QCameraFocusZoneList focusZones() const Q_DECL_OVERRIDE; + +private: + void updateCustomFocusRegion(); + bool retrieveViewfinderSize(int *width, int *height); + + BbCameraSession *m_session; + + QCameraFocus::FocusModes m_focusMode; + QCameraFocus::FocusPointMode m_focusPointMode; + QPointF m_customFocusPoint; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/qnx/camera/bbcameraimagecapturecontrol.cpp b/src/plugins/qnx/camera/bbcameraimagecapturecontrol.cpp new file mode 100644 index 000000000..a2f61f73d --- /dev/null +++ b/src/plugins/qnx/camera/bbcameraimagecapturecontrol.cpp @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Research In Motion +** Contact: http://www.qt-project.org/legal +** +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional +** rights. These rights are described in the Digia 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "bbcameraimagecapturecontrol.h" + +#include "bbcamerasession.h" + +QT_BEGIN_NAMESPACE + +BbCameraImageCaptureControl::BbCameraImageCaptureControl(BbCameraSession *session, QObject *parent) + : QCameraImageCaptureControl(parent) + , m_session(session) +{ + connect(m_session, SIGNAL(readyForCaptureChanged(bool)), this, SIGNAL(readyForCaptureChanged(bool))); + connect(m_session, SIGNAL(imageExposed(int)), this, SIGNAL(imageExposed(int))); + connect(m_session, SIGNAL(imageCaptured(int,QImage)), this, SIGNAL(imageCaptured(int,QImage))); + connect(m_session, SIGNAL(imageMetadataAvailable(int,QString,QVariant)), this, SIGNAL(imageMetadataAvailable(int,QString,QVariant))); + connect(m_session, SIGNAL(imageAvailable(int,QVideoFrame)), this, SIGNAL(imageAvailable(int,QVideoFrame))); + connect(m_session, SIGNAL(imageSaved(int,QString)), this, SIGNAL(imageSaved(int,QString))); + connect(m_session, SIGNAL(imageCaptureError(int,int,QString)), this, SIGNAL(error(int,int,QString))); +} + +bool BbCameraImageCaptureControl::isReadyForCapture() const +{ + return m_session->isReadyForCapture(); +} + +QCameraImageCapture::DriveMode BbCameraImageCaptureControl::driveMode() const +{ + return m_session->driveMode(); +} + +void BbCameraImageCaptureControl::setDriveMode(QCameraImageCapture::DriveMode mode) +{ + m_session->setDriveMode(mode); +} + +int BbCameraImageCaptureControl::capture(const QString &fileName) +{ + return m_session->capture(fileName); +} + +void BbCameraImageCaptureControl::cancelCapture() +{ + m_session->cancelCapture(); +} + +QT_END_NAMESPACE diff --git a/src/plugins/qnx/camera/bbcameraimagecapturecontrol.h b/src/plugins/qnx/camera/bbcameraimagecapturecontrol.h new file mode 100644 index 000000000..a73a4f1d5 --- /dev/null +++ b/src/plugins/qnx/camera/bbcameraimagecapturecontrol.h @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Research In Motion +** Contact: http://www.qt-project.org/legal +** +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional +** rights. These rights are described in the Digia 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef BBCAMERAIMAGECAPTURECONTROL_H +#define BBCAMERAIMAGECAPTURECONTROL_H + +#include + +QT_BEGIN_NAMESPACE + +class BbCameraSession; + +class BbCameraImageCaptureControl : public QCameraImageCaptureControl +{ + Q_OBJECT +public: + explicit BbCameraImageCaptureControl(BbCameraSession *session, QObject *parent = 0); + + bool isReadyForCapture() const Q_DECL_OVERRIDE; + + QCameraImageCapture::DriveMode driveMode() const Q_DECL_OVERRIDE; + void setDriveMode(QCameraImageCapture::DriveMode mode) Q_DECL_OVERRIDE; + + int capture(const QString &fileName) Q_DECL_OVERRIDE; + void cancelCapture() Q_DECL_OVERRIDE; + +private: + BbCameraSession *m_session; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/qnx/camera/bbcameraimageprocessingcontrol.cpp b/src/plugins/qnx/camera/bbcameraimageprocessingcontrol.cpp new file mode 100644 index 000000000..54ae48c6b --- /dev/null +++ b/src/plugins/qnx/camera/bbcameraimageprocessingcontrol.cpp @@ -0,0 +1,146 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Research In Motion +** Contact: http://www.qt-project.org/legal +** +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional +** rights. These rights are described in the Digia 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "bbcameraimageprocessingcontrol.h" + +#include "bbcamerasession.h" + +#include + +QT_BEGIN_NAMESPACE + +BbCameraImageProcessingControl::BbCameraImageProcessingControl(BbCameraSession *session, QObject *parent) + : QCameraImageProcessingControl(parent) + , m_session(session) +{ +} + +bool BbCameraImageProcessingControl::isParameterSupported(ProcessingParameter parameter) const +{ + return (parameter == QCameraImageProcessingControl::WhiteBalancePreset); +} + +bool BbCameraImageProcessingControl::isParameterValueSupported(ProcessingParameter parameter, const QVariant &value) const +{ + if (parameter != QCameraImageProcessingControl::WhiteBalancePreset) + return false; + + if (m_session->handle() == CAMERA_HANDLE_INVALID) + return false; + + int supported = 0; + camera_whitebalancemode_t modes[20]; + const camera_error_t result = camera_get_whitebalance_modes(m_session->handle(), 20, &supported, modes); + + if (result != CAMERA_EOK) { + qWarning() << "Unable to retrieve supported whitebalance modes:" << result; + return false; + } + + QSet supportedModes; + for (int i = 0; i < supported; ++i) { + switch (modes[i]) { + case CAMERA_WHITEBALANCEMODE_AUTO: + supportedModes.insert(QCameraImageProcessing::WhiteBalanceAuto); + break; + case CAMERA_WHITEBALANCEMODE_MANUAL: + supportedModes.insert(QCameraImageProcessing::WhiteBalanceManual); + break; + default: + break; + } + } + + return supportedModes.contains(value.value()); +} + +QVariant BbCameraImageProcessingControl::parameter(ProcessingParameter parameter) const +{ + if (parameter != QCameraImageProcessingControl::WhiteBalancePreset) + return QVariant(); + + if (m_session->handle() == CAMERA_HANDLE_INVALID) + return QVariant(); + + camera_whitebalancemode_t mode; + const camera_error_t result = camera_get_whitebalance_mode(m_session->handle(), &mode); + + if (result != CAMERA_EOK) { + qWarning() << "Unable to retrieve current whitebalance mode:" << result; + return QVariant(); + } + + switch (mode) { + case CAMERA_WHITEBALANCEMODE_AUTO: + return QVariant::fromValue(QCameraImageProcessing::WhiteBalanceAuto); + case CAMERA_WHITEBALANCEMODE_MANUAL: + return QVariant::fromValue(QCameraImageProcessing::WhiteBalanceManual); + default: + return QVariant(); + } +} + +void BbCameraImageProcessingControl::setParameter(ProcessingParameter parameter, const QVariant &value) +{ + if (parameter != QCameraImageProcessingControl::WhiteBalancePreset) + return; + + if (m_session->handle() == CAMERA_HANDLE_INVALID) + return; + + camera_whitebalancemode_t mode = CAMERA_WHITEBALANCEMODE_DEFAULT; + switch (value.value()) { + case QCameraImageProcessing::WhiteBalanceAuto: + mode = CAMERA_WHITEBALANCEMODE_AUTO; + break; + case QCameraImageProcessing::WhiteBalanceManual: + mode = CAMERA_WHITEBALANCEMODE_MANUAL; + break; + default: + break; + } + + const camera_error_t result = camera_set_whitebalance_mode(m_session->handle(), mode); + + if (result != CAMERA_EOK) + qWarning() << "Unable to set whitebalance mode:" << result; +} + +QT_END_NAMESPACE diff --git a/src/plugins/qnx/camera/bbcameraimageprocessingcontrol.h b/src/plugins/qnx/camera/bbcameraimageprocessingcontrol.h new file mode 100644 index 000000000..ec16d66d7 --- /dev/null +++ b/src/plugins/qnx/camera/bbcameraimageprocessingcontrol.h @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Research In Motion +** Contact: http://www.qt-project.org/legal +** +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional +** rights. These rights are described in the Digia 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef BBCAMERAIMAGEPROCESSINGCONTROL_H +#define BBCAMERAIMAGEPROCESSINGCONTROL_H + +#include + +QT_BEGIN_NAMESPACE + +class BbCameraSession; + +class BbCameraImageProcessingControl : public QCameraImageProcessingControl +{ + Q_OBJECT +public: + explicit BbCameraImageProcessingControl(BbCameraSession *session, QObject *parent = 0); + + bool isParameterSupported(ProcessingParameter) const Q_DECL_OVERRIDE; + bool isParameterValueSupported(ProcessingParameter parameter, const QVariant &value) const Q_DECL_OVERRIDE; + QVariant parameter(ProcessingParameter parameter) const Q_DECL_OVERRIDE; + void setParameter(ProcessingParameter parameter, const QVariant &value) Q_DECL_OVERRIDE; + +private: + BbCameraSession *m_session; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/qnx/camera/bbcameralockscontrol.cpp b/src/plugins/qnx/camera/bbcameralockscontrol.cpp new file mode 100644 index 000000000..d2537361c --- /dev/null +++ b/src/plugins/qnx/camera/bbcameralockscontrol.cpp @@ -0,0 +1,258 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Research In Motion +** Contact: http://www.qt-project.org/legal +** +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional +** rights. These rights are described in the Digia 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "bbcameralockscontrol.h" + +#include "bbcamerasession.h" + +QT_BEGIN_NAMESPACE + +BbCameraLocksControl::BbCameraLocksControl(BbCameraSession *session, QObject *parent) + : QCameraLocksControl(parent) + , m_session(session) + , m_locksApplyMode(IndependentMode) + , m_focusLockStatus(QCamera::Unlocked) + , m_exposureLockStatus(QCamera::Unlocked) + , m_whiteBalanceLockStatus(QCamera::Unlocked) + , m_currentLockTypes(QCamera::NoLock) + , m_supportedLockTypes(QCamera::NoLock) +{ + connect(m_session, SIGNAL(cameraOpened()), SLOT(cameraOpened())); + connect(m_session, SIGNAL(focusStatusChanged(int)), SLOT(focusStatusChanged(int))); +} + +QCamera::LockTypes BbCameraLocksControl::supportedLocks() const +{ + return (QCamera::LockFocus | QCamera::LockExposure | QCamera::LockWhiteBalance); +} + +QCamera::LockStatus BbCameraLocksControl::lockStatus(QCamera::LockType lock) const +{ + if (!m_supportedLockTypes.testFlag(lock) || (m_session->handle() == CAMERA_HANDLE_INVALID)) + return QCamera::Locked; + + switch (lock) { + case QCamera::LockExposure: + return m_exposureLockStatus; + case QCamera::LockWhiteBalance: + return m_whiteBalanceLockStatus; + case QCamera::LockFocus: + return m_focusLockStatus; + default: + return QCamera::Locked; + } +} + +void BbCameraLocksControl::searchAndLock(QCamera::LockTypes locks) +{ + if (m_session->handle() == CAMERA_HANDLE_INVALID) + return; + + // filter out unsupported locks + locks &= m_supportedLockTypes; + + m_currentLockTypes |= locks; + + uint32_t lockModes = CAMERA_3A_NONE; + + switch (m_locksApplyMode) { + case IndependentMode: + if (m_currentLockTypes & QCamera::LockExposure) + lockModes |= CAMERA_3A_AUTOEXPOSURE; + if (m_currentLockTypes & QCamera::LockWhiteBalance) + lockModes |= CAMERA_3A_AUTOWHITEBALANCE; + if (m_currentLockTypes & QCamera::LockFocus) + lockModes |= CAMERA_3A_AUTOFOCUS; + break; + case FocusExposureBoundMode: + if ((m_currentLockTypes & QCamera::LockExposure) || (m_currentLockTypes & QCamera::LockFocus)) + lockModes = (CAMERA_3A_AUTOEXPOSURE | CAMERA_3A_AUTOFOCUS); + break; + case AllBoundMode: + lockModes = (CAMERA_3A_AUTOEXPOSURE | CAMERA_3A_AUTOFOCUS | CAMERA_3A_AUTOWHITEBALANCE); + break; + case FocusOnlyMode: + lockModes = CAMERA_3A_AUTOFOCUS; + break; + } + + const camera_error_t result = camera_set_3a_lock(m_session->handle(), lockModes); + + if (result != CAMERA_EOK) { + qWarning() << "Unable to set lock modes:" << result; + } else { + if (lockModes & CAMERA_3A_AUTOFOCUS) { + // handled by focusStatusChanged() + } + + if (lockModes & CAMERA_3A_AUTOEXPOSURE) { + m_exposureLockStatus = QCamera::Locked; + emit lockStatusChanged(QCamera::LockExposure, QCamera::Locked, QCamera::LockAcquired); + } + + if (lockModes & CAMERA_3A_AUTOWHITEBALANCE) { + m_whiteBalanceLockStatus = QCamera::Locked; + emit lockStatusChanged(QCamera::LockWhiteBalance, QCamera::Locked, QCamera::LockAcquired); + } + } +} + +void BbCameraLocksControl::unlock(QCamera::LockTypes locks) +{ + // filter out unsupported locks + locks &= m_supportedLockTypes; + + m_currentLockTypes &= ~locks; + + uint32_t lockModes = CAMERA_3A_NONE; + + switch (m_locksApplyMode) { + case IndependentMode: + if (m_currentLockTypes & QCamera::LockExposure) + lockModes |= CAMERA_3A_AUTOEXPOSURE; + if (m_currentLockTypes & QCamera::LockWhiteBalance) + lockModes |= CAMERA_3A_AUTOWHITEBALANCE; + if (m_currentLockTypes & QCamera::LockFocus) + lockModes |= CAMERA_3A_AUTOFOCUS; + break; + case FocusExposureBoundMode: + if ((m_currentLockTypes & QCamera::LockExposure) || (m_currentLockTypes & QCamera::LockFocus)) + lockModes = (CAMERA_3A_AUTOEXPOSURE | CAMERA_3A_AUTOFOCUS); + break; + case AllBoundMode: + lockModes = (CAMERA_3A_AUTOEXPOSURE | CAMERA_3A_AUTOFOCUS | CAMERA_3A_AUTOWHITEBALANCE); + break; + case FocusOnlyMode: + lockModes = CAMERA_3A_AUTOFOCUS; + break; + } + + const camera_error_t result = camera_set_3a_lock(m_session->handle(), lockModes); + + if (result != CAMERA_EOK) { + qWarning() << "Unable to set lock modes:" << result; + } else { + if (locks.testFlag(QCamera::LockFocus)) { + // handled by focusStatusChanged() + } + + if (locks.testFlag(QCamera::LockExposure)) { + m_exposureLockStatus = QCamera::Unlocked; + emit lockStatusChanged(QCamera::LockExposure, QCamera::Unlocked, QCamera::UserRequest); + } + + if (locks.testFlag(QCamera::LockWhiteBalance)) { + m_whiteBalanceLockStatus = QCamera::Unlocked; + emit lockStatusChanged(QCamera::LockWhiteBalance, QCamera::Unlocked, QCamera::UserRequest); + } + } +} + +void BbCameraLocksControl::cameraOpened() +{ + // retrieve information about lock apply modes + int supported = 0; + uint32_t modes[20]; + + const camera_error_t result = camera_get_3a_lock_modes(m_session->handle(), 20, &supported, modes); + + if (result == CAMERA_EOK) { + // see API documentation of camera_get_3a_lock_modes for explanation of case discrimination below + if (supported == 4) { + m_locksApplyMode = IndependentMode; + } else if (supported == 3) { + m_locksApplyMode = FocusExposureBoundMode; + } else if (supported == 2) { + if (modes[0] == (CAMERA_3A_AUTOFOCUS | CAMERA_3A_AUTOEXPOSURE | CAMERA_3A_AUTOWHITEBALANCE)) + m_locksApplyMode = AllBoundMode; + else + m_locksApplyMode = FocusOnlyMode; + } + } + + // retrieve information about supported lock types + m_supportedLockTypes = QCamera::NoLock; + + if (camera_has_feature(m_session->handle(), CAMERA_FEATURE_AUTOFOCUS)) + m_supportedLockTypes |= QCamera::LockFocus; + + if (camera_has_feature(m_session->handle(), CAMERA_FEATURE_AUTOEXPOSURE)) + m_supportedLockTypes |= QCamera::LockExposure; + + if (camera_has_feature(m_session->handle(), CAMERA_FEATURE_AUTOWHITEBALANCE)) + m_supportedLockTypes |= QCamera::LockWhiteBalance; + + m_focusLockStatus = QCamera::Unlocked; + m_exposureLockStatus = QCamera::Unlocked; + m_whiteBalanceLockStatus = QCamera::Unlocked; +} + +void BbCameraLocksControl::focusStatusChanged(int value) +{ + const camera_focusstate_t focusState = static_cast(value); + + switch (focusState) { + case CAMERA_FOCUSSTATE_NONE: + m_focusLockStatus = QCamera::Unlocked; + emit lockStatusChanged(QCamera::LockFocus, QCamera::Unlocked, QCamera::UserRequest); + break; + case CAMERA_FOCUSSTATE_WAITING: + case CAMERA_FOCUSSTATE_SEARCHING: + m_focusLockStatus = QCamera::Searching; + emit lockStatusChanged(QCamera::LockFocus, QCamera::Searching, QCamera::UserRequest); + break; + case CAMERA_FOCUSSTATE_FAILED: + m_focusLockStatus = QCamera::Unlocked; + emit lockStatusChanged(QCamera::LockFocus, QCamera::Unlocked, QCamera::LockFailed); + break; + case CAMERA_FOCUSSTATE_LOCKED: + m_focusLockStatus = QCamera::Locked; + emit lockStatusChanged(QCamera::LockFocus, QCamera::Locked, QCamera::LockAcquired); + break; + case CAMERA_FOCUSSTATE_SCENECHANGE: + m_focusLockStatus = QCamera::Unlocked; + emit lockStatusChanged(QCamera::LockFocus, QCamera::Unlocked, QCamera::LockTemporaryLost); + break; + default: + break; + } +} + +QT_END_NAMESPACE diff --git a/src/plugins/qnx/camera/bbcameralockscontrol.h b/src/plugins/qnx/camera/bbcameralockscontrol.h new file mode 100644 index 000000000..8257abdbc --- /dev/null +++ b/src/plugins/qnx/camera/bbcameralockscontrol.h @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Research In Motion +** Contact: http://www.qt-project.org/legal +** +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional +** rights. These rights are described in the Digia 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef BBCAMERALOCKSCONTROL_H +#define BBCAMERALOCKSCONTROL_H + +#include + +QT_BEGIN_NAMESPACE + +class BbCameraSession; + +class BbCameraLocksControl : public QCameraLocksControl +{ + Q_OBJECT +public: + enum LocksApplyMode + { + IndependentMode, + FocusExposureBoundMode, + AllBoundMode, + FocusOnlyMode + }; + + explicit BbCameraLocksControl(BbCameraSession *session, QObject *parent = 0); + + QCamera::LockTypes supportedLocks() const Q_DECL_OVERRIDE; + QCamera::LockStatus lockStatus(QCamera::LockType lock) const Q_DECL_OVERRIDE; + void searchAndLock(QCamera::LockTypes locks) Q_DECL_OVERRIDE; + void unlock(QCamera::LockTypes locks) Q_DECL_OVERRIDE; + +private Q_SLOTS: + void cameraOpened(); + void focusStatusChanged(int value); + +private: + BbCameraSession *m_session; + + LocksApplyMode m_locksApplyMode; + QCamera::LockStatus m_focusLockStatus; + QCamera::LockStatus m_exposureLockStatus; + QCamera::LockStatus m_whiteBalanceLockStatus; + QCamera::LockTypes m_currentLockTypes; + QCamera::LockTypes m_supportedLockTypes; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/qnx/camera/bbcameramediarecordercontrol.cpp b/src/plugins/qnx/camera/bbcameramediarecordercontrol.cpp new file mode 100644 index 000000000..44c19fb46 --- /dev/null +++ b/src/plugins/qnx/camera/bbcameramediarecordercontrol.cpp @@ -0,0 +1,169 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Research In Motion +** Contact: http://www.qt-project.org/legal +** +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/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 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, Digia gives you certain additional +** rights. These rights are described in the Digia 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "bbcameramediarecordercontrol.h" + +#include "bbcamerasession.h" + +#include +#include + +#ifndef Q_OS_BLACKBERRY_TABLET +#include