Merge remote-tracking branch 'origin/stable' into dev

Change-Id: Ifee8e5713e95d516081c4bc911e8f0bb6a169b13
This commit is contained in:
Frederik Gladhorn
2013-03-14 09:25:28 +01:00
17 changed files with 370 additions and 218 deletions

View File

@@ -65,13 +65,15 @@ have_gst_photography {
$$PWD/camerabinfocus.h \
$$PWD/camerabinexposure.h \
$$PWD/camerabinflash.h \
$$PWD/camerabinlocks.h
$$PWD/camerabinlocks.h \
$$PWD/camerabinzoom.h
SOURCES += \
$$PWD/camerabinexposure.cpp \
$$PWD/camerabinflash.cpp \
$$PWD/camerabinfocus.cpp \
$$PWD/camerabinlocks.cpp
$$PWD/camerabinlocks.cpp \
$$PWD/camerabinzoom.cpp
LIBS += -lgstphotography-0.10
DEFINES += GST_USE_UNSTABLE_API #prevents warnings because of unstable photography API

View File

@@ -57,69 +57,6 @@ CameraBinExposure::~CameraBinExposure()
{
}
QCameraExposure::ExposureMode CameraBinExposure::exposureMode() const
{
GstSceneMode sceneMode;
gst_photography_get_scene_mode(m_session->photography(), &sceneMode);
switch (sceneMode) {
case GST_PHOTOGRAPHY_SCENE_MODE_PORTRAIT: return QCameraExposure::ExposurePortrait;
case GST_PHOTOGRAPHY_SCENE_MODE_SPORT: return QCameraExposure::ExposureSports;
case GST_PHOTOGRAPHY_SCENE_MODE_NIGHT: return QCameraExposure::ExposureNight;
case GST_PHOTOGRAPHY_SCENE_MODE_MANUAL: return QCameraExposure::ExposureManual;
case GST_PHOTOGRAPHY_SCENE_MODE_CLOSEUP: //no direct mapping available so mapping to auto mode
case GST_PHOTOGRAPHY_SCENE_MODE_LANDSCAPE: //no direct mapping available so mapping to auto mode
case GST_PHOTOGRAPHY_SCENE_MODE_AUTO:
default:
return QCameraExposure::ExposureAuto;
}
}
void CameraBinExposure::setExposureMode(QCameraExposure::ExposureMode mode)
{
GstSceneMode sceneMode;
gst_photography_get_scene_mode(m_session->photography(), &sceneMode);
switch (mode) {
case QCameraExposure::ExposureManual: sceneMode = GST_PHOTOGRAPHY_SCENE_MODE_MANUAL; break;
case QCameraExposure::ExposurePortrait: sceneMode = GST_PHOTOGRAPHY_SCENE_MODE_PORTRAIT; break;
case QCameraExposure::ExposureSports: sceneMode = GST_PHOTOGRAPHY_SCENE_MODE_SPORT; break;
case QCameraExposure::ExposureNight: sceneMode = GST_PHOTOGRAPHY_SCENE_MODE_NIGHT; break;
case QCameraExposure::ExposureAuto: sceneMode = GST_PHOTOGRAPHY_SCENE_MODE_AUTO; break;
default:
break;
}
gst_photography_set_scene_mode(m_session->photography(), sceneMode);
}
bool CameraBinExposure::isExposureModeSupported(QCameraExposure::ExposureMode mode) const
{
//Similar mode names can be found in gst as GstSceneMode
return mode == QCameraExposure::ExposureAuto ||
mode == QCameraExposure::ExposurePortrait ||
mode == QCameraExposure::ExposureSports ||
mode == QCameraExposure::ExposureNight;
//No direct mapping available for GST_PHOTOGRAPHY_SCENE_MODE_CLOSEUP and
//GST_PHOTOGRAPHY_SCENE_MODE_LANDSCAPE
}
QCameraExposure::MeteringMode CameraBinExposure::meteringMode() const
{
return QCameraExposure::MeteringMatrix;
}
void CameraBinExposure::setMeteringMode(QCameraExposure::MeteringMode mode)
{
Q_UNUSED(mode);
}
bool CameraBinExposure::isMeteringModeSupported(QCameraExposure::MeteringMode mode) const
{
return mode == QCameraExposure::MeteringMatrix;
}
bool CameraBinExposure::isParameterSupported(ExposureParameter parameter) const
{
switch (parameter) {
@@ -133,58 +70,17 @@ bool CameraBinExposure::isParameterSupported(ExposureParameter parameter) const
}
}
QVariant CameraBinExposure::exposureParameter(ExposureParameter parameter) const
QVariantList CameraBinExposure::supportedParameterRange(ExposureParameter parameter,
bool *continuous) const
{
switch (parameter) {
case QCameraExposureControl::ExposureCompensation:
{
gfloat ev;
gst_photography_get_ev_compensation(m_session->photography(), &ev);
return QVariant(ev);
}
case QCameraExposureControl::ISO:
{
guint isoSpeed = 0;
gst_photography_get_iso_speed(m_session->photography(), &isoSpeed);
return QVariant(isoSpeed);
}
case QCameraExposureControl::Aperture:
return QVariant(2.8);
case QCameraExposureControl::ShutterSpeed:
{
guint32 shutterSpeed = 0;
gst_photography_get_exposure(m_session->photography(), &shutterSpeed);
if (continuous)
*continuous = false;
return QVariant(shutterSpeed/1000000.0);
}
default:
return QVariant();
}
}
QCameraExposureControl::ParameterFlags CameraBinExposure::exposureParameterFlags(ExposureParameter parameter) const
{
QCameraExposureControl::ParameterFlags flags = 0;
switch (parameter) {
case QCameraExposureControl::ExposureCompensation:
flags |= ContinuousRange;
break;
case QCameraExposureControl::Aperture:
flags |= ReadOnly;
break;
default:
break;
}
return flags;
}
QVariantList CameraBinExposure::supportedParameterRange(ExposureParameter parameter) const
{
QVariantList res;
switch (parameter) {
case QCameraExposureControl::ExposureCompensation:
if (continuous)
*continuous = true;
res << -2.0 << 2.0;
break;
case QCameraExposureControl::ISO:
@@ -200,9 +96,68 @@ QVariantList CameraBinExposure::supportedParameterRange(ExposureParameter parame
return res;
}
bool CameraBinExposure::setExposureParameter(ExposureParameter parameter, const QVariant& value)
QVariant CameraBinExposure::requestedValue(ExposureParameter parameter) const
{
QVariant oldValue = exposureParameter(parameter);
return m_requestedValues.value(parameter);
}
QVariant CameraBinExposure::actualValue(ExposureParameter parameter) const
{
switch (parameter) {
case QCameraExposureControl::ExposureCompensation:
{
gfloat ev;
gst_photography_get_ev_compensation(m_session->photography(), &ev);
return QVariant(ev);
}
case QCameraExposureControl::ISO:
{
guint isoSpeed = 0;
gst_photography_get_iso_speed(m_session->photography(), &isoSpeed);
return QVariant(isoSpeed);
}
case QCameraExposureControl::Aperture:
return QVariant(2.8);
case QCameraExposureControl::ShutterSpeed:
{
guint32 shutterSpeed = 0;
gst_photography_get_exposure(m_session->photography(), &shutterSpeed);
return QVariant(shutterSpeed/1000000.0);
}
case QCameraExposureControl::ExposureMode:
{
GstSceneMode sceneMode;
gst_photography_get_scene_mode(m_session->photography(), &sceneMode);
switch (sceneMode) {
case GST_PHOTOGRAPHY_SCENE_MODE_PORTRAIT:
return QCameraExposure::ExposurePortrait;
case GST_PHOTOGRAPHY_SCENE_MODE_SPORT:
return QCameraExposure::ExposureSports;
case GST_PHOTOGRAPHY_SCENE_MODE_NIGHT:
return QCameraExposure::ExposureNight;
case GST_PHOTOGRAPHY_SCENE_MODE_MANUAL:
return QCameraExposure::ExposureManual;
case GST_PHOTOGRAPHY_SCENE_MODE_CLOSEUP:
//no direct mapping available so mapping to auto mode
case GST_PHOTOGRAPHY_SCENE_MODE_LANDSCAPE:
//no direct mapping available so mapping to auto mode
case GST_PHOTOGRAPHY_SCENE_MODE_AUTO:
default:
return QCameraExposure::ExposureAuto;
}
}
case QCameraExposureControl::MeteringMode:
return QCameraExposure::MeteringMatrix;
default:
return QVariant();
}
}
bool CameraBinExposure::setValue(ExposureParameter parameter, const QVariant& value)
{
QVariant oldValue = actualValue(parameter);
switch (parameter) {
case QCameraExposureControl::ExposureCompensation:
@@ -217,20 +172,49 @@ bool CameraBinExposure::setExposureParameter(ExposureParameter parameter, const
case QCameraExposureControl::ShutterSpeed:
gst_photography_set_exposure(m_session->photography(), guint(value.toReal()*1000000));
break;
case QCameraExposureControl::ExposureMode:
{
QCameraExposure::ExposureMode mode = QCameraExposure::ExposureMode(value.toInt());
GstSceneMode sceneMode;
gst_photography_get_scene_mode(m_session->photography(), &sceneMode);
switch (mode) {
case QCameraExposure::ExposureManual:
sceneMode = GST_PHOTOGRAPHY_SCENE_MODE_MANUAL;
break;
case QCameraExposure::ExposurePortrait:
sceneMode = GST_PHOTOGRAPHY_SCENE_MODE_PORTRAIT;
break;
case QCameraExposure::ExposureSports:
sceneMode = GST_PHOTOGRAPHY_SCENE_MODE_SPORT;
break;
case QCameraExposure::ExposureNight:
sceneMode = GST_PHOTOGRAPHY_SCENE_MODE_NIGHT;
break;
case QCameraExposure::ExposureAuto:
sceneMode = GST_PHOTOGRAPHY_SCENE_MODE_AUTO;
break;
default:
break;
}
gst_photography_set_scene_mode(m_session->photography(), sceneMode);
break;
}
default:
return false;
}
QVariant newValue = exposureParameter(parameter);
if (!qFuzzyCompare(m_requestedValues.value(parameter).toReal(), value.toReal())) {
m_requestedValues[parameter] = value;
emit requestedValueChanged(parameter);
}
QVariant newValue = actualValue(parameter);
if (!qFuzzyCompare(oldValue.toReal(), newValue.toReal()))
emit exposureParameterChanged(parameter);
emit actualValueChanged(parameter);
return true;
}
QString CameraBinExposure::extendedParameterName(ExposureParameter)
{
return QString();
}
QT_END_NAMESPACE

View File

@@ -60,24 +60,16 @@ public:
CameraBinExposure(CameraBinSession *session);
virtual ~CameraBinExposure();
QCameraExposure::ExposureMode exposureMode() const;
void setExposureMode(QCameraExposure::ExposureMode mode);
bool isExposureModeSupported(QCameraExposure::ExposureMode mode) const;
QCameraExposure::MeteringMode meteringMode() const;
void setMeteringMode(QCameraExposure::MeteringMode mode);
bool isMeteringModeSupported(QCameraExposure::MeteringMode mode) const;
bool isParameterSupported(ExposureParameter parameter) const;
QVariant exposureParameter(ExposureParameter parameter) const;
ParameterFlags exposureParameterFlags(ExposureParameter parameter) const;
QVariantList supportedParameterRange(ExposureParameter parameter) const;
bool setExposureParameter(ExposureParameter parameter, const QVariant& value);
QVariantList supportedParameterRange(ExposureParameter parameter, bool *continuous) const;
QString extendedParameterName(ExposureParameter parameter);
QVariant requestedValue(ExposureParameter parameter) const;
QVariant actualValue(ExposureParameter parameter) const;
bool setValue(ExposureParameter parameter, const QVariant& value);
private:
CameraBinSession *m_session;
CameraBinSession *m_session;
QHash<ExposureParameter, QVariant> m_requestedValues;
};
QT_END_NAMESPACE

View File

@@ -48,8 +48,6 @@
#include <QtCore/qmetaobject.h>
//#define CAMERABIN_DEBUG 1
#define ZOOM_PROPERTY "zoom"
#define MAX_ZOOM_PROPERTY "max-zoom"
QT_BEGIN_NAMESPACE
@@ -68,55 +66,23 @@ CameraBinFocus::~CameraBinFocus()
{
}
QCameraFocus::FocusMode CameraBinFocus::focusMode() const
QCameraFocus::FocusModes CameraBinFocus::focusMode() const
{
return m_focusMode;
}
void CameraBinFocus::setFocusMode(QCameraFocus::FocusMode mode)
void CameraBinFocus::setFocusMode(QCameraFocus::FocusModes mode)
{
if (isFocusModeSupported(mode)) {
m_focusMode = mode;
}
}
bool CameraBinFocus::isFocusModeSupported(QCameraFocus::FocusMode mode) const
bool CameraBinFocus::isFocusModeSupported(QCameraFocus::FocusModes mode) const
{
return mode & QCameraFocus::AutoFocus;
}
qreal CameraBinFocus::maximumOpticalZoom() const
{
return 1.0;
}
qreal CameraBinFocus::maximumDigitalZoom() const
{
gfloat zoomFactor = 1.0;
g_object_get(GST_BIN(m_session->cameraBin()), MAX_ZOOM_PROPERTY, &zoomFactor, NULL);
return zoomFactor;
}
qreal CameraBinFocus::opticalZoom() const
{
return 1.0;
}
qreal CameraBinFocus::digitalZoom() const
{
gfloat zoomFactor = 1.0;
g_object_get(GST_BIN(m_session->cameraBin()), ZOOM_PROPERTY, &zoomFactor, NULL);
return zoomFactor;
}
void CameraBinFocus::zoomTo(qreal optical, qreal digital)
{
Q_UNUSED(optical);
digital = qBound(qreal(1.0), digital, maximumDigitalZoom());
g_object_set(GST_BIN(m_session->cameraBin()), ZOOM_PROPERTY, digital, NULL);
emit digitalZoomChanged(digital);
}
QCameraFocus::FocusPointMode CameraBinFocus::focusPointMode() const
{
return QCameraFocus::FocusPointAuto;

View File

@@ -60,16 +60,9 @@ public:
CameraBinFocus(CameraBinSession *session);
virtual ~CameraBinFocus();
QCameraFocus::FocusMode focusMode() const;
void setFocusMode(QCameraFocus::FocusMode mode);
bool isFocusModeSupported(QCameraFocus::FocusMode mode) const;
qreal maximumOpticalZoom() const;
qreal maximumDigitalZoom() const;
qreal opticalZoom() const;
qreal digitalZoom() const;
void zoomTo(qreal optical, qreal digital) ;
QCameraFocus::FocusModes focusMode() const;
void setFocusMode(QCameraFocus::FocusModes mode);
bool isFocusModeSupported(QCameraFocus::FocusModes mode) const;
QCameraFocus::FocusPointMode focusPointMode() const;
void setFocusPointMode(QCameraFocus::FocusPointMode mode) ;
@@ -95,7 +88,7 @@ private Q_SLOTS:
private:
CameraBinSession *m_session;
QCameraFocus::FocusMode m_focusMode;
QCameraFocus::FocusModes m_focusMode;
QCamera::LockStatus m_focusStatus;
QCameraFocusZone::FocusZoneStatus m_focusZoneStatus;
};

View File

@@ -42,9 +42,7 @@
#include "camerabinimageprocessing.h"
#include "camerabinsession.h"
#ifdef HAVE_GST_PHOTOGRAPHY
#include <gst/interfaces/photography.h>
#endif
#include <gst/interfaces/colorbalance.h>
QT_BEGIN_NAMESPACE

View File

@@ -48,7 +48,9 @@
#include <gst/gst.h>
#include <glib.h>
#include <gst/interfaces/colorbalance.h>
#ifdef HAVE_GST_PHOTOGRAPHY
#include <gst/interfaces/photography.h>
#endif
QT_BEGIN_NAMESPACE

View File

@@ -54,6 +54,7 @@
#include "camerabinflash.h"
#include "camerabinfocus.h"
#include "camerabinlocks.h"
#include "camerabinzoom.h"
#endif
#include "camerabinimagecapture.h"
@@ -226,6 +227,9 @@ QMediaControl *CameraBinService::requestControl(const char *name)
if (qstrcmp(name, QCameraLocksControl_iid) == 0)
return m_captureSession->cameraLocksControl();
if (qstrcmp(name, QCameraZoomControl_iid) == 0)
return m_captureSession->cameraZoomControl();
#endif
if (qstrcmp(name, QCameraImageProcessingControl_iid) == 0)

View File

@@ -50,6 +50,7 @@
#include "camerabinflash.h"
#include "camerabinfocus.h"
#include "camerabinlocks.h"
#include "camerabinzoom.h"
#endif
#include "camerabinimageprocessing.h"
@@ -162,6 +163,7 @@ CameraBinSession::CameraBinSession(QObject *parent)
m_cameraFlashControl = new CameraBinFlash(this);
m_cameraFocusControl = new CameraBinFocus(this);
m_cameraLocksControl = new CameraBinLocks(this);
m_cameraZoomControl = new CameraBinZoom(this);
#endif
m_imageProcessingControl = new CameraBinImageProcessing(this);
m_captureDestinationControl = new CameraBinCaptureDestination(this);

View File

@@ -69,6 +69,7 @@ class CameraBinFlash;
class CameraBinFocus;
class CameraBinImageProcessing;
class CameraBinLocks;
class CameraBinZoom;
class CameraBinCaptureDestination;
class CameraBinCaptureBufferFormat;
class QGstreamerVideoRendererInterface;
@@ -125,6 +126,7 @@ public:
CameraBinFlash *cameraFlashControl() const { return m_cameraFlashControl; }
CameraBinFocus *cameraFocusControl() const { return m_cameraFocusControl; }
CameraBinLocks *cameraLocksControl() const { return m_cameraLocksControl; }
CameraBinZoom *cameraZoomControl() const { return m_cameraZoomControl; }
#endif
CameraBinImageProcessing *imageProcessingControl() const { return m_imageProcessingControl; }
@@ -217,6 +219,7 @@ private:
CameraBinFlash *m_cameraFlashControl;
CameraBinFocus *m_cameraFocusControl;
CameraBinLocks *m_cameraLocksControl;
CameraBinZoom *m_cameraZoomControl;
#endif
CameraBinImageProcessing *m_imageProcessingControl;

View File

@@ -0,0 +1,121 @@
/****************************************************************************
**
** Copyright (C) 2013 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 "camerabinzoom.h"
#include "camerabinsession.h"
#include <gst/interfaces/photography.h>
#define ZOOM_PROPERTY "zoom"
#define MAX_ZOOM_PROPERTY "max-zoom"
QT_BEGIN_NAMESPACE
CameraBinZoom::CameraBinZoom(CameraBinSession *session)
: QCameraZoomControl(session)
, m_session(session)
, m_requestedOpticalZoom(1.0)
, m_requestedDigitalZoom(1.0)
{
}
CameraBinZoom::~CameraBinZoom()
{
}
qreal CameraBinZoom::maximumOpticalZoom() const
{
return 1.0;
}
qreal CameraBinZoom::maximumDigitalZoom() const
{
gfloat zoomFactor = 1.0;
g_object_get(GST_BIN(m_session->cameraBin()), MAX_ZOOM_PROPERTY, &zoomFactor, NULL);
return zoomFactor;
}
qreal CameraBinZoom::requestedDigitalZoom() const
{
return m_requestedDigitalZoom;
}
qreal CameraBinZoom::requestedOpticalZoom() const
{
return m_requestedOpticalZoom;
}
qreal CameraBinZoom::currentOpticalZoom() const
{
return 1.0;
}
qreal CameraBinZoom::currentDigitalZoom() const
{
gfloat zoomFactor = 1.0;
g_object_get(GST_BIN(m_session->cameraBin()), ZOOM_PROPERTY, &zoomFactor, NULL);
return zoomFactor;
}
void CameraBinZoom::zoomTo(qreal optical, qreal digital)
{
qreal oldDigitalZoom = currentDigitalZoom();
if (m_requestedDigitalZoom != digital) {
m_requestedDigitalZoom = digital;
emit requestedDigitalZoomChanged(digital);
}
if (m_requestedOpticalZoom != optical) {
m_requestedOpticalZoom = optical;
emit requestedOpticalZoomChanged(optical);
}
digital = qBound(qreal(1.0), digital, maximumDigitalZoom());
g_object_set(GST_BIN(m_session->cameraBin()), ZOOM_PROPERTY, digital, NULL);
qreal newDigitalZoom = currentDigitalZoom();
if (!qFuzzyCompare(oldDigitalZoom, newDigitalZoom))
emit currentDigitalZoomChanged(digital);
}
QT_END_NAMESPACE

View File

@@ -0,0 +1,76 @@
/****************************************************************************
**
** Copyright (C) 2013 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 CAMERABINZOOMCONTROL_H
#define CAMERABINZOOMCONTROL_H
#include <qcamerazoomcontrol.h>
QT_BEGIN_NAMESPACE
class CameraBinSession;
class CameraBinZoom : public QCameraZoomControl
{
Q_OBJECT
public:
CameraBinZoom(CameraBinSession *session);
virtual ~CameraBinZoom();
qreal maximumOpticalZoom() const;
qreal maximumDigitalZoom() const;
qreal requestedOpticalZoom() const;
qreal requestedDigitalZoom() const;
qreal currentOpticalZoom() const;
qreal currentDigitalZoom() const;
void zoomTo(qreal optical, qreal digital);
private:
CameraBinSession *m_session;
qreal m_requestedOpticalZoom;
qreal m_requestedDigitalZoom;
};
QT_END_NAMESPACE
#endif // CAMERABINZOOMCONTROL_H