diff options
author | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2013-03-14 09:25:28 +0100 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2013-03-14 09:25:28 +0100 |
commit | 954bb7b9603e6049ef3b22ddd5fad2b324d937c3 (patch) | |
tree | 9fd3db2fa39826639f51a931c2638143df7c9c67 /src | |
parent | 788715e176f2dc4d600a405511519fd61d1ad717 (diff) | |
parent | 403e829f9dd4ad981c589b1f1e943a5bfbb9b1f9 (diff) | |
download | qtmultimedia-954bb7b9603e6049ef3b22ddd5fad2b324d937c3.tar.gz |
Merge remote-tracking branch 'origin/stable' into dev
Change-Id: Ifee8e5713e95d516081c4bc911e8f0bb6a169b13
Diffstat (limited to 'src')
-rw-r--r-- | src/multimedia/audio/qaudioinput.cpp | 35 | ||||
-rw-r--r-- | src/multimedia/audio/qaudiooutput.cpp | 30 | ||||
-rw-r--r-- | src/plugins/gstreamer/camerabin/camerabin.pro | 6 | ||||
-rw-r--r-- | src/plugins/gstreamer/camerabin/camerabinexposure.cpp | 218 | ||||
-rw-r--r-- | src/plugins/gstreamer/camerabin/camerabinexposure.h | 20 | ||||
-rw-r--r-- | src/plugins/gstreamer/camerabin/camerabinfocus.cpp | 40 | ||||
-rw-r--r-- | src/plugins/gstreamer/camerabin/camerabinfocus.h | 15 | ||||
-rw-r--r-- | src/plugins/gstreamer/camerabin/camerabinimageprocessing.cpp | 4 | ||||
-rw-r--r-- | src/plugins/gstreamer/camerabin/camerabinimageprocessing.h | 4 | ||||
-rw-r--r-- | src/plugins/gstreamer/camerabin/camerabinservice.cpp | 4 | ||||
-rw-r--r-- | src/plugins/gstreamer/camerabin/camerabinsession.cpp | 2 | ||||
-rw-r--r-- | src/plugins/gstreamer/camerabin/camerabinsession.h | 3 | ||||
-rw-r--r-- | src/plugins/gstreamer/camerabin/camerabinzoom.cpp | 121 | ||||
-rw-r--r-- | src/plugins/gstreamer/camerabin/camerabinzoom.h | 76 |
14 files changed, 364 insertions, 214 deletions
diff --git a/src/multimedia/audio/qaudioinput.cpp b/src/multimedia/audio/qaudioinput.cpp index 0389b681b..35ec3a661 100644 --- a/src/multimedia/audio/qaudioinput.cpp +++ b/src/multimedia/audio/qaudioinput.cpp @@ -151,18 +151,18 @@ QAudioInput::~QAudioInput() } /*! - Uses the \a device as the QIODevice to transfer data. - Passing a QIODevice allows the data to be transferred without any extra code. - All that is required is to open the QIODevice. + Starts transferring audio data from the system's audio input to the \a device. + The \a device must have been opened in the \l{QIODevice::WriteOnly}{WriteOnly}, + \l{QIODevice::Append}{Append} or \l{QIODevice::ReadWrite}{ReadWrite} modes. - If able to successfully get audio data from the systems audio device the - state() is set to either QAudio::ActiveState or QAudio::IdleState, - error() is set to QAudio::NoError and the stateChanged() signal is emitted. + If the QAudioInput is able to successfully get audio data, state() returns + either QAudio::ActiveState or QAudio::IdleState, error() returns QAudio::NoError + and the stateChanged() signal is emitted. - If a problem occurs during this process the error() is set to QAudio::OpenError, - state() is set to QAudio::StoppedState and stateChanged() signal is emitted. + If a problem occurs during this process, error() returns QAudio::OpenError, + state() returns QAudio::StoppedState and the stateChanged() signal is emitted. - \sa QIODevice + \sa QIODevice */ void QAudioInput::start(QIODevice* device) @@ -171,16 +171,19 @@ void QAudioInput::start(QIODevice* device) } /*! - Returns a pointer to the QIODevice being used to handle the data - transfer. This QIODevice can be used to read() audio data - directly. + Returns a pointer to the internal QIODevice being used to transfer data from + the system's audio input. The device will already be open and + \l{QIODevice::read()}{read()} can read data directly from it. + + \note The pointer will become invalid after the stream is stopped or + if you start another stream. - If able to access the systems audio device the state() is set to - QAudio::IdleState, error() is set to QAudio::NoError + If the QAudioInput is able to access the system's audio device, state() returns + QAudio::IdleState, error() returns QAudio::NoError and the stateChanged() signal is emitted. - If a problem occurs during this process the error() is set to QAudio::OpenError, - state() is set to QAudio::StoppedState and stateChanged() signal is emitted. + If a problem occurs during this process, error() returns QAudio::OpenError, + state() returns QAudio::StoppedState and the stateChanged() signal is emitted. \sa QIODevice */ diff --git a/src/multimedia/audio/qaudiooutput.cpp b/src/multimedia/audio/qaudiooutput.cpp index add0e5463..d6b0c5f10 100644 --- a/src/multimedia/audio/qaudiooutput.cpp +++ b/src/multimedia/audio/qaudiooutput.cpp @@ -161,16 +161,16 @@ QAudioFormat QAudioOutput::format() const } /*! - Uses the \a device as the QIODevice to transfer data. - Passing a QIODevice allows the data to be transferred without any extra code. - All that is required is to open the QIODevice. + Starts transferring audio data from the \a device to the system's audio output. + The \a device must have been opened in the \l{QIODevice::ReadOnly}{ReadOnly} or + \l{QIODevice::ReadWrite}{ReadWrite} modes. - If able to successfully output audio data to the systems audio device the - state() is set to QAudio::ActiveState, error() is set to QAudio::NoError + If the QAudioOutput is able to successfully output audio data, state() returns + QAudio::ActiveState, error() returns QAudio::NoError and the stateChanged() signal is emitted. - If a problem occurs during this process the error() is set to QAudio::OpenError, - state() is set to QAudio::StoppedState and stateChanged() signal is emitted. + If a problem occurs during this process, error() returns QAudio::OpenError, + state() returns QAudio::StoppedState and the stateChanged() signal is emitted. \sa QIODevice */ @@ -180,15 +180,19 @@ void QAudioOutput::start(QIODevice* device) } /*! - Returns a pointer to the QIODevice being used to handle the data - transfer. This QIODevice can be used to write() audio data directly. + Returns a pointer to the internal QIODevice being used to transfer data to + the system's audio output. The device will already be open and + \l{QIODevice::write()}{write()} can write data directly to it. - If able to access the systems audio device the state() is set to - QAudio::IdleState, error() is set to QAudio::NoError + \note The pointer will become invalid after the stream is stopped or + if you start another stream. + + If the QAudioOutput is able to access the system's audio device, state() returns + QAudio::IdleState, error() returns QAudio::NoError and the stateChanged() signal is emitted. - If a problem occurs during this process the error() is set to QAudio::OpenError, - state() is set to QAudio::StoppedState and stateChanged() signal is emitted. + If a problem occurs during this process, error() returns QAudio::OpenError, + state() returns QAudio::StoppedState and the stateChanged() signal is emitted. \sa QIODevice */ diff --git a/src/plugins/gstreamer/camerabin/camerabin.pro b/src/plugins/gstreamer/camerabin/camerabin.pro index 7f84fe54d..27c368e86 100644 --- a/src/plugins/gstreamer/camerabin/camerabin.pro +++ b/src/plugins/gstreamer/camerabin/camerabin.pro @@ -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 diff --git a/src/plugins/gstreamer/camerabin/camerabinexposure.cpp b/src/plugins/gstreamer/camerabin/camerabinexposure.cpp index 92507d614..cb9d10a17 100644 --- a/src/plugins/gstreamer/camerabin/camerabinexposure.cpp +++ b/src/plugins/gstreamer/camerabin/camerabinexposure.cpp @@ -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,76 +70,94 @@ bool CameraBinExposure::isParameterSupported(ExposureParameter parameter) const } } -QVariant CameraBinExposure::exposureParameter(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); - } - default: - return QVariant(); - } -} - -QCameraExposureControl::ParameterFlags CameraBinExposure::exposureParameterFlags(ExposureParameter parameter) const +QVariantList CameraBinExposure::supportedParameterRange(ExposureParameter parameter, + bool *continuous) const { - QCameraExposureControl::ParameterFlags flags = 0; + if (continuous) + *continuous = false; + QVariantList res; switch (parameter) { case QCameraExposureControl::ExposureCompensation: - flags |= ContinuousRange; + if (continuous) + *continuous = true; + res << -2.0 << 2.0; + break; + case QCameraExposureControl::ISO: + res << 100 << 200 << 400; break; case QCameraExposureControl::Aperture: - flags |= ReadOnly; + res << 2.8; break; default: break; } - return flags; + return res; } -QVariantList CameraBinExposure::supportedParameterRange(ExposureParameter parameter) const +QVariant CameraBinExposure::requestedValue(ExposureParameter parameter) const +{ + return m_requestedValues.value(parameter); +} + +QVariant CameraBinExposure::actualValue(ExposureParameter parameter) const { - QVariantList res; switch (parameter) { case QCameraExposureControl::ExposureCompensation: - res << -2.0 << 2.0; - break; + { + gfloat ev; + gst_photography_get_ev_compensation(m_session->photography(), &ev); + return QVariant(ev); + } case QCameraExposureControl::ISO: - res << 100 << 200 << 400; - break; + { + guint isoSpeed = 0; + gst_photography_get_iso_speed(m_session->photography(), &isoSpeed); + return QVariant(isoSpeed); + } case QCameraExposureControl::Aperture: - res << 2.8; - break; + 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: - break; + return QVariant(); } - - return res; } -bool CameraBinExposure::setExposureParameter(ExposureParameter parameter, const QVariant& value) +bool CameraBinExposure::setValue(ExposureParameter parameter, const QVariant& value) { - QVariant oldValue = exposureParameter(parameter); + 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 diff --git a/src/plugins/gstreamer/camerabin/camerabinexposure.h b/src/plugins/gstreamer/camerabin/camerabinexposure.h index fc92cf712..6fbf93494 100644 --- a/src/plugins/gstreamer/camerabin/camerabinexposure.h +++ b/src/plugins/gstreamer/camerabin/camerabinexposure.h @@ -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 diff --git a/src/plugins/gstreamer/camerabin/camerabinfocus.cpp b/src/plugins/gstreamer/camerabin/camerabinfocus.cpp index 60fb84260..2f69cad37 100644 --- a/src/plugins/gstreamer/camerabin/camerabinfocus.cpp +++ b/src/plugins/gstreamer/camerabin/camerabinfocus.cpp @@ -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; diff --git a/src/plugins/gstreamer/camerabin/camerabinfocus.h b/src/plugins/gstreamer/camerabin/camerabinfocus.h index 3057a71c3..e1f4dcd36 100644 --- a/src/plugins/gstreamer/camerabin/camerabinfocus.h +++ b/src/plugins/gstreamer/camerabin/camerabinfocus.h @@ -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; }; diff --git a/src/plugins/gstreamer/camerabin/camerabinimageprocessing.cpp b/src/plugins/gstreamer/camerabin/camerabinimageprocessing.cpp index a09ff9b7e..a714b2892 100644 --- a/src/plugins/gstreamer/camerabin/camerabinimageprocessing.cpp +++ b/src/plugins/gstreamer/camerabin/camerabinimageprocessing.cpp @@ -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 diff --git a/src/plugins/gstreamer/camerabin/camerabinimageprocessing.h b/src/plugins/gstreamer/camerabin/camerabinimageprocessing.h index c3e1dbb01..519a58c56 100644 --- a/src/plugins/gstreamer/camerabin/camerabinimageprocessing.h +++ b/src/plugins/gstreamer/camerabin/camerabinimageprocessing.h @@ -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 diff --git a/src/plugins/gstreamer/camerabin/camerabinservice.cpp b/src/plugins/gstreamer/camerabin/camerabinservice.cpp index f2bfc2869..5003699ee 100644 --- a/src/plugins/gstreamer/camerabin/camerabinservice.cpp +++ b/src/plugins/gstreamer/camerabin/camerabinservice.cpp @@ -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) diff --git a/src/plugins/gstreamer/camerabin/camerabinsession.cpp b/src/plugins/gstreamer/camerabin/camerabinsession.cpp index 57dc9cc47..f58bea205 100644 --- a/src/plugins/gstreamer/camerabin/camerabinsession.cpp +++ b/src/plugins/gstreamer/camerabin/camerabinsession.cpp @@ -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); diff --git a/src/plugins/gstreamer/camerabin/camerabinsession.h b/src/plugins/gstreamer/camerabin/camerabinsession.h index db1dfe0b6..305c1168b 100644 --- a/src/plugins/gstreamer/camerabin/camerabinsession.h +++ b/src/plugins/gstreamer/camerabin/camerabinsession.h @@ -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; diff --git a/src/plugins/gstreamer/camerabin/camerabinzoom.cpp b/src/plugins/gstreamer/camerabin/camerabinzoom.cpp new file mode 100644 index 000000000..9b42c4e1d --- /dev/null +++ b/src/plugins/gstreamer/camerabin/camerabinzoom.cpp @@ -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 diff --git a/src/plugins/gstreamer/camerabin/camerabinzoom.h b/src/plugins/gstreamer/camerabin/camerabinzoom.h new file mode 100644 index 000000000..f3049b61c --- /dev/null +++ b/src/plugins/gstreamer/camerabin/camerabinzoom.h @@ -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 |