Blackberry: implement QCameraInfoControl.
authorYoann Lopes <yoann.lopes@digia.com>
Tue, 4 Feb 2014 13:59:44 +0000 (14:59 +0100)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Thu, 27 Mar 2014 15:43:51 +0000 (16:43 +0100)
We also now correctly report the default camera to be the rear camera.

Change-Id: Ie96b2950344194637c8feace77246f036c9a3757
Reviewed-by: Fabian Bumberger <fbumberger@rim.com>
src/plugins/qnx/bbserviceplugin.cpp
src/plugins/qnx/bbserviceplugin.h
src/plugins/qnx/camera/bbcamerainfocontrol.cpp [new file with mode: 0644]
src/plugins/qnx/camera/bbcamerainfocontrol.h [new file with mode: 0644]
src/plugins/qnx/camera/bbcameraservice.cpp
src/plugins/qnx/camera/bbcameraservice.h
src/plugins/qnx/camera/bbvideodeviceselectorcontrol.cpp
src/plugins/qnx/camera/bbvideodeviceselectorcontrol.h
src/plugins/qnx/camera/camera.pri

index 2351e57..a0eade6 100644 (file)
@@ -40,7 +40,9 @@
 ****************************************************************************/
 #include "bbserviceplugin.h"
 
+#include "bbcamerainfocontrol.h"
 #include "bbcameraservice.h"
+#include "bbcamerasession.h"
 #include "bbvideodeviceselectorcontrol.h"
 #include "mmrenderermediaplayerservice.h"
 
@@ -120,8 +122,20 @@ void BbServicePlugin::updateDevices() const
     if (m_cameraDevices.isEmpty()) {
         qWarning() << "No camera devices found";
     } else {
-        m_defaultCameraDevice = m_cameraDevices.first();
+        m_defaultCameraDevice = m_cameraDevices.contains(BbCameraSession::cameraIdentifierRear())
+                                ? BbCameraSession::cameraIdentifierRear()
+                                : m_cameraDevices.first();
     }
 }
 
+QCamera::Position BbServicePlugin::cameraPosition(const QByteArray &device) const
+{
+    return BbCameraInfoControl::position(device);
+}
+
+int BbServicePlugin::cameraOrientation(const QByteArray &device) const
+{
+    return BbCameraInfoControl::orientation(device);
+}
+
 QT_END_NAMESPACE
index 45ea4cc..f6a20b8 100644 (file)
@@ -49,11 +49,13 @@ class BbServicePlugin
     : public QMediaServiceProviderPlugin,
       public QMediaServiceSupportedDevicesInterface,
       public QMediaServiceDefaultDeviceInterface,
+      public QMediaServiceCameraInfoInterface,
       public QMediaServiceFeaturesInterface
 {
     Q_OBJECT
     Q_INTERFACES(QMediaServiceSupportedDevicesInterface)
     Q_INTERFACES(QMediaServiceDefaultDeviceInterface)
+    Q_INTERFACES(QMediaServiceCameraInfoInterface)
     Q_INTERFACES(QMediaServiceFeaturesInterface)
     Q_PLUGIN_METADATA(IID "org.qt-project.qt.mediaserviceproviderfactory/5.0" FILE "blackberry_mediaservice.json")
 public:
@@ -68,6 +70,9 @@ public:
     QString deviceDescription(const QByteArray &service, const QByteArray &device) Q_DECL_OVERRIDE;
     QVariant deviceProperty(const QByteArray &service, const QByteArray &device, const QByteArray &property) Q_DECL_OVERRIDE;
 
+    QCamera::Position cameraPosition(const QByteArray &device) const Q_DECL_OVERRIDE;
+    int cameraOrientation(const QByteArray &device) const Q_DECL_OVERRIDE;
+
 private:
     void updateDevices() const;
 
diff --git a/src/plugins/qnx/camera/bbcamerainfocontrol.cpp b/src/plugins/qnx/camera/bbcamerainfocontrol.cpp
new file mode 100644 (file)
index 0000000..366495d
--- /dev/null
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** 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 "bbcamerainfocontrol.h"
+
+#include "bbcamerasession.h"
+
+QT_BEGIN_NAMESPACE
+
+BbCameraInfoControl::BbCameraInfoControl(QObject *parent)
+    : QCameraInfoControl(parent)
+{
+}
+
+QCamera::Position BbCameraInfoControl::position(const QString &deviceName)
+{
+    if (deviceName == QString::fromUtf8(BbCameraSession::cameraIdentifierFront()))
+        return QCamera::FrontFace;
+    else if (deviceName == QString::fromUtf8(BbCameraSession::cameraIdentifierRear()))
+        return QCamera::BackFace;
+    else
+        return QCamera::UnspecifiedPosition;
+}
+
+int BbCameraInfoControl::orientation(const QString &deviceName)
+{
+    // The camera sensor orientation could be retrieved with camera_get_native_orientation()
+    // but since the sensor angular offset is compensated with camera_set_videovf_property() and
+    // camera_set_photovf_property() we should always return 0 here.
+    Q_UNUSED(deviceName);
+    return 0;
+}
+
+QCamera::Position BbCameraInfoControl::cameraPosition(const QString &deviceName) const
+{
+    return position(deviceName);
+}
+
+int BbCameraInfoControl::cameraOrientation(const QString &deviceName) const
+{
+    return orientation(deviceName);
+}
+
+QT_END_NAMESPACE
+
diff --git a/src/plugins/qnx/camera/bbcamerainfocontrol.h b/src/plugins/qnx/camera/bbcamerainfocontrol.h
new file mode 100644 (file)
index 0000000..a083bbf
--- /dev/null
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** 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 BBCAMERAINFOCONTROL_H
+#define BBCAMERAINFOCONTROL_H
+
+#include <qcamerainfocontrol.h>
+
+QT_BEGIN_NAMESPACE
+
+class BbCameraInfoControl : public QCameraInfoControl
+{
+    Q_OBJECT
+public:
+    explicit BbCameraInfoControl(QObject *parent = 0);
+
+    QCamera::Position cameraPosition(const QString &deviceName) const;
+    int cameraOrientation(const QString &deviceName) const;
+
+    static QCamera::Position position(const QString &deviceName);
+    static int orientation(const QString &deviceName);
+};
+
+QT_END_NAMESPACE
+
+#endif // BBCAMERAINFOCONTROL_H
+
index d9adc7c..98feee5 100644 (file)
@@ -49,6 +49,7 @@
 #include "bbcamerafocuscontrol.h"
 #include "bbcameraimagecapturecontrol.h"
 #include "bbcameraimageprocessingcontrol.h"
+#include "bbcamerainfocontrol.h"
 #include "bbcameralockscontrol.h"
 #include "bbcameramediarecordercontrol.h"
 #include "bbcamerasession.h"
@@ -76,6 +77,7 @@ BbCameraService::BbCameraService(QObject *parent)
     , m_cameraFocusControl(new BbCameraFocusControl(m_cameraSession, this))
     , m_cameraImageCaptureControl(new BbCameraImageCaptureControl(m_cameraSession, this))
     , m_cameraImageProcessingControl(new BbCameraImageProcessingControl(m_cameraSession, this))
+    , m_cameraInfoControl(new BbCameraInfoControl(this))
     , m_cameraLocksControl(new BbCameraLocksControl(m_cameraSession, this))
     , m_cameraMediaRecorderControl(new BbCameraMediaRecorderControl(m_cameraSession, this))
     , m_cameraVideoEncoderSettingsControl(new BbCameraVideoEncoderSettingsControl(m_cameraSession, this))
@@ -101,6 +103,8 @@ QMediaControl* BbCameraService::requestControl(const char *name)
         return m_cameraCaptureDestinationControl;
     else if (qstrcmp(name, QCameraControl_iid) == 0)
         return m_cameraControl;
+    else if (qstrcmp(name, QCameraInfoControl_iid) == 0)
+        return m_cameraInfoControl;
     else if (qstrcmp(name, QCameraExposureControl_iid) == 0)
         return m_cameraExposureControl;
     else if (qstrcmp(name, QCameraFlashControl_iid) == 0)
index 374d03c..f87dd0a 100644 (file)
@@ -56,6 +56,7 @@ class BbCameraFlashControl;
 class BbCameraFocusControl;
 class BbCameraImageCaptureControl;
 class BbCameraImageProcessingControl;
+class BbCameraInfoControl;
 class BbCameraLocksControl;
 class BbCameraMediaRecorderControl;
 class BbCameraSession;
@@ -89,6 +90,7 @@ private:
     BbCameraFocusControl* m_cameraFocusControl;
     BbCameraImageCaptureControl* m_cameraImageCaptureControl;
     BbCameraImageProcessingControl* m_cameraImageProcessingControl;
+    BbCameraInfoControl* m_cameraInfoControl;
     BbCameraLocksControl* m_cameraLocksControl;
     BbCameraMediaRecorderControl* m_cameraMediaRecorderControl;
     BbCameraVideoEncoderSettingsControl* m_cameraVideoEncoderSettingsControl;
index 6a6e9d3..f0221e1 100644 (file)
@@ -49,6 +49,7 @@ QT_BEGIN_NAMESPACE
 BbVideoDeviceSelectorControl::BbVideoDeviceSelectorControl(BbCameraSession *session, QObject *parent)
     : QVideoDeviceSelectorControl(parent)
     , m_session(session)
+    , m_default(0)
     , m_selected(0)
 {
     enumerateDevices(&m_devices, &m_descriptions);
@@ -56,7 +57,7 @@ BbVideoDeviceSelectorControl::BbVideoDeviceSelectorControl(BbCameraSession *sess
     // pre-select the rear camera
     const int index = m_devices.indexOf(BbCameraSession::cameraIdentifierRear());
     if (index != -1)
-        m_selected = index;
+        m_default = m_selected = index;
 }
 
 int BbVideoDeviceSelectorControl::deviceCount() const
@@ -82,7 +83,7 @@ QString BbVideoDeviceSelectorControl::deviceDescription(int index) const
 
 int BbVideoDeviceSelectorControl::defaultDevice() const
 {
-    return 0;
+    return m_default;
 }
 
 int BbVideoDeviceSelectorControl::selectedDevice() const
index 1987f54..2439615 100644 (file)
@@ -71,6 +71,7 @@ private:
     QList<QByteArray> m_devices;
     QStringList m_descriptions;
 
+    int m_default;
     int m_selected;
 };
 
index 6665573..7e5fbeb 100644 (file)
@@ -10,6 +10,7 @@ HEADERS += \
     $$PWD/bbcamerafocuscontrol.h \
     $$PWD/bbcameraimagecapturecontrol.h \
     $$PWD/bbcameraimageprocessingcontrol.h \
+    $$PWD/bbcamerainfocontrol.h \
     $$PWD/bbcameralockscontrol.h \
     $$PWD/bbcameramediarecordercontrol.h \
     $$PWD/bbcameraorientationhandler.h \
@@ -33,6 +34,7 @@ SOURCES += \
     $$PWD/bbcamerafocuscontrol.cpp \
     $$PWD/bbcameraimagecapturecontrol.cpp \
     $$PWD/bbcameraimageprocessingcontrol.cpp \
+    $$PWD/bbcamerainfocontrol.cpp \
     $$PWD/bbcameralockscontrol.cpp \
     $$PWD/bbcameramediarecordercontrol.cpp \
     $$PWD/bbcameraorientationhandler.cpp \